37int main(
int argc,
const char** argv)
39 bpo::variables_map vm;
40 bpo::options_description opt_general(
"Usage:\n " + std::string(argv[0]) +
42 " Tool will encode cpv raw data from input file\n"
43 "Commands / Options");
44 bpo::options_description opt_hidden(
"");
45 bpo::options_description opt_all;
46 bpo::positional_options_description opt_pos;
49 auto add_option = opt_general.add_options();
50 add_option(
"help,h",
"Print this help message");
51 add_option(
"verbose,v", bpo::value<uint32_t>()->default_value(0),
"Select verbosity level [0 = no output]");
52 add_option(
"input-file,i", bpo::value<std::string>()->default_value(
"cpvdigits.root"),
"Specifies digit input file.");
53 add_option(
"file-for,f", bpo::value<std::string>()->default_value(
"all"),
"single file per: all,cruendpoint,link");
54 add_option(
"output-dir,o", bpo::value<std::string>()->default_value(
"./"),
"output directory for raw data");
55 add_option(
"rdh-version,r", bpo::value<uint32_t>()->default_value(
DefRDHVersion),
"RDH version to use");
56 add_option(
"enable-padding", bpo::value<bool>()->default_value(
false)->implicit_value(
true),
"enable GBT word padding to 128 bits even for RDH V7");
57 add_option(
"debug,d", bpo::value<uint32_t>()->default_value(0),
"Select debug output level [0 = no debug output]");
59 add_option(
"configKeyValues", bpo::value<std::string>()->default_value(
""),
"comma-separated configKeyValues");
61 opt_all.add(opt_general).add(opt_hidden);
62 bpo::store(bpo::command_line_parser(argc, argv).options(opt_all).positional(opt_pos).run(), vm);
64 if (vm.count(
"help") || argc == 1) {
65 std::cout << opt_general << std::endl;
69 }
catch (bpo::error& e) {
70 std::cerr <<
"ERROR: " << e.what() << std::endl
72 std::cerr << opt_general << std::endl;
74 }
catch (std::exception& e) {
75 std::cerr << e.what() <<
", application will now exit" << std::endl;
79 std::string confDig = vm[
"hbfutils-config"].as<std::string>();
80 if (!confDig.empty() && confDig !=
"none") {
85 auto digitfilename = vm[
"input-file"].as<std::string>(),
86 outputdir = vm[
"output-dir"].as<std::string>(),
87 filefor = vm[
"file-for"].as<std::string>();
89 auto rdhV = vm[
"rdh-version"].as<uint32_t>();
90 auto enablePadding = vm[
"enable-padding"].as<
bool>();
92 if (rdhV < 7 && !enablePadding) {
94 LOG(info) <<
"padding is always ON for RDH version " << rdhV;
98 if (!std::filesystem::exists(outputdir)) {
99 if (!std::filesystem::create_directories(outputdir)) {
100 LOG(fatal) <<
"could not create output directory " << outputdir;
102 LOG(info) <<
"created output directory " << outputdir;
106 std::unique_ptr<TFile> digitfile(TFile::Open(digitfilename.data(),
"READ"));
107 auto treereader = std::make_unique<TTreeReader>(
static_cast<TTree*
>(digitfile->Get(
"o2sim")));
108 TTreeReaderValue<std::vector<o2::cpv::Digit>> digitbranch(*treereader,
"CPVDigit");
109 TTreeReaderValue<std::vector<o2::cpv::TriggerRecord>> triggerbranch(*treereader,
"CPVDigitTrigRecords");
112 if ((filefor ==
"all") || (filefor ==
"cruendpoint")) {
114 }
else if (filefor ==
"link") {
134 while (treereader->Next()) {
136 rawwriter.
digitsToRaw(*digitbranch, *triggerbranch);