ATLAS Offline Software
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 
6 if __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 
192  def __monflags():
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  flags.lock()
207 
208  flags.dump()
209 
210  # taken from future EmonByteStreamConfig
211  from AthenaConfiguration.ComponentFactory import CompFactory
212 
213  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
214  acc = MainServicesCfg(flags)
215 
216  bytestream_conversion = CompFactory.ByteStreamCnvSvc()
217  acc.addService(bytestream_conversion, primary=True)
218 
219  from ByteStreamEmonSvc.EmonByteStreamConfig import EmonByteStreamCfg
220  acc.merge(EmonByteStreamCfg(flags))
221 
222  bytestream_input = acc.getService("ByteStreamInputSvc")
223 
224  # ############################################################
225  # The name of the partition you want to connect to is taken
226  # from 'TDAQ_PARTITION' if it exists, otherwise from here.
227  # ############################################################
228 
229  bytestream_input.Partition = partition
230 
231  # #########################################
232  # The source of events, dcm for full events.
233  # #########################################
234 
235  if partition == "ATLAS" or partition[:3] == "LAr":
236  bytestream_input.Key = "dcm"
237  else:
238  bytestream_input.Key = "CompleteEvent"
239 
240  bytestream_input.KeyCount = 15
241  bytestream_input.KeyCount = 150
242  bytestream_input.UpdatePeriod = 60
243  #
244  # #######################################
245  # Set this to the IS server where you want
246  # to publish histograms, too. If unset, no histograms
247  # are published.
248  # #######################################
249 
250  bytestream_input.ISServer = 'LArHistogramming'
251 
252  # ########################################
253  # The provider name under which your histograms
254  # appear in OH.
255  # ########################################
256 
257  if STREAM!='NONE':
258  bytestream_input.PublishName = '%s-Test-%s'%(CONFIG,STREAM)
259  else:
260  bytestream_input.PublishName = '%s-Test-%s'%(CONFIG,"NoTrigSel")
261 
262  # ###################################################
263  # Should histograms be cleared at new run ? default: yes
264  # Moved to False 27th Jan 2010 - Reset for each event in HLT 15.5.5
265  # ###################################################
266 
267  bytestream_input.ClearHistograms = True
268 
269  # #########################
270  # To get all Beam Splashes this needs uncomment
271  # #########################
272 
273  #bytestream_input.Dispersion=False
274 
275  # ###############################################
276  # Frequency of updates (in number of events, not secs...)
277  # ###############################################
278 
279  #bytestream_input.Frequency = 5
280 
281  # #######################################################
282  # TimeOut (in milliseconds) - Prevent job with low rates
283  # to reconnect too often to SFIs
284  # ######################################################
285 
286  bytestream_input.Timeout = 3600000
287 
288  # ###################################################
289  # Stream/trigger Selection
290  # --> For LAr partitions, no stream available
291  # --> For ATLAS, can create streams from L1 items
292  # ##################################################
293 
294  if bytestream_input.Partition[:3] == "LAr":
295  bytestream_input.StreamType = ""
296  else:
297  bytestream_input.LVL1Logic = "Or"
298  bytestream_input.LVL1Origin = "TAV"
299  bytestream_input.StreamType = "physics"
300  bytestream_input.StreamLogic = "And"
301  if STREAM!="NONE":
302  if STREAM=="LArCellsEmpty":
303  bytestream_input.StreamType = "calibration"
304  bytestream_input.StreamNames = ['LArCellsEmpty']
305  if STREAM=="Main":
306  bytestream_input.StreamNames = ['Main']
307  if STREAM=="CosmicCalo":
308  bytestream_input.StreamNames = ['CosmicCalo']
309  if STREAM=="L1Topo":
310  bytestream_input.StreamNames = ['L1Topo']
311  if STREAM=="L1Calo":
312  bytestream_input.StreamNames = ['L1Calo']
313  if STREAM=="express":
314  bytestream_input.StreamNames = ['express']
315  bytestream_input.StreamType = "express"
316  if STREAM=="LArNoiseBurst":
317  bytestream_input.StreamType = "calibration"
318  bytestream_input.StreamNames = ['LArNoiseBurst']
319  if STREAM=="Standby":
320  bytestream_input.StreamNames = ['Standby']
321  if STREAM=="ZeroBias":
322  bytestream_input.StreamNames = ['ZeroBias']
323  if STREAM=="MinBias":
324  bytestream_input.StreamNames = ['MinBias']
325  if STREAM=="Background":
326  bytestream_input.StreamNames = ['Background']
327  if STREAM=="05_Jets":
328  bytestream_input.StreamType = "calibration"
329  bytestream_input.StreamNames = ['DataScouting_05_Jets']
330  if STREAM=="random":
331  bytestream_input.StreamNames = ['monitoring_random']
332  bytestream_input.StreamType = "monitoring"
333  if STREAM=="calibration":
334  bytestream_input.StreamType = "calibration"
335 
336 
337  print("DEBUG: bytestream_input.StreamNames:",bytestream_input.StreamNames)
338 
339  else: # select any trigger, but from physics events only !
340  bytestream_input.StreamType = "physics"
341  bytestream_input.StreamLogic = "Or"
342  # not possible to ignore one stream, so creating a full list
343  bytestream_input.StreamNames = ["Main","CosmicCalo","L1Topo","L1Calo","Standby","ZeroBias","Background", "EnhancedBias", "MinBias", "LArCells", "LArCellsEmpty", "LArNoiseBurst", "BphysDelayed", "Late"]
344 
345 
346  # #################################################
347  # Shall athena exit if the partition is shutdown ?
348  # For offline athena tasks ONLY.
349  # Set this parameter to FALSE online.
350  # #################################################
351  bytestream_input.ExitOnPartitionShutdown = False
352 
353  # #################################################
354  # From Sergei Kolos, Nov. 2009:
355  # Parameter default overwritten to drastically
356  # decrease the load on the network
357  # #################################################
358 
359  bytestream_input.BufferSize = 10
360 
361  # #################################################
362  # Private Application Configuration options, replace with
363  # your configuration.
364  # #################################################
365 
366  #acc.addService(bytestream_input)
367 
368  event_selector = CompFactory.EventSelectorByteStream(
369  name='EventSelector',
370  ByteStreamInputSvc=bytestream_input.name,
371  FileBased=False)
372  acc.addService(event_selector)
373  acc.setAppProperty("EvtSel", event_selector.name)
374 
375  event_persistency = CompFactory.EvtPersistencySvc(
376  name="EventPersistencySvc",
377  CnvServices=[bytestream_conversion.name])
378  acc.addService(event_persistency)
379 
380  address_provider = CompFactory.ByteStreamAddressProviderSvc()
381  acc.addService(address_provider)
382 
383  proxy = CompFactory.ProxyProviderSvc()
384  proxy.ProviderNames += [address_provider.name]
385  acc.addService(proxy)
386 
387  from TriggerJobOpts.TriggerRecoConfig import TriggerRecoCfg
388  acc.merge(TriggerRecoCfg(flags))
389 
390 
391  l1bsdec = acc.getEventAlgo("L1TriggerByteStreamDecoder")
392  l1bsdec.ByteStreamMetadataRHKey=""
393  print("MaybeMissingROBs: ",l1bsdec.MaybeMissingROBs)
394  l1bsdec.MaybeMissingROBs += [0x770001, 0x7500ac, 0x7500ad, 0x7300a8, 0x7300a9, 0x7300aa, 0x7300ab]
395 
396  from LArMonitoring.RecoPT_NewConfig import LArMonitoringConfig
397  print('CONFIG ',CONFIG)
398  print('STREAM ',STREAM)
399 
400  # testing Denis stuff
401  from LArMonitoring.LArSuperCellMonAlg import LArSuperCellMonConfig
402  acc.merge(LArSuperCellMonConfig(flags))
403 
404  # fixes for splashes
405  if RunType == 0:
406  acc.getEventAlgo("LArRawDataReadingAlg").LArRawChannelKey=""
407 
408  #example for blocking the folder not filled during cosmics
409  #cil=acc.getCondAlgo('CondInputLoader')
410  #iovdbsvc=acc.getService('IOVDbSvc')
411  #folder='/TRIGGER/LUMI/LBLB'
412  #for i in range(0,len(iovdbsvc.Folders)):
413  # if (iovdbsvc.Folders[i].find(folder)>=0):
414  # del iovdbsvc.Folders[i]
415  # break
416  #for i in range(0, len(cil.Load)):
417  # if (cil.Load[i][-1] == folder):
418  # del cil.Load[i]
419  # break
420 
421  # somehow needs to add postprocessing
422  from AthenaCommon.Constants import WARNING
423  from DataQualityUtils.DQPostProcessingAlg import DQPostProcessingAlg
424  ppa = DQPostProcessingAlg("DQPostProcessingAlg")
425  ppa.ExtraInputs = {( 'xAOD::EventInfo' , 'StoreGateSvc+EventInfo' )}
426  ppa.Interval = 200
427  ppa.OutputLevel = WARNING
428  if flags.Common.isOnline:
429  ppa.FileKey = ((flags.DQ.FileKey + '/') if not flags.DQ.FileKey.endswith('/')
430  else flags.DQ.FileKey)
431 
432  acc.addEventAlgo(ppa, sequenceName='AthEndSeq')
433 
434  # example how to dump the store:
435  #acc.getService("StoreGateSvc").Dump=True
436  #acc.getService("StoreGateSvc").OutputLevel=DEBUG
437  #acc.getService("MessageSvc").OutputLevel=DEBUG
438 
439  acc.run()
EmonByteStreamConfig.EmonByteStreamCfg
def EmonByteStreamCfg(flags, type_names=[])
Definition: EmonByteStreamConfig.py:12
LArSuperCellMonAlg.LArSuperCellMonConfig
def LArSuperCellMonConfig(flags, **kwargs)
Definition: LArSuperCellMonAlg.py:5
LArMonConfigFlags.createLArMonConfigFlags
def createLArMonConfigFlags()
Definition: LArMonConfigFlags.py:19
StateLessPT_Test_NewConfig.__monflags
def __monflags()
Definition: StateLessPT_Test_NewConfig.py:192
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
python.DQConfigFlags.allSteeringFlagsOff
def allSteeringFlagsOff(flags)
Definition: DQConfigFlags.py:128
python.AutoConfigOnlineRecoFlags.autoConfigOnlineRecoFlags
def autoConfigOnlineRecoFlags(flags, partition=None)
Definition: AutoConfigOnlineRecoFlags.py:134
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:289
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.TriggerRecoConfig.TriggerRecoCfg
def TriggerRecoCfg(flags)
Definition: TriggerRecoConfig.py:17
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70