diff --git a/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py b/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py index 29750681d07ca5bd2a6d8004cc01ba6e28cbf8a1..d1b0ae658d6507eaf007107703ae8aa9554491c3 100644 --- a/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py +++ b/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py @@ -165,3 +165,126 @@ class Volume: def getZs(self): return self.z +# For new configuration - doesn't have access to DetFlags as of writing, so all HGTD stuff is missing. +# Just copied from above. +def EnvelopeDefSvc(flags, **kwargs): + kwargs.setdefault("DBInDetNode" , 'InDetEnvelope' ) + kwargs.setdefault("DBBeamPipeNode" , 'BeamPipeEnvelope' ) + kwargs.setdefault("DBCaloNode" , 'CaloEnvelope' ) + kwargs.setdefault("DBMSNode" , 'MuonEnvelope' ) + kwargs.setdefault("DBCavernNode" , 'CavernEnvelope' ) + + # allow for python-based envelope definitions (see below) + # -> TODO: set this to False once the envelope definitions are tagged in the DDDB + kwargs.setdefault("EnableFallback" , True ) + + # setup fallback BeamPipeEnvelope + BeamPipe = Volume() + BeamPipe.addRZ( 34.3, 3475.0 ) + BeamPipe.addRZ( 120.0, 3475.0 ) # TODO - re-add HGTD stuff once we can configure + BeamPipe.addRZ( 120.0, 4185.0 ) + BeamPipe.addRZ( 41.0, 4185.0 ) + BeamPipe.addRZ( 41.0, 6783.0 ) + BeamPipe.addRZ( 70.0, 6783.0 ) + BeamPipe.addRZ( 70.0, 12900.0 ) + BeamPipe.addRZ( 279.0, 12900.0 ) + BeamPipe.addRZ( 279.0, 18650.0 ) + BeamPipe.addRZ( 436.0, 18650.0 ) + BeamPipe.addRZ( 436.0, 22030.0 ) + BeamPipe.addRZ( 1050.0, 22030.0 ) + BeamPipe.addRZ( 1050.0, 26046.0 ) + BeamPipe.addRZ( 0.0, 26046.0 ) + + kwargs.setdefault("FallbackBeamPipeR" , BeamPipe.getRs() ) + kwargs.setdefault("FallbackBeamPipeZ" , BeamPipe.getZs() ) + + + # setup fallback IDEnvelope + InDet = Volume() + InDet.addRZ( 1148., 3475. ) + InDet.addRZ( 34.3, 3475. ) + kwargs.setdefault("FallbackInDetR" , InDet.getRs() ) + kwargs.setdefault("FallbackInDetZ" , InDet.getZs() ) + + + # setup fallback CaloEnvelope + Calo = Volume() + Calo.addRZ( 1148.0, 3475.0 ) + Calo.addRZ( 120.0, 3475.0 ) # TODO - re-add HGTD stuff once we can configure + Calo.addRZ( 120.0, 4185.0 ) + Calo.addRZ( 41.0, 4185.0 ) + Calo.addRZ( 41.0, 6783.0 ) + Calo.addRZ( 420.0, 6783.0 ) + Calo.addRZ( 420.0, 6736.0 ) + Calo.addRZ( 3800.0, 6736.0 ) + Calo.addRZ( 3800.0, 6550.0 ) + Calo.addRZ( 4255.0, 6550.0 ) + + kwargs.setdefault("FallbackCaloR" , Calo.getRs() ) + kwargs.setdefault("FallbackCaloZ" , Calo.getZs() ) + + + # setup fallback MuonEnvelope + Muon = Volume() + Muon.addRZ( 4255.0 , 4000.0 ) + Muon.addRZ( 4255.0 , 6550.0 ) + Muon.addRZ( 3800.0 , 6550.0 ) + Muon.addRZ( 3800.0 , 6736.0 ) + Muon.addRZ( 420.0 , 6736.0 ) + Muon.addRZ( 420.0 , 6783.0 ) + Muon.addRZ( 70.0 , 6783.0 ) + Muon.addRZ( 70.0 , 12900.0 ) + Muon.addRZ( 279.0 , 12900.0 ) + Muon.addRZ( 279.0 , 18650.0 ) + Muon.addRZ( 436.7 , 18650.0 ) + Muon.addRZ( 436.7 , 22030.0 ) + Muon.addRZ( 1050.0 , 22030.0 ) + Muon.addRZ( 1050.0 , 26046.0 ) + Muon.addRZ( 1500.0 , 26046.0 ) + Muon.addRZ( 1500.0 , 23001.0 ) + Muon.addRZ( 2750.0 , 23001.0 ) + Muon.addRZ( 2750.0 , 22030.0 ) + Muon.addRZ( 12650.0 , 22030.0 ) + Muon.addRZ( 12650.0 , 18650.0 ) + Muon.addRZ( 13400.0 , 18650.0 ) + Muon.addRZ( 13400.0 , 12900.0 ) + Muon.addRZ( 14200.0 , 12900.0 ) + Muon.addRZ( 14200.0 , 4000.0 ) + Muon.addRZ( 13000.0 , 4000.0 ) + kwargs.setdefault("FallbackMuonR" , Muon.getRs() ) + kwargs.setdefault("FallbackMuonZ" , Muon.getZs() ) + + + # setup fallback CavernEnvelope + Cavern = Volume() + Cavern.addRZ( 13000.0 , 4000.0 ) + Cavern.addRZ( 14200.0 , 4000.0 ) + Cavern.addRZ( 14200.0 , 12900.0 ) # boundary with MS + Cavern.addRZ( 13400.0 , 12900.0 ) # boundary with MS + Cavern.addRZ( 13400.0 , 18650.0 ) # boundary with MS + Cavern.addRZ( 12650.0 , 18650.0 ) # boundary with MS + Cavern.addRZ( 12650.0 , 22030.0 ) # boundary with MS + Cavern.addRZ( 2750.0 , 22030.0 ) # boundary with MS + Cavern.addRZ( 2750.0 , 23001.0 ) # boundary with MS + Cavern.addRZ( 1500.0 , 23001.0 ) # boundary with MS + Cavern.addRZ( 1500.0 , 26046.0 ) # boundary with MS + Cavern.addRZ( 0.0 , 26046.0 ) # + + # the outer dimesions differ between collision and cosmics jobs + from AthenaCommon.BeamFlags import jobproperties + if flags.Beam.Type != 'cosmics': + # -> for collision jobs the 'cavern' envelope is much smaller + Cavern.addRZ( 0.0 , 500000.0 ) # z= +500m + Cavern.addRZ( 500000.0 , 500000.0 ) # r= 500m + else: + # -> for cosmics simulation the 'cavern' envelope spans much further + kwargs.setdefault("DBCavernNode" , 'CavernEnvelopeNONE' ) + kwargs.setdefault("EnableFallback" , True ) + Cavern.addRZ( 0.0 , 3000000.0 ) # z= +3km + Cavern.addRZ( 3000000.0 , 3000000.0 ) # r= 3km + kwargs.setdefault("FallbackCavernR" , Cavern.getRs() ) + kwargs.setdefault("FallbackCavernZ" , Cavern.getZs() ) + + from SubDetectorEnvelopes.SubDetectorEnvelopesConf import DetDescrDBEnvelopeSvc + return DetDescrDBEnvelopeSvc(**kwargs) + diff --git a/Control/AthenaConfiguration/python/AllConfigFlags.py b/Control/AthenaConfiguration/python/AllConfigFlags.py index 4c00c139cf0e432703bfb6fd0b5d6897f479919e..940a9f1b1da9f122a3ffcabd1631faae4c01ab32 100644 --- a/Control/AthenaConfiguration/python/AllConfigFlags.py +++ b/Control/AthenaConfiguration/python/AllConfigFlags.py @@ -59,6 +59,10 @@ def _createCfgFlags(): from TriggerJobOpts.TriggerConfigFlags import createTriggerFlags acf.join( createTriggerFlags() ) +# Muon + from MuonConfig.MuonConfigFlags import createMuonConfigFlags + acf.join( createMuonConfigFlags() ) + return acf diff --git a/MagneticField/MagFieldServices/python/MagFieldServicesConfig.py b/MagneticField/MagFieldServices/python/MagFieldServicesConfig.py index ec62197199b70d4d4de388d1203750896103c1a8..c26d27057547ac98425657f14e1d8b25e72dc564 100644 --- a/MagneticField/MagFieldServices/python/MagFieldServicesConfig.py +++ b/MagneticField/MagFieldServices/python/MagFieldServicesConfig.py @@ -11,6 +11,9 @@ logging.getLogger().info("Importing %s", __name__) from AthenaCommon.AthenaCommonFlags import athenaCommonFlags from AthenaCommon.GlobalFlags import GlobalFlags from AthenaCommon import CfgMgr +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from MagFieldServices.MagFieldServicesConf import MagField__AtlasFieldSvc + #-------------------------------------------------------------- def AtlasFieldSvc(name="AtlasFieldSvc",**kwargs): @@ -31,3 +34,62 @@ def GetFieldSvc(name="AtlasFieldSvc",**kwargs): return H8FieldSvc(name, **kwargs) else: return AtlasFieldSvc(name, **kwargs) + +# The magneticfields is going to need a big update for MT, so this is all temporary. Ed +def MagneticFieldSvcCfg(flags): + result=ComponentAccumulator() + + # initialise required conditions DB folders + from IOVDbSvc.IOVDbSvcConfig import addFolders + + # This handles addFolderSplitMC https://gitlab.cern.ch/atlas/athena/blob/master/Database/IOVDbSvc/python/CondDB.py#L240 + # i.e. replaces conddb.addFolderSplitMC('GLOBAL','/GLOBAL/BField/Maps <noover/>','/GLOBAL/BField/Maps <noover/>') + # def addFolders(configFlags,folderstrings,detDb=None,className=None): + if flags.Input.isMC: + db='GLOBAL_OFL' + else: + db='GLOBAL' + + result.merge(addFolders(flags,['/GLOBAL/BField/Maps <noover/>'],detDb=db) ) + result.getService('IOVDbSvc').FoldersToMetaData += ['/GLOBAL/BField/Maps'] # TODO fixme? + + if not flags.Common.isOnline: + result.merge(addFolders(flags, ['/EXT/DCS/MAGNETS/SENSORDATA'], detDb='DCS_OFL', className="CondAttrListCollection") ) + + kwargs={} + + if flags.Common.isOnline: + kwargs.setdefault( "UseDCS", False ) + kwargs.setdefault( "UseSoleCurrent", 7730 ) + kwargs.setdefault( "UseToroCurrent", 20400 ) + else: + kwargs.setdefault( "UseDCS", True ) + mag_field_svc = MagField__AtlasFieldSvc("AtlasFieldSvc",**kwargs) + result.addService(mag_field_svc) + return result, mag_field_svc + +if __name__=="__main__": + # To run this, do e.g. + # python ../athena/MagneticField/MagFieldServices/python/MagFieldServicesConfig.py + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior=1 + + from AthenaCommon.Logging import log + from AthenaCommon.Constants import VERBOSE + from AthenaConfiguration.AllConfigFlags import ConfigFlags + + log.setLevel(VERBOSE) + ConfigFlags.Input.Files = ["myESD.pool.root"] + ConfigFlags.Input.isMC = False + ConfigFlags.lock() + + cfg=ComponentAccumulator() + + acc,magfield = MagneticFieldSvcCfg(ConfigFlags) + cfg.merge(acc) + + log.verbose(magfield) + + f=open("MagneticFieldSvc.pkl","w") + cfg.store(f) + f.close() diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/src/MdtCalibrationDbSvc.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/src/MdtCalibrationDbSvc.cxx index cc59fd788788e6cec09451a42d02c48a5723f83b..c9cf4d6ec2650bfa49608fec711d409088dfe0bc 100644 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/src/MdtCalibrationDbSvc.cxx +++ b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc/src/MdtCalibrationDbSvc.cxx @@ -36,11 +36,11 @@ MdtCalibrationDbSvc::MdtCalibrationDbSvc(const std::string &n,ISvcLocator *sl) m_corDataLocation("CorKey") { declareProperty("DBTool", m_dbTool, - "the Tool to be used to retreive the constants"); + "the Tool to be used to retrieve the constants"); declareProperty("AccessTubeConstants", m_getTubeConstants = true, "configure the Tool to retrieve the constants per tube (t0)"); declareProperty("AccessCorrections", m_getCorrections = true, - "configure the Tool to retreive the parameters of the correction functions"); + "configure the Tool to retrieve the parameters of the correction functions"); declareProperty("CreateBFieldFunctions", m_create_b_field_function = false, "If set to true, the B-field correction functions are initialized for each rt-relation that is loaded."); declareProperty("CreateWireSagFunctions", m_createWireSagFunction = false, diff --git a/MuonSpectrometer/MuonConfig/CMakeLists.txt b/MuonSpectrometer/MuonConfig/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..378e13d59737394db286c62abd607e66f95dc0e5 --- /dev/null +++ b/MuonSpectrometer/MuonConfig/CMakeLists.txt @@ -0,0 +1,10 @@ +################################################################################ +# Package: MuonConfiguration +################################################################################ + +# Declare the package name: +atlas_subdir( MuonConfig ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_joboptions( share/*.py ) \ No newline at end of file diff --git a/MuonSpectrometer/MuonConfig/python/MuonCablingConfig.py b/MuonSpectrometer/MuonConfig/python/MuonCablingConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..daf94b6caa6ba74cd2182cb229f9c1ca59016e32 --- /dev/null +++ b/MuonSpectrometer/MuonConfig/python/MuonCablingConfig.py @@ -0,0 +1,91 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +# Heavily based on Trigger/TrigSteer/L1Decoder/python/L1MuonConfig.py +# TODO add MDTs, CSCs + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg + +def RPCCablingConfig(flags): + acc = ComponentAccumulator() + + # TODO check if we actually need this here? + acc.merge(MuonGeoModelCfg(flags)) + + from MuonCablingServers.MuonCablingServersConf import RPCcablingServerSvc + RPCCablingSvc = RPCcablingServerSvc() + RPCCablingSvc.Atlas = True + RPCCablingSvc.forcedUse = True + RPCCablingSvc.useMuonRPC_CablingSvc = True #Needed to switch to new cabling + acc.addService( RPCCablingSvc ) + + + from MuonRPC_Cabling.MuonRPC_CablingConf import MuonRPC_CablingSvc + rpcCablingSvc = MuonRPC_CablingSvc() + rpcCablingSvc.ConfFileName = 'LVL1confAtlas.data' # this should come from config flag maybe ??? + rpcCablingSvc.CorrFileName = 'LVL1confAtlas.corr' + rpcCablingSvc.ConfFilePath = 'MuonRPC_Cabling/' + rpcCablingSvc.RPCTriggerRoadsfromCool = True + #rpcCablingSvc.CosmicConfiguration = True # was set like this in egamma test, looks incorrect ??? + + from IOVDbSvc.IOVDbSvcConfig import addFolders + acc.merge(addFolders(flags, + [ '/RPC/TRIGGER/CM_THR_ETA', '/RPC/TRIGGER/CM_THR_ETA', '/RPC/TRIGGER/CM_THR_PHI', + '/RPC/TRIGGER/CM_THR_PHI', '/RPC/CABLING/MAP_SCHEMA', '/RPC/CABLING/MAP_SCHEMA_CORR' ], + 'RPC' )) + + # that should not be here??? + acc.getService('IOVDbSvc').FoldersToMetaData += ['/GLOBAL/BField/Maps'] + + + from RPC_CondCabling.RPC_CondCablingConf import RPCCablingDbTool + RPCCablingDbTool = RPCCablingDbTool() + RPCCablingDbTool.MapConfigurationFolder = '/RPC/CABLING/MAP_SCHEMA' + RPCCablingDbTool.MapCorrectionFolder = '/RPC/CABLING/MAP_SCHEMA_CORR' + + acc.addPublicTool( RPCCablingDbTool ) + rpcCablingSvc.TheRpcCablingDbTool = RPCCablingDbTool + + acc.addService( rpcCablingSvc ) + + return acc, rpcCablingSvc + +def TGCCablingConfig(flags): + acc = ComponentAccumulator() + + # TODO check if we actually need this here? + acc.merge(MuonGeoModelCfg(flags)) + + from TrigT1TGCRecRoiSvc.TrigT1TGCRecRoiSvcConf import LVL1TGC__TGCRecRoiSvc + acc.addService( LVL1TGC__TGCRecRoiSvc() ) + + from MuonCablingServers.MuonCablingServersConf import TGCcablingServerSvc + TGCCablingSvc = TGCcablingServerSvc() + TGCCablingSvc.Atlas=True + TGCCablingSvc.useMuonTGC_CablingSvc=True + TGCCablingSvc.forcedUse=True + acc.addService( TGCCablingSvc ) + + from IOVDbSvc.IOVDbSvcConfig import addFolders + acc.merge(addFolders(flags, ['/TGC/CABLING/MAP_SCHEMA','/TGC/CABLING/MAP_SCHEMA'], 'TGC')) + return acc, TGCCablingSvc + +if __name__ == '__main__': + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior=1 + from AthenaConfiguration.AllConfigFlags import ConfigFlags + + ConfigFlags.Input.Files =["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data17_13TeV.00327265.physics_EnhancedBias.merge.RAW._lb0100._SFO-1._0001.1"] + ConfigFlags.lock() + + from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + acc = ComponentAccumulator() + + acc.merge(RPCCablingConfig(ConfigFlags )) + acc.merge(TGCCablingConfig(ConfigFlags )) + + f=open('MuonCabling.pkl','w') + acc.store(f) + f.close() + + diff --git a/MuonSpectrometer/MuonConfig/python/MuonCalibConfig.py b/MuonSpectrometer/MuonConfig/python/MuonCalibConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..e0a810e60c83f923c7173cc2bbf2bd8e87bbc54b --- /dev/null +++ b/MuonSpectrometer/MuonConfig/python/MuonCalibConfig.py @@ -0,0 +1,233 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +# Based on : https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibConfig.py + +from MdtCalibSvc.MdtCalibSvcConf import MdtCalibrationDbSvc, MdtCalibrationSvc +from MdtCalibDbCoolStrTool.MdtCalibDbCoolStrToolConf import MuonCalib__MdtCalibDbCoolStrTool +from MuonCnvExample.MuonCnvUtils import mdtCalibWindowNumber, mdtCalibWindowName, specialAddFolderSplitOnline # TODO should maybe shift this elsewhere? +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg, addFolders +from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg + +# Probably shouldn't be here: +def addFoldersSplitOnline(flags, db, online_folders, offline_folders, className=None, addMCString="_OFL"): + "Add access to given folder, using online_folder online, offline_folder offline" + result=ComponentAccumulator() + + if flags.Common.isOnline and not configFlags.Input.isMC: + folders = online_folders + else: + # MC, so add addMCString + db = db+addMCString + folders = offline_folders + result.merge( addFolders(flags, folders, className=className, detDb=db) ) + return result, None + + +################################################################################ +# CSC calibration +################################################################################ + +# def setupCscCondDB(): +# # Access to the CSC calibration database +# # Copied and modified from: +# # include( "CscCalibTools/CscCalibTool_jobOptions.py" ) +# from MuonCondSvc.CscCondDB import cscCondDB +# +# ## Load Ped File +# if cscCalibFlags.CscPedFromLocalFile: +# cscCondDB.useLocalFile( True ) #All following "add" db folder commands are from local files +# cscCondDB.addPedFolder() #<--- Adds pedestal and noise folders +# cscCondDB.useLocalFile( False ) #To make sure to stop refering to local sqlite DB file +# else: +# cscCondDB.addPedFolder() #<--- Adds pedestal and noise folders +# +# ## Load Noise File +# if cscCalibFlags.CscNoiseFromLocalFile: +# cscCondDB.useLocalFile( True ) #All following "add" db folder commands are from local files +# cscCondDB.addNoiseFolder() #<--- Adds pedestal and noise folders +# cscCondDB.useLocalFile( False ) #To make sure to stop refering to local sqlite DB file +# else: +# cscCondDB.addNoiseFolder() #<--- Adds pedestal and noise folders +# +# ## Load PSlope File +# if cscCalibFlags.CscPSlopeFromLocalFile: +# cscCondDB.useLocalFile( True ) #All following "add" db folder commands are from local files +# cscCondDB.addPSlopeFolder() #<--- Adds pedestal and noise folders +# cscCondDB.useLocalFile( False ) #To make sure to stop refering to local sqlite DB file +# else: +# cscCondDB.addPSlopeFolder() #<--- Adds pedestal and noise folders +# +# ## Load Status File +# if cscCalibFlags.CscStatusFromLocalFile: +# cscCondDB.useLocalFile( True ) #All following "add" db folder commands are from local files +# cscCondDB.addStatusFolder() #<--- Adds pedestal and noise folders +# cscCondDB.useLocalFile( False ) #To make sure to stop refering to local sqlite DB file +# else: +# cscCondDB.addStatusFolder() #<--- Adds pedestal and noise folders +# +# ## Load Rms File +# if cscCalibFlags.CscRmsFromLocalFile: +# cscCondDB.useLocalFile( True ) #All following "add" db folder commands are from local files +# cscCondDB.addRmsFolder() #<--- Adds pedestal and noise folders +# cscCondDB.useLocalFile( False ) #To make sure to stop refering to local sqlite DB file +# else: +# cscCondDB.addRmsFolder() #<--- Adds pedestal and noise folders +# +# ## Load F001 File +# if cscCalibFlags.CscF001FromLocalFile: +# cscCondDB.useLocalFile( True ) #All following "add" db folder commands are from local files +# cscCondDB.addF001Folder() +# cscCondDB.useLocalFile( False ) #To make sure to stop refering to local sqlite DB file +# else: +# cscCondDB.addF001Folder() +# +# +# if not athenaCommonFlags.isOnline(): +# log = logging.getLogger(__name__+".setupCscCondDB()") +# log.info("This is for OffLine so T0Base and T0Phase folders are added!!") +# +# ## Load T0Base File +# if cscCalibFlags.CscT0BaseFromLocalFile: +# cscCondDB.useLocalFile( True ) #All following "add" db folder commands are from local files +# cscCondDB.addT0BaseFolder() +# cscCondDB.useLocalFile( False ) #To make sure to stop refering to local sqlite DB file +# else: +# cscCondDB.addT0BaseFolder() +# +# +# ## Load T0Phase File +# if cscCalibFlags.CscT0PhaseFromLocalFile: +# cscCondDB.useLocalFile( True ) #All following "add" db folder commands are from local files +# cscCondDB.addT0PhaseFolder() +# cscCondDB.useLocalFile( False ) #To make sure to stop refering to local sqlite DB file +# else: +# cscCondDB.addT0PhaseFolder() +# +# #cscCondDB.addPedFolders() #<--- Adds pedestal and noise folders +# #cscCondDB.addAllFolders() +# +# # end of function setupCscCondDB() +# +# # +# def CscCalibTool(name,**kwargs): +# # setup condDB folders +# setupCscCondDB() +# # make tool +# return CfgMgr.CscCalibTool( +# Slope=0.19, +# Noise=3.5, +# Pedestal=2048.0, +# ReadFromDatabase=True, +# SlopeFromDatabase=False, +# integrationNumber=12.0, +# integrationNumber2=11.66, +# samplingTime=50.0, +# signalWidth=14.40922, +# timeOffset=71.825, +# IsOnline = athenaCommonFlags.isOnline(), +# Latency = 119 +# ) +# # timeOffset=46.825) + 25 SimHIT digit time + + +################################################################################ +# MDT calibration +################################################################################ + +def _setupMdtCondDB(flags): + result=ComponentAccumulator() + + # print '_setupMdtCondDB flags.Muon.Calib.readMDTCalibFromBlob:',flags.Muon.Calib.readMDTCalibFromBlob + if flags.Muon.Calib.readMDTCalibFromBlob: + mdt_folder_name_appendix = "BLOB" + else: + mdt_folder_name_appendix="" + + online_folders = ['/MDT/Onl/RT'+ mdt_folder_name_appendix,'/MDT/Onl/T0' + mdt_folder_name_appendix] + offline_folders = ['/MDT/RT' + mdt_folder_name_appendix, '/MDT/T0' + mdt_folder_name_appendix] + + if flags.Muon.Calib.mdtCalibrationSource=="MDT": + result.merge(addFoldersSplitOnline(flags, 'MDT', online_folders , offline_folders ) ) + else: + from AthenaCommon.AppMgr import ServiceMgr + ServiceMgr.TagInfoMgr.ExtraTagValuePairs += ["MDTCalibrationSource", flags.Muon.Calib.mdtCalibrationSource()] # TODO Check this. + addMCString=None + result.merge(addFoldersSplitOnline(flags, flags.Muon.Calib.mdtCalibrationSource, online_folders, offline_folders ) ) + + return result, mdt_folder_name_appendix +# end of function setupMdtCondDB() + +def MdtCalibDbToolCfg(flags,**kwargs): + result=ComponentAccumulator() + + # result.merge( IOVDbSvcCfg(flags) ) + + # setup COOL folders + acc, mdt_folder_name_appendix = _setupMdtCondDB(flags) + result.merge(acc) + + # set some default proper ties + from IOVDbSvc.CondDB import conddb + if conddb.isOnline and not conddb.isMC: + kwargs.setdefault("TubeFolder", "/MDT/T0") + kwargs.setdefault("RtFolder", "/MDT/RT") + else: + kwargs.setdefault("TubeFolder", "/MDT/T0"+ mdt_folder_name_appendix) + kwargs.setdefault("RtFolder", "/MDT/RT"+ mdt_folder_name_appendix) + kwargs.setdefault("RT_InputFiles" , ["Muon_RT_default.data"]) + if not flags.Input.isMC == 'data': + kwargs.setdefault("defaultT0", 40) + else: + kwargs.setdefault("defaultT0", 799) + kwargs.setdefault("UseMLRt", flags.Muon.Calib.useMLRt ) + kwargs.setdefault("TimeSlewingCorrection", flags.Muon.Calib.correctMdtRtForTimeSlewing) + kwargs.setdefault("MeanCorrectionVsR", [ -5.45973, -4.57559, -3.71995, -3.45051, -3.4505, -3.4834, -3.59509, -3.74869, -3.92066, -4.10799, -4.35237, -4.61329, -4.84111, -5.14524 ]) + kwargs.setdefault("PropagationSpeedBeta", flags.Muon.Calib.mdtPropagationSpeedBeta) + return result, MuonCalib__MdtCalibDbCoolStrTool(**kwargs) + +def MdtCalibrationDbSvcCfg(flags, **kwargs): + result=ComponentAccumulator() + + kwargs.setdefault( "CreateBFieldFunctions", flags.Muon.Calib.correctMdtRtForBField ) + kwargs.setdefault( "CreateWireSagFunctions", flags.Muon.Calib.correctMdtRtWireSag ) + kwargs.setdefault( "CreateSlewingFunctions", flags.Muon.Calib.correctMdtRtForTimeSlewing) + + acc, mdt_calib_db_tool = MdtCalibDbToolCfg(flags) + acc.addPublicTool(mdt_calib_db_tool) + result.merge(acc) + # kwargs.setdefault( "DBTool", mdt_calib_db_tool ) + + mdt_calib_db_svc = MdtCalibrationDbSvc(**kwargs) + result.addService(mdt_calib_db_svc) + + return result, mdt_calib_db_svc + +def MdtCalibrationSvcCfg(flags, **kwargs): + result=ComponentAccumulator() + + # call dependent tools. TODO: fix in C++ (move to ServiceHandle + declareProperty) + # C++ code is missing Property declaration of MagFieldSvc, but it does depend on it. + + acc, mag_field_svc = MagneticFieldSvcCfg(flags) + result.merge( acc ) + + acc, mdt_calibration_db_svc = MdtCalibrationDbSvcCfg(flags) + result.merge(acc) + + kwargs.setdefault( "DoSlewingCorrection", flags.Muon.Calib.correctMdtRtForTimeSlewing ) + +# Hack to use DoTemperatureCorrection for applyRtScaling; but applyRtScaling should not be used anyway, since MLRT can be used + kwargs.setdefault( "DoTemperatureCorrection", flags.Muon.Calib.applyRtScaling ) #TODO get MDT expert to help fix this. + kwargs.setdefault( "DoWireSagCorrection", flags.Muon.Calib.correctMdtRtWireSag ) + if flags.Beam.Type== 'collisions': + kwargs.setdefault("DoTofCorrection",True) + # for collisions cut away hits that are far outside of the MDT time window + kwargs.setdefault( "TimeWindowSetting", mdtCalibWindowNumber('Collision_G4') ) + + else: # cosmics or single beam + kwargs.setdefault("DoTofCorrection",False) + + mdt_calib_svc = MdtCalibrationSvc(**kwargs) + result.addService(mdt_calib_svc) + return result, MdtCalibrationSvc(**kwargs) diff --git a/MuonSpectrometer/MuonConfig/python/MuonCondSvcConfig.py b/MuonSpectrometer/MuonConfig/python/MuonCondSvcConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..17c7c55f47b7dc44d3b3291f68add5c7628c398d --- /dev/null +++ b/MuonSpectrometer/MuonConfig/python/MuonCondSvcConfig.py @@ -0,0 +1,97 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +# Based on http://acode-browser1.usatlas.bnl.gov/lxr/source/athena/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondSvc/python/ + +# Looking here in particular: http://acode-browser1.usatlas.bnl.gov/lxr/source/athena/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondSvc/python/MuonTopCondSvcConfigRUN2.py +# FIXME - work out how to support run1 +# FIXME - in general my impression is that this is overly complicated and needs a huge clean up (the code, not just the configuration) + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from MuonStationIntersectSvc.MuonStationIntersectSvcConf import MuonStationIntersectSvc +from MuonCondSvc.MuonCondSvcConf import MDTCondSummarySvc, RPCCondSummarySvc, CSCCondSummarySvc, \ + TGCCondSummarySvc, MDT_DQConditionsSvc, MDT_DCSConditionsRun2Svc, MDT_DCSConditionsSvc +from MuonCondTool.MuonCondToolConf import MDT_DCSConditionsTool, MDT_DCSConditionsRun2Tool, MDT_MapConversion +from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg, addFolders + +# def MDT_DCSConditionsSvcCfg(flags, **kwargs): +# result = ComponentAccumulator() +# # FIXME! Finish. +# dcs_cond_svc = MDT_DCSConditionsSvc(MDT_DQConditionsTool=mdt_dcs_cond_tool) +# result.addService(result) +# return result + +def MDTCondSummarySvcCfg(flags, **kwargs): + # This is probably wrong. I'm pretty confused by this for the moment. + result = ComponentAccumulator() + # result.merge(IOVDbSvcCfg(flags)) + if flags.Common.isOnline: + kwargs['ConditionsServices'] = [] # COOL folders not available online + else: + if flags.Input.isMC : # OFLP200 + mdt_dcs_cond_tool = MDT_DCSConditionsTool(Simulation_Setup=flags.Input.isMC) + result.addPublicTool(mdt_dcs_cond_tool) + cond_svc = MDT_DCSConditionsSvc(MDT_DCSConditionsTool = mdt_dcs_cond_tool) + folders = [ "/MDT/DCS/DROPPEDCH", "/MDT/DCS/PSLVCHSTATE" ] # FIXME got this by observing other job ... not really sure if it's correct + else: + # if conddb.dbdata=="CONDBR2": + # kwargs['ConditionsServices'] = ['MDT_DCSConditionsRun2Svc'] + # else: + # kwargs['ConditionsServices'] = ['MDT_DCSConditionsSvc'] + if flags.IOVDb.DatabaseInstance=='CONDBR2': # CONDBR2 - run 2 data + map_conversion_tool = MDT_MapConversion() + result.addPublicTool(map_conversion_tool) + + mdt_dcs_cond_tool=MDT_DCSConditionsRun2Tool(MDT_MapConversion=map_conversion_tool) + result.addPublicTool(mdt_dcs_cond_tool) + cond_svc = MDT_DCSConditionsRun2Svc(MDT_DCSConditionsRun2Tool=mdt_dcs_cond_tool) + # folders = ['/MDT/DCS/DROPPEDCH','/MDT/DCS/PSHVMLSTATE','/MDT/DCS/PSLVCHSTATE','/MDT/DCS/JTAGCHSTATE','/MDT/DCS/PSV0SETPOINTS', '/MDT/DCS/PSV1SETPOINTS'] + folders = [ "LVFolder", "HVFolder" ] + else: + # Not yet implemented. Need to try to understand what on earth is going on first. + mdt_dcs_cond_tool = MDT_DCSConditionsTool(Simulation_Setup=flags.Input.isMC) + result.addPublicTool(mdt_dcs_cond_tool) + cond_svc = MDT_DCSConditionsSvc(MDT_DCSConditionsTool=mdt_dcs_cond_tool) + folders = [ "LVFolder", "HVFolder" ] + result.merge( addFolders(flags, folders , detDb="DCS_OFL") ) # TODO FIXME! Get correct list + result.addService(cond_svc) + kwargs['ConditionsServices'] = [cond_svc] # COOL folders not available online + cond_summary = MDTCondSummarySvc(**kwargs) + result.addService(cond_summary) + return result, cond_summary + +def RPCCondSummarySvcCfg(flags,**kwargs): + result = ComponentAccumulator() + result.merge(IOVDbSvcCfg(flags)) + + if flags.Common.isOnline: + kwargs['ConditionsServices'] = [] # COOL folders not available online + else: + if flags.Input.isMC: + kwargs['ConditionsServices'] = ['RPC_STATUSConditionsSvc'] + else: + kwargs['ConditionsServices'] = ['RPC_STATUSConditionsSvc','RPC_DCSConditionsSvc'] # COOL folders not available online + + return RPCCondSummarySvc(name,**kwargs) + +def CSCCondSummarySvcCfg(flags,**kwargs): + result = ComponentAccumulator() + result.merge(IOVDbSvcCfg(flags)) + + if flags.Common.isOnline: + kwargs['ConditionsServices'] = [] # COOL folders not available online + return CSCCondSummarySvc(name,**kwargs) + +def TGCCondSummarySvcCfg(flags,**kwargs): + result = ComponentAccumulator() + result.merge(IOVDbSvcCfg(flags)) + + if flags.Common.isOnline: + kwargs['ConditionsServices'] = [] # COOL folders not available online + return TGCCondSummarySvc(name,**kwargs) + +# def MuonStationIntersectSvcCfg(flags, **kwargs): +# # has dependencies on +# # 'IdHelper' : PublicToolHandle('Muon::MuonIdHelperTool/MuonIdHelperTool'), # GaudiHandle +# # 'MDTCondSummarySvc' : ServiceHandle('MDTCondSummarySvc'), # GaudiHandle +# result=ComponentAccumulator() + diff --git a/MuonSpectrometer/MuonConfig/python/MuonConfigFlags.py b/MuonSpectrometer/MuonConfig/python/MuonConfigFlags.py new file mode 100644 index 0000000000000000000000000000000000000000..d0948e2cc301defa17c6671ca104b7155ff9d04d --- /dev/null +++ b/MuonSpectrometer/MuonConfig/python/MuonConfigFlags.py @@ -0,0 +1,117 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.AthConfigFlags import AthConfigFlags + +# Some comments from Ed about existing flags +# MuonCnvExample +# - MuonCnvFlags - not sure we need this - it really only configures single properties of the various cablings - we can just do this directly. +# - MuonCalibFlags - looks like we need this + +# MuonByteStream +# - MuonByteStreamFlags.py - AFAICS this is only used here MuonCablings/MuonCablingServers/python/MuonCablingServersConfig.py, MuonCnv/MuonCnvExample/python/MuonCablingConfig.py & duplicates global flag functionality. + +# MuonRecExample +# - MuonAlignFlags.py - looks necessary +# - MuonStandaloneFlags.py - necessary, but should be cleaned up (and probably merged with MuonRecFlags i.e. here) +# https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonStandaloneFlags.py +# - MuonRecFlags.py - necessary, but needs cleaning up. +# https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonRecFlags.py + +def createMuonConfigFlags(): + mcf=AthConfigFlags() + + # Geometry flags + mcf.addFlag("Muon.doMDTs",True) + mcf.addFlag("Muon.doTGCs",True) + mcf.addFlag("Muon.doRPCs",True) + # TODO auto handle NSW here. + mcf.addFlag("Muon.doCSCs",True) + mcf.addFlag("Muon.doMicromegas",False) + mcf.addFlag("Muon.dosTGCs",False) + + # stages of processing + # 1. Digitization + mcf.addFlag("Muon.doDigitization",True) + mcf.addFlag("Muon.doFastDigitization",False) + mcf.addFlag("Muon.doPseudoTracking",False) + + # 2. Reco MuonRecFlags + + mcf.addFlag("Muon.doTGCClusterSegmentFinding", False) # Run cluster segment finding + mcf.addFlag("Muon.doRPCClusterSegmentFinding", False) # Run cluster segment finding + mcf.addFlag("Muon.prdToxAOD", False) # Run clusterization + mcf.addFlag("Muon.rpcRawToxAOD", False) # Add RPC RDO to xAOD + mcf.addFlag("Muon.doMSVertex", False) # Run MS vertex (arXiv:1311.7070) + # mcf.addFlag("Muon.doDigitization", False) # TODO rename? Re-run muon digitization on-the-fly just before reconstruction. Needs DIGITS as input file. + # mcf.addFlag("Muon.doSegmentsOnly", False) # Stop reconstruction after segment making. Typically used when making Calibration Ntuple. TODO surely redundant? + + mcf.addFlag("Muon.doSegmentT0Fit",False) # Fit MDT segments using a variable t0. Used for cosmics and single beam to compensate for large errors on the trigger time. + mcf.addFlag("Muon.enableErrorTuning",False) # turn on error tuning to account for misalignments + mcf.addFlag("Muon.useLooseErrorTuning",False) + mcf.addFlag("Muon.useTGCPriorNextBC",False) # Use TGC measurements from Prior and Next Bunch Crossings. These measurements are available in the real data since somewhere in 2008. + mcf.addFlag("Muon.useAlignmentCorrections",False) # Apply alignment corrections to MuonGeoModel. The corrections are read from a COOL database + mcf.addFlag("Muon.useWireSagCorrections",False) # tApply wire sag corrections. + + # makePRDs - surely this is top level and redundant with makeRIO? + + # MuonStandaloneFlags.py + mcf.addFlag("Muon.printSummary", False) # Print out a summary for each event at each reco stage + mcf.addFlag("Muon.segmentOrigin", "Muon") # Can be 'Muon','TruthTracking' + # reconstructionMode - I think this is a complete duplication of global.BeamType. Dropping. + mcf.addFlag("Muon.strategy", []) # CutSeedsOnTracks, CombineSegInStation, DynamicSeeding, PreferOutsideIn, AllowOneSharedHit, DoRefinement, DoAmbiSolving + mcf.addFlag("Muon.trackBuilder", "Moore") # Allowed: 'Moore','TruthTracking','None' + mcf.addFlag("Muon.refinementTool", "Moore") # Allowed: Moore TODO surely we can drop this if there is only one option? + mcf.addFlag("Muon.optimiseMomentumResolutionUsingChi2", False) + mcf.addFlag("Muon.patternsOnly", False) # TODO probably can be dropped? Just disable later steps. + mcf.addFlag("Muon.createTrackParticles", True ) # TODO do we ever turn this off? + mcf.addFlag("Muon.straightLineFitMomentum", 2000.0 ) + #mcf.addFlag("Muon.doSegmentsOnly", True) # Also in MuonRecFlags ... redundant in both? + mcf.addFlag("Muon.Chi2NDofCut", 20.0 ) # chi-squared per degree of freedom cut in fitter. + mcf.addFlag("Muon.enableCurvedSegmentFinding", False ) # TODO I think this one could possibly be removed, since it really is a Tool level configuration. + mcf.addFlag("Muon.updateSegmentSecondCoordinate", lambda prevFlags : prevFlags.Beam.Type=="collisions") # Do not use for cosmics or singlebeam + + mcf.addFlag("Muon.useSegmentMatching", lambda prevFlags : prevFlags.Beam.Type=="collisions") # Do not use for cosmics or singlebeam + mcf.addFlag("Muon.useTrackSegmentMatching", True ) + + # CalibFlags + mcf.addFlag("Muon.Calib.readMDTCalibFromBlob", True) # Read mdt tube calibration from blob-folders + mcf.addFlag("Muon.Calib.correctMdtRtForBField", False) # Apply B-field correction to drift times + mcf.addFlag("Muon.Calib.correctMdtRtForTimeSlewing", False) # Apply time slewing correction to drift time + mcf.addFlag("Muon.Calib.useMLRt", True) # use ML-RT functions from COOL + mcf.addFlag("Muon.Calib.applyRtScaling", True) # TODO - apparently not needed, but currently used in MuonCalibConfig. + mcf.addFlag("Muon.Calib.correctMdtRtWireSag", False) # Apply RT wiresag correction + mcf.addFlag("Muon.Calib.mdtCalibrationSource", "MDT") # Source for MDT t0s and rts + mcf.addFlag("Muon.Calib.mdtPropagationSpeedBeta", 0.85) # + + mcf.addFlag("Muon.Calib.CscPedFromLocalFile", False) + mcf.addFlag("Muon.Calib.CscNoiseFromLocalFile", False) + mcf.addFlag("Muon.Calib.CscPSlopeFromLocalFile", False) + mcf.addFlag("Muon.Calib.CscStatusFromLocalFile", False) + mcf.addFlag("Muon.Calib.CscRmsFromLocalFile", False) + mcf.addFlag("Muon.Calib.CscF001FromLocalFile", False) + mcf.addFlag("Muon.Calib.CscT0BaseFromLocalFile", False) + mcf.addFlag("Muon.Calib.CscT0PhaseFromLocalFile", False) + + mcf.addFlag("Muon.Calib.EventTag", "MoMu") + + # Choose the (MDT) calibration mode. + # 'ntuple' : write standard calibration ntuple (up to segments) + # 'trackNtuple' : write standard ntuple + tracks + # 'regionNtuple' : write one ntuple per calibration region + # 't0Classic' : do classic t0 calibration + # 't0MT' : do MT t0 calibration + # 'rtClassic' : do classic rt calibration + # 'rtAnalytic' : do analytic rt calibration + mcf.addFlag("Muon.Calib.mdtMode", "ntuple") + + # Muon Align flags + + mcf.addFlag("Muon.Align.UseALines", False) + mcf.addFlag("Muon.Align.UseBLines", 'none') # Can be ['none','all','barrel','endcaps'] + mcf.addFlag("Muon.Align.UseILines", False) + mcf.addFlag("Muon.Align.UseAsBuilt", False) + + # TODO - add configuration for above + + return mcf + diff --git a/MuonSpectrometer/MuonConfig/python/MuonGeometryConfig.py b/MuonSpectrometer/MuonConfig/python/MuonGeometryConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..d3c05941d48d12a53f639c1cc8b1f39c3c21e2fe --- /dev/null +++ b/MuonSpectrometer/MuonConfig/python/MuonGeometryConfig.py @@ -0,0 +1,25 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AtlasGeoModel.GeoModelConfig import GeoModelCfg +from MuonGeoModel.MuonGeoModelConf import MuonDetectorTool +from MuonIdHelpers.MuonIdHelpersConf import Muon__MuonIdHelperTool +from StoreGate.StoreGateConf import StoreGateSvc + +def MuonGeoModelCfg(flags): + acc = ComponentAccumulator() + + # get the GeoModelSvc and add MuonDetectorTool + gmsAcc,gms=GeoModelCfg(flags ) + acc.merge(gmsAcc) + + detTool = MuonDetectorTool() + detTool.UseConditionDb = 1 + detTool.UseIlinesFromGM = 1 + gms.DetectorTools += [ detTool ] + acc.addService(gms) + + # Temporary, until we move to services/private tools + acc.addPublicTool( Muon__MuonIdHelperTool() ) + + return acc diff --git a/MuonSpectrometer/MuonConfig/python/MuonRIO_OnTrackCreatorConfig.py b/MuonSpectrometer/MuonConfig/python/MuonRIO_OnTrackCreatorConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..9aa6b8d5b6f7290430823f8c7801521d3e6d853b --- /dev/null +++ b/MuonSpectrometer/MuonConfig/python/MuonRIO_OnTrackCreatorConfig.py @@ -0,0 +1,118 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from MuonConfig.MuonCalibConfig import MdtCalibrationSvcCfg, MdtCalibrationDbSvcCfg +from MuonCnvExample.MuonCnvUtils import mdtCalibWindowNumber # TODO should maybe shift this elsewhere? +from MdtDriftCircleOnTrackCreator.MdtDriftCircleOnTrackCreatorConf import Muon__MdtDriftCircleOnTrackCreator +from MuonClusterOnTrackCreator.MuonClusterOnTrackCreatorConf import Muon__CscClusterOnTrackCreator, Muon__MuonClusterOnTrackCreator +from TrkRIO_OnTrackCreator.TrkRIO_OnTrackCreatorConf import Trk__RIO_OnTrackCreator + +def CscClusterOnTrackCreatorCfg(flags,**kwargs): + from MuonConfig.MuonSegmentFindingConfig import QratCscClusterFitterCfg + + result=ComponentAccumulator() + + acc, qrat = MuonConfig.MuonSegmentFindingConfig.QratCscClusterFitterCfg(flags) + result.addPublicTool(qrat) + result.merge(acc) + + # TODO fix this + # kwargs.setdefault("CscStripFitter", getPublicTool("CalibCscStripFitter") ) + kwargs.setdefault("CscClusterFitter", qrat ) + # kwargs.setdefault("CscClusterUtilTool", getPublicTool("CscClusterUtilTool") ) + if False : # enable CscClusterOnTrack error scaling : + from InDetRecExample.TrackingCommon import getRIO_OnTrackErrorScalingCondAlg,createAndAddCondAlg + createAndAddCondAlg(getMuonRIO_OnTrackErrorScalingCondAlg,'RIO_OnTrackErrorScalingCondAlg') + + kwargs.setdefault("CSCErrorScalingKey","/MUON/TrkErrorScalingCSC") + + if not flags.Input.isMC: # collisions real data or simulated first data + # scale CSC and hit errors + kwargs.setdefault("ErrorScalerBeta", 0.070 ) + + csc_cluster_creator = Muon__CscClusterOnTrackCreator(**kwargs) + + return result, csc_cluster_creator + + +def MdtDriftCircleOnTrackCreatorCfg(flags,**kwargs): + result=ComponentAccumulator() + + # setup dependencies missing in C++. TODO: fix in C++ + acc, mdt_calib_svc = MdtCalibrationSvcCfg(flags) + result.merge(acc) + + acc,mdt_calib_db_svc = MdtCalibrationDbSvcCfg(flags) + result.merge(acc) + + kwargs.setdefault("DoMagneticFieldCorrection", flags.Muon.Calib.correctMdtRtForBField) + kwargs.setdefault("DoWireSag", flags.Muon.useWireSagCorrections) + kwargs.setdefault("DoSlewingCorrection", flags.Muon.Calib.correctMdtRtForTimeSlewing) + + if flags.Beam.Type== 'cosmics' or flags.Beam.Type == 'singlebeam' : + kwargs.setdefault("DoTofCorrection", False) + kwargs.setdefault("DoFixedError", True) + kwargs.setdefault("TimingMode", 1) + kwargs.setdefault("UseParametrisedError", True) + + else: # collisions simulation/data settings + kwargs.setdefault("DoTofCorrection", True) + kwargs.setdefault("DoFixedError", False) + kwargs.setdefault("DoErrorScaling", False) + kwargs.setdefault("MuonTofTool", None) + kwargs.setdefault("TimeWindowSetting", mdtCalibWindowNumber('Collision_data')) # MJW: should this be Collision_G4 ??? + kwargs.setdefault("UseParametrisedError", False) + + if not flags.Input.isMC : + kwargs.setdefault("CreateTubeHit", True) # BroadErrors + kwargs.setdefault("UseLooseErrors", flags.Muon.useLooseErrorTuning) # LooseErrors on data + + kwargs.setdefault("IsMC", flags.Input.isMC) + + return result,Muon__MdtDriftCircleOnTrackCreator(**kwargs) + +def MuonClusterOnTrackCreatorCfg(flags,**kwargs): + result=ComponentAccumulator() + if not flags.Input.isMC: # collisions real data or simulated first data + # scale TGC eta hit errors as long as TGC eta are not well aligned + kwargs.setdefault("DoFixedErrorTgcEta", True) + kwargs.setdefault("FixedErrorTgcEta", 15.) + + # TODO Fixme - the cxx class retrieves public MuonIdHelperTool ... should be private / service. + + muon_cluster_rot_creator = Muon__MuonClusterOnTrackCreator(**kwargs) + return result, muon_cluster_rot_creator + + +# default RIO_OnTrackCreator for muons +# make a dedicated class to delay instantiation of the muon RIO_OnTrack creators members +# class MuonRotCreator(Trk__RIO_OnTrackCreator,ConfiguredBase): +# __slots__ = () +# +# def __init__(self,name="MuonRotCreator",**kwargs): +# self.applyUserDefaults(kwargs,name) +# kwargs.setdefault("ToolMuonDriftCircle", "MdtDriftCircleOnTrackCreator") +# kwargs.setdefault("ToolMuonCluster", "MuonClusterOnTrackCreator") +# kwargs.setdefault("Mode", 'muon' ) +# super(MuonRotCreator,self).__init__(name,**kwargs) +# end of class MuonRotCreator + +def MuonRotCreatorCfg(flags, **kwargs): + result=ComponentAccumulator() + acc, mdt_rot_creator = MdtDriftCircleOnTrackCreatorCfg(flags) + acc.addPublicTool(mdt_rot_creator) # TODO remove + result.merge(acc) + + acc, cluster_rot_creator = MuonClusterOnTrackCreatorCfg(flags) + acc.addPublicTool(cluster_rot_creator) # TODO remove + result.merge(acc) + kwargs.setdefault("ToolMuonDriftCircle", mdt_rot_creator) + kwargs.setdefault("ToolMuonCluster", cluster_rot_creator) + kwargs.setdefault("ToolPixelCluster", None) + kwargs.setdefault("ToolSCT_Cluster", None) + kwargs.setdefault("ToolTRT_DriftCircle", None) + kwargs.setdefault("Mode", 'muon' ) + + muon_rot_creator = Trk__RIO_OnTrackCreator(**kwargs) + return result, muon_rot_creator + diff --git a/MuonSpectrometer/MuonConfig/python/MuonReconstructionConfig.py b/MuonSpectrometer/MuonConfig/python/MuonReconstructionConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..00d03f611e9468bef1093b86c45208f624b844ee --- /dev/null +++ b/MuonSpectrometer/MuonConfig/python/MuonReconstructionConfig.py @@ -0,0 +1,41 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + +from AthenaCommon import CfgMgr +from AthenaCommon.CfgGetter import getPublicTool,getPublicToolClone,getPrivateTool + +def MuonReconstructionCfg(flags): + # TODO - add lots! + # https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonStandalone.py + result=ComponentAccumulator() + from MuonConfig.MuonSegmentFindingConfig import MuonSegmentFindingCfg + result.merge( MuonSegmentFindingCfg(flags) ) + return result + +if __name__=="__main__": + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior=1 + + from AthenaCommon.Logging import log + from AthenaCommon.Constants import DEBUG + from AthenaConfiguration.AllConfigFlags import ConfigFlags + + log.setLevel(DEBUG) + + ConfigFlags.Input.isMC=False + ConfigFlags.Input.Files = ["myESD.pool.root"] + ConfigFlags.lock() + + cfg=ComponentAccumulator() + + from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg + cfg.merge(PoolReadCfg(ConfigFlags)) + + acc=MuonReconstructionCfg(ConfigFlags) + + cfg.merge(acc) + + f=open("MuonReconstruction.pkl","w") + cfg.store(f) + f.close() diff --git a/MuonSpectrometer/MuonConfig/python/MuonSegmentFindingConfig.py b/MuonSpectrometer/MuonConfig/python/MuonSegmentFindingConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..3d7da112aadaaa5962a4edd2de71a93ef7dc6c4b --- /dev/null +++ b/MuonSpectrometer/MuonConfig/python/MuonSegmentFindingConfig.py @@ -0,0 +1,834 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +# This file configures the Muon segment finding. It is based on a few files in the old configuration system: +# Tools, which are configured here: +# https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonRecTools.py +# https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MooreTools.py +# from https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/CscTools.py +# +# and algorithms which are defined in several places: +# +# +# When porting it I have tried to remove anything redundant, and I have tried to simplify the number of configuration techniques +# used, so for example I'm no longer using CfgGetter, and am minimising the use of CfgMgr, + +# There is now quite a lot in here not solely needed for SegmentFinding, so probably need to spit into another fragment. +# Core +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + +# Tracking +from TrkMeasurementUpdator.TrkMeasurementUpdatorConf import Trk__KalmanUpdator +from TrkExTools.TrkExToolsConf import Trk__MaterialEffectsUpdator, Trk__EnergyLossUpdator, Trk__MultipleScatteringUpdator, Trk__Navigator +from TrkDetDescrSvc.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg +from TrkExSTEP_Propagator.TrkExSTEP_PropagatorConf import Trk__STEP_Propagator +from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__TrackSelectionProcessorTool +from TrkTrackSummaryTool.TrkTrackSummaryToolConf import Trk__TrackSummaryTool + +# Muon +from CscSegmentMakers.CscSegmentMakersConf import CscSegmentUtilTool, Csc2dSegmentMaker, Csc4dSegmentMaker +from DCMathSegmentMaker.DCMathSegmentMakerConf import Muon__DCMathSegmentMaker, Muon__MdtMathSegmentFinder, Muon__MuonSegmentFittingTool, Muon__MuonClusterSegmentFinderTool +from MuonTrackFinderTools.MuonTrackFinderToolsConf import Muon__MuonTrackCleaner, Muon__MuonTrackScoringTool +from MuonCompetingClustersOnTrackCreator.MuonCompetingClustersOnTrackCreatorConf import Muon__TriggerChamberClusterOnTrackCreator +from MuonStationIntersectSvc.MuonStationIntersectSvcConf import MuonStationIntersectSvc +from MuonSegmentSelectionTools.MuonSegmentSelectionToolsConf import Muon__MuonSegmentSelectionTool, Muon__MuonSegmentHitSummaryTool +from MdtSegmentT0Fitter.MdtSegmentT0FitterConf import TrkDriftCircleMath__MdtSegmentT0Fitter +from MuonClusterSegmentMakerTools.MuonClusterSegmentMakerToolsConf import Muon__MuonClusterSegmentFinder +from MuonAmbiTrackSelectionTool.MuonAmbiTrackSelectionToolConf import Muon__MuonAmbiTrackSelectionTool + +#Local +import MuonConfig.MuonRIO_OnTrackCreatorConfig # Trying to avoid circular dependencies here +from MuonConfig.MuonCondSvcConfig import MDTCondSummarySvcCfg +from MuonConfig.MuonCalibConfig import MdtCalibrationDbSvcCfg + +def MuonTrackSummaryHelperToolCfg(flags, **kwargs): + # m_muonTgTool("MuonHolesOnTrack"), + # m_idHelperTool("Muon::MuonIdHelperTool/MuonIdHelperTool"), + # m_edmHelperTool("Muon::MuonEDMHelperTool/MuonEDMHelperTool"), + # m_extrapolator("Trk::Extrapolator/AtlasExtrapolator"), + # m_slExtrapolator("Trk::Extrapolator/MuonStraightLineExtrapolator"), + + result = ComponentAccumulator() + acc, geom_svc = TrackingGeometrySvcCfg(flags) + result.merge(acc) + kwargs.setdefault("TrackingGeometryName", 'AtlasTrackingGeometry') # FIXME - get this from somewhere? + + acc, extrap = MuonExtrapolatorCfg(flags) + acc.addPublicTool(extrap) + result.merge(acc) + kwargs.setdefault("Extrapolator", extrap) + + kwargs.setdefault("DoHolesOnTrack", False) + kwargs.setdefault("CalculateCloseHits", True) + + from MuonTrackSummaryHelperTool.MuonTrackSummaryHelperToolConf import Muon__MuonTrackSummaryHelperTool + + return result, Muon__MuonTrackSummaryHelperTool(**kwargs) + + +def MuonTrackSummaryToolCfg(flags, **kwargs): + result = ComponentAccumulator() + acc, track_summary_helper = MuonTrackSummaryHelperToolCfg(flags) + acc.addPublicTool(track_summary_helper) + result.merge(acc) + kwargs.setdefault("MuonSummaryHelperTool", track_summary_helper ) + kwargs.setdefault("doSharedHits", False ) + kwargs.setdefault("AddDetailedMuonSummary", True ) + return result, Trk__TrackSummaryTool(**kwargs) + +def MuonTrackScoringToolCfg(flags, **kwargs): + # m_trkSummaryTool("Trk::TrackSummaryTool"), + # m_printer("Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"), + result = ComponentAccumulator() + acc,muon_track_summary_tool = MuonTrackSummaryToolCfg(flags) + acc.addPublicTool(muon_track_summary_tool) + result.merge(acc) + kwargs.setdefault('SumHelpTool', muon_track_summary_tool) + scoring_tool = Muon__MuonTrackScoringTool(**kwargs) + return result, scoring_tool + +def MuonAmbiProcessorCfg(flags, **kwargs): + #m_scoringTool("Trk::TrackScoringTool/TrackScoringTool"), + #m_selectionTool("InDet::InDetAmbiTrackSelectionTool/InDetAmbiTrackSelectionTool") + result = ComponentAccumulator() + kwargs.setdefault('DropDouble', False) + acc, scoring_tool = MuonTrackScoringToolCfg( flags ) + acc.addPublicTool(scoring_tool) + result.merge(acc) + kwargs.setdefault('ScoringTool', scoring_tool ) + muon_ami_selection_tool = Muon__MuonAmbiTrackSelectionTool() + result.addPublicTool(muon_ami_selection_tool) + kwargs.setdefault('SelectionTool', muon_ami_selection_tool) + + return result, Trk__TrackSelectionProcessorTool(**kwargs) + +# This probably doesn't belong here. +def MuonStationIntersectSvcCfg(flags, **kwargs): + # Has dependency on MDTCondSummarySvc and IdHelperTool (which we ignore for now) + result = ComponentAccumulator() + acc, mdt_cond_summary_svc = MDTCondSummarySvcCfg(flags) + result.merge(acc) + kwargs.setdefault("MDTCondSummarySvc", mdt_cond_summary_svc) + muon_station_intersect_svc = MuonStationIntersectSvc(**kwargs) + result.addService(muon_station_intersect_svc) + return result, muon_station_intersect_svc + +# default muon navigator +def MuonNavigatorCfg(flags, **kwargs): + result = ComponentAccumulator() + + acc, tracking_geom_service = TrackingGeometrySvcCfg(flags) + result.merge(acc) + kwargs.setdefault("TrackingGeometrySvc", tracking_geom_service) + + navigator = Trk__Navigator(**kwargs) + result.addPublicTool(navigator) + return result,navigator + +def MuonExtrapolatorCfg(flags,**kwargs): + from TrkExTools.TrkExToolsConf import Trk__Extrapolator + result = ComponentAccumulator() + + energy_loss_updator = Trk__EnergyLossUpdator() # Not really sure these should be tools... + result.addPublicTool(energy_loss_updator) # TODO remove + + # This one has a dependency on RndNumberService + mult_scat_updator = Trk__MultipleScatteringUpdator() + result.addPublicTool(mult_scat_updator) # TODO remove + + material_effects_updator = Trk__MaterialEffectsUpdator( EnergyLossUpdator=energy_loss_updator, MultipleScatteringUpdator=mult_scat_updator) + result.addPublicTool(material_effects_updator) + kwargs.setdefault("MaterialEffectsUpdators", [material_effects_updator]) + + acc,navigator = MuonNavigatorCfg(flags) + acc.addPublicTool(navigator) + result.merge(acc) + kwargs.setdefault("Navigator", navigator) + + muon_prop = Trk__STEP_Propagator(Tolerance = 0.00001, MaterialEffects=True, IncludeBgradients=True) + acc.addPublicTool(muon_prop) + + kwargs.setdefault("Propagators", [muon_prop]) + kwargs.setdefault("ResolveMuonStation", True) + kwargs.setdefault("Tolerance", 0.0011) # must be > 1um to avoid missing MTG intersections + extrap = Trk__Extrapolator(**kwargs) + return result, extrap + +def MuonChi2TrackFitterCfg(flags,**kwargs): + result = ComponentAccumulator() + from TrkGlobalChi2Fitter.TrkGlobalChi2FitterConf import Trk__GlobalChi2Fitter + + acc,extrapolator = MuonExtrapolatorCfg(flags) + acc.addPublicTool(extrapolator) # TODO remove + result.merge(acc) + + acc,rotcreator = MuonConfig.MuonRIO_OnTrackCreatorConfig.MuonRotCreatorCfg(flags) + acc.addPublicTool(rotcreator) # TODO remove + result.merge(acc) + + measurement_updater = Trk__KalmanUpdator() + result.addPublicTool(measurement_updater) #FIXME + + kwargs.setdefault("ExtrapolationTool" , extrapolator) + kwargs.setdefault("RotCreatorTool" , rotcreator) + kwargs.setdefault("MeasurementUpdateTool", measurement_updater) + kwargs.setdefault("StraightLine" , False) + kwargs.setdefault("OutlierCut" , 3.0) + kwargs.setdefault("GetMaterialFromTrack" , False) + kwargs.setdefault("RejectLargeNScat" , True) + + # take propagator and navigator from the extrapolator + acc, extrapolator = MuonExtrapolatorCfg(flags) + acc.addPublicTool(extrapolator) # TODO remove + result.merge(acc) + + kwargs["ExtrapolationTool"] = extrapolator + kwargs["PropagatorTool"] = extrapolator.Propagators[0] + kwargs["NavigatorTool"] = extrapolator.Navigator + + fitter = Trk__GlobalChi2Fitter(**kwargs) + result.addPublicTool(fitter) + print fitter + return result, fitter + + +def MCTBExtrapolatorCfg(name='MCTBExtrapolator',**kwargs): + result = ComponentAccumulator() + kwargs.setdefault("Propagators", ["MCTBPropagator"]) # FIXME! + kwargs.setdefault("ResolveMuonStation", False) + extrap = MuonExtrapolatorCfg(flags, **kwargs) + return result, extrap + +def MCTBFitterCfg(flags, **kwargs): + # didn't bother with MCTBSLFitter, since this seems redundant. Just set "StraightLine" = True + result = ComponentAccumulator() + kwargs.setdefault("ExtrapolationTool", "MCTBExtrapolator") + kwargs.setdefault("GetMaterialFromTrack", True) + kwargs.setdefault("Momentum", flags.Muon.straightLineFitMomentum) + acc, mctbfitter = MuonChi2TrackFitterCfg(flags, **kwargs) + result.merge(acc) + print mctbfitter + return result,mctbfitter + +def MuonHoughPatternFinderTool(flags, **kwargs): + # Taken from https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonRecTools.py#L173 from MuonHoughPatternTools/MuonHoughPatternToolsConf import Muon__MuonHoughPatternFinderTool + + from MuonHoughPatternTools.MuonHoughPatternToolsConf import Muon__MuonHoughPatternFinderTool + + # TODO + # getPublicTool("MuonCombinePatternTool") + # getPublicTool("MuonHoughPatternTool") + if flags.Beam.Type == 'collisions': + kwargs.setdefault("MDT_TDC_cut", False) + kwargs.setdefault("RecordAll",False) + return Muon__MuonHoughPatternFinderTool("MuonHoughPatternFinderTool",**kwargs) + +def MuonCurvedSegmentCombiner(flags, **kwargs): + # Taken from https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MooreTools.py#L74 + # The original code seems very odd. The default MissedHitsCut is 100 by default, and the rest of it is a bit tortuous. + # I've tried to clean it up, but might have made mistakes. + from MuonCurvedSegmentCombiner.MuonCurvedSegmentCombinerConf import Muon__MuonCurvedSegmentCombiner + if flags.Beam.Type!= 'collisions' : + kwargs.setdefault( "AddUnassociatedMiddleEndcapSegments", False ) + elif flags.Input.isMC: + kwargs.setdefault( "MissedHitsCut", 4 ) + + kwargs.setdefault("DoCosmics", flags.Beam.Type != 'collisions' ) + kwargs.setdefault( "AddAll2DCscs", False ) + kwargs.setdefault( "UseCscSegments", flags.Muon.doCSCs ) + kwargs.setdefault( "AddUnassociatedMiddleEndcapSegments", True ) + return Muon__MuonCurvedSegmentCombiner("MuonCurvedSegmentCombiner", **kwargs) + +# def MuonSegmentCombinationCleanerTool(flags): + +def MdtDriftCircleOnTrackCreatorAdjustableT0(flags,**kwargs): + kwargs.setdefault("TimingMode", 3) + kwargs.setdefault("DoTofCorrection", True) + kwargs.setdefault("TimeWindowSetting", mdtCalibWindowNumber('Collision_data')) + kwargs.setdefault("MuonTofTool", AdjustableT0Tool(flags)) + return MdtDriftCircleOnTrackCreator(name,**kwargs) + +def AdjustableT0Tool(flags,**kwargs): + # NB: the following 'ifs' are the same as in the MdtDriftCircleOnTrackCreator, so that the ToF setting is the same + if flags.Beam.Type == 'cosmics': + kwargs.setdefault("DoTof", 0) + else: # collisions simulation final precise cuts + kwargs.setdefault("DoTof", 1) + + from MdtDriftCircleOnTrackCreator.MdtDriftCircleOnTrackCreatorConf import AdjT0__AdjustableT0Tool + return AdjT0__AdjustableT0Tool(**kwargs) + +def MdtMathSegmentFinder(flags,**kwargs): + # beamType = getattr(extraFlags,"beamType", beamFlags.beamType()) + # doSegmentT0Fit = getattr(extraFlags,"doSegmentT0Fit",muonRecFlags.doSegmentT0Fit()) + # enableCurvedSegmentFinding = getattr(extraFlags,"enableCurvedSegmentFinding", muonStandaloneFlags.enableCurvedSegmentFinding()) + + if flags.Muon.doSegmentT0Fit: + kwargs.setdefault("AssociationRoadWidth", 3.) + kwargs.setdefault("MDTAssocationPullcut", 3.) + kwargs.setdefault("RecoverMdtOutliers", False) + kwargs.setdefault("DCFitProvider", "MdtSegmentT0Fitter" ) + + if flags.Beam.Type == 'singlebeam' or flags.Beam.Type == 'cosmics' or flags.Input.isMC == False: + kwargs.setdefault("AssociationRoadWidth", 2.) + kwargs.setdefault("MDTAssocationPullcut", 4.) + kwargs.setdefault("RecoverMdtOutliers", True ) + + if flags.Muon.enableCurvedSegmentFinding: + kwargs.setdefault("DoCurvedSegmentFinder",True) + + return Muon__MdtMathSegmentFinder(**kwargs) + +def TriggerChamberClusterOnTrackCreatorCfg(flags, **kwargs): + result=ComponentAccumulator() + acc, muon_cluster_creator = MuonConfig.MuonRIO_OnTrackCreatorConfig.MuonClusterOnTrackCreatorCfg(flags) + acc.addPublicTool(muon_cluster_creator) + result.merge(acc) + kwargs.setdefault("ClusterCreator", muon_cluster_creator) + return result, Muon__TriggerChamberClusterOnTrackCreator(**kwargs) + +def MuonTrackCleanerCfg(flags, **kwargs): + # declareProperty("IdHelper",m_idHelper); + # declareProperty("Helper",m_helper); + # declareProperty("Printer",m_printer); + # declareProperty("MdtRotCreator", m_mdtRotCreator ); + # declareProperty("CompRotCreator", m_compRotCreator ); + # declareProperty("PullCalculator", m_pullCalculator ); + # declareProperty("Extrapolator", m_extrapolator ); + # declareProperty("MagFieldSvc", m_magFieldSvc ); + # declareProperty("MeasurementUpdator", m_measurementUpdator ); + result=ComponentAccumulator() + + acc, mdt_creator = MuonConfig.MuonRIO_OnTrackCreatorConfig.MdtDriftCircleOnTrackCreatorCfg(flags) + acc.addPublicTool(mdt_creator) + result.merge(acc) + kwargs.setdefault("MdtRotCreator", mdt_creator) + + acc, muon_cluster_creator = TriggerChamberClusterOnTrackCreatorCfg(flags) + acc.addPublicTool(muon_cluster_creator) + result.merge(acc) + kwargs.setdefault("CompRotCreator", muon_cluster_creator) + + # For PullCalculator, just let it get default for moment. FIXME + + acc,extrapolator = MuonExtrapolatorCfg(flags) + acc.addPublicTool(extrapolator) # TODO remove + result.merge(acc) + kwargs.setdefault("Extrapolator", extrapolator) + + acc, slfitter = MCTBFitterCfg(flags, name = "SLFitter", StraightLine=True) + acc.addPublicTool(slfitter) + result.merge(acc) + kwargs.setdefault("SLFitter", slfitter) + + acc, fitter = MCTBFitterCfg(flags, name = "CurvedFitter") + acc.addPublicTool(fitter) + result.merge(acc) + kwargs.setdefault("Fitter", fitter) + + # kwargs.setdefault("MagFieldSvc", mag_field_svc) Default for moment + + # FIXME - do remaining tools + + + return result, Muon__MuonTrackCleaner(**kwargs) + +def MuonSegmentFittingToolCfg(flags, **kwargs): + # declareProperty("SLPropagator", m_slPropagator); + # declareProperty("SLFitter", m_slTrackFitter); + # declareProperty("CurvedFitter", m_curvedTrackFitter); + # declareProperty("TrackCleaner", m_trackCleaner); + # declareProperty("IdHelper", m_idHelperTool); + # declareProperty("UpdatePrecisionCoordinate", m_updatePrecisionCoordinate = false ); + result=ComponentAccumulator() + # FIXME! Add this. + # acc, propagator = AtlasRungeKuttaPropagatorCfg(flags) + # result.merge(acc) + # kwargs.setdefault("SLPropagator", propagator) + + acc, slfitter = MCTBFitterCfg(flags, name = "SLFitter", StraightLine=True) + acc.addPublicTool(slfitter) + result.merge(acc) + kwargs.setdefault("SLFitter", slfitter) + + acc, fitter = MCTBFitterCfg(flags, name = "CurvedFitter") + acc.addPublicTool(fitter) + result.merge(acc) + kwargs.setdefault("CurvedFitter", fitter) + + acc, cleaner = MuonTrackCleanerCfg(flags) + acc.addPublicTool(cleaner) + result.merge(acc) + kwargs.setdefault("TrackCleaner", cleaner) + + return result, Muon__MuonSegmentFittingTool(**kwargs) + +def DCMathSegmentMakerCfg(flags, **kwargs): + # This in general is a pretty problematic piece of code. It seems to have a lot of potential issues, because it has loads of mutables / subtools etc + # https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.h + # ToolHandle<IMdtDriftCircleOnTrackCreator> m_mdtCreator; //<! mdt rio ontrack creator + # ToolHandle<IMdtDriftCircleOnTrackCreator> m_mdtCreatorT0; //<! mdt rio ontrack creator + # ToolHandle<IMuonClusterOnTrackCreator> m_clusterCreator; //<! cluster rio ontrack creator + # ToolHandle<IMuonCompetingClustersOnTrackCreator> m_compClusterCreator; //<! competing clusters rio ontrack creator + # ToolHandle<MuonIdHelperTool> m_idHelperTool; //<! Id helper tool + # ToolHandle<MuonEDMPrinterTool> m_printer; //<! printer helper tool + # ToolHandle<MuonEDMHelperTool> m_helper; //<! printer helper tool + # ToolHandle<IMdtSegmentFinder> m_segmentFinder; //<! segment finder tool MdtSegmentFinder + # mutable ToolHandle<AdjT0::IAdjustableT0Tool> m_tofTool; //<! tof tool + # ToolHandle<IMuonSegmentFittingTool> m_segmentFitter; //<! segment fitting tool + # ToolHandle<IMuonSegmentSelectionTool> m_segmentSelectionTool; //<! segment selection tool + # ToolHandle<IDCSLFitProvider> m_dcslFitProvider; + + result=ComponentAccumulator() + + beamType = flags.Beam.Type + doSegmentT0Fit = flags.Muon.doSegmentT0Fit + updateSegmentSecondCoordinate = flags.Muon.updateSegmentSecondCoordinate + enableCurvedSegmentFinding = flags.Muon.enableCurvedSegmentFinding + + kwargs.setdefault("RefitSegment", True) + kwargs.setdefault("AssumePointingPhi", beamType != 'cosmics') + kwargs.setdefault("OutputFittedT0", True) + + acc, mdt_calib_service = MdtCalibrationDbSvcCfg(flags) # Needed by MdtSegmentT0Fitter + result.merge(acc) + mdt_segment_t0_fitter = TrkDriftCircleMath__MdtSegmentT0Fitter() + result.addPublicTool(mdt_segment_t0_fitter) + kwargs.setdefault("DCFitProvider", mdt_segment_t0_fitter) + #kwargs.setdefault("CurvedErrorScaling", False) + kwargs.setdefault("UsePreciseError", True) + kwargs.setdefault("SinAngleCut", 0.4) + + if (beamType == 'singlebeam' or beamType == 'cosmics'): + kwargs.setdefault("SinAngleCut", 0.9) + kwargs.setdefault("AddUnassociatedPhiHits", True) + kwargs.setdefault("RecoverBadRpcCabling", True) + kwargs.setdefault("CurvedErrorScaling", False) + elif not flags.Input.isMC: # collisions real data + kwargs.setdefault("AddUnassociatedPhiHits", True) + kwargs.setdefault("RecoverBadRpcCabling", True) + + if doSegmentT0Fit: + tof_tool = AdjustableT0Tool(flags) + acc, mdt_creator = MuonConfig.MuonRIO_OnTrackCreatorConfig.MdtDriftCircleOnTrackCreatorCfg(flags, name="MdtDriftCircleOnTrackCreatorAdjustableT0", TimingMode=3, \ + DoTofCorrection=True, TimeWindowSetting=mdtCalibWindowNumber('Collision_data'), MuonTofTool=tof_tool) + acc.addPublicTool(mdt_creator) + result.merge(acc) + kwargs.setdefault("MdtCreatorT0", mdt_creator) # TODO - is this correct? + kwargs.setdefault("TofTool", tof_tool(flags)) + mdt_math_segment_finder = MdtMathSegmentFinder(flags, doSegmentT0Fit=True) + else: + mdt_math_segment_finder = MdtMathSegmentFinder(flags) + + result.addPublicTool(mdt_math_segment_finder) + kwargs.setdefault("MdtSegmentFinder", mdt_math_segment_finder ) + + if updateSegmentSecondCoordinate: + kwargs.setdefault("UpdatePhiUsingPhiHits",True) + + if enableCurvedSegmentFinding: + kwargs.setdefault("CurvedErrorScaling", False) + kwargs.setdefault("PreciseErrorScale", 1) + kwargs.setdefault("UsePreciseError", True) + + # Now stuff that wasn't explicitly configured before. + + acc, muon_station_intersect_svc = MuonStationIntersectSvcCfg(flags) + result.merge(acc) + kwargs.setdefault("MuonStationIntersectSvc", muon_station_intersect_svc) + + acc, mdt_creator = MuonConfig.MuonRIO_OnTrackCreatorConfig.MdtDriftCircleOnTrackCreatorCfg(flags) + acc.addPublicTool(mdt_creator) + result.merge(acc) + kwargs.setdefault("MdtCreator", mdt_creator) + + acc, muon_cluster_creator = MuonConfig.MuonRIO_OnTrackCreatorConfig.MuonClusterOnTrackCreatorCfg(flags) + acc.addPublicTool(muon_cluster_creator) + result.merge(acc) + + # FIXME - declare property for muon_cluster_creatoris missing from the tool. + + muon_comp_cluster_creator = Muon__TriggerChamberClusterOnTrackCreator(ClusterCreator=muon_cluster_creator) + acc.addPublicTool(muon_comp_cluster_creator) + kwargs.setdefault("MuonCompetingClustersCreator", muon_comp_cluster_creator) + + acc, segment_fitter = MuonSegmentFittingToolCfg(flags, name="NewMuonSegmentFittingTool") + acc.addPublicTool(segment_fitter) + print segment_fitter + + result.merge(acc) + kwargs.setdefault("SegmentFitter", segment_fitter) + + segment_selector = Muon__MuonSegmentSelectionTool() + result.addPublicTool(segment_selector) + kwargs.setdefault("SegmentSelector", segment_selector) + + dc_segment_maker = Muon__DCMathSegmentMaker(**kwargs) + print dc_segment_maker + return result, dc_segment_maker + + +def MuonPatternSegmentMakerCfg(flags, **kwargs): + # Taken from https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MooreTools.py#L49 + + # Tool has the following subtools: + # DCMathSegmentMaker, MdtDriftCircleOnTrackCreator, MuonClusterOnTrackCreator, MuonEDMPrinterTool, MuonIdHelperTool + result=ComponentAccumulator() + from MuonPatternSegmentMaker.MuonPatternSegmentMakerConf import Muon__MuonPatternSegmentMaker + from MuonCnvExample.MuonCnvUtils import mdtCalibWindowNumber # TODO - should maybe move this somewhere else? + + if "MdtCreator" not in kwargs: + # on data configure a MdtDriftCircleOnTrackCreator for the segment finding with reduced errors + # when using the t0 refit enlarge the time window + if not flags.Input.isMC and flags.Beam.Type == 'collisions': + if flags.Muon.doSegmentT0Fit: + timeWindowSetting = mdtCalibWindowNumber('Collision_t0fit') + else: + timeWindowSetting = mdtCalibWindowNumber('Collision_data') + acc, mdt_creator = MuonConfig.MuonRIO_OnTrackCreatorConfig.MdtDriftCircleOnTrackCreatorCfg(flags, name="MdtDriftCircleOnTrackCreator_NoTubeHits", CreateTubeHit = False, TimeWindowSetting = timeWindowSetting) + else: + # I think we need to configure a 'default' version of the MdtDriftCircleOnTrackCreator here + acc, mdt_creator = MuonConfig.MuonRIO_OnTrackCreatorConfig.MdtDriftCircleOnTrackCreatorCfg(flags) + result.merge(acc) + result.addPublicTool(mdt_creator) # TODO Temporary until we migrate to private tools in cxx! + kwargs.setdefault('MdtCreator', mdt_creator) + #else: + # TODO work out what to do here + + acc, muon_cluster_creator = MuonConfig.MuonRIO_OnTrackCreatorConfig.MuonClusterOnTrackCreatorCfg(flags) + acc.addPublicTool(muon_cluster_creator) + kwargs.setdefault('ClusterCreator', muon_cluster_creator) + result.merge(acc) + + # Other dependencies: + # EDM printer tool, MuonIdHelperTool + + acc, segment_maker = DCMathSegmentMakerCfg(flags,name="NewDCMathSegmentMaker") + acc.addPublicTool(segment_maker) + kwargs.setdefault('SegmentMaker', segment_maker) + result.merge(acc) + + if flags.Beam.Type == 'cosmics': + kwargs.setdefault("AngleCutPhi", 1e9) + kwargs.setdefault("DropDistance", 100000000.) + + return result, Muon__MuonPatternSegmentMaker("MuonPatternSegmentMaker", **kwargs) + +def CscAlignmentTool(flags, **kwargs): + from CscClusterization.CscClusterizationConf import CscAlignmentTool + etaposAlignConsts = [ # 1st, 2nd, 3rd, 4th layer + 0.0, -0.0902347, -0.0984321, -0.141175, #sector -16 + 0.0, -0.166412, -0.150399, -0.18592, #sector -15 + 0.0, -0.0544449, 0.101448, -0.0433321, #sector -14 + 0.0, -0.047769, -0.156247, -0.0854826, #sector -13 + 0.0, -0.0970101, -0.227578, -0.301079, #sector -12 + 0.0, -0.152912, -0.365218, -0.314042, #sector -11 + 0.0, 0.0338696, -0.264766, -0.224567, #sector -10 + 0.0, -0.107372, -0.16099, -0.13508, #sector -9 + 0.0, -0.0663979, -0.0312645, -0.130711, #sector -8 + 0.0, -0.249974, -0.269372, -0.353648, #sector -7 + 0.0, -0.194175, 0.0238348, -0.188433, #sector -6 + 0.0, 0.0977346, 0.0492461, 0.150434, #sector -5 + 0.0, 0.0444637, -0.0871214, -0.0627541, #sector -4 + 0.0, 0.0347245, -0.0226186, -0.0826478, #sector -3 + 0.0, -0.00408879, -0.0638005, -0.206868, #sector -2 + 0.0, 0.0331328, 0.0402103, 0.118611, #sector -1 + 0.0, -0.0634537, -0.0516743, 0.0045364, #sector 1 + 0.0, -0.0957718, -0.235246, -0.439811, #sector 2 + 0.0, -0.163504, -0.0129115, 0.00140143, #sector 3 + 0.0, -0.182903, -0.0503858, -0.207799, #sector 4 + 0.0, -0.0970927, 0, 0.124744, #sector 5 + 0.0, -0.0169602, -0.0527447, 0.0319154, #sector 6 + 0.0, -0.176499, -0.196542, -0.0846979, #sector 7 + 0.0, 0.0589994, 0.0131431, 0.0461769, #sector 8 + 0.0, -0.0237507, -0.0307316, 0.144429, #sector 9 + 0.0, -0.0144483, -0.0328234, -0.00553684, #sector 10 + 0.0, 0.113188, -0.176182, 0.0635706, #sector 11 + 0.0, -0.109776, -0.727705, -0.756824, #sector 12 + 0.0, -0.0553061, -0.056162, -0.0336955, #sector 13 + 0.0, -0.070077, -0.127203, -0.140082, #sector 14 + 0.0, -0.0844368, -0.0735331, -0.016667, #sector 15 + 0.0, 0.0426443, -0.153659, -0.129711, #sector 16 + ] + + phiposAlignConsts = [ # 1st, 2nd, 3rd, 4th layer + 0.0, 0.0, 0.0, 0.0, #-16 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #-14 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #-12 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #-10 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #-8 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #-6 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #-4 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #-2 + 0.0, 0.0, 0.0, 0.0, #-1 + 0.0, 0.0, 0.0, 0.0, # sector =1 and above... + 0.0, 0.0, 0.0, 0.0, #2 + 0.0, 0.0, 0.0, 0.0, #3 + 0.0, 0.0, 0.0, 0.0, #4 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #6 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #8 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #10 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #12 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, #14 + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0 #16 + ] + kwargs.setdefault("phiposAlignConsts", phiposAlignConsts) + kwargs.setdefault("etaposAlignConsts", etaposAlignConsts) + # kwargs.setdefault("useAlignment", flags.global.isMC is False and flags.muonAlign.UseIlines is False ) + + return CscAlignmentTool(**kwargs) + + +def QratCscClusterFitterCfg(flags, **kwargs): + # This is based on https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/CscTools.py#L151 + from CscClusterization.CscClusterizationConf import QratCscClusterFitter + result=ComponentAccumulator() + qratcor_css_eta = [ + 0.000000, 0.000000, 0.000000, 0.000000, 0.0699381, 0.178291, 0.271303, 0.345611, + 0.400738, 0.452451, 0.493772, 0.526792, 0.553845, 0.580111, 0.603337, 0.624749, + 0.646065, 0.663924, 0.681897, 0.701345, 0.716067, 0.730324, 0.743168, 0.760598, + 0.773341, 0.786406, 0.798358, 0.811339, 0.820949, 0.832676, 0.843917, 0.85412, + 0.863914, 0.873229, 0.88251, 0.892856, 0.903296, 0.910067, 0.917892, 0.928028, + 0.93461, 0.943679, 0.951617, 0.958326, 0.964428, 0.97341, 0.978204, 0.987075, + 0.994789, 1.000000 + ] + qratcor_csl_eta = [ + 0.000000, 0.000000, 0.000000, 0.000000, 0.0290177, 0.0834867, 0.188683, 0.269967, + 0.334887, 0.393036, 0.440317, 0.481884, 0.51725, 0.545107, 0.56959, 0.592327, + 0.614087, 0.635344, 0.655252, 0.672766, 0.690929, 0.707293, 0.722742, 0.738323, + 0.753562, 0.76749, 0.780983, 0.79354, 0.806521, 0.818085, 0.829987, 0.841443, + 0.853723, 0.863393, 0.87431, 0.883139, 0.892962, 0.902803, 0.911276, 0.921417, + 0.929387, 0.938106, 0.947072, 0.954406, 0.961692, 0.97055, 0.978517, 0.985133, + 0.992257, 1.000000 + ] + kwargs.setdefault("qratcor_csl_eta",qratcor_csl_eta) + kwargs.setdefault("qratcor_css_eta",qratcor_css_eta) + csc_align_tool = CscAlignmentTool(flags) + result.addPublicTool(csc_align_tool) # TODO remove once private + kwargs.setdefault("CscAlignmentTool", csc_align_tool ) + return result,QratCscClusterFitter(**kwargs) + +def CscSegmentUtilToolCfg(flags, **kwargs): + result=ComponentAccumulator() + acc, qrat = QratCscClusterFitterCfg(flags) + result.merge(acc) + kwargs.setdefault("precision_fitter", ) + acc, csc_cluster_creator = MuonConfig.MuonRIO_OnTrackCreatorConfig.CscClusterOnTrackCreatorCfg(flags) + result.merge(acc) + kwargs.setdefault("rot_creator", csc_cluster_creator ) + return result,CscSegmentUtilToolCfg(flags) + +def Csc2dSegmentMakerCfg(flags, **kwargs): + result=ComponentAccumulator() + acc, csc_segment_util_tool = CscSegmentUtilToolCfg(flags) + result.merge(acc) + acc, csc_segment_maker = Csc2dSegmentMaker("Csc2dSegmentMaker", + segmentTool=csc_segment_util_tool) + result.merge(acc) + return result, csc_segment_maker + +def Csc4dSegmentMakerCfg(flags, **kwargs): + result=ComponentAccumulator() + acc, csc_segment_util_tool = CscSegmentUtilToolCfg(flags) + result.merge(acc) + acc, csc_segment_maker = Csc4dSegmentMaker("Csc4dSegmentMaker", + segmentTool=csc_segment_util_tool) + result.merge(acc) + return result, csc_segment_maker + +def MooSegmentFinderCfg(flags, **kwargs): + # This is based on https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MooreTools.py#L99 + + from MuonHoughPatternTools.MuonHoughPatternToolsConf import Muon__MuonLayerHoughTool + from MuonSegmentOverlapRemovalTools.MuonSegmentOverlapRemovalToolsConf import Muon__MuonSegmentCombinationCleanerTool + from MooSegmentCombinationFinder.MooSegmentCombinationFinderConf import Muon__MooSegmentCombinationFinder + + result=ComponentAccumulator() + + # Need muon geometry to work! + from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg + result.merge( MuonGeoModelCfg(flags) ) + + muon_curved_segment_combiner_tool = MuonCurvedSegmentCombiner(flags) + result.addPublicTool(muon_curved_segment_combiner_tool) + + muon_segment_combination_cleaner_tool = Muon__MuonSegmentCombinationCleanerTool() + result.addPublicTool(muon_segment_combination_cleaner_tool) + + # Use the MuonLayerHoughTool for collisions, MuonHoughPatternFinderTool for everything else. + # This is based on https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonRecTools.py#L428 + muon_pattern_finder_tool = Muon__MuonLayerHoughTool("MuonLayerHoughTool", DoTruth= flags.Input.isMC) \ + if flags.Beam.Type=="collisions" else MuonHoughPatternFinderTool(flags) + result.addPublicTool(muon_pattern_finder_tool) + + acc, muon_pattern_segment_maker = MuonPatternSegmentMakerCfg(flags) + result.merge(acc) + result.addPublicTool(muon_pattern_segment_maker) + + if flags.Muon.doCSCs: + acc,csc_2d_segment_maker = Csc2dSegmentMakerCfg(flags) + result.merge(acc) + + acc,csc_4d_segment_maker = Csc4dSegmentMakerCfg(flags) + result.merge(acc) + else: + csc_2d_segment_maker=None + csc_4d_segment_maker=None + + segment_finder_tool = Muon__MooSegmentCombinationFinder("NewMooSegmentCombinationFinder", + SegmentCombiner = muon_curved_segment_combiner_tool, + SegmentCombinationCleaner = muon_segment_combination_cleaner_tool, + HoughPatternFinder =muon_pattern_finder_tool, + MdtSegmentMaker=muon_pattern_segment_maker, + DoSegmentCombinations=False, + DoSegmentCombinationCleaning=False, + DoCscSegments = flags.Muon.doCSCs, + DoMdtSegments = flags.Muon.doMDTs, + Csc2dSegmentMaker = csc_2d_segment_maker, + Csc4dSegmentMaker = csc_4d_segment_maker, + DoSummary = flags.Muon.printSummary + ) + + return result, segment_finder_tool + +def MuonClusterSegmentFinderToolCfg(flags, **kwargs): + #m_slTrackFitter("Trk::GlobalChi2Fitter/MCTBSLFitter"), + #m_ambiTool("Trk::SimpleAmbiguityProcessorTool/MuonAmbiProcessor"), + #m_trackToSegmentTool("Muon::MuonTrackToSegmentTool/MuonTrackToSegmentTool"), + #m_idHelperTool("Muon::MuonIdHelperTool/MuonIdHelperTool"), + #m_printer("Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"), + #m_helper("Muon::MuonEDMHelperTool/MuonEDMHelperTool"), + #m_trackCleaner("Muon::MuonTrackCleaner/MuonTrackCleaner") { + #declareProperty("SLFitter", m_slTrackFitter); + #declareProperty("SegmentAmbiguityTool",m_ambiTool); + #declareProperty("TrackToSegmentTool", m_trackToSegmentTool); + #declareProperty("IdHelper", m_idHelperTool); + #declareProperty("TrackCleaner", m_trackCleaner); + result=ComponentAccumulator() + + acc, slfitter = MCTBFitterCfg(flags, name = "SLFitter", StraightLine=True) + acc.addPublicTool(slfitter) + result.merge(acc) + kwargs.setdefault("SLFitter", slfitter) + + acc, cleaner = MuonTrackCleanerCfg(flags) + acc.addPublicTool(cleaner) + result.merge(acc) + kwargs.setdefault("TrackCleaner", cleaner) + + # FIXME - remaining tools + return acc, Muon__MuonClusterSegmentFinderTool(**kwargs) + +def MuonClusterSegmentFinderCfg(flags, **kwargs): + #declareProperty("MuonClusterizationTool", m_clusterTool); + #declareProperty("MuonIdHelperTool",m_idHelper ); + #declareProperty("MuonEDMPrinterTool",m_printer ); + #declareProperty("MuonPRDSelectionTool", m_muonPRDSelectionTool ); + #declareProperty("MdtSegmentMaker",m_segmentMaker); + #declareProperty("SLFitter", m_slTrackFitter); + #declareProperty("TrackToSegmentTool", m_trackToSegmentTool); + #declareProperty("AmbiguityProcessor",m_ambiguityProcessor); + #declareProperty("TrackCleaner", m_trackCleaner); + result=ComponentAccumulator() + # FIXME - rest of the tools. + + acc, segment_maker = DCMathSegmentMakerCfg(flags,name="NewDCMathSegmentMaker") + acc.addPublicTool(segment_maker) + kwargs.setdefault('MdtSegmentMaker', segment_maker) + result.merge(acc) + + acc, slfitter = MCTBFitterCfg(flags, name = "SLFitter", StraightLine=True) + acc.addPublicTool(slfitter) + result.merge(acc) + kwargs.setdefault("SLFitter", slfitter) + + acc, ambi = MuonAmbiProcessorCfg(flags, name='NewMuonAmbiProcessor') + acc.addPublicTool(ambi) + result.merge(acc) + kwargs.setdefault("AmbiguityProcessor", ambi) + + acc, cleaner = MuonTrackCleanerCfg(flags) + acc.addPublicTool(cleaner) + result.merge(acc) + kwargs.setdefault("TrackCleaner", cleaner) + + return result, Muon__MuonClusterSegmentFinder(**kwargs) + +def MuonSegmentFindingCfg(flags, **kwargs): + # This is based on https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonStandalone.py#L113 + from MooSegmentCombinationFinder.MooSegmentCombinationFinderConf import MooSegmentFinderAlg + result=ComponentAccumulator() + + segment_location = "ThirdChainSegments" if flags.Muon.segmentOrigin=="TruthTracking" else "MuonSegments" + + acc, segment_finder_tool = MooSegmentFinderCfg(flags) + result.merge(acc) + result.addPublicTool(segment_finder_tool) + + acc, muon_cluster_segment_finder = MuonClusterSegmentFinderCfg(flags) + result.merge(acc) + result.addPublicTool(muon_cluster_segment_finder) + + moo_segment_finder_alg = MooSegmentFinderAlg( "MuonSegmentMaker", + SegmentFinder = segment_finder_tool, + MuonClusterSegmentFinderTool=muon_cluster_segment_finder, + MuonSegmentOutputLocation = segment_location, + UseCSC = flags.Muon.doCSCs, + UseMDT = flags.Muon.doMDTs, + UseRPC = flags.Muon.doRPCs, + UseTGC = flags.Muon.doTGCs, + UseTGCPriorBC = flags.Muon.doTGCs and flags.Muon.useTGCPriorNextBC, + UseTGCNextBC = flags.Muon.doTGCs and flags.Muon.useTGCPriorNextBC, + doTGCClust = flags.Muon.doTGCClusterSegmentFinding, + doRPCClust = flags.Muon.doRPCClusterSegmentFinding ) + result.addEventAlgo( moo_segment_finder_alg ) + + # TODO - add NCB stuff + return result + + +if __name__=="__main__": + # To run this, do e.g. + # python ../athena/MuonSpectrometer/MuonConfig/python/MuonSegmentFinding.py + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior=1 + + from AthenaCommon.Logging import log + from AthenaCommon.Constants import DEBUG + from AthenaConfiguration.AllConfigFlags import ConfigFlags + + log.setLevel(DEBUG) + from AthenaCommon.Logging import log + log.debug('About to set up Segment Finding.') + + ConfigFlags.Input.Files = ["myESD.pool.root"] + ConfigFlags.Muon.doCSCs = False + ConfigFlags.lock() + + cfg=ComponentAccumulator() + + # This is a temporary fix! Should be private! + from MuonRecHelperTools.MuonRecHelperToolsConf import Muon__MuonEDMHelperTool + muon_edm_helper_tool = Muon__MuonEDMHelperTool("MuonEDMHelperTool", MuonExtrapolator=None) # Don't bring in this dependency yet! + cfg.addPublicTool( muon_edm_helper_tool ) + + from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg + cfg.merge(PoolReadCfg(ConfigFlags)) + + cfg.merge(MuonSegmentFindingCfg(ConfigFlags)) + + f=open("MuonSegmentFinding.pkl","w") + cfg.store(f) + f.close() diff --git a/MuonSpectrometer/MuonConfig/python/__init__.py b/MuonSpectrometer/MuonConfig/python/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Tracking/TrkDetDescr/TrkDetDescrSvc/python/AtlasTrackingGeometrySvcConfig.py b/Tracking/TrkDetDescr/TrkDetDescrSvc/python/AtlasTrackingGeometrySvcConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..5304aa7a12e709b64e137f3020827a032cd2e1ff --- /dev/null +++ b/Tracking/TrkDetDescr/TrkDetDescrSvc/python/AtlasTrackingGeometrySvcConfig.py @@ -0,0 +1,115 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# TODO This + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from TrkDetDescrSvc.TrkDetDescrSvcConf import Trk__TrackingGeometrySvc +from TrkDetDescrTools.TrkDetDescrToolsConf import Trk__GeometryBuilder +from CaloTrackingGeometry.ConfiguredCaloTrackingGeometryBuilder import ConfiguredCaloTrackingGeometryBuilder +from InDetTrackingGeometry.ConfiguredInDetTrackingGeometryBuilder import ConfiguredInDetTrackingGeometryBuilder +from MuonTrackingGeometry.ConfiguredMuonTrackingGeometry import MuonTrackingGeometryBuilder +from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg, addFolders +from SubDetectorEnvelopes.SubDetectorEnvelopesConfig import EnvelopeDefSvc + +# Copied from MuonCalibConfig - should be central. +def addFoldersSplitOnline(flags, db, online_folders, offline_folders, className=None, addMCString="_OFL"): + "Add access to given folder, using online_folder online, offline_folder offline" + result=ComponentAccumulator() + + if flags.Common.isOnline and not configFlags.Input.isMC: + folders = online_folders + else: + # MC, so add addMCString + db = db+addMCString + folders = offline_folders + result.merge( addFolders(flags, folders, className=className, detDb=db) ) + return result, None + +def _setupCondDB(flags, CoolDataBaseFolder): + result=ComponentAccumulator() + + # the tag names + materialTagBase = 'AtlasLayerMat_v' + version = 21 + sub_version = '' + + AtlasMaterialTag = materialTagBase+str(version)+sub_version+'_' + cfolder = CoolDataBaseFolder +'<tag>TagInfoMajor/'+AtlasMaterialTag+'/GeoAtlas</tag>' + # load the right folders (preparation for calo inclusion) + result.merge( addFoldersSplitOnline(flags,'GLOBAL',[cfolder],[cfolder]) ) + return result + +def TrackingGeometrySvcCfg( flags ) : + result = ComponentAccumulator() + + AtlasTrackingGeometryName = 'AtlasTrackingGeometry' + atlas_geometry_builder = Trk__GeometryBuilder(name = 'AtlasGeometryBuilder') + result.addPublicTool(atlas_geometry_builder) #TODO remove one day + + AtlasEnvelopeSvc = EnvelopeDefSvc( flags ) + result.addService(AtlasEnvelopeSvc) + + # No Det Flags right now. + + # Inner Detector + if (False): + InDetTrackingGeometryBuilder = ConfiguredInDetTrackingGeometryBuilder(name ='InDetTrackingGeometryBuilder') + result.addPublicTool(InDetTrackingGeometryBuilder) + # and give it to the Geometry Builder + atlas_geometry_builder.InDetTrackingGeometryBuilder = InDetTrackingGeometryBuilder + + # (Calo) + if (False): + from TrkDetDescrTools.TrkDetDescrToolsConf import Trk__CylinderVolumeCreator + CaloVolumeCreator = Trk__CylinderVolumeCreator("CaloVolumeCreator") + result.addPublicTool(CaloVolumeCreator) + + CaloTrackingGeometryBuilder = ConfiguredCaloTrackingGeometryBuilder(name='CaloTrackingGeometryBuilder'); + CaloTrackingGeometryBuilder.TrackingVolumeCreator = CaloVolumeCreator + CaloTrackingGeometryBuilder.EnvelopeDefinitionSvc = AtlasEnvelopeSvc + CaloTrackingGeometryBuilder.GeometryName = 'Calo' + result.addPublicTool(CaloTrackingGeometryBuilder) + # and give it to the Geometry Builder + atlas_geometry_builder.CaloTrackingGeometryBuilder = CaloTrackingGeometryBuilder + + # (Muon) + if (True): + MuonTrackingGeometryBuilder.EnvelopeDefinitionSvc = AtlasEnvelopeSvc + result.addPublicTool(MuonTrackingGeometryBuilder) + # and give it to the Geometry Builder + atlas_geometry_builder.MuonTrackingGeometryBuilder = MuonTrackingGeometryBuilder + + # the material provider + from TrkDetDescrTools.TrkDetDescrToolsConf import Trk__LayerMaterialProvider + AtlasMaterialProvider = Trk__LayerMaterialProvider('AtlasMaterialProvider') + CoolDataBaseFolder = '/GLOBAL/TrackingGeo/LayerMaterialV2' + + AtlasMaterialProvider.LayerMaterialMapName = CoolDataBaseFolder + result.addPublicTool(AtlasMaterialProvider) + + AtlasGeometryProcessors = [ AtlasMaterialProvider ] + + # Setup DBs + result.merge(_setupCondDB(flags, CoolDataBaseFolder)) + + tracking_geometry_service = Trk__TrackingGeometrySvc(name = 'AtlasTrackingGeometrySvc', GeometryBuilder=atlas_geometry_builder) + result.addService(tracking_geometry_service) + + return result, tracking_geometry_service + +if __name__ == '__main__': + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior=1 + from AthenaConfiguration.AllConfigFlags import ConfigFlags + + ConfigFlags.Input.Files = ["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data17_13TeV.00327265.physics_EnhancedBias.merge.RAW._lb0100._SFO-1._0001.1"] + ConfigFlags.lock() + + from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + result = ComponentAccumulator() + + acc, tracking_geometry_service = TrackingGeometrySvcCfg(ConfigFlags ) + result.merge(acc) + + f=open('TrackingGeometrySvcCfg.pkl','w') + acc.store(f) + f.close() diff --git a/Tracking/TrkExtrapolation/TrkExTools/python/AtlasExtrapolatorConfig.py b/Tracking/TrkExtrapolation/TrkExTools/python/AtlasExtrapolatorConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..85068f6cb4683f9e7ba189a5903793c608e17fd9 --- /dev/null +++ b/Tracking/TrkExtrapolation/TrkExTools/python/AtlasExtrapolatorConfig.py @@ -0,0 +1,135 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +# New configuration for ATLAS extrapolator +# Based heavily on AtlasExtrapolator.py + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + +# import the Extrapolator configurable +from TrkExTools.TrkExToolsConf import Trk__Extrapolator + +# define the class +class AtlasExtrapolatorCfg( Trk__Extrapolator ): + # constructor + def __init__(self,name = 'AtlasExtrapolator'): + + # get the correct TrackingGeometry setup + from TrkDetDescrSvc.AtlasTrackingGeometrySvc import AtlasTrackingGeometrySvc + from AthenaCommon.AppMgr import ServiceMgr as svcMgr + AtlasTrackingGeometrySvc = svcMgr.AtlasTrackingGeometrySvc + + # import the ToolSvc + from AthenaCommon.AppMgr import ToolSvc + if 'ToolSvc' not in dir() : + ToolSvc = ToolSvc() + + # PROPAGATOR DEFAULTS -------------------------------------------------------------------------------------- + + self.AtlasPropagators = [] + + from TrkExRungeKuttaPropagator.TrkExRungeKuttaPropagatorConf import Trk__RungeKuttaPropagator as RkPropagator + AtlasRungeKuttaPropagator = RkPropagator(name = 'AtlasRungeKuttaPropagator') + ToolSvc += AtlasRungeKuttaPropagator + + self.AtlasPropagators += [AtlasRungeKuttaPropagator] + + from TrkExSTEP_Propagator.TrkExSTEP_PropagatorConf import Trk__STEP_Propagator as STEP_Propagator + AtlasSTEP_Propagator = STEP_Propagator(name = 'AtlasSTEP_Propagator') + ToolSvc += AtlasSTEP_Propagator + + self.AtlasPropagators += [AtlasSTEP_Propagator] + + # UPDATOR DEFAULTS ----------------------------------------------------------------------------------------- + + self.AtlasUpdators = [] + + from TrkExTools.TrkExToolsConf import Trk__MaterialEffectsUpdator as MaterialEffectsUpdator + AtlasMaterialEffectsUpdator = MaterialEffectsUpdator(name = 'AtlasMaterialEffectsUpdator') + ToolSvc += AtlasMaterialEffectsUpdator + + self.AtlasUpdators += [ AtlasMaterialEffectsUpdator ] + + AtlasMaterialEffectsUpdatorLandau = MaterialEffectsUpdator(name = 'AtlasMaterialEffectsUpdatorLandau') + AtlasMaterialEffectsUpdatorLandau.LandauMode = True + ToolSvc += AtlasMaterialEffectsUpdatorLandau + + self.AtlasUpdators += [ AtlasMaterialEffectsUpdatorLandau ] + + # the UNIQUE NAVIGATOR ( === UNIQUE GEOMETRY) -------------------------------------------------------------- + from TrkExTools.TrkExToolsConf import Trk__Navigator + AtlasNavigator = Trk__Navigator(name = 'AtlasNavigator') + AtlasNavigator.TrackingGeometrySvc = AtlasTrackingGeometrySvc + ToolSvc += AtlasNavigator + + # CONFIGURE PROPAGATORS/UPDATORS ACCORDING TO GEOMETRY SIGNATURE + + AtlasSubPropagators = [] + AtlasSubUpdators = [] + + # -------------------- set it depending on the geometry ---------------------------------------------------- + # default for Global is (Rk,Mat) + AtlasSubPropagators += [ AtlasRungeKuttaPropagator.name() ] + AtlasSubUpdators += [ AtlasMaterialEffectsUpdator.name() ] + + # default for ID is (Rk,Mat) + AtlasSubPropagators += [ AtlasRungeKuttaPropagator.name() ] + AtlasSubUpdators += [ AtlasMaterialEffectsUpdator.name() ] + + # default for BeamPipe is (STEP,Mat) + AtlasSubPropagators += [ AtlasSTEP_Propagator.name() ] + AtlasSubUpdators += [ AtlasMaterialEffectsUpdator.name() ] + + # default for Calo is (STEP,Mat) + AtlasSubPropagators += [ AtlasSTEP_Propagator.name() ] + AtlasSubUpdators += [ AtlasMaterialEffectsUpdator.name() ] + + # default for MS is (STEP,Mat) + AtlasSubPropagators += [ AtlasSTEP_Propagator.name() ] + AtlasSubUpdators += [ AtlasMaterialEffectsUpdator.name() ] + + # default for Cavern is (Rk,Mat) + AtlasSubPropagators += [ AtlasRungeKuttaPropagator.name() ] + AtlasSubUpdators += [ AtlasMaterialEffectsUpdator.name() ] + + # ---------------------------------------------------------------------------------------------------------- + + # call the base class constructor + Trk__Extrapolator.__init__(self,name,\ + Navigator = AtlasNavigator,\ + MaterialEffectsUpdators = self.AtlasUpdators,\ + Propagators = self.AtlasPropagators,\ + SubPropagators = AtlasSubPropagators,\ + SubMEUpdators = AtlasSubUpdators,\ + DoCaloDynamic = False + ) + + # switches for simple steering : output navigators + def setNavigatorOutputLevel(self, msgLvl) : + self.Navigator.OutputLevel = msgLvl + + # switches for simple steering : output propagators + def setPropagatorsOutputLevel(self, msgLvl) : + for iprop in self.Propagators : + iprop.OutputLevel = msgLvl + + # switches for simple steering : output material effect updators + def setUpdatorsOutputLevel(self, msgLvl) : + for iupd in self.AtlasUpdators : + iupd.OutputLevel = msgLvl + + # switches for material effects integration + def setEnergyLoss(self, eloss) : + for iupd in self.AtlasUpdators : + try: + iupd.EnergyLoss = eloss + except AttributeError: + pass + + # switches for material effects integration + def setMultipleScattering(self, ms) : + for iupd in self.AtlasUpdators : + try: + iupd.MultipleScattering = ms + except AttributeError: + pass +