9 #include "artdaq-core/Data/Fragment.hh"    14 #pragma GCC diagnostic push    15 #pragma GCC diagnostic ignored "-Wsign-compare"    17 #define BOOST_TEST_MODULE(MilliSlice_t)    20 BOOST_AUTO_TEST_SUITE(FelixFragment_test)
    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;
    57     std::ifstream in(
filename, std::ios::binary);
    59       std::cout << 
"Could not open file " << 
filename << 
".\n";
    62     std::cout << 
"Reading from " << 
filename << 
".\n";
    63     std::string contents((std::istreambuf_iterator<char>(in)),
    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';
    82     BOOST_REQUIRE_EQUAL(flxfrg.
total_words(), frames * 116);
    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";
   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)
   150                      comp_end - comp_begin)
   151                      .
count() << 
'\t' << frag_rms << 
'\n';
   204   std::cout << 
"### WOOF WOOF -> Done...\n";
   207 BOOST_AUTO_TEST_SUITE_END()
   209 #pragma GCC diagnostic pop size_t total_frames() const 
 
uint8_t version(const unsigned &frame_ID=0) const 
 
uint8_t slot_no(const unsigned &frame_ID=0) const 
 
uint8_t crate_no(const unsigned &frame_ID=0) const 
 
artdaq::Fragment FelixDecompress(const std::vector< char > &buff)
 
BOOST_AUTO_TEST_CASE(BaselineTest)
 
std::vector< char > FelixCompress(const dune::FelixFragment &frag)
 
QTextStream & hex(QTextStream &s)
 
microsecond microseconds
Alias for common language habits. 
 
adc_t get_ADC(const unsigned &frame_ID, const uint8_t channel_ID) const 
 
size_t total_words() const 
 
QTextStream & dec(QTextStream &s)
 
FragmentType toFragmentType(std::string t_string)
 
uint8_t fiber_no(const unsigned &frame_ID=0) const 
 
size_t total_adc_values() const 
 
size_t dataSizeBytes() const 
 
std::string to_string(ModuleType const mt)
 
uint8_t sof(const unsigned &frame_ID=0) const 
 
Event finding and building. 
 
uint64_t timestamp(const unsigned &frame_ID=0) const