Belle II Software  release-08-01-10
CDCStateFilterFactory.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/ckf/cdc/filters/states/CDCStateFilterFactory.h>
9 
10 #include <tracking/trackFindingCDC/filters/base/FilterFactory.icc.h>
11 #include <tracking/trackFindingCDC/filters/base/AllFilter.icc.h>
12 #include <tracking/trackFindingCDC/filters/base/NoneFilter.icc.h>
13 #include <tracking/trackFindingCDC/filters/base/AndFilter.icc.h>
14 #include <tracking/trackFindingCDC/filters/base/RecordingFilter.icc.h>
15 
16 #include <tracking/trackFindingCDC/varsets/VariadicUnionVarSet.h>
17 
18 #include <tracking/ckf/cdc/filters/states/CDCStateBasicVarSet.h>
19 #include <tracking/ckf/cdc/filters/states/CDCfromEclStateTruthVarSet.h>
20 
21 #include <tracking/ckf/cdc/filters/states/MCTruthCDCStateFilter.h>
22 #include <tracking/ckf/cdc/filters/states/RoughCDCStateFilter.h>
23 #include <tracking/ckf/cdc/filters/states/RoughCDCfromEclStateFilter.h>
24 #include <tracking/ckf/cdc/filters/states/ExtrapolateAndUpdateCDCStateFilter.h>
25 #include <tracking/ckf/cdc/filters/states/DistanceCDCStateFilter.h>
26 #include <tracking/ckf/cdc/filters/states/MCTruthEclSeedFilter.h>
27 
28 using namespace Belle2;
29 using namespace TrackFindingCDC;
30 
31 namespace {
33  using RecordingCDCStateFilter = RecordingFilter<VariadicUnionVarSet<CDCStateBasicVarSet>>;
34  //using RecordingCDCStateFilter = RecordingFilter<VariadicUnionVarSet<CDCStateBasicVarSet, CDCStateTruthVarSet>>;
38  using AndCDCStateFilter = AndFilter<BaseCDCStateFilter>;
39 }
40 
41 
42 CDCStateFilterFactory::CDCStateFilterFactory(const std::string& defaultFilterName)
43  : Super(defaultFilterName)
44 {
45 }
46 
48 
50 {
51  return "CDCState";
52 }
53 
55 {
56  return "Reject CDC CKF states. ";
57 }
58 
59 std::map<std::string, std::string> CDCStateFilterFactory::getValidFilterNamesAndDescriptions() const
60 {
61  return {
62  {"none", "no track combination is valid"},
63  {"all", "set all track combinations as good"},
64  {"mc_truth", "filtering based on the mc truth information"},
65  {"mc_truth_eclSeed", "filtering based on the mc truth information"},
66  {"rough", "very rough filtering"},
67  {"rough_eclSeed", "very rough filtering, seed created from ECL shower"},
68  {"extrapolate_and_update", "Extrapolation and update"},
69  {"distance", "Give a weight based on the distance"},
70  {"recording", "record variables to a TTree"},
71  {"recording_eclSeed", "record variables to a TTree"},
72  {"rough_and_recording", "very rough filtering, seed created from SVD track"},
73  {"rough_and_recording_eclSeed", "very rough filtering, seed created from ECL shower"},
74  {"distance_and_recording_eclSeed", "Give a weight based on the distance"},
75 
76  };
77 }
78 
79 std::unique_ptr<BaseCDCStateFilter>
80 CDCStateFilterFactory::create(const std::string& filterName) const
81 {
82  if (filterName == "none") {
83  return std::make_unique<TrackFindingCDC::NoneFilter<BaseCDCStateFilter>>();
84  // cppcheck-suppress knownConditionTrueFalse
85  } else if (filterName == "all") {
86  return std::make_unique<TrackFindingCDC::AllFilter<BaseCDCStateFilter>>();
87  // cppcheck-suppress knownConditionTrueFalse
88  } else if (filterName == "rough") {
89  return std::make_unique<RoughCDCStateFilter>();
90  // cppcheck-suppress knownConditionTrueFalse
91  } else if (filterName == "rough_eclSeed") {
92  return std::make_unique<RoughCDCfromEclStateFilter>();
93  // cppcheck-suppress knownConditionTrueFalse
94  } else if (filterName == "mc_truth") {
95  return std::make_unique<MCTruthCDCStateFilter>();
96  // cppcheck-suppress knownConditionTrueFalse
97  } else if (filterName == "mc_truth_eclSeed") {
98  return std::make_unique<MCTruthEclSeedFilter>();
99  // cppcheck-suppress knownConditionTrueFalse
100  } else if (filterName == "extrapolate_and_update") {
101  return std::make_unique<ExtrapolateAndUpdateCDCStateFilter>();
102  // cppcheck-suppress knownConditionTrueFalse
103  } else if (filterName == "distance") {
104  return std::make_unique<DistanceCDCStateFilter>();
105  // cppcheck-suppress knownConditionTrueFalse
106  } else if (filterName == "recording") {
107  return std::make_unique<RecordingCDCStateFilter>("CDCStateFilter.root");
108  // cppcheck-suppress knownConditionTrueFalse
109  } else if (filterName == "rough_and_recording") {
110  return std::make_unique<AndCDCStateFilter>(
111  std::make_unique<RecordingCDCStateFilter>("CDCStateFilter.root"),
112  std::make_unique<RoughCDCStateFilter>()
113  );
114  // cppcheck-suppress knownConditionTrueFalse
115  } else if (filterName == "recording_eclSeed") {
116  return std::make_unique<RecordingCDCfromEclStateFilter>("CDCfromECLStateFilter.root");
117  // cppcheck-suppress knownConditionTrueFalse
118  } else if (filterName == "rough_and_recording_eclSeed") {
119  return std::make_unique<AndCDCStateFilter>(
120  std::make_unique<RecordingCDCfromEclStateFilter>("CDCfromECLStateFilter.root"),
121  std::make_unique<RoughCDCfromEclStateFilter>()
122  );
123  // cppcheck-suppress knownConditionTrueFalse
124  } else if (filterName == "distance_and_recording_eclSeed") {
125  return std::make_unique<AndCDCStateFilter>(
126  std::make_unique<RecordingCDCfromEclStateFilter>("CDCfromECLStateFilter.root"),
127  std::make_unique<DistanceCDCStateFilter>()
128  );
129  } else {
130  return Super::create(filterName);
131  }
132 }
~CDCStateFilterFactory()
Default destructor.
std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const override
Getter for valid filter names and a description for each.
std::string getIdentifier() const override
Getter for a short identifier for the factory.
CDCStateFilterFactory(const std::string &defaultFilterName="all")
Constructor forwarding the default filter name.
std::string getFilterPurpose() const override
Getter for a descriptive purpose of the constructed filters.
std::unique_ptr< BaseCDCStateFilter > create(const std::string &filterName) const override
Create a filter with the given name.
Filter adapter type that joins two filter results in an and like fashion.
Definition: AndFilter.dcl.h:24
virtual std::unique_ptr< BaseCDCStateFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.
Convience template to create a recording filter for a set of variables.
Abstract base class for different kinds of events.