Skip to content

Commit a10ab18

Browse files
mfasDashahor02
authored andcommitted
[EMCAL-918] Handling corrupted trailer words
Corrupted trailer words are words with the trailer marker but an invalid trailer word code, for which the trailer word type cannot be determined. Handled in the RawReaderMemory as MinorRawDataError (non- crashing)
1 parent 896f350 commit a10ab18

8 files changed

Lines changed: 111 additions & 21 deletions

File tree

Detectors/EMCAL/base/include/EMCALBase/RCUTrailer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ class RCUTrailer
153153
/// \return Size of the payload as number of 32 bit workds
154154
uint32_t getPayloadSize() const { return mPayloadSize; }
155155

156+
/// \brief Get number of corrupted trailer words (undefined trailer word code)
157+
/// \return Number of trailer word corruptions
158+
uint32_t getTrailerWordCorruptions() const { return mWordCorruptions; }
159+
156160
/// \brief Get the firmware version
157161
/// \return Firmware version
158162
uint8_t getFirmwareVersion() const { return mFirmwareVersion; }
@@ -438,6 +442,7 @@ class RCUTrailer
438442
uint8_t mFirmwareVersion = 0; ///< RCU firmware version
439443
uint32_t mTrailerSize = 0; ///< Size of the trailer (in number of 32 bit words)
440444
uint32_t mPayloadSize = 0; ///< Size of the payload (in nunber of 32 bit words)
445+
uint32_t mWordCorruptions = 0; ///< Number of trailer word corruptions (decoding only)
441446
uint32_t mFECERRA = 0; ///< contains errors related to ALTROBUS transactions
442447
uint32_t mFECERRB = 0; ///< contains errors related to ALTROBUS transactions
443448
ErrorCounters mErrorCounter = {0, 0}; ///< Error counter registers

Detectors/EMCAL/base/src/RCUTrailer.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <fmt/format.h>
1515
#include "CommonConstants/LHCConstants.h"
1616
#include "EMCALBase/RCUTrailer.h"
17+
#include <fairlogger/Logger.h>
1718

1819
using namespace o2::emcal;
1920

@@ -94,7 +95,8 @@ void RCUTrailer::constructFromRawPayload(const gsl::span<const uint32_t> payload
9495
mAltroConfig.mWord2 = parData & 0x1FFFFFF;
9596
break;
9697
default:
97-
std::cerr << "Undefined parameter code " << parCode << ", ignore it !\n";
98+
LOG(warning) << "RCU trailer: Undefined parameter code " << parCode << " in word " << index << " (0x" << std::hex << word << std::dec << "), ignoring word";
99+
mWordCorruptions++;
98100
break;
99101
}
100102
}

Detectors/EMCAL/reconstruction/include/EMCALReconstruction/RawDecodingError.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class RawDecodingError : public std::exception
4444
HEADER_INVALID, ///< Header in memory not belonging to requested superpage
4545
PAGE_START_INVALID, ///< Page position starting outside payload size
4646
PAYLOAD_INVALID, ///< Payload in memory not belonging to requested superpage
47-
TRAILER_DECODING ///< Inconsistent trailer in memory (several trailer words missing the trailer marker)
47+
TRAILER_DECODING, ///< Inconsistent trailer in memory (several trailer words missing the trailer marker)
48+
TRAILER_INCOMPLETE ///< Incomplete trailer words (i.e. registers)
4849
};
4950

5051
/// \brief Constructor
@@ -93,6 +94,8 @@ class RawDecodingError : public std::exception
9394
return 5;
9495
case ErrorType_t::TRAILER_DECODING:
9596
return 6;
97+
case ErrorType_t::TRAILER_INCOMPLETE:
98+
return 7;
9699
};
97100
// can never reach this, due to enum class
98101
// just to make Werror happy
@@ -101,15 +104,15 @@ class RawDecodingError : public std::exception
101104

102105
/// \brief Get the number of error codes
103106
/// \return Number of error codes
104-
static constexpr int getNumberOfErrorTypes() { return 7; }
107+
static constexpr int getNumberOfErrorTypes() { return 8; }
105108

106109
static ErrorType_t intToErrorType(unsigned int errortype)
107110
{
108111
assert(errortype < getNumberOfErrorTypes());
109112
static constexpr std::array<ErrorType_t, getNumberOfErrorTypes()> errortypes = {{ErrorType_t::PAGE_NOTFOUND, ErrorType_t::HEADER_DECODING,
110113
ErrorType_t::PAYLOAD_DECODING, ErrorType_t::HEADER_INVALID,
111114
ErrorType_t::PAGE_START_INVALID, ErrorType_t::PAYLOAD_INVALID,
112-
ErrorType_t::TRAILER_DECODING}};
115+
ErrorType_t::TRAILER_DECODING, ErrorType_t::TRAILER_INCOMPLETE}};
113116
return errortypes[errortype];
114117
}
115118

@@ -137,6 +140,8 @@ class RawDecodingError : public std::exception
137140
return "PayloadCorruption";
138141
case ErrorType_t::TRAILER_DECODING:
139142
return "TrailerDecoding";
143+
case ErrorType_t::TRAILER_INCOMPLETE:
144+
return "TrailerIncomplete";
140145
};
141146
return "Undefined error";
142147
}
@@ -177,6 +182,8 @@ class RawDecodingError : public std::exception
177182
return "Payload corruption";
178183
case ErrorType_t::TRAILER_DECODING:
179184
return "Trailer decoding";
185+
case ErrorType_t::TRAILER_INCOMPLETE:
186+
return "Trailer incomplete";
180187
};
181188
return "Undefined error";
182189
}
@@ -217,6 +224,8 @@ class RawDecodingError : public std::exception
217224
return "Access to payload not belonging to requested superpage";
218225
case ErrorType_t::TRAILER_DECODING:
219226
return "Inconsistent trailer in memory";
227+
case ErrorType_t::TRAILER_INCOMPLETE:
228+
return "Incomplete trailer";
220229
};
221230
return "Undefined error";
222231
}

Detectors/EMCAL/reconstruction/include/EMCALReconstruction/RawReaderMemory.h

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
#ifndef ALICEO2_EMCAL_RAWREADERMEMORY_H
1212
#define ALICEO2_EMCAL_RAWREADERMEMORY_H
1313

14+
#include <vector>
1415
#include <gsl/span>
1516
#include <Rtypes.h>
1617

1718
#include "EMCALBase/RCUTrailer.h"
1819
#include "EMCALReconstruction/RawBuffer.h"
20+
#include "EMCALReconstruction/RawDecodingError.h"
1921
#include "EMCALReconstruction/RawPayload.h"
2022
#include "Headers/RAWDataHeader.h"
2123
#include "Headers/RDHAny.h"
@@ -36,6 +38,46 @@ namespace emcal
3638
class RawReaderMemory
3739
{
3840
public:
41+
/// \class MinorError
42+
/// \brief Minor (non-crashing) raw decoding errors
43+
///
44+
/// Minor errors share the same codes as major raw decoding errors,
45+
/// however are not crashing.
46+
class MinorError
47+
{
48+
public:
49+
/// \brief Dummy constructor
50+
MinorError() = default;
51+
52+
/// \brief Main constructor
53+
/// \param errortype Type of the error
54+
/// \param feeID ID of the FEE equipment
55+
MinorError(RawDecodingError::ErrorType_t errortype, int feeID) : mErrorType(errortype), mFEEID(feeID) {}
56+
57+
/// \brief Destructor
58+
~MinorError() = default;
59+
60+
/// \brief Set the type of the error
61+
/// \param errortype Type of the error
62+
void setErrorType(RawDecodingError::ErrorType_t errortype) { mErrorType = errortype; }
63+
64+
/// \brief Set the ID of the FEE equipment
65+
/// \param feeID ID of the FEE
66+
void setFEEID(int feeID) { mFEEID = feeID; }
67+
68+
/// \brief Get type of the error
69+
/// \return Type of the error
70+
RawDecodingError::ErrorType_t getErrorType() const { return mErrorType; }
71+
72+
/// \brief Get ID of the FEE
73+
/// \return ID of the FEE
74+
int getFEEID() const { return mFEEID; }
75+
76+
private:
77+
RawDecodingError::ErrorType_t mErrorType; ///< Type of the error
78+
int mFEEID; ///< ID of the FEC responsible for the ERROR
79+
};
80+
3981
/// \brief Constructor
4082
RawReaderMemory(const gsl::span<const char> rawmemory);
4183

@@ -58,8 +100,7 @@ class RawReaderMemory
58100
/// \brief Read next payload from the stream
59101
///
60102
/// Read the next pages until the stop bit is found.
61-
void
62-
next();
103+
void next();
63104

64105
/// \brief Read the next page from the stream (single DMA page)
65106
/// \param resetPayload If true the raw payload is reset
@@ -85,6 +126,10 @@ class RawReaderMemory
85126
/// \return Raw Payload of the data until the stop bit is received.
86127
const RawPayload& getPayload() const { return mRawPayload; }
87128

129+
/// \brief Get minor (non-crashing) raw decoding errors
130+
/// \return Minor raw decoding errors
131+
gsl::span<const MinorError> getMinorErrors() const { return mMinorErrors; }
132+
88133
/// \brief Return size of the payload
89134
/// \return size of the payload
90135
int getPayloadSize() const { return mRawPayload.getPayloadSize(); }
@@ -123,6 +168,7 @@ class RawReaderMemory
123168
int mCurrentFEE = -1; ///< Current FEE in the data stream
124169
bool mRawHeaderInitialized = false; ///< RDH for current page initialized
125170
bool mPayloadInitialized = false; ///< Payload for current page initialized
171+
std::vector<MinorError> mMinorErrors; ///< Minor raw decoding errors
126172

127173
ClassDefNV(RawReaderMemory, 1);
128174
};

Detectors/EMCAL/reconstruction/src/RawReaderMemory.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <sstream>
1313
#include <string>
1414
#include "EMCALReconstruction/RawReaderMemory.h"
15-
#include "EMCALReconstruction/RawDecodingError.h"
1615
#include "DetectorsRaw/RDHUtils.h"
1716

1817
using namespace o2::emcal;
@@ -51,6 +50,7 @@ void RawReaderMemory::next()
5150
{
5251
mRawPayload.reset();
5352
mCurrentTrailer.reset();
53+
mMinorErrors.clear();
5454
bool isDataTerminated = false;
5555
do {
5656
nextPage(false);
@@ -150,6 +150,9 @@ void RawReaderMemory::nextPage(bool doResetPayload)
150150
mCurrentTrailer.setPayloadSize(mCurrentTrailer.getPayloadSize() + trailer.getPayloadSize());
151151
}
152152
payloadWithoutTrailer = gsl::span<const uint32_t>(mRawBuffer.getDataWords().data(), mRawBuffer.getDataWords().size() - trailer.getTrailerSize());
153+
if (trailer.getTrailerWordCorruptions()) {
154+
mMinorErrors.emplace_back(RawDecodingError::ErrorType_t::TRAILER_INCOMPLETE, mCurrentFEE);
155+
}
153156
} catch (RCUTrailer::Error& e) {
154157
throw RawDecodingError(RawDecodingError::ErrorType_t::TRAILER_DECODING, mCurrentFEE);
155158
}

Detectors/EMCAL/reconstruction/test/testRawDecodingError.cxx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,39 @@ void testThrow(RawDecodingError::ErrorType_t errtype, unsigned int feeID)
2828

2929
BOOST_AUTO_TEST_CASE(RawDecodingError_test)
3030
{
31-
BOOST_CHECK_EQUAL(RawDecodingError::getNumberOfErrorTypes(), 7);
32-
std::array<std::string, 7> errornames = {{"PageNotFound",
31+
BOOST_CHECK_EQUAL(RawDecodingError::getNumberOfErrorTypes(), 8);
32+
std::array<std::string, 8> errornames = {{"PageNotFound",
3333
"HeaderDecoding",
3434
"PayloadDecoding",
3535
"HeaderCorruption",
3636
"PageStartInvalid",
3737
"PayloadCorruption",
38-
"TrailerDecoding"}},
38+
"TrailerDecoding",
39+
"TrailerIncomplete"}},
3940
errortitles = {{"Page not found",
4041
"Header decoding",
4142
"Payload decoding",
4243
"Header corruption",
4344
"Page start invalid",
4445
"Payload corruption",
45-
"Trailer decoding"}},
46+
"Trailer decoding",
47+
"Trailer incomplete"}},
4648
errordescriptions = {{"Page with requested index not found",
4749
"RDH of page cannot be decoded",
4850
"Payload of page cannot be decoded",
4951
"Access to header not belonging to requested superpage",
5052
"Page decoding starting outside payload size",
5153
"Access to payload not belonging to requested superpage",
52-
"Inconsistent trailer in memory"}};
53-
std::array<RawDecodingError::ErrorType_t, 7> errortypes = {{
54-
RawDecodingError::ErrorType_t::PAGE_NOTFOUND,
55-
RawDecodingError::ErrorType_t::HEADER_DECODING,
56-
RawDecodingError::ErrorType_t::PAYLOAD_DECODING,
57-
RawDecodingError::ErrorType_t::HEADER_INVALID,
58-
RawDecodingError::ErrorType_t::PAGE_START_INVALID,
59-
RawDecodingError::ErrorType_t::PAYLOAD_INVALID,
60-
RawDecodingError::ErrorType_t::TRAILER_DECODING,
61-
}};
54+
"Inconsistent trailer in memory",
55+
"Incomplete trailer"}};
56+
std::array<RawDecodingError::ErrorType_t, 8> errortypes = {{RawDecodingError::ErrorType_t::PAGE_NOTFOUND,
57+
RawDecodingError::ErrorType_t::HEADER_DECODING,
58+
RawDecodingError::ErrorType_t::PAYLOAD_DECODING,
59+
RawDecodingError::ErrorType_t::HEADER_INVALID,
60+
RawDecodingError::ErrorType_t::PAGE_START_INVALID,
61+
RawDecodingError::ErrorType_t::PAYLOAD_INVALID,
62+
RawDecodingError::ErrorType_t::TRAILER_DECODING,
63+
RawDecodingError::ErrorType_t::TRAILER_INCOMPLETE}};
6264
for (int errortype = 0; errortype < RawDecodingError::getNumberOfErrorTypes(); errortype++) {
6365
BOOST_CHECK_EQUAL(RawDecodingError::ErrorTypeToInt(errortypes[errortype]), errortype);
6466
BOOST_CHECK_EQUAL(RawDecodingError::intToErrorType(errortype), errortypes[errortype]);

Detectors/EMCAL/workflow/include/EMCALWorkflow/RawToCellConverterSpec.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "EMCALBase/Geometry.h"
2626
#include "EMCALBase/Mapper.h"
2727
#include "EMCALReconstruction/CaloRawFitter.h"
28+
#include "EMCALReconstruction/RawReaderMemory.h"
2829
#include "EMCALReconstruction/RecoContainer.h"
2930
#include "EMCALReconstruction/ReconstructionErrors.h"
3031
#include "EMCALWorkflow/CalibLoader.h"
@@ -236,6 +237,8 @@ class RawToCellConverterSpec : public framework::Task
236237

237238
void handlePageError(const RawDecodingError& e);
238239

240+
void handleMinorPageError(const RawReaderMemory::MinorError& e);
241+
239242
header::DataHeader::SubSpecificationType mSubspecification = 0; ///< Subspecification for output channels
240243
int mNoiseThreshold = 0; ///< Noise threshold in raw fit
241244
int mNumErrorMessages = 0; ///< Current number of error messages

Detectors/EMCAL/workflow/src/RawToCellConverterSpec.cxx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ void RawToCellConverterSpec::run(framework::ProcessingContext& ctx)
168168
// the page format does not follow the expected format
169169
continue;
170170
}
171+
for (auto& e : rawreader.getMinorErrors()) {
172+
handleMinorPageError(e);
173+
// For minor errors we do not need to skip the page, just print and send the error to the QC
174+
}
171175

172176
auto& header = rawreader.getRawHeader();
173177
auto triggerBC = raw::RDHUtils::getTriggerBC(header);
@@ -691,6 +695,22 @@ void RawToCellConverterSpec::handlePageError(const RawDecodingError& e)
691695
}
692696
}
693697

698+
void RawToCellConverterSpec::handleMinorPageError(const RawReaderMemory::MinorError& e)
699+
{
700+
if (mCreateRawDataErrors) {
701+
mOutputDecoderErrors.emplace_back(e.getFEEID(), ErrorTypeFEE::ErrorSource_t::PAGE_ERROR, RawDecodingError::ErrorTypeToInt(e.getErrorType()), -1, -1);
702+
}
703+
if (mNumErrorMessages < mMaxErrorMessages) {
704+
LOG(warning) << " Page decoding: " << RawDecodingError::getErrorCodeDescription(e.getErrorType()) << " in FEE ID " << e.getFEEID();
705+
mNumErrorMessages++;
706+
if (mNumErrorMessages == mMaxErrorMessages) {
707+
LOG(warning) << "Max. amount of error messages (" << mMaxErrorMessages << " reached, further messages will be suppressed";
708+
}
709+
} else {
710+
mErrorMessagesSuppressed++;
711+
}
712+
}
713+
694714
void RawToCellConverterSpec::sendData(framework::ProcessingContext& ctx, const std::vector<o2::emcal::Cell>& cells, const std::vector<o2::emcal::TriggerRecord>& triggers, const std::vector<ErrorTypeFEE>& decodingErrors) const
695715
{
696716
constexpr auto originEMC = o2::header::gDataOriginEMC;

0 commit comments

Comments
 (0)