Belle II Software development
SegmentTrackFilterFactory Class Reference

Factory that can create appropriate segment to track combinations filters from associated names. More...

#include <SegmentTrackFilterFactory.h>

Inheritance diagram for SegmentTrackFilterFactory:
FilterFactory< BaseSegmentTrackFilter >

Public Types

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

Public Member Functions

 SegmentTrackFilterFactory (const std::string &defaultFilterName="mva")
 Constructor forwarding the default filter name.
 
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< BaseSegmentTrackFiltercreate (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 = FilterFactory< BaseSegmentTrackFilter >
 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 segment to track combinations filters from associated names.

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

Constructor & Destructor Documentation

◆ SegmentTrackFilterFactory()

SegmentTrackFilterFactory ( const std::string &  defaultFilterName = "mva")
explicit

Constructor forwarding the default filter name.

Definition at line 38 of file SegmentTrackFilterFactory.cc.

39 : Super(defaultFilterName)
40{
41}
FilterFactory< BaseSegmentTrackFilter > Super
Type of the base class.

Member Function Documentation

◆ create()

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

Create a filter with the given name.

Reimplemented from FilterFactory< BaseSegmentTrackFilter >.

Definition at line 55 of file SegmentTrackFilterFactory.cc.

56{
57 if (filterName == "none") {
58 return std::make_unique<NoneSegmentTrackFilter>();
59 } else if (filterName == "truth") {
60 return std::make_unique<MCSegmentTrackFilter>();
61 } else if (filterName == "mva") {
62 return std::make_unique<MVASegmentTrackFilter>("trackfindingcdc_SegmentTrackFilter", 0.74);
63 } else if (filterName == "eval") {
64 auto recordedVarSets = std::make_unique<UnionVarSet<BaseSegmentTrackFilter::Object>>();
65 using TrackFilterVarSet = FilterVarSet<BaseSegmentTrackFilter>;
66 recordedVarSets->push_back(std::make_unique<TrackFilterVarSet>("mva", create("mva")));
67 recordedVarSets->push_back(std::make_unique<TrackFilterVarSet>("truth", create("truth")));
68 return std::make_unique<Recording<BaseSegmentTrackFilter>>(std::move(recordedVarSets), "SegmentTrackFilter_eval.root");
69 } else if (filterName == "recording") {
70 return std::make_unique<RecordingSegmentTrackFilter>("SegmentTrackFilter.root");
71 } else {
72 return Super::create(filterName);
73 }
74}
virtual std::unique_ptr< BaseSegmentTrackFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.
Class to compute floating point variables from a filter response which can be recorded as a flat TNtu...
std::unique_ptr< BaseSegmentTrackFilter > create(const std::string &filterName) const override
Create a filter with the given name.

◆ 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< BaseSegmentTrackFilter >.

Definition at line 76 of file SegmentTrackFilterFactory.cc.

77{
78 return "Segment track chooser to be used during the combination of segment track pairs";
79}

◆ getIdentifier()

std::string getIdentifier ( ) const
overridevirtual

Getter for a short identifier for the factory.

Implements FilterFactory< BaseSegmentTrackFilter >.

Definition at line 81 of file SegmentTrackFilterFactory.cc.

82{
83 return "SegmentTrackFilter";
84}

◆ getValidFilterNamesAndDescriptions()

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

Getter for valid filter names and a description for each.

Implements FilterFactory< BaseSegmentTrackFilter >.

Definition at line 44 of file SegmentTrackFilterFactory.cc.

45{
46 return {
47 {"none", "no segment track combination is valid"},
48 {"truth", "monte carlo truth"},
49 {"mva", "test with a mva method"},
50 {"recording", "record variables to a TTree"},
51 };
52}

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: