Belle II Software  release-08-01-10
TrackFilterFactory.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/track/TrackFilterFactory.h>
9 
10 #include <tracking/trackFindingCDC/filters/track/TruthTrackVarSet.h>
11 #include <tracking/trackFindingCDC/filters/track/BasicTrackVarSet.h>
12 
13 #include <tracking/trackFindingCDC/filters/base/MVAFilter.icc.h>
14 
15 #include <tracking/trackFindingCDC/filters/base/RecordingFilter.icc.h>
16 #include <tracking/trackFindingCDC/filters/base/TruthVarFilter.icc.h>
17 #include <tracking/trackFindingCDC/filters/base/AllFilter.icc.h>
18 #include <tracking/trackFindingCDC/filters/base/NoneFilter.icc.h>
19 
20 #include <tracking/trackFindingCDC/filters/base/FilterFactory.icc.h>
21 #include <tracking/trackFindingCDC/filters/base/FilterVarSet.icc.h>
22 
23 #include <tracking/trackFindingCDC/varsets/VariadicUnionVarSet.h>
24 
25 using namespace Belle2;
26 using namespace TrackFindingCDC;
27 
28 namespace {
29  using AllTrackFilter = AllFilter<BaseTrackFilter>;
30  using NoneTrackFilter = NoneFilter<BaseTrackFilter>;
31  using MCTrackFilter = TruthVarFilter<TruthTrackVarSet>;
33  using RecordingDataTrackFilter = RecordingFilter<BasicTrackVarSet>;
34  using MVATrackFilter = MVAFilter<BasicTrackVarSet>;
35 }
36 
38 
39 TrackFilterFactory::TrackFilterFactory(const std::string& defaultFilterName)
40  : Super(defaultFilterName)
41 {
42 }
43 
45 {
46  return "Track";
47 }
48 
50 {
51  return "Track filter to reject fakes";
52 }
53 
54 std::map<std::string, std::string>
56 {
57  return {
58  {"none", "no track is valid"},
59  {"all", "set all tracks as good"},
60  {"truth", "monte carlo truth"},
61  {"recording", "record variables to a TTree"},
62  {"recording_data", "record reco-variables to a TTree (no truth information)"},
63  {"eval", "record truth and the mva response for insitu comparision"},
64  {"mva", "test with a mva method"}
65  };
66 }
67 
68 std::unique_ptr<BaseTrackFilter>
69 TrackFilterFactory::create(const std::string& filterName) const
70 {
71  if (filterName == "none") {
72  return std::make_unique<NoneTrackFilter>();
73  } else if (filterName == "all") {
74  return std::make_unique<AllTrackFilter>();
75  } else if (filterName == "truth") {
76  return std::make_unique<MCTrackFilter>();
77  } else if (filterName == "recording") {
78  return std::make_unique<RecordingTrackFilter>("TrackFilter.root");
79  } else if (filterName == "recording_data") {
80  return std::make_unique<RecordingDataTrackFilter>("TrackFilter.root");
81  } else if (filterName == "eval") {
82  auto recordedVarSets = std::make_unique<UnionVarSet<CDCTrack>>();
83  using TrackFilterVarSet = FilterVarSet<BaseTrackFilter>;
84  recordedVarSets->push_back(std::make_unique<TrackFilterVarSet>("mva", create("mva")));
85  recordedVarSets->push_back(std::make_unique<TrackFilterVarSet>("truth", create("truth")));
86  return std::make_unique<Recording<BaseTrackFilter>>(std::move(recordedVarSets), "TrackFilter_eval.root");
87  } else if (filterName == "mva") {
88  return std::make_unique<MVATrackFilter>("trackfindingcdc_TrackFilter", 0.10);
89  } else {
90  return Super::create(filterName);
91  }
92 }
Filter adapter type that accepts all items (just for reference).
Definition: AllFilter.dcl.h:21
virtual std::unique_ptr< BaseTrackFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.
Class to compute floating point variables from a filter response which can be recorded as a flat TNtu...
Convience template to create a mva filter for a set of variables.
Definition: MVAFilter.dcl.h:92
Filter adapter type that rejects all items.
Convience template to create a recording filter for a set of variables.
std::unique_ptr< BaseTrackFilter > create(const std::string &filterName) const override
Create a filter with the given name.
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.
TrackFilterFactory(const std::string &defaultFilterName="mva")
Constructor forwarding the default filter name.
std::string getFilterPurpose() const override
Getter for a descriptive purpose of the constructed filters.
MC Filter Type using a VarSet and the truth variable in it.
Abstract base class for different kinds of events.