33int main(
int argc,
const char** argv)
35 bpo::variables_map vm;
36 bpo::options_description opt_general(
"Usage:\n " + std::string(argv[0]) +
38 " Tool will encode phos raw data from input file\n"
39 "Commands / Options");
40 bpo::options_description opt_hidden(
"");
41 bpo::options_description opt_all;
42 bpo::positional_options_description opt_pos;
45 auto add_option = opt_general.add_options();
46 add_option(
"help,h",
"Print this help message");
47 add_option(
"verbose,v", bpo::value<uint32_t>()->default_value(0),
"Select verbosity level [0 = no output]");
48 add_option(
"input-file,i", bpo::value<std::string>()->default_value(
"phosdigits.root"),
"Specifies digit input file.");
49 add_option(
"file-for,f", bpo::value<std::string>()->default_value(
"all"),
"single file per: all,link");
50 add_option(
"output-dir,o", bpo::value<std::string>()->default_value(
"./"),
"output directory for raw data");
51 add_option(
"debug,d", bpo::value<uint32_t>()->default_value(0),
"Select debug output level [0 = no debug output]");
53 add_option(
"configKeyValues", bpo::value<std::string>()->default_value(
""),
"comma-separated configKeyValues");
55 opt_all.add(opt_general).add(opt_hidden);
56 bpo::store(bpo::command_line_parser(argc, argv).options(opt_all).positional(opt_pos).run(), vm);
58 if (vm.count(
"help") || argc == 1) {
59 std::cout << opt_general << std::endl;
63 }
catch (bpo::error& e) {
64 std::cerr <<
"ERROR: " << e.what() << std::endl
66 std::cerr << opt_general << std::endl;
68 }
catch (std::exception& e) {
69 std::cerr << e.what() <<
", application will now exit" << std::endl;
73 std::string confDig = vm[
"hbfutils-config"].as<std::string>();
74 if (!confDig.empty() && confDig !=
"none") {
79 auto digitfilename = vm[
"input-file"].as<std::string>(),
80 outputdir = vm[
"output-dir"].as<std::string>(),
81 filefor = vm[
"file-for"].as<std::string>();
84 if (!std::filesystem::exists(outputdir)) {
85 if (!std::filesystem::create_directories(outputdir)) {
86 LOG(fatal) <<
"could not create output directory " << outputdir;
88 LOG(info) <<
"created output directory " << outputdir;
92 std::unique_ptr<TFile> digitfile(TFile::Open(digitfilename.data(),
"READ"));
93 auto treereader = std::make_unique<TTreeReader>(
static_cast<TTree*
>(digitfile->Get(
"o2sim")));
94 TTreeReaderValue<std::vector<o2::phos::Digit>> digitbranch(*treereader,
"PHOSDigit");
95 TTreeReaderValue<std::vector<o2::phos::TriggerRecord>> triggerbranch(*treereader,
"PHOSDigitTrigRecords");
98 if (filefor ==
"all") {
100 }
else if (filefor ==
"crorc") {
102 }
else if (filefor ==
"link") {
112 while (treereader->Next()) {
113 rawwriter.
digitsToRaw(*digitbranch, *triggerbranch);