Belle II Software  release-08-01-10
ChargedPidMVAModule.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/dataobjects/EventMetaData.h>
14 #include <framework/database/DBObjPtr.h>
15 #include <analysis/DecayDescriptor/DecayDescriptor.h>
16 #include <framework/datastore/StoreArray.h>
17 
18 // MVA
19 #include <mva/interface/Expert.h>
20 #include <mva/interface/Dataset.h>
21 
22 // ANALYSIS
23 #include <analysis/VariableManager/Manager.h>
24 #include <analysis/dbobjects/ChargedPidMVAWeights.h>
25 #include <analysis/VariableManager/Utility.h>
26 
27 
28 namespace Belle2 {
43  class ChargedPidMVAModule : public Module {
44 
45  typedef std::vector<std::unique_ptr<MVA::Expert> > ExpertsList;
46  typedef std::vector<std::unique_ptr<MVA::SingleDataset> > DatasetsList;
47  typedef std::vector<std::unique_ptr<Variable::Cut>> CutsList;
48  typedef std::vector< std::vector<const Variable::Manager::Var*> > VariablesLists;
50  public:
51 
56 
61 
68  virtual void initialize() override;
69 
75  virtual void beginRun() override;
76 
82  virtual void event() override;
83 
84  private:
85 
91  void initializeMVA();
92 
93  private:
102 
107 
114  std::vector<std::string> m_decayStrings;
115 
119  std::string m_payload_name;
120 
125 
130 
134  std::string m_score_varname;
135 
140 
148  std::unique_ptr<DBObjPtr<ChargedPidMVAWeights>> m_weightfiles_representation;
149 
155 
161 
167 
173 
179 
183  std::map<int, std::tuple<std::string, std::string, int>> m_stdChargedInfo = {
184  { Const::electron.getPDGCode(), std::make_tuple("e", "pi", Const::pion.getPDGCode()) },
185  { Const::muon.getPDGCode(), std::make_tuple("mu", "pi", Const::pion.getPDGCode()) },
186  { Const::pion.getPDGCode(), std::make_tuple("pi", "K", Const::kaon.getPDGCode()) },
187  { Const::kaon.getPDGCode(), std::make_tuple("K", "pi", Const::pion.getPDGCode()) },
188  { Const::proton.getPDGCode(), std::make_tuple("p", "pi", Const::pion.getPDGCode()) },
189  { Const::deuteron.getPDGCode(), std::make_tuple("d", "pi", Const::pion.getPDGCode()) }
190  };
191 
196 
201 
202  };
204 }
This module evaluates the response of an MVA trained for binary charged particle identification betwe...
StoreObjPtr< EventMetaData > m_event_metadata
The event information.
int m_bkg_pdg
The input background mass hypothesis' pdgId.
std::vector< std::unique_ptr< Variable::Cut > > CutsList
Typedef.
std::vector< std::string > m_decayStrings
The input list of DecayStrings, where each selected (^) daughter should correspond to a standard char...
bool m_ecl_only
Flag to specify if we use an ECL-only based training.
std::string m_score_varname
The lookup name of the MVA score variable, given the input S, B mass hypotheses for the algorithm.
std::unique_ptr< DBObjPtr< ChargedPidMVAWeights > > m_weightfiles_representation
Interface to get the database payload with the MVA weight files.
std::vector< std::unique_ptr< MVA::SingleDataset > > DatasetsList
Typedef.
StoreArray< Particle > m_particles
StoreArray of Particles.
DatasetsList m_datasets
List of MVA::SingleDataset objects.
std::map< int, std::tuple< std::string, std::string, int > > m_stdChargedInfo
Map with standard charged particles' info.
bool m_charge_independent
Flag to specify if we use a charge-independent training.
virtual void event() override
Called once for each event.
void registerAliases()
Set variable aliases needed by the MVA.
virtual void initialize() override
Use this to initialize resources or memory your module needs.
int m_sig_pdg
The input signal mass hypothesis' pdgId.
virtual void beginRun() override
Called once before a new run begins.
VariablesLists m_variables
List of lists of feature variables.
std::vector< std::vector< const Variable::Manager::Var * > > VariablesLists
Typedef.
void registerAliasesLegacy()
Set variable aliases needed by the MVA.
ChargedPidMVAModule()
Constructor, for setting module description and parameters.
CutsList m_cuts
List of Cut objects.
VariablesLists m_spectators
List of lists of spectator variables.
virtual ~ChargedPidMVAModule()
Destructor, use this to clean up anything you created in the constructor.
std::vector< std::unique_ptr< MVA::Expert > > ExpertsList
Typedef.
ExpertsList m_experts
List of MVA::Expert objects.
std::string m_payload_name
The name of the database payload object with the MVA weights.
int getPDGCode() const
PDG code.
Definition: Const.h:464
static const ChargedStable muon
muon particle
Definition: Const.h:651
static const ChargedStable pion
charged pion particle
Definition: Const.h:652
static const ChargedStable proton
proton particle
Definition: Const.h:654
static const ChargedStable kaon
charged kaon particle
Definition: Const.h:653
static const ChargedStable electron
electron particle
Definition: Const.h:650
static const ChargedStable deuteron
deuteron particle
Definition: Const.h:655
Base class for Modules.
Definition: Module.h:72
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.