From 0a8300d18af883668746f8cc389954f8363f820c Mon Sep 17 00:00:00 2001 From: Dave Casper <dcasper@uci.edu> Date: Sat, 9 Oct 2021 20:54:04 +0200 Subject: [PATCH] Clean up and automate conditions DB generation --- .../python/GeoModelConfigFlags.py | 2 + .../GeoModelTest/CMakeLists.txt | 10 ++- ...odelTestConfig.py => Faser01TestConfig.py} | 6 +- .../GeoModelTest/python/Faser02TestConfig.py | 66 +++++++++++++++++ .../GeoModelTest/python/TestBeamTestConfig.py | 2 +- .../python/TrackerDataAccessExampleConfig.py | 8 +- .../python/TriggerDataAccessExampleConfig.py | 8 +- .../python/WaveformDataAccessExampleConfig.py | 8 +- ...fig.py => WriteAlignmentConfig_Faser01.py} | 21 +++--- .../python/WriteAlignmentConfig_Faser02.py | 73 +++++++++++++++++++ .../python/WriteAlignmentConfig_FaserTB00.py | 73 +++++++++++++++++++ .../WriteAlignment/scripts/CopyAlignFolder.sh | 19 ++++- .../WriteAlignment/src/WriteAlignmentAlg.cxx | 2 +- .../WriteAlignment/src/WriteAlignmentAlg.h | 7 ++ .../FaserAuthentication/data/dblookup.xml | 4 + .../src/TrackerAlignDBTool.cxx | 25 ++----- .../src/TrackerAlignDBTool.h | 4 +- .../FaserSCT_ConditionsData/CMakeLists.txt | 2 +- .../data/SCT_Conditions.py | 10 +++ .../python/FaserSCT_GeoModelConfig.py | 3 + .../src/SCT_DetectorFactory.cxx | 5 +- .../src/TrackerDetectorManager.cxx | 1 + 22 files changed, 315 insertions(+), 44 deletions(-) rename Control/CalypsoExample/GeoModelTest/python/{GeoModelTestConfig.py => Faser01TestConfig.py} (87%) create mode 100644 Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py rename Control/CalypsoExample/WriteAlignment/python/{WriteAlignmentConfig.py => WriteAlignmentConfig_Faser01.py} (73%) create mode 100644 Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser02.py create mode 100644 Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_FaserTB00.py diff --git a/Control/CalypsoConfiguration/python/GeoModelConfigFlags.py b/Control/CalypsoConfiguration/python/GeoModelConfigFlags.py index 448d65d8..69d280a8 100644 --- a/Control/CalypsoConfiguration/python/GeoModelConfigFlags.py +++ b/Control/CalypsoConfiguration/python/GeoModelConfigFlags.py @@ -10,6 +10,8 @@ def createGeoModelConfigFlags(): GetFileMD(prevFlags.Input.Files).get("GeoFaser",None)) or "FASER-01")) gcf.addFlag("GeoModel.GeoExportFile","") + gcf.addFlag("GeoModel.Align.Disable", False) # Hack to avoid loading alignment when we want to create it from scratch + return gcf diff --git a/Control/CalypsoExample/GeoModelTest/CMakeLists.txt b/Control/CalypsoExample/GeoModelTest/CMakeLists.txt index 5c420501..9db978f8 100644 --- a/Control/CalypsoExample/GeoModelTest/CMakeLists.txt +++ b/Control/CalypsoExample/GeoModelTest/CMakeLists.txt @@ -15,11 +15,17 @@ atlas_add_component( GeoModelTest INCLUDE_DIRS ${GEOMODEL_INCLUDE_DIRS} LINK_LIBRARIES ${GEOMODEL_LIBRARIES} AthenaBaseComps GeoModelFaserUtilities ScintReadoutGeometry TrackerReadoutGeometry MagFieldInterfaces MagFieldElements MagFieldConditions ) -atlas_add_test( GeoModelCheck - SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/GeoModelTestConfig.py +atlas_add_test( Faser01GeoCheck + SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/Faser01TestConfig.py PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR} PROPERTIES TIMEOUT 300 ) +atlas_add_test( Faser02GeoCheck + SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/Faser02TestConfig.py + PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + PROPERTIES TIMEOUT 300 ) + + atlas_add_test( TestBeamGeoCheck SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/TestBeamTestConfig.py PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR} diff --git a/Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py b/Control/CalypsoExample/GeoModelTest/python/Faser01TestConfig.py similarity index 87% rename from Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py rename to Control/CalypsoExample/GeoModelTest/python/Faser01TestConfig.py index ad33f2cf..69a57833 100644 --- a/Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py +++ b/Control/CalypsoExample/GeoModelTest/python/Faser01TestConfig.py @@ -17,7 +17,9 @@ def GeoModelTestCfg(flags, name="GeoModelTestAlg", **kwargs): # Configure the algorithm itself GeoModelTestAlg = CompFactory.GeoModelTestAlg - a.addEventAlgo(GeoModelTestAlg(name, **kwargs)) + a.addEventAlgo(GeoModelTestAlg(name, FirstSCTStation=1, + LastSCTStation=3, + **kwargs)) return a @@ -32,7 +34,7 @@ if __name__ == "__main__": ConfigFlags.Input.isMC = True # Needed to bypass autoconfig ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Always needed; must match FaserVersion ConfigFlags.GeoModel.FaserVersion = "FASER-01" # Default FASER geometry - ConfigFlags.GeoModel.GeoExportFile = "faserGeo.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) + # ConfigFlags.GeoModel.GeoExportFile = "faserGeo01.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) # ConfigFlags.Detector.EnableVeto = True # ConfigFlags.Detector.EnableTrigger = True # ConfigFlags.Detector.EnablePreshower= True diff --git a/Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py b/Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py new file mode 100644 index 00000000..03913db7 --- /dev/null +++ b/Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py @@ -0,0 +1,66 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +#!/usr/bin/env python +import sys +from AthenaCommon.Constants import VERBOSE, INFO +from AthenaConfiguration.ComponentFactory import CompFactory + +def GeoModelTestCfg(flags, name="GeoModelTestAlg", **kwargs): + + # Initialize GeoModel + from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg + a = FaserGeometryCfg(flags) + + # Initialize field service + from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg + a.merge(MagneticFieldSvcCfg(flags)) + + # Configure the algorithm itself + GeoModelTestAlg = CompFactory.GeoModelTestAlg + a.addEventAlgo(GeoModelTestAlg(name, FirstSCTStation=0, + LastSCTStation=3, + PrintSctIDs=True, + **kwargs)) + + return a + +if __name__ == "__main__": + from AthenaCommon.Logging import log#, logging + from AthenaCommon.Configurable import Configurable + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + + Configurable.configurableRun3Behavior = True + +# Flags for this job + ConfigFlags.Input.isMC = True # Needed to bypass autoconfig + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Always needed; must match FaserVersion + ConfigFlags.GeoModel.FaserVersion = "FASERNU-02" # Default FASER geometry + # ConfigFlags.GeoModel.GeoExportFile = "faserGeoNu02.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) + # ConfigFlags.Detector.EnableVeto = True + # ConfigFlags.Detector.EnableTrigger = True + # ConfigFlags.Detector.EnablePreshower= True + # ConfigFlags.Detector.EnableFaserSCT = True + # ConfigFlags.Detector.EnableUpstreamDipole = True + # ConfigFlags.Detector.EnableCentralDipole = True + # ConfigFlags.Detector.EnableDownstreamDipole = True + # ConfigFlags.Detector.EnableEcal = True + ConfigFlags.lock() + +# Configure components + from CalypsoConfiguration.MainServicesConfig import MainServicesCfg + acc = MainServicesCfg(ConfigFlags) + +# Set up algorithm + acc.merge(GeoModelTestCfg(ConfigFlags)) + +# Configure verbosity + msgSvc = acc.getService("MessageSvc") + msgSvc.Format = "% F%30W%S%7W%R%T %0W%M" + # ConfigFlags.dump() + # logging.getLogger('forcomps').setLevel(VERBOSE) + acc.foreach_component("*").OutputLevel = VERBOSE + acc.foreach_component("*ClassID*").OutputLevel = INFO + log.setLevel(VERBOSE) + +# Execute and finish + sys.exit(int(acc.run(maxEvents=1).isFailure())) diff --git a/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py b/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py index 91a2d33e..d590b125 100644 --- a/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py +++ b/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py @@ -42,7 +42,7 @@ if __name__ == "__main__": ConfigFlags.Input.isMC = True # Needed to bypass autoconfig ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00" # Always needed; must match FaserVersion ConfigFlags.GeoModel.FaserVersion = "FASER-TB00" # Default FASER geometry - ConfigFlags.GeoModel.GeoExportFile = "faserTestBeamGeo.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) + # ConfigFlags.GeoModel.GeoExportFile = "faserTestBeamGeo.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) # ConfigFlags.Detector.EnableVeto = True # ConfigFlags.Detector.EnableTrigger = True # ConfigFlags.Detector.EnablePreshower= True diff --git a/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py b/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py index 066f8560..7a0df38c 100755 --- a/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py +++ b/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py @@ -53,7 +53,6 @@ if __name__ == "__main__": acc.merge(PoolWriteCfg(ConfigFlags)) # Configure output - from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg itemList = [ "xAOD::EventInfo#*", "xAOD::EventAuxInfo#*", @@ -65,6 +64,13 @@ if __name__ == "__main__": # Set up algorithm acc.merge(TrackerDataAccessExampleCfg(ConfigFlags)) +# Hack to avoid problem with our use of MC databases when isMC = False + replicaSvc = acc.getService("DBReplicaSvc") + replicaSvc.COOLSQLiteVetoPattern = "" + replicaSvc.UseCOOLSQLite = True + replicaSvc.UseCOOLFrontier = False + replicaSvc.UseGeomSQLite = True + # Configure verbosity # ConfigFlags.dump() logging.getLogger('forcomps').setLevel(WARNING) diff --git a/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py b/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py index 737d0372..add815c7 100755 --- a/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py +++ b/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py @@ -52,7 +52,6 @@ if __name__ == "__main__": acc.merge(PoolWriteCfg(ConfigFlags)) # Configure output - from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg itemList = [ "xAOD::EventInfo#*", "xAOD::EventAuxInfo#*", @@ -64,6 +63,13 @@ if __name__ == "__main__": # Set up algorithm acc.merge(TriggerDataAccessExampleCfg(ConfigFlags)) +# Hack to avoid problem with our use of MC databases when isMC = False + replicaSvc = acc.getService("DBReplicaSvc") + replicaSvc.COOLSQLiteVetoPattern = "" + replicaSvc.UseCOOLSQLite = True + replicaSvc.UseCOOLFrontier = False + replicaSvc.UseGeomSQLite = True + # Configure verbosity # ConfigFlags.dump() # logging.getLogger('forcomps').setLevel(VERBOSE) diff --git a/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py b/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py index 1151c74d..e360be84 100755 --- a/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py +++ b/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py @@ -52,7 +52,6 @@ if __name__ == "__main__": acc.merge(PoolWriteCfg(ConfigFlags)) # Configure output - from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg itemList = [ "xAOD::EventInfo#*", "xAOD::EventAuxInfo#*", @@ -64,6 +63,13 @@ if __name__ == "__main__": # Set up algorithm acc.merge(WaveformDataAccessExampleCfg(ConfigFlags)) +# Hack to avoid problem with our use of MC databases when isMC = False + replicaSvc = acc.getService("DBReplicaSvc") + replicaSvc.COOLSQLiteVetoPattern = "" + replicaSvc.UseCOOLSQLite = True + replicaSvc.UseCOOLFrontier = False + replicaSvc.UseGeomSQLite = True + # Configure verbosity # ConfigFlags.dump() # logging.getLogger('forcomps').setLevel(VERBOSE) diff --git a/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig.py b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser01.py similarity index 73% rename from Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig.py rename to Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser01.py index de5a92ac..675f61f5 100644 --- a/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig.py +++ b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser01.py @@ -12,11 +12,11 @@ def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs): a = FaserGeometryCfg(flags) # This section is to allow alignment to be written to a conditions DB file - # from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg - # result = IOVDbSvcCfg(flags) - # iovDbSvc = result.getPrimary() - # iovDbSvc.dbConnection="sqlite://;schema=ALLP200.db;dbname=OFLP200" - # a.merge(result) + from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg + result = IOVDbSvcCfg(flags) + iovDbSvc = result.getPrimary() + iovDbSvc.dbConnection=flags.IOVDb.DBConnection + a.merge(result) AthenaPoolCnvSvc=CompFactory.AthenaPoolCnvSvc apcs=AthenaPoolCnvSvc() @@ -28,7 +28,7 @@ def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs): # Configure the algorithm itself WriteAlignmentAlg = CompFactory.WriteAlignmentAlg - outputTool = CompFactory.AthenaOutputStreamTool("DbStreamTool", OutputFile = "FaserSCT_AlignDb.pool.root", + outputTool = CompFactory.AthenaOutputStreamTool("DbStreamTool", OutputFile = flags.WriteAlignment.PoolFileName, PoolContainerPrefix="ConditionsContainer", TopLevelContainerName = "<type>", SubLevelBranchName= "<key>" ) @@ -48,10 +48,11 @@ if __name__ == "__main__": # Flags for this job ConfigFlags.Input.isMC = True # Needed to bypass autoconfig - ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Always needed; must match FaserVersion ConfigFlags.GeoModel.FaserVersion = "FASER-01" # Default FASER geometry - ConfigFlags.GeoModel.GeoExportFile = "faserGeo.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) - ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=ALLP200.db;dbname=OFLP200" + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-"+ ConfigFlags.GeoModel.FaserVersion # Always needed; must match FaserVersion + ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=" + ConfigFlags.GeoModel.FaserVersion + "_ALLP200.db;dbname=OFLP200" + ConfigFlags.GeoModel.Align.Disable = True # Hack to avoid loading alignment when we want to create it from scratch + ConfigFlags.addFlag("WriteAlignment.PoolFileName", ConfigFlags.GeoModel.FaserVersion + "_Align.pool.root") ConfigFlags.lock() # Configure components @@ -59,7 +60,7 @@ if __name__ == "__main__": acc = MainServicesCfg(ConfigFlags) # Set things up to create a conditions DB with neutral Tracker alignment transforms - acc.merge(WriteAlignmentCfg(ConfigFlags)) + acc.merge(WriteAlignmentCfg(ConfigFlags, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN"))) # Configure verbosity # ConfigFlags.dump() diff --git a/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser02.py b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser02.py new file mode 100644 index 00000000..b05c1563 --- /dev/null +++ b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser02.py @@ -0,0 +1,73 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +#!/usr/bin/env python +import sys +from AthenaCommon.Constants import VERBOSE, INFO +from AthenaConfiguration.ComponentFactory import CompFactory + +def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs): + + # Initialize GeoModel + from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg + a = FaserGeometryCfg(flags) + + # This section is to allow alignment to be written to a conditions DB file + from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg + result = IOVDbSvcCfg(flags) + iovDbSvc = result.getPrimary() + iovDbSvc.dbConnection=flags.IOVDb.DBConnection + a.merge(result) + + AthenaPoolCnvSvc=CompFactory.AthenaPoolCnvSvc + apcs=AthenaPoolCnvSvc() + a.addService(apcs) + EvtPersistencySvc=CompFactory.EvtPersistencySvc + a.addService(EvtPersistencySvc("EventPersistencySvc",CnvServices=[apcs.getFullJobOptName(),])) + + a.addService(CompFactory.IOVRegistrationSvc(PayloadTable=False,OutputLevel=VERBOSE)) + + # Configure the algorithm itself + WriteAlignmentAlg = CompFactory.WriteAlignmentAlg + outputTool = CompFactory.AthenaOutputStreamTool("DbStreamTool", OutputFile = flags.WriteAlignment.PoolFileName, + PoolContainerPrefix="ConditionsContainer", + TopLevelContainerName = "<type>", + SubLevelBranchName= "<key>" ) + kwargs.setdefault("AlignDbTool", CompFactory.TrackerAlignDBTool("AlignDbTool", OutputTool = outputTool, OutputLevel=VERBOSE)) + a.addEventAlgo(WriteAlignmentAlg(name, **kwargs)) + + return a + + +if __name__ == "__main__": + # from AthenaCommon.Logging import log, logging + from AthenaCommon.Configurable import Configurable + # from AthenaConfiguration.ComponentFactory import CompFactory + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + + Configurable.configurableRun3Behavior = True + +# Flags for this job + ConfigFlags.Input.isMC = True # Needed to bypass autoconfig + ConfigFlags.GeoModel.FaserVersion = "FASER-02" # Default FASER geometry + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-"+ ConfigFlags.GeoModel.FaserVersion # Always needed; must match FaserVersion + ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=" + ConfigFlags.GeoModel.FaserVersion + "_ALLP200.db;dbname=OFLP200" + ConfigFlags.GeoModel.Align.Disable = True # Hack to avoid loading alignment when we want to create it from scratch + ConfigFlags.addFlag("WriteAlignment.PoolFileName", ConfigFlags.GeoModel.FaserVersion + "_Align.pool.root") + ConfigFlags.lock() + +# Configure components + from CalypsoConfiguration.MainServicesConfig import MainServicesCfg + acc = MainServicesCfg(ConfigFlags) + +# Set things up to create a conditions DB with neutral Tracker alignment transforms + acc.merge(WriteAlignmentCfg(ConfigFlags, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN"))) + +# Configure verbosity + # ConfigFlags.dump() + # logging.getLogger('forcomps').setLevel(VERBOSE) + acc.foreach_component("*").OutputLevel = VERBOSE + acc.foreach_component("*ClassID*").OutputLevel = INFO + # log.setLevel(VERBOSE) + +# Execute and finish + sys.exit(int(acc.run(maxEvents=1).isFailure())) diff --git a/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_FaserTB00.py b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_FaserTB00.py new file mode 100644 index 00000000..d57092f2 --- /dev/null +++ b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_FaserTB00.py @@ -0,0 +1,73 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +#!/usr/bin/env python +import sys +from AthenaCommon.Constants import VERBOSE, INFO +from AthenaConfiguration.ComponentFactory import CompFactory + +def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs): + + # Initialize GeoModel + from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg + a = FaserGeometryCfg(flags) + + # This section is to allow alignment to be written to a conditions DB file + from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg + result = IOVDbSvcCfg(flags) + iovDbSvc = result.getPrimary() + iovDbSvc.dbConnection=flags.IOVDb.DBConnection + a.merge(result) + + AthenaPoolCnvSvc=CompFactory.AthenaPoolCnvSvc + apcs=AthenaPoolCnvSvc() + a.addService(apcs) + EvtPersistencySvc=CompFactory.EvtPersistencySvc + a.addService(EvtPersistencySvc("EventPersistencySvc",CnvServices=[apcs.getFullJobOptName(),])) + + a.addService(CompFactory.IOVRegistrationSvc(PayloadTable=False,OutputLevel=VERBOSE)) + + # Configure the algorithm itself + WriteAlignmentAlg = CompFactory.WriteAlignmentAlg + outputTool = CompFactory.AthenaOutputStreamTool("DbStreamTool", OutputFile = flags.WriteAlignment.PoolFileName, + PoolContainerPrefix="ConditionsContainer", + TopLevelContainerName = "<type>", + SubLevelBranchName= "<key>" ) + kwargs.setdefault("AlignDbTool", CompFactory.TrackerAlignDBTool("AlignDbTool", OutputTool = outputTool, OutputLevel=VERBOSE)) + a.addEventAlgo(WriteAlignmentAlg(name, **kwargs)) + + return a + + +if __name__ == "__main__": + # from AthenaCommon.Logging import log, logging + from AthenaCommon.Configurable import Configurable + # from AthenaConfiguration.ComponentFactory import CompFactory + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + + Configurable.configurableRun3Behavior = True + +# Flags for this job + ConfigFlags.Input.isMC = True # Needed to bypass autoconfig + ConfigFlags.GeoModel.FaserVersion = "FASER-TB00" # Default FASER geometry + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-"+ ConfigFlags.GeoModel.FaserVersion # Always needed; must match FaserVersion + ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=" + ConfigFlags.GeoModel.FaserVersion + "_ALLP200.db;dbname=OFLP200" + ConfigFlags.GeoModel.Align.Disable = True # Hack to avoid loading alignment when we want to create it from scratch + ConfigFlags.addFlag("WriteAlignment.PoolFileName", ConfigFlags.GeoModel.FaserVersion + "_Align.pool.root") + ConfigFlags.lock() + +# Configure components + from CalypsoConfiguration.MainServicesConfig import MainServicesCfg + acc = MainServicesCfg(ConfigFlags) + +# Set things up to create a conditions DB with neutral Tracker alignment transforms + acc.merge(WriteAlignmentCfg(ConfigFlags, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN"))) + +# Configure verbosity + # ConfigFlags.dump() + # logging.getLogger('forcomps').setLevel(VERBOSE) + acc.foreach_component("*").OutputLevel = VERBOSE + acc.foreach_component("*ClassID*").OutputLevel = INFO + # log.setLevel(VERBOSE) + +# Execute and finish + sys.exit(int(acc.run(maxEvents=1).isFailure())) diff --git a/Control/CalypsoExample/WriteAlignment/scripts/CopyAlignFolder.sh b/Control/CalypsoExample/WriteAlignment/scripts/CopyAlignFolder.sh index ce694ce4..4ed49f4d 100644 --- a/Control/CalypsoExample/WriteAlignment/scripts/CopyAlignFolder.sh +++ b/Control/CalypsoExample/WriteAlignment/scripts/CopyAlignFolder.sh @@ -1,5 +1,18 @@ #!/bin/sh -AtlCoolCopy "sqlite://;schema=./ALLP200.db;dbname=OFLP200" "sqlite://;schema=data/ALLP200.db;dbname=OFLP200" -a -fnp -ot "TRACKER-ALIGN-01" -cp -n PoolFileCatalog.xml data/ -cp -n FaserSCT_AlignDb.pool.root data/ \ No newline at end of file +rm -f *_Align.pool.root +rm -f *_ALLP200.db +rm -f PoolFileCatalog.xml +rm -f writeAlignment_*.log + +python python/WriteAlignment/WriteAlignmentConfig_Faser01.py >& writeAlignment_Faser01.log +python python/WriteAlignment/WriteAlignmentConfig_Faser02.py >& writeAlignment_Faser02.log +python python/WriteAlignment/WriteAlignmentConfig_FaserTB00.py >& writeAlignment_FaserTB00.log + +AtlCoolCopy "sqlite://;schema=./FASER-01_ALLP200.db;dbname=OFLP200" "sqlite://;schema=data/sqlite200/ALLP200.db;dbname=OFLP200" -fnp -ot "TRACKER-ALIGN-01" +AtlCoolCopy "sqlite://;schema=./FASER-02_ALLP200.db;dbname=OFLP200" "sqlite://;schema=data/sqlite200/ALLP200.db;dbname=OFLP200" -fnp -ot "TRACKER-ALIGN-02" +AtlCoolCopy "sqlite://;schema=./FASER-TB00_ALLP200.db;dbname=OFLP200" "sqlite://;schema=data/sqlite200/ALLP200.db;dbname=OFLP200" -fnp -ot "TRACKER-ALIGN-TB00" +mkdir data/poolcond +cp -n PoolFileCatalog.xml data/poolcond/ +ln -s ${PWD}/data/poolcond/PoolFileCatalog.xml ${PWD}/data/poolcond/PoolCat_oflcond.xml +cp -n *_Align.pool.root data/poolcond/ \ No newline at end of file diff --git a/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.cxx b/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.cxx index 6efcb9b4..38accc36 100644 --- a/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.cxx +++ b/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.cxx @@ -73,7 +73,7 @@ StatusCode WriteAlignmentAlg::execute(const EventContext&) const ATH_CHECK(m_alignTool->createDB()); ATH_CHECK(m_alignTool->sortTrans()); ATH_CHECK(m_alignTool->outputObjs()); - ATH_CHECK(m_alignTool->fillDB("",1,0,9999999,9999999)); + ATH_CHECK(m_alignTool->fillDB(m_conditionsTag, m_validRunStart, m_validEvtStart , m_validRunEnd, m_validEvtEnd)); return StatusCode::SUCCESS; } diff --git a/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.h b/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.h index 0797a34f..37d8b903 100644 --- a/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.h +++ b/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.h @@ -41,6 +41,13 @@ class WriteAlignmentAlg : public AthReentrantAlgorithm Gaudi::Property<int> m_numSctModulesPerRow {this, "NumSCTModulesPerRow", 2, "Number of modules per row in the SCT detector"}; Gaudi::Property<int> m_numSctStripsPerSensor {this, "NumSCTStripsPerSensor", 768,"Number of readout strips per sensor in the SCT detector"}; + Gaudi::Property<int> m_validRunStart {this, "ValidRunStart", 1, "Run number of IOV start"}; + Gaudi::Property<int> m_validRunEnd {this, "ValidRunEnd", 9999999, "Run number of IOV end"}; + Gaudi::Property<int> m_validEvtStart {this, "ValidEvtStart", 0, "Event number of IOV start"}; + Gaudi::Property<int> m_validEvtEnd {this, "ValidEvtEnd", 9999999, "Event number of IOV end"}; + + Gaudi::Property<std::string> m_conditionsTag {this, "CondTag", "", "Conditions tag for created alignment"}; + int m_numSctStations; ToolHandle<ITrackerAlignDBTool> m_alignTool { this, "AlignDbTool", "TrackerAlignDBTool" }; diff --git a/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml b/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml index 91ba8175..5b309fd7 100644 --- a/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml +++ b/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml @@ -2,18 +2,22 @@ <servicelist> <logicalservice name="FASERDD"> + <service name="sqlite_file:data/geomDB/geomDB_sqlite" accessMode="read" /> <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/geomDB/geomDB_sqlite" accessMode="read" /> </logicalservice> <logicalservice name="COOLOFL_SCT"> + <service name="sqlite_file:data/sqlite200/ALLP200.db" accessMode="read" /> <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/ALLP200.db" accessMode="read" /> </logicalservice> <logicalservice name="COOLOFL_DCS"> + <service name="sqlite_file:data/sqlite200/ALLP200.db" accessMode="read" /> <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/ALLP200.db" accessMode="read" /> </logicalservice> <logicalservice name="COOLOFL_GLOBAL"> + <service name="sqlite_file:data/sqlite200/ALLP200.db" accessMode="read" /> <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/ALLP200.db" accessMode="read" /> </logicalservice> diff --git a/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.cxx b/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.cxx index a92e78dc..77714ac0 100644 --- a/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.cxx +++ b/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.cxx @@ -99,7 +99,6 @@ StatusCode TrackerAlignDBTool::initialize() for (int i=0;i<3;++i) chan[i]=100*i; - int minStation = 3; std::string man_name; for (const TrackerDD::SiDetectorElement* element : *(m_sctman->getDetectorElementCollection())) { @@ -112,7 +111,7 @@ StatusCode TrackerAlignDBTool::initialize() std::string level[3]; for (int i=TransfLevel_low; i<3; ++i) { - minStation = std::min(station, minStation); + m_stations.insert(station); level[i]=dirkey(station, layer, 1+i, phi); // add this to list if not seen already std::vector<std::string>::const_iterator ix = @@ -130,9 +129,8 @@ StatusCode TrackerAlignDBTool::initialize() ATH_MSG_ERROR("Error translating element identifier." ); } } - } - m_ift =(minStation == 0); - ATH_CHECK(m_outputTool.retrieve()); + } + ATH_CHECK(m_outputTool.retrieve()); if (msgLvl(MSG::DEBUG)) { @@ -246,21 +244,11 @@ StatusCode TrackerAlignDBTool::createDB() const { Amg::Transform3D globshift; globshift.setIdentity(); - // Tracker interface - if (m_ift) + for (int station : m_stations) { - ident1 = m_sctid->wafer_id(0, 0, 0, 0, 0); - pat->add(ident1, Amg::EigenTransformToCLHEP(globshift)); + ident1 = m_sctid->wafer_id(station, 0, 0, 0, 0); + pat->add(ident1, Amg::EigenTransformToCLHEP(globshift)); } - // Tracker upstream - ident1 = m_sctid->wafer_id(1, 0, 0, 0, 0); - pat->add(ident1, Amg::EigenTransformToCLHEP(globshift)); - // Tracker central - ident1 = m_sctid->wafer_id(2, 0, 0, 0, 0); - pat->add(ident1, Amg::EigenTransformToCLHEP(globshift)); - // Tracker downstream - ident1 = m_sctid->wafer_id(3, 0, 0, 0, 0); - pat->add(ident1, Amg::EigenTransformToCLHEP(globshift)); } else { @@ -328,6 +316,7 @@ std::string TrackerAlignDBTool::dirkey(const int station, if (station == 3 ) result << "Downstream"; if (station == 2 ) result << "Central"; if (station == 1 ) result << "Upstream"; + if (station == 0 ) result << "Interface"; result << 1+layer; } } diff --git a/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.h b/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.h index 9ff68007..2c82c20a 100644 --- a/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.h +++ b/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.h @@ -185,8 +185,8 @@ class TrackerAlignDBTool: virtual public ITrackerAlignDBTool, public AthAlgTool const AlignableTransform* cgetTransPtr(const std::string key) const; bool m_dynamicDB; bool m_forceUserDBConfig; - bool m_ift {false}; - + std::set<int> m_stations; + mutable ToolHandle<IAthenaOutputStreamTool> m_outputTool { this, "OutputTool", "AthenaOutputStreamTool/CondStream1"} ; }; diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt b/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt index 9c0b2c7b..f13ae327 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt @@ -24,6 +24,6 @@ if (INSTALL_CONDB) # Install the generated file: install( FILES ${CMAKE_CURRENT_BINARY_DIR}/ALLP200.db - DESTINATION ${CMAKE_INSTALL_DATADIR} + DESTINATION ${CMAKE_INSTALL_DATADIR}/sqlite200 ) endif() \ No newline at end of file diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/SCT_Conditions.py b/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/SCT_Conditions.py index d68e6934..0fb2802c 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/SCT_Conditions.py +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/SCT_Conditions.py @@ -32,6 +32,8 @@ description = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header clid=" descriptionDCS = '<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName><cache>600</cache>' +descriptionAlign = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="256" clid="1170039409" /></addrHeader><typeName>AlignableTransformContainer</typeName>' + from PyCool import cool, coral dbSvc = cool.DatabaseSvcFactory.databaseService() @@ -41,24 +43,32 @@ print('recreating database') dbSvc.dropDatabase( connectString ) db = dbSvc.createDatabase( connectString ) +alignSpec = cool.RecordSpecification() +alignSpec.extend( 'PoolRef', cool.StorageType.String4k ) +alignFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, alignSpec, cool.PayloadMode.INLINEPAYLOAD) + tracker = db.createFolderSet("/Tracker") +align = db.createFolder("/Tracker/Align", alignFolderSpec, descriptionAlign, True) sct = db.createFolderSet("/SCT") sct_dcs = db.createFolderSet("/SCT/DCS") sct_daq = db.createFolderSet("/SCT/DAQ") sct_daq_calibration = db.createFolderSet("/SCT/DAQ/Calibration") +align.createTagRelation("TRACKER-01","TRACKER-ALIGN-01") tracker.createTagRelation("OFLCOND-FASER-01","TRACKER-01") sct_daq_calibration.createTagRelation("SCT-DAQ-01", "SCT-DAQ-Calibration-01") sct_daq.createTagRelation("SCT-01", "SCT-DAQ-01") sct_dcs.createTagRelation("SCT-01", "SCT-DCS-01") sct.createTagRelation("OFLCOND-FASER-01", "SCT-01") +align.createTagRelation("TRACKER-02","TRACKER-ALIGN-02") tracker.createTagRelation("OFLCOND-FASER-02","TRACKER-02") sct_daq_calibration.createTagRelation("SCT-DAQ-02", "SCT-DAQ-Calibration-02") sct_daq.createTagRelation("SCT-02", "SCT-DAQ-02") sct_dcs.createTagRelation("SCT-02", "SCT-DCS-02") sct.createTagRelation("OFLCOND-FASER-02", "SCT-02") +align.createTagRelation("TRACKER-TB00","TRACKER-ALIGN-TB00") tracker.createTagRelation("OFLCOND-FASER-TB00","TRACKER-TB00") sct_daq_calibration.createTagRelation("SCT-DAQ-TB00", "SCT-DAQ-Calibration-TB00") sct_daq.createTagRelation("SCT-TB00", "SCT-DAQ-TB00") diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py index 88a5b7b1..26dff64f 100644 --- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py +++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py @@ -24,6 +24,9 @@ def FaserSCT_GeometryCfg( flags ): sctDetectorTool.useDynamicAlignFolders = flags.GeoModel.Align.Dynamic geoModelSvc.DetectorTools += [ sctDetectorTool ] + if flags.GeoModel.Align.Disable: + return acc + if flags.GeoModel.Align.Dynamic: # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL1/ID","/Indet/AlignL1/ID",className="CondAttrListCollection")) # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL2/SCT","/Indet/AlignL2/SCT",className="CondAttrListCollection")) diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_DetectorFactory.cxx b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_DetectorFactory.cxx index 003173e9..63763a9a 100644 --- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_DetectorFactory.cxx +++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_DetectorFactory.cxx @@ -182,7 +182,10 @@ void SCT_DetectorFactory::create(GeoPhysVol *world) m_detectorManager->addFolder("/Tracker/Align"); m_detectorManager->addChannel("/Tracker/Align/Stations", 3, TrackerDD::global); // Stations in world m_detectorManager->addChannel("/Tracker/Align/Planes", 2, TrackerDD::global); // Planes in world - m_detectorManager->addChannel("/Tracker/Align/Upstream1", 1, TrackerDD::local); // Modules in planes and wafers in modules + m_detectorManager->addChannel("/Tracker/Align/Interface1", 1, TrackerDD::local); // Modules in planes + m_detectorManager->addChannel("/Tracker/Align/Interface2", 1, TrackerDD::local); + m_detectorManager->addChannel("/Tracker/Align/Interface3", 1, TrackerDD::local); + m_detectorManager->addChannel("/Tracker/Align/Upstream1", 1, TrackerDD::local); m_detectorManager->addChannel("/Tracker/Align/Upstream2", 1, TrackerDD::local); m_detectorManager->addChannel("/Tracker/Align/Upstream3", 1, TrackerDD::local); m_detectorManager->addChannel("/Tracker/Align/Central1" , 1, TrackerDD::local); diff --git a/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/TrackerDetectorManager.cxx b/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/TrackerDetectorManager.cxx index 41c0ab60..ae76706e 100755 --- a/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/TrackerDetectorManager.cxx +++ b/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/TrackerDetectorManager.cxx @@ -8,6 +8,7 @@ #include "StoreGate/StoreGateSvc.h" #include "DetDescrConditions/AlignableTransform.h" #include "FaserDetDescr/FaserDetectorID.h" +#include "Identifier/IdentifierHash.h" #include "GeoPrimitives/CLHEPtoEigenConverter.h" #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "AthenaBaseComps/AthMsgStreamMacros.h" -- GitLab