CbmRoot
Loading...
Searching...
No Matches
services/online_par_dump/ProgramOptions.cxx
Go to the documentation of this file.
1/* Copyright (C) 2024 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Felix Weiglhofer [committer] */
4
5#include "ProgramOptions.h"
6
7#include <boost/program_options.hpp>
8
9#include <iostream>
10
11namespace po = boost::program_options;
12
13ProgramOptions::ProgramOptions(int argc, char** argv)
14{
15 po::options_description required("Required options");
16 // clang-format off
17 required.add_options()
18 ("run,r", po::value(&runId)->value_name("<runID>")->required(),
19 "Run identifier")
20 ("outdir,o", po::value(&outputDir)->value_name("<outputDir>")->required(),
21 "Output directory for the parameter files")
22 ("geo,g", po::value(&geoFileDir)->value_name("<geoFileDir>")->required(),
23 "Directory, which contains a valid geometry ROOT-file (*.geo.root) the run")
24 ;
25 // clang-format on
26
27 po::options_description optional{"Other options"};
28 // clang-format off
29 optional.add_options()
30 ("no-alignment", po::bool_switch(&skipAlignment),
31 "Do not do alignment")
32 ("experimental", po::bool_switch(&experimental),
33 "Copy existing parameters for unpackers and hitfinders from the repository; create tracking parameters")
34 ("help,h", "Print help message")
35 ;
36 // clang-format on
37
38
39 po::options_description cmdline_options;
40 cmdline_options.add(required).add(optional);
41
42 po::variables_map vm;
43 po::command_line_parser parser{argc, argv};
44 parser.options(cmdline_options);
45 try {
46 auto result = parser.run();
47 po::store(result, vm);
48 }
49 catch (const std::exception& e) {
50 std::cerr << "Error: " << e.what() << std::endl;
51 std::cerr << "Use '-h' to display all valid options." << std::endl;
52 std::exit(EXIT_FAILURE);
53 }
54
55 if (vm.count("help") > 0) {
56 std::cout << cmdline_options << std::endl;
57 std::exit(EXIT_SUCCESS);
58 }
59
60 try {
61 po::notify(vm);
62 }
63 catch (const po::required_option& e) {
64 std::cerr << "Error: " << e.what() << std::endl;
65 std::cerr << "Use '-h' to display all valid options." << std::endl;
66 std::exit(EXIT_FAILURE);
67 }
68}
bool experimental
Creating some parameters, copy the others from par. repo.
std::string geoFileDir
Path to the directory, which has a geo-file with a proper geo-tag.
ProgramOptions(int argc, char *argv[])
Standard constructor with command line arguments.