23 string const omLabel(
ps.get<
string>(
"module_label"));
27 auto producer_keys = producers.
get_names();
28 map<string, vector<string>> paths;
30 if (producer_keys.empty() && !results.is_empty()) {
32 <<
"Parameter set " << omLabel
33 <<
".results is non-empty, but does not contain\n" 34 <<
"a non-empty producers parameter set.\n";
36 auto const path_keys_end =
37 remove(results_keys.begin(), results_keys.end(),
"producers");
38 auto const& all_labels = producers.
get_names();
39 set<string> all_labels_set(all_labels.cbegin(), all_labels.cend());
40 map<string, string> used_labels;
41 for (
auto path_key = results_keys.begin(); path_key != path_keys_end;
43 if (!results.is_key_to_sequence(*path_key)) {
44 errMsg +=
"Parameter " + omLabel +
".results." + *path_key +
45 " does not describe a sequence (i.e. a path).\n";
48 auto path = results.get<vector<string>>(*path_key);
50 for (
auto const&
l : path) {
51 if (all_labels_set.find(
l) == all_labels_set.end()) {
53 errMsg += omLabel +
".results."s + *path_key +
'[' +
55 " is not defined in "s + omLabel +
".results.producers.\n"s;
59 auto const ans = used_labels.emplace(
l, *path_key);
62 errMsg += omLabel +
".results." + *path_key +
'[' +
64 " is a duplicate: previously used in path " +
65 ans.
first->second +
".\n";
70 paths.emplace(*path_key,
move(path));
73 if (paths.empty() && (errMsg.empty())) {
74 paths.emplace(
"default_path", all_labels);
76 if (!errMsg.empty()) {
78 <<
"Errors encountered while configuring ResultsProducers:\n" 82 for (
auto const& path : paths) {
83 auto ins_res =
rpmap_.emplace(path.first,
vector<unique_ptr<RPWorker>>{});
84 transform(path.second.cbegin(),
86 back_inserter(ins_res.first->second),
87 [&pf, &producers, &omLabel, &errMsg](
string const& pkey) {
88 unique_ptr<RPWorker>
result;
90 auto libspec = pconfig.
get<
string>(
"plugin_type");
91 auto const& ptype = pf.pluginType(libspec);
93 result = pf.makePlugin<unique_ptr<RPWorker>,
96 libspec, {pconfig.
id(), libspec, pkey}, pconfig);
99 "Parameter set " + omLabel +
".results." + pkey +
100 " specifies a plugin " + libspec +
101 "\n which is not of required type ResultsProducer.\n";
106 if (!errMsg.empty()) {
108 <<
"Errors encountered while instantiating ResultsProducers:\n" 116 for (
auto& path :
rpmap_) {
117 for (
auto&
w : path.second) {
std::map< std::string, std::vector< std::unique_ptr< RPWorker > > > rpmap_
std::function< void(RPWorker &)> on_rpworker_t
void for_each_RPWorker(on_rpworker_t wfunc)
T get(std::string const &key) const
static constexpr double ps
static std::string const & plugin()
ParameterSetID id() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::vector< std::string > get_names() const
std::string to_string(ModuleType const mt)