FELIXdecode.cc
Go to the documentation of this file.
2 #include <stdint.h>
3 #include <fstream>
4 #include <iostream>
5 #include <string>
6 #include <vector>
8 #include "artdaq-core/Data/Fragment.hh"
11 #include "gallery/Event.h"
12 
13 int main(int argc, char *argv[]) {
14  // Checking of input arguments.
15  if (argc < 3) {
16  std::cout << "ERROR: need both inputfile(s) and destination.\n";
17  return 1;
18  }
19 
20  // Number of files to be considered.
21  const unsigned total_files = 10;
22 
23  // The user has to input both an input file and a destination.
24  std::vector<std::string> filenames;
25  for(unsigned file = 1; file < std::min<unsigned>(total_files, argc-1); ++file) {
26  filenames.push_back(argv[file]);
27  }
28  std::string destination = argv[argc-1];
29  std::string print = "";
30  if (argc == 4) {
31  print = argv[3];
32  }
33 
34  // Initialise a decoder object from the file.
35  dune::FelixDecoder flxdec(filenames);
36 
37  // Check fragment length here for now.
38  artdaq::Fragment frag = flxdec.Fragment(0);
39 
41  *frag.metadata<dune::FelixFragment::Metadata>();
42  std::cout << "METADATA: " << (unsigned)meta.control_word << " "
43  << (unsigned)meta.version << " " << (unsigned)meta.reordered
44  << " " << (unsigned)meta.compressed << " "
45  << (unsigned)meta.num_frames << " "
46  << (unsigned)meta.offset_frames << " "
47  << (unsigned)meta.window_frames << '\n';
48  dune::FelixFragment flxfrag(frag);
49  if (flxfrag.total_frames() < 6000 || flxfrag.total_frames() > 6036) {
50  std::cout << "WARNING: first fragment has a strange size: "
51  << flxfrag.total_frames() << ".\n";
52  }
53 
54  // // Print uncompressed fragment to file.
55  // std::cout << "Going to decompress fragment.\n";
56  // dune::FelixFragmentCompressed compflxfrag(frag);
57  // artdaq::Fragment uncompfrag = compflxfrag.uncompressed_fragment();
58  // std::ofstream ofile("outfrag.dat");
59  // ofile.write(reinterpret_cast<const char *>(uncompfrag.dataBeginBytes()),
60  // uncompfrag.dataSizeBytes());
61  // ofile.close();
62  // std::cout << "Produced uncompressed fragment to file.\n";
63 
64  // artdaq::Fragment newfrag;
65  // newfrag.setTimestamp(frag.timestamp());
66  // newfrag.resize(frag.dataSizeBytes());
67  // memcpy(newfrag.dataBeginBytes(), frag.dataBeginBytes(),
68  // frag.dataSizeBytes());
69 
70  // dune::FelixFragment::Metadata newmeta = {0xabc, 1, 0, 0, 6024, 500, 6000};
71  // newfrag.setMetadata(newmeta);
72 
73  // Print some value.
74  for (unsigned f = 0; f < flxdec.total_fragments(); ++f) {
75  artdaq::Fragment frag = flxdec.Fragment(f);
76  dune::FelixFragment flxfrag(frag);
77  std::cout << f << '\t' << flxfrag.get_ADC(259,37) << '\n';
78  }
79 
80  flxdec.check_all_timestamps();
81  flxdec.check_all_CCCs();
82  flxdec.check_all_IDs();
83 
84  // // Print RMS values to file.
85  // flxdec.analyse(destination);
86 
87  return 0;
88 }
bool check_all_IDs() const
Definition: FelixDecode.hh:227
size_t total_frames() const
std::string string
Definition: nybbler.cc:12
artdaq::Fragment Fragment(const size_t &frag_num) const
Definition: FelixDecode.hh:243
adc_t get_ADC(const unsigned &frame_ID, const uint8_t channel_ID) const
size_t total_fragments() const
Definition: FelixDecode.hh:59
int main(int argc, char *argv[])
Definition: FELIXdecode.cc:13
bool check_all_timestamps() const
Definition: FelixDecode.hh:98
bool check_all_CCCs() const
Definition: FelixDecode.hh:165