From 1dcde223affefb44ae463ada2e1658c7db0a7326 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Mon, 21 Oct 2024 10:12:07 +0200
Subject: [PATCH] CommissionRec: service pointer migration (ATEAM-1020)

---
 Commission/CommissionRec/src/ComTimeRec.cxx     | 17 ++---------------
 Commission/CommissionRec/src/ComTimeRec.h       |  7 +++----
 .../CommissionRec/src/CosmicTriggerTimeTool.cxx |  5 ++---
 .../CommissionRec/src/CosmicTriggerTimeTool.h   |  8 ++++----
 4 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/Commission/CommissionRec/src/ComTimeRec.cxx b/Commission/CommissionRec/src/ComTimeRec.cxx
index 9b6bc26c17db..b784314bdb66 100755
--- a/Commission/CommissionRec/src/ComTimeRec.cxx
+++ b/Commission/CommissionRec/src/ComTimeRec.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "ComTimeRec.h"
@@ -46,11 +46,9 @@ StatusCode ComTimeRec::initialize()
   //  the timing tool, does not provide the method that is needed here (which is bad design).
   // The right thing to do is to fix the interface, at which point this is a simple retrieve.
   // Until then, we are stuck with the old way.
-  IToolSvc *toolSvc(0);
-  CHECK( service( "ToolSvc",toolSvc ) );
 
   IAlgTool *trigTool(0);
-  CHECK( toolSvc->retrieveTool("CosmicTriggerTimeTool",trigTool) );
+  CHECK( toolSvc()->retrieveTool("CosmicTriggerTimeTool",trigTool) );
 
   m_triggerTimeTool = dynamic_cast<CosmicTriggerTimeTool*>(trigTool);
   if(0==m_triggerTimeTool){
@@ -206,14 +204,3 @@ StatusCode ComTimeRec::execute()
   return StatusCode::SUCCESS;
 }
 
-//----------------------------------------------------------------
-
-StatusCode ComTimeRec::finalize() {
-
-  ATH_MSG_INFO( "In finalize()" );
-
-  return StatusCode::SUCCESS;
-
-}
-
-//----------------------------------------------------------------
diff --git a/Commission/CommissionRec/src/ComTimeRec.h b/Commission/CommissionRec/src/ComTimeRec.h
index c096a96f0c97..c5122aea56b1 100755
--- a/Commission/CommissionRec/src/ComTimeRec.h
+++ b/Commission/CommissionRec/src/ComTimeRec.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef COMMISSIONREC_COMTIMEREC
@@ -17,9 +17,8 @@ public:
   ComTimeRec(const std::string& name, ISvcLocator* pSvcLocator);
   ~ComTimeRec();
 
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode finalize();
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute() override;
 
 private:
 
diff --git a/Commission/CommissionRec/src/CosmicTriggerTimeTool.cxx b/Commission/CommissionRec/src/CosmicTriggerTimeTool.cxx
index a9dc3e0984ae..34091241f2f6 100644
--- a/Commission/CommissionRec/src/CosmicTriggerTimeTool.cxx
+++ b/Commission/CommissionRec/src/CosmicTriggerTimeTool.cxx
@@ -20,7 +20,6 @@ CosmicTriggerTimeTool::CosmicTriggerTimeTool(const std::string& type,
   m_comTime(0) , m_useLArTime(false)
 {
 
-  declareInterface<ITriggerTime>(this);
   declareProperty("UseLArTime", m_useLArTime);
 
 }
@@ -29,8 +28,8 @@ CosmicTriggerTimeTool::CosmicTriggerTimeTool(const std::string& type,
 StatusCode CosmicTriggerTimeTool::initialize()
 {
 
-  IIncidentSvc* incsvc;
-  CHECK( service("IncidentSvc",incsvc) );
+  ServiceHandle<IIncidentSvc> incsvc("IncidentSvc", name());
+  CHECK( incsvc.retrieve() );
 
   long int pri=100;
   incsvc->addListener(this,"BeginEvent",pri);
diff --git a/Commission/CommissionRec/src/CosmicTriggerTimeTool.h b/Commission/CommissionRec/src/CosmicTriggerTimeTool.h
index edb240ea6d86..dc84c4ff2e93 100644
--- a/Commission/CommissionRec/src/CosmicTriggerTimeTool.h
+++ b/Commission/CommissionRec/src/CosmicTriggerTimeTool.h
@@ -9,7 +9,7 @@
 #include "GaudiKernel/IIncidentListener.h"
 #include "AthenaBaseComps/AthAlgTool.h"
 
-class ComTime      ; 
+class ComTime;
 
 class CosmicTriggerTimeTool : public extends<AthAlgTool, ITriggerTime, IIncidentListener>
 {
@@ -20,14 +20,14 @@ public:
 			 const IInterface* parent);
 
 
-   virtual StatusCode initialize() ; 
+   virtual StatusCode initialize() override;
 
    virtual ~CosmicTriggerTimeTool() {}
 
    /// returns the time offset of the current trigger
-   virtual double time() ;
+   virtual double time() override;
 
-   virtual void handle(const Incident& incident);
+   virtual void handle(const Incident& incident) override;
 
     double larTime(); 
     double trackRecordTime()   ; 
-- 
GitLab