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

#include <TriggerConfigurationExtractor.h>

Inheritance diagram for icarus::TriggerConfigurationExtractorBase:
icarus::TriggerConfigurationExtractor

Public Types

using ConfigurationData_t = icarus::TriggerConfiguration
 

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 Trigger configuration from config. More...
 

Detailed Description

Definition at line 52 of file TriggerConfigurationExtractor.h.

Member Typedef Documentation

Definition at line 56 of file TriggerConfigurationExtractor.h.

Member Function Documentation

fhicl::ParameterSet icarus::TriggerConfigurationExtractorBase::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 22 of file TriggerConfigurationExtractor.cxx.

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

Extracts all supported Trigger configuration from config.

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

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

This function is undefined here: it must be overridden.

template<typename RBegin , typename REnd >
bool icarus::TriggerConfigurationExtractorBase::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 455 of file TriggerConfigurationExtractor.h.

456 {
457  for (auto iRegex = rbegin; iRegex != rend; ++iRegex)
458  if (std::regex_match(key, *iRegex)) return true;
459  return false;
460 } // icarus::PMTconfigurationExtractorBase::matchKey()
static bool icarus::TriggerConfigurationExtractorBase::mayHaveConfiguration ( fhicl::ParameterSet const &  pset)
inlinestatic

Returns whether pset may contain the needed configuration.

Definition at line 63 of file TriggerConfigurationExtractor.h.

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

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