30auto main(
int argc,
char** argv) ->
int
33 auto timer = TStopwatch{};
37 auto help = programOptions.create_option<
bool>(
"help,h",
"help message",
false);
38 auto logLevel = programOptions.create_option<std::string>(
"logLevel,v",
"set log level of fairlog",
"error");
39 auto input_file = programOptions.create_option<std::string>(
"in,i",
"set the input files (regex)");
40 auto input_par = programOptions.create_option<std::string>(
"in-par,p",
"set the input parameter");
41 auto output_file = programOptions.create_option<std::string>(
"out,o",
"set the output file");
43 programOptions.create_option<
int>(
"eventNum,n",
"set the number of events per run",
DEFAULT_EVENT_NUM);
45 if (!programOptions.verify(argc, argv))
50 FairLogger::GetLogger()->SetLogScreenLevel(logLevel().c_str());
52 const auto outputfile_path = fs::path{ output_file() };
57 R3BLOG(debug, fmt::format(
"input data file: {}", fmt::join(input_filenames,
";")).c_str());
58 R3BLOG(debug, fmt::format(
"input data par file: {}", input_par()).c_str());
59 R3BLOG(debug, fmt::format(
"output data file: {}", output_file()).c_str());
61 auto source = std::make_unique<R3BFileSource2>();
62 for (
const auto& filename : input_filenames)
64 source->AddFile(filename);
68 auto sink = std::make_unique<FairRootFileSink>(sinkFile.release());
70 auto run = std::make_unique<FairRunAna>();
71 FairRootManager::SetTreeName(
"evt");
74 auto EvntHeader = std::make_unique<R3BEventHeader>();
75 run->SetEventHeader(EvntHeader.release());
76 run->SetSource(source.release());
77 run->SetSink(sink.release());
79 auto fileio = std::make_unique<FairParRootFileIo>();
80 fileio->open(input_par().c_str());
81 run->GetRuntimeDb()->setFirstInput(fileio.release());
84 auto runIdTask = std::make_unique<R3BEventHeaderPropagator>();
85 run->AddTask(runIdTask.release());
87 auto cal2hit = std::make_unique<R3B::Neuland::Cal2HitTask>();
90 run->AddTask(cal2hit.release());
98 std::cout <<
"A runtime error has occured: \n";
99 std::cerr << ex.what();
104 std::cout <<
"A logic error has occured: \n";
105 std::cerr << ex.what();
108 catch (std::exception& ex)
110 std::cout <<
"A error has occured: \n";
111 std::cerr << ex.what();
116 std::cout <<
"An unrecognized error has occured: \n";
120 auto* sinkfile = run->GetSink();
121 if (sinkfile !=
nullptr)