Belle II Software  release-06-02-00
MVAExpertModule.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 
9 #pragma once
10 
11 #include <framework/core/Module.h>
12 
13 #include <mva/dataobjects/DatabaseRepresentationOfWeightfile.h>
14 #include <mva/interface/Weightfile.h>
15 #include <mva/interface/Expert.h>
16 
17 #include <framework/database/DBObjPtr.h>
18 
19 #include <analysis/VariableManager/Manager.h>
20 
21 #include <vector>
22 #include <string>
23 #include <memory>
24 
25 namespace Belle2 {
31  class Particle;
32 
40  class MVAExpertModule : public Module {
41  public:
42 
47 
51  virtual void initialize() override;
52 
56  virtual void beginRun() override;
57 
61  virtual void event() override;
62 
66  virtual void terminate() override
67  {
68  m_expert.reset();
69  m_dataset.reset();
70  }
71 
72  private:
76  float analyse(Particle*);
77 
82  void init_mva(MVA::Weightfile& weightfile);
83 
84 
85  private:
86 
87  std::vector<std::string> m_listNames;
88  std::string m_identifier;
89  std::string m_extraInfoName;
92  std::vector<const Variable::Manager::Var*> m_feature_variables;
94  std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>
96  std::unique_ptr<MVA::Expert> m_expert;
97  std::unique_ptr<MVA::SingleDataset> m_dataset;
98  };
99 
101 } // Belle2 namespace
102 
This module adds an ExtraInfo to the Particle objects in a given ParticleList.
virtual void terminate() override
Called at the end of the event processing.
std::unique_ptr< MVA::SingleDataset > m_dataset
Pointer to the current dataset.
std::vector< const Variable::Manager::Var * > m_feature_variables
Pointers to the feature variables.
std::unique_ptr< MVA::Expert > m_expert
Pointer to the current MVA Expert.
double m_signal_fraction_override
Signal Fraction which should be used.
std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > m_weightfile_representation
Database pointer to the Database representation of the weightfile.
std::vector< std::string > m_listNames
input particle list names
std::string m_extraInfoName
Name under which the SignalProbability is stored in the extraInfo of the Particle object.
std::string m_identifier
weight-file
The Weightfile class serializes all information about a training into an xml tree.
Definition: Weightfile.h:38
Base class for Modules.
Definition: Module.h:72
Class to store reconstructed particles.
Definition: Particle.h:74
virtual void initialize() override
Initialize the module.
virtual void event() override
Called for each event.
virtual void beginRun() override
Called at the beginning of a new run.
MVAExpertModule()
Constructor.
float analyse(Particle *)
Calculates expert output for given Particle pointer.
void init_mva(MVA::Weightfile &weightfile)
Initialize mva expert, dataset and features Called every time the weightfile in the database changes ...
Abstract base class for different kinds of events.