Belle II Software light-2406-ragdoll
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 <framework/gearbox/Const.h>
12#include <framework/logging/Logger.h>
13
14#include <TObject.h>
15
16namespace Belle2 {
28 typedef std::vector<std::tuple<size_t, float>> PIDNNMissingInputs;
29
40 typedef std::vector< std::tuple<size_t, size_t, double, double, double> > PIDNNInputsToCut;
41
45 class PIDNeuralNetworkParameters: public TObject {
46
47 public:
50
54 PIDNeuralNetworkParameters(const std::string& description,
55 const std::vector<std::string>& inputNames,
56 const std::string& modelDefinition,
57 const std::vector<int>& outputSpeciesPdg,
58 const std::vector<float>& meanValues,
59 const std::vector<float>& standardDeviations,
60 const PIDNNMissingInputs& handleMissingInputs,
61 const PIDNNInputsToCut& inputsToCut
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 {}
72
79 int pdg2OutputIndex(const int pdg, const bool throwException = true) const;
80
87 bool hasPdgCode(const int pdg, const bool throwException = false) const {return pdg2OutputIndex(pdg, throwException) >= 0;}
88
93 const std::string& getModelDefinition() const {return m_modelDefinition;}
98 const std::vector<float>& getMeanValues() const {return m_meanValues;}
103 const std::vector<float>& getStandardDeviations() const {return m_standardDeviations;}
118 size_t getInputSize() const {return m_inputNames.size();}
123 const std::vector<std::string>& getInputNames() const {return m_inputNames;}
129 size_t getInputIndex(const std::string& name) const;
130
135 const std::string& getDescription() const {return m_description;}
136
142 const std::vector<int>& getOutputSpeciesPdg() const {return m_outputSpeciesPdg;}
143
144 private:
145
146 std::string m_description;
147 std::vector<std::string> m_inputNames;
148 std::string m_modelDefinition;
149 std::vector<int> m_outputSpeciesPdg;
150 std::vector<float> m_meanValues;
151 std::vector<float> m_standardDeviations;
157 };
158
160} // Belle2 namespace
161
162
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.
Definition: ClusterUtils.h:24