ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkEGamma
src
EGammaFudgeAlgorithm.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// EDM include(s):
6
7
// local include
8
#include "
DerivationFrameworkEGamma/EGammaFudgeAlgorithm.h
"
9
#include "
xAODEgamma/ElectronContainer.h
"
10
#include "
xAODEgamma/PhotonContainer.h
"
11
12
#include "
xAODCore/ShallowCopy.h
"
13
#include "
xAODBase/IParticleHelpers.h
"
14
#include "
PATInterfaces/CorrectionCode.h
"
15
16
namespace
DerivationFramework
{
17
18
StatusCode
EGammaFudgeAlgorithm::initialize
() {
19
ATH_CHECK
(
m_inputKey
.initialize());
20
ATH_CHECK
(
m_outputKey
.initialize());
21
ATH_CHECK
(
m_fudgeTool
.retrieve());
22
return
StatusCode::SUCCESS;
23
}
24
25
StatusCode
EGammaFudgeAlgorithm::execute
(
const
EventContext& ctx)
const
{
26
27
SG::ReadHandle<xAOD::EgammaContainer>
readHandle{
m_inputKey
, ctx};
28
if
(!readHandle.
isValid
()) {
29
ATH_MSG_FATAL
(
"No EGamma container found"
);
30
return
StatusCode::FAILURE;
31
}
32
const
xAOD::EgammaContainer
* egammas{readHandle.
cptr
()};
33
const
xAOD::ElectronContainer
* electrons =
dynamic_cast<
const
xAOD::ElectronContainer
*
>
(egammas);
34
const
xAOD::PhotonContainer
* photons =
dynamic_cast<
const
xAOD::PhotonContainer
*
>
(egammas);
35
36
xAOD::EgammaContainer
* outcontainer{
nullptr
};
37
if
(electrons) {
38
xAOD::ShallowCopyResult_t<xAOD::ElectronContainer>
output =
xAOD::shallowCopy
(*electrons, ctx);
39
if
(!output.first || !output.second) {
40
ATH_MSG_FATAL
(
"Creation of shallow copy failed"
);
41
return
StatusCode::FAILURE;
42
}
43
outcontainer = output.first.get();
44
SG::WriteHandle<xAOD::EgammaContainer>
writeHandle{
m_outputKey
, ctx};
45
ATH_CHECK
(writeHandle.
recordNonConst
(std::move(output.first), std::move(output.second)));
46
47
}
else
if
(photons) {
48
xAOD::ShallowCopyResult_t<xAOD::PhotonContainer>
output =
xAOD::shallowCopy
(*photons, ctx);
49
if
(!output.first || !output.second) {
50
ATH_MSG_FATAL
(
"Creation of shallow copy failed"
);
51
return
StatusCode::FAILURE;
52
}
53
outcontainer = output.first.get();
54
SG::WriteHandle<xAOD::EgammaContainer>
writeHandle{
m_outputKey
, ctx};
55
ATH_CHECK
(writeHandle.
recordNonConst
(std::move(output.first), std::move(output.second)));
56
}
else
{
57
ATH_MSG_FATAL
(
"Unknown Egamma container "
<<
m_inputKey
.fullKey());
58
return
StatusCode::FAILURE;
59
}
60
61
if
(!setOriginalObjectLink(*egammas, *outcontainer)) {
62
ATH_MSG_ERROR
(
"Failed to add original object links to shallow copy of "
<<
m_inputKey
);
63
return
StatusCode::FAILURE;
64
}
65
66
for
(
xAOD::Egamma
* iParticle : *outcontainer) {
67
if
(electrons) {
68
auto
* electron =
static_cast<
xAOD::Electron
*
>
(iParticle);
69
if
(
m_fudgeTool
->applyCorrection(*electron)==
CP::CorrectionCode::Error
)
70
return
StatusCode::FAILURE;
71
}
else
{
72
auto
* photon =
static_cast<
xAOD::Photon
*
>
(iParticle);
73
if
(
m_fudgeTool
->applyCorrection(*photon) ==
CP::CorrectionCode::Error
)
74
return
StatusCode::FAILURE;
75
}
76
}
77
78
return
StatusCode::SUCCESS;
79
}
80
81
}
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_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
CorrectionCode.h
EGammaFudgeAlgorithm.h
ElectronContainer.h
PhotonContainer.h
IParticleHelpers.h
ShallowCopy.h
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition
CorrectionCode.h:36
DerivationFramework::EGammaFudgeAlgorithm::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Definition
EGammaFudgeAlgorithm.cxx:25
DerivationFramework::EGammaFudgeAlgorithm::m_fudgeTool
ToolHandle< IElectronPhotonShowerShapeFudgeTool > m_fudgeTool
Definition
EGammaFudgeAlgorithm.h:32
DerivationFramework::EGammaFudgeAlgorithm::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition
EGammaFudgeAlgorithm.cxx:18
DerivationFramework::EGammaFudgeAlgorithm::m_outputKey
SG::WriteHandleKey< xAOD::EgammaContainer > m_outputKey
Definition
EGammaFudgeAlgorithm.h:31
DerivationFramework::EGammaFudgeAlgorithm::m_inputKey
SG::ReadHandleKey< xAOD::EgammaContainer > m_inputKey
Definition
EGammaFudgeAlgorithm.h:30
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::recordNonConst
StatusCode recordNonConst(std::unique_ptr< T > data)
Record a non-const object to the store.
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
xAOD::ShallowCopyResult_t
typename ShallowCopyResult< T >::type ShallowCopyResult_t
Return type of xAOD::shallowCopy.
Definition
ShallowCopy.h:68
xAOD::PhotonContainer
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/PhotonContainer.h:17
xAOD::ElectronContainer
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/ElectronContainer.h:17
xAOD::shallowCopy
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
xAOD::Egamma
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition
Egamma.h:17
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
xAOD::EgammaContainer
EgammaContainer_v1 EgammaContainer
Definition of the current "egamma container version".
Definition
EgammaContainer.h:17
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
Generated on
for ATLAS Offline Software by
1.17.0