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