Belle II Software  release-05-02-19
MVAMultipleExpertsModule.h
1 /* BASF2 (Belle Analysis Framework 2) *
2  * Copyright(C) 2016 - Belle II Collaboration *
3  * *
4  * Author: The Belle II Collaboration *
5  * Contributors: Thomas Keck and Fernando Abudinen *
6  * *
7  * This software is provided "as is" without any warranty. *
8  **************************************************************************/
9 
10 #pragma once
11 
12 #include <framework/core/Module.h>
13 
14 #include <mva/dataobjects/DatabaseRepresentationOfWeightfile.h>
15 #include <mva/interface/Weightfile.h>
16 #include <mva/interface/Expert.h>
17 
18 #include <framework/database/DBObjPtr.h>
19 
20 #include <analysis/VariableManager/Manager.h>
21 
22 #include <vector>
23 #include <string>
24 #include <memory>
25 
26 namespace Belle2 {
32  class Particle;
33 
42  public:
43 
48 
52  virtual void initialize() override;
53 
57  virtual void beginRun() override;
58 
62  virtual void event() override;
63 
67  virtual void terminate() override
68  {
69  for (unsigned int i = 0; i < m_identifiers.size(); ++i) {
70  m_experts[i].reset();
71  m_datasets[i].reset();
72  }
73  }
74 
75  private:
79  std::vector<float> analyse(Particle*);
80 
85  void init_mva(MVA::Weightfile& weightfile, unsigned int i);
86 
87 
88  private:
89 
90  std::vector<std::string> m_listNames;
91  std::vector<std::string> m_identifiers;
92  std::vector<std::string>
96  std::vector<std::vector<const Variable::Manager::Var*>>
99 // std::vector<const Variable::Manager::Var*> m_feature_variables;
100 
101  std::map<const Variable::Manager::Var*, float>
104  std::vector<std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>>
107  std::vector<std::unique_ptr<MVA::Expert>> m_experts;
109  std::vector<std::unique_ptr<MVA::SingleDataset>> m_datasets;
110  };
111 
113 } // Belle2 namespace
114 
Belle2::MVAMultipleExpertsModule::init_mva
void init_mva(MVA::Weightfile &weightfile, unsigned int i)
Initialize mva expert, dataset and features Called everytime the weightfile in the database changes i...
Definition: MVAMultipleExpertsModule.cc:115
Belle2::MVAMultipleExpertsModule::m_datasets
std::vector< std::unique_ptr< MVA::SingleDataset > > m_datasets
Vector of pointers to the current input datasets.
Definition: MVAMultipleExpertsModule.h:109
Belle2::MVAMultipleExpertsModule::m_experts
std::vector< std::unique_ptr< MVA::Expert > > m_experts
Vector of pointers to the current MVA Experts.
Definition: MVAMultipleExpertsModule.h:107
Belle2::MVAMultipleExpertsModule::m_signal_fraction_override
double m_signal_fraction_override
Signal Fraction which should be used.
Definition: MVAMultipleExpertsModule.h:94
Belle2::MVA::Weightfile
The Weightfile class serializes all information about a training into an xml tree.
Definition: Weightfile.h:40
Belle2::MVAMultipleExpertsModule::initialize
virtual void initialize() override
Initialize the module.
Definition: MVAMultipleExpertsModule.cc:59
Belle2::MVAMultipleExpertsModule::MVAMultipleExpertsModule
MVAMultipleExpertsModule()
Constructor.
Definition: MVAMultipleExpertsModule.cc:43
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::MVAMultipleExpertsModule
This module adds an ExtraInfo to the Particle objects in a given ParticleList.
Definition: MVAMultipleExpertsModule.h:41
Belle2::MVAMultipleExpertsModule::m_extraInfoNames
std::vector< std::string > m_extraInfoNames
Names under which the SignalProbability is stored in the extraInfo of the Particle object.
Definition: MVAMultipleExpertsModule.h:93
Belle2::MVAMultipleExpertsModule::terminate
virtual void terminate() override
Called at the end of the event processing.
Definition: MVAMultipleExpertsModule.h:67
Belle2::MVAMultipleExpertsModule::analyse
std::vector< float > analyse(Particle *)
Calculates expert output for given Particle pointer.
Definition: MVAMultipleExpertsModule.cc:150
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MVAMultipleExpertsModule::m_identifiers
std::vector< std::string > m_identifiers
weight-files
Definition: MVAMultipleExpertsModule.h:91
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::MVAMultipleExpertsModule::m_weightfile_representations
std::vector< std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > > m_weightfile_representations
Vector of database pointers to the Database representation of the weightfile.
Definition: MVAMultipleExpertsModule.h:105
Belle2::MVAMultipleExpertsModule::m_listNames
std::vector< std::string > m_listNames
input particle list names
Definition: MVAMultipleExpertsModule.h:90
Belle2::MVAMultipleExpertsModule::beginRun
virtual void beginRun() override
Called at the beginning of a new run.
Definition: MVAMultipleExpertsModule.cc:95
Belle2::MVAMultipleExpertsModule::event
virtual void event() override
Called for each event.
Definition: MVAMultipleExpertsModule.cc:170
Belle2::MVAMultipleExpertsModule::m_feature_variables
std::map< const Variable::Manager::Var *, float > m_feature_variables
Map containing the values of all needed feature variables.
Definition: MVAMultipleExpertsModule.h:102
Belle2::MVAMultipleExpertsModule::m_individual_feature_variables
std::vector< std::vector< const Variable::Manager::Var * > > m_individual_feature_variables
Vector of pointers to the feature variables for each expert.
Definition: MVAMultipleExpertsModule.h:97