Belle II Software  release-08-01-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 namespace Belle2 {
16  namespace ECL {
17 
18  class BitStream;
19 
21  unsigned int ilog2(unsigned int v);
22 
29  struct width_t {
30  unsigned char w0,
31  w1,
32  w2,
33  w3;
34  };
35 
39  class ECLCompress {
40  public:
42  virtual ~ECLCompress() {};
43 
48  virtual void compress(BitStream& out, const int* adc) = 0;
49 
54  virtual void uncompress(BitStream& in, int* adc) = 0;
55  };
56 
60  class ECLBaseCompress: public ECLCompress {
61  public:
62  void compress(BitStream& out, const int* adc) override;
63  void uncompress(BitStream& out, int* adc) override;
64  };
65 
69  class ECLDeltaCompress: public ECLCompress {
70  public:
74  void compress(BitStream& out, const int* adc) override;
78  void uncompress(BitStream& out, int* adc) override;
79  };
80 
84  class ECLDCTCompress: public ECLCompress {
85  public:
91  ECLDCTCompress(double scale, double c0, width_t* w);
95  void compress(BitStream& out, const int* adc) override;
99  void uncompress(BitStream& in, int* adc) override;
100  protected:
101  const double m_scale;
102  const double m_c0;
103  const width_t* m_widths;
104  };
105 
110  ECLCompress* selectAlgo(int compAlgo);
111  }
113 }
Bit stream struct.
Definition: BitStream.h:19
ECL waveform compression/decompression to/from the BitStream storage with the BASE algorithm.
Definition: ECLCompress.h:60
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:39
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:42
ECL waveform compression/decompression to/from the BitStream storage based on the Discrete Cosine Tra...
Definition: ECLCompress.h:84
const width_t * m_widths
Bit widths for the DCT coefficients for prefix encoding.
Definition: ECLCompress.h:103
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:101
const double m_c0
Average waveform amplitude.
Definition: ECLCompress.h:102
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:69
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:29
unsigned char w0
Progressive bit width to encode an integer value.
Definition: ECLCompress.h:30
unsigned char w2
Progressive bit width to encode an integer value.
Definition: ECLCompress.h:32
unsigned char w1
Progressive bit width to encode an integer value.
Definition: ECLCompress.h:31
unsigned char w3
Progressive bit width to encode an integer value.
Definition: ECLCompress.h:33