ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
TRT_RodDecoder Class Reference

#include <TRT_RodDecoder.h>

Inheritance diagram for TRT_RodDecoder:
Collaboration 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 More...
 
virtual ~TRT_RodDecoder ()
 destructor More...
 
virtual StatusCode initialize () override
 initialize More...
 
virtual StatusCode finalize () override
 finalize More...
 
virtual StatusCode fillCollection (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, TRT_RDO_Container *rdoIdc, TRT_BSErrContainer *bserr, DataPool< TRT_LoLumRawData > *dataItemsPool, const std::vector< IdentifierHash > *vecHash=0) const override
 the method to fill the IDC More...
 

Private Member Functions

StatusCode update () 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 More...
 
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
 
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),
40  m_lookAtSidErrors(true),
41  m_lookAtErrorErrors(false),
42  m_lookAtL1idErrors(true),
43  m_lookAtBcidErrors(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 }

◆ ~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 std::vector< IdentifierHash > *  vecHash = 0 
) const
overridevirtual

the method to fill the IDC

Definition at line 179 of file TRT_RodDecoder.cxx.

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

◆ finalize()

StatusCode TRT_RodDecoder::finalize ( )
overridevirtual

finalize

Definition at line 153 of file TRT_RodDecoder.cxx.

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

◆ initialize()

StatusCode TRT_RodDecoder::initialize ( )
overridevirtual

initialize

Definition at line 79 of file TRT_RodDecoder.cxx.

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

◆ 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 416 of file TRT_RodDecoder.cxx.

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

◆ 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 809 of file TRT_RodDecoder.cxx.

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

◆ 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 590 of file TRT_RodDecoder.cxx.

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

◆ ReadCompressTableDB()

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

◆ ReadCompressTableFile()

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

Definition at line 1062 of file TRT_RodDecoder.cxx.

1066  {
1067  ATH_MSG_FATAL(
1068  "Reading Compression Table from File is not supported anymore!");
1069 
1070  return StatusCode::FAILURE;
1071 
1072 #ifdef TRT_READCOMPTABLE_FILE
1073 
1074  auto t_CompressTable Ctable = std::make_unique<t_CompressTable>();
1075 
1076  ATH_MSG_INFO("Reading Compress Table File: " << TableFilename);
1077 
1078  std::string file = PathResolver::find_file(TableFilename, "DATAPATH");
1079  std::ifstream inFile(file.c_str());
1080 
1081  if (!inFile.is_open()) {
1082  ATH_MSG_FATAL("Could not open Compression Table File " << TableFilename);
1083  return StatusCode::FAILURE;
1084  }
1085 
1086 #define MAXLINE 1024
1087 
1088  char line[MAXLINE];
1089  char* tok;
1090 
1091  int* lengths = 0; // Array of codeword lengths
1092  int* codewords = 0; // Array of codewords
1093 
1094  Ctable->m_Nsymbols = 0;
1095 
1096  while (!inFile.eof()) {
1097  inFile.getline(line, MAXLINE);
1098 
1099  tok = strtok(line, " \t\n<");
1100  if (!tok)
1101  continue;
1102 
1103  /*************************************/
1104  if (!strncmp(tok, "Version", 7)) {
1105  tok = strtok(NULL, " \t\n");
1106  Ctable->m_TableVersion = atoi(tok);
1107 
1108  ATH_MSG_DEBUG("Table Version = " << Ctable->m_TableVersion);
1109 
1110  tok = strtok(NULL, " \t\n");
1111  if (!tok) {
1112  inFile.getline(line, MAXLINE);
1113 
1114  tok = strtok(line, " \t\n");
1115  }
1116 
1117  if (strncmp(tok, ">", 1)) {
1118  ATH_MSG_WARNING("Invalid file format in Version!");
1119  inFile.close();
1120 
1121  if (lengths)
1122  delete[] lengths;
1123 
1124  if (codewords)
1125  delete[] codewords;
1126 
1127  return StatusCode::FAILURE;
1128  }
1129 
1130  Ctable->m_syms = std::make_unique<unsigned int[]>(Ctable->m_Nsymbols);
1131 
1132  if (lengths)
1133  delete[] lengths;
1134  lengths = new int[Ctable->m_Nsymbols];
1135 
1136  if (codewords)
1137  delete[] codewords;
1138  codewords = new int[Ctable->m_Nsymbols];
1139  }
1140 
1141  /*************************************/
1142  if (!strncmp(tok, "Nsymbols", 8)) {
1143  tok = strtok(NULL, " \t\n");
1144  Ctable->m_Nsymbols = atoi(tok);
1145 
1146  ATH_MSG_DEBUG("Nsymbols = " << Ctable->m_Nsymbols);
1147 
1148  tok = strtok(NULL, " \t\n");
1149  if (!tok) {
1150  inFile.getline(line, MAXLINE);
1151 
1152  tok = strtok(line, " \t\n");
1153  }
1154 
1155  if (strncmp(tok, ">", 1)) {
1156  ATH_MSG_WARNING("Invalid file format in Nsymbols!");
1157  inFile.close();
1158 
1159  if (lengths)
1160  delete[] lengths;
1161 
1162  if (codewords)
1163  delete[] codewords;
1164 
1165  return StatusCode::FAILURE;
1166  }
1167 
1168  Ctable->m_syms = std::make_unique<unsigned int[]>(Ctable->m_Nsymbols);
1169 
1170  if (lengths)
1171  delete[] lengths;
1172  lengths = new int[Ctable->m_Nsymbols];
1173 
1174  if (codewords)
1175  delete[] codewords;
1176  codewords = new int[Ctable->m_Nsymbols];
1177  }
1178 
1179  /*************************************/
1180  if (!strncmp(tok, "syms", 4)) {
1181 
1182  if (!Ctable->m_syms) {
1183  ATH_MSG_WARNING("Invalid file format Nsymbols must come first!");
1184  inFile.close();
1185 
1186  if (lengths)
1187  delete[] lengths;
1188 
1189  if (codewords)
1190  delete[] codewords;
1191 
1192  return StatusCode::FAILURE;
1193  }
1194 
1195  int i = 0;
1196 
1197  tok = strtok(NULL, " \t\n");
1198  while (i < Ctable->m_Nsymbols) {
1199  while ((tok) && (i < Ctable->m_Nsymbols)) {
1200  Ctable->m_syms[i++] = atoi(tok);
1201  tok = strtok(NULL, " \t\n");
1202  }
1203 
1204  if (!tok) {
1205  inFile.getline(line, MAXLINE);
1206  tok = strtok(line, " \t\n");
1207  }
1208  }
1209 
1210  if (strncmp(tok, ">", 1)) {
1211  ATH_MSG_WARNING("Invalid file format in syms!");
1212  inFile.close();
1213 
1214  if (lengths)
1215  delete[] lengths;
1216 
1217  if (codewords)
1218  delete[] codewords;
1219 
1220  return StatusCode::FAILURE;
1221  }
1222  }
1223 
1224  /*************************************/
1225  if (!strncmp(tok, "codewords", 9)) {
1226  if (!codewords) {
1227  ATH_MSG_WARNING("Invalid file format Nsymbols must come first!");
1228  inFile.close();
1229 
1230  if (lengths)
1231  delete[] lengths;
1232 
1233  return StatusCode::FAILURE;
1234  }
1235 
1236  int i = 0;
1237 
1238  tok = strtok(NULL, " \t\n");
1239  while (i < Ctable->m_Nsymbols) {
1240  while ((tok) && (i < Ctable->m_Nsymbols)) {
1241  codewords[i++] = atoi(tok);
1242  tok = strtok(NULL, " \t\n");
1243  }
1244 
1245  if (!tok) {
1246  inFile.getline(line, MAXLINE);
1247  tok = strtok(line, " \t\n");
1248  }
1249  }
1250 
1251  if (strncmp(tok, ">", 1)) {
1252  ATH_MSG_WARNING("Invalid file format in codewords!");
1253  inFile.close();
1254 
1255  if (lengths)
1256  delete[] lengths;
1257 
1258  if (codewords)
1259  delete[] codewords;
1260 
1261  return StatusCode::FAILURE;
1262  }
1263  }
1264 
1265  /*************************************/
1266  if (!strncmp(tok, "firstcode", 9)) {
1267  int i = 1;
1268 
1269  tok = strtok(NULL, " \t\n");
1270  while (i < 33) {
1271  while ((tok) && (i < 33)) {
1272  Ctable->m_firstcode[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 firstcode");
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, "lengths_integral", 16)) {
1298  int i = 1;
1299 
1300  tok = strtok(NULL, " \t\n");
1301  while (i < 33) {
1302  while ((tok) && (i < 33)) {
1303  Ctable->m_lengths_integral[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 lengths_integral!");
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", 7)) {
1329  if (!lengths) {
1330  ATH_MSG_WARNING("Invalid file format Nsymbols must come first!");
1331  inFile.close();
1332 
1333  if (codewords)
1334  delete[] codewords;
1335 
1336  return StatusCode::FAILURE;
1337  }
1338 
1339  int i = 0;
1340 
1341  tok = strtok(NULL, " \t\n");
1342  while (i < Ctable->m_Nsymbols) {
1343  while ((tok) && (i < Ctable->m_Nsymbols)) {
1344  lengths[i++] = atoi(tok);
1345  tok = strtok(NULL, " \t\n");
1346  }
1347 
1348  if (!tok) {
1349  inFile.getline(line, MAXLINE);
1350  tok = strtok(line, " \t\n");
1351  }
1352  }
1353 
1354  if (strncmp(tok, ">", 1)) {
1355  ATH_MSG_WARNING("Invalid file format in lengths!");
1356  inFile.close();
1357 
1358  if (lengths)
1359  delete[] lengths;
1360 
1361  if (codewords)
1362  delete[] codewords;
1363 
1364  return StatusCode::FAILURE;
1365  }
1366  }
1367  }
1368 
1369  inFile.close();
1370 
1371  if (!codewords || !lengths) {
1372  ATH_MSG_WARNING("Invalid file format Nsymbols must come first!");
1373 
1374  if (lengths)
1375  delete[] lengths;
1376 
1377  if (codewords)
1378  delete[] codewords;
1379 
1380  return StatusCode::FAILURE;
1381  }
1382 
1383  /*
1384  * Recover escape info from the table
1385  */
1386  int i = Ctable->m_Nsymbols - 1;
1387  int escape_length = 0;
1388  // uint32_t escape_codeword; // Set but not used
1389 
1390  while ((m_escape_marker != Ctable->m_syms[i]) && (i >= 0))
1391  i--;
1392 
1393  if (i < 0) {
1394  ATH_MSG_WARNING("Escape code not found!");
1395 
1396  if (lengths)
1397  delete[] lengths;
1398 
1399  if (codewords)
1400  delete[] codewords;
1401 
1402  return StatusCode::FAILURE;
1403  } else {
1404  // escape_codeword = codewords[i]; // Set but not used
1405  escape_length = lengths[i];
1406 
1407  if (escape_length != 5)
1408  ATH_MSG_WARNING("WARNING! Escape code length is " << escape_length
1409  << " rather than 5!");
1410  }
1411 
1412 #ifdef PRINT_TABLE
1413  for (int j = 0; j < Ctable->m_Nsymbols; j++) {
1414  ATH_MSG_INFO("Table: " << j << " " << lengths[j] << " " << MSG::hex
1415  << codewords[j] << " " << Ctable->m_syms[j]
1416  << std::dec);
1417  }
1418 #endif // PRINT_TABLE
1419 
1420  if (lengths)
1421  delete[] lengths;
1422 
1423  if (codewords)
1424  delete[] codewords;
1425 
1426  if (Ctable->m_TableVersion > m_maxCompressionVersion) {
1428  "Invalid Compression Table Version: " << Ctable->m_TableVersion);
1429 
1430  return StatusCode::FAILURE;
1431  }
1432 
1433  if (m_CompressionTables[Ctable->m_TableVersion]) {
1434  ATH_MSG_WARNING("Table " << Ctable->m_TableVersion
1435  << " already loaded! Not overwriting");
1436  } else {
1437  ATH_MSG_INFO("Loaded Compress Table Version: " << Ctable->m_TableVersion);
1438  m_CompressionTables[Ctable->m_TableVersion].store(std::move(Ctable))
1439  }
1440 
1441  return StatusCode::SUCCESS;
1442 
1443 #endif /* TRT_READCOMPTABLE_FILE */
1444 }

◆ update()

StatusCode TRT_RodDecoder::update ( ) const
private

Definition at line 1449 of file TRT_RodDecoder.cxx.

1449  {
1450  /*
1451  * function to update compression table when condDB data changes:
1452  */
1453 
1455  const CondAttrListCollection* catrlist = *rst;
1456  if (!catrlist) {
1457  ATH_MSG_ERROR("No Compression Table found in condDB ");
1458  return StatusCode::FAILURE;
1459  }
1460 
1461  CondAttrListCollection::const_iterator catrIt(catrlist->begin());
1462  CondAttrListCollection::const_iterator last_catr(catrlist->end());
1463 
1464  while (catrIt != last_catr) {
1465  const coral::AttributeList& atrlist = catrIt->second;
1466 
1467  int TableVersion = (atrlist)["Version"].data<cool::Int32>();
1468 
1469  if (TableVersion > m_maxCompressionVersion) {
1470  ATH_MSG_WARNING("Invalid Compression Table Version: " << TableVersion);
1471 
1472  ++catrIt;
1473 
1474  continue;
1475  }
1476 
1477  if (m_CompressionTables[TableVersion]) {
1478  ATH_MSG_DEBUG("Table " << TableVersion
1479  << " already loaded! Not overwriting");
1480  ++catrIt;
1481 
1482  continue;
1483  }
1484 
1485  auto Ctable = std::make_unique<t_CompressTable>();
1486  Ctable->m_TableVersion = TableVersion;
1487  Ctable->m_Nsymbols = (atrlist)["Nsymbols"].data<cool::Int32>();
1488  ATH_MSG_DEBUG("Nsymbols = " << Ctable->m_Nsymbols);
1489 
1490  Ctable->m_syms = std::make_unique<unsigned int[]>(Ctable->m_Nsymbols);
1491 
1492  const cool::Blob16M& blob = (atrlist)["syms"].data<cool::Blob16M>();
1493 
1494  if (blob.size() !=
1495  (unsigned int)(Ctable->m_Nsymbols * sizeof(unsigned int))) {
1496  ATH_MSG_ERROR("Unexpected size of symbol table! ( "
1497  << blob.size() << " != "
1498  << (Ctable->m_Nsymbols * sizeof(unsigned int)) << " )");
1499 
1500  return StatusCode::FAILURE;
1501  }
1502 
1503  const unsigned char* BlobStart =
1504  static_cast<const unsigned char*>(blob.startingAddress());
1505  int j = 0;
1506  for (int i = 0; (i < blob.size()) && (j < Ctable->m_Nsymbols);
1507  i += sizeof(unsigned int)) {
1508  Ctable->m_syms[j++] = *((unsigned int*)(BlobStart + i));
1509  }
1510 
1511  std::istringstream iss((atrlist)["firstcode"].data<cool::String4k>());
1512  std::string tok;
1513  int i = 1;
1514  while (getline(iss, tok, ' ') && (i < CTABLE_FC_LENGTH)) {
1515  Ctable->m_firstcode[i++] = atoi(tok.c_str());
1516  }
1517 
1518  std::istringstream iss2(
1519  (atrlist)["lengths_integral"].data<cool::String4k>());
1520  i = 1;
1521  while (getline(iss2, tok, ' ') && (i < CTABLE_LI_LENGTH)) {
1522  Ctable->m_lengths_integral[i++] = atoi(tok.c_str());
1523  }
1524 
1525  int ctable_version = Ctable->m_TableVersion;
1526  ATH_MSG_INFO("Loaded Compress Table Version: " << ctable_version);
1527  m_CompressionTables[ctable_version].set(std::move(Ctable));
1528 
1529  ++catrIt;
1530  }
1531 
1532  return StatusCode::SUCCESS;
1533 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

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

Definition at line 163 of file TRT_RodDecoder.h.

◆ m_accept

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

Definition at line 166 of file TRT_RodDecoder.h.

◆ m_CablingSvc

ServiceHandle<ITRT_CablingSvc> TRT_RodDecoder::m_CablingSvc
private

Definition at line 82 of file TRT_RodDecoder.h.

◆ m_CompressionTables

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

Definition at line 129 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 138 of file TRT_RodDecoder.h.

◆ m_err_count_fillCollection

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

Definition at line 133 of file TRT_RodDecoder.h.

◆ m_err_count_int_fillFullCompress

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

Definition at line 135 of file TRT_RodDecoder.h.

◆ m_err_count_int_fillMinimalCompress

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

Definition at line 134 of file TRT_RodDecoder.h.

◆ m_escape_marker

uint32_t TRT_RodDecoder::m_escape_marker
private

Definition at line 113 of file TRT_RodDecoder.h.

◆ m_eventTypeIsSim

bool TRT_RodDecoder::m_eventTypeIsSim
private

Definition at line 110 of file TRT_RodDecoder.h.

◆ m_forceRodVersion

int TRT_RodDecoder::m_forceRodVersion
private

Definition at line 102 of file TRT_RodDecoder.h.

◆ m_loadCompressTableDB

bool TRT_RodDecoder::m_loadCompressTableDB
private

Definition at line 99 of file TRT_RodDecoder.h.

◆ m_loadCompressTableFile

bool TRT_RodDecoder::m_loadCompressTableFile
private

Definition at line 98 of file TRT_RodDecoder.h.

◆ m_LoadCompressTableVersions

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

Definition at line 100 of file TRT_RodDecoder.h.

◆ m_LoLumRawData

BooleanProperty TRT_RodDecoder::m_LoLumRawData
private

Definition at line 108 of file TRT_RodDecoder.h.

◆ m_lookAtBcidErrors

bool TRT_RodDecoder::m_lookAtBcidErrors
private

Definition at line 95 of file TRT_RodDecoder.h.

◆ m_lookAtErrorErrors

bool TRT_RodDecoder::m_lookAtErrorErrors
private

Definition at line 93 of file TRT_RodDecoder.h.

◆ m_lookAtL1idErrors

bool TRT_RodDecoder::m_lookAtL1idErrors
private

Definition at line 94 of file TRT_RodDecoder.h.

◆ m_lookAtMissingErrors

bool TRT_RodDecoder::m_lookAtMissingErrors
private

Definition at line 96 of file TRT_RodDecoder.h.

◆ m_lookAtSidErrors

bool TRT_RodDecoder::m_lookAtSidErrors
private

Definition at line 92 of file TRT_RodDecoder.h.

◆ m_maxCompressionVersion

const int TRT_RodDecoder::m_maxCompressionVersion
private

Definition at line 101 of file TRT_RodDecoder.h.

◆ m_Nrdos

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

Definition at line 131 of file TRT_RodDecoder.h.

◆ m_recordBSErrors

bool TRT_RodDecoder::m_recordBSErrors
private

Definition at line 87 of file TRT_RodDecoder.h.

◆ m_skip

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

Definition at line 165 of file TRT_RodDecoder.h.

◆ m_straw_layer_context

IdContext TRT_RodDecoder::m_straw_layer_context
private

Definition at line 105 of file TRT_RodDecoder.h.

◆ m_TB04_RawData

BooleanProperty TRT_RodDecoder::m_TB04_RawData
private

Definition at line 107 of file TRT_RodDecoder.h.

◆ m_trt_id

const TRT_ID* TRT_RodDecoder::m_trt_id
private

Definition at line 104 of file TRT_RodDecoder.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
ReadOfcFromCool.phase
phase
Definition: ReadOfcFromCool.py:127
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
checkFileSG.line
line
Definition: checkFileSG.py:75
TRT_RodDecoder::m_escape_marker
uint32_t m_escape_marker
Definition: TRT_RodDecoder.h:113
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
InDetRawDataCollection::setIdentifier
void setIdentifier(Identifier id)
TRT_RodDecoder::m_lookAtL1idErrors
bool m_lookAtL1idErrors
Definition: TRT_RodDecoder.h:94
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TRT_RodDecoder::m_err_count_int_fillMinimalCompress
std::atomic< int > m_err_count_int_fillMinimalCompress
Definition: TRT_RodDecoder.h:134
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TRT_RodDecoder::m_LoadCompressTableVersions
std::vector< int > m_LoadCompressTableVersions
Definition: TRT_RodDecoder.h:100
TRT_RodDecoder::m_loadCompressTableFile
bool m_loadCompressTableFile
Definition: TRT_RodDecoder.h:98
TRT_LoLumRawData
Definition: TRT_LoLumRawData.h:25
TRT_RodDecoder::m_lookAtMissingErrors
bool m_lookAtMissingErrors
Definition: TRT_RodDecoder.h:96
initialize
void initialize()
Definition: run_EoverP.cxx:894
TRT_RodDecoder::m_err_count_fillCollection
std::atomic< int > m_err_count_fillCollection
Definition: TRT_RodDecoder.h:133
makeTOC.inFile
string inFile
Definition: makeTOC.py:5
TRT_RodDecoder::m_skip
std::atomic< unsigned int > m_skip
Definition: TRT_RodDecoder.h:165
skel.it
it
Definition: skel.GENtoEVGEN.py:423
TRT_RodDecoder::m_CompressionTables
std::vector< CxxUtils::CachedUniquePtr< t_CompressTable > > m_CompressionTables
Definition: TRT_RodDecoder.h:129
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
TRT_RodDecoder::m_lookAtSidErrors
bool m_lookAtSidErrors
Definition: TRT_RodDecoder.h:92
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
TRT_RodDecoder::ReadCompressTableFile
StatusCode ReadCompressTableFile(const std::string &TableFilename)
Definition: TRT_RodDecoder.cxx:1062
TRT_RodDecoder::m_trt_id
const TRT_ID * m_trt_id
Definition: TRT_RodDecoder.h:104
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TRT_RodDecoder::m_err_count_int_fillFullCompress
std::atomic< int > m_err_count_int_fillFullCompress
Definition: TRT_RodDecoder.h:135
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TRT_RodDecoder::m_maxCompressionVersion
const int m_maxCompressionVersion
Definition: TRT_RodDecoder.h:101
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
const DataType * PointerType
Definition: RawEvent.h:25
TRT_ID::get_id
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const override final
Create compact id from hash id (return == 0 for OK)
Definition: TRT_ID.cxx:897
Index
IndexedConstituentUserInfo::Index Index
Definition: IndexedConstituentUserInfo.cxx:12
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
CTABLE_LI_LENGTH
#define CTABLE_LI_LENGTH
Definition: TRT_RodDecoder.h:116
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
TRT_ID::straw_layer_context
IdContext straw_layer_context(void) const
straw_layer id
Definition: TRT_ID.h:713
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT_RodDecoder::update
StatusCode update() const
Definition: TRT_RodDecoder.cxx:1449
file
TFile * file
Definition: tile_monitor.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TRT_RodDecoder::m_loadCompressTableDB
bool m_loadCompressTableDB
Definition: TRT_RodDecoder.h:99
DataPool::nextElementPtr
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
beamspotman.stat
stat
Definition: beamspotman.py:266
DataVector::clear
void clear()
Erase all the elements in the collection.
TRT_RodDecoder::m_CablingSvc
ServiceHandle< ITRT_CablingSvc > m_CablingSvc
Definition: TRT_RodDecoder.h:82
TRT_RodDecoder::m_CompressKey
SG::ReadCondHandleKey< CondAttrListCollection > m_CompressKey
Definition: TRT_RodDecoder.h:138
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
AtlasDetectorID::print_to_string
std::string print_to_string(Identifier id, const IdContext *context=0) const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:655
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TRT_RodDecoder::m_straw_layer_context
IdContext m_straw_layer_context
Definition: TRT_RodDecoder.h:105
CTABLE_FC_LENGTH
#define CTABLE_FC_LENGTH
Definition: TRT_RodDecoder.h:115
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
TRT_RodDecoder::m_forceRodVersion
int m_forceRodVersion
Definition: TRT_RodDecoder.h:102
TRT_RodDecoder::m_lookAtBcidErrors
bool m_lookAtBcidErrors
Definition: TRT_RodDecoder.h:95
python.PyAthena.v
v
Definition: PyAthena.py:157
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
TRT_RodDecoder::int_fillMinimalCompress
StatusCode int_fillMinimalCompress(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, TRT_RDO_Container *rdoIdo, DataPool< TRT_LoLumRawData > *dataItemsPool, const std::vector< IdentifierHash > *vecHash=0) const
Definition: TRT_RodDecoder.cxx:590
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
TRT_RodDecoder::m_accept
std::atomic< unsigned int > m_accept
Definition: TRT_RodDecoder.h:166
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TRT_RodDecoder::m_lookAtErrorErrors
bool m_lookAtErrorErrors
Definition: TRT_RodDecoder.h:93
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TRT_RodDecoder::m_recordBSErrors
bool m_recordBSErrors
Definition: TRT_RodDecoder.h:87
TRT_RodDecoder::m_eventTypeIsSim
bool m_eventTypeIsSim
Definition: TRT_RodDecoder.h:110
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
TRT_RodDecoder::m_Nrdos
std::atomic< uint32_t > m_Nrdos
Definition: TRT_RodDecoder.h:131
IdentifierHash
Definition: IdentifierHash.h:38
TRT_RodDecoder::int_fillExpanded
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
Definition: TRT_RodDecoder.cxx:416
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
TRT_RodDecoder::int_fillFullCompress
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
Definition: TRT_RodDecoder.cxx:809