Belle II Software  release-08-00-10
ECLCompress.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <framework/utilities/Utils.h>
12 
13 namespace Belle2 {
18  namespace ECL {
19 
20  class BitStream;
21 
23  unsigned int ilog2(unsigned int v);
24 
31  struct width_t {
32  unsigned char w0,
33  w1,
34  w2,
35  w3;
36  };
37 
41  class ECLCompress {
42  public:
44  virtual ~ECLCompress() {};
45 
50  virtual void compress(BitStream& out, const int* adc) = 0;
51 
56  virtual void uncompress(BitStream& in, int* adc) = 0;
57  };
58 
62  class ECLBaseCompress: public ECLCompress {
63  public:
64  void compress(BitStream& out, const int* adc) override;
65  void uncompress(BitStream& out, int* adc) override;
66  };
67 
71  class ECLDeltaCompress: public ECLCompress {
72  public:
76  void compress(BitStream& out, const int* adc) override;
80  void uncompress(BitStream& out, int* adc) override;
81  };
82 
86  class ECLDCTCompress: public ECLCompress {
87  public:
93  ECLDCTCompress(double scale, double c0, width_t* w);
97  void compress(BitStream& out, const int* adc) override;
101  void uncompress(BitStream& in, int* adc) override;
102  protected:
103  const double m_scale;
104  const double m_c0;
105  const width_t* m_widths;
106  };
107 
112  ECLCompress* selectAlgo(int compAlgo);
113  }
115 }
Bit stream struct.
Definition: BitStream.h:19
ECL waveform compression/decompression to/from the BitStream storage with the BASE algorithm.
Definition: ECLCompress.h:62
void compress(BitStream &out, const int *adc) override
Compress the ECL waveform.
Definition: ECLCompress.cc:35
void uncompress(BitStream &out, int *adc) override
Decompress the ECL waveform.
Definition: ECLCompress.cc:55
Abstract class (interface) for ECL waveform compression/decompression to/from the BitStream storage.
Definition: ECLCompress.h:41
virtual void uncompress(BitStream &in, int *adc)=0
Decompress the ECL waveform.
virtual void compress(BitStream &out, const int *adc)=0
Compress the ECL waveform.
virtual ~ECLCompress()
virtual destructure
Definition: ECLCompress.h:44
ECL waveform compression/decompression to/from the BitStream storage based on the Discrete Cosine Tra...
Definition: ECLCompress.h:86
const width_t * m_widths
Bit widths for the DCT coefficients for prefix encoding.
Definition: ECLCompress.h:105
ECLDCTCompress(double scale, double c0, width_t *w)
Constructor for DCT based compression algorithm.
Definition: ECLCompress.cc:241
void compress(BitStream &out, const int *adc) override
function to compress
Definition: ECLCompress.cc:243
const double m_scale
Scale factor for quantization.
Definition: ECLCompress.h:103
const double m_c0
Average waveform amplitude.
Definition: ECLCompress.h:104
void uncompress(BitStream &in, int *adc) override
function to decompress
Definition: ECLCompress.cc:261
ECL waveform compression/decompression to/from the BitStream storage with the DELTA algorithm.
Definition: ECLCompress.h:71
void compress(BitStream &out, const int *adc) override
function to compress the ECL waveform with the DELTA algorithm
Definition: ECLCompress.cc:62
void uncompress(BitStream &out, int *adc) override
function to decompress the ECL waveform with the DELTA algorithm
Definition: ECLCompress.cc:87
Abstract base class for different kinds of events.
Bit widths for the prefix coding to encode integers which are mainly concentrated around zero and pro...
Definition: ECLCompress.h:31
unsigned char w0
Progressive bit width to encode an integer value.
Definition: ECLCompress.h:32
unsigned char w2
Progressive bit width to encode an integer value.
Definition: ECLCompress.h:34
unsigned char w1
Progressive bit width to encode an integer value.
Definition: ECLCompress.h:33
unsigned char w3
Progressive bit width to encode an integer value.
Definition: ECLCompress.h:35