From b10d338ba9a05ef604df9323d6a2cdac173e47b3 Mon Sep 17 00:00:00 2001
From: Susumu Oda <susumu.oda@cern.ch>
Date: Mon, 11 Nov 2019 17:31:22 +0000
Subject: [PATCH] Revert "Reserve vector (ATLASRECTS-3828)"

This reverts commit 2ae7a960ff7533b220f4092d8628d470e109f8fa.
---
 .../DiscOverlapDescriptor.h                   |  9 +++++--
 .../src/DiscOverlapDescriptor.cxx             | 26 ++++++++++---------
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/InnerDetector/InDetDetDescr/InDetTrackingGeometry/InDetTrackingGeometry/DiscOverlapDescriptor.h b/InnerDetector/InDetDetDescr/InDetTrackingGeometry/InDetTrackingGeometry/DiscOverlapDescriptor.h
index 818ee14e493..992f1940236 100644
--- a/InnerDetector/InDetDetDescr/InDetTrackingGeometry/InDetTrackingGeometry/DiscOverlapDescriptor.h
+++ b/InnerDetector/InDetDetDescr/InDetTrackingGeometry/InDetTrackingGeometry/DiscOverlapDescriptor.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 ///////////////////////////////////////////////////////////////////
@@ -17,6 +17,9 @@
 #include "TrkDetDescrUtils/BinnedArray1D1D.h"
 #include "TrkDetDescrUtils/Intersection.h"
 
+// STL include
+#include <atomic>
+
 #ifndef INDETTRACKINGGEOMETRY_DISCDETADDNEXTPHIETA
 #define INDETTRACKINGGEOMETRY_DISCDETADDNEXTPHIETA
 #define addSurfaceDO(cur,surfaces) if (cur) surfaces.push_back(Trk::SurfaceIntersection(Trk::Intersection(Amg::Vector3D(0.,0.,0.),0.,true),&(cur->surface(cur->identify()))))
@@ -27,6 +30,8 @@
 #define addPrevInEtaDO(cur, surfaces) addSurfaceDO(cur->prevInEta(), surfaces); addOtherSideDO(cur->prevInEta(),surfaces)
 #endif // INDETTRACKINGGEOMETRY_DISCDETADDNEXTPHIETA
 
+class SCT_ID;
+
 namespace Trk {
   class Surface;
 }
@@ -87,7 +92,7 @@ namespace InDet {
     
     const Trk::BinnedArray<Trk::Surface>*           m_bin_array;
     std::vector<Trk::BinUtility*>*                  m_singleBinUtils;
-    
+    mutable std::atomic<const SCT_ID*>              m_sctIdHelper{nullptr};
     
   };
   
diff --git a/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/DiscOverlapDescriptor.cxx b/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/DiscOverlapDescriptor.cxx
index 8891d9fdd6b..d00d5be8191 100644
--- a/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/DiscOverlapDescriptor.cxx
+++ b/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/DiscOverlapDescriptor.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 ///////////////////////////////////////////////////////////////////
@@ -32,18 +32,20 @@ bool InDet::DiscOverlapDescriptor::reachableSurfaces(std::vector<Trk::SurfaceInt
   
 {
   // Get Storegate, ID helpers, and so on
-  ISvcLocator* svcLocator = Gaudi::svcLocator();
+  if (m_sctIdHelper==nullptr) {
+    ISvcLocator* svcLocator = Gaudi::svcLocator();
     
-  // get DetectorStore service
-  StoreGateSvc* detStore;
-  StatusCode sc = svcLocator->service("DetectorStore",detStore);
-  if (sc.isFailure()) {
-    return 0;
-  }
+    // get DetectorStore service
+    StoreGateSvc* detStore = nullptr;
+    if (svcLocator->service("DetectorStore", detStore).isFailure()) {
+      return false;
+    }
 
-  const SCT_ID* sctIdHelper = 0;
-  if (detStore->retrieve(sctIdHelper, "SCT_ID").isFailure()) {
-    return 0;
+    const SCT_ID* sctIdHelper = nullptr;
+    if (detStore->retrieve(sctIdHelper, "SCT_ID").isFailure()) {
+      return false;
+    }
+    m_sctIdHelper = sctIdHelper;
   }
   
   // get the according detector element
@@ -51,7 +53,7 @@ bool InDet::DiscOverlapDescriptor::reachableSurfaces(std::vector<Trk::SurfaceInt
   
   // first add the target surface
   surfaces.push_back(Trk::SurfaceIntersection(Trk::Intersection(pos, 0., true),&tsf));
-  int etaModule = sctIdHelper->eta_module(tsf.associatedDetectorElementIdentifier());
+  int etaModule = m_sctIdHelper.load()->eta_module(tsf.associatedDetectorElementIdentifier());
   
   // return empty cell vector
   if (pElement) {
-- 
GitLab