Belle II Software development
PIDNeuralNetworkParameters.cc
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#include <analysis/dbobjects/PIDNeuralNetworkParameters.h>
10
11#include <framework/gearbox/Unit.h>
12#include <framework/gearbox/Const.h>
13#include <framework/logging/Logger.h>
14
15
16using namespace Belle2;
17
18
19int PIDNeuralNetworkParameters::pdg2OutputIndex(const int pdg, const bool throwException) const
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}
30
31
32size_t PIDNeuralNetworkParameters::getInputIndex(const std::string& name) const
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}
size_t getInputIndex(const std::string &name) const
Get input index for input name.
std::vector< std::string > m_inputNames
list of input names
std::vector< int > m_outputSpeciesPdg
PDG codes of hypotheses of neural-network output.
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...
Abstract base class for different kinds of events.