Project
Loading...
Searching...
No Matches
rawReaderFile.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#include <iostream>
16#include <boost/program_options.hpp>
17
21#include <fairlogger/Logger.h>
22
23namespace bpo = boost::program_options;
24//using namespace o2::emcal;
25
26int main(int argc, char** argv)
27{
28 bpo::variables_map vm;
29 bpo::options_description opt_general("Usage:\n " + std::string(argv[0]) +
30 " <cmds/options>\n"
31 " Tool will decode the DDLx data for EMCAL 0\n"
32 "Commands / Options");
33 bpo::options_description opt_hidden("");
34 bpo::options_description opt_all;
35 bpo::positional_options_description opt_pos;
36
37 try {
38 auto add_option = opt_general.add_options();
39 add_option("help,h", "Print this help message");
40 add_option("verbose,v", bpo::value<uint32_t>()->default_value(0), "Select verbosity level [0 = no output]");
41 add_option("version", "Print version information");
42 add_option("input-file,i", bpo::value<std::string>()->required(), "Specifies input file.");
43 add_option("debug,d", bpo::value<uint32_t>()->default_value(0), "Select debug output level [0 = no debug output]");
44
45 opt_all.add(opt_general).add(opt_hidden);
46 bpo::store(bpo::command_line_parser(argc, argv).options(opt_all).positional(opt_pos).run(), vm);
47
48 if (vm.count("help") || argc == 1) {
49 std::cout << opt_general << std::endl;
50 exit(0);
51 }
52
53 if (vm.count("version")) {
54 //std::cout << GitInfo();
55 exit(0);
56 }
57
58 bpo::notify(vm);
59 } catch (bpo::error& e) {
60 std::cerr << "ERROR: " << e.what() << std::endl
61 << std::endl;
62 std::cerr << opt_general << std::endl;
63 exit(1);
64 } catch (std::exception& e) {
65 std::cerr << e.what() << ", application will now exit" << std::endl;
66 exit(2);
67 }
68
69 auto rawfilename = vm["input-file"].as<std::string>();
70
73 reader.setDefaultDataDescription(o2::header::gDataDescriptionRawData);
74 reader.setDefaultReadoutCardType(o2::raw::RawFileReader::RORC);
75 reader.addFile(rawfilename);
76 reader.init();
77
78 while (1) {
79 int tfID = reader.getNextTFToRead();
80 if (tfID >= reader.getNTimeFrames()) {
81 LOG(info) << "nothing left to read after " << tfID << " TFs read";
82 break;
83 }
84 std::vector<char> dataBuffer; // where to put extracted data
85 for (int il = 0; il < reader.getNLinks(); il++) {
86 auto& link = reader.getLink(il);
87 std::cout << "Decoding link " << il << std::endl;
88
89 auto sz = link.getNextTFSize(); // size in bytes needed for the next TF of this link
90 dataBuffer.resize(sz);
91 link.readNextTF(dataBuffer.data());
92
93 // Parse
94 o2::emcal::RawReaderMemory parser(dataBuffer);
95 while (parser.hasNext()) {
96 parser.next();
97 // Exclude STU DDLs
98 if (o2::raw::RDHUtils::getFEEID(parser.getRawHeader()) >= 40) {
99 continue;
100 }
101 o2::emcal::AltroDecoder decoder(parser);
102 decoder.decode();
103
104 std::cout << decoder.getRCUTrailer() << std::endl;
105 for (auto& chan : decoder.getChannels()) {
106 std::cout << "Hw address: " << chan.getHardwareAddress() << std::endl;
107 for (auto& bunch : chan.getBunches()) {
108 std::cout << "BunchLength: " << int(bunch.getBunchLength()) << std::endl;
109 auto adcs = bunch.getADC();
110 int time = bunch.getStartTime();
111 for (int i = adcs.size() - 1; i >= 0; i--) {
112 std::cout << "Timebin " << time << ", ADC " << adcs[i] << std::endl;
113 time--;
114 }
115 }
116 }
117 }
118 }
119 reader.setNextTFToRead(++tfID);
120 }
121}
int16_t time
Definition RawEventData.h:4
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
Reader for (multiple) raw data files.
Decoder of the ALTRO data in the raw page.
void decode()
Decode the ALTRO stream.
const RCUTrailer & getRCUTrailer() const
Get reference to the RCU trailer object.
const std::vector< Channel > & getChannels() const
Get the reference to the channel container.
Reader for raw data produced by the Readout application in in-memory format.
bool hasNext() const
check if more pages are available in the raw file
const o2::header::RDHAny & getRawHeader() const
access to the raw header of the current page
void next()
Read next payload from the stream.
void setDefaultDataOrigin(const std::string &orig)
constexpr o2::header::DataDescription gDataDescriptionRawData
Definition DataHeader.h:601
constexpr o2::header::DataOrigin gDataOriginEMC
Definition DataHeader.h:568
#define main
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"