Belle II Software development
ChooseableFilter< AFilterFactory > Class Template Reference

Convenvience wrapper to setup a Chooseable filter from a specific factory object. More...

#include <ChooseableFilter.dcl.h>

Inheritance diagram for ChooseableFilter< AFilterFactory >:
Chooseable< AFilterFactory::CreatedFilter >

Public Types

using Object = typename AFilter::Object
 Type of the object to be analysed.
 

Public Member Functions

 ChooseableFilter ()
 Constructor of the chooseable filter.
 
 ChooseableFilter (const std::string &filterName)
 Constructor of the chooseable filter taking the default filter name.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) final
 Expose the set of parameters of the filter to the module parameter list.
 
void initialize () override
 Initialize before event processing.
 
bool needsTruthInformation () override
 Indicates if the filter requires Monte Carlo information.
 
Weight operator() (const Object &object) final
 Function to evaluate the object.
 
Weight operator() (const Object &object) const
 Const version of operator.
 
virtual std::vector< float > operator() (const std::vector< Object * > &objs) override
 Evaluate the MVA method over a vector of objects. Returns float weight or NAN (when object is rejected) for each object.
 
std::string getFilterName () const
 Return name of the selected filter.
 

Private Types

using Super = Chooseable< typename AFilterFactory::CreatedFilter >
 Type of the super class.
 

Private Attributes

std::string m_param_filterName
 Parameters : Name of the selected filter.
 
FilterParamMap m_param_filterParameters
 Parameter: Parameter keys and values to be forwarded to the chosen filter.
 
std::unique_ptr< FilterFactory< AFilterFactory::CreatedFilter > > m_filterFactory
 Filter factor to construct a chosen filter.
 
std::unique_ptr< AFilterFactory::CreatedFilter > m_filter
 Chosen filter.
 

Detailed Description

template<class AFilterFactory>
class Belle2::TrackFindingCDC::ChooseableFilter< AFilterFactory >

Convenvience wrapper to setup a Chooseable filter from a specific factory object.

Definition at line 103 of file ChooseableFilter.dcl.h.

Member Typedef Documentation

◆ Object

using Object = typename AFilter::Object
inherited

Type of the object to be analysed.

Definition at line 40 of file ChooseableFilter.dcl.h.

◆ Super

using Super = Chooseable<typename AFilterFactory::CreatedFilter>
private

Type of the super class.

Definition at line 108 of file ChooseableFilter.dcl.h.

Constructor & Destructor Documentation

◆ ChooseableFilter() [1/2]

Constructor of the chooseable filter.

Definition at line 112 of file ChooseableFilter.icc.h.

113 : Super(std::make_unique<AFilterFactory>())
114 {
115 }
Chooseable< typename AFilterFactory::CreatedFilter > Super
Type of the super class.

◆ ChooseableFilter() [2/2]

ChooseableFilter ( const std::string &  filterName)
explicit

Constructor of the chooseable filter taking the default filter name.

Definition at line 118 of file ChooseableFilter.icc.h.

119 : Super(std::make_unique<AFilterFactory>(), filterName)
120 {
121 }

Member Function Documentation

◆ exposeParameters()

void exposeParameters ( ModuleParamList moduleParamList,
const std::string &  prefix 
)
finalinherited

Expose the set of parameters of the filter to the module parameter list.

Make a force parameter in case no default was given

Make a normal parameter in case default is known

Definition at line 51 of file ChooseableFilter.icc.h.

49 {
50 Super::exposeParameters(moduleParamList, prefix);
51 if (m_param_filterName == "") {
53 moduleParamList->addParameter(prefixed(prefix, "filter"),
54 m_param_filterName,
55 m_filterFactory->createFiltersNameDescription());
56 } else {
58 moduleParamList->addParameter(prefixed(prefix, "filter"),
59 m_param_filterName,
60 m_filterFactory->createFiltersNameDescription(),
61 m_param_filterName);
62 }
63
65 prefixed(prefix, "filterParameters"),
66 m_filterFactory->createFiltersParametersDescription());
67 }
std::unique_ptr< FilterFactory< AFilterFactory::CreatedFilter > > m_filterFactory
Filter factor to construct a chosen filter.
FilterParamMap m_param_filterParameters
Parameter: Parameter keys and values to be forwarded to the chosen filter.
void addParameter(ModuleParamList *moduleParamList, const std::string &name, const std::string &description)
Create one parameter in the parameter list for the module with the given name and description.

◆ getFilterName()

std::string getFilterName ( ) const
inlineinherited

Return name of the selected filter.

Definition at line 77 of file ChooseableFilter.dcl.h.

78 {
79 return m_param_filterName;
80 }
std::string m_param_filterName
Parameters : Name of the selected filter.

◆ initialize()

void initialize
overrideinherited

Initialize before event processing.

Transfer parameters

Definition at line 54 of file ChooseableFilter.icc.h.

71 {
72 m_filter = m_filterFactory->create(m_param_filterName);
73 if (not m_filter) {
74 B2ERROR("Could not create filter with name " << m_param_filterName);
75 return;
76 }
77
79 ModuleParamList filterModuleParamList;
80 const std::string prefix = "";
81 m_filter->exposeParameters(&filterModuleParamList, prefix);
82 m_param_filterParameters.assignTo(&filterModuleParamList);
83 this->addProcessingSignalListener(m_filter.get());
84 Super::initialize();
85 }
std::unique_ptr< AFilterFactory::CreatedFilter > m_filter
Chosen filter.
void assignTo(ModuleParamList *filterModuleParamList)
Unpack the map of parameters and forward them to the concrete filter.

◆ needsTruthInformation()

bool needsTruthInformation
overrideinherited

Indicates if the filter requires Monte Carlo information.

Definition at line 57 of file ChooseableFilter.icc.h.

89 {
90 return m_filter->needsTruthInformation();
91 }

◆ operator()() [1/3]

Weight operator() ( const Object object) const
inherited

Const version of operator.

Definition at line 70 of file ChooseableFilter.icc.h.

101 {
102 return (*m_filter)(object);
103 }

◆ operator()() [2/3]

Weight operator() ( const Object object)
finalinherited

Function to evaluate the object.

Delegates to the filter chosen by module parameters.

Parameters
objectThe object to be accepted or rejected.
Returns
A finit float value if the object is accepted. NAN if the object is rejected.

Definition at line 67 of file ChooseableFilter.icc.h.

95 {
96 return (*m_filter)(object);
97 }

◆ operator()() [3/3]

std::vector< float > operator() ( const std::vector< Object * > &  objs)
overridevirtualinherited

Evaluate the MVA method over a vector of objects. Returns float weight or NAN (when object is rejected) for each object.

Definition at line 73 of file ChooseableFilter.icc.h.

107 {
108 return (*m_filter)(objs);
109 }

Member Data Documentation

◆ m_filter

std::unique_ptr<AFilterFactory::CreatedFilter > m_filter
privateinherited

Chosen filter.

Definition at line 94 of file ChooseableFilter.dcl.h.

◆ m_filterFactory

std::unique_ptr<FilterFactory<AFilterFactory::CreatedFilter > > m_filterFactory
privateinherited

Filter factor to construct a chosen filter.

Definition at line 91 of file ChooseableFilter.dcl.h.

◆ m_param_filterName

std::string m_param_filterName
privateinherited

Parameters : Name of the selected filter.

Definition at line 84 of file ChooseableFilter.dcl.h.

◆ m_param_filterParameters

FilterParamMap m_param_filterParameters
privateinherited

Parameter: Parameter keys and values to be forwarded to the chosen filter.

Definition at line 87 of file ChooseableFilter.dcl.h.


The documentation for this class was generated from the following files: