Belle II Software development
FacetFilterFactory Class Reference

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

#include <FacetFilterFactory.h>

Inheritance diagram for FacetFilterFactory:
FilterFactory< BaseFacetFilter >

Public Types

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

Public Member Functions

 FacetFilterFactory (const std::string &defaultFilterName="chi2")
 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< BaseFacetFiltercreate (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< BaseFacetFilter >
 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 facet filters from associated names.

Definition at line 24 of file FacetFilterFactory.h.

Member Typedef Documentation

◆ CreatedFilter

using CreatedFilter = BaseFacetFilter
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 FacetFilterFactory.h.

Constructor & Destructor Documentation

◆ FacetFilterFactory()

FacetFilterFactory ( const std::string &  defaultFilterName = "chi2")
explicit

Constructor forwarding the default filter name.

Definition at line 30 of file FacetFilterFactory.cc.

31 : Super(defaultFilterName)
32{
33}
FilterFactory< BaseFacetFilter > Super
Type of the base class.

Member Function Documentation

◆ create()

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

Create a filter with the given name.

Reimplemented from FilterFactory< BaseFacetFilter >.

Definition at line 62 of file FacetFilterFactory.cc.

63{
64 if (filterName == "none") {
65 return std::make_unique<NoneFilter<BaseFacetFilter>>();
66 // cppcheck-suppress knownConditionTrueFalse
67 } else if (filterName == "all") {
68 return std::make_unique<AllFacetFilter>();
69 // cppcheck-suppress knownConditionTrueFalse
70 } else if (filterName == "truth") {
71 return std::make_unique<MCFacetFilter>();
72 // cppcheck-suppress knownConditionTrueFalse
73 } else if (filterName == "feasible") {
74 return std::make_unique<FeasibleRLFacetFilter>();
75 // cppcheck-suppress knownConditionTrueFalse
76 } else if (filterName == "simple") {
77 return std::make_unique<SimpleFacetFilter>();
78 // cppcheck-suppress knownConditionTrueFalse
79 } else if (filterName == "realistic") {
80 return std::make_unique<RealisticFacetFilter>();
81 // cppcheck-suppress knownConditionTrueFalse
82 } else if (filterName == "realistic_loss") {
83 return std::make_unique<RealisticFacetFilter>(25);
84 // cppcheck-suppress knownConditionTrueFalse
85 } else if (filterName == "chi2") {
86 return std::make_unique<Chi2FacetFilter>();
87 // cppcheck-suppress knownConditionTrueFalse
88 } else if (filterName == "chi2_old") {
89 return std::make_unique<Chi2FacetFilter>(75.0, 120.0);
90 // cppcheck-suppress knownConditionTrueFalse
91 } else if (filterName == "unionrecording") {
92 return std::make_unique<UnionRecordingFacetFilter>();
93 // cppcheck-suppress knownConditionTrueFalse
94 } else if (filterName == "mva") {
95 return std::make_unique<MVAFacetFilter>();
96 } else {
97 return Super::create(filterName);
98 }
99}
virtual std::unique_ptr< BaseFacetFilter > 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< BaseFacetFilter >.

Definition at line 40 of file FacetFilterFactory.cc.

41{
42 return "Facet filter to construct of a facet network";
43}

◆ getIdentifier()

std::string getIdentifier ( ) const
finalvirtual

Getter for a short identifier for the factory.

Implements FilterFactory< BaseFacetFilter >.

Definition at line 35 of file FacetFilterFactory.cc.

36{
37 return "Facet";
38}

◆ getValidFilterNamesAndDescriptions()

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

Getter for valid filter names and a description for each.

Implements FilterFactory< BaseFacetFilter >.

Definition at line 45 of file FacetFilterFactory.cc.

46{
47 return {
48 {"none", "no facet is valid, stop at cluster generation."},
49 {"all", "all facets are valid"},
50 {"truth", "monte carlo truth"},
51 {"feasible", "only checking the feasibility of right left passage information"},
52 {"simple", "mc free with simple criteria"},
53 {"realistic", "mc free with realistic criteria"},
54 {"realistic_loss", "mc with realistic criteria but looser cut"},
55 {"chi2", "mc free based on chi2 fitting"},
56 {"chi2_old", "old based on chi2 fitting with single cut regardless of superlayer"},
57 {"unionrecording", "record many multiple choosable variable set"},
58 {"mva", "filter facets with a mva method"},
59 };
60}

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: