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

Tool filling an HLTResultMT from ByteStream event data. More...

#include <HLTResultMTByteStreamDecoderTool.h>

Inheritance diagram for HLTResultMTByteStreamDecoderTool:
Collaboration diagram for HLTResultMTByteStreamDecoderTool:

Public Member Functions

 HLTResultMTByteStreamDecoderTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard constructor.
virtual StatusCode initialize () override
virtual StatusCode finalize () override
HLT::HLTResultMT::RODMinorVersion getHltRodMinorVersion (const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf) const
 Retrieves the HLT ROD minor version from vector of ROBFragments, checking it is the same in all of them.
StatusCode decodeHeader (const RawEvent *rawEvent, HLT::HLTResultMT &resultToFill) const
 Fills the HLTResultMT object from the ByteStream event header.
StatusCode decodePayload (const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf, HLT::HLTResultMT &resultToFill) const
 Fills the HLTResultMT object from vector of ROBFragments.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode checkRodMinorVersion (const HLT::HLTResultMT::RODMinorVersion version) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Tool filling an HLTResultMT from ByteStream event data.

Definition at line 18 of file HLTResultMTByteStreamDecoderTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ HLTResultMTByteStreamDecoderTool()

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

Standard constructor.

Definition at line 23 of file HLTResultMTByteStreamDecoderTool.cxx.

26: AthAlgTool(type,name,parent) {}
AthAlgTool()
Default constructor:

Member Function Documentation

◆ checkRodMinorVersion()

StatusCode HLTResultMTByteStreamDecoderTool::checkRodMinorVersion ( const HLT::HLTResultMT::RODMinorVersion version) const
private

Definition at line 219 of file HLTResultMTByteStreamDecoderTool.cxx.

219 {
220 if (version == RODMinorVersion{0xff, 0xff}) {
221 ATH_MSG_ERROR("Invalid HLT ROD minor version {0xff, 0xff}");
222 return StatusCode::FAILURE;
223 }
224 if (version.first < 1) {
225 ATH_MSG_ERROR("HLT ROD minor version " << printRodMinorVersion(version) << " is lower than 1.0. "
226 << "This tool is for decoding versions 1.0 or later (i.e. HLT ByteStream from Run 3 or later)");
227 return StatusCode::FAILURE;
228 }
229 ATH_MSG_DEBUG("HLT ROD minor version is " << printRodMinorVersion(version));
230 return StatusCode::SUCCESS;
231}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
HLT::HLTResultMT::RODMinorVersion RODMinorVersion

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ decodeHeader()

StatusCode HLTResultMTByteStreamDecoderTool::decodeHeader ( const RawEvent * rawEvent,
HLT::HLTResultMT & resultToFill ) const

Fills the HLTResultMT object from the ByteStream event header.

The decoding may depend on HLT ROD Minor version. The passed HLTResultMT should have a valid version set.

Parameters
[in]rawEventA pointer to the FullEventFragment to decode
[out]resultToFillThe HLTResultMT object to be updated with the decoded information
Returns
FAILURE if anything goes wrong, else SUCCESS

Definition at line 78 of file HLTResultMTByteStreamDecoderTool.cxx.

78 {
79
80 if (!rawEvent) {
81 ATH_MSG_ERROR("Decoding requested with nullptr RawEvent");
82 return StatusCode::FAILURE;
83 }
84 ATH_MSG_DEBUG("Decoding HLTResultMT from ByteStream event " << rawEvent->global_id());
85
86 const RODMinorVersion hltRodMinorVersion = resultToFill.getVersion();
87 ATH_CHECK(checkRodMinorVersion(hltRodMinorVersion));
88
89 // ---------------------------------------------------------------------------
90 // Read the status words (error codes from online event processing)
91 // ---------------------------------------------------------------------------
92 std::vector<uint32_t> statusWords;
93 // try-catch around eformat calls and raw-pointer operations
94 try {
95 const uint32_t nStatus = rawEvent->nstatus();
96 const uint32_t* rawStatus = rawEvent->status(); // owned by rawEvent
97 //Copy range of data into vector using efficient memmove/memcopy
98 statusWords.assign(rawStatus, rawStatus+nStatus);
99 }
100 catch (const std::exception& ex) {
101 ATH_MSG_ERROR("std::exception caught when reading status words: " << ex.what());
102 return StatusCode::FAILURE;
103 }
104 catch (...) {
105 ATH_MSG_ERROR("Unknown exception caught when reading status words");
106 return StatusCode::FAILURE;
107 }
108 ATH_MSG_DEBUG("Successfully read " << statusWords.size() << " status words");
109 resultToFill.setStatus(std::move(statusWords)); //statusWords is moved so it now empty
110
111 // ---------------------------------------------------------------------------
112 // Read the stream tags
113 // ---------------------------------------------------------------------------
114 std::vector<eformat::helper::StreamTag> streamTags;
115 // try-catch around eformat calls and raw-pointer operations
116 try {
117 eformat::helper::decode(rawEvent->nstream_tag(),rawEvent->stream_tag(),streamTags);
118 }
119 catch (const std::exception& ex) {
120 ATH_MSG_ERROR("std::exception caught when reading stream tags: " << ex.what());
121 return StatusCode::FAILURE;
122 }
123 catch (...) {
124 ATH_MSG_ERROR("Unknown exception caught when reading stream tags");
125 return StatusCode::FAILURE;
126 }
127 ATH_MSG_DEBUG("Successfully read " << streamTags.size() << " stream tags");
128 ATH_CHECK(resultToFill.setStreamTags(streamTags));
129
130
131 // ---------------------------------------------------------------------------
132 // Read the HLT bits
133 // ---------------------------------------------------------------------------
134 std::vector<uint32_t> hltBitWords;
135 // try-catch around eformat calls and raw-pointer operations
136 try {
137 const uint32_t nHltInfo = rawEvent->nhlt_info();
138 const uint32_t* hltInfo = rawEvent->hlt_info(); // owned by rawEvent
139 //Copy range of data into vector using efficient memmove/memcopy
140 hltBitWords.assign(hltInfo, hltInfo+nHltInfo);
141 }
142 catch (const std::exception& ex) {
143 ATH_MSG_ERROR("std::exception caught when reading HLT bits: " << ex.what());
144 return StatusCode::FAILURE;
145 }
146 catch (...) {
147 ATH_MSG_ERROR("Unknown exception caught when reading HLT bits");
148 return StatusCode::FAILURE;
149 }
150
151 // Version 1.0 includes rerun bits, removed since version 1.1
152 const size_t numBitSets = (hltRodMinorVersion==RODMinorVersion{1,0}) ? 3 : 2;
153
154 if (hltBitWords.size() % numBitSets != 0) {
155 ATH_MSG_ERROR("Size of hltBitWords=" << hltBitWords.size() << " must be divisible by " << numBitSets
156 << ". Expecting {raw, prescaled" << (numBitSets==3 ? ", rerun" : "") << "} bits.");
157 return StatusCode::FAILURE;
158 }
159 const size_t sizeOfBlock = hltBitWords.size() / numBitSets;
160 auto beginPrescaledIt = hltBitWords.cbegin() + sizeOfBlock;
161 auto endIt = (numBitSets==2) ? hltBitWords.cend() : hltBitWords.cbegin() + 2*sizeOfBlock;
162 resultToFill.setHltBits( {hltBitWords.cbegin(), beginPrescaledIt},
163 {beginPrescaledIt, endIt} );
164 ATH_MSG_DEBUG("Successfully read " << std::distance(hltBitWords.cbegin(), endIt) << " HLT bit words");
165 return StatusCode::SUCCESS;
166}
#define ATH_CHECK
Evaluate an expression and check for errors.
StatusCode checkRodMinorVersion(const HLT::HLTResultMT::RODMinorVersion version) const
void setHltBits(const boost::dynamic_bitset< uint32_t > &passRawBitset, const boost::dynamic_bitset< uint32_t > &prescaledBitset)
Replace both HLT pass raw and prescaled bits with the given bitsets.
RODMinorVersion getVersion() const
ROD minor version getter.
StatusCode setStreamTags(const std::vector< eformat::helper::StreamTag > &streamTags)
Replace the stored list of stream tags with the given one.
void setStatus(std::vector< uint32_t > status)
Replace the full status words with the given data.
setEventNumber uint32_t

◆ decodePayload()

StatusCode HLTResultMTByteStreamDecoderTool::decodePayload ( const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > & vrobf,
HLT::HLTResultMT & resultToFill ) const

Fills the HLTResultMT object from vector of ROBFragments.

The decoding may depend on HLT ROD Minor version. The passed HLTResultMT should have a valid version set.

Parameters
[in]vrobfA vector of HLT ROBFragments to decode (subdetector identifier TDAQ_HLT)
[out]resultToFillThe HLTResultMT object to be updated with the decoded information
Returns
FAILURE if anything goes wrong, else SUCCESS

Definition at line 169 of file HLTResultMTByteStreamDecoderTool.cxx.

170 {
171 const RODMinorVersion hltRodMinorVersion = resultToFill.getVersion();
172 ATH_CHECK(checkRodMinorVersion(hltRodMinorVersion));
173
174 for (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* robf : vrobf) {
175 eformat::helper::SourceIdentifier sid(robf->rob_source_id());
176 ATH_MSG_DEBUG("Reading ROBFragment " << sid.human());
177
178 // ---------------------------------------------------------------------------
179 // Read the ROB status words (error codes from online event processing)
180 // ---------------------------------------------------------------------------
181 if (robf->nstatus() > 1) {
182 eformat::helper::Status firstStatusWord(*robf->status());
183 if (firstStatusWord.generic() == eformat::GenericStatus::DATA_CORRUPTION &&
184 *(robf->status()+1) == static_cast<uint32_t>(HLT::OnlineErrorCode::RESULT_TRUNCATION)) {
185 ATH_MSG_DEBUG("Detected truncated ROBFragment " << sid.human());
186 resultToFill.addTruncatedModuleId(sid.module_id());
187 }
188 }
189
190 // ---------------------------------------------------------------------------
191 // Read the payload
192 // ---------------------------------------------------------------------------
193 std::vector<uint32_t> data;
194 // try-catch around eformat calls and raw-pointer operations
195 try {
196 const uint32_t nRodData = robf->rod_ndata();
197 const uint32_t* rodData = robf->rod_data(); // owned by robf
198 //Copy range of data into vector using efficient memmove
199 data.assign(rodData, rodData+nRodData);
200 }
201 catch (const std::exception& ex) {
202 ATH_MSG_ERROR("std::exception caught when reading HLT result payload: " << ex.what());
203 return StatusCode::FAILURE;
204 }
205 catch (...) {
206 ATH_MSG_ERROR("Unknown exception caught when reading HLT result payload");
207 return StatusCode::FAILURE;
208 }
209 size_t datasize = data.size(); //I need to ask size before moving the vector
210 ATH_CHECK( resultToFill.addSerialisedDataWithCheck(sid.module_id(), std::move(data)) );
211 //Moved "data" so it is now empty vector
212 ATH_MSG_DEBUG("Successfully read " << datasize << " words of HLT result payload for module ID "
213 << sid.module_id());
214 }
215 return StatusCode::SUCCESS;
216}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
StatusCode addSerialisedDataWithCheck(const uint16_t moduleId, std::vector< uint32_t > data)
Add serialised data for a given moduleId.
void addTruncatedModuleId(const uint16_t moduleId, bool severeTruncation=true)
Add module ID to the list of truncated results.
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode HLTResultMTByteStreamDecoderTool::finalize ( )
overridevirtual

Definition at line 39 of file HLTResultMTByteStreamDecoderTool.cxx.

39 {
40 ATH_MSG_DEBUG("Finalising " << name());
41 return StatusCode::SUCCESS;
42}

◆ getHltRodMinorVersion()

RODMinorVersion HLTResultMTByteStreamDecoderTool::getHltRodMinorVersion ( const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > & vrobf) const

Retrieves the HLT ROD minor version from vector of ROBFragments, checking it is the same in all of them.

Parameters
[in]vrobfA vector of HLT ROBFragments to decode (subdetector identifier TDAQ_HLT)
Returns
The decoded minor version number or {0xff,0xff} in case of errors

Definition at line 45 of file HLTResultMTByteStreamDecoderTool.cxx.

46 {
47
48 if (vrobf.empty()) {
49 ATH_MSG_ERROR("Empty ROBFragment vector passed to getHltRodMinorVersion, returning invalid version");
50 return {0xff, 0xff};
51 }
52
53 uint16_t version{0xffff};
54 bool first{true};
55 for (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* robf : vrobf) {
56 uint32_t thisRodVersion = robf->rod_version();
57 uint16_t thisRodMinorVersion = (thisRodVersion & 0xffffu);
58 if (thisRodMinorVersion == 0xffffu) {
59 ATH_MSG_WARNING("Invalid HLT ROD minor version 0xffff found in ROBFragment 0x"
60 << MSG::hex << robf->rob_source_id() << MSG::dec);
61 }
62 if (first) {
63 version = thisRodMinorVersion;
64 }
65 else if (thisRodMinorVersion != version) {
66 ATH_MSG_ERROR("Inconsistent HLT ROD minor versions in different ROBFragments, 0x"
67 << MSG::hex << version << " and " << thisRodMinorVersion << MSG::dec
68 << ", getHltRodMinorVersion returning invalid version");
69 return {0xff, 0xff};
70 }
71 first = false;
72 }
73 // Split the version 0xabcd into {0xab, 0xcd}
74 return {((version & 0xff00u) >> 8u), (version & 0x00ffu)};
75}
#define ATH_MSG_WARNING(x)
bool first
Definition DeMoScan.py:534
setWord1 uint16_t

◆ initialize()

StatusCode HLTResultMTByteStreamDecoderTool::initialize ( )
overridevirtual

Definition at line 31 of file HLTResultMTByteStreamDecoderTool.cxx.

31 {
32 ATH_MSG_DEBUG("Initialising " << name());
33 return StatusCode::SUCCESS;
34}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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