From 555d1d8bb94a4f4588a71ec89c5ca9b63075efc1 Mon Sep 17 00:00:00 2001
From: Susumu Oda <Susumu.Oda@cern.ch>
Date: Tue, 22 Jan 2019 08:19:27 +0100
Subject: [PATCH] Make SiElementPropertiesTableCondAlg,
 SiDetElementsRoadCondAlg_xk and SiDetElementBoundaryLinksCondAlg_xk
 reentrant.

---
 .../src/SiElementPropertiesTableCondAlg.cxx   | 12 ++++----
 .../src/SiElementPropertiesTableCondAlg.h     |  8 +++---
 .../SiDetElementBoundaryLinksCondAlg_xk.cxx   | 12 ++++----
 .../src/SiDetElementBoundaryLinksCondAlg_xk.h |  8 +++---
 .../src/SiDetElementsRoadCondAlg_xk.cxx       | 28 +++++++++----------
 .../src/SiDetElementsRoadCondAlg_xk.h         | 12 ++++----
 6 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTableCondAlg.cxx b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTableCondAlg.cxx
index cfff38a7aec4..79e80dcf6d44 100644
--- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTableCondAlg.cxx
+++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTableCondAlg.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "SiElementPropertiesTableCondAlg.h"
@@ -12,7 +12,7 @@
 namespace InDet {
 
   SiElementPropertiesTableCondAlg::SiElementPropertiesTableCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
-    : ::AthAlgorithm(name, pSvcLocator)
+    : ::AthReentrantAlgorithm(name, pSvcLocator)
     , m_condSvc{"CondSvc", name}
     , m_idHelper{nullptr}
 {
@@ -37,12 +37,12 @@ namespace InDet {
     return StatusCode::SUCCESS;
   }
 
-  StatusCode SiElementPropertiesTableCondAlg::execute()
+  StatusCode SiElementPropertiesTableCondAlg::execute(const EventContext& ctx) const
   {
     ATH_MSG_DEBUG("execute " << name());
 
     // ____________ Construct Write Cond Handle and check its validity ____________
-    SG::WriteCondHandle<InDet::SiElementPropertiesTable> writeHandle{m_writeKey};
+    SG::WriteCondHandle<InDet::SiElementPropertiesTable> writeHandle{m_writeKey, ctx};
 
     // Do we have a valid Write Cond Handle for current time?
     if (writeHandle.isValid()) {
@@ -53,7 +53,7 @@ namespace InDet {
     }
 
     // ____________ Get Read Cond Object ____________
-    SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> readHandle{m_readKey};
+    SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> readHandle{m_readKey, ctx};
     const InDetDD::SiDetectorElementCollection* readCdo{*readHandle};
     if (readCdo==nullptr) {
       ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKey.key());
@@ -74,7 +74,7 @@ namespace InDet {
 
     // Record WriteCondHandle
     if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
-      ATH_MSG_ERROR("Could not record " << writeHandle.key()
+      ATH_MSG_FATAL("Could not record " << writeHandle.key()
                     << " with EventRange " << rangeW
                     << " into Conditions Store");
       return StatusCode::FAILURE;
diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTableCondAlg.h b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTableCondAlg.h
index 7b1fbd908c83..5eb8e7e7009b 100644
--- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTableCondAlg.h
+++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTableCondAlg.h
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef SiElementPropertiesTableCondAlg_h
 #define SiElementPropertiesTableCondAlg_h
 
-#include "AthenaBaseComps/AthAlgorithm.h"
+#include "AthenaBaseComps/AthReentrantAlgorithm.h"
 #include "StoreGate/ReadCondHandleKey.h"
 #include "StoreGate/WriteCondHandleKey.h"
 
@@ -18,13 +18,13 @@ class SCT_ID;
 
 namespace InDet {
 
-  class SiElementPropertiesTableCondAlg : public AthAlgorithm {
+  class SiElementPropertiesTableCondAlg : public AthReentrantAlgorithm {
   public:
     SiElementPropertiesTableCondAlg(const std::string& name, ISvcLocator* pSvcLocator);
     virtual ~SiElementPropertiesTableCondAlg() override = default;
 
     virtual StatusCode initialize() override;
-    virtual StatusCode execute() override;
+    virtual StatusCode execute(const EventContext& ctx) const override;
     virtual StatusCode finalize() override;
 
   private:
diff --git a/InnerDetector/InDetRecTools/SiCombinatorialTrackFinderTool_xk/src/SiDetElementBoundaryLinksCondAlg_xk.cxx b/InnerDetector/InDetRecTools/SiCombinatorialTrackFinderTool_xk/src/SiDetElementBoundaryLinksCondAlg_xk.cxx
index 7d8d9c33cbd4..1ff3884ce65c 100644
--- a/InnerDetector/InDetRecTools/SiCombinatorialTrackFinderTool_xk/src/SiDetElementBoundaryLinksCondAlg_xk.cxx
+++ b/InnerDetector/InDetRecTools/SiCombinatorialTrackFinderTool_xk/src/SiDetElementBoundaryLinksCondAlg_xk.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "SiDetElementBoundaryLinksCondAlg_xk.h"
@@ -12,7 +12,7 @@
 namespace InDet {
 
   SiDetElementBoundaryLinksCondAlg_xk::SiDetElementBoundaryLinksCondAlg_xk(const std::string& name, ISvcLocator* pSvcLocator)
-    : ::AthAlgorithm(name, pSvcLocator)
+    : ::AthReentrantAlgorithm(name, pSvcLocator)
     , m_condSvc{"CondSvc", name}
 {
 }
@@ -34,12 +34,12 @@ namespace InDet {
     return StatusCode::SUCCESS;
   }
 
-  StatusCode SiDetElementBoundaryLinksCondAlg_xk::execute()
+  StatusCode SiDetElementBoundaryLinksCondAlg_xk::execute(const EventContext& ctx) const
   {
     ATH_MSG_DEBUG("execute " << name());
 
     // ____________ Construct Write Cond Handle and check its validity ____________
-    SG::WriteCondHandle<InDet::SiDetElementBoundaryLinks_xk> writeHandle{m_writeKey};
+    SG::WriteCondHandle<InDet::SiDetElementBoundaryLinks_xk> writeHandle{m_writeKey, ctx};
 
     // Do we have a valid Write Cond Handle for current time?
     if (writeHandle.isValid()) {
@@ -50,7 +50,7 @@ namespace InDet {
     }
 
     // ____________ Get Read Cond Object ____________
-    SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> readHandle{m_readKey};
+    SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> readHandle{m_readKey, ctx};
     const InDetDD::SiDetectorElementCollection* readCdo{*readHandle};
     if (readCdo==nullptr) {
       ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKey.key());
@@ -76,7 +76,7 @@ namespace InDet {
 
     // Record WriteCondHandle
     if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
-      ATH_MSG_ERROR("Could not record " << writeHandle.key()
+      ATH_MSG_FATAL("Could not record " << writeHandle.key()
                     << " with EventRange " << rangeW
                     << " into Conditions Store");
       return StatusCode::FAILURE;
diff --git a/InnerDetector/InDetRecTools/SiCombinatorialTrackFinderTool_xk/src/SiDetElementBoundaryLinksCondAlg_xk.h b/InnerDetector/InDetRecTools/SiCombinatorialTrackFinderTool_xk/src/SiDetElementBoundaryLinksCondAlg_xk.h
index 1f614f6e359e..c24176dc48d5 100644
--- a/InnerDetector/InDetRecTools/SiCombinatorialTrackFinderTool_xk/src/SiDetElementBoundaryLinksCondAlg_xk.h
+++ b/InnerDetector/InDetRecTools/SiCombinatorialTrackFinderTool_xk/src/SiDetElementBoundaryLinksCondAlg_xk.h
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef SiDetElementBoundaryLinksCondAlg_xk_h
 #define SiDetElementBoundaryLinksCondAlg_xk_h
 
-#include "AthenaBaseComps/AthAlgorithm.h"
+#include "AthenaBaseComps/AthReentrantAlgorithm.h"
 
 #include "InDetReadoutGeometry/SiDetectorElementCollection.h"
 #include "SiCombinatorialTrackFinderTool_xk/SiDetElementBoundaryLinks_xk.h"
@@ -16,13 +16,13 @@
 
 namespace InDet {
 
-  class SiDetElementBoundaryLinksCondAlg_xk : public AthAlgorithm {
+  class SiDetElementBoundaryLinksCondAlg_xk : public AthReentrantAlgorithm {
   public:
     SiDetElementBoundaryLinksCondAlg_xk(const std::string& name, ISvcLocator* pSvcLocator);
     virtual ~SiDetElementBoundaryLinksCondAlg_xk() override = default;
 
     virtual StatusCode initialize() override;
-    virtual StatusCode execute() override;
+    virtual StatusCode execute(const EventContext& ctx) const override;
     virtual StatusCode finalize() override;
 
   private:
diff --git a/InnerDetector/InDetRecTools/SiDetElementsRoadTool_xk/src/SiDetElementsRoadCondAlg_xk.cxx b/InnerDetector/InDetRecTools/SiDetElementsRoadTool_xk/src/SiDetElementsRoadCondAlg_xk.cxx
index 6a94690b339c..349d2f9f0138 100644
--- a/InnerDetector/InDetRecTools/SiDetElementsRoadTool_xk/src/SiDetElementsRoadCondAlg_xk.cxx
+++ b/InnerDetector/InDetRecTools/SiDetElementsRoadTool_xk/src/SiDetElementsRoadCondAlg_xk.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "SiDetElementsRoadCondAlg_xk.h"
@@ -16,7 +16,7 @@
 ///////////////////////////////////////////////////////////////////
 
 InDet::SiDetElementsRoadCondAlg_xk::SiDetElementsRoadCondAlg_xk(const std::string& name, ISvcLocator* pSvcLocator)
-  : ::AthAlgorithm(name, pSvcLocator),
+  : ::AthReentrantAlgorithm(name, pSvcLocator),
   m_pixmgr{nullptr},
   m_condSvc{"CondSvc", name}
 {
@@ -68,12 +68,12 @@ StatusCode InDet::SiDetElementsRoadCondAlg_xk::finalize()
 // Taken from InDet::SiDetElementsRoadMaker_xk::mapDetectorElementsProduction()
 ///////////////////////////////////////////////////////////////////
 
-StatusCode InDet::SiDetElementsRoadCondAlg_xk::execute()
+StatusCode InDet::SiDetElementsRoadCondAlg_xk::execute(const EventContext& ctx) const
 {
   const double pi2=2.*M_PI;
   const double pi=M_PI;
 
-  SG::WriteCondHandle<SiDetElementsLayerVectors_xk> writeHandle{m_writeKey};
+  SG::WriteCondHandle<SiDetElementsLayerVectors_xk> writeHandle{m_writeKey, ctx};
   if (writeHandle.isValid()) {
     ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
                   << ". In theory this should not be called, but may happen"
@@ -96,24 +96,24 @@ StatusCode InDet::SiDetElementsRoadCondAlg_xk::execute()
       else                              pW[0].push_back((*s)); // Left  endcap
     }
 
-    SG::ReadCondHandle<CondAttrListCollection> iblDistFolder(m_IBLDistFolderKey);
+    SG::ReadCondHandle<CondAttrListCollection> iblDistFolder(m_IBLDistFolderKey, ctx);
     if (not iblDistFolder.isValid()) {
-      ATH_MSG_ERROR(m_IBLDistFolderKey.fullKey() << " is not available.");
+      ATH_MSG_FATAL(m_IBLDistFolderKey.fullKey() << " is not available.");
       return StatusCode::FAILURE;
     }
     if (not iblDistFolder.range(rangePixel)) {
-      ATH_MSG_ERROR("Failed to retrieve validity range for " << iblDistFolder.key());
+      ATH_MSG_FATAL("Failed to retrieve validity range for " << iblDistFolder.key());
       return StatusCode::FAILURE;
     }
     if (m_useDynamicAlignFolders) {
-      SG::ReadCondHandle<CondAttrListCollection> pixelL2Folder(m_pixelL2FolderKey);
+      SG::ReadCondHandle<CondAttrListCollection> pixelL2Folder(m_pixelL2FolderKey, ctx);
       if (not pixelL2Folder.isValid()) {
-        ATH_MSG_ERROR(pixelL2Folder.fullKey() << " is not available.");
+        ATH_MSG_FATAL(pixelL2Folder.fullKey() << " is not available.");
         return StatusCode::FAILURE;
       }
       EventIDRange rangePixelL2;
       if (not pixelL2Folder.range(rangePixelL2)) {
-        ATH_MSG_ERROR("Failed to retrieve validity range for " << pixelL2Folder.key());
+        ATH_MSG_FATAL("Failed to retrieve validity range for " << pixelL2Folder.key());
         return StatusCode::FAILURE;
       }
       rangePixel = EventIDRange::intersect(rangePixel, rangePixelL2);
@@ -123,10 +123,10 @@ StatusCode InDet::SiDetElementsRoadCondAlg_xk::execute()
   EventIDRange rangeSct;
   if (m_useSCT) {
     // Loop over each wafer of sct
-    SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEleHandle(m_SCTDetEleCollKey);
+    SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEleHandle(m_SCTDetEleCollKey, ctx);
     const InDetDD::SiDetectorElementCollection* sctDetEle{*sctDetEleHandle};
     if (not sctDetEleHandle.isValid() or sctDetEle==nullptr) {
-      ATH_MSG_ERROR(m_SCTDetEleCollKey.fullKey() << " is not available.");
+      ATH_MSG_FATAL(m_SCTDetEleCollKey.fullKey() << " is not available.");
       return StatusCode::FAILURE;
     }
     for (const InDetDD::SiDetectorElement* s: *sctDetEle) {
@@ -136,7 +136,7 @@ StatusCode InDet::SiDetElementsRoadCondAlg_xk::execute()
     }
 
     if (not sctDetEleHandle.range(rangeSct)) {
-      ATH_MSG_ERROR("Failed to retrieve validity range for " << sctDetEleHandle.key());
+      ATH_MSG_FATAL("Failed to retrieve validity range for " << sctDetEleHandle.key());
       return StatusCode::FAILURE;
     }
   }
@@ -233,7 +233,7 @@ StatusCode InDet::SiDetElementsRoadCondAlg_xk::execute()
 
   EventIDRange rangeW{EventIDRange::intersect(rangePixel, rangeSct)};
   if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
-    ATH_MSG_ERROR("Could not record " << writeHandle.key()
+    ATH_MSG_FATAL("Could not record " << writeHandle.key()
                   << " with EventRange " << rangeW
                   << " into Conditions Store");
     return StatusCode::FAILURE;
diff --git a/InnerDetector/InDetRecTools/SiDetElementsRoadTool_xk/src/SiDetElementsRoadCondAlg_xk.h b/InnerDetector/InDetRecTools/SiDetElementsRoadTool_xk/src/SiDetElementsRoadCondAlg_xk.h
index d4bc41f32ef0..ec9924ab2e76 100644
--- a/InnerDetector/InDetRecTools/SiDetElementsRoadTool_xk/src/SiDetElementsRoadCondAlg_xk.h
+++ b/InnerDetector/InDetRecTools/SiDetElementsRoadTool_xk/src/SiDetElementsRoadCondAlg_xk.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -12,7 +12,7 @@
 
 #include <vector>
 #include "GaudiKernel/ICondSvc.h"
-#include "AthenaBaseComps/AthAlgorithm.h"
+#include "AthenaBaseComps/AthReentrantAlgorithm.h"
 #include "AthenaPoolUtilities/CondAttrListCollection.h"
 #include "InDetReadoutGeometry/SiDetectorElementCollection.h"
 #include "SiDetElementsRoadTool_xk/SiDetElementsLayerVectors_xk.h"
@@ -34,7 +34,7 @@ namespace InDet {
      @author Susumu.Oda@cern.ch
   */
 
-  class SiDetElementsRoadCondAlg_xk : public AthAlgorithm
+  class SiDetElementsRoadCondAlg_xk : public AthReentrantAlgorithm
   {
     ///////////////////////////////////////////////////////////////////
     // Public methods:
@@ -48,9 +48,9 @@ namespace InDet {
 
     SiDetElementsRoadCondAlg_xk(const std::string& name, ISvcLocator* pSvcLocator);
     virtual ~SiDetElementsRoadCondAlg_xk() = default;
-    virtual StatusCode initialize();
-    virtual StatusCode finalize();
-    virtual StatusCode execute();
+    virtual StatusCode initialize() override;
+    virtual StatusCode finalize() override;
+    virtual StatusCode execute(const EventContext& ctx) const override;
 
   private:
       
-- 
GitLab