ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
egamma
egammaAlgs
src
egammaTrackThinner.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/********************************************************************
6
NAME: egammaTrackThinner.cxx
7
PACKAGE: offline/Reconstruction/egammaRec
8
********************************************************************/
9
10
// INCLUDE HEADER FILES:
11
12
#include "
egammaTrackThinner.h
"
13
14
#include "
xAODTracking/TrackParticleContainer.h
"
15
#include "
xAODTracking/VertexContainer.h
"
16
#include "
xAODEgamma/ElectronContainer.h
"
17
#include "
xAODEgamma/PhotonContainer.h
"
18
#include "
xAODEgamma/EgammaxAODHelpers.h
"
19
20
#include "
StoreGate/ReadHandle.h
"
21
#include "
StoreGate/ThinningHandle.h
"
22
23
// END OF HEADER FILES INCLUDE
24
26
27
28
// INITIALIZE METHOD:
29
30
StatusCode
egammaTrackThinner::initialize
()
31
{
32
33
// initialize data handles
34
ATH_CHECK
(
m_InputElectronContainerKey
.initialize(
m_doThinning
));
35
ATH_CHECK
(
m_InputPhotonContainerKey
.initialize(
m_doThinning
));
36
bool
includeFwdEl =
37
m_doThinning
&& !
m_InputForwardElectronContainerKey
.empty();
38
ATH_CHECK
(
m_InputForwardElectronContainerKey
.initialize(includeFwdEl));
39
ATH_CHECK
(
m_TrackParticlesKey
.initialize(
m_streamName
,
m_doThinning
));
40
ATH_CHECK
(
m_VertexKey
.initialize(
m_streamName
,
m_doThinning
));
41
42
return
StatusCode::SUCCESS;
43
}
44
45
// FINALIZE METHOD:
46
47
StatusCode
egammaTrackThinner::finalize
() {
48
return
StatusCode::SUCCESS;
49
}
50
52
// ATHENA EXECUTE METHOD:
53
54
StatusCode
egammaTrackThinner::execute
(
const
EventContext& ctx)
const
{
55
56
ATH_MSG_DEBUG
(
"Executing egammaTrackThinner"
);
57
if
(!
m_doThinning
){
58
ATH_MSG_DEBUG
(
"Thinning not requested do nothing"
);
59
return
StatusCode::SUCCESS;
60
}
61
62
/*
63
* GSF Track Particles
64
* The vector that we'll use to filter the track particles:
65
*/
66
std::vector<bool> keptTrackParticles;
67
SG::ThinningHandle<xAOD::TrackParticleContainer>
trackPC(
m_TrackParticlesKey
, ctx);
68
// check is only used for serial running; remove when MT scheduler used
69
ATH_CHECK
(trackPC.isValid());
70
ATH_MSG_DEBUG
(
"Number of TrackParticles "
<< trackPC->size());
71
keptTrackParticles.resize( trackPC->size(),
false
);
72
73
/*
74
* GSF Vertices
75
* The vector that we'll use to filter the GSF vertices:
76
*/
77
std::vector<bool> keptVertices;
78
SG::ThinningHandle<xAOD::VertexContainer>
vertices(
m_VertexKey
, ctx);
79
// check is only used for serial running; remove when MT scheduler used
80
ATH_CHECK
(vertices.isValid());
81
ATH_MSG_DEBUG
(
"Number of Vertices "
<< vertices->size());
82
keptVertices.resize( vertices->size(),
false
);
83
84
/*
85
* In Det Track Particles
86
* TRT standalone tracks are now centrally thinned by ThinTRTStandaloneTrackAlg for e/gamma and taus
87
*/
88
89
/*
90
* Electron track particle Thinning
91
*/
92
SG::ReadHandle<xAOD::ElectronContainer>
electrons(
m_InputElectronContainerKey
, ctx);
93
// check is only used for serial running; remove when MT scheduler used
94
ATH_CHECK
(electrons.isValid());
95
96
//Loop over electrons
97
auto
el_itr = electrons->begin();
98
auto
el_end = electrons->end();
99
for
( ; el_itr != el_end; ++el_itr ) {
100
101
auto
trackParticleLinks = (*el_itr)->trackParticleLinks();
102
for
(
const
auto
& link : trackParticleLinks){
103
if
( ! link.isValid() ){
104
continue
;
105
}
106
ATH_MSG_DEBUG
(
"Electrons : Keeping GSF Track Particle with index : "
<< link.index() );
107
keptTrackParticles[link.index() ] =
true
;
108
}
109
}
110
111
/*
112
* Photon Vertex and track particle Thinning
113
*/
114
SG::ReadHandle<xAOD::PhotonContainer>
photons(
m_InputPhotonContainerKey
, ctx);
115
// check is only used for serial running; remove when MT scheduler used
116
ATH_CHECK
(photons.
isValid
());
117
118
//Loop over photons
119
auto
ph_itr = photons->begin();
120
auto
ph_end = photons->end();
121
for
( ; ph_itr != ph_end; ++ph_itr ) {
122
123
auto
vertexLinks= (*ph_itr) ->vertexLinks();
124
for
(
const
auto
& vxlink : vertexLinks){
125
if
( ! vxlink.isValid() ){
126
continue
;
127
}
128
ATH_MSG_DEBUG
(
"Photons : Keeping GSF Vertex with index : "
<< vxlink.index() );
129
keptVertices[vxlink.index()]=
true
;
130
const
xAOD::Vertex
* vx = *(vxlink);
131
if
(!vx){
132
continue
;
133
}
134
135
auto
trackParticleLinks = vx->
trackParticleLinks
();
136
for
(
const
auto
& link : trackParticleLinks){
137
if
( ! link.isValid() ){
138
continue
;
139
}
140
ATH_MSG_DEBUG
(
"Photons : Keeping GSF Track Particle with index : "
<< link.index() );
141
keptTrackParticles[link.index() ] =
true
;
142
}
143
}
144
}
145
146
if
(!
m_InputForwardElectronContainerKey
.empty()) {
147
SG::ReadHandle<xAOD::ElectronContainer>
148
fwdelectrons(
m_InputForwardElectronContainerKey
, ctx);
149
// check is only used for serial running; remove when MT scheduler used
150
ATH_CHECK
(fwdelectrons.
isValid
());
151
152
//Loop over forward electrons
153
for
(
const
auto
*el : *fwdelectrons) {
154
155
auto
trackParticleLinks = el->trackParticleLinks();
156
for
(
const
auto
& link : trackParticleLinks){
157
if
(!link.isValid()) {
158
continue
;
159
}
160
ATH_MSG_DEBUG
(
"ForwardElectrons : "
161
"Keeping GSF Track Particle with index : "
162
<< link.index());
163
keptTrackParticles[link.index()] =
true
;
164
}
165
}
166
}
167
168
//Do the Thinning
169
ATH_MSG_DEBUG
(
"Do the Thinning"
);
170
trackPC.
keep
(keptTrackParticles);
171
vertices.
keep
(keptVertices);
172
ATH_MSG_DEBUG
(
"completed successfully"
);
173
174
//Return Gracefully
175
return
StatusCode::SUCCESS;
176
}
177
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
EgammaxAODHelpers.h
ElectronContainer.h
PhotonContainer.h
TrackParticleContainer.h
ReadHandle.h
Handle class for reading from StoreGate.
ThinningHandle.h
Handle for requesting thinning for a data object.
VertexContainer.h
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ThinningHandleBase::keep
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Definition
ThinningHandleBase.cxx:75
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition
ThinningHandle.h:84
egammaTrackThinner::m_VertexKey
SG::ThinningHandleKey< xAOD::VertexContainer > m_VertexKey
GSF vertex container to thin.
Definition
egammaTrackThinner.h:68
egammaTrackThinner::m_InputForwardElectronContainerKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_InputForwardElectronContainerKey
forward electron collection input name
Definition
egammaTrackThinner.h:56
egammaTrackThinner::m_InputElectronContainerKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_InputElectronContainerKey
electron collection input name
Definition
egammaTrackThinner.h:43
egammaTrackThinner::m_TrackParticlesKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_TrackParticlesKey
GSF Track Particle container to thin.
Definition
egammaTrackThinner.h:62
egammaTrackThinner::m_doThinning
Gaudi::Property< bool > m_doThinning
Bool to decide if we actually do the Thinning.
Definition
egammaTrackThinner.h:78
egammaTrackThinner::initialize
StatusCode initialize() override final
initialize method
Definition
egammaTrackThinner.cxx:30
egammaTrackThinner::finalize
StatusCode finalize() override final
finalize method
Definition
egammaTrackThinner.cxx:47
egammaTrackThinner::m_InputPhotonContainerKey
SG::ReadHandleKey< xAOD::PhotonContainer > m_InputPhotonContainerKey
photon collection input name
Definition
egammaTrackThinner.h:49
egammaTrackThinner::m_streamName
StringProperty m_streamName
Name of the stream being thinned.
Definition
egammaTrackThinner.h:75
egammaTrackThinner::execute
StatusCode execute(const EventContext &ctx) const override final
execute method
Definition
egammaTrackThinner.cxx:54
xAOD::Vertex_v1::trackParticleLinks
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
egammaTrackThinner.h
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
Generated on
for ATLAS Offline Software by
1.17.0