From 9be537bee7d27aac2f5cc65aa82deac0b1ba50e6 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Sat, 19 Oct 2024 18:56:35 +0200
Subject: [PATCH] PixelConditions: service pointer migration (ATEAM-1020)

---
 .../src/ITkPixelOfflineCalibCondAlg.cxx               |  5 ++---
 .../src/ITkPixelOfflineCalibCondAlg.h                 |  3 +--
 .../PixelConditionsData/ITkPixelClusterErrorData.h    |  2 --
 .../src/ITkPixelClusterErrorData.cxx                  | 11 +++++------
 4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/ITkPixelOfflineCalibCondAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/ITkPixelOfflineCalibCondAlg.cxx
index 5a78370b233a..6afbc3615747 100644
--- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/ITkPixelOfflineCalibCondAlg.cxx
+++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/ITkPixelOfflineCalibCondAlg.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "ITkPixelOfflineCalibCondAlg.h"
@@ -22,8 +22,7 @@ PixelOfflineCalibCondAlg::PixelOfflineCalibCondAlg(const std::string& name, ISvc
 StatusCode PixelOfflineCalibCondAlg::initialize() {
   ATH_MSG_DEBUG("ITkPixelOfflineCalibCondAlg::initialize()");
 
-  ATH_CHECK(service("DetectorStore", m_detStore));
-  ATH_CHECK(m_detStore->retrieve(m_pixelid, "PixelID")) ;
+  ATH_CHECK(detStore()->retrieve(m_pixelid, "PixelID")) ;
 
   if (m_inputSource==2 && m_readKey.key().empty()) {
     ATH_MSG_ERROR("The database is set to be input source (2) but the ReadKey is empty.");
diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/ITkPixelOfflineCalibCondAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/ITkPixelOfflineCalibCondAlg.h
index b1915d209fd3..daa3f7dab026 100644
--- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/ITkPixelOfflineCalibCondAlg.h
+++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/ITkPixelOfflineCalibCondAlg.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef ITKPIXELOFFLINECALIBCONDALG
@@ -46,7 +46,6 @@ class PixelOfflineCalibCondAlg : public AthReentrantAlgorithm
     SG::WriteCondHandleKey<ITk::PixelOfflineCalibData> m_writeKey
     {this, "WriteKey", "ITkPixelOfflineCalibData", "Output key of pixel module data"};
 
-    StoreGateSvc* m_detStore{nullptr};
     const PixelID* m_pixelid{nullptr};
 
 };
diff --git a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/ITkPixelClusterErrorData.h b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/ITkPixelClusterErrorData.h
index 8f45d1525126..01370d3e1d22 100644
--- a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/ITkPixelClusterErrorData.h
+++ b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/ITkPixelClusterErrorData.h
@@ -9,7 +9,6 @@
 
 #include "Identifier/Identifier.h"
 #include "InDetIdentifier/PixelID.h"
-#include "StoreGate/StoreGateSvc.h"
 
 #include <string>
 #include <vector>
@@ -47,7 +46,6 @@ class PixelClusterErrorData
      // map to store all ITk Analogue Clustering constants and errors
      std::map< const Identifier, std::vector<double> > m_constmap;
 
-     StoreGateSvc* m_detStore{nullptr};
      const PixelID* m_pixelID{nullptr};
 
 };
diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/ITkPixelClusterErrorData.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/ITkPixelClusterErrorData.cxx
index 4ac3da2a031c..a86d93dac4c7 100644
--- a/InnerDetector/InDetConditions/PixelConditionsData/src/ITkPixelClusterErrorData.cxx
+++ b/InnerDetector/InDetConditions/PixelConditionsData/src/ITkPixelClusterErrorData.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "PixelConditionsData/ITkPixelClusterErrorData.h"
@@ -7,6 +7,7 @@
 #include "GaudiKernel/ISvcLocator.h"
 
 #include "Identifier/IdentifierHash.h"
+#include "StoreGate/StoreGateSvc.h"
 
 #include <fstream>
 #include <string>
@@ -18,13 +19,11 @@ namespace ITk
 
 void PixelClusterErrorData::Initialize()
 {
-
-  ISvcLocator* svcLoc = Gaudi::svcLocator();
-  StatusCode sc = svcLoc->service("DetectorStore", m_detStore);
-  if(sc.isFailure()){
+  SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
+  if(!detStore){
     throw std::runtime_error("Could not retrieve DetectorStore");
   }
-  sc = m_detStore->retrieve(m_pixelID, "PixelID");
+  StatusCode sc = detStore->retrieve(m_pixelID, "PixelID");
   if(sc.isFailure()){
     throw std::runtime_error("Could not retrieve PixelID");
   }
-- 
GitLab