1 #ifndef artdaq_proto_LoadParameterSet_hh
2 #define artdaq_proto_LoadParameterSet_hh 1
4 #include "fhiclcpp/make_ParameterSet.h"
5 #include <boost/program_options.hpp>
7 namespace bpo = boost::program_options;
9 inline fhicl::ParameterSet LoadParameterSet(
int argc,
char* argv[]) {
10 std::ostringstream descstr;
12 <<
" <-c <config-file>> <other-options> [<source-file>]+";
13 bpo::options_description desc(descstr.str());
15 (
"config,c", bpo::value<std::string>(),
"Configuration file.")
16 (
"help,h",
"produce help message");
17 bpo::variables_map vm;
19 bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm);
22 catch (bpo::error
const & e) {
23 std::cerr <<
"Exception from command line processing in " << argv[0]
24 <<
": " << e.what() <<
"\n";
27 if (vm.count(
"help")) {
28 std::cout << desc << std::endl;
31 if (!vm.count(
"config")) {
32 std::cerr <<
"Exception from command line processing in " << argv[0]
33 <<
": no configuration file given.\n"
34 <<
"For usage and an options list, please do '"
35 << argv[0] <<
" --help"
39 fhicl::ParameterSet pset;
40 if (getenv(
"FHICL_FILE_PATH") ==
nullptr) {
42 <<
"INFO: environment variable FHICL_FILE_PATH was not set. Using \".\"\n";
43 setenv(
"FHICL_FILE_PATH",
".", 0);
45 cet::filepath_lookup_after1 lookup_policy(
"FHICL_FILE_PATH");
46 make_ParameterSet(vm[
"config"].as<std::string>(), lookup_policy, pset);
49 #endif //artdaq_proto_LoadParameterSet_hh