151def L1TriggerByteStreamDecoderCfg(flags, returnEDM=False):
152 acc = ComponentAccumulator()
153 decoderTools = []
154 maybeMissingRobs = []
155
156
159 if not flags.Trigger.doLVL1:
160 if doRoIBResult(flags):
161 roibResultTool = acc.popToolsAndMerge(RoIBResultByteStreamToolCfg(
162 flags, name="RoIBResultBSDecoderTool", writeBS=False))
163 decoderTools += [roibResultTool]
164
165 for module_id in roibResultTool.L1TopoModuleIds:
166 maybeMissingRobs.append(int(SourceIdentifier(SubDetector.TDAQ_CALO_TOPO_PROC, module_id)))
167 if flags.Trigger.EDMVersion == 2 and not flags.Trigger.doHLT:
168
169 for module_id in roibResultTool.JetModuleIds:
170 maybeMissingRobs.append(int(SourceIdentifier(SubDetector.TDAQ_CALO_JET_PROC_ROI, module_id)))
171 for module_id in roibResultTool.EMModuleIds:
172 maybeMissingRobs.append(int(SourceIdentifier(SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI, module_id)))
173
174
175
176
177 if not flags.Trigger.doLVL1 and flags.Trigger.CTP.UseEDMxAOD:
178 ctpResultTool = acc.popToolsAndMerge(CTPResultByteStreamToolCfg(
179 flags, name="CTPResultBSDecoderTool", writeBS=False))
180 decoderTools += [ctpResultTool]
181
182
185 if flags.Trigger.L1.doMuon and flags.Trigger.enableL1MuonPhase1 and flags.Trigger.doHLT :
186 muonRoiTool = acc.popToolsAndMerge(MuonRoIByteStreamToolCfg(
187 flags, name="L1MuonBSDecoderTool", writeBS=False))
188 decoderTools += [muonRoiTool]
189
190
193 if flags.Trigger.L1.doCalo and flags.Trigger.enableL1CaloPhase1:
194
195
196
197 if flags.Trigger.L1.doeFex:
198
199 if flags.Trigger.doHLT:
200 eFexByteStreamTool = acc.popToolsAndMerge(eFexByteStreamToolCfg(
201 flags,
202 'eFexBSDecoderTool',
203 writeBS=False,
204 TOBs=True,
205 xTOBs=False,
206 multiSlice=False
207 ))
208
209 else:
210 eFexByteStreamTool = acc.popToolsAndMerge(eFexByteStreamToolCfg(
211 flags,
212 'eFexBSDecoderTool',
213 writeBS=False,
214 TOBs=False,
215 xTOBs=True,
216 multiSlice=True,
217 decodeInputs=flags.Trigger.L1.doCaloInputs
218 ))
219 decoderTools += [eFexByteStreamTool]
220
221
222 if not flags.Trigger.doHLT:
223 maybeMissingRobs += eFexByteStreamTool.ROBIDs
224
225
226
227
228 if flags.Trigger.L1.dojFex:
229
230 if flags.Trigger.doHLT:
231 jFexRoiByteStreamTool = acc.popToolsAndMerge(jFexRoiByteStreamToolCfg(
232 flags,
233 'jFexBSDecoderTool',
234 writeBS=False
235 ))
236
237 else:
238 jFexRoiByteStreamTool = acc.popToolsAndMerge(jFexRoiByteStreamToolCfg(
239 flags,
240 'jFexBSDecoderTool',
241 writeBS=False,
242 xTOBs=True
243 ))
244 decoderTools += [jFexRoiByteStreamTool]
245 maybeMissingRobs += jFexRoiByteStreamTool.ROBIDs
246
247
248 if flags.Trigger.L1.doCaloInputs:
249 jFexInputByteStreamTool = acc.popToolsAndMerge(jFexInputByteStreamToolCfg(
250 flags,
251 'jFexInputBSDecoderTool',
252 writeBS=False
253 ))
254 decoderTools += [jFexInputByteStreamTool]
255 maybeMissingRobs += jFexInputByteStreamTool.ROBIDs
256
257
258
259
260
261 if flags.Trigger.L1.dogFex:
262
263 if flags.Trigger.doHLT:
264 gFexByteStreamTool = acc.popToolsAndMerge(gFexByteStreamToolCfg(
265 flags,
266 'gFexBSDecoderTool',
267 writeBS=False
268 ))
269 decoderTools += [gFexByteStreamTool]
270 maybeMissingRobs += gFexByteStreamTool.ROBIDs
271
272
273 if flags.Trigger.L1.doCaloInputs:
274 gFexInputByteStreamTool = acc.popToolsAndMerge(gFexInputByteStreamToolCfg(
275 flags,
276 'gFexInputBSDecoderTool',
277 writeBS=False
278 ))
279 decoderTools += [gFexInputByteStreamTool]
280 maybeMissingRobs += gFexInputByteStreamTool.ROBIDs
281
282
285 if flags.Trigger.L1.doTopo and flags.Trigger.enableL1CaloPhase1 and flags.Trigger.L1.doTopoPhase1:
286 topoByteStreamTool = acc.popToolsAndMerge(L1TopoPhase1ByteStreamToolCfg(
287 flags,
288 "L1TopoBSDecoderTool",
289 writeBS=False
290 ))
291 decoderTools += [topoByteStreamTool]
292 maybeMissingRobs += topoByteStreamTool.ROBIDs
293
294 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name="L1TriggerByteStreamDecoder",
295 DecoderTools=decoderTools,
296 MaybeMissingROBs=list(
set(maybeMissingRobs)))
297
298 if flags.Trigger.doHLT or flags.DQ.Steering.doHLTMon:
299 from TrigT1ResultByteStream.TrigT1ResultByteStreamMonitoringConfig import L1TriggerByteStreamDecoderMonitoringCfg
300 decoderAlg.MonTool = acc.popToolsAndMerge(L1TriggerByteStreamDecoderMonitoringCfg(flags, decoderAlg.getName(), decoderTools))
301
302 acc.addEventAlgo(decoderAlg, primary=True)
303
304
305 from TriggerJobOpts.TriggerByteStreamConfig import ByteStreamReadCfg
306 readBSAcc = ByteStreamReadCfg(flags)
307 readBSAcc.getEventAlgo('SGInputLoader').Load.add(
308 ('ByteStreamMetadataContainer', 'InputMetaDataStore+ByteStreamMetadata'))
309 acc.merge(readBSAcc)
310
311
312 if not flags.Trigger.doHLT:
313 from OutputStreamAthenaPool.OutputStreamConfig import addToESD, addToAOD
314 outputEDM = getEDMListFromWriteHandles([tool for tool in decoderAlg.DecoderTools if ('RoIBResult' not in tool.getName() and 'CTPResult' not in tool.getName())])
315 _log.info('Adding the following output EDM to ItemList: %s', outputEDM)
316 acc.merge(addToESD(flags, outputEDM))
317 acc.merge(addToAOD(flags, outputEDM))
318
319
320
321
322 if returnEDM:
323 return acc, outputEDM
324 return acc
325