ATLAS Offline Software
GlobalL1TopoSimulation.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 
4 from AthenaConfiguration.ComponentAccumulator import (ComponentAccumulator,)
5 from AthenaConfiguration.ComponentFactory import CompFactory
6 from libpyeformat_helper import SourceIdentifier, SubDetector
7 
8 from getAlgData import algdata_from_menu
9 from toolFromAlgData import toolFromAlgData
10 
11 from AthenaCommon.Logging import logging
12 logger = logging.getLogger(__name__)
13 from AthenaCommon.Constants import VERBOSE
14 logger.setLevel(VERBOSE)
15 
16 import sys, os
17 
18 def GlobalL1TopoSimulationCfg(flags, algLogLevel):
19 
20  acc = ComponentAccumulator()
21 
22  globalSimAlg = CompFactory.GlobalSim.GlobalL1TopoSimulation("GlobalSimTest")
23  globalSimAlg.OutputLevel = algLogLevel
24 
25  if 'GSDEBUG' in os.environ:
26  globalSimAlg.enableDumps = True
27 
28  # for now, only run a small sub graph corresponding to
29  # existing L1Topo Algorithms.
30  root_names = [
31  'SC111-CjJ40abpETA26',
32  '0DR03-eEM9ab-CjJ40ab',
33  'Mult_jXESPARE8', # cTauMultiplicity COUNT
34  'Mult_cTAU30M',
35  'Mult_cTAU35M',
36  'Mult_cTAUSPARE2',
37  ]
38 
39  alg_data_list = algdata_from_menu(flags, root_names=root_names, do_dot=True)
40  logger.info("number of alg_data " + str(len(alg_data_list)))
41 
42  [globalSimAlg.topo_algs.append(toolFromAlgData(flags, ad)) for
43  ad in alg_data_list]
44 
45  acc.addEventAlgo(globalSimAlg)
46 
47  histSvc = CompFactory.THistSvc(Output =["EXPERT DATAFILE='expert-monitoring.root', OPT='RECREATE'"])
48  acc.addService(histSvc)
49  return acc
50 
51 def add_subsystems(subsystems, acc, args):
52 
53  decoderTools = []
54  outputEDM = []
55  maybeMissingRobs = []
56 
57  from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig import RoIBResultByteStreamToolCfg
58  roibResultTool = acc.popToolsAndMerge(RoIBResultByteStreamToolCfg(flags, name="RoIBResultBSDecoderTool", writeBS=False))
59  decoderTools += [roibResultTool]
60 
61 
62  for module_id in roibResultTool.L1TopoModuleIds:
63  maybeMissingRobs.append(int(SourceIdentifier(SubDetector.TDAQ_CALO_TOPO_PROC, module_id)))
64 
65  for module_id in roibResultTool.JetModuleIds:
66  maybeMissingRobs.append(int(SourceIdentifier(SubDetector.TDAQ_CALO_JET_PROC_ROI, module_id)))
67 
68  for module_id in roibResultTool.EMModuleIds:
69  maybeMissingRobs.append(int(SourceIdentifier(SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI, module_id)))
70 
71 
72  def addEDM(edmType, edmName):
73  auxType = edmType.replace('Container','AuxContainer')
74  return [f'{edmType}#{edmName}', f'{auxType}#{edmName}Aux.']
75 
76  if 'jFex' in subsystems:
77  from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig import (
78  jFexRoiByteStreamToolCfg,jFexInputByteStreamToolCfg)
79 
80 
81  jFexTool = acc.popToolsAndMerge(jFexRoiByteStreamToolCfg(
82  flags, 'jFexBSDecoder', writeBS=False))
83 
84  decoderTools += [jFexTool]
85  outputEDM += addEDM('xAOD::jFexSRJetRoIContainer',
86  jFexTool.jJRoIContainerWriteKey.Path)
87 
88  outputEDM += addEDM('xAOD::jFexLRJetRoIContainer',
89  jFexTool.jLJRoIContainerWriteKey.Path)
90 
91  outputEDM += addEDM('xAOD::jFexTauRoIContainer' ,
92  jFexTool.jTauRoIContainerWriteKey.Path)
93 
94  outputEDM += addEDM('xAOD::jFexFwdElRoIContainer',
95  jFexTool.jEMRoIContainerWriteKey.Path)
96 
97  outputEDM += addEDM('xAOD::jFexSumETRoIContainer',
98  jFexTool.jTERoIContainerWriteKey.Path)
99  outputEDM += addEDM('xAOD::jFexMETRoIContainer' ,
100  jFexTool.jXERoIContainerWriteKey.Path)
101  maybeMissingRobs += jFexTool.ROBIDs
102 
103  if args.doCaloInput:
104 
105  jFexInputByteStreamTool = acc.popToolsAndMerge(
107  'jFexInputBSDecoderTool',
108  writeBS=False))
109 
110  decoderTools += [jFexInputByteStreamTool]
111  outputEDM += addEDM('xAOD::jFexTowerContainer',
112  jFexInputByteStreamTool.jTowersWriteKey.Path)
113  maybeMissingRobs += jFexInputByteStreamTool.ROBIDs
114 
115  if 'eFex' in subsystems:
116  from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig import (
117  eFexByteStreamToolCfg,)
118 
119  eFexTool = acc.popToolsAndMerge(
120  eFexByteStreamToolCfg(flags,
121  'eFexBSDecoder',
122  writeBS=False,
123  decodeInputs=args.doCaloInput))
124 
125  decoderTools += [eFexTool]
126  outputEDM += addEDM('xAOD::eFexEMRoIContainer',
127  eFexTool.eEMContainerWriteKey.Path)
128  outputEDM += addEDM('xAOD::eFexTauRoIContainer',
129  eFexTool.eTAUContainerWriteKey.Path)
130 
131  if args.doCaloInput:
132  outputEDM += addEDM('xAOD::eFexTowerContainer',
133  eFexTool.eTowerContainerWriteKey.Path)
134 
135  maybeMissingRobs += eFexTool.ROBIDs
136 
137  if 'gFex' in subsystems:
138  from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig import (
139  gFexByteStreamToolCfg,gFexInputByteStreamToolCfg,)
140 
141  gFexTool = acc.popToolsAndMerge(gFexByteStreamToolCfg(
142  flags, 'gFexBSDecoder', writeBS=False))
143 
144  decoderTools += [gFexTool]
145  outputEDM += addEDM(
146  'xAOD::gFexJetRoIContainer',
147  gFexTool.gFexRhoOutputContainerWriteKey.Path)
148 
149  outputEDM += addEDM(
150  'xAOD::gFexJetRoIContainer',
151  gFexTool.gFexSRJetOutputContainerWriteKey.Path)
152 
153  outputEDM += addEDM(
154  'xAOD::gFexJetRoIContainer',
155  gFexTool.gFexLRJetOutputContainerWriteKey.Path)
156 
157  outputEDM += addEDM(
158  'xAOD::gFexGlobalRoIContainer',
159  gFexTool.gScalarEJwojOutputContainerWriteKey.Path)
160 
161  outputEDM += addEDM(
162  'xAOD::gFexGlobalRoIContainer',
163  gFexTool.gMETComponentsJwojOutputContainerWriteKey.Path)
164 
165  outputEDM += addEDM(
166  'xAOD::gFexGlobalRoIContainer',
167  gFexTool.gMHTComponentsJwojOutputContainerWriteKey.Path)
168 
169  outputEDM += addEDM(
170  'xAOD::gFexGlobalRoIContainer',
171  gFexTool.gMSTComponentsJwojOutputContainerWriteKey.Path)
172 
173  outputEDM += addEDM(
174  'xAOD::gFexGlobalRoIContainer',
175  gFexTool.gMETComponentsNoiseCutOutputContainerWriteKey.Path)
176 
177  outputEDM += addEDM(
178  'xAOD::gFexGlobalRoIContainer',
179  gFexTool.gMETComponentsRmsOutputContainerWriteKey.Path)
180 
181  outputEDM += addEDM(
182  'xAOD::gFexGlobalRoIContainer',
183  gFexTool.gScalarENoiseCutOutputContainerWriteKey.Path)
184 
185  outputEDM += addEDM(
186  'xAOD::gFexGlobalRoIContainer',
187  gFexTool.gScalarERmsOutputContainerWriteKey.Path)
188 
189  maybeMissingRobs += gFexTool.ROBIDs
190 
191  if args.doCaloInput:
192  gFexInputByteStreamTool = acc.popToolsAndMerge(
194  flags, 'gFexInputByteStreamTool', writeBS=False))
195 
196  decoderTools += [gFexInputByteStreamTool]
197  outputEDM += addEDM('xAOD::gFexTowerContainer',
198  gFexInputByteStreamTool.gTowersWriteKey.Path)
199 
200  maybeMissingRobs += gFexInputByteStreamTool.ROBIDs
201 
202  decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(
203  name="L1TriggerByteStreamDecoder",
204  DecoderTools=decoderTools,
205  MaybeMissingROBs=maybeMissingRobs,
206  OutputLevel=algLogLevel)
207 
208  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
209  log.debug('Adding the following output EDM to ItemList: %s', outputEDM)
210 
211  acc.addEventAlgo(decoderAlg, sequenceName='AthAlgSeq')
212 
213  acc.merge(OutputStreamCfg(flags, 'AOD', ItemList=outputEDM))
214 
215 
216 if __name__ == '__main__':
217  from AthenaConfiguration.AllConfigFlags import initConfigFlags
218  from AthenaCommon.Logging import logging
219 
220  from AthenaCommon.Constants import DEBUG
221 
222  log = logging.getLogger('globalSim')
223  log.setLevel(DEBUG)
224  algLogLevel = DEBUG
225 
226  import argparse
227  from argparse import RawTextHelpFormatter
228 
229  parser = argparse.ArgumentParser(
230  "Running L1TopoSimulation standalone for the BS input",
231  formatter_class=RawTextHelpFormatter)
232 
233  parser.add_argument(
234  "-i",
235  "--inputs",
236  nargs='*',
237  action="store",
238  dest="inputFiles",
239  help="files to process",
240  required=True)
241 
242 
243  parser.add_argument(
244  "-ifex",
245  "--doCaloInput",
246  action="store_true",
247  dest="doCaloInput",
248  help="Decoding L1Calo inputs",
249  default=False,
250  required=False)
251 
252  parser.add_argument(
253  "-n",
254  "--nevent",
255  type=int,
256  action="store",
257  dest="nevent",
258  help="Maximum number of events will be executed.",
259  default=0,
260  required=False)
261 
262  parser.add_argument(
263  "-s",
264  "--skipEvents",
265  type=int,
266  action="store",
267  dest="skipEvents",
268  help="Number of events to skip.",
269  default=0,
270  required=False)
271 
272  args = parser.parse_args()
273 
274  logger.debug('args:')
275 
276  logger.debug(args)
277 
278  flags = initConfigFlags()
279 
280  if(args.nevent > 0):
281  flags.Exec.MaxEvents = args.nevent
282 
283  if args.inputFiles:
284  flags.Input.Files = args.inputFiles
285  else:
286  flags.Input.Files = ['/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/CampaignInputs/data23/RAW/data23_13p6TeV.00452463.physics_Main.daq.RAW/540events.data23_13p6TeV.00452463.physics_Main.daq.RAW._lb0514._SFO-16._0004.data']
287 
288 
289  flags.Concurrency.NumThreads = 1
290  flags.Concurrency.NumConcurrentEvents = 1
291  flags.Exec.SkipEvents = args.skipEvents
292 
293  flags.Output.AODFileName = 'AOD.pool.root'
294  flags.Trigger.triggerMenuSetup = 'PhysicsP1_pp_run3_v1'
295 
296  flags.GeoModel.AtlasVersion="ATLAS-R3S-2021-03-01-00"
297 
298 
299 
300  print (flags.dump())
301 
302  flags.lock()
303 
304  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
305  acc = MainServicesCfg(flags)
306 
307  from TriggerJobOpts.TriggerByteStreamConfig import ByteStreamReadCfg
308  acc.merge(ByteStreamReadCfg(flags, type_names=['CTP_RDO/CTP_RDO']))
309 
310  # Generate run3 L1 menu
311  from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg, generateL1Menu
312  acc.merge(L1ConfigSvcCfg(flags))
313  generateL1Menu(flags)
314 
315  subsystems = ('jFex', 'eFex')
316  add_subsystems(subsystems, acc, args)
317 
318  acc.merge(GlobalL1TopoSimulationCfg(flags, algLogLevel))
319 
320 
321  roib2topo = CompFactory.LVL1.RoiB2TopoInputDataCnv(
322  name='RoiB2TopoInputDataCnv')
323 
324  roib2topo.OutputLevel = algLogLevel
325  acc.addEventAlgo(roib2topo, sequenceName="AthAlgSeq")
326 
327  from L1TopoByteStream.L1TopoByteStreamConfig import L1TopoByteStreamCfg
328  acc.merge(L1TopoByteStreamCfg(flags), sequenceName='AthAlgSeq')
329 
330  if acc.run().isFailure():
331  sys.exit(1)
332 
333 
L1TopoByteStreamConfig.L1TopoByteStreamCfg
def L1TopoByteStreamCfg(flags)
Definition: L1TopoByteStreamConfig.py:40
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.TrigConfigSvcCfg.generateL1Menu
def generateL1Menu(flags)
Definition: TrigConfigSvcCfg.py:184
GlobalL1TopoSimulation.GlobalL1TopoSimulationCfg
def GlobalL1TopoSimulationCfg(flags, algLogLevel)
Definition: GlobalL1TopoSimulation.py:18
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
L1CaloFEXByteStreamConfig.jFexInputByteStreamToolCfg
def jFexInputByteStreamToolCfg(flags, name, *writeBS=False)
Definition: L1CaloFEXByteStreamConfig.py:232
GlobalL1TopoSimulation.add_subsystems
def add_subsystems(subsystems, acc, args)
Definition: GlobalL1TopoSimulation.py:51
TrigT1ResultByteStreamConfig.RoIBResultByteStreamToolCfg
def RoIBResultByteStreamToolCfg(flags, name, writeBS=False)
Definition: TrigT1ResultByteStreamConfig.py:19
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
L1CaloFEXByteStreamConfig.gFexByteStreamToolCfg
def gFexByteStreamToolCfg(flags, name, *writeBS=False)
Definition: L1CaloFEXByteStreamConfig.py:148
getAlgData.algdata_from_menu
def algdata_from_menu(flags, do_dot=False, root_names=[])
Definition: getAlgData.py:12
Constants
some useful constants -------------------------------------------------—
L1CaloFEXByteStreamConfig.gFexInputByteStreamToolCfg
def gFexInputByteStreamToolCfg(flags, name, *writeBS=False)
Definition: L1CaloFEXByteStreamConfig.py:275
python.TrigConfigSvcCfg.L1ConfigSvcCfg
def L1ConfigSvcCfg(flags)
Definition: TrigConfigSvcCfg.py:198
FexEmulatedTowersConfig.addEDM
def addEDM(edmType, edmName)
Definition: FexEmulatedTowersConfig.py:107
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
L1CaloFEXByteStreamConfig.jFexRoiByteStreamToolCfg
def jFexRoiByteStreamToolCfg(flags, name, *writeBS=False, xTOBs=False)
Definition: L1CaloFEXByteStreamConfig.py:87
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
str
Definition: BTagTrackIpAccessor.cxx:11
L1CaloFEXByteStreamConfig.eFexByteStreamToolCfg
def eFexByteStreamToolCfg(flags, name, *writeBS=False, TOBs=True, xTOBs=False, multiSlice=False, decodeInputs=False)
Definition: L1CaloFEXByteStreamConfig.py:8
toolFromAlgData
Definition: toolFromAlgData.py:1