All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | List of all members
icarus::PMTconfigurationExtractorBase Class Reference

#include <PMTconfigurationExtractor.h>

Inheritance diagram for icarus::PMTconfigurationExtractorBase:
icarus::PMTconfigurationExtractor

Public Types

using ConfigurationData_t = sbn::PMTconfiguration
 

Static Public Member Functions

Utility
static fhicl::ParameterSet convertConfigurationDocuments (fhicl::ParameterSet const &container, std::string const &configListKey, std::initializer_list< std::regex const > components)
 Returns a parameter set with the content of configuration_documents key from container. More...
 
template<typename RBegin , typename REnd >
static bool matchKey (std::string const &key, RBegin rbegin, REnd rend)
 

Interface

static bool mayHaveConfiguration (fhicl::ParameterSet const &pset)
 Returns whether pset may contain the needed configuration. More...
 
ConfigurationData_t extract (fhicl::ParameterSet const &config) const
 Extracts all supported PMT configuration from config. More...
 
ConfigurationData_t finalize (ConfigurationData_t config) const
 Finalizes the content of config and returns it. More...
 

Detailed Description

Definition at line 63 of file PMTconfigurationExtractor.h.

Member Typedef Documentation

Definition at line 67 of file PMTconfigurationExtractor.h.

Member Function Documentation

fhicl::ParameterSet icarus::PMTconfigurationExtractorBase::convertConfigurationDocuments ( fhicl::ParameterSet const &  container,
std::string const &  configListKey,
std::initializer_list< std::regex const >  components 
)
static

Returns a parameter set with the content of configuration_documents key from container.

Parameters
containerparameter set including a table with key configListKey
configListKeyname of the key in container with the configuration
componentskeys to be converted (as regular expressions)
Returns
a parameter set

The configuration_documents element of container is processed: for each of its keys which match at least one of the components regular expression patterns (std::regex_match()), the associated string value is parsed with FHiCL parser, and the result is set as a FHiCL table in the output parameter set. For example, if the components are { std::regex{".*pmt.*"}, std::regex{".*trigger.*"} }, the returned value is a parameter set that may have keys like icaruspmtee01, icaruspmtew02, icarustrigger etc., each one with a FHiCL table as `value.

Definition at line 23 of file PMTconfigurationExtractor.cxx.

27  {
28 
29  fhicl::ParameterSet const sourceConfig
30  = container.get<fhicl::ParameterSet>(configListKey);
31 
32  fhicl::ParameterSet configDocs;
33  for (auto const& key: sourceConfig.get_names()) {
34  if (!sourceConfig.is_key_to_atom(key)) continue;
35 
36  if (!matchKey(key, components.begin(), components.end())) continue;
37 
38  std::string const psetStr = sourceConfig.get<std::string>(key);
39 
40  fhicl::ParameterSet pset;
41  try {
42  pset = fhicl::ParameterSet::make(psetStr);
43  }
44  catch (cet::exception& e) {
45  throw cet::exception{ "convertConfigurationDocuments", "", e }
46  << "Error parsing the content of key '" << configListKey << "." << key
47  << "'; content was:\n" << psetStr << "\n";
48  }
49 
50  configDocs.put(key, pset);
51 
52  } // for all main keys
53 
54  return configDocs;
55 } // convertConfigurationDocuments()
static bool matchKey(std::string const &key, RBegin rbegin, REnd rend)
do i e
ConfigurationData_t icarus::PMTconfigurationExtractorBase::extract ( fhicl::ParameterSet const &  config) const

Extracts all supported PMT configuration from config.

Parameters
configa FHiCL parameter set with component configuration
Returns
an object with the supported PMT configuration

All PMT-related configuration that is known to this code is extracted and returned.

This function is undefined here: it must be overridden.

ConfigurationData_t icarus::PMTconfigurationExtractorBase::finalize ( ConfigurationData_t  config) const
inline

Finalizes the content of config and returns it.

Definition at line 92 of file PMTconfigurationExtractor.h.

93  { return config; }
template<typename RBegin , typename REnd >
bool icarus::PMTconfigurationExtractorBase::matchKey ( std::string const &  key,
RBegin  rbegin,
REnd  rend 
)
static

Returns whether key matches at least one of the regular expressions in the [ rbegin, rend [ range.

Definition at line 483 of file PMTconfigurationExtractor.h.

484 {
485  for (auto iRegex = rbegin; iRegex != rend; ++iRegex)
486  if (std::regex_match(key, *iRegex)) return true;
487  return false;
488 } // icarus::PMTconfigurationExtractorBase::matchKey()
static bool icarus::PMTconfigurationExtractorBase::mayHaveConfiguration ( fhicl::ParameterSet const &  pset)
inlinestatic

Returns whether pset may contain the needed configuration.

Definition at line 74 of file PMTconfigurationExtractor.h.

75  { return pset.has_key("configuration_documents"); }

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