Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRRTF-154: MCH raw data decoder now catches exceptions #8664

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<const std::byte> 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<const std::byte> buf);

/// Functions to set and get the calibration offset for the SAMPA time computation
void setSampaBcOffset(uint32_t offset) { mSampaTimeOffset = offset; }
Expand Down
28 changes: 14 additions & 14 deletions Detectors/MUON/MCH/Raw/Decoder/include/MCHRawDecoder/ErrorCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 9 additions & 2 deletions Detectors/MUON/MCH/Raw/Decoder/src/DataDecoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -264,7 +265,7 @@ void DataDecoder::setFirstOrbitInTF(uint32_t orbit)

//_________________________________________________________________________________________________

void DataDecoder::decodeBuffer(gsl::span<const std::byte> buf)
bool DataDecoder::decodeBuffer(gsl::span<const std::byte> buf)
{
if (mDebug) {
std::cout << "\n\n============================\nStart of new buffer\n";
Expand All @@ -289,7 +290,12 @@ void DataDecoder::decodeBuffer(gsl::span<const std::byte> buf)
auto pageSize = o2::raw::RDHUtils::getOffsetToNext(rdh);

gsl::span<const std::byte> page(reinterpret_cast<const std::byte*>(rdh), pageSize);
decodePage(page);
try {
decodePage(page);
} catch (const std::exception& e) {
mErrors.emplace_back(DecoderError(0, 0, 0, ErrorNonRecoverableDecodingError));
return false;
}

pageStart += pageSize;
}
Expand All @@ -300,6 +306,7 @@ void DataDecoder::decodeBuffer(gsl::span<const std::byte> buf)
std::cout << "[decodeBuffer] mDigits size: " << mDigits.size() << std::endl;
dumpDigits();
}
return true;
}

//_________________________________________________________________________________________________
Expand Down
5 changes: 4 additions & 1 deletion Detectors/MUON/MCH/Raw/Decoder/src/ErrorCodes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace raw

uint32_t getErrorCodesSize()
{
return 13;
return 14;
}

void append(const char* msg, std::string& to)
Expand Down Expand Up @@ -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;
}

Expand Down
9 changes: 7 additions & 2 deletions Detectors/MUON/MCH/Workflow/src/DataDecoderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,20 @@ 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;
}
size_t payloadSize = it.size();

gsl::span<const std::byte> buffer(reinterpret_cast<const std::byte*>(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;
}
}
}

Expand Down