Skip to content
Snippets Groups Projects
Commit e48b2b2f authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'geodb_config' into 'master'

Refactor code to read GeoDB

See merge request atlas/athena!38926
parents a00a42cc e40ce6ea
No related branches found
No related tags found
No related merge requests found
Showing
with 244 additions and 452 deletions
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from PyUtils.MetaReader import read_metadata from PyUtils.MetaReader import read_metadata
from AtlasGeoModel.AtlasGeoDBInterface import AtlasGeoDBInterface from AtlasGeoModel.AtlasGeoDBInterface import AtlasGeoDBInterface
from AthenaCommon.Logging import logging
from functools import lru_cache
#Module level cache of file-metadata: msg = logging.getLogger('AutoConfigFlags')
_fileMetaData=dict()
#Module level cache of DDDB cursor
_dbGeomCursor = 0
#Module level dictionary of DDDB information:
_detDescrInfo = dict()
# Module level cache of file-metadata:
_fileMetaData = dict()
def GetFileMD(filenames): def GetFileMD(filenames):
from AthenaCommon.Logging import logging
msg = logging.getLogger('AutoConfigFlags')
filename=filenames[0] filename=filenames[0]
if filename == '_ATHENA_GENERIC_INPUTFILE_NAME_': if filename == '_ATHENA_GENERIC_INPUTFILE_NAME_':
raise RuntimeError('Input file name not set, instead _ATHENA_GENERIC_INPUTFILE_NAME_ found. Cannot read metadata.') raise RuntimeError('Input file name not set, instead _ATHENA_GENERIC_INPUTFILE_NAME_ found. Cannot read metadata.')
...@@ -31,171 +26,31 @@ def GetFileMD(filenames): ...@@ -31,171 +26,31 @@ def GetFileMD(filenames):
return _fileMetaData[filename] return _fileMetaData[filename]
def initializeGeometryParameters(): def _initializeGeometryParameters(geoTag):
# ---------------------------------------------------------------------------- """Read geometry database for all detetors"""
# Connect to database
from AtlasGeoModel import CommonGeoDB
bVerbose = False from PixelGeoModel import PixelGeoDB
_dbGeomCursor = AtlasGeoDBInterface(_detDescrInfo["geomTag"],bVerbose) from LArGeoAlgsNV import LArGeoDB
_dbGeomCursor.ConnectAndBrowseGeoDB() from MuonGeoModel import MuonGeoDB
# ---------------------------------------------------------------------------- dbGeomCursor = AtlasGeoDBInterface(geoTag)
# Read version name, layout and dbm from AtlasCommon table dbGeomCursor.ConnectAndBrowseGeoDB()
dbId,dbCommon,dbParam = _dbGeomCursor.GetCurrentLeafContent("AtlasCommon")
_run = "UNDEFINED"
_geotype = "UNDEFINED"
_stripgeotype = "UNDEFINED"
if len(dbId)>0:
key=dbId[0]
if "CONFIG" in dbParam :
_run = dbCommon[key][dbParam.index("CONFIG")]
if "GEOTYPE" in dbParam :
_geotype = dbCommon[key][dbParam.index("GEOTYPE")]
if "STRIPGEOTYPE" in dbParam :
_stripgeotype = dbCommon[key][dbParam.index("STRIPGEOTYPE")]
_detDescrInfo["Run"]=_run
_detDescrInfo["GeoType"]=_geotype
_detDescrInfo["StripGeoType"]=_stripgeotype
# ----------------------------------------------------------------------------
# Read version name, layout and dbm from PixelSwitches table
dbId,dbSwitches,dbParam = _dbGeomCursor.GetCurrentLeafContent("PixelSwitches")
_versionName="UNDEFINED"
_layout="UNDEFINED"
_dbm = False
if len(dbId)>0:
key=dbId[0]
if "VERSIONNAME" in dbParam:
_versionName = dbSwitches[key][dbParam.index("VERSIONNAME")]
if "LAYOUT" in dbParam :
_layout = dbSwitches[key][dbParam.index("LAYOUT")]
if "BUILDDBM" in dbParam :
_dbm = (dbSwitches[key][dbParam.index("BUILDDBM")] != 0)
_detDescrInfo["VersionName"] = _versionName
_detDescrInfo["Layout"] = _layout
_detDescrInfo["DBM"] = _dbm
# ----------------------------------------------------------------------------
# IBL layout
dbId,dbLayers,dbParam = _dbGeomCursor.GetCurrentLeafContent("PixelLayer")
IBLStaveIndex = -1
IBLgeoLayout = -1
_IBLlayout = "noIBL"
if len(dbId)>0:
key=dbId[0]
if "STAVEINDEX" in dbParam and dbLayers[key][dbParam.index("STAVEINDEX")] not in ["NULL",None]:
IBLStaveIndex = int(dbLayers[key][dbParam.index("STAVEINDEX")])
if IBLStaveIndex>-1:
dbId,dbStaves,dbParam = _dbGeomCursor.GetCurrentLeafContent("PixelStave")
if len(dbId)>0 and IBLStaveIndex<=len(dbStaves.keys()):
key=dbId[IBLStaveIndex]
if "LAYOUT" in dbParam and dbStaves[key][dbParam.index("LAYOUT")] not in ["NULL",None]:
IBLgeoLayout = int(dbStaves[key][dbParam.index("LAYOUT")])
if IBLgeoLayout in [3,4] :
_IBLlayout = "planar"
elif IBLgeoLayout in [5] :
_IBLlayout = "3D"
_detDescrInfo["IBLlayout"]=_IBLlayout
# ----------------------------------------------------------------------------
# IBL and SLHC parameters
_detDescrInfo["IBL"] = False
_detDescrInfo["SLHC"] = False
if _layout in ['IBL'] :
_detDescrInfo["IBL"] = True
if _detDescrInfo["IBL"] is False:
_detDescrInfo["IBLlayout"] = "noIBL"
if _layout not in ['SLHC'] and ( _detDescrInfo["Run"] in ["RUN2", "RUN3"] ) :
_detDescrInfo["IBL"] = True
if _layout in ['SLHC'] :
_detDescrInfo["SLHC"] = True
# ----------------------------------------------------------------------------
# Read version name, layout and dbm from LArSwitches table
dbId,dbSwitches,dbParam = _dbGeomCursor.GetCurrentLeafContent("LArSwitches")
_sagging = None
_barrelOn = None
_endcapOn = None
_FCalFlag="UNDEFINED"
_detAbsorber = None
_detAbsorber_EC = None
if len(dbId)>0:
key=dbId[0]
if "SAGGING" in dbParam:
_sagging = dbSwitches[key][dbParam.index("SAGGING")]
if "BARREL_ON" in dbParam:
_barrelOn = dbSwitches[key][dbParam.index("BARREL_ON")]
if "ENDCAP_ON" in dbParam :
_endcapOn = dbSwitches[key][dbParam.index("ENDCAP_ON")]
if "DETAILED_ABSORBER" in dbParam :
_detAbsorber = dbSwitches[key][dbParam.index("DETAILED_ABSORBER")]
if "DETAILED_ABSORBER_EC" in dbParam :
_detAbsorber_EC = dbSwitches[key][dbParam.index("DETAILED_ABSORBER_EC")]
if "FCAL_GEOTYPE" in dbParam :
_FCalFlag = dbSwitches[key][dbParam.index("FCAL_GEOTYPE")]
_detDescrInfo["Sagging"] = _sagging
_detDescrInfo["BarrelOn"] = _barrelOn
_detDescrInfo["EndcapOn"] = _endcapOn
_detDescrInfo["FCal_GeoType"] = _FCalFlag
_detDescrInfo["DetAbs"] = _detAbsorber
_detDescrInfo["DetAbs_EC"] = _detAbsorber_EC
# ------------------------------------------------------------------------
# Muon geometry flag initi
dbId,dbSwitches,dbParam = _dbGeomCursor.GetCurrentLeafContent("MuonSwitches")
_layoutName=None
_hasCsc=True
_hasStgc=True
_hasMM=True
if len(dbId)>0:
key=dbId[0]
if "LAYOUTNAME" in dbParam:
_layoutName = dbSwitches[key][dbParam.index("LAYOUTNAME")]
if "HASCSC" in dbParam:
_hasCsc = dbSwitches[key][dbParam.index("HASCSC")]
if "HASSTGC" in dbParam:
_hasStgc = dbSwitches[key][dbParam.index("HASSTGC")]
if "HASMM" in dbParam:
_hasMM = dbSwitches[key][dbParam.index("HASMM")]
_detDescrInfo["MuonLayout"] = (_layoutName if _layoutName else "UNDEFINED")
if _hasCsc == 0:
_detDescrInfo["HasCSC"] = False
else:
_detDescrInfo["HasCSC"] = True
if _hasStgc == 0:
_detDescrInfo["HasSTGC"] = False
else:
_detDescrInfo["HasSTGC"] = True
if _hasMM == 0:
_detDescrInfo["HasMM"] = False
else:
_detDescrInfo["HasMM"] = True
return
# FIXME: geometry parameter names need to be unique across systems!
params = {}
params.update(CommonGeoDB.InitializeGeometryParameters(dbGeomCursor))
params.update(PixelGeoDB.InitializeGeometryParameters(dbGeomCursor))
params.update(LArGeoDB.InitializeGeometryParameters(dbGeomCursor))
params.update(MuonGeoDB.InitializeGeometryParameters(dbGeomCursor))
return params
@lru_cache(maxsize=4) # maxsize=1 should be enough for most jobs
def GetDetDescrInfo(geoTag): def GetDetDescrInfo(geoTag):
if _dbGeomCursor == 0: """Query geometry DB for detector description"""
# set geometry tag name
_detDescrInfo["geomTag"] = geoTag detDescrInfo = _initializeGeometryParameters(geoTag)
initializeGeometryParameters() detDescrInfo["geomTag"] = geoTag
return _detDescrInfo return detDescrInfo
# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# #
# Common Geometry job property base class # Common Geometry job property base class
...@@ -8,66 +8,7 @@ from AthenaCommon.GlobalFlags import globalflags ...@@ -8,66 +8,7 @@ from AthenaCommon.GlobalFlags import globalflags
from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties
from AthenaCommon import Logging from AthenaCommon import Logging
from AtlasGeoModel.AtlasGeoDBInterface import AtlasGeoDBInterface from AtlasGeoModel.AtlasGeoDBInterface import AtlasGeoDBInterface
from AtlasGeoModel import CommonGeoDB
class CommonGMFlags:
def __init__(self, geoTag="none"):
self.__dict__={}
# set geometry tag name
self.__dict__["geomTag"]= globalflags.DetDescrVersion()
if geoTag!="none": self.__dict__["geomTag"] = geoTag
self.dbGeomCursor = 0
self.connectToDB()
self.InitializeGeometryParameters()
def connectToDB(self):
bVerbose=False
self.dbGeomCursor = AtlasGeoDBInterface(self.__dict__["geomTag"],bVerbose)
self.dbGeomCursor.ConnectAndBrowseGeoDB()
return
def InitializeGeometryParameters(self):
# ----------------------------------------------------------------------------
# Read versionname, layout and dbm from AtlasCommon table
dbId,dbCommon,dbParam = self.dbGeomCursor.GetCurrentLeafContent("AtlasCommon")
_run = "UNDEFINED"
_geotype = "UNDEFINED"
_stripgeotype = "UNDEFINED"
if len(dbId)>0:
key=dbId[0]
if "CONFIG" in dbParam : _run = dbCommon[key][dbParam.index("CONFIG")]
if "GEOTYPE" in dbParam : _geotype = dbCommon[key][dbParam.index("GEOTYPE")]
if "STRIPGEOTYPE" in dbParam : _stripgeotype = dbCommon[key][dbParam.index("STRIPGEOTYPE")]
self.__dict__["Run"]=_run
self.__dict__["GeoType"]=_geotype
self.__dict__["StripGeoType"]=_stripgeotype
def getValue(self,name):
return self.__dict__[name]
def dump(self):
Logging.log.info("Geometry tag CommonGMFlags : "+self.__dict__["geomTag"]+" ------------------------------------")
Logging.log.info("RUN flag : "+self.__dict__["Run"])
Logging.log.info("GeoType flag : "+self.__dict__["GeoType"])
Logging.log.info("Strip GeoType flag : "+self.__dict__["StripGeoType"])
# ------------------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------------------
# Geometry jobproperties defined for the common geometry (invented by the ID - no calo and muon specific flags ...) # Geometry jobproperties defined for the common geometry (invented by the ID - no calo and muon specific flags ...)
...@@ -100,16 +41,18 @@ class CommonGeometryFlags_JobProperties(JobPropertyContainer): ...@@ -100,16 +41,18 @@ class CommonGeometryFlags_JobProperties(JobPropertyContainer):
return return
def setupValuesFromDB(self,geoTagName="none"): def setupValuesFromDB(self, geoTagName=None):
CommonGeoFlags = CommonGMFlags(geoTagName) dbGeomCursor = AtlasGeoDBInterface(geoTagName or globalflags.DetDescrVersion())
dbGeomCursor.ConnectAndBrowseGeoDB()
params = CommonGeoDB.InitializeGeometryParameters(dbGeomCursor)
self.Run.set_Value_and_Lock(CommonGeoFlags.getValue("Run")) self.Run.set_Value_and_Lock(params["Run"])
self.GeoType.set_Value_and_Lock(CommonGeoFlags.getValue("GeoType")) self.GeoType.set_Value_and_Lock(params["GeoType"])
self.StripGeoType.set_Value_and_Lock(CommonGeoFlags.getValue("StripGeoType")) self.StripGeoType.set_Value_and_Lock(params["StripGeoType"])
def reset(self,geoTagName="none"): def reset(self):
self.Run.unlock() self.Run.unlock()
self.GeoType.unlock() self.GeoType.unlock()
...@@ -118,9 +61,9 @@ class CommonGeometryFlags_JobProperties(JobPropertyContainer): ...@@ -118,9 +61,9 @@ class CommonGeometryFlags_JobProperties(JobPropertyContainer):
def dump(self): def dump(self):
Logging.log.info("RUN flag :"+self.Run()) Logging.log.info("RUN flag : %s", self.Run())
Logging.log.info("GeoType flag : "+self.GeoType()) Logging.log.info("GeoType flag : %s", self.GeoType())
Logging.log.info("Strip geoType flag : "+self.StripGeoType()) Logging.log.info("Strip geoType flag : %s", self.StripGeoType())
jobproperties.add_Container(CommonGeometryFlags_JobProperties) jobproperties.add_Container(CommonGeometryFlags_JobProperties)
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
def InitializeGeometryParameters(dbGeomCursor):
"""Read version name, layout and dbm from AtlasCommon table.
dbGeomCursor: AtlasGeoDBInterface instance
"""
dbId, dbCommon, dbParam = dbGeomCursor.GetCurrentLeafContent("AtlasCommon")
params = {"Run" : "UNDEFINED",
"GeoType" : "UNDEFINED",
"StripGeoType" : "UNDEFINED"}
if len(dbId)>0:
key = dbId[0]
if "CONFIG" in dbParam :
params["Run"] = dbCommon[key][dbParam.index("CONFIG")]
if "GEOTYPE" in dbParam :
params["GeoType"] = dbCommon[key][dbParam.index("GEOTYPE")]
if "STRIPGEOTYPE" in dbParam :
params["StripGeoType"] = dbCommon[key][dbParam.index("STRIPGEOTYPE")]
return params
...@@ -3,89 +3,12 @@ ...@@ -3,89 +3,12 @@
# #
# InDet GeoModel initialization # InDet GeoModel initialization
# #
from AthenaCommon.GlobalFlags import globalflags
from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties
from AtlasGeoModel.CommonGMJobProperties import CommonGMFlags, CommonGeometryFlags from AtlasGeoModel.AtlasGeoDBInterface import AtlasGeoDBInterface
from PixelGeoModel import PixelGeoDB
from AthenaCommon import Logging from AthenaCommon import Logging
# -------------------------------------------------------------------------------------
# InDet geometry flags initialization
# -------------------------------------------------------------------------------------
class InDetGMFlags(CommonGMFlags, object):
def __init__(self, geoTag="none"):
super(InDetGMFlags, self).__init__()
def InitializeGeometryParameters(self):
# ----------------------------------------------------------------------------
# Read versionname, layout and dbm from PixelSwicthes table
dbId,dbSwitches,dbParam = self.dbGeomCursor.GetCurrentLeafContent("PixelSwitches")
_versionName="UNDEFINED"
_layout="UNDEFINED"
_dbm = False
if len(dbId)>0:
key=dbId[0]
if "VERSIONNAME" in dbParam: _versionName = dbSwitches[key][dbParam.index("VERSIONNAME")]
if "LAYOUT" in dbParam : _layout = dbSwitches[key][dbParam.index("LAYOUT")]
if "BUILDDBM" in dbParam : _dbm = (dbSwitches[key][dbParam.index("BUILDDBM")] != 0)
self.__dict__["VersionName"] = _versionName
self.__dict__["Layout"] = _layout
self.__dict__["DBM"] = _dbm
# ----------------------------------------------------------------------------
# IBL layout
dbId,dbLayers,dbParam = self.dbGeomCursor.GetCurrentLeafContent("PixelLayer")
IBLStaveIndex = -1
IBLgeoLayout = -1
_IBLlayout = "noIBL"
if len(dbId)>0:
key=dbId[0]
if "STAVEINDEX" in dbParam and dbLayers[key][dbParam.index("STAVEINDEX")] not in ["NULL",None]:
IBLStaveIndex = int(dbLayers[key][dbParam.index("STAVEINDEX")])
if IBLStaveIndex>-1:
dbId,dbStaves,dbParam = self.dbGeomCursor.GetCurrentLeafContent("PixelStave")
if len(dbId)>0 and IBLStaveIndex<=len(dbStaves.keys()):
key=dbId[IBLStaveIndex]
if "LAYOUT" in dbParam and dbStaves[key][dbParam.index("LAYOUT")] not in ["NULL",None]:
IBLgeoLayout = int(dbStaves[key][dbParam.index("LAYOUT")])
if IBLgeoLayout in [3,4] : _IBLlayout = "planar"
elif IBLgeoLayout in [5] : _IBLlayout = "3D"
self.__dict__["IBLlayout"]=_IBLlayout
# ----------------------------------------------------------------------------
# IBL and SLHC parameters
self.__dict__["IBL"] = False
self.__dict__["SLHC"] = False
if _layout in ['IBL'] : self.__dict__["IBL"] = True
if self.__dict__["IBL"] is False: self.__dict__["IBLlayout"]="noIBL"
if _layout not in ['SLHC'] and ( CommonGeometryFlags.Run() in ["RUN2", "RUN3"] ) : self.__dict__["IBL"] = True
if _layout in ['SLHC'] : self.__dict__["SLHC"] = True
def dump(self):
Logging.log.info("Geometry tag InDetGMFlags : %s", self.__dict__["geomTag"]+" ------------------------------------")
Logging.log.info("VersionName = %s", self.__dict__["VersionName"])
Logging.log.info("Layout = %s", self.__dict__["Layout"])
Logging.log.info("DBM = %s", self.__dict__["DBM"])
Logging.log.info("SLHC flag : %s", self.__dict__["SLHC"])
Logging.log.info("IBL flag : %s", self.__dict__["IBL"])
Logging.log.info("IBL layout : %s", self.__dict__["IBLlayout"])
# ------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------
# Geometry jobproperties defined for the InDet geometry # Geometry jobproperties defined for the InDet geometry
...@@ -144,16 +67,18 @@ class InDetGeometryFlags_JobProperties(JobPropertyContainer): ...@@ -144,16 +67,18 @@ class InDetGeometryFlags_JobProperties(JobPropertyContainer):
JobPropertyContainer.__init__(self,context) JobPropertyContainer.__init__(self,context)
return return
def setupValuesFromDB(self,geoTagName="none"): def setupValuesFromDB(self,geoTagName=None):
InDetGeoFlags = InDetGMFlags(geoTagName) dbGeomCursor = AtlasGeoDBInterface(geoTagName or globalflags.DetDescrVersion())
dbGeomCursor.ConnectAndBrowseGeoDB()
self.isSLHC.set_Value_and_Lock( InDetGeoFlags.getValue("SLHC") ) params = PixelGeoDB.InitializeGeometryParameters(dbGeomCursor)
self.isIBL.set_Value_and_Lock(InDetGeoFlags.getValue("IBL"))
self.isDBM.set_Value_and_Lock(InDetGeoFlags.getValue("DBM")) self.isSLHC.set_Value_and_Lock(params["SLHC"] )
self.IBLLayout.set_Value_and_Lock(InDetGeoFlags.getValue("IBLlayout")) self.isIBL.set_Value_and_Lock(params["IBL"] )
self.GeoVersionName.set_Value_and_Lock(InDetGeoFlags.getValue("VersionName")) self.isDBM.set_Value_and_Lock(params["DBM"])
self.GeoLayout.set_Value_and_Lock(InDetGeoFlags.getValue("Layout")) self.IBLLayout.set_Value_and_Lock(params["IBLlayout"])
self.GeoVersionName.set_Value_and_Lock(params["VersionName"])
self.GeoLayout.set_Value_and_Lock(params["Layout"])
def reset(self,geoTagName="none"): def reset(self,geoTagName="none"):
......
# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# #
# LAr GeoModel initialization # LAr GeoModel initialization
# #
from AthenaCommon.GlobalFlags import globalflags
from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties
from AtlasGeoModel.CommonGMJobProperties import CommonGMFlags
from AthenaCommon import Logging from AthenaCommon import Logging
from AtlasGeoModel.AtlasGeoDBInterface import AtlasGeoDBInterface
# ------------------------------------------------------------------------------------- from LArGeoAlgsNV import LArGeoDB
# LAr geometry flags initialization
# -------------------------------------------------------------------------------------
class LArGMFlags(CommonGMFlags, object):
def __init__(self, geoTag="none"):
super(LArGMFlags, self).__init__()
def InitializeGeometryParameters(self):
# ----------------------------------------------------------------------------
# Read versionname, layout and dbm from PixelSwicthes table
dbId,dbSwitches,dbParam = self.dbGeomCursor.GetCurrentLeafContent("LArSwitches")
_sagging = None
_barrelOn = None
_endcapOn = None
_FCalFlag="UNDEFINED"
_detAbsorber = None
_detAbsorber_EC = None
if len(dbId)>0:
key=dbId[0]
if "SAGGING" in dbParam: _sagging = dbSwitches[key][dbParam.index("SAGGING")]
if "BARREL_ON" in dbParam: _barrelOn = dbSwitches[key][dbParam.index("BARREL_ON")]
if "ENDCAP_ON" in dbParam : _endcapOn = dbSwitches[key][dbParam.index("ENDCAP_ON")]
if "DETAILED_ABSORBER" in dbParam : _detAbsorber = dbSwitches[key][dbParam.index("DETAILED_ABSORBER")]
if "DETAILED_ABSORBER_EC" in dbParam :_detAbsorber_EC = dbSwitches[key][dbParam.index("DETAILED_ABSORBER_EC")]
if "FCAL_GEOTYPE" in dbParam : _FCalFlag = dbSwitches[key][dbParam.index("FCAL_GEOTYPE")]
self.__dict__["Sagging"] = _sagging
self.__dict__["BarrelOn"] = _barrelOn
self.__dict__["EndcapOn"] = _endcapOn
self.__dict__["FCal_GeoType"] = _FCalFlag
self.__dict__["DetAbs"] = _detAbsorber
self.__dict__["DetAbs_EC"] = _detAbsorber_EC
def dump(self):
Logging.log.info("Geometry tag LArGMFlags : "+self.__dict__["geomTag"]+" ------------------------------------")
Logging.log.info("Sagging = "+self.__dict__["Sagging"])
Logging.log.info("BarrelOn = "+self.__dict__["BarrelOn"])
Logging.log.info("EndcapON = "+self.__dict__["EndcapOn"])
Logging.log.info("Detailed Absorber = "+self.__dict__["DetAbs"])
Logging.log.info("Detailed Absorber EC = "+self.__dict__["DetAbs_EC"])
Logging.log.info("FCal geotype = "+self.__dict__["FCal_GeoType"])
# ------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------
# Geometry jobproperties defined for the InDet geometry # Geometry jobproperties defined for the InDet geometry
...@@ -108,19 +58,21 @@ class LArGeometryFlags_JobProperties(JobPropertyContainer): ...@@ -108,19 +58,21 @@ class LArGeometryFlags_JobProperties(JobPropertyContainer):
JobPropertyContainer.__init__(self,context) JobPropertyContainer.__init__(self,context)
return return
def setupValuesFromDB(self,geoTagName="none"): def setupValuesFromDB(self,geoTagName=None):
LArGeoFlags = LArGMFlags(geoTagName) dbGeomCursor = AtlasGeoDBInterface(geoTagName or globalflags.DetDescrVersion())
dbGeomCursor.ConnectAndBrowseGeoDB()
params = LArGeoDB.InitializeGeometryParameters(dbGeomCursor)
self.Sagging.set_Value_and_Lock( LArGeoFlags.getValue("Sagging")) self.Sagging.set_Value_and_Lock(params["Sagging"])
self.BarrelOn.set_Value_and_Lock( LArGeoFlags.getValue("BarrelOn")) self.BarrelOn.set_Value_and_Lock(params["BarrelOn"])
self.EndcapOn.set_Value_and_Lock(LArGeoFlags.getValue("EndcapOn")) self.EndcapOn.set_Value_and_Lock(params["EndcapOn"])
self.DetailedAbsorber.set_Value_and_Lock(LArGeoFlags.getValue("DetAbs")) self.DetailedAbsorber.set_Value_and_Lock(params["DetAbs"])
self.DetailedAbsorber_EC.set_Value_and_Lock(LArGeoFlags.getValue("DetAbs_EC")) self.DetailedAbsorber_EC.set_Value_and_Lock(params["DetAbs_EC"])
self.FCalGeoType.set_Value_and_Lock(LArGeoFlags.getValue("FCal_GeoType")) self.FCalGeoType.set_Value_and_Lock(params["FCal_GeoType"])
def reset(self,geoTagName="none"): def reset(self):
self.Sagging.unlock() self.Sagging.unlock()
self.BarrelOn.unlock() self.BarrelOn.unlock()
...@@ -131,13 +83,13 @@ class LArGeometryFlags_JobProperties(JobPropertyContainer): ...@@ -131,13 +83,13 @@ class LArGeometryFlags_JobProperties(JobPropertyContainer):
def dump(self): def dump(self):
Logging.log.info("Sagging = "+self.Sagging()) Logging.log.info("Sagging = %s", self.Sagging())
Logging.log.info("Barrel_On = "+self.BarrelOn()) Logging.log.info("Barrel_On = %s", self.BarrelOn())
Logging.log.info("Endcap_On = "+self.EndcapOn()) Logging.log.info("Endcap_On = %s", self.EndcapOn())
Logging.log.info("Detailed absorber = "+self.DetailedAbsorber()) Logging.log.info("Detailed absorber = %s", self.DetailedAbsorber())
Logging.log.info("Detailed absorber EC = "+self.DetailedAbsorber_EC()) Logging.log.info("Detailed absorber EC = %s", self.DetailedAbsorber_EC())
Logging.log.info("FCal GeoType = "+self.FCalGeoType()) Logging.log.info("FCal GeoType = %s", self.FCalGeoType())
jobproperties.add_Container(LArGeometryFlags_JobProperties) jobproperties.add_Container(LArGeometryFlags_JobProperties)
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from AthenaCommon.GlobalFlags import globalflags
from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties
from AtlasGeoModel.CommonGMJobProperties import CommonGMFlags from AtlasGeoModel.AtlasGeoDBInterface import AtlasGeoDBInterface
from MuonGeoModel import MuonGeoDB
# ------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------
# Muon geometry flags initialization # Muon geometry flags
# ------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------
class MuonGMFlags(CommonGMFlags, object):
def __init__(self, geoTag="none"):
super(MuonGMFlags, self).__init__()
def InitializeGeometryParameters(self):
dbId,dbSwitches,dbParam = self.dbGeomCursor.GetCurrentLeafContent("MuonSwitches")
_layoutName=None
_hasCsc=True
_hasStgc=True
_hasMM=True
if len(dbId)>0:
key=dbId[0]
if "LAYOUTNAME" in dbParam: _layoutName = dbSwitches[key][dbParam.index("LAYOUTNAME")]
if "HASCSC" in dbParam: _hasCsc = dbSwitches[key][dbParam.index("HASCSC")]
if "HASSTGC" in dbParam: _hasStgc = dbSwitches[key][dbParam.index("HASSTGC")]
if "HASMM" in dbParam: _hasMM = dbSwitches[key][dbParam.index("HASMM")]
self.__dict__["Layout"] = (_layoutName if _layoutName else "UNDEFINED")
if _hasCsc == 0: self.__dict__["HasCSC"] = False
else: self.__dict__["HasCSC"] = True
if _hasStgc == 0: self.__dict__["HasSTGC"] = False
else: self.__dict__["HasSTGC"] = True
if _hasMM == 0: self.__dict__["HasMM"] = False
else: self.__dict__["HasMM"] = True
def dump(self):
print ("MuonGMFlags:")
print ("Layout = ",self.__dict__["Layout"])
print ("HasCSC = ",self.__dict__["HasCSC"])
print ("HasSTGC = ",self.__dict__["HasSTGC"])
print ("HasMM = ",self.__dict__["HasMM"])
class GeoLayout(JobProperty): class GeoLayout(JobProperty):
""" geometry layout """ """ geometry layout """
...@@ -70,14 +39,18 @@ class MuonGeometryFlags_JobProperties(JobPropertyContainer): ...@@ -70,14 +39,18 @@ class MuonGeometryFlags_JobProperties(JobPropertyContainer):
def __init__(self, context=""): def __init__(self, context=""):
JobPropertyContainer.__init__(self,context) JobPropertyContainer.__init__(self,context)
return return
def setupValuesFromDB(self,geoTagName="none"): def setupValuesFromDB(self,geoTagName=None):
MuonGeoFlags = MuonGMFlags(geoTagName)
self.GeoLayout.set_Value_and_Lock(MuonGeoFlags.getValue("Layout")) dbGeomCursor = AtlasGeoDBInterface(geoTagName or globalflags.DetDescrVersion())
self.hasCSC.set_Value_and_Lock(MuonGeoFlags.getValue("HasCSC")) dbGeomCursor.ConnectAndBrowseGeoDB()
self.hasSTGC.set_Value_and_Lock(MuonGeoFlags.getValue("HasSTGC")) params = MuonGeoDB.InitializeGeometryParameters(dbGeomCursor)
self.hasMM.set_Value_and_Lock(MuonGeoFlags.getValue("HasMM"))
self.GeoLayout.set_Value_and_Lock(params["Layout"])
def reset(self,geoTagName="none"): self.hasCSC.set_Value_and_Lock(params["HasCSC"])
self.hasSTGC.set_Value_and_Lock(params["HasSTGC"])
self.hasMM.set_Value_and_Lock(params["HasMM"])
def reset(self):
self.GeoLayout.unlock() self.GeoLayout.unlock()
self.hasCSC.unlock() self.hasCSC.unlock()
self.hasSTGC.unlock() self.hasSTGC.unlock()
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from AtlasGeoModel.CommonGMJobProperties import CommonGeometryFlags
def InitializeGeometryParameters(dbGeomCursor):
"""Read geometry parameters for Pixel
dbGeomCursor: AtlasGeoDBInterface instance
"""
# ----------------------------------------------------------------------------
# Read versionname, layout and dbm from PixelSwitches table
dbId,dbSwitches,dbParam = dbGeomCursor.GetCurrentLeafContent("PixelSwitches")
params = {"VersionName" : "UNDEFINED",
"Layout" : "UNDEFINED",
"DBM" : False }
if len(dbId)>0:
key=dbId[0]
if "VERSIONNAME" in dbParam:
params["VersionName"] = dbSwitches[key][dbParam.index("VERSIONNAME")]
if "LAYOUT" in dbParam :
params["Layout"] = dbSwitches[key][dbParam.index("LAYOUT")]
if "BUILDDBM" in dbParam :
params["DBM"] = (dbSwitches[key][dbParam.index("BUILDDBM")] != 0)
# ----------------------------------------------------------------------------
# IBL layout
dbId,dbLayers,dbParam = dbGeomCursor.GetCurrentLeafContent("PixelLayer")
IBLStaveIndex = -1
IBLgeoLayout = -1
params["IBLlayout"] = "noIBL"
if len(dbId)>0:
key=dbId[0]
if "STAVEINDEX" in dbParam and dbLayers[key][dbParam.index("STAVEINDEX")] not in ["NULL",None]:
IBLStaveIndex = int(dbLayers[key][dbParam.index("STAVEINDEX")])
if IBLStaveIndex>-1:
dbId,dbStaves,dbParam = dbGeomCursor.GetCurrentLeafContent("PixelStave")
if len(dbId)>0 and IBLStaveIndex<=len(dbStaves.keys()):
key=dbId[IBLStaveIndex]
if "LAYOUT" in dbParam and dbStaves[key][dbParam.index("LAYOUT")] not in ["NULL",None]:
IBLgeoLayout = int(dbStaves[key][dbParam.index("LAYOUT")])
if IBLgeoLayout in [3,4] : params["IBLlayout"] = "planar"
elif IBLgeoLayout in [5] : params["IBLlayout"] = "3D"
# ----------------------------------------------------------------------------
# IBL and SLHC parameters
params["IBL"] = (params["Layout"] == 'IBL')
params["SLHC"] = (params["Layout"] == 'SLHC')
if params["IBL"] is False:
params["IBLlayout"] = "noIBL"
if params["Layout"]!='SLHC' and ( CommonGeometryFlags.Run() in ["RUN2", "RUN3"] ) :
params["IBL"] = True
return params
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
def InitializeGeometryParameters(dbGeomCursor):
"""Read versionname, layout and dbm from LArSwitches table
dbGeomCursor: AtlasGeoDBInterface instance
"""
dbId, dbSwitches, dbParam = dbGeomCursor.GetCurrentLeafContent("LArSwitches")
params = {"Sagging" : None,
"BarrelOn" : None,
"EndcapOn" : None,
"FCal_GeoType" : "UNDEFINED",
"DetAbs" : None,
"DetAbs_EC" : None}
if len(dbId)>0:
key=dbId[0]
if "SAGGING" in dbParam:
params["Sagging"] = dbSwitches[key][dbParam.index("SAGGING")]
if "BARREL_ON" in dbParam:
params["BarrelOn"] = dbSwitches[key][dbParam.index("BARREL_ON")]
if "ENDCAP_ON" in dbParam :
params["EndcapOn"] = dbSwitches[key][dbParam.index("ENDCAP_ON")]
if "DETAILED_ABSORBER" in dbParam :
params["DetAbs"] = dbSwitches[key][dbParam.index("DETAILED_ABSORBER")]
if "DETAILED_ABSORBER_EC" in dbParam :
params["DetAbs_EC"] = dbSwitches[key][dbParam.index("DETAILED_ABSORBER_EC")]
if "FCAL_GEOTYPE" in dbParam :
params["FCal_GeoType"] = dbSwitches[key][dbParam.index("FCAL_GEOTYPE")]
return params
...@@ -21,5 +21,5 @@ atlas_add_component( MuonGeoModel ...@@ -21,5 +21,5 @@ atlas_add_component( MuonGeoModel
LINK_LIBRARIES ${GEOMODELCORE_LIBRARIES} AthenaKernel StoreGateLib SGtests GeoModelUtilities GaudiKernel MuonCondInterface MuonReadoutGeometry MuonGMdbObjects AthenaPoolUtilities AGDDKernel IdDictDetDescr MuonAGDDDescription MuonDetDescrUtils MuonIdHelpersLib MuonGeoModelLib AmdcDbLib ) LINK_LIBRARIES ${GEOMODELCORE_LIBRARIES} AthenaKernel StoreGateLib SGtests GeoModelUtilities GaudiKernel MuonCondInterface MuonReadoutGeometry MuonGMdbObjects AthenaPoolUtilities AGDDKernel IdDictDetDescr MuonAGDDDescription MuonDetDescrUtils MuonIdHelpersLib MuonGeoModelLib AmdcDbLib )
# Install files from the package: # Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
atlas_install_joboptions( share/*.py ) atlas_install_joboptions( share/*.py )
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
def InitializeGeometryParameters(dbGeomCursor):
"""Read muon geometry parameters
dbGeomCursor: AtlasGeoDBInterface instance
"""
dbId, dbSwitches, dbParam = dbGeomCursor.GetCurrentLeafContent("MuonSwitches")
params = {"Layout" : "UNDEFINED",
"HasCSC" : True,
"HasSTGC" : True,
"HasMM" : True}
if len(dbId)>0:
key=dbId[0]
if "LAYOUTNAME" in dbParam:
params["Layout"] = dbSwitches[key][dbParam.index("LAYOUTNAME")]
if "HASCSC" in dbParam:
params["HasCSC"] = (dbSwitches[key][dbParam.index("HASCSC")] != 0)
if "HASSTGC" in dbParam:
params["HasSTGC"] = (dbSwitches[key][dbParam.index("HASSTGC")] !=0)
if "HASMM" in dbParam:
params["HasMM"] = (dbSwitches[key][dbParam.index("HASMM")] != 0)
return params
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment