31int main(
int argc,
char** argv)
33 bpo::variables_map vm;
34 bpo::options_description opt_general(
"Usage:\n " + std::string(argv[0]) +
36 " Tool will decode the DDLx data for EMCAL 0\n"
37 "Commands / Options");
38 bpo::options_description opt_hidden(
"");
39 bpo::options_description opt_all;
40 bpo::positional_options_description opt_pos;
43 auto add_option = opt_general.add_options();
44 add_option(
"help,h",
"Print this help message");
45 add_option(
"verbose,v", bpo::value<uint32_t>()->default_value(0),
"Select verbosity level [0 = no output]");
46 add_option(
"version",
"Print version information");
47 add_option(
"input-file,i", bpo::value<std::string>()->required(),
"Specifies input file.");
48 add_option(
"debug,d", bpo::value<uint32_t>()->default_value(0),
"Select debug output level [0 = no debug output]");
50 opt_all.add(opt_general).add(opt_hidden);
51 bpo::store(bpo::command_line_parser(argc, argv).options(opt_all).positional(opt_pos).run(), vm);
53 if (vm.count(
"help") || argc == 1) {
54 std::cout << opt_general << std::endl;
58 if (vm.count(
"version")) {
64 }
catch (bpo::error& e) {
65 std::cerr <<
"ERROR: " << e.what() << std::endl
67 std::cerr << opt_general << std::endl;
69 }
catch (std::exception& e) {
70 std::cerr << e.what() <<
", application will now exit" << std::endl;
74 auto rawfilename = vm[
"input-file"].as<std::string>();
80 reader.addFile(rawfilename);
86 std::unique_ptr<TFile> treefile(TFile::Open(
"trudata.root",
"RECREATE"));
87 TTree trudata(
"trudata",
"Tree with TRU data");
89 struct collisiontrigger {
95 std::vector<int> timesamples;
96 tree->Branch(&mycollision,
"collisiontrigger",
"bc,orbit/l");
97 tree->Branch(&starttime,
"starttime",
"starttime/i");
98 tree->Branch(×amples,
"timesamples",
"");
101 int tfID = reader.getNextTFToRead();
102 if (tfID >= reader.getNTimeFrames()) {
103 LOG(info) <<
"nothing left to read after " << tfID <<
" TFs read";
106 std::vector<char> dataBuffer;
107 for (
int il = 0; il < reader.getNLinks(); il++) {
108 auto& link = reader.getLink(il);
109 std::cout <<
"Decoding link " << il << std::endl;
111 auto sz = link.getNextTFSize();
112 dataBuffer.resize(sz);
113 link.readNextTF(dataBuffer.data());
120 auto ddl = o2::raw::RDHUtils::getFEEID(parser.
getRawHeader());
126 mycollision.bc = o2::raw::RDHUtils::getTriggerBC(rdh);
127 mycollision.orbit = o2::raw::RDHUtils::getTriggerOrbit(rdh);
138 std::cout <<
"Hw address: " << chan.getHardwareAddress() << std::endl;
144 auto fastorInTRU = ddlmapping.getColumn(chan.getHardwareAddress());
145 if (fastorInTRU >= 96) {
152 for (
auto& bunch : chan.getBunches()) {
153 std::cout <<
"BunchLength: " <<
int(bunch.getBunchLength()) << std::endl;
154 auto adcs = bunch.getADC();
155 int time = bunch.getStartTime();
158 timesamples.resize(adcs.size());
159 std::copy(adcs.begin(), adcs.end(), timesamples.begin());
161 for (
int i = adcs.size() - 1;
i >= 0;
i--) {
162 std::cout <<
"Timebin " <<
time <<
", ADC " << adcs[
i] << std::endl;
169 reader.setNextTFToRead(++tfID);