Belle II Software development
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 <ecl/dataobjects/ECLPidLikelihood.h>
17#include <klm/dataobjects/KLMMuidLikelihood.h>
18
19#include <string>
20#include <cmath>
21#include <map>
22
23namespace Belle2 {
28 class Track;
29 class TOPLikelihood;
30 class ARICHLikelihood;
33 class PIDLikelihood;
34
38
39 class MdstPIDModule : public Module {
40 public:
41
42
47
52 virtual void initialize() override;
53
58 virtual void event() override;
59
60 private:
61
66 void setLikelihoods(const TOPLikelihood* logl);
67
72 void setLikelihoods(const ARICHLikelihood* logl);
73
78 void setLikelihoods(const CDCDedxLikelihood* logl);
79
84 void setLikelihoods(const VXDDedxLikelihood* logl);
85
90 void setLikelihoods(const ECLPidLikelihood* logl);
91
96 void setLikelihoods(const KLMMuidLikelihood* muid);
97
104 template<class T>
105 float getLogL(const T* logl, const Const::ChargedStable& chargedStable) const
106 {
107 return logl->getLogL(chargedStable);
108 }
109
116 float getLogL(const ECLPidLikelihood* logl, const Const::ChargedStable& chargedStable) const
117 {
118 return logl->getLogLikelihood(chargedStable);
119 }
120
127 float getLogL(const KLMMuidLikelihood* logl, const Const::ChargedStable& chargedStable) const
128 {
129 return logl->getLogL(chargedStable.getPDGCode());
130 }
131
137 template<class T>
138 bool areLikelihoodsValid(const T* logl)
139 {
140 std::vector<float> values;
141 for (const auto& chargedStable : Const::chargedStableSet) {
142 auto value = getLogL(logl, chargedStable);
143 values.push_back(value);
144 if (std::isnan(value) or value == INFINITY) {
145 B2ERROR("MdstPID::setLikelihoods: invalid " << logl->ClassName() << " for " << m_chargedNames[chargedStable]
146 << ", is " << value
147 << ". Likelihoods ignored.");
148 return false;
149 }
150 }
151 // check if log likelihoods differ
152 for (auto value : values) {
153 if (value != values.back()) return true; // values differ
154 }
155 return false; // values are all the same - ignore Likelihoods
156 }
157
158 // module parameters
160
161 // input collections
169
170 // output collection
172
173 // other
175 std::map<Const::ChargedStable, std::string> m_chargedNames;
176
177 };
178
180} // Belle2 namespace
181
182
183
184
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 information related to the extrapolation.
double getLogL(int pdg) const
Get the log-likelihood.
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).
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)
Module()
Constructor.
Definition Module.cc:30
Class to collect log likelihoods from TOP, ARICH, dEdx, ECL and KLM aimed for output to mdst includes...
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Class to store TOP log likelihoods (output of TOPReconstructor).
Class that bundles various TrackFitResults.
Definition Track.h:25
Container for likelihoods obtained by the VXD dE/dx PID (VXDDedxPIDModule).
Abstract base class for different kinds of events.