@@ -273,33 +273,44 @@ class AlpideCoder
273273 uint16_t row = pixID >> 1 ;
274274 // abs id of left column in double column
275275 uint16_t colD = (region * NDColInReg + dColID) << 1 ; // TODO consider <<4 instead of *NDColInReg?
276- bool rightC = (row & 0x1 ) ? !(pixID & 0x1 ) : (pixID & 0x1 ); // true for right column / lalse for left
276+ bool rightC = (row & 0x1 ) ? !(pixID & 0x1 ) : (pixID & 0x1 ); // true for right column / false for left
277277
278- if (row == rowPrev && colD == colDPrev) {
279- // this is a special test to exclude repeated data of the same pixel fired
278+ if (colD == colDPrev) {
279+ bool skip = false ;
280+ if (row == rowPrev) { // this is a special test to exclude repeated data of the same pixel fired
281+ skip = true ;
280282#ifdef ALPIDE_DECODING_STAT
281- chipData.setError (ChipStat::RepeatingPixel);
282- chipData.addErrorInfo ((uint64_t (colD + rightC) << 16 ) | uint64_t (row));
283+ chipData.setError (ChipStat::RepeatingPixel);
284+ chipData.addErrorInfo ((uint64_t (colD + rightC) << 16 ) | uint64_t (row));
283285#endif
284- if ((dataS & (~MaskDColID)) == DATALONG) { // skip pattern w/o decoding
285- uint8_t hitsPattern = 0 ;
286- if (!buffer.next (hitsPattern)) {
286+ } else if (rowPrev < 0xffff && row < rowPrev) {
287287#ifdef ALPIDE_DECODING_STAT
288- chipData.setError (ChipStat::TruncatedLondData);
288+ chipData.setError (ChipStat::DecreasingRow);
289+ chipData.addErrorInfo ((uint64_t (colD + rightC) << 16 ) | uint64_t (row));
289290#endif
290- return unexpectedEOF (" CHIP_DATA_LONG:Pattern" ); // abandon cable data
291- }
292- if (hitsPattern & (~MaskHitMap)) {
291+ return unexpectedEOF (" DECREASING_ROW" ); // abandon cable data
292+ }
293+ if (skip) {
294+ if ((dataS & (~MaskDColID)) == DATALONG) { // skip pattern w/o decoding
295+ uint8_t hitsPattern = 0 ;
296+ if (!buffer.next (hitsPattern)) {
293297#ifdef ALPIDE_DECODING_STAT
294- chipData.setError (ChipStat::WrongDataLongPattern );
298+ chipData.setError (ChipStat::TruncatedLondData );
295299#endif
296- return unexpectedEOF (" CHIP_DATA_LONG:Pattern" ); // abandon cable data
300+ return unexpectedEOF (" CHIP_DATA_LONG:Pattern" ); // abandon cable data
301+ }
302+ if (hitsPattern & (~MaskHitMap)) {
303+ #ifdef ALPIDE_DECODING_STAT
304+ chipData.setError (ChipStat::WrongDataLongPattern);
305+ #endif
306+ return unexpectedEOF (" CHIP_DATA_LONG:Pattern" ); // abandon cable data
307+ }
308+ LOGP (debug, " hitsPattern: {:#b} expect {:#b}" , int (hitsPattern), int (expectInp));
297309 }
298- LOGP (debug, " hitsPattern: {:#b} expect {:#b}" , int (hitsPattern), int (expectInp));
310+ expectInp = ExpectChipTrailer | ExpectData | ExpectRegion;
311+ continue ; // end of DATA(SHORT or LONG) processing
299312 }
300- expectInp = ExpectChipTrailer | ExpectData | ExpectRegion;
301- continue ; // end of DATA(SHORT or LONG) processing
302- } else if (colD != colDPrev) {
313+ } else {
303314 // if we start new double column, transfer the hits accumulated in the right column buffer of prev. double column
304315 if (colD < colDPrev && colDPrev != 0xffff ) {
305316#ifdef ALPIDE_DECODING_STAT
@@ -321,7 +332,7 @@ class AlpideCoder
321332 // are first collected in the temporary buffer
322333 // real columnt id is col = colD + 1;
323334 if (rightC) {
324- rightColHits[nRightCHits++] = row; // col = colD+1
335+ rightColHits[nRightCHits++] = row;
325336 } else {
326337 addHit (chipData, row, colD); // col = colD, left column hits are added directly to the container
327338 }
@@ -355,7 +366,7 @@ class AlpideCoder
355366 if (rightC) { // same as above
356367 rightColHits[nRightCHits++] = rowE;
357368 } else {
358- addHit (chipData, rowE, colD + rightC ); // left column hits are added directly to the container
369+ addHit (chipData, rowE, colD); // left column hits are added directly to the container
359370 }
360371 }
361372 }
0 commit comments