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