Belle II Software light-2406-ragdoll
TrackIsoScoreCalculatorTest Class Reference

Test the calculation of the track helix-based isolation score per particle. More...

Inheritance diagram for TrackIsoScoreCalculatorTest:
Collaboration diagram for TrackIsoScoreCalculatorTest:

Public Attributes

Const::ChargedStable m_testHypo = Const::electron
 The charged particle hypothesis to test.
 
Const::EDetector m_detector = Const::ECL
 The detector to test.
 
int m_layer = 0
 The detector layer to test.
 
std::string m_dummyFile = "dummyFile.root"
 Dummy ROOT file name.
 

Protected Member Functions

void createDummyTTree ()
 Create a ROOT::TTree for the detector weights w/ a few entries.
 
void createDummyBrokenTTree ()
 Create a ROOT::TTree with a "broken" bin edges structure, i.e.
 
void SetUp () override
 Prepare resources for the tests.
 
void TearDown () override
 Release all resources.
 

Detailed Description

Test the calculation of the track helix-based isolation score per particle.

Definition at line 28 of file trackIsoScoreCalculator.cc.

Member Function Documentation

◆ createDummyBrokenTTree()

void createDummyBrokenTTree ( )
inlineprotected

Create a ROOT::TTree with a "broken" bin edges structure, i.e.

non-contiguous bin edges. This will throw a FATAL error, and indicate the CSV weights file has problems.

Definition at line 106 of file trackIsoScoreCalculator.cc.

107 {
108
109 unsigned int nEntries(6);
110
111 ROOT::RDataFrame rdf(nEntries);
112
113 std::vector<double> pdgIds(nEntries, static_cast<double>(m_testHypo.getPDGCode()));
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}; // note the non-contiguous edges wrt. pMinEdges
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};
120
121 // Tell snapshot to update file.
122 ROOT::RDF::RSnapshotOptions opt;
123 opt.fMode = "UPDATE";
124
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; })
133 .Snapshot("tree_broken", m_dummyFile, "", opt);
134
135 };
int getPDGCode() const
PDG code.
Definition: Const.h:473
Const::ChargedStable m_testHypo
The charged particle hypothesis to test.
std::string m_dummyFile
Dummy ROOT file name.

◆ createDummyTTree()

void createDummyTTree ( )
inlineprotected

Create a ROOT::TTree for the detector weights w/ a few entries.

This replicates the structure of the CSV weights file that are serialised in the payload.

Definition at line 61 of file trackIsoScoreCalculator.cc.

62 {
63
64 unsigned int nEntries(6);
65
66 ROOT::RDataFrame rdf(nEntries);
67
68 std::vector<double> pdgIds(nEntries, static_cast<double>(m_testHypo.getPDGCode()));
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};
82
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; }) // Only the last call in the chain must increment the entry counter!
98 .Snapshot("tree", m_dummyFile);
99
100 };

◆ SetUp()

void SetUp ( )
inlineoverrideprotected

Prepare resources for the tests.

Definition at line 140 of file trackIsoScoreCalculator.cc.

141 {
144 }
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.

◆ TearDown()

void TearDown ( )
inlineoverrideprotected

Release all resources.

Definition at line 149 of file trackIsoScoreCalculator.cc.

150 {
151 // Delete all dummy files.
152 if (remove(m_dummyFile.c_str())) {
153 B2ERROR("Couldn't remove file: " << m_dummyFile);
154 }
155 }

Member Data Documentation

◆ m_detector

Const::EDetector m_detector = Const::ECL

The detector to test.

Definition at line 40 of file trackIsoScoreCalculator.cc.

◆ m_dummyFile

std::string m_dummyFile = "dummyFile.root"

Dummy ROOT file name.

Files are created at the start of the test, and deleted at the end.

Definition at line 52 of file trackIsoScoreCalculator.cc.

◆ m_layer

int m_layer = 0

The detector layer to test.

Definition at line 45 of file trackIsoScoreCalculator.cc.

◆ m_testHypo

The charged particle hypothesis to test.

Definition at line 35 of file trackIsoScoreCalculator.cc.


The documentation for this class was generated from the following file: