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