From b9879f28b26a91d59430f2df17233a891b83df63 Mon Sep 17 00:00:00 2001
From: christos <christos@cern.ch>
Date: Tue, 2 Jun 2020 23:03:03 +0200
Subject: [PATCH] Try to remove execute with no EventContext

---
 .../CaloFillRectangularCluster.h              |  7 ----
 .../ClusterEnergyPerLayerDecorator.h          |  8 ++---
 .../src/ClusterEnergyPerLayerDecorator.cxx    | 36 ++++++++++++-------
 3 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/Calorimeter/CaloClusterCorrection/CaloClusterCorrection/CaloFillRectangularCluster.h b/Calorimeter/CaloClusterCorrection/CaloClusterCorrection/CaloFillRectangularCluster.h
index 699410b9b5d..68f600d6403 100755
--- a/Calorimeter/CaloClusterCorrection/CaloClusterCorrection/CaloFillRectangularCluster.h
+++ b/Calorimeter/CaloClusterCorrection/CaloClusterCorrection/CaloFillRectangularCluster.h
@@ -84,13 +84,6 @@ public:
   virtual void makeCorrection(const EventContext& ctx,
                               xAOD::CaloCluster* cluster) const override;
 
-
-  // Temp workaround to keep IsolationTools happy.
-  void makeCorrection(xAOD::CaloCluster* cluster) const
-  {
-    return makeCorrection (Gaudi::Hive::currentContext(), cluster);
-  }
-
   /*
    * @brief Return the seed position of a cluster.
    * @param helper Sampling calculation helper object.
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/DerivationFrameworkCalo/ClusterEnergyPerLayerDecorator.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/DerivationFrameworkCalo/ClusterEnergyPerLayerDecorator.h
index f39483f02c9..309d1c45899 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/DerivationFrameworkCalo/ClusterEnergyPerLayerDecorator.h
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/DerivationFrameworkCalo/ClusterEnergyPerLayerDecorator.h
@@ -14,9 +14,8 @@
 #include "AthenaBaseComps/AthAlgTool.h"
 #include "DerivationFrameworkInterfaces/IThinningTool.h"
 #include "DerivationFrameworkInterfaces/IAugmentationTool.h"
-
 #include "xAODEgamma/EgammaFwd.h"
-
+#include "GaudiKernel/EventContext.h"
 #include "GaudiKernel/ToolHandle.h"
 
 class CaloFillRectangularCluster;
@@ -45,8 +44,9 @@ namespace DerivationFramework {
       ToolHandle<CaloClusterCollectionProcessor> m_caloFillRectangularTool;
       CaloFillRectangularCluster *m_tool;
       std::string m_CellCollectionName;
-      
-      void decorateObject(const xAOD::Egamma*& egamma) const;
+
+      void decorateObject(const EventContext& ctx,
+                          const xAOD::Egamma* egamma) const;
   };
 }
 
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/src/ClusterEnergyPerLayerDecorator.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/src/ClusterEnergyPerLayerDecorator.cxx
index fb82b127204..4bf6030d84f 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/src/ClusterEnergyPerLayerDecorator.cxx
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/src/ClusterEnergyPerLayerDecorator.cxx
@@ -66,20 +66,27 @@ StatusCode DerivationFramework::ClusterEnergyPerLayerDecorator::finalize()
 // The decoration itself
 StatusCode DerivationFramework::ClusterEnergyPerLayerDecorator::addBranches() const
 {
+
+  const EventContext& ctx=Gaudi::Hive::currentContext();
   for (const std::string& SGkey : {m_SGKey_photons, m_SGKey_electrons})
   {
     if (SGkey == "") continue;
     const xAOD::EgammaContainer *container(0);
     ATH_CHECK( evtStore()->retrieve(container, SGkey) );
-    for (auto egamma : *container)
-      decorateObject(egamma);  
+    for (auto egamma : *container){
+      decorateObject(ctx, egamma);
+    }
   }
-  
+
   return StatusCode::SUCCESS;
 }
 
-void DerivationFramework::ClusterEnergyPerLayerDecorator::decorateObject(const xAOD::Egamma*& egamma) const{
-  
+void
+DerivationFramework::ClusterEnergyPerLayerDecorator::decorateObject(
+  const EventContext& ctx,
+  const xAOD::Egamma* egamma) const
+{
+
   if (not egamma or not egamma->caloCluster()) return;
   
   const CaloCellContainer* cellCont(0);
@@ -88,17 +95,20 @@ void DerivationFramework::ClusterEnergyPerLayerDecorator::decorateObject(const x
   if (evtStore()->retrieve(cellCont,m_CellCollectionName).isFailure())
     ATH_MSG_WARNING(m_CellCollectionName<< " not found");
   else if (not egamma->author(xAOD::EgammaParameters::AuthorCaloTopo35) )
-  {  
-    egcClone = CaloClusterStoreHelper::makeCluster( cellCont,
-                                                    egamma->caloCluster()->eta0(),
-                                                    egamma->caloCluster()->phi0(),
-                                                    egamma->caloCluster()->clusterSize());
-    m_tool->makeCorrection(egcClone);
+  {
+    egcClone =
+      CaloClusterStoreHelper::makeCluster(cellCont,
+                                          egamma->caloCluster()->eta0(),
+                                          egamma->caloCluster()->phi0(),
+                                          egamma->caloCluster()->clusterSize());
+    m_tool->makeCorrection(ctx, egcClone);
   }
   
-  for (unsigned int layer: m_layers)
-    egamma->auxdecor<float>(Form("E%dx%d_Lr%d", m_eta_size, m_phi_size, layer)) =\
+  for (unsigned int layer: m_layers){
+    egamma->auxdecor<float>(
+      Form("E%dx%d_Lr%d", m_eta_size, m_phi_size, layer)) =
       egcClone ? egcClone->energyBE(layer) : 0.;
+  }
 
   delete egcClone;
 }
-- 
GitLab