10#include <tracking/trackFindingCDC/filters/base/ChooseableFilter.dcl.h>
12#include <tracking/trackFindingCDC/filters/base/FilterFactory.icc.h>
14#include <framework/core/ModuleParamList.templateDetails.h>
16#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
26 namespace TrackFindingCDC {
28 template <
class AFilter>
30 : m_param_filterName(filterFactory ? filterFactory->getDefaultFilterName() :
"")
31 , m_param_filterParameters()
32 , m_filterFactory(
std::move(filterFactory))
34 B2ASSERT(
"Constructing a chooseable filter with no factory",
m_filterFactory);
37 template <
class AFilter>
39 const std::string& filterName)
40 : m_param_filterName(filterName)
41 , m_param_filterParameters()
42 , m_filterFactory(
std::move(filterFactory))
47 template <
class AFilter>
50 Super::exposeParameters(moduleParamList, prefix);
51 if (m_param_filterName ==
"") {
53 moduleParamList->
addParameter(prefixed(prefix,
"filter"),
55 m_filterFactory->createFiltersNameDescription());
58 moduleParamList->
addParameter(prefixed(prefix,
"filter"),
60 m_filterFactory->createFiltersNameDescription(),
64 m_param_filterParameters.addParameter(moduleParamList,
65 prefixed(prefix,
"filterParameters"),
66 m_filterFactory->createFiltersParametersDescription());
69 template <
class AFilter>
72 m_filter = m_filterFactory->create(m_param_filterName);
74 B2ERROR(
"Could not create filter with name " << m_param_filterName);
80 const std::string prefix =
"";
81 m_filter->exposeParameters(&filterModuleParamList, prefix);
82 m_param_filterParameters.assignTo(&filterModuleParamList);
83 this->addProcessingSignalListener(m_filter.get());
87 template <
class AFilter>
90 return m_filter->needsTruthInformation();
93 template <
class AFilter>
96 return (*m_filter)(object);
99 template <
class AFilter>
102 return (*m_filter)(object);
105 template <
class AFilter>
108 return (*m_filter)(objs);
111 template <
class AFilterFactory>
113 :
Super(
std::make_unique<AFilterFactory>())
117 template <
class AFilterFactory>
119 :
Super(
std::make_unique<AFilterFactory>(), filterName)
The Module parameter list class.
ChooseableFilter()
Constructor of the chooseable filter.
Filter can delegate to a filter chosen and set up at run time by parameters.
Chooseable(std::unique_ptr< FilterFactory< AFilter > > filterFactory)
Setup the chooseable filter with available choices from the factory.
void initialize() override
Initialize before event processing.
std::unique_ptr< FilterFactory< AFilter > > m_filterFactory
Filter factor to construct a chosen filter.
bool needsTruthInformation() override
Indicates if the filter requires Monte Carlo information.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.
typename AFilter::Object Object
Type of the object to be analysed.
Weight operator()(const Object &object) final
Function to evaluate the object.
Factory that can create appropriate filter instances from a name.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.