ATLAS Offline Software
Classes | Public Member Functions | Protected Types | Protected Member Functions | Private Attributes | List of all members
IL1TriggerByteStreamTool Class Referenceabstract

Interface for AlgTools converting ByteStream to xAOD RoI objects and vice versa. More...

#include <IL1TriggerByteStreamTool.h>

Inheritance diagram for IL1TriggerByteStreamTool:
Collaboration diagram for IL1TriggerByteStreamTool:

Classes

struct  Cache
 Cache which tracks memory allocated for ByteStream data representation in the convertToBS method. More...
 

Public Member Functions

 DeclareInterfaceID (IL1TriggerByteStreamTool, 1, 0)
 
virtual ~IL1TriggerByteStreamTool () override=default
 
virtual StatusCode convertFromBS (const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf, const EventContext &eventContext) const =0
 Convert BS -> xAOD. More...
 
virtual StatusCode convertToBS (std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const EventContext &eventContext)=0
 Convert xAOD -> BS. More...
 
virtual const std::vector< uint32_t > & robIds () const =0
 List of IDs of ROBs which the convert methods expect in the vrobf input/output parameter. More...
 

Protected Types

enum  ConversionMode { ConversionMode::Undefined, ConversionMode::Decoding, ConversionMode::Encoding }
 Enum defining conversion mode. More...
 

Protected Member Functions

template<typename RHK , typename WHK >
ConversionMode getConversionMode (const RHK &readHandleKeys, const WHK &writeHandleKeys, MsgStream &msg)
 Helper to find out the conversion mode based on configured data handles. More...
 
void clearCache (const EventContext &eventContext)
 Helper to clear the ByteStream data cache for a given event slot. More...
 
uint32_t * newRodData (const EventContext &eventContext, const size_t size)
 Allocate new array of raw ROD words for output ByteStream data. More...
 
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragmentnewRobFragment (const EventContext &eventContext, uint32_t source_id, uint32_t ndata, const uint32_t *data, uint32_t detev_type=0, uint32_t status_position=eformat::STATUS_BACK)
 Allocate new ROBFragment for output ByteStream data. More...
 

Private Attributes

SG::SlotSpecificObj< Cachem_cache
 

Detailed Description

Interface for AlgTools converting ByteStream to xAOD RoI objects and vice versa.

Definition at line 19 of file IL1TriggerByteStreamTool.h.

Member Enumeration Documentation

◆ ConversionMode

Enum defining conversion mode.

Enumerator
Undefined 
Decoding 

= BS->xAOD

Encoding 

= xAOD->BS

Definition at line 59 of file IL1TriggerByteStreamTool.h.

59 {Undefined, Decoding , Encoding };

Constructor & Destructor Documentation

◆ ~IL1TriggerByteStreamTool()

virtual IL1TriggerByteStreamTool::~IL1TriggerByteStreamTool ( )
overridevirtualdefault

Member Function Documentation

◆ clearCache()

void IL1TriggerByteStreamTool::clearCache ( const EventContext &  eventContext)
inlineprotected

Helper to clear the ByteStream data cache for a given event slot.

Definition at line 81 of file IL1TriggerByteStreamTool.h.

81  {
82  m_cache.get(eventContext)->clear();
83  }

◆ convertFromBS()

virtual StatusCode IL1TriggerByteStreamTool::convertFromBS ( const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &  vrobf,
const EventContext &  eventContext 
) const
pure virtual

Convert BS -> xAOD.

The implementation should create an xAOD RoI object from the raw data and record it in the event store using a WriteHandle it declares.

◆ convertToBS()

virtual StatusCode IL1TriggerByteStreamTool::convertToBS ( std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &  vrobf,
const EventContext &  eventContext 
)
pure virtual

Convert xAOD -> BS.

The implementation should take the xAOD RoI object from the event store using a ReadHandle it declares, convert it to raw data, and fill the vrobf vector. The function is not const, as it needs to rely on the internal cache to track data allocated for BS representation. The provided helpers clearCache, newRodData, newRobFragment should be used to allocate memory for the BS representation.

The caller should set LVL1 ID and TriggerType in all ROBs created by this function after it returns, because it already has a handle on the FullEventFragment (RawEvent). The LVL1 ID and TriggerType set for the ROBs inside this function should not matter.

◆ DeclareInterfaceID()

IL1TriggerByteStreamTool::DeclareInterfaceID ( IL1TriggerByteStreamTool  ,
,
 
)

◆ getConversionMode()

template<typename RHK , typename WHK >
ConversionMode IL1TriggerByteStreamTool::getConversionMode ( const RHK &  readHandleKeys,
const WHK &  writeHandleKeys,
MsgStream &  msg 
)
inlineprotected

Helper to find out the conversion mode based on configured data handles.

Definition at line 62 of file IL1TriggerByteStreamTool.h.

62  {
63  if (readHandleKeys.empty() and not writeHandleKeys.empty()) {
65  }
66  if (writeHandleKeys.empty() and not readHandleKeys.empty()) {
68  }
69  if constexpr (std::is_base_of_v<SG::VarHandleKeyArray, RHK>) {
70  msg << MSG::ERROR << "Exactly one of the read / write handle key arrays has to be set and the other has to"
71  << " be empty, but they have " << readHandleKeys.size() << " / " << writeHandleKeys.size() << " elements"
72  << endmsg;
73  } else if constexpr (std::is_base_of_v<SG::VarHandleKey, RHK>) {
74  msg << MSG::ERROR << "Exactly one of the read / write handle keys has to be set and the other has to"
75  << " be empty, but they are \"" << readHandleKeys.key() << "\" / \"" << writeHandleKeys.key() << "\""
76  << endmsg;
77  }
79  }

◆ newRobFragment()

OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment* IL1TriggerByteStreamTool::newRobFragment ( const EventContext &  eventContext,
uint32_t  source_id,
uint32_t  ndata,
const uint32_t *  data,
uint32_t  detev_type = 0,
uint32_t  status_position = eformat::STATUS_BACK 
)
inlineprotected

Allocate new ROBFragment for output ByteStream data.

Definition at line 91 of file IL1TriggerByteStreamTool.h.

97  {
98 
99  Cache* cache = m_cache.get(eventContext);
100  const EventIDBase& eid = eventContext.eventID();
101  cache->robFragments.push_back(std::make_unique<OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment>(
102  source_id,
103  eid.run_number(),
104  0, // lvl1_id will be overwritten downstream from full event fragment
105  eid.bunch_crossing_id(),
106  0, // lvl1_type will be overwritten downstream from full event fragment
107  detev_type,
108  ndata,
109  data,
110  status_position
111  ));
112  return cache->robFragments.back().get();
113  }

◆ newRodData()

uint32_t* IL1TriggerByteStreamTool::newRodData ( const EventContext &  eventContext,
const size_t  size 
)
inlineprotected

Allocate new array of raw ROD words for output ByteStream data.

Definition at line 85 of file IL1TriggerByteStreamTool.h.

85  {
86  Cache* cache = m_cache.get(eventContext);
87  cache->rodData.push_back(std::make_unique<uint32_t[]>(size));
88  return cache->rodData.back().get();
89  }

◆ robIds()

virtual const std::vector<uint32_t>& IL1TriggerByteStreamTool::robIds ( ) const
pure virtual

List of IDs of ROBs which the convert methods expect in the vrobf input/output parameter.

The implementation has to hold a Gaudi::Property<vector<uint32_t>> to declare the ROB IDs it requires/provides and this method has to return the value of this property. There is no easy way to declare a Gaudi::Property here in the interface, so it is delegated to the implementation.

Member Data Documentation

◆ m_cache

SG::SlotSpecificObj<Cache> IL1TriggerByteStreamTool::m_cache
private

Definition at line 132 of file IL1TriggerByteStreamTool.h.


The documentation for this class was generated from the following file:
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
IL1TriggerByteStreamTool::ConversionMode::Decoding
@ Decoding
= BS->xAOD
IL1TriggerByteStreamTool::ConversionMode::Encoding
@ Encoding
= xAOD->BS
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
IL1TriggerByteStreamTool::ConversionMode::Undefined
@ Undefined
PixelByteStreamErrors::Decoding
@ Decoding
Definition: PixelByteStreamErrors.h:14
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Region::Undefined
@ Undefined
IL1TriggerByteStreamTool::m_cache
SG::SlotSpecificObj< Cache > m_cache
Definition: IL1TriggerByteStreamTool.h:132
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
toolFromAlgData.writeHandleKeys
writeHandleKeys
Definition: toolFromAlgData.py:27