From 44eaaa8b96690cb3c9c2e9ad7df69d2fd5b1d694 Mon Sep 17 00:00:00 2001
From: scott snyder <snyder@bnl.gov>
Date: Thu, 3 Dec 2020 17:57:33 +0100
Subject: [PATCH] LArRecUtils: Update tower builder tool interfaces.

Update the tower builder tool interfaces to pass the EventContext
to the execute() methods.  Should save some TLS looksups.
---
 .../LArRecUtils/src/LArFCalTowerBuilderTool.cxx     | 11 +++++++----
 .../LArRecUtils/src/LArFCalTowerBuilderTool.h       |  7 +++++--
 .../src/LArFCalTowerBuilderToolTestAlg.cxx          | 13 ++++++++-----
 .../src/LArFCalTowerBuilderToolTestAlg.h            |  3 ++-
 4 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderTool.cxx b/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderTool.cxx
index 60a29da2467..448818ce016 100644
--- a/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderTool.cxx
+++ b/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderTool.cxx
@@ -125,7 +125,8 @@ LArFCalTowerBuilderTool::iterateSubSeg (CaloTowerContainer* towers,
 /////////////////////////
 
 StatusCode
-LArFCalTowerBuilderTool::execute(CaloTowerContainer* theTowers,
+LArFCalTowerBuilderTool::execute(const EventContext& ctx,
+                                 CaloTowerContainer* theTowers,
                                  const CaloCellContainer* theCells,
                                  const CaloTowerSeg::SubSeg* subseg) const
 {
@@ -155,7 +156,7 @@ LArFCalTowerBuilderTool::execute(CaloTowerContainer* theTowers,
   // register this calorimeter
   theTowers->setCalo(m_caloIndex);
 
-  const ElementLink<CaloCellContainer> cellsEL (*theCells, 0);
+  const ElementLink<CaloCellContainer> cellsEL (*theCells, 0, ctx);
   if (subseg)
     iterateSubSeg (theTowers, cellsEL, subseg);
   else
@@ -167,19 +168,21 @@ LArFCalTowerBuilderTool::execute(CaloTowerContainer* theTowers,
 
 /**
  * @brief Run tower building and add results to the tower container.
+ * @param ctx The current event context.
  * @param theContainer The tower container to fill.
  *
  * If the segmentation hasn't been set, take it from the tower container.
  * This is for use by converters.
  */
-StatusCode LArFCalTowerBuilderTool::execute (CaloTowerContainer* theContainer)
+StatusCode LArFCalTowerBuilderTool::execute (const EventContext& ctx,
+                                             CaloTowerContainer* theContainer)
 {
   if (m_cellStore.size() == 0) {
     setTowerSeg (theContainer->towerseg());
     ATH_CHECK( rebuildLookup() );
   }
 
-  return execute (theContainer, nullptr, nullptr);
+  return execute (ctx, theContainer, nullptr, nullptr);
 }
 
 
diff --git a/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderTool.h b/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderTool.h
index 306a3f0bd73..c4e8f353b72 100644
--- a/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderTool.h
+++ b/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderTool.h
@@ -46,19 +46,22 @@ class LArFCalTowerBuilderTool : public CaloTowerBuilderToolBase
 
   virtual ~LArFCalTowerBuilderTool();
 
-  virtual StatusCode execute(CaloTowerContainer* theContainer,
+  virtual StatusCode execute(const EventContext& ctx,
+                             CaloTowerContainer* theContainer,
                              const CaloCellContainer* theCell=0,
                              const CaloTowerSeg::SubSeg* subseg = 0) const override;
 
 
   /**
    * @brief Run tower building and add results to the tower container.
+   * @param ctx The current event context.
    * @param theContainer The tower container to fill.
    *
    * If the segmentation hasn't been set, take it from the tower container.
    * This is for use by converters.
    */
-  virtual StatusCode execute (CaloTowerContainer* theContainer) override;
+  virtual StatusCode execute (const EventContext& ctx,
+                              CaloTowerContainer* theContainer) override;
 
 
   virtual void handle(const Incident&) override;
diff --git a/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderToolTestAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderToolTestAlg.cxx
index 9bc94d23cda..3c50703aeca 100644
--- a/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderToolTestAlg.cxx
+++ b/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderToolTestAlg.cxx
@@ -18,6 +18,7 @@
 #include "AthenaKernel/errorcheck.h"
 #include "TestTools/random.h"
 #include "CLHEP/Units/SystemOfUnits.h"
+#include "GaudiKernel/ThreadLocalContext.h"
 #include <cstdlib>
 #include <iostream>
 #include <cmath>
@@ -91,12 +92,13 @@ LArFCalTowerBuilderToolTestAlg::make_cells()
 
 
 StatusCode
-LArFCalTowerBuilderToolTestAlg::test_subseg (const CaloTowerSeg::SubSeg& subseg,
+LArFCalTowerBuilderToolTestAlg::test_subseg (const EventContext& ctx,
+                                             const CaloTowerSeg::SubSeg& subseg,
                                              const CaloCellContainer* cells,
                                              const CaloTowerContainer* tow0)
 {
   CaloTowerContainer* tow = new CaloTowerContainer (subseg.segmentation());
-  CHECK( m_builder->execute (tow, cells, &subseg) );
+  CHECK( m_builder->execute (ctx, tow, cells, &subseg) );
 
   for (size_t i = 0; i < tow->size(); i++) {
     typedef CaloTowerContainer::index_t index_t;
@@ -155,10 +157,11 @@ LArFCalTowerBuilderToolTestAlg::test_subseg (const CaloTowerSeg::SubSeg& subseg,
 StatusCode LArFCalTowerBuilderToolTestAlg::test1()
 {
   std::cout << "test1\n";
+  const EventContext& ctx = Gaudi::Hive::currentContext();
 
   const CaloCellContainer* cells = make_cells();
   CaloTowerContainer* tow1 = new CaloTowerContainer (m_seg);
-  CHECK( m_builder->execute (tow1, cells) );
+  CHECK( m_builder->execute (ctx, tow1, cells) );
 
 #if 0
   std::cout << "cells\n";
@@ -186,8 +189,8 @@ StatusCode LArFCalTowerBuilderToolTestAlg::test1()
     std::cout << "\n";
   }
 
-  CHECK( test_subseg (m_seg.subseg ( 4.5, 0.3, -0.2, 0.4), cells, tow1) );
-  CHECK( test_subseg (m_seg.subseg (-4.5, 0.3,  3.1, 0.4), cells, tow1) );
+  CHECK( test_subseg (ctx, m_seg.subseg ( 4.5, 0.3, -0.2, 0.4), cells, tow1) );
+  CHECK( test_subseg (ctx, m_seg.subseg (-4.5, 0.3,  3.1, 0.4), cells, tow1) );
 
   delete cells;
   delete tow1;
diff --git a/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderToolTestAlg.h b/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderToolTestAlg.h
index 97dd8dfabd4..10b7d21de78 100644
--- a/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderToolTestAlg.h
+++ b/LArCalorimeter/LArRecUtils/src/LArFCalTowerBuilderToolTestAlg.h
@@ -51,7 +51,8 @@ public:
 
 private:
   CaloCellContainer* make_cells();
-  StatusCode test_subseg (const CaloTowerSeg::SubSeg& subseg,
+  StatusCode test_subseg (const EventContext& ctx,
+                          const CaloTowerSeg::SubSeg& subseg,
                           const CaloCellContainer* cells,
                           const CaloTowerContainer* tow0);
   StatusCode test1();
-- 
GitLab