ATLAS Offline Software
Loading...
Searching...
No Matches
PhotonOriginCorrectionAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7//
8// includes
9//
10
13
15//
16// method implementations
17//
18
19namespace CP {
20PhotonOriginCorrectionAlg ::PhotonOriginCorrectionAlg(const std::string& name,
21 ISvcLocator* pSvcLocator)
22 : AnaReentrantAlgorithm(name, pSvcLocator) {}
23
24StatusCode PhotonOriginCorrectionAlg ::initialize() {
28
29 // We do not have systematics in principle from this operation
30 ANA_CHECK(m_systematicsList.initialize());
31 ANA_CHECK(m_primVertices.initialize());
32 return StatusCode::SUCCESS;
33}
34
35StatusCode PhotonOriginCorrectionAlg ::execute(const EventContext &ctx) const {
36
37 // If we can not rely on Event Cleaning or something
38 // else having run before for the PHYSLITE.
39 // We have to see if we have a PriVtx.
41 const xAOD::Vertex* primary = nullptr;
42 for (const xAOD::Vertex* vtx : *vertices) {
43 if (vtx->vertexType() == xAOD::VxType::PriVtx) {
44 primary = vtx;
45 break;
46 }
47 }
48 if (!primary) {
49 ATH_MSG_WARNING("Could not find a Primary vertex");
50 }
51
52 for (const auto& sys : m_systematicsList.systematicsVector()) {
53
54 xAOD::PhotonContainer* photons = nullptr;
55
56 ANA_CHECK(m_PhotonHandle.getCopy(photons, sys));
57
58 // Actually here we rely on the egamma preselection
59 // to have run. Otherwise there is high danger
60 // or garbage for the LarEM "gap" region.
61 // It seems to be the case for PHYSLITE
62 for (xAOD::Photon* ph : *photons) {
63 if (m_preselection.getBool(*ph, sys) && primary) {
64 // We have a primary vertex so we should be able
65 // to correct the Photon Origin from (0,0,0)
66 // to (0,0,z)
67 photonWrtPoint::correctForZ(*ph, primary->z());
68 }
69 }
70 }
71 return StatusCode::SUCCESS;
72}
73} // namespace CP
#define ATH_MSG_WARNING(x)
Handle class for reading from StoreGate.
#define ANA_CHECK(EXP)
check whether the given expression was successful
SysCopyHandle< xAOD::PhotonContainer > m_PhotonHandle
the egamma collection we run on
SysReadSelectionHandle m_preselection
the preselection we apply to our input
SysListHandle m_systematicsList
the systematics list we run
SG::ReadHandleKey< xAOD::VertexContainer > m_primVertices
the vertices to loop over to select the Primary
AnaReentrantAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Select isolated Photons, Electrons and Muons.
void correctForZ(xAOD::Egamma &ph, double z)
Function to modify in place the kinematics of a photon wrt (0,0,z0)
@ PriVtx
Primary vertex.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
Photon_v1 Photon
Definition of the current "egamma version".