#include <FelixCompress.hh>
Definition at line 200 of file FelixCompress.hh.
dune::FelixCompressor::FelixCompressor |
( |
const uint8_t * |
data, |
|
|
const size_t |
num_frames = 10000 |
|
) |
| |
|
inline |
Definition at line 218 of file FelixCompress.hh.
const size_t input_length
size_t dataSizeBytes() const
const uint8_t * dataBeginBytes() const
void dune::FelixCompressor::ADC_compress |
( |
std::vector< char > & |
out | ) |
|
|
inline |
Definition at line 371 of file FelixCompress.hh.
373 const size_t tail = out.size();
376 unsigned rec_bits = 0;
377 const char*
dest = &out[0] + tail;
379 for(
unsigned j = 0; j < 256; ++j) {
381 *(
unsigned long*)(dest + (rec_bits/8)) |=
hufftree(curr_val)->huffcode << (rec_bits%8);
382 rec_bits +=
hufftree(curr_val)->hufflength;
392 *(uint64_t*)(dest + (rec_bits/8)) |=
hufftree(curr_val)->huffcode << (rec_bits%8);
393 rec_bits +=
hufftree(curr_val)->hufflength;
397 out.resize(tail + rec_bits / 8 + 1);
FelixFrame const * frame_(const size_t &frame_num=0) const
uint16_t channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch) const
void dune::FelixCompressor::compress_copy |
( |
std::vector< char > & |
out | ) |
|
|
inline |
Definition at line 401 of file FelixCompress.hh.
void generate_Huff_tree(std::vector< char > &out)
void header_reduce(std::vector< char > &out)
void store_metadata(std::vector< char > &out)
void ADC_compress(std::vector< char > &out)
FelixFrame const* dune::FelixCompressor::frame_ |
( |
const size_t & |
frame_num = 0 | ) |
const |
|
inlineprivate |
void dune::FelixCompressor::generate_Huff_tree |
( |
std::vector< char > & |
out | ) |
|
|
inline |
Definition at line 322 of file FelixCompress.hh.
324 std::unordered_map<adc_t, uint32_t> freq_table;
327 for (
unsigned fri = 1; fri <
num_frames; ++fri) {
333 freq_table[curr_val]++;
338 MetaData* meta =
reinterpret_cast<MetaData*
>(&out[0]);
339 meta->unique_values = freq_table.size();
343 size_t tail = out.size();
344 out.resize(tail + freq_table.size() * (
sizeof(
adc_t) + 4));
345 for (
auto p : freq_table) {
346 memcpy(&out[tail], &
p.first,
sizeof(
p.first));
347 memcpy(&out[tail +
sizeof(
p.first)], &
p.second,
sizeof(
p.second));
348 tail +=
sizeof(
p.first) +
sizeof(
p.second);
353 std::vector<HuffTree::Node>
nodes;
356 for (
auto p : freq_table) {
358 curr_node.value =
p.first;
359 curr_node.frequency =
p.second;
360 nodes.push_back(curr_node);
362 entropy += (double)
p.second / num_vals * log((
double)num_vals /
p.second);
static constexpr size_t num_ch_per_frame
FelixFrame const * frame_(const size_t &frame_num=0) const
std::unordered_map< uint16_t, Node * > make_tree(std::vector< Node > nodevec)
uint16_t channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch) const
void dune::FelixCompressor::header_reduce |
( |
std::vector< char > & |
out | ) |
|
|
inline |
Definition at line 233 of file FelixCompress.hh.
235 std::vector<uint8_t> bad_headers(
num_frames/8 + 1);
238 bool check_failed =
false;
255 for (
unsigned j = 0; j < 4; ++j) {
262 for (
unsigned h = 0;
h < 8; ++
h) {
273 bad_headers[i/8] |= 1 << (i%8);
287 size_t tail = out.size();
288 out.resize(tail + num_frames/8+1);
289 memcpy(&out[tail], &bad_headers[0], bad_headers.size());
293 out.resize(tail +
sizeof(WIBHeader) + 4*
sizeof(ColdataHeader));
295 memcpy(&out[tail],
frame_()->wib_header(),
sizeof(WIBHeader));
296 memcpy(&out[tail +
sizeof(WIBHeader)],
frame_()->coldata_header(0),
297 sizeof(ColdataHeader));
298 memcpy(&out[tail +
sizeof(WIBHeader) +
sizeof(ColdataHeader)],
frame_()->coldata_header(1),
299 sizeof(ColdataHeader));
300 memcpy(&out[tail +
sizeof(WIBHeader) + 2*
sizeof(ColdataHeader)],
frame_()->coldata_header(2),
301 sizeof(ColdataHeader));
302 memcpy(&out[tail +
sizeof(WIBHeader) + 3*
sizeof(ColdataHeader)],
frame_()->coldata_header(3),
303 sizeof(ColdataHeader));
307 bool check_failed = (bad_headers[i / 8] >> (7 - (i % 8))) & 1;
308 if(!check_failed) {
continue; }
311 out.resize(tail +
sizeof(WIBHeader) + 4*
sizeof(ColdataHeader));
313 memcpy(&out[tail],
frame_(i)->wib_header(),
sizeof(WIBHeader));
314 for(
unsigned j = 0; j < 4; ++j) {
315 memcpy(&out[tail +
sizeof(WIBHeader)],
frame_(i)->coldata_header(j),
316 sizeof(ColdataHeader));
uint8_t hdr(const uint8_t block_num, const uint8_t i) const
FelixFrame const * frame_(const size_t &frame_num=0) const
uint16_t checksum_b(const uint8_t block_num) const
uint16_t wib_errors() const
uint16_t error_register(const uint8_t block_num) const
uint8_t s2_error(const uint8_t block_num) const
uint16_t coldata_convert_count(const uint8_t block_num) const
uint16_t checksum_a(const uint8_t block_num) const
uint8_t s1_error(const uint8_t block_num) const
uint64_t timestamp() const
void dune::FelixCompressor::store_metadata |
( |
std::vector< char > & |
out | ) |
|
|
inline |
Definition at line 222 of file FelixCompress.hh.
228 out.resize(
sizeof(meta));
229 memcpy(&out[0], &meta,
sizeof(meta));
HuffTree dune::FelixCompressor::hufftree |
|
private |
const void* dune::FelixCompressor::input |
|
private |
const size_t dune::FelixCompressor::input_length |
|
private |
The documentation for this class was generated from the following file: