25#define ENCODER_PARANOID
27#define ENCODER_VERBOSE
29#ifdef DECODER_PARANOID
30#warning "Building code with DecoderParanoid option. This may limit the speed."
33#warning "Building code with DecoderVerbose option. This may limit the speed."
36#define colorReset "\033[0m"
37#define colorRed "\033[1;31m"
38#define colorGreen "\033[1;32m"
39#define colorYellow "\033[1;33m"
40#define colorBlue "\033[1;34m"
51template <
typename RDH>
52bool DecoderBaseT<RDH>::processHBF()
56 if (mDecoderVerbose) {
64 if (mDecoderBufferSize <= 0) {
66 <<
" got an empty buffer, do nothing"
72 mDecoderRDH =
reinterpret_cast<const RDH*
>(mDecoderPointer);
73 auto rdh = mDecoderRDH;
77 while (!RDHUtils::getStop(*rdh)) {
83 if (mDecoderVerbose) {
85 <<
"--- RDH open/continue detected"
95 auto headerSize = RDHUtils::getHeaderSize(*rdh);
96 auto memorySize = RDHUtils::getMemorySize(*rdh);
97 auto offsetToNext = RDHUtils::getOffsetToNext(*rdh);
98 auto drmPayload = memorySize - headerSize;
103 if (isValidRDH && drmPayload > 0) {
104 std::memcpy(mDecoderSaveBuffer + mDecoderSaveBufferDataSize,
reinterpret_cast<const char*
>(rdh) + headerSize, drmPayload);
105 mDecoderSaveBufferDataSize += drmPayload;
107#ifdef DECODER_VERBOSE
109 if (mDecoderVerbose) {
116 rdh =
reinterpret_cast<const RDH*
>(
reinterpret_cast<const char*
>(rdh) + offsetToNext);
119 if (
reinterpret_cast<const char*
>(rdh) < mDecoderBuffer + mDecoderBufferSize) {
127#ifdef DECODER_VERBOSE
128 if (mDecoderVerbose) {
130 <<
"--- RDH close detected"
138 mDecoderPointer =
reinterpret_cast<const uint32_t*
>(mDecoderSaveBuffer);
139 mDecoderPointerMax =
reinterpret_cast<const uint32_t*
>(mDecoderSaveBuffer + mDecoderSaveBufferDataSize);
140 while (mDecoderPointer < mDecoderPointerMax) {
145 mDecoderSaveBufferDataSize = 0;
150#ifdef DECODER_VERBOSE
151 if (mDecoderVerbose) {
153 <<
"--- END PROCESS HBF"
160 mDecoderPointer =
reinterpret_cast<const uint32_t*
>(
reinterpret_cast<const char*
>(rdh) + RDHUtils::getOffsetToNext(*rdh));
163 if (
reinterpret_cast<const char*
>(mDecoderPointer) < mDecoderBuffer + mDecoderBufferSize) {
171template <
typename RDH>
172bool DecoderBaseT<RDH>::processDRM()
175#ifdef DECODER_VERBOSE
176 if (mDecoderVerbose) {
177 std::cout <<
colorBlue <<
"--- PROCESS DRM"
183 if ((*mDecoderPointer & 0x80000000) != 0x80000000) {
184#ifdef DECODER_VERBOSE
185 if (mDecoderVerbose) {
186 printf(
" %08x [ERROR] \n ", *mDecoderPointer);
193 auto crateHeader =
reinterpret_cast<const CrateHeader_t*
>(mDecoderPointer);
194#ifdef DECODER_VERBOSE
195 if (mDecoderVerbose) {
196 printf(
" %08x CrateHeader (drmID=%d) \n ", *mDecoderPointer, crateHeader->drmID);
202 auto crateOrbit =
reinterpret_cast<const CrateOrbit_t*
>(mDecoderPointer);
203#ifdef DECODER_VERBOSE
204 if (mDecoderVerbose) {
205 printf(
" %08x CrateOrbit (orbit=0x%08x) \n ", *mDecoderPointer, crateOrbit->orbitID);
211 headerHandler(crateHeader, crateOrbit);
216 if (*mDecoderPointer & 0x80000000) {
217 auto crateTrailer =
reinterpret_cast<const CrateTrailer_t*
>(mDecoderPointer);
218#ifdef DECODER_VERBOSE
219 if (mDecoderVerbose) {
220 printf(
" %08x CrateTrailer (numberOfDiagnostics=%d, numberOfErrors=%d) \n ", *mDecoderPointer, crateTrailer->numberOfDiagnostics, crateTrailer->numberOfErrors);
224 auto diagnostics =
reinterpret_cast<const Diagnostic_t*
>(mDecoderPointer);
225#ifdef DECODER_VERBOSE
226 if (mDecoderVerbose) {
227 for (
int i = 0;
i < crateTrailer->numberOfDiagnostics; ++
i) {
228 auto diagnostic =
reinterpret_cast<const Diagnostic_t*
>(mDecoderPointer +
i);
229 printf(
" %08x Diagnostic (slotId=%d) \n ", *(mDecoderPointer +
i), diagnostic->slotID);
233 mDecoderPointer += crateTrailer->numberOfDiagnostics;
234 auto errors =
reinterpret_cast<const Error_t*
>(mDecoderPointer);
235#ifdef DECODER_VERBOSE
236 if (mDecoderVerbose) {
237 for (
int i = 0;
i < crateTrailer->numberOfErrors; ++
i) {
238 auto error =
reinterpret_cast<const Error_t*
>(mDecoderPointer +
i);
239 printf(
" %08x Error (slotId=%d) \n ", *(mDecoderPointer +
i), error->slotID);
243 mDecoderPointer += crateTrailer->numberOfErrors;
246 trailerHandler(crateHeader, crateOrbit, crateTrailer, diagnostics, errors);
252 auto frameHeader =
reinterpret_cast<const FrameHeader_t*
>(mDecoderPointer);
253#ifdef DECODER_VERBOSE
254 if (mDecoderVerbose) {
255 printf(
" %08x FrameHeader (numberOfHits=%d) \n ", *mDecoderPointer, frameHeader->numberOfHits);
259 auto packedHits =
reinterpret_cast<const PackedHit_t*
>(mDecoderPointer);
260#ifdef DECODER_VERBOSE
261 if (mDecoderVerbose) {
262 for (
int i = 0;
i < frameHeader->numberOfHits; ++
i) {
263 auto packedHit =
reinterpret_cast<const PackedHit_t*
>(mDecoderPointer + 1);
264 printf(
" %08x PackedHit (tdcID=%d) \n ", *(mDecoderPointer + 1), packedHit->tdcID);
269 mDecoderPointer += frameHeader->numberOfHits;
272 frameHandler(crateHeader, crateOrbit, frameHeader, packedHits);
279template class DecoderBaseT<o2::header::RAWDataHeaderV4>;
280template class DecoderBaseT<o2::header::RAWDataHeaderV6>;
281template class DecoderBaseT<o2::header::RAWDataHeaderV7>;
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static void printRDH(const RDHv4 &rdh)
static bool checkRDH(const RDHv4 &rdh, bool verbose=true, bool checkZeros=false)