![]() |
FairShip
|
Energy-dependent electron / hadron / muon identification from confusion matrices. More...
#include <CaloScoringPlanePID.h>
Public Types | |
| enum | Species : Int_t { kUnknown = -1 , kElectron = 0 , kHadron = 1 , kMuon = 2 } |
Public Member Functions | |
| CaloScoringPlanePID () | |
| 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) |
| Species | TrueSpecies (Int_t pdg) const |
| Double_t | Probability (Species trueSpecies, Species recoSpecies, Double_t energy) const |
| std::vector< Double_t > | Matrix (Double_t energy) const |
| Species | Identify (Int_t pdg, Double_t energy, Double_t u) const |
| Species | Identify (Int_t pdg, Double_t energy, TRandom &rng) const |
| Species | Identify (const CaloScoringPlanePoint &point, TRandom &rng) const |
| const std::vector< Double_t > & | GetEnergies () const |
| Bool_t | IsLogInterpolation () const |
| void | Print () const |
Static Public Member Functions | |
| static Double_t | Energy (const CaloScoringPlanePoint &point) |
| static const char * | SpeciesName (Int_t species) |
Static Public Attributes | |
| static constexpr Int_t | kNSpecies = 3 |
Private Types | |
| using | Row = std::array<Double_t, kNSpecies> |
Private Member Functions | |
| void | SetIdentity () |
| Row | InterpolatedRow (Double_t energy, Int_t trueSpecies) const |
| Double_t | At (size_t iEnergy, Int_t i, Int_t j) const |
Private Attributes | |
| std::vector< Double_t > | fEnergies |
| GeV, strictly increasing. | |
| std::vector< Double_t > | fMatrices |
| 9 per energy, row-major, internal order | |
| std::map< Int_t, Int_t > | fOverrides |
| |pdg| -> Species | |
| Bool_t | fLogInterpolation = kFALSE |
Energy-dependent electron / hadron / muon identification from confusion matrices.
The model is a list of 3x3 confusion matrices given at increasing energies. M(E)[i][j] is the probability that a particle of true species i is identified as species j; each row sums to 1. For a particle of total energy E the matrix is interpolated element by element between the two neighbouring energy points (linearly in E, or in log E); below the first or above the last point, that point's matrix is used. Interpolating row-stochastic matrices this way keeps every row normalised and non-negative.
True species from the PDG code: |pdg| = 11 electron, 13 muon; any meson or baryon (|pdg| < 9900000 with a non-zero quark digit n_q2) is a hadron; anything else (photons, neutrinos, nuclei, BSM codes) is kUnknown and is never identified. Overrides change this per |pdg|.
The model is given with Set(), which validates it. Reconstruction reads it from a YAML file in Python (python/caloScoringPlanePID.py; format in CaloScoringPlane/README.md, example in geometry/caloScoringPlane_pid_provided.yaml).
Usage from C++ (link against the CaloScoringPlane library):
and from Python:
Definition at line 53 of file CaloScoringPlanePID.h.
|
private |
Definition at line 120 of file CaloScoringPlanePID.h.
| enum CaloScoringPlanePID::Species : Int_t |
| CaloScoringPlanePID::CaloScoringPlanePID | ( | ) |
Perfect identification (identity matrix at all energies).
Definition at line 82 of file CaloScoringPlanePID.cxx.
|
inlineprivate |
Definition at line 125 of file CaloScoringPlanePID.h.
|
static |
Total energy (GeV) at the point, using the PDG mass (0 if unknown).
Definition at line 240 of file CaloScoringPlanePID.cxx.
|
inline |
Definition at line 115 of file CaloScoringPlanePID.h.
| CaloScoringPlanePID::Species CaloScoringPlanePID::Identify | ( | const CaloScoringPlanePoint & | point, |
| TRandom & | rng ) const |
Same, with the PDG code and total energy taken from the point.
Definition at line 233 of file CaloScoringPlanePID.cxx.
| CaloScoringPlanePID::Species CaloScoringPlanePID::Identify | ( | Int_t | pdg, |
| Double_t | energy, | ||
| Double_t | u ) const |
Draw the PID outcome with a given uniform number u in [0, 1]. A non-finite energy gives kUnknown, as for the overloads below.
Definition at line 213 of file CaloScoringPlanePID.cxx.
| CaloScoringPlanePID::Species CaloScoringPlanePID::Identify | ( | Int_t | pdg, |
| Double_t | energy, | ||
| TRandom & | rng ) const |
Draw the PID outcome with the generator rng. No number is drawn when the outcome is fixed: for an unknown species, or a matrix row with a single non-zero entry (as everywhere with perfect identification).
Definition at line 221 of file CaloScoringPlanePID.cxx.
|
private |
Interpolated matrix row of trueSpecies (not kUnknown).
Definition at line 161 of file CaloScoringPlanePID.cxx.
|
inline |
Definition at line 116 of file CaloScoringPlanePID.h.
| std::vector< Double_t > CaloScoringPlanePID::Matrix | ( | Double_t | energy | ) | const |
Interpolated 3x3 matrix, row-major (9 values). Throws std::invalid_argument for a non-finite energy.
Definition at line 188 of file CaloScoringPlanePID.cxx.
| void CaloScoringPlanePID::Print | ( | ) | const |
Definition at line 265 of file CaloScoringPlanePID.cxx.
| Double_t CaloScoringPlanePID::Probability | ( | Species | trueSpecies, |
| Species | recoSpecies, | ||
| Double_t | energy ) const |
Interpolated probability P(identified as reco | true species, E). Throws std::out_of_range for a species other than kUnknown, kElectron, kHadron or kMuon, and std::invalid_argument for a non-finite energy.
Definition at line 197 of file CaloScoringPlanePID.cxx.
| void CaloScoringPlanePID::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 ) |
Replace the model.
| energies | total energies in GeV, finite and strictly increasing (and positive with log interpolation) |
| matrices | 9 values per energy, row-major; rows are the true and columns the identified species, both in the order electron, hadron, muon. Entries are finite and non-negative, each row sums to 1. |
| overrides | |pdg| -> species (kUnknown allowed); a negative key applies to |pdg| as well. |
| logInterpolation | interpolate linearly in log E instead of E |
Throws std::invalid_argument, naming the energy point and row, if the model is invalid; the previous model is then kept.
Definition at line 92 of file CaloScoringPlanePID.cxx.
|
private |
Definition at line 84 of file CaloScoringPlanePID.cxx.
|
static |
Definition at line 252 of file CaloScoringPlanePID.cxx.
| CaloScoringPlanePID::Species CaloScoringPlanePID::TrueSpecies | ( | Int_t | pdg | ) | const |
True species for a PDG code (overrides applied).
Definition at line 150 of file CaloScoringPlanePID.cxx.
|
private |
GeV, strictly increasing.
Definition at line 129 of file CaloScoringPlanePID.h.
|
private |
Definition at line 132 of file CaloScoringPlanePID.h.
|
private |
9 per energy, row-major, internal order
Definition at line 130 of file CaloScoringPlanePID.h.
|
private |
|pdg| -> Species
Definition at line 131 of file CaloScoringPlanePID.h.
|
staticconstexpr |
Definition at line 56 of file CaloScoringPlanePID.h.