Belle II Software development
PIDCalibrationWeight.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/gearbox/Const.h>
12#include <framework/logging/Logger.h>
13
14#include <boost/algorithm/string.hpp>
15
16#include <TObject.h>
17
18namespace Belle2 {
30 typedef std::vector<std::vector<double>> WeightMatrix;
31
35 class PIDCalibrationWeight : public TObject {
36
37 public:
40
43 {
44 m_weightMatrix = weightMatrix;
45 };
46
51 void setWeightMatrix(WeightMatrix weightMatrix)
52 {
53 m_weightMatrix = weightMatrix;
54 };
55
60 {
61 return m_weightMatrix;
62 };
63
70 double getWeight(int pdg, std::string detector) const
71 {
72 std::vector<double> weightVector = getWeights(pdg);
73
75 boost::to_lower(detector);
76 if (detector == "svd") det = Const::SVD;
77 else if (detector == "cdc") det = Const::CDC;
78 else if (detector == "top") det = Const::TOP;
79 else if (detector == "arich") det = Const::ARICH;
80 else if (detector == "ecl") det = Const::ECL;
81 else if (detector == "klm") det = Const::KLM;
82 else B2FATAL("Unknown detector component: " << detector);
83 int det_index = Const::PIDDetectors::c_set.getIndex(det);
84
85 return weightVector[det_index];
86 };
87
94 double getWeight(int pdg, Const::EDetector det) const
95 {
96 std::vector<double> weightVector = getWeights(pdg);
97
98 int det_index = Const::PIDDetectors::c_set.getIndex(det);
99 return weightVector[det_index];
100 };
101
107 std::vector<double> getWeights(int pdg) const
108 {
109 int p_index = -1;
110 for (const auto& pdgIter : Const::chargedStableSet) {
111 if (pdgIter.getPDGCode() == pdg) {
112 p_index = pdgIter.getIndex();
113 break;
114 }
115 }
116 if (p_index == -1)
117 B2FATAL("Invalid particle: " << pdg);
118
119 return m_weightMatrix[p_index];
120 };
121
122 private:
123
128
131 };
132
134} // Belle2 namespace
135
136
int getIndex(EDetector det) const
Getter for the index of a given detector in this set.
Definition: UnitConst.cc:278
static const DetectorSet c_set
The set of valid PID detectors.
Definition: Const.h:375
static const ParticleSet chargedStableSet
set of charged stable particles
Definition: Const.h:618
EDetector
Enum for identifying the detector components (detector and subdetector).
Definition: Const.h:42
Class for handling the PID calibration weight matrix.
PIDCalibrationWeight(WeightMatrix weightMatrix)
Constructor with the initial WeightMatrix.
std::vector< double > getWeights(int pdg) const
Get the weights for the given PDG code.
void setWeightMatrix(WeightMatrix weightMatrix)
Set the WeightMatrix.
WeightMatrix m_weightMatrix
PID calibration weight matrix.
WeightMatrix getWeightMatrix() const
Get the WeightMatrix.
double getWeight(int pdg, Const::EDetector det) const
Get the weight for the given combination of the PDG code and the detector in Const::EDetector.
double getWeight(int pdg, std::string detector) const
Get the weight for the given combination of the PDG code and the detector name.
ClassDef(PIDCalibrationWeight, 1)
ClassDef as this is a TObject.
std::vector< std::vector< double > > WeightMatrix
PID calibration weight matrix, 6 (particle type) x 6 (detectors).
Abstract base class for different kinds of events.