Project
Loading...
Searching...
No Matches
DecoderBase.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
16
17#ifndef O2_TOF_DECODERBASE
18#define O2_TOF_DECODERBASE
19
20#include <fstream>
21#include <string>
22#include <cstdint>
23#include <vector>
26
27namespace o2
28{
29namespace tof
30{
31namespace compressed
32{
33
34template <typename RDH>
36{
37
38 public:
39 DecoderBaseT() = default;
40 virtual ~DecoderBaseT() = default;
41
42 inline bool run()
43 {
44 rewind();
45 if (mDecoderCONET) {
46 mDecoderPointerMax = reinterpret_cast<const uint32_t*>(mDecoderBuffer + mDecoderBufferSize);
47 while (mDecoderPointer < mDecoderPointerMax) {
48 if (processDRM()) {
49 return false;
50 }
51 }
52 return false;
53 }
54 while (!processHBF()) {
55 ;
56 }
57 return false;
58 };
59
60 inline void rewind()
61 {
62 decoderRewind();
63 };
64
65 void setDecoderVerbose(bool val) { mDecoderVerbose = val; };
66 void setDecoderBuffer(const char* val) { mDecoderBuffer = val; };
67 void setDecoderBufferSize(long val) { mDecoderBufferSize = val; };
68 void setDecoderCONET(bool val) { mDecoderCONET = val; };
69
70 private:
73 virtual void rdhHandler(const RDH* rdh) = 0;
74 virtual void headerHandler(const CrateHeader_t* crateHeader, const CrateOrbit_t* crateOrbit) = 0;
75
76 virtual void frameHandler(const CrateHeader_t* crateHeader, const CrateOrbit_t* crateOrbit,
77 const FrameHeader_t* frameHeader, const PackedHit_t* packedHits) = 0;
78
79 virtual void trailerHandler(const CrateHeader_t* crateHeader, const CrateOrbit_t* crateOrbit,
80 const CrateTrailer_t* crateTrailer, const Diagnostic_t* diagnostics,
81 const Error_t* errors) = 0;
82
83 bool processHBF();
84 bool processDRM();
85
87 inline void decoderRewind() { mDecoderPointer = reinterpret_cast<const uint32_t*>(mDecoderBuffer); };
88
89 const char* mDecoderBuffer = nullptr;
90 long mDecoderBufferSize;
91 const uint32_t* mDecoderPointer = nullptr;
92 const uint32_t* mDecoderPointerMax = nullptr;
93 const uint32_t* mDecoderPointerNext = nullptr;
94 const RDH* mDecoderRDH;
95 bool mDecoderVerbose = false;
96 bool mDecoderError = false;
97 bool mDecoderFatal = false;
98 bool mDecoderCONET = false;
99 char mDecoderSaveBuffer[1048576];
100 uint32_t mDecoderSaveBufferDataSize = 0;
101 uint32_t mDecoderSaveBufferDataLeft = 0;
102};
103
108
109} // namespace compressed
110} // namespace tof
111} // namespace o2
112
113#endif
Definition of the RAW Data Header.
void setDecoderBuffer(const char *val)
Definition DecoderBase.h:66
GLuint GLfloat * val
Definition glcorearb.h:1582
DecoderBaseT< o2::header::RAWDataHeaderV6 > DecoderBaseV6
DecoderBaseT< o2::header::RAWDataHeaderV4 > DecoderBaseV4
DecoderBaseT< o2::header::RAWDataHeaderV7 > DecoderBaseV7
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...