Belle II Software  release-08-01-10
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 
24 namespace 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 
76  private:
78  std::string m_identifier = "";
79 
81  double m_cutValue;
82 
84  std::string m_DBPayloadName = "";
85 
87  std::unique_ptr<MVAExpert> m_mvaExpert;
88  };
89 
91  template<class AVarSet>
92  class MVAFilter: public MVA<Filter<typename AVarSet::Object> > {
93 
94  private:
97 
98  public:
100  using Object = typename AVarSet::Object;
101 
103  explicit MVAFilter(const std::string& defaultTrainingName = "",
104  double defaultCut = NAN,
105  const std::string& defaultDBObjectName = "");
106 
109  };
110  }
112 }
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:92
~MVAFilter()
Default destructor.
MVAFilter(const std::string &defaultTrainingName="", double defaultCut=NAN, const std::string &defaultDBObjectName="")
Constructor of the filter.
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.
Definition: MVAFilter.icc.h:97
std::unique_ptr< MVAExpert > m_mvaExpert
MVA Expert to examine the object.
Definition: MVAFilter.dcl.h:87
std::string m_DBPayloadName
Name of the DB payload.
Definition: MVAFilter.dcl.h:84
void beginRun() override
Signal to load new run parameters.
Definition: MVAFilter.icc.h:90
MVA(std::unique_ptr< AVarSet > varSet, const std::string &identifier="", double defaultCut=NAN, const std::string &dbObjectName="")
Constructor of the filter.
Definition: MVAFilter.icc.h:37
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:81
std::string m_identifier
Database identifier of the expert or weight file name.
Definition: MVAFilter.dcl.h:78
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.