34int main(
int argc,
const char** argv)
36 bpo::variables_map vm;
37 bpo::options_description opt_general(
"Usage:\n " + std::string(argv[0]) +
39 " Tool will encode emcal raw data from input file\n"
40 "Commands / Options");
41 bpo::options_description opt_hidden(
"");
42 bpo::options_description opt_all;
43 bpo::positional_options_description opt_pos;
46 auto add_option = opt_general.add_options();
47 add_option(
"help,h",
"Print this help message");
48 add_option(
"verbose,v", bpo::value<uint32_t>()->default_value(0),
"Select verbosity level [0 = no output]");
49 add_option(
"input-file,i", bpo::value<std::string>()->default_value(
"emcaldigits.root"),
"Specifies digit input file.");
50 add_option(
"file-for,f", bpo::value<std::string>()->default_value(
"all"),
"single file per: all,subdet,link");
51 add_option(
"output-dir,o", bpo::value<std::string>()->default_value(
"./"),
"output directory for raw data");
52 add_option(
"debug,d", bpo::value<uint32_t>()->default_value(0),
"Select debug output level [0 = no debug output]");
54 add_option(
"configKeyValues", bpo::value<std::string>()->default_value(
""),
"comma-separated configKeyValues");
56 opt_all.add(opt_general).add(opt_hidden);
57 bpo::store(bpo::command_line_parser(argc, argv).options(opt_all).positional(opt_pos).run(), vm);
59 if (vm.count(
"help") || argc == 1) {
60 std::cout << opt_general << std::endl;
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 debuglevel = vm[
"debug"].as<uint32_t>();
76 fair::Logger::SetConsoleSeverity(
"DEBUG");
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>();
90 if (!std::filesystem::exists(outputdir)) {
91 if (!std::filesystem::create_directories(outputdir)) {
92 LOG(fatal) <<
"could not create output directory " << outputdir;
94 LOG(info) <<
"created output directory " << outputdir;
98 std::unique_ptr<TFile> digitfile(TFile::Open(digitfilename.data(),
"READ"));
99 auto treereader = std::make_unique<TTreeReader>(
static_cast<TTree*
>(digitfile->Get(
"o2sim")));
100 TTreeReaderValue<std::vector<o2::emcal::Digit>> digitbranch(*treereader,
"EMCALDigit");
101 TTreeReaderValue<std::vector<o2::emcal::TriggerRecord>> triggerbranch(*treereader,
"EMCALDigitTRGR");
104 if (filefor ==
"all") {
106 }
else if (filefor ==
"subdet") {
108 }
else if (filefor ==
"crorc") {
110 }
else if (filefor ==
"link") {
113 LOG(fatal) <<
"Unknown granularity, supported: all, subdet, crorc, link";
125 while (treereader->Next()) {
126 rawwriter.
digitsToRaw(*digitbranch, *triggerbranch);
static Geometry * GetInstanceFromRunNumber(Int_t runNumber, const std::string_view="", const std::string_view mcname="TGeant3", const std::string_view mctitle="")
Instanciate geometry depending on the run number. Mostly used in analysis and MC anchors.