All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MVAPID.cc
Go to the documentation of this file.
2 
3 #include "cetlib_except/exception.h"
4 #include "messagefacility/MessageLogger/MessageLogger.h"
5 
6 #include <algorithm>
7 
8 void sbn::MVAPID::AddScore(int pdg, float score)
9 {
10  if (!mvaScoreMap.try_emplace(pdg, score).second)
11  throw cet::exception("MVAPID") << "Failed to add entry: " << pdg << " to MVA PID score map as it already exists" << std::endl;
12 }
13 
14 std::pair<int, float> sbn::MVAPID::BestIter() const
15 {
16  auto iter = std::max_element(mvaScoreMap.begin(), mvaScoreMap.end(), [](auto const& lhs, auto const& rhs) { return lhs.second < rhs.second; });
17 
18  if (iter == mvaScoreMap.end()) {
19  mf::LogError("MVAPID") << "Failed to find max element in map" << std::endl;
20  return {-1, std::numeric_limits<float>::lowest()};
21  }
22 
23  return *iter;
24 }
var pdg
Definition: selectors.fcl:14
BEGIN_PROLOG or score(default)}sbnd_crttrackmatchingalg_crID
void AddScore(int pdg, float score)
Definition: MVAPID.cc:8
std::pair< int, float > BestIter() const
Definition: MVAPID.cc:14
std::map< int, float > mvaScoreMap
Definition: MVAPID.h:13