Belle II Software development
PIDDetectorWeights.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#include <set>
16
17#include <TObject.h>
18#include <ROOT/RDataFrame.hxx>
19#include <ROOT/RCsvDS.hxx>
20
21
22namespace Belle2 {
31 class PIDDetectorWeights : public TObject {
32
33 public:
34
40 public:
41
42 WeightsTable() :
43 m_isEmpty(false),
44 m_nPBins(0),
46 {};
48 bool m_isEmpty;
50 std::set<double> m_pBinEdges;
51 std::set<double> m_thetaBinEdges;
60 std::unordered_map<double, unsigned int> m_linBinIdxsToRowIdxs;
65 std::map<std::string, std::vector<double>> m_weightsPerDet;
66
67 private:
68
70 };
71
76
81
88 PIDDetectorWeights(const std::string& weightsCSVFileName)
89 {
90 m_weightsRDataFrame = ROOT::RDF::MakeCsvDataFrame(weightsCSVFileName);
92 };
93
99 PIDDetectorWeights(const std::string& treeName, const std::string& weightsROOTFileName) :
100 m_weightsRDataFrame(treeName, weightsROOTFileName)
101 {
103 };
104
109 ROOT::RDataFrame getWeightsRDF() const
110 {
111 return m_weightsRDataFrame;
112 };
113
121 double getWeight(Const::ChargedStable hypo, Const::EDetector det, double p, double theta) const;
122
123 private:
124
129 std::map<int, WeightsTable> m_weightsTablePerHypo;
130
136 ROOT::RDataFrame m_weightsRDataFrame = ROOT::RDataFrame(1);
137
141 std::map<std::string, std::string> m_weightNames = {
142 {Const::parseDetectors(Const::CDC), "ablat_s_CDC"},
143 {Const::parseDetectors(Const::TOP), "ablat_s_TOP"},
144 {Const::parseDetectors(Const::ARICH), "ablat_s_ARICH"},
145 {Const::parseDetectors(Const::ECL), "ablat_s_ECL"},
146 {Const::parseDetectors(Const::KLM), "ablat_s_KLM"}
147 };
148
153
156 };
157
159} // Belle2 namespace
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:589
EDetector
Enum for identifying the detector components (detector and subdetector).
Definition: Const.h:42
static std::string parseDetectors(EDetector det)
Converts Const::EDetector object to string.
Definition: UnitConst.cc:162
Nested class acting as a container the per-detector weights.
std::unordered_map< double, unsigned int > m_linBinIdxsToRowIdxs
Map the linearised index of the (p, theta) bin indexes to the row index in the (filtered) table.
std::map< std::string, std::vector< double > > m_weightsPerDet
Map each detector to its vector of weights.
ClassDef(WeightsTable, 1)
Needed for sub-class schema evolution.
std::set< double > m_pBinEdges
Set of p bins edges.
std::set< double > m_thetaBinEdges
Set of theta bins edges.
Class for handling the PID weights per detector, used to calculate the track helix isolation score pe...
std::map< std::string, std::string > m_weightNames
The names of the per-detector weight columns in the RDataFrame.
PIDDetectorWeights()
Default constructor, necessary for ROOT to stream the object.
PIDDetectorWeights(const std::string &weightsCSVFileName)
Constructor from CSV file of weights.
ClassDef(PIDDetectorWeights, 4)
ClassDef as this is a TObject.
void fillWeightsTablePerHypoFromRDF()
Fill the internal weights container class per particle hypo, based on the content of the RDataFrame.
ROOT::RDataFrame m_weightsRDataFrame
The RDataFrame containing the detector weights per particle hypo, per phase space bin.
PIDDetectorWeights(const std::string &treeName, const std::string &weightsROOTFileName)
Constructor from ROOT file w/ TTree of weights.
ROOT::RDataFrame getWeightsRDF() const
Get the RDataFrame of detector weights.
double getWeight(Const::ChargedStable hypo, Const::EDetector det, double p, double theta) const
Lookup the weight from the internal map structures.
std::map< int, WeightsTable > m_weightsTablePerHypo
Map containing a WeightsTable object per particle hypo.
Abstract base class for different kinds of events.