Belle II Software development
ChargedPidMVAMulticlassModule.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 <framework/datastore/StoreArray.h>
16
17// MVA
18#include <mva/interface/Expert.h>
19#include <mva/interface/Dataset.h>
20
21// ANALYSIS
22#include <analysis/dataobjects/ParticleList.h>
23#include <analysis/VariableManager/Manager.h>
24#include <analysis/VariableManager/Utility.h>
25#include <analysis/dbobjects/ChargedPidMVAWeights.h>
26
27namespace Belle2 {
42
43 typedef std::vector<std::unique_ptr<MVA::Expert> > ExpertsList;
44 typedef std::vector<std::unique_ptr<MVA::SingleDataset> > DatasetsList;
45 typedef std::vector<std::unique_ptr<Variable::Cut>> CutsList;
46 typedef std::vector< std::vector<const Variable::Manager::Var*> > VariablesLists;
48 public:
49
54
59
66 virtual void initialize() override;
67
73 virtual void beginRun() override;
74
80 virtual void event() override;
81
82 private:
83
89 void initializeMVA();
90
96 const std::string getParticleName(const ParticleList* pList) const
97 {
98
99 auto fullName = pList->getParticleListName();
100 auto delimiter(":");
101 auto signedName = fullName.substr(0, fullName.find(delimiter));
102 signedName.pop_back();
103
104 return signedName;
105 }
106
107 private:
112
119 std::vector<std::string> m_decayStrings;
120
124 std::string m_payload_name;
125
130
135
140
148 std::unique_ptr<DBObjPtr<ChargedPidMVAWeights>> m_weightfiles_representation;
149
156
162
168
174
180
184 std::vector<std::string> m_classes;
185
189 std::map<int, std::string> m_stdChargedInfo = {
190 { Const::electron.getPDGCode(), "electron" },
191 { Const::muon.getPDGCode(), "muon" },
192 { Const::pion.getPDGCode(), "pion" },
193 { Const::kaon.getPDGCode(), "kaon" },
194 { Const::proton.getPDGCode(), "proton" },
195 { Const::deuteron.getPDGCode(), "deuteron" }
196 };
197
202
206 void registerAliases();
207
208 };
210}
This module evaluates the response of a multi-class MVA trained for global charged particle identific...
StoreObjPtr< EventMetaData > m_event_metadata
The event information.
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...
virtual void initialize() override
Use this to initialize resources or memory your module needs.
bool m_ecl_only
Flag to specify if we use an ECL-only based training.
virtual void event() override
Called once for each event.
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::vector< std::string > m_classes
List of MVA class names.
std::map< int, std::string > m_stdChargedInfo
Map with standard charged particles' info.
ChargedPidMVAMulticlassModule()
Constructor, for setting module description and parameters.
bool m_charge_independent
Flag to specify if we use a charge-independent training.
const std::string getParticleName(const ParticleList *pList) const
Split the particle list name in "particleName", "particleLabel", and return the particle name w/o the...
virtual ~ChargedPidMVAMulticlassModule()
Destructor, use this to clean up anything you created in the constructor.
virtual void beginRun() override
Called once before a new run begins.
void registerAliases()
Set variable aliases needed by the MVA.
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.
VariablesLists m_spectators
List of lists of spectator variables.
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:473
static const ChargedStable muon
muon particle
Definition: Const.h:660
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
static const ChargedStable proton
proton particle
Definition: Const.h:663
static const ChargedStable kaon
charged kaon particle
Definition: Const.h:662
static const ChargedStable electron
electron particle
Definition: Const.h:659
static const ChargedStable deuteron
deuteron particle
Definition: Const.h:664
Base class for Modules.
Definition: Module.h:72
ParticleList is a container class that stores a collection of Particle objects.
Definition: ParticleList.h:140
std::string getParticleListName() const
Returns the name this ParticleList.
Definition: ParticleList.h:277
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:95
Abstract base class for different kinds of events.