ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
PanTau
PanTauAlgs
Root
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
5
#include "
PanTauAlgs/TauFeature.h
"
6
7
#include <cmath>
8
#include <stdexcept>
9
10
static
const
std::vector<double>
s_defaultVec
(0);
11
12
PanTau::TauFeature::TauFeature
():
13
m_featureMap
(),
14
m_vecFeatureMap
()
15
{
16
}
17
18
19
PanTau::TauFeature::~TauFeature
()
20
=
default
;
21
22
23
double
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
35
const
std::vector<double>&
PanTau::TauFeature::vecValue
(
const
std::string& name)
const
{
36
VectorFeatureMapConstIter
iter =
m_vecFeatureMap
.find(name);
37
if
(
m_vecFeatureMap
.end() == iter) {
38
return
s_defaultVec
;
39
}
40
return
(*iter).second;
41
}
42
43
44
bool
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
57
bool
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
64
int
PanTau::TauFeature::nValues
()
const
{
65
return
m_featureMap
.size();
66
}
67
68
69
int
PanTau::TauFeature::nVecValues
()
const
{
70
return
m_vecFeatureMap
.size();
71
}
72
73
// FIXME: use StatusCode instead of throwing exceptions
74
void
PanTau::TauFeature::add
(
PanTau::TauFeature
* otherFeatures) {
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
}
isValid
bool isValid() const
Test to see if the link can be dereferenced.
s_defaultVec
static const std::vector< double > s_defaultVec(0)
TauFeature.h
PanTau::TauFeature
Class containing features of a tau seed.
Definition
TauFeature.h:19
PanTau::TauFeature::nValues
int nValues() const
returns the size of the m_featureMap
Definition
TauFeature.cxx:64
PanTau::TauFeature::m_featureMap
FeatureMap m_featureMap
The map containg all features.
Definition
TauFeature.h:61
PanTau::TauFeature::m_vecFeatureMap
VectorFeatureMap m_vecFeatureMap
The map containg all features.
Definition
TauFeature.h:63
PanTau::TauFeature::nVecValues
int nVecValues() const
returns the size of the m_vecFeatureMap
Definition
TauFeature.cxx:69
PanTau::TauFeature::addFeature
bool addFeature(const std::string &name, const double value)
adds a new feature
Definition
TauFeature.cxx:44
PanTau::TauFeature::FeatureMapConstIter
FeatureMap::const_iterator FeatureMapConstIter
Definition
TauFeature.h:23
PanTau::TauFeature::VectorFeatureMapConstIter
VectorFeatureMap::const_iterator VectorFeatureMapConstIter
Definition
TauFeature.h:26
PanTau::TauFeature::addVecFeature
bool addVecFeature(const std::string &name, const std::vector< double > &value)
adds a new vector feature
Definition
TauFeature.cxx:57
PanTau::TauFeature::TauFeature
TauFeature()
Default constructor.
Definition
TauFeature.cxx:12
PanTau::TauFeature::value
double value(const std::string &name, bool &isValid) const
returns the value of the feature given by its name
Definition
TauFeature.cxx:23
PanTau::TauFeature::add
void add(PanTau::TauFeature *otherFeatures)
Definition
TauFeature.cxx:74
PanTau::TauFeature::vecValue
const std::vector< double > & vecValue(const std::string &name) const
returns the value of a vector feature given by its name
Definition
TauFeature.cxx:35
PanTau::TauFeature::~TauFeature
virtual ~TauFeature()
Destructor.
Generated on
for ATLAS Offline Software by
1.17.0