Belle II Software  release-05-01-25
MVAFilter.dcl.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/filters/base/FilterOnVarSet.dcl.h>
13 #include <tracking/trackFindingCDC/filters/base/Filter.fwd.h>
14 
15 #include <tracking/trackFindingCDC/varsets/BaseVarSet.h>
16 
17 #include <tracking/trackFindingCDC/numerics/Weight.h>
18 
19 #include <memory>
20 #include <string>
21 #include <cmath>
22 
23 namespace Belle2 {
28  class ModuleParamList;
29 
30  namespace TrackFindingCDC {
31  class MVAExpert;
32 
34  template<class AFilter>
35  class MVA : public OnVarSet<AFilter> {
36 
37  private:
39  using Super = OnVarSet<AFilter>;
40 
41  public:
43  using Object = typename AFilter::Object;
44 
45  private:
48 
49  public:
51  explicit MVA(std::unique_ptr<AVarSet> varSet,
52  const std::string& identifier = "",
53  double defaultCut = NAN);
54 
56  virtual ~MVA();
57 
59  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override;
60 
62  void initialize() override;
63 
65  void beginRun() override;
66 
67  public:
69  Weight operator()(const Object& obj) override;
70 
72  virtual double predict(const Object& obj);
73 
74  private:
76  double m_param_cut;
77 
79  std::string m_param_identifier;
80 
82  std::unique_ptr<MVAExpert> m_mvaExpert;
83  };
84 
86  template<class AVarSet>
87  class MVAFilter: public MVA<Filter<typename AVarSet::Object> > {
88 
89  private:
92 
93  public:
95  using Object = typename AVarSet::Object;
96 
98  explicit MVAFilter(const std::string& defaultTrainingName = "",
99  double defaultCut = NAN);
100 
102  ~MVAFilter();
103  };
104  }
106 }
Belle2::TrackFindingCDC::MVA::operator()
Weight operator()(const Object &obj) override
Function to object for its signalness.
Definition: MVAFilter.icc.h:91
Belle2::TrackFindingCDC::MVAFilter
Convience template to create a mva filter for a set of variables.
Definition: MVAFilter.dcl.h:95
Belle2::TrackFindingCDC::MVA::~MVA
virtual ~MVA()
Default destructor.
Belle2::TrackFindingCDC::MVA::m_mvaExpert
std::unique_ptr< MVAExpert > m_mvaExpert
MVA Expert to examine the object.
Definition: MVAFilter.dcl.h:90
Belle2::TrackFindingCDC::OnVarSet::Object
typename AFilter::Object Object
Type of pbject to be filtered.
Definition: FilterOnVarSet.dcl.h:45
Belle2::TrackFindingCDC::MVA::Super
OnVarSet< AFilter > Super
Type of the super class.
Definition: MVAFilter.dcl.h:47
Belle2::TrackFindingCDC::MVA::initialize
void initialize() override
Initialize the expert before event processing.
Definition: MVAFilter.icc.h:75
Belle2::TrackFindingCDC::ProcessingSignalListener
Interface for an algorithm part that needs to receive the module processing signals.
Definition: ProcessingSignalListener.h:30
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::MVA::exposeParameters
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:60
Belle2::TrackFindingCDC::MVAFilter::MVAFilter
MVAFilter(const std::string &defaultTrainingName="", double defaultCut=NAN)
Constructor of the filter.
Definition: MVAFilter.icc.h:109
Belle2::TrackFindingCDC::MVA
Filter based on a mva method.
Definition: MVAFilter.dcl.h:43
Belle2::TrackFindingCDC::MVA::MVA
MVA(std::unique_ptr< AVarSet > varSet, const std::string &identifier="", double defaultCut=NAN)
Constructor of the filter.
Definition: MVAFilter.icc.h:47
Belle2::TrackFindingCDC::MVAFilter::~MVAFilter
~MVAFilter()
Default destructor.
Belle2::TrackFindingCDC::MVA::predict
virtual double predict(const Object &obj)
Evaluate the mva method.
Definition: MVAFilter.icc.h:98
Belle2::TrackFindingCDC::MVA::m_param_cut
double m_param_cut
The cut on the MVA output.
Definition: MVAFilter.dcl.h:84
Belle2::TrackFindingCDC::MVA::beginRun
void beginRun() override
Signal to load new run parameters.
Definition: MVAFilter.icc.h:84
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFindingCDC::BaseVarSet< Object >
Belle2::TrackFindingCDC::MVAFilter::Object
typename AVarSet::Object Object
Type of the object to be analysed.
Definition: MVAFilter.dcl.h:103
Belle2::TrackFindingCDC::BaseVarSet< Object >::Object
Object Object
Object type from which variables shall be extracted.
Definition: BaseVarSet.h:47
Belle2::TrackFindingCDC::Filter< AVarSet::Object >::Object
AVarSet::Object Object
Type of the object to be analysed.
Definition: Filter.dcl.h:43
Belle2::TrackFindingCDC::MVA::m_param_identifier
std::string m_param_identifier
Database identifier of the expert or weight file name.
Definition: MVAFilter.dcl.h:87