ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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. More...
 
virtual StatusCode convertToBS (std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const EventContext &eventContext) override
 xAOD->BS conversion More...
 
virtual const std::vector< uint32_t > & robIds () const override
 Declare ROB IDs for conversion. More...
 

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 }

◆ 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 }

◆ initialize()

StatusCode ExampleL1TriggerByteStreamTool::initialize ( )
overridevirtual

Definition at line 26 of file ExampleL1TriggerByteStreamTool.cxx.

26  {
27  ConversionMode mode = getConversionMode(m_roiReadKey, m_roiWriteKey, msg());
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 }

◆ 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.

◆ 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.

◆ 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.


The documentation for this class was generated from the following files:
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
CxxUtils::span
span(T *ptr, std::size_t sz) -> span< T >
A couple needed deduction guides.
Undefined
@ Undefined
Definition: MaterialTypes.h:8
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
skel.it
it
Definition: skel.GENtoEVGEN.py:423
PixelByteStreamErrors::Decoding
@ Decoding
Definition: PixelByteStreamErrors.h:14
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
ROBF
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
Definition: ByteStreamMergeOutputSvc.cxx:16
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
ExampleL1TriggerByteStreamTool::m_roiReadKey
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_roiReadKey
Definition: ExampleL1TriggerByteStreamTool.h:55
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::MuonRoI_v1
Class describing a LVL1 muon region of interest.
Definition: MuonRoI_v1.h:33
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ExampleL1TriggerByteStreamTool::m_roiWriteKey
SG::WriteHandleKey< xAOD::MuonRoIContainer > m_roiWriteKey
Definition: ExampleL1TriggerByteStreamTool.h:52
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Preparation.mode
mode
Definition: Preparation.py:95
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ExampleL1TriggerByteStreamTool::m_robIds
Gaudi::Property< std::vector< uint32_t > > m_robIds
Definition: ExampleL1TriggerByteStreamTool.h:48