Belle II Software development
CDCStateFilterFactory Class Reference

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

#include <CDCStateFilterFactory.h>

Inheritance diagram for CDCStateFilterFactory:
FilterFactory< BaseCDCStateFilter >

Public Types

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

Public Member Functions

 CDCStateFilterFactory (const std::string &defaultFilterName="all")
 Constructor forwarding the default filter name.
 
 ~CDCStateFilterFactory ()
 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< BaseCDCStateFiltercreate (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< BaseCDCStateFilter >
 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 19 of file CDCStateFilterFactory.h.

Member Typedef Documentation

◆ CreatedFilter

using CreatedFilter = BaseCDCStateFilter
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 23 of file CDCStateFilterFactory.h.

Constructor & Destructor Documentation

◆ CDCStateFilterFactory()

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

Constructor forwarding the default filter name.

Definition at line 42 of file CDCStateFilterFactory.cc.

43 : Super(defaultFilterName)
44{
45}
TrackFindingCDC::FilterFactory< BaseCDCStateFilter > Super
Type of the base class.

Member Function Documentation

◆ create()

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

Create a filter with the given name.

Reimplemented from FilterFactory< BaseCDCStateFilter >.

Definition at line 80 of file CDCStateFilterFactory.cc.

81{
82 if (filterName == "none") {
83 return std::make_unique<TrackFindingCDC::NoneFilter<BaseCDCStateFilter>>();
84 // cppcheck-suppress knownConditionTrueFalse
85 } else if (filterName == "all") {
86 return std::make_unique<TrackFindingCDC::AllFilter<BaseCDCStateFilter>>();
87 // cppcheck-suppress knownConditionTrueFalse
88 } else if (filterName == "rough") {
89 return std::make_unique<RoughCDCStateFilter>();
90 // cppcheck-suppress knownConditionTrueFalse
91 } else if (filterName == "rough_eclSeed") {
92 return std::make_unique<RoughCDCfromEclStateFilter>();
93 // cppcheck-suppress knownConditionTrueFalse
94 } else if (filterName == "mc_truth") {
95 return std::make_unique<MCTruthCDCStateFilter>();
96 // cppcheck-suppress knownConditionTrueFalse
97 } else if (filterName == "mc_truth_eclSeed") {
98 return std::make_unique<MCTruthEclSeedFilter>();
99 // cppcheck-suppress knownConditionTrueFalse
100 } else if (filterName == "extrapolate_and_update") {
101 return std::make_unique<ExtrapolateAndUpdateCDCStateFilter>();
102 // cppcheck-suppress knownConditionTrueFalse
103 } else if (filterName == "distance") {
104 return std::make_unique<DistanceCDCStateFilter>();
105 // cppcheck-suppress knownConditionTrueFalse
106 } else if (filterName == "recording") {
107 return std::make_unique<RecordingCDCStateFilter>("CDCStateFilter.root");
108 // cppcheck-suppress knownConditionTrueFalse
109 } else if (filterName == "rough_and_recording") {
110 return std::make_unique<AndCDCStateFilter>(
111 std::make_unique<RecordingCDCStateFilter>("CDCStateFilter.root"),
112 std::make_unique<RoughCDCStateFilter>()
113 );
114 // cppcheck-suppress knownConditionTrueFalse
115 } else if (filterName == "recording_eclSeed") {
116 return std::make_unique<RecordingCDCfromEclStateFilter>("CDCfromECLStateFilter.root");
117 // cppcheck-suppress knownConditionTrueFalse
118 } else if (filterName == "rough_and_recording_eclSeed") {
119 return std::make_unique<AndCDCStateFilter>(
120 std::make_unique<RecordingCDCfromEclStateFilter>("CDCfromECLStateFilter.root"),
121 std::make_unique<RoughCDCfromEclStateFilter>()
122 );
123 // cppcheck-suppress knownConditionTrueFalse
124 } else if (filterName == "distance_and_recording_eclSeed") {
125 return std::make_unique<AndCDCStateFilter>(
126 std::make_unique<RecordingCDCfromEclStateFilter>("CDCfromECLStateFilter.root"),
127 std::make_unique<DistanceCDCStateFilter>()
128 );
129 } else {
130 return Super::create(filterName);
131 }
132}
virtual std::unique_ptr< BaseCDCStateFilter > 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< BaseCDCStateFilter >.

Definition at line 54 of file CDCStateFilterFactory.cc.

55{
56 return "Reject CDC CKF states. ";
57}

◆ getIdentifier()

std::string getIdentifier ( ) const
overridevirtual

Getter for a short identifier for the factory.

Implements FilterFactory< BaseCDCStateFilter >.

Definition at line 49 of file CDCStateFilterFactory.cc.

50{
51 return "CDCState";
52}

◆ getValidFilterNamesAndDescriptions()

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

Getter for valid filter names and a description for each.

Implements FilterFactory< BaseCDCStateFilter >.

Definition at line 59 of file CDCStateFilterFactory.cc.

60{
61 return {
62 {"none", "no track combination is valid"},
63 {"all", "set all track combinations as good"},
64 {"mc_truth", "filtering based on the mc truth information"},
65 {"mc_truth_eclSeed", "filtering based on the mc truth information"},
66 {"rough", "very rough filtering"},
67 {"rough_eclSeed", "very rough filtering, seed created from ECL shower"},
68 {"extrapolate_and_update", "Extrapolation and update"},
69 {"distance", "Give a weight based on the distance"},
70 {"recording", "record variables to a TTree"},
71 {"recording_eclSeed", "record variables to a TTree"},
72 {"rough_and_recording", "very rough filtering, seed created from SVD track"},
73 {"rough_and_recording_eclSeed", "very rough filtering, seed created from ECL shower"},
74 {"distance_and_recording_eclSeed", "Give a weight based on the distance"},
75
76 };
77}

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: