Belle II Software development
ECLDeltaCompress Class Reference

ECL waveform compression/decompression to/from the BitStream storage with the DELTA algorithm. More...

#include <ECLCompress.h>

Inheritance diagram for ECLDeltaCompress:
ECLCompress

Public Member Functions

void compress (BitStream &out, const int *adc) override
 function to compress the ECL waveform with the DELTA algorithm
 
void uncompress (BitStream &out, int *adc) override
 function to decompress the ECL waveform with the DELTA algorithm
 

Detailed Description

ECL waveform compression/decompression to/from the BitStream storage with the DELTA algorithm.

Definition at line 69 of file ECLCompress.h.

Member Function Documentation

◆ compress()

void compress ( BitStream out,
const int *  adc 
)
overridevirtual

function to compress the ECL waveform with the DELTA algorithm

Implements ECLCompress.

Definition at line 62 of file ECLCompress.cc.

63{
64 int a0 = adc[0], dmin = 0, dmax = 0;
65 for (int k = 1; k < EclConfiguration::m_nsmp; k++) {
66 int d = adc[k] - a0;
67 dmin = std::min(dmin, d);
68 dmax = std::max(dmax, d);
69 a0 = adc[k];
70 }
71
72 unsigned int w = ilog2(std::max(2 * dmax, -2 * dmin)) + 1;
73 w &= 0xf;
74 out.putNBits(w, 4);
75
76 a0 = adc[0] & 0x3ffff;
77 out.putNBits(a0, 18);
78
79 unsigned int base = 1 << (w - 1);
80 for (unsigned int i = 1; i < EclConfiguration::m_nsmp; i++) {
81 unsigned int d = int(adc[i]) - a0 + base;
82 out.putNBits(d, w);
83 a0 = adc[i];
84 }
85}
static constexpr int m_nsmp
number of ADC measurements for signal fitting

◆ uncompress()

void uncompress ( BitStream out,
int *  adc 
)
overridevirtual

function to decompress the ECL waveform with the DELTA algorithm

Implements ECLCompress.

Definition at line 87 of file ECLCompress.cc.

88{
89 unsigned int w = out.getNBits(4);
90 adc[0] = out.getNBits(18);
91 unsigned int base = 1 << (w - 1);
92 for (unsigned int i = 1; i < EclConfiguration::m_nsmp; i++) {
93 adc[i] = adc[i - 1] + out.getNBits(w) - base;
94 }
95}

The documentation for this class was generated from the following files: