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

#include <TRT_RodDecoder.h>

Inheritance diagram for TRT_RodDecoder:

Classes

struct  t_CompressTable

Public Member Functions

 TRT_RodDecoder (const std::string &type, const std::string &name, const IInterface *parent)
 constructor
virtual ~TRT_RodDecoder ()
 destructor
virtual StatusCode initialize () override
 initialize
virtual StatusCode finalize () override
 finalize
virtual StatusCode fillCollection (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, TRT_RDO_Container *rdoIdc, TRT_BSErrContainer *bserr, DataPool< TRT_LoLumRawData > *dataItemsPool, const EventContext &ctx, const std::vector< IdentifierHash > *vecHash=0) const override
 the method to fill the IDC

Private Member Functions

StatusCode update (const EventContext &ctx) const
StatusCode int_fillExpanded (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, TRT_RDO_Container *rodIdc, DataPool< TRT_LoLumRawData > *dataItemsPool, const std::vector< IdentifierHash > *vecHash=0) const
 private methods
StatusCode int_fillMinimalCompress (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, TRT_RDO_Container *rdoIdo, DataPool< TRT_LoLumRawData > *dataItemsPool, const std::vector< IdentifierHash > *vecHash=0) const
StatusCode int_fillFullCompress (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, TRT_RDO_Container *rdoIdo, DataPool< TRT_LoLumRawData > *dataItemsPool, const t_CompressTable &Ctable, const std::vector< IdentifierHash > *vecHash=0) const
StatusCode ReadCompressTableFile (const std::string &TableFilename)
StatusCode ReadCompressTableDB (std::string Tag)

Private Attributes

ServiceHandle< ITRT_CablingSvcm_CablingSvc
bool m_recordBSErrors
bool m_lookAtSidErrors
bool m_lookAtErrorErrors
bool m_lookAtL1idErrors
bool m_lookAtBcidErrors
bool m_lookAtMissingErrors
bool m_loadCompressTableFile
bool m_loadCompressTableDB
std::vector< int > m_LoadCompressTableVersions
const int m_maxCompressionVersion
int m_forceRodVersion
const TRT_IDm_trt_id
IdContext m_straw_layer_context
BooleanProperty m_TB04_RawData
BooleanProperty m_LoLumRawData
bool m_eventTypeIsSim
uint32_t m_escape_marker
bool m_sortCollections {}
std::vector< CxxUtils::CachedUniquePtr< t_CompressTable > > m_CompressionTables
std::atomic< uint32_t > m_Nrdos
std::atomic< int > m_err_count_fillCollection {0}
std::atomic< int > m_err_count_int_fillMinimalCompress {0}
std::atomic< int > m_err_count_int_fillFullCompress {0}
SG::ReadCondHandleKey< CondAttrListCollectionm_CompressKey {this,"keyName","/TRT/Onl/ROD/Compress","in-key"}
SG::SlotSpecificObj< std::atomic< EventContext::ContextEvt_t > > m_lastPrint ATLAS_THREAD_SAFE
std::atomic< unsigned int > m_skip {}
std::atomic< unsigned int > m_accept {}

Detailed Description

Definition at line 59 of file TRT_RodDecoder.h.

Constructor & Destructor Documentation

◆ TRT_RodDecoder()

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

constructor

Definition at line 35 of file TRT_RodDecoder.cxx.

37 : base_class(type, name, parent),
38 m_CablingSvc("TRT_CablingSvc", name),
39 m_recordBSErrors(true),
49 m_trt_id(nullptr),
50 m_eventTypeIsSim(false),
51 m_escape_marker(0x8000000),
52 m_Nrdos(0)
53
54{
55 declareProperty("TRT_Cabling", m_CablingSvc);
56 declareProperty("RecordByteStreamErrors", m_recordBSErrors);
57 declareProperty("LookAtSidErrors", m_lookAtSidErrors);
58 declareProperty("LookAtErrorErrors", m_lookAtErrorErrors);
59 declareProperty("LookAtL1idErrors", m_lookAtL1idErrors);
60 declareProperty("LookAtBcidErrors", m_lookAtBcidErrors);
61 declareProperty("LookAtMissingErrors", m_lookAtMissingErrors);
62 declareProperty("LoadCompressTableFile", m_loadCompressTableFile);
63 declareProperty("LoadCompressTableDB", m_loadCompressTableDB);
64 declareProperty("ForceRodVersion", m_forceRodVersion);
65 declareProperty("LoadCompressTableVersions", m_LoadCompressTableVersions);
66 declareProperty("SortCollections", m_sortCollections);
67}
uint32_t m_escape_marker
std::vector< int > m_LoadCompressTableVersions
std::atomic< uint32_t > m_Nrdos
bool m_loadCompressTableFile
ServiceHandle< ITRT_CablingSvc > m_CablingSvc
const int m_maxCompressionVersion
const TRT_ID * m_trt_id

◆ ~TRT_RodDecoder()

TRT_RodDecoder::~TRT_RodDecoder ( )
virtualdefault

destructor

Member Function Documentation

◆ fillCollection()

StatusCode TRT_RodDecoder::fillCollection ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * robFrag,
TRT_RDO_Container * rdoIdc,
TRT_BSErrContainer * bserr,
DataPool< TRT_LoLumRawData > * dataItemsPool,
const EventContext & ctx,
const std::vector< IdentifierHash > * vecHash = 0 ) const
overridevirtual

the method to fill the IDC

Definition at line 180 of file TRT_RodDecoder.cxx.

184 {
185 // update compression tables
188 sc = update(ctx);
189
190 int RodBlockVersion = (robFrag->rod_version() & 0xff);
191
192 if (m_forceRodVersion > 0)
193 RodBlockVersion = m_forceRodVersion;
194
195 uint32_t robid = robFrag->rod_source_id();
196
197 /*
198 * Save non-zero rob status to TRT BS Conditions Services
199 */
200 if (robFrag->nstatus()) {
201 const uint32_t* rob_status;
202 robFrag->status(rob_status);
203
204 if (*rob_status) {
205
206 bsErr->add_rob_error(robFrag->rob_source_id(), *rob_status);
207
208 /*
209 * This is a hack to only print once per event.
210 */
211
212 std::atomic<EventContext::ContextEvt_t>* evt = m_lastPrint.get(ctx);
213 EventContext::ContextEvt_t lastEvt = *evt;
214
215 while (lastEvt != ctx.evt() &&
216 !evt->compare_exchange_strong(lastEvt, ctx.evt()));
217
218 if (lastEvt != ctx.evt()) { // New event in this slot
219 *evt = ctx.evt();
220 ATH_MSG_INFO("Non-Zero ROB status word for ROB "
221 << MSG::hex << robFrag->rob_source_id() << " ( "
222 << *rob_status << " ) " << MSG::dec
223 << " Skipping decoding...");
224 }
225
226 sc = StatusCode::RECOVERABLE; // XXX - Evil, but cannot trust anything
227 return sc;
228 }
229 }
230
231 // get version to decide which method to use to decode !
232 if (3 < RodBlockVersion &&
233 m_maxCompressionVersion >= RodBlockVersion) // Full Compression
234 {
235 if (m_CompressionTables[RodBlockVersion])
236 sc = int_fillFullCompress(robFrag, rdoIdc, dataItemsPool,
237 *m_CompressionTables[RodBlockVersion], vecHash);
238 else {
239 if (m_err_count_fillCollection < 100) {
240 ATH_MSG_WARNING("Rod Version: "
241 << RodBlockVersion
242 << ", but Compression Table not loaded! ROD ID = "
243 << MSG::hex << robid << MSG::dec);
245 } else if (100 == m_err_count_fillCollection) {
246 ATH_MSG_WARNING("Too many Rod Version messages. "
247 << "Turning message off.");
249 }
250
251 sc = StatusCode::FAILURE;
252 }
253 } else if (3 == RodBlockVersion) {
254 sc = int_fillMinimalCompress(robFrag, rdoIdc, dataItemsPool, vecHash);
255 } else if ((2 == RodBlockVersion) || (1 == RodBlockVersion)) {
256 sc = int_fillExpanded(robFrag, rdoIdc, dataItemsPool, vecHash);
257 } else if (0 == RodBlockVersion) {
258 if (0 == robFrag->rod_ndata()) {
259 return sc;
260 }
261
262 if (!m_eventTypeIsSim) {
263 ATH_MSG_FATAL("ROD Format Version Number is ZERO. "
264 << "and event_type is not EventType::IS_SIMULATION, "
265 << "ROD ID = " << MSG::hex << robid << MSG::dec);
266 return StatusCode::FAILURE;
267 }
268
269 sc = int_fillExpanded(robFrag, rdoIdc, dataItemsPool, vecHash);
270 } else {
271 }
272
273 /*
274 * Decode Status Block, only if we have a modern block and
275 * are OK at this point
276 */
277 if ((RodBlockVersion >= 2) && (sc == StatusCode::SUCCESS)) {
278 /*
279 * Error counters
280 */
281 int sid_errors = 0;
282 int error_errors = 0;
283 int l1id_errors = 0;
284 int bcid_errors = 0;
285 int missing_errors = 0;
286
287 if (m_recordBSErrors) {
288 uint32_t rod_L1ID = robFrag->rod_lvl1_id();
289 uint32_t rod_BCID = robFrag->rod_bc_id();
290 uint32_t rod_SourceID = robFrag->rod_source_id();
291
293 robFrag->rod_status(vint);
294
295 int v_index = 0;
296
297 /*
298 * skip mandatory status word
299 */
300 // uint32_t mandatory = vint[v_index++];
301 v_index++;
302
303 uint32_t n_status = vint[v_index++];
304
305 if (n_status > robFrag->rod_nstatus()) {
306 if (n_status > robFrag->rod_fragment_size_word()) {
308 "Rejecting fragment because the number of status words exceeds "
309 "the fragement size: "
310 << n_status << " > " << robFrag->rod_fragment_size_word()
311 << " (nstatus from fragment header = " << robFrag->rod_nstatus()
312 << ")");
313 return StatusCode::RECOVERABLE;
314 } else {
316 "The number of status words exceeds the number of status words "
317 "marked in the header: "
318 << n_status << " !< " << robFrag->rod_nstatus()
319 << " (fragment size = " << robFrag->rod_fragment_size_word()
320 << ")");
321 }
322 }
323
324 uint32_t i = 1;
325 while (i < n_status) {
326 uint32_t word = vint[v_index++];
327
328 for (int j = 0; j < 2; j++) {
329 uint32_t stat = (word >> (16 * j)) & 0xffff;
330 if (stat) // Skip 0 words, bug in ROD???
331 {
332 int DTMROC_index = stat & 0x7f;
333 int DTMROC_head = (stat >> 7) & 0x1ff;
334
335 uint32_t Index = (rod_SourceID << 8) | DTMROC_index;
336
337 if (DTMROC_head) {
338 int D_sid = DTMROC_head & 0x100;
339 uint32_t D_L1ID = (DTMROC_head >> 5) & 0x7;
340 uint32_t D_BCID = (DTMROC_head >> 1) & 0xf;
341 int D_error = !(DTMROC_head & 1);
342
343 if (m_lookAtSidErrors && D_sid) {
344 bsErr->add_sid_error(Index);
345 sid_errors++;
346 }
347
348 if (m_lookAtErrorErrors && D_error) {
349 bsErr->add_error_error(Index);
350 error_errors++;
351 }
352
353 if (m_lookAtL1idErrors && (D_L1ID != (rod_L1ID & 0x7))) {
354 bsErr->add_l1id_error(Index, D_L1ID);
355 l1id_errors++;
356 }
357
358 /*
359 * We need to account for the fact that we EXPECT the BCIDs
360 * to be off by 12 for the first 7*16 bunch crossing due to
361 * the way our timing works. ugh!
362 */
363 uint32_t expected_BCID;
364 if (rod_BCID < 7 * 16) {
365 expected_BCID = (rod_BCID + 12) & 0xf;
366 } else {
367 expected_BCID = rod_BCID & 0xf;
368 }
369 if (m_lookAtBcidErrors && (D_BCID != expected_BCID)) {
370 bsErr->add_bcid_error(Index, D_BCID);
371 bcid_errors++;
372 }
373 } else if (m_lookAtMissingErrors) {
374 bsErr->add_missing_error(Index);
375 missing_errors++;
376 }
377 } // end of non-zero status check
378 }
379
380 i++;
381 } // End of loop over status words
382 } // End of if on m_recordBSErrors
383
384 uint32_t errorWord = 0;
385
386 errorWord = l1id_errors;
387 errorWord |= (bcid_errors << 7);
388 errorWord |= (missing_errors << 14);
389 errorWord |= (error_errors << 21);
390 if (sid_errors > 0xf)
391 sid_errors = 0xf;
392 errorWord |= ((static_cast<uint32_t>(sid_errors) & 0xf)
393 << 28); // Only report first 15
394
395 if (errorWord) {
396 sc = StatusCode::RECOVERABLE;
397 }
398 }
399 return sc;
400}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
IndexedConstituentUserInfo::Index Index
StatusCode int_fillExpanded(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, TRT_RDO_Container *rodIdc, DataPool< TRT_LoLumRawData > *dataItemsPool, const std::vector< IdentifierHash > *vecHash=0) const
private methods
std::atomic< int > m_err_count_fillCollection
StatusCode update(const EventContext &ctx) const
std::vector< CxxUtils::CachedUniquePtr< t_CompressTable > > m_CompressionTables
StatusCode int_fillMinimalCompress(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, TRT_RDO_Container *rdoIdo, DataPool< TRT_LoLumRawData > *dataItemsPool, const std::vector< IdentifierHash > *vecHash=0) const
StatusCode int_fillFullCompress(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, TRT_RDO_Container *rdoIdo, DataPool< TRT_LoLumRawData > *dataItemsPool, const t_CompressTable &Ctable, const std::vector< IdentifierHash > *vecHash=0) const
::StatusCode StatusCode
StatusCode definition for legacy code.
const DataType * PointerType
Definition RawEvent.h:25
setEventNumber uint32_t

◆ finalize()

StatusCode TRT_RodDecoder::finalize ( )
overridevirtual

finalize

Definition at line 154 of file TRT_RodDecoder.cxx.

154 {
155
156 ATH_MSG_VERBOSE("in TRT_RodDecoder::finalize");
157 if (m_skip > 0) {
158 ATH_MSG_INFO("Number of TRT RDOs created: " << m_Nrdos << " hashes: accept "
159 << m_accept << " skipped "
160 << m_skip);
161 } else {
162 ATH_MSG_INFO("Number of TRT RDOs created: " << m_Nrdos);
163 }
164
165 return StatusCode::SUCCESS;
166}
#define ATH_MSG_VERBOSE(x)
std::atomic< unsigned int > m_skip
std::atomic< unsigned int > m_accept

◆ initialize()

StatusCode TRT_RodDecoder::initialize ( )
overridevirtual

initialize

Definition at line 80 of file TRT_RodDecoder.cxx.

80 {
81 ATH_MSG_DEBUG(" initialize ");
82
83 ATH_CHECK(AlgTool::initialize());
84
86 for (std::atomic<EventContext::ContextEvt_t>& evt : m_lastPrint) {
87 evt = EventContext::INVALID_CONTEXT_EVT;
88 }
89
90 /*
91 * Retrieve id mapping
92 */
93 ATH_CHECK(m_CablingSvc.retrieve());
94 ATH_MSG_INFO("Retrieved tool " << m_CablingSvc);
95
96 ATH_CHECK(detStore()->retrieve(m_trt_id, "TRT_ID"));
97 m_straw_layer_context = m_trt_id->straw_layer_context();
98
99 /*
100 * Show Look At Me's
101 */
102 ATH_MSG_INFO("Look at Sid Errors : " << m_lookAtSidErrors);
103 ATH_MSG_INFO("Look at Error Errors : " << m_lookAtErrorErrors);
104 ATH_MSG_INFO("Look at L1ID Errors : " << m_lookAtL1idErrors);
105 ATH_MSG_INFO("Look at BCID Errors : " << m_lookAtBcidErrors);
106 ATH_MSG_INFO("Look at Missing Errors: " << m_lookAtMissingErrors);
107
108 // m_loadCompressTableDB is set to (globalflags.DataSource()!='geant4') in JO
110 ATH_CHECK(m_CompressKey.initialize());
111 } else {
112 m_eventTypeIsSim = true;
113 }
114
116 if (m_LoadCompressTableVersions.empty()) {
117 m_LoadCompressTableVersions.push_back(4);
118 }
119
120 std::vector<int>::iterator it;
121
122 for (it = m_LoadCompressTableVersions.begin();
123 it < m_LoadCompressTableVersions.end(); ++it) {
124 if ((*it < 4) || (*it > m_maxCompressionVersion)) {
125 ATH_MSG_INFO("Not reading bad Compress Table Version: " << *it);
126 } else {
127 std::ostringstream ssVersion;
128 ssVersion << *it;
129 std::string compressTableFile =
130 "Compress_Table-" + ssVersion.str() + ".dat";
131
132 ATH_MSG_INFO("Reading Compress Table: " << compressTableFile);
133
134 ATH_CHECK(ReadCompressTableFile(compressTableFile));
135 }
136 }
137 }
138
139 if (m_forceRodVersion > 0) {
140 ATH_MSG_WARNING("****************************");
141 ATH_MSG_WARNING("****************************");
142 ATH_MSG_WARNING("* Forcing ROD Version to " << m_forceRodVersion << " *");
143 ATH_MSG_WARNING("****************************");
144 ATH_MSG_WARNING("****************************");
145 }
146
147 return StatusCode::SUCCESS;
148}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
SG::ReadCondHandleKey< CondAttrListCollection > m_CompressKey
StatusCode ReadCompressTableFile(const std::string &TableFilename)
IdContext m_straw_layer_context
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ int_fillExpanded()

StatusCode TRT_RodDecoder::int_fillExpanded ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * robFrag,
TRT_RDO_Container * rodIdc,
DataPool< TRT_LoLumRawData > * dataItemsPool,
const std::vector< IdentifierHash > * vecHash = 0 ) const
private

private methods

Definition at line 417 of file TRT_RodDecoder.cxx.

420 {
421 // get the ROBid
422 uint32_t robid = robFrag->rod_source_id();
423
424 // get the ROD version. It could be used to decode the data in one
425 // way or another
426 // eformat::helper::Version rodVersion(robFrag->rod_version());
427 // const uint16_t rodMinorVersion= rodVersion.minor();
428
429#ifdef TRT_BSC_DEBUG
430 ATH_MSG_DEBUG("fillCollections for " << MSG::hex << robid << MSG::dec);
431#endif
432
433 uint32_t word;
435 Identifier idStraw;
436 IdentifierHash idHash, skipHash = 0xffffffff, lastHash = 0xffffffff;
437 const Identifier NULLId(0);
438
439 // get the data of the fragment
441 robFrag->rod_data(vint);
442
443 std::unordered_map<IdentifierHash, std::unique_ptr<TRT_RDO_Collection> >
444 colls;
445
446 // loop over the data in the fragment
447 unsigned int i;
448 uint32_t v_size = robFrag->rod_ndata();
449 int bufferOffset = -1;
450 for (i = 0; i < v_size; i++) {
451 // increment offest
452 bufferOffset++;
453
454 // get the raw data bit word
455 word = vint[i];
456 // mask it
457 digit = word & 0x07ffffff; // We only use 27 bits
458 if (!digit)
459 continue; // Empty Straw
460
461#ifdef TRT_BSC_DEBUG
462 ATH_MSG_VERBOSE((hex) << robid << " " << bufferOffset << " " << word << " "
463 << idHash << (dec) << " "
464 << m_trt_id->print_to_string(idStraw))
465#endif
466
467 // Make an Identifier for the RDO and get the IdHash
468 idStraw = m_CablingSvc->getIdentifier((eformat::SubDetector)0 /*unused*/,
469 robid, bufferOffset, idHash);
470
471 if (NULLId == idStraw) {
472#ifdef TRT_BSC_DEBUG
473 ATH_MSG_DEBUG("Null Identifier for bufferOffset "
474 << bufferOffset << " word " << MSG::hex << word << MSG::dec)
475#endif
476 continue;
477 }
478
479#ifdef TRT_BSC_DEBUG
480 ATH_MSG_DEBUG(" Collection ID = " << idHash << " Straw ID = "
481 << m_trt_id->show_to_string(idStraw));
482#endif
483
484 // this option is for the trigger, if there is a vecHash* given, test it !
485 if (vecHash) {
486 if (idHash == skipHash) {
487#ifdef TRT_BSC_DEBUG
488 ATH_MSG_DEBUG("Collection for Hash not to be decoded, skip");
489#endif
490 continue;
491 } else if (idHash != lastHash) {
492#ifdef TRT_BSC_DEBUG
493 ATH_MSG_DEBUG("New hash, see if we should decode it");
494#endif
495 lastHash = idHash;
496 // maybe the new hash is not in the list, so test it
497 std::vector<IdentifierHash>::const_iterator p =
498 find(vecHash->begin(), vecHash->end(), idHash);
499 if (p == vecHash->end()) {
500#ifdef TRT_BSC_DEBUG
501 ATH_MSG_DEBUG("Collection for Hash not to be decoded, skip");
502#endif
503 // remember this one, so that we do not find(...) forever
504 skipHash = idHash;
505 continue;
506 }
507 }
508 } else {
509 if (idHash == skipHash) {
510 ++m_skip;
511#ifdef TRT_BSC_DEBUG
512 ATH_MSG_DEBUG("Collection for Hash not to be decoded, skip");
513#endif
514 continue;
515 }
516 ++m_accept;
517 }
518 // Skip if this collection has already been done.
519 if (rdoIdc->indexFindPtr(idHash)) {
520 continue;
521 }
522
523 // get the collection
524 std::unique_ptr<TRT_RDO_Collection>& theColl = colls[idHash];
525
526 // Check if the Collection is already created.
527 if (!theColl) {
528#ifdef TRT_BSC_DEBUG
529 ATH_MSG_DEBUG(" Collection ID = " << idHash
530 << " does not exist, create it ");
531#endif
532 // create new collection
533 theColl = std::make_unique<TRT_RDO_Collection>(idHash);
534 if (dataItemsPool) {
535 // If we use pool then the pool will own the elements
536 theColl->clear(SG::VIEW_ELEMENTS);
537 }
538 // get identifier from the hash, this is not nice
539 Identifier ident;
540 m_trt_id->get_id(idHash, ident, &m_straw_layer_context);
541 // get the Identifier to be nice to downstream clients
542 theColl->setIdentifier(ident);
543 }
544
545 // Now the Collection is there for sure. Create RDO and push it
546 TRT_LoLumRawData* rdo = nullptr;
547 if (!dataItemsPool) {
548 rdo = new TRT_LoLumRawData(idStraw, digit);
549 } else {
550 rdo = dataItemsPool->nextElementPtr();
551 (*rdo) = TRT_LoLumRawData(idStraw, digit);
552 }
553
554 // add the RDO
555 theColl->push_back(rdo);
556
557 } // End of loop over all words in ROD
558
559 // Some workflows may require RDOs to be sorted
560 if (m_sortCollections) {
561 ATH_MSG_DEBUG( "Sorting the RDOs..." );
562 for (auto &[id, coll] : colls) {
563 std::stable_sort(coll->begin(), coll->end(), [](const TRT_RDORawData* a, const TRT_RDORawData* b) {
564 return a->identify() < b->identify();
565 });
566 }
567 }
568
569 // add collections into IDC
570 for (auto& p : colls) {
571 ATH_CHECK(rdoIdc->addOrDelete(std::move(p.second), p.first));
572 }
573
574 return StatusCode::SUCCESS;
575}
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
TList * a
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
@ ident
Definition HitInfo.h:77
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.

◆ int_fillFullCompress()

StatusCode TRT_RodDecoder::int_fillFullCompress ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * robFrag,
TRT_RDO_Container * rdoIdo,
DataPool< TRT_LoLumRawData > * dataItemsPool,
const t_CompressTable & Ctable,
const std::vector< IdentifierHash > * vecHash = 0 ) const
private

Definition at line 830 of file TRT_RodDecoder.cxx.

833 {
834 int phase;
835 for (phase = 0; phase < 2; phase++) {
836
837 uint32_t robid = robFrag->rod_source_id();
838
839 // get the ROD version. It could be used to decode the data in one
840 // way or another
841 // eformat::helper::Version rodVersion(m_robFrag->rod_version());
842 // const uint16_t rodMinorVersion= rodVersion.minor();
843
844#ifdef TRT_BSC_DEBUG
845 ATH_MSG_DEBUG("fillCollection3 for " << MSG::hex << robid << MSG::dec);
846#endif
847
848 uint32_t word;
850 Identifier idStraw;
851 IdentifierHash idHash, skipHash = 0xffffffff, lastHash = 0xffffffff;
852 const Identifier NULLId(0);
853
854 // get the data of the fragment
856 robFrag->rod_data(vint);
857
858 std::unordered_map<IdentifierHash, std::unique_ptr<TRT_RDO_Collection> >
859 colls;
860
861 int bit = 0;
862 int v, l;
863 int i;
864
865 // loop over the data in the fragment and decode the bits
866 unsigned int in_ptr = 0;
867 unsigned int out_ptr = 0;
868 int bufferOffset = -1;
869 uint32_t v_size = robFrag->rod_ndata();
870
871 // ATH_MSG_WARNING( "vint[" << in_ptr << "] = " << MSG::hex << vint[in_ptr]
872 // << MSG::dec );
873
874 while ((in_ptr < v_size) && (out_ptr < 1920)) // XXX -- avoid HardCode!
875 {
876 // increment buffer offset
877 bufferOffset++;
878 out_ptr++;
879
880 // get the next word from the bits
881 word = 0;
882 v = (vint[in_ptr] >> bit) & 0x1;
883 bit++;
884 if (bit > 31) {
885 in_ptr++;
886 bit = 0;
887 // ATH_MSG_WARNING( "vint[" << in_ptr << "] = " << MSG::hex <<
888 // vint[in_ptr] << MSG::dec );
889 }
890 l = 1;
891
892 // ATH_MSG_INFO( "l, firstcode, v " << l << " "
893 // << MSG::hex << Ctable.m_firstcode[l] << " " << v <<
894 // MSG::dec );
895
896 while (v < Ctable.m_firstcode[l]) {
897 v = 2 * v + ((vint[in_ptr] >> bit) & 0x1);
898
899 bit++;
900 if (bit > 31) {
901 in_ptr++;
902 bit = 0;
903 // ATH_MSG_WARNING( "vint[" << in_ptr << "] = " << MSG::hex <<
904 // vint[in_ptr] << MSG::dec );
905 }
906
907 l++;
908
909 // ATH_MSG_INFO( "l, firstcode, v " << l << " "
910 // << MSG::hex << Ctable.m_firstcode[l] << " " << v <<
911 // MSG::dec );
912 }
913
914 int idx = Ctable.m_lengths_integral[l] + (v - Ctable.m_firstcode[l]);
915
916 // ATH_MSG_INFO ( "lengths_int, idx, syms " <<
917 // Ctable.m_lengths_integral[l] << " " << idx << " " << MSG::hex
918 //<< idx << " " << Ctable.m_syms[idx] << MSG::dec );
919
920 if (idx <= Ctable.m_Nsymbols)
921 word = Ctable.m_syms[idx];
922 else {
924 ATH_MSG_WARNING("Invalid ByteStream, ROD ID = " << MSG::hex << robid
925 << MSG::dec);
927 } else if (100 == m_err_count_int_fillFullCompress) {
928 ATH_MSG_WARNING("Too many Invalid ByteStream messages "
929 << "Turning message off.");
931 }
932
933 return StatusCode::RECOVERABLE;
934 }
935
936 /*
937 * Handle case of escaped literal
938 */
939 if (word == m_escape_marker) {
940 word = 0;
941 for (i = 0; i < 27; i++) {
942 word = word | (((vint[in_ptr] >> bit) & 0x1) << i);
943 bit++;
944 if (bit > 31) {
945 in_ptr++;
946 bit = 0;
947 }
948 }
949 }
950
951 if (1 == phase) {
952
953 if (word) {
954
955 // get data word
956 digit = word; // We only use 27 bits
957
958#ifdef TRT_BSC_DEBUG
959 ATH_MSG_VERBOSE((hex) << robid << " " << bufferOffset << " " << word
960 << " " << idHash << (dec) << " "
961 << m_trt_id->print_to_string(idStraw));
962#endif
963
964 // Make an Identifier for the RDO and get the IdHash
965 idStraw = m_CablingSvc->getIdentifier(
966 (eformat::SubDetector)0 /*unused*/, robid, bufferOffset, idHash);
967
968 if (NULLId == idStraw) {
969#ifdef TRT_BSC_DEBUG
970 ATH_MSG_DEBUG("Null Identifier for bufferOffset " << bufferOffset);
971#endif
972 continue;
973 }
974
975#ifdef TRT_BSC_DEBUG
976 ATH_MSG_DEBUG(" Collection ID = "
977 << idHash
978 << " Straw ID = " << m_trt_id->show_to_string(idStraw));
979#endif
980
981 // this option is for the trigger, if there is a vecHash* given, test
982 // it !
983 if (vecHash) {
984 if (idHash == skipHash) {
985#ifdef TRT_BSC_DEBUG
986 ATH_MSG_DEBUG("Collection for Hash not to be decoded, skip");
987#endif
988 continue;
989 } else if (idHash != lastHash) {
990#ifdef TRT_BSC_DEBUG
991 ATH_MSG_DEBUG("New hash, see if we should decode it");
992#endif
993 lastHash = idHash;
994 // maybe the new hash is not in the list, so test it
995 std::vector<IdentifierHash>::const_iterator p =
996 find(vecHash->begin(), vecHash->end(), idHash);
997 if (p == vecHash->end()) {
998#ifdef TRT_BSC_DEBUG
999 ATH_MSG_DEBUG("Collection for Hash not to be decoded, skip");
1000#endif
1001 // remember this one, so that we do not find(...) forever
1002 skipHash = idHash;
1003 continue;
1004 }
1005 }
1006 } else {
1007 if (idHash == skipHash) {
1008 ++m_skip;
1009#ifdef TRT_BSC_DEBUG
1010 ATH_MSG_DEBUG("Collection for Hash not to be decoded, skip");
1011#endif
1012 continue;
1013 }
1014 ++m_accept;
1015 }
1016
1017 // Skip if this collection has already been done.
1018 if (rdoIdc->indexFindPtr(idHash)) {
1019 continue;
1020 }
1021
1022 // get the collection
1023 std::unique_ptr<TRT_RDO_Collection>& theColl = colls[idHash];
1024
1025 // Check if the Collection is already created.
1026 if (!theColl) {
1027#ifdef TRT_BSC_DEBUG
1028 ATH_MSG_DEBUG(" Collection ID = " << idHash
1029 << " does not exist, create it ");
1030#endif
1031 // create new collection
1032 theColl = std::make_unique<TRT_RDO_Collection>(idHash);
1033 if (dataItemsPool) {
1034 // If we use pool then the pool will own the elements
1035 theColl->clear(SG::VIEW_ELEMENTS);
1036 }
1037 // get identifier from the hash, this is not nice
1038 Identifier ident;
1039 m_trt_id->get_id(idHash, ident, &m_straw_layer_context);
1040 // get the Identifier to be nice to downstream clients
1041 theColl->setIdentifier(ident);
1042 }
1043 // Now the Collection is there for sure. Create RDO and push it
1044 // into Collection.
1045 TRT_LoLumRawData* rdo = nullptr;
1046 if (!dataItemsPool) {
1047 rdo = new TRT_LoLumRawData(idStraw, digit);
1048 } else {
1049 rdo = dataItemsPool->nextElementPtr();
1050 (*rdo) = TRT_LoLumRawData(idStraw, digit);
1051 }
1052 m_Nrdos++;
1053
1054 // get the collection
1055 // add the RDO
1056 theColl->push_back(rdo);
1057 }
1058 } // if phase == 1
1059 } // End of loop over all words in ROD
1060
1061 // Some workflows may require RDOs to be sorted
1062 if (m_sortCollections) {
1063 ATH_MSG_DEBUG( "Sorting the RDOs..." );
1064 for (auto &[id, coll] : colls) {
1065 std::stable_sort(coll->begin(), coll->end(), [](const TRT_RDORawData* a, const TRT_RDORawData* b) {
1066 return a->identify() < b->identify();
1067 });
1068 }
1069 }
1070
1071 // add collections into IDC
1072 for (auto& p : colls) {
1073 ATH_CHECK(rdoIdc->addOrDelete(std::move(p.second), p.first));
1074 }
1075
1076 if ((out_ptr != 1920) || ((in_ptr == v_size) && bit != 0) ||
1077 ((in_ptr == (v_size - 1)) && (bit == 0)) || (in_ptr < (v_size - 1))) {
1078 ATH_MSG_WARNING("Decode error: "
1079 << "L1ID = " << MSG::hex << robFrag->rod_lvl1_id()
1080 << " ROD = " << robFrag->rod_source_id() << MSG::dec
1081 << " bit = " << bit << " " << in_ptr << " / " << v_size
1082 << " : " << out_ptr << " / 1920");
1083 return StatusCode::RECOVERABLE;
1084 }
1085 }
1086
1087 return StatusCode::SUCCESS;
1088}
std::atomic< int > m_err_count_int_fillFullCompress
l
Printing final latex table to .tex output file.

◆ int_fillMinimalCompress()

StatusCode TRT_RodDecoder::int_fillMinimalCompress ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * robFrag,
TRT_RDO_Container * rdoIdo,
DataPool< TRT_LoLumRawData > * dataItemsPool,
const std::vector< IdentifierHash > * vecHash = 0 ) const
private

Definition at line 601 of file TRT_RodDecoder.cxx.

604 {
605 uint32_t robid = robFrag->rod_source_id();
606
607 // get the ROD version. It could be used to decode the data in one
608 // way or another
609 // eformat::helper::Version rodVersion(m_robFrag->rod_version());
610 // const uint16_t rodMinorVersion= rodVersion.minor();
611
612#ifdef TRT_BSC_DEBUG
613 ATH_MSG_DEBUG("fillCollection3 for " << MSG::hex << robid << MSG::dec);
614#endif
615
616 uint32_t word;
618 Identifier idStraw;
619 IdentifierHash idHash, skipHash = 0xffffffff, lastHash = 0xffffffff;
620 const Identifier NULLId(0);
621
622 // get the data of the fragment
624 robFrag->rod_data(vint);
625
626 std::unordered_map<IdentifierHash, std::unique_ptr<TRT_RDO_Collection> >
627 colls;
628
629 int bit = 0;
630 int v;
631
632 // loop over the data in the fragment and decode the bits
633 unsigned int in_ptr = 0;
634 unsigned int out_ptr = 0;
635 int bufferOffset = -1;
636 uint32_t v_size = robFrag->rod_ndata();
637
638 // ATH_MSG_WARNING( "vint[" << in_ptr << "] = " << MSG::hex << vint[in_ptr]
639 // << MSG::dec );
640
641 while ((in_ptr < v_size) && (out_ptr < 1920)) // XXX -- avoid HardCode!
642 {
643 // increment buffer offset
644 bufferOffset++;
645 out_ptr++;
646
647 // get the next word from the bits
648 word = 0;
649 v = (vint[in_ptr] >> bit) & 0x1;
650 bit++;
651 if (bit > 31) {
652 in_ptr++;
653 bit = 0;
654 // ATH_MSG_WARNING( "vint[" << in_ptr << "] = " << MSG::hex <<
655 // vint[in_ptr] << MSG::dec );
656 }
657 if (v)
658 continue;
659 else {
660 for (int i = 0; i < 4; i++) { // Look for 4 more 0's
661 v = (vint[in_ptr] >> bit) & 0x1;
662 bit++;
663 if (bit > 31) {
664 in_ptr++;
665 bit = 0;
666 // ATH_MSG_WARNING( "vint[" << in_ptr << "] = " << MSG::hex <<
667 // vint[in_ptr] << MSG::dec );
668 }
669 if (v) {
671 ATH_MSG_WARNING("Invalid ByteStream, ROD ID = " << MSG::hex << robid
672 << MSG::dec);
674 } else if (100 == m_err_count_int_fillMinimalCompress) {
675 ATH_MSG_WARNING("Too many Invalid ByteStream messages "
676 << "Turning message off.");
678 }
679 return StatusCode::RECOVERABLE;
680 }
681 }
682 for (int i = 0; i < 27; i++) {
683 word = word | (((vint[in_ptr] >> bit) & 0x1) << i);
684 bit++;
685 if (bit > 31) {
686 in_ptr++;
687 bit = 0;
688 // ATH_MSG_WARNING( "vint[" << in_ptr << "] = " << MSG::hex <<
689 // vint[in_ptr] << MSG::dec );
690 }
691 }
692 }
693
694 // get data word
695 digit = word; // We only use 27 bits
696
697#ifdef TRT_BSC_DEBUG
698 ATH_MSG_VERBOSE((hex) << robid << " " << bufferOffset << " " << word << " "
699 << idHash << (dec) << " "
700 << m_trt_id->print_to_string(idStraw));
701#endif
702
703 // Make an Identifier for the RDO and get the IdHash
704 idStraw = m_CablingSvc->getIdentifier((eformat::SubDetector)0 /*unused*/,
705 robid, bufferOffset, idHash);
706
707 if (NULLId == idStraw) {
708#ifdef TRT_BSC_DEBUG
709 ATH_MSG_DEBUG("Null Identifier for bufferOffset " << bufferOffset);
710#endif
711 continue;
712 }
713
714#ifdef TRT_BSC_DEBUG
715 ATH_MSG_DEBUG(" Collection ID = " << idHash << " Straw ID = "
716 << m_trt_id->show_to_string(idStraw));
717#endif
718
719 // this option is for the trigger, if there is a vecHash* given, test it !
720 if (vecHash) {
721 if (idHash == skipHash) {
722#ifdef TRT_BSC_DEBUG
723 ATH_MSG_DEBUG("Collection for Hash not to be decoded, skip");
724#endif
725 continue;
726 } else if (idHash != lastHash) {
727#ifdef TRT_BSC_DEBUG
728 ATH_MSG_DEBUG("New hash, see if we should decode it");
729#endif
730 lastHash = idHash;
731 // maybe the new hash is not in the list, so test it
732 std::vector<IdentifierHash>::const_iterator p =
733 find(vecHash->begin(), vecHash->end(), idHash);
734 if (p == vecHash->end()) {
735#ifdef TRT_BSC_DEBUG
736 ATH_MSG_DEBUG("Collection for Hash not to be decoded, skip");
737#endif
738 // remember this one, so that we do not find(...) forever
739 skipHash = idHash;
740 continue;
741 }
742 }
743 }
744
745 // Skip if this collection has already been done.
746 if (rdoIdc->indexFindPtr(idHash)) {
747 continue;
748 }
749
750 // get the collection
751 std::unique_ptr<TRT_RDO_Collection>& theColl = colls[idHash];
752
753 // Check if the Collection is already created.
754 if (!theColl) {
755#ifdef TRT_BSC_DEBUG
756 ATH_MSG_DEBUG(" Collection ID = " << idHash
757 << " does not exist, create it ");
758#endif
759 // create new collection
760 theColl = std::make_unique<TRT_RDO_Collection>(idHash);
761 if (dataItemsPool) {
762 // If we use pool then the pool will own the elements
763 theColl->clear(SG::VIEW_ELEMENTS);
764 }
765 // get identifier from the hash, this is not nice
766 Identifier ident;
767 m_trt_id->get_id(idHash, ident, &m_straw_layer_context);
768 // get the Identifier to be nice to downstream clients
769 theColl->setIdentifier(ident);
770 }
771
772 // Now the Collection is there for sure. Create RDO and push it
773 // into Collection.
774
775 // ATH_MSG_INFO ( "idStraw: " << idStraw
776 // << " digit: " << MSG::hex << digit << MSG::dec );
777 TRT_LoLumRawData* rdo = nullptr;
778 if (!dataItemsPool) {
779 rdo = new TRT_LoLumRawData(idStraw, digit);
780 } else {
781 rdo = dataItemsPool->nextElementPtr();
782 (*rdo) = TRT_LoLumRawData(idStraw, digit);
783 }
784 m_Nrdos++;
785
786 // get the collection
787 // add the RDO
788 theColl->push_back(rdo);
789
790 } // End of loop over all words in ROD
791
792 // Some workflows may require RDOs to be sorted
793 if (m_sortCollections) {
794 ATH_MSG_DEBUG( "Sorting the RDOs..." );
795 for (auto &[id, coll] : colls) {
796 std::stable_sort(coll->begin(), coll->end(), [](const TRT_RDORawData* a, const TRT_RDORawData* b) {
797 return a->identify() < b->identify();
798 });
799 }
800 }
801
802 // add collections into IDC
803 for (auto& p : colls) {
804 ATH_CHECK(rdoIdc->addOrDelete(std::move(p.second), p.first));
805 }
806
807 return StatusCode::SUCCESS;
808}
std::atomic< int > m_err_count_int_fillMinimalCompress

◆ ReadCompressTableDB()

StatusCode TRT_RodDecoder::ReadCompressTableDB ( std::string Tag)
private

◆ ReadCompressTableFile()

StatusCode TRT_RodDecoder::ReadCompressTableFile ( const std::string & TableFilename)
private

Definition at line 1093 of file TRT_RodDecoder.cxx.

1097 {
1099 "Reading Compression Table from File is not supported anymore!");
1100
1101 return StatusCode::FAILURE;
1102
1103#ifdef TRT_READCOMPTABLE_FILE
1104
1105 auto t_CompressTable Ctable = std::make_unique<t_CompressTable>();
1106
1107 ATH_MSG_INFO("Reading Compress Table File: " << TableFilename);
1108
1109 std::string file = PathResolver::find_file(TableFilename, "DATAPATH");
1110 std::ifstream inFile(file.c_str());
1111
1112 if (!inFile.is_open()) {
1113 ATH_MSG_FATAL("Could not open Compression Table File " << TableFilename);
1114 return StatusCode::FAILURE;
1115 }
1116
1117#define MAXLINE 1024
1118
1119 char line[MAXLINE];
1120 char* tok;
1121
1122 int* lengths = 0; // Array of codeword lengths
1123 int* codewords = 0; // Array of codewords
1124
1125 Ctable->m_Nsymbols = 0;
1126
1127 while (!inFile.eof()) {
1128 inFile.getline(line, MAXLINE);
1129
1130 tok = strtok(line, " \t\n<");
1131 if (!tok)
1132 continue;
1133
1134 /*************************************/
1135 if (!strncmp(tok, "Version", 7)) {
1136 tok = strtok(NULL, " \t\n");
1137 Ctable->m_TableVersion = atoi(tok);
1138
1139 ATH_MSG_DEBUG("Table Version = " << Ctable->m_TableVersion);
1140
1141 tok = strtok(NULL, " \t\n");
1142 if (!tok) {
1143 inFile.getline(line, MAXLINE);
1144
1145 tok = strtok(line, " \t\n");
1146 }
1147
1148 if (strncmp(tok, ">", 1)) {
1149 ATH_MSG_WARNING("Invalid file format in Version!");
1150 inFile.close();
1151
1152 if (lengths)
1153 delete[] lengths;
1154
1155 if (codewords)
1156 delete[] codewords;
1157
1158 return StatusCode::FAILURE;
1159 }
1160
1161 Ctable->m_syms = std::make_unique<unsigned int[]>(Ctable->m_Nsymbols);
1162
1163 if (lengths)
1164 delete[] lengths;
1165 lengths = new int[Ctable->m_Nsymbols];
1166
1167 if (codewords)
1168 delete[] codewords;
1169 codewords = new int[Ctable->m_Nsymbols];
1170 }
1171
1172 /*************************************/
1173 if (!strncmp(tok, "Nsymbols", 8)) {
1174 tok = strtok(NULL, " \t\n");
1175 Ctable->m_Nsymbols = atoi(tok);
1176
1177 ATH_MSG_DEBUG("Nsymbols = " << Ctable->m_Nsymbols);
1178
1179 tok = strtok(NULL, " \t\n");
1180 if (!tok) {
1181 inFile.getline(line, MAXLINE);
1182
1183 tok = strtok(line, " \t\n");
1184 }
1185
1186 if (strncmp(tok, ">", 1)) {
1187 ATH_MSG_WARNING("Invalid file format in Nsymbols!");
1188 inFile.close();
1189
1190 if (lengths)
1191 delete[] lengths;
1192
1193 if (codewords)
1194 delete[] codewords;
1195
1196 return StatusCode::FAILURE;
1197 }
1198
1199 Ctable->m_syms = std::make_unique<unsigned int[]>(Ctable->m_Nsymbols);
1200
1201 if (lengths)
1202 delete[] lengths;
1203 lengths = new int[Ctable->m_Nsymbols];
1204
1205 if (codewords)
1206 delete[] codewords;
1207 codewords = new int[Ctable->m_Nsymbols];
1208 }
1209
1210 /*************************************/
1211 if (!strncmp(tok, "syms", 4)) {
1212
1213 if (!Ctable->m_syms) {
1214 ATH_MSG_WARNING("Invalid file format Nsymbols must come first!");
1215 inFile.close();
1216
1217 if (lengths)
1218 delete[] lengths;
1219
1220 if (codewords)
1221 delete[] codewords;
1222
1223 return StatusCode::FAILURE;
1224 }
1225
1226 int i = 0;
1227
1228 tok = strtok(NULL, " \t\n");
1229 while (i < Ctable->m_Nsymbols) {
1230 while ((tok) && (i < Ctable->m_Nsymbols)) {
1231 Ctable->m_syms[i++] = atoi(tok);
1232 tok = strtok(NULL, " \t\n");
1233 }
1234
1235 if (!tok) {
1236 inFile.getline(line, MAXLINE);
1237 tok = strtok(line, " \t\n");
1238 }
1239 }
1240
1241 if (strncmp(tok, ">", 1)) {
1242 ATH_MSG_WARNING("Invalid file format in syms!");
1243 inFile.close();
1244
1245 if (lengths)
1246 delete[] lengths;
1247
1248 if (codewords)
1249 delete[] codewords;
1250
1251 return StatusCode::FAILURE;
1252 }
1253 }
1254
1255 /*************************************/
1256 if (!strncmp(tok, "codewords", 9)) {
1257 if (!codewords) {
1258 ATH_MSG_WARNING("Invalid file format Nsymbols must come first!");
1259 inFile.close();
1260
1261 if (lengths)
1262 delete[] lengths;
1263
1264 return StatusCode::FAILURE;
1265 }
1266
1267 int i = 0;
1268
1269 tok = strtok(NULL, " \t\n");
1270 while (i < Ctable->m_Nsymbols) {
1271 while ((tok) && (i < Ctable->m_Nsymbols)) {
1272 codewords[i++] = atoi(tok);
1273 tok = strtok(NULL, " \t\n");
1274 }
1275
1276 if (!tok) {
1277 inFile.getline(line, MAXLINE);
1278 tok = strtok(line, " \t\n");
1279 }
1280 }
1281
1282 if (strncmp(tok, ">", 1)) {
1283 ATH_MSG_WARNING("Invalid file format in codewords!");
1284 inFile.close();
1285
1286 if (lengths)
1287 delete[] lengths;
1288
1289 if (codewords)
1290 delete[] codewords;
1291
1292 return StatusCode::FAILURE;
1293 }
1294 }
1295
1296 /*************************************/
1297 if (!strncmp(tok, "firstcode", 9)) {
1298 int i = 1;
1299
1300 tok = strtok(NULL, " \t\n");
1301 while (i < 33) {
1302 while ((tok) && (i < 33)) {
1303 Ctable->m_firstcode[i++] = atoi(tok);
1304 tok = strtok(NULL, " \t\n");
1305 }
1306
1307 if (!tok) {
1308 inFile.getline(line, MAXLINE);
1309 tok = strtok(line, " \t\n");
1310 }
1311 }
1312
1313 if (strncmp(tok, ">", 1)) {
1314 ATH_MSG_WARNING("Invalid file format in firstcode");
1315 inFile.close();
1316
1317 if (lengths)
1318 delete[] lengths;
1319
1320 if (codewords)
1321 delete[] codewords;
1322
1323 return StatusCode::FAILURE;
1324 }
1325 }
1326
1327 /*************************************/
1328 if (!strncmp(tok, "lengths_integral", 16)) {
1329 int i = 1;
1330
1331 tok = strtok(NULL, " \t\n");
1332 while (i < 33) {
1333 while ((tok) && (i < 33)) {
1334 Ctable->m_lengths_integral[i++] = atoi(tok);
1335 tok = strtok(NULL, " \t\n");
1336 }
1337
1338 if (!tok) {
1339 inFile.getline(line, MAXLINE);
1340 tok = strtok(line, " \t\n");
1341 }
1342 }
1343
1344 if (strncmp(tok, ">", 1)) {
1345 ATH_MSG_WARNING("Invalid file format in lengths_integral!");
1346 inFile.close();
1347
1348 if (lengths)
1349 delete[] lengths;
1350
1351 if (codewords)
1352 delete[] codewords;
1353
1354 return StatusCode::FAILURE;
1355 }
1356 }
1357
1358 /*************************************/
1359 if (!strncmp(tok, "lengths", 7)) {
1360 if (!lengths) {
1361 ATH_MSG_WARNING("Invalid file format Nsymbols must come first!");
1362 inFile.close();
1363
1364 if (codewords)
1365 delete[] codewords;
1366
1367 return StatusCode::FAILURE;
1368 }
1369
1370 int i = 0;
1371
1372 tok = strtok(NULL, " \t\n");
1373 while (i < Ctable->m_Nsymbols) {
1374 while ((tok) && (i < Ctable->m_Nsymbols)) {
1375 lengths[i++] = atoi(tok);
1376 tok = strtok(NULL, " \t\n");
1377 }
1378
1379 if (!tok) {
1380 inFile.getline(line, MAXLINE);
1381 tok = strtok(line, " \t\n");
1382 }
1383 }
1384
1385 if (strncmp(tok, ">", 1)) {
1386 ATH_MSG_WARNING("Invalid file format in lengths!");
1387 inFile.close();
1388
1389 if (lengths)
1390 delete[] lengths;
1391
1392 if (codewords)
1393 delete[] codewords;
1394
1395 return StatusCode::FAILURE;
1396 }
1397 }
1398 }
1399
1400 inFile.close();
1401
1402 if (!codewords || !lengths) {
1403 ATH_MSG_WARNING("Invalid file format Nsymbols must come first!");
1404
1405 if (lengths)
1406 delete[] lengths;
1407
1408 if (codewords)
1409 delete[] codewords;
1410
1411 return StatusCode::FAILURE;
1412 }
1413
1414 /*
1415 * Recover escape info from the table
1416 */
1417 int i = Ctable->m_Nsymbols - 1;
1418 int escape_length = 0;
1419 // uint32_t escape_codeword; // Set but not used
1420
1421 while ((m_escape_marker != Ctable->m_syms[i]) && (i >= 0))
1422 i--;
1423
1424 if (i < 0) {
1425 ATH_MSG_WARNING("Escape code not found!");
1426
1427 if (lengths)
1428 delete[] lengths;
1429
1430 if (codewords)
1431 delete[] codewords;
1432
1433 return StatusCode::FAILURE;
1434 } else {
1435 // escape_codeword = codewords[i]; // Set but not used
1436 escape_length = lengths[i];
1437
1438 if (escape_length != 5)
1439 ATH_MSG_WARNING("WARNING! Escape code length is " << escape_length
1440 << " rather than 5!");
1441 }
1442
1443#ifdef PRINT_TABLE
1444 for (int j = 0; j < Ctable->m_Nsymbols; j++) {
1445 ATH_MSG_INFO("Table: " << j << " " << lengths[j] << " " << MSG::hex
1446 << codewords[j] << " " << Ctable->m_syms[j]
1447 << std::dec);
1448 }
1449#endif // PRINT_TABLE
1450
1451 if (lengths)
1452 delete[] lengths;
1453
1454 if (codewords)
1455 delete[] codewords;
1456
1457 if (Ctable->m_TableVersion > m_maxCompressionVersion) {
1459 "Invalid Compression Table Version: " << Ctable->m_TableVersion);
1460
1461 return StatusCode::FAILURE;
1462 }
1463
1464 if (m_CompressionTables[Ctable->m_TableVersion]) {
1465 ATH_MSG_WARNING("Table " << Ctable->m_TableVersion
1466 << " already loaded! Not overwriting");
1467 } else {
1468 ATH_MSG_INFO("Loaded Compress Table Version: " << Ctable->m_TableVersion);
1469 m_CompressionTables[Ctable->m_TableVersion].store(std::move(Ctable))
1470 }
1471
1472 return StatusCode::SUCCESS;
1473
1474#endif /* TRT_READCOMPTABLE_FILE */
1475}
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
str inFile
Definition makeTOC.py:5
TFile * file

◆ update()

StatusCode TRT_RodDecoder::update ( const EventContext & ctx) const
private

Definition at line 1480 of file TRT_RodDecoder.cxx.

1480 {
1481 /*
1482 * function to update compression table when condDB data changes:
1483 */
1484
1485 SG::ReadCondHandle<CondAttrListCollection> rst(m_CompressKey, ctx);
1486 const CondAttrListCollection* catrlist = *rst;
1487 if (!catrlist) {
1488 ATH_MSG_ERROR("No Compression Table found in condDB ");
1489 return StatusCode::FAILURE;
1490 }
1491
1493 CondAttrListCollection::const_iterator last_catr(catrlist->end());
1494
1495 while (catrIt != last_catr) {
1496 const coral::AttributeList& atrlist = catrIt->second;
1497
1498 int TableVersion = (atrlist)["Version"].data<cool::Int32>();
1499
1500 if (TableVersion > m_maxCompressionVersion) {
1501 ATH_MSG_WARNING("Invalid Compression Table Version: " << TableVersion);
1502
1503 ++catrIt;
1504
1505 continue;
1506 }
1507
1508 if (m_CompressionTables[TableVersion]) {
1509 ATH_MSG_DEBUG("Table " << TableVersion
1510 << " already loaded! Not overwriting");
1511 ++catrIt;
1512
1513 continue;
1514 }
1515
1516 auto Ctable = std::make_unique<t_CompressTable>();
1517 Ctable->m_TableVersion = TableVersion;
1518 Ctable->m_Nsymbols = (atrlist)["Nsymbols"].data<cool::Int32>();
1519 ATH_MSG_DEBUG("Nsymbols = " << Ctable->m_Nsymbols);
1520
1521 Ctable->m_syms = std::make_unique<unsigned int[]>(Ctable->m_Nsymbols);
1522
1523 const cool::Blob16M& blob = (atrlist)["syms"].data<cool::Blob16M>();
1524
1525 if (blob.size() !=
1526 (unsigned int)(Ctable->m_Nsymbols * sizeof(unsigned int))) {
1527 ATH_MSG_ERROR("Unexpected size of symbol table! ( "
1528 << blob.size() << " != "
1529 << (Ctable->m_Nsymbols * sizeof(unsigned int)) << " )");
1530
1531 return StatusCode::FAILURE;
1532 }
1533
1534 const unsigned char* BlobStart =
1535 static_cast<const unsigned char*>(blob.startingAddress());
1536 int j = 0;
1537 for (int i = 0; (i < blob.size()) && (j < Ctable->m_Nsymbols);
1538 i += sizeof(unsigned int)) {
1539 Ctable->m_syms[j++] = *(reinterpret_cast<const unsigned int*>(BlobStart + i));
1540 }
1541
1542 std::istringstream iss((atrlist)["firstcode"].data<cool::String4k>());
1543 std::string tok;
1544 int i = 1;
1545 while (getline(iss, tok, ' ') && (i < CTABLE_FC_LENGTH)) {
1546 Ctable->m_firstcode[i++] = atoi(tok.c_str());
1547 }
1548
1549 std::istringstream iss2(
1550 (atrlist)["lengths_integral"].data<cool::String4k>());
1551 i = 1;
1552 while (getline(iss2, tok, ' ') && (i < CTABLE_LI_LENGTH)) {
1553 Ctable->m_lengths_integral[i++] = atoi(tok.c_str());
1554 }
1555
1556 int ctable_version = Ctable->m_TableVersion;
1557 ATH_MSG_INFO("Loaded Compress Table Version: " << ctable_version);
1558 m_CompressionTables[ctable_version].set(std::move(Ctable));
1559
1560 ++catrIt;
1561 }
1562
1563 return StatusCode::SUCCESS;
1564}
#define ATH_MSG_ERROR(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
#define CTABLE_FC_LENGTH
#define CTABLE_LI_LENGTH
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator

Member Data Documentation

◆ ATLAS_THREAD_SAFE

SG::SlotSpecificObj<std::atomic<EventContext::ContextEvt_t> > m_lastPrint TRT_RodDecoder::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 166 of file TRT_RodDecoder.h.

◆ m_accept

std::atomic<unsigned int> TRT_RodDecoder::m_accept {}
mutableprivate

Definition at line 169 of file TRT_RodDecoder.h.

169{};

◆ m_CablingSvc

ServiceHandle<ITRT_CablingSvc> TRT_RodDecoder::m_CablingSvc
private

Definition at line 83 of file TRT_RodDecoder.h.

◆ m_CompressionTables

std::vector<CxxUtils::CachedUniquePtr<t_CompressTable> > TRT_RodDecoder::m_CompressionTables
private

Definition at line 132 of file TRT_RodDecoder.h.

◆ m_CompressKey

SG::ReadCondHandleKey<CondAttrListCollection> TRT_RodDecoder::m_CompressKey {this,"keyName","/TRT/Onl/ROD/Compress","in-key"}
private

Definition at line 141 of file TRT_RodDecoder.h.

141{this,"keyName","/TRT/Onl/ROD/Compress","in-key"};

◆ m_err_count_fillCollection

std::atomic<int> TRT_RodDecoder::m_err_count_fillCollection {0}
mutableprivate

Definition at line 136 of file TRT_RodDecoder.h.

136{0};

◆ m_err_count_int_fillFullCompress

std::atomic<int> TRT_RodDecoder::m_err_count_int_fillFullCompress {0}
mutableprivate

Definition at line 138 of file TRT_RodDecoder.h.

138{0};

◆ m_err_count_int_fillMinimalCompress

std::atomic<int> TRT_RodDecoder::m_err_count_int_fillMinimalCompress {0}
mutableprivate

Definition at line 137 of file TRT_RodDecoder.h.

137{0};

◆ m_escape_marker

uint32_t TRT_RodDecoder::m_escape_marker
private

Definition at line 114 of file TRT_RodDecoder.h.

◆ m_eventTypeIsSim

bool TRT_RodDecoder::m_eventTypeIsSim
private

Definition at line 111 of file TRT_RodDecoder.h.

◆ m_forceRodVersion

int TRT_RodDecoder::m_forceRodVersion
private

Definition at line 103 of file TRT_RodDecoder.h.

◆ m_loadCompressTableDB

bool TRT_RodDecoder::m_loadCompressTableDB
private

Definition at line 100 of file TRT_RodDecoder.h.

◆ m_loadCompressTableFile

bool TRT_RodDecoder::m_loadCompressTableFile
private

Definition at line 99 of file TRT_RodDecoder.h.

◆ m_LoadCompressTableVersions

std::vector<int> TRT_RodDecoder::m_LoadCompressTableVersions
private

Definition at line 101 of file TRT_RodDecoder.h.

◆ m_LoLumRawData

BooleanProperty TRT_RodDecoder::m_LoLumRawData
private

Definition at line 109 of file TRT_RodDecoder.h.

◆ m_lookAtBcidErrors

bool TRT_RodDecoder::m_lookAtBcidErrors
private

Definition at line 96 of file TRT_RodDecoder.h.

◆ m_lookAtErrorErrors

bool TRT_RodDecoder::m_lookAtErrorErrors
private

Definition at line 94 of file TRT_RodDecoder.h.

◆ m_lookAtL1idErrors

bool TRT_RodDecoder::m_lookAtL1idErrors
private

Definition at line 95 of file TRT_RodDecoder.h.

◆ m_lookAtMissingErrors

bool TRT_RodDecoder::m_lookAtMissingErrors
private

Definition at line 97 of file TRT_RodDecoder.h.

◆ m_lookAtSidErrors

bool TRT_RodDecoder::m_lookAtSidErrors
private

Definition at line 93 of file TRT_RodDecoder.h.

◆ m_maxCompressionVersion

const int TRT_RodDecoder::m_maxCompressionVersion
private

Definition at line 102 of file TRT_RodDecoder.h.

◆ m_Nrdos

std::atomic<uint32_t> TRT_RodDecoder::m_Nrdos
mutableprivate

Definition at line 134 of file TRT_RodDecoder.h.

◆ m_recordBSErrors

bool TRT_RodDecoder::m_recordBSErrors
private

Definition at line 88 of file TRT_RodDecoder.h.

◆ m_skip

std::atomic<unsigned int> TRT_RodDecoder::m_skip {}
mutableprivate

Definition at line 168 of file TRT_RodDecoder.h.

168{};

◆ m_sortCollections

bool TRT_RodDecoder::m_sortCollections {}
private

Definition at line 116 of file TRT_RodDecoder.h.

116{}; // sort collections by identifiers if required

◆ m_straw_layer_context

IdContext TRT_RodDecoder::m_straw_layer_context
private

Definition at line 106 of file TRT_RodDecoder.h.

◆ m_TB04_RawData

BooleanProperty TRT_RodDecoder::m_TB04_RawData
private

Definition at line 108 of file TRT_RodDecoder.h.

◆ m_trt_id

const TRT_ID* TRT_RodDecoder::m_trt_id
private

Definition at line 105 of file TRT_RodDecoder.h.


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