11#include <analysis/VariableManager/Manager.h>
12#include <analysis/dbobjects/PIDNeuralNetworkParameters.h>
13#include <framework/database/DBObjPtr.h>
14#include <framework/logging/Logger.h>
16#include <framework/gearbox/Const.h>
18#define FDEEP_FLOAT_TYPE float
19#include <fdeep/fdeep.hpp>
78 std::map<int, double>
predict(std::vector<float> inputs)
const;
84 size_t getInputSize()
const {
return (*m_pidNeuralNetworkParametersDB)->getInputSize(); }
97 const std::vector<int>&
getOutputSpeciesPdg()
const {
return (*m_pidNeuralNetworkParametersDB)->getOutputSpeciesPdg();}
111 bool hasPdgCode(
const int pdg,
const bool throwException =
false)
const {
return (*m_pidNeuralNetworkParametersDB)->hasPdgCode(pdg, throwException);}
147 B2FATAL(
"PID neural network needs input '" + name +
"', but this input is not available!");
Class to call PID neural network.
PIDNeuralNetwork(const std::string ¶meterName)
Constructor with given paramenter-set name.
size_t getInputSize() const
Get number of inputs.
PIDNeuralNetwork()
Constructor with default paramenter-set name.
const std::string & getExtraInfoName(const int pdg) const
std::vector< std::string > m_inputBasf2Names
list of input names of input variables in the basf2 naming scheme
std::string m_pidNeuralNetworkParametersName
name of the parameter set
const std::string & getPIDNeuralNetworkParametersName() const
Get the name of the used neural network.
void loadParametersFromDB()
Load neural-network parameters with name m_pidNeuralNetworkParametersName from the conditions data ba...
std::map< int, double > predict(std::vector< float > inputs) const
Predict neural-network output for all implemented hypotheses using the given inputs.
void check()
Check that Neural Network can be evaluated, e.g.
bool hasPdgCode(const int pdg, const bool throwException=false) const
std::unique_ptr< const fdeep::model > m_model
frugally-deep neural network
const std::vector< std::string > & getInputBasf2Names() const
Get names of input variables in the basf2 naming scheme, which may be different from the one in the p...
PIDNeuralNetwork(PIDNeuralNetwork &&other)
Move constructor.
const std::vector< int > & getOutputSpeciesPdg() const
Get the list of pdg codes of species hypotheses, for which the network predicts the probability in th...
std::map< int, std::string > m_extraInfoNames
map from PDG code to extraInfo name that stores the output of this network
std::unique_ptr< DBObjPtr< PIDNeuralNetworkParameters > > m_pidNeuralNetworkParametersDB
db object for the parameter set
static Manager & Instance()
get singleton instance.
Abstract base class for different kinds of events.