Belle II Software development
TrackFilterFactory Class Reference

Factory that can create appropriate track filters from associated names. More...

#include <TrackFilterFactory.h>

Inheritance diagram for TrackFilterFactory:
FilterFactory< BaseTrackFilter > TrackQualityFilterFactory

Public Types

using CreatedFilter
 Type of the filter that this factory creates.
 
using CreatedFilter
 Type of the filter that this factory creates.
 

Public Member Functions

 TrackFilterFactory (const std::string &defaultFilterName="mva")
 Constructor forwarding the default filter 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.
 
std::map< std::string, std::string > getValidFilterNamesAndDescriptions () const override
 Getter for valid filter names and a description for each.
 
std::unique_ptr< BaseTrackFiltercreate (const std::string &filterName) const override
 Create a filter with the given name.
 
virtual std::string createFiltersNameDescription () const
 Create a string with a description mentioning the names of the chooseable filter.
 
virtual std::string createFiltersNameDescription () const
 Create a string with a description mentioning the names of the chooseable filter.
 
virtual std::string createFiltersParametersDescription () const
 Create a string with a description mentioning the parameters of the chooseable filter.
 
virtual std::string createFiltersParametersDescription () const
 Create a string with a description mentioning the parameters of the chooseable filter.
 
const std::string & getDefaultFilterName () const
 Legacy - Return the default filter suggested by the factory.
 
const std::string & getDefaultFilterName () const
 Legacy - Return the default filter suggested by the factory.
 

Private Types

using Super = TrackingUtilities::FilterFactory<BaseTrackFilter>
 Type of the base class.
 

Private Attributes

std::string m_defaultFilterName
 Legacy - Default filter name suggested by this factory.
 
std::string m_defaultFilterName
 Legacy - Default filter name suggested by this factory.
 

Detailed Description

Factory that can create appropriate track filters from associated names.

Definition at line 24 of file TrackFilterFactory.h.

Member Typedef Documentation

◆ CreatedFilter [1/2]

using CreatedFilter
inherited

Type of the filter that this factory creates.

Definition at line 29 of file FilterFactory.dcl.h.

◆ CreatedFilter [2/2]

using CreatedFilter
inherited

Type of the filter that this factory creates.

Definition at line 29 of file FilterFactory.dcl.h.

◆ Super

Type of the base class.

Definition at line 28 of file TrackFilterFactory.h.

Constructor & Destructor Documentation

◆ TrackFilterFactory()

TrackFilterFactory ( const std::string & defaultFilterName = "mva")
explicit

Constructor forwarding the default filter name.

Definition at line 40 of file TrackFilterFactory.cc.

41 : Super(defaultFilterName)
42{
43}
TrackingUtilities::FilterFactory< BaseTrackFilter > Super
Type of the base class.

Member Function Documentation

◆ create()

std::unique_ptr< BaseTrackFilter > create ( const std::string & filterName) const
overridevirtual

Create a filter with the given name.

Reimplemented from FilterFactory< BaseTrackFilter >.

Reimplemented in TrackQualityFilterFactory.

Definition at line 70 of file TrackFilterFactory.cc.

71{
72 if (filterName == "none") {
73 return std::make_unique<NoneTrackFilter>();
74 } else if (filterName == "all") {
75 return std::make_unique<AllTrackFilter>();
76 } else if (filterName == "truth") {
77 return std::make_unique<MCTrackFilter>();
78 } else if (filterName == "recording") {
79 return std::make_unique<RecordingTrackFilter>("TrackFilter.root");
80 } else if (filterName == "recording_data") {
81 return std::make_unique<RecordingDataTrackFilter>("TrackFilter.root");
82 } else if (filterName == "eval") {
83 auto recordedVarSets = std::make_unique<UnionVarSet<CDCTrack>>();
84 using TrackFilterVarSet = FilterVarSet<BaseTrackFilter>;
85 recordedVarSets->push_back(std::make_unique<TrackFilterVarSet>("mva", create("mva")));
86 recordedVarSets->push_back(std::make_unique<TrackFilterVarSet>("truth", create("truth")));
87 return std::make_unique<Recording<BaseTrackFilter>>(std::move(recordedVarSets), "TrackFilter_eval.root");
88 } else if (filterName == "mva") {
89 return std::make_unique<MVATrackFilter>("trackfindingcdc_TrackFilter", 0.10);
90 } else {
91 return Super::create(filterName);
92 }
93}
std::unique_ptr< BaseTrackFilter > create(const std::string &filterName) const override
Create a filter with the given name.
virtual std::unique_ptr< BaseTrackFilter > create(const std::string &filterName) const

◆ createFiltersNameDescription()

std::string createFiltersNameDescription ( ) const
virtualinherited

Create a string with a description mentioning the names of the chooseable filter.

Definition at line 56 of file FilterFactory.icc.h.

87 {
88 // Compose description for the filter names
89 std::ostringstream oss;
90 oss << this->getFilterPurpose();
91 oss << "Allowed values are: ";
92 std::vector<std::string> filterNameAndDescriptions;
93 for (const auto& filterNameAndDescription : this->getValidFilterNamesAndDescriptions()) {
94 const std::string& filterName = filterNameAndDescription.first;
95 const std::string& filterDescription = filterNameAndDescription.second;
96 filterNameAndDescriptions.push_back(quoted(filterName) + " " + bracketed(filterDescription));
97 }
98 oss << join(", ", filterNameAndDescriptions);
99 return oss.str();
100 }

◆ createFiltersParametersDescription()

std::string createFiltersParametersDescription ( ) const
virtualinherited

Create a string with a description mentioning the parameters of the chooseable filter.

Definition at line 59 of file FilterFactory.icc.h.

104 {
105 // Compose description for the filter parameters
106 std::ostringstream oss;
107 oss << "Key -- value pairs depending on the filter." << std::endl;
108 for (const auto& filterNameAndDescription : this->getValidFilterNamesAndDescriptions()) {
109
110 const std::string& filterName = filterNameAndDescription.first;
111 // const std::string& filterDescription = filterNameAndDescription.second;
112
113 std::unique_ptr<AFilter> filter = this->create(filterName);
114 if (not filter) {
115 B2WARNING("Could not create a filter for name " << filterName);
116 continue;
117 }
118
119 ModuleParamList moduleParamList;
120 const std::string prefix = "";
121 filter->exposeParameters(&moduleParamList, prefix);
122
123 std::map<std::string, std::string> filterParameters;
124 for (auto&& name : moduleParamList.getParameterNames()) {
125 filterParameters[name] = moduleParamList.getParameterDescription(name);
126 }
127
128 oss << quoted(filterName) << " :\n";
129 if (filterParameters.empty()) {
130 oss << "(no parameters)";
131 } else {
132 std::vector<std::string> parameterDescriptions;
133 for (const auto& parameterNameAndDescription : filterParameters) {
134 const std::string& parameterName = parameterNameAndDescription.first;
135 const std::string& parameterDescription = parameterNameAndDescription.second;
136 parameterDescriptions.push_back(parameterName + " -- " + parameterDescription);
137 }
138 oss << join(",\n", parameterDescriptions);
139 }
140 oss << ";\n";
141 }
142 return oss.str();
143 }

◆ getDefaultFilterName()

const std::string & getDefaultFilterName ( ) const
inherited

Legacy - Return the default filter suggested by the factory.

Definition at line 63 of file FilterFactory.icc.h.

147 {
148 return m_defaultFilterName;
149 }

◆ getFilterPurpose()

std::string getFilterPurpose ( ) const
overridevirtual

Getter for a descriptive purpose of the constructed filters.

Implements FilterFactory< BaseTrackFilter >.

Reimplemented in TrackQualityFilterFactory.

Definition at line 50 of file TrackFilterFactory.cc.

51{
52 return "Track filter to reject fakes";
53}

◆ getIdentifier()

std::string getIdentifier ( ) const
overridevirtual

Getter for a short identifier for the factory.

Implements FilterFactory< BaseTrackFilter >.

Definition at line 45 of file TrackFilterFactory.cc.

46{
47 return "Track";
48}

◆ getValidFilterNamesAndDescriptions()

std::map< std::string, std::string > getValidFilterNamesAndDescriptions ( ) const
overridevirtual

Getter for valid filter names and a description for each.

Implements FilterFactory< BaseTrackFilter >.

Definition at line 56 of file TrackFilterFactory.cc.

57{
58 return {
59 {"none", "no track is valid"},
60 {"all", "set all tracks as good"},
61 {"truth", "monte carlo truth"},
62 {"recording", "record variables to a TTree"},
63 {"recording_data", "record reco-variables to a TTree (no truth information)"},
64 {"eval", "record truth and the mva response for insitu comparison"},
65 {"mva", "test with a mva method"}
66 };
67}

Member Data Documentation

◆ m_defaultFilterName [1/2]

std::string m_defaultFilterName
privateinherited

Legacy - Default filter name suggested by this factory.

Definition at line 67 of file FilterFactory.dcl.h.

◆ m_defaultFilterName [2/2]

std::string m_defaultFilterName
privateinherited

Legacy - Default filter name suggested by this factory.

Definition at line 67 of file FilterFactory.dcl.h.


The documentation for this class was generated from the following files: