Belle II Software  release-06-01-15
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 <memory>
18 #include <string>
19 #include <cmath>
20 
21 namespace Belle2 {
26  class ModuleParamList;
27 
28  namespace TrackFindingCDC {
29  class MVAExpert;
30 
32  template<class AFilter>
33  class MVA : public OnVarSet<AFilter> {
34 
35  private:
38 
39  public:
41  using Object = typename AFilter::Object;
42 
43  private:
46 
47  public:
49  explicit MVA(std::unique_ptr<AVarSet> varSet,
50  const std::string& identifier = "",
51  double defaultCut = NAN);
52 
54  virtual ~MVA();
55 
57  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override;
58 
60  void initialize() override;
61 
63  void beginRun() override;
64 
65  public:
67  Weight operator()(const Object& obj) override;
68 
70  virtual double predict(const Object& obj);
71 
72  private:
74  double m_param_cut;
75 
77  std::string m_param_identifier;
78 
80  std::unique_ptr<MVAExpert> m_mvaExpert;
81  };
82 
84  template<class AVarSet>
85  class MVAFilter: public MVA<Filter<typename AVarSet::Object> > {
86 
87  private:
90 
91  public:
93  using Object = typename AVarSet::Object;
94 
96  explicit MVAFilter(const std::string& defaultTrainingName = "",
97  double defaultCut = NAN);
98 
101  };
102  }
104 }
The Module parameter list class.
Generic class that generates some named float values from a given object.
Definition: BaseVarSet.h:33
AObject Object
Object type from which variables shall be extracted.
Definition: BaseVarSet.h:37
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:33
Convience template to create a mva filter for a set of variables.
Definition: MVAFilter.dcl.h:85
MVAFilter(const std::string &defaultTrainingName="", double defaultCut=NAN)
Constructor of the filter.
Definition: MVAFilter.icc.h:99
~MVAFilter()
Default destructor.
Filter based on a mva method.
Definition: MVAFilter.dcl.h:33
virtual ~MVA()
Default destructor.
void initialize() override
Initialize the expert before event processing.
Definition: MVAFilter.icc.h:65
std::string m_param_identifier
Database identifier of the expert or weight file name.
Definition: MVAFilter.dcl.h:77
Weight operator()(const Object &obj) override
Function to object for its signalness.
Definition: MVAFilter.icc.h:81
std::unique_ptr< MVAExpert > m_mvaExpert
MVA Expert to examine the object.
Definition: MVAFilter.dcl.h:80
void beginRun() override
Signal to load new run parameters.
Definition: MVAFilter.icc.h:74
MVA(std::unique_ptr< AVarSet > varSet, const std::string &identifier="", double defaultCut=NAN)
Constructor of the filter.
Definition: MVAFilter.icc.h:37
virtual double predict(const Object &obj)
Evaluate the mva method.
Definition: MVAFilter.icc.h:88
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:50
double m_param_cut
The cut on the MVA output.
Definition: MVAFilter.dcl.h:74
Filter adapter to make a filter work on a set of variables.
AFilter Super
Type of the base class.
typename AFilter::Object Object
Type of pbject to be filtered.
Abstract base class for different kinds of events.