Belle II Software development
PIDNeuralNetworkParameters.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <TObject.h>
12
13namespace Belle2 {
25 typedef std::vector<std::tuple<size_t, float>> PIDNNMissingInputs;
26
37 typedef std::vector< std::tuple<size_t, size_t, double, double, double> > PIDNNInputsToCut;
38
42 class PIDNeuralNetworkParameters: public TObject {
43
44 public:
47
51 PIDNeuralNetworkParameters(const std::string& description,
52 const std::vector<std::string>& inputNames,
53 const std::string& modelDefinition,
54 const std::vector<int>& outputSpeciesPdg,
55 const std::vector<float>& meanValues,
56 const std::vector<float>& standardDeviations,
57 const PIDNNMissingInputs& handleMissingInputs,
58 const PIDNNInputsToCut& inputsToCut
59 ):
60 m_description(description),
61 m_inputNames(inputNames),
62 m_modelDefinition(modelDefinition),
63 m_outputSpeciesPdg(outputSpeciesPdg),
64 m_meanValues(meanValues),
65 m_standardDeviations(standardDeviations),
66 m_handleMissingInputs(handleMissingInputs),
67 m_inputsToCut(inputsToCut)
68 {}
69
76 int pdg2OutputIndex(const int pdg, const bool throwException = true) const;
77
84 bool hasPdgCode(const int pdg, const bool throwException = false) const {return pdg2OutputIndex(pdg, throwException) >= 0;}
85
90 const std::string& getModelDefinition() const {return m_modelDefinition;}
95 const std::vector<float>& getMeanValues() const {return m_meanValues;}
100 const std::vector<float>& getStandardDeviations() const {return m_standardDeviations;}
115 size_t getInputSize() const {return m_inputNames.size();}
120 const std::vector<std::string>& getInputNames() const {return m_inputNames;}
126 size_t getInputIndex(const std::string& name) const;
127
132 const std::string& getDescription() const {return m_description;}
133
139 const std::vector<int>& getOutputSpeciesPdg() const {return m_outputSpeciesPdg;}
140
141 private:
142
143 std::string m_description;
144 std::vector<std::string> m_inputNames;
145 std::string m_modelDefinition;
146 std::vector<int> m_outputSpeciesPdg;
147 std::vector<float> m_meanValues;
148 std::vector<float> m_standardDeviations;
154 };
155
157} // Belle2 namespace
158
159
Class for handling the parameters for the neural-network PID.
size_t getInputSize() const
Get number of inputs.
PIDNNInputsToCut m_inputsToCut
overwrite certain input variables
size_t getInputIndex(const std::string &name) const
Get input index for input name.
const PIDNNMissingInputs & getHandleMissingInputs() const
Get vector of input indices and corresponding values that are set if the corresponding input is NaN.
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::string & getDescription() const
Get neural network description.
std::vector< float > m_standardDeviations
standard deviations of inputs
ClassDef(PIDNeuralNetworkParameters, 1)
ClassDef as this is a TObject.
PIDNNMissingInputs m_handleMissingInputs
handling of NaN inputs
std::vector< std::string > m_inputNames
list of input names
const std::vector< float > & getStandardDeviations() const
Get the standard deviations of the inputs for normalization.
bool hasPdgCode(const int pdg, const bool throwException=false) const
std::string m_modelDefinition
neural network string for frugally-deep
const PIDNNInputsToCut & getInputsToCut() const
Get vector of input indices, whose values are overwritten if other input variables are in a certain r...
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.
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
const std::vector< int > & getOutputSpeciesPdg() const
Get the list of pdg codes of species hypotheses, for which the network predicts the probability in th...
const std::vector< std::string > & getInputNames() const
Get input names.
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...
std::vector< std::tuple< size_t, size_t, double, double, double > > PIDNNInputsToCut
Stores information on whether and how to overwrite certain inputs.
std::vector< std::tuple< size_t, float > > PIDNNMissingInputs
Stores information on how to handle missing inputs, i.e.
Abstract base class for different kinds of events.