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

#include <BasicOutputOptionsHandler.h>

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

Public Member Functions

 BasicOutputOptionsHandler (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
 

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 28 of file BasicOutputOptionsHandler.cc.

30 {
31  bpo::options_description output_options{"Output options"};
32  // clang-format off
33  output_options.add_options()
34  ("TFileName,T", bpo::value<std::string>(), "File name for TFileService.")
35  ("tmpdir",
36  bpo::value<std::string>(&tmpDir_),
37  "Temporary directory for in-progress output files (defaults to directory "
38  "of specified output file names).")
39  ("tmpDir", bpo::value<std::string>(&tmpDir_), "Synonym for --tmpdir.")
40  ("output,o",
41  bpo::value<stringvec>()->composing(),
42  "Event output stream file (optionally specify stream with "
43  "stream-label:fileName in which case multiples are OK).")
44  ("no-output", "Disable all output streams.");
45  // clang-format on
46  desc.add(output_options);
47 }

Member Function Documentation

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

Implements art::OptionsHandler.

Definition at line 50 of file BasicOutputOptionsHandler.cc.

51 {
52  return 0;
53 }
int art::BasicOutputOptionsHandler::doProcessOptions ( bpo::variables_map const &  vm,
fhicl::intermediate_table raw_config 
)
overrideprivatevirtual

Implements art::OptionsHandler.

Definition at line 226 of file BasicOutputOptionsHandler.cc.

229 {
230  // TFileService output.
231  if (vm.count("TFileName") == 1) {
232  std::string tFileName(vm["TFileName"].as<std::string>());
233  std::string const& key{"services.TFileService"};
234  if (tFileName.empty() && detail::exists_outside_prolog(raw_config, key) &&
235  raw_config.get<table_t const&>(key).empty()) {
236  tFileName = "hist.root";
237  }
238  if (!tFileName.empty()) {
239  raw_config.put(key + ".fileName", tFileName);
240  }
241  }
242  // Output stream options.
243  processFileOutputOptions(vm, raw_config);
244  // tmpDir option for TFileService and output streams.
245  if (!tmpDir_.empty()) {
246  std::string const& tfile_key = fhicl_key("services", "TFileService");
247  if (detail::exists_outside_prolog(raw_config, tfile_key)) {
248  auto has_tmpDir [[maybe_unused]] =
249  detail::supports_key(Suffixes::service(), "TFileService", "tmpDir");
250  assert(has_tmpDir); // Should never happen.
251  raw_config.put(fhicl_key(tfile_key, "tmpDir"), tmpDir_);
252  }
253 
254  // Inject tmpDir for output modules that support the 'tmpDir' parameter.
255  std::string const outputs_stem{"outputs"};
256  if (detail::exists_outside_prolog(raw_config, outputs_stem)) {
257  auto const& table = raw_config.get<table_t const&>(outputs_stem);
258  for (auto const& output : table) {
259  auto const& module_label = fhicl_key(outputs_stem, output.first);
260  auto const& module_type = fhicl_key(module_label, "module_type");
261  if (!detail::exists_outside_prolog(raw_config, module_type))
262  continue;
263 
264  auto const& spec = raw_config.get<std::string>(module_type);
265  if (!detail::supports_key(Suffixes::module(), spec, "tmpDir"))
266  continue;
267 
268  raw_config.put(fhicl_key(module_label, "tmpDir"), tmpDir_);
269  }
270  }
271  }
272 
273  return 0;
274 }
bool exists_outside_prolog(fhicl::intermediate_table const &config, std::string const &key)
std::string string
Definition: nybbler.cc:12
bool supports_key(std::string const &suffix, std::string const &spec, std::string const &key)
ModuleType module_type(std::string const &full_key)
def key(type, name=None)
Definition: graph.py:13
std::enable_if_t< std::is_convertible_v< T, std::string >, std::string > fhicl_key(T const &name)
Definition: fhicl_key.h:12
bool put(std::string const &name, std::string const &value, bool in_prolog=false)
T get(std::string const &name)
static std::string const & service()
static std::string const & module()
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97

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: