ATLAS Offline Software
Loading...
Searching...
No Matches
StateLessPT_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 LATOME_FW = 5
98 #for splash test
99 #ReadDigits = True
100 #FirstSample = 6
101 #NSamples = 32
102 #LArFormat = 0
103 #RunType = 0
104 else:
105 try:
106 x.checkout()
107 except:
108 print("Couldn not find IS Parameters - Set default flag")
109 ReadDigits = False
110 FirstSample = 3
111 NSamples = 4
112 LArFormat = 1
113 RunType = 2
114 LATOME_FW = 5
115 #for splash test
116 #ReadDigits = True
117 #FirstSample = 6
118 #NSamples = 32
119 #LArFormat = 0
120 #RunType = 0
121 else:
122 RunType = x.runType
123 LArFormat = x.format
124 FirstSample = x.firstSample
125 NSamples = x.nbOfSamples
126 RunType = x.runType
127 LATOME_FW = x.ttype_mask_A
128 print("RUN CONFIGURATION: format %i,run type %i"%(RunType,LArFormat))
129 # Decide how to get cell energy: DSP or digits
130 if LArFormat==0:
131 ReadDigits = True
132 else:
133 ReadDigits = False
134
135 print("RUN CONFIGURATION: ReadDigits =", ReadDigits)
136
137
138 from AthenaConfiguration.AllConfigFlags import initConfigFlags
139 flags = initConfigFlags()
140 from AthenaMonitoring.DQConfigFlags import allSteeringFlagsOff
141 allSteeringFlagsOff(flags)
142
143
144 flags.Beam.Type=beamType
145 flags.Beam.BunchSpacing=25
146 print("RUN CONFIGURATION: Beamtype =",flags.Beam.Type)
147
148 flags.Common.isOnline=True
149 flags.Input.Format=Format.BS
150 flags.Input.isMC=False
151
152
153 from AthenaCommon.Constants import WARNING
154 flags.Exec.MaxEvents=-1
155
156 from AthenaConfiguration.AutoConfigOnlineRecoFlags import autoConfigOnlineRecoFlags
157 autoConfigOnlineRecoFlags(flags,partition)
158
159 flags.IOVDb.DatabaseInstance="CONDBR2"
160 flags.IOVDb.GlobalTag="CONDBR2-ES1PA-2023-03"
161
162 flags.GeoModel.Layout="atlas"
163 from AthenaConfiguration.TestDefaults import defaultGeometryTags
164 flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
165
166 #overwrite the run number
167 flags.Input.RunNumbers=[runnumber]
168 # overwrite LB number for playback partition if needed....
169 flags.Input.LumiBlockNumbers=[0]
170
171 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
172 setupDetectorFlags(flags, ['LAr'], toggle_geometry=True)
173
174 flags.Trigger.doID=False
175 flags.Trigger.doMuon=False
176 flags.Trigger.L1.doMuon=False
177 flags.Trigger.L1.doTopo=False
178 flags.Trigger.doHLT=False
179 flags.Trigger.doLVL1=False
180 flags.Trigger.Online.isPartition=True
181 flags.Trigger.triggerConfig='DB'
182 flags.Trigger.DecisionMakerValidation.Execute=False
183 flags.Trigger.enableL1CaloPhase1=False
184
185 flags.DQ.doMonitoring=True
186 flags.DQ.disableAtlasReadyFilter=True
187 flags.DQ.useTrigger=True
188 flags.DQ.FileKey=''
189 flags.DQ.Environment='online'
190
191 flags.LAr.doAlign=False
192 flags.LAr.doHVCorr=False
193
194 # in case to debug FPE:
195 #flags.Exec.FPE=3
196 #if 'DTMon' in CONFIG:
197 # flags.Exec.FPE=5
198
199 if RunType == 0:
200 flags.LAr.ROD.forceIter=True
201
202 flags.Calo.TopoCluster.doTopoClusterLocalCalib=False
203
205 from LArMonitoring.LArMonConfigFlags import createLArMonConfigFlags
206 return createLArMonConfigFlags()
207
208 flags.addFlagsCategory("LArMon", __monflags)
209
210 if STREAM=="CosmicCalo" or STREAM=="LArCellsEmpty":
211 flags.LArMon.doLArRawMonitorSignal=True
212
213 if 'CaloMon' in CONFIG: # needs Lumi access
214 flags.DQ.enableLumiAccess=False
215 else:
216 flags.DQ.enableLumiAccess=True
217
218 if 'PEB' in STREAM: # do not have HLT results
219 flags.Trigger.decodeHLT=False
220 flags.DQ.useTrigger = False
221
222 flags.lock()
223
224 flags.dump()
225
226 # taken from future EmonByteStreamConfig
227 from AthenaConfiguration.ComponentFactory import CompFactory
228 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
229
230 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
231 acc = MainServicesCfg(flags)
232
233 bytestream_conversion = CompFactory.ByteStreamCnvSvc()
234 acc.addService(bytestream_conversion, primary=True)
235
236 from ByteStreamEmonSvc.EmonByteStreamConfig import EmonByteStreamCfg
237 acc.merge(EmonByteStreamCfg(flags))
238
239 bytestream_input = acc.getService("ByteStreamInputSvc")
240
241 # ############################################################
242 # The name of the partition you want to connect to is taken
243 # from 'TDAQ_PARTITION' if it exists, otherwise from here.
244 # ############################################################
245
246 bytestream_input.Partition = partition
247
248 # #########################################
249 # The source of events, dcm for full events.
250 # #########################################
251
252 if partition == "ATLAS" or partition[:3] == "LAr":
253 bytestream_input.Key = "dcm"
254 else:
255 bytestream_input.Key = "CompleteEvent"
256
257 bytestream_input.KeyCount = 15
258 bytestream_input.KeyCount = 150
259 bytestream_input.UpdatePeriod = 200
260 #
261 # #######################################
262 # Set this to the IS server where you want
263 # to publish histograms, too. If unset, no histograms
264 # are published.
265 # #######################################
266
267 bytestream_input.ISServer = 'LArHistogramming'
268
269 # ########################################
270 # The provider name under which your histograms
271 # appear in OH.
272 # ########################################
273
274 if STREAM!='NONE':
275 bytestream_input.PublishName = '%s-%s'%(CONFIG,STREAM)
276 else:
277 bytestream_input.PublishName = '%s-%s'%(CONFIG,"NoTrigSel")
278
279 # ###################################################
280 # Should histograms be cleared at new run ? default: yes
281 # Moved to False 27th Jan 2010 - Reset for each event in HLT 15.5.5
282 # ###################################################
283
284 bytestream_input.ClearHistograms = True
285
286 # #########################
287 # To get all Beam Splashes this needs uncomment
288 # #########################
289
290 #bytestream_input.Dispersion=False
291
292 # ###############################################
293 # Frequency of updates (in number of events, not secs...)
294 # ###############################################
295
296 bytestream_input.Frequency = 5
297
298 # #######################################################
299 # TimeOut (in milliseconds) - Prevent job with low rates
300 # to reconnect too often to SFIs
301 # ######################################################
302
303 bytestream_input.Timeout = 3600000
304
305 # FIXME, hack for bad events from IBL
306 bytestream_input.ProcessCorruptedEvents = True
307
308 # ###################################################
309 # Stream/trigger Selection
310 # --> For LAr partitions, no stream available
311 # --> For ATLAS, can create streams from L1 items
312 # ##################################################
313
314 if bytestream_input.Partition[:3] == "LAr":
315 bytestream_input.StreamType = ""
316 else:
317 bytestream_input.LVL1Logic = "Or"
318 bytestream_input.LVL1Origin = "TAV"
319 bytestream_input.StreamType = "physics"
320 bytestream_input.StreamLogic = "And"
321 if STREAM!="NONE":
322 if STREAM=="LArCellsEmpty":
323 bytestream_input.StreamType = "calibration"
324 bytestream_input.StreamNames = ['LArCellsEmpty']
325 if STREAM=="Main":
326 bytestream_input.StreamNames = ['Main']
327 #bytestream_input.StreamNames = ['HardProbes'] # to be used for HI runs
328 if STREAM=="UPC":
329 bytestream_input.StreamNames = ['UPC']
330 if STREAM=="CosmicCalo":
331 bytestream_input.StreamNames = ['CosmicCalo']
332 if STREAM=="L1Topo":
333 bytestream_input.StreamNames = ['L1Topo']
334 if STREAM=="L1Calo":
335 bytestream_input.StreamNames = ['L1Calo']
336 if STREAM=="express":
337 bytestream_input.StreamNames = ['express']
338 bytestream_input.StreamType = "express"
339 if STREAM=="LArNoiseBurst":
340 bytestream_input.StreamType = "calibration"
341 bytestream_input.StreamNames = ['LArNoiseBurst']
342 if STREAM=="Standby":
343 bytestream_input.StreamNames = ['Standby']
344 if STREAM=="ZeroBias":
345 bytestream_input.StreamNames = ['ZeroBias']
346 if STREAM=="MinBias":
347 bytestream_input.StreamNames = ['MinBias']
348 if STREAM=="Background":
349 bytestream_input.StreamNames = ['Background']
350 if STREAM=="05_Jets":
351 bytestream_input.StreamType = "calibration"
352 bytestream_input.StreamNames = ['DataScouting_05_Jets']
353 if STREAM=="random":
354 bytestream_input.StreamNames = ['monitoring_random']
355 bytestream_input.StreamType = "monitoring"
356 if STREAM=="calibration":
357 bytestream_input.StreamType = "calibration"
358 if "LArPEBDigitalTrigger" in STREAM:
359 bytestream_input.StreamType = "calibration"
360 bytestream_input.StreamNames = ['LArPEBDigitalTrigger']
361 if "EMPTY" in STREAM:
362 bytestream_input.LVL1Names=["L1_RD0_EMPTY","L1_RD0_LAR_EMPTY","L1_RD0_FIRSTEMPTY"]
363 elif "FILLED" in STREAM:
364 bytestream_input.LVL1Names=["L1_RD0_FILLED"]
365 elif "PHYS" in STREAM:
366 bytestream_input.LVL1Names=["L1_jJ500_LAR","L1_LAR-ZEE-eEM"]
367 pass
368
369 print("DEBUG: bytestream_input.StreamNames:",bytestream_input.StreamNames)
370
371 else: # select any trigger, but from physics events only !
372 bytestream_input.StreamType = "physics"
373 bytestream_input.StreamLogic = "Or"
374 # not possible to ignore one stream, so creating a full list
375 bytestream_input.StreamNames = ["Main","CosmicCalo","L1Topo","L1Calo","Standby","ZeroBias","Background", "EnhancedBias", "MinBias", "LArCells", "LArCellsEmpty", "LArNoiseBurst", "BphysDelayed", "Late"]
376 # for HI:
377 #bytestream_input.StreamNames = ["HardProbes","UPC","UCC","PC","CC","CosmicCalo","L1Topo","L1Calo","Standby","ZeroBias","Background", "EnhancedBias", "MinBias", "LArCells", "LArCellsEmpty", "LArNoiseBurst", "BphysDelayed", "Late"]
378
379
380 # #################################################
381 # Shall athena exit if the partition is shutdown ?
382 # For offline athena tasks ONLY.
383 # Set this parameter to FALSE online.
384 # #################################################
385 bytestream_input.ExitOnPartitionShutdown = False
386
387 # #################################################
388 # From Sergei Kolos, Nov. 2009:
389 # Parameter default overwritten to drastically
390 # decrease the load on the network
391 # #################################################
392
393 bytestream_input.BufferSize = 10
394
395 # #################################################
396 # Private Application Configuration options, replace with
397 # your configuration.
398 # #################################################
399
400 event_selector = CompFactory.EventSelectorByteStream(
401 name='EventSelector',
402 ByteStreamInputSvc=bytestream_input.name,
403 FileBased=False)
404 acc.addService(event_selector)
405 acc.setAppProperty("EvtSel", event_selector.name)
406
407 event_persistency = CompFactory.EvtPersistencySvc(
408 name="EventPersistencySvc",
409 CnvServices=[bytestream_conversion.name])
410 acc.addService(event_persistency)
411
412 address_provider = CompFactory.ByteStreamAddressProviderSvc()
413 acc.addService(address_provider)
414
415 proxy = CompFactory.ProxyProviderSvc()
416 proxy.ProviderNames += [address_provider.name]
417 acc.addService(proxy)
418
419 acc.merge(SGInputLoaderCfg(flags, FailIfNoProxy=True))
420
421
422 from TriggerJobOpts.TriggerRecoConfig import TriggerRecoCfg
423 acc.merge(TriggerRecoCfg(flags))
424
425
426 l1bsdec = acc.getEventAlgo("L1TriggerByteStreamDecoder")
427 l1bsdec.ByteStreamMetadataRHKey=""
428 print("MaybeMissingROBs: ",l1bsdec.MaybeMissingROBs)
429 l1bsdec.MaybeMissingROBs += [0x770001, 0x7500ac, 0x7500ad, 0x7300a8, 0x7300a9, 0x7300aa, 0x7300ab]
430
431 if LATOME_FW == 6:
432 print("LATOME FW VERSION IS 6 - USING CUSTOM MAPPING")
433 #if isFW6:
434 # Temporary fix for FW6 mapping. These two lines must be removed when we are not running with fw6 print("ADDING FW6 MAPPING HACK")
435 from IOVDbSvc.IOVDbSvcConfig import addOverride
436 acc.merge(addOverride(flags,"/LAR/Identifier/LatomeMapping","LARIdentifierLatomeMapping-fw6"))
437
438 print('CONFIG ',CONFIG)
439 print('STREAM ',STREAM)
440
441 if "LArSCvsRawChannel" in CONFIG:
442 from LArMonitoring.RecoPT_Phase1NewConfig import LArSCvsRawChannelMonAlgCfg
443 acc.merge(LArSCvsRawChannelMonAlgCfg(flags,STREAM))
444
445 elif CONFIG!="LArDTMon":
446 from LArMonitoring.RecoPT_NewConfig import LArMonitoringConfig
447 acc.merge(LArMonitoringConfig(flags,CONFIG,STREAM,RunType))
448
449 else:
450 from LArMonitoring.RecoPT_Phase1NewConfig import LArDTMonitoringConfig
451 acc.merge(LArDTMonitoringConfig(flags,STREAM))
452
453
454 # fixes for splashes
455 if RunType == 0 and CONFIG!="LArDTMon":
456 acc.getEventAlgo("LArRawDataReadingAlg").LArRawChannelKey=""
457
458 # example for blocking the folder not filled during cosmics
459 cil=acc.getCondAlgo('CondInputLoader')
460 iovdbsvc=acc.getService('IOVDbSvc')
461 folder='/TRIGGER/LUMI/LBLB'
462 for i in range(0,len(iovdbsvc.Folders)):
463 if (iovdbsvc.Folders[i].find(folder)>=0):
464 del iovdbsvc.Folders[i]
465 break
466
467 remove_folder = False
468 for cil_Loadval in cil.Load:
469 if folder in cil_Loadval:
470 print(f"Removing {cil_Loadval} from cil/Load")
471 remove_folder = True
472 break
473 if remove_folder: cil.Load.remove(cil_Loadval)
474
475 if flags.DQ.enableLumiAccess:
476 lbd = acc.getCondAlgo('LBDurationCondAlg')
477 lbd.LBLBFolderInputKey=""
478 print('lbd ',lbd)
479
480 # somehow needs to add postprocessing
481 from DataQualityUtils.DQPostProcessingAlg import DQPostProcessingAlg
482 ppa = DQPostProcessingAlg("DQPostProcessingAlg")
483 ppa.ExtraInputs = {( 'xAOD::EventInfo' , 'StoreGateSvc+EventInfo' )}
484 ppa.Interval = 200
485 ppa.OutputLevel = WARNING
486 if flags.Common.isOnline:
487 ppa.FileKey = ((flags.DQ.FileKey + '/') if not flags.DQ.FileKey.endswith('/')
488 else flags.DQ.FileKey)
489
490 acc.addEventAlgo(ppa, sequenceName='AthEndSeq')
491
492 # example how to dump the store:
493 #acc.getService("StoreGateSvc").Dump=True
494 #acc.getService("StoreGateSvc").OutputLevel=DEBUG
495
496 acc.printConfig()
497 acc.run()
void print(char *figname, TCanvas *c1)
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138