![]() |
Belle II Software development
|
This is a set of function for packing/unpacking the data produced by the new ShaperDSP firmware that does hadron component fit. More...
Functions | |
unsigned long long | packAmplitude (long long peak_amp) |
Amplitude packing. | |
unsigned long long | unpackAmplitude (unsigned long long amp_packed) |
Amplitude unpacking (from 14 bits float to 18 bit int) | |
int | packTime (int peak_time) |
Time packing. | |
int | unpackTime (int time_packed) |
Time unpacking (from 11 bits float to 12 bits int) | |
int | packHadronFraction (int A_hadron, int A_total) |
Hadron fraction packing. | |
double | unpackHadronFraction (int fraction_packed) |
Hadron fraction unpacking. | |
int | integer_division_32 (int dividend, int divisor) |
Basically the fastest algorithm for approximate integer division (with the precision (1/32)). | |
This is a set of function for packing/unpacking the data produced by the new ShaperDSP firmware that does hadron component fit.
See ecl/utility/include/ECLRawDataHadron.h for details.
See 51st B2GM slides from ECL session, these docs and eclUnpackerModule.cc for more details.
Data format has changed to make space for the hadron fraction value. Unlike the original ShaperDSP which sent fit amplitude and time as integer values, new firmware sends amplitude and time as IEEE 754 floating point values.
int integer_division_32 | ( | int | dividend, |
int | divisor ) |
Basically the fastest algorithm for approximate integer division (with the precision (1/32)).
Calculating (n / m)
⎛ p ⎞32 <= ⎝ m / 2 ⎠ < 64
pn = n / 2 ∈ [0, 63] S p m = m / 2 ∈ [32, 63] S
\frac{n}{m} = \frac{n_S}{m_S} = n_S \cdot \left( \frac{2^{16}}{m_S} \right) \cdot \frac{1}{2^{16}}
n ⎛ 16 ⎞
n S ⎜ 2 ⎟ 1 ─ = ── = n ∙ ⎜ ─── ⎟ ∙ ─── m m S ⎜ m ⎟ 16 S ⎝ S ⎠ 2
┌─────────────└───────┘────────────────────────────────┐ Since m_S can take only 32 different values, we pre-calculate 32 different constants for (2^{16} / m_S)
Correction to improve division accuracy:
Instead of n_S, use (n_S + m_S / 2), this will result in correct rounding for the division.
Definition at line 216 of file ECLRawDataHadron.cc.
unsigned long long packAmplitude | ( | long long | peak_amp | ) |
Amplitude packing.
See format description in unpackAmplitude docs.
Definition at line 27 of file ECLRawDataHadron.cc.
int packHadronFraction | ( | int | A_hadron, |
int | A_total ) |
Hadron fraction packing.
Simply shifting (A_hadron / A_total) from [-0.25, 0.5) into [0, 31]
Definition at line 298 of file ECLRawDataHadron.cc.
int packTime | ( | int | peak_time | ) |
Time packing.
See format description in unpackTime docs.
Definition at line 101 of file ECLRawDataHadron.cc.
unsigned long long unpackAmplitude | ( | unsigned long long | amp_packed | ) |
Amplitude unpacking (from 14 bits float to 18 bit int)
sign – not used, 0 bits exponent – 3 bits fraction – 11 bits
Definition at line 87 of file ECLRawDataHadron.cc.
double unpackHadronFraction | ( | int | fraction_packed | ) |
Hadron fraction unpacking.
Simply shifting packed value from [0, 31] into [-0.25, 0.5)
Definition at line 308 of file ECLRawDataHadron.cc.
int unpackTime | ( | int | time_packed | ) |
Time unpacking (from 11 bits float to 12 bits int)
sign – 1 bit exponent – 2 bits fraction – 8 bits
Definition at line 154 of file ECLRawDataHadron.cc.