Belle II Software development
MdstPIDModule.cc
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#include <reconstruction/modules/MdstPID/MdstPIDModule.h>
10#include <klm/muid/MuidElementNumbers.h>
11
12using namespace std;
13using namespace Belle2;
14
15REG_MODULE(MdstPID);
16
18 m_pid(nullptr)
19{
20 setDescription("Create MDST PID format (PIDLikelihood objects) from subdetector PID info.");
22
23 m_chargedNames[Const::electron] = "electron";
27 m_chargedNames[Const::proton] = "proton";
28 m_chargedNames[Const::deuteron] = "deuteron";
29
30 addParam("subtractMaximum", m_subtractMaximum,
31 "if set to True, subtract the maximum of log likelihoods to reduce the range of values", false);
32}
33
34
36{
37 // data store registration
38
39 // required input
40 m_tracks.isRequired();
41 m_pidLikelihoods.registerInDataStore();
42 m_tracks.registerRelationTo(m_pidLikelihoods);
43
44 // optional input
45 m_topLikelihoods.isOptional();
46 m_arichLikelihoods.isOptional();
47 m_cdcDedxLikelihoods.isOptional();
48 m_vxdDedxLikelihoods.isOptional();
49 m_eclLikelihoods.isOptional();
50 m_muid.isOptional();
51}
52
53
55{
56 // loop over reconstructed tracks and collect likelihoods
57 for (int itra = 0; itra < m_tracks.getEntries(); ++itra) {
58
59 // reconstructed track
60 const Track* track = m_tracks[itra];
61
62 // append new and set relation
63 m_pid = m_pidLikelihoods.appendNew();
64 track->addRelationTo(m_pid);
65
66 // set top likelihoods
67 const TOPLikelihood* top = track->getRelated<TOPLikelihood>();
68 if (top) setLikelihoods(top);
69
70 // set arich likelihoods
71 const ARICHLikelihood* arich = track->getRelated<ARICHLikelihood>();
72 if (arich) setLikelihoods(arich);
73
74 // set CDC dE/dx likelihoods
75 const CDCDedxLikelihood* cdcdedx = track->getRelatedTo<CDCDedxLikelihood>();
76 if (cdcdedx) setLikelihoods(cdcdedx);
77
78 // set VXD dE/dx likelihoods
79 const VXDDedxLikelihood* vxddedx = track->getRelatedTo<VXDDedxLikelihood>();
80 if (vxddedx) setLikelihoods(vxddedx);
81
82 // set ecl likelihoods
83 const ECLPidLikelihood* ecl = track->getRelatedTo<ECLPidLikelihood>();
84 if (ecl) setLikelihoods(ecl);
85
86 // set klm likelihoods
87 const KLMMuidLikelihood* muid = track->getRelatedTo<KLMMuidLikelihood>();
88 if (muid) setLikelihoods(muid);
89
91 }
92
93}
94
95
97{
98 if (logl->getFlag() != 1) return;
99 if (not areLikelihoodsValid(logl)) return;
100
101 for (const auto& chargedStable : Const::chargedStableSet) {
102 m_pid->setLogLikelihood(Const::TOP, chargedStable, logl->getLogL(chargedStable));
103 }
104
105}
106
107
109{
110 if (logl->getFlag() != 1) return;
111 if (not areLikelihoodsValid(logl)) return;
112
113 for (const auto& chargedStable : Const::chargedStableSet) {
114 m_pid->setLogLikelihood(Const::ARICH, chargedStable, logl->getLogL(chargedStable));
115 }
116
117}
118
119
121{
122 if (not areLikelihoodsValid(logl)) return;
123
124 for (const auto& chargedStable : Const::chargedStableSet) {
125 m_pid->setLogLikelihood(Const::CDC, chargedStable, logl->getLogL(chargedStable));
126 }
127
128}
129
130
132{
133 if (not areLikelihoodsValid(logl)) return;
134
135 for (const auto& chargedStable : Const::chargedStableSet) {
136 m_pid->setLogLikelihood(Const::SVD, chargedStable, logl->getLogL(chargedStable));
137 }
138
139}
140
141
143{
144 if (not areLikelihoodsValid(logl)) return;
145
146 for (const auto& chargedStable : Const::chargedStableSet) {
147 m_pid->setLogLikelihood(Const::ECL, chargedStable, logl->getLogLikelihood(chargedStable));
148 }
149
150}
151
152
154{
155 if (abs(muid->getPDGCode()) != abs(Const::muon.getPDGCode())) {
156 B2WARNING("MdstPID, KLMMuidLikelihood: extrapolation with other than muon hypothesis ignored");
157 return;
158 }
159
160 if (muid->getOutcome() == MuidElementNumbers::c_NotReached)
161 return; // track extrapolation didn't reach KLM
162
163 if (muid->getJunkPDFValue())
164 return; // unclassifiable track (all likelihoods were zero), extremely rare
165
166 if (not areLikelihoodsValid(muid)) return;
167
168 for (const auto& chargedStable : Const::chargedStableSet) {
169 m_pid->setLogLikelihood(Const::KLM, chargedStable, muid->getLogL(chargedStable.getPDGCode()));
170 }
171}
This is a class to store ARICH likelihoods in the datastore.
int getFlag() const
Get reconstruction flag.
float getLogL(const Const::ChargedStable &part) const
Return log likelihood for a given particle.
Container for likelihoods obtained by the CDC dE/dx PID (CDCDedxPIDModule).
double getLogL(const Const::ChargedStable &type) const
returns unnormalised log-likelihood value for a particle hypothesis using CDC information.
static const ChargedStable muon
muon particle
Definition: Const.h:660
static const ParticleSet chargedStableSet
set of charged stable particles
Definition: Const.h:618
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
Container for likelihoods with ECL PID (ECLChargedPIDModule)
float getLogLikelihood(const Const::ChargedStable &type) const
returns log-likelihood value for a particle hypothesis.
Class to store the likelihoods from KLM with additional information related to the extrapolation.
StoreArray< KLMMuidLikelihood > m_muid
Optional collection of KLMMuidLikelihood.
bool areLikelihoodsValid(const T *logl)
Check for validity of log likelihood values (NaN and +Inf are not allowed).
StoreArray< VXDDedxLikelihood > m_vxdDedxLikelihoods
Optional collection of VXDDedxLikelihoods.
bool m_subtractMaximum
if true subtract the maximum of log likelihoods
virtual void initialize() override
Initialize the module.
virtual void event() override
Called for each event.
StoreArray< TOPLikelihood > m_topLikelihoods
Optional collection of TOPLikelihoods.
MdstPIDModule()
Constructor.
StoreArray< ECLPidLikelihood > m_eclLikelihoods
Optional collection of ECLPidLikelihoods.
PIDLikelihood * m_pid
pointer to the object to be filled
std::map< Const::ChargedStable, std::string > m_chargedNames
names of charged particles (used in error messages)
StoreArray< Track > m_tracks
Required collection of Tracks.
StoreArray< ARICHLikelihood > m_arichLikelihoods
Optional collection of ARICHLikelihoods.
void setLikelihoods(const TOPLikelihood *logl)
Set TOP log likelihoods and corresponding reconstruction flag.
StoreArray< CDCDedxLikelihood > m_cdcDedxLikelihoods
Optional collection of CDCDedxLikelihoods.
StoreArray< PIDLikelihood > m_pidLikelihoods
collection of PIDLikelihoods
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
void subtractMaximum()
Subtract the maximum of log likelihoods of each detector component in order to reduce the range of va...
void setLogLikelihood(Const::EDetector det, const Const::ChargedStable &part, float logl)
Set log likelihood for a given detector and particle.
Class to store TOP log likelihoods (output of TOPReconstructor).
Definition: TOPLikelihood.h:26
int getFlag() const
Return reconstruction flag.
Definition: TOPLikelihood.h:82
float getLogL(const Const::ChargedStable &part) const
Return log likelihood for a given particle.
Class that bundles various TrackFitResults.
Definition: Track.h:25
Container for likelihoods obtained by the VXD dE/dx PID (VXDDedxPIDModule).
double getLogL(const Const::ChargedStable &type) const
returns unnormalised log-likelihood value for a particle hypothesis using SVD (and/or PXD) informatio...
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.