4 from AthenaCommon.Logging
import logging
5 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory
import CompFactory
7 from TrigEDMConfig.TriggerEDM
import recordable
8 from TrigEDMConfig.Utils
import getEDMListFromWriteHandles
9 from libpyeformat_helper
import SourceIdentifier, SubDetector
11 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import eFexByteStreamToolCfg, jFexRoiByteStreamToolCfg, jFexInputByteStreamToolCfg, gFexByteStreamToolCfg, gFexInputByteStreamToolCfg
12 from L1TopoByteStream.L1TopoByteStreamConfig
import L1TopoPhase1ByteStreamToolCfg
13 from TrigT1MuonRecRoiTool.TrigT1MuonRecRoiToolConfig
import RPCRecRoiToolCfg, TGCRecRoiToolCfg
14 from TrigT1MuctpiPhase1.TrigT1MuctpiPhase1Config
import TrigThresholdDecisionToolCfg
16 _log = logging.getLogger(
'TrigT1ResultByteStreamConfig')
20 tool = CompFactory.RoIBResultByteStreamTool(name)
22 if not flags.Trigger.L1.doCTP:
24 tool.CTPModuleId = 0xFF
26 if flags.Trigger.enableL1MuonPhase1
or not flags.Trigger.L1.doMuon:
28 tool.MUCTPIModuleId = 0xFF
30 if not flags.Trigger.enableL1CaloLegacy
or not flags.Trigger.L1.doCalo:
32 tool.JetModuleIds = []
35 if flags.Trigger.EDMVersion == 1
or not flags.Trigger.L1.doTopo:
37 tool.L1TopoModuleIds = []
41 tool.RoIBResultReadKey=
"RoIBResult"
42 tool.RoIBResultWriteKey=
""
45 tool.RoIBResultReadKey=
""
46 tool.RoIBResultWriteKey=
"RoIBResult"
48 acc.setPrivateTools(tool)
53 tool = CompFactory.ExampleL1TriggerByteStreamTool(name)
55 muctpi_robid =
int(SourceIdentifier(SubDetector.TDAQ_MUON_CTP_INTERFACE, muctpi_moduleid))
56 tool.ROBIDs = [muctpi_robid]
59 tool.MuonRoIContainerReadKey=
"LVL1MuonRoIs"
60 tool.MuonRoIContainerWriteKey=
""
61 tool.L1TopoOutputLocID=
""
64 tool.MuonRoIContainerReadKey=
""
65 tool.MuonRoIContainerWriteKey=
recordable(
"LVL1MuonRoIs")
66 acc.setPrivateTools(tool)
71 tool = CompFactory.MuonRoIByteStreamTool(name)
73 muctpi_robid =
int(SourceIdentifier(SubDetector.TDAQ_MUON_CTP_INTERFACE, muctpi_moduleid))
74 tool.ROBIDs = [muctpi_robid]
75 tool.DoTopo = flags.Trigger.L1.doMuonTopoInputs
77 from TrigT1ResultByteStream.TrigT1ResultByteStreamMonitoringConfig
import L1MuonBSConverterMonitoringCfg
81 containerBaseName =
"LVL1MuonRoIs"
83 containerBaseName +
"BCm2",
84 containerBaseName +
"BCm1",
86 containerBaseName +
"BCp1",
87 containerBaseName +
"BCp2",
89 topocontainerBaseName =
"L1MuCTPItoL1TopoLocationFromMuonRoI"
90 topocontainerNames = [
91 topocontainerBaseName +
"-2",
92 topocontainerBaseName +
"-1",
93 topocontainerBaseName,
94 topocontainerBaseName +
"1",
95 topocontainerBaseName +
"2",
99 tool.MuonRoIContainerReadKeys += containerNames
102 tool.MuonRoIContainerWriteKeys += [
recordable(c)
for c
in containerNames]
103 tool.L1TopoOutputLocID += topocontainerNames
109 acc.setPrivateTools(tool)
114 Helper function returning a logic combination of flags deciding
115 whether the RoIBResult decoding/encoding is required in the job
117 if flags.Trigger.L1.doCalo
and flags.Trigger.enableL1CaloLegacy:
120 if flags.Trigger.L1.doMuon
and not flags.Trigger.enableL1MuonPhase1:
123 if flags.Trigger.L1.doTopo:
126 if flags.Trigger.L1.doCTP:
135 maybeMissingRobs = []
140 if not flags.Trigger.doLVL1:
143 flags, name=
"RoIBResultBSDecoderTool", writeBS=
False))
144 decoderTools += [roibResultTool]
146 for module_id
in roibResultTool.L1TopoModuleIds:
147 maybeMissingRobs.append(
int(SourceIdentifier(SubDetector.TDAQ_CALO_TOPO_PROC, module_id)))
148 if flags.Trigger.EDMVersion == 2
and not flags.Trigger.doHLT:
150 for module_id
in roibResultTool.JetModuleIds:
151 maybeMissingRobs.append(
int(SourceIdentifier(SubDetector.TDAQ_CALO_JET_PROC_ROI, module_id)))
152 for module_id
in roibResultTool.EMModuleIds:
153 maybeMissingRobs.append(
int(SourceIdentifier(SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI, module_id)))
158 if flags.Trigger.L1.doMuon
and flags.Trigger.enableL1MuonPhase1
and flags.Trigger.doHLT:
160 flags, name=
"L1MuonBSDecoderTool", writeBS=
False))
161 decoderTools += [muonRoiTool]
166 if flags.Trigger.L1.doCalo
and flags.Trigger.enableL1CaloPhase1:
170 if flags.Trigger.L1.doeFex:
172 if flags.Trigger.doHLT:
190 decodeInputs=flags.Trigger.L1.doCaloInputs
192 decoderTools += [eFexByteStreamTool]
195 if not flags.Trigger.doHLT:
196 maybeMissingRobs += eFexByteStreamTool.ROBIDs
201 if flags.Trigger.L1.dojFex:
203 if flags.Trigger.doHLT:
217 decoderTools += [jFexRoiByteStreamTool]
218 maybeMissingRobs += jFexRoiByteStreamTool.ROBIDs
221 if flags.Trigger.L1.doCaloInputs:
224 'jFexInputBSDecoderTool',
227 decoderTools += [jFexInputByteStreamTool]
228 maybeMissingRobs += jFexInputByteStreamTool.ROBIDs
234 if flags.Trigger.L1.dogFex:
236 if flags.Trigger.doHLT:
242 decoderTools += [gFexByteStreamTool]
243 maybeMissingRobs += gFexByteStreamTool.ROBIDs
246 if flags.Trigger.L1.doCaloInputs:
249 'gFexInputBSDecoderTool',
252 decoderTools += [gFexInputByteStreamTool]
253 maybeMissingRobs += gFexInputByteStreamTool.ROBIDs
258 if flags.Trigger.L1.doTopo
and flags.Trigger.enableL1CaloPhase1
and flags.Trigger.L1.doTopoPhase1:
261 "L1TopoBSDecoderTool",
264 decoderTools += [topoByteStreamTool]
265 maybeMissingRobs += topoByteStreamTool.ROBIDs
267 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder",
268 DecoderTools=decoderTools,
269 MaybeMissingROBs=
list(
set(maybeMissingRobs)))
271 if flags.Trigger.doHLT
or flags.DQ.Steering.doHLTMon:
272 from TrigT1ResultByteStream.TrigT1ResultByteStreamMonitoringConfig
import L1TriggerByteStreamDecoderMonitoringCfg
275 acc.addEventAlgo(decoderAlg, primary=
True)
278 from TriggerJobOpts.TriggerByteStreamConfig
import ByteStreamReadCfg
280 readBSAcc.getEventAlgo(
'SGInputLoader').Load.add(
281 (
'ByteStreamMetadataContainer',
'InputMetaDataStore+ByteStreamMetadata'))
285 if not flags.Trigger.doHLT:
286 from OutputStreamAthenaPool.OutputStreamConfig
import addToESD, addToAOD
288 _log.info(
'Adding the following output EDM to ItemList: %s', outputEDM)
289 acc.merge(
addToESD(flags, outputEDM))
290 acc.merge(
addToAOD(flags, outputEDM))
296 return acc, outputEDM
305 flags, name=
"RoIBResultBSEncoderTool", writeBS=
True))
306 acc.addPublicTool(roibResultTool)
309 if flags.Trigger.L1.doMuon
and flags.Trigger.enableL1MuonPhase1:
311 flags, name=
"L1MuonBSEncoderTool", writeBS=
True))
312 acc.addPublicTool(muonRoiTool)
321 alg = CompFactory.MuCTPIPhase1ByteStreamAlgo()
322 acc.addEventAlgo(alg)
325 if __name__ ==
'__main__':
326 print(
"Please use: athena TrigT1CaloMonitoring/L1CaloPhase1Monitoring.py\nUse --help to see info about how options/examples for running the command")