Belle II Software development
PIDNeuralNetworkParameters Class Reference

Class for handling the parameters for the neural-network PID. More...

#include <PIDNeuralNetworkParameters.h>

Inheritance diagram for PIDNeuralNetworkParameters:

Public Member Functions

 PIDNeuralNetworkParameters ()
 Constructor.
 
 PIDNeuralNetworkParameters (const std::string &description, const std::vector< std::string > &inputNames, const std::string &modelDefinition, const std::vector< int > &outputSpeciesPdg, const std::vector< float > &meanValues, const std::vector< float > &standardDeviations, const PIDNNMissingInputs &handleMissingInputs, const PIDNNInputsToCut &inputsToCut)
 Construct with individual neural-network parameters.
 
int pdg2OutputIndex (const int pdg, const bool throwException=true) const
 Convert pdg code to the index of the neural-network output that represents the corresponding probability.
 
bool hasPdgCode (const int pdg, const bool throwException=false) const
 
const std::string & getModelDefinition () const
 Get the neural network model-definition string for frugally-deep.
 
const std::vector< float > & getMeanValues () const
 Get the mean values of the inputs for normalization.
 
const std::vector< float > & getStandardDeviations () const
 Get the standard deviations of the inputs for normalization.
 
const PIDNNMissingInputsgetHandleMissingInputs () const
 Get vector of input indices and corresponding values that are set if the corresponding input is NaN.
 
const PIDNNInputsToCutgetInputsToCut () const
 Get vector of input indices, whose values are overwritten if other input variables are in a certain range.
 
size_t getInputSize () const
 Get number of inputs.
 
const std::vector< std::string > & getInputNames () const
 Get input names.
 
size_t getInputIndex (const std::string &name) const
 Get input index for input name.
 
const std::string & getDescription () const
 Get neural network description.
 
const std::vector< int > & getOutputSpeciesPdg () const
 Get the list of pdg codes of species hypotheses, for which the network predicts the probability in the order defined by the network output layer.
 

Private Member Functions

 ClassDef (PIDNeuralNetworkParameters, 1)
 ClassDef as this is a TObject.
 

Private Attributes

std::string m_description
 description of neural network parameters
 
std::vector< std::string > m_inputNames
 list of input names
 
std::string m_modelDefinition
 neural network string for frugally-deep
 
std::vector< int > m_outputSpeciesPdg
 PDG codes of hypotheses of neural-network output.
 
std::vector< float > m_meanValues
 mean values of inputs
 
std::vector< float > m_standardDeviations
 standard deviations of inputs
 
PIDNNMissingInputs m_handleMissingInputs
 handling of NaN inputs
 
PIDNNInputsToCut m_inputsToCut
 overwrite certain input variables
 

Detailed Description

Class for handling the parameters for the neural-network PID.

Definition at line 45 of file PIDNeuralNetworkParameters.h.

Constructor & Destructor Documentation

◆ PIDNeuralNetworkParameters() [1/2]

Constructor.

Definition at line 49 of file PIDNeuralNetworkParameters.h.

49{}

◆ PIDNeuralNetworkParameters() [2/2]

PIDNeuralNetworkParameters ( const std::string &  description,
const std::vector< std::string > &  inputNames,
const std::string &  modelDefinition,
const std::vector< int > &  outputSpeciesPdg,
const std::vector< float > &  meanValues,
const std::vector< float > &  standardDeviations,
const PIDNNMissingInputs handleMissingInputs,
const PIDNNInputsToCut inputsToCut 
)
inline

Construct with individual neural-network parameters.

Definition at line 54 of file PIDNeuralNetworkParameters.h.

62 :
63 m_description(description),
64 m_inputNames(inputNames),
65 m_modelDefinition(modelDefinition),
66 m_outputSpeciesPdg(outputSpeciesPdg),
67 m_meanValues(meanValues),
68 m_standardDeviations(standardDeviations),
69 m_handleMissingInputs(handleMissingInputs),
70 m_inputsToCut(inputsToCut)
71 {}
PIDNNInputsToCut m_inputsToCut
overwrite certain input variables
std::vector< float > m_standardDeviations
standard deviations of inputs
PIDNNMissingInputs m_handleMissingInputs
handling of NaN inputs
std::vector< std::string > m_inputNames
list of input names
std::string m_modelDefinition
neural network string for frugally-deep
std::vector< float > m_meanValues
mean values of inputs
std::vector< int > m_outputSpeciesPdg
PDG codes of hypotheses of neural-network output.
std::string m_description
description of neural network parameters

Member Function Documentation

◆ getDescription()

const std::string & getDescription ( ) const
inline

Get neural network description.

Returns
const std::string& neural network description

Definition at line 135 of file PIDNeuralNetworkParameters.h.

135{return m_description;}

◆ getHandleMissingInputs()

const PIDNNMissingInputs & getHandleMissingInputs ( ) const
inline

Get vector of input indices and corresponding values that are set if the corresponding input is NaN.

Returns
const PIDNNMissingInputs& missing input handnling information

Definition at line 108 of file PIDNeuralNetworkParameters.h.

108{return m_handleMissingInputs;}

◆ getInputIndex()

size_t getInputIndex ( const std::string &  name) const

Get input index for input name.

Parameters
nameInput name that should be matched to a index
Returns
size_t input index, -1 if name not in inputs

Definition at line 32 of file PIDNeuralNetworkParameters.cc.

33{
34 const auto itr = std::find(m_inputNames.begin(), m_inputNames.end(), name);
35 if (itr == m_inputNames.end()) B2FATAL("Invalid input name: " << name);
36 return static_cast<size_t>(itr - m_inputNames.begin());
37}

◆ getInputNames()

const std::vector< std::string > & getInputNames ( ) const
inline

Get input names.

Returns
const std::vector<std::string>& input names

Definition at line 123 of file PIDNeuralNetworkParameters.h.

123{return m_inputNames;}

◆ getInputSize()

size_t getInputSize ( ) const
inline

Get number of inputs.

Returns
size_t number of inputs

Definition at line 118 of file PIDNeuralNetworkParameters.h.

118{return m_inputNames.size();}

◆ getInputsToCut()

const PIDNNInputsToCut & getInputsToCut ( ) const
inline

Get vector of input indices, whose values are overwritten if other input variables are in a certain range.

Returns
const PIDNNInputsToCut& overwrite inputs information

Definition at line 113 of file PIDNeuralNetworkParameters.h.

113{return m_inputsToCut;}

◆ getMeanValues()

const std::vector< float > & getMeanValues ( ) const
inline

Get the mean values of the inputs for normalization.

Returns
const std::vector<float>& input mean values

Definition at line 98 of file PIDNeuralNetworkParameters.h.

98{return m_meanValues;}

◆ getModelDefinition()

const std::string & getModelDefinition ( ) const
inline

Get the neural network model-definition string for frugally-deep.

Returns
const std::string& model-definition string

Definition at line 93 of file PIDNeuralNetworkParameters.h.

93{return m_modelDefinition;}

◆ getOutputSpeciesPdg()

const std::vector< int > & getOutputSpeciesPdg ( ) const
inline

Get the list of pdg codes of species hypotheses, for which the network predicts the probability in the order defined by the network output layer.

Returns
const std::vector<int>& list of pdg codes of hypotheses predicted by the network

Definition at line 142 of file PIDNeuralNetworkParameters.h.

142{return m_outputSpeciesPdg;}

◆ getStandardDeviations()

const std::vector< float > & getStandardDeviations ( ) const
inline

Get the standard deviations of the inputs for normalization.

Returns
const std::vector<float>& input standard deviations

Definition at line 103 of file PIDNeuralNetworkParameters.h.

103{return m_standardDeviations;}

◆ hasPdgCode()

bool hasPdgCode ( const int  pdg,
const bool  throwException = false 
) const
inline
Parameters
pdgpdg code of hypothesis
throwExceptionthrow exception if pdg code is not predicted
Returns
true if neural network predicts probability for the given hypothesis
false if neural network does not predict probability for the given hypothesis

Definition at line 87 of file PIDNeuralNetworkParameters.h.

87{return pdg2OutputIndex(pdg, throwException) >= 0;}
int pdg2OutputIndex(const int pdg, const bool throwException=true) const
Convert pdg code to the index of the neural-network output that represents the corresponding probabil...

◆ pdg2OutputIndex()

int pdg2OutputIndex ( const int  pdg,
const bool  throwException = true 
) const

Convert pdg code to the index of the neural-network output that represents the corresponding probability.

Parameters
pdgPDG code for particle-species hypothesis
throwExceptionthrow exception if pdg code is not predicted
Returns
int Index of neural-network output. -1 if pdg code not predicted by neural network

Definition at line 19 of file PIDNeuralNetworkParameters.cc.

20{
21 const auto itr = std::find(m_outputSpeciesPdg.begin(), m_outputSpeciesPdg.end(), pdg);
22 if (itr == m_outputSpeciesPdg.end()) {
23 if (throwException)
24 B2FATAL("Invalid particle-species hypothesis: " << pdg
25 << ". PID neural network is not trained for this particle-species hypothesis");
26 return -1;
27 }
28 return static_cast<size_t>(itr - m_outputSpeciesPdg.begin());
29}

Member Data Documentation

◆ m_description

std::string m_description
private

description of neural network parameters

Definition at line 146 of file PIDNeuralNetworkParameters.h.

◆ m_handleMissingInputs

PIDNNMissingInputs m_handleMissingInputs
private

handling of NaN inputs

Definition at line 152 of file PIDNeuralNetworkParameters.h.

◆ m_inputNames

std::vector<std::string> m_inputNames
private

list of input names

Definition at line 147 of file PIDNeuralNetworkParameters.h.

◆ m_inputsToCut

PIDNNInputsToCut m_inputsToCut
private

overwrite certain input variables

Definition at line 153 of file PIDNeuralNetworkParameters.h.

◆ m_meanValues

std::vector<float> m_meanValues
private

mean values of inputs

Definition at line 150 of file PIDNeuralNetworkParameters.h.

◆ m_modelDefinition

std::string m_modelDefinition
private

neural network string for frugally-deep

Definition at line 148 of file PIDNeuralNetworkParameters.h.

◆ m_outputSpeciesPdg

std::vector<int> m_outputSpeciesPdg
private

PDG codes of hypotheses of neural-network output.

Definition at line 149 of file PIDNeuralNetworkParameters.h.

◆ m_standardDeviations

std::vector<float> m_standardDeviations
private

standard deviations of inputs

Definition at line 151 of file PIDNeuralNetworkParameters.h.


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