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#include <mdst/dataobjects/Track.h>
12#include <mdst/dataobjects/PIDLikelihood.h>
13#include <top/dataobjects/TOPLikelihood.h>
14#include <arich/dataobjects/ARICHLikelihood.h>
15#include <cdc/dataobjects/CDCDedxLikelihood.h>
16#include <reconstruction/dataobjects/VXDDedxLikelihood.h>
17
18using namespace std;
19using namespace Belle2;
20
21REG_MODULE(MdstPID);
22
24 m_pid(nullptr)
25{
26 setDescription("Create MDST PID format (PIDLikelihood objects) from subdetector PID info.");
28
29 m_chargedNames[Const::electron] = "electron";
33 m_chargedNames[Const::proton] = "proton";
34 m_chargedNames[Const::deuteron] = "deuteron";
35
36 addParam("subtractMaximum", m_subtractMaximum,
37 "if set to True, subtract the maximum of log likelihoods to reduce the range of values", false);
38}
39
40
42{
43 // data store registration
44
45 // required input
46 m_tracks.isRequired();
47 m_pidLikelihoods.registerInDataStore();
48 m_tracks.registerRelationTo(m_pidLikelihoods);
49
50 // optional input
51 m_topLikelihoods.isOptional();
52 m_arichLikelihoods.isOptional();
53 m_cdcDedxLikelihoods.isOptional();
54 m_vxdDedxLikelihoods.isOptional();
55 m_eclLikelihoods.isOptional();
56 m_muid.isOptional();
57}
58
59
61{
62 // loop over reconstructed tracks and collect likelihoods
63 for (int itra = 0; itra < m_tracks.getEntries(); ++itra) {
64
65 // reconstructed track
66 const Track* track = m_tracks[itra];
67
68 // append new and set relation
69 m_pid = m_pidLikelihoods.appendNew();
70 track->addRelationTo(m_pid);
71
72 // set top likelihoods
73 const TOPLikelihood* top = track->getRelated<TOPLikelihood>();
74 if (top) setLikelihoods(top);
75
76 // set arich likelihoods
77 const ARICHLikelihood* arich = track->getRelated<ARICHLikelihood>();
78 if (arich) setLikelihoods(arich);
79
80 // set CDC dE/dx likelihoods
81 const CDCDedxLikelihood* cdcdedx = track->getRelatedTo<CDCDedxLikelihood>();
82 if (cdcdedx) setLikelihoods(cdcdedx);
83
84 // set VXD dE/dx likelihoods
85 const VXDDedxLikelihood* vxddedx = track->getRelatedTo<VXDDedxLikelihood>();
86 if (vxddedx) setLikelihoods(vxddedx);
87
88 // set ecl likelihoods
89 const ECLPidLikelihood* ecl = track->getRelatedTo<ECLPidLikelihood>();
90 if (ecl) setLikelihoods(ecl);
91
92 // set klm likelihoods
93 const KLMMuidLikelihood* muid = track->getRelatedTo<KLMMuidLikelihood>();
94 if (muid) setLikelihoods(muid);
95
96 if (m_subtractMaximum) m_pid->subtractMaximum();
97 }
98
99}
100
101
103{
104 if (logl->getFlag() != 1) return;
105 if (not areLikelihoodsValid(logl)) return;
106
107 for (const auto& chargedStable : Const::chargedStableSet) {
108 m_pid->setLogLikelihood(Const::TOP, chargedStable, logl->getLogL(chargedStable));
109 }
110
111}
112
113
115{
116 if (logl->getFlag() != 1) return;
117 if (not areLikelihoodsValid(logl)) return;
118
119 for (const auto& chargedStable : Const::chargedStableSet) {
120 m_pid->setLogLikelihood(Const::ARICH, chargedStable, logl->getLogL(chargedStable));
121 }
122
123}
124
125
127{
128 if (not areLikelihoodsValid(logl)) return;
129
130 for (const auto& chargedStable : Const::chargedStableSet) {
131 m_pid->setLogLikelihood(Const::CDC, chargedStable, logl->getLogL(chargedStable));
132 }
133
134}
135
136
138{
139 if (not areLikelihoodsValid(logl)) return;
140
141 for (const auto& chargedStable : Const::chargedStableSet) {
142 m_pid->setLogLikelihood(Const::SVD, chargedStable, logl->getLogL(chargedStable));
143 }
144
145}
146
147
149{
150 if (not areLikelihoodsValid(logl)) return;
151
152 for (const auto& chargedStable : Const::chargedStableSet) {
153 m_pid->setLogLikelihood(Const::ECL, chargedStable, logl->getLogLikelihood(chargedStable));
154 }
155
156}
157
158
160{
161 if (abs(muid->getPDGCode()) != abs(Const::muon.getPDGCode())) {
162 B2WARNING("MdstPID, KLMMuidLikelihood: extrapolation with other than muon hypothesis ignored");
163 return;
164 }
165
166 if (muid->getOutcome() == MuidElementNumbers::c_NotReached)
167 return; // track extrapolation didn't reach KLM
168
169 if (muid->getJunkPDFValue())
170 return; // unclassifiable track (all likelihoods were zero), extremely rare
171
172 if (not areLikelihoodsValid(muid)) return;
173
174 for (const auto& chargedStable : Const::chargedStableSet) {
175 m_pid->setLogLikelihood(Const::KLM, chargedStable, muid->getLogL(chargedStable.getPDGCode()));
176 }
177}
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
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
Module()
Constructor.
Definition Module.cc:30
@ 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
Class to store TOP log likelihoods (output of TOPReconstructor).
int getFlag() const
Return reconstruction flag.
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.