Belle II Software  release-08-01-10
PXDStateFilterFactory.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/pxd/filters/states/PXDStateFilterFactory.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/NegativeFilter.icc.h>
15 #include <tracking/trackFindingCDC/filters/base/ChoosableFromVarSetFilter.icc.h>
16 #include <tracking/trackFindingCDC/filters/base/RecordingFilter.icc.h>
17 #include <tracking/trackFindingCDC/filters/base/MVAFilter.icc.h>
18 #include <tracking/trackFindingCDC/filters/base/SloppyFilter.icc.h>
19 #include <tracking/trackFindingCDC/filters/base/TruthVarFilter.icc.h>
20 
21 #include <tracking/trackFindingCDC/varsets/VariadicUnionVarSet.h>
22 
23 #include <tracking/ckf/general/filters/AdvanceFilter.h>
24 #include <tracking/ckf/general/filters/KalmanFilter.h>
25 #include <tracking/ckf/pxd/utilities/PXDAdvancer.h>
26 #include <tracking/ckf/pxd/utilities/PXDKalmanStepper.h>
27 
28 #include <tracking/ckf/pxd/filters/states/PXDStateBasicVarSet.h>
29 #include <tracking/ckf/pxd/filters/states/PXDStateTruthVarSet.h>
30 #include <tracking/ckf/pxd/filters/states/SimplePXDStateFilter.h>
31 #include <tracking/ckf/pxd/filters/states/AllPXDStateFilter.h>
32 #include <tracking/ckf/pxd/filters/states/NonIPCrossingPXDStateFilter.h>
33 
34 using namespace Belle2;
35 using namespace TrackFindingCDC;
36 
37 namespace {
39  using MCPXDStateFilter = TruthVarFilter<PXDStateTruthVarSet>;
40 
42  using MCOrderingPXDStateFilter = ChoosableFromVarSetFilter<PXDStateTruthVarSet>;
43 
45  using SloppyMCPXDStateFilter = Sloppy<TruthVarFilter<PXDStateTruthVarSet>>;
46 
49 
51  using MVAPXDStateFilter = NegativeFilter<MVAFilter<PXDStateBasicVarSet>>;
52 
54  using AndPXDStateFilter = AndFilter<BasePXDStateFilter>;
55 
57  class SloppyRecordingPXDStateFilter : public RecordingPXDStateFilter {
58  public:
59  explicit SloppyRecordingPXDStateFilter(const std::string& defaultRootFileName) : RecordingPXDStateFilter(defaultRootFileName)
60  {
61  setSkimFilter(std::make_unique<SloppyMCPXDStateFilter>());
62  }
63  };
64 }
65 
66 
67 PXDStateFilterFactory::PXDStateFilterFactory(const std::string& defaultFilterName)
68  : Super(defaultFilterName)
69 {
70 }
71 
73 
75 {
76  return "PXDState";
77 }
78 
80 {
81  return "Reject PXD CKF states. ";
82 }
83 
84 std::map<std::string, std::string> PXDStateFilterFactory::getValidFilterNamesAndDescriptions() const
85 {
86  return {
87  {"none", "no track combination is valid"},
88  {"all", "set all track combinations as good"},
89  {"advance", "extrapolate the states"},
90  {"fit", "update the mSoP using a Kalman Filter"},
91  {"truth", "monte carlo truth"},
92  {"ordering_truth", "monte carlo truth ordering"},
93  {"sloppy_truth", "sloppy monte carlo truth"},
94  {"simple", "simple filter to be used in pxd"},
95  {"recording", "record variables to a TTree"},
96  {"recording_and_truth", "record variables to a TTree and store truth information"},
97  {"recording_with_direction_check", "record variables to a TTree with direction check"},
98  {"mva_with_direction_check", "MVA filter with direction check"},
99  {"mva", "MVA filter"},
100  {"sloppy_recording", "record variables to a TTree"},
101  };
102 }
103 
104 std::unique_ptr<BasePXDStateFilter>
105 PXDStateFilterFactory::create(const std::string& filterName) const
106 {
107  if (filterName == "none") {
108  return std::make_unique<TrackFindingCDC::NoneFilter<BasePXDStateFilter>>();
109  } else if (filterName == "all") {
110  return std::make_unique<AllPXDStateFilter>();
111  } else if (filterName == "advance") {
112  return std::make_unique<AdvanceFilter<CKFToPXDState, PXDAdvancer>>();
113  } else if (filterName == "fit") {
114  return std::make_unique<KalmanFilter<CKFToPXDState, PXDKalmanStepper>>();
115  } else if (filterName == "simple") {
116  return std::make_unique<SimplePXDStateFilter>();
117  } else if (filterName == "truth") {
118  return std::make_unique<MCPXDStateFilter>();
119  } else if (filterName == "ordering_truth") {
120  return std::make_unique<MCOrderingPXDStateFilter>("truth_inverted");
121  } else if (filterName == "sloppy_truth") {
122  return std::make_unique<SloppyMCPXDStateFilter>();
123  } else if (filterName == "recording") {
124  return std::make_unique<RecordingPXDStateFilter>("PXDStateFilter.root");
125  } else if (filterName == "recording_and_truth") {
126  return std::make_unique<AndPXDStateFilter>(
127  std::make_unique<RecordingPXDStateFilter>("PXDStateFilter.root"),
128  std::make_unique<MCPXDStateFilter>());
129  } else if (filterName == "recording_with_direction_check") {
130  return std::make_unique<AndPXDStateFilter>(
131  std::make_unique<NonIPCrossingPXDStateFilter>(),
132  std::make_unique<RecordingPXDStateFilter>("PXDStateFilter.root"));
133  } else if (filterName == "mva_with_direction_check") {
134  return std::make_unique<AndPXDStateFilter>(
135  std::make_unique<NonIPCrossingPXDStateFilter>(),
136  std::make_unique<MVAPXDStateFilter>("ckf_CDCPXDStateFilter_1"));
137  } else if (filterName == "mva") {
138  return std::make_unique<AndPXDStateFilter>(
139  std::make_unique<MVAPXDStateFilter>("ckf_CDCPXDStateFilter_1"),
140  std::make_unique<NonIPCrossingPXDStateFilter>());
141  } else if (filterName == "sloppy_recording") {
142  return std::make_unique<SloppyRecordingPXDStateFilter>("PXDStateFilter.root");
143  } else {
144  return Super::create(filterName);
145  }
146 }
std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const override
Getter for valid filter names and a description for each.
PXDStateFilterFactory(const std::string &defaultFilterName="all")
Constructor forwarding the default filter name.
std::unique_ptr< BasePXDStateFilter > 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.
std::string getFilterPurpose() const override
Getter for a descriptive purpose of the constructed filters.
~PXDStateFilterFactory()
Default destructor.
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< BasePXDStateFilter > 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.