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