Belle II Software  release-08-01-10
SVDStateFilterFactory.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/svd/filters/states/SVDStateFilterFactory.h>
9 
10 #include <tracking/trackFindingCDC/filters/base/FilterFactory.icc.h>
11 #include <tracking/trackFindingCDC/filters/base/NoneFilter.icc.h>
12 #include <tracking/trackFindingCDC/filters/base/NegativeFilter.icc.h>
13 #include <tracking/trackFindingCDC/filters/base/ChoosableFromVarSetFilter.icc.h>
14 #include <tracking/trackFindingCDC/filters/base/AndFilter.icc.h>
15 #include <tracking/trackFindingCDC/filters/base/RecordingFilter.icc.h>
16 #include <tracking/trackFindingCDC/filters/base/MVAFilter.icc.h>
17 #include <tracking/trackFindingCDC/filters/base/SloppyFilter.icc.h>
18 #include <tracking/trackFindingCDC/filters/base/TruthVarFilter.icc.h>
19 
20 #include <tracking/trackFindingCDC/varsets/VariadicUnionVarSet.h>
21 
22 #include <tracking/ckf/general/filters/AdvanceFilter.h>
23 #include <tracking/ckf/general/filters/KalmanFilter.h>
24 #include <tracking/ckf/svd/utilities/SVDAdvancer.h>
25 #include <tracking/ckf/svd/utilities/SVDKalmanStepper.h>
26 
27 #include <tracking/ckf/svd/filters/states/SVDStateVarSet.h>
28 #include <tracking/ckf/svd/filters/states/SVDStateBasicVarSet.h>
29 #include <tracking/ckf/svd/filters/states/SVDStateTruthVarSet.h>
30 #include <tracking/ckf/svd/filters/states/SimpleSVDStateFilter.h>
31 #include <tracking/ckf/svd/filters/states/ResidualSVDStateFilter.h>
32 #include <tracking/ckf/svd/filters/states/AllSVDStateFilter.h>
33 #include <tracking/ckf/svd/filters/states/NonIPCrossingSVDStateFilter.h>
34 
35 using namespace Belle2;
36 using namespace TrackFindingCDC;
37 
38 namespace {
40  using MCSVDStateFilter = TruthVarFilter<SVDStateTruthVarSet>;
41 
43  using MCOrderingSVDStateFilter = ChoosableFromVarSetFilter<SVDStateTruthVarSet>;
44 
46  using SloppyMCSVDStateFilter = Sloppy<TruthVarFilter<SVDStateTruthVarSet>>;
47 
50 
53 
55  using AndSVDStateFilter = AndFilter<BaseSVDStateFilter>;
56 
58  class SloppyRecordingSVDStateFilter : public RecordingSVDStateFilter {
59  public:
60  explicit SloppyRecordingSVDStateFilter(const std::string& defaultRootFileName) : RecordingSVDStateFilter(defaultRootFileName)
61  {
62  setSkimFilter(std::make_unique<SloppyMCSVDStateFilter>());
63  }
64  };
65 }
66 
67 
68 SVDStateFilterFactory::SVDStateFilterFactory(const std::string& defaultFilterName)
69  : Super(defaultFilterName)
70 {
71 }
72 
74 
76 {
77  return "SVDState";
78 }
79 
81 {
82  return "Reject SVD CKF states. ";
83 }
84 
85 std::map<std::string, std::string> SVDStateFilterFactory::getValidFilterNamesAndDescriptions() const
86 {
87  return {
88  {"none", "no track combination is valid"},
89  {"all", "set all track combinations as good"},
90  {"non_ip_crossing", "all combinations are fine, except for crossing IPs"},
91  {"advance", "extrapolate the states"},
92  {"fit", "update the mSoP using a Kalman Filter"},
93  {"truth", "monte carlo truth"},
94  {"ordering_truth", "monte carlo truth ordering"},
95  {"sloppy_truth", "sloppy monte carlo truth"},
96  {"simple", "simple filter to be used in svd"},
97  {"residual", "residual filter to be used in svd"},
98  {"recording", "record variables to a TTree"},
99  {"recording_and_truth", "record variables to a TTree and store truth information"},
100  {"recording_with_direction_check", "record variables to a TTree with direction check"},
101  {"mva", "MVA filter"},
102  {"mva_with_direction_check", "MVA filter with direction check"},
103  {"sloppy_recording", "record variables to a TTree"},
104  };
105 }
106 
107 std::unique_ptr<BaseSVDStateFilter>
108 SVDStateFilterFactory::create(const std::string& filterName) const
109 {
110  if (filterName == "none") {
111  return std::make_unique<TrackFindingCDC::NoneFilter<BaseSVDStateFilter>>();
112  } else if (filterName == "all") {
113  return std::make_unique<AllSVDStateFilter>();
114  } else if (filterName == "non_ip_crossing") {
115  return std::make_unique<NonIPCrossingSVDStateFilter>();
116  } else if (filterName == "advance") {
117  return std::make_unique<AdvanceFilter<CKFToSVDState, SVDAdvancer>>();
118  } else if (filterName == "fit") {
119  return std::make_unique<KalmanFilter<CKFToSVDState, SVDKalmanStepper>>();
120  } else if (filterName == "simple") {
121  return std::make_unique<SimpleSVDStateFilter>();
122  } else if (filterName == "residual") {
123  return std::make_unique<ResidualSVDStateFilter>();
124  } else if (filterName == "truth") {
125  return std::make_unique<MCSVDStateFilter>();
126  } else if (filterName == "ordering_truth") {
127  return std::make_unique<MCOrderingSVDStateFilter>("truth_inverted");
128  } else if (filterName == "sloppy_truth") {
129  return std::make_unique<SloppyMCSVDStateFilter>();
130  } else if (filterName == "recording") {
131  return std::make_unique<RecordingSVDStateFilter>("SVDStateFilter.root");
132  } else if (filterName == "recording_and_truth") {
133  return std::make_unique<AndSVDStateFilter>(
134  std::make_unique<RecordingSVDStateFilter>("SVDStateFilter.root"),
135  std::make_unique<MCSVDStateFilter>());
136  } else if (filterName == "recording_with_direction_check") {
137  return std::make_unique<AndSVDStateFilter>(
138  std::make_unique<NonIPCrossingSVDStateFilter>(),
139  std::make_unique<RecordingSVDStateFilter>("SVDStateFilter.root"));
140  } else if (filterName == "mva") {
141  return std::make_unique<MVASVDStateFilter>("ckf_CDCSVDStateFilter_1");
142  } else if (filterName == "mva_with_direction_check") {
143  return std::make_unique<AndSVDStateFilter>(
144  std::make_unique<NonIPCrossingSVDStateFilter>(),
145  std::make_unique<MVASVDStateFilter>("ckf_CDCSVDStateFilter_1"));
146  } else if (filterName == "sloppy_recording") {
147  return std::make_unique<SloppyRecordingSVDStateFilter>("SVDStateFilter.root");
148  } else {
149  return Super::create(filterName);
150  }
151 }
std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const override
Getter for valid filter names and a description for each.
std::unique_ptr< BaseSVDStateFilter > create(const std::string &filterName) const override
Create a filter with the given name.
SVDStateFilterFactory(const std::string &defaultFilterName="all")
Constructor forwarding the default filter name.
std::string getIdentifier() const override
Getter for a short identifier for the factory.
~SVDStateFilterFactory()
Default destructor.
std::string getFilterPurpose() const override
Getter for a descriptive purpose of the constructed filters.
Filter adapter type that joins two filter results in an and like fashion.
Definition: AndFilter.dcl.h:24
Convience template to create a filter returning on variable from a set of variables.
virtual std::unique_ptr< BaseSVDStateFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.
Filter adapter type that negates the acceptance criterion for cross checks.
Convience template to create a recording filter for a set of variables.
A filter that accepts every <sloppinessFactor>th candidate on average (random selection)
MC Filter Type using a VarSet and the truth variable in it.
Abstract base class for different kinds of events.