ATLAS Offline Software
Loading...
Searching...
No Matches
EMShowerBuilder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3 */
4
5// INCLUDE HEADER FILES:
6#include "GaudiKernel/EventContext.h"
7#include "GaudiKernel/IChronoStatSvc.h"
9
10#include "EMShowerBuilder.h"
13
17
19#include "xAODEgamma/Egamma.h"
20
21#include <algorithm>
22
23// END OF HEADER FILES INCLUDE
24
26 const std::string& name,
27 const IInterface* parent)
28 : AthAlgTool(type, name, parent)
29{
30 // declare interface
31 declareInterface<IEMShowerBuilder>(this);
32}
33
34
35StatusCode
37{
39 " Initializing EMShowerBuilder, m_cellKey = " << m_cellsKey.key());
40
42 !m_cellsKey.key().empty()));
43
46
47 return StatusCode::SUCCESS;
48}
49
50template <typename T>
51StatusCode
52EMShowerBuilder::RetrieveTool(ToolHandle<T> &tool, bool tool_requested)
53{
54 if (!tool_requested) {
55 tool.disable();
56 return StatusCode::SUCCESS;
57 }
58 if (tool.empty()) {
59 ATH_MSG_INFO(tool.type() << " is empty");
60 return StatusCode::FAILURE;
61 }
62 ATH_CHECK(tool.retrieve());
63 return StatusCode::SUCCESS;
64}
65
66StatusCode
68{
69 return StatusCode::SUCCESS;
70}
71
72StatusCode
73EMShowerBuilder::execute(const EventContext& ctx,
74 const CaloDetDescrManager& cmgr,
75 xAOD::Egamma* eg) const
76{
77
78 ATH_MSG_DEBUG("Executing EMShowerBuilder::execute");
79 // protection against bad pointers
80 if (eg == nullptr)
81 return StatusCode::SUCCESS;
82
83 // retrieve the cell containers
85 // check is only used for serial running; remove when MT scheduler used
86 ATH_CHECK(cellcoll.isValid());
87
88 ATH_CHECK(executeWithCells(cellcoll.cptr(), cmgr, eg));
89 return StatusCode::SUCCESS;
90}
91
92StatusCode
94 const CaloDetDescrManager& cmgr,
95 xAOD::Egamma* eg) const
96{
97 ATH_CHECK(CalcShowerShape(eg, cmgr, cellcoll));
98 return StatusCode::SUCCESS;
99}
100
101StatusCode
103 const CaloDetDescrManager& cmgr,
104 const CaloCellContainer* cellcoll) const
105{
106 //
107 // Estimate shower shapes and fill the EMShower object associated to eg
108 //
109 ATH_MSG_DEBUG("Executing CalcShowerShape");
110 // protection against bad pointers
111 if (eg == nullptr) {
112 return StatusCode::SUCCESS;
113 }
114 // retrieve the cluster
115 const xAOD::CaloCluster* clus = eg->caloCluster();
116 // Protect against non-existent structures.
117 if (clus == nullptr) {
118 ATH_MSG_WARNING("No Cluster");
119 return StatusCode::SUCCESS;
120 }
121 if (cellcoll == nullptr) {
122 ATH_MSG_WARNING("No cells");
123 return StatusCode::SUCCESS;
124 }
125 // call calorimeter isolation tool only if needed
126 if (m_UseCaloIsoTool) {
127 ATH_CHECK(CalcHadronicLeakage(eg, cmgr, clus, cellcoll));
128 }
129
130 // Calculate shower shapes in all samplings
132 // protection in case tool does not exist
134 ATH_CHECK(m_ShowerShapeTool->execute(*clus, cmgr, *cellcoll, info));
135 ATH_CHECK(FillEMShowerShape(eg, info));
136 }
137 return StatusCode::SUCCESS;
138}
139
140StatusCode
142 const CaloDetDescrManager& cmgr,
143 const xAOD::CaloCluster* clus,
144 const CaloCellContainer* cellcoll) const
145{
146 //
147 // Call calorimeter isolation tool
148 //
149 ATH_MSG_DEBUG("Executing CalcHadronicLeakage");
150 if (m_caloNums.size() < 3) {
151 ATH_MSG_DEBUG("Less than 3 subCalos, skipping");
152 return StatusCode::SUCCESS;
153 }
154 // protection in case tool does not exist
155 if (m_HadronicLeakageTool.empty()) {
156 return StatusCode::SUCCESS;
157 }
158 // calculate information concerning just the hadronic leakage
159 IegammaIso::Info info;
160 StatusCode sc = m_HadronicLeakageTool->execute(*clus, cmgr, *cellcoll, info);
161 if (sc.isFailure()) {
162 ATH_MSG_WARNING("call to Iso returns failure for execute");
163 return sc;
164 }
165 float value = 0;
167 const double et = eg->caloCluster()->et();
168 value = static_cast<float>(info.ethad1);
170 eg->setShowerShapeValue(et != 0. ? value / et : 0.,
172 value = static_cast<float>(info.ethad);
174 eg->setShowerShapeValue(et != 0. ? value / et : 0.,
176 value = static_cast<float>(info.ehad1);
178 return StatusCode::SUCCESS;
179}
180
181StatusCode
183 const IegammaShowerShape::Info& info) const
184{
185
186 // protection in case Tool does not exist
187 if (m_ShowerShapeTool.empty()) {
188 return StatusCode::SUCCESS;
189 }
190 // information in the presampler
191
192 // E in 1x1 cells in pre sampler
193 float value = 0;
194 // E in 1x1 cells in pre sampler
195 value = static_cast<float>(info.e011);
197 // E in 3x3 cells in pre sampler
198 value = static_cast<float>(info.e033);
200 // E in 3x2 cells in S1
201 value = static_cast<float>(info.e132);
203 // E in 15x2 cells in S1
204 value = static_cast<float>(info.e1152);
206 // fraction of E in S1
207 value = static_cast<float>(info.f1);
209 // fraction of E in the core(e132) in S1
210 value = static_cast<float>(info.f1core);
212 // corr width with 3 strips
213 value = static_cast<float>(info.ws3c);
215 // energy in second max
216 value = static_cast<float>(info.esec);
218 // energy strip of second max
219 value = static_cast<float>(info.esec1);
221 // fraction of E outside core in S1
222 value = static_cast<float>(info.fside);
224 // width with 5 strips
225 value = static_cast<float>(info.widths5);
227 // eta pos within cell in S1
228 value = static_cast<float>(info.poscs1);
230 // asymmetry with 3 strips
231 value = static_cast<float>(info.asymmetrys3);
233 // diff position +/- 1 cells
234 value = static_cast<float>(info.deltaEtaTrackShower);
236 // diff position +/- 7 cells
237 value = static_cast<float>(info.deltaEtaTrackShower7);
239 // E of strip with min E
240 value = static_cast<float>(info.emins1);
242 // E of strip with max E
243 value = static_cast<float>(info.emaxs1);
245 // barycentre in eta in S1
246 value = static_cast<float>(info.etas3);
248 // total width in strips
249 value = static_cast<float>(info.wstot);
251 //
252 // information in the 2nd sampling
253 //
254 // E in 3x3 cells in S2
255 value = static_cast<float>(info.e233);
257 // E in 3x5 cells in S2
258 value = static_cast<float>(info.e235);
260 // E in 3x7 cells in S2
261 value = static_cast<float>(info.e237);
263 // E in 5x5 cells in S2
264 value = static_cast<float>(info.e255);
266 // E in 7x7 cells in S2
267 value = static_cast<float>(info.e277);
269 // corr width in S2
270 value = static_cast<float>(info.etaw);
272 // uncorr width in S2
273 value = static_cast<float>(info.width);
275 // position in eta within cell in S2
276 value = static_cast<float>(info.poscs2);
278 //
279 // information in the 3rd sampling
280 //
281 // fraction of E in S3
282 value = static_cast<float>(info.f3);
284 // fraction of E in the core (e333) in S3
285 value = static_cast<float>(info.f3core);
287 // E in 3x3 cells in S3
288 value = static_cast<float>(info.e333);
290 // E in 3x5 cells in S3
291 value = static_cast<float>(info.e335);
293 // E in 3x7 cells in S3
294 value = static_cast<float>(info.e337);
296 // E in 7x7 cells in S3
297 value = static_cast<float>(info.e377);
299 //
300 // information combining all samplings
301 //
302 // ratio of energy in 3x3/3x7 cells
303 value = static_cast<float>(info.reta3337_allcalo);
305 // core energy
306 value = static_cast<float>(info.ecore);
308 //
309 // information combining different shower shape
310 //
311 float valueSecond = 0;
313 value = static_cast<float>(info.e277);
314 valueSecond = static_cast<float>(info.e237);
315 eg->setShowerShapeValue(value != 0 ? valueSecond / value : 0.,
318 value = static_cast<float>(info.e233);
319 valueSecond = static_cast<float>(info.e237);
320 eg->setShowerShapeValue(valueSecond != 0 ? value / valueSecond : 0.,
323 value = static_cast<float>(info.emaxs1);
324 valueSecond = static_cast<float>(info.esec1);
325 eg->setShowerShapeValue(std::abs(value + valueSecond) > 0.
326 ? (value - valueSecond) / (value + valueSecond)
327 : 0.,
329
330 value = static_cast<float>(info.emins1);
331 eg->setShowerShapeValue((valueSecond - value),
333 return StatusCode::SUCCESS;
334}
335
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Definition of CaloDetDescrManager.
static Double_t sc
Handle class for reading from StoreGate.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Container class for CaloCell.
This class provides the client interface for accessing the detector description information common to...
virtual StatusCode executeWithCells(const CaloCellContainer *cellcoll, const CaloDetDescrManager &cmgr, xAOD::Egamma *) const override final
@Execute passing the cells explicitly
StatusCode CalcShowerShape(xAOD::Egamma *eg, const CaloDetDescrManager &cmgr, const CaloCellContainer *cellcoll) const
calculate shower shapes
virtual StatusCode initialize() override final
initialize method
Gaudi::Property< std::vector< int > > m_caloNums
Obsolete enum on the layers to use for the HadLeakage variables.
StatusCode CalcHadronicLeakage(xAOD::Egamma *eg, const CaloDetDescrManager &cmgr, const xAOD::CaloCluster *clus, const CaloCellContainer *cellcoll) const
calculate Hadronic leakage
virtual StatusCode execute(const EventContext &ctx, const CaloDetDescrManager &cmgr, xAOD::Egamma *) const override final
standard execute method
StatusCode RetrieveTool(ToolHandle< T > &tool, bool tool_requested)
Wraps tool retrieval to ensure it is has a name.
Gaudi::Property< bool > m_UseShowerShapeTool
Boolean to call shower shape calculation and filling (NB: this could be important when redoing calcul...
ToolHandle< IegammaIso > m_HadronicLeakageTool
Tool for hadronic leakage calculation.
virtual StatusCode finalize() override
finalize method
ToolHandle< IegammaShowerShape > m_ShowerShapeTool
Tool for shower shape calculation.
StatusCode FillEMShowerShape(xAOD::Egamma *eg, const IegammaShowerShape::Info &info) const
fill shower detail from shower shape calculation
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
Cell container.
Gaudi::Property< bool > m_UseCaloIsoTool
Boolean to call calo isolation variables calculation and filling (NB: this could be important when re...
EMShowerBuilder(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
bool setShowerShapeValue(float value, const EgammaParameters::ShowerShapeType information)
Set method for Shower Shape values.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
@ e235
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 3x5
Definition EgammaEnums.h:72
@ e337
uncalibrated energy (sum of cells) of the third sampling in a rectangle of size 3x7
Definition EgammaEnums.h:90
@ wtots1
shower width is determined in a window detaxdphi = 0,0625 ×~0,2, corresponding typically to 20 strips...
@ pos7
Difference between the track and the shower positions: sum_{i=i_m-7}^{i=i_m+7}E_i x (i-i_m) / sum_{i=...
@ f3core
E3(3x3)/E fraction of the energy reconstructed in the third compartment of the electromagnetic calori...
Definition EgammaEnums.h:66
@ ethad1
transverse energy in the first sampling of the hadronic calorimeters behind the cluster calculated fr...
Definition EgammaEnums.h:43
@ e277
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 7x7
Definition EgammaEnums.h:81
@ e237
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 3x7
Definition EgammaEnums.h:78
@ ethad
ET leakage into hadronic calorimeter with exclusion of energy in CaloSampling::TileGap3.
Definition EgammaEnums.h:46
@ e1152
uncalibrated energy (sum of cells) in strips in a 15x2 window in cells in eta X phi
Definition EgammaEnums.h:40
@ f3
fraction of energy reconstructed in 3rd sampling
Definition EgammaEnums.h:55
@ poscs2
relative position in eta within cell in 2nd sampling
@ ecore
core energy in em calo E(core) = E0(3x3) + E1(15x2) + E2(5x5) + E3(3x5)
@ f1
E1/E = fraction of energy reconstructed in the first sampling, where E1 is energy in all strips belon...
Definition EgammaEnums.h:53
@ pos
difference between shower cell and predicted track in +/- 1 cells
@ widths2
same as egammaParameters::weta2 but without corrections on particle impact point inside the cell
@ e2ts1
2nd max in strips calc by summing 3 strips
@ poscs1
relative position in eta within cell in 1st sampling
@ Eratio
(emaxs1-e2tsts1)/(emaxs1+e2tsts1)
@ e335
uncalibrated energy (sum of cells) of the third sampling in a rectangle of size 3x5
Definition EgammaEnums.h:87
@ e377
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 7x7
Definition EgammaEnums.h:93
@ e333
uncalibrated energy (sum of cells) of the third sampling in a rectangle of size 3x3
Definition EgammaEnums.h:84
@ emaxs1
energy of strip with maximal energy deposit
@ e255
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 5x5
Definition EgammaEnums.h:75
@ DeltaE
e2tsts1-emins1
@ ehad1
E leakage into 1st sampling of had calo (CaloSampling::HEC0 + CaloSampling::TileBar0 + CaloSampling::...
Definition EgammaEnums.h:49
@ barys1
barycentre in sampling 1 calculated in 3 strips
@ e233
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 3x3 (in cell units e...
Definition EgammaEnums.h:69
@ asy1
uncorr asymmetry in 3 strips in the 1st sampling
@ e033
uncalibrated energy (sum of cells) in presampler in a 3x3 window in cells in eta X phi
Definition EgammaEnums.h:34
@ e132
uncalibrated energy (sum of cells) in strips in a 3x2 window in cells in eta X phi
Definition EgammaEnums.h:37
@ fracs1
shower shape in the shower core : [E(+/-3)-E(+/-1)]/E(+/-1), where E(+/-n) is the energy in ± n strip...
@ r33over37allcalo
1-ratio of energy in 3x3 over 3x7 cells; E(3x3) = E0(1x1) + E1(3x1) + E2(3x3) + E3(3x3); E(3x7) = E0(...
@ weta2
the lateral width is calculated with a window of 3x5 cells using the energy weighted sum over all cel...
@ e011
uncalibrated energy (sum of cells) in presampler in a 1x1 window in cells in eta X phi
Definition EgammaEnums.h:31
@ weta1
shower width using +/-3 strips around the one with the maximal energy deposit: w3 strips = sqrt{sum(E...
Definition EgammaEnums.h:98
@ e2tsts1
energy of the cell corresponding to second energy maximum in the first sampling
@ emins1
energy reconstructed in the strip with the minimal value between the first and second maximum
@ widths1
same as egammaParameters::weta1 but without corrections on particle impact point inside the cell
@ f1core
E1(3x1)/E = fraction of the energy reconstructed in the first longitudinal compartment of the electro...
Definition EgammaEnums.h:61
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
Extra patterns decribing particle interation process.