ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
AsgNumDecorationSelectionTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
AsgAnalysisAlgorithms/AsgNumDecorationSelectionTool.h
"
6
7
namespace
CP
8
{
9
10
#ifndef XAOD_STANDALONE
11
template
<
typename
T>
12
AsgNumDecorationSelectionTool<T>::AsgNumDecorationSelectionTool
(
13
const
std::string&
type
,
14
const
std::string& myname,
15
const
IInterface* parent)
16
:
asg
::
AsgTool
(
std
::string(
asg
::ptrToString(parent))+
"#"
+
type
+
"/"
+myname)
17
{
18
// cppcheck-suppress missingReturn; false positive
19
}
20
template
<
typename
T>
21
AsgNumDecorationSelectionTool<T>::~AsgNumDecorationSelectionTool
()
22
{
23
}
24
#else
25
template
<
typename
T>
26
AsgNumDecorationSelectionTool<T>::AsgNumDecorationSelectionTool
(
const
std::string& myname)
27
:
asg
::AsgTool(myname)
28
{
29
}
30
#endif
31
32
template
<
typename
T>
33
StatusCode
AsgNumDecorationSelectionTool<T>::initialize
()
34
{
35
if
(
m_doEqual
) {
36
if
(
m_doMin
||
m_doMax
) {
37
ATH_MSG_WARNING
(
"Equal cut overrides min/max on \""
<<
m_name
<<
"\"; disabling min/max."
);
38
m_doMin
=
false
;
39
m_doMax
=
false
;
40
}
41
ATH_MSG_DEBUG
(
"Applying "
<< m_name <<
" == "
<< m_equal <<
" selection"
);
42
m_equalCutIndex = m_accept.addCut(
"equal"
,
"Exact equality cut"
);
43
}
44
45
if
(m_doMin) {
46
ATH_MSG_DEBUG
(
"Applying "
<< m_name <<
" >= "
<< m_min <<
" selection"
);
47
m_minCutIndex = m_accept.addCut(
"min"
,
"Minimum cut"
);
48
}
49
50
if
(m_doMax) {
51
ATH_MSG_DEBUG
(
"Applying "
<< m_name <<
" < "
<< m_max <<
" selection"
);
52
m_maxCutIndex = m_accept.addCut(
"max"
,
"Maximum cut"
);
53
}
54
55
// Construct the decoration accessor for the desired type
56
m_accessor = std::make_unique<SG::ConstAccessor<T>>(
m_name
);
57
58
return
StatusCode::SUCCESS;
59
}
60
61
template
<
typename
T>
62
const
asg::AcceptInfo
&
AsgNumDecorationSelectionTool<T>::getAcceptInfo
()
const
63
{
64
return
m_accept
;
65
}
66
67
template
<
typename
T>
68
asg::AcceptData
AsgNumDecorationSelectionTool<T>::accept
(
const
xAOD::IParticle
*particle)
const
69
{
70
asg::AcceptData
accept
(&
m_accept
);
71
72
const
SG::AuxElement
* aux =
dynamic_cast<
const
SG::AuxElement
*
>
(particle);
73
if
(!aux) {
74
ATH_MSG_ERROR
(
"Particle is not derived from AuxElement, cannot read decoration. Cut considered as failed."
);
75
return
accept
;
// reject all cuts by default
76
}
77
78
if
(!
m_accessor
->isAvailable(*aux)) {
79
ATH_MSG_WARNING
(
"Decoration \""
<<
m_name
<<
"\" not available; setting all cuts as passed."
);
80
if
(
m_equalCutIndex
>= 0)
accept
.setCutResult(
m_equalCutIndex
,
true
);
81
if
(
m_minCutIndex
>= 0)
accept
.setCutResult(
m_minCutIndex
,
true
);
82
if
(
m_maxCutIndex
>= 0)
accept
.setCutResult(
m_maxCutIndex
,
true
);
83
return
accept
;
84
}
85
86
const
T value = (*m_accessor)(*aux);
87
88
if
(
m_equalCutIndex
>= 0) {
89
accept
.setCutResult(
m_equalCutIndex
,
static_cast<
float
>
(value) ==
m_equal
);
90
}
91
92
if
(
m_minCutIndex
>= 0) {
93
accept
.setCutResult(
m_minCutIndex
,
static_cast<
float
>
(value) >=
m_min
);
94
}
95
96
if
(
m_maxCutIndex
>= 0) {
97
accept
.setCutResult(
m_maxCutIndex
,
static_cast<
float
>
(value) <
m_max
);
98
}
99
100
return
accept
;
101
}
102
103
#ifndef XAOD_STANDALONE
104
AsgNumDecorationSelectionToolInt::AsgNumDecorationSelectionToolInt
(
105
const
std::string&
type
,
106
const
std::string& myname,
107
const
IInterface* parent)
108
:
AsgNumDecorationSelectionTool
<
int
>(
type
, myname, parent)
109
{
110
}
111
AsgNumDecorationSelectionToolUInt8::AsgNumDecorationSelectionToolUInt8
(
112
const
std::string&
type
,
113
const
std::string& myname,
114
const
IInterface* parent)
115
:
AsgNumDecorationSelectionTool
<
uint8_t
>(
type
, myname, parent)
116
{
117
}
118
#else
119
AsgNumDecorationSelectionToolInt::AsgNumDecorationSelectionToolInt
(
const
std::string& myname)
120
:
AsgNumDecorationSelectionTool
<
int
>(myname)
121
{
122
}
123
AsgNumDecorationSelectionToolUInt8::AsgNumDecorationSelectionToolUInt8
(
const
std::string& myname)
124
: AsgNumDecorationSelectionTool<
uint8_t
>(myname)
125
{
126
}
127
#endif
128
129
// Explicit template instantiations
130
template
class
AsgNumDecorationSelectionTool<int>
;
131
template
class
AsgNumDecorationSelectionTool<uint8_t>
;
132
133
}
AsgNumDecorationSelectionTool.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CP::AsgNumDecorationSelectionToolInt::AsgNumDecorationSelectionToolInt
AsgNumDecorationSelectionToolInt(const std::string &type, const std::string &myname, const IInterface *parent)
Definition
AsgNumDecorationSelectionTool.cxx:104
CP::AsgNumDecorationSelectionToolUInt8::AsgNumDecorationSelectionToolUInt8
AsgNumDecorationSelectionToolUInt8(const std::string &type, const std::string &myname, const IInterface *parent)
Definition
AsgNumDecorationSelectionTool.cxx:111
CP::AsgNumDecorationSelectionTool
a templated IAsgSelectionTool that performs basic cut on numerical decorations (e....
Definition
AsgNumDecorationSelectionTool.h:26
CP::AsgNumDecorationSelectionTool::getAcceptInfo
virtual const asg::AcceptInfo & getAcceptInfo() const override
Declare the interface ID for this pure-virtual interface class to the Athena framework.
Definition
AsgNumDecorationSelectionTool.cxx:62
CP::AsgNumDecorationSelectionTool::m_min
Gaudi::Property< float > m_min
Definition
AsgNumDecorationSelectionTool.h:53
CP::AsgNumDecorationSelectionTool::m_doMax
Gaudi::Property< bool > m_doMax
Definition
AsgNumDecorationSelectionTool.h:51
CP::AsgNumDecorationSelectionTool::accept
virtual asg::AcceptData accept(const xAOD::IParticle *particle) const override
The main accept method: the actual cuts are applied here.
Definition
AsgNumDecorationSelectionTool.cxx:68
CP::AsgNumDecorationSelectionTool::~AsgNumDecorationSelectionTool
virtual ~AsgNumDecorationSelectionTool()
Definition
AsgNumDecorationSelectionTool.cxx:21
CP::AsgNumDecorationSelectionTool::m_equal
Gaudi::Property< float > m_equal
Definition
AsgNumDecorationSelectionTool.h:52
CP::AsgNumDecorationSelectionTool::m_max
Gaudi::Property< float > m_max
Definition
AsgNumDecorationSelectionTool.h:54
CP::AsgNumDecorationSelectionTool< int >::m_name
Gaudi::Property< std::string > m_name
Definition
AsgNumDecorationSelectionTool.h:48
CP::AsgNumDecorationSelectionTool::AsgNumDecorationSelectionTool
AsgNumDecorationSelectionTool(const std::string &type, const std::string &myname, const IInterface *parent)
Definition
AsgNumDecorationSelectionTool.cxx:12
CP::AsgNumDecorationSelectionTool::m_equalCutIndex
int m_equalCutIndex
Definition
AsgNumDecorationSelectionTool.h:56
CP::AsgNumDecorationSelectionTool::m_doMin
Gaudi::Property< bool > m_doMin
Definition
AsgNumDecorationSelectionTool.h:50
CP::AsgNumDecorationSelectionTool::m_doEqual
Gaudi::Property< bool > m_doEqual
Definition
AsgNumDecorationSelectionTool.h:49
CP::AsgNumDecorationSelectionTool::m_maxCutIndex
int m_maxCutIndex
Definition
AsgNumDecorationSelectionTool.h:58
CP::AsgNumDecorationSelectionTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
AsgNumDecorationSelectionTool.cxx:33
CP::AsgNumDecorationSelectionTool::m_minCutIndex
int m_minCutIndex
Definition
AsgNumDecorationSelectionTool.h:57
CP::AsgNumDecorationSelectionTool::m_accept
asg::AcceptInfo m_accept
Definition
AsgNumDecorationSelectionTool.h:62
CP::AsgNumDecorationSelectionTool::m_accessor
std::unique_ptr< SG::ConstAccessor< T > > m_accessor
Definition
AsgNumDecorationSelectionTool.h:60
asg::AcceptData
Definition
AcceptData.h:31
asg::AcceptInfo
Definition
AcceptInfo.h:28
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
CxxUtils::m_name
std::string m_name
The primary name part of this expression.
Definition
CxxUtils/CxxUtils/ClassName.h:486
SG::AuxElement
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
asg
Definition
DataHandleTestTool.h:28
std
STL namespace.
xAOD::uint8_t
uint8_t
Definition
Muon_v1.cxx:500
xAOD::int
setRawEt setRawPhi int
Definition
TrigCaloCluster_v1.cxx:33
type
Generated on
for ATLAS Offline Software by
1.17.0