ATLAS Offline Software
Loading...
Searching...
No Matches
StateLessPT_Test_NewConfig.py
Go to the documentation of this file.
1#!/usr/bin/env python
2#
3# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4#
5
6if __name__=='__main__':
7 import os,sys,getopt
8
9 if len(sys.argv)>1 and (sys.argv[1]=="-h" or sys.argv[1]=="--help"):
10 print("Usage:")
11 print(" ")
12 print("StateLessPT_NewConfig.py {--config XXX} {--stream YYY} {--run Z}")
13 print(" default XXX: LArMon")
14 print(" default YYY: ''")
15 print(" default Z: '435946'")
16
17 # #####################################################
18 # Read jobOpt configuration options
19 # #####################################################
20
21 #some defaults
22 CONFIG = 'LArMon'
23 STREAM = "NONE"
24 RUNN = 448285
25 if len(sys.argv)>1:
26 for ii in range(1,len(sys.argv)):
27 print(ii," ",sys.argv[ii])
28 try:
29 opts,args=getopt.getopt(sys.argv[1:],"t:",["config=","stream=","run="])
30 except getopt.GetoptError as e:
31 print("Failed to interpret arguments")
32 print(e)
33 sys.exit(-1)
34 pass
35
36 for o,a in opts:
37 if o=="--config":
38 print("Got option --config: ",a)
39 CONFIG=a
40 if o=="--stream": STREAM=a
41 if o=="--run": RUNN=int(a)
42
43 from AthenaConfiguration.Enums import Format
44
45 # #####################################################
46 # Get environment variables
47 # #####################################################
48
49 partition = os.environ.get("TDAQ_PARTITION")
50
51 from ispy import IPCPartition, ISObject
52
53 # ################################
54 # To read run parameters from IS
55 # ################################
56 p = IPCPartition(partition)
57 if not p.isValid():
58 print("Partition:",p.name(),"is not valid")
59 sys.exit(1)
60
61
62 from AthenaConfiguration.Enums import BeamType
63 runnumber = RUNN
64 if partition == "ATLAS" or partition[0:3] == "LAr":
65 try:
66 y = ISObject(p, 'RunParams.SOR_RunParams', 'RunParams')
67 except:
68 print("Could not find Run Parameters in IS - Set default beam type to 'cosmics'")
69 beamType=BeamType.Cosmics
70 else:
71 y.checkout()
72 beamtype = y.beam_type
73 beamenergy = y.beam_energy
74 runnumber = y.run_number
75 project = y.T0_project_tag
76 print("RUN CONFIGURATION: beam type %i, beam energy %i, run number %i, project tag %s"%(beamtype,beamenergy,runnumber,project))
77 # define beam type based on project tag name
78 if project[7:10]=="cos":
79 beamType=BeamType.Cosmics
80 else:
81 beamType=BeamType.Collisions
82
83
84 else:
85 beamType=BeamType.Collisions
86
87
88 try:
89 x = ISObject(p, 'LArParams.LAr.RunLogger.GlobalParams', 'GlobalParamsInfo')
90 except:
91 print("Could not find IS Parameters - Set default flag")
92 ReadDigits = False
93 FirstSample = 3
94 NSamples = 4
95 LArFormat = 1
96 RunType = 2
97 runnumber = 423433
98 #for splash test
99 #ReadDigits = True
100 #FirstSample = 6
101 #NSamples = 32
102 #LArFormat = 0
103 #RunType = 0
104 #runnumber = 418554
105 else:
106 try:
107 x.checkout()
108 except:
109 print("Couldn not find IS Parameters - Set default flag")
110 ReadDigits = False
111 FirstSample = 3
112 NSamples = 4
113 LArFormat = 1
114 RunType = 2
115 runnumber = 423433
116 #for splash test
117 #ReadDigits = True
118 #FirstSample = 6
119 #NSamples = 32
120 #LArFormat = 0
121 #RunType = 0
122 #runnumber = 418554
123 else:
124 RunType = x.runType
125 LArFormat = x.format
126 FirstSample = x.firstSample
127 NSamples = x.nbOfSamples
128 RunType = x.runType
129 print("RUN CONFIGURATION: format %i,run type %i"%(RunType,LArFormat))
130 # Decide how to get cell energy: DSP or digits
131 if LArFormat==0:
132 ReadDigits = True
133 else:
134 ReadDigits = False
135
136 print("RUN CONFIGURATION: ReadDigits =", ReadDigits)
137
138
139 from AthenaConfiguration.AllConfigFlags import initConfigFlags
140 flags = initConfigFlags()
141 from AthenaMonitoring.DQConfigFlags import allSteeringFlagsOff
142 allSteeringFlagsOff(flags)
143
144
145 flags.Beam.Type=beamType
146 flags.Beam.BunchSpacing=25
147 print("RUN CONFIGURATION: Beamtype =",flags.Beam.Type)
148
149 flags.Common.isOnline=True
150 flags.Input.Format=Format.BS
151 flags.Input.isMC=False
152
153
154 from AthenaCommon.Constants import WARNING
155 flags.Exec.MaxEvents=-1
156
157 from AthenaConfiguration.AutoConfigOnlineRecoFlags import autoConfigOnlineRecoFlags
158 autoConfigOnlineRecoFlags(flags,partition)
159
160 flags.IOVDb.DatabaseInstance="CONDBR2"
161 flags.IOVDb.GlobalTag="CONDBR2-ES1PA-2023-03"
162
163 flags.GeoModel.Layout="atlas"
164 from AthenaConfiguration.TestDefaults import defaultGeometryTags
165 flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
166
167 #overwrite the run number
168 flags.Input.RunNumbers=[runnumber]
169 # overwrite LB number for playback partition if needed....
170 flags.Input.LumiBlockNumbers=[0]
171
172 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
173 setupDetectorFlags(flags, ['LAr'], toggle_geometry=True)
174
175 flags.Trigger.doID=False
176 flags.Trigger.doMuon=False
177 flags.Trigger.L1.doMuon=False
178 flags.Trigger.L1.doTopo=False
179 flags.Trigger.doHLT=False
180 flags.Trigger.doLVL1=False
181 flags.Trigger.Online.isPartition=True
182 flags.Trigger.triggerConfig='DB'
183 flags.Trigger.DecisionMakerValidation.Execute=False
184 flags.Trigger.enableL1CaloPhase1=False
185
186 flags.DQ.doMonitoring=True
187 flags.DQ.disableAtlasReadyFilter=True
188 flags.DQ.useTrigger=True
189 flags.DQ.FileKey=''
190 flags.DQ.Environment='online'
191
192 flags.LAr.doAlign=False
193 flags.LAr.doHVCorr=False
194
195 # in case to debug FPE:
196 #flags.Exec.FPE=3
197 #if 'DTMon' in CONFIG:
198 # flags.Exec.FPE=5
199
200 if RunType == 0:
201 flags.LAr.ROD.forceIter=True
202
203 flags.Calo.TopoCluster.doTopoClusterLocalCalib=False
204
205 #test multithreads
206 #flags.Concurrency.NumThreads=1
207 #flags.Concurrency.NumConcurrentEvents=1
208
210 from LArMonitoring.LArMonConfigFlags import createLArMonConfigFlags
211 return createLArMonConfigFlags()
212
213 flags.addFlagsCategory("LArMon", __monflags)
214
215 if STREAM=="CosmicCalo" or STREAM=="LArCellsEmpty":
216 flags.LArMon.doLArRawMonitorSignal=True
217
218 if 'CaloMon' in CONFIG: # needs Lumi access
219 flags.DQ.enableLumiAccess=False
220 else:
221 flags.DQ.enableLumiAccess=True
222
223 if 'PEB' in STREAM: # do not have HLT results
224 flags.Trigger.decodeHLT=False
225 flags.DQ.useTrigger = False
226
227 flags.lock()
228
229 flags.dump()
230
231 # taken from future EmonByteStreamConfig
232 from AthenaConfiguration.ComponentFactory import CompFactory
233
234 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
235 acc = MainServicesCfg(flags)
236
237 bytestream_conversion = CompFactory.ByteStreamCnvSvc()
238 acc.addService(bytestream_conversion, primary=True)
239
240 from ByteStreamEmonSvc.EmonByteStreamConfig import EmonByteStreamCfg
241 acc.merge(EmonByteStreamCfg(flags))
242
243 bytestream_input = acc.getService("ByteStreamInputSvc")
244
245 # ############################################################
246 # The name of the partition you want to connect to is taken
247 # from 'TDAQ_PARTITION' if it exists, otherwise from here.
248 # ############################################################
249
250 bytestream_input.Partition = partition
251
252 # #########################################
253 # The source of events, dcm for full events.
254 # #########################################
255
256 if partition == "ATLAS" or partition[:3] == "LAr":
257 bytestream_input.Key = "dcm"
258 else:
259 bytestream_input.Key = "CompleteEvent"
260
261 bytestream_input.KeyCount = 15
262 bytestream_input.KeyCount = 150
263 bytestream_input.UpdatePeriod = 60
264 #
265 # #######################################
266 # Set this to the IS server where you want
267 # to publish histograms, too. If unset, no histograms
268 # are published.
269 # #######################################
270
271 bytestream_input.ISServer = 'LArHistogramming'
272
273 # ########################################
274 # The provider name under which your histograms
275 # appear in OH.
276 # ########################################
277
278 if STREAM!='NONE':
279 bytestream_input.PublishName = '%s-Test-%s'%(CONFIG,STREAM)
280 else:
281 bytestream_input.PublishName = '%s-Test-%s'%(CONFIG,"NoTrigSel")
282
283 # ###################################################
284 # Should histograms be cleared at new run ? default: yes
285 # Moved to False 27th Jan 2010 - Reset for each event in HLT 15.5.5
286 # ###################################################
287
288 bytestream_input.ClearHistograms = True
289
290 # #########################
291 # To get all Beam Splashes this needs uncomment
292 # #########################
293
294 #bytestream_input.Dispersion=False
295
296 # ###############################################
297 # Frequency of updates (in number of events, not secs...)
298 # ###############################################
299
300 #bytestream_input.Frequency = 5
301
302 # #######################################################
303 # TimeOut (in milliseconds) - Prevent job with low rates
304 # to reconnect too often to SFIs
305 # ######################################################
306
307 bytestream_input.Timeout = 3600000
308
309 # ###################################################
310 # Stream/trigger Selection
311 # --> For LAr partitions, no stream available
312 # --> For ATLAS, can create streams from L1 items
313 # ##################################################
314
315 if bytestream_input.Partition[:3] == "LAr":
316 bytestream_input.StreamType = ""
317 else:
318 bytestream_input.LVL1Logic = "Or"
319 bytestream_input.LVL1Origin = "TAV"
320 bytestream_input.StreamType = "physics"
321 bytestream_input.StreamLogic = "And"
322 if STREAM!="NONE":
323 if STREAM=="LArCellsEmpty":
324 bytestream_input.StreamType = "calibration"
325 bytestream_input.StreamNames = ['LArCellsEmpty']
326 if STREAM=="Main":
327 bytestream_input.StreamNames = ['Main']
328 if STREAM=="CosmicCalo":
329 bytestream_input.StreamNames = ['CosmicCalo']
330 if STREAM=="L1Topo":
331 bytestream_input.StreamNames = ['L1Topo']
332 if STREAM=="L1Calo":
333 bytestream_input.StreamNames = ['L1Calo']
334 if STREAM=="express":
335 bytestream_input.StreamNames = ['express']
336 bytestream_input.StreamType = "express"
337 if STREAM=="LArNoiseBurst":
338 bytestream_input.StreamType = "calibration"
339 bytestream_input.StreamNames = ['LArNoiseBurst']
340 if STREAM=="Standby":
341 bytestream_input.StreamNames = ['Standby']
342 if STREAM=="ZeroBias":
343 bytestream_input.StreamNames = ['ZeroBias']
344 if STREAM=="MinBias":
345 bytestream_input.StreamNames = ['MinBias']
346 if STREAM=="Background":
347 bytestream_input.StreamNames = ['Background']
348 if STREAM=="05_Jets":
349 bytestream_input.StreamType = "calibration"
350 bytestream_input.StreamNames = ['DataScouting_05_Jets']
351 if STREAM=="random":
352 bytestream_input.StreamNames = ['monitoring_random']
353 bytestream_input.StreamType = "monitoring"
354 if STREAM=="calibration":
355 bytestream_input.StreamType = "calibration"
356 if "LArPEBDigitalTrigger" in STREAM:
357 bytestream_input.StreamType = "calibration"
358 bytestream_input.StreamNames = ['LArPEBDigitalTrigger']
359 if "EMPTY" in STREAM:
360 bytestream_input.LVL1Names=["L1_RD0_EMPTY","L1_RD0_LAR_EMPTY","L1_RD0_FIRSTEMPTY"]
361 elif "FILLED" in STREAM:
362 bytestream_input.LVL1Names=["L1_RD0_FILLED"]
363 elif "PHYS" in STREAM:
364 bytestream_input.LVL1Names=["L1_jJ500_LAR","L1_LAR-ZEE-eEM"]
365 pass
366
367
368 print("DEBUG: bytestream_input.StreamNames:",bytestream_input.StreamNames)
369
370 else: # select any trigger, but from physics events only !
371 bytestream_input.StreamType = "physics"
372 bytestream_input.StreamLogic = "Or"
373 # not possible to ignore one stream, so creating a full list
374 bytestream_input.StreamNames = ["Main","CosmicCalo","L1Topo","L1Calo","Standby","ZeroBias","Background", "EnhancedBias", "MinBias", "LArCells", "LArCellsEmpty", "LArNoiseBurst", "BphysDelayed", "Late"]
375
376
377 # #################################################
378 # Shall athena exit if the partition is shutdown ?
379 # For offline athena tasks ONLY.
380 # Set this parameter to FALSE online.
381 # #################################################
382 bytestream_input.ExitOnPartitionShutdown = False
383
384 # #################################################
385 # From Sergei Kolos, Nov. 2009:
386 # Parameter default overwritten to drastically
387 # decrease the load on the network
388 # #################################################
389
390 bytestream_input.BufferSize = 10
391
392 # #################################################
393 # Private Application Configuration options, replace with
394 # your configuration.
395 # #################################################
396
397 #acc.addService(bytestream_input)
398
399 event_selector = CompFactory.EventSelectorByteStream(
400 name='EventSelector',
401 ByteStreamInputSvc=bytestream_input.name,
402 FileBased=False)
403 acc.addService(event_selector)
404 acc.setAppProperty("EvtSel", event_selector.name)
405
406 event_persistency = CompFactory.EvtPersistencySvc(
407 name="EventPersistencySvc",
408 CnvServices=[bytestream_conversion.name])
409 acc.addService(event_persistency)
410
411 address_provider = CompFactory.ByteStreamAddressProviderSvc()
412 acc.addService(address_provider)
413
414 proxy = CompFactory.ProxyProviderSvc()
415 proxy.ProviderNames += [address_provider.name]
416 acc.addService(proxy)
417
418 from TriggerJobOpts.TriggerRecoConfig import TriggerRecoCfg
419 acc.merge(TriggerRecoCfg(flags))
420
421
422 l1bsdec = acc.getEventAlgo("L1TriggerByteStreamDecoder")
423 l1bsdec.ByteStreamMetadataRHKey=""
424 print("MaybeMissingROBs: ",l1bsdec.MaybeMissingROBs)
425 l1bsdec.MaybeMissingROBs += [0x770001, 0x7500ac, 0x7500ad, 0x7300a8, 0x7300a9, 0x7300aa, 0x7300ab]
426
427 from LArMonitoring.RecoPT_NewConfig import LArMonitoringConfig
428 print('CONFIG ',CONFIG)
429 print('STREAM ',STREAM)
430
431 # testing Denis stuff
432 # not working, because MbtsDetDescrManager not found.....
433 #from TileGeoModel.TileGMConfig import TileGMCfg
434 #acc.merge(TileGMCfg(flags))
435 #from LArMonitoring.LArSuperCellMonAlg import LArSuperCellMonConfig
436 #acc.merge(LArSuperCellMonConfig(flags))
437
438 if "LArSCvsRawChannel" in CONFIG:
439 from LArMonitoring.RecoPT_Phase1NewConfig import LArSCvsRawChannelMonAlgCfg
440 acc.merge(LArSCvsRawChannelMonAlgCfg(flags,STREAM))
441
442 elif CONFIG!="LArDTMon":
443 from LArMonitoring.RecoPT_NewConfig import LArMonitoringConfig
444 acc.merge(LArMonitoringConfig(flags,CONFIG,STREAM,RunType))
445
446 else:
447 from LArMonitoring.RecoPT_Phase1NewConfig import LArDTMonitoringConfig
448 acc.merge(LArDTMonitoringConfig(flags,STREAM))
449
450
451 # fixes for splashes
452 if RunType == 0 and CONFIG!="LArDTMon":
453 acc.getEventAlgo("LArRawDataReadingAlg").LArRawChannelKey=""
454
455 # example for blocking the folder not filled during cosmics
456 cil=acc.getCondAlgo('CondInputLoader')
457 iovdbsvc=acc.getService('IOVDbSvc')
458 folder='/TRIGGER/LUMI/LBLB'
459 for i in range(0,len(iovdbsvc.Folders)):
460 if (iovdbsvc.Folders[i].find(folder)>=0):
461 del iovdbsvc.Folders[i]
462 break
463
464 remove_folder = False
465 for cil_Loadval in cil.Load:
466 if folder in cil_Loadval:
467 print(f"Removing {cil_Loadval} from cil/Load")
468 remove_folder = True
469 break
470 if remove_folder: cil.Load.remove(cil_Loadval)
471
472 if flags.DQ.enableLumiAccess:
473 lbd = acc.getCondAlgo('LBDurationCondAlg')
474 lbd.LBLBFolderInputKey=""
475 print('lbd ',lbd)
476
477 # somehow needs to add postprocessing
478 from AthenaCommon.Constants import WARNING
479 from DataQualityUtils.DQPostProcessingAlg import DQPostProcessingAlg
480 ppa = DQPostProcessingAlg("DQPostProcessingAlg")
481 ppa.ExtraInputs = {( 'xAOD::EventInfo' , 'StoreGateSvc+EventInfo' )}
482 ppa.Interval = 200
483 ppa.OutputLevel = WARNING
484 if flags.Common.isOnline:
485 ppa.FileKey = ((flags.DQ.FileKey + '/') if not flags.DQ.FileKey.endswith('/')
486 else flags.DQ.FileKey)
487
488 acc.addEventAlgo(ppa, sequenceName='AthEndSeq')
489
490 # example how to dump the store:
491 #acc.getService("StoreGateSvc").Dump=True
492 #acc.getService("StoreGateSvc").OutputLevel=DEBUG
493 #acc.getService("MessageSvc").OutputLevel=DEBUG
494
495 acc.printConfig()
496 acc.run()
void print(char *figname, TCanvas *c1)
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138