22auto main(
int argc,
char** argv) ->
int
25 auto timer = TStopwatch{};
29 auto help = programOptions.create_option<
bool>(
"help,h",
"help message",
false);
30 auto logLevel = programOptions.create_option<std::string>(
"logLevel,v",
"set log level of fairlog",
"error");
31 auto input_file = programOptions.create_option<std::string>(
"in,i",
"set the input files (regex)");
32 auto input_par = programOptions.create_option<std::string>(
"in-par,p",
"set the input parameter");
33 auto output_file = programOptions.create_option<std::string>(
"out,o",
"set the output file");
35 programOptions.create_option<
int>(
"eventNum,n",
"set the number of events per run",
DEFAULT_EVENT_NUM);
37 if (!programOptions.verify(argc, argv))
42 FairLogger::GetLogger()->SetLogScreenLevel(logLevel().c_str());
44 const auto outputfile_path = fs::path{ output_file() };
45 const auto outputParFileName =
46 outputDir / fmt::format(
"{}.par.{}", outputfile_path.stem(), outputfile_path.extension());
49 R3BLOG(debug, fmt::format(
"input data file: {}", fmt::join(input_filenames,
";")).c_str());
50 R3BLOG(debug, fmt::format(
"input data par file: {}", input_par()).c_str());
51 R3BLOG(debug, fmt::format(
"output data file: {}", output_file()).c_str());
53 auto source = std::make_unique<R3BFileSource2>();
54 for (
const auto& filename : input_filenames)
56 source->AddFile(filename);
60 auto sink = std::make_unique<FairRootFileSink>(sinkFile.release());
62 auto run = std::make_unique<FairRunAna>();
63 FairRootManager::SetTreeName(
"evt");
66 auto EvntHeader = std::make_unique<R3BEventHeader>();
67 run->SetEventHeader(EvntHeader.release());
68 run->SetSource(source.release());
69 run->SetSink(sink.release());
71 auto fileio = std::make_unique<FairParRootFileIo>();
72 fileio->open(input_par().c_str());
73 run->GetRuntimeDb()->setFirstInput(fileio.release());
76 auto runIdTask = std::make_unique<R3BEventHeaderPropagator>();
77 run->AddTask(runIdTask.release());
79 auto cal2hit = std::make_unique<R3B::Neuland::Cal2HitTask>();
82 run->AddTask(cal2hit.release());
90 std::cout <<
"A runtime error has occured: \n";
91 std::cerr << ex.what();
96 std::cout <<
"A logic error has occured: \n";
97 std::cerr << ex.what();
100 catch (std::exception& ex)
102 std::cout <<
"A error has occured: \n";
103 std::cerr << ex.what();
108 std::cout <<
"An unrecognized error has occured: \n";
112 auto* sinkfile = run->GetSink();
113 if (sinkfile !=
nullptr)