10 #ifndef ICARUSCODE_DECODE_DECODERTOOLS_TRIGGERCONFIGURATIONEXTRACTOR_H
11 #define ICARUSCODE_DECODE_DECODERTOOLS_TRIGGERCONFIGURATIONEXTRACTOR_H
19 #include "art/Framework/Principal/DataViewImpl.h"
20 #include "messagefacility/MessageLogger/MessageLogger.h"
21 #include "fhiclcpp/ParameterSet.h"
22 #include "cetlib_except/exception.h"
32 #include <initializer_list>
37 class TriggerConfigurationExtractorBase;
38 class TriggerConfigurationExtractor;
44 template <
typename Principal>
64 {
return pset.has_key(
"configuration_documents"); }
107 fhicl::ParameterSet
const& container,
108 std::string
const& configListKey,
109 std::initializer_list<std::regex const> components
114 template <
typename RBegin,
typename REnd>
115 static bool matchKey(std::string
const& key, RBegin rbegin, REnd rend);
317 (std::string
const& expectedFragmentType =
"ICARUSTriggerUDP")
327 {
return pset.has_key(
"configuration_documents"); }
331 (fhicl::ParameterSet
const& pset, std::string
const& key);
363 (fhicl::ParameterSet
const& pset)
373 (fhicl::ParameterSet
const& pset, std::string
const& key)
const;
386 namespace icarus::details {
388 template <
typename ConfigMap>
411 using Key_t = std::tuple_element_t<0U, typename ConfigMap::value_type>;
413 std::optional<std::pair<Key_t, icarus::TriggerConfiguration>> config;
417 for (
auto const& [
id, pset ]: configMap) {
420 fhicl::ParameterSet
const configDocs
422 (pset,
"configuration_documents", { std::regex{
"icarustrigger.*" } })
427 if (config->second == candidateConfig)
continue;
428 mf::LogError log(
"extractTriggerReadoutConfiguration");
429 log <<
"Found two candidate configurations differring:"
430 "\nFirst [" << config->first <<
"]:\n" << config->second
431 <<
"\nSecond [" <<
id <<
"]:\n" << candidateConfig
433 throw cet::exception(
"extractTriggerReadoutConfiguration")
434 <<
"extractTriggerReadoutConfiguration() found inconsistent configurations.\n";
437 config.emplace(std::move(
id), std::move(candidateConfig));
441 throw cet::exception(
"extractTriggerReadoutConfiguration")
442 <<
"extractTriggerReadoutConfiguration() could not find a suitable configuration.\n";
445 return std::move(config->second);
453 template <
typename RBegin,
typename REnd>
455 (std::string
const& key, RBegin rbegin, REnd rend)
457 for (
auto iRegex = rbegin; iRegex != rend; ++iRegex)
458 if (std::regex_match(key, *iRegex))
return true;
464 template <
typename Principal>
478 #endif // ICARUSCODE_DECODE_DECODERTOOLS_TRIGGERCONFIGURATIONEXTRACTOR_H
Definitions of the trigger bits for SBN.
Information from the configuration of the ICARUS trigger readout.
Utilities to extract art FHiCL configuration from different sources.
icarus::TriggerConfiguration extractTriggerReadoutConfigurationImpl(ConfigMap const &configMap, icarus::TriggerConfigurationExtractor extractor)
icarus::TriggerConfiguration extractTriggerReadoutConfiguration(std::string const &srcFileName, icarus::TriggerConfigurationExtractor extractor)
std::map< std::string, fhicl::ParameterSet > readConfigurationFromArtPrincipal(Principal const &principal)
Reads and returns the complete art configuration in the principal.