4 #include "cetlib/PluginTypeDeducer.h" 13 std::size_t result = 0ul;
14 for (
auto const& path : rpmap) {
15 result += path.second.size();
23 , rpmap_(makeRPs_(ps))
24 , size_(countProducers(rpmap_))
28 std::unique_ptr<art::RPWorker>
29 pathLoader(cet::BasicPluginFactory& pf,
31 std::string
const& pkey,
32 std::string
const& omLabel,
35 std::unique_ptr<art::RPWorker> result;
37 auto libspec = pconfig.
get<std::string>(
"plugin_type");
38 auto const& ptype = pf.pluginType(libspec);
40 result = pf.makePlugin<std::unique_ptr<art::RPWorker>,
43 libspec, {pconfig.
id(), libspec, pkey}, pconfig);
45 errMsg += +
"Parameter set " + omLabel,
46 +
".results." + pkey +
" specifies a plugin " + libspec +
47 "\n which is not of required type ResultsProducer.\n";
58 auto results = ps.
get<ParameterSet>(
"results", {});
59 auto producers = results.get<ParameterSet>(
"producers", {});
60 auto results_keys = results.get_names();
61 auto producer_keys = producers.get_names();
62 std::map<std::string, std::vector<std::string>> paths;
63 std::string
const omLabel(ps.get<std::string>(
"module_label"));
65 if (producer_keys.empty()) {
66 if (!results.is_empty()) {
68 <<
"Parameter set " << omLabel
69 <<
".results is non-empty, but does not contain\n" 70 <<
"a non-empty producers parameter set.\n";
73 auto const path_keys_end =
74 std::remove(results_keys.begin(), results_keys.end(),
"producers");
75 auto const& all_labels = producers.get_names();
76 std::set<std::string> all_labels_set(all_labels.cbegin(),
78 std::map<std::string, std::string> used_labels;
79 for (
auto path_key = results_keys.begin(); path_key != path_keys_end;
81 if (!results.is_key_to_sequence(*path_key)) {
82 errMsg += +
"Parameter " + omLabel +
".results." + *path_key +
83 " does not describe a sequence (i.e. a path).\n";
85 auto path = results.get<std::vector<std::string>>(*path_key);
86 std::size_t path_index = 0ull;
87 for (
auto const& l : path) {
88 if (all_labels_set.find(l) == all_labels_set.end()) {
89 errMsg += omLabel +
".results." + *path_key +
'[' +
91 " is not defined in " + omLabel +
".results.producers.\n";
93 auto const ans = used_labels.emplace(l, *path_key);
95 errMsg += omLabel +
".results." + *path_key +
'[' +
97 " is a duplicate: previously used in path " +
98 ans.first->second +
".\n";
103 if (errMsg.empty()) {
104 paths.emplace(*path_key, std::move(path));
108 if (paths.empty() && (errMsg.empty())) {
109 paths.emplace(
"default_path", all_labels);
112 if (!errMsg.empty()) {
114 <<
"Errors encountered while configuring ResultsProducers:\n" 117 for (
auto const& path : paths) {
118 auto ins_res =
rpmap_.emplace(path.first, decltype(
rpmap_)::mapped_type{});
119 std::transform(path.second.cbegin(),
121 std::back_inserter(ins_res.first->second),
122 std::bind(&pathLoader,
124 std::cref(producers),
125 std::placeholders::_1,
129 if (!errMsg.empty()) {
131 <<
"Errors encountered while instantiating ResultsProducers:\n" static std::string const value
cet::BasicPluginFactory pf_
std::map< std::string, RPPath_t > RPMap_t
RPManager(fhicl::ParameterSet const &ps)
T get(std::string const &key) const
ParameterSetID id() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
RPMap_t makeRPs_(fhicl::ParameterSet const &ps)