ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkCalo
src
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
10
#include "
DerivationFrameworkCalo/ClusterEnergyPerLayerDecorator.h
"
11
#include "
CaloUtils/CaloClusterStoreHelper.h
"
12
13
#include <TString.h>
14
15
// Athena initialize
16
StatusCode
17
DerivationFramework::ClusterEnergyPerLayerDecorator::initialize
()
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
27
ATH_CHECK
(
m_caloFillRectangularTool
.retrieve());
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());
40
ATH_CHECK
(
m_SGKey_electrons
.initialize(
SG::AllowEmpty
));
41
if
(!
m_SGKey_electrons
.key().empty()) {
42
ATH_MSG_DEBUG
(
"Using "
<<
m_SGKey_electrons
<<
" for electrons"
);
43
}
44
ATH_CHECK
(
m_SGKey_electrons_decorations
.initialize(!
m_SGKey_electrons
.key().empty()));
45
46
ATH_CHECK
(
m_SGKey_photons
.initialize(
SG::AllowEmpty
));
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
57
StatusCode
58
DerivationFramework::ClusterEnergyPerLayerDecorator::addBranches
(
const
EventContext& ctx)
const
59
{
60
61
// Retrieve cell container
62
63
SG::ReadHandle<CaloCellContainer>
cellContainer(
m_SGKey_caloCells
, ctx);
64
const
CaloCellContainer
* cellCont = cellContainer.
ptr
();
65
66
// Photon decorations
67
68
if
(!
m_SGKey_photons
.key().empty()) {
69
70
// Retrieve photon container
71
SG::ReadHandle<xAOD::EgammaContainer>
photonContainer
(
m_SGKey_photons
, ctx);
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
79
m_SGKey_photons_decorations
[i], ctx);
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
96
SG::ReadHandle<xAOD::EgammaContainer>
electronContainer
(
m_SGKey_electrons
,
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
105
m_SGKey_electrons_decorations
[i], ctx);
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
120
std::vector<float>
121
DerivationFramework::ClusterEnergyPerLayerDecorator::decorateObject
(
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;
132
if
(not
egamma
->
author
(
xAOD::EgammaParameters::AuthorCaloTopo35
)) {
133
egcClone =
134
CaloClusterStoreHelper::makeCluster
(cellCont,
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
}
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:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x,...)
Definition
AthMsgStreamMacros.h:42
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x,...)
Definition
AthMsgStreamMacros.h:48
CaloClusterStoreHelper.h
ClusterEnergyPerLayerDecorator.h
electronContainer
xAOD::ElectronContainer * electronContainer
Definition
TrigGlobEffCorrValidation.cxx:187
photonContainer
xAOD::PhotonContainer * photonContainer
Definition
TrigGlobEffCorrValidation.cxx:189
CaloCellContainer
Container class for CaloCell.
Definition
CaloCellContainer.h:55
CaloClusterStoreHelper::makeCluster
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
Definition
CaloClusterStoreHelper.cxx:13
CaloFillRectangularCluster
Definition
CaloFillRectangularCluster.h:61
DerivationFramework::ClusterEnergyPerLayerDecorator::m_layers
Gaudi::Property< std::vector< unsigned int > > m_layers
Definition
ClusterEnergyPerLayerDecorator.h:36
DerivationFramework::ClusterEnergyPerLayerDecorator::m_SGKey_caloCells
SG::ReadHandleKey< CaloCellContainer > m_SGKey_caloCells
Definition
ClusterEnergyPerLayerDecorator.h:48
DerivationFramework::ClusterEnergyPerLayerDecorator::m_caloFillRectangularTool
ToolHandle< CaloClusterProcessor > m_caloFillRectangularTool
Definition
ClusterEnergyPerLayerDecorator.h:55
DerivationFramework::ClusterEnergyPerLayerDecorator::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition
ClusterEnergyPerLayerDecorator.cxx:58
DerivationFramework::ClusterEnergyPerLayerDecorator::decorateObject
std::vector< float > decorateObject(const EventContext &ctx, const xAOD::Egamma *egamma, const CaloCellContainer *cellCont) const
Definition
ClusterEnergyPerLayerDecorator.cxx:121
DerivationFramework::ClusterEnergyPerLayerDecorator::initialize
virtual StatusCode initialize() override final
Definition
ClusterEnergyPerLayerDecorator.cxx:17
DerivationFramework::ClusterEnergyPerLayerDecorator::m_SGKey_photons
SG::ReadHandleKey< xAOD::EgammaContainer > m_SGKey_photons
Definition
ClusterEnergyPerLayerDecorator.h:39
DerivationFramework::ClusterEnergyPerLayerDecorator::m_tool
const CaloFillRectangularCluster * m_tool
Definition
ClusterEnergyPerLayerDecorator.h:78
DerivationFramework::ClusterEnergyPerLayerDecorator::m_SGKey_electrons_decorations
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer > m_SGKey_electrons_decorations
Definition
ClusterEnergyPerLayerDecorator.h:71
DerivationFramework::ClusterEnergyPerLayerDecorator::m_SGKey_electrons
SG::ReadHandleKey< xAOD::EgammaContainer > m_SGKey_electrons
Definition
ClusterEnergyPerLayerDecorator.h:41
DerivationFramework::ClusterEnergyPerLayerDecorator::m_SGKey_photons_decorations
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer > m_SGKey_photons_decorations
Definition
ClusterEnergyPerLayerDecorator.h:63
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::ptr
const_pointer_type ptr()
Dereference the pointer.
egamma
elec/gamma data class.
Definition
egamma.h:59
egamma::author
unsigned int author() const
Reconstruction Author.
Definition
egamma.h:245
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
xAOD::EgammaParameters::AuthorCaloTopo35
const uint16_t AuthorCaloTopo35
Photon reconstructed by SW CaloTopo35 seeded clusters.
Definition
EgammaDefs.h:38
xAOD::Egamma
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition
Egamma.h:17
xAOD::EgammaContainer
EgammaContainer_v1 EgammaContainer
Definition of the current "egamma container version".
Definition
EgammaContainer.h:17
Generated on
for ATLAS Offline Software by
1.17.0