From 013b856a06a4729843a8c0ef51f2ef2729cc6301 Mon Sep 17 00:00:00 2001
From: Tomoe Kishimoto <tomoe.kishimoto@cern.ch>
Date: Mon, 17 Jun 2019 11:31:58 +0900
Subject: [PATCH] Removed the callback fuction from MuonTGC_CablingSvc
 (ATLASRECTS-4577 and ATLASRECTS-4577)

The condition DB of the TGC cabling service is designed to correct mis-cablings of the TGC.
However, there was only one DB update in 2009. And, the TGC operation team expects no updates
during Run3. So, we have removed this condition DB because the migration is not so easy.
The current contents in the DB are put into the share directory of the package as text files.
---
 .../MuonTGC_Cabling/MuonTGC_CablingSvc.h      |   2 -
 .../src/MuonTGC_CablingSvc.cxx                |  29 +----
 .../MuonTGC_Cabling/src/TGCCableASDToPP.cxx   |   6 +
 .../python/MuonCablingConfig.py               |   8 ++
 .../TGC_CondCabling/CMakeLists.txt            |   2 +-
 .../TGC_CondCabling/TGCCablingDbTool.h        |   4 +-
 .../share/ASD2PP_diff_12_OFL.db               |  45 +++++++
 .../share/ASD2PP_diff_12_ONL.db               | 120 ++++++++++++++++++
 .../TGC_CondCabling/src/TGCCablingDbTool.cxx  |   6 +-
 .../MuonCondInterface/ITGCCablingDbTool.h     |   2 +
 10 files changed, 190 insertions(+), 34 deletions(-)
 create mode 100644 MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/share/ASD2PP_diff_12_OFL.db
 create mode 100644 MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/share/ASD2PP_diff_12_ONL.db

diff --git a/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/MuonTGC_Cabling/MuonTGC_CablingSvc.h b/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/MuonTGC_Cabling/MuonTGC_CablingSvc.h
index 28e7b6d6389..5b4d4912e3b 100644
--- a/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/MuonTGC_Cabling/MuonTGC_CablingSvc.h
+++ b/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/MuonTGC_Cabling/MuonTGC_CablingSvc.h
@@ -334,8 +334,6 @@ class MuonTGC_CablingSvc : public ITGCcablingSvc
 					    int & pos, 
 					    bool middle=false) const;
 
-  virtual 
-    StatusCode updateCableASDToPP(IOVSVC_CALLBACK_ARGS_P(I, keys));
 
   /////////////////////////////////////////////////////////////
   // channel connection
diff --git a/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/src/MuonTGC_CablingSvc.cxx b/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/src/MuonTGC_CablingSvc.cxx
index 7f4464b333c..77ef2cf8d3b 100644
--- a/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/src/MuonTGC_CablingSvc.cxx
+++ b/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/src/MuonTGC_CablingSvc.cxx
@@ -181,15 +181,10 @@ StatusCode MuonTGC_CablingSvc::initialize(void)
     return StatusCode::FAILURE;
   } 
 
-  const DataHandle<CondAttrListCollection> mapDataClob;
-  sc = detStore->regFcn(&MuonTGC_CablingSvc::updateCableASDToPP, 
-			this, 
-			mapDataClob, 
-			folderName, 
-			true);
+  sc = m_cabling->updateCableASDToPP();
   if(!sc.isSuccess()) {
-    ATH_MSG_FATAL("Could not register &updateCableASDToPP against folder " << folderName); 
-    return StatusCode::FAILURE; 
+    ATH_MSG_WARNING("updateCableASDToPP failed");
+    return StatusCode::SUCCESS;
   }
 
   return StatusCode::SUCCESS;
@@ -1832,21 +1827,3 @@ bool MuonTGC_CablingSvc::getLowPtCoincidenceIDfromOfflineID(const Identifier & o
 						   pos,
 						   middle);
 }
-
-StatusCode MuonTGC_CablingSvc::updateCableASDToPP(IOVSVC_CALLBACK_ARGS_P(I, keys)) { 
-  ATH_MSG_INFO("updateCableASDToPP called");
-
-  StatusCode sc = m_condDataTool->loadASD2PP_DIFF_12(I, keys);
-  if(!sc.isSuccess()) {
-    ATH_MSG_WARNING("loadASD2PP_DIFF_12 failed");
-    return StatusCode::SUCCESS;
-  }
-
-  sc = m_cabling->updateCableASDToPP();
-  if(!sc.isSuccess()) {
-    ATH_MSG_WARNING("updateCableASDToPP failed");
-    return StatusCode::SUCCESS;
-  }
-
-  return StatusCode::SUCCESS; 
-}
diff --git a/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/src/TGCCableASDToPP.cxx b/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/src/TGCCableASDToPP.cxx
index 41fef937e6c..c33aeb2dee6 100644
--- a/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/src/TGCCableASDToPP.cxx
+++ b/MuonSpectrometer/MuonCablings/MuonTGC_Cabling/src/TGCCableASDToPP.cxx
@@ -109,6 +109,12 @@ void TGCCableASDToPP::initialize(std::string& filename)
 StatusCode TGCCableASDToPP::updateDatabase()
 {
   if(m_tgcCablingDbTool.retrieve().isFailure()) return StatusCode::FAILURE;
+
+  StatusCode sc = m_tgcCablingDbTool->readASD2PP_DIFF_12FromText();
+  if(!sc.isSuccess()) {
+    return StatusCode::SUCCESS;
+  }
+
   std::vector<std::string> *tmp_ASD2PP_DIFF_12 = m_tgcCablingDbTool->giveASD2PP_DIFF_12();
   if(!tmp_ASD2PP_DIFF_12) return StatusCode::FAILURE;
 
diff --git a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCablingConfig.py b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCablingConfig.py
index b71857af95b..c4ec7d91b08 100644
--- a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCablingConfig.py
+++ b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCablingConfig.py
@@ -113,6 +113,14 @@ if DetFlags.readRDOBS.TGC_on() or DetFlags.readRDOPool.TGC_on() or DetFlags.read
         from IOVDbSvc.CondDB import conddb
         conddb.addFolderSplitMC('TGC','/TGC/CABLING/MAP_SCHEMA','/TGC/CABLING/MAP_SCHEMA')
 
+    from TGC_CondCabling.TGC_CondCablingConf import TGCCablingDbTool
+    TGCCablingDbTool = TGCCablingDbTool()
+    if globalflags.DataSource() == 'geant4':
+        TGCCablingDbTool.filename_ASD2PP_DIFF_12='ASD2PP_diff_12_OFL.db'
+    else:
+        TGCCablingDbTool.filename_ASD2PP_DIFF_12='ASD2PP_diff_12_ONL.db'
+    ToolSvc+=TGCCablingDbTool
+
     #if globalflags.DataSource() == 'geant4' and not DetFlags.digitize.TGC_on():
         #conddb.addFolder("TGC_OFL","/TGC/TRIGGER/CW_EIFI")
         #conddb.addFolder("TGC_OFL","/TGC/TRIGGER/CW_BW")
diff --git a/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/CMakeLists.txt b/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/CMakeLists.txt
index ef633c99832..3a35556ccbf 100644
--- a/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/CMakeLists.txt
+++ b/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/CMakeLists.txt
@@ -27,4 +27,4 @@ atlas_add_component( TGC_CondCabling
 
 # Install files from the package:
 atlas_install_headers( TGC_CondCabling )
-
+atlas_install_runtime( share/*.db )
diff --git a/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/TGC_CondCabling/TGCCablingDbTool.h b/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/TGC_CondCabling/TGCCablingDbTool.h
index 28336fc1ace..be4dd8954e3 100644
--- a/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/TGC_CondCabling/TGCCablingDbTool.h
+++ b/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/TGC_CondCabling/TGCCablingDbTool.h
@@ -38,11 +38,11 @@ class TGCCablingDbTool: public AthAlgTool, public ITGCCablingDbTool
   virtual StatusCode loadParameters(IOVSVC_CALLBACK_ARGS);
   /** Load parameters using the folder name */
   virtual StatusCode loadASD2PP_DIFF_12(IOVSVC_CALLBACK_ARGS);
-
- private: 
   /** Load parameters from text database */
   virtual StatusCode readASD2PP_DIFF_12FromText();
 
+ private: 
+
   /** IIOVSvc member */
   IIOVSvc* m_IOVSvc;
   /** IChronoStatSvc member */
diff --git a/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/share/ASD2PP_diff_12_OFL.db b/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/share/ASD2PP_diff_12_OFL.db
new file mode 100644
index 00000000000..ef718196a0c
--- /dev/null
+++ b/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/share/ASD2PP_diff_12_OFL.db
@@ -0,0 +1,45 @@
+//----------------------------------------------------------------------
+// ASD2PP_diff.db
+//-----------
+// Connection information between ASDs and Patch Panels (PPs)
+// This file describes diff from ASD2PP.db
+//
+// Table contents: iii nnnn
+//                 iii  = PP type
+//                 nnnn = Number of channels
+//
+//                     |-  ASD -||-- PP -|
+//                 q r  s t uuu   x y zz
+//                 q    = Side ( 0: A , 1:C )
+//                 r    = Sector ID
+//                 s    = Layer ID
+//                 t    = Chamber ID
+//                 uuu  = Wire-group ID
+//                 x    = PP ID
+//                 y    = PP input-connector ID
+//                 zz   = PP input-channel ID of a connector
+//---------------------------------------------------------------------- 
+// OWNER:  Hisaya Kurashige          SECTION: Connection
+//
+//               
+//                  Date      Who     Explanation of Changes
+//               ----------- ------- -----------------------------------
+// Version  0.00 29-OCT-2008  HK     Creation
+// Version  0.01 22-JUL-2009  Susumu Update for simulationd; just added 
+//                                   this message   
+//
+//----------------------------------------------------------------------
+//
+EWT 0
+EWD 0
+EST 0
+ESD 0
+FWT 0
+FWD 0
+FST 0
+FSD 0 
+EWI 0
+ESI 0
+FWI 0
+FSI 0
+//
diff --git a/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/share/ASD2PP_diff_12_ONL.db b/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/share/ASD2PP_diff_12_ONL.db
new file mode 100644
index 00000000000..ab2243ac540
--- /dev/null
+++ b/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/share/ASD2PP_diff_12_ONL.db
@@ -0,0 +1,120 @@
+//----------------------------------------------------------------------
+// ASD2PP_diff.db
+//-----------
+// Connection information between ASDs and Patch Panels (PPs)
+// This file describes diff from ASD2PP.db
+//
+// Table contents: iii nnnn
+//                 iii  = PP type
+//                 nnnn = Number of channels
+//
+//                     |-  ASD -||-- PP -|
+//                 q r  s t uuu   x y zz
+//                 q    = Side ( 0: A , 1:C )
+//                 r    = Sector ID
+//                 s    = Layer ID
+//                 t    = Chamber ID
+//                 uuu  = Wire-group ID
+//                 x    = PP ID
+//                 y    = PP input-connector ID
+//                 zz   = PP input-channel ID of a connector
+//---------------------------------------------------------------------- 
+// OWNER:  Hisaya Kurashige          SECTION: Connection
+//
+//               
+//                  Date      Who     Explanation of Changes
+//               ----------- ------- -----------------------------------
+// Version  0.00 29-OCT-2008  HK     Creation
+// Version  0.01 22-JUL-2009  Susumu Update for simulationd; just added
+//                                   this message
+// Version  0.02 22-JUL-2009  Susumu Update for data; just added this
+//                                   message
+// Version  1.00  9-OCT-2009  HK     Layer Swap for Endcap A10 Phi2 
+//                                   EWT2 and EWT3
+// Version  1.01 28-OCT-2009  Susumu Fixed Layer ID (3->2)
+// Version  1.02  8-SEP-2010  Susumu Fixed PP input-connector ID
+//                                   (0->2, 2->3, 3->0) 
+//--------------------------------------------------------------------
+//
+EWT  69
+  0  38  2  1   0  1  2  4
+  0  38  2  1   1  1  2  5
+  0  38  2  1   2  1  2  6
+  0  38  2  1   3  1  2  7
+  0  38  2  1   4  1  2  8
+  0  38  2  1   5  1  2  9
+  0  38  2  1   6  1  2 10
+  0  38  2  1   7  1  2 11
+  0  38  2  1   8  1  2 12
+  0  38  2  1   9  1  2 13
+  0  38  2  1  10  1  2 14
+  0  38  2  1  11  1  2 15
+  0  38  2  1  12  1  2 16
+  0  38  2  1  13  1  2 17
+  0  38  2  1  14  1  2 18
+  0  38  2  1  15  1  2 19
+  0  38  2  1  16  1  2 20
+  0  38  2  1  17  1  2 21
+  0  38  2  1  18  1  2 22
+  0  38  2  1  19  1  2 23
+  0  38  2  1  20  1  2 24
+  0  38  2  1  21  1  2 25
+  0  38  2  1  22  1  2 26
+  0  38  0  1   0  1  3  4
+  0  38  0  1   1  1  3  5
+  0  38  0  1   2  1  3  6
+  0  38  0  1   3  1  3  7
+  0  38  0  1   4  1  3  8
+  0  38  0  1   5  1  3  9
+  0  38  0  1   6  1  3 10
+  0  38  0  1   7  1  3 11
+  0  38  0  1   8  1  3 12
+  0  38  0  1   9  1  3 13
+  0  38  0  1  10  1  3 14
+  0  38  0  1  11  1  3 15
+  0  38  0  1  12  1  3 16
+  0  38  0  1  13  1  3 17
+  0  38  0  1  14  1  3 18
+  0  38  0  1  15  1  3 19
+  0  38  0  1  16  1  3 20
+  0  38  0  1  17  1  3 21
+  0  38  0  1  18  1  3 22
+  0  38  0  1  19  1  3 23
+  0  38  0  1  20  1  3 24
+  0  38  0  1  21  1  3 25
+  0  38  0  1  22  1  3 26
+  0  38  1  1   0  1  0  4
+  0  38  1  1   1  1  0  5
+  0  38  1  1   2  1  0  6
+  0  38  1  1   3  1  0  7
+  0  38  1  1   4  1  0  8
+  0  38  1  1   5  1  0  9
+  0  38  1  1   6  1  0 10
+  0  38  1  1   7  1  0 11
+  0  38  1  1   8  1  0 12
+  0  38  1  1   9  1  0 13
+  0  38  1  1  10  1  0 14
+  0  38  1  1  11  1  0 15
+  0  38  1  1  12  1  0 16
+  0  38  1  1  13  1  0 17
+  0  38  1  1  14  1  0 18
+  0  38  1  1  15  1  0 19
+  0  38  1  1  16  1  0 20
+  0  38  1  1  17  1  0 21
+  0  38  1  1  18  1  0 22
+  0  38  1  1  19  1  0 23
+  0  38  1  1  20  1  0 24
+  0  38  1  1  21  1  0 25
+  0  38  1  1  22  1  0 26
+EWD 0
+EST 0
+ESD 0
+FWT 0
+FWD 0
+FST 0
+FSD 0 
+EWI 0
+ESI 0
+FWI 0
+FSI 0
+//
diff --git a/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/src/TGCCablingDbTool.cxx b/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/src/TGCCablingDbTool.cxx
index f2fad6259eb..125d8446612 100644
--- a/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/src/TGCCablingDbTool.cxx
+++ b/MuonSpectrometer/MuonConditions/MuonCondCabling/TGC_CondCabling/src/TGCCablingDbTool.cxx
@@ -30,8 +30,8 @@ TGCCablingDbTool::TGCCablingDbTool(const std::string& type,
   declareProperty("Folder", m_Folder="/TGC/CABLING/MAP_SCHEMA");
 
   // ASD2PP_diff_12.db is the text database for the TGCcabling12 package
-  declareProperty("filename_ASD2PP_DIFF_12", m_filename="ASD2PP_diff_12.db");
-  declareProperty("readASD2PP_DIFF_12FromText", m_readASD2PP_DIFF_12FromText=false);
+  declareProperty("filename_ASD2PP_DIFF_12", m_filename="ASD2PP_diff_12_ONL.db");
+  declareProperty("readASD2PP_DIFF_12FromText", m_readASD2PP_DIFF_12FromText=true);
 }
 
 
@@ -207,7 +207,7 @@ StatusCode TGCCablingDbTool::readASD2PP_DIFF_12FromText() {
   // Copy database into m_ASD2PP_DIFF_12
   while(getline(inASDToPP, buf)){ 
     m_ASD2PP_DIFF_12->push_back(buf);
-    ATH_MSG_INFO(m_filename.c_str() << " L" << ++nLines << ": " << buf.c_str());
+    ATH_MSG_DEBUG(m_filename.c_str() << " L" << ++nLines << ": " << buf.c_str());
   }
 
   inASDToPP.close(); 
diff --git a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondInterface/MuonCondInterface/ITGCCablingDbTool.h b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondInterface/MuonCondInterface/ITGCCablingDbTool.h
index b036b7ada14..1c9f8cabefb 100644
--- a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondInterface/MuonCondInterface/ITGCCablingDbTool.h
+++ b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondInterface/MuonCondInterface/ITGCCablingDbTool.h
@@ -27,6 +27,8 @@ class ITGCCablingDbTool: virtual public IAlgTool,
   
   virtual StatusCode loadASD2PP_DIFF_12(IOVSVC_CALLBACK_ARGS) = 0;
 
+  virtual StatusCode readASD2PP_DIFF_12FromText() = 0;
+
   virtual std::vector<std::string>* giveASD2PP_DIFF_12(void) = 0;
 
   virtual std::string getFolderName(void) const = 0;
-- 
GitLab