ATLAS Offline Software
Loading...
Searching...
No Matches
TauFeature.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <cmath>
8#include <stdexcept>
9
10static const std::vector<double> s_defaultVec(0);
11
17
18
20= default;
21
22
23double PanTau::TauFeature::value(const std::string& name, bool& isValid) const
24{
25 FeatureMapConstIter iter = m_featureMap.find(name);
26 if (m_featureMap.end() == iter) {
27 isValid=false;
28 return -999999.;
29 }
30 isValid=true;
31 return (*iter).second;
32}
33
34
35const std::vector<double>& PanTau::TauFeature::vecValue(const std::string& name) const {
37 if (m_vecFeatureMap.end() == iter) {
38 return s_defaultVec;
39 }
40 return (*iter).second;
41}
42
43
44bool PanTau::TauFeature::addFeature(const std::string& name, const double value) {
45
46 if (std::isnan(value)) {
47 throw std::runtime_error("TauFeature::addFeature: Given " + name + " value is NaN!");
48 }
49 if (std::isinf(value)){
50 throw std::runtime_error("TauFeature::addFeature: Given " + name + " value is inf!");
51 }
52 std::pair<FeatureMapConstIter, bool> result = m_featureMap.insert(make_pair(name, value));
53 return result.second;
54}
55
56
57bool PanTau::TauFeature::addVecFeature(const std::string& name,
58 const std::vector<double>& value) {
59 std::pair<VectorFeatureMapConstIter, bool> result = m_vecFeatureMap.insert(make_pair(name, value));
60 return result.second;
61}
62
63
65 return m_featureMap.size();
66}
67
68
70 return m_vecFeatureMap.size();
71}
72
73// FIXME: use StatusCode instead of throwing exceptions
75
76 //add the scalar features
77 for (const auto& p : otherFeatures->m_featureMap) {
78 if (!(this->addFeature(p.first, p.second))) {
79 throw std::runtime_error("PanTau::TauFeature::add( PanTau::TauFeature* ): Error when adding scalar feature " + p.first);
80 }
81 }
82
83 //add the vector features
84 for (const auto& p : otherFeatures->m_vecFeatureMap) {
85 if (!(this->addVecFeature(p.first, p.second))) {
86 throw std::runtime_error("PanTau::TauFeature::add( PanTau::TauFeature* ): Error when adding vector feature " + p.first);
87 }
88 }
89}
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
static const std::vector< double > s_defaultVec(0)
Class containing features of a tau seed.
Definition TauFeature.h:19
int nValues() const
returns the size of the m_featureMap
FeatureMap m_featureMap
The map containg all features.
Definition TauFeature.h:61
VectorFeatureMap m_vecFeatureMap
The map containg all features.
Definition TauFeature.h:63
int nVecValues() const
returns the size of the m_vecFeatureMap
bool addFeature(const std::string &name, const double value)
adds a new feature
FeatureMap::const_iterator FeatureMapConstIter
Definition TauFeature.h:23
VectorFeatureMap::const_iterator VectorFeatureMapConstIter
Definition TauFeature.h:26
bool addVecFeature(const std::string &name, const std::vector< double > &value)
adds a new vector feature
TauFeature()
Default constructor.
double value(const std::string &name, bool &isValid) const
returns the value of the feature given by its name
void add(PanTau::TauFeature *otherFeatures)
const std::vector< double > & vecValue(const std::string &name) const
returns the value of a vector feature given by its name
virtual ~TauFeature()
Destructor.