10 #include <tracking/trackFindingCDC/filters/base/MVAFilter.dcl.h>
12 #include <tracking/trackFindingCDC/mva/MVAExpert.h>
14 #include <tracking/trackFindingCDC/filters/base/FilterOnVarSet.icc.h>
16 #include <framework/core/ModuleParamList.templateDetails.h>
17 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
19 #include <tracking/trackFindingCDC/utilities/Named.h>
21 #include <RtypesCore.h>
34 namespace TrackFindingCDC {
36 template <
class AFilter>
38 const std::string& identifier,
40 :
Super(std::move(varSet))
41 , m_param_cut(defaultCut)
42 , m_param_identifier(identifier)
46 template <
class AFilter>
49 template <
class AFilter>
52 Super::exposeParameters(moduleParamList, prefix);
55 "The cut value of the mva output below which the object is rejected",
58 moduleParamList->
addParameter(prefixed(prefix,
"identifier"),
60 "Database identfier of the expert of weight file name",
64 template <
class AFilter>
68 std::vector<Named<Float_t*>> namedVariables = Super::getVarSet().getNamedVariables();
69 m_mvaExpert = std::make_unique<MVAExpert>(m_param_identifier, std::move(namedVariables));
70 m_mvaExpert->initialize();
73 template <
class AFilter>
77 m_mvaExpert->beginRun();
80 template <
class AFilter>
83 double prediction = predict(obj);
84 return prediction < m_param_cut ? NAN : prediction;
87 template <
class AFilter>
90 Weight extracted = Super::operator()(obj);
91 if (std::isnan(extracted)) {
94 return m_mvaExpert->predict();
98 template <
class AVarSet>
101 :
Super(std::make_unique<
AVarSet>(), defaultTrainingName, defaultCut)
105 template <
class AVarSet>
The Module parameter list class.
Generic class that generates some named float values from a given object.
MVAFilter(const std::string &defaultTrainingName="", double defaultCut=NAN)
Constructor of the filter.
~MVAFilter()
Default destructor.
Filter based on a mva method.
virtual ~MVA()
Default destructor.
void initialize() override
Initialize the expert before event processing.
Weight operator()(const Object &obj) override
Function to object for its signalness.
void beginRun() override
Signal to load new run parameters.
MVA(std::unique_ptr< AVarSet > varSet, const std::string &identifier="", double defaultCut=NAN)
Constructor of the filter.
virtual double predict(const Object &obj)
Evaluate the mva method.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the set of parameters of the filter to the module parameter list.
AFilter Super
Type of the base class.
typename AFilter::Object Object
Type of pbject to be filtered.
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.