Project
Loading...
Searching...
No Matches
digits-dumper.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
12#include "boost/program_options.hpp"
13#include <iostream>
14#include <fstream>
15#include "DigitSampler.h"
16#include "DigitSink.h"
19#include <fmt/format.h>
20#include "ProgOptions.h"
21
22namespace po = boost::program_options;
23
29int main(int argc, char* argv[])
30{
31 std::string inputFile;
32 po::variables_map vm;
33 po::options_description options("options");
34 bool count{false};
35 bool describe{false};
36 bool printDigits{false};
37 bool printTFs{false};
38 int maxNofTimeFrames{std::numeric_limits<int>::max()};
39 int firstTimeFrame{0};
40
41 // clang-format off
42 // clang-format off
43 options.add_options()
44 ("help,h", "produce help message")
45 ("infile,i", po::value<std::string>(&inputFile)->required(), "input file name")
46 ("count,c",po::bool_switch(&count),"count items (rofs, tfs, etc...)")
47 ("describe,d",po::bool_switch(&describe),"describe file format")
48 (OPTNAME_PRINT_DIGITS,po::bool_switch(&printDigits),OPTHELP_PRINT_DIGITS)
49 (OPTNAME_PRINT_TFS,po::bool_switch(&printTFs),OPTHELP_PRINT_TFS)
50 (OPTNAME_MAX_NOF_TFS,po::value<int>(&maxNofTimeFrames),OPTHELP_MAX_NOF_TFS)
51 (OPTNAME_FIRST_TF,po::value<int>(&firstTimeFrame),OPTHELP_FIRST_TF)
52 ;
53 // clang-format on
54
55 po::options_description cmdline;
56 cmdline.add(options);
57
58 po::store(po::command_line_parser(argc, argv).options(cmdline).run(), vm);
59
60 if (vm.count("help")) {
61 std::cout << options << "\n";
62 return 2;
63 }
64
65 try {
66 po::notify(vm);
67 } catch (boost::program_options::error& e) {
68 std::cout << "Error: " << e.what() << "\n";
69 exit(1);
70 }
71
72 std::ifstream in(inputFile.c_str());
73 if (!in.is_open()) {
74 std::cerr << "cannot open input file " << inputFile << "\n";
75 return 3;
76 }
78
79 if (describe) {
80 std::cout << dr.fileFormat() << "\n";
81 }
82 if (count) {
83 std::cout << fmt::format("nTFs {} nROFs {} nDigits {}\n",
84 dr.nofTimeFrames(), dr.nofROFs(), dr.nofDigits());
85 }
86
87 if (printTFs || printDigits) {
88 int tfid{0};
89 int tfcount{0};
91 std::vector<o2::mch::Digit> digits;
92 std::vector<o2::mch::ROFRecord> rofs;
93 while (dr.read(digits, rofs)) {
94 if (tfid >= firstTimeFrame && tfcount < maxNofTimeFrames) {
95 if (printTFs) {
96 std::cout << fmt::format("TF {:5d} {:4d} rofs {:5d} digits\n",
97 tfid, rofs.size(), digits.size());
98 }
99 if (printDigits) {
100 dump.write(digits, rofs);
101 }
102 ++tfcount;
103 }
104 ++tfid;
105 }
106 }
107 return 0;
108}
Definition of the MCH ROFrame record.
constexpr const char * OPTHELP_MAX_NOF_TFS
Definition ProgOptions.h:20
constexpr const char * OPTHELP_FIRST_TF
Definition ProgOptions.h:23
constexpr const char * OPTNAME_PRINT_DIGITS
Definition ProgOptions.h:25
constexpr const char * OPTNAME_PRINT_TFS
Definition ProgOptions.h:28
constexpr const char * OPTHELP_PRINT_TFS
Definition ProgOptions.h:29
constexpr const char * OPTHELP_PRINT_DIGITS
Definition ProgOptions.h:26
constexpr const char * OPTNAME_MAX_NOF_TFS
Definition ProgOptions.h:19
constexpr const char * OPTNAME_FIRST_TF
Definition ProgOptions.h:22
DigitFileFormat fileFormat() const
bool read(std::vector< Digit > &digits, std::vector< ROFRecord > &rofs)
void dump(const std::string what, DPMAP m, int verbose)
Definition dcs-ccdb.cxx:79
GLint GLsizei count
Definition glcorearb.h:399
#define main
std::vector< Digit > digits