Belle II Software  release-08-01-10
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 /* Own header. */
10 #include <reconstruction/modules/MdstPID/MdstPIDModule.h>
11 
12 /* Basf2 headers. */
13 #include <framework/gearbox/Const.h>
14 #include <framework/logging/Logger.h>
15 #include <klm/muid/MuidElementNumbers.h>
16 
17 /* C++ headers. */
18 #include <string>
19 
20 using namespace std;
21 using namespace Belle2;
22 
23 REG_MODULE(MdstPID);
24 
25 MdstPIDModule::MdstPIDModule() : Module(),
26  m_pid(nullptr)
27 {
28  setDescription("Create MDST PID format (PIDLikelihood objects) from subdetector PID info.");
30 }
31 
33 {
34 }
35 
37 {
38  // data store registration
39 
40  // required input
41  m_tracks.isRequired();
42  m_pidLikelihoods.registerInDataStore();
43  m_tracks.registerRelationTo(m_pidLikelihoods);
44 
45  // optional input
46  m_topLikelihoods.isOptional();
47  m_arichLikelihoods.isOptional();
48  m_cdcDedxLikelihoods.isOptional();
49  m_vxdDedxLikelihoods.isOptional();
50  m_eclLikelihoods.isOptional();
51  m_muid.isOptional();
52 }
53 
54 
56 {
57 }
58 
60 {
61 }
62 
64 {
65 }
66 
68 {
69  // loop over reconstructed tracks and collect likelihoods
70  for (int itra = 0; itra < m_tracks.getEntries(); ++itra) {
71 
72  // reconstructed track
73  const Track* track = m_tracks[itra];
74 
75  // append new and set relation
76  m_pid = m_pidLikelihoods.appendNew();
77  track->addRelationTo(m_pid);
78 
79  // set top likelihoods
80  const TOPLikelihood* top = track->getRelated<TOPLikelihood>();
81  if (top) setLikelihoods(top);
82 
83  // set arich likelihoods
84  const ARICHLikelihood* arich = track->getRelated<ARICHLikelihood>();
85  if (arich) setLikelihoods(arich);
86 
87  // set CDC dE/dx likelihoods
88  const CDCDedxLikelihood* cdcdedx = track->getRelatedTo<CDCDedxLikelihood>();
89  if (cdcdedx) setLikelihoods(cdcdedx);
90 
91  // set VXD dE/dx likelihoods
92  const VXDDedxLikelihood* vxddedx = track->getRelatedTo<VXDDedxLikelihood>();
93  if (vxddedx) setLikelihoods(vxddedx);
94 
95  // set ecl likelihoods
96  const ECLPidLikelihood* ecl = track->getRelatedTo<ECLPidLikelihood>();
97  if (ecl) setLikelihoods(ecl);
98 
99  // set klm likelihoods
100  const KLMMuidLikelihood* muid = track->getRelatedTo<KLMMuidLikelihood>();
101  if (muid) setLikelihoods(muid);
102 
103  }
104 
105 }
106 
107 
109 {
110  if (logl->getFlag() != 1) return;
111 
112  for (const auto& chargedStable : Const::chargedStableSet) {
113  m_pid->setLogLikelihood(Const::TOP, chargedStable, logl->getLogL(chargedStable));
114  }
115 
116 }
117 
118 
120 {
121  if (logl->getFlag() != 1) return;
122 
123  for (const auto& chargedStable : Const::chargedStableSet) {
124  m_pid->setLogLikelihood(Const::ARICH, chargedStable, logl->getLogL(chargedStable));
125  }
126 
127 }
128 
129 
131 {
132 
133  for (const auto& chargedStable : Const::chargedStableSet) {
134  m_pid->setLogLikelihood(Const::CDC, chargedStable, logl->getLogL(chargedStable));
135  }
136 
137 }
138 
139 
141 {
142 
143  for (const auto& chargedStable : Const::chargedStableSet) {
144  m_pid->setLogLikelihood(Const::SVD, chargedStable, logl->getLogL(chargedStable));
145  }
146 
147 }
148 
149 
151 {
152 
153  for (const auto& chargedStable : Const::chargedStableSet) {
154  m_pid->setLogLikelihood(Const::ECL, chargedStable, logl->getLogLikelihood(chargedStable));
155  }
156 
157 }
158 
159 
161 {
162  if (abs(muid->getPDGCode()) != abs(Const::muon.getPDGCode())) {
163  B2WARNING("MdstPID, KLMMuidLikelihood: extrapolation with other than muon hypothesis ignored");
164  return;
165  }
166 
167  if (muid->getOutcome() == MuidElementNumbers::c_NotReached)
168  return; // track extrapolation didn't reach KLM
169 
170  if (muid->getJunkPDFValue())
171  return; // unclassifiable track (all likelihoods were zero), extremely rare
172 
173  for (const auto& chargedStable : Const::chargedStableSet) {
174  m_pid->setLogLikelihood(Const::KLM, chargedStable, muid->getLogL(chargedStable.getPDGCode()));
175  }
176 }
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:651
static const ParticleSet chargedStableSet
set of charged stable particles
Definition: Const.h:609
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 informations related to the extrapolation.
StoreArray< KLMMuidLikelihood > m_muid
Optional array for KLMMuidLikelihood.
Definition: MdstPIDModule.h:90
StoreArray< VXDDedxLikelihood > m_vxdDedxLikelihoods
Optional array for VXDDedxLikelihoods.
Definition: MdstPIDModule.h:88
virtual void initialize() override
Initialize the module.
virtual void event() override
Called for each event.
StoreArray< TOPLikelihood > m_topLikelihoods
Optional array for TOPLikelihoods.
Definition: MdstPIDModule.h:85
StoreArray< ECLPidLikelihood > m_eclLikelihoods
Optional array for ECLPidLikelihoods.
Definition: MdstPIDModule.h:89
virtual ~MdstPIDModule()
Destructor.
virtual void endRun() override
Called when run ended.
virtual void terminate() override
Terminates the module.
PIDLikelihood * m_pid
pointer to the object to be filled
virtual void beginRun() override
Called when a new run is started.
StoreArray< Track > m_tracks
Required array for Tracks.
Definition: MdstPIDModule.h:81
StoreArray< ARICHLikelihood > m_arichLikelihoods
Optional array for ARICHLikelihoods.
Definition: MdstPIDModule.h:86
void setLikelihoods(const TOPLikelihood *logl)
Set TOP log likelihoods and corresponding reconstruction flag.
StoreArray< CDCDedxLikelihood > m_cdcDedxLikelihoods
Optional array for CDCDedxLikelihoods.
Definition: MdstPIDModule.h:87
StoreArray< PIDLikelihood > m_pidLikelihoods
Required array for PIDLikelihoods.
Definition: MdstPIDModule.h:82
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 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:63
float getLogL(const Const::ChargedStable &part) const
Return log likelihood for a given particle.
Definition: TOPLikelihood.h:76
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...
#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.