Belle II Software  release-08-01-10
ECLChargedPIDMVAModule.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 //FRAMEWORK
12 #include <framework/core/Module.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <framework/database/DBObjPtr.h>
16 #include <framework/dataobjects/EventMetaData.h>
17 
18 // MVA
19 #include <mva/interface/Expert.h>
20 #include <mva/interface/Dataset.h>
21 
22 //MDST
23 #include <mdst/dataobjects/Track.h>
24 
25 //ECL
26 #include <ecl/dataobjects/ECLPidLikelihood.h>
27 #include <ecl/dbobjects/ECLChargedPIDMVAWeights.h>
28 
29 
30 namespace Belle2 {
47  class ECLChargedPIDMVAModule : public Module {
48 
49  public:
50 
55 
60 
67  virtual void initialize() override;
68 
74  virtual void beginRun() override;
75 
81  virtual void event() override;
82 
86  void checkDBPayloads();
87 
91  void initializeMVA();
92 
99  float logTransformation(const float value, const float offset, const float max) const;
100 
106  float gaussTransformation(const float value, const TH1F* cdf) const;
107 
114  std::vector<float> decorrTransformation(const std::vector<float> scores, const std::vector<float>* decorrelationMatrix) const;
115 
116 
117  private:
118 
122  float evaluateVariable(const Variable::Manager::Var* varobj, const Particle* particle);
123 
127  std::string m_payload_name;
128 
133 
138 
143 
147  std::unique_ptr<DBObjPtr<ECLChargedPIDMVAWeights>> m_mvaWeights;
148 
153  std::unordered_map<unsigned int, std::unique_ptr<MVA::Expert>> m_experts;
154 
170  static constexpr float c_dummyLogL = -87.3365;
171 
175  std::vector<const Variable::Manager::Var*> m_binningVariables;
176 
181  std::unordered_map<unsigned int, std::vector<const Variable::Manager::Var*>> m_variables;
182 
187  std::unordered_map<unsigned int, std::unique_ptr<MVA::SingleDataset>> m_datasets;
188 
192  static constexpr double c_sqrt2 = 1.41421356237309504880;
193 
194  }; // class
196 } // Belle2 namespace
This module implements charged particle identification using ECL-related observables via a multiclass...
std::unordered_map< unsigned int, std::unique_ptr< MVA::Expert > > m_experts
unordered map of MVA experts.
std::vector< const Variable::Manager::Var * > m_binningVariables
Vector of variables used to define the regions in which the MVAs are trained.
void checkDBPayloads()
Check payloads for consistency.
std::vector< float > decorrTransformation(const std::vector< float > scores, const std::vector< float > *decorrelationMatrix) const
decorrelation transformation.
virtual void initialize() override
Use this to initialize resources or memory your module needs.
virtual void event() override
Called once for each event.
std::unordered_map< unsigned int, std::unique_ptr< MVA::SingleDataset > > m_datasets
MVA dataset to be passed to the expert.
static constexpr double c_sqrt2
Definition of sqrt(2)
StoreObjPtr< EventMetaData > m_eventMetaData
The event information.
void initializeMVA()
Initialise the multiclass MVAs.
virtual ~ECLChargedPIDMVAModule()
Destructor.
float evaluateVariable(const Variable::Manager::Var *varobj, const Particle *particle)
evaluate the variable for the particle and convert the return value float.
float logTransformation(const float value, const float offset, const float max) const
log transformation.
static constexpr float c_dummyLogL
Dummy value of log Likelihood for a particle hypothesis.
virtual void beginRun() override
Called once before a new run begins.
std::unordered_map< unsigned int, std::vector< const Variable::Manager::Var * > > m_variables
Map of vectors containing the variables objects to be fed to the MVA.
StoreArray< Track > m_tracks
array of track objects.
float gaussTransformation(const float value, const TH1F *cdf) const
gaussian transformation.
std::unique_ptr< DBObjPtr< ECLChargedPIDMVAWeights > > m_mvaWeights
Interface to DB payloads containing MVA weightfiles and pdfs.
StoreArray< ECLPidLikelihood > m_eclPidLikelihoods
Array of ECLPidLikelihood objects.
std::string m_payload_name
The name of the database payload object with the MVA weights.
Base class for Modules.
Definition: Module.h:72
Class to store reconstructed particles.
Definition: Particle.h:75
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.
A variable returning a floating-point value for a given Particle.
Definition: Manager.h:146