Project
Loading...
Searching...
No Matches
rawfileCheck.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
15
18#include "Framework/Logger.h"
19#include <TStopwatch.h>
20#include <boost/program_options.hpp>
21#include <iostream>
22#include <string>
23#include <vector>
24
25namespace bpo = boost::program_options;
26
27using namespace o2::raw;
28
29int main(int argc, char* argv[])
30{
31 RawFileReader reader;
32 std::vector<std::string> fnames;
33 std::string config, configKeyValues;
34 bpo::variables_map vm;
35 bpo::options_description descOpt("Options");
36 auto desc_add_option = descOpt.add_options();
37 desc_add_option("help,h", "print this help message.");
38 desc_add_option("input-conf,c", bpo::value(&config)->default_value(""), "read input from configuration file");
39 desc_add_option("max-tf,m", bpo::value<uint32_t>()->default_value(0xffffffff), " ID to read (counts from 0)");
40 desc_add_option("verbosity,v", bpo::value<int>()->default_value(reader.getVerbosity()), "1: long report, 2 or 3: print or dump all RDH");
41 desc_add_option("spsize,s", bpo::value<int>()->default_value(reader.getNominalSPageSize()), "nominal super-page size in bytes");
42 desc_add_option("buffer-size,b", bpo::value<size_t>()->default_value(reader.getNominalSPageSize()), "buffer size for files preprocessing");
43 desc_add_option("detect-tf0", "autodetect HBFUtils start Orbit/BC from 1st TF seen");
44 desc_add_option("calculate-tf-start", "calculate TF start instead of using TType");
45 desc_add_option("rorc", "impose RORC as default detector mode");
46 desc_add_option("configKeyValues", bpo::value(&configKeyValues)->default_value(""), "semicolon separated key=value strings");
47 for (int i = 0; i < RawFileReader::NErrorsDefined; i++) {
48 auto ei = RawFileReader::ErrTypes(i);
49 desc_add_option(RawFileReader::nochk_opt(ei).c_str(), RawFileReader::nochk_expl(ei).c_str());
50 }
51
52 bpo::options_description hiddenOpt("hidden");
53 hiddenOpt.add_options()("files", bpo::value(&fnames)->composing(), "");
54
55 bpo::options_description fullOpt("cmd");
56 fullOpt.add(descOpt).add(hiddenOpt);
57
58 bpo::positional_options_description posOpt;
59 posOpt.add("files", -1);
60
61 auto printHelp = [&](std::ostream& stream) {
62 stream << "Usage: " << argv[0] << " [options] file0 [... fileN]" << std::endl;
63 stream << descOpt << std::endl;
64 stream << " (input files are optional if config file was provided)" << std::endl;
65 };
66
67 try {
68 bpo::store(bpo::command_line_parser(argc, argv)
69 .options(fullOpt)
70 .positional(posOpt)
71 .allow_unregistered()
72 .run(),
73 vm);
74 bpo::notify(vm);
75 if (argc == 1 || vm.count("help") || (fnames.empty() && config.empty())) {
76 printHelp(std::cout);
77 return 0;
78 }
80 } catch (const bpo::error& e) {
81 std::cerr << e.what() << "\n\n";
82 std::cerr << "Error parsing command line arguments\n";
83 printHelp(std::cerr);
84 return -1;
85 }
86
88 LOG(info) << "RawDataHeader v" << int(rdh.version) << " is assumed";
89
91
92 reader.setVerbosity(vm["verbosity"].as<int>());
93 reader.setNominalSPageSize(vm["spsize"].as<int>());
94 reader.setMaxTFToRead(vm["max-tf"].as<uint32_t>());
95 reader.setBufferSize(vm["buffer-size"].as<size_t>());
96 reader.setPreferCalculatedTFStart(vm.count("calculate-tf-start"));
97 reader.setDefaultReadoutCardType(rocard);
98 reader.setTFAutodetect(vm.count("detect-tf0") ? RawFileReader::FirstTFDetection::Pending : RawFileReader::FirstTFDetection::Disabled);
99 uint32_t errmap = 0;
100 for (int i = RawFileReader::NErrorsDefined; i--;) {
101 auto ei = RawFileReader::ErrTypes(i);
103 errmap |= 0x1 << i;
104 }
105 if (vm.count(RawFileReader::nochk_opt(ei).c_str())) { // toggle
106 errmap ^= 0x1 << i;
107 }
108 LOG(info) << ((errmap & (0x1 << i)) ? "apply " : "ignore") << " check for " << RawFileReader::ErrNames[i].data();
109 }
110
111 if (!config.empty()) {
112 auto inp = o2::raw::RawFileReader::parseInput(config);
113 reader.loadFromInputsMap(inp);
114 }
115
116 for (int i = 0; i < fnames.size(); i++) {
117 reader.addFile(fnames[i]);
118 }
119
120 TStopwatch sw;
121 sw.Start();
122
123 reader.setCheckErrors(errmap);
124 reader.init();
125
126 sw.Print();
127
128 return 0;
129}
int32_t i
Reader for (multiple) raw data files.
static void updateFromString(std::string const &)
void setVerbosity(int v=1)
static InputsMap parseInput(const std::string &confUri, const std::string &onlyDet={}, bool verbose=false)
static std::string nochk_expl(ErrTypes e)
void setTFAutodetect(FirstTFDetection v)
void setBufferSize(size_t s)
void setNominalSPageSize(int n=0x1<< 20)
void loadFromInputsMap(const InputsMap &inp)
int getNominalSPageSize() const
void setMaxTFToRead(uint32_t n)
static constexpr bool ErrCheckDefaults[]
static std::string nochk_opt(ErrTypes e)
void setCheckErrors(uint32_t m=0xffffffff)
void setDefaultReadoutCardType(ReadoutCardType t=CRU)
static constexpr std::string_view ErrNames[]
bool addFile(const std::string &sname, o2::header::DataOrigin origin, o2::header::DataDescription desc, ReadoutCardType t=CRU)
void setPreferCalculatedTFStart(bool v)
GLboolean * data
Definition glcorearb.h:298
GLuint GLuint stream
Definition glcorearb.h:1806
void printHelp(bpo::variables_map const &varmap, bpo::options_description const &executorOptions, std::vector< DataProcessorSpec > const &physicalWorkflow, std::vector< ConfigParamSpec > const &currentWorkflowOptions)
#define main
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
TStopwatch sw