Commit 20c36425 authored by Rafal Bielski's avatar Rafal Bielski
Browse files

Encode MUCTPI ByteStream to both RoIB and DAQ ROBs

parent c320b523
......@@ -59,10 +59,10 @@ def ExampleL1TriggerByteStreamToolCfg(name, writeBS=False):
tool.MuonRoIContainerWriteKey="LVL1MuonRoIs"
return tool
def MuonRoIByteStreamToolCfg(name, flags, writeBS=False):
tool_name = name if flags.Trigger.doHLT else name+"DAQ"
def MuonRoIByteStreamToolCfg(name, flags, daq=False, writeBS=False):
tool_name = name+"DAQ" if daq else name
tool = CompFactory.MuonRoIByteStreamTool(tool_name)
muctpi_moduleid = 1 if flags.Trigger.doHLT else 0 # RoIB ROB for HLT, DAQ ROB for offline
muctpi_moduleid = 0 if daq else 1
muctpi_robid = int(SourceIdentifier(SubDetector.TDAQ_MUON_CTP_INTERFACE, muctpi_moduleid))
tool.MUCTPIModuleId = muctpi_moduleid
tool.ROBIDs = [muctpi_robid]
......@@ -73,7 +73,7 @@ def MuonRoIByteStreamToolCfg(name, flags, writeBS=False):
else:
# read BS == write xAOD
tool.MuonRoIContainerReadKey=""
tool.MuonRoIContainerWriteKey = "LVL1MuonRoIs" if flags.Trigger.doHLT else "LVL1MuonRoIsDAQ"
tool.MuonRoIContainerWriteKey = "LVL1MuonRoIsDAQ" if daq else "LVL1MuonRoIs"
tool.UseRun3Config = flags.Trigger.enableL1MuonPhase1
tool.RPCRecRoiTool = getRun3RPCRecRoiTool(name="RPCRecRoiTool",useRun3Config=flags.Trigger.enableL1MuonPhase1)
......@@ -128,7 +128,10 @@ def L1TriggerByteStreamDecoderCfg(flags):
# Run-3 L1Muon decoding
if flags.Trigger.enableL1MuonPhase1:
muonRoiTool = MuonRoIByteStreamToolCfg(name="L1MuonBSDecoderTool", flags=flags, writeBS=False)
muonRoiTool = MuonRoIByteStreamToolCfg(name="L1MuonBSDecoderTool",
flags=flags,
daq=(not flags.Trigger.doHLT), # RoIB ROB for HLT, DAQ ROB for offline
writeBS=False)
decoderTools += [muonRoiTool]
# TODO: Run-3 L1Calo, L1Topo, CTP
......@@ -172,8 +175,13 @@ def L1TriggerByteStreamEncoderCfg(flags):
# Run-3 L1Muon encoding
if flags.Trigger.L1.doMuon and flags.Trigger.enableL1MuonPhase1:
muonRoiTool = MuonRoIByteStreamToolCfg(name="L1MuonBSEncoderTool", flags=flags, writeBS=True)
acc.addPublicTool(muonRoiTool)
# Write to both RoIB and DAQ ROBs
for encode_daq in [False, True]:
muonRoiTool = MuonRoIByteStreamToolCfg(name="L1MuonBSEncoderTool",
flags=flags,
daq=encode_daq,
writeBS=True)
acc.addPublicTool(muonRoiTool)
# TODO: Run-3 L1Calo, L1Topo, CTP
......
......@@ -11,7 +11,6 @@
#include "AthenaKernel/ClassID_traits.h"
#include "AthenaKernel/StorableConversions.h"
#include "ByteStreamCnvSvcBase/ByteStreamAddress.h"
#include "ByteStreamData/RawEvent.h"
// Gaudi includes
#include "GaudiKernel/IRegistry.h"
......@@ -47,6 +46,10 @@ StatusCode L1TriggerResultByteStreamCnv::initialize() {
ATH_MSG_DEBUG("MUCTPI BS encoding is " << (doMuon ? "enabled" : "disabled"));
ATH_CHECK(m_muonEncoderTool.retrieve(EnableTool(doMuon)));
const bool doMuonDaq = not serviceLocator()->getOptsSvc().get("ToolSvc.L1MuonBSEncoderToolDAQ.ROBIDs").empty();
ATH_MSG_DEBUG("MUCTPI DAQ ROB encoding is " << (doMuonDaq ? "enabled" : "disabled"));
ATH_CHECK(m_muonEncoderToolDaq.retrieve(EnableTool(doMuonDaq)));
ATH_MSG_VERBOSE("end of " << __FUNCTION__);
return StatusCode::SUCCESS;
}
......@@ -60,6 +63,8 @@ StatusCode L1TriggerResultByteStreamCnv::finalize() {
ATH_MSG_WARNING("Failed to release service " << m_ByteStreamEventAccess.typeAndName());
if (m_muonEncoderTool.isEnabled() && m_muonEncoderTool.release().isFailure())
ATH_MSG_WARNING("Failed to release tool " << m_muonEncoderTool.typeAndName());
if (m_muonEncoderToolDaq.isEnabled() && m_muonEncoderToolDaq.release().isFailure())
ATH_MSG_WARNING("Failed to release tool " << m_muonEncoderToolDaq.typeAndName());
ATH_MSG_VERBOSE("end of " << __FUNCTION__);
return StatusCode::SUCCESS;
}
......@@ -100,24 +105,18 @@ StatusCode L1TriggerResultByteStreamCnv::createRep(DataObject* pObj, IOpaqueAddr
// The xAOD CTP result object holding the bits will be obtained here via ElementLink from l1TriggerResult
// MuonRoI encoding
if (m_muonEncoderTool.isEnabled()) {
for (ToolHandle<IL1TriggerByteStreamTool>& tool : {std::reference_wrapper(m_muonEncoderTool), std::reference_wrapper(m_muonEncoderToolDaq)}) {
if (not tool.isEnabled()) {continue;}
std::vector<WROBF*> muon_robs;
ATH_CHECK(m_muonEncoderTool->convertToBS(muon_robs, Gaudi::Hive::currentContext())); // TODO: find a way to avoid ThreadLocalContext
ATH_MSG_DEBUG("Created " << muon_robs.size() << " L1Muon ROB Fragments");
ATH_CHECK(tool->convertToBS(muon_robs, Gaudi::Hive::currentContext())); // TODO: find a way to avoid ThreadLocalContext
ATH_MSG_DEBUG(tool.name() << " created " << muon_robs.size() << " L1Muon ROB Fragments");
for (WROBF* rob : muon_robs) {
if (msgLvl(MSG::DEBUG)) {
const uint32_t ndata = rob->rod_ndata();
const uint32_t* data = rob->rod_data();
ATH_MSG_DEBUG("This ROB has " << ndata << " data words");
for (uint32_t i=0; i<ndata; ++i, ++data) {
ATH_MSG_DEBUG("--- " << MSG::hex << *data << MSG::dec);
}
}
printRob(*rob);
// Set LVL1 Trigger Type from the full event
rob->rod_lvl1_type(re->lvl1_trigger_type());
// Add the ROBFragment to the full event
re->append(rob);
ATH_MSG_DEBUG("Added ROB fragment " << MSG::hex << rob->source_id() << MSG::dec << " to the output raw event");
ATH_MSG_DEBUG("Added ROB fragment 0x" << MSG::hex << rob->source_id() << MSG::dec << " to the output raw event");
}
}
......@@ -131,6 +130,19 @@ StatusCode L1TriggerResultByteStreamCnv::createRep(DataObject* pObj, IOpaqueAddr
return StatusCode::SUCCESS;
}
// =============================================================================
// Debug print helper
// =============================================================================
void L1TriggerResultByteStreamCnv::printRob(const OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment& rob) const {
if (not msgLvl(MSG::DEBUG)) {return;}
const uint32_t ndata = rob.rod_ndata();
const uint32_t* data = rob.rod_data();
ATH_MSG_DEBUG("This ROB has " << ndata << " data words");
for (uint32_t i=0; i<ndata; ++i, ++data) {
ATH_MSG_DEBUG("--- 0x" << MSG::hex << *data << MSG::dec);
}
}
// =============================================================================
// CLID / storageType
// =============================================================================
......
......@@ -12,6 +12,7 @@
#include "AthenaBaseComps/AthMessaging.h"
#include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h"
#include "ByteStreamCnvSvcBase/FullEventAssembler.h"
#include "ByteStreamData/RawEvent.h"
// Gaudi includes
#include "GaudiKernel/Converter.h"
......@@ -44,12 +45,16 @@ public:
long repSvcType() const override { return i_repSvcType(); } //!< return repSvcType
private:
/// Helper method for debug printouts
void printRob(const OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment& rob) const;
/// Helper to obtain the RawEvent pointer
ServiceHandle<IByteStreamEventAccess> m_ByteStreamEventAccess{"ByteStreamCnvSvc", "L1TriggerResultByteStreamCnv"};
// Tools performing the decoding work - *public* tools hard-coded in C++ because of Converter interface limitations
/// Encoder tool for L1Muon RoIs
/// Encoder tools for L1Muon RoIs (one writing RoIB ROB, one writing DAQ ROB)
ToolHandle<IL1TriggerByteStreamTool> m_muonEncoderTool{"MuonRoIByteStreamTool/L1MuonBSEncoderTool"};
ToolHandle<IL1TriggerByteStreamTool> m_muonEncoderToolDaq{"MuonRoIByteStreamTool/L1MuonBSEncoderToolDAQ"};
// Placeholder for other L1 xAOD outputs:
// - CTP result
// - L1Topo result
......
......@@ -30,6 +30,9 @@ StatusCode MuonRoIByteStreamTool::initialize() {
ATH_CHECK(m_roiWriteKey.initialize(!m_roiWriteKey.empty()));
ATH_CHECK(m_roiReadKey.initialize(!m_roiReadKey.empty()));
ATH_MSG_DEBUG((m_roiWriteKey.empty() ? "Encoding" : "Decoding") << " ROB IDs: "
<< MSG::hex << m_robIds.value() << MSG::dec);
CHECK( m_rpcTool.retrieve() );
CHECK( m_tgcTool.retrieve() );
CHECK( m_thresholdTool.retrieve() );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment