ATLAS Offline Software
DecoratePhotonPointingAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
12 
14  ISvcLocator* svcLoc)
15  : EL::AnaAlgorithm(name, svcLoc) {}
16 
18  ATH_CHECK(m_photonContainerKey.initialize());
20 
21  ATH_CHECK(m_pointingTool.retrieve());
22  ATH_CHECK(m_photonVtxTool.retrieve());
23 
24  std::string baseName = m_photonContainerKey.key();
25 
26  m_caloPointingZ = baseName + "." + m_caloPointingZDecorName;
27  m_zCommon = baseName + "." + m_zCommonDecorName;
28  m_zCommonError = baseName + "." + m_zCommonErrorDecorName;
29 
30  ATH_CHECK(m_caloPointingZ.initialize());
31  ATH_CHECK(m_zCommon.initialize());
32  ATH_CHECK(m_zCommonError.initialize());
33 
34  return StatusCode::SUCCESS;
35 }
36 
38 
39  const EventContext& ctx = Gaudi::Hive::currentContext();
40 
42  if (!egammas.isValid()) {
43  ATH_MSG_ERROR("Invalid egamma container from " << m_photonContainerKey.key());
44  return StatusCode::FAILURE;
45  }
47  ATH_CHECK(eventInfo.isValid());
48 
52 
53  ATH_CHECK(m_pointingTool->updatePointingAuxdata(*egammas));
54  ATH_CHECK(m_photonVtxTool->decorateInputs(*egammas));
55 
56  for(const xAOD::Egamma* photon : *egammas){
57  std::pair<float, float> caloPointing = m_pointingTool->getCaloPointing(photon);
58 
59  caloPointingZDec(*photon) = caloPointing.first;
60 
62  photons_selected.push_back(photon);
63  std::pair<float, float> zCommon = xAOD::PVHelpers::getZCommonAndError(&(*eventInfo), photons_selected.asDataVector(), 2e3);
64  zCommonDec(*photon) = zCommon.first;
65  zCommonErrorDec(*photon) = zCommon.second;
66  }
67 
68  return StatusCode::SUCCESS;
69 }
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
CurrentContext.h
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
xAOD::PVHelpers::getZCommonAndError
std::pair< float, float > getZCommonAndError(const xAOD::EventInfo *eventInfo, const xAOD::EgammaContainer *egammas, float convPtCut=2e3)
Return zCommon and zCommonError.
Definition: PhotonVertexHelpers.cxx:44
DecoratePhotonPointingAlg::m_zCommon
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_zCommon
Definition: DecoratePhotonPointingAlg.h:37
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
DecoratePhotonPointingAlg.h
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
EgammaContainer.h
DecoratePhotonPointingAlg::DecoratePhotonPointingAlg
DecoratePhotonPointingAlg(const std::string &name, ISvcLocator *svcLoc=nullptr)
Definition: DecoratePhotonPointingAlg.cxx:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DecoratePhotonPointingAlg::m_zCommonErrorDecorName
Gaudi::Property< std::string > m_zCommonErrorDecorName
Definition: DecoratePhotonPointingAlg.h:42
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
DecoratePhotonPointingAlg::m_photonContainerKey
SG::ReadHandleKey< xAOD::EgammaContainer > m_photonContainerKey
Definition: DecoratePhotonPointingAlg.h:44
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
DecoratePhotonPointingAlg::m_caloPointingZ
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_caloPointingZ
Definition: DecoratePhotonPointingAlg.h:36
WriteDecorHandle.h
Handle class for adding a decoration to an object.
DecoratePhotonPointingAlg::initialize
virtual StatusCode initialize() override
Definition: DecoratePhotonPointingAlg.cxx:17
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
PhotonVertexHelpers.h
DecoratePhotonPointingAlg::m_pointingTool
ToolHandle< CP::IPhotonPointingTool > m_pointingTool
Definition: DecoratePhotonPointingAlg.h:50
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ReadHandle.h
Handle class for reading from StoreGate.
DecoratePhotonPointingAlg::m_photonVtxTool
ToolHandle< CP::IPhotonVertexSelectionTool > m_photonVtxTool
Definition: DecoratePhotonPointingAlg.h:54
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DecoratePhotonPointingAlg::execute
StatusCode execute() override
Definition: DecoratePhotonPointingAlg.cxx:37
DecoratePhotonPointingAlg::m_caloPointingZDecorName
Gaudi::Property< std::string > m_caloPointingZDecorName
Definition: DecoratePhotonPointingAlg.h:40
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
DecoratePhotonPointingAlg::m_zCommonError
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_zCommonError
Definition: DecoratePhotonPointingAlg.h:38
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
DecoratePhotonPointingAlg::m_zCommonDecorName
Gaudi::Property< std::string > m_zCommonDecorName
Definition: DecoratePhotonPointingAlg.h:41
DecoratePhotonPointingAlg::m_eventInKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInKey
Definition: DecoratePhotonPointingAlg.h:47