26 std::vector<int> event_nums = {7258, 7263, 7264, 7269, 7276, 7283, 7284, 7287, 7294, 7296};
27 std::vector<std::string> filenames;
28 for (
auto event : event_nums) {
29 for (
unsigned p = 0;
p < 3; ++
p) {
30 for (
unsigned f = 1;
f < 10; ++
f) {
32 "/nfs/sw/felix/fragment-ana/uBdat/Run_8700-SubRun_145-Event_" +
37 for (
unsigned f = 10;
f < 14; ++
f) {
39 "/nfs/sw/felix/fragment-ana/uBdat/Run_8700-SubRun_145-Event_" +
48 std::ofstream ofile(
"prev_compression_results.dat");
49 ofile <<
"#Compression factor\tCompression time\tNoise RMS\n";
52 std::vector<double> comp_factors;
53 std::vector<size_t> comp_times;
59 std::cout <<
"Could not open file " <<
filename <<
".\n";
62 std::cout <<
"Reading from " <<
filename <<
".\n";
64 (std::istreambuf_iterator<char>()));
67 std::unique_ptr<artdaq::Fragment> frag_ptr(artdaq::Fragment::FragmentBytes(
69 frag_ptr->resizeBytes(contents.size());
70 memcpy(frag_ptr->dataBeginBytes(), contents.c_str(), contents.size());
75 std::cout <<
"### WOOF -> Test for the presence of 6000 frames...\n";
76 const size_t frames = 6000;
78 std::cout <<
" -> Total words: " << flxfrg.total_words() <<
'\n';
79 std::cout <<
" -> Total frames: " << flxfrg.total_frames() <<
'\n';
80 std::cout <<
" -> Total adc values: " << flxfrg.total_adc_values() <<
'\n';
82 BOOST_REQUIRE_EQUAL(flxfrg.total_words(), frames * 116);
83 BOOST_REQUIRE_EQUAL(flxfrg.total_frames(), frames);
84 BOOST_REQUIRE_EQUAL(flxfrg.total_adc_values(), frames * 256);
87 std::cout <<
"### WOOF -> WIB frame test.\n";
89 std::cout <<
" -> SOF: " << unsigned(flxfrg.sof(0)) <<
"\n";
90 std::cout <<
" -> Version: " << unsigned(flxfrg.version(0)) <<
"\n";
91 std::cout <<
" -> FiberNo: " << unsigned(flxfrg.fiber_no(0)) <<
"\n";
92 std::cout <<
" -> SlotNo: " << unsigned(flxfrg.slot_no(0)) <<
"\n";
93 std::cout <<
" -> CrateNo: " << unsigned(flxfrg.crate_no(0)) <<
"\n";
94 std::cout <<
" -> Timestamp: " <<
std::hex << flxfrg.timestamp(0)
100 std::vector<double> chan_avg(256,0);
101 std::vector<double> chan_rms(256,0);
103 for(
unsigned vi = 0; vi < 256; ++vi) {
104 for(
unsigned ti = 1; ti < frames; ++ti) {
105 chan_avg[vi] += (double)flxfrg.get_ADC(ti, vi) - flxfrg.get_ADC(ti-1, vi);
107 chan_avg[vi] /= frames;
110 for(
unsigned vi = 0; vi < 256; ++vi) {
111 for(
unsigned ti = 1; ti < frames; ++ti) {
112 chan_rms[vi] +=
pow(flxfrg.get_ADC(ti, vi) - flxfrg.get_ADC(ti-1, vi) - chan_avg[vi], 2);
114 chan_rms[vi] = sqrt(chan_rms[vi]/(frames-2));
115 frag_rms += chan_rms[vi];
119 std::cout <<
"FRAGMENT RMS: " << frag_rms <<
'\n';
122 std::cout <<
"### MEOW -> WIB frame compression test.\n";
130 std::cout <<
"Compressed buffer size: " << compfrg.size() <<
".\n" 131 <<
"Compression factor: " << (double)flxfrg.dataSizeBytes() / compfrg.size() <<
'\n' 132 <<
"Compression time taken: " 134 comp_end - comp_begin)
137 <<
"Decompression time taken: " 139 decomp_end - comp_end)
142 <<
"Noise RMS: " << frag_rms <<
'\n';
144 comp_factors.push_back((
double)flxfrg.dataSizeBytes() / compfrg.size());
145 comp_times.push_back(std::chrono::duration_cast<std::chrono::microseconds>(
146 comp_end - comp_begin)
149 ofile << (double)flxfrg.dataSizeBytes() / compfrg.size() <<
'\t' << std::chrono::duration_cast<
std::chrono::microseconds>(
150 comp_end - comp_begin)
151 .
count() <<
'\t' << frag_rms <<
'\n';
204 std::cout <<
"### WOOF WOOF -> Done...\n";
artdaq::Fragment FelixDecompress(const std::vector< char > &buff)
std::vector< char > FelixCompress(const dune::FelixFragment &frag)
QTextStream & hex(QTextStream &s)
microsecond microseconds
Alias for common language habits.
QTextStream & dec(QTextStream &s)
FragmentType toFragmentType(std::string t_string)
std::string to_string(ModuleType const mt)
Event finding and building.