Belle II Software development
SVDResultFilterFactory Class Reference

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

#include <SVDResultFilterFactory.h>

Inheritance diagram for SVDResultFilterFactory:
FilterFactory< BaseSVDResultFilter >

Public Types

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

Public Member Functions

 SVDResultFilterFactory (const std::string &defaultFilterName="all")
 Constructor forwarding the default filter name.
 
 ~SVDResultFilterFactory ()
 Default destructor.
 
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< BaseSVDResultFiltercreate (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 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 = TrackFindingCDC::FilterFactory< BaseSVDResultFilter >
 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 cluster filters from associated names.

Definition at line 20 of file SVDResultFilterFactory.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 24 of file SVDResultFilterFactory.h.

Constructor & Destructor Documentation

◆ SVDResultFilterFactory()

SVDResultFilterFactory ( const std::string &  defaultFilterName = "all")
explicit

Constructor forwarding the default filter name.

Definition at line 48 of file SVDResultFilterFactory.cc.

49 : Super(defaultFilterName)
50{
51}
TrackFindingCDC::FilterFactory< BaseSVDResultFilter > Super
Type of the base class.

Member Function Documentation

◆ create()

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

Create a filter with the given name.

Reimplemented from FilterFactory< BaseSVDResultFilter >.

Definition at line 82 of file SVDResultFilterFactory.cc.

83{
84 if (filterName == "none") {
85 return std::make_unique<TrackFindingCDC::NoneFilter<BaseSVDResultFilter>>();
86 // cppcheck-suppress knownConditionTrueFalse
87 } else if (filterName == "all") {
88 return std::make_unique<TrackFindingCDC::AllFilter<BaseSVDResultFilter>>();
89 // cppcheck-suppress knownConditionTrueFalse
90 } else if (filterName == "recording") {
91 return std::make_unique<RecordingSVDResultFilter>();
92 // cppcheck-suppress knownConditionTrueFalse
93 } else if (filterName == "recording_with_relations") {
94 return std::make_unique<RecordingSVDSeededResultFilter>();
95 // cppcheck-suppress knownConditionTrueFalse
96 } else if (filterName == "mva") {
97 return std::make_unique<MVASVDResultFilter>("ckf_CDCToSVDResult");
98 // cppcheck-suppress knownConditionTrueFalse
99 } else if (filterName == "mva_with_relations") {
100 return std::make_unique<MVASVDSeededResultFilter>("ckf_SeededCDCToSVDResult");
101 // cppcheck-suppress knownConditionTrueFalse
102 } else if (filterName == "truth") {
103 return std::make_unique<ChooseableTruthSVDResultFilter>("truth");
104 // cppcheck-suppress knownConditionTrueFalse
105 } else if (filterName == "truth_svd_cdc_relation") {
106 return std::make_unique<ChooseableTruthSVDResultFilter>("truth_svd_cdc_relation");
107 // cppcheck-suppress knownConditionTrueFalse
108 } else if (filterName == "size") {
109 return std::make_unique<SizeSVDResultFilter>();
110 // cppcheck-suppress knownConditionTrueFalse
111 } else if (filterName == "weight") {
112 return std::make_unique<WeightSVDResultFilter>();
113 } else {
114 return Super::create(filterName);
115 }
116}
virtual std::unique_ptr< BaseSVDResultFilter > 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
overridevirtual

Getter for a descriptive purpose of the constructed filters.

Implements FilterFactory< BaseSVDResultFilter >.

Definition at line 60 of file SVDResultFilterFactory.cc.

61{
62 return "Reject SVD CKF results. ";
63}

◆ getIdentifier()

std::string getIdentifier ( ) const
overridevirtual

Getter for a short identifier for the factory.

Implements FilterFactory< BaseSVDResultFilter >.

Definition at line 55 of file SVDResultFilterFactory.cc.

56{
57 return "SVDResult";
58}

◆ getValidFilterNamesAndDescriptions()

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

Getter for valid filter names and a description for each.

Implements FilterFactory< BaseSVDResultFilter >.

Definition at line 65 of file SVDResultFilterFactory.cc.

66{
67 return {
68 {"none", "no combination is valid"},
69 {"all", "all combination are valid"},
70 {"recording", "record variables to a TTree"},
71 {"recording_with_relations", "record variables to a TTree"},
72 {"mva", "filter based on the trained MVA method"},
73 {"mva_with_relations", "filter based on the trained MVA method"},
74 {"size", "ordering according to size"},
75 {"weight", "ordering according to weight"},
76 {"truth", "monte carlo truth"},
77 {"truth_svd_cdc_relation", "monte carlo truth on the related CDC and SVD tracks"},
78 };
79}

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: