ATLAS Offline Software
Loading...
Searching...
No Matches
EMClusterTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "EMClusterTool.h"
7#include "GaudiKernel/EventContext.h"
11
14
18
20 const std::string& name,
21 const IInterface* parent)
22 : AthAlgTool(type, name, parent)
23{
24 declareInterface<IEMClusterTool>(this);
25}
26
27StatusCode
29{
30
31 ATH_MSG_DEBUG("Initializing " << name() << "...");
32
34
36 m_outputClusterContainerKey.key() + "_links";
38
39 // Get the cluster correction tool
40 ATH_CHECK(m_MVACalibSvc.retrieve());
41
42 ATH_MSG_DEBUG("Initialization successful");
43
44 return StatusCode::SUCCESS;
45}
46
47StatusCode
48EMClusterTool::contExecute(const EventContext& ctx,
51{
52
53 // Create output cluster container and register in StoreGate
56
58
59 SG::WriteHandle<CaloClusterCellLinkContainer> outputClusterContainerCellLink(
61
62 ATH_CHECK(outputClusterContainerCellLink.record(
63 std::make_unique<CaloClusterCellLinkContainer>()));
64
65 // Loop over electrons and create new clusters
67 for (auto electron : *electronContainer) {
68 setNewCluster(ctx, electron, outputClusterContainer.ptr());
69 }
70 }
71
72 if (photonContainer) {
73 // Loop over photons and create new clusters
74 for (auto photon : *photonContainer) {
75 setNewCluster(ctx, photon, outputClusterContainer.ptr());
76 }
77 }
78
80 ctx,
81 outputClusterContainer,
82 outputClusterContainerCellLink);
83
84 return StatusCode::SUCCESS;
85}
86
87void
89 const EventContext& ctx,
90 xAOD::Egamma* eg,
91 xAOD::CaloClusterContainer* outputClusterContainer) const
92{
93 if (!eg) {
94 return;
95 }
96 if (!eg->caloCluster()) {
97 ATH_MSG_DEBUG("egamma object does not have a cluster associated");
98 return;
99 }
101 //create new cluster
102xAOD::CaloCluster* cluster = outputClusterContainer->push_back(std::make_unique<xAOD::CaloCluster>());
103 //copy over
104 (*cluster)=*(eg->caloCluster());
105 //and do final calibration
106 if (m_MVACalibSvc->execute(*cluster, *eg).isFailure()) {
107 ATH_MSG_ERROR("Problem executing MVA cluster tool");
108 }
109 // Set the link to the new cluster
110 ClusterLink_t clusterLink(cluster, *outputClusterContainer, ctx);
111 const std::vector<ClusterLink_t> clusterLinks{ clusterLink };
112 eg->setCaloClusterLinks(clusterLinks);
113}
114
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Definition of CaloDetDescrManager.
Handle class for recording to StoreGate.
xAOD::ElectronContainer * electronContainer
xAOD::PhotonContainer * photonContainer
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_outputClusterContainerCellLinkKey
Key of the output cluster container cell links: name taken from containter name; only dummy configura...
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outputClusterContainerKey
Key of the output cluster container.
virtual StatusCode contExecute(const EventContext &ctx, xAOD::ElectronContainer *electronContainer, xAOD::PhotonContainer *photonContainer) const override final
execute on container
ServiceHandle< IegammaMVASvc > m_MVACalibSvc
Handle to the MVA calibration service.
EMClusterTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
void setNewCluster(const EventContext &ctx, xAOD::Egamma *eg, xAOD::CaloClusterContainer *outputClusterContainer) const
Set new cluster to the egamma object, decorate the new cluster with a link to the old one.
virtual StatusCode initialize() override final
initialize method
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
ElementLink< xAOD::CaloClusterContainer > ClusterLink_t
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.