ATLAS Offline Software
Loading...
Searching...
No Matches
ExampleL1TriggerByteStreamTool Class Reference

Example implementation of a tool for L1 RoI conversion from BS to xAOD and from xAOD to BS (IL1TriggerByteStreamTool interface) More...

#include <ExampleL1TriggerByteStreamTool.h>

Inheritance diagram for ExampleL1TriggerByteStreamTool:
Collaboration diagram for ExampleL1TriggerByteStreamTool:

Public Member Functions

 ExampleL1TriggerByteStreamTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ExampleL1TriggerByteStreamTool () override=default
virtual StatusCode initialize () override
virtual StatusCode convertFromBS (const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf, const EventContext &eventContext) const override
 BS->xAOD conversion.
virtual StatusCode convertToBS (std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const EventContext &eventContext) override
 xAOD->BS conversion
virtual const std::vector< uint32_t > & robIds () const override
 Declare ROB IDs for conversion.

Private Attributes

Gaudi::Property< std::vector< uint32_t > > m_robIds
SG::WriteHandleKey< xAOD::MuonRoIContainerm_roiWriteKey
SG::ReadHandleKey< xAOD::MuonRoIContainerm_roiReadKey

Detailed Description

Example implementation of a tool for L1 RoI conversion from BS to xAOD and from xAOD to BS (IL1TriggerByteStreamTool interface)

This example decodes Muon RoIs from MUCTPI raw data, filling the results with dummy values. Real implementations should have very similar structure and should implement the same functionality and properties. In particular, the convertFromBS method should record a new xAOD collection in the event store using a WriteHandle, and the convertToBS method should take the xAOD collection from the event store using a ReadHandle.

Definition at line 27 of file ExampleL1TriggerByteStreamTool.h.

Constructor & Destructor Documentation

◆ ExampleL1TriggerByteStreamTool()

ExampleL1TriggerByteStreamTool::ExampleL1TriggerByteStreamTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 21 of file ExampleL1TriggerByteStreamTool.cxx.

24: base_class(type, name, parent) {}

◆ ~ExampleL1TriggerByteStreamTool()

virtual ExampleL1TriggerByteStreamTool::~ExampleL1TriggerByteStreamTool ( )
overridevirtualdefault

Member Function Documentation

◆ convertFromBS()

StatusCode ExampleL1TriggerByteStreamTool::convertFromBS ( const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > & vrobf,
const EventContext & eventContext ) const
overridevirtual

BS->xAOD conversion.

Definition at line 37 of file ExampleL1TriggerByteStreamTool.cxx.

38 {
39 if (m_roiWriteKey.empty()) {
40 ATH_MSG_ERROR("Conversion from BS to xAOD RoI requested but RoI WriteHandleKey is empty");
41 return StatusCode::FAILURE;
42 }
43
44 // Create and record the RoI container
45 auto handle = SG::makeHandle(m_roiWriteKey, eventContext);
46 auto cont = std::make_unique<xAOD::MuonRoIContainer>();
47 auto auxcont = std::make_unique<xAOD::MuonRoIAuxContainer>();
48 cont->setStore(auxcont.get());
49 ATH_CHECK(handle.record(std::move(cont), std::move(auxcont)));
50 ATH_MSG_DEBUG("Recorded MuonRoIContainer with key " << m_roiWriteKey.key());
51
52 // Find the ROB fragment to decode
53 const eformat::helper::SourceIdentifier sid(m_robIds.value().at(0));
54 auto it = std::find_if(vrobf.begin(), vrobf.end(), [&sid](const ROBF* rob){return rob->rob_source_id() == sid.code();});
55 if (it == vrobf.end()) {
56 ATH_MSG_DEBUG("No MUCTPI ROB fragment with ID 0x" << std::hex << sid.code() << std::dec
57 << " was found, MuonRoIContainer will be empty");
58 return StatusCode::SUCCESS;
59 }
60
61 // Iterate over ROD words and decode
62 const ROBF* rob = *it;
63 const uint32_t ndata = rob->rod_ndata();
64 const uint32_t* data = rob->rod_data();
65 ATH_MSG_DEBUG("Starting to decode " << ndata << " ROD words");
66 for (const uint32_t word : std::span{data, ndata}) {
67 ATH_MSG_DEBUG("Muon RoI raw word: 0x" << std::hex << word << std::dec);
68 // Here comes the decoding
69 // Using some dummy values as this is not real decoding, just an example
70 handle->push_back(new xAOD::MuonRoI);
71 handle->back()->initialize(word, 99, 99, "DummyThreshold", 99);
72 }
73
74 ATH_MSG_DEBUG("Decoded " << handle->size() << " Muon RoIs");
75 return StatusCode::SUCCESS;
76}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Gaudi::Property< std::vector< uint32_t > > m_robIds
SG::WriteHandleKey< xAOD::MuonRoIContainer > m_roiWriteKey
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
MuonRoI_v1 MuonRoI
Definition MuonRoI.h:15
setEventNumber uint32_t

◆ convertToBS()

StatusCode ExampleL1TriggerByteStreamTool::convertToBS ( std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > & vrobf,
const EventContext & eventContext )
overridevirtual

xAOD->BS conversion

Definition at line 79 of file ExampleL1TriggerByteStreamTool.cxx.

80 {
81 // Retrieve the RoI container
82 auto muonRoIs = SG::makeHandle(m_roiReadKey, eventContext);
83 ATH_CHECK(muonRoIs.isValid());
84
85 // Clear BS data cache
86 clearCache(eventContext);
87
88 // Create raw ROD data words
89 ATH_MSG_DEBUG("Converting " << muonRoIs->size() << " L1 Muon RoIs to ByteStream");
90 uint32_t* data = newRodData(eventContext, muonRoIs->size());
91 for (size_t i=0; i<muonRoIs->size(); ++i) {
92 data[i] = muonRoIs->at(i)->roiWord();
93 }
94
95 // Create ROBFragment containing the ROD words
96 const eformat::helper::SourceIdentifier sid(m_robIds.value().at(0));
97 vrobf.push_back(newRobFragment(eventContext, sid.code(), muonRoIs->size(), data));
98
99 return StatusCode::SUCCESS;
100}
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_roiReadKey

◆ initialize()

StatusCode ExampleL1TriggerByteStreamTool::initialize ( )
overridevirtual

Definition at line 26 of file ExampleL1TriggerByteStreamTool.cxx.

26 {
27 ConversionMode mode = getConversionMode(m_roiReadKey, m_roiWriteKey, msg());
28 ATH_CHECK(mode!=ConversionMode::Undefined);
29 ATH_CHECK(m_roiWriteKey.initialize(mode==ConversionMode::Decoding));
30 ATH_CHECK(m_roiReadKey.initialize(mode==ConversionMode::Encoding));
31 ATH_MSG_DEBUG((mode==ConversionMode::Encoding ? "Encoding" : "Decoding") << " ROB IDs: "
32 << MSG::hex << m_robIds.value() << MSG::dec);
33 return StatusCode::SUCCESS;
34}
MsgStream & msg
Definition testRead.cxx:32

◆ robIds()

virtual const std::vector< uint32_t > & ExampleL1TriggerByteStreamTool::robIds ( ) const
inlineoverridevirtual

Declare ROB IDs for conversion.

Definition at line 43 of file ExampleL1TriggerByteStreamTool.h.

43{return m_robIds.value();}

Member Data Documentation

◆ m_robIds

Gaudi::Property<std::vector<uint32_t> > ExampleL1TriggerByteStreamTool::m_robIds
private
Initial value:
{
this, "ROBIDs", {}, "List of ROB IDs required for conversion to/from xAOD RoI"}

Definition at line 48 of file ExampleL1TriggerByteStreamTool.h.

48 {
49 this, "ROBIDs", {}, "List of ROB IDs required for conversion to/from xAOD RoI"};

◆ m_roiReadKey

SG::ReadHandleKey<xAOD::MuonRoIContainer> ExampleL1TriggerByteStreamTool::m_roiReadKey
private
Initial value:
{
this, "MuonRoIContainerReadKey", "", "Read handle key to MuonRoIContainer for conversion to ByteStream"}

Definition at line 55 of file ExampleL1TriggerByteStreamTool.h.

55 {
56 this, "MuonRoIContainerReadKey", "", "Read handle key to MuonRoIContainer for conversion to ByteStream"};

◆ m_roiWriteKey

SG::WriteHandleKey<xAOD::MuonRoIContainer> ExampleL1TriggerByteStreamTool::m_roiWriteKey
private
Initial value:
{
this, "MuonRoIContainerWriteKey", "", "Write handle key to MuonRoIContainer for conversion from ByteStream"}

Definition at line 52 of file ExampleL1TriggerByteStreamTool.h.

52 {
53 this, "MuonRoIContainerWriteKey", "", "Write handle key to MuonRoIContainer for conversion from ByteStream"};

The documentation for this class was generated from the following files: