Belle II Software  release-05-01-25
Reweighter.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Keck *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 #ifndef INCLUDE_GUARD_BELLE2_MVA_REWEIGHTER_HEADER
13 #define INCLUDE_GUARD_BELLE2_MVA_REWEIGHTER_HEADER
14 
15 #include <mva/interface/Options.h>
16 #include <mva/interface/Teacher.h>
17 #include <mva/interface/Expert.h>
18 
19 
20 namespace Belle2 {
25  namespace MVA {
26 
31 
32  public:
37  virtual void load(const boost::property_tree::ptree& pt) override;
38 
43  virtual void save(boost::property_tree::ptree& pt) const override;
44 
48  virtual po::options_description getDescription() override;
49 
53  virtual std::string getMethod() const override { return "Reweighter"; }
54 
55  std::string m_weightfile;
56  std::string m_variable;
58  };
59 
63  class ReweighterTeacher : public Teacher {
64 
65  public:
71  ReweighterTeacher(const GeneralOptions& general_options, const ReweighterOptions& specific_options);
72 
77  virtual Weightfile train(Dataset& training_data) const override;
78 
79  private:
81  };
82 
86  class ReweighterExpert : public MVA::Expert {
87 
88  public:
93  virtual void load(Weightfile& weightfile) override;
94 
99  virtual std::vector<float> apply(Dataset& test_data) const override;
100 
101  private:
104  std::unique_ptr<Expert> m_expert;
105  double m_norm = 0.0;
106  };
107 
108 
109  }
111 }
112 
113 #endif
Belle2::MVA::ReweighterOptions
Options for the Reweighter MVA method.
Definition: Reweighter.h:30
Belle2::MVA::Dataset
Abstract base class of all Datasets given to the MVA interface The current event can always be access...
Definition: Dataset.h:34
Belle2::MVA::ReweighterOptions::load
virtual void load(const boost::property_tree::ptree &pt) override
Load mechanism to load Options from a xml tree.
Definition: Reweighter.cc:30
Belle2::MVA::ReweighterOptions::m_variable
std::string m_variable
Variable which decides if the reweighter is applied or not.
Definition: Reweighter.h:56
Belle2::MVA::Weightfile
The Weightfile class serializes all information about a training into an xml tree.
Definition: Weightfile.h:40
Belle2::MVA::ReweighterTeacher
Teacher for the Reweighter MVA method.
Definition: Reweighter.h:63
Belle2::MVA::ReweighterTeacher::train
virtual Weightfile train(Dataset &training_data) const override
Train a mva method using the given dataset returning a Weightfile.
Definition: Reweighter.cc:66
Belle2::MVA::ReweighterOptions::m_weightfile
std::string m_weightfile
Weightfile of the reweighting expert.
Definition: Reweighter.h:55
Belle2::MVA::ReweighterExpert
Expert for the Reweighter MVA method.
Definition: Reweighter.h:86
Belle2::MVA::SpecificOptions
Specific Options, all mehtod Options have to inherit from this class.
Definition: Options.h:99
Belle2::MVA::ReweighterOptions::getMethod
virtual std::string getMethod() const override
Return method name.
Definition: Reweighter.h:53
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MVA::Teacher
Abstract base class of all Teachers Each MVA library has its own implementation of this class,...
Definition: Teacher.h:31
Belle2::MVA::ReweighterOptions::save
virtual void save(boost::property_tree::ptree &pt) const override
Save mechanism to store Options in a xml tree.
Definition: Reweighter.cc:43
Belle2::MVA::ReweighterExpert::load
virtual void load(Weightfile &weightfile) override
Load the expert from a Weightfile.
Definition: Reweighter.cc:164
Belle2::MVA::ReweighterExpert::m_norm
double m_norm
Norm for the weights.
Definition: Reweighter.h:105
Belle2::MVA::Expert
Abstract base class of all Expert Each MVA library has its own implementation of this class,...
Definition: Expert.h:33
Belle2::MVA::GeneralOptions
General options which are shared by all MVA trainings.
Definition: Options.h:64
Belle2::MVA::ReweighterExpert::m_expert_options
GeneralOptions m_expert_options
Method general options of the expert.
Definition: Reweighter.h:103
Belle2::MVA::ReweighterExpert::m_specific_options
ReweighterOptions m_specific_options
Method specific options.
Definition: Reweighter.h:102
Belle2::MVA::ReweighterExpert::apply
virtual std::vector< float > apply(Dataset &test_data) const override
Apply this expert onto a dataset.
Definition: Reweighter.cc:186
Belle2::MVA::ReweighterExpert::m_expert
std::unique_ptr< Expert > m_expert
Experts used to reweight.
Definition: Reweighter.h:104
Belle2::MVA::ReweighterOptions::getDescription
virtual po::options_description getDescription() override
Returns a program options description for all available options.
Definition: Reweighter.cc:50
Belle2::MVA::ReweighterTeacher::m_specific_options
ReweighterOptions m_specific_options
Method specific options.
Definition: Reweighter.h:80
Belle2::MVA::ReweighterTeacher::ReweighterTeacher
ReweighterTeacher(const GeneralOptions &general_options, const ReweighterOptions &specific_options)
Constructs a new teacher using the GeneralOptions and specific options of this training.
Definition: Reweighter.cc:62