ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetRecTools
JetRecTools
WriteDecorHandleTriplet.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#pragma once
6
9
10
#include "
AsgTools/AsgTool.h
"
11
#include "
xAODBase/IParticleContainer.h
"
12
#include "
xAODPFlow/FlowElementContainer.h
"
13
#include "
xAODPFlow/FlowElementAuxContainer.h
"
14
#include "
xAODCaloEvent/CaloClusterContainer.h
"
15
#include "
xAODTracking/TrackParticleContainer.h
"
16
#include "
xAODPFlow/FlowElement.h
"
17
#include "
xAODPFlow/PFO.h
"
18
#include "
AsgDataHandles/WriteDecorHandle.h
"
19
#include "
AsgDataHandles/WriteDecorHandleKey.h
"
20
#include <memory>
21
#include <stdexcept>
22
23
template
<
typename
T>
24
class
WriteDecorHandleTriplet
25
{
26
std::unique_ptr<SG::WriteDecorHandle<xAOD::IParticleContainer, T>>
m_standard
;
27
std::unique_ptr<SG::WriteDecorHandle<xAOD::IParticleContainer, T>>
m_charged
;
28
std::unique_ptr<SG::WriteDecorHandle<xAOD::IParticleContainer, T>>
m_neutral
;
29
unsigned
short
m_objectType
{};
30
31
void
checkType
() {
32
switch
(
m_objectType
) {
33
case
xAOD::Type::CaloCluster
:
34
case
xAOD::Type::TrackCaloCluster
:
35
case
xAOD::Type::ParticleFlow
:
36
case
xAOD::Type::FlowElement
:
37
return
;
38
break
;
39
40
default
:
41
throw
std::runtime_error(
42
"WriteDecorHandleTriplet: Unsupported input type "
+
43
std::to_string(
static_cast<
int
>
(
m_objectType
)));
44
}
45
46
}
47
48
public
:
49
50
void
setObjectType
(
unsigned
short
type
)
51
{
52
m_objectType
=
type
;
53
checkType
();
54
}
55
56
void
setStandard
(
57
const
SG::WriteDecorHandleKey<xAOD::IParticleContainer>
& key,
58
const
EventContext& ctx)
59
{
60
m_standard
=
61
std::make_unique<
62
SG::WriteDecorHandle<xAOD::IParticleContainer,T>
63
>(key, ctx);
64
}
65
66
void
setCharged
(
67
const
SG::WriteDecorHandleKey<xAOD::IParticleContainer>
& key,
68
const
EventContext& ctx)
69
{
70
m_charged
=
71
std::make_unique<
72
SG::WriteDecorHandle<xAOD::IParticleContainer,T>
73
>(key, ctx);
74
}
75
76
void
setNeutral
(
77
const
SG::WriteDecorHandleKey<xAOD::IParticleContainer>
& key,
78
const
EventContext& ctx)
79
{
80
m_neutral
=
81
std::make_unique<
82
SG::WriteDecorHandle<xAOD::IParticleContainer,T>
83
>(key, ctx);
84
}
85
86
T&
operator()
(
const
xAOD::IParticle
& part)
87
{
88
switch
(
m_objectType
) {
89
90
case
xAOD::Type::CaloCluster
:
91
case
xAOD::Type::TrackCaloCluster
:
92
return
(*
m_standard
)(part);
93
94
case
xAOD::Type::ParticleFlow
:
95
{
96
auto
& pfo =
static_cast<
const
xAOD::PFO
&
>
(part);
97
return
pfo.isCharged()
98
? (*m_charged)(pfo)
99
: (*m_neutral)(pfo);
100
}
101
102
case
xAOD::Type::FlowElement
:
103
{
104
auto
& fe =
static_cast<
const
xAOD::FlowElement
&
>
(part);
105
return
fe.isCharged()
106
? (*m_charged)(fe)
107
: (*m_neutral)(fe);
108
}
109
110
default
:
111
throw
std::runtime_error(
"WriteDecorHandleTriplet: Unsupported input type"
);
112
}
113
}
114
};
115
116
template
<
typename
T>
117
class
WriteDecorHandleKeyTriplet
118
{
119
SG::WriteDecorHandleKey<xAOD::IParticleContainer>
m_standard
;
120
SG::WriteDecorHandleKey<xAOD::IParticleContainer>
m_charged
;
121
SG::WriteDecorHandleKey<xAOD::IParticleContainer>
m_neutral
;
122
123
static
bool
startsWith
(
124
const
std::string& value,
125
const
std::string& prefix)
126
{
127
return
value.compare(0, prefix.size(), prefix) == 0;
128
}
129
130
public
:
131
132
WriteDecorHandleKeyTriplet
(
133
asg::AsgTool
* owner,
134
const
std::string& propertyName,
135
const
std::string& decorName,
136
const
std::string&
description
)
137
:
m_standard
(
138
owner,
139
propertyName.c_str(),
140
decorName.c_str(),
141
description
.c_str())
142
,
m_charged
(
143
owner,
144
(
"Charged"
+ propertyName).c_str(),
145
decorName.c_str(),
146
(
"Charged "
+
description
).c_str())
147
,
m_neutral
(
148
owner,
149
(
"Neutral"
+ propertyName).c_str(),
150
decorName.c_str(),
151
(
"Neutral "
+
description
).c_str())
152
{}
153
154
StatusCode
assign
(
155
const
std::string& standardCont,
156
const
std::string& chargedCont,
157
const
std::string& neutralCont)
158
{
159
if
(!standardCont.empty() && !
startsWith
(
m_standard
.key(), standardCont +
"."
)) {
160
ATH_CHECK
(
m_standard
.assign(
161
standardCont +
"."
+
m_standard
.key()));
162
}
163
164
if
(!chargedCont.empty() && !
startsWith
(
m_charged
.key(), chargedCont +
"."
)) {
165
ATH_CHECK
(
m_charged
.assign(
166
chargedCont +
"."
+
m_charged
.key()));
167
}
168
169
if
(!neutralCont.empty() && !
startsWith
(
m_neutral
.key(), neutralCont +
"."
)) {
170
ATH_CHECK
(
m_neutral
.assign(
171
neutralCont +
"."
+
m_neutral
.key()));
172
}
173
174
return
StatusCode::SUCCESS;
175
}
176
177
StatusCode
initialize
()
178
{
179
ATH_CHECK
(
m_standard
.initialize());
180
ATH_CHECK
(
m_charged
.initialize());
181
ATH_CHECK
(
m_neutral
.initialize());
182
183
return
StatusCode::SUCCESS;
184
}
185
186
WriteDecorHandleTriplet<T>
makeHandles
(
const
unsigned
short
& inputType,
const
EventContext& ctx)
const
187
{
188
WriteDecorHandleTriplet<T>
handles;
189
handles.
setObjectType
(inputType);
190
191
192
if
(inputType ==
xAOD::Type::CaloCluster
|| inputType==
xAOD::Type::TrackCaloCluster
) {
193
handles.
setStandard
(
m_standard
, ctx);
194
}
195
else
if
(inputType ==
xAOD::Type::ParticleFlow
|| inputType==
xAOD::Type::FlowElement
) {
196
handles.
setCharged
(
m_charged
, ctx);
197
handles.
setNeutral
(
m_neutral
, ctx);
198
}
199
200
return
handles;
201
}
202
};
203
204
AsgTool.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
WriteDecorHandleKey.h
WriteDecorHandle.h
Handle class for adding a decoration to an object.
CaloClusterContainer.h
TrackParticleContainer.h
FlowElementAuxContainer.h
FlowElementContainer.h
FlowElement.h
PFO.h
SG::WriteDecorHandleKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Definition
StoreGate/StoreGate/WriteDecorHandleKey.h:90
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
WriteDecorHandleKeyTriplet::initialize
StatusCode initialize()
Definition
WriteDecorHandleTriplet.h:177
WriteDecorHandleKeyTriplet::startsWith
static bool startsWith(const std::string &value, const std::string &prefix)
Definition
WriteDecorHandleTriplet.h:123
WriteDecorHandleKeyTriplet::m_charged
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_charged
Definition
WriteDecorHandleTriplet.h:120
WriteDecorHandleKeyTriplet::WriteDecorHandleKeyTriplet
WriteDecorHandleKeyTriplet(asg::AsgTool *owner, const std::string &propertyName, const std::string &decorName, const std::string &description)
Definition
WriteDecorHandleTriplet.h:132
WriteDecorHandleKeyTriplet::makeHandles
WriteDecorHandleTriplet< T > makeHandles(const unsigned short &inputType, const EventContext &ctx) const
Definition
WriteDecorHandleTriplet.h:186
WriteDecorHandleKeyTriplet::assign
StatusCode assign(const std::string &standardCont, const std::string &chargedCont, const std::string &neutralCont)
Definition
WriteDecorHandleTriplet.h:154
WriteDecorHandleKeyTriplet::m_neutral
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_neutral
Definition
WriteDecorHandleTriplet.h:121
WriteDecorHandleKeyTriplet::m_standard
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_standard
Definition
WriteDecorHandleTriplet.h:119
WriteDecorHandleTriplet
Definition
WriteDecorHandleTriplet.h:25
WriteDecorHandleTriplet::m_neutral
std::unique_ptr< SG::WriteDecorHandle< xAOD::IParticleContainer, T > > m_neutral
Definition
WriteDecorHandleTriplet.h:28
WriteDecorHandleTriplet::setStandard
void setStandard(const SG::WriteDecorHandleKey< xAOD::IParticleContainer > &key, const EventContext &ctx)
Definition
WriteDecorHandleTriplet.h:56
WriteDecorHandleTriplet::m_standard
std::unique_ptr< SG::WriteDecorHandle< xAOD::IParticleContainer, T > > m_standard
Definition
WriteDecorHandleTriplet.h:26
WriteDecorHandleTriplet::setNeutral
void setNeutral(const SG::WriteDecorHandleKey< xAOD::IParticleContainer > &key, const EventContext &ctx)
Definition
WriteDecorHandleTriplet.h:76
WriteDecorHandleTriplet::setCharged
void setCharged(const SG::WriteDecorHandleKey< xAOD::IParticleContainer > &key, const EventContext &ctx)
Definition
WriteDecorHandleTriplet.h:66
WriteDecorHandleTriplet::setObjectType
void setObjectType(unsigned short type)
Definition
WriteDecorHandleTriplet.h:50
WriteDecorHandleTriplet::m_objectType
unsigned short m_objectType
Definition
WriteDecorHandleTriplet.h:29
WriteDecorHandleTriplet::operator()
T & operator()(const xAOD::IParticle &part)
Definition
WriteDecorHandleTriplet.h:86
WriteDecorHandleTriplet::checkType
void checkType()
Definition
WriteDecorHandleTriplet.h:31
WriteDecorHandleTriplet::m_charged
std::unique_ptr< SG::WriteDecorHandle< xAOD::IParticleContainer, T > > m_charged
Definition
WriteDecorHandleTriplet.h:27
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition
AsgTool.h:47
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
description
std::string description
glabal timer - how long have I taken so far?
Definition
hcg.cxx:93
xAODType::ParticleFlow
@ ParticleFlow
The object is a particle-flow object.
Definition
ObjectType.h:41
xAODType::FlowElement
@ FlowElement
The object is a track-calo-cluster.
Definition
ObjectType.h:52
xAODType::CaloCluster
@ CaloCluster
The object is a calorimeter cluster.
Definition
ObjectType.h:39
xAODType::TrackCaloCluster
@ TrackCaloCluster
The object is a track-calo-cluster.
Definition
ObjectType.h:51
xAOD::PFO
PFO_v1 PFO
Definition of the current "pfo version".
Definition
PFO.h:17
xAOD::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition
FlowElement.h:16
type
IParticleContainer.h
Generated on
for ATLAS Offline Software by
1.17.0