9#include <framework/logging/Logger.h>
10#include <framework/gearbox/Const.h>
11#include <framework/gearbox/Unit.h>
12#include <framework/utilities/TestHelpers.h>
14#include <analysis/dbobjects/PIDDetectorWeights.h>
16#include <gtest/gtest.h>
64 unsigned int nEntries(6);
66 ROOT::RDataFrame rdf(nEntries);
69 std::vector<double> pMinEdges = {1.0, 1.0, 1.0, 1.5, 1.5, 1.5};
70 std::vector<double> pMaxEdges = {1.5, 1.5, 1.5, 3.0, 3.0, 3.0};
71 std::vector<double> thetaMinEdges = {0.22, 0.56, 2.23, 0.22, 0.56, 2.23};
72 std::vector<double> thetaMaxEdges = {0.56, 2.23, 2.71, 0.56, 2.23, 2.71};
73 std::vector<double> pBinIdxs = {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
74 std::vector<double> thetaBinIdxs = {1.0, 2.0, 3.0, 1.0, 2.0, 3.0};
75 std::vector<std::string> regLabels = {
"FWD",
"Barrel",
"BWD",
"FWD",
"Barrel",
"BWD"};
76 std::vector<double> weights_SVD = {0., 0., -0.003, 0.031, 0.017, 0.077};
77 std::vector<double> weights_CDC = {-0.061, -0.084, -0.162, -0.073, -0.073, -0.05, -0.121};
78 std::vector<double> weights_TOP = {0., 0., 0., 0., 0., 0.};
79 std::vector<double> weights_ARICH = {0., 0., 0., -0.004, 0., 0.};
80 std::vector<double> weights_ECL = {-0.062, -0.118, -0.136, -0.22, -0.255, -0.377};
81 std::vector<double> weights_KLM = {0., 0., 0.006, -0.003, 0.003, 0.002};
83 unsigned int iEntry(0);
84 rdf.Define(
"pdgId", [&]() {
auto x = pdgIds[iEntry];
return x; })
85 .Define(
"p_min", [&]() {
auto x = pMinEdges[iEntry];
return x; })
86 .Define(
"p_max", [&]() {
auto x = pMaxEdges[iEntry];
return x; })
87 .Define(
"theta_min", [&]() {
auto x = thetaMinEdges[iEntry];
return x; })
88 .Define(
"theta_max", [&]() {
auto x = thetaMaxEdges[iEntry];
return x; })
89 .Define(
"p_bin_idx", [&]() {
auto x = pBinIdxs[iEntry];
return x; })
90 .Define(
"theta_bin_idx", [&]() {
auto x = thetaBinIdxs[iEntry];
return x; })
91 .Define(
"reg_label", [&]() {
auto x = regLabels[iEntry];
return x; })
92 .Define(
"ablat_s_SVD", [&]() {
auto x = weights_SVD[iEntry];
return x; })
93 .Define(
"ablat_s_CDC", [&]() {
auto x = weights_CDC[iEntry];
return x; })
94 .Define(
"ablat_s_TOP", [&]() {
auto x = weights_TOP[iEntry];
return x; })
95 .Define(
"ablat_s_ARICH", [&]() {
auto x = weights_ARICH[iEntry];
return x; })
96 .Define(
"ablat_s_ECL", [&]() {
auto x = weights_ECL[iEntry];
return x; })
97 .Define(
"ablat_s_KLM", [&]() {
auto x = weights_KLM[iEntry]; ++iEntry;
return x; })
109 unsigned int nEntries(6);
111 ROOT::RDataFrame rdf(nEntries);
114 std::vector<double> pMinEdges = {1.0, 1.0, 1.0, 1.5, 1.5, 1.5};
115 std::vector<double> pMaxEdges = {1.8, 1.8, 1.8, 3.0, 3.0, 3.0};
116 std::vector<double> thetaMinEdges = {0.22, 0.56, 2.23, 0.22, 0.56, 2.23};
117 std::vector<double> thetaMaxEdges = {0.56, 2.23, 2.71, 0.56, 2.23, 2.71};
118 std::vector<double> pBinIdxs = {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
119 std::vector<double> thetaBinIdxs = {1.0, 2.0, 3.0, 1.0, 2.0, 3.0};
122 ROOT::RDF::RSnapshotOptions opt;
123 opt.fMode =
"UPDATE";
125 unsigned int iEntry(0);
126 rdf.Define(
"pdgId", [&]() {
auto x = pdgIds[iEntry];
return x; })
127 .Define(
"p_min", [&]() {
auto x = pMinEdges[iEntry];
return x; })
128 .Define(
"p_max", [&]() {
auto x = pMaxEdges[iEntry];
return x; })
129 .Define(
"theta_min", [&]() {
auto x = thetaMinEdges[iEntry];
return x; })
130 .Define(
"theta_max", [&]() {
auto x = thetaMaxEdges[iEntry];
return x; })
131 .Define(
"p_bin_idx", [&]() {
auto x = pBinIdxs[iEntry];
return x; })
132 .Define(
"theta_bin_idx", [&]() {
auto x = thetaBinIdxs[iEntry]; ++iEntry;
return x; })
169 auto pdgIds = dbrep.
getWeightsRDF().Take<
double>(
"pdgId").GetValue();
170 for (
const auto& pdgId : pdgIds) {
171 EXPECT_EQ(pdgId, m_testHypo.getPDGCode());
177 auto weight = dbrep.
getWeight(m_testHypo, m_detector, p, theta);
178 EXPECT_EQ(weight, -0.118);
183 weight = dbrep.
getWeight(m_testHypo, m_detector, p, theta);
184 EXPECT_TRUE(std::isnan(weight));
Provides a type-safe way to pass members of the chargedStableSet set.
int getPDGCode() const
PDG code.
EDetector
Enum for identifying the detector components (detector and subdetector).
static const ChargedStable electron
electron particle
Class for handling the PID weights per detector, used to calculate the track helix isolation score pe...
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.
Test the calculation of the track helix-based isolation score per particle.
Const::ChargedStable m_testHypo
The charged particle hypothesis to test.
Const::EDetector m_detector
The detector to test.
void SetUp() override
Prepare resources for the tests.
void createDummyBrokenTTree()
Create a ROOT::TTree with a "broken" bin edges structure, i.e.
void createDummyTTree()
Create a ROOT::TTree for the detector weights w/ a few entries.
void TearDown() override
Release all resources.
std::string m_dummyFile
Dummy ROOT file name.
int m_layer
The detector layer to test.
Abstract base class for different kinds of events.