ATLAS Offline Software
PhotonsDirectionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // PhotonsDirectionTool.cxx, (c) ATLAS Detector software
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 
16 
17 namespace DerivationFramework {
18 
20  const std::string& n,
21  const IInterface* p)
22  : AthAlgTool(t, n, p)
23 {
24  declareInterface<DerivationFramework::IAugmentationTool>(this);
25 }
26 
29 {
30  ATH_CHECK(m_collName.initialize());
31 
32  m_doEta = !(m_sgEta.key().empty());
33  m_doPhi = !(m_sgPhi.key().empty());
34  m_doEt = !(m_sgEt.key().empty());
35  m_doE = !(m_sgE.key().empty());
36  if (!m_doEta && !m_doPhi && !m_doE && !m_doEt) {
37  ATH_MSG_ERROR("You are requesting the PhotonsDirectionTool but have "
38  "provided no SG names for any of the results");
39  return StatusCode::FAILURE;
40  }
45  return StatusCode::SUCCESS;
46 }
47 
50 {
51  const EventContext& ctx = Gaudi::Hive::currentContext();
52  // Retrieve photon container
54  // define the pointers to vectors which will hold the additional payloads
55  auto recEta = std::make_unique<std::vector<float>>();
56  auto recPhi = std::make_unique<std::vector<float>>();
57  auto recEt = std::make_unique<std::vector<float>>();
58  auto recE = std::make_unique<std::vector<float>>();
59 
60  // Loop over electrons and fill the vectors
61  for (const xAOD::Photon* ph : *photons) {
62  // Prepare variables
63  float eta(0.0), phi(0.0), e(0.0), et(0.0);
64 
65  if (ph->nCaloClusters() > 0) {
66  const xAOD::CaloCluster* gCluster = ph->caloCluster(0);
67  eta = gCluster->etaBE(2);
68  phi = gCluster->phi();
69  e = gCluster->e();
70  et = e / cosh(eta);
71  } else {
73  "Couldn't retrieve photon cluster, will use photon 4-momentum");
74  eta = ph->eta();
75  phi = ph->phi();
76  e = ph->e();
77  et = ph->pt();
78  }
79  recEta->push_back(eta);
80  recPhi->push_back(phi);
81  recEt->push_back(et);
82  recE->push_back(e);
83  } // end of loop over photons
84 
85  // Write payload to StoreGate for downstream client access
86  if (m_doEta) {
88  ATH_CHECK(etas.record(std::move(recEta)));
89  }
90  if (m_doPhi) {
92  ATH_CHECK(phis.record(std::move(recPhi)));
93  }
94  if (m_doEt) {
96  ATH_CHECK(ets.record(std::move(recEt)));
97  }
98  if (m_doE) {
100  ATH_CHECK(es.record(std::move(recE)));
101  }
102  return StatusCode::SUCCESS;
103 }
104 
105 } // end of namespace
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
et
Extra patterns decribing particle interation process.
DerivationFramework::PhotonsDirectionTool::m_doE
bool m_doE
Definition: PhotonsDirectionTool.h:63
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
DerivationFramework::PhotonsDirectionTool::m_sgE
SG::WriteHandleKey< std::vector< float > > m_sgE
Definition: PhotonsDirectionTool.h:55
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::PhotonsDirectionTool::m_doEt
bool m_doEt
Definition: PhotonsDirectionTool.h:62
DerivationFramework::PhotonsDirectionTool::m_sgEta
SG::WriteHandleKey< std::vector< float > > m_sgEta
Definition: PhotonsDirectionTool.h:40
DerivationFramework::PhotonsDirectionTool::m_sgEt
SG::WriteHandleKey< std::vector< float > > m_sgEt
Definition: PhotonsDirectionTool.h:50
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DerivationFramework::PhotonsDirectionTool::addBranches
virtual StatusCode addBranches() const override final
Pass the thinning service
Definition: PhotonsDirectionTool.cxx:49
DerivationFramework::PhotonsDirectionTool::m_collName
SG::ReadHandleKey< xAOD::PhotonContainer > m_collName
Definition: PhotonsDirectionTool.h:35
DerivationFramework::PhotonsDirectionTool::m_doPhi
bool m_doPhi
Definition: PhotonsDirectionTool.h:61
xAOD::CaloCluster_v1::etaBE
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
Definition: CaloCluster_v1.cxx:644
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::PhotonsDirectionTool::m_sgPhi
SG::WriteHandleKey< std::vector< float > > m_sgPhi
Definition: PhotonsDirectionTool.h:45
CaloCluster.h
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DerivationFramework::PhotonsDirectionTool::m_doEta
bool m_doEta
Definition: PhotonsDirectionTool.h:60
PhotonsDirectionTool.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
DerivationFramework::PhotonsDirectionTool::PhotonsDirectionTool
PhotonsDirectionTool(const std::string &t, const std::string &n, const IInterface *p)
Definition: PhotonsDirectionTool.cxx:19
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::Photon_v1
Definition: Photon_v1.h:37
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::PhotonsDirectionTool::initialize
virtual StatusCode initialize() override final
Definition: PhotonsDirectionTool.cxx:28
AthAlgTool
Definition: AthAlgTool.h:26
PhotonContainer.h
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition: CaloCluster_v1.cxx:265
EgEfficiencyCorr_testFixedInput.etas
list etas
Definition: EgEfficiencyCorr_testFixedInput.py:9