10#include <tracking/trackFindingCDC/filters/base/FilterOnVarSet.dcl.h>
12#include <tracking/trackFindingCDC/utilities/Named.h>
14#include <framework/logging/Logger.h>
16#include <RtypesCore.h>
29 namespace TrackFindingCDC {
31 template <
class AFilter>
33 : m_varSet(
std::move(varSet))
35 B2ASSERT(
"Varset initialised as nullptr",
m_varSet);
38 template <
class AFilter>
41 template <
class AFilter>
44 this->addProcessingSignalListener(m_varSet.get());
48 template <
class AFilter>
51 bool result = Super::needsTruthInformation();
52 if (result)
return true;
54 const std::vector<Named<Float_t*>>& namedVariables = m_varSet->getNamedVariables();
56 std::string name = namedVariable.getName();
58 if (name.find(
"truth") != std::string::npos) {
65 template <
class AFilter>
68 Weight weight = Super::operator()(obj);
69 if (std::isnan(weight))
return NAN;
70 bool extracted = m_varSet->extract(&obj);
71 return extracted ? weight : NAN;
74 template <
class AFilter>
76 return std::move(m_varSet);
79 template <
class AFilter>
85 template <
class AFilter>
88 m_varSet = std::move(varSet);
91 template <
class AVarSet>
97 template <
class AVarSet>
~FilterOnVarSet()
Default destructor.
FilterOnVarSet()
Constructor of the filter.
A mixin class to attach a name to an object.
Filter adapter to make a filter work on a set of variables.
void initialize() override
No reassignment of variable set possible for now.
bool needsTruthInformation() override
Checks if any variables need Monte Carlo information.
Weight operator()(const Object &obj) override
Function extracting the variables of the object into the variable set.
std::unique_ptr< AVarSet > m_varSet
Instance of the variable set to be used in the filter.
std::unique_ptr< AVarSet > releaseVarSet() &&
Steal the set of variables form this filter - filter becomes dysfunctional afterwards.
AVarSet & getVarSet() const
Getter for the set of variables.
typename AFilter::Object Object
Type of pbject to be filtered.
void setVarSet(std::unique_ptr< AVarSet > varSet)
Setter for the set of variables.
OnVarSet(std::unique_ptr< AVarSet > varSet)
Constructor from the variable set the filter should use.
~OnVarSet()
Default destructor.
Abstract base class for different kinds of events.