ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
JetMissingEtID
JetSelectorTools
Root
JetAttributeSelector.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
JetSelectorTools/JetAttributeSelector.h
"
6
#include <limits>
7
8
namespace
{
9
10
template
<
class
T>
11
struct
ValueRetriever :
public
JetAttributeSelector::SelValueRetriever
{
12
ValueRetriever(
const
std::string &n) : acc(
n
) {}
13
virtual
float
value
(
const
xAOD::Jet
& j)
const override
{
return
acc(j);}
14
SG::AuxElement::Accessor<T> acc;
15
};
16
17
template
<
class
T>
18
struct
VecValueRetriever :
public
JetAttributeSelector::SelValueRetriever
{
19
VecValueRetriever(
const
std::string &n,
int
ind) : acc(
n
), index(
ind
) {}
20
virtual
float
value
(
const
xAOD::Jet
& j)
const override
{
return
acc(j)[index];}
21
SG::AuxElement::Accessor<std::vector<T> > acc;
22
int
index;
23
};
24
25
}
26
27
28
JetAttributeSelector::JetAttributeSelector
(
const
std::string &t)
29
:
asg
::
AsgTool
(t)
30
,
m_min
(-
std
::numeric_limits<float>::
max
())
31
,
m_max
(
std
::numeric_limits<float>::
max
())
32
,
m_attName
(
""
)
33
,
m_attType
(
"float"
)
34
,
m_vectorAttIndex
(0)
35
,
m_vretriever
(NULL)
36
{
37
38
declareProperty
(
"CutMin"
,
m_min
);
39
declareProperty
(
"CutMax"
,
m_max
);
40
declareProperty
(
"Attribute"
,
m_attName
) ;
41
declareProperty
(
"AttributeType"
,
m_attType
) ;
42
declareProperty
(
"VectorIndex"
,
m_vectorAttIndex
) ;
43
44
}
45
46
JetAttributeSelector:: ~JetAttributeSelector
(){
47
if
(
m_vretriever
)
delete
m_vretriever
;
48
}
49
50
51
JetAttributeSelector::SelValueRetriever
*
JetAttributeSelector::buildValueRetriever
(
const
std::string&
type
,
const
std::string& name,
int
index
){
52
SelValueRetriever
* retriever = NULL;
53
if
(
type
==
"float"
) retriever = new ::ValueRetriever<float>(name);
54
else
if
(
type
==
"int"
) retriever = new ::ValueRetriever<int>(name);
55
else
if
(
type
==
"vector<float>"
) retriever = new ::VecValueRetriever<float>(name,
index
);
56
else
if
(
type
==
"vector<int>"
) retriever = new ::VecValueRetriever<int>(name,
index
);
57
else
{
58
ATH_MSG_ERROR
(
"Unsupported attribute type : "
<<
type
);
59
// will return NULL
60
}
61
return
retriever;
62
}
63
64
65
StatusCode
JetAttributeSelector::initialize
() {
66
if
(
m_attName
==
""
) {
67
ATH_MSG_ERROR
(
"Please specify an attribute name"
);
68
return
StatusCode::FAILURE;
69
}
70
71
m_vretriever
=
buildValueRetriever
(
m_attType
,
m_attName
,
m_vectorAttIndex
);
72
if
(
m_vretriever
==NULL) {
73
ATH_MSG_ERROR
(
"Can't retrieve attribute type : "
<<
m_attType
<<
" name : "
<<
m_attName
);
74
return
StatusCode::FAILURE;
75
}
76
ATH_MSG_INFO
(
" will select on attribute of type : "
<<
m_attType
<<
". "
<<
m_min
<<
" < "
<<
m_attName
<<
" < "
<<
m_max
);
77
return
StatusCode::SUCCESS;
78
}
79
80
int
JetAttributeSelector::keep
(
const
xAOD::Jet
&
jet
)
const
{
81
float
v =
m_vretriever
->value(
jet
);
82
return
(
m_min
<= v ) && (v<=
m_max
);
83
}
84
85
86
JetAbsAttributeSelector::JetAbsAttributeSelector
(
const
std::string &t) :
JetAttributeSelector
(t) { }
87
88
int
JetAbsAttributeSelector::keep
(
const
xAOD::Jet
&
jet
)
const
{
89
float
v = fabs(
m_vretriever
->value(
jet
));
90
return
(
m_min
<= v ) && (v<=
m_max
);
91
}
92
93
JetAttributeRatioSelector::JetAttributeRatioSelector
(
const
std::string &t) :
JetAttributeSelector
(t)
94
,
m_attName2
(
""
)
95
,
m_attType2
(
"float"
)
96
,
m_vectorAttIndex2
(0)
97
,
m_vretriever2
(NULL) {
98
declareProperty
(
"Attribute2"
,
m_attName2
) ;
99
declareProperty
(
"AttributeType2"
,
m_attType2
) ;
100
declareProperty
(
"VectorIndex2"
,
m_vectorAttIndex2
) ;
101
102
}
103
104
105
StatusCode
JetAttributeRatioSelector::initialize
() {
106
ATH_CHECK
(
JetAttributeSelector::initialize
() );
107
108
m_vretriever2
=
buildValueRetriever
(
m_attType2
,
m_attName2
,
m_vectorAttIndex2
);
109
if
(
m_vretriever2
==NULL) {
110
ATH_MSG_ERROR
(
"Can't retrieve attribute type : "
<<
m_attType2
<<
" name : "
<<
m_attName2
);
111
return
StatusCode::FAILURE;
112
}
113
ATH_MSG_INFO
(
" will select on RATIO of attribute of type : "
<<
m_attType
<<
" , "
<<
m_attName
);
114
ATH_MSG_INFO
(
" over attribute of type : "
<<
m_attType2
<<
" , "
<<
m_attName
<<
" within "
<<
m_min
<<
" < r < "
<<
m_max
);
115
return
StatusCode::SUCCESS;
116
117
}
118
119
int
JetAttributeRatioSelector::keep
(
const
xAOD::Jet
&
jet
)
const
{
120
float
v1 =
m_vretriever
->value(
jet
);
121
float
v2 =
m_vretriever2
->value(
jet
);
122
if
( v2 == 0.)
return
false
;
123
double
r
= v1/v2;
124
return
(
m_min
<=
r
) && (
r
<=
m_max
);
125
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
JetAttributeSelector.h
define simple IJetSelector based on jet attributes
max
#define max(a, b)
Definition
cfImp.cxx:41
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
JetAbsAttributeSelector::keep
virtual int keep(const xAOD::Jet &jet) const
Method to select.
Definition
JetAttributeSelector.cxx:88
JetAbsAttributeSelector::JetAbsAttributeSelector
JetAbsAttributeSelector(const std::string &t)
Definition
JetAttributeSelector.cxx:86
JetAttributeRatioSelector::JetAttributeRatioSelector
JetAttributeRatioSelector(const std::string &t)
Definition
JetAttributeSelector.cxx:93
JetAttributeRatioSelector::m_vretriever2
SelValueRetriever * m_vretriever2
if the attribute is a vector we'll use the value at this index. else it is ignored.
Definition
JetAttributeSelector.h:97
JetAttributeRatioSelector::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition
JetAttributeSelector.cxx:105
JetAttributeRatioSelector::keep
virtual int keep(const xAOD::Jet &jet) const
Method to select.
Definition
JetAttributeSelector.cxx:119
JetAttributeRatioSelector::m_vectorAttIndex2
int m_vectorAttIndex2
Definition
JetAttributeSelector.h:96
JetAttributeRatioSelector::m_attType2
std::string m_attType2
Definition
JetAttributeSelector.h:94
JetAttributeRatioSelector::m_attName2
std::string m_attName2
Definition
JetAttributeSelector.h:93
JetAttributeSelector::~JetAttributeSelector
virtual ~JetAttributeSelector()
Definition
JetAttributeSelector.cxx:46
JetAttributeSelector::keep
virtual int keep(const xAOD::Jet &jet) const
Method to select.
Definition
JetAttributeSelector.cxx:80
JetAttributeSelector::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition
JetAttributeSelector.cxx:65
JetAttributeSelector::JetAttributeSelector
JetAttributeSelector(const std::string &t)
Definition
JetAttributeSelector.cxx:28
JetAttributeSelector::m_vretriever
SelValueRetriever * m_vretriever
if the attribute is a vector we'll use the value at this index. else it is ignored.
Definition
JetAttributeSelector.h:68
JetAttributeSelector::m_vectorAttIndex
int m_vectorAttIndex
Definition
JetAttributeSelector.h:67
JetAttributeSelector::m_max
float m_max
Definition
JetAttributeSelector.h:62
JetAttributeSelector::m_attName
std::string m_attName
Definition
JetAttributeSelector.h:64
JetAttributeSelector::buildValueRetriever
SelValueRetriever * buildValueRetriever(const std::string &type, const std::string &name, int index)
Definition
JetAttributeSelector.cxx:51
JetAttributeSelector::m_min
float m_min
Definition
JetAttributeSelector.h:61
JetAttributeSelector::m_attType
std::string m_attType
Definition
JetAttributeSelector.h:65
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
r
int r
Definition
globals.cxx:22
WriteLumiToCool.ind
int ind
Definition
WriteLumiToCool.py:198
asg
Definition
DataHandleTestTool.h:28
athena.value
value
Definition
athena.py:126
beamspotman.n
n
Definition
beamspotman.py:727
index
Definition
index.py:1
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
std
STL namespace.
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
type
JetAttributeSelector::SelValueRetriever
value on which this tool select jets.
Definition
JetAttributeSelector.h:46
Generated on
for ATLAS Offline Software by
1.17.0