Belle II Software development
ChargedParticleIdentificatorTest Class Reference

Test the MVA-based charged PID. More...

Inheritance diagram for ChargedParticleIdentificatorTest:

Public Attributes

ChargedPidMVAWeights m_dbrep
 Database representation of MVA weightfiles.
 
Const::ChargedStable m_testHypo = Const::electron
 The signal charged particle hypothesis to test.
 
std::vector< double > m_thetabins = {0.2164208, 0.5480334, 0.561996, 2.2462387, 2.2811453, 2.7070057}
 The clusterTheta bin edges in [rad].
 
std::vector< double > m_pbins = {0.2, 0.6, 0.75, 1.0, 3.0, 7.0}
 The p bin edges in [GeV/c].
 
std::vector< double > m_chbins = { -1.5, -0.5, 0.5, 1.5}
 The charge bin edges.
 
std::string m_basename = "dummy_weightfile"
 Base common name for all dummy weight files.
 
std::vector< std::string > m_dummyfiles
 List of dummy xml file names.
 

Protected Member Functions

void SetUp () override
 Prepare resources for the tests.
 
void TearDown () override
 Release all resources.
 

Detailed Description

Test the MVA-based charged PID.

Definition at line 27 of file chargedParticleIdentificator.cc.

Member Function Documentation

◆ SetUp()

void SetUp ( )
inlineoverrideprotected

Prepare resources for the tests.

Definition at line 73 of file chargedParticleIdentificator.cc.

74 {
75
77 m_pbins.data(), m_pbins.size() - 1,
78 m_chbins.data(), m_chbins.size() - 1);
79
80 std::vector<std::tuple<double, double, double>> gridBinCentres;
81
82 for (unsigned int kch(0); kch < m_chbins.size() - 1; kch++) {
83 auto ch_bin_centre = (m_chbins.at(kch) + m_chbins.at(kch + 1)) / 2.0;
84 for (unsigned int ip(0); ip < m_pbins.size() - 1; ip++) {
85 auto p_bin_centre = (m_pbins.at(ip) + m_pbins.at(ip + 1)) / 2.0;
86 for (unsigned int jth(0); jth < m_thetabins.size() - 1; jth++) {
87 auto th_bin_centre = (m_thetabins.at(jth) + m_thetabins.at(jth + 1)) / 2.0;
88 auto fname = m_basename
89 + "__clusterTheta__" + std::to_string(m_thetabins.at(jth)) + "_" + std::to_string(m_thetabins.at(jth + 1))
90 + "__p__" + std::to_string(m_pbins.at(ip)) + "_" + std::to_string(m_pbins.at(ip + 1))
91 + "__charge__" + std::to_string(ch_bin_centre);
92
93 std::replace(fname.begin(), fname.end(), '.', '_');
94 fname += ".xml";
95 std::ofstream dummyfile(fname);
96 dummyfile.close();
97 m_dummyfiles.push_back(fname);
98
99 auto centre = std::make_tuple(th_bin_centre, p_bin_centre, ch_bin_centre);
100 gridBinCentres.push_back(centre);
101 }
102 }
103 }
105
106 }
Const::ChargedStable m_testHypo
The signal charged particle hypothesis to test.
std::vector< double > m_chbins
The charge bin edges.
std::vector< double > m_pbins
The p bin edges in [GeV/c].
std::string m_basename
Base common name for all dummy weight files.
ChargedPidMVAWeights m_dbrep
Database representation of MVA weightfiles.
std::vector< double > m_thetabins
The clusterTheta bin edges in [rad].
std::vector< std::string > m_dummyfiles
List of dummy xml file names.
void setWeightCategories(const double *clusterThetaBins, const int nClusterThetaBins, const double *pBins, const int nPBins, const double *chargeBins, const int nChargeBins)
Set the 3D (clusterTheta, p, charge) grid representing the categories for which weightfiles are defin...
void storeMVAWeights(const int pdg, const std::vector< std::string > &filepaths, const std::vector< std::tuple< double, double, double > > &categoryBinCentres)
Given a particle mass hypothesis' pdgId, store the list of MVA weight files (one for each category) i...
int getPDGCode() const
PDG code.
Definition: Const.h:473

◆ TearDown()

void TearDown ( )
inlineoverrideprotected

Release all resources.

Definition at line 111 of file chargedParticleIdentificator.cc.

112 {
113
114 // Delete all dummy files.
115 for (const auto& fname : m_dummyfiles) {
116 if (remove(fname.c_str())) {
117 B2ERROR("Couldn't remove file: " << fname);
118 }
119 }
120
121 }

Member Data Documentation

◆ m_basename

std::string m_basename = "dummy_weightfile"

Base common name for all dummy weight files.

Definition at line 59 of file chargedParticleIdentificator.cc.

◆ m_chbins

std::vector<double> m_chbins = { -1.5, -0.5, 0.5, 1.5}

The charge bin edges.

Definition at line 54 of file chargedParticleIdentificator.cc.

◆ m_dbrep

Database representation of MVA weightfiles.

Definition at line 34 of file chargedParticleIdentificator.cc.

◆ m_dummyfiles

std::vector<std::string> m_dummyfiles

List of dummy xml file names.

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

Definition at line 66 of file chargedParticleIdentificator.cc.

◆ m_pbins

std::vector<double> m_pbins = {0.2, 0.6, 0.75, 1.0, 3.0, 7.0}

The p bin edges in [GeV/c].

Definition at line 49 of file chargedParticleIdentificator.cc.

◆ m_testHypo

The signal charged particle hypothesis to test.

Definition at line 39 of file chargedParticleIdentificator.cc.

◆ m_thetabins

std::vector<double> m_thetabins = {0.2164208, 0.5480334, 0.561996, 2.2462387, 2.2811453, 2.7070057}

The clusterTheta bin edges in [rad].

Definition at line 44 of file chargedParticleIdentificator.cc.


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