13 #include <system_error>
16 using namespace boost::program_options;
19 std::string caption) {
20 options_description opt(caption);
22 opt.add_options()(
"help,h",
"Produce help message");
25 "The output log level. Please set the wished number (0 = VERBOSE, 1 = "
26 "DEBUG, 2 = INFO, 3 = WARNING, 4 = ERROR, 5 = FATAL).");
29 "Configuration file (response file) replacing command line options.");
35 boost::program_options::options_description& opt) {
38 "The number of events to process. If not given, all "
39 "available events will be processed.")(
41 "The number of events to skip")(
43 "Number of parallel jobs, negative for automatic.");
47 boost::program_options::options_description& opt) {
49 "Random numbers seed.");
53 boost::program_options::options_description& opt) {
54 opt.add_options()(
"geo-surface-loglevel",
value<size_t>()->default_value(3),
55 "The outoput log level for the surface building.")(
57 "The output log level for the layer building.")(
59 "The output log level for the volume building.")(
62 "Sub detectors for the output writing");
66 boost::program_options::options_description& opt) {
69 "The way material is loaded: 'none', 'build', 'proto', 'file'.")(
71 "Name of the material map input file, supported: '.json' or '.root'.")(
73 "Name of the material map output file (without extension).")(
74 "mat-output-sensitives",
value<bool>()->default_value(
true),
75 "Write material information of sensitive surfaces.")(
76 "mat-output-approaches",
value<bool>()->default_value(
true),
77 "Write material information of approach surfaces.")(
78 "mat-output-representing",
value<bool>()->default_value(
true),
79 "Write material information of representing surfaces.")(
80 "mat-output-boundaries",
value<bool>()->default_value(
true),
81 "Write material information of boundary surfaces.")(
82 "mat-output-volumes",
value<bool>()->default_value(
true),
83 "Write material information of dense volumes.")(
84 "mat-output-data",
value<bool>()->default_value(
true),
85 "Output the data field(s).")(
86 "mat-output-allsurfaces",
value<bool>()->default_value(
false),
87 "Output all the selected surfaces to create a surface map.");
91 boost::program_options::options_description& opt) {
94 "Output directory location.")(
96 "Switch on to write '.root' output file(s).")(
98 "Switch on to write '.csv' output file(s).")(
100 "Switch on to write '.obj' ouput file(s).")(
101 "output-json",
value<bool>()->default_value(
false),
102 "Switch on to write '.json' ouput file(s).")(
104 "Switch on to write '.txt' ouput file(s).");
108 boost::program_options::options_description& opt) {
111 "Input directory location.")(
113 "Input files, space separated.")(
"input-root",
115 "Switch on to read '.root' file(s).")(
117 "Switch on to read '.csv' file(s).")(
"input-obj",
119 "Switch on to read '.obj' file(s).")(
121 "Switch on to read '.json' file(s).");
125 const boost::program_options::options_description& opt,
int argc,
126 char* argv[]) noexcept(
false) {
128 store(command_line_parser(argc, argv).options(opt).run(), vm);
131 if (vm.count(
"response-file") and
132 not vm[
"response-file"].template as<std::string>().empty()) {
134 std::ifstream ifs(vm[
"response-file"].as<std::string>().c_str());
136 throw(std::system_error(std::error_code(),
137 "Could not open response file."));
140 std::stringstream ss;
142 std::string rString = ss.str();
143 std::vector<std::string> args;
144 const std::regex rgx(
"[ \t\r\n\f]");
145 std::sregex_token_iterator iter(rString.begin(), rString.end(), rgx, -1);
146 std::sregex_token_iterator end;
147 for (; iter != end; ++iter) {
148 if (std::string(*iter).empty()) {
151 args.push_back(*iter);
154 store(command_line_parser(args).options(opt).run(), vm);
158 if (vm.count(
"help")) {
159 std::cout << opt << std::endl;
166 const boost::program_options::variables_map& vm) {
171 const boost::program_options::variables_map& vm) {
173 cfg.
skip = vm[
"skip"].as<
size_t>();
174 if (not vm[
"events"].empty()) {
175 cfg.
events = vm[
"events"].as<
size_t>();
179 if (not vm[
"output-dir"].empty()) {
180 cfg.
outputDir = vm[
"output-dir"].as<std::string>();
187 const boost::program_options::variables_map& vm) {
189 cfg.
seed = vm[
"rnd-seed"].as<uint64_t>();