Belle II Software  release-05-01-25
SVDResultFilterFactory.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/ckf/svd/filters/results/SVDResultFilterFactory.h>
11 
12 #include <tracking/trackFindingCDC/filters/base/FilterFactory.icc.h>
13 #include <tracking/trackFindingCDC/filters/base/AllFilter.icc.h>
14 #include <tracking/trackFindingCDC/filters/base/NoneFilter.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 
19 #include <tracking/trackFindingCDC/varsets/VariadicUnionVarSet.h>
20 
21 #include <tracking/ckf/svd/filters/results/SVDResultVarSet.h>
22 #include <tracking/ckf/svd/filters/results/RelationSVDResultVarSet.h>
23 #include <tracking/ckf/svd/filters/results/SVDResultTruthVarSet.h>
24 #include <tracking/ckf/svd/filters/results/SizeSVDResultFilter.h>
25 #include <tracking/ckf/svd/filters/results/WeightSVDResultFilter.h>
26 
27 using namespace Belle2;
28 using namespace TrackFindingCDC;
29 
30 namespace {
32  using ChooseableTruthSVDResultFilter = ChoosableFromVarSetFilter<SVDResultTruthVarSet>;
33 
35  using RecordingSVDResultFilter =
36  RecordingFilter<VariadicUnionVarSet<SVDResultTruthVarSet, SVDResultVarSet>>;
37 
39  using RecordingSVDSeededResultFilter =
40  RecordingFilter<VariadicUnionVarSet<SVDResultTruthVarSet, SVDResultVarSet, RelationSVDResultVarSet>>;
41 
43  using MVASVDResultFilter = MVAFilter<SVDResultVarSet>;
44 
46  using MVASVDSeededResultFilter = MVAFilter<VariadicUnionVarSet<SVDResultVarSet, RelationSVDResultVarSet>>;
47 }
48 
49 
50 SVDResultFilterFactory::SVDResultFilterFactory(const std::string& defaultFilterName)
51  : Super(defaultFilterName)
52 {
53 }
54 
56 
58 {
59  return "SVDResult";
60 }
61 
63 {
64  return "Reject svd results";
65 }
66 
67 std::map<std::string, std::string> SVDResultFilterFactory::getValidFilterNamesAndDescriptions() const
68 {
69  return {
70  {"none", "no combination is valid"},
71  {"all", "all combination are valid"},
72  {"recording", "record variables to a TTree"},
73  {"recording_with_relations", "record variables to a TTree"},
74  {"mva", "filter based on the trained MVA method"},
75  {"mva_with_relations", "filter based on the trained MVA method"},
76  {"size", "ordering according to size"},
77  {"weight", "ordering according to weight"},
78  {"truth", "monte carlo truth"},
79  {"truth_svd_cdc_relation", "monte carlo truth on the related CDC and SVD tracks"},
80  };
81 }
82 
83 std::unique_ptr<BaseSVDResultFilter>
84 SVDResultFilterFactory::create(const std::string& filterName) const
85 {
86  if (filterName == "none") {
87  return std::make_unique<TrackFindingCDC::NoneFilter<BaseSVDResultFilter>>();
88  } else if (filterName == "all") {
89  return std::make_unique<TrackFindingCDC::AllFilter<BaseSVDResultFilter>>();
90  } else if (filterName == "recording") {
91  return std::make_unique<RecordingSVDResultFilter>();
92  } else if (filterName == "recording_with_relations") {
93  return std::make_unique<RecordingSVDSeededResultFilter>();
94  } else if (filterName == "mva") {
95  return std::make_unique<MVASVDResultFilter>("ckf_CDCToSVDResult");
96  } else if (filterName == "mva_with_relations") {
97  return std::make_unique<MVASVDSeededResultFilter>("ckf_SeededCDCToSVDResult");
98  } else if (filterName == "truth") {
99  return std::make_unique<ChooseableTruthSVDResultFilter>("truth");
100  } else if (filterName == "truth_svd_cdc_relation") {
101  return std::make_unique<ChooseableTruthSVDResultFilter>("truth_svd_cdc_relation");
102  } else if (filterName == "size") {
103  return std::make_unique<SizeSVDResultFilter>();
104  } else if (filterName == "weight") {
105  return std::make_unique<WeightSVDResultFilter>();
106  } else {
107  return Super::create(filterName);
108  }
109 }
Belle2::SVDResultFilterFactory::SVDResultFilterFactory
SVDResultFilterFactory(const std::string &defaultFilterName="all")
Constructor forwarding the default filter name.
Definition: SVDResultFilterFactory.cc:50
Belle2::TrackFindingCDC::FilterFactory< BaseSVDResultFilter >
Belle2::SVDResultFilterFactory::~SVDResultFilterFactory
~SVDResultFilterFactory()
Default destructor.
Belle2::TrackFindingCDC::FilterFactory< BaseSVDResultFilter >::create
virtual std::unique_ptr< BaseSVDResultFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.
Definition: FilterFactory.icc.h:54
Belle2::SVDResultFilterFactory::getFilterPurpose
std::string getFilterPurpose() const override
Getter for a descriptive purpose of the constructed filters.
Definition: SVDResultFilterFactory.cc:62
Belle2::SVDResultFilterFactory::getIdentifier
std::string getIdentifier() const override
Getter for a short identifier for the factory.
Definition: SVDResultFilterFactory.cc:57
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVDResultFilterFactory::getValidFilterNamesAndDescriptions
std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const override
Getter for valid filter names and a description for each.
Definition: SVDResultFilterFactory.cc:67
Belle2::SVDResultFilterFactory::create
std::unique_ptr< BaseSVDResultFilter > create(const std::string &filterName) const override
Create a filter with the given name.
Definition: SVDResultFilterFactory.cc:84