Belle II Software development
SVDStateFilterFactory Class Reference

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

#include <SVDStateFilterFactory.h>

Inheritance diagram for SVDStateFilterFactory:
FilterFactory< BaseSVDStateFilter >

Public Types

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

Public Member Functions

 SVDStateFilterFactory (const std::string &defaultFilterName="all")
 Constructor forwarding the default filter name.
 
 ~SVDStateFilterFactory ()
 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< BaseSVDStateFiltercreate (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< BaseSVDStateFilter >
 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 SVDStateFilterFactory.h.

Member Typedef Documentation

◆ CreatedFilter

using CreatedFilter = BaseSVDStateFilter
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 24 of file SVDStateFilterFactory.h.

Constructor & Destructor Documentation

◆ SVDStateFilterFactory()

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

Constructor forwarding the default filter name.

Definition at line 68 of file SVDStateFilterFactory.cc.

69 : Super(defaultFilterName)
70{
71}
TrackFindingCDC::FilterFactory< BaseSVDStateFilter > Super
Type of the base class.

Member Function Documentation

◆ create()

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

Create a filter with the given name.

Reimplemented from FilterFactory< BaseSVDStateFilter >.

Definition at line 109 of file SVDStateFilterFactory.cc.

110{
111 if (filterName == "none") {
112 return std::make_unique<TrackFindingCDC::NoneFilter<BaseSVDStateFilter>>();
113 } else if (filterName == "all") {
114 return std::make_unique<AllSVDStateFilter>();
115 } else if (filterName == "non_ip_crossing") {
116 return std::make_unique<NonIPCrossingSVDStateFilter>();
117 } else if (filterName == "advance") {
118 return std::make_unique<AdvanceFilter<CKFToSVDState, SVDAdvancer>>();
119 } else if (filterName == "fit") {
120 return std::make_unique<KalmanFilter<CKFToSVDState, SVDKalmanStepper>>();
121 } else if (filterName == "simple") {
122 return std::make_unique<SimpleSVDStateFilter>();
123 } else if (filterName == "residual") {
124 return std::make_unique<ResidualSVDStateFilter>();
125 } else if (filterName == "truth") {
126 return std::make_unique<MCSVDStateFilter>();
127 } else if (filterName == "ordering_truth") {
128 return std::make_unique<MCOrderingSVDStateFilter>("truth_inverted");
129 } else if (filterName == "sloppy_truth") {
130 return std::make_unique<SloppyMCSVDStateFilter>();
131 } else if (filterName == "recording") {
132 return std::make_unique<RecordingSVDStateFilter>("SVDStateFilter.root");
133 // This filter causes trouble with the parameters added to the SVDStateTruthVarSet, as both the RecordingSVDStateFilter
134 // AND the MCSVDStateFilter internally use the SVDStateTruthVarSet, so the parameters are added twice for the same filter
135 // causing an error. Currently this filter isn't actively used, but to keep it in the code in some way, even if it would
136 // not work currently, it's commented.
137 // } else if (filterName == "recording_and_truth") {
138 // return std::make_unique<AndSVDStateFilter>(
139 // std::make_unique<RecordingSVDStateFilter>("SVDStateFilter.root"),
140 // std::make_unique<MCSVDStateFilter>());
141 } else if (filterName == "recording_with_direction_check") {
142 return std::make_unique<AndSVDStateFilter>(
143 std::make_unique<NonIPCrossingSVDStateFilter>(),
144 std::make_unique<RecordingSVDStateFilter>("SVDStateFilter.root"));
145 } else if (filterName == "mva") {
146 return std::make_unique<MVASVDStateFilter>("ckf_CDCSVDStateFilter_1");
147 } else if (filterName == "mva_with_direction_check") {
148 return std::make_unique<AndSVDStateFilter>(
149 std::make_unique<NonIPCrossingSVDStateFilter>(),
150 std::make_unique<MVASVDStateFilter>("ckf_CDCSVDStateFilter_1"));
151 } else if (filterName == "sloppy_recording") {
152 return std::make_unique<SloppyRecordingSVDStateFilter>("SVDStateFilter.root");
153 } else {
154 return Super::create(filterName);
155 }
156}
virtual std::unique_ptr< BaseSVDStateFilter > 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< BaseSVDStateFilter >.

Definition at line 80 of file SVDStateFilterFactory.cc.

81{
82 return "Reject SVD CKF states. ";
83}

◆ getIdentifier()

std::string getIdentifier ( ) const
overridevirtual

Getter for a short identifier for the factory.

Implements FilterFactory< BaseSVDStateFilter >.

Definition at line 75 of file SVDStateFilterFactory.cc.

76{
77 return "SVDState";
78}

◆ getValidFilterNamesAndDescriptions()

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

Getter for valid filter names and a description for each.

Implements FilterFactory< BaseSVDStateFilter >.

Definition at line 85 of file SVDStateFilterFactory.cc.

86{
87 return {
88 {"none", "no track combination is valid"},
89 {"all", "set all track combinations as good"},
90 {"non_ip_crossing", "all combinations are fine, except for crossing IPs"},
91 {"advance", "extrapolate the states"},
92 {"fit", "update the mSoP using a Kalman Filter"},
93 {"truth", "monte carlo truth"},
94 {"ordering_truth", "monte carlo truth ordering"},
95 {"sloppy_truth", "sloppy monte carlo truth"},
96 {"simple", "simple filter to be used in svd"},
97 {"residual", "residual filter to be used in svd"},
98 {"recording", "record variables to a TTree"},
99 // For details on why the "recording_and_truth" filter option is commented please see the comment below in ::create()
100 // {"recording_and_truth", "record variables to a TTree and store truth information"},
101 {"recording_with_direction_check", "record variables to a TTree with direction check"},
102 {"mva", "MVA filter"},
103 {"mva_with_direction_check", "MVA filter with direction check"},
104 {"sloppy_recording", "record variables to a TTree"},
105 };
106}

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: