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.
Object Object
Object type from which variables shall be extracted.
Definition: BaseVarSet.h:37
Convenience template to create a mva filter for a set of variables.
typename AVarSet::Object Object
Type of the object to be analysed.
~MVAFilter()
Default destructor.
Filter based on a mva method.
Definition: MVAFilter.dcl.h:36
virtual ~MVA()
Default destructor.
void initialize() override
Initialize the expert before event processing.
Definition: MVAFilter.icc.h:69
Weight operator()(const Object &obj) override
Function to object for its signalness.
std::unique_ptr< MVAExpert > m_mvaExpert
MVA Expert to examine the object.
Definition: MVAFilter.dcl.h:92
std::string m_DBPayloadName
Name of the DB payload.
Definition: MVAFilter.dcl.h:89
void beginRun() override
Signal to load new run parameters.
Definition: MVAFilter.icc.h:90
typename AFilter::Object Object
Type of the object to be analysed.
Definition: MVAFilter.dcl.h:44
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.
Definition: MVAFilter.icc.h:49
double m_cutValue
The cut on the MVA output.
Definition: MVAFilter.dcl.h:86
std::vector< Named< Float_t * > > m_namedVariables
named variables, ordered as in the weightFile:
Definition: MVAFilter.dcl.h:95
std::string m_identifier
Database identifier of the expert or weight file name.
Definition: MVAFilter.dcl.h:83
Filter adapter to make a filter work on a set of variables.
Abstract base class for different kinds of events.