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

#include <PhotonsDirectionTool.h>

Inheritance diagram for DerivationFramework::PhotonsDirectionTool:
Collaboration diagram for DerivationFramework::PhotonsDirectionTool:

Public Member Functions

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

Private Attributes

SG::ReadHandleKey< xAOD::PhotonContainerm_collName
SG::WriteHandleKey< std::vector< float > > m_sgEta
SG::WriteHandleKey< std::vector< float > > m_sgPhi
SG::WriteHandleKey< std::vector< float > > m_sgEt
SG::WriteHandleKey< std::vector< float > > m_sgE
bool m_doEta = false
bool m_doPhi = false
bool m_doEt = false
bool m_doE = false

Detailed Description

Definition at line 17 of file PhotonsDirectionTool.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::PhotonsDirectionTool::addBranches ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 41 of file PhotonsDirectionTool.cxx.

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 {
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}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
float et(const xAOD::jFexSRJetRoI *j)
SG::WriteHandleKey< std::vector< float > > m_sgE
SG::WriteHandleKey< std::vector< float > > m_sgPhi
SG::WriteHandleKey< std::vector< float > > m_sgEt
SG::ReadHandleKey< xAOD::PhotonContainer > m_collName
SG::WriteHandleKey< std::vector< float > > m_sgEta
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Photon_v1 Photon
Definition of the current "egamma version".

◆ initialize()

StatusCode DerivationFramework::PhotonsDirectionTool::initialize ( )
finaloverridevirtual

Definition at line 20 of file PhotonsDirectionTool.cxx.

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}
#define ATH_MSG_ERROR(x)
static const Attributes_t empty

Member Data Documentation

◆ m_collName

SG::ReadHandleKey<xAOD::PhotonContainer> DerivationFramework::PhotonsDirectionTool::m_collName
private
Initial value:
{ this,
"PhotonContainer",
"Photons",
"Input Photons" }

Definition at line 27 of file PhotonsDirectionTool.h.

27 { this,
28 "PhotonContainer",
29 "Photons",
30 "Input Photons" };

◆ m_doE

bool DerivationFramework::PhotonsDirectionTool::m_doE = false
private

Definition at line 55 of file PhotonsDirectionTool.h.

◆ m_doEt

bool DerivationFramework::PhotonsDirectionTool::m_doEt = false
private

Definition at line 54 of file PhotonsDirectionTool.h.

◆ m_doEta

bool DerivationFramework::PhotonsDirectionTool::m_doEta = false
private

Definition at line 52 of file PhotonsDirectionTool.h.

◆ m_doPhi

bool DerivationFramework::PhotonsDirectionTool::m_doPhi = false
private

Definition at line 53 of file PhotonsDirectionTool.h.

◆ m_sgE

SG::WriteHandleKey<std::vector<float> > DerivationFramework::PhotonsDirectionTool::m_sgE
private
Initial value:
{ this,
"ESGEntry",
"",
"output E vector" }

Definition at line 47 of file PhotonsDirectionTool.h.

47 { this,
48 "ESGEntry",
49 "",
50 "output E vector" };

◆ m_sgEt

SG::WriteHandleKey<std::vector<float> > DerivationFramework::PhotonsDirectionTool::m_sgEt
private
Initial value:
{ this,
"EtSGEntry",
"",
"output E vector" }

Definition at line 42 of file PhotonsDirectionTool.h.

42 { this,
43 "EtSGEntry",
44 "",
45 "output E vector" };

◆ m_sgEta

SG::WriteHandleKey<std::vector<float> > DerivationFramework::PhotonsDirectionTool::m_sgEta
private
Initial value:
{ this,
"EtaSGEntry",
"",
"output Eta vector" }

Definition at line 32 of file PhotonsDirectionTool.h.

32 { this,
33 "EtaSGEntry",
34 "",
35 "output Eta vector" };

◆ m_sgPhi

SG::WriteHandleKey<std::vector<float> > DerivationFramework::PhotonsDirectionTool::m_sgPhi
private
Initial value:
{ this,
"PhiSGEntry",
"",
"output Phi vector" }

Definition at line 37 of file PhotonsDirectionTool.h.

37 { this,
38 "PhiSGEntry",
39 "",
40 "output Phi vector" };

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