11from AthenaCommon.Logging
import logging
12from AthenaCommon.Logging
import log
as topLog
13topLog.setLevel(logging.WARNING)
14log = logging.getLogger(
'l1calo-ath-mon')
15log.setLevel(logging.INFO)
17from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig
import L1CaloMonitorCfgHelper
18L1CaloMonitorCfgHelper.embargoed = [
"Expert/Efficiency/gFEX/MuonReferenceTrigger/SRpt_L1_gJ400p0ETA25"]
22from AthenaConfiguration.ComponentFactory
import CompFactory
23from AthenaConfiguration.AllConfigFlags
import initConfigFlags
24from AthenaConfiguration.Enums
import LHCPeriod,Format
25from AthenaCommon
import Constants
29partition = ispy.IPCPartition(os.getenv(
"TDAQ_PARTITION",
"ATLAS"))
31flags = initConfigFlags()
38flags.Exec.OutputLevel = Constants.WARNING
39flags.Exec.InfoMessageComponents = [
"AthenaEventLoopMgr",
"AthenaHiveEventLoopMgr",
"THistSvc",
"PerfMonMTSvc",
"ApplicationMgr",
"AvalancheSchedulerSvc"]
40flags.Exec.PrintAlgsSequence =
True
44flags.GeoModel.Run = LHCPeriod.Run3
45flags.Common.useOnlineLumi =
True
46flags.DQ.doMonitoring =
True
47flags.DQ.enableLumiAccess =
False
48flags.DQ.FileKey =
"" if partition.isValid()
else "EXPERT"
49flags.Output.HISTFileName = os.getenv(
"L1CALO_ATHENA_JOB_NAME",
"") +
"monitoring.root"
50flags.DQ.useTrigger =
False
51flags.Trigger.L1.doCaloInputs = partition.isValid()
52flags.Trigger.enableL1CaloPhase1 =
True
53flags.Trigger.enableL1MuonPhase1 =
False
55flags.Trigger.L1.doCalo = partition.isValid()
56flags.Trigger.L1.doeFex = partition.isValid()
57flags.Trigger.L1.dojFex = partition.isValid()
58flags.Trigger.L1.dogFex = partition.isValid()
59flags.Trigger.L1.doTopo = partition.isValid()
62if partition.isValid():
65 flags.Trigger.doLVL1 =
False
66 flags.Trigger.doHLT =
False
67 from AthenaConfiguration.AutoConfigOnlineRecoFlags
import autoConfigOnlineRecoFlags
68 autoConfigOnlineRecoFlags(flags, partition.name())
70 flags.Trigger.doLVL1 =
True
74if "--help" in sys.argv:
76 neededCats = [
"DQ",
"Trigger",
"PerfMon"]
77 for cat
in list(flags._dynaflags.keys()):
78 if cat
not in neededCats: del flags._dynaflags[cat]
82parser = flags.getArgumentParser(epilog=
"""
83Extra flags are specified after a " -- " and the following are most relevant flags for this script:
85 Trigger.enableL1CaloPhase1 : turn on/off the offline simulation [default: True]
86 DQ.doMonitoring : turn on/off the monitoring [default: True]
87 Trigger.L1.doCaloInputs : controls input readout decoding and monitoring [default: False*]
88 Trigger.L1.doCalo : controls trex (legacy syst) monitoring [default: False]
89 Trigger.L1.doeFex : controls efex simulation and monitoring [default: False*]
90 Trigger.L1.dojFex : controls jfex simulation and monitoring [default: False*]
91 Trigger.L1.dogFex : controls gfex simulation and monitoring [default: False*]
92 Trigger.L1.doTopo : controls topo simulation and monitoring [default: False*] (from 2023 Onwards)
93 Trigger.L1.doGlobal : controls global simulation and monitoring [default: False]
94 DQ.useTrigger : controls if JetEfficiency monitoring alg is run or not [default: False]
95 PerfMon.doFullMonMT : print info about execution time of algorithms and memory use etc [default: False]
96 Trigger.triggerConfig : if you specifying this as "FILE:<filename>" the script will use that L1 json menu. [default: "DB" (takes menu from DB for data)]
98Note: If you do not specify any flags, then all the flags that are marked with a * will automatically become True
100E.g. to run just the jFex monitoring, without offline simulation, you can do:
102l1calo-ath-mon .... -- Trigger.enableL1CaloPhase1=False Trigger.L1.doCaloInputs=False Trigger.L1.doeFex=False Trigger.L1.dogFex=False
104To run with a plugin you can do e.g:
106l1calo-ath-mon PluginPackage/plugin.py --evtMax 10 ...
108Further notes: Run with "--evtMax 0" to print flags and ca config, and generate a hanConfig file.
109 Run with "--evtMax 1" to dump StoreGate contents after the first event
114parser.formatter_class = argparse.RawDescriptionHelpFormatter
115parser.add_argument(
'--runNumber',default=
None,help=
"specify to select a run number")
116parser.add_argument(
'--lumiBlock',default=
None,help=
"specify to select a lumiBlock")
117parser.add_argument(
'--evtNumber',default=
None,nargs=
"+",type=int,help=
"specify to select an evtNumber")
118parser.add_argument(
'--stream',default=
"*",help=
"stream to lookup files in")
119parser.add_argument(
'--fexReadoutFilter',action=
'store_true',help=
"If specified, will skip events without fexReadout")
120parser.add_argument(
'--dbOverrides',default=
None,nargs=
"+",type=str,help=
"specify overrides of COOL database folders in form <folder>=<dbPath> or <folder>:<tag>[=<dbPath>] to override a tag, example: /TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib=mytest.db ")
121parser.add_argument(
'--postConfig',default=[],nargs=
"+",type=str,help=
"specify component properties to apply at the end of the config. Can also specify in the flags section if start with 'cfg.' Use '--postHelp' option to explore the configurables and their properties")
122parser.add_argument(
'--postInclude',default=[],nargs=
"+",type=str,help=
"specify python files to call before configuration completes")
123parser.add_argument(
'--postHelp',default=
None,nargs=
"*",help=
"Displays configurables and their properties")
126sys.argv = [
"--help" if x==
"-h" else x
for x
in sys.argv]
127preHelpArgs = sys.argv[0:sys.argv.index(
"--help")]
if "--help" in sys.argv
else sys.argv
128postHelpArgs = sys.argv[sys.argv.index(
"--help"):]
if "--help" in sys.argv
else []
129args,unknown_args = flags.fillFromArgs(parser=parser,return_unknown=
True,listOfArgs=preHelpArgs[1:])
133 optionsPathEnv = os.environ[
'JOBOPTSEARCHPATH' ]
135 optionsPathEnv = os.curdir
136optionsPath = re.split(
',|' + os.pathsep, optionsPathEnv )
138 optionsPath[ optionsPath.index(
'' ) ] = str(os.curdir)
139for fn
in unknown_args:
140 from AthenaCommon.Utils.unixtools
import FindFile
141 name = FindFile( os.path.expanduser( os.path.expandvars( fn ) ), optionsPath, os.R_OK )
142 if not name: name = FindFile( os.path.basename( fn ), optionsPath, os.R_OK )
144 args.postInclude += [fn]
145 unknown_args.remove(fn)
146args.postConfig += [x[4:]
for x
in unknown_args
if x.startswith(
"cfg.")]
147if any([
not x.startswith(
"cfg.")
for x
in unknown_args]):
148 raise KeyError(
"Unknown flags: " +
" ".join([x
for x
in unknown_args
if not x.startswith(
"cfg.")]))
153if len(flags.Input.Files)>0:
155 from AthenaConfiguration.TestDefaults
import defaultTestFiles
156 flags.Input.Files = [getattr(defaultTestFiles,f,f)
for f
in flags.Input.Files]
157 flags.Input.Files = [item
for x
in flags.Input.Files
for item
in (x
if isinstance(x,list)
else [x])]
159 for f
in flags.Input.Files:
160 if not os.path.exists(f):
161 log.fatal(f
"file '{f}' does not exist")
164if args.runNumber
is not None:
170 from glob
import glob
171 if args.lumiBlock
is None: args.lumiBlock=
"*"
172 log.info(
" ".join((
"Looking up files in atlastier0 for run",args.runNumber,
"lb =",args.lumiBlock)))
173 flags.Input.Files = []
174 for lb
in args.lumiBlock.split(
","):
176 tryStr = f
"/eos/atlas/atlastier0/rucio/data*/{args.stream}/*{args.runNumber}/*RAW/*lb*.*"
178 tryStr = f
"/eos/atlas/atlastier0/rucio/data*/{args.stream}/*{args.runNumber}/*RAW/*lb{int(lb):04}.*"
179 log.info(
" ".join((
"Trying",tryStr)))
180 flags.Input.Files += glob(tryStr)
181 log.info(
" ".join((
"Found",str(len(flags.Input.Files)),
"files")))
185if not flags.Common.isOnline
and len(flags.Input.Files)==0:
186 if flags.Exec.MaxEvents==0:
188 flags.Input.Files = [
"/eos/atlas/atlascerngroupdisk/det-l1calo/OfflineSoftware/TestFiles/data24_13p6TeV/data24_13p6TeV.00477048.physics_Main.daq.RAW._lb0821._SFO-20._0001.data"]
190 if len(postHelpArgs): flags.fillFromArgs(listOfArgs=postHelpArgs)
191 log.fatal(
"Running in offline mode but no input files provided. Please specify with: --filesInput <file>")
192 from AthenaConfiguration.TestDefaults
import defaultTestFiles
193 log.fatal(
"You can specify one of the default test files:" +
",".join([f
for f
in dir(defaultTestFiles)
if f[0].isupper()]))
195elif flags.Common.isOnline:
196 log.info(
"Running Online with Partition: "+partition.name())
199 if flags.Trigger.Online.partitionName ==
'':
202 flags.Trigger.doLVL1 =
False
203 flags.Trigger.doHLT =
False
204 from AthenaConfiguration.AutoConfigOnlineRecoFlags
import autoConfigOnlineRecoFlags
205 autoConfigOnlineRecoFlags(flags, partition.name())
206 standalone = (partition.name()!=
"ATLAS")
207 if standalone : log.info(
"Using local menu because partition is not ATLAS")
208 elif len(flags.Input.Files)==0
and partition.isValid():
211 log.info(
"Waiting 2 minutes for LATOME to get their databases in order")
215if len(args.postInclude):
218 with ConfigurableCABehavior():
219 from AthenaCommon.Utils.unixtools
import FindFile
223 with open(file_path,
"r", encoding=
"utf-8")
as f:
225 tree = ast.parse(source, filename=file_path)
226 for node
in tree.body:
227 if isinstance(node, ast.FunctionDef)
and node.name == function_name:
229 mod = ast.Module(body=[node], type_ignores=[])
231 code = compile(mod, filename=file_path, mode=
"exec")
234 exec(code, namespace)
235 return namespace[function_name]
236 for fn
in args.postInclude:
237 name = FindFile( os.path.expanduser( os.path.expandvars( fn ) ), optionsPath, os.R_OK )
239 name = FindFile( os.path.basename( fn ), optionsPath, os.R_OK )
240 if not name:
raise RuntimeError(
'plugin file %s can not be found' % fn )
243 topLog.setLevel(logging.INFO)
245 topLog.setLevel(logging.WARNING)
247if len(args.postInclude)==0
and not any([flags.Trigger.L1.doCalo,flags.Trigger.L1.doCaloInputs,flags.Trigger.L1.doeFex,flags.Trigger.L1.dojFex,flags.Trigger.L1.dogFex,flags.Trigger.L1.doTopo,flags.DQ.useTrigger]):
248 log.info(
"No steering flags specified and no postInclude, turning on all phase 1 systems (trex,efex,jfex,gfex,topo)")
249 flags.Trigger.L1.doCaloInputs =
True
250 flags.Trigger.L1.doCalo =
True
251 flags.Trigger.L1.doeFex =
True
252 flags.Trigger.L1.dojFex =
True
253 flags.Trigger.L1.dogFex =
True
254 flags.Trigger.L1.doTopo =
True
258if type(flags.Trigger.triggerConfig)==str
and flags.Trigger.triggerConfig.startswith(
"FILE:"):
259 customMenuFile = flags.Trigger.triggerConfig.split(
":",1)[-1]
260 flags.Trigger.triggerConfig=
"FILE"
265if len(flags.Input.Files)>0:
266 flags.DQ.Environment =
"user"
269 standalone = ((flags.Input.ProjectName ==
"data_test")
or (re.match(
r"data\d\d_calib", flags.Input.ProjectName)))
270 if standalone :
print(
"Using local menu because project_name=",flags.Input.ProjectName)
271 if flags.Input.isMC : flags.Trigger.triggerConfig=
'FILE'
272 elif flags.Trigger.triggerConfig==
'INFILE':
274 flags.Trigger.triggerConfig=
"DB"
276 if flags.Input.isMC
and flags.Trigger.L1.doCalo:
277 log.info(
"Disabling legacy monitoring because it doesn't work with MC")
278 flags.Trigger.L1.doCalo=
False
281 flags.Trigger.triggerConfig=
'FILE'
284if flags.Exec.MaxEvents == 0:
286 flags.DQ.doMonitoring=
True
287 flags.Trigger.L1.doCalo=
True
288 flags.Trigger.L1.doCaloInputs=
True
289 flags.Trigger.L1.doeFex=
True
290 flags.Trigger.L1.dojFex=
True
291 flags.Trigger.L1.dogFex=
True
292 flags.Trigger.L1.doTopo=
True
293 flags.DQ.useTrigger=
True
294 flags.Exec.OutputLevel = Constants.INFO
297if flags.GeoModel.AtlasVersion
is None:
298 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
299 flags.GeoModel.AtlasVersion = defaultGeometryTags.autoconfigure(flags)
301if flags.Trigger.triggerConfig==
"FILE" and flags.Trigger.L1.doCalo:
304 log.warning(
"Cannot run Legacy sim/mon when using json l1 menu. Disabling")
305 flags.Trigger.L1.doCalo=
False
307if (flags.Input.Format == Format.POOL): flags.Trigger.L1.doTopo =
False
308if not flags.Trigger.L1.doTopo: flags.Trigger.L1.doMuon =
False
310if flags.Trigger.enableL1CaloPhase1:
313 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorsFromList
314 setupDetectorsFromList(flags,[
'LAr',
'Tile',
'MBTS'] + ([
'RPC',
'TGC',
'MDT']
if flags.Trigger.L1.doMuon
else []),
True)
316from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
317cfg = MainServicesCfg(flags)
319log.setLevel(logging.INFO)
324if len(postHelpArgs): flags.fillFromArgs(listOfArgs=postHelpArgs)
327if flags.Exec.MaxEvents == 0: flags.dump(evaluate=
True)
330if len(args.postInclude)==0
and not any([flags.Trigger.L1.doCaloInputs,flags.Trigger.L1.doCalo,flags.Trigger.L1.doeFex,flags.Trigger.L1.dojFex,flags.Trigger.L1.dogFex,flags.Trigger.L1.doTopo]):
331 log.fatal(
"You did not set any flags to specify what to run. ")
332 log.fatal(
"Please set at least one of the flags in Trigger.L1.(doCaloInputs, doCalo, doeFex, dojFex, dogFex, doTopo) ")
333 log.fatal(
"or use '--all' option to turn on everything (but that is slow)")
334 log.fatal(
"See --help for more info about the flags")
337if flags.Common.isOnline
and len(flags.Input.Files)==0:
338 flags.dump(evaluate=
True)
339 from ByteStreamEmonSvc.EmonByteStreamConfig
import EmonByteStreamCfg
340 cfg.merge(EmonByteStreamCfg(flags))
341 bsSvc = cfg.getService(
"ByteStreamInputSvc")
342 bsSvc.Partition = partition.name()
343 bsSvc.Key = os.environ.get(
"L1CALO_PTIO_KEY",
"REB" if partition.name()==
"L1CaloStandalone" else "dcm")
344 if partition.name()==
"L1CaloSTF": bsSvc.Key =
"SWROD"
345 bsSvc.KeyCount = int(os.environ.get(
"L1CALO_PTIO_KEY_COUNT",
"25"))
346 bsSvc.ISServer =
"Histogramming"
347 bsSvc.BufferSize = 10
348 bsSvc.UpdatePeriod = 30
349 bsSvc.Timeout = 240000
350 bsSvc.PublishName = os.getenv(
"L1CALO_ATHENA_JOB_NAME",
"testing")
351 bsSvc.StreamType = os.getenv(
"L1CALO_PTIO_STREAM_TYPE",
"physics")
352 bsSvc.ExitOnPartitionShutdown =
False
353 bsSvc.ClearHistograms =
True
354 bsSvc.GroupName =
"RecExOnline"
356 bsSvc.StreamNames = os.getenv(
"L1CALO_PTIO_STREAM_NAME",
"L1Calo:Main:MinBias:MinBiasOverlay:UPC:EnhancedBias:ZeroBias:HardProbes:Standby:ALFACalib").
split(
":")
357 bsSvc.StreamLogic = os.getenv(
"L1CALO_PTIO_STREAM_LOGIC",
"Or")
if partition.name() !=
"L1CaloStandalone" else "Ignore"
359 bsSvc.LVL1Logic =
"Ignore"
360elif flags.Input.Format == Format.POOL:
361 log.info(f
"Running Offline on {len(flags.Input.Files)} POOL files: {flags.Input.Files[0]} ...")
362 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
363 cfg.merge(PoolReadCfg(flags))
364elif len(flags.Input.Files)>0:
365 log.info(f
"Running Offline on {len(flags.Input.Files)} bytestream files: {flags.Input.Files[0]} ...")
368 from TriggerJobOpts.TriggerByteStreamConfig
import ByteStreamReadCfg
369 cfg.merge(ByteStreamReadCfg(flags))
372from AthenaMonitoring.AthMonitorCfgHelper
import getDQTHistSvc
373cfg.merge(getDQTHistSvc(flags))
376from TrigConfigSvc.TrigConfigSvcCfg
import L1ConfigSvcCfg,generateL1Menu, createL1PrescalesFileFromMenu,getL1MenuFileName
377if flags.Trigger.triggerConfig==
"FILE":
379 menuFilename = getL1MenuFileName(flags)
380 if customMenuFile ==
"":
381 if os.path.exists(menuFilename): os.remove(menuFilename)
382 generateL1Menu(flags)
387 os.symlink(customMenuFile, menuFilename)
389 if e.errno == errno.EEXIST:
390 os.remove(menuFilename)
391 os.symlink(customMenuFile, menuFilename)
394 menuFilename = customMenuFile
395 if os.path.exists(menuFilename):
396 log.info(f
"Using L1Menu: {menuFilename}")
398 log.fatal(f
"L1Menu file does not exist: {menuFilename}")
400 createL1PrescalesFileFromMenu(flags)
403if not (
not flags.Common.isOnline
and len(flags.Input.Files)==0): cfg.merge(L1ConfigSvcCfg(flags))
410if flags.Common.isOnline
or (flags.Input.Format != Format.POOL
and not flags.Input.isMC):
411 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import eFexByteStreamToolCfg, jFexRoiByteStreamToolCfg, jFexInputByteStreamToolCfg, gFexByteStreamToolCfg, gFexInputByteStreamToolCfg
412 if flags.Trigger.L1.doeFex: decoderTools += [cfg.popToolsAndMerge(eFexByteStreamToolCfg(flags=flags,name=
'eFexBSDecoderTool',TOBs=flags.Trigger.L1.doeFex,xTOBs=flags.Trigger.L1.doeFex,decodeInputs=flags.Trigger.L1.doCaloInputs,multiSlice=
True))]
413 if flags.Trigger.L1.dojFex: decoderTools += [cfg.popToolsAndMerge(jFexRoiByteStreamToolCfg(flags=flags,name=
"jFexBSDecoderTool",writeBS=
False))]
414 if flags.Trigger.L1.dogFex: decoderTools += [cfg.popToolsAndMerge(gFexByteStreamToolCfg(flags=flags,name=
"gFexBSDecoderTool",writeBS=
False))]
415 if flags.Trigger.L1.doTopo:
416 from L1TopoByteStream.L1TopoByteStreamConfig
import L1TopoPhase1ByteStreamToolCfg
417 decoderTools += [cfg.popToolsAndMerge(L1TopoPhase1ByteStreamToolCfg(flags=flags,name=
"L1TopoBSDecoderTool",writeBS=
False))]
419 if flags.Trigger.L1.doMuon:
420 from MuonConfig.MuonBytestreamDecodeConfig
import RpcBytestreamDecodeCfg,TgcBytestreamDecodeCfg
421 cfg.merge(RpcBytestreamDecodeCfg(flags))
422 cfg.merge(TgcBytestreamDecodeCfg(flags))
423 from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig
import MuonRoIByteStreamToolCfg
424 decoderTools += [cfg.popToolsAndMerge(MuonRoIByteStreamToolCfg(flags, name=
"L1MuonBSDecoderTool", writeBS=
False))]
427 if flags.Trigger.L1.doCaloInputs:
428 if flags.Trigger.L1.dojFex: decoderTools += [cfg.popToolsAndMerge(jFexInputByteStreamToolCfg(flags=flags,name=
'jFexInputBSDecoderTool',writeBS=
False))]
429 if flags.Trigger.L1.dogFex: decoderTools += [cfg.popToolsAndMerge(gFexInputByteStreamToolCfg(flags=flags,name=
'gFexInputBSDecoderTool',writeBS=
False))]
431 if len(decoderTools) > 0:
432 from TrigT1ResultByteStream.TrigT1ResultByteStreamMonitoringConfig
import L1TriggerByteStreamDecoderMonitoringCfg
433 cfg.addEventAlgo(CompFactory.L1TriggerByteStreamDecoderAlg(
434 name=
"L1TriggerByteStreamDecoder",
435 OutputLevel=Constants.ERROR,
436 DecoderTools=decoderTools,
437 ByteStreamMetadataRHKey =
'',
438 MaybeMissingROBs= [id
for tool
in decoderTools
for id
in tool.ROBIDs ]
if partition.name()!=
"ATLAS" or not flags.Common.isOnline
else [],
439 MonTool= cfg.popToolsAndMerge(L1TriggerByteStreamDecoderMonitoringCfg(flags,
"L1TriggerByteStreamDecoder", decoderTools))
440 ),sequenceName=
'AthAlgSeq'
444if flags.Trigger.enableL1CaloPhase1:
445 from L1CaloFEXSim.L1CaloFEXSimCfg
import L1CaloFEXSimCfg
447 cfg.addSequence(CompFactory.AthSequencer(
"L1Sim",StopOverride=
True),parentName=
"AthAlgSeq")
452 cfg.merge(
L1CaloFEXSimCfg(flags,outputSuffix=
"_ReSim" if flags.Input.Format == Format.POOL
and flags.Input.ProcessingTags != [
'StreamRDO']
else ""),sequenceName=
"L1Sim")
454 if flags.Trigger.L1.doTopo:
455 from L1TopoSimulation.L1TopoSimulationConfig
import L1TopoSimulationCfg
456 cfg.merge(L1TopoSimulationCfg(flags,readMuCTPI=
True,doMonitoring=
False),sequenceName=
"L1Sim")
458 for alg
in cfg.getSequence(
"L1Sim").Members:
459 if alg.name
in [a.name
for a
in cfg.getSequence(
"AthAlgSeq").Members]:
460 cfg.getSequence(
"L1Sim").Members.remove(alg)
464 if "doGlobal" in flags.Trigger.L1
and flags.Trigger.L1.doGlobal:
466 cfg.addSequence(CompFactory.AthSequencer(
"L1GlobalSim",StopOverride=
True),parentName=
"AthAlgSeq")
467 from GlobalSimulation.GlobalSimulationConfig
import GlobalSimulationCfg
468 cfg.merge(GlobalSimulationCfg(flags),sequenceName=
"L1GlobalSim")
470 if flags.Trigger.L1.doeFex:
472 from TrigConfigSvc.TriggerConfigAccess
import getL1MenuAccess
473 L1_menu = getL1MenuAccess(flags)
474 L1_menu.printSummary()
475 em_algoVersion = L1_menu.thresholdExtraInfo(
"eEM").
get(
"algoVersion", 0)
476 tau_algoVersion = L1_menu.thresholdExtraInfo(
"eTAU").
get(
"algoVersion", 0)
477 log.info(f
"algoVersions: eEM: {em_algoVersion}, eTAU: {tau_algoVersion}")
492if flags.Trigger.enableL1MuonPhase1:
494 cfg.addSequence(CompFactory.AthSequencer(
"L1MuonSim",StopOverride=
True),parentName=
"AthAlgSeq")
495 from TriggerJobOpts.Lvl1MuonSimulationConfig
import Lvl1MuonSimulationCfg
496 cfg.merge(Lvl1MuonSimulationCfg(flags), sequenceName=
'L1MuonSim')
499if flags.DQ.doMonitoring:
501 cfg.addSequence(CompFactory.AthSequencer(
"L1Mon",StopOverride=
True),parentName=
"AthAlgSeq")
502 if flags.Trigger.L1.doCalo:
503 from TrigT1CaloMonitoring.PprMonitorAlgorithm
import PprMonitoringConfig
504 cfg.merge(PprMonitoringConfig(flags),sequenceName=
"L1Mon")
505 from TrigT1CaloMonitoring.PPMSimBSMonitorAlgorithm
import PPMSimBSMonitoringConfig
506 cfg.merge(PPMSimBSMonitoringConfig(flags),sequenceName=
"L1Mon")
507 from TrigT1CaloMonitoring.OverviewMonitorAlgorithm
import OverviewMonitoringConfig
508 cfg.merge(OverviewMonitoringConfig(flags),sequenceName=
"L1Mon")
511 OverviewMonAlg = cfg.getEventAlgo(
"OverviewMonAlg")
512 OverviewMonAlg.CPMErrorLocation =
""
513 OverviewMonAlg.CPMMismatchLocation =
""
515 if flags.Trigger.L1.doeFex:
516 from TrigT1CaloMonitoring.EfexMonitorAlgorithm
import EfexMonitoringConfig
517 cfg.merge(EfexMonitoringConfig(flags),sequenceName=
"L1Mon")
518 EfexMonAlg = cfg.getEventAlgo(
'EfexMonAlg')
520 EfexMonAlg.eFexEMTobKeyList = [
'L1_eEMRoI',
'L1_eEMxRoI']
521 EfexMonAlg.eFexTauTobKeyList = [
'L1_eTauRoI',
'L1_eTauxRoI']
523 if flags.Input.Format == Format.POOL
or flags.Trigger.enableL1CaloPhase1:
524 for l
in [EfexMonAlg.eFexEMTobKeyList,EfexMonAlg.eFexTauTobKeyList]: l += [x + (
"_ReSim" if flags.Input.Format == Format.POOL
and flags.Trigger.enableL1CaloPhase1
else "Sim")
for x
in l ]
526 if not flags.Input.isMC
and flags.Trigger.enableL1CaloPhase1:
527 from TrigT1CaloMonitoring.EfexSimMonitorAlgorithm
import EfexSimMonitoringConfig
528 cfg.merge(EfexSimMonitoringConfig(flags),sequenceName=
"L1Mon")
531 from TrigT1CaloMonitoring.EfexMonitorAlgorithm
import EfexMonitoringHistConfig
532 cfg.merge(EfexMonitoringHistConfig(flags,EfexMonAlg),sequenceName=
"L1Mon")
534 if flags.Trigger.L1.dojFex:
535 from TrigT1CaloMonitoring.JfexMonitorAlgorithm
import JfexMonitoringConfig
536 cfg.merge(JfexMonitoringConfig(flags),sequenceName=
"L1Mon")
537 if not flags.Input.isMC
and flags.Trigger.enableL1CaloPhase1:
538 from TrigT1CaloMonitoring.JfexSimMonitorAlgorithm
import JfexSimMonitoringConfig
539 cfg.merge(JfexSimMonitoringConfig(flags),sequenceName=
"L1Mon")
540 if flags.Trigger.L1.dogFex:
541 from TrigT1CaloMonitoring.GfexMonitorAlgorithm
import GfexMonitoringConfig
542 cfg.merge(GfexMonitoringConfig(flags),sequenceName=
"L1Mon")
543 if not flags.Input.isMC
and flags.Trigger.enableL1CaloPhase1:
544 from TrigT1CaloMonitoring.GfexSimMonitorAlgorithm
import GfexSimMonitoringConfig
545 cfg.merge(GfexSimMonitoringConfig(flags),sequenceName=
"L1Mon")
548 if flags.DQ.useTrigger:
549 from TrigT1CaloMonitoring.JetEfficiencyMonitorAlgorithm
import JetEfficiencyMonitoringConfig
550 cfg.merge(JetEfficiencyMonitoringConfig(flags),sequenceName=
"L1Mon")
552 if flags.Trigger.L1.doTopo:
553 from L1TopoOnlineMonitoring.L1TopoOnlineMonitoringConfig
import Phase1TopoMonitoringCfg
554 cfg.merge(Phase1TopoMonitoringCfg(flags))
557 if flags.Trigger.L1.doCaloInputs
and not flags.Input.isMC:
558 from TrigT1CaloMonitoring.EfexInputMonitorAlgorithm
import EfexInputMonitoringConfig
559 if flags.Trigger.L1.doeFex: cfg.merge(EfexInputMonitoringConfig(flags),sequenceName=
"L1Mon")
560 from TrigT1CaloMonitoring.JfexInputMonitorAlgorithm
import JfexInputMonitoringConfig
561 if flags.Trigger.L1.dojFex: cfg.merge(JfexInputMonitoringConfig(flags),sequenceName=
"L1Mon")
562 from TrigT1CaloMonitoring.GfexInputMonitorAlgorithm
import GfexInputMonitoringConfig
563 if flags.Trigger.L1.dogFex: cfg.merge(GfexInputMonitoringConfig(flags),sequenceName=
"L1Mon")
565mainSeq =
"AthAllAlgSeq"
566if args.fexReadoutFilter:
568 topSeq = cfg.getSequence(
"AthAlgEvtSeq")
569 algSeq = cfg.getSequence(mainSeq)
570 mainSeq =
"New" + mainSeq
572 topSeq.Members = [topSeq.Members[0],CompFactory.AthSequencer(mainSeq),topSeq.Members[-1]]
573 cfg.addEventAlgo(CompFactory.L1IDFilterAlgorithm(),sequenceName=mainSeq)
574 cfg.getSequence(mainSeq).Members += [algSeq]
576if args.evtNumber
is not None:
577 print(
"filtering events",args.evtNumber)
579 topSeq = cfg.getSequence(
"AthAlgEvtSeq")
580 algSeq = cfg.getSequence(mainSeq)
581 mainSeq =
"New" + mainSeq
583 topSeq.Members = [topSeq.Members[0],CompFactory.AthSequencer(mainSeq),topSeq.Members[-1]]
584 cfg.addEventAlgo(CompFactory.EventNumberFilterAlgorithm(
"EvtNumberFilter",EventNumbers=args.evtNumber),sequenceName=mainSeq)
585 cfg.getSequence(mainSeq).Members += [algSeq]
587from PerfMonComps.PerfMonCompsConfig
import PerfMonMTSvcCfg
588cfg.merge( PerfMonMTSvcCfg(flags) )
590from AthenaConfiguration.Utils
import setupLoggingLevels
591setupLoggingLevels(flags,cfg)
593if any([s.name==
"AthenaEventLoopMgr" for s
in cfg.getServices()]): cfg.getService(
"AthenaEventLoopMgr").IntervalInSeconds = 30
594if any([s.name==
"AthenaHiveEventLoopMgr" for s
in cfg.getServices()]): cfg.getService(
"AthenaHiveEventLoopMgr").EventPrintoutInterval = 100
595if any([s.name==
"AvalancheSchedulerSvc" for s
in cfg.getServices()]): cfg.getService(
"AvalancheSchedulerSvc").ShowDataDependencies=
True
598if not flags.Input.isMC:
600 runinfo = getLArDTInfoForRun(flags.Input.RunNumbers[0], connstring=
"COOLONL_LAR/CONDBR2")
601 if runinfo.FWversion()==6:
603 if args.dbOverrides
is None: args.dbOverrides = []
604 args.dbOverrides += [
"/LAR/Identifier/LatomeMapping:LARIdentifierLatomeMapping-fw6"]
608if type(args.dbOverrides)==list:
609 from IOVDbSvc.IOVDbSvcConfig
import addOverride
613 for override
in args.dbOverrides:
614 folderName,dbPath = override.split(
"=",1)
if "=" in override
else (override,
"")
615 if folderName ==
"":
raise ValueError(
"Cannot parse dbOverride: " + override)
618 if ";dbname=" not in dbPath: dbPath +=
";dbname=CONDBR2"
619 dbPath,dbInst = dbPath.split(
";dbname=")
620 if not os.path.exists(dbPath):
raise ValueError(
"dbOverride file doesn't exist: " + dbPath)
621 db = f
"sqlite://;schema={dbPath};dbname={dbInst}"
623 if ":" in folderName:
624 folderName,tag = folderName.split(
":",1)
625 if folderName[0] !=
"/": folderName =
"/TRIGGER/L1Calo/V1/Calibration/" + folderName
626 log.info(
" ".join((
"Overriding COOL folder=",folderName,
"db=",db,
"tag=",tag)))
628 cfg.merge( addOverride(flags,folder=folderName,tag=tag))
630 cfg.merge( addOverride(flags,folder=folderName,db=db,tag=tag))
635if flags.Output.AODFileName !=
"" and len(flags.Input.Files)>0:
637 if edmName.endswith(
"Sim")
and flags.Input.Format == Format.POOL: edmName = edmName.replace(
"Sim",
"_ReSim")
638 auxType = edmType.replace(
'Container',
'AuxContainer')
639 return [f
'{edmType}#{edmName}', f
'{auxType}#{edmName}Aux.']
643 if flags.Trigger.L1.doeFex:
644 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer' ,
"L1_eEMRoI")
645 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer' ,
"L1_eEMRoISim")
646 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer' ,
"L1_eEMxRoI")
647 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer' ,
"L1_eEMxRoISim")
649 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer' ,
"L1_eTauRoI")
650 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer' ,
"L1_eTauRoISim")
651 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer' ,
"L1_eTauxRoI")
652 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer' ,
"L1_eTauxRoISim")
654 if flags.Trigger.L1.dojFex:
655 outputEDM +=
addEDM(
'xAOD::jFexTowerContainer' ,
"L1_jFexDataTowers")
656 outputEDM +=
addEDM(
'xAOD::jFexTowerContainer' ,
"L1_jFexEmulatedTowers")
657 outputEDM +=
addEDM(
'xAOD::jFexSRJetRoIContainer',
'L1_jFexSRJetRoISim')
658 outputEDM +=
addEDM(
'xAOD::jFexLRJetRoIContainer',
'L1_jFexLRJetRoISim')
659 outputEDM +=
addEDM(
'xAOD::jFexTauRoIContainer' ,
'L1_jFexTauRoISim' )
660 outputEDM +=
addEDM(
'xAOD::jFexFwdElRoIContainer',
'L1_jFexFwdElRoISim')
661 outputEDM +=
addEDM(
'xAOD::jFexSumETRoIContainer',
'L1_jFexSumETRoISim')
662 outputEDM +=
addEDM(
'xAOD::jFexMETRoIContainer' ,
'L1_jFexMETRoISim' )
663 outputEDM +=
addEDM(
'xAOD::jFexSRJetRoIContainer',
'L1_jFexSRJetRoI')
664 outputEDM +=
addEDM(
'xAOD::jFexLRJetRoIContainer',
'L1_jFexLRJetRoI')
665 outputEDM +=
addEDM(
'xAOD::jFexTauRoIContainer' ,
'L1_jFexTauRoI' )
666 outputEDM +=
addEDM(
'xAOD::jFexFwdElRoIContainer',
'L1_jFexFwdElRoI')
667 outputEDM +=
addEDM(
'xAOD::jFexSumETRoIContainer',
'L1_jFexSumETRoI')
668 outputEDM +=
addEDM(
'xAOD::jFexMETRoIContainer' ,
'L1_jFexMETRoI' )
670 outputEDM +=
addEDM(
'xAOD::jFexSRJetRoIContainer',
'L1_jFexSRJetxRoI')
671 outputEDM +=
addEDM(
'xAOD::jFexLRJetRoIContainer',
'L1_jFexLRJetxRoI')
672 outputEDM +=
addEDM(
'xAOD::jFexTauRoIContainer' ,
'L1_jFexTauxRoI' )
673 outputEDM +=
addEDM(
'xAOD::jFexFwdElRoIContainer',
'L1_jFexFwdElxRoI')
674 outputEDM +=
addEDM(
'xAOD::jFexSumETRoIContainer',
'L1_jFexSumETxRoI')
675 outputEDM +=
addEDM(
'xAOD::jFexMETRoIContainer' ,
'L1_jFexMETxRoI' )
677 if flags.Trigger.L1.dogFex:
678 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMETComponentsJwoj')
679 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMETComponentsJwojSim')
680 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMHTComponentsJwoj')
681 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMHTComponentsJwojSim')
682 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMSTComponentsJwoj')
683 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMSTComponentsJwojSim')
684 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gScalarEJwoj')
685 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gScalarEJwojSim')
686 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gScalarENoiseCutSim')
687 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gScalarERmsSim')
689 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer',
'L1_gFexLRJetRoI')
690 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer',
'L1_gFexLRJetRoISim')
691 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer',
'L1_gFexSRJetRoI')
692 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer',
'L1_gFexSRJetRoISim')
693 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer',
'L1_gFexRhoRoI')
694 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer',
'L1_gFexRhoRoISim')
698 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
699 cfg.merge(OutputStreamCfg(flags,
'AOD', ItemList=outputEDM, takeItemsFromInput=
True))
700 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
701 cfg.merge(SetupMetaDataForStreamCfg(flags,
'AOD'))
704if flags.Output.BSFileName !=
"":
705 from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig
import L1TriggerByteStreamEncoderCfg
706 cfg.merge(L1TriggerByteStreamEncoderCfg(flags))
709 algo = CompFactory.L1TriggerResultMaker(
"OutputBSTCCMaker",
711 eFexEMRoIKeys=[], eFexTauRoIKeys=[],
712 jFexFwdElRoIKeys=[], jFexTauRoIKeys = [],
713 jFexSRJetRoIKeys = [], jFexLRJetRoIKeys = [],
714 gFexSRJetRoIKeys = [], gFexLRJetRoIKeys = [],
715 cTauRoIKey =
"", cjTauLinkKey =
"", ThresholdPatternTools= [],
717 L1TriggerResultWHKey =
"OutputBSTCC")
719 cfg.getService(
"ByteStreamCnvSvc").FillTriggerBits=
False
720 if flags.Trigger.L1.doeFex:
721 algo.eFexEMRoIKeys = [
"L1_eEMRoI",
"L1_eEMxRoI"]
722 algo.eFexTauRoIKeys = [
"L1_eTauRoI",
"L1_eTauxRoI"]
724 if flags.Trigger.L1.dojFex:
725 algo.jFexSRJetRoIKeys = [
"L1_jFexSRJetRoI"]
726 algo.jFexLRJetRoIKeys = [
"L1_jFexLRJetRoI"]
727 algo.jFexTauRoIKeys = [
"L1_jFexTauRoI"]
728 algo.jFexFwdElRoIKeys = [
"L1_jFexFwdElRoI"]
730 if flags.Trigger.L1.dogFex:
731 algo.gFexSRJetRoIKeys = [
"L1_gFexSRJetRoI"]
732 algo.gFexLRJetRoIKeys = [
"L1_gFexLRJetRoI"]
733 algo.gScalarEJwojKeys = [
"L1_gScalarEJwoj"]
734 algo.gMETComponentsJwojKeys = [
"L1_gMETComponentsJwoj"]
736 cfg.addEventAlgo(algo)
737 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamWriteCfg
738 write = ByteStreamWriteCfg(flags, [
"xAOD::TrigCompositeContainer#OutputBSTCC"])
741if "MuonAlignmentCondAlg" in [a.name
for a
in cfg.getCondAlgos()]: cfg.getCondAlgo(
"MuonAlignmentCondAlg").OutputLevel=Constants.ERROR
744if flags.Trigger.L1.doeFex
and (args.evtNumber
is not None):
746 cfg.addEventAlgo(CompFactory.LVL1.eFexEventDumper(TowersKey=
"L1_eFexDataTowers",EMRoIKey=
"L1_eEMRoI",TauRoIKey=
"L1_eTauRoI"))
751from AthenaCommon.Include
import include
753with ConfigurableCABehavior():
754 for inc
in args.postInclude:
756 topLog.setLevel(logging.INFO)
758 topLog.setLevel(logging.WARNING)
759 except Exception
as e:
761 print(f
"Exception from {inc}")
765 while tb
is not None:
766 if tb.tb_frame.f_code.co_filename.endswith(inc):
770 traceback.print_exception(
type(e), e, tb)
773for conf
in args.postConfig:
774 compName,propNameAndVal=conf.split(
".",1)
775 propName,propVal=propNameAndVal.split(
"=",1)
777 from collections
import defaultdict
778 availableComps = defaultdict(list)
779 for comp
in [c
for c
in cfg._allComponents()]+cfg.getServices():
780 availableComps[comp.getType()] += [comp.getName()]
781 if comp.getName()==compName
or comp.getType()==compName
or comp.toStringProperty()==compName:
784 log.info(
"Setting "+compName+
" property: "+propNameAndVal)
785 exec(f
"comp.{propNameAndVal}")
786 except AttributeError
as e:
787 log.fatal(
"Unknown property of " + compName +
" : " + propNameAndVal)
788 log.fatal(
"See next line for available properties:")
793 print(
"Available comps:")
794 for k,v
in availableComps.items():
796 raise ValueError(f
"postConfig {conf} had no effect ... typo? See list above of available components")
798if args.postHelp
is not None:
799 from collections
import defaultdict
800 availableComps = defaultdict(list)
801 for comp
in [c
for c
in cfg._allComponents()]+cfg.getServices():
802 availableComps[comp.getType()] += [comp.getName()]
803 print(
"Available comps:")
804 for k,v
in availableComps.items():
805 print(
"",k,
":",
", ".join(v))
810if flags.Exec.MaxEvents==0: cfg.printConfig(withDetails =
True, summariseProps =
True, printDefaults =
True)
811log.info(
" ".join((
"Configured Services:",*[svc.name
for svc
in cfg.getServices()])) )
815if flags.Exec.MaxEvents==1:
817 cfg.getService(
"StoreGateSvc").Dump=
True
818 cfg.getService(
"DetectorStore").Dump=
True
821if cfg.getService(
"StoreGateSvc").Dump:
822 cfg.getService(
"StoreGateSvc").OutputLevel=3
823if cfg.getService(
"DetectorStore").Dump:
824 cfg.getService(
"DetectorStore").OutputLevel=3
827 from AthenaConfiguration.ComponentAccumulator
import startInteractive
828 oldLevel = int(cfg._msg.getEffectiveLevel())
829 cfg._msg.setLevel(logging.INFO)
830 print(
"\n\nEntering interactive configuration mode. You can explore and edit the cfg object. Ctrl+D to configure application and move to pre-initialize step")
831 startInteractive(locals()|{
"self":cfg})
832 cfg._msg.setLevel(oldLevel)
835 readline.write_history_file(os.path.expanduser(
'~/.athena.history' ))
837if flags.Exec.MaxEvents==0:
841 from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig
import L1CaloMonitorCfgHelper
842 L1CaloMonitorCfgHelper.printHanConfig()
843 cfg._wasMerged =
True
846if cfg.run().isFailure():
void print(char *figname, TCanvas *c1)
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
load_function(file_path, function_name)