@@ -240,6 +240,7 @@ GPUdii() void GPUTPCCFDecodeZSLink::Thread<0>(int nBlocks, int nThreads, int iBl
240240#endif
241241 }
242242
243+ int nDecoded = 0 ;
243244 const auto * decHdr = ConsumeHeader<TPCZSHDRV2 >(page);
244245 ConsumeBytes (page, decHdr->firstZSDataOffset * 16 );
245246
@@ -257,6 +258,7 @@ GPUdii() void GPUTPCCFDecodeZSLink::Thread<0>(int nBlocks, int nThreads, int iBl
257258 unsigned int nAdc = CAMath::Popcount (channelMask[0 ]) + CAMath::Popcount (channelMask[1 ]) + CAMath::Popcount (channelMask[2 ]);
258259
259260 bool inFragment = fragment.contains (timeBin);
261+ nDecoded += nAdc;
260262
261263 // TimeBin not in fragment: Skip this timebin header and fill positions with dummy values instead
262264 if (not inFragment) {
@@ -293,6 +295,17 @@ GPUdii() void GPUTPCCFDecodeZSLink::Thread<0>(int nBlocks, int nThreads, int iBl
293295#endif
294296 pageDigitOffset += nAdc;
295297 } // for (unsigned int t = 0; t < decHdr->nTimebinHeaders; t++)
298+ (void )nDecoded;
299+ #ifdef GPUCA_CHECK_TPCZS_CORRUPTION
300+ if (iThread == 0 && nDecoded != decHdr->nADCsamples ) {
301+ clusterer.raiseError (GPUErrors::ERROR_TPCZS_INVALID_NADC , clusterer.mISlice , decHdr->nADCsamples , nDecoded);
302+ /* #ifndef GPUCA_GPUCODE
303+ FILE* foo = fopen("dump.bin", "w+b");
304+ fwrite(pageSrc, 1, o2::raw::RDHUtils::getMemorySize(*rdHdr), foo);
305+ fclose(foo);
306+ #endif*/
307+ }
308+ #endif
296309 } // [CPU] for (unsigned int j = minJ; j < maxJ; j++)
297310 } // [CPU] for (unsigned int i = clusterer.mMinMaxCN[endpoint].minC; i < clusterer.mMinMaxCN[endpoint].maxC; i++)
298311}
@@ -447,12 +460,14 @@ GPUd() void GPUTPCCFDecodeZSLink::WriteCharge(processorType& clusterer, unsigned
447460{
448461 const unsigned int slice = clusterer.mISlice ;
449462 ChargePos* positions = clusterer.mPpositions ;
450- if (padAndRow.getRow () >= GPUCA_ROW_COUNT ) { // FIXME: to be removed once TPC does not send corrupt data any more
463+ #ifdef GPUCA_CHECK_TPCZS_CORRUPTION
464+ if (padAndRow.getRow () >= GPUCA_ROW_COUNT ) {
451465 constexpr ChargePos INVALID_POS (UCHAR_MAX , UCHAR_MAX , INVALID_TIME_BIN );
452466 positions[positionOffset] = INVALID_POS ;
467+ clusterer.raiseError (GPUErrors::ERROR_CF_ROW_CLUSTER_OVERFLOW , clusterer.mISlice * 1000 + padAndRow.getRow (), 0 , 0 );
453468 return ;
454469 }
455-
470+ # endif
456471 Array2D<PackedCharge> chargeMap (reinterpret_cast <PackedCharge*>(clusterer.mPchargeMap ));
457472
458473 ChargePos pos (padAndRow.getRow (), padAndRow.getPad (), localTime);
0 commit comments