Belle II Software development
SegmentPairFilterFactory Class Reference

Factory that can create appropriate segment pair filters from associated names. More...

#include <SegmentPairFilterFactory.h>

Inheritance diagram for SegmentPairFilterFactory:
FilterFactory< BaseSegmentPairFilter >

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

 SegmentPairFilterFactory (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< BaseSegmentPairFiltercreate (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 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<BaseSegmentPairFilter>
 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 segment pair filters from associated names.

Definition at line 28 of file SegmentPairFilterFactory.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 32 of file SegmentPairFilterFactory.h.

Constructor & Destructor Documentation

◆ SegmentPairFilterFactory()

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

Constructor forwarding the default filter name.

Definition at line 29 of file SegmentPairFilterFactory.cc.

30 : Super(defaultFilterName)
31{
32}
TrackingUtilities::FilterFactory< BaseSegmentPairFilter > Super
Type of the base class.

Member Function Documentation

◆ create()

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

Create a filter with the given name.

Reimplemented from FilterFactory< BaseSegmentPairFilter >.

Definition at line 60 of file SegmentPairFilterFactory.cc.

61{
62 if (filterName == "none") {
63 return std::make_unique<NoneFilter<BaseSegmentPairFilter>>();
64 // cppcheck-suppress knownConditionTrueFalse
65 } else if (filterName == "all") {
66 return std::make_unique<AllSegmentPairFilter>();
67 // cppcheck-suppress knownConditionTrueFalse
68 } else if (filterName == "truth") {
69 return std::make_unique<MCSegmentPairFilter>();
70 // cppcheck-suppress knownConditionTrueFalse
71 } else if (filterName == "fitless") {
72 return std::make_unique<FitlessSegmentPairFilter>();
73 // cppcheck-suppress knownConditionTrueFalse
74 } else if (filterName == "simple") {
75 return std::make_unique<SimpleSegmentPairFilter>();
76 // cppcheck-suppress knownConditionTrueFalse
77 } else if (filterName == "unionrecording") {
78 return std::make_unique<UnionRecordingSegmentPairFilter>();
79 // cppcheck-suppress knownConditionTrueFalse
80 } else if (filterName == "feasible") {
81 return std::make_unique<MVAFeasibleSegmentPairFilter>();
82 // cppcheck-suppress knownConditionTrueFalse
83 } else if (filterName == "realistic") {
84 return std::make_unique<MVARealisticSegmentPairFilter>();
85 } else {
86 return Super::create(filterName);
87 }
88}
virtual std::unique_ptr< BaseSegmentPairFilter > 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
finalvirtual

Getter for a descriptive purpose of the constructed filters.

Implements FilterFactory< BaseSegmentPairFilter >.

Definition at line 39 of file SegmentPairFilterFactory.cc.

40{
41 return "Segment pair filter to construct of a segment pair network";
42}

◆ getIdentifier()

std::string getIdentifier ( ) const
finalvirtual

Getter for a short identifier for the factory.

Implements FilterFactory< BaseSegmentPairFilter >.

Definition at line 34 of file SegmentPairFilterFactory.cc.

35{
36 return "SegmentPair";
37}

◆ getValidFilterNamesAndDescriptions()

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

Getter for valid filter names and a description for each.

Implements FilterFactory< BaseSegmentPairFilter >.

Definition at line 45 of file SegmentPairFilterFactory.cc.

46{
47 return {
48 {"none", "no segment pair is valid"},
49 {"all", "all segment pairs are valid"},
50 {"truth", "monte carlo truth"},
51 {"fitless", "mc free with simple criteria without the common fit"},
52 {"simple", "mc free with simple criteria"},
53 {"unionrecording", "record many multiple choosable variable set"},
54 {"feasible", "multivariat method based on variables of the first and last hit in each segment meant as precut"},
55 {"realistic", "realistic filter using a common fit and combination of all information with an mva"},
56 };
57}

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: