ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
10namespace DerivationFramework {
11
13{
15 ATH_CHECK(m_photonContainerKey.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
23StatusCode EGammaEnergyCalibrationWrapper::addBranches(const EventContext& ctx) const
24{
25 // Process electrons
27 if (!electrons.isValid()) {
28 ATH_MSG_ERROR("Cannot retrieve electron container " << m_electronContainerKey.key());
29 return StatusCode::FAILURE;
30 }
31
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
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
67 if (!photons.isValid()) {
68 ATH_MSG_ERROR("Cannot retrieve photon container " << m_photonContainerKey.key());
69 return StatusCode::FAILURE;
70 }
71
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
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
static Double_t sc
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_electronEnergyDecoKey
SG::ReadHandleKey< xAOD::EgammaContainer > m_electronContainerKey
SG::ReadHandleKey< xAOD::EgammaContainer > m_photonContainerKey
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_photonEnergyDecoKey
StatusCode addBranches(const EventContext &ctx) const override final
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
THE reconstruction tool.
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
A structure holding some global event information.
const xAOD::EventInfo * eventInfo