LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
art::BasicOutputOptionsHandler Class Reference

#include "BasicOutputOptionsHandler.h"

Inheritance diagram for art::BasicOutputOptionsHandler:
art::OptionsHandler

Public Member Functions

 BasicOutputOptionsHandler (bpo::options_description &desc)
 
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
 

Private Attributes

std::string tmpDir_ {}
 

Detailed Description

Definition at line 12 of file BasicOutputOptionsHandler.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file BasicOutputOptionsHandler.cc.

References art::add_opt().

34 {
35  bpo::options_description output_options{"Output options"};
36  auto options = output_options.add_options();
37  add_opt(options,
38  "TFileName,T",
39  bpo::value<std::string>(),
40  "File name for TFileService.");
41  add_opt(
42  options,
43  "tmpdir",
44  bpo::value<std::string>(&tmpDir_),
45  "Temporary directory for in-progress output files (defaults to directory "
46  "of specified output file names).");
47  add_opt(options,
48  "tmpDir",
49  bpo::value<std::string>(&tmpDir_),
50  "Synonym for --tmpdir.");
51  add_opt(options,
52  "output,o",
53  bpo::value<stringvec>()->composing(),
54  "Event output stream file (optionally specify stream with "
55  "stream-label:fileName in which case multiples are OK).");
56  add_opt(options, "no-output", "Disable all output streams.");
57  desc.add(output_options);
58 }
void add_opt(T &t, Args &&...args)

Member Function Documentation

int art::OptionsHandler::checkOptions ( bpo::variables_map const &  vm)
inherited

Definition at line 51 of file OptionsHandler.cc.

52 {
53  std::string const thisClass(cet::demangle_symbol(typeid(*this).name()));
54  return exceptionCatcher([&vm, this] { return doCheckOptions(vm); },
55  thisClass + "::doCheckOptions()",
56  89);
57 }
virtual int doCheckOptions(bpo::variables_map const &vm)=0
int art::BasicOutputOptionsHandler::doCheckOptions ( bpo::variables_map const &  vm)
overrideprivatevirtual
int art::BasicOutputOptionsHandler::doProcessOptions ( bpo::variables_map const &  vm,
fhicl::intermediate_table raw_config 
)
overrideprivatevirtual

Implements art::OptionsHandler.

Definition at line 240 of file BasicOutputOptionsHandler.cc.

References art::completeRootHandlers(), art::detail::exists_outside_prolog(), art::detail::fhicl_key(), fhicl::intermediate_table::get(), art::module, fhicl::intermediate_table::put(), art::service, art::detail::supports_key(), and art::unloadRootSigHandler().

243 {
244  // TFileService output.
245  if (vm.count("TFileName") == 1) {
246  std::string tFileName(vm["TFileName"].as<std::string>());
247  std::string const& key{"services.TFileService"};
248  if (tFileName.empty() && detail::exists_outside_prolog(raw_config, key) &&
249  raw_config.get<table_t const&>(key).empty()) {
250  tFileName = "hist.root";
251  }
252  if (!tFileName.empty()) {
253  raw_config.put(key + ".fileName", tFileName);
254  }
255  }
256  // Output stream options.
257  processFileOutputOptions(vm, raw_config);
258  // tmpDir option for TFileService and output streams.
259  if (!tmpDir_.empty()) {
260  std::string const& tfile_key = fhicl_key("services", "TFileService");
261  if (detail::exists_outside_prolog(raw_config, tfile_key)) {
262  assert(detail::supports_key(
263  art::suffix_type::service, "TFileService", "tmpDir"));
264  raw_config.put(fhicl_key(tfile_key, "tmpDir"), tmpDir_);
265  }
266 
267  // Inject tmpDir for output modules that support the 'tmpDir' parameter.
268  std::string const outputs_stem{"outputs"};
269  if (detail::exists_outside_prolog(raw_config, outputs_stem)) {
270  auto const& table = raw_config.get<table_t const&>(outputs_stem);
271  for (auto const& output : table) {
272  auto const& module_label = fhicl_key(outputs_stem, output.first);
273  auto const& module_type = fhicl_key(module_label, "module_type");
274  if (!detail::exists_outside_prolog(raw_config, module_type))
275  continue;
276 
277  auto const& spec = raw_config.get<std::string>(module_type);
278  if (!detail::supports_key(art::suffix_type::module, spec, "tmpDir"))
279  continue;
280 
281  raw_config.put(fhicl_key(module_label, "tmpDir"), tmpDir_);
282  }
283  }
284  }
285 
286  // Init ROOT handlers facility
287  auto const unload_key = fhicl_key("scheduler", "unloadRootSigHandler");
288  auto const unloadRSHandler =
289  detail::exists_outside_prolog(raw_config, unload_key) ?
290  raw_config.get<bool>(unload_key) :
291  true;
292  if (unloadRSHandler) {
294  }
295 
296  auto const reset_key = fhicl_key("scheduler", "resetRootErrHandler");
297  auto const maybe_reset =
298  detail::exists_outside_prolog(raw_config, reset_key) ?
299  raw_config.get<bool>(reset_key) :
300  true;
301  RootErrorHandlerSentry re_sentry{maybe_reset};
303 
304  return 0;
305 }
bool exists_outside_prolog(fhicl::intermediate_table const &config, std::string const &key)
void unloadRootSigHandler()
bool put(std::string const &name, std::string const &value, bool in_prolog=false)
std::enable_if_t< std::is_convertible< T, std::string >::value, std::string > fhicl_key(T const &name)
Definition: fhicl_key.h:13
void completeRootHandlers()
T get(std::string const &name)
bool supports_key(suffix_type st, std::string const &spec, std::string const &key)
int art::OptionsHandler::processOptions ( bpo::variables_map const &  vm,
fhicl::intermediate_table raw_config 
)
inherited

Definition at line 60 of file OptionsHandler.cc.

Referenced by art::run_art_string_config().

62 {
63  std::string const thisClass(cet::demangle_symbol(typeid(*this).name()));
64  return exceptionCatcher(
65  [&, this] { return doProcessOptions(vm, raw_config); },
66  thisClass + "::doProcessOptions()",
67  90);
68 }
virtual int doProcessOptions(bpo::variables_map const &vm, fhicl::intermediate_table &raw_config)=0

Member Data Documentation

std::string art::BasicOutputOptionsHandler::tmpDir_ {}
private

Definition at line 23 of file BasicOutputOptionsHandler.h.


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