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/logging/Logger.h>
12
13#include <algorithm>
14
15using namespace Belle2;
16
17
18int PIDNeuralNetworkParameters::pdg2OutputIndex(const int pdg, const bool throwException) const
19{
20 const auto itr = std::find(m_outputSpeciesPdg.begin(), m_outputSpeciesPdg.end(), pdg);
21 if (itr == m_outputSpeciesPdg.end()) {
22 if (throwException)
23 B2FATAL("Invalid particle-species hypothesis: " << pdg
24 << ". PID neural network is not trained for this particle-species hypothesis");
25 return -1;
26 }
27 return static_cast<size_t>(itr - m_outputSpeciesPdg.begin());
28}
29
30
31size_t PIDNeuralNetworkParameters::getInputIndex(const std::string& name) const
32{
33 const auto itr = std::find(m_inputNames.begin(), m_inputNames.end(), name);
34 if (itr == m_inputNames.end()) B2FATAL("Invalid input name: " << name);
35 return static_cast<size_t>(itr - m_inputNames.begin());
36}
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.