Public Member Functions | Private Member Functions | List of all members
art::BasicSourceOptionsHandler Class Reference

#include <BasicSourceOptionsHandler.h>

Inheritance diagram for art::BasicSourceOptionsHandler:
art::OptionsHandler

Public Member Functions

 BasicSourceOptionsHandler (bpo::options_description &desc)
 
- Public Member Functions inherited from art::OptionsHandler
virtual ~OptionsHandler ()=default
 
int checkOptions (bpo::variables_map const &vm)
 
int processOptions (bpo::variables_map const &vm, fhicl::intermediate_table &raw_config)
 

Private Member Functions

int doCheckOptions (bpo::variables_map const &vm) override
 
int doProcessOptions (bpo::variables_map const &vm, fhicl::intermediate_table &raw_config) override
 
bool processSourceListArg_ (bpo::variables_map const &vm, std::vector< std::string > &source_list)
 

Detailed Description

Definition at line 14 of file BasicSourceOptionsHandler.h.

Constructor & Destructor Documentation

art::BasicSourceOptionsHandler::BasicSourceOptionsHandler ( bpo::options_description &  desc)
explicit

Definition at line 12 of file BasicSourceOptionsHandler.cc.

14 {
15  bpo::options_description source_options{"Source options"};
16  // clang-format off
17  source_options.add_options()
18  ("source,s",
19  bpo::value<std::vector<std::string>>()->composing(),
20  "Source data file (multiple OK); precludes -S.")
21  ("source-list,S",
22  bpo::value<std::string>(),
23  "file containing a list of source files to read, one per line; "
24  "precludes -s.")
25  ("estart,e",
26  bpo::value<std::string>(),
27  "EventID of first event to process (e.g. '1:2:4' starts event "
28  "processing at run 1, subrun2, event 4).")
29  ("nevts,n", bpo::value<int>(), "Number of events to process.")
30  ("nskip", bpo::value<unsigned long>(), "Number of events to skip.");
31  // clang-format on
32  desc.add(source_options);
33 }

Member Function Documentation

int art::BasicSourceOptionsHandler::doCheckOptions ( bpo::variables_map const &  vm)
overrideprivatevirtual

Implements art::OptionsHandler.

Definition at line 36 of file BasicSourceOptionsHandler.cc.

37 {
38  return 0;
39 }
int art::BasicSourceOptionsHandler::doProcessOptions ( bpo::variables_map const &  vm,
fhicl::intermediate_table raw_config 
)
overrideprivatevirtual

Implements art::OptionsHandler.

Definition at line 42 of file BasicSourceOptionsHandler.cc.

45 {
46  std::vector<std::string> source_list;
47  if (vm.count("source")) {
48  source_list = vm["source"].as<std::vector<std::string>>();
49  }
50  auto have_source_list_file = processSourceListArg_(vm, source_list);
51  // Post-process the config.
52  if (source_list.size() > 0 || have_source_list_file) {
53  // Empty source list file will override non-empty FHiCL spec.
54  raw_config.put("source.fileNames", source_list);
55  }
56  if (vm.count("nevts")) {
57  raw_config.put("source.maxEvents", vm["nevts"].as<int>());
58  }
59  if (vm.count("estart")) {
60  auto const [run, subRun, event] =
61  detail::event_start(vm["estart"].as<std::string>());
62  raw_config.put("source.firstRun", run);
63  raw_config.put("source.firstSubRun", subRun);
64  raw_config.put("source.firstEvent", event);
65  }
66  if (vm.count("nskip")) {
67  raw_config.put("source.skipEvents", vm["nskip"].as<unsigned long>());
68  }
69  return 0;
70 }
std::tuple< RunNumber_t, SubRunNumber_t, EventNumber_t > event_start(std::string const &str_num)
Definition: event_start.cc:72
bool put(std::string const &name, std::string const &value, bool in_prolog=false)
Event finding and building.
bool processSourceListArg_(bpo::variables_map const &vm, std::vector< std::string > &source_list)
bool art::BasicSourceOptionsHandler::processSourceListArg_ ( bpo::variables_map const &  vm,
std::vector< std::string > &  source_list 
)
private

Definition at line 73 of file BasicSourceOptionsHandler.cc.

76 {
77  bool result = !!vm.count("source-list");
78  if (result) {
79  if (!source_list.empty()) {
81  << "--source-list (-S) and --source (-s) or non-option arguments are "
82  << "incompatible due to ordering ambiguities.\n";
83  }
84  auto const filename = vm["source-list"].as<std::string>();
85  std::ifstream flist{filename};
86  if (!flist) {
88  << "Specified source-list file \"" << filename
89  << "\" cannot be read.\n";
90  }
91  art::detail::fillSourceList(flist, source_list);
92  }
93  return result;
94 }
static QCString result
std::string string
Definition: nybbler.cc:12
void fillSourceList(std::istream &ifs, std::vector< std::string > &source_list)
string filename
Definition: train.py:213
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66

The documentation for this class was generated from the following files: