diff --git a/Detectors/MUON/MCH/Raw/Decoder/include/MCHRawDecoder/DataDecoder.h b/Detectors/MUON/MCH/Raw/Decoder/include/MCHRawDecoder/DataDecoder.h index 1e98c5717c8af..258d62d9566b4 100644 --- a/Detectors/MUON/MCH/Raw/Decoder/include/MCHRawDecoder/DataDecoder.h +++ b/Detectors/MUON/MCH/Raw/Decoder/include/MCHRawDecoder/DataDecoder.h @@ -158,8 +158,12 @@ class DataDecoder /// Must be called before processing the TmeFrame buffer void setFirstOrbitInTF(uint32_t orbit); - /// Decode one TimeFrame buffer and fill the vector of digits - void decodeBuffer(gsl::span buf); + /** Decode one TimeFrame buffer and fill the vector of digits. + * @return true if decoding went ok, or false otherwise. + * if false is returned, the decoding of the (rest of the) TF should be + * abandonned simply. + */ + bool decodeBuffer(gsl::span buf); /// Functions to set and get the calibration offset for the SAMPA time computation void setSampaBcOffset(uint32_t offset) { mSampaTimeOffset = offset; } diff --git a/Detectors/MUON/MCH/Raw/Decoder/include/MCHRawDecoder/ErrorCodes.h b/Detectors/MUON/MCH/Raw/Decoder/include/MCHRawDecoder/ErrorCodes.h index f9febc570694e..693e224382250 100644 --- a/Detectors/MUON/MCH/Raw/Decoder/include/MCHRawDecoder/ErrorCodes.h +++ b/Detectors/MUON/MCH/Raw/Decoder/include/MCHRawDecoder/ErrorCodes.h @@ -22,20 +22,20 @@ namespace raw { enum ErrorCodes { - ErrorParity = 1, // 1 - ErrorHammingCorrectable = 1 << 1, // 2 - ErrorHammingUncorrectable = 1 << 2, // 4 - ErrorBadClusterSize = 1 << 3, // 8 - ErrorBadPacketType = 1 << 4, // 16 - ErrorBadHeartBeatPacket = 1 << 5, // 32 - ErrorBadIncompleteWord = 1 << 6, // 64 - ErrorTruncatedData = 1 << 7, // 128 - ErrorBadELinkID = 1 << 8, // 256 - ErrorBadLinkID = 1 << 9, // 512 - ErrorUnknownLinkID = 1 << 10, // 1024 - ErrorBadDigitTime = 1 << 11, // 2048 - ErrorInvalidDigitTime = 1 << 12 // 4096 - + ErrorParity = 1, // 1 + ErrorHammingCorrectable = 1 << 1, // 2 + ErrorHammingUncorrectable = 1 << 2, // 4 + ErrorBadClusterSize = 1 << 3, // 8 + ErrorBadPacketType = 1 << 4, // 16 + ErrorBadHeartBeatPacket = 1 << 5, // 32 + ErrorBadIncompleteWord = 1 << 6, // 64 + ErrorTruncatedData = 1 << 7, // 128 + ErrorBadELinkID = 1 << 8, // 256 + ErrorBadLinkID = 1 << 9, // 512 + ErrorUnknownLinkID = 1 << 10, // 1024 + ErrorBadDigitTime = 1 << 11, // 2048 + ErrorInvalidDigitTime = 1 << 12, // 4096 + ErrorNonRecoverableDecodingError = 1 << 13 // 8192 }; uint32_t getErrorCodesSize(); diff --git a/Detectors/MUON/MCH/Raw/Decoder/src/DataDecoder.cxx b/Detectors/MUON/MCH/Raw/Decoder/src/DataDecoder.cxx index 36891adf1dd79..c4285ce15c2c1 100644 --- a/Detectors/MUON/MCH/Raw/Decoder/src/DataDecoder.cxx +++ b/Detectors/MUON/MCH/Raw/Decoder/src/DataDecoder.cxx @@ -24,6 +24,7 @@ #include "CommonConstants/LHCConstants.h" #include "DetectorsRaw/RDHUtils.h" #include "DetectorsRaw/HBFUtils.h" +#include "MCHBase/DecoderError.h" #include "MCHMappingInterface/Segmentation.h" #include "Framework/Logger.h" #include "MCHRawDecoder/ErrorCodes.h" @@ -264,7 +265,7 @@ void DataDecoder::setFirstOrbitInTF(uint32_t orbit) //_________________________________________________________________________________________________ -void DataDecoder::decodeBuffer(gsl::span buf) +bool DataDecoder::decodeBuffer(gsl::span buf) { if (mDebug) { std::cout << "\n\n============================\nStart of new buffer\n"; @@ -289,7 +290,12 @@ void DataDecoder::decodeBuffer(gsl::span buf) auto pageSize = o2::raw::RDHUtils::getOffsetToNext(rdh); gsl::span page(reinterpret_cast(rdh), pageSize); - decodePage(page); + try { + decodePage(page); + } catch (const std::exception& e) { + mErrors.emplace_back(DecoderError(0, 0, 0, ErrorNonRecoverableDecodingError)); + return false; + } pageStart += pageSize; } @@ -300,6 +306,7 @@ void DataDecoder::decodeBuffer(gsl::span buf) std::cout << "[decodeBuffer] mDigits size: " << mDigits.size() << std::endl; dumpDigits(); } + return true; } //_________________________________________________________________________________________________ diff --git a/Detectors/MUON/MCH/Raw/Decoder/src/ErrorCodes.cxx b/Detectors/MUON/MCH/Raw/Decoder/src/ErrorCodes.cxx index 91d9ca0fe7151..521f57499486c 100644 --- a/Detectors/MUON/MCH/Raw/Decoder/src/ErrorCodes.cxx +++ b/Detectors/MUON/MCH/Raw/Decoder/src/ErrorCodes.cxx @@ -20,7 +20,7 @@ namespace raw uint32_t getErrorCodesSize() { - return 13; + return 14; } void append(const char* msg, std::string& to) @@ -76,6 +76,9 @@ std::string errorCodeAsString(uint32_t ec) if (ec & ErrorInvalidDigitTime) { append("Invalid Digit Time", msg); } + if (ec & ErrorNonRecoverableDecodingError) { + append("Non Recoverable", msg); + } return msg; } diff --git a/Detectors/MUON/MCH/Workflow/src/DataDecoderSpec.cxx b/Detectors/MUON/MCH/Workflow/src/DataDecoderSpec.cxx index 689251847a776..dd22a70862326 100644 --- a/Detectors/MUON/MCH/Workflow/src/DataDecoderSpec.cxx +++ b/Detectors/MUON/MCH/Workflow/src/DataDecoderSpec.cxx @@ -122,7 +122,8 @@ class DataDecoderTask // get the input buffer auto& inputs = pc.inputs(); DPLRawParser parser(inputs, o2::framework::select(mInputSpec.c_str())); - for (auto it = parser.begin(), end = parser.end(); it != end; ++it) { + bool abort{false}; + for (auto it = parser.begin(), end = parser.end(); it != end && abort == false; ++it) { auto const* raw = it.raw(); if (!raw) { continue; @@ -130,7 +131,11 @@ class DataDecoderTask size_t payloadSize = it.size(); gsl::span buffer(reinterpret_cast(raw), sizeof(RDH) + payloadSize); - mDecoder->decodeBuffer(buffer); + bool ok = mDecoder->decodeBuffer(buffer); + if (!ok) { + LOG(alarm) << "critical decoding error : aborting this TF decoding\n"; + abort = true; + } } }