Belle II Software release-09-00-00
MdstPIDModule.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#include <framework/core/Module.h>
12#include <framework/datastore/StoreArray.h>
13#include <framework/logging/Logger.h>
14#include <framework/gearbox/Const.h>
15
16#include <mdst/dataobjects/Track.h>
17#include <mdst/dataobjects/PIDLikelihood.h>
18
19#include <top/dataobjects/TOPLikelihood.h>
20#include <arich/dataobjects/ARICHLikelihood.h>
21#include <cdc/dataobjects/CDCDedxLikelihood.h>
22#include <reconstruction/dataobjects/VXDDedxLikelihood.h>
23#include <ecl/dataobjects/ECLPidLikelihood.h>
24#include <klm/dataobjects/KLMMuidLikelihood.h>
25
26#include <string>
27#include <cmath>
28#include <map>
29
30namespace Belle2 {
43 class MdstPIDModule : public Module {
44 public:
45
46
51
56 virtual void initialize() override;
57
62 virtual void event() override;
63
64 private:
65
70 void setLikelihoods(const TOPLikelihood* logl);
71
76 void setLikelihoods(const ARICHLikelihood* logl);
77
82 void setLikelihoods(const CDCDedxLikelihood* logl);
83
88 void setLikelihoods(const VXDDedxLikelihood* logl);
89
94 void setLikelihoods(const ECLPidLikelihood* logl);
95
100 void setLikelihoods(const KLMMuidLikelihood* muid);
101
108 template<class T>
109 float getLogL(const T* logl, const Const::ChargedStable& chargedStable) const
110 {
111 return logl->getLogL(chargedStable);
112 }
113
120 float getLogL(const ECLPidLikelihood* logl, const Const::ChargedStable& chargedStable) const
121 {
122 return logl->getLogLikelihood(chargedStable);
123 }
124
131 float getLogL(const KLMMuidLikelihood* logl, const Const::ChargedStable& chargedStable) const
132 {
133 return logl->getLogL(chargedStable.getPDGCode());
134 }
135
141 template<class T>
142 bool areLikelihoodsValid(const T* logl)
143 {
144 std::vector<float> values;
145 for (const auto& chargedStable : Const::chargedStableSet) {
146 auto value = getLogL(logl, chargedStable);
147 values.push_back(value);
148 if (std::isnan(value) or value == INFINITY) {
149 B2ERROR("MdstPID::setLikelihoods: invalid " << logl->ClassName() << " for " << m_chargedNames[chargedStable]
150 << ", is " << value
151 << ". Likelihoods ignored.");
152 return false;
153 }
154 }
155 // check if log likelihoods differ
156 for (auto value : values) {
157 if (value != values.back()) return true; // values differ
158 }
159 return false; // values are all the same - ignore Likelihoods
160 }
161
162 // module parameters
165 // input collections
174 // output collection
177 // other
179 std::map<Const::ChargedStable, std::string> m_chargedNames;
181 };
182
184} // Belle2 namespace
185
186
187
188
This is a class to store ARICH likelihoods in the datastore.
Container for likelihoods obtained by the CDC dE/dx PID (CDCDedxPIDModule).
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:589
int getPDGCode() const
PDG code.
Definition: Const.h:473
static const ParticleSet chargedStableSet
set of charged stable particles
Definition: Const.h:618
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.
double getLogL(int pdg) const
Get the log-likelihood.
a module to fill PIDLikelihoods
Definition: MdstPIDModule.h:43
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 alowed).
float getLogL(const ECLPidLikelihood *logl, const Const::ChargedStable &chargedStable) const
Get log likelihood for a given particle (ECL specialization)
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.
float getLogL(const T *logl, const Const::ChargedStable &chargedStable) const
Get log likelihood for a given particle.
StoreArray< PIDLikelihood > m_pidLikelihoods
collection of PIDLikelihoods
float getLogL(const KLMMuidLikelihood *logl, const Const::ChargedStable &chargedStable) const
Get log likelihood for a given particle (KLM specialization)
Base class for Modules.
Definition: Module.h:72
Class to collect log likelihoods from TOP, ARICH, dEdx, ECL and KLM aimed for output to mdst includes...
Definition: PIDLikelihood.h:29
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Class to store TOP log likelihoods (output of TOPReconstructor).
Definition: TOPLikelihood.h:26
Container for likelihoods obtained by the VXD dE/dx PID (VXDDedxPIDModule).
Abstract base class for different kinds of events.