ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkEGamma
src
EGammaEnergyCalibrationWrapper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
// Author: Chengxi Yang (cxyang@berkeley.edu)
5
6
#include "
DerivationFrameworkEGamma/EGammaEnergyCalibrationWrapper.h
"
7
#include "
StoreGate/ReadHandle.h
"
8
#include "
StoreGate/WriteDecorHandle.h
"
9
10
namespace
DerivationFramework
{
11
12
StatusCode
EGammaEnergyCalibrationWrapper::initialize
()
13
{
14
ATH_CHECK
(
m_electronContainerKey
.initialize());
15
ATH_CHECK
(
m_photonContainerKey
.initialize());
16
ATH_CHECK
(
m_electronEnergyDecoKey
.initialize());
17
ATH_CHECK
(
m_photonEnergyDecoKey
.initialize());
18
ATH_CHECK
(
m_eventInfo_key
.initialize());
19
ATH_CHECK
(
m_MVACalibSvc
.retrieve());
20
return
StatusCode::SUCCESS;
21
}
22
23
StatusCode
EGammaEnergyCalibrationWrapper::addBranches
(
const
EventContext& ctx)
const
24
{
25
// Process electrons
26
SG::ReadHandle<xAOD::EgammaContainer>
electrons{
m_electronContainerKey
, ctx};
27
if
(!electrons.isValid()) {
28
ATH_MSG_ERROR
(
"Cannot retrieve electron container "
<<
m_electronContainerKey
.key());
29
return
StatusCode::FAILURE;
30
}
31
32
SG::WriteDecorHandle<xAOD::EgammaContainer, float>
electronEnergyDeco{
m_electronEnergyDecoKey
, ctx};
33
SG::ReadHandle<xAOD::EventInfo>
evt(
m_eventInfo_key
, ctx);
34
if
(!evt.isValid()) {
35
ATH_MSG_ERROR
(
"Cannot retrieve EventInfo "
<<
m_eventInfo_key
.key());
36
return
StatusCode::FAILURE;
37
}
38
39
for
(
const
xAOD::Egamma
* eg : *electrons) {
40
if
(!eg)
continue
;
41
const
xAOD::CaloCluster
* cluster = eg->caloCluster();
42
float
value = 0;
43
if
(!cluster) {
44
ATH_MSG_ERROR
(
"Electron object without CaloCluster, storing zero"
);
45
electronEnergyDeco(*eg) = value;
46
continue
;
47
}
48
49
double
calibratedEnergy = 0.;
50
StatusCode
sc
= StatusCode::FAILURE;
51
52
egammaMVACalib::GlobalEventInfo
gei;
53
gei.
eventInfo
= evt.cptr();
54
sc
=
m_MVACalibSvc
->getEnergy(*cluster, *eg, calibratedEnergy, gei);
55
56
if
(
sc
.isFailure()) {
57
ATH_MSG_WARNING
(
"MVACalibSvc failed for electron at eta="
<< cluster->
eta
()
58
<<
" phi="
<< cluster->
phi
());
59
}
else
{
60
value =
static_cast<
float
>
(calibratedEnergy);
61
}
62
electronEnergyDeco(*eg) = value;
63
}
64
65
// Process photons
66
SG::ReadHandle<xAOD::EgammaContainer>
photons{
m_photonContainerKey
, ctx};
67
if
(!photons.
isValid
()) {
68
ATH_MSG_ERROR
(
"Cannot retrieve photon container "
<<
m_photonContainerKey
.key());
69
return
StatusCode::FAILURE;
70
}
71
72
SG::WriteDecorHandle<xAOD::EgammaContainer, float>
photonEnergyDeco{
m_photonEnergyDecoKey
, ctx};
73
for
(
const
xAOD::Egamma
* eg : *photons) {
74
if
(!eg)
continue
;
75
const
xAOD::CaloCluster
* cluster = eg->caloCluster();
76
float
value = 0;
77
if
(!cluster) {
78
ATH_MSG_ERROR
(
"Photon object without CaloCluster"
);
79
photonEnergyDeco(*eg) = value;
80
continue
;
81
}
82
83
double
calibratedEnergy = 0.;
84
StatusCode
sc
= StatusCode::FAILURE;
85
86
egammaMVACalib::GlobalEventInfo
gei;
87
gei.
eventInfo
= evt.cptr();
88
sc
=
m_MVACalibSvc
->getEnergy(*cluster, *eg, calibratedEnergy, gei);
89
90
if
(
sc
.isFailure()) {
91
ATH_MSG_WARNING
(
"MVACalibSvc failed for photon at eta="
<< cluster->
eta
()
92
<<
" phi="
<< cluster->
phi
());
93
}
else
{
94
value =
static_cast<
float
>
(calibratedEnergy);
95
}
96
photonEnergyDeco(*eg) = value;
97
}
98
99
return
StatusCode::SUCCESS;
100
}
101
102
}
// namespace DerivationFramework
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
EGammaEnergyCalibrationWrapper.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
DerivationFramework::EGammaEnergyCalibrationWrapper::m_eventInfo_key
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo_key
Definition
EGammaEnergyCalibrationWrapper.h:50
DerivationFramework::EGammaEnergyCalibrationWrapper::m_electronEnergyDecoKey
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_electronEnergyDecoKey
Definition
EGammaEnergyCalibrationWrapper.h:42
DerivationFramework::EGammaEnergyCalibrationWrapper::m_electronContainerKey
SG::ReadHandleKey< xAOD::EgammaContainer > m_electronContainerKey
Definition
EGammaEnergyCalibrationWrapper.h:34
DerivationFramework::EGammaEnergyCalibrationWrapper::initialize
StatusCode initialize() override final
Definition
EGammaEnergyCalibrationWrapper.cxx:12
DerivationFramework::EGammaEnergyCalibrationWrapper::m_photonContainerKey
SG::ReadHandleKey< xAOD::EgammaContainer > m_photonContainerKey
Definition
EGammaEnergyCalibrationWrapper.h:38
DerivationFramework::EGammaEnergyCalibrationWrapper::m_photonEnergyDecoKey
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_photonEnergyDecoKey
Definition
EGammaEnergyCalibrationWrapper.h:46
DerivationFramework::EGammaEnergyCalibrationWrapper::m_MVACalibSvc
ServiceHandle< IegammaMVASvc > m_MVACalibSvc
Definition
EGammaEnergyCalibrationWrapper.h:52
DerivationFramework::EGammaEnergyCalibrationWrapper::addBranches
StatusCode addBranches(const EventContext &ctx) const override final
Definition
EGammaEnergyCalibrationWrapper.cxx:23
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition
CaloCluster_v1.cxx:251
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition
CaloCluster_v1.cxx:256
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::Egamma
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition
Egamma.h:17
egammaMVACalib::GlobalEventInfo
A structure holding some global event information.
Definition
GlobalEventInfo.h:10
egammaMVACalib::GlobalEventInfo::eventInfo
const xAOD::EventInfo * eventInfo
Definition
GlobalEventInfo.h:13
Generated on
for ATLAS Offline Software by
1.17.0