12 #include "eformat/SourceIdentifier.h"
17 #include <unordered_set>
22 constexpr
unsigned long long operator"" _BIT(
unsigned long long bitPosition){
23 return 1
ull << bitPosition;
27 #define generalwarning(x) \
28 if (this->m_numGenWarnings < this->m_maxNumGenWarnings) \
29 {ATH_MSG_DEBUG(x); ++this->m_numGenWarnings;} \
30 else if (this->m_numGenWarnings == this->m_maxNumGenWarnings) \
31 {ATH_MSG_DEBUG("PixelRodDecoder: suppressing further general warnings"); ++this->m_numGenWarnings;} \
32 else {++this->m_numGenWarnings; }
34 #define lvl1id_bcid_warning(x) \
35 if (this->m_numBCIDWarnings < this->m_maxNumBCIDWarnings) \
36 {ATH_MSG_DEBUG(x); ++this->m_numBCIDWarnings;} \
37 else if (this->m_numBCIDWarnings == this->m_maxNumBCIDWarnings) \
38 {ATH_MSG_DEBUG("PixelRodDecoder: suppressing further BCID/LVL1ID warnings"); ++this->m_numBCIDWarnings;} \
39 else {++this->m_numBCIDWarnings; }
44 inline bool isIBL(
uint32_t robId ) {
return ((robId>>16) & 0xFF)==0x14; }
45 inline bool isDBM(
uint32_t robId ) {
return ((robId>>16) & 0xFF)==0x15; }
49 (
const std::string&
type,
const std::string&
name,
const IInterface*
parent )
51 m_is_ibl_present(false){
52 declareInterface< IPixelRodDecoder >(
this );
78 return StatusCode::SUCCESS;
107 ATH_MSG_INFO(
" --------------------------------------------- ");
108 return StatusCode::SUCCESS;
113 std::array<uint64_t, PixelRodDecoder::ERROR_CONTAINER_MAX> &bsErrWord,
116 const char *error_description)
const {
123 ATH_MSG_DEBUG(
"ROB status word for robid 0x"<< std::hex << robId << std::dec <<
" indicates " << error_description <<
".");
124 assert( bsErrWord.size() <= decodingErrors.
maxSize() );
125 for (
size_t i=0; i<static_cast<size_t>(bsErrWord.size());
i++) {
126 if (bsErrWord[
i]>0) {
135 ATH_MSG_VERBOSE(
"-------------------------------------------------------------------------------------------------------------");
142 bool isIBLModule =
false;
143 bool isDBMModule =
false;
144 uint32_t rodId = robFrag->rod_source_id();
145 uint32_t robId = robFrag->rob_source_id();
146 uint32_t robBCID = robFrag->rod_bc_id();
147 if (
isIBL( robId ) && robId != rodId ) {
148 generalwarning(
"Discrepancy in IBL SourceId: ROBID 0x" << std::hex << robId <<
" unequal to RODID 0x" << rodId);
151 std::unique_ptr<SG::ReadCondHandle<PixelHitDiscCnfgData> > pixHitDiscCnfg;
152 unsigned int errorRecoverable = 0;
158 std::array<uint64_t, PixelRodDecoder::ERROR_CONTAINER_MAX> bsErrWord{};
159 std::fill(bsErrWord.begin(),bsErrWord.end(),0);
161 if (robFrag->nstatus()!=0) {
163 robFrag->status(rob_status);
166 ATH_MSG_DEBUG(
"ROB status word for robid 0x"<< std::hex << robId <<
" is non-zero 0x" << (*rob_status) << std::dec);
171 if ((*rob_status) & (0x1u << 27)) {
173 return StatusCode::RECOVERABLE;
175 if ((*rob_status) & (0x1u << 31)) {
177 return StatusCode::RECOVERABLE;
182 if (robFrag->rod_ndata() > robFrag->payload_size_word() && !robFrag->check_rod_noex(robFrag->rod_version() >> 16)) {
184 " invalid ROD fragment, invalid payload size");
185 return StatusCode::RECOVERABLE;
192 unsigned int mBCID = 0x3FFF;
193 unsigned int mLVL1ID = 0x3FFF;
194 unsigned int mLink = 0x3FFF;
196 int offsetBCID_ROB_FE = 0x3FFF;
204 bool link_start =
false;
207 int mBCID_offset = -1;
208 unsigned int mBCID_max_pix = 0x100;
209 unsigned int mBCID_max_IBL = 0x400;
210 bool receivedCondensedWords =
false;
211 int countHitCondensedWords = 0;
212 uint32_t condensedWords[nCondensedWords] = {};
213 bool are_4condensed_words =
false;
214 unsigned int prevBCID = 0x3FFF;
215 unsigned int prevLVL1ID = 0x3FFF;
217 int prevOffsetBCID_ROB_FE = 0x3FFF;
218 unsigned int prevStartingBCID = 0x3FFF;
219 unsigned int nFragmentsPerFE[8] = {0};
224 robFrag->rod_data(vint);
227 eformat::helper::SourceIdentifier sid_rob(robId);
228 sLinkSourceId = (sid_rob.module_id()) & 0x000F;
229 if (
isIBL( robId ) && sLinkSourceId>0x3) {
230 generalwarning(
"In ROB 0x" << std::hex << robId <<
": IBL/DBM SLink number not in correct range (0-3): SLink = " << std::dec << sLinkSourceId);
233 bool corruptionError =
false;
235 std::unordered_set<Identifier> foundPixels;
238 const int nwords = robFrag->rod_ndata();
239 for (
int dataword_it = 0; dataword_it < nwords; ++dataword_it) {
240 const uint32_t rawDataWord = vint[dataword_it];
244 serviceCodeCounter = 0;
247 int indexModule = -1;
250 if (offlineIdHash!=0xffffffff) {
254 isIBLModule =
isIBL(robId);
255 isDBMModule =
isDBM(robId);
259 if (isIBLModule || isDBMModule) {
267 indexModule =
static_cast<int>(offlineIdHash);
272 bool headerErr_decoding =
false;
273 bool headerErr_flagged =
false;
274 bool headerErr_preamble =
false;
275 bool headerErr_timeout =
false;
276 bool headerErr_lvl1id =
false;
277 bool headerErr_bcid =
false;
283 errorRecoverable = 0;
286 generalwarning(
"In ROB 0x" << std::hex << robId <<
": Unexpected link header found: 0x" << std::hex << rawDataWord <<
", data corruption" << std::dec);
288 headerErr_decoding =
true;
294 are_4condensed_words =
false;
295 receivedCondensedWords =
false;
298 countHitCondensedWords = 0;
300 isIBLModule =
isIBL(robId);
301 isDBMModule =
isDBM(robId);
304 prevLVL1ID = mLVL1ID;
307 prevOffsetBCID_ROB_FE = offsetBCID_ROB_FE;
309 if (isIBLModule || isDBMModule) {
311 ATH_MSG_VERBOSE(
"Decoding the IBL/DBM header word: 0x" << std::hex << rawDataWord << std::dec );
320 headerErr_flagged =
true;
323 mLink = fe_IBLheader;
325 if (sLinkHeader != sLinkSourceId) {
326 generalwarning(
"In ROB 0x" << std::hex << robId <<
", link 0x" << mLink <<
": SLink discrepancy: Slink number from SourceId = 0x" << std::hex << sLinkSourceId <<
", number from link header = 0x" << sLinkHeader << std::dec);
329 if (mLink == prevLinkNum) {
331 if (mLVL1ID != prevLVL1ID && prevLVL1ID != 0x3FFF) {
332 lvl1id_bcid_warning(
"In ROB 0x" << std::hex << robId <<
", FE: 0x" << mLink <<
": frame header LVL1ID differs from previous one (current frame LVL1ID = 0x" << mLVL1ID <<
", previous frame LVL1ID = 0x" << prevLVL1ID <<
")" << std::dec);
335 if ((mBCID != prevBCID + 1) && prevBCID != 0x3FFF && prevBCID != mBCID_max_IBL) {
336 lvl1id_bcid_warning(
"In ROB 0x" << std::hex << robId <<
", FE: 0x" << mLink <<
": frame header with non-consecutive BCID (current BCID = 0x" << mBCID <<
", previous BCID = 0x" << prevBCID <<
")" << std::dec);
340 offsetBCID_ROB_FE =
static_cast<int>(mBCID) - robBCID;
341 if (offsetBCID_ROB_FE != prevOffsetBCID_ROB_FE && (offsetBCID_ROB_FE != 0x3FFF && prevOffsetBCID_ROB_FE != 0x3FFF)) {
342 lvl1id_bcid_warning(
"In ROB 0x" << std::hex << robId <<
", FE: 0x" << mLink << std::dec <<
": FE header with unexpected BCID offset" <<
" wrt to ROB header (offset = " << offsetBCID_ROB_FE <<
", expected " << prevOffsetBCID_ROB_FE <<
" from ROB)");
345 if (mBCID != prevStartingBCID && prevStartingBCID != 0x3FFF) {
346 lvl1id_bcid_warning(
"In ROB 0x" << std::hex << robId <<
", FE: 0x" << mLink <<
": FE BCID starts at different value than in previous FE (current BCID = 0x" << mBCID <<
", prev starting BCID = 0x" << prevStartingBCID <<
")" << std::dec);
348 prevStartingBCID = mBCID;
351 if (mLink < 0x8) { ++nFragmentsPerFE[mLink]; }
354 ATH_MSG_VERBOSE(
"Decoding Pixel header word: 0x" << std::hex << rawDataWord << std::dec );
359 if ( headerError != 0 ) {
360 sc = StatusCode::RECOVERABLE;
361 errorRecoverable = errorRecoverable | (headerError << 20);
364 if (headerError & (1 << 3)) {
366 headerErr_preamble =
true;
368 if (headerError & (1 << 2)) {
370 headerErr_timeout =
true;
372 if (headerError & (1 << 1)) {
374 headerErr_lvl1id =
true;
376 if (headerError & (1 << 0)) {
378 headerErr_bcid =
true;
387 generalwarning(
"In ROB 0x" << std::hex << robId <<
", FE: 0x" << mLink <<
": Got invalid onlineId (= 0) in FE header - dataword = 0x" << rawDataWord);
391 ATH_MSG_VERBOSE(
"In decoder: got onlineId 0x" << std::hex << onlineId );
395 if (offlineIdHash != previous_offlineIdHash) {
396 mBCID_offset = mBCID;
399 bsErrWord[
static_cast<int>(offlineIdHash)+52736] = 1;
401 mLVL1A = mBCID - mBCID_offset;
403 if (isIBLModule || isDBMModule) { mLVL1A=mLVL1A+mBCID_max_IBL; }
404 else { mLVL1A=mLVL1A+mBCID_max_pix; }
408 if (isIBLModule || isDBMModule) {
430 ATH_MSG_VERBOSE(
"link header with BCID: " << mBCID <<
" LVL1ID: " << mLVL1ID <<
" LVL1A: " << mLVL1A <<
" link: " << mLink <<
" found");
431 ATH_MSG_VERBOSE(
"got OfflineIDHash: 0x" << std::hex << offlineIdHash <<
" from OnlineID: 0x" << onlineId << std::dec <<
" link: " << mLink);
434 if (offlineIdHash == 0xffffffff) {
435 generalwarning(
"In ROB 0x" << std::hex << robId <<
", FE: 0x" << mLink <<
": Unknown OnlineId identifier in FE header - not found by mapping" << std::dec);
445 unsigned int mFE = 0;
446 unsigned int mRow = 0;
447 unsigned int mColumn = 0;
451 if (isIBLModule || isDBMModule) {
454 ATH_MSG_DEBUG (
"Decoding IBL/DBM hit word: 0x" << std::hex << rawDataWord << std::dec);
457 if (((rawDataWord & PRB_DATAMASK) == PRB_FIRSTHITCONDENSEDWORD) && (countHitCondensedWords == 0)) {
458 countHitCondensedWords = 1;
459 are_4condensed_words =
false;
460 condensedWords[0] = rawDataWord;
463 else if (countHitCondensedWords == 1) {
464 ++countHitCondensedWords;
465 condensedWords[1] = rawDataWord;
468 else if (countHitCondensedWords == 2) {
469 ++countHitCondensedWords;
470 condensedWords[2] = rawDataWord;
473 else if (((rawDataWord & PRB_DATAMASK) == PRB_LASTHITCONDENSEDWORD) && (countHitCondensedWords == 3)) {
474 are_4condensed_words =
true;
475 receivedCondensedWords =
true;
476 condensedWords[3] = rawDataWord;
485 hitwords[0] = (condensedWords[0] & mask24);
487 hitwords[1] = ((condensedWords[0] >> (skipRow + skipCol+ skipTOT) ) & mask5) + ((condensedWords[1] & mask19) << skip5);
489 hitwords[2] = ((condensedWords[1] >> (skip4 + skipCol + skipTOT)) & mask12) + ((condensedWords[2] & mask12) << (skipRow + skip3));
491 hitwords[3] = ((condensedWords[2] >> (skipTOT + skip4)) & mask19) + ((condensedWords[3] & mask5) << (skip3 + skipRow + skipCol));
493 hitwords[4] = (condensedWords[3] >> skip5) & mask24;
496 ATH_MSG_VERBOSE(
"4 consecutive IBL hit words found. Condensed hits are being decoded");
499 for (
unsigned int i(0);
i < nHits; ++
i) {
503 ATH_MSG_VERBOSE(
"hitword[" <<
i <<
"] = 0x" << std::hex << hitwords[
i] <<
", row: 0x" <<
row[
i] <<
", col: 0x" <<
col[
i] <<
", 8-bit ToT: 0x" << tot[
i] << std::dec);
505 countHitCondensedWords = 0;
506 linkNum_IBLword = linkNum_IBLheader;
508 else if ((rawDataWord & PRB_DATAMASK) == PRB_DATAWORD) {
509 if (countHitCondensedWords != 0) {
510 generalwarning(
"In ROB 0x" << std::hex << robId <<
", link 0x" << mLink <<
": Interruption of IBL condensed words - hit(s) ignored (current dataword: 0x" << std::hex << rawDataWord << std::dec <<
")");
514 countHitCondensedWords = 0;
517 are_4condensed_words =
false;
518 mRow =
decodeRow(rawDataWord, isIBLModule || isDBMModule );
519 mColumn =
decodeColumn(rawDataWord, isIBLModule || isDBMModule);
520 mToT =
decodeToT(rawDataWord, isIBLModule || isDBMModule);
523 if (linkNum_IBLword != linkNum_IBLheader) {
524 generalwarning(
"In ROB 0x" << std::hex << robId <<
": Link number mismatch - nnnnn (hit word) = 0x" << linkNum_IBLword <<
", nnnnn (header) = 0x" << linkNum_IBLheader << std::dec);
528 ATH_MSG_DEBUG(
"hit dataword found for module offlineIDHash: " << offlineIdHash <<
" Row: 0x" << std::hex << mRow <<
" Col: 0x" << mColumn <<
" Tot: 0x" << mToT << std::dec);
533 generalwarning(
"In ROB 0x" << std::hex << robId <<
", FE: 0x" << mLink <<
": IBL/DBM hit word 0x" << rawDataWord <<
" not recognised" << std::dec);
549 ATH_MSG_VERBOSE(
"Decoding Pixel hit word: 0x" << std::hex << rawDataWord << std::dec);
552 if (countHitCondensedWords != 0){
553 generalwarning(
"In ROB 0x" << std::hex << robId <<
", link 0x" << mLink
554 <<
": Interruption of IBL condensed words - hit(s) ignored (current dataword: 0x"
555 << std::hex << rawDataWord << std::dec <<
")");
559 countHitCondensedWords = 0;
562 are_4condensed_words =
false;
564 mRow =
decodeRow(rawDataWord, isIBLModule || isDBMModule );
565 mColumn =
decodeColumn(rawDataWord, isIBLModule || isDBMModule);
566 mToT =
decodeToT(rawDataWord, isIBLModule || isDBMModule);
569 ATH_MSG_DEBUG(
"hit dataword found for module offlineIDHash: " << offlineIdHash <<
" FE: " << mFE <<
" Row: " << mRow <<
" Col: " << mColumn );
578 if (offlineIdHash == skipHash)
continue;
579 if (offlineIdHash != lastHash) {
580 lastHash = offlineIdHash;
581 if (vecHash!=
nullptr) {
583 if (
p == vecHash->end()) {
584 skipHash = offlineIdHash;
589 if( coll ==
nullptr ) {
599 ATH_MSG_ERROR(
"failed to add Pixel RDO collection to container" );
605 if (isIBLModule || isDBMModule) {
606 unsigned int num_cycles_toFillCollection(0);
607 if (are_4condensed_words) {
608 num_cycles_toFillCollection = nHits;
611 num_cycles_toFillCollection = 1;
617 for (
unsigned int i(0);
i < num_cycles_toFillCollection; ++
i) {
620 ATH_MSG_VERBOSE(
"ROW[" <<
i <<
"] = 0x" << std::hex <<
row[
i] << std::dec <<
", COL[" <<
i <<
"] = 0x" << std::hex <<
col[
i] << std::dec <<
", 8-bit TOT[" <<
i <<
"] = 0x" << std::hex << tot[
i] << std::dec );
624 if ((tot[
i] & 0xF0) == 0x00) {
625 generalwarning(
"In ROB 0x" << std::hex << robId <<
", FE 0x" << mLink <<
": First IBL ToT field is 0 - hit word 0x" << rawDataWord <<
" decodes to ToT1 = 0" << (tot[
i] >> 4) <<
", ToT2 = 0x" << (tot[
i] & 0xF) <<
", row = " << std::dec <<
row[
i] <<
" col = " <<
col[
i] << std::dec);
629 if (((
row[
i] != 0) && (
col[
i] != 0) && (
row[
i] <= 336) && (
col[
i] <= 80)) || isDBMModule) {
638 ATH_MSG_VERBOSE(
" eta_i: " << eta_i <<
", phi_i: " << phi_i <<
", eta_m: " << eta_m <<
", phi_m: " << phi_m );
640 if (pixelId == invalidPixelId) {
641 generalwarning(
"In ROB 0x" << std::hex << robId <<
", FE 0x" << mLink <<
": Illegal pixelId - hit word 0x" << rawDataWord <<
" decodes to ToT1 = 0" << (tot[
i] >> 4) <<
", ToT2 = 0x" << (tot[
i] & 0xF) <<
", row = " << std::dec <<
row[
i] <<
" col = " <<
col[
i] << std::dec);
649 ATH_MSG_VERBOSE(
"Starting from tot = 0x" << std::hex << tot[
i] <<
" IBLtot[0] = 0x" << std::hex << IBLtot[0] <<
" IBLtot[1] = 0x" << IBLtot[1] << std::dec );
652 if (!pixHitDiscCnfg) {
653 pixHitDiscCnfg = std::make_unique<SG::ReadCondHandle<PixelHitDiscCnfgData> > (
m_condHitDiscCnfgKey,ctx);
657 hitDiscCnfg = (*pixHitDiscCnfg)->getHitDiscCnfgPL();
660 hitDiscCnfg = (*pixHitDiscCnfg)->getHitDiscCnfg3D();
663 if (hitDiscCnfg == 2 && IBLtot[0] == 2) IBLtot[0] = 16;
664 if (hitDiscCnfg == 2 && IBLtot[1] == 2) IBLtot[1] = 16;
667 coll->
push_back(
new RDO(pixelId, IBLtot[0], mBCID, mLVL1ID, mLVL1A));
674 ATH_MSG_VERBOSE(
"Collection filled with pixelId: " << pixelId <<
" TOT = 0x" << std::hex << IBLtot[0] << std::dec <<
" mBCID = " << mBCID <<
" mLVL1ID = " << mLVL1ID <<
" mLVL1A = " << mLVL1A );
680 if (IBLtot[1] != 0x0 && (IBLtot[1] != 0xF || hitDiscCnfg != 3)) {
681 if ((
row[
i] + 1) > 336) {
683 generalwarning(
"In ROB = 0x" << std::hex << robId <<
", link 0x" << mLink <<
": Illegal IBL row number for second ToT field, hit word 0x" << rawDataWord <<
" decodes to row = " << std::dec <<
row[
i]+1 <<
" col = " <<
col[
i] <<
" (ToT1 = 0x" << std::hex << IBLtot[0] <<
" ToT2 = 0x" << IBLtot[1] <<
")");
699 ATH_MSG_VERBOSE(
" eta_i: " << eta_i <<
", phi_i: " << phi_i <<
", eta_m: " << eta_m <<
", phi_m: " << phi_m <<
", eta_i_max: " << eta_i_max <<
", phi_i_max: " << phi_i_max );
702 if (pixelId == invalidPixelId) {
703 generalwarning(
"In ROB 0x" << std::hex << robId <<
", FE 0x" << mLink <<
": Illegal pixelId - hit word 0x" << rawDataWord <<
" decodes to ToT1 = 0" << (tot[
i] >> 4) <<
", ToT2 = 0x" << (tot[
i] & 0xF) <<
", row = " << std::dec <<
row[
i] <<
" col = " <<
col[
i] << std::dec);
709 coll->
push_back(
new RDO(pixelId, IBLtot[1], mBCID, mLVL1ID, mLVL1A));
716 ATH_MSG_VERBOSE(
"Collection filled with pixelId: " << pixelId <<
" TOT = 0x" << std::hex << IBLtot[1] << std::dec <<
" mBCID = " << mBCID <<
" mLVL1ID = " << mLVL1ID <<
" mLVL1A = " << mLVL1A );
723 generalwarning(
"In ROB = 0x" << std::hex << robId <<
", link 0x" << mLink <<
": Illegal IBL row/col number, hit word 0x" << rawDataWord <<
" decodes to row = " << std::dec <<
row[
i] <<
" col = " <<
col[
i] <<
" (ToT1 = 0x" << std::hex << (tot[
i] >> 4) <<
" ToT2 = 0x" << (tot[
i] & 0xF) <<
")");
733 pixelId =
m_pixelReadout->getPixelIdfromHash(offlineIdHash, mFE, mRow, mColumn);
734 if (pixelId == invalidPixelId) {
735 ATH_MSG_DEBUG(
"In ROB = 0x" << std::hex << robId <<
", link 0x" << mLink <<
": Illegal pixelId - row = " << std::dec << mRow <<
", col = " << mColumn <<
", dataword = 0x" << std::hex << rawDataWord << std::dec);
743 coll->
push_back(
new RDO(pixelId, mToT, mBCID, mLVL1ID, mLVL1A));
750 ATH_MSG_VERBOSE(
"Collection filled with pixelId: " << pixelId <<
" TOT = 0x" << std::hex << mToT << std::dec <<
" mBCID = " << mBCID <<
" mLVL1ID = " << mLVL1ID <<
" mLVL1A = " << mLVL1A );
756 generalwarning(
"In ROB = 0x" << std::hex << robId <<
", link 0x" << mLink <<
": Unexpected hit dataword: " << rawDataWord <<
" - hit ignored");
764 case PRB_LINKTRAILER:
769 generalwarning(
"In ROB = 0x" << std::hex << robId <<
", link 0x" << mLink <<
": Unexpected trailer found: 0x" << std::hex << rawDataWord <<
", data corruption");
775 previous_offlineIdHash = offlineIdHash;
777 are_4condensed_words =
false;
779 if (isIBLModule || isDBMModule) {
780 ATH_MSG_VERBOSE(
"Decoding IBL/DBM trailer word: 0x" << std::hex << rawDataWord << std::dec );
783 if (trailerError & (1 << 8)) {
788 if (trailerError & (1 << 6)) {
792 if (trailerError & (1 << 5)) {
796 if (trailerError & (1 << 4)) {
800 if (trailerError & (1 << 3)) {
804 if (trailerError & (1 << 2)) {
808 if (trailerError & (1 << 1)) {
812 if (trailerError & (1 << 0)) {
817 if (trailerError & (1 << 7)) {
818 if (!receivedCondensedWords) {
generalwarning(
"In ROB 0x" << std::hex << robId <<
", link 0x" << mLink <<
": condensed mode bit is set, but no condensed words received" << std::dec); }
823 if (linkNum_IBLword != linkNum_IBLheader) {
824 generalwarning(
"In ROB 0x" << std::hex << robId <<
", link 0x" << mLink <<
": Link number mismatch - nnnnn (trailer) = 0x" << linkNum_IBLword <<
", nnnnn (header) = 0x" << linkNum_IBLheader << std::dec);
827 generalwarning(
"In ROB 0x" << std::hex << robId <<
", link 0x" << mLink <<
": Trailer BCID does not match header (trailer BCID = 0x" <<
decodeBcidTrailer_IBL(rawDataWord) <<
", 5LSB of header BCID = 0x" << (mBCID & PRB_BCIDSKIPTRAILERmask_IBL) <<
")" << std::dec);
831 ATH_MSG_VERBOSE(
"Decoding Pixel trailer word: 0x" << std::hex << rawDataWord << std::dec );
833 if (trailerError != 0) {
834 sc = StatusCode ::RECOVERABLE;
835 errorRecoverable = errorRecoverable | trailerError;
837 const std::array<unsigned long long, 4> bitPosition{0_BIT, 1_BIT, 2_BIT, 3_BIT};
838 for (
const auto bit:bitPosition){
842 if ( trailerError & 0xF ) {
848 if (trailerError != 0) {
849 if (indexModule>-1) {
867 are_4condensed_words =
false;
868 if (isIBLModule || isDBMModule) {
869 ATH_MSG_VERBOSE(
"Decoding IBL/DBM FEflag word: 0x" << std::hex << rawDataWord << std::dec);
871 if (linkNum_IBLword != linkNum_IBLheader) {
872 generalwarning(
"In ROB 0x" << std::hex << robId <<
", link 0x" << mLink <<
": Link number mismatch - nnnnn (error word) = 0x" << linkNum_IBLword <<
", nnnnn (header) = 0x" << linkNum_IBLheader << std::dec);
877 if (serviceCode>31) {
878 generalwarning(
"In ROB 0x" << std::hex << robId <<
", link 0x" << mLink <<
": Got out-of-bounds service code: " << std::dec << serviceCode <<
" (counter: " << serviceCodeCounter <<
"), ignored");
884 if (serviceCodeCounter>0 && serviceCode<32) {
885 if (serviceCode!=14) {
887 if (
static_cast<int>(offlineIdHash)>155 &&
static_cast<int>(offlineIdHash)<436) {
890 int indexSvcCounter = indexOffset+serviceCode*280*2+2*(
static_cast<int>(offlineIdHash)-156)+chFE;
892 bsErrWord[indexSvcCounter] = serviceCodeCounter;
899 ATH_MSG_VERBOSE(
"Decoding Pixel FEflag word: 0x" << std::hex << rawDataWord << std::dec );
902 FEFlags = FEFlags & 0xff;
903 if ((MCCFlags | FEFlags) != 0) {
904 sc = StatusCode::RECOVERABLE;
905 errorRecoverable = errorRecoverable | (MCCFlags << 12) | (FEFlags << 4);
907 static constexpr std::array<unsigned long long, 8> bitPosition {0_BIT, 1_BIT, 2_BIT, 3_BIT, 4_BIT, 5_BIT, 6_BIT, 7_BIT};
908 for (
const auto thisBit:bitPosition){
913 if ( MCCFlags & 0xff or FEFlags & 0xf3 ) {
918 if (indexModule>-1) {
955 ATH_MSG_DEBUG(
"Disabled Pixel chip " << ((rawDataWord & 0x0F000000) >> 24) );
964 are_4condensed_words =
false;
970 generalwarning(
"In ROB 0x" << std::hex << robId <<
", FE 0x" << mLink <<
": Unknown word type found, 0x" << std::hex << rawDataWord << std::dec <<
", ignoring");
981 if (isIBLModule || isDBMModule) {
986 for (
size_t i=0; i<static_cast<size_t>(bsErrWord.size());
i++) {
987 if (bsErrWord[
i]>0) {
992 if (
sc == StatusCode::RECOVERABLE) {
994 if (errorRecoverable == (3 << 20) ){
996 return StatusCode::SUCCESS;
998 ATH_MSG_DEBUG(
"Recoverable errors found in PixelRodDecoder, errorcode: " << errorRecoverable );
1010 return linkNum & 0x7;
1018 return (linkNum >> 3) & 0x3;
1029 return ((word >> PRB_BCIDskip_IBL) & PRB_BCIDmask_IBL);
1037 return ((word >> PRB_L1IDskip_IBL) & PRB_L1IDmask_IBL);
1045 return ((word >> PRB_FeI4BFLAGskip_IBL) & PRB_FeI4BFLAGmask_IBL);
1053 return ((word >> PRB_MODULEskip_IBL) & PRB_MODULEmask_IBL);
1061 return ((word >> PRB_BCIDskip) & PRB_BCIDmask);
1069 return ((word >> PRB_L1IDskip) & PRB_L1IDmask);
1077 return ((word >> PRB_L1IDSKIPskip) & PRB_L1IDSKIPmask);
1085 return ((word >> PRB_MODULEskip) & PRB_MODULEmask);
1093 return ((word >> PRB_HEADERERRORSskip) & PRB_HEADERERRORSmask);
1106 return ((word >> PRB_ROWskip_IBL) & PRB_ROWmask_IBL);
1109 return ((word >> PRB_ROWskip) & PRB_ROWmask);
1118 return ((word >> PRB_COLUMNskip_IBL) & PRB_COLUMNmask_IBL);
1121 return ((word >> PRB_COLUMNskip) & PRB_COLUMNmask);
1130 uint32_t Tot8Bits = ((word >> PRB_TOTskip_IBL) & PRB_TOTmask_IBL);
1134 return ((word >> PRB_TOTskip) & PRB_TOTmask);
1142 return ((word >> PRB_LINKNUMHITskip_IBL) & PRB_LINKNUMHITmask_IBL);
1149 return ((word >> PRB_FEskip) & PRB_FEmask);
1158 return ((word >> PRB_SKIPPEDTRIGGERTRAILERskip_IBL) & PRB_SKIPPEDTRIGGERTRAILERmask_IBL);
1165 return ((word >> PRB_TRAILERERRORSskip_IBL) & PRB_TRAILERERRORSmask_IBL);
1172 return ((word >> PRB_LINKNUMTRAILERskip_IBL) & PRB_LINKNUMTRAILERmask_IBL);
1180 return ((word >> PRB_BCIDSKIPTRAILERskip_IBL) & PRB_BCIDSKIPTRAILERmask_IBL);
1188 return ((word >> PRB_CONDENSEDMODEskip_IBL) & PRB_CONDENSEDMODEmask_IBL);
1196 return ((word >> PRB_TRAILERERRORSskip) & PRB_TRAILERERRORSmask);
1203 uint32_t flipword = ((word >> PRB_TRAILERBITFLIPskip) & PRB_TRAILERBITFLIPmask);
1205 if (flipword != 0) {
1206 for (
int i=0;
i<=25;
i++){
1207 if (flipword & 1) errorcount++;
1220 return((word >> PRB_SERVICECODECOUNTERskip_IBL) & PRB_SERVICECODECOUNTERmask_IBL);
1227 return((word >> PRB_SERVICECODEskip_IBL) & PRB_SERVICECODEmask_IBL);
1234 return((word >> PRB_LINKNUMBERFEFLAGskip_IBL) & PRB_LINKNUMBERFEFLAGmask_IBL);
1242 return ((word >> PRB_FEFlagskip2) & PRB_FEFlagmask2);
1249 return ((word >> PRB_MCCFlagskip) & PRB_MCCFlagmask);
1257 if ((rawDataWord & PRB_DATAMASK) == PRB_RAWDATA )
return PRB_RAWDATA;
1258 if (rawDataWord == PRB_TIMEOUT)
return PRB_TIMEOUT;
1260 if ((rawDataWord & PRB_DATAMASK) == PRB_LINKHEADER)
return PRB_LINKHEADER;
1261 if (((rawDataWord & PRB_FEERRORMASK) == PRB_FEERROR2) && ((rawDataWord & PRB_FEERROR2CHECK) == PRB_FEERROR2CHECK))
return PRB_FEERROR2;
1262 if (((rawDataWord & PRB_DATAMASK) == PRB_FEERROR_IBL))
return PRB_FEERROR2;
1263 if ((rawDataWord & PRB_HITMASK) == PRB_DATAWORD)
return PRB_DATAWORD;
1264 if ((rawDataWord & PRB_DATAMASK) == PRB_LINKTRAILER)
return PRB_LINKTRAILER;
1265 return PRB_UNKNOWNWORD;
1271 generalwarning(
"Evt marker encountered during loop on ROD datawords");
1275 generalwarning(
"ROB marker encountered during loop on ROD datawords");
1279 generalwarning(
"ROD marker encountered during loop on ROD datawords");
1286 unsigned int etc = 0, l1req = 0;
1288 if (serviceCode == 16) {
1289 etc = (serviceCodeCounter >> 4) & 0x1F;
1290 l1req = serviceCodeCounter & 0x7;
1298 switch (serviceCode) {
1300 ATH_MSG_DEBUG(
"BCID counter error (retrieved in IBL FE Flag word)");
1305 ATH_MSG_DEBUG(
"Hamming code error in word 0 (retrieved in IBL FE Flag word)");
1310 ATH_MSG_DEBUG(
"Hamming code error in word 1 (retrieved in IBL FE Flag word)");
1315 ATH_MSG_DEBUG(
"Hamming code error in word 2 (retrieved in IBL FE Flag word)");
1320 ATH_MSG_DEBUG(
"L1_in counter error (retrieved in IBL FE Flag word)");
1325 ATH_MSG_DEBUG(
"L1 request counter error (retrieved in IBL FE Flag word)");
1330 ATH_MSG_DEBUG(
"L1 register error (retrieved in IBL FE Flag word)");
1335 ATH_MSG_DEBUG(
"L1 Trigger ID error (retrieved in IBL FE Flag word)");
1340 ATH_MSG_DEBUG(
"Readout processor error (retrieved in IBL FE Flag word)");
1345 ATH_MSG_DEBUG(
"Fifo_Full flag pulsed (retrieved in IBL FE Flag word)");
1349 ATH_MSG_DEBUG(
"HitOr bus pulsed (retrieved in IBL FE Flag word)");
1356 ATH_MSG_DEBUG(
"Received invalid service code: " << serviceCode <<
" (payload = " << serviceCodeCounter <<
")");
1364 ATH_MSG_DEBUG(
"Skipped trigger counter (retrieved in IBL FE Flag word). There are " << serviceCodeCounter <<
" skipped triggers.");
1369 ATH_MSG_DEBUG(
"Truncated event flag: ETC = " << etc <<
", L1Req = " << l1req);
1378 ATH_MSG_DEBUG(
"Received invalid service code: " << serviceCode <<
" (payload = " << serviceCodeCounter <<
")");
1382 ATH_MSG_DEBUG(
"Reset bar RA2b pulsed (retrieved in IBL FE Flag word)");
1386 ATH_MSG_DEBUG(
"PLL generated clock phase faster than reference (retrieved in IBL FE Flag word)");
1390 ATH_MSG_DEBUG(
"Reference clock phase faster than PLL (retrieved in IBL FE Flag word)");
1394 ATH_MSG_DEBUG(
"Triple redundant mismatch (retrieved in IBL FE Flag word)");
1399 ATH_MSG_DEBUG(
"Write register data error (retrieved in IBL FE Flag word)");
1404 ATH_MSG_DEBUG(
"Address error (retrieved in IBL FE Flag word)");
1409 ATH_MSG_DEBUG(
"Other command decoder error- see CMD section (retrieved in IBL FE Flag word)");
1414 ATH_MSG_DEBUG(
"Bit flip detected in command decoder input stream (retrieved in IBL FE Flag word)");
1419 ATH_MSG_DEBUG(
"SEU upset detected in command decoder (triple redundant mismatch) (retrieved in IBL FE Flag word)");
1424 ATH_MSG_DEBUG(
"Data bus address error (retrieved in IBL FE Flag word)");
1429 ATH_MSG_DEBUG(
"Triple redundant mismatch (retrieved in IBL FE Flag word)");
1441 if ( not isCorrupted )
1442 return StatusCode::SUCCESS;
1452 return StatusCode::SUCCESS;
1457 unsigned int nFrags = 0;
1458 bool foundIssue =
false;
1459 for (
unsigned int i = 0;
i < 8; ++
i) {
1461 if (nFragmentsPerFE[
i] != 0) nFrags = nFragmentsPerFE[
i];
1464 if (nFragmentsPerFE[
i] != 0 && nFragmentsPerFE[
i] != nFrags) {
1469 if ( not foundIssue )
return;
1474 for (
unsigned int j = 0; j < 8; ++j) {
1475 if (nFragmentsPerFE[j] != 0) {
1479 generalwarning(
"In ROB 0x" << std::hex << robId <<
": got unequal number of headers per FE" << std::dec);
1486 unsigned int linknum40 = (onlineId>>24) & 0xFF;
1487 unsigned int linknum80 = (onlineId>>32) & 0xFF;
1489 if (fe == linknum40) {
1491 }
else if (fe == linknum80) {
1494 ATH_MSG_ERROR(
"Error in retrieving local FE-I4 number: linknumber " << fe <<
" not found in onlineID " << std::hex << onlineId);