ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::EGammaEnergyCalibrationWrapper Class Reference

#include <EGammaEnergyCalibrationWrapper.h>

Inheritance diagram for DerivationFramework::EGammaEnergyCalibrationWrapper:
Collaboration diagram for DerivationFramework::EGammaEnergyCalibrationWrapper:

Public Member Functions

StatusCode initialize () override final
StatusCode addBranches (const EventContext &ctx) const override final

Private Attributes

SG::ReadHandleKey< xAOD::EgammaContainerm_electronContainerKey
SG::ReadHandleKey< xAOD::EgammaContainerm_photonContainerKey
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_electronEnergyDecoKey
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_photonEnergyDecoKey
SG::ReadHandleKey< xAOD::EventInfom_eventInfo_key {this, "EventInfo", "EventInfo", "Input event information"}
ServiceHandle< IegammaMVASvcm_MVACalibSvc

Detailed Description

Definition at line 24 of file EGammaEnergyCalibrationWrapper.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::EGammaEnergyCalibrationWrapper::addBranches ( const EventContext & ctx) const
finaloverride

Definition at line 23 of file EGammaEnergyCalibrationWrapper.cxx.

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}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
static Double_t sc
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_electronEnergyDecoKey
SG::ReadHandleKey< xAOD::EgammaContainer > m_electronContainerKey
SG::ReadHandleKey< xAOD::EgammaContainer > m_photonContainerKey
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_photonEnergyDecoKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
::StatusCode StatusCode
StatusCode definition for legacy code.
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
const xAOD::EventInfo * eventInfo

◆ initialize()

StatusCode DerivationFramework::EGammaEnergyCalibrationWrapper::initialize ( )
finaloverride

Definition at line 12 of file EGammaEnergyCalibrationWrapper.cxx.

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}
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_electronContainerKey

SG::ReadHandleKey<xAOD::EgammaContainer> DerivationFramework::EGammaEnergyCalibrationWrapper::m_electronContainerKey
private
Initial value:
{
this, "ElectronContainerName", "Electrons", "Electron container"
}

Definition at line 34 of file EGammaEnergyCalibrationWrapper.h.

34 {
35 this, "ElectronContainerName", "Electrons", "Electron container"
36 };

◆ m_electronEnergyDecoKey

SG::WriteDecorHandleKey<xAOD::EgammaContainer> DerivationFramework::EGammaEnergyCalibrationWrapper::m_electronEnergyDecoKey
private
Initial value:
{
this, "decoratorTransformerEnergy", m_electronContainerKey, "", "Calibrated energy decoration for electrons"
}

Definition at line 42 of file EGammaEnergyCalibrationWrapper.h.

42 {
43 this, "decoratorTransformerEnergy", m_electronContainerKey, "", "Calibrated energy decoration for electrons"
44 };

◆ m_eventInfo_key

SG::ReadHandleKey<xAOD::EventInfo> DerivationFramework::EGammaEnergyCalibrationWrapper::m_eventInfo_key {this, "EventInfo", "EventInfo", "Input event information"}
private

Definition at line 50 of file EGammaEnergyCalibrationWrapper.h.

50{this, "EventInfo", "EventInfo", "Input event information"};

◆ m_MVACalibSvc

ServiceHandle<IegammaMVASvc> DerivationFramework::EGammaEnergyCalibrationWrapper::m_MVACalibSvc
private
Initial value:
{
this, "TransformerCalibSvc", "", "Calibration service using Transformer model"
}

Definition at line 52 of file EGammaEnergyCalibrationWrapper.h.

52 {
53 this, "TransformerCalibSvc", "", "Calibration service using Transformer model"
54 };

◆ m_photonContainerKey

SG::ReadHandleKey<xAOD::EgammaContainer> DerivationFramework::EGammaEnergyCalibrationWrapper::m_photonContainerKey
private
Initial value:
{
this, "PhotonContainerName", "Photons", "Photon container"
}

Definition at line 38 of file EGammaEnergyCalibrationWrapper.h.

38 {
39 this, "PhotonContainerName", "Photons", "Photon container"
40 };

◆ m_photonEnergyDecoKey

SG::WriteDecorHandleKey<xAOD::EgammaContainer> DerivationFramework::EGammaEnergyCalibrationWrapper::m_photonEnergyDecoKey
private
Initial value:
{
this, "decoratorTransformerEnergyPhoton", m_photonContainerKey, "", "Calibrated energy decoration for photons"
}

Definition at line 46 of file EGammaEnergyCalibrationWrapper.h.

46 {
47 this, "decoratorTransformerEnergyPhoton", m_photonContainerKey, "", "Calibrated energy decoration for photons"
48 };

The documentation for this class was generated from the following files: