ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
ElectronPhotonID
PhotonVertexSelection
Root
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
5
#include "
PhotonVertexSelection/DecoratePhotonPointingAlg.h
"
6
#include "
PhotonVertexSelection/PhotonVertexHelpers.h
"
7
#include "
xAODEgamma/EgammaContainer.h
"
8
#include "
AthContainers/ConstDataVector.h
"
9
#include "
AsgDataHandles/ReadHandle.h
"
10
#include "
AsgDataHandles/WriteDecorHandle.h
"
11
#include "
AsgTools/CurrentContext.h
"
12
13
DecoratePhotonPointingAlg::DecoratePhotonPointingAlg
(
const
std::string& name,
14
ISvcLocator* svcLoc)
15
:
EL
::
AnaAlgorithm
(name, svcLoc) {}
16
17
StatusCode
DecoratePhotonPointingAlg::initialize
() {
18
ATH_CHECK
(
m_photonContainerKey
.initialize());
19
ATH_CHECK
(
m_eventInKey
.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
37
StatusCode
DecoratePhotonPointingAlg::execute
() {
38
39
const
EventContext& ctx = Gaudi::Hive::currentContext();
40
41
SG::ReadHandle<xAOD::EgammaContainer>
egammas(
m_photonContainerKey
, ctx);
42
if
(!egammas.
isValid
()) {
43
ATH_MSG_ERROR
(
"Invalid egamma container from "
<<
m_photonContainerKey
.key());
44
return
StatusCode::FAILURE;
45
}
46
SG::ReadHandle<xAOD::EventInfo>
eventInfo(
m_eventInKey
, ctx);
47
ATH_CHECK
(eventInfo.
isValid
());
48
49
SG::WriteDecorHandle<xAOD::EgammaContainer, float>
caloPointingZDec(
m_caloPointingZ
, ctx);
50
SG::WriteDecorHandle<xAOD::EgammaContainer, float>
zCommonDec(
m_zCommon
, ctx);
51
SG::WriteDecorHandle<xAOD::EgammaContainer, float>
zCommonErrorDec(
m_zCommonError
, ctx);
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
61
ConstDataVector<DataVector<xAOD::Egamma>
> photons_selected(
SG::VIEW_ELEMENTS
);
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
}
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
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
CurrentContext.h
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
DecoratePhotonPointingAlg.h
EgammaContainer.h
PhotonVertexHelpers.h
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition
ConstDataVector.h:76
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
DecoratePhotonPointingAlg::execute
StatusCode execute() override
Definition
DecoratePhotonPointingAlg.cxx:37
DecoratePhotonPointingAlg::initialize
virtual StatusCode initialize() override
Definition
DecoratePhotonPointingAlg.cxx:17
DecoratePhotonPointingAlg::m_photonContainerKey
SG::ReadHandleKey< xAOD::EgammaContainer > m_photonContainerKey
Definition
DecoratePhotonPointingAlg.h:44
DecoratePhotonPointingAlg::m_zCommonDecorName
Gaudi::Property< std::string > m_zCommonDecorName
Definition
DecoratePhotonPointingAlg.h:41
DecoratePhotonPointingAlg::m_zCommonError
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_zCommonError
Definition
DecoratePhotonPointingAlg.h:38
DecoratePhotonPointingAlg::m_pointingTool
ToolHandle< CP::IPhotonPointingTool > m_pointingTool
Definition
DecoratePhotonPointingAlg.h:50
DecoratePhotonPointingAlg::m_eventInKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInKey
Definition
DecoratePhotonPointingAlg.h:47
DecoratePhotonPointingAlg::m_zCommon
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_zCommon
Definition
DecoratePhotonPointingAlg.h:37
DecoratePhotonPointingAlg::m_photonVtxTool
ToolHandle< CP::IPhotonVertexSelectionTool > m_photonVtxTool
Definition
DecoratePhotonPointingAlg.h:54
DecoratePhotonPointingAlg::m_caloPointingZ
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_caloPointingZ
Definition
DecoratePhotonPointingAlg.h:36
DecoratePhotonPointingAlg::m_caloPointingZDecorName
Gaudi::Property< std::string > m_caloPointingZDecorName
Definition
DecoratePhotonPointingAlg.h:40
DecoratePhotonPointingAlg::DecoratePhotonPointingAlg
DecoratePhotonPointingAlg(const std::string &name, ISvcLocator *svcLoc=nullptr)
Definition
DecoratePhotonPointingAlg.cxx:13
DecoratePhotonPointingAlg::m_zCommonErrorDecorName
Gaudi::Property< std::string > m_zCommonErrorDecorName
Definition
DecoratePhotonPointingAlg.h:42
EL::AnaAlgorithm::AnaAlgorithm
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Definition
AnaAlgorithm.cxx:40
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition
AsgComponentFactories.h:16
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
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:43
xAOD::Egamma
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition
Egamma.h:17
Generated on
for ATLAS Offline Software by
1.17.0