Belle II Software development
StereoHitFilterFactory.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/stereoHits/StereoHitFilterFactory.h>
9
10#include <tracking/trackFindingCDC/filters/stereoHits/StereoHitTruthVarSet.h>
11#include <tracking/trackFindingCDC/filters/stereoHits/StereoHitVarSet.h>
12
13#include <tracking/trackFindingCDC/filters/base/MVAFilter.icc.h>
14
15#include <tracking/trackFindingCDC/filters/base/AllFilter.icc.h>
16#include <tracking/trackFindingCDC/filters/base/NoneFilter.icc.h>
17#include <tracking/trackFindingCDC/filters/base/RandomFilter.icc.h>
18#include <tracking/trackFindingCDC/filters/base/ChoosableFromVarSetFilter.icc.h>
19#include <tracking/trackFindingCDC/filters/base/TruthVarFilter.icc.h>
20#include <tracking/trackFindingCDC/filters/base/RecordingFilter.icc.h>
21
22#include <tracking/trackFindingCDC/filters/base/FilterFactory.icc.h>
23
24#include <tracking/trackFindingCDC/varsets/VariadicUnionVarSet.h>
25
26using namespace Belle2;
27using namespace TrackFindingCDC;
28
29namespace {
30 using AllStereoHitFilter = AllFilter<BaseStereoHitFilter>;
31 using NoneStereoHitFilter = NoneFilter<BaseStereoHitFilter>;
32 using RandomStereoHitFilter = RandomFilter<BaseStereoHitFilter>;
33 using MCStereoHitFilter = TruthVarFilter<StereoHitTruthVarSet>;
34 using SimpleStereoHitFilter = ChoosableFromVarSetFilter<StereoHitVarSet>;
35 using RecordingStereoHitFilter =
37 using MVAStereoHitFilter = MVAFilter<StereoHitVarSet>;
38}
39
41
42StereoHitFilterFactory::StereoHitFilterFactory(const std::string& defaultFilterName)
43 : Super(defaultFilterName)
44{
45}
46
48{
49 return "StereoHit";
50}
51
53{
54 return "Stereo hit to track combination filter for adding the hit.";
55}
56
57std::map<std::string, std::string>
59{
60 return {
61 {"none", "no hit track combination is valid."},
62 {"all", "set all hits as good."},
63 {"random", "returns a random weight (for testing)."},
64 {"truth", "monte carlo truth."},
65 {"simple", "give back a weight based on very simple variables you can give as a parameter."},
66 {"recording", "record variables to a TTree."},
67 {"mva", "use the trained BDT."},
68 };
69}
70
71std::unique_ptr<BaseStereoHitFilter>
72StereoHitFilterFactory::create(const std::string& filterName) const
73{
74 if (filterName == "none") {
75 return std::make_unique<NoneStereoHitFilter>();
76 // cppcheck-suppress knownConditionTrueFalse
77 } else if (filterName == "all") {
78 return std::make_unique<AllStereoHitFilter>();
79 // cppcheck-suppress knownConditionTrueFalse
80 } else if (filterName == "random") {
81 return std::make_unique<RandomStereoHitFilter>();
82 // cppcheck-suppress knownConditionTrueFalse
83 } else if (filterName == "simple") {
84 return std::make_unique<SimpleStereoHitFilter>();
85 // cppcheck-suppress knownConditionTrueFalse
86 } else if (filterName == "truth") {
87 return std::make_unique<MCStereoHitFilter>();
88 // cppcheck-suppress knownConditionTrueFalse
89 } else if (filterName == "recording") {
90 return std::make_unique<RecordingStereoHitFilter>("StereoHitFilter.root");
91 // cppcheck-suppress knownConditionTrueFalse
92 } else if (filterName == "mva") {
93 return std::make_unique<MVAStereoHitFilter>("trackfindingcdc_StereoHitFilter");
94 } else {
95 return Super::create(filterName);
96 }
97}
Filter adapter type that accepts all items (just for reference).
Definition: AllFilter.dcl.h:21
Convince template to create a filter returning on variable from a set of variables.
Factory that can create appropriate filter instances from a name.
virtual std::unique_ptr< BaseStereoHitFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.
Convenience template to create a mva filter for a set of variables.
Filter adapter type that rejects all items.
Random filter resulting in a random weight between 0 and 1.
Convenience template to create a recording filter for a set of variables.
StereoHitFilterFactory(const std::string &defaultFilterName="all")
Constructor forwarding the default filter name.
std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const override
Getter for valid filter names and a description for each.
std::unique_ptr< BaseStereoHitFilter > 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.
MC Filter Type using a VarSet and the truth variable in it.
Abstract base class for different kinds of events.