Skip to content

Commit

Permalink
Add base compressed-decoder class and adapt compressed decoder workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
preghenella committed Feb 26, 2020
1 parent 4c94343 commit eb5bc89
Show file tree
Hide file tree
Showing 12 changed files with 528 additions and 315 deletions.
5 changes: 3 additions & 2 deletions Detectors/TOF/compression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
o2_add_library(TOFCompression
SOURCES src/Compressor.cxx
src/CompressorTask.cxx
src/CompressedInspectorTask.cxx
PUBLIC_LINK_LIBRARIES O2::TOFBase O2::Framework O2::Headers O2::DataFormatsTOF
O2::DetectorsRaw
)
Expand All @@ -25,5 +24,7 @@ o2_add_executable(compressor
o2_add_executable(compressed-inspector
COMPONENT_NAME tof
SOURCES src/tof-compressed-inspector.cxx
PUBLIC_LINK_LIBRARIES O2::TOFCompression
PUBLIC_LINK_LIBRARIES O2::TOFWorkflowUtils
)


196 changes: 0 additions & 196 deletions Detectors/TOF/compression/src/CompressedInspectorTask.cxx

This file was deleted.

10 changes: 5 additions & 5 deletions Detectors/TOF/compression/src/Compressor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#include <cstring>
#include <iostream>

#define DECODER_PARANOID
#define DECODER_VERBOSE
#define ENCODER_VERBOSE
#define CHECKER_VERBOSE
#define CHECKER_COUNTER
//#define DECODER_PARANOID
//#define DECODER_VERBOSE
//#define ENCODER_VERBOSE
//#define CHECKER_VERBOSE
//#define CHECKER_COUNTER

#ifdef DECODER_PARANOID
#warning "Building code with DecoderParanoid option. This may limit the speed."
Expand Down
2 changes: 1 addition & 1 deletion Detectors/TOF/compression/src/tof-compressed-inspector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/// @since 2019-12-18
/// @brief Basic DPL workflow for TOF raw data compression

#include "TOFCompression/CompressedInspectorTask.h"
#include "TOFWorkflow/CompressedInspectorTask.h"
#include "Framework/WorkflowSpec.h"
#include "Framework/ConfigParamSpec.h"
#include "FairLogger.h"
Expand Down
2 changes: 2 additions & 0 deletions Detectors/TOF/reconstruction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
o2_add_library(TOFReconstruction
SOURCES src/DataReader.cxx src/Clusterer.cxx
src/ClustererTask.cxx src/Encoder.cxx
src/DecoderBase.cxx
src/Decoder.cxx
PUBLIC_LINK_LIBRARIES O2::TOFBase O2::DataFormatsTOF
O2::SimulationDataFormat
Expand All @@ -21,4 +22,5 @@ o2_target_root_dictionary(TOFReconstruction
include/TOFReconstruction/Clusterer.h
include/TOFReconstruction/ClustererTask.h
include/TOFReconstruction/Encoder.h
include/TOFReconstruction/DecoderBase.h
include/TOFReconstruction/Decoder.h)
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// @file Decoder.h
/// @author Roberto Preghenella
/// @since 2020-02-24
/// @brief TOF compressed data decoder

#ifndef O2_TOF_DECODERBASE
#define O2_TOF_DECODERBASE

#include <fstream>
#include <string>
#include <cstdint>
#include <vector>
#include "Headers/RAWDataHeader.h"
#include "DataFormatsTOF/CompressedDataFormat.h"

namespace o2
{
namespace tof
{
namespace compressed
{

class DecoderBase
{

public:
DecoderBase() = default;
~DecoderBase() = default;

inline bool run()
{
rewind();
while (!processHBF())
;
return false;
};

inline void rewind()
{
decoderRewind();
};

void setDecoderVerbose(bool val) { mDecoderVerbose = val; };
void setDecoderBuffer(char* val) { mDecoderBuffer = val; };
void setDecoderBufferSize(long val) { mDecoderBufferSize = val; };

private:
/** handlers **/

virtual void rdhHandler(const o2::header::RAWDataHeader* rdh){};
virtual void headerHandler(const CrateHeader_t* crateHeader, const CrateOrbit_t* crateOrbit){};

virtual void frameHandler(const CrateHeader_t* crateHeader, const CrateOrbit_t* crateOrbit,
const FrameHeader_t* frameHeader, const PackedHit_t* packedHits){};

virtual void trailerHandler(const CrateHeader_t* crateHeader, const CrateOrbit_t* crateOrbit,
const CrateTrailer_t* crateTrailer, const Diagnostic_t* diagnostics){};

bool processHBF();
bool processDRM();

/** decoder private functions and data members **/
inline void decoderRewind() { mDecoderPointer = reinterpret_cast<uint32_t*>(mDecoderBuffer); };

char* mDecoderBuffer = nullptr;
long mDecoderBufferSize;
uint32_t* mDecoderPointer = nullptr;
uint32_t* mDecoderPointerMax = nullptr;
uint32_t* mDecoderPointerNext = nullptr;
o2::header::RAWDataHeader* mDecoderRDH;
bool mDecoderVerbose = false;
bool mDecoderError = false;
bool mDecoderFatal = false;
char mDecoderSaveBuffer[1048576];
uint32_t mDecoderSaveBufferDataSize = 0;
uint32_t mDecoderSaveBufferDataLeft = 0;
};

} // namespace compressed
} // namespace tof
} // namespace o2

#endif /** O2_TOF_DECODERBASE **/
Loading

0 comments on commit eb5bc89

Please sign in to comment.