10#include <tracking/trackFindingCDC/filters/base/FilterVarSet.dcl.h>
12#include <framework/core/ModuleParamList.templateDetails.h>
13#include <framework/core/ModuleParam.h>
15#include <RtypesCore.h>
28 namespace TrackFindingCDC {
31 static char const*
const filterVarNames[] = {
37 template<
class AFilter>
40 template<
class AFilter>
43 return filterVarNames[iName];
46 template <
class AFilter>
49 , m_filterName(filterName)
50 , m_filterNamePrefix(filterName +
'_')
55 template <
class AFilter>
57 std::unique_ptr<Filter> ptrFilter)
59 , m_filterName(filterName)
60 , m_filterNamePrefix(filterName +
'_')
61 , m_ptrFilter(
std::move(ptrFilter))
65 template <
class AFilter>
68 bool extracted = Super::extract(obj);
69 if (m_ptrFilter and obj) {
70 Weight weight = (*m_ptrFilter)(*obj);
71 this->
template var<named(
"weight")>() = weight;
72 this->
template var<named(
"accept")>() = not std::isnan(weight) and not(weight < m_cut);
73 this->
template var<named(
"positive")>() = weight > 0 and not(weight < m_cut);
82 template <
class AFilter>
86 const std::string prefix =
"";
87 m_ptrFilter->exposeParameters(&moduleParamList, prefix);
91 if (std::count(paramNames.begin(), paramNames.end(),
"cut")) {
97 this->addProcessingSignalListener(m_ptrFilter.get());
101 template <
class AFilter>
104 return Super::getNamedVariables(prefix + m_filterNamePrefix);
107 template <
class AFilter>
110 if (varName.find(m_filterNamePrefix) == 0) {
111 std::string varNameWithoutPrefix = varName.substr(m_filterNamePrefix.size());
112 MayBePtr<Float_t> found = Super::find(varNameWithoutPrefix);
113 if (found)
return found;
The Module parameter list class.
std::vector< std::string > getParameterNames() const
Returns the names of all parameters in this parameter list.
A single parameter of the module.
std::vector< Named< Float_t * > > getNamedVariables()
Getter for the named references to the individual variables.
FilterVarSet(const std::string &filterName="")
Construct the varset making an instance of the template filter.
void initialize() final
Initialize the filter before event processing.
bool extract(const Object *obj) final
Generate filter weight variable from the object.
typename Filter::Object Object
Type of the object from which the filter judgement should be extracted.
AFilter Filter
Type of the filter.
MayBePtr< Float_t > find(const std::string &varName) override
Pointer to the variable with the given name.
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
T & getValue()
Returns the value of the parameter.
void setDefaultValue(const T &defaultValue)
Sets the default value of a parameter.
Abstract base class for different kinds of events.
static const size_t nVars
Number of variables to be generated.
static constexpr char const * getName(int iName)
Getter for the name at the given index.