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
76 tool.WriteDecodedMuonRoIs = writeDecodedMuonRoIs
78 from TrigT1ResultByteStream.TrigT1ResultByteStreamMonitoringConfig
import L1MuonBSConverterMonitoringCfg
82 containerBaseName =
"LVL1MuonRoIs"
84 containerBaseName +
"BCm2",
85 containerBaseName +
"BCm1",
87 containerBaseName +
"BCp1",
88 containerBaseName +
"BCp2",
90 topocontainerBaseName =
"L1MuCTPItoL1TopoLocationFromMuonRoI"
91 topocontainerNames = [
92 topocontainerBaseName +
"-2",
93 topocontainerBaseName +
"-1",
94 topocontainerBaseName,
95 topocontainerBaseName +
"1",
96 topocontainerBaseName +
"2",
100 tool.MuonRoIContainerReadKeys += containerNames
103 tool.MuonRoIContainerWriteKeys += [
recordable(c)
for c
in containerNames]
104 tool.L1TopoOutputLocID += topocontainerNames
110 acc.setPrivateTools(tool)
115 Helper function returning a logic combination of flags deciding
116 whether the RoIBResult decoding/encoding is required in the job
118 if flags.Trigger.L1.doCalo
and flags.Trigger.enableL1CaloLegacy:
121 if flags.Trigger.L1.doMuon
and not flags.Trigger.enableL1MuonPhase1:
124 if flags.Trigger.L1.doTopo:
127 if flags.Trigger.L1.doCTP:
136 maybeMissingRobs = []
141 if not flags.Trigger.doLVL1:
144 flags, name=
"RoIBResultBSDecoderTool", writeBS=
False))
145 decoderTools += [roibResultTool]
147 for module_id
in roibResultTool.L1TopoModuleIds:
148 maybeMissingRobs.append(
int(SourceIdentifier(SubDetector.TDAQ_CALO_TOPO_PROC, module_id)))
149 if flags.Trigger.EDMVersion == 2
and not flags.Trigger.doHLT:
151 for module_id
in roibResultTool.JetModuleIds:
152 maybeMissingRobs.append(
int(SourceIdentifier(SubDetector.TDAQ_CALO_JET_PROC_ROI, module_id)))
153 for module_id
in roibResultTool.EMModuleIds:
154 maybeMissingRobs.append(
int(SourceIdentifier(SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI, module_id)))
159 if flags.Trigger.L1.doMuon
and flags.Trigger.enableL1MuonPhase1
and flags.Trigger.doHLT :
161 flags, name=
"L1MuonBSDecoderTool", writeBS=
False))
162 decoderTools += [muonRoiTool]
167 if flags.Trigger.L1.doCalo
and flags.Trigger.enableL1CaloPhase1:
171 if flags.Trigger.L1.doeFex:
173 if flags.Trigger.doHLT:
191 decodeInputs=flags.Trigger.L1.doCaloInputs
193 decoderTools += [eFexByteStreamTool]
196 if not flags.Trigger.doHLT:
197 maybeMissingRobs += eFexByteStreamTool.ROBIDs
202 if flags.Trigger.L1.dojFex:
204 if flags.Trigger.doHLT:
218 decoderTools += [jFexRoiByteStreamTool]
219 maybeMissingRobs += jFexRoiByteStreamTool.ROBIDs
222 if flags.Trigger.L1.doCaloInputs:
225 'jFexInputBSDecoderTool',
228 decoderTools += [jFexInputByteStreamTool]
229 maybeMissingRobs += jFexInputByteStreamTool.ROBIDs
235 if flags.Trigger.L1.dogFex:
237 if flags.Trigger.doHLT:
243 decoderTools += [gFexByteStreamTool]
244 maybeMissingRobs += gFexByteStreamTool.ROBIDs
247 if flags.Trigger.L1.doCaloInputs:
250 'gFexInputBSDecoderTool',
253 decoderTools += [gFexInputByteStreamTool]
254 maybeMissingRobs += gFexInputByteStreamTool.ROBIDs
259 if flags.Trigger.L1.doTopo
and flags.Trigger.enableL1CaloPhase1
and flags.Trigger.L1.doTopoPhase1:
262 "L1TopoBSDecoderTool",
265 decoderTools += [topoByteStreamTool]
266 maybeMissingRobs += topoByteStreamTool.ROBIDs
268 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder",
269 DecoderTools=decoderTools,
270 MaybeMissingROBs=
list(
set(maybeMissingRobs)))
272 if flags.Trigger.doHLT
or flags.DQ.Steering.doHLTMon:
273 from TrigT1ResultByteStream.TrigT1ResultByteStreamMonitoringConfig
import L1TriggerByteStreamDecoderMonitoringCfg
276 acc.addEventAlgo(decoderAlg, primary=
True)
279 from TriggerJobOpts.TriggerByteStreamConfig
import ByteStreamReadCfg
281 readBSAcc.getEventAlgo(
'SGInputLoader').Load.add(
282 (
'ByteStreamMetadataContainer',
'InputMetaDataStore+ByteStreamMetadata'))
286 if not flags.Trigger.doHLT:
287 from OutputStreamAthenaPool.OutputStreamConfig
import addToESD, addToAOD
289 _log.info(
'Adding the following output EDM to ItemList: %s', outputEDM)
290 acc.merge(
addToESD(flags, outputEDM))
291 acc.merge(
addToAOD(flags, outputEDM))
297 return acc, outputEDM
306 flags, name=
"RoIBResultBSEncoderTool", writeBS=
True))
307 acc.addPublicTool(roibResultTool)
310 if flags.Trigger.L1.doMuon
and flags.Trigger.enableL1MuonPhase1:
312 flags, name=
"L1MuonBSEncoderTool", writeBS=
True))
313 acc.addPublicTool(muonRoiTool)
322 alg = CompFactory.MuCTPIPhase1ByteStreamAlgo()
323 acc.addEventAlgo(alg)
326 if __name__ ==
'__main__':
327 print(
"Please use: athena TrigT1CaloMonitoring/L1CaloPhase1Monitoring.py\nUse --help to see info about how options/examples for running the command")