16 #include <system_error>
18 using namespace boost::program_options;
20 boost::program_options::options_description
22 options_description opt(caption);
24 opt.add_options()(
"help,h",
"Produce help message");
26 "loglevel,l", value<size_t>()->default_value(2),
27 "The output log level. Please set the wished number (0 = VERBOSE, 1 = "
28 "DEBUG, 2 = INFO, 3 = WARNING, 4 = ERROR, 5 = FATAL).");
30 "response-file", value<std::string>()->default_value(
""),
31 "Configuration file (response file) replacing command line options.");
37 boost::program_options::options_description& opt) {
39 opt.add_options()(
"events,n", value<size_t>(),
40 "The number of events to process. If not given, all "
41 "available events will be processed.")(
42 "skip", value<size_t>()->default_value(0),
43 "The number of events to skip")(
44 "jobs,j", value<int>()->default_value(-1),
45 "Number of parallel jobs, negative for automatic.");
49 boost::program_options::options_description& opt) {
50 opt.add_options()(
"rnd-seed", value<uint64_t>()->default_value(1234567890
u),
51 "Random numbers seed.");
55 boost::program_options::options_description& opt) {
56 opt.add_options()(
"geo-surface-loglevel", value<size_t>()->default_value(3),
57 "The outoput log level for the surface building.")(
58 "geo-layer-loglevel", value<size_t>()->default_value(3),
59 "The output log level for the layer building.")(
60 "geo-volume-loglevel", value<size_t>()->default_value(3),
61 "The output log level for the volume building.")(
62 "geo-detector-volume", value<read_strings>()->default_value({{}}),
63 "Sub detectors for the output writing");
67 boost::program_options::options_description& opt) {
69 "mat-input-type", value<std::string>()->default_value(
"build"),
70 "The way material is loaded: 'none', 'build', 'proto', 'file'.")(
71 "mat-input-file", value<std::string>()->default_value(
""),
72 "Name of the material map input file, supported: '.json' or '.root'.")(
73 "mat-output-file", value<std::string>()->default_value(
""),
74 "Name of the material map output file (without extension).")(
75 "mat-output-sensitives", value<bool>()->default_value(
true),
76 "Write material information of sensitive surfaces.")(
77 "mat-output-approaches", value<bool>()->default_value(
true),
78 "Write material information of approach surfaces.")(
79 "mat-output-representing", value<bool>()->default_value(
true),
80 "Write material information of representing surfaces.")(
81 "mat-output-boundaries", value<bool>()->default_value(
true),
82 "Write material information of boundary surfaces.")(
83 "mat-output-volumes", value<bool>()->default_value(
true),
84 "Write material information of volumes.")(
85 "mat-output-dense-volumes", value<bool>()->default_value(
false),
86 "Write material information of dense volumes.")(
87 "mat-output-data", value<bool>()->default_value(
true),
88 "Output the data field(s).")(
89 "mat-output-allmaterial", value<bool>()->default_value(
false),
90 "Add protoMaterial to all surfaces and volume for the mapping.");
94 boost::program_options::options_description& opt) {
96 opt.add_options()(
"output-dir", value<std::string>()->default_value(
""),
97 "Output directory location.")(
98 "output-root", value<bool>()->default_value(
false),
99 "Switch on to write '.root' output file(s).")(
100 "output-csv", value<bool>()->default_value(
false),
101 "Switch on to write '.csv' output file(s).")(
102 "output-obj", value<bool>()->default_value(
false),
103 "Switch on to write '.obj' ouput file(s).")(
104 "output-json", value<bool>()->default_value(
false),
105 "Switch on to write '.json' ouput file(s).")(
106 "output-txt", value<bool>()->default_value(
false),
107 "Switch on to write '.txt' ouput file(s).");
111 boost::program_options::options_description& opt) {
113 opt.add_options()(
"input-dir", value<std::string>()->default_value(
""),
114 "Input directory location.")(
115 "input-files", value<read_strings>()->multitoken()->default_value({}),
116 "Input files, space separated.")(
"input-root",
117 value<bool>()->default_value(
false),
118 "Switch on to read '.root' file(s).")(
119 "input-csv", value<bool>()->default_value(
false),
120 "Switch on to read '.csv' file(s).")(
"input-obj",
121 value<bool>()->default_value(
false),
122 "Switch on to read '.obj' file(s).")(
123 "input-json", value<bool>()->default_value(
false),
124 "Switch on to read '.json' file(s).");
128 const boost::program_options::options_description& opt,
int argc,
129 char* argv[]) noexcept(
false) {
131 store(command_line_parser(argc, argv).
options(opt).
run(), vm);
134 if (vm.count(
"response-file") and
135 not vm[
"response-file"].template as<std::string>().empty()) {
137 std::ifstream ifs(vm[
"response-file"].as<std::string>().c_str());
139 throw(std::system_error(std::error_code(),
140 "Could not open response file."));
143 std::stringstream ss;
145 std::string rString = ss.str();
146 std::vector<std::string>
args;
147 const std::regex rgx(
"[ \t\r\n\f]");
148 std::sregex_token_iterator iter(rString.begin(), rString.end(), rgx, -1);
149 std::sregex_token_iterator end;
150 for (; iter != end; ++iter) {
151 if (std::string(*iter).empty()) {
154 args.push_back(*iter);
157 store(command_line_parser(args).
options(opt).
run(), vm);
161 if (vm.count(
"help")) {
162 std::cout << opt << std::endl;
169 const boost::program_options::variables_map& vm) {
174 const boost::program_options::variables_map& vm) {
176 cfg.
skip = vm[
"skip"].as<
size_t>();
177 if (not vm[
"events"].empty()) {
178 cfg.
events = vm[
"events"].as<
size_t>();
182 if (not vm[
"output-dir"].empty()) {
183 cfg.
outputDir = vm[
"output-dir"].as<std::string>();
191 const boost::program_options::variables_map& vm) {
193 cfg.
seed = vm[
"rnd-seed"].as<uint64_t>();