Belle II Software development
TrackRelationFilterFactory Class Reference

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

#include <TrackRelationFilterFactory.h>

Inheritance diagram for TrackRelationFilterFactory:
FilterFactory< BaseTrackRelationFilter >

Public Types

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

Public Member Functions

 TrackRelationFilterFactory (const std::string &defaultFilterName="realistic")
 Constructor forwarding the default filter name.
 
std::string getIdentifier () const final
 Getter for a short identifier for the factory.
 
std::string getFilterPurpose () const final
 Getter for a descriptive purpose of the constructed filters.
 
std::map< std::string, std::string > getValidFilterNamesAndDescriptions () const final
 Getter for valid filter names and a description for each.
 
std::unique_ptr< BaseTrackRelationFiltercreate (const std::string &filterName) const final
 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 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.
 

Private Types

using Super = FilterFactory< BaseTrackRelationFilter >
 Type of the base class.
 

Private Attributes

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

Detailed Description

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

Definition at line 24 of file TrackRelationFilterFactory.h.

Member Typedef Documentation

◆ CreatedFilter

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 TrackRelationFilterFactory.h.

Constructor & Destructor Documentation

◆ TrackRelationFilterFactory()

TrackRelationFilterFactory ( const std::string &  defaultFilterName = "realistic")
explicit

Constructor forwarding the default filter name.

Definition at line 28 of file TrackRelationFilterFactory.cc.

29 : Super(defaultFilterName)
30{
31}
FilterFactory< BaseTrackRelationFilter > Super
Type of the base class.

Member Function Documentation

◆ create()

std::unique_ptr< BaseTrackRelationFilter > create ( const std::string &  filterName) const
finalvirtual

Create a filter with the given name.

Reimplemented from FilterFactory< BaseTrackRelationFilter >.

Definition at line 58 of file TrackRelationFilterFactory.cc.

59{
60 if (filterName == "none") {
61 return std::make_unique<NoneFilter<BaseTrackRelationFilter>>();
62 // cppcheck-suppress knownConditionTrueFalse
63 } else if (filterName == "all") {
64 return std::make_unique<AllTrackRelationFilter>();
65 // cppcheck-suppress knownConditionTrueFalse
66 } else if (filterName == "truth") {
67 return std::make_unique<MCTrackRelationFilter>();
68 // cppcheck-suppress knownConditionTrueFalse
69 } else if (filterName == "unionrecording") {
70 return std::make_unique< UnionRecordingTrackRelationFilter>();
71 // cppcheck-suppress knownConditionTrueFalse
72 } else if (filterName == "feasible") {
73 return std::make_unique<MVAFeasibleTrackRelationFilter>();
74 // cppcheck-suppress knownConditionTrueFalse
75 } else if (filterName == "realistic") {
76 return std::make_unique<MVARealisticTrackRelationFilter>();
77 // cppcheck-suppress knownConditionTrueFalse
78 } else if (filterName == "phi") {
79 return std::make_unique<PhiTrackRelationFilter>();
80 } else {
81 return Super::create(filterName);
82 }
83}
virtual std::unique_ptr< BaseTrackRelationFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.

◆ createFiltersNameDescription()

std::string createFiltersNameDescription
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 }
virtual std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const=0
Getter for the valid filter names and a description for each.
virtual std::string getFilterPurpose() const=0
Getter for a descriptive purpose of the filter.

◆ createFiltersParametersDescription()

std::string createFiltersParametersDescription
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
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 }
std::string m_defaultFilterName
Legacy - Default filter name suggested by this factory.

◆ getFilterPurpose()

std::string getFilterPurpose ( ) const
finalvirtual

Getter for a descriptive purpose of the constructed filters.

Implements FilterFactory< BaseTrackRelationFilter >.

Definition at line 38 of file TrackRelationFilterFactory.cc.

39{
40 return "Track relation filter to construct a track network for merging";
41}

◆ getIdentifier()

std::string getIdentifier ( ) const
finalvirtual

Getter for a short identifier for the factory.

Implements FilterFactory< BaseTrackRelationFilter >.

Definition at line 33 of file TrackRelationFilterFactory.cc.

34{
35 return "TrackRelation";
36}

◆ getValidFilterNamesAndDescriptions()

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

Getter for valid filter names and a description for each.

Implements FilterFactory< BaseTrackRelationFilter >.

Definition at line 44 of file TrackRelationFilterFactory.cc.

45{
46 return {
47 {"none", "accepts nothing"},
48 {"all", "accepts everything"},
49 {"truth", "accepts based on monte carlo information"},
50 {"unionrecording", "record multiple choosable variable set"},
51 {"phi", "filter just based on the phi distance"},
52 {"feasible", "a rough efficient compatibility check"},
53 {"realistic", "an expensive pure compatibility check"},
54 };
55}

Member Data Documentation

◆ m_defaultFilterName

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: