ATLAS Offline Software
L1CaloPhase1Monitoring.py
Go to the documentation of this file.
1 #!/usr/bin/env athena
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 
4 
10 
11 from AthenaConfiguration.ComponentFactory import CompFactory
12 from AthenaConfiguration.AllConfigFlags import initConfigFlags
13 from AthenaConfiguration.Enums import LHCPeriod,Format
14 from AthenaCommon import Constants
15 import os,sys
16 import ispy
17 import re
18 partition = ispy.IPCPartition(os.getenv("TDAQ_PARTITION","ATLAS"))
19 
20 flags = initConfigFlags()
21 flags.Input.Files = [] # so that when no files given we can detect that
22 
23 # Note: The order in which all these flag defaults get set is very fragile
24 # so don't reorder the setup of this flags stuff
25 
26 
27 flags.Exec.OutputLevel = Constants.WARNING # by default make everything output at WARNING level
28 flags.Exec.InfoMessageComponents = ["AthenaEventLoopMgr","THistSvc","PerfMonMTSvc","ApplicationMgr"] # Re-enable some info messaging though
29 flags.Exec.PrintAlgsSequence = True # print the alg sequence at the start of the job (helpful to see what is scheduled)
30 # flags.Exec.FPE = -2 # disable FPE auditing ... set to 0 to re-enable
31 
32 
33 flags.GeoModel.Run = LHCPeriod.Run3 # needed for LArGMConfig - or can infer from above
34 flags.Common.useOnlineLumi = True # needed for lumi-scaled monitoring, only have lumi in online DB at this time
35 flags.DQ.doMonitoring = True # use this flag to turn on/off monitoring in this application
36 flags.DQ.enableLumiAccess = False # in fact, we don't need lumi access for now ... this turns it all off
37 flags.DQ.FileKey = "" if partition.isValid() else "EXPERT" # histsvc file "name" to record to - Rafal asked it to be blank @ P1 ... means monitoring.root will be empty
38 flags.Output.HISTFileName = os.getenv("L1CALO_ATHENA_JOB_NAME","") + "monitoring.root" # control names of monitoring root file - ensure each online monitoring job gets a different filename to avoid collision between processes
39 flags.DQ.useTrigger = False # don't do TrigDecisionTool in MonitorCfg helper methods
40 flags.Trigger.L1.doCaloInputs = True # flag for saying if inputs should be decoded or not
41 flags.Trigger.enableL1CaloPhase1 = True # used by this script to turn on/off the simulation
42 # flags for rerunning simulation
43 flags.Trigger.L1.doeFex = True
44 flags.Trigger.L1.dojFex = True
45 flags.Trigger.L1.dogFex = True
46 # if running online, override these with autoconfig values
47 # will set things like the GlobalTag automatically
48 if partition.isValid():
49  # must ensure doLVL1 and doHLT are False, otherwise will get ByteStreamCnvSvc conflicts (TrigByteStreamCnvSvc is setup, but EMon setup provides ByteStreamCnvSvc)
50  # see TriggerByteStreamConfig.py
51  flags.Trigger.doLVL1 = False
52  flags.Trigger.doHLT = False
53  from AthenaConfiguration.AutoConfigOnlineRecoFlags import autoConfigOnlineRecoFlags
54  autoConfigOnlineRecoFlags(flags, partition.name()) # sets things like projectName etc which would otherwise be inferred from input file
55 else:
56  flags.Trigger.doLVL1 = True # set this just so that IOBDb.GlobalTag is autoconfigured based on release setup if running on RAW (autoconfig will take it from POOL file if running on that)
57 #flags.IOVDb.GlobalTag = lambda s: "OFLCOND-MC23-SDR-RUN3-02" if s.Input.isMC else "CONDBR2-ES1PA-2022-07" #"CONDBR2-HLTP-2022-02"
58 
59 # now parse
60 
61 parser = flags.getArgumentParser(epilog="""
62 Extra flags are specified after a " -- " and the following are most relevant bool flags for this script:
63 
64  Trigger.enableL1CaloPhase1 : turn on/off the offline simulation [default: True]
65  DQ.doMonitoring : turn on/off the monitoring [default: True]
66  Trigger.L1.doCaloInputs : controls input readout decoding and monitoring [default: True]
67  Trigger.L1.doCalo : controls trex (legacy syst) monitoring [default: True]
68  Trigger.L1.doeFex : controls efex simulation and monitoring [default: True]
69  Trigger.L1.dojFex : controls jfex simulation and monitoring [default: True]
70  Trigger.L1.dogFex : controls gfex simulation and monitoring [default: True]
71  DQ.useTrigger : controls if JetEfficiency monitoring alg is run or not [default: False]
72  PerfMon.doFullMonMT : print info about execution time of algorithms and memory use etc [default: False]
73 
74 E.g. to run just the jFex monitoring, without offline simulation, you can do:
75 
76 athena TrigT1CaloMonitoring/L1CalPhase1Monitoring.py .... -- Trigger.enableL1CaloPhase1=False Trigger.L1.doCaloInputs=False Trigger.L1.doeFex=False Trigger.L1.dogFex=False
77 
78 Further notes: Run with "--evtMax 0" to print flags and ca config, and generate a hanConfig file.
79  Run with "--evtMax 1" to dump StoreGate contents after the first event
80 
81 """)
82 import argparse
83 #class combinedFormatter(parser.formatter_class,argparse.RawDescriptionHelpFormatter): pass
84 parser.formatter_class = argparse.RawDescriptionHelpFormatter
85 parser.add_argument('--runNumber',default=None,help="specify to select a run number")
86 parser.add_argument('--lumiBlock',default=None,help="specify to select a lumiBlock")
87 parser.add_argument('--evtNumber',default=None,nargs="+",type=int,help="specify to select an evtNumber")
88 parser.add_argument('--stream',default="*",help="stream to lookup files in")
89 parser.add_argument('--fexReadoutFilter',action='store_true',help="If specified, will skip events without fexReadout")
90 parser.add_argument('--dbOverrides',default=None,nargs="+",type=str,help="specify overrides of COOL database folders in form <folder>=<dbPath>, example: /TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib=mytest.db ")
91 parser.add_argument('--postConfig',default=[],nargs="+",type=str,help="specify component properties to apply at the end of the config")
92 args = flags.fillFromArgs(parser=parser)
93 if args.runNumber is not None:
94  # todo: if an exact event number is provided, we can in theory use the event index and rucio to obtain a filename:
95  # e.g: event-lookup -D RAW "477048 3459682284"
96  # use GUID result to do:
97  # ~/getRucioLFNbyGUID.sh 264a4214-e922-ef11-ab28-b8cef6444828
98  # gives a filename (last part): data24_13p6TeV.00477048.physics_Main.daq.RAW._lb0975._SFO-13._0001.data
99  from glob import glob
100  if args.lumiBlock is None: args.lumiBlock="*"
101  print("Looking up files in atlastier0 for run",args.runNumber,"lb =",args.lumiBlock)
102  flags.Input.Files = []
103  for lb in args.lumiBlock.split(","):
104  if lb=="*":
105  tryStr = f"/eos/atlas/atlastier0/rucio/data*/{args.stream}/*{args.runNumber}/*RAW/*lb*.*"
106  else:
107  tryStr = f"/eos/atlas/atlastier0/rucio/data*/{args.stream}/*{args.runNumber}/*RAW/*lb{int(lb):04}.*"
108  print("Trying",tryStr)
109  flags.Input.Files += glob(tryStr)
110  print("Found",len(flags.Input.Files),"files")
111 
112 standalone = False
113 # require at least 1 input file if running offline
114 if not partition.isValid() and len(flags.Input.Files)==0:
115  print("FATAL: Running in offline mode but no input files provided")
116  sys.exit(1)
117 elif partition.isValid():
118  print("Running Online with Partition:",partition.name())
119  standalone = (partition.name()!="ATLAS")
120  if standalone : print("Using local menu because partition is not ATLAS")
121 
122 # if running on an input file, change the DQ environment, which will allow debug tree creation from monitoring algs
123 if len(flags.Input.Files)>0:
124  flags.DQ.Environment = "user"
125  # triggerConfig should default to DB which is appropriate if running on data
126  # standalone if project tag is data_test of dataXX_calib
127  standalone = ((flags.Input.ProjectName == "data_test") or (re.match(r"data\d\d_calib", flags.Input.ProjectName)))
128  if standalone : print("Using local menu because project_name=",flags.Input.ProjectName)
129  if flags.Input.isMC : flags.Trigger.triggerConfig='FILE' # uses the generated L1Menu (see below)
130  elif flags.Trigger.triggerConfig=='INFILE':
131  # this happens with AOD data files, but this is incompatible with the setup of the LVL1ConfigSvc
132  flags.Trigger.triggerConfig="DB" # so force onto DB usage
133 
134 if standalone :
135  flags.Trigger.triggerConfig='FILE' #Uses generated L1Menu In online on input files
136 
137 
138 if flags.Exec.MaxEvents == 0:
139  # in this mode, ensure all monitoring activated, so that generated han config is complete
140  flags.DQ.doMonitoring=True
141  flags.Trigger.L1.doCaloInputs=True
142  flags.Trigger.L1.doeFex=True
143  flags.Trigger.L1.dojFex=True
144  flags.Trigger.L1.dogFex=True
145  flags.DQ.useTrigger=True # enables JetEfficiency algorithms
146  flags.Exec.OutputLevel = Constants.INFO
147 
148 # due to https://gitlab.cern.ch/atlas/athena/-/merge_requests/65253 must now specify geomodel explicitly if cant take from input file, but can autoconfigure it based on LHCPeriod set above
149 if flags.GeoModel.AtlasVersion is None:
150  from AthenaConfiguration.TestDefaults import defaultGeometryTags
151  flags.GeoModel.AtlasVersion = defaultGeometryTags.autoconfigure(flags)
152 
153 if flags.Trigger.enableL1CaloPhase1:
154  # add detector conditions flags required for rerunning simulation
155  # needs input files declared if offline, hence doing after parsing
156  from AthenaConfiguration.DetectorConfigFlags import setupDetectorsFromList
157  setupDetectorsFromList(flags,['LAr','Tile','MBTS'],True)
158 
159 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
160 cfg = MainServicesCfg(flags)
161 
162 
163 flags.lock()
164 if flags.Exec.MaxEvents == 0: flags.dump(evaluate=True)
165 
166 if partition.isValid() and len(flags.Input.Files)==0:
167  from ByteStreamEmonSvc.EmonByteStreamConfig import EmonByteStreamCfg
168  cfg.merge(EmonByteStreamCfg(flags)) # setup EmonSvc
169  bsSvc = cfg.getService("ByteStreamInputSvc")
170  bsSvc.Partition = partition.name()
171  bsSvc.Key = os.environ.get("L1CALO_PTIO_KEY", "REB" if partition.name()=="L1CaloStandalone" else "dcm") # set the Sampler Key Type name (default is SFI)
172  if partition.name()=="L1CaloSTF": bsSvc.Key = "SWROD"
173  bsSvc.KeyCount = int(os.environ.get("L1CALO_PTIO_KEY_COUNT","25"))
174  bsSvc.ISServer = "Histogramming" # IS server on which to create this provider
175  bsSvc.BufferSize = 10 # event buffer size for each sampler
176  bsSvc.UpdatePeriod = 30 # time in seconds between updating plots
177  bsSvc.Timeout = 240000 # timeout (not sure what this does)
178  bsSvc.PublishName = os.getenv("L1CALO_ATHENA_JOB_NAME","testing") # set name of this publisher as it will appear in IS (default is "l1calo-athenaHLT"; change to something sensible for testing)
179  bsSvc.StreamType = os.getenv("L1CALO_PTIO_STREAM_TYPE","physics") # name of the stream type (physics,express, etc.)
180  bsSvc.ExitOnPartitionShutdown = False
181  bsSvc.ClearHistograms = True # clear hists at start of new run
182  bsSvc.GroupName = "RecExOnline"
183  # name of the stream (Egamma,JetTauEtmiss,MinBias,Standby, etc.), this can be a colon(:) separated list of streams that use the 'streamLogic' to combine stream for 2016 HI run
184  bsSvc.StreamNames = os.getenv("L1CALO_PTIO_STREAM_NAME","L1Calo:Main:MinBias:MinBiasOverlay:UPC:EnhancedBias:ZeroBias:HardProbes:Standby:ALFACalib").split(":")
185  bsSvc.StreamLogic = os.getenv("L1CALO_PTIO_STREAM_LOGIC","Or") if partition.name() != "L1CaloStandalone" else "Ignore"
186  bsSvc.LVL1Names = [] # name of L1 items to select
187  bsSvc.LVL1Logic = "Ignore" # one of: Ignore, Or, And
188 elif flags.Input.Format == Format.POOL:
189  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
190  cfg.merge(PoolReadCfg(flags))
191 else:
192  print("Running Offline on", len(flags.Input.Files)," bytestream files")
193  #from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
194  #TODO: Figure out why the above line causes CA conflict @ P1 if try to run on a RAW file there
195  from TriggerJobOpts.TriggerByteStreamConfig import ByteStreamReadCfg
196  cfg.merge(ByteStreamReadCfg(flags)) # configure reading bytestream
197 
198 # ensure histsvc is set up
199 from AthenaMonitoring.AthMonitorCfgHelper import getDQTHistSvc
200 cfg.merge(getDQTHistSvc(flags))
201 
202 # Create run3 L1 menu (needed for L1Calo EDMs)
203 from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg,generateL1Menu, createL1PrescalesFileFromMenu,getL1MenuFileName
204 if flags.Trigger.triggerConfig=="FILE":
205  # for MC we set the TriggerConfig to "FILE" above, so must generate a menu for it to load (will be the release's menu)
206  generateL1Menu(flags)
208  menuFilename = getL1MenuFileName(flags)
209  if os.path.exists(menuFilename):
210  print("Using L1Menu:",menuFilename)
211  else:
212  print("L1Menu file does not exist:",menuFilename)
213  sys.exit(1)
214 cfg.merge(L1ConfigSvcCfg(flags))
215 
216 # -------- CHANGES GO BELOW ------------
217 # setup the L1Calo software we want to monitor
218 
219 decoderTools = []
220 
221 if partition.isValid() or (flags.Input.Format != Format.POOL and not flags.Input.isMC):
222  from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig import eFexByteStreamToolCfg, jFexRoiByteStreamToolCfg, jFexInputByteStreamToolCfg, gFexByteStreamToolCfg, gFexInputByteStreamToolCfg
223  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))]
224  if flags.Trigger.L1.dojFex: decoderTools += [cfg.popToolsAndMerge(jFexRoiByteStreamToolCfg(flags=flags,name="jFexBSDecoderTool",writeBS=False))]
225  if flags.Trigger.L1.dogFex: decoderTools += [cfg.popToolsAndMerge(gFexByteStreamToolCfg(flags=flags,name="gFexBSDecoderTool",writeBS=False))]
226 
227 
228 
229  if flags.Trigger.L1.doCaloInputs:
230  if flags.Trigger.L1.dojFex: decoderTools += [cfg.popToolsAndMerge(jFexInputByteStreamToolCfg(flags=flags,name='jFexInputBSDecoderTool',writeBS=False))]
231  if flags.Trigger.L1.dogFex: decoderTools += [cfg.popToolsAndMerge(gFexInputByteStreamToolCfg(flags=flags,name='gFexInputBSDecoderTool',writeBS=False))]
232 
233  if len(decoderTools) > 0:
234  from TrigT1ResultByteStream.TrigT1ResultByteStreamMonitoringConfig import L1TriggerByteStreamDecoderMonitoringCfg
235  cfg.addEventAlgo(CompFactory.L1TriggerByteStreamDecoderAlg(
236  name="L1TriggerByteStreamDecoder",
237  OutputLevel=Constants.ERROR, # hides warnings about non-zero status codes in fragments ... will show up in hists
238  DecoderTools=decoderTools,
239  ByteStreamMetadataRHKey = '', # seems necessary @ P1 if trying to run on a raw file
240  MaybeMissingROBs= [id for tool in decoderTools for id in tool.ROBIDs ] if partition.name()!="ATLAS" or not partition.isValid() else [], # allow missing ROBs away from online ATLAS partition
241  MonTool= cfg.popToolsAndMerge(L1TriggerByteStreamDecoderMonitoringCfg(flags,"L1TriggerByteStreamDecoder", decoderTools))
242  ),sequenceName='AthAlgSeq'
243  )
244 
245 # rerun sim if required
246 if flags.Trigger.enableL1CaloPhase1:
247  from L1CaloFEXSim.L1CaloFEXSimCfg import L1CaloFEXSimCfg
248  # note to self ... could look into input key remapping to avoid conflict with sim from input:
249  # from SGComps.AddressRemappingConfig import InputRenameCfg
250  # acc.merge(InputRenameCfg('xAOD::TriggerTowerContainer', 'xAODTriggerTowers_rerun', 'xAODTriggerTowers'))
251  cfg.merge(L1CaloFEXSimCfg(flags,outputSuffix="_ReSim" if flags.Input.Format == Format.POOL else ""))
252 
253  # do otf masking:
254  # from IOVDbSvc.IOVDbSvcConfig import addFolders,addOverride
255  # #cfg.merge(addFolders(flags,"<db>sqlite://;schema=/afs/cern.ch/user/w/will/new_maskedSCs_run457976.db;dbname=CONDBR2</db> /LAR/BadChannels/NoisyChannelsSC",className="CondAttrListCollection")) # dmCorr from DB!
256  # cfg.merge(addFolders(flags,"/LAR/BadChannels/MaskedSC","LAR_ONL",tag="LARBadChannelsMaskedSC-RUN3-UPD1-00",className="CondAttrListCollection",extensible=False)) # when run online, need folder to be extensible to force reload each event
257  # cfg.addCondAlgo(CompFactory.LArBadChannelCondAlg(name="MaskedSCCondAlg",ReadKey="/LAR/BadChannels/MaskedSC",isSC=True,CablingKey="LArOnOffIdMapSC",WriteKey="LArMaskedSC"))
258  # # note to self, if need to flag extensible after loaded elsewhere, look at property: cfg.getService("IOVDbSvc").Folders ... extend relevant entry with "<extensible/>"
259  # print(cfg.getService("MessageSvc"))
260  # cfg.getService("MessageSvc").errorLimit = 0
261  #
262  # cfg.getEventAlgo("L1_eFexEmulatedTowers").LArBadChannelKey = "LArMaskedSC"
263 
264 
265 
266 if flags.DQ.doMonitoring:
267  if flags.Trigger.L1.doCalo:
268  from TrigT1CaloMonitoring.PprMonitorAlgorithm import PprMonitoringConfig
269  cfg.merge(PprMonitoringConfig(flags))
270  from TrigT1CaloMonitoring.PPMSimBSMonitorAlgorithm import PPMSimBSMonitoringConfig
271  cfg.merge(PPMSimBSMonitoringConfig(flags))
272  from TrigT1CaloMonitoring.OverviewMonitorAlgorithm import OverviewMonitoringConfig
273  cfg.merge(OverviewMonitoringConfig(flags))
274  # CPM was disabled for run 480893 onwards, so stop monitoring that part
275  # could have used detectorMask to determine if CPM is disabled, but will just assume it here
276  OverviewMonAlg = cfg.getEventAlgo("OverviewMonAlg")
277  OverviewMonAlg.CPMErrorLocation = ""
278  OverviewMonAlg.CPMMismatchLocation = ""
279 
280  if flags.Trigger.L1.doeFex:
281  from TrigT1CaloMonitoring.EfexMonitorAlgorithm import EfexMonitoringConfig
282  cfg.merge(EfexMonitoringConfig(flags))
283  EfexMonAlg = cfg.getEventAlgo('EfexMonAlg')
284  # do we need next lines??
285  EfexMonAlg.eFexEMTobKeyList = ['L1_eEMRoI', 'L1_eEMxRoI'] # default is just L1_eEMRoI
286  EfexMonAlg.eFexTauTobKeyList = ['L1_eTauRoI', 'L1_eTauxRoI']
287  # Adjust eFEX containers to be monitored to also monitor the sim RoI unless running on raw without simulation
288  if flags.Input.Format == Format.POOL or flags.Trigger.enableL1CaloPhase1:
289  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 ]
290  # monitoring of simulation vs hardware
291  if not flags.Input.isMC and flags.Trigger.enableL1CaloPhase1:
292  from TrigT1CaloMonitoring.EfexSimMonitorAlgorithm import EfexSimMonitoringConfig
293  cfg.merge(EfexSimMonitoringConfig(flags))
294  # EfexSimMonitorAlgorithm = cfg.getEventAlgo('EfexSimMonAlg')
295  # and now book the histograms that depend on the containers
296  from TrigT1CaloMonitoring.EfexMonitorAlgorithm import EfexMonitoringHistConfig
297  cfg.merge(EfexMonitoringHistConfig(flags,EfexMonAlg))
298 
299  if flags.Trigger.L1.dojFex:
300  from TrigT1CaloMonitoring.JfexMonitorAlgorithm import JfexMonitoringConfig
301  cfg.merge(JfexMonitoringConfig(flags))
302  if not flags.Input.isMC and flags.Trigger.enableL1CaloPhase1:
303  from TrigT1CaloMonitoring.JfexSimMonitorAlgorithm import JfexSimMonitoringConfig
304  cfg.merge(JfexSimMonitoringConfig(flags))
305  if flags.Trigger.L1.dogFex:
306  from TrigT1CaloMonitoring.GfexMonitorAlgorithm import GfexMonitoringConfig
307  cfg.merge(GfexMonitoringConfig(flags))
308  if not flags.Input.isMC and flags.Trigger.enableL1CaloPhase1:
309  from TrigT1CaloMonitoring.GfexSimMonitorAlgorithm import GfexSimMonitoringConfig
310  cfg.merge(GfexSimMonitoringConfig(flags))
311  # generally can't include efficiency monitoring because requires too many things we don't have
312  # but b.c. alg requires TrigDecisionTool, we activate it if DQ.useTrigger explicitly set
313  if flags.DQ.useTrigger:
314  from TrigT1CaloMonitoring.JetEfficiencyMonitorAlgorithm import JetEfficiencyMonitoringConfig
315  cfg.merge(JetEfficiencyMonitoringConfig(flags))
316 
317  # input data monitoring
318  if flags.Trigger.L1.doCaloInputs and not flags.Input.isMC:
319  from TrigT1CaloMonitoring.EfexInputMonitorAlgorithm import EfexInputMonitoringConfig
320  if flags.Trigger.L1.doeFex: cfg.merge(EfexInputMonitoringConfig(flags))
321  from TrigT1CaloMonitoring.JfexInputMonitorAlgorithm import JfexInputMonitoringConfig
322  if flags.Trigger.L1.dojFex: cfg.merge(JfexInputMonitoringConfig(flags))
323  from TrigT1CaloMonitoring.GfexInputMonitorAlgorithm import GfexInputMonitoringConfig
324  if flags.Trigger.L1.dogFex: cfg.merge(GfexInputMonitoringConfig(flags))
325 
326 mainSeq = "AthAllAlgSeq"
327 if args.fexReadoutFilter:
328  # want to take existing AthAllSeqSeq and move it inside a new sequence
329  topSeq = cfg.getSequence("AthAlgEvtSeq")
330  algSeq = cfg.getSequence(mainSeq)
331  mainSeq = "New" + mainSeq
332  # topSeq has three sub-sequencers ... preserve first and last
333  topSeq.Members = [topSeq.Members[0],CompFactory.AthSequencer(mainSeq),topSeq.Members[-1]]
334  cfg.addEventAlgo(CompFactory.L1IDFilterAlgorithm(),sequenceName=mainSeq)
335  cfg.getSequence(mainSeq).Members += [algSeq]
336 
337 if args.evtNumber is not None:
338  print("filtering events",args.evtNumber)
339  # similar adjustment with an event filter
340  topSeq = cfg.getSequence("AthAlgEvtSeq")
341  algSeq = cfg.getSequence(mainSeq)
342  mainSeq = "New" + mainSeq
343  # topSeq has three sub-sequencers ... preserve first and last
344  topSeq.Members = [topSeq.Members[0],CompFactory.AthSequencer(mainSeq),topSeq.Members[-1]]
345  cfg.addEventAlgo(CompFactory.EventNumberFilterAlgorithm("EvtNumberFilter",EventNumbers=args.evtNumber),sequenceName=mainSeq)
346  cfg.getSequence(mainSeq).Members += [algSeq]
347  # cfg.addEventAlgo(CompFactory.LVL1.eFexEventDumper("Dumper",TowersKey="L1_eFexEmulatedTowers"))
348 
349 from PerfMonComps.PerfMonCompsConfig import PerfMonMTSvcCfg
350 cfg.merge( PerfMonMTSvcCfg(flags) )
351 
352 from AthenaConfiguration.Utils import setupLoggingLevels
353 setupLoggingLevels(flags,cfg)
354 
355 if cfg.getService("AthenaEventLoopMgr"): cfg.getService("AthenaEventLoopMgr").IntervalInSeconds = 30
356 
357 if type(args.dbOverrides)==list:
358  from IOVDbSvc.IOVDbSvcConfig import addOverride
359  #examples:
360  #cfg.merge( addOverride(flags, folder="/TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib", db="sqlite://;schema=mytest.db;dbname=CONDBR2",tag="" ) )
361  #cfg.merge( addOverride(flags, folder="/TRIGGER/L1Calo/V1/Calibration/EfexNoiseCuts", db="sqlite://;schema=/afs/cern.ch/user/w/will/calib.sqlite;dbname=L1CALO",tag="" ) )
362  for override in args.dbOverrides:
363  print(override)
364  folderName,dbPath = override.split("=",1)
365  if folderName == "": raise ValueError("Cannot parse dbOverride: " + override)
366  if ";dbname=" not in dbPath: dbPath += ";dbname=CONDBR2"
367  dbPath,dbInst = dbPath.split(";dbname=")
368  if not os.path.exists(dbPath): raise ValueError("dbOverride file doesn't exist: " + dbPath)
369  if folderName[0] != "/": folderName = "/TRIGGER/L1Calo/V1/Calibration/" + folderName
370  print("Overriding COOL folder:",folderName,dbPath,dbInst)
371  cfg.merge( addOverride(flags,folder=folderName,db=f"sqlite://;schema={dbPath};dbname={dbInst}",tag=""))
372 
373 
374 # configure output AOD if requested
375 if flags.Output.AODFileName != "":
376  def addEDM(edmType, edmName):
377  if edmName.endswith("Sim") and flags.Input.Format == Format.POOL: edmName = edmName.replace("Sim","_ReSim")
378  auxType = edmType.replace('Container','AuxContainer')
379  return [f'{edmType}#{edmName}', f'{auxType}#{edmName}Aux.']
380 
381  outputEDM = []
382 
383  if flags.Trigger.L1.doeFex:
384  outputEDM += addEDM('xAOD::eFexEMRoIContainer' , "L1_eEMRoI")
385  outputEDM += addEDM('xAOD::eFexEMRoIContainer' , "L1_eEMRoISim")
386  outputEDM += addEDM('xAOD::eFexEMRoIContainer' , "L1_eEMxRoI")
387  outputEDM += addEDM('xAOD::eFexEMRoIContainer' , "L1_eEMxRoISim")
388 
389  outputEDM += addEDM('xAOD::eFexTauRoIContainer' , "L1_eTauRoI")
390  outputEDM += addEDM('xAOD::eFexTauRoIContainer' , "L1_eTauRoISim")
391  outputEDM += addEDM('xAOD::eFexTauRoIContainer' , "L1_eTauxRoI")
392  outputEDM += addEDM('xAOD::eFexTauRoIContainer' , "L1_eTauxRoISim")
393 
394  if flags.Trigger.L1.dojFex:
395  outputEDM += addEDM('xAOD::jFexTowerContainer' , "L1_jFexDataTowers")
396  outputEDM += addEDM('xAOD::jFexTowerContainer' , "L1_jFexEmulatedTowers")
397  outputEDM += addEDM('xAOD::jFexSRJetRoIContainer', 'L1_jFexSRJetRoISim')
398  outputEDM += addEDM('xAOD::jFexLRJetRoIContainer', 'L1_jFexLRJetRoISim')
399  outputEDM += addEDM('xAOD::jFexTauRoIContainer' , 'L1_jFexTauRoISim' )
400  outputEDM += addEDM('xAOD::jFexFwdElRoIContainer', 'L1_jFexFwdElRoISim')
401  outputEDM += addEDM('xAOD::jFexSumETRoIContainer', 'L1_jFexSumETRoISim')
402  outputEDM += addEDM('xAOD::jFexMETRoIContainer' , 'L1_jFexMETRoISim' )
403  outputEDM += addEDM('xAOD::jFexSRJetRoIContainer', 'L1_jFexSRJetRoI')
404  outputEDM += addEDM('xAOD::jFexLRJetRoIContainer', 'L1_jFexLRJetRoI')
405  outputEDM += addEDM('xAOD::jFexTauRoIContainer' , 'L1_jFexTauRoI' )
406  outputEDM += addEDM('xAOD::jFexFwdElRoIContainer', 'L1_jFexFwdElRoI')
407  outputEDM += addEDM('xAOD::jFexSumETRoIContainer', 'L1_jFexSumETRoI')
408  outputEDM += addEDM('xAOD::jFexMETRoIContainer' , 'L1_jFexMETRoI' )
409 
410  outputEDM += addEDM('xAOD::jFexSRJetRoIContainer', 'L1_jFexSRJetxRoI')
411  outputEDM += addEDM('xAOD::jFexLRJetRoIContainer', 'L1_jFexLRJetxRoI')
412  outputEDM += addEDM('xAOD::jFexTauRoIContainer' , 'L1_jFexTauxRoI' )
413  outputEDM += addEDM('xAOD::jFexFwdElRoIContainer', 'L1_jFexFwdElxRoI')
414  outputEDM += addEDM('xAOD::jFexSumETRoIContainer', 'L1_jFexSumETxRoI')
415  outputEDM += addEDM('xAOD::jFexMETRoIContainer' , 'L1_jFexMETxRoI' )
416 
417  if flags.Trigger.L1.dogFex:
418  outputEDM += addEDM('xAOD::gFexGlobalRoIContainer','L1_gMETComponentsJwoj')
419  outputEDM += addEDM('xAOD::gFexGlobalRoIContainer','L1_gMETComponentsJwojSim')
420  outputEDM += addEDM('xAOD::gFexGlobalRoIContainer','L1_gMHTComponentsJwoj')
421  outputEDM += addEDM('xAOD::gFexGlobalRoIContainer','L1_gMHTComponentsJwojSim')
422  outputEDM += addEDM('xAOD::gFexGlobalRoIContainer','L1_gMSTComponentsJwoj')
423  outputEDM += addEDM('xAOD::gFexGlobalRoIContainer','L1_gMSTComponentsJwojSim')
424  outputEDM += addEDM('xAOD::gFexGlobalRoIContainer','L1_gScalarEJwoj')
425  outputEDM += addEDM('xAOD::gFexGlobalRoIContainer','L1_gScalarEJwojSim')
426  outputEDM += addEDM('xAOD::gFexGlobalRoIContainer','L1_gScalarENoiseCutSim')
427  outputEDM += addEDM('xAOD::gFexGlobalRoIContainer','L1_gScalarERmsSim')
428 
429  outputEDM += addEDM('xAOD::gFexJetRoIContainer','L1_gFexLRJetRoI')
430  outputEDM += addEDM('xAOD::gFexJetRoIContainer','L1_gFexLRJetRoISim')
431  outputEDM += addEDM('xAOD::gFexJetRoIContainer','L1_gFexSRJetRoI')
432  outputEDM += addEDM('xAOD::gFexJetRoIContainer','L1_gFexSRJetRoISim')
433  outputEDM += addEDM('xAOD::gFexJetRoIContainer','L1_gFexRhoRoI')
434  outputEDM += addEDM('xAOD::gFexJetRoIContainer','L1_gFexRhoRoISim')
435 
436 
437 
438  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
439  cfg.merge(OutputStreamCfg(flags, 'AOD', ItemList=outputEDM, takeItemsFromInput=True))
440  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
441  cfg.merge(SetupMetaDataForStreamCfg(flags, 'AOD'))
442 
443 # ensure reloading OTF masking every event if running online monitoring
444 if "MaskedSCCondAlg" in cfg.getCondAlgos(): cfg.getCondAlgo("MaskedSCCondAlg").ReloadEveryEvent=flags.Common.isOnline
445 
446 # example of adding user algorithm
447 # cfg.addEventAlgo(CompFactory.AnotherPackageAlg(),sequenceName="AthAlgSeq")
448 
449 for conf in args.postConfig:
450  compName,propNameAndVal=conf.split(".",1)
451  propName,propVal=propNameAndVal.split("=",1)
452  applied = False
453  for comp in [c for c in cfg._allComponents()]+cfg.getServices():
454  if comp.name==compName:
455  applied = True
456  exec(f"comp.{propNameAndVal}")
457  break
458  if not applied:
459  raise ValueError(f"postConfig {conf} had no effect ... typo?")
460 
461 # -------- CHANGES GO ABOVE ------------
462 
463 if flags.Exec.MaxEvents==0: cfg.printConfig(summariseProps=True)
464 print("Configured Services:",*[svc.name for svc in cfg.getServices()])
465 #print("Configured EventAlgos:",*[alg.name for alg in cfg.getEventAlgos()])
466 #print("Configured CondAlgos:",*[alg.name for alg in cfg.getCondAlgos()])
467 
468 if flags.Exec.MaxEvents==1:
469  # special debugging mode
470  cfg.getService("StoreGateSvc").Dump=True
471  cfg.getService("DetectorStore").Dump=True
472 
473 # ensure printout level is low enough if dumping
474 if cfg.getService("StoreGateSvc").Dump:
475  cfg.getService("StoreGateSvc").OutputLevel=3
476 if cfg.getService("DetectorStore").Dump:
477  cfg.getService("DetectorStore").OutputLevel=3
478 
479 if flags.Exec.MaxEvents==0:
480  # create a han config file if running in config-only mode
481  # command used to generate official config:
482  # athena TrigT1CaloMonitoring/L1CaloPhase1Monitoring.py --filesInput /eos/atlas/atlascerngroupdisk/det-l1calo/OfflineSoftware/TestFiles/data24_13p6TeV/data24_13p6TeV.00477048.physics_Main.daq.RAW._lb0821._SFO-20._0001.data --evtMax 0 -- DQ.useTrigger=True
483  from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
484  L1CaloMonitorCfgHelper.printHanConfig()
485  sys.exit(0)
486 
487 if cfg.run().isFailure():
488  import sys
489  sys.exit(1)
EfexMonitorAlgorithm.EfexMonitoringHistConfig
def EfexMonitoringHistConfig(flags, eFexAlg)
Definition: EfexMonitorAlgorithm.py:35
EmonByteStreamConfig.EmonByteStreamCfg
def EmonByteStreamCfg(flags, type_names=[])
Definition: EmonByteStreamConfig.py:12
PPMSimBSMonitorAlgorithm.PPMSimBSMonitoringConfig
def PPMSimBSMonitoringConfig(flags)
Definition: PPMSimBSMonitorAlgorithm.py:7
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
EfexSimMonitorAlgorithm.EfexSimMonitoringConfig
def EfexSimMonitoringConfig(flags)
Definition: EfexSimMonitorAlgorithm.py:4
GfexSimMonitorAlgorithm.GfexSimMonitoringConfig
def GfexSimMonitoringConfig(flags, UseOfflineCopy=True)
Definition: GfexSimMonitorAlgorithm.py:4
python.TrigConfigSvcCfg.createL1PrescalesFileFromMenu
def createL1PrescalesFileFromMenu(flags)
Definition: TrigConfigSvcCfg.py:165
python.TrigConfigSvcCfg.generateL1Menu
def generateL1Menu(flags)
Definition: TrigConfigSvcCfg.py:184
python.TrigConfigSvcCfg.getL1MenuFileName
def getL1MenuFileName(flags)
Definition: TrigConfigSvcCfg.py:136
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
L1CaloFEXByteStreamConfig.jFexInputByteStreamToolCfg
def jFexInputByteStreamToolCfg(flags, name, *writeBS=False)
Definition: L1CaloFEXByteStreamConfig.py:232
python.PerfMonCompsConfig.PerfMonMTSvcCfg
def PerfMonMTSvcCfg(flags, **kwargs)
A minimal new-style configuration for PerfMonMTSvc.
Definition: PerfMonCompsConfig.py:10
python.Utils.setupLoggingLevels
def setupLoggingLevels(flags, ca)
Definition: Control/AthenaConfiguration/python/Utils.py:46
python.DetectorConfigFlags.setupDetectorsFromList
def setupDetectorsFromList(flags, detectors, toggle_geometry=False, validate_only=False)
Definition: DetectorConfigFlags.py:354
EfexInputMonitorAlgorithm.EfexInputMonitoringConfig
def EfexInputMonitoringConfig(flags)
Definition: EfexInputMonitorAlgorithm.py:4
L1CaloPhase1Monitoring.addEDM
def addEDM(edmType, edmName)
Definition: L1CaloPhase1Monitoring.py:376
python.IOVDbSvcConfig.addOverride
def addOverride(flags, folder, tag, db=None)
Definition: IOVDbSvcConfig.py:224
LArG4FSStartPointFilter.exec
exec
Definition: LArG4FSStartPointFilter.py:103
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
L1CaloFEXByteStreamConfig.gFexByteStreamToolCfg
def gFexByteStreamToolCfg(flags, name, *writeBS=False)
Definition: L1CaloFEXByteStreamConfig.py:148
TrigT1ResultByteStreamMonitoringConfig.L1TriggerByteStreamDecoderMonitoringCfg
def L1TriggerByteStreamDecoderMonitoringCfg(flags, name, decoderTools)
Definition: TrigT1ResultByteStreamMonitoringConfig.py:75
python.AutoConfigOnlineRecoFlags.autoConfigOnlineRecoFlags
def autoConfigOnlineRecoFlags(flags, partition=None)
Definition: AutoConfigOnlineRecoFlags.py:134
GfexInputMonitorAlgorithm.GfexInputMonitoringConfig
def GfexInputMonitoringConfig(flags)
Definition: GfexInputMonitorAlgorithm.py:4
PprMonitorAlgorithm.PprMonitoringConfig
def PprMonitoringConfig(inputFlags)
Definition: PprMonitorAlgorithm.py:5
L1CaloPhase1Monitoring.int
int
Definition: L1CaloPhase1Monitoring.py:87
L1CaloFEXByteStreamConfig.gFexInputByteStreamToolCfg
def gFexInputByteStreamToolCfg(flags, name, *writeBS=False)
Definition: L1CaloFEXByteStreamConfig.py:275
GfexMonitorAlgorithm.GfexMonitoringConfig
def GfexMonitoringConfig(flags)
Definition: GfexMonitorAlgorithm.py:4
python.AthMonitorCfgHelper.getDQTHistSvc
def getDQTHistSvc(flags)
Definition: AthMonitorCfgHelper.py:169
python.TrigConfigSvcCfg.L1ConfigSvcCfg
def L1ConfigSvcCfg(flags)
Definition: TrigConfigSvcCfg.py:198
L1CaloPhase1Monitoring.type
type
Definition: L1CaloPhase1Monitoring.py:87
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
L1CaloFEXByteStreamConfig.jFexRoiByteStreamToolCfg
def jFexRoiByteStreamToolCfg(flags, name, *writeBS=False, xTOBs=False)
Definition: L1CaloFEXByteStreamConfig.py:87
JfexSimMonitorAlgorithm.JfexSimMonitoringConfig
def JfexSimMonitoringConfig(flags)
Definition: JfexSimMonitorAlgorithm.py:4
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
L1CaloFEXByteStreamConfig.eFexByteStreamToolCfg
def eFexByteStreamToolCfg(flags, name, *writeBS=False, TOBs=True, xTOBs=False, multiSlice=False, decodeInputs=False)
Definition: L1CaloFEXByteStreamConfig.py:8
JfexInputMonitorAlgorithm.JfexInputMonitoringConfig
def JfexInputMonitoringConfig(flags)
Definition: JfexInputMonitorAlgorithm.py:4
EfexMonitorAlgorithm.EfexMonitoringConfig
def EfexMonitoringConfig(inputFlags)
Definition: EfexMonitorAlgorithm.py:4
InfileMetaDataConfig.SetupMetaDataForStreamCfg
def SetupMetaDataForStreamCfg(flags, streamName="", AcceptAlgs=None, createMetadata=None, propagateMetadataFromInput=True, *args, **kwargs)
Definition: InfileMetaDataConfig.py:219
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
JetEfficiencyMonitorAlgorithm.JetEfficiencyMonitoringConfig
def JetEfficiencyMonitoringConfig(flags)
Definition: JetEfficiencyMonitorAlgorithm.py:4
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
L1CaloFEXSimCfg
Definition: L1CaloFEXSimCfg.py:1
JfexMonitorAlgorithm.JfexMonitoringConfig
def JfexMonitoringConfig(flags)
Definition: JfexMonitorAlgorithm.py:4
OverviewMonitorAlgorithm.OverviewMonitoringConfig
def OverviewMonitoringConfig(inputFlags)
Definition: OverviewMonitorAlgorithm.py:4