From 29b1345c943cb5f8084fd0a34c9460f88375af79 Mon Sep 17 00:00:00 2001
From: Dave Casper <dcasper@uci.edu>
Date: Tue, 5 Feb 2019 21:44:31 -0800
Subject: [PATCH] Commission reading from Geometry database

---
 .../GeoModel/FaserGeoModel/data/geomDB.sql    |  28 ++---
 .../GeoModelFaserUtilities/CMakeLists.txt     |  35 ++++++
 .../DecodeFaserVersionKey.h                   |  52 +++++++++
 .../src/DecodeFaserVersionKey.cxx             | 106 ++++++++++++++++++
 .../GeoModel/GeoModelSvc/CMakeLists.txt       |   3 +-
 .../GeoModel/GeoModelSvc/share/geoDebug.py    |  60 ++++++++++
 .../GeoModel/GeoModelSvc/src/GeoDbTagSvc.cxx  |   4 +-
 .../GeoModel/GeoModelSvc/src/GeoModelSvc.cxx  |   8 +-
 .../GeoModelSvc/src/RDBMaterialManager.cxx    |  28 ++---
 9 files changed, 289 insertions(+), 35 deletions(-)
 create mode 100644 DetectorDescription/GeoModel/GeoModelFaserUtilities/CMakeLists.txt
 create mode 100644 DetectorDescription/GeoModel/GeoModelFaserUtilities/GeoModelFaserUtilities/DecodeFaserVersionKey.h
 create mode 100644 DetectorDescription/GeoModel/GeoModelFaserUtilities/src/DecodeFaserVersionKey.cxx
 create mode 100644 DetectorDescription/GeoModel/GeoModelSvc/share/geoDebug.py

diff --git a/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql b/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql
index c1084b35a..726b2e3f6 100644
--- a/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql
+++ b/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql
@@ -201,20 +201,20 @@ INSERT INTO "HVS_NODE" VALUES (1003, "ScintMaterials", 1, 0, NULL);
 INSERT INTO "HVS_NODE" VALUES (1004, "ScintMatComponents", 1, 0, NULL);
 INSERT INTO "HVS_NODE" VALUES (110,  "FaserCommon", 0, 0, NULL);
 -- Data for the HVS_TAG2NODE table
-INSERT INTO "HVS_TAG2NODE" VALUES (0, "FASER-00", 100000, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (1, "Scintillator-00", 100001, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (2, "Tracker-00", 100002, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (3, "Calorimeter-00", 100003, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (4, "Magnet-00", 100004, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (100, "Materials-00", 100005, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (101, "StdMaterials-00", 100006, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (102, "StdMatComponents-00", 100007, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (103, "Elements-00", 100008, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (1001, "ScintPlate-00", 100009, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (1002, "ScintStation-00", 100010, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (1003, "ScintMaterials-00", 100011, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (1004, "ScintMatComponents-00", 100012, NULL, 0, 0, 1549238400000000000, NULL, 1);
-INSERT INTO "HVS_TAG2NODE" VALUES (110,  "FaserCommon-00", 100013, NULL, 0, 0, 1549324800000000000, NULL, 1);
+INSERT INTO "HVS_TAG2NODE" VALUES (0, "FASER-00", 100000, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (1, "Scintillator-00", 100001, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (2, "Tracker-00", 100002, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (3, "Calorimeter-00", 100003, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (4, "Magnet-00", 100004, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (100, "Materials-00", 100005, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (101, "StdMaterials-00", 100006, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (102, "StdMatComponents-00", 100007, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (103, "Elements-00", 100008, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (1001, "ScintPlate-00", 100009, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (1002, "ScintStation-00", 100010, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (1003, "ScintMaterials-00", 100011, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (1004, "ScintMatComponents-00", 100012, NULL, 0, 0, 1549238400000000000, NULL, 22);
+INSERT INTO "HVS_TAG2NODE" VALUES (110,  "FaserCommon-00", 100013, NULL, 0, 0, 1549324800000000000, NULL, 22);
 -- Data for the HVS_LTAG2LTAG table
 INSERT INTO "HVS_LTAG2LTAG" VALUES (0,   100000, 1,    100001);
 INSERT INTO "HVS_LTAG2LTAG" VALUES (0,   100000, 2,    100002);
diff --git a/DetectorDescription/GeoModel/GeoModelFaserUtilities/CMakeLists.txt b/DetectorDescription/GeoModel/GeoModelFaserUtilities/CMakeLists.txt
new file mode 100644
index 000000000..8028900c7
--- /dev/null
+++ b/DetectorDescription/GeoModel/GeoModelFaserUtilities/CMakeLists.txt
@@ -0,0 +1,35 @@
+################################################################################
+# Package: GeoModelFaserUtilities
+################################################################################
+#
+# Only one class in the ATLAS GeoModelUtilities library needs to be modified for FASER
+# so instead of duplicating the entire library, create a small one with only
+# the modified class
+#
+
+# Declare the package name:
+atlas_subdir( GeoModelFaserUtilities )
+
+# Declare the package's dependencies:
+atlas_depends_on_subdirs( PUBLIC
+                          Control/AthenaBaseComps
+                          Control/AthenaKernel
+                          Database/RDBAccessSvc
+                          DetectorDescription/GeoModel/GeoModelInterfaces
+                          PRIVATE
+                          GaudiKernel )
+
+# External dependencies:
+find_package( Boost COMPONENTS filesystem thread system )
+find_package( Eigen )
+find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess )
+find_package( GeoModel )
+
+# Component(s) in the package:
+atlas_add_library( GeoModelFaserUtilities
+                   src/*.cxx
+                   PUBLIC_HEADERS GeoModelFaserUtilities
+                   INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${GEOMODEL_INCLUDE_DIRS}
+                   LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${EIGEN_LIBRARIES} ${GEOMODEL_LIBRARIES} AthenaBaseComps SGTools 
+                   PRIVATE_LINK_LIBRARIES GaudiKernel )
+
diff --git a/DetectorDescription/GeoModel/GeoModelFaserUtilities/GeoModelFaserUtilities/DecodeFaserVersionKey.h b/DetectorDescription/GeoModel/GeoModelFaserUtilities/GeoModelFaserUtilities/DecodeFaserVersionKey.h
new file mode 100644
index 000000000..902e683d2
--- /dev/null
+++ b/DetectorDescription/GeoModel/GeoModelFaserUtilities/GeoModelFaserUtilities/DecodeFaserVersionKey.h
@@ -0,0 +1,52 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef GEOMODELSVC_DECODEFASERVERSIONKEY_H
+#define GEOMODELSVC_DECODEFASERVERSIONKEY_H
+
+#include <string>
+class IGeoModelSvc;
+class IGeoDbTagSvc;
+
+/// This is a helper class to query the version tags from GeoModelSvc and
+/// determine the appropriate tag and node to pass to RDBAccessServer.
+/// If a subsystem has an override tag then that tag is used otherwise the 
+/// FASER tag is used.
+
+class DecodeFaserVersionKey
+{
+  
+ public:
+  /// Constructor is passed a pointer to GeoModelSvc plus the node
+  /// for which you want the tag. 
+  /// Possible nodes are FASER, Scintillator, Tracker, Magnet, Calorimeter.
+  DecodeFaserVersionKey(const IGeoModelSvc *, const std::string & node);
+  // Overloading the constructor to allow adiabatic migration of clients away from the IGeoModelSvc
+  DecodeFaserVersionKey(const IGeoDbTagSvc *, const std::string & node);
+  DecodeFaserVersionKey(const std::string & node);
+  
+  /// Return version tag 
+  const std::string & tag() const;
+
+  /// Return the version node.
+  const std::string & node() const;
+
+  /// Return true if CUSTOM is selected.
+  bool custom() const;
+
+ private:
+
+  template <class T>
+    void defineTag(const T* svc, const std::string & node);
+
+  // utilily for dealing with CUSTOM tags.
+  bool getCustomTag(const std::string & inputTag, std::string & outputTag);
+
+  std::string m_tag;
+  std::string m_node;
+  bool m_custom;
+
+};
+
+#endif // GEOMODELSVC_DECODEFASERVERSIONKEY_H
diff --git a/DetectorDescription/GeoModel/GeoModelFaserUtilities/src/DecodeFaserVersionKey.cxx b/DetectorDescription/GeoModel/GeoModelFaserUtilities/src/DecodeFaserVersionKey.cxx
new file mode 100644
index 000000000..e962e4149
--- /dev/null
+++ b/DetectorDescription/GeoModel/GeoModelFaserUtilities/src/DecodeFaserVersionKey.cxx
@@ -0,0 +1,106 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h"
+#include "GeoModelInterfaces/IGeoModelSvc.h"
+#include "GeoModelInterfaces/IGeoDbTagSvc.h"
+#include "GaudiKernel/ISvcLocator.h"
+#include "GaudiKernel/Bootstrap.h"
+#include <string>
+#include <iostream>
+
+DecodeFaserVersionKey::DecodeFaserVersionKey(const IGeoModelSvc * geoModel, const std::string & node)
+{
+  defineTag<IGeoModelSvc>(geoModel,node);
+}
+
+DecodeFaserVersionKey::DecodeFaserVersionKey(const IGeoDbTagSvc * geoDbTag, const std::string & node)
+{
+  defineTag<IGeoDbTagSvc>(geoDbTag,node);
+}
+
+DecodeFaserVersionKey::DecodeFaserVersionKey(const std::string & node)
+{
+  ISvcLocator* svcLocator = Gaudi::svcLocator();
+  IGeoDbTagSvc* geoDbTag{nullptr};
+  if(svcLocator->service("GeoDbTagSvc",geoDbTag).isFailure())
+    throw std::runtime_error("DecodeFaserVersionKey constructor: cannot access GeoDbTagSvc");
+  defineTag<IGeoDbTagSvc>(geoDbTag,node);
+}
+
+template <class T>
+void DecodeFaserVersionKey::defineTag(const T* svc, const std::string & node)
+{
+  std::string nodeOverrideTag;
+  std::string indetOverrideTag; // Indet has two levels.
+  if (node == "FASER") {
+    nodeOverrideTag = "";
+  } else if (node == "Scintillator") {
+    nodeOverrideTag = svc->scintVersionOverride();
+  // } else if (node == "SCT") {
+  //   indetOverrideTag = svc->inDetVersionOverride();
+  //   nodeOverrideTag  = svc->SCT_VersionOverride();
+  // } else if (node == "Calorimeter") {
+  //   nodeOverrideTag  = svc->caloVersionOverride();
+  } else {
+    std::cout << "DecodeFaserVersionKey passed an unknown node:" << node << std::endl; 
+    nodeOverrideTag = "";
+  }
+
+  // Default to faser version
+  m_tag = svc->faserVersion();
+  m_node = "FASER";
+  
+  // Finally if subsystem tag is overriden then use that.
+  std::string outputTag;
+  m_custom = getCustomTag(nodeOverrideTag, outputTag);
+
+  if (!outputTag.empty()) {
+    m_tag  = outputTag;
+    m_node = node;
+  }
+}
+
+const std::string &
+DecodeFaserVersionKey::tag() const
+{
+  return m_tag;
+}
+
+const std::string &
+DecodeFaserVersionKey::node() const
+{
+  return m_node;
+}
+
+bool
+DecodeFaserVersionKey::custom() const
+{
+  return m_custom;
+}
+
+
+
+bool 
+DecodeFaserVersionKey::getCustomTag(const std::string & inputTag, std::string & outputTag)
+{
+  //
+  // Check if CUSTOM is specified. If it is not specified then outputTag = inputTag.
+  // If the tag is just "CUSTOM" then set output tag to "" so that we use the higher level tag.
+  // If the tag is of the form CUSTOM-XXXXX use the XXXXX as the tag
+  // The separating character (in this example a '-') can be any character. 
+  //
+  bool custom = false;
+  outputTag = inputTag;
+  if (!inputTag.empty()) {
+    if (inputTag.substr(0,6) == "CUSTOM") {
+      custom = true;
+      // If its CUSTOM-something skip the next character and get the something
+      outputTag = inputTag.substr(6);
+      if (!outputTag.empty()) outputTag = outputTag.substr(1);
+    }
+  }
+  return custom;
+}
+
diff --git a/DetectorDescription/GeoModel/GeoModelSvc/CMakeLists.txt b/DetectorDescription/GeoModel/GeoModelSvc/CMakeLists.txt
index 2ae87919c..51c3615d8 100644
--- a/DetectorDescription/GeoModel/GeoModelSvc/CMakeLists.txt
+++ b/DetectorDescription/GeoModel/GeoModelSvc/CMakeLists.txt
@@ -15,6 +15,7 @@ atlas_depends_on_subdirs( PRIVATE
                           Database/RDBAccessSvc
                           DetectorDescription/GeoModel/GeoModelInterfaces
                           DetectorDescription/GeoModel/GeoModelUtilities
+                          DetectorDescription/GeoModel/GeoModelFaserUtilities
                           Event/EventInfo
                           Event/EventInfoMgt
                           GaudiKernel )
@@ -33,7 +34,7 @@ atlas_add_component( GeoModelSvc
                      src/RDBMaterialManager.cxx
                      src/components/GeoModelSvc_entries.cxx
                      INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${GEOMODEL_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${GEOMODEL_LIBRARIES} AthenaBaseComps CxxUtils AthenaKernel SGTools StoreGateLib SGtests GeoModelUtilities EventInfo GaudiKernel )
+                     LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${GEOMODEL_LIBRARIES} AthenaBaseComps CxxUtils AthenaKernel SGTools StoreGateLib SGtests GeoModelUtilities GeoModelFaserUtilities EventInfo GaudiKernel )
 
 # Install files from the package:
 atlas_install_headers( GeoModelSvc )
diff --git a/DetectorDescription/GeoModel/GeoModelSvc/share/geoDebug.py b/DetectorDescription/GeoModel/GeoModelSvc/share/geoDebug.py
new file mode 100644
index 000000000..2cdf2c9fd
--- /dev/null
+++ b/DetectorDescription/GeoModel/GeoModelSvc/share/geoDebug.py
@@ -0,0 +1,60 @@
+MessageSvc.OutputLevel = VERBOSE
+
+from AthenaCommon.GlobalFlags import globalflags
+
+globalflags.DetDescrVersion.set_Value_and_Lock( "FASER-00" )
+
+#globalflags.ConditionsTag.set_Value_and_Lock( "OFLCOND-MC16-SDR-14" )
+
+#from IOVDbSvc.CondDB import conddb
+#conddb.setGlobalTag(globalflags.ConditionsTag())
+
+#from AthenaCommon.DetFlags import DetFlags
+
+#DetFlags.geometry.SCT_setOn()
+#DetFlags.detdescr.SCT_setOn()
+
+#include('ISF_Config/AllDet_detDescr.py')
+# from SetGeometryVersion
+from GeoModelSvc.GeoModelSvcConf import GeoModelSvc
+from DetDescrCnvSvc.DetDescrCnvSvcConf import DetDescrCnvSvc
+
+GeoModelSvc = GeoModelSvc()
+DetDescrCnvSvc = DetDescrCnvSvc()
+
+GeoModelSvc.FaserVersion = "FASER-00"
+
+from AthenaCommon.AppMgr import release_metadata
+rel_metadata = release_metadata()
+relversion = rel_metadata['release'].split('.')
+if len(relversion) < 3:
+    relversion = rel_metadata['base release'].split('.')
+
+print "SetGeometryVersion.py obtained major release version %s" % relversion[0]
+GeoModelSvc.SupportedGeometry = int(relversion[0])
+GeoModelSvc.PrintMaterials = True
+
+# from GeoModelInit
+
+import DetDescrCnvSvc.DetStoreConfig
+svcMgr.DetDescrCnvSvc.IdDictFromRDB = True
+
+# from GeoModelInitStandard
+
+ServiceMgr += GeoModelSvc
+theApp.CreateSvc += [ "GeoModelSvc"]
+
+#DetFlags.Print()
+
+from AthenaCommon.AppMgr import theApp
+
+theApp.EvtMax = 1
+
+# Uses SQLite by default (if available)
+# These lines suppress SQLite for geometry
+#from DBReplicaSvc.DBReplicaSvcConf import DBReplicaSvc
+#
+#DBReplicaSvc.UseGeomSQLite = False
+
+# This only affects conditions, not geometry
+#include('PyJobTransforms/UseFrontier.py')
diff --git a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.cxx b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.cxx
index f0ba30fbd..3e2e9cf85 100644
--- a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.cxx
+++ b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoDbTagSvc.cxx
@@ -68,7 +68,7 @@ StatusCode GeoDbTagSvc::setupTags()
 
   // Get subsystem tags
   m_ScintVersion = (m_ScintVersionOverride.empty() 
-		    ? rdbAccessSvc->getChildTag("Scintillator", m_FaserVersion, "FASER") 
+		    ? rdbAccessSvc->getChildTag("Scintillator", m_FaserVersion, "FASER", "FASERDD") 
 		    : m_ScintVersionOverride);
 
   // m_SCT_Version = (m_SCT_VersionOverride.empty()
@@ -88,7 +88,7 @@ StatusCode GeoDbTagSvc::setupTags()
 	// 		  : m_CavernInfraVersionOverride);
 
   // Retrieve geometry config information (RUN1, RUN2, etc...)
-  IRDBRecordset_ptr faserCommonRec = rdbAccessSvc->getRecordsetPtr("FaserCommon", m_FaserVersion, "FASER");
+  IRDBRecordset_ptr faserCommonRec = rdbAccessSvc->getRecordsetPtr("FaserCommon", m_FaserVersion, "FASER", "FASERDD");
   if(faserCommonRec->size()==0) {
     m_geoConfig = GeoModel::GEO_RUN3;
   }
diff --git a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.cxx b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.cxx
index 5ebef7092..722d941d6 100644
--- a/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.cxx
+++ b/DetectorDescription/GeoModel/GeoModelSvc/src/GeoModelSvc.cxx
@@ -231,13 +231,13 @@ StatusCode GeoModelSvc::geoInit()
   ServiceHandle<IRDBAccessSvc> rdbAccess("RDBAccessSvc",name());
   ATH_CHECK( rdbAccess.retrieve() );
 
-  if(!rdbAccess->connect()) {
+  if(!rdbAccess->connect("FASERDD")) {
     ATH_MSG_ERROR("Unable to connect to the Geometry DB");
     return StatusCode::FAILURE;
   }
 
   // Check the existence of FASER tag in the database
-  if(rdbAccess->getChildTag("FASER",m_FaserVersion,"FASER")=="") {
+  if(rdbAccess->getChildTag("FASER",m_FaserVersion,"FASER", "FASERDD")=="") {
     ATH_MSG_FATAL(" *** *** Wrong FASER layout: " << m_FaserVersion << " *** ***");
     ATH_MSG_FATAL(" Either FASER geometry tag has been misspelled, or the DB Release does not contain the geometry specified.");
     ATH_MSG_FATAL(" In latter case please update DB Release version");
@@ -245,7 +245,7 @@ StatusCode GeoModelSvc::geoInit()
   }
 
   if(!m_ignoreTagSupport) {
-    RDBTagDetails faserTagDetails = rdbAccess->getTagDetails(m_FaserVersion);
+    RDBTagDetails faserTagDetails = rdbAccess->getTagDetails(m_FaserVersion, "FASERDD");
     const coral::AttributeSpecification& supportedSpec = faserTagDetails["SUPPORTED"].specification();
     if(supportedSpec.type()==typeid(bool)) {
       if(!faserTagDetails["SUPPORTED"].data<bool>()) {
@@ -342,7 +342,7 @@ StatusCode GeoModelSvc::geoInit()
   }
 	
   // Close DB connection
-  rdbAccess->shutdown();
+  rdbAccess->shutdown("FASERDD");
   if(m_printMaterials)
     theMaterialManager->printAll();
   
diff --git a/DetectorDescription/GeoModel/GeoModelSvc/src/RDBMaterialManager.cxx b/DetectorDescription/GeoModel/GeoModelSvc/src/RDBMaterialManager.cxx
index 23386d107..7e724edb1 100644
--- a/DetectorDescription/GeoModel/GeoModelSvc/src/RDBMaterialManager.cxx
+++ b/DetectorDescription/GeoModel/GeoModelSvc/src/RDBMaterialManager.cxx
@@ -3,7 +3,7 @@
 */
 
 #include "RDBMaterialManager.h"
-#include "GeoModelUtilities/DecodeVersionKey.h"
+#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h"
 #include "GeoModelInterfaces/IGeoModelSvc.h"
 
 #include "GeoModelKernel/GeoMaterial.h"
@@ -151,39 +151,39 @@ StatusCode RDBMaterialManager::readMaterialsFromDB(ISvcLocator* pSvcLocator)
   ATH_CHECK(pSvcLocator->service("RDBAccessSvc",iAccessSvc));
 
   // --- Standard materials, elements
-  DecodeVersionKey keyFaser(iGeoModel, "FASER");
-  m_elements = iAccessSvc->getRecordsetPtr("Elements",keyFaser.tag(),keyFaser.node());
+  DecodeFaserVersionKey keyFaser(iGeoModel, "FASER");
+  m_elements = iAccessSvc->getRecordsetPtr("Elements",keyFaser.tag(),keyFaser.node(), "FASERDD");
   if(m_elements->size()==0) {
     if(log.level()<=MSG::WARNING)
       log << MSG::WARNING << " Getting Elements with default tag" <<endmsg;
-    m_elements = iAccessSvc->getRecordsetPtr("Elements","Materials-00","Materials");
+    m_elements = iAccessSvc->getRecordsetPtr("Elements","Materials-00","Materials", "FASERDD");
   }
-  m_stdmatcomponents = iAccessSvc->getRecordsetPtr("StdMatComponents",keyFaser.tag(),keyFaser.node());
+  m_stdmatcomponents = iAccessSvc->getRecordsetPtr("StdMatComponents",keyFaser.tag(),keyFaser.node(), "FASERDD");
   if(m_stdmatcomponents->size()==0)	{
     if(log.level()<=MSG::WARNING)
       log << MSG::WARNING << " Getting StdMatComponents with default tag" <<endmsg;
-    m_stdmatcomponents = iAccessSvc->getRecordsetPtr("StdMatComponents","Materials-00","Materials");
+    m_stdmatcomponents = iAccessSvc->getRecordsetPtr("StdMatComponents","Materials-00","Materials", "FASERDD");
   }
-  m_stdmaterials = iAccessSvc->getRecordsetPtr("StdMaterials",keyFaser.tag(),keyFaser.node());
+  m_stdmaterials = iAccessSvc->getRecordsetPtr("StdMaterials",keyFaser.tag(),keyFaser.node(), "FASERDD");
   if(m_stdmaterials->size()==0) {
     if(log.level()<=MSG::WARNING)
       log << MSG::WARNING << " Getting StdMaterials with default tag" <<endmsg;
-    m_stdmaterials = iAccessSvc->getRecordsetPtr("StdMaterials","Materials-00","Materials");
+    m_stdmaterials = iAccessSvc->getRecordsetPtr("StdMaterials","Materials-00","Materials", "FASERDD");
   }
   
-  // --- Pixel materials
-  DecodeVersionKey keyScintillator(iGeoModel, "Scintillator");
-  m_scintmatcomponents = iAccessSvc->getRecordsetPtr("ScintMatComponents",keyScintillator.tag(),keyScintillator.node());
+  // --- Scintillator materials
+  DecodeFaserVersionKey keyScintillator(iGeoModel, "Scintillator");
+  m_scintmatcomponents = iAccessSvc->getRecordsetPtr("ScintMatComponents",keyScintillator.tag(),keyScintillator.node(),"FASERDD");
   if(m_scintmatcomponents->size()==0) {
     if(log.level()<=MSG::WARNING)
       log << MSG::WARNING << " Getting ScintMatComponents with default tag" <<endmsg;
-    m_scintmatcomponents = iAccessSvc->getRecordsetPtr("ScintMatComponents","ScintMatComponents-00");
+    m_scintmatcomponents = iAccessSvc->getRecordsetPtr("ScintMatComponents","ScintMatComponents-00", "", "FASERDD");
   }
-  m_scintmaterials = iAccessSvc->getRecordsetPtr("PixMaterials",keyScintillator.tag(),keyScintillator.node());
+  m_scintmaterials = iAccessSvc->getRecordsetPtr("ScintMaterials",keyScintillator.tag(),keyScintillator.node(), "FASERDD");
   if(m_scintmaterials->size()==0) {
     if(log.level()<=MSG::WARNING)
       log << MSG::WARNING << " Getting ScintMaterials with default tag" <<endmsg;
-    m_scintmaterials = iAccessSvc->getRecordsetPtr("ScintMaterials","ScintMaterials-00");
+    m_scintmaterials = iAccessSvc->getRecordsetPtr("ScintMaterials","ScintMaterials-00", "", "FASERDD");
   }
   
   // --- SCT materials
-- 
GitLab