ATLAS Offline Software
MuonConfigUtils.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 
4 
5 def setupHistSvcCfg(flags, outFile: str, outStream: str):
6  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7  result = ComponentAccumulator()
8  if len(outFile) == 0: return result
9  from AthenaConfiguration.ComponentFactory import CompFactory
10  histSvc = CompFactory.THistSvc(Output=[f"{outStream} DATAFILE='{outFile}', OPT='RECREATE'"])
11  print(f"Regiter new stream {outStream} piped to {outFile}")
12  result.addService(histSvc, primary=True)
13  return result
14 
15 def executeTest(cfg):
16  cfg.printConfig(withDetails=True, summariseProps=True)
17  if not cfg.run().isSuccess(): exit(1)
18 
19 def configureCondTag(flags):
20  if not flags.GeoModel.AtlasVersion:
21  raise ValueError("No ATLAS version is configured")
22 
23  from AthenaConfiguration.Enums import LHCPeriod
24  from AthenaConfiguration.TestDefaults import defaultConditionsTags
25  if flags.GeoModel.Run == LHCPeriod.Run2:
26  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC if flags.Input.isMC else defaultConditionsTags.RUN2_DATA
27  elif flags.GeoModel.Run == LHCPeriod.Run3:
28  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN3_MC if flags.Input.isMC else defaultConditionsTags.RUN3_DATA
29  elif flags.GeoModel.Run == LHCPeriod.Run4:
30  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
31  else:
32  raise ValueError(f"Invalid run period {flags.GeoModel.Run}")
33 
35  """
36  Setup flags necessary for Muon standalone.
37  """
38  from AthenaConfiguration.AllConfigFlags import initConfigFlags
39  flags = initConfigFlags()
40  flags.Detector.GeometryMDT = True
41  flags.Detector.GeometryTGC = True
42 
43  flags.Detector.GeometryRPC = True
44  # TODO: disable these for now, to be determined if needed
45  flags.Detector.GeometryCalo = False
46  flags.Detector.GeometryID = False
47 
48  # FIXME This is temporary. I think it can be removed with some other refactoring
49  flags.Muon.makePRDs = False
50 
51  flags.Exec.MaxEvents = 20 # Set default to 20 if not overridden
52  flags.Scheduler.ShowDataDeps = True
53  flags.Scheduler.CheckDependencies = True
54  flags.Scheduler.ShowDataFlow = True
55  flags.Scheduler.ShowControlFlow = True
56  flags.Concurrency.NumThreads = 1
57  flags.Concurrency.NumConcurrentEvents = 1
58  flags.Exec.FPE= 500
59 
60  flags.fillFromArgs()
61 
62  if flags.Input.Files == ['_ATHENA_GENERIC_INPUTFILE_NAME_'] or len(flags.Input.Files) == 0:
63  # If something is set from an arg (i.e. the command line), this takes priority
64  from AthenaConfiguration.TestDefaults import defaultTestFiles
65  flags.Input.Files = defaultTestFiles.ESD_RUN3_MC
66 
67  configureCondTag(flags)
68 
69  from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
70  setupDetectorFlags(flags)
71 
72  if flags.Output.ESDFileName == '':
73  flags.Output.ESDFileName='newESD.pool.root'
74 
75  flags.lock()
76  flags.dump(evaluate = True)
77  return flags
78 
80  # When running from a pickled file, athena inserts some services automatically. So only use this if running now.
81 
82  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
83  cfg = MainServicesCfg(flags)
84  msgService = cfg.getService('MessageSvc')
85  msgService.Format = "S:%s E:%e % F%128W%S%7W%R%T %0W%M"
86  msgService.debugLimit = 2147483647
87  msgService.verboseLimit = 2147483647
88  msgService.infoLimit = 2147483647
89 
90 
91  from AthenaConfiguration.Enums import Format
92  if flags.Input.Format is Format.POOL:
93  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
94  cfg.merge(PoolReadCfg(flags))
95  elif flags.Input.Format == Format.BS:
96  from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
97  cfg.merge(ByteStreamReadCfg(flags))
98 
99  if flags.Input.isMC:
100  if ("TruthEvents" in flags.Input.Collections):
101  from xAODTruthCnv.RedoTruthLinksConfig import RedoTruthLinksAlgCfg
102  cfg.merge( RedoTruthLinksAlgCfg(flags) )
103  elif ("TruthEvent" in flags.Input.Collections):
104  from xAODTruthCnv.xAODTruthCnvConfig import GEN_AOD2xAODCfg
105  cfg.merge(GEN_AOD2xAODCfg(flags))
106 
107 
108  from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
109  cfg.merge(MuonGeoModelCfg(flags))
110  from MuonConfig.MuonGeometryConfig import MuonIdHelperSvcCfg
111  cfg.merge(MuonIdHelperSvcCfg(flags))
112 
113  return cfg
114 
115 def SetupMuonStandaloneOutput(cfg, flags, itemsToRecord):
116  # Set up output
117  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg, outputStreamName
118 
119  cfg.merge( OutputStreamCfg( flags, 'ESD', ItemList=itemsToRecord) )
120  outstream = cfg.getEventAlgo(outputStreamName("ESD"))
121  outstream.ForceRead = True
122 
123  # Fix for ATLASRECTS-5151
124  from TrkEventCnvTools.TrkEventCnvToolsConfig import (
125  TrkEventCnvSuperToolCfg)
126  cfg.merge(TrkEventCnvSuperToolCfg(flags))
127 
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=None, MetadataItemList=None, disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, keepProvenanceTagsRegEx=None, AcceptAlgs=None, HelperTools=None)
Definition: OutputStreamConfig.py:13
AthenaPoolExample_WriteCond.outputStreamName
string outputStreamName
Definition: AthenaPoolExample_WriteCond.py:21
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
MuonGeometryConfig.MuonIdHelperSvcCfg
def MuonIdHelperSvcCfg(flags)
Definition: MuonGeometryConfig.py:15
xAODTruthCnvConfig.GEN_AOD2xAODCfg
def GEN_AOD2xAODCfg(flags, name="GEN_AOD2xAOD", **kwargs)
Definition: xAODTruthCnvConfig.py:22
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
RedoTruthLinksConfig.RedoTruthLinksAlgCfg
def RedoTruthLinksAlgCfg(flags)
Definition: RedoTruthLinksConfig.py:5
python.TrkEventCnvToolsConfig.TrkEventCnvSuperToolCfg
def TrkEventCnvSuperToolCfg(flags, name='EventCnvSuperTool', **kwargs)
Definition: TrkEventCnvToolsConfig.py:51
MuonGeometryConfig.MuonGeoModelCfg
def MuonGeoModelCfg(flags)
Definition: MuonGeometryConfig.py:28
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
MuonConfigUtils.executeTest
def executeTest(cfg)
Definition: MuonConfigUtils.py:15
MuonConfigUtils.SetupMuonStandaloneConfigFlags
def SetupMuonStandaloneConfigFlags()
Definition: MuonConfigUtils.py:34
calibdata.exit
exit
Definition: calibdata.py:235
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
MuonConfigUtils.configureCondTag
def configureCondTag(flags)
Definition: MuonConfigUtils.py:19
MuonConfigUtils.SetupMuonStandaloneCA
def SetupMuonStandaloneCA(flags)
Definition: MuonConfigUtils.py:79
MuonConfigUtils.SetupMuonStandaloneOutput
def SetupMuonStandaloneOutput(cfg, flags, itemsToRecord)
Definition: MuonConfigUtils.py:115
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:292
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
MuonConfigUtils.setupHistSvcCfg
def setupHistSvcCfg(flags, str outFile, str outStream)
Configuration snippet to setup the THistSvc.
Definition: MuonConfigUtils.py:5
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:71