FairShip
Loading...
Searching...
No Matches
CaloScoringPlanePID.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5#ifndef CALOSCORINGPLANE_CALOSCORINGPLANEPID_H_
6#define CALOSCORINGPLANE_CALOSCORINGPLANEPID_H_
7
8#include <array>
9#include <map>
10#include <vector>
11
12#include "Rtypes.h"
13
15class TRandom;
16
54 public:
55 enum Species : Int_t { kUnknown = -1, kElectron = 0, kHadron = 1, kMuon = 2 };
56 static constexpr Int_t kNSpecies = 3;
57
60
76 void Set(const std::vector<Double_t>& energies,
77 const std::vector<Double_t>& matrices,
78 const std::map<Int_t, Int_t>& overrides = {},
79 Bool_t logInterpolation = kFALSE);
80
82 Species TrueSpecies(Int_t pdg) const;
83
89 Double_t Probability(Species trueSpecies, Species recoSpecies,
90 Double_t energy) const;
95 std::vector<Double_t> Matrix(Double_t energy) const;
96
101 Species Identify(Int_t pdg, Double_t energy, Double_t u) const;
107 Species Identify(Int_t pdg, Double_t energy, TRandom& rng) const;
109 Species Identify(const CaloScoringPlanePoint& point, TRandom& rng) const;
110
112 static Double_t Energy(const CaloScoringPlanePoint& point);
113 static const char* SpeciesName(Int_t species);
114
115 const std::vector<Double_t>& GetEnergies() const { return fEnergies; }
116 Bool_t IsLogInterpolation() const { return fLogInterpolation; }
117 void Print() const;
118
119 private:
120 using Row = std::array<Double_t, kNSpecies>;
121
122 void SetIdentity();
124 Row InterpolatedRow(Double_t energy, Int_t trueSpecies) const;
125 Double_t At(size_t iEnergy, Int_t i, Int_t j) const {
126 return fMatrices[9 * iEnergy + static_cast<size_t>(3 * i + j)];
127 }
128
129 std::vector<Double_t> fEnergies;
130 std::vector<Double_t> fMatrices;
131 std::map<Int_t, Int_t> fOverrides;
132 Bool_t fLogInterpolation = kFALSE;
133};
134
135#endif // CALOSCORINGPLANE_CALOSCORINGPLANEPID_H_
std::vector< Double_t > fEnergies
GeV, strictly increasing.
static constexpr Int_t kNSpecies
Double_t Probability(Species trueSpecies, Species recoSpecies, Double_t energy) const
static Double_t Energy(const CaloScoringPlanePoint &point)
std::vector< Double_t > fMatrices
9 per energy, row-major, internal order
std::array< Double_t, kNSpecies > Row
Double_t At(size_t iEnergy, Int_t i, Int_t j) const
static const char * SpeciesName(Int_t species)
std::vector< Double_t > Matrix(Double_t energy) const
Row InterpolatedRow(Double_t energy, Int_t trueSpecies) const
std::map< Int_t, Int_t > fOverrides
|pdg| -> Species
const std::vector< Double_t > & GetEnergies() const
void Set(const std::vector< Double_t > &energies, const std::vector< Double_t > &matrices, const std::map< Int_t, Int_t > &overrides={}, Bool_t logInterpolation=kFALSE)
Bool_t IsLogInterpolation() const
Species Identify(Int_t pdg, Double_t energy, Double_t u) const
Species TrueSpecies(Int_t pdg) const