Functions
FELIXdecode.cc File Reference
#include "dune-raw-data/Overlays/FelixDecode.hh"
#include <stdint.h>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "art/Framework/Principal/Handle.h"
#include "artdaq-core/Data/Fragment.hh"
#include "canvas/Utilities/InputTag.h"
#include "dune-raw-data/Overlays/FelixFragment.hh"
#include "gallery/Event.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 13 of file FELIXdecode.cc.

13  {
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 }
size_t total_frames() const
std::string string
Definition: nybbler.cc:12