ATLAS Offline Software
Loading...
Searching...
No Matches
ClusterEnergyPerLayerDecorator.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// Author: Bruno Lenzi,
6// Giovanni Marchiori (giovanni.marchiori@cern.ch)
7// Decorate egamma objects with the energy per layer for a rectangular cluster
8// of size neta X nphi built on the fly
9
12
13#include <TString.h>
14
15// Athena initialize
16StatusCode
18{
19 ATH_MSG_VERBOSE("initialize() ...");
20
21 if (m_SGKey_photons.empty() and m_SGKey_electrons.empty()) {
22 ATH_MSG_FATAL("No e-gamma collection provided for thinning. At least one "
23 "egamma collection (photons/electrons) must be provided!");
24 return StatusCode::FAILURE;
25 }
26
28 // how to add a statement to check that the tool indeed has the size matching
29 // the neta and nphi properties? ATH_MSG_DEBUG("CaloFillRectangularCluster
30 // print size ...
31 m_tool =
32 dynamic_cast<const CaloFillRectangularCluster*>(
33 &(*m_caloFillRectangularTool));
34 if (!m_tool) {
35 ATH_MSG_ERROR("Pointer to CaloFillRectantularCluster tool is invalid");
36 return StatusCode::FAILURE;
37 }
38
39 ATH_CHECK(m_SGKey_caloCells.initialize());
41 if (!m_SGKey_electrons.key().empty()) {
42 ATH_MSG_DEBUG("Using " << m_SGKey_electrons << " for electrons");
43 }
45
47 if (!m_SGKey_photons.key().empty()) {
48 ATH_MSG_DEBUG("Using " << m_SGKey_photons << " for photons");
49 }
50 ATH_CHECK(m_SGKey_photons_decorations.initialize(!m_SGKey_photons.key().empty()));
51
52 return StatusCode::SUCCESS;
53}
54
55
56// The decoration itself
57StatusCode
59{
60
61 // Retrieve cell container
62
64 const CaloCellContainer* cellCont = cellContainer.ptr();
65
66 // Photon decorations
67
68 if (!m_SGKey_photons.key().empty()) {
69
70 // Retrieve photon container
72 const xAOD::EgammaContainer* importedPhotons = photonContainer.ptr();
73
74 // Setup vectors of photon decorations
75 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>> decorations;
76 for (unsigned int i = 0; i < m_layers.size(); i++) {
77 decorations.emplace_back(
78
80 }
81
82 // Decorate photons
83 for (const auto* photon : *importedPhotons) {
84 std::vector<float> result = decorateObject(ctx, photon, cellCont);
85 for (unsigned int i = 0; i < m_layers.size(); i++) {
86 decorations[i](*photon) = result[i];
87 }
88 }
89 }
90
91 // Electron decorations
92
93 if (!m_SGKey_electrons.key().empty()) {
94
95 // Retrieve electron container
97 ctx);
98 const xAOD::EgammaContainer* importedElectrons = electronContainer.ptr();
99
100 // Setup vectors of electron decorations
101 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>> decorations;
102 for (unsigned int i = 0; i < m_layers.size(); i++) {
103 decorations.emplace_back(
104
106 }
107
108 // Decorate electrons
109 for (const auto* electron : *importedElectrons) {
110 std::vector<float> result = decorateObject(ctx, electron, cellCont);
111 for (unsigned int i = 0; i < m_layers.size(); i++) {
112 decorations[i](*electron) = result[i];
113 }
114 }
115 }
116
117 return StatusCode::SUCCESS;
118}
119
120std::vector<float>
122 const EventContext& ctx,
123 const xAOD::Egamma* egamma,
124 const CaloCellContainer* cellCont) const
125{
126 std::vector<float> result;
127 result.clear();
128 if (not egamma or not egamma->caloCluster())
129 return result;
130
131 std::unique_ptr<xAOD::CaloCluster> egcClone;
133 egcClone =
135 egamma->caloCluster()->eta0(),
136 egamma->caloCluster()->phi0(),
137 egamma->caloCluster()->clusterSize());
138 m_tool->makeCorrection(ctx, egcClone.get());
139 }
140
141 for (unsigned int layer : m_layers) {
142 result.emplace_back(egcClone ? egcClone->energyBE(layer) : 0.);
143 }
144
145 return result;
146}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
xAOD::ElectronContainer * electronContainer
xAOD::PhotonContainer * photonContainer
Container class for CaloCell.
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
Gaudi::Property< std::vector< unsigned int > > m_layers
virtual StatusCode addBranches(const EventContext &ctx) const override final
std::vector< float > decorateObject(const EventContext &ctx, const xAOD::Egamma *egamma, const CaloCellContainer *cellCont) const
SG::ReadHandleKey< xAOD::EgammaContainer > m_SGKey_photons
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer > m_SGKey_electrons_decorations
SG::ReadHandleKey< xAOD::EgammaContainer > m_SGKey_electrons
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer > m_SGKey_photons_decorations
const_pointer_type ptr()
Dereference the pointer.
elec/gamma data class.
Definition egamma.h:58
unsigned int author() const
Reconstruction Author.
Definition egamma.h:244
const uint16_t AuthorCaloTopo35
Photon reconstructed by SW CaloTopo35 seeded clusters.
Definition EgammaDefs.h:38
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
EgammaContainer_v1 EgammaContainer
Definition of the current "egamma container version".