Skip to content
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 @@ -86,27 +86,27 @@ union Union_t {
} // namespace tof
} // namespace o2

#define DIAGNOSTIC_DRM_HEADER 0x80000000
#define DIAGNOSTIC_DRM_TRAILER 0x40000000
#define DIAGNOSTIC_DRM_HEADER_MISSING 0x80000000
#define DIAGNOSTIC_DRM_TRAILER_MISSING 0x40000000
#define DIAGNOSTIC_DRM_CRC 0x20000000
#define DIAGNOSTIC_DRM_ENABLEMASK 0x08000000
#define DIAGNOSTIC_DRM_CBIT 0x04000000
#define DIAGNOSTIC_DRM_FAULTID 0x02000000
#define DIAGNOSTIC_DRM_RTOBIT 0x01000000
#define DIAGNOSTIC_DRM_ENAPARTMASK_DIFFER 0x08000000
#define DIAGNOSTIC_DRM_CLOCKSTATUS_WRONG 0x04000000
#define DIAGNOSTIC_DRM_FAULTSLOTMASK_NOTZERO 0x02000000
#define DIAGNOSTIC_DRM_READOUTTIMEOUT_NOTZERO 0x01000000

#define DIAGNOSTIC_TRM_HEADER 0x80000000
#define DIAGNOSTIC_TRM_TRAILER 0x40000000
#define DIAGNOSTIC_TRM_HEADER_MISSING 0x80000000
#define DIAGNOSTIC_TRM_TRAILER_MISSING 0x40000000
#define DIAGNOSTIC_TRM_CRC 0x20000000
#define DIAGNOSTIC_TRM_UNEXPECTED 0x20000000
#define DIAGNOSTIC_TRM_EVENTCOUNTER 0x08000000
#define DIAGNOSTIC_TRM_EBIT 0x06000000
#define DIAGNOSTIC_TRM_HEADER_UNEXPECTED 0x20000000
#define DIAGNOSTIC_TRM_EVENTCNT_MISMATCH 0x08000000
#define DIAGNOSTIC_TRM_EMPTYBIT_NOTZERO 0x06000000
#define DIAGNOSTIC_TRM_LBIT 0x02000000

#define DIAGNOSTIC_TRMCHAIN_HEADER(x) (0x00080000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_TRAILER(x) (0x00040000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_STATUS(x) (0x00020000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_EVENTCOUNTER(x) (0x00008000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_TDCERRORS(x) (0x00004000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_BUNCHID(x) (0x00002000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_HEADER_MISSING(x) (0x00080000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_TRAILER_MISSING(x) (0x00040000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_STATUS_NOTZERO(x) (0x00020000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_EVENTCNT_MISMATCH(x) (0x00008000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_TDCERROR_DETECTED(x) (0x00004000 << (8 * x))
#define DIAGNOSTIC_TRMCHAIN_BUNCHCNT_MISMATCH(x) (0x00002000 << (8 * x))

#endif /** O2_TOF_CMPDATAFORMAT **/
47 changes: 33 additions & 14 deletions Detectors/TOF/compression/include/TOFCompression/Compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ class Compressor
inline bool run()
{
rewind();
if (processRDH())
return false;
for (int i = 0; i < 3 && !processDRM(); ++i)
;
while (!processHBF());
return false;
};

Expand All @@ -56,9 +53,8 @@ class Compressor
};
inline bool write() { return encoderWrite(); };

bool processRDH();
bool processDRM();
void checkSummary();
void resetCounters();

void setDecoderVerbose(bool val) { mDecoderVerbose = val; };
void setEncoderVerbose(bool val) { mEncoderVerbose = val; };
Expand All @@ -77,29 +73,48 @@ class Compressor
double mIntegratedTime = 0.;

protected:

bool processSave();
bool processHBF();
bool processHBFsave();
bool processRDH();
bool processDRM();

/** decoder private functions and data members **/

bool decoderInit();
bool decoderOpen(std::string name);
bool decoderRead();
bool decoderClose();
void decoderClear();
bool decoderParanoid();
inline void decoderRewind() { mDecoderPointer = reinterpret_cast<uint32_t*>(mDecoderBuffer); };
inline void decoderNext()
{
mDecoderPointer += mDecoderNextWord;
mDecoderNextWord = (mDecoderNextWord + 2) % 4;
// mDecoderNextWord = mDecoderNextWord == 1 ? 3 : 1;
// mDecoderNextWord = (mDecoderNextWord + 2) % 4;
mDecoderNextWord = (mDecoderNextWord + 2) & 0x3;
};

int mJumpRDH = 0;

std::ifstream mDecoderFile;
char* mDecoderBuffer = nullptr;
bool mOwnDecoderBuffer = false;
long mDecoderBufferSize = 8192;
// long mDecoderBufferSize = 1048576;
uint32_t* mDecoderPointer = nullptr;
uint32_t mDecoderNextWord = 1;
uint32_t* mDecoderPointerMax = nullptr;
uint32_t* mDecoderPointerNext = nullptr;
uint8_t mDecoderNextWord = 1;
o2::header::RAWDataHeader* mDecoderRDH;
bool mDecoderVerbose = false;

bool mDecoderError = false;
bool mDecoderFatal = false;
char mDecoderSaveBuffer[1048576];
uint32_t mDecoderSaveBufferDataSize = 0;
uint32_t mDecoderSaveBufferDataLeft = 0;

/** encoder private functions and data members **/

bool encoderInit();
Expand All @@ -113,23 +128,27 @@ class Compressor
std::ofstream mEncoderFile;
char* mEncoderBuffer = nullptr;
bool mOwnEncoderBuffer = false;
long mEncoderBufferSize = 8192;
long mEncoderBufferSize = 1048576;
uint32_t* mEncoderPointer = nullptr;
uint32_t mEncoderNextWord = 1;
uint32_t* mEncoderPointerMax = nullptr;
uint32_t* mEncoderPointerStart = nullptr;
uint8_t mEncoderNextWord = 1;
o2::header::RAWDataHeader* mEncoderRDH;
bool mEncoderVerbose = false;

/** checker private functions and data members **/

bool checkerCheck();

uint32_t mCounter;
uint32_t mEventCounter;
uint32_t mFatalCounter;
uint32_t mErrorCounter;
bool mCheckerVerbose = false;

struct DRMCounters_t {
uint32_t Headers;
uint32_t EventWordsMismatch;
uint32_t CBit;
uint32_t clockStatus;
uint32_t Fault;
uint32_t RTOBit;
} mDRMCounters = {0};
Expand Down
30 changes: 26 additions & 4 deletions Detectors/TOF/compression/include/TOFCompression/RawDataFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,35 @@ class RawDataFrame
{

public:
RawDataFrame() = default;
~RawDataFrame() = default;
RawDataFrame(int size = 1048576)
: mSize(size), mBuffer(new char[size]){};
RawDataFrame(const RawDataFrame& other)
: mSize(other.mSize), mBuffer(new char[other.mSize])
{
for (int i = 0; i < mSize; ++i)
mBuffer[i] = other.mBuffer[i];
};
RawDataFrame& operator=(const RawDataFrame& other)
{
if (&other == this)
return *this;
if (mSize != other.mSize) {
delete[] mBuffer;
mSize = other.mSize;
mBuffer = new char[mSize];
}
for (int i = 0; i < mSize; ++i)
mBuffer[i] = other.mBuffer[i];
return *this;
};
~RawDataFrame() { delete[] mBuffer; };
int getSize() const { return mSize; };
char* getBuffer() const { return mBuffer; };

// private:

char mBuffer[8192]; // [mSize]
long mSize = 8192;
int mSize;
char* mBuffer; // [mSize]

ClassDef(RawDataFrame, 1);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class RawReaderTask : public Task
private:
bool mStatus = false;
std::ifstream mFile;
RawDataFrame mDataFrame;
std::string mBuffer;
};

} // namespace tof
Expand Down
2 changes: 1 addition & 1 deletion Detectors/TOF/compression/src/CompressedWriterTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ DataProcessorSpec CompressedWriterTask::getSpec()
Outputs{}, // outputs
AlgorithmSpec{adaptFromTask<CompressedWriterTask>()}, // call constructor + execute init (check)
Options{
{"tof-compressed-filename", VariantType::String, "", {"Name of the compressed output file"}}}};
{"tof-compressed-filename", VariantType::String, "/dev/null", {"Name of the compressed output file"}}}};
}

} // namespace tof
Expand Down
Loading