Belle II Software development
MVAFilter.dcl.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/trackFindingCDC/filters/base/FilterOnVarSet.dcl.h>
11#include <tracking/trackFindingCDC/filters/base/Filter.fwd.h>
12
13#include <tracking/trackFindingCDC/varsets/BaseVarSet.h>
14
15#include <tracking/trackFindingCDC/numerics/Weight.h>
16
17#include <framework/database/DBObjPtr.h>
18#include <tracking/dbobjects/TrackingMVAFilterParameters.h>
19
20#include <memory>
21#include <string>
22#include <cmath>
23
24namespace Belle2 {
29 class ModuleParamList;
30
31 namespace TrackFindingCDC {
32 class MVAExpert;
33
35 template<class AFilter>
36 class MVA : public OnVarSet<AFilter> {
37
38 private:
41
42 public:
44 using Object = typename AFilter::Object;
45
46 private:
49
50 public:
52 explicit MVA(std::unique_ptr<AVarSet> varSet,
53 const std::string& identifier = "",
54 double defaultCut = NAN,
55 const std::string& dbObjectName = "");
56
58 virtual ~MVA();
59
61 void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override;
62
64 void initialize() override;
65
67 void beginRun() override;
68
69 public:
71 Weight operator()(const Object& obj) override;
72
74 virtual double predict(const Object& obj);
75
77 std::vector<float> predict(const std::vector<Object*>& objs);
78
80 virtual std::vector<float> operator()(const std::vector <Object*>& objs) override;
81 private:
83 std::string m_identifier = "";
84
86 double m_cutValue;
87
89 std::string m_DBPayloadName = "";
90
92 std::unique_ptr<MVAExpert> m_mvaExpert;
93
95 std::vector<Named<Float_t*>> m_namedVariables;
96 };
97
99 template<class AVarSet>
100 class MVAFilter: public MVA<Filter<typename AVarSet::Object> > {
101
102 private:
105
106 public:
108 using Object = typename AVarSet::Object;
109
111 explicit MVAFilter(const std::string& defaultTrainingName = "",
112 double defaultCut = NAN,
113 const std::string& defaultDBObjectName = "");
114
117 };
118 }
120}
The Module parameter list class.
Generic class that generates some named float values from a given object.
Definition BaseVarSet.h:34
Class to interact with the MVA package.
Definition MVAExpert.h:26
typename AVarSet::Object Object
Type of the object to be analysed.
MVA< Filter< typename AVarSet::Object > > Super
Type of the super class.
~MVAFilter()
Default destructor.
MVAFilter(const std::string &defaultTrainingName="", double defaultCut=NAN, const std::string &defaultDBObjectName="")
Constructor of the filter.
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.
virtual std::vector< float > operator()(const std::vector< Object * > &objs) override
Evaluate the MVA method over a vector of objects.
std::vector< float > predict(const std::vector< Object * > &objs)
Evaluate the MVA method over several inputs simultaneously.
void beginRun() override
Signal to load new run parameters.
MVA(std::unique_ptr< AVarSet > varSet, const std::string &identifier="", double defaultCut=NAN, const std::string &dbObjectName="")
Constructor of the filter.
typename BaseAxialSegmentPairFilter::Object Object
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.
OnVarSet(std::unique_ptr< AVarSet > varSet)
Constructor from the variable set the filter should use.
Abstract base class for different kinds of events.