ATLAS Offline Software
Loading...
Searching...
No Matches
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/********************************************************************
6NAME: egammaTrackThinner.cxx
7PACKAGE: offline/Reconstruction/egammaRec
8********************************************************************/
9
10// INCLUDE HEADER FILES:
11
12#include "egammaTrackThinner.h"
13
19
22
23// END OF HEADER FILES INCLUDE
24
26
27
28// INITIALIZE METHOD:
29
31{
32
33 // initialize data handles
36 bool includeFwdEl =
38 ATH_CHECK(m_InputForwardElectronContainerKey.initialize(includeFwdEl));
41
42 return StatusCode::SUCCESS;
43}
44
45// FINALIZE METHOD:
46
48 return StatusCode::SUCCESS;
49}
50
52// ATHENA EXECUTE METHOD:
53
54StatusCode 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;
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;
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 */
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 */
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
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle for requesting thinning for a data object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Handle for requesting thinning for a data object.
SG::ThinningHandleKey< xAOD::VertexContainer > m_VertexKey
GSF vertex container to thin.
SG::ReadHandleKey< xAOD::ElectronContainer > m_InputForwardElectronContainerKey
forward electron collection input name
SG::ReadHandleKey< xAOD::ElectronContainer > m_InputElectronContainerKey
electron collection input name
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_TrackParticlesKey
GSF Track Particle container to thin.
Gaudi::Property< bool > m_doThinning
Bool to decide if we actually do the Thinning.
StatusCode initialize() override final
initialize method
StatusCode finalize() override final
finalize method
SG::ReadHandleKey< xAOD::PhotonContainer > m_InputPhotonContainerKey
photon collection input name
StringProperty m_streamName
Name of the stream being thinned.
StatusCode execute(const EventContext &ctx) const override final
execute method
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.