From 1cb47a7c10925ed12e68ac8477cd812282b5ee9c Mon Sep 17 00:00:00 2001
From: Vakho Tsulaia <vakhtang.tsulaia@cern.ch>
Date: Sat, 14 Nov 2020 02:23:03 +0100
Subject: [PATCH] Code cleanup in the ReadAlignTrans algorithm

Dropped the dependency on IGeoModelSvc::align(). Also moved all headers into
src directory
---
 .../DetDescrCondExample/CMakeLists.txt        |  2 +-
 .../src/CoolHistExample.cxx                   |  2 +-
 .../CoolHistExample.h                         |  0
 .../src/ReadAlignTrans.cxx                    | 53 ++++---------------
 .../ReadAlignTrans.h                          |  6 +--
 .../DetDescrCondExample/src/ReadTopTrans.cxx  |  2 +-
 .../ReadTopTrans.h                            |  0
 .../src/ReadWriteCoolStrFile.cxx              |  2 +-
 .../ReadWriteCoolStrFile.h                    |  0
 .../DetDescrCondExample_entries.cxx           |  8 +--
 10 files changed, 18 insertions(+), 57 deletions(-)
 rename DetectorDescription/DetDescrCond/DetDescrCondExample/{DetDescrCondExample => src}/CoolHistExample.h (100%)
 rename DetectorDescription/DetDescrCond/DetDescrCondExample/{DetDescrCondExample => src}/ReadAlignTrans.h (84%)
 rename DetectorDescription/DetDescrCond/DetDescrCondExample/{DetDescrCondExample => src}/ReadTopTrans.h (100%)
 rename DetectorDescription/DetDescrCond/DetDescrCondExample/{DetDescrCondExample => src}/ReadWriteCoolStrFile.h (100%)

diff --git a/DetectorDescription/DetDescrCond/DetDescrCondExample/CMakeLists.txt b/DetectorDescription/DetDescrCond/DetDescrCondExample/CMakeLists.txt
index 38ea725012fc..bd6bbfeffee4 100644
--- a/DetectorDescription/DetDescrCond/DetDescrCondExample/CMakeLists.txt
+++ b/DetectorDescription/DetDescrCond/DetDescrCondExample/CMakeLists.txt
@@ -14,7 +14,7 @@ atlas_add_component( DetDescrCondExample
                      src/CoolHistExample.cxx
                      src/components/*.cxx
                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps AthenaKernel AthenaPoolUtilities DetDescrCondToolsLib DetDescrConditions GaudiKernel GeoModelInterfaces GeoPrimitives Identifier InDetReadoutGeometry )
+                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps AthenaKernel AthenaPoolUtilities DetDescrCondToolsLib DetDescrConditions GaudiKernel GeoPrimitives Identifier InDetReadoutGeometry )
 
 # Install files from the package:
 atlas_install_joboptions( share/*.py )
diff --git a/DetectorDescription/DetDescrCond/DetDescrCondExample/src/CoolHistExample.cxx b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/CoolHistExample.cxx
index ff9f9b5467c1..b5208ebb30f7 100755
--- a/DetectorDescription/DetDescrCond/DetDescrCondExample/src/CoolHistExample.cxx
+++ b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/CoolHistExample.cxx
@@ -7,12 +7,12 @@
 // Richard Hawkings, started 09/2/07
 //
 
+#include "CoolHistExample.h"
 #include "GaudiKernel/ISvcLocator.h"
 #include "AthenaPoolUtilities/CondAttrListCollection.h"
 #include "DetDescrCondTools/ICoolHistSvc.h"
 #include "TH1.h"
 #include "TDirectory.h"
-#include "DetDescrCondExample/CoolHistExample.h"
 
 CoolHistExample::CoolHistExample(const std::string& name, 
   ISvcLocator* pSvcLocator) :AthAlgorithm(name,pSvcLocator),
diff --git a/DetectorDescription/DetDescrCond/DetDescrCondExample/DetDescrCondExample/CoolHistExample.h b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/CoolHistExample.h
similarity index 100%
rename from DetectorDescription/DetDescrCond/DetDescrCondExample/DetDescrCondExample/CoolHistExample.h
rename to DetectorDescription/DetDescrCond/DetDescrCondExample/src/CoolHistExample.h
diff --git a/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadAlignTrans.cxx b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadAlignTrans.cxx
index 480e9da90fa8..5b014dfb8054 100755
--- a/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadAlignTrans.cxx
+++ b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadAlignTrans.cxx
@@ -1,24 +1,22 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 // ReadAlignTrans - simple example of algorithm reading AlignableTransforms
 // Richard Hawkings, started 19/1/04
 
-#include <list>
+#include "ReadAlignTrans.h"
 #include "GaudiKernel/ISvcLocator.h"
 #include "Identifier/Identifier.h"
-#include "GeoModelInterfaces/IGeoModelSvc.h"
 #include "InDetReadoutGeometry/SiDetectorManager.h"
 #include "InDetReadoutGeometry/SiDetectorElement.h"
 #include "InDetReadoutGeometry/SiDetectorElementCollection.h"
+#include <list>
 
-#include "DetDescrCondExample/ReadAlignTrans.h"
-
-ReadAlignTrans::ReadAlignTrans(const std::string& name, 
-  ISvcLocator* pSvcLocator) :AthAlgorithm(name,pSvcLocator),
-   p_geomodelsvc(0),
-   m_sidetman()
+ReadAlignTrans::ReadAlignTrans(const std::string& name
+			       , ISvcLocator* pSvcLocator) 
+  : AthAlgorithm(name,pSvcLocator)
+  , m_sidetman()
 {}
 
 ReadAlignTrans::~ReadAlignTrans(void)
@@ -28,32 +26,10 @@ StatusCode ReadAlignTrans::initialize()
 {
   ATH_MSG_INFO("ReadAlignTrans::initialize() called");
 
-  // get ptr to GeoModelSvc to be able to register callback
-  if (StatusCode::SUCCESS!=service("GeoModelSvc",p_geomodelsvc)) {
-    ATH_MSG_ERROR("Cannot get ptr to GeoModelSvc");
-    return StatusCode::FAILURE;
-  }
-
   // get SiDetectorManagers for checking module positions
-  if (StatusCode::SUCCESS!=detStore()->retrieve(m_sidetman[0],"Pixel")) {
-    ATH_MSG_ERROR("Cannot get Pixel SiDetectorManager");
-    return StatusCode::FAILURE;
-  }
-  if (StatusCode::SUCCESS!=detStore()->retrieve(m_sidetman[1],"SCT")) {
-    ATH_MSG_ERROR("Cannot get SCT SiDetectorManager");
-    return StatusCode::FAILURE;
-  }
+  ATH_CHECK(detStore()->retrieve(m_sidetman[0],"Pixel"));
+  ATH_CHECK(detStore()->retrieve(m_sidetman[1],"SCT"));
 
-  // register callbacks on IGeoModelSvc::align to be called back after
-  // alignment has been recalculated
-
-  if (StatusCode::SUCCESS==detStore()->regFcn(&IGeoModelSvc::align,
-	    p_geomodelsvc,&ReadAlignTrans::testCallBack,this)) {
-    ATH_MSG_INFO("Registered callback for IGeoModelSvc");
-  } else {
-    ATH_MSG_ERROR("Register callback failed");
-    return StatusCode::FAILURE;
-  }
   return StatusCode::SUCCESS;
 }
 
@@ -98,17 +74,6 @@ StatusCode ReadAlignTrans::finalize() {
   return StatusCode::SUCCESS;
 }
 
-StatusCode ReadAlignTrans::testCallBack( IOVSVC_CALLBACK_ARGS_P( /* I */ ,
-								 keys ) ) {
-  // print out the keys we were given (for info)
-  // could do nothing if key is not /Indet/Align to save time
-  std::string keylist;
-  for (std::list<std::string>::const_iterator itr=keys.begin();
-       itr!=keys.end(); ++itr) keylist+=" "+*itr;
-  ATH_MSG_INFO("ReadAlignTrans callback invoked for keys:"+keylist);
-  return readSiPositions(m_identcache,m_poscache);
-}
-
 StatusCode ReadAlignTrans::readSiPositions(std::vector<Identifier>& idvec,
 					   std::vector<Amg::Vector3D >& posvec) {
   // find the identifier and position of all the pixel and SCT modules
diff --git a/DetectorDescription/DetDescrCond/DetDescrCondExample/DetDescrCondExample/ReadAlignTrans.h b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadAlignTrans.h
similarity index 84%
rename from DetectorDescription/DetDescrCond/DetDescrCondExample/DetDescrCondExample/ReadAlignTrans.h
rename to DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadAlignTrans.h
index cd8c0b454eeb..505ad5ccb074 100755
--- a/DetectorDescription/DetDescrCond/DetDescrCondExample/DetDescrCondExample/ReadAlignTrans.h
+++ b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadAlignTrans.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef DETDESCRCONDEXAMPLE_READALIGNTRANS_H
@@ -15,8 +15,6 @@
 #include "GeoPrimitives/GeoPrimitives.h"
 #include "AthenaKernel/IOVSvcDefs.h"
 
-class IGeoModelTool;
-class IGeoModelSvc;
 namespace InDetDD {
   class SiDetectorManager;
 }
@@ -30,12 +28,10 @@ class ReadAlignTrans: public AthAlgorithm
   StatusCode execute(void);
   StatusCode finalize(void);
 
-  StatusCode testCallBack( IOVSVC_CALLBACK_ARGS );
   StatusCode readSiPositions(std::vector<Identifier>&, 
 			     std::vector<Amg::Vector3D >&);
 
  private:
-  IGeoModelSvc* p_geomodelsvc;
   const InDetDD::SiDetectorManager* m_sidetman[2];
   std::vector<Identifier> m_identcache;
   std::vector<Amg::Vector3D> m_poscache;
diff --git a/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadTopTrans.cxx b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadTopTrans.cxx
index 372040c1cfa2..b9a675922c2d 100755
--- a/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadTopTrans.cxx
+++ b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadTopTrans.cxx
@@ -12,10 +12,10 @@
 // - BeginRun incident
 
 
+#include "ReadTopTrans.h"
 #include "GaudiKernel/ISvcLocator.h"
 #include "GaudiKernel/IIncidentSvc.h"
 #include "DetDescrConditions/DetCondKeyTrans.h"
-#include "DetDescrCondExample/ReadTopTrans.h"
 
 ReadTopTrans::ReadTopTrans(const std::string& name, 
   ISvcLocator* pSvcLocator) :AthAlgorithm(name,pSvcLocator) {}
diff --git a/DetectorDescription/DetDescrCond/DetDescrCondExample/DetDescrCondExample/ReadTopTrans.h b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadTopTrans.h
similarity index 100%
rename from DetectorDescription/DetDescrCond/DetDescrCondExample/DetDescrCondExample/ReadTopTrans.h
rename to DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadTopTrans.h
diff --git a/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadWriteCoolStrFile.cxx b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadWriteCoolStrFile.cxx
index 615a54e5babf..8469d3c51e2c 100755
--- a/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadWriteCoolStrFile.cxx
+++ b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadWriteCoolStrFile.cxx
@@ -6,10 +6,10 @@
 // read/write of CondStrFile
 // Richard Hawkings, started 14/11/05
 
+#include "ReadWriteCoolStrFile.h"
 #include "GaudiKernel/ISvcLocator.h"
 #include "DetDescrConditions/DetCondKeyTrans.h"
 #include "DetDescrCondTools/ICoolStrFileSvc.h"
-#include "DetDescrCondExample/ReadWriteCoolStrFile.h"
 
 ReadWriteCoolStrFile::ReadWriteCoolStrFile(const std::string& name, 
   ISvcLocator* pSvcLocator) :AthAlgorithm(name,pSvcLocator),
diff --git a/DetectorDescription/DetDescrCond/DetDescrCondExample/DetDescrCondExample/ReadWriteCoolStrFile.h b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadWriteCoolStrFile.h
similarity index 100%
rename from DetectorDescription/DetDescrCond/DetDescrCondExample/DetDescrCondExample/ReadWriteCoolStrFile.h
rename to DetectorDescription/DetDescrCond/DetDescrCondExample/src/ReadWriteCoolStrFile.h
diff --git a/DetectorDescription/DetDescrCond/DetDescrCondExample/src/components/DetDescrCondExample_entries.cxx b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/components/DetDescrCondExample_entries.cxx
index b773e3cade47..c4f8d55c93f1 100644
--- a/DetectorDescription/DetDescrCond/DetDescrCondExample/src/components/DetDescrCondExample_entries.cxx
+++ b/DetectorDescription/DetDescrCond/DetDescrCondExample/src/components/DetDescrCondExample_entries.cxx
@@ -1,7 +1,7 @@
-#include "DetDescrCondExample/ReadAlignTrans.h"
-#include "DetDescrCondExample/ReadTopTrans.h"
-#include "DetDescrCondExample/ReadWriteCoolStrFile.h"
-#include "DetDescrCondExample/CoolHistExample.h"
+#include "../ReadAlignTrans.h"
+#include "../ReadTopTrans.h"
+#include "../ReadWriteCoolStrFile.h"
+#include "../CoolHistExample.h"
 
 DECLARE_COMPONENT( ReadAlignTrans )
 DECLARE_COMPONENT( ReadTopTrans )
-- 
GitLab