Belle II Software prerelease-11-00-00a
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
42 class MdstPIDModule : public Module {
43 public:
44
45
50
55 virtual void initialize() override;
56
61 virtual void event() override;
62
63 private:
64
69 void setLikelihoods(const TOPLikelihood* logl);
70
75 void setLikelihoods(const ARICHLikelihood* logl);
76
81 void setLikelihoods(const CDCDedxLikelihood* logl);
82
87 void setLikelihoods(const VXDDedxLikelihood* logl);
88
93 void setLikelihoods(const ECLPidLikelihood* logl);
94
99 void setLikelihoods(const KLMMuidLikelihood* muid);
100
107 template<class T>
108 float getLogL(const T* logl, const Const::ChargedStable& chargedStable) const
109 {
110 return logl->getLogL(chargedStable);
111 }
112
119 float getLogL(const ECLPidLikelihood* logl, const Const::ChargedStable& chargedStable) const
120 {
121 return logl->getLogLikelihood(chargedStable);
122 }
123
130 float getLogL(const KLMMuidLikelihood* logl, const Const::ChargedStable& chargedStable) const
131 {
132 return logl->getLogL(chargedStable.getPDGCode());
133 }
134
140 template<class T>
141 bool areLikelihoodsValid(const T* logl)
142 {
143 std::vector<float> values;
144 for (const auto& chargedStable : Const::chargedStableSet) {
145 auto value = getLogL(logl, chargedStable);
146 values.push_back(value);
147 if (std::isnan(value) or value == INFINITY) {
148 B2ERROR("MdstPID::setLikelihoods: invalid " << logl->ClassName() << " for " << m_chargedNames[chargedStable]
149 << ", is " << value
150 << ". Likelihoods ignored.");
151 return false;
152 }
153 }
154 // check if log likelihoods differ
155 for (auto value : values) {
156 if (value != values.back()) return true; // values differ
157 }
158 return false; // values are all the same - ignore Likelihoods
159 }
160
161 // module parameters
163
164 // input collections
172
173 // output collection
175
176 // other
178 std::map<Const::ChargedStable, std::string> m_chargedNames;
180
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 information related to the extrapolation.
double getLogL(int pdg) const
Get the log-likelihood.
StoreArray< KLMMuidLikelihood > m_muid
Optional collection of KLMMuidLikelihood.
int m_CDCnLayerHitsUsed
number of layers with measurements used in the CDC likelihood
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.