Skip to content
Snippets Groups Projects
Commit 81202236 authored by Felix Weiglhofer's avatar Felix Weiglhofer
Browse files

Options.cxx: Add flag for output-file.

parent 932d9bc7
No related branches found
No related tags found
1 merge request!1192cbmreco: Add support to store results to file
......@@ -59,6 +59,10 @@ Options::Options(int argc, char** argv)
po::options_description generic("Other options");
// clang-format off
generic.add_options()
("output,o", po::value(&fOutputFile)->default_value("")->value_name("<file>"),
"write results to file")
("write-per-ts,W", po::bool_switch(&fWritePerTimeslice)->default_value(false),
"Write results to file per timeslice (resulting files are named <file>_<tsnr>). Requires -o.")
("device,d", po::value(&fDevice)->default_value("cpu")->value_name("<device>"),
"select device (cpu, cuda0, cuda1, hip0, ...)")
("log-level,l", po::value(&fLogLevel)->default_value(info)->value_name("<level>"),
......
......@@ -23,6 +23,8 @@ namespace cbm::algo
fs::path ParamsDir() const { return fParamsDir; }
const std::string& InputLocator() const { return fInputLocator; }
fs::path OutputFile() const { return fOutputFile; }
bool WritePerTimeslice() const { return fWritePerTimeslice; }
severity_level LogLevel() const { return fLogLevel; }
fs::path LogFile() const { return fLogFile; }
const std::string& Device() const { return fDevice; }
......@@ -49,6 +51,8 @@ namespace cbm::algo
private:
std::string fParamsDir; // TODO: can we make this a std::path?
std::string fInputLocator;
std::string fOutputFile;
bool fWritePerTimeslice = false;
severity_level fLogLevel;
std::string fLogFile;
std::string fDevice;
......
......@@ -46,7 +46,7 @@ int main(int argc, char** argv)
reco.Init(opts);
Archive archive(opts.Detectors());
Archive archive({fles::SubsystemIdentifier::STS}); // TODO: use opts.Detector() once detector flag is merged
fles::TimesliceAutoSource source {opts.InputLocator()};
int tsIdx = 0;
int num_ts = opts.NumTimeslices();
......@@ -57,12 +57,20 @@ int main(int argc, char** argv)
continue;
}
auto result = reco.Run(*ts);
archive.TimesliceResults().push_back(result);
if (opts.WritePerTimeslice() && !opts.OutputFile().empty()) {
Archive tsResults({fles::SubsystemIdentifier::STS}); // TODO: use opts.Detector() once detector flag is merged
tsResults.TimesliceResults().push_back(result);
// TODO: handle file endings
tsResults.Store(fmt::format("{}_{}", opts.OutputFile().string(), ts->index()));
}
archive.TimesliceResults().push_back(result); // TODO: result should be moved not copied
tsIdx++;
if (num_ts > 0 && tsIdx >= num_ts) { break; }
}
if (!opts.WritePerTimeslice() && !opts.OutputFile().empty()) archive.Store(opts.OutputFile());
reco.Finalize();
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment