17 #ifndef ICARUSCODE_DECODE_DECODERTOOLS_PMTCONFIGURATIONEXTRACTOR_H
18 #define ICARUSCODE_DECODE_DECODERTOOLS_PMTCONFIGURATIONEXTRACTOR_H
28 #include "art/Framework/Principal/DataViewImpl.h"
29 #include "messagefacility/MessageLogger/MessageLogger.h"
30 #include "fhiclcpp/ParameterSet.h"
31 #include "cetlib_except/exception.h"
41 #include <initializer_list>
48 class PMTconfigurationExtractorBase;
49 class PMTconfigurationExtractor;
55 template <
typename Principal>
75 {
return pset.has_key(
"configuration_documents"); }
124 fhicl::ParameterSet
const& container,
125 std::string
const& configListKey,
126 std::initializer_list<std::regex const> components
131 template <
typename RBegin,
typename REnd>
132 static bool matchKey(std::string
const& key, RBegin rbegin, REnd rend);
332 {
return pset.has_key(
"configuration_documents"); }
336 (fhicl::ParameterSet
const& pset, std::string
const& key);
373 (fhicl::ParameterSet
const& pset, std::string
const& boardName)
383 (fhicl::ParameterSet
const& boardPSet,
unsigned short int channelNo)
const;
392 (fhicl::ParameterSet
const& pset, std::string
const& key)
const;
407 : fChannelMap(&channelMappingService)
414 namespace icarus::details {
416 template <
typename ConfigMap>
439 using Key_t = std::tuple_element_t<0U, typename ConfigMap::value_type>;
441 std::optional<std::pair<Key_t, sbn::PMTconfiguration>> config;
445 for (
auto const& [
id, pset ]: configMap) {
448 fhicl::ParameterSet
const configDocs
450 (pset,
"configuration_documents", { std::regex{
"icaruspmt.*" } })
455 if (config->second == candidateConfig)
continue;
456 mf::LogError log(
"extractPMTreadoutConfiguration");
457 log <<
"Found two candidate configurations differring:"
458 "\nFirst [" << config->first <<
"]:\n" << config->second
459 <<
"\nSecond [" <<
id <<
"]:\n" << candidateConfig
461 throw cet::exception(
"extractPMTreadoutConfiguration")
462 <<
"extractPMTreadoutConfiguration() found inconsistent configurations.\n";
465 config.emplace(std::move(
id), std::move(candidateConfig));
469 throw cet::exception(
"extractPMTreadoutConfiguration")
470 <<
"extractPMTreadoutConfiguration() could not find a suitable configuration.\n";
473 return extractor.
finalize(std::move(config->second));
481 template <
typename RBegin,
typename REnd>
483 (std::string
const& key, RBegin rbegin, REnd rend)
485 for (
auto iRegex = rbegin; iRegex != rend; ++iRegex)
486 if (std::regex_match(key, *iRegex))
return true;
492 template <
typename Principal>
506 #endif // ICARUSCODE_DECODE_DECODERTOOLS_PMTCONFIGURATIONEXTRACTOR_H
sbn::PMTconfiguration extractPMTreadoutConfiguration(std::string const &srcFileName, icarus::PMTconfigurationExtractor extractor)
Information from the configuration of a V1730 PMT readout board.
Utilities to extract art FHiCL configuration from different sources.
Information from the configuration of PMT readout.
std::map< std::string, fhicl::ParameterSet > readConfigurationFromArtPrincipal(Principal const &principal)
Reads and returns the complete art configuration in the principal.
Class containing configuration for a V1730 channel.
Class containing configuration for PMT readout.
sbn::PMTconfiguration extractPMTreadoutConfigurationImpl(ConfigMap const &configMap, icarus::PMTconfigurationExtractor extractor)
Class containing configuration for a V1730 board.