diff --git a/Control/AthenaConfiguration/python/AllConfigFlags.py b/Control/AthenaConfiguration/python/AllConfigFlags.py index 2f509675efde3653835ba9ecb673acc9c06f7b66..a6e32f48fb26e04056c964e8c8366e89656bce71 100644 --- a/Control/AthenaConfiguration/python/AllConfigFlags.py +++ b/Control/AthenaConfiguration/python/AllConfigFlags.py @@ -4,7 +4,7 @@ from __future__ import print_function from AthenaConfiguration.AthConfigFlags import AthConfigFlags from AthenaCommon.SystemOfUnits import TeV -from AthenaConfiguration.AutoConfigFlags import GetFileMD +from AthenaConfiguration.AutoConfigFlags import GetFileMD, GetDetDescrInfo import six @@ -117,10 +117,10 @@ def _createCfgFlags(): acf.addFlag('GeoModel.Layout', 'atlas') # replaces global.GeoLayout acf.addFlag("GeoModel.AtlasVersion", lambda prevFlags : GetFileMD(prevFlags.Input.Files).get("GeoAtlas",None) or "ATLAS-R2-2016-01-00-01") # acf.addFlag("GeoModel.Align.Dynamic", lambda prevFlags : (not prevFlags.Detector.Simulate)) - acf.addFlag("GeoModel.StripGeoType", "GMX") # Based on CommonGeometryFlags.StripGeoType - acf.addFlag("GeoModel.Run","RUN2") # Based on CommonGeometryFlags.Run (InDetGeometryFlags.isSLHC replaced by GeoModel.Run=="RUN4") - acf.addFlag("GeoModel.Type", "UNDEFINED") # Geometry type in {ITKLoI, ITkLoI-VF, etc...} - acf.addFlag("GeoModel.IBLLayout", "UNDEFINED") # IBL layer layout in {"planar", "3D", "noIBL", "UNDEFINED"} + acf.addFlag("GeoModel.StripGeoType", lambda prevFlags : GetDetDescrInfo(prevFlags.GeoModel.AtlasVersion).get('StripGeoType',"GMX")) # Based on CommonGeometryFlags.StripGeoType + acf.addFlag("GeoModel.Run", lambda prevFlags : GetDetDescrInfo(prevFlags.GeoModel.AtlasVersion).get('Run',"RUN2")) # Based on CommonGeometryFlags.Run (InDetGeometryFlags.isSLHC replaced by GeoModel.Run=="RUN4") + acf.addFlag("GeoModel.Type", lambda prevFlags : GetDetDescrInfo(prevFlags.GeoModel.AtlasVersion).get('GeoType',"UNDEFINED")) # Geometry type in {ITKLoI, ITkLoI-VF, etc...} + acf.addFlag("GeoModel.IBLLayout", lambda prevFlags : GetDetDescrInfo(prevFlags.GeoModel.AtlasVersion).get('IBLlayout',"UNDEFINED")) # IBL layer layout in {"planar", "3D", "noIBL", "UNDEFINED"} #IOVDbSvc Flags: acf.addFlag("IOVDb.GlobalTag",lambda prevFlags : GetFileMD(prevFlags.Input.Files).get("IOVDbGlobalTag",None) or "CONDBR2-BLKPA-2017-05") diff --git a/Control/AthenaConfiguration/python/AutoConfigFlags.py b/Control/AthenaConfiguration/python/AutoConfigFlags.py index a9e23448e54b26f2516a61e7cd4e99722d279057..68613345a9be8b6180e0d5f62f736014727e8dc1 100644 --- a/Control/AthenaConfiguration/python/AutoConfigFlags.py +++ b/Control/AthenaConfiguration/python/AutoConfigFlags.py @@ -1,10 +1,18 @@ # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration from PyUtils.MetaReader import read_metadata +from AtlasGeoModel.AtlasGeoDBInterface import AtlasGeoDBInterface #Module level cache of file-metadata: _fileMetaData=dict() +#Module level cache of DDDB cursor +_dbGeomCursor = 0 + +#Module level dictionary of DDDB information: +_detDescrInfo = dict() + + def GetFileMD(filenames): from AthenaCommon.Logging import logging msg = logging.getLogger('AutoConfigFlags') @@ -19,4 +27,137 @@ def GetFileMD(filenames): _fileMetaData.update(thisFileMD) return _fileMetaData[filename] - + + +def initializeGeometryParameters(): + # ---------------------------------------------------------------------------- + # Connect to database + + bVerbose = False + _dbGeomCursor = AtlasGeoDBInterface(_detDescrInfo["geomTag"],bVerbose) + _dbGeomCursor.ConnectAndBrowseGeoDB() + + # ---------------------------------------------------------------------------- + # Read version name, layout and dbm from AtlasCommon table + + 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 + return + +def GetDetDescrInfo(geoTag): + if _dbGeomCursor == 0: + # set geometry tag name + _detDescrInfo["geomTag"] = geoTag + initializeGeometryParameters() + return _detDescrInfo diff --git a/Simulation/Digitization/test/DigitizationConfigNew_test.py b/Simulation/Digitization/test/DigitizationConfigNew_test.py index d4887cee62cc0a3ef2ff042f2daa0ba5e615619e..04b4bfdf06e33a5f7daf5b7c706b691719cc1d5b 100755 --- a/Simulation/Digitization/test/DigitizationConfigNew_test.py +++ b/Simulation/Digitization/test/DigitizationConfigNew_test.py @@ -31,7 +31,6 @@ ConfigFlags.Output.RDOFileName = "myRDO.pool.root" ConfigFlags.IOVDb.GlobalTag = "OFLCOND-MC16-SDR-16" ConfigFlags.GeoModel.Align.Dynamic = False ConfigFlags.Concurrency.NumThreads = 1 -ConfigFlags.GeoModel.Type = "BrlIncl4.0_ref" ConfigFlags.Beam.NumberOfCollisions = 0. ConfigFlags.lock() # Construct our accumulator to run