Project
Loading...
Searching...
No Matches
AltroDecoder.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef ALICEO2_EMCAL_ALTRODECODER_H
12#define ALICEO2_EMCAL_ALTRODECODER_H
13
14#include <climits>
15#include <exception>
16#include <iosfwd>
17#include <gsl/span>
18#include <string>
19#include <string_view>
24
25namespace o2
26{
27namespace emcal
28{
29
33class AltroDecoderError : public std::exception
34{
35 public:
48
56 AltroDecoderError(ErrorType_t errtype, const std::string_view message) : mErrorType(errtype), mErrorMessage(message) {}
57
59 ~AltroDecoderError() noexcept override = default;
60
63 const char* what() const noexcept override { return mErrorMessage.data(); }
64
67 static int errorTypeToInt(ErrorType_t errortype);
68
71 static ErrorType_t intToErrorType(int errornumber);
72
75 static constexpr int getNumberOfErrorTypes() noexcept { return 8; }
76
79 const ErrorType_t getErrorType() const noexcept { return mErrorType; }
80
88 static const char* getErrorTypeName(ErrorType_t errortype);
89
97 static const char* getErrorTypeName(unsigned int errortype)
98 {
99 return getErrorTypeName(intToErrorType(errortype));
100 }
101
109 static const char* getErrorTypeTitle(ErrorType_t errortype);
110
118 static const char* getErrorTypeTitle(unsigned int errortype)
119 {
120 return getErrorTypeTitle(intToErrorType(errortype));
121 }
122
130 static const char* getErrorTypeDescription(ErrorType_t errortype);
131
139 static const char* getErrorTypeDescription(unsigned int errortype)
140 {
141 return getErrorTypeDescription(intToErrorType(errortype));
142 }
143
144 private:
145 ErrorType_t mErrorType;
146 std::string mErrorMessage;
147};
148
153{
154 public:
167
170
175 MinorAltroDecodingError(ErrorType_t errtype, uint32_t channelHeader, uint32_t payloadword) : mErrorType(errtype),
176 mChannelHeader(channelHeader),
177 mPayloadWord(payloadword)
178 {
179 }
180
182 ~MinorAltroDecodingError() noexcept = default;
183
186 uint32_t getChannelHeader() const noexcept { return mChannelHeader; };
187
190 uint32_t getPayloadWord() const noexcept { return mPayloadWord; }
191
194 ErrorType_t getErrorType() const noexcept { return mErrorType; }
195
202 std::string what() const noexcept;
203
206 static int errorTypeToInt(ErrorType_t errortype);
207
210 static ErrorType_t intToErrorType(int errornumber);
211
214 static constexpr int getNumberOfErrorTypes() noexcept { return 8; }
215
223 static const char* getErrorTypeName(ErrorType_t errortype);
224
232 static const char* getErrorTypeName(unsigned int errortype)
233 {
234 return getErrorTypeName(intToErrorType(errortype));
235 }
236
244 static const char* getErrorTypeTitle(ErrorType_t errortype);
245
253 static const char* getErrorTypeTitle(unsigned int errortype)
254 {
255 return getErrorTypeTitle(intToErrorType(errortype));
256 }
257
265 static const char* getErrorTypeDescription(ErrorType_t errortype);
266
274 static const char* getErrorTypeDescription(unsigned int errortype)
275 {
276 return getErrorTypeDescription(intToErrorType(errortype));
277 }
278
279 private:
280 ErrorType_t mErrorType;
281 uint32_t mChannelHeader;
282 uint32_t mPayloadWord;
283};
284
299
301{
302 public:
306
308 ~AltroDecoder() = default;
309
315 void setMaxBunchLength(int maxBunchLength) { mMaxBunchLength = maxBunchLength; }
316
326 void decode();
327
331 const RCUTrailer& getRCUTrailer() const;
332
336 const std::vector<Channel>& getChannels() const;
337
339 void readRCUTrailer();
340
342 void readChannels();
343
346 const std::vector<MinorAltroDecodingError>& getMinorDecodingErrors() const { return mMinorDecodingErrors; }
347
348 private:
354 void checkRCUTrailer();
355
359 bool checkChannelHWAddress(int hwaddress);
360
361 RawReaderMemory& mRawReader;
362 RCUTrailer mRCUTrailer;
363 std::vector<Channel> mChannels;
364 std::vector<MinorAltroDecodingError> mMinorDecodingErrors;
365 bool mChannelsInitialized = false;
366 unsigned int mMaxBunchLength = UINT_MAX;
367
368 ClassDefNV(AltroDecoder, 1);
369};
370
378std::ostream& operator<<(std::ostream& stream, const AltroDecoderError& error);
379
387std::ostream& operator<<(std::ostream& stream, const AltroDecoderError::ErrorType_t& errortype);
388
396std::ostream& operator<<(std::ostream& stream, const MinorAltroDecodingError& error);
397
405std::ostream& operator<<(std::ostream& stream, const MinorAltroDecodingError::ErrorType_t& errortype);
406
407} // namespace emcal
408
409} // namespace o2
410
411#endif
Error handling of the ALTRO Decoder.
ErrorType_t
Error codes connected with the ALTRO decoding.
@ ALTRO_BUNCH_HEADER_ERROR
ALTRO bunch header cannot be decoded or is invalid.
@ ALTRO_MAPPING_ERROR
Incorrect ALTRO channel mapping.
@ RCU_TRAILER_SIZE_ERROR
RCU trailer size length.
@ CHANNEL_ERROR
Channels not initialized.
@ RCU_VERSION_ERROR
RCU trailer version not matching with the version in the raw header.
@ RCU_TRAILER_ERROR
RCU trailer cannot be decoded or invalid.
@ ALTRO_PAYLOAD_ERROR
ALTRO payload cannot be decoded.
@ ALTRO_BUNCH_LENGTH_ERROR
ALTRO bunch has incorrect length.
static int errorTypeToInt(ErrorType_t errortype)
convert the error type from symoblic constant into int
static const char * getErrorTypeDescription(unsigned int errortype)
Get the description connected to the error type.
static const char * getErrorTypeTitle(unsigned int errortype)
Get the title connected to the error type.
~AltroDecoderError() noexcept override=default
Destructor.
static ErrorType_t intToErrorType(int errornumber)
convert the error from number into a type (symbolic constant)
static constexpr int getNumberOfErrorTypes() noexcept
Get the number of error types handled by the AltroDecoderError.
static const char * getErrorTypeName(unsigned int errortype)
Get the name connected to the error type.
const ErrorType_t getErrorType() const noexcept
Access to the error type connected to the erro.
static const char * getErrorTypeTitle(ErrorType_t errortype)
Get the title connected to the error type.
AltroDecoderError(ErrorType_t errtype, const std::string_view message)
Constructor.
const char * what() const noexcept override
Access to error message cnnected to the error.
static const char * getErrorTypeDescription(ErrorType_t errortype)
Get the description connected to the error type.
static const char * getErrorTypeName(ErrorType_t errortype)
Get the name connected to the error type.
Decoder of the ALTRO data in the raw page.
void decode()
Decode the ALTRO stream.
const RCUTrailer & getRCUTrailer() const
Get reference to the RCU trailer object.
~AltroDecoder()=default
Destructor.
void readRCUTrailer()
Read RCU trailer for the current event in the raw buffer.
const std::vector< Channel > & getChannels() const
Get the reference to the channel container.
const std::vector< MinorAltroDecodingError > & getMinorDecodingErrors() const
Get list of minor decoding errors.
void setMaxBunchLength(int maxBunchLength)
Set the max. allowed bunch length.
void readChannels()
Read channels for the current event in the raw buffer.
Error handling for the ALTRO decoder for non-crashing errors.
MinorAltroDecodingError()=default
Dummy constructor.
static const char * getErrorTypeTitle(ErrorType_t errortype)
Get the title connected to the error type.
static const char * getErrorTypeDescription(unsigned int errortype)
Get the description connected to the error type.
ErrorType_t
Error codes connected with the ALTRO decoding.
@ CHANNEL_HEADER
Channel header corruption.
@ CHANNEL_ORDER
Channels not in increasing order.
@ BUNCH_LENGTH_ALLOW_EXCEED
Exceeds maximum allowed bunch length.
@ BUNCH_STARTTIME
Bunch start time exceeding.
@ BUNCH_LENGTH_EXCEED
Bunch length exceeding channel payload size.
@ CHANNEL_END_PAYLOAD_UNEXPECT
Unexpected end of payload (channel or trailer word in bunch words)
@ CHANNEL_PAYLOAD_EXCEED
Exceeding channel payload block.
~MinorAltroDecodingError() noexcept=default
Destructor.
static ErrorType_t intToErrorType(int errornumber)
convert the error from number into a type (symbolic constant)
static int errorTypeToInt(ErrorType_t errortype)
convert the error type from symoblic constant into int
static const char * getErrorTypeName(unsigned int errortype)
Get the name connected to the error type.
uint32_t getPayloadWord() const noexcept
Get the payload word raising the error.
ErrorType_t getErrorType() const noexcept
Get the type of the error.
static const char * getErrorTypeTitle(unsigned int errortype)
Get the title connected to the error type.
static const char * getErrorTypeDescription(ErrorType_t errortype)
Get the description connected to the error type.
std::string what() const noexcept
Create and return error message for different error types.
MinorAltroDecodingError(ErrorType_t errtype, uint32_t channelHeader, uint32_t payloadword)
Constructor, initializing the object.
static const char * getErrorTypeName(ErrorType_t errortype)
Get the name connected to the error type.
static constexpr int getNumberOfErrorTypes() noexcept
Get the number of error types handled by the AltroDecoderError.
uint32_t getChannelHeader() const noexcept
Get the header of the channel raising the error.
Information stored in the RCU trailer.
Definition RCUTrailer.h:75
Reader for raw data produced by the Readout application in in-memory format.
GLuint GLsizei const GLchar * message
Definition glcorearb.h:2517
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
Definition Cell.cxx:355
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...