11 #include <framework/logging/Logger.h>
12 #include <framework/gearbox/Const.h>
13 #include <framework/gearbox/Unit.h>
15 #include <analysis/dbobjects/ChargedPidMVAWeights.h>
17 #include <gtest/gtest.h>
28 class ChargedParticleIdentificatorTest :
public ::testing::Test {
45 std::unique_ptr<TH2F>
m_grid;
50 std::vector<float>
m_thetabins = {0.2164208, 0.5480334, 0.561996, 2.2462387, 2.2811453, 2.7070057};
55 std::vector<float>
m_pbins = {0.0, 0.5, 0.75, 1.0, 3.0, 100.0};
82 m_grid = std::make_unique<TH2F>(
"theta_p_binsgrid",
83 ";ECL cluster #theta;p_{lab}",
94 std::vector<std::pair<float, float>> gridBinCentres;
96 for (
unsigned int ip(0); ip <
m_pbins.size() - 1; ip++) {
98 for (
unsigned int jth(0); jth <
m_thetabins.size() - 1; jth++) {
101 +
"__p__" + std::to_string(
m_pbins.at(ip)) +
"_" + std::to_string(
m_pbins.at(ip + 1))
102 +
"__clusterTheta__" + std::to_string(
m_thetabins.at(jth)) +
"_" + std::to_string(
m_thetabins.at(jth + 1));
103 std::replace(fname.begin(), fname.end(),
'.',
'_');
105 std::ofstream dummyfile(fname);
109 auto centre = std::make_pair(th_bin_centre, p_bin_centre);
110 gridBinCentres.push_back(centre);
125 if (remove(fname.c_str())) {
126 B2ERROR(
"Couldn't remove file: " << fname);
138 TEST_F(ChargedParticleIdentificatorTest, TestDBRep)
144 auto theta = m_grid->GetXaxis()->GetBinCenter(binx);
145 auto p = m_grid->GetYaxis()->GetBinCenter(biny);
148 auto ji = m_dbrep.getMVAWeightIdx(theta, p, jth, ip);
150 EXPECT_EQ(jth, binx);
153 auto thisfname = m_basename
154 +
"__p__" + std::to_string(m_pbins.at(ip - 1)) +
"_" + std::to_string(m_pbins.at(ip))
155 +
"__clusterTheta__" + std::to_string(m_thetabins.at(jth - 1)) +
"_" + std::to_string(m_thetabins.at(jth));
156 std::replace(thisfname.begin(), thisfname.end(),
'.',
'_');
159 EXPECT_EQ(thisfname, m_dummyfiles.at(ji));
161 auto matchitr = std::find(m_dummyfiles.begin(), m_dummyfiles.end(), thisfname);
162 auto thisidx = std::distance(m_dummyfiles.begin(), matchitr);
164 EXPECT_EQ(thisidx, ji);