Belle II Software light-2406-ragdoll
|
Class to contain the payload of MVA weightfiles needed for charged particle identification. More...
#include <ChargedPidMVAWeights.h>
Public Types | |
enum class | ChargedPidMVATrainingMode : unsigned int { c_Classification = 0 , c_Multiclass = 1 , c_ECL_Classification = 2 , c_ECL_Multiclass = 3 , c_PSD_Classification = 4 , c_PSD_Multiclass = 5 , c_ECL_PSD_Classification = 6 , c_ECL_PSD_Multiclass = 7 } |
A (strongly-typed) enumerator identifier for each valid MVA training mode. More... | |
Public Member Functions | |
ChargedPidMVAWeights () | |
Default constructor, necessary for ROOT to stream the object. | |
ChargedPidMVAWeights (const double &energyUnit, const double &angUnit, const std::string &thetaVarName="clusterTheta", bool implictNaNmasking=false) | |
Specialized constructor. | |
~ChargedPidMVAWeights () | |
Destructor. | |
void | setEnergyUnit (const double &unit) |
Set the energy unit to ensure consistency w/ the one used to define the bins grid. | |
void | setAngularUnit (const double &unit) |
Set the angular unit to ensure consistency w/ the one used to define the bins grid. | |
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 defined. | |
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) into the payload. | |
void | storeMVAWeightsMultiClass (const std::vector< std::string > &filepaths, const std::vector< std::tuple< double, double, double > > &categoryBinCentres) |
For the multi-class mode, store the list of MVA weight files (one for each category) into the payload. | |
void | storeCuts (const int pdg, const std::vector< std::string > &cutfiles, const std::vector< std::tuple< double, double, double > > &categoryBinCentres) |
Given a particle mass hypothesis' pdgId, store the list of selection cuts (one for each category) into the payload. | |
void | storeCutsMultiClass (const std::vector< std::string > &cutfiles, const std::vector< std::tuple< double, double, double > > &categoryBinCentres) |
For the multi-class mode, store the list of selection cuts (one for each category) into the payload. | |
void | storeAliases (const VariablesByAlias &aliases) |
Store the map associating variable aliases to variable names knowm to VariableManager. | |
const TH3F * | getWeightCategories () const |
Get the raw pointer to the 3D grid representing the categories for which weightfiles are defined. | |
const std::vector< std::string > * | getMVAWeights (const int pdg) const |
Given a particle mass hypothesis' pdgId, get the list of (serialized) MVA weightfiles stored in the payload, one for each category. | |
const std::vector< std::string > * | getMVAWeightsMulticlass () const |
For the multi-class mode, get the list of (serialized) MVA weightfiles stored in the payload, one for each category. | |
const std::vector< std::string > * | getCuts (const int pdg) const |
Given a particle mass hypothesis' pdgId, get the list of selection cuts stored in the payload, one for each category. | |
const std::vector< std::string > * | getCutsMulticlass () const |
For the multi-class mode, get the list of selection cuts stored in the payload, one for each category. | |
const VariablesByAlias * | getAliases () const |
Get the map of unique aliases. | |
unsigned int | getMVAWeightIdx (const double &theta, const double &p, const double &charge, int &idx_theta, int &idx_p, int &idx_charge) const |
Get the index of the XML weight file, for a given reconstructed triplet (clusterTheta(theta), p, charge). | |
unsigned int | getMVAWeightIdx (const double &theta, const double &p, const double &charge) const |
Overloaded method, to be used if not interested in knowing the 3D bin coordinates. | |
void | dumpPayload (const double &theta, const double &p, const double &charge, const int pdg, bool dump_all=false) const |
Read and dump the payload content from the internal 'matrioska' maps into an XML weightfile for the given set of inputs. | |
void | dumpPayloadMulticlass (const double &theta, const double &p, const double &charge) const |
Special version for multi-class mode. | |
bool | isValidPdg (const int pdg) const |
Check if the input pdgId is that of a valid charged particle. | |
std::string | getThetaVarName () const |
Get the name of the polar angle variable. | |
bool | hasImplicitNaNmasking () const |
Check flag for implicit NaN masking. | |
Private Types | |
typedef std::unordered_map< int, std::vector< std::string > > | WeightfilesByParticle |
Typedef. | |
typedef std::map< std::string, std::string > | VariablesByAlias |
Typedef. | |
Private Member Functions | |
int | findBin (const double &x, const double &y, const double &z) const |
Find global bin index of the 3D categories histogram for the given (x, y, z) values. | |
ClassDef (ChargedPidMVAWeights, 10) | |
2: add energy/angular units. | |
Private Attributes | |
TParameter< double > | m_energy_unit |
The energy unit used for defining the bins grid. | |
TParameter< double > | m_ang_unit |
The angular unit used for defining the bins grid. | |
std::string | m_thetaVarName |
The name of the polar angle variable used in the MVA categorisation. | |
bool | m_implicitNaNmasking |
Flag to indicate whether the MVA variables have been NaN-masked directly in the weightfiles. | |
std::unique_ptr< TH3F > | m_categories |
A 3D histogram whose bins represent the categories for which XML weight files are defined. | |
WeightfilesByParticle | m_weightfiles |
For each charged particle mass hypothesis' pdgId, this map contains a list of (serialized) Weightfile objects to be stored in the payload. | |
WeightfilesByParticle | m_cuts |
For each charged particle mass hypothesis' pdgId, this map contains a list of selection cuts to be stored in the payload. | |
VariablesByAlias | m_aliases |
A map that associates variable aliases used in the MVA training to variable names known to the VariableManager. | |
Class to contain the payload of MVA weightfiles needed for charged particle identification.
Definition at line 38 of file ChargedPidMVAWeights.h.
|
private |
Typedef.
Definition at line 41 of file ChargedPidMVAWeights.h.
|
private |
Typedef.
Definition at line 40 of file ChargedPidMVAWeights.h.
|
strong |
A (strongly-typed) enumerator identifier for each valid MVA training mode.
Definition at line 77 of file ChargedPidMVAWeights.h.
|
inline |
Default constructor, necessary for ROOT to stream the object.
Definition at line 48 of file ChargedPidMVAWeights.h.
|
inline |
Specialized constructor.
Definition at line 59 of file ChargedPidMVAWeights.h.
|
inline |
|
private |
2: add energy/angular units.
|
inline |
Read and dump the payload content from the internal 'matrioska' maps into an XML weightfile for the given set of inputs.
Useful for debugging.
theta | the particle polar angle (from the cluster, or from the track if no cluster match) in [rad]. |
p | the particle momentum (from the track) in [GeV/c]. |
charge | the particle charge (from the track). |
pdg | the particle mass hypothesis' pdgId. |
dump_all | dump all information. |
Definition at line 395 of file ChargedPidMVAWeights.h.
|
inline |
Special version for multi-class mode.
Uses the special value of pdg=0 reserved for multi-class mode.
Definition at line 442 of file ChargedPidMVAWeights.h.
|
inlineprivate |
Find global bin index of the 3D categories histogram for the given (x, y, z) values.
This method had to be re-implemented b/c ROOT has no const version of TH1::FindBin() :(
x | value along the x axis. |
y | value along the y axis. |
z | value along the z axis. |
Definition at line 487 of file ChargedPidMVAWeights.h.
|
inline |
Get the map of unique aliases.
Definition at line 337 of file ChargedPidMVAWeights.h.
|
inline |
Given a particle mass hypothesis' pdgId, get the list of selection cuts stored in the payload, one for each category.
pdg | the particle mass hypothesis' pdgId. |
Definition at line 317 of file ChargedPidMVAWeights.h.
|
inline |
For the multi-class mode, get the list of selection cuts stored in the payload, one for each category.
Uses the special value of pdg=0 reserved for multi-class mode.
Definition at line 328 of file ChargedPidMVAWeights.h.
|
inline |
Overloaded method, to be used if not interested in knowing the 3D bin coordinates.
Definition at line 379 of file ChargedPidMVAWeights.h.
|
inline |
Get the index of the XML weight file, for a given reconstructed triplet (clusterTheta(theta), p, charge).
The index is obtained by linearising the 3D m_categories
histogram. The same index can be used to look up the correct MVAExpert, Dataset and Cut in the application module, hence we believe it's more useful to return the index rather than a pointer to the weightfile itself. The function also retrieves the 3D bin coordinates.
theta | the particle polar angle (from the cluster, or from the track if no cluster match) in [rad]. | |
p | the particle momentum (from the track) in [GeV/c]. | |
charge | the particle charge (from the track). | |
[out] | idx_theta | the index of the 3D bin along the theta (X) axis. |
[out] | idx_p | the index of the 3D bin along the p (Y) axis. |
[out] | idx_charge | the index of the 3D bin along the charge (Z) axis. |
Definition at line 357 of file ChargedPidMVAWeights.h.
|
inline |
Given a particle mass hypothesis' pdgId, get the list of (serialized) MVA weightfiles stored in the payload, one for each category.
pdg | the particle mass hypothesis' pdgId. |
Definition at line 295 of file ChargedPidMVAWeights.h.
|
inline |
For the multi-class mode, get the list of (serialized) MVA weightfiles stored in the payload, one for each category.
Uses the special value of pdg=0 reserved for multi-class mode.
Definition at line 306 of file ChargedPidMVAWeights.h.
|
inline |
Get the name of the polar angle variable.
Definition at line 461 of file ChargedPidMVAWeights.h.
|
inline |
Get the raw pointer to the 3D grid representing the categories for which weightfiles are defined.
Used just to view the stored data.
Definition at line 284 of file ChargedPidMVAWeights.h.
|
inline |
Check flag for implicit NaN masking.
Definition at line 470 of file ChargedPidMVAWeights.h.
|
inline |
Check if the input pdgId is that of a valid charged particle.
An input value of pdg=0 is considered valid, since it's reserved for multi-class mode.
Definition at line 452 of file ChargedPidMVAWeights.h.
|
inline |
Set the angular unit to ensure consistency w/ the one used to define the bins grid.
Definition at line 106 of file ChargedPidMVAWeights.h.
|
inline |
Set the energy unit to ensure consistency w/ the one used to define the bins grid.
Definition at line 100 of file ChargedPidMVAWeights.h.
|
inline |
Set the 3D (clusterTheta, p, charge) grid representing the categories for which weightfiles are defined.
clusterThetaBins | array of clusterTheta bin edges |
nClusterThetaBins | number of clusterTheta bins |
pBins | array of p bin edges |
nPBins | number of p bins |
chargeBins | array of charge bin edges |
nChargeBins | number of charge bins |
Definition at line 117 of file ChargedPidMVAWeights.h.
|
inline |
Store the map associating variable aliases to variable names knowm to VariableManager.
aliases | a map of (alias, VM variable) pairs. NB: it is supposed to contain all the aliases for every category. |
Definition at line 274 of file ChargedPidMVAWeights.h.
|
inline |
Given a particle mass hypothesis' pdgId, store the list of selection cuts (one for each category) into the payload.
pdg | the particle mass hypothesis' pdgId. |
cutfiles | a list of text files w/ cut strings, for each (clusterTheta, p, charge) category. The format of the cut must comply with the GeneralCut syntax. |
categoryBinCentres | a list of <double, double, double> representing the (clusterTheta, p, charge) bin centres. Used to check consistency of the xml vector indexing w/ the linearised TH3 category map. |
Definition at line 213 of file ChargedPidMVAWeights.h.
|
inline |
For the multi-class mode, store the list of selection cuts (one for each category) into the payload.
Uses the special value of pdg=0 reserved for multi-class mode.
cutfiles | a list of text files w/ cut strings, for each (clusterTheta, p, charge) category. The format of the cut must comply with the GeneralCut syntax. |
categoryBinCentres | a list of <double, double, double> representing the (clusterTheta, p, charge) bin centres. Used to check consistency of the xml vector indexing w/ the linearised TH3 category map. |
Definition at line 262 of file ChargedPidMVAWeights.h.
|
inline |
Given a particle mass hypothesis' pdgId, store the list of MVA weight files (one for each category) into the payload.
pdg | the particle mass hypothesis' pdgId. |
filepaths | a list of xml (root) file paths for several (clusterTheta, p, charge) categories. |
categoryBinCentres | a list of <double, double, double> representing the (clusterTheta, p, charge) bin centres. Used to check consistency of the xml vector indexing w/ the linearised TH3 category map. |
Definition at line 138 of file ChargedPidMVAWeights.h.
|
inline |
For the multi-class mode, store the list of MVA weight files (one for each category) into the payload.
Uses the special value of pdg=0 reserved for multi-class mode.
filepaths | a list of xml (root) file paths for several (clusterTheta, p, charge) categories. |
categoryBinCentres | a list of <double, double, double> representing the (clusterTheta, p, charge) bin centres. Used to check consistency of the xml vector indexing w/ the linearised TH3 category map. |
Definition at line 196 of file ChargedPidMVAWeights.h.
|
private |
A map that associates variable aliases used in the MVA training to variable names known to the VariableManager.
Definition at line 576 of file ChargedPidMVAWeights.h.
|
private |
The angular unit used for defining the bins grid.
Definition at line 522 of file ChargedPidMVAWeights.h.
|
private |
A 3D histogram whose bins represent the categories for which XML weight files are defined.
It is used to lookup the correct file in the payload, given a reconstructed set of (clusterTheta(theta), p, charge).
Definition at line 532 of file ChargedPidMVAWeights.h.
|
private |
For each charged particle mass hypothesis' pdgId, this map contains a list of selection cuts to be stored in the payload.
To each Weightfile (i.e., category) corresponds a cut. The indexing in each vector must reflect the one of the corresponding 'linearised' TH3F histogram contained in the m_grids map.
The dummy pdgId=0 key is reserved for multi-class, where a unique signal hypothesis is not defined.
Definition at line 562 of file ChargedPidMVAWeights.h.
|
private |
The energy unit used for defining the bins grid.
Definition at line 521 of file ChargedPidMVAWeights.h.
|
private |
Flag to indicate whether the MVA variables have been NaN-masked directly in the weightfiles.
Definition at line 525 of file ChargedPidMVAWeights.h.
|
private |
The name of the polar angle variable used in the MVA categorisation.
Must be a string that can be parsed by the VariableManager.
Definition at line 524 of file ChargedPidMVAWeights.h.
|
private |
For each charged particle mass hypothesis' pdgId, this map contains a list of (serialized) Weightfile objects to be stored in the payload.
Each weightfile in the list corresponds to a 3D category. The indexing in each vector must reflect the one of the corresponding 'linearised' TH3F histogram contained in the m_grids map.
The dummy pdgId=0 key is reserved for multi-class, where a unique signal hypothesis is not defined.
Definition at line 543 of file ChargedPidMVAWeights.h.