ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkEGamma
src
PhotonsDirectionTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// PhotonsDirectionTool
7
// compute photon et = E(cluster)/cosh(eta of 2nd sampling)
8
// eventually E will be after recalibration
10
// Author: Giovanni Marchiori (giovanni.marchiori@cern.ch)
11
//
12
13
#include "
DerivationFrameworkEGamma/PhotonsDirectionTool.h
"
14
#include "
xAODCaloEvent/CaloCluster.h
"
15
#include "
xAODEgamma/PhotonContainer.h
"
16
17
namespace
DerivationFramework
{
18
19
StatusCode
20
PhotonsDirectionTool::initialize
()
21
{
22
ATH_CHECK
(
m_collName
.initialize());
23
24
m_doEta
= !(
m_sgEta
.key().
empty
());
25
m_doPhi
= !(
m_sgPhi
.key().
empty
());
26
m_doEt
= !(
m_sgEt
.key().
empty
());
27
m_doE
= !(
m_sgE
.key().
empty
());
28
if
(!
m_doEta
&& !
m_doPhi
&& !
m_doE
&& !
m_doEt
) {
29
ATH_MSG_ERROR
(
"You are requesting the PhotonsDirectionTool but have "
30
"provided no SG names for any of the results"
);
31
return
StatusCode::FAILURE;
32
}
33
ATH_CHECK
(
m_sgEta
.initialize(
m_doEta
));
34
ATH_CHECK
(
m_sgPhi
.initialize(
m_doPhi
));
35
ATH_CHECK
(
m_sgEt
.initialize(
m_doEt
));
36
ATH_CHECK
(
m_sgE
.initialize(
m_doE
));
37
return
StatusCode::SUCCESS;
38
}
39
40
StatusCode
41
PhotonsDirectionTool::addBranches
(
const
EventContext& ctx)
const
42
{
43
// Retrieve photon container
44
SG::ReadHandle<xAOD::PhotonContainer>
photons(
m_collName
, ctx);
45
// define the pointers to vectors which will hold the additional payloads
46
auto
recEta = std::make_unique<std::vector<float>>();
47
auto
recPhi = std::make_unique<std::vector<float>>();
48
auto
recEt = std::make_unique<std::vector<float>>();
49
auto
recE = std::make_unique<std::vector<float>>();
50
51
// Loop over electrons and fill the vectors
52
for
(
const
xAOD::Photon
* ph : *photons) {
53
// Prepare variables
54
float
eta
(0.0),
phi
(0.0), e(0.0),
et
(0.0);
55
56
if
(ph->nCaloClusters() > 0) {
57
const
xAOD::CaloCluster
* gCluster = ph->caloCluster(0);
58
eta
= gCluster->
etaBE
(2);
59
phi
= gCluster->
phi
();
60
e = gCluster->
e
();
61
et
= e / cosh(
eta
);
62
}
else
{
63
ATH_MSG_WARNING
(
64
"Couldn't retrieve photon cluster, will use photon 4-momentum"
);
65
eta
= ph->eta();
66
phi
= ph->phi();
67
e = ph->e();
68
et
= ph->pt();
69
}
70
recEta->push_back(
eta
);
71
recPhi->push_back(
phi
);
72
recEt->push_back(
et
);
73
recE->push_back(e);
74
}
// end of loop over photons
75
76
// Write payload to StoreGate for downstream client access
77
if
(
m_doEta
) {
78
SG::WriteHandle<std::vector<float>
> etas(
m_sgEta
, ctx);
79
ATH_CHECK
(etas.record(std::move(recEta)));
80
}
81
if
(
m_doPhi
) {
82
SG::WriteHandle<std::vector<float>
> phis(
m_sgPhi
, ctx);
83
ATH_CHECK
(phis.
record
(std::move(recPhi)));
84
}
85
if
(
m_doEt
) {
86
SG::WriteHandle<std::vector<float>
> ets(
m_sgEt
, ctx);
87
ATH_CHECK
(ets.
record
(std::move(recEt)));
88
}
89
if
(
m_doE
) {
90
SG::WriteHandle<std::vector<float>
> es(
m_sgE
, ctx);
91
ATH_CHECK
(es.
record
(std::move(recE)));
92
}
93
return
StatusCode::SUCCESS;
94
}
95
96
}
// end of namespace
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
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
CaloCluster.h
PhotonContainer.h
et
float et(const xAOD::jFexSRJetRoI *j)
Definition
L1MonitorAdaptors.h:17
PhotonsDirectionTool.h
empty
static const Attributes_t empty
Definition
XmlStreamer.cxx:16
DerivationFramework::PhotonsDirectionTool::m_doPhi
bool m_doPhi
Definition
PhotonsDirectionTool.h:53
DerivationFramework::PhotonsDirectionTool::m_doEta
bool m_doEta
Definition
PhotonsDirectionTool.h:52
DerivationFramework::PhotonsDirectionTool::m_sgE
SG::WriteHandleKey< std::vector< float > > m_sgE
Definition
PhotonsDirectionTool.h:47
DerivationFramework::PhotonsDirectionTool::m_sgPhi
SG::WriteHandleKey< std::vector< float > > m_sgPhi
Definition
PhotonsDirectionTool.h:37
DerivationFramework::PhotonsDirectionTool::m_doE
bool m_doE
Definition
PhotonsDirectionTool.h:55
DerivationFramework::PhotonsDirectionTool::m_doEt
bool m_doEt
Definition
PhotonsDirectionTool.h:54
DerivationFramework::PhotonsDirectionTool::initialize
virtual StatusCode initialize() override final
Definition
PhotonsDirectionTool.cxx:20
DerivationFramework::PhotonsDirectionTool::m_sgEt
SG::WriteHandleKey< std::vector< float > > m_sgEt
Definition
PhotonsDirectionTool.h:42
DerivationFramework::PhotonsDirectionTool::m_collName
SG::ReadHandleKey< xAOD::PhotonContainer > m_collName
Definition
PhotonsDirectionTool.h:27
DerivationFramework::PhotonsDirectionTool::m_sgEta
SG::WriteHandleKey< std::vector< float > > m_sgEta
Definition
PhotonsDirectionTool.h:32
DerivationFramework::PhotonsDirectionTool::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition
PhotonsDirectionTool.cxx:41
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition
CaloCluster_v1.cxx:265
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition
CaloCluster_v1.cxx:256
xAOD::CaloCluster_v1::etaBE
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
Definition
CaloCluster_v1.cxx:628
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
et
Extra patterns decribing particle interation process.
Generated on
for ATLAS Offline Software by
1.17.0