ATLAS Offline Software
EventDisplaysOnlineConfig.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 
4 def EventDisplaysOnlineCfg(flags, **kwargs):
5  from EventDisplaysOnline.EventDisplaysOnlineHelpers import GetBFields, WaitForPartition, GetUniqueJobID, GetRunNumber, Ready4Physics
6 
7  from AthenaCommon.Logging import logging
8  mlog = logging.getLogger( 'EventDisplaysOnlineCfg' )
9 
10  if not flags.OnlineEventDisplays.OfflineTest:
11  from AthenaConfiguration.AutoConfigOnlineRecoFlags import autoConfigOnlineRecoFlags
12  autoConfigOnlineRecoFlags(flags, flags.OnlineEventDisplays.PartitionName)
13  flags.OnlineEventDisplays.Ready4PhysicsAtStart=Ready4Physics()
14 
15  # An explicit list for nominal data taking to exclude some high rate streams
16  # Empty list to read all
17  flags.OnlineEventDisplays.TriggerStreams = ['MinBias','express','ZeroBias','CosmicCalo','IDCosmic','CosmicMuons','Background','Standby','L1Calo','Main']
18  if flags.OnlineEventDisplays.BeamSplashMode:
19  flags.OnlineEventDisplays.TriggerStreams = ['MinBias'] #if trigger fails it will go to debug_HltError
20 
21  # If testing at p1, create dir /tmp/your_user_name and write out to /tmp/your_user_name to see output
22  flags.OnlineEventDisplays.OutputDirectory = "/atlas/EventDisplayEvents/"
23 
24  if flags.OnlineEventDisplays.OfflineTest:
25  flags.OnlineEventDisplays.OutputDirectory = "."
26 
27 
38  flags.OnlineEventDisplays.PartitionName='ATLAS' # 'ATLAS', 'GMTestPartition' or 'GMTestPartitionT9'
39 
40  if flags.OnlineEventDisplays.HIMode:
41  flags.OnlineEventDisplays.MaxEvents=200
42  flags.OnlineEventDisplays.ProjectTag='data25_hi'
43  flags.OnlineEventDisplays.PublicStreams=['HardProbes']
44  if flags.OnlineEventDisplays.HIPMode:
45  flags.OnlineEventDisplays.MaxEvents=200
46  flags.OnlineEventDisplays.ProjectTag='data25_hip'
47  flags.OnlineEventDisplays.PublicStreams=['Main']
48  if flags.OnlineEventDisplays.CosmicMode:
49  flags.OnlineEventDisplays.MaxEvents=200
50  flags.OnlineEventDisplays.ProjectTag='data25_cos'
51  flags.OnlineEventDisplays.PublicStreams=['']
52  if flags.OnlineEventDisplays.BeamSplashMode:
53  flags.OnlineEventDisplays.MaxEvents=-1 # keep all the events
54  flags.OnlineEventDisplays.ProjectTag='data25_comm'
55  flags.OnlineEventDisplays.PublicStreams=['']
56  else:
57  flags.OnlineEventDisplays.MaxEvents=50
58  flags.OnlineEventDisplays.ProjectTag='data25_13p6TeV'
59  flags.OnlineEventDisplays.PublicStreams=['Main']
60 
61  # Pause this thread until the partition is up
62  if not flags.OnlineEventDisplays.OfflineTest:
63  WaitForPartition(flags.OnlineEventDisplays.PartitionName)
64 
65  if not flags.OnlineEventDisplays.OfflineTest:
66  import os
67  IPC_timeout = int(os.environ['TDAQ_IPC_TIMEOUT'])
68  print(" IPC_timeout Envrionment Variable = %d" %IPC_timeout)
69 
70  # Conditions tag
71  if flags.OnlineEventDisplays.OfflineTest:
72  flags.IOVDb.GlobalTag = 'CONDBR2-BLKPA-2025-02'
73  else:
74  flags.IOVDb.GlobalTag = 'CONDBR2-HLTP-2025-01' # Online conditions tag
75 
76  # Geometry tag
77  flags.GeoModel.AtlasVersion = 'ATLAS-R3S-2021-03-02-00'
78 
79  flags.Trigger.triggerConfig='DB'
80 
81  jobId = GetUniqueJobID()
82 
83  # Test wth a small amount of events and write out to e.g. a tmp dir
84  if flags.OnlineEventDisplays.PartitionName != 'ATLAS' or flags.OnlineEventDisplays.OfflineTest:
85  flags.Exec.MaxEvents = 5
86  flags.Output.ESDFileName = flags.OnlineEventDisplays.OutputDirectory + "ESD-%s-%s.pool.root" % (jobId[3], jobId[4])
87  else:
88  flags.Exec.MaxEvents = 20000 # hack until we find a way to fix the memory fragmentation ATEAM-896, this resets the memory after 20k events
89  flags.Output.ESDFileName = "ESD-%s-%s.pool.root" % (jobId[3], jobId[4])
90 
91  if flags.OnlineEventDisplays.MakeVP1File:
92  flags.Output.doWriteESD = True
93  else:
94  flags.Output.doWriteESD = False
95 
96  flags.Output.doJiveXML = False # We call the AlgoJive later on
97 
98  if flags.OnlineEventDisplays.OfflineTest:
99  flags.Input.Files = ['/eos/home-m/myexley/sharedWithATLASauthors/data25_13p6TeV.00499912.physics_Main.daq.RAW._lb0600._SFO-11._0001.data']
100  else:
101  flags.Input.Files = [] # Files are read from the ATLAS (or GM test) partition
102 
103  flags.Reco.EnableTrigger = False # TODO test True
104  flags.Detector.GeometryForward = False
105  flags.Detector.EnableFwdRegion = False
106  flags.LAr.doHVCorr = False # ATLASRECTS-6823
107  flags.DQ.doMonitoring = False
108  flags.DQ.doPostProcessing = False
109  flags.Concurrency.NumThreads = 1
110 
111  if flags.OnlineEventDisplays.MakeVP1File:
112  flags.Concurrency.NumThreads = 0 # We cannot run multithread if we want one ESD file per event named with the event number etc. changing the name of the output ESD file when multithreading is not so simple...
113  if flags.OnlineEventDisplays.HIMode or flags.OnlineEventDisplays.HIPMode:
114  mlog.warning("You have said you want to create a vp1 file 'flags.OnlineEventDisplays.MakeVP1File=True' but you have also said you want to run reconstruction in an heavy ion mode, this will not work as heavy ion mode needs to run in multithreading mode, and in this mode we cannot write out one ESD file (i.e. vp1 file) per event.")
115 
116  if flags.OnlineEventDisplays.HIMode:
117  from AthenaConfiguration.Enums import HIMode
118  flags.Reco.HIMode = HIMode.HI
119  flags.Concurrency.NumThreads = 1
120  flags.OnlineEventDisplays.MakeVP1File = False
121  flags.Beam.BunchSpacing = 50
122 
123  if flags.OnlineEventDisplays.HIPMode:
124  from AthenaConfiguration.Enums import HIMode
125  flags.Reco.HIMode = HIMode.HIP
126  flags.Concurrency.NumThreads = 1
127  flags.OnlineEventDisplays.MakeVP1File = False
128 
129  if flags.OnlineEventDisplays.BeamSplashMode:
130  flags.Reco.EnableJet=False
131  flags.Reco.EnableMet=False
132  flags.Reco.EnableTau=False
133  flags.Reco.EnablePFlow=False
134  flags.Reco.EnableBTagging=False
135  flags.Reco.EnableEgamma=False
136  flags.Reco.EnableCombinedMuon=False
137 
138  from AthenaCommon.Constants import INFO
139  flags.Exec.OutputLevel = INFO
140 
141  flags.Common.isOnline = not flags.OnlineEventDisplays.OfflineTest
142 
143  if flags.OnlineEventDisplays.PartitionName == 'ATLAS' and not flags.OnlineEventDisplays.OfflineTest:
144  # For beam plashes when LAr running in a different samples mode, the current run number to LAr config is needed
145  run_number = GetRunNumber(flags.OnlineEventDisplays.PartitionName)
146  flags.Input.OverrideRunNumber = True
147  flags.Input.RunNumbers = [run_number]
148 
149  # Get the B field
150  (solenoidOn,toroidOn)=GetBFields()
151  flags.BField.solenoidOn = solenoidOn
152  flags.BField.barrelToroidOn = toroidOn
153  flags.BField.endcapToroidOn = toroidOn
154 
155  # GM test partition needs to be given the below info
156  if (flags.OnlineEventDisplays.PartitionName == 'GMTestPartition' or flags.OnlineEventDisplays.PartitionName == 'GMTestPartitionT9'):
157  flags.Input.RunNumbers = [482485] # keep this number the same as (or close to) the run number of the file you are testing on
158  flags.Input.LumiBlockNumbers = [111]
159 
160  from AthenaConfiguration.Enums import BeamType
161  if not flags.OnlineEventDisplays.OfflineTest:
162  if flags.OnlineEventDisplays.CosmicMode:
163  flags.Beam.Type = BeamType.Cosmics
164  else:
165  flags.Beam.Type = BeamType.Collisions
166  flags.lock()
167  flags.dump()
168 
170  from RecJobTransforms.RecoSteering import RecoSteering
171  cfg = RecoSteering(flags)
172 
173  from IOVDbSvc.IOVDbSvcConfig import addOverride
174  if not flags.OnlineEventDisplays.OfflineTest:
175  cfg.merge(addOverride(flags, "/TRT/Onl/Calib/PID_NN", "TRTCalibPID_NN_v2", db=""))
176 
177  # Get the input files from the partition
178  if not flags.OnlineEventDisplays.OfflineTest:
179  from EventDisplaysOnline.ByteStreamConfig import ByteStreamCfg
180  cfg.merge(ByteStreamCfg(flags, **kwargs))
181 
182  from EventDisplaysOnline.OnlineEventDisplaysSvcConfig import OnlineEventDisplaysSvcCfg
183  cfg.merge(OnlineEventDisplaysSvcCfg(flags, **kwargs))
184 
185  from JiveXML.OnlineStreamToFileConfig import OnlineStreamToFileCfg
186  streamToFileTool = cfg.popToolsAndMerge(OnlineStreamToFileCfg(flags, **kwargs))
187 
188  streamToServerTool = None
189  if not flags.OnlineEventDisplays.OfflineTest:
190  from JiveXML.OnlineStreamToServerConfig import OnlineStreamToServerCfg
191  streamToServerTool = cfg.popToolsAndMerge(OnlineStreamToServerCfg(flags, **kwargs))
192 
193  from JiveXML.JiveXMLConfig import AlgoJiveXMLCfg
194  cfg.merge(AlgoJiveXMLCfg(flags,
195  StreamToFileTool = streamToFileTool,
196  StreamToServerTool = streamToServerTool,
197  OnlineMode = not flags.OnlineEventDisplays.OfflineTest))
198 
199  if flags.OnlineEventDisplays.HIMode:
200  from EventDisplaysOnline.ContainerKeysCfg import getHIContainterKeys
202 
203  if flags.OnlineEventDisplays.HIPMode:
204  from EventDisplaysOnline.ContainerKeysCfg import getHIPContainterKeys
206 
207  if flags.OnlineEventDisplays.MakeVP1File:
208  # This gets the ESD output file which is renamed and moved to the desired output stream
209  # in the VP1 Event Prod alg, this creates one ESD file per event
210  from AthenaServices.OutputStreamSequencerSvcConfig import OutputStreamSequencerSvcCfg
211  cfg.merge(OutputStreamSequencerSvcCfg(flags,incidentName="EndEvent"))
212  from OutputStreamAthenaPool.OutputStreamConfig import outputStreamName
213  streamESD = cfg.getEventAlgo(outputStreamName("ESD"))
214  streamESD.OutputFile=flags.Output.ESDFileName
215 
216  from VP1AlgsEventProd.VP1AlgsEventProdConfig import VP1AlgsEventProdCfg
217  cfg.merge(VP1AlgsEventProdCfg(flags, streamESD, **kwargs))
218 
219  # switch of the NSW segment making as it takes too much CPU in beamsplashes
220  if flags.OnlineEventDisplays.BeamSplashMode:
221  cfg.getEventAlgo("MuonSegmentMaker").doStgcSegments=False
222  cfg.getEventAlgo("MuonSegmentMaker").doMMSegments=False
223  cfg.getEventAlgo("MuonSegmentMaker_NCB").doStgcSegments=False
224  cfg.getEventAlgo("MuonSegmentMaker_NCB").doMMSegments=False
225  cfg.dropEventAlgo("QuadNSW_MuonSegmentCnvAlg")
226 
227  if flags.OnlineEventDisplays.HorizontalMuonsMode:
228  from MuonConfig.MuonReconstructionConfig import MuonNCBTrackCfg
229  cfg.merge(MuonNCBTrackCfg(flags))
230 
231  cfg.getService("PoolSvc").WriteCatalog = "xmlcatalog_file:PoolFileCatalog_%s_%s.xml" % (jobId[3], jobId[4])
232 
233 
237  cfg.getService("PoolSvc").ReadCatalog += ["xmlcatalog_file:/det/dqm/GlobalMonitoring/PoolFileCatalog_M7/PoolFileCatalog.xml"]
238 
239  # Dump the pickle file
240  with open("OnlineEventDisplays.pkl", "wb") as f:
241  cfg.store(f)
242 
243  return cfg
244 
245 if __name__ == "__main__":
246  from AthenaConfiguration.AllConfigFlags import initConfigFlags
247  flags = initConfigFlags()
248 
249  flags.OnlineEventDisplays.HorizontalMuonsMode = False
250  flags.OnlineEventDisplays.MakeVP1File = True
251  flags.OnlineEventDisplays.CosmicMode = False
252  flags.OnlineEventDisplays.HIMode = False
253  flags.OnlineEventDisplays.HIPMode = False
254  flags.OnlineEventDisplays.BeamSplashMode = False
255  flags.OnlineEventDisplays.OfflineTest = False
256 
258  # Execute
259  sc = cfg.run()
260  import sys
261  sys.exit(0 if sc.isSuccess() else 1)
AthenaPoolExample_WriteCond.outputStreamName
string outputStreamName
Definition: AthenaPoolExample_WriteCond.py:21
python.RecoSteering.RecoSteering
def RecoSteering(flags)
Definition: RecoSteering.py:6
OnlineStreamToServerConfig.OnlineStreamToServerCfg
def OnlineStreamToServerCfg(flags, name='OnlineStreamToServerTool', **kwargs)
Definition: OnlineStreamToServerConfig.py:6
JiveXMLConfig.AlgoJiveXMLCfg
def AlgoJiveXMLCfg(flags, name="AlgoJiveXML", **kwargs)
Definition: JiveXMLConfig.py:18
MuonReconstructionConfig.MuonNCBTrackCfg
def MuonNCBTrackCfg(flags, cfg)
Definition: MuonReconstructionConfig.py:280
EventDisplaysOnlineHelpers.WaitForPartition
def WaitForPartition(partitionName=None)
Definition: EventDisplaysOnlineHelpers.py:46
VP1AlgsEventProdConfig.VP1AlgsEventProdCfg
def VP1AlgsEventProdCfg(flags, StreamESD, **kwargs)
Definition: VP1AlgsEventProdConfig.py:6
EventDisplaysOnlineConfig.EventDisplaysOnlineCfg
def EventDisplaysOnlineCfg(flags, **kwargs)
Definition: EventDisplaysOnlineConfig.py:4
EventDisplaysOnlineHelpers.GetUniqueJobID
def GetUniqueJobID()
Definition: EventDisplaysOnlineHelpers.py:93
Constants
some useful constants -------------------------------------------------—
python.AutoConfigOnlineRecoFlags.autoConfigOnlineRecoFlags
def autoConfigOnlineRecoFlags(flags, partition=None)
Definition: AutoConfigOnlineRecoFlags.py:134
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
ByteStreamConfig.ByteStreamCfg
def ByteStreamCfg(flags, **kwargs)
Definition: graphics/EventDisplaysOnline/python/ByteStreamConfig.py:5
python.IOVDbSvcConfig.addOverride
def addOverride(flags, folder, tag, tagType="tag", db=None)
Definition: IOVDbSvcConfig.py:238
ContainerKeysCfg.getHIPContainterKeys
def getHIPContainterKeys(cfg)
Definition: ContainerKeysCfg.py:15
Trk::open
@ open
Definition: BinningType.h:40
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
OnlineEventDisplaysSvcConfig.OnlineEventDisplaysSvcCfg
def OnlineEventDisplaysSvcCfg(flags, name="OnlineEventDisplaysSvc", **kwargs)
Definition: OnlineEventDisplaysSvcConfig.py:6
EventDisplaysOnlineHelpers.GetRunNumber
def GetRunNumber(partitionName)
Definition: EventDisplaysOnlineHelpers.py:103
EventDisplaysOnlineHelpers.GetBFields
def GetBFields()
Definition: EventDisplaysOnlineHelpers.py:7
python.OutputStreamSequencerSvcConfig.OutputStreamSequencerSvcCfg
def OutputStreamSequencerSvcCfg(flags, incidentName='', reportingOn=False, replaceRangeMode=False)
Definition: OutputStreamSequencerSvcConfig.py:6
EventDisplaysOnlineHelpers.Ready4Physics
def Ready4Physics()
Definition: EventDisplaysOnlineHelpers.py:60
ContainerKeysCfg.getHIContainterKeys
def getHIContainterKeys(cfg)
Definition: ContainerKeysCfg.py:4
OnlineStreamToFileConfig.OnlineStreamToFileCfg
def OnlineStreamToFileCfg(flags, name='OnlineStreamToFileTool', **kwargs)
Definition: OnlineStreamToFileConfig.py:7