Belle II Software development
SegmentFilterFactory.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackFindingCDC/filters/segment/SegmentFilterFactory.h>
9
10#include <tracking/trackFindingCDC/filters/segment/BkgTruthSegmentVarSet.h>
11
12#include <tracking/trackFindingCDC/filters/segment/AdvancedSegmentVarSet.h>
13
14#include <tracking/trackingUtilities/filters/base/MVAFilter.icc.h>
15
16#include <tracking/trackingUtilities/filters/base/RecordingFilter.icc.h>
17#include <tracking/trackingUtilities/filters/base/TruthVarFilter.icc.h>
18#include <tracking/trackingUtilities/filters/base/AllFilter.icc.h>
19#include <tracking/trackingUtilities/filters/base/NoneFilter.icc.h>
20
21#include <tracking/trackingUtilities/filters/base/FilterFactory.icc.h>
22
23#include <tracking/trackingUtilities/varsets/VariadicUnionVarSet.h>
24
25using namespace Belle2;
26using namespace TrackFindingCDC;
27using namespace TrackingUtilities;
28
29namespace {
30 using AllSegmentFilter = AllFilter<BaseSegmentFilter>;
31 using NoneSegmentFilter = NoneFilter<BaseSegmentFilter>;
32 using BkgMCSegmentFilter = TruthVarFilter<BkgTruthSegmentVarSet>;
33 using BkgRecordingSegmentFilter =
35 using BkgMVASegmentFilter = MVAFilter<AdvancedSegmentVarSet>;
36}
37
39
40SegmentFilterFactory::SegmentFilterFactory(const std::string& defaultFilterName)
41 : Super(defaultFilterName)
42{
43}
44
46{
47 return "Segment";
48}
49
51{
52 return "Segment filter to reject fakes";
53}
54
55std::map<std::string, std::string>
57{
58 return {
59 {"none", "no segment track combination is valid"},
60 {"all", "filter out all segments as background"},
61 {"bkg_truth", "monte carlo truth"},
62 {"bkg_recording", "record variables to a TTree"},
63 {"bkg_mva", "test with a mva method"}
64 };
65}
66
67std::unique_ptr<BaseSegmentFilter>
68SegmentFilterFactory::create(const std::string& filterName) const
69{
70 if (filterName == "none") {
71 return std::make_unique<NoneSegmentFilter>();
72 // cppcheck-suppress knownConditionTrueFalse
73 } else if (filterName == "all") {
74 return std::make_unique<AllSegmentFilter>();
75 // cppcheck-suppress knownConditionTrueFalse
76 } else if (filterName == "bkg_truth") {
77 return std::make_unique<BkgMCSegmentFilter>();
78 // cppcheck-suppress knownConditionTrueFalse
79 } else if (filterName == "bkg_recording") {
80 return std::make_unique<BkgRecordingSegmentFilter>("BackgroundSegmentFilter.root");
81 // cppcheck-suppress knownConditionTrueFalse
82 } else if (filterName == "bkg_mva") {
83 return std::make_unique<BkgMVASegmentFilter>("trackfindingcdc_BackgroundSegmentFilter");
84 } else {
85 return Super::create(filterName);
86 }
87}
SegmentFilterFactory(const std::string &defaultFilterName="all")
Constructor forwarding the default filter name.
std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const override
Getter for valid filter names and a description for each.
std::unique_ptr< BaseSegmentFilter > create(const std::string &filterName) const override
Create a filter with the given name.
std::string getIdentifier() const override
Getter for a short identifier for the factory.
TrackingUtilities::FilterFactory< BaseSegmentFilter > Super
Type of the base class.
std::string getFilterPurpose() const override
Getter for a descriptive purpose of the constructed filters.
Filter adapter type that accepts all items (just for reference).
Factory that can create appropriate filter instances from a name.
virtual std::unique_ptr< BaseSegmentFilter > create(const std::string &filterName) const
Convenience template to create a mva filter for a set of variables.
Filter adapter type that rejects all items.
Convenience template to create a recording filter for a set of variables.
MC Filter Type using a VarSet and the truth variable in it.
Abstract base class for different kinds of events.