LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
art::RPManager Class Reference

#include "RPManager.h"

Public Types

using RPPath_t = std::vector< std::unique_ptr< art::RPWorker >>
 
using RPMap_t = std::map< std::string, RPPath_t >
 
template<typename RET , typename... ARGS>
using invoke_function_t = RET(art::ResultsProducer::*)(ARGS...)
 
using on_rpworker_t = std::function< void(art::RPWorker &)>
 

Public Member Functions

 RPManager (fhicl::ParameterSet const &ps)
 
std::size_t size () const
 
bool empty () const
 
template<typename... ARGS>
void invoke (invoke_function_t< void, ARGS... > mfunc, ARGS &&...args)
 
void for_each_RPWorker (on_rpworker_t wfunc)
 

Private Member Functions

RPMap_t makeRPs_ (fhicl::ParameterSet const &ps)
 

Private Attributes

cet::BasicPluginFactory pf_
 
RPMap_t rpmap_
 
std::size_t size_
 

Detailed Description

Definition at line 24 of file RPManager.h.

Member Typedef Documentation

template<typename RET , typename... ARGS>
using art::RPManager::invoke_function_t = RET (art::ResultsProducer::*)(ARGS...)

Definition at line 30 of file RPManager.h.

using art::RPManager::on_rpworker_t = std::function<void(art::RPWorker&)>

Definition at line 32 of file RPManager.h.

using art::RPManager::RPMap_t = std::map<std::string, RPPath_t>

Definition at line 27 of file RPManager.h.

using art::RPManager::RPPath_t = std::vector<std::unique_ptr<art::RPWorker>>

Definition at line 26 of file RPManager.h.

Constructor & Destructor Documentation

art::RPManager::RPManager ( fhicl::ParameterSet const &  ps)

Definition at line 21 of file RPManager.cc.

References fhicl::ParameterSet::get(), fhicl::ParameterSet::id(), art::plugin, and cet::PluginTypeDeducer< art::ResultsProducer >::value.

22  : pf_(Suffixes::plugin(), "makeRP")
23  , rpmap_(makeRPs_(ps))
24  , size_(countProducers(rpmap_))
25 {}
cet::BasicPluginFactory pf_
Definition: RPManager.h:45
static std::string const & plugin()
std::size_t size_
Definition: RPManager.h:47
RPMap_t rpmap_
Definition: RPManager.h:46
RPMap_t makeRPs_(fhicl::ParameterSet const &ps)
Definition: RPManager.cc:54

Member Function Documentation

bool art::RPManager::empty ( void  ) const
inline

Definition at line 59 of file RPManager.h.

References size_.

60 {
61  return size_ == 0ul;
62 }
std::size_t size_
Definition: RPManager.h:47
void art::RPManager::for_each_RPWorker ( on_rpworker_t  wfunc)

Definition at line 76 of file RPManager.h.

References rpmap_, and w.

Referenced by art::RootOutput::beginRun(), art::RootOutput::beginSubRun(), art::RootOutput::doRegisterProducts(), art::RootOutput::endRun(), art::RootOutput::endSubRun(), art::RootOutput::event(), art::RootOutput::readResults(), and art::RootOutput::startEndFile().

77 {
78  for (auto& path : rpmap_) {
79  for (auto& w : path.second) {
80  wfunc(*w);
81  }
82  }
83 }
Float_t w
Definition: plot.C:23
RPMap_t rpmap_
Definition: RPManager.h:46
template<typename... ARGS>
void art::RPManager::invoke ( invoke_function_t< void, ARGS... >  mfunc,
ARGS &&...  args 
)

Definition at line 66 of file RPManager.h.

References rpmap_, and w.

Referenced by art::RootOutput::beginJob(), art::RootOutput::endJob(), and art::RootOutput::finishEndFile().

67 {
68  for (auto& path : rpmap_) {
69  for (auto& w : path.second) {
70  (w->rp().*mfunc)(std::forward<ARGS>(args)...);
71  }
72  }
73 }
Float_t w
Definition: plot.C:23
RPMap_t rpmap_
Definition: RPManager.h:46
auto art::RPManager::makeRPs_ ( fhicl::ParameterSet const &  ps)
private

Definition at line 54 of file RPManager.cc.

References art::errors::Configuration, fhicl::ParameterSet::get(), pf_, rpmap_, and util::flags::to_string().

55 {
56  using fhicl::ParameterSet;
57  decltype(rpmap_) result;
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"));
64  std::string errMsg;
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";
71  }
72  } else {
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(),
77  all_labels.cend());
78  std::map<std::string, std::string> used_labels;
79  for (auto path_key = results_keys.begin(); path_key != path_keys_end;
80  ++path_key) {
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";
84  } else {
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()) { // Bad label
89  errMsg += omLabel + ".results." + *path_key + '[' +
90  std::to_string(path_index) + "] (" + l + ')' +
91  " is not defined in " + omLabel + ".results.producers.\n";
92  } else {
93  auto const ans = used_labels.emplace(l, *path_key);
94  if (!ans.second) { // Duplicate
95  errMsg += omLabel + ".results." + *path_key + '[' +
96  std::to_string(path_index) + "] (" + l + ')' +
97  " is a duplicate: previously used in path " +
98  ans.first->second + ".\n";
99  }
100  }
101  ++path_index;
102  }
103  if (errMsg.empty()) {
104  paths.emplace(*path_key, std::move(path));
105  }
106  }
107  }
108  if (paths.empty() && (errMsg.empty())) {
109  paths.emplace("default_path", all_labels);
110  }
111  }
112  if (!errMsg.empty()) {
114  << "Errors encountered while configuring ResultsProducers:\n"
115  << errMsg;
116  }
117  for (auto const& path : paths) {
118  auto ins_res = rpmap_.emplace(path.first, decltype(rpmap_)::mapped_type{});
119  std::transform(path.second.cbegin(),
120  path.second.cend(),
121  std::back_inserter(ins_res.first->second),
122  std::bind(&pathLoader,
123  std::ref(pf_),
124  std::cref(producers),
125  std::placeholders::_1,
126  std::cref(omLabel),
127  std::ref(errMsg)));
128  }
129  if (!errMsg.empty()) {
131  << "Errors encountered while instantiating ResultsProducers:\n"
132  << errMsg;
133  }
134  return result;
135 }
cet::BasicPluginFactory pf_
Definition: RPManager.h:45
T get(std::string const &key) const
Definition: ParameterSet.h:231
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Definition: BitMask.h:187
RPMap_t rpmap_
Definition: RPManager.h:46
std::size_t art::RPManager::size ( void  ) const
inline

Definition at line 53 of file RPManager.h.

References size_.

54 {
55  return size_;
56 }
std::size_t size_
Definition: RPManager.h:47

Member Data Documentation

cet::BasicPluginFactory art::RPManager::pf_
private

Definition at line 45 of file RPManager.h.

Referenced by makeRPs_().

RPMap_t art::RPManager::rpmap_
private

Definition at line 46 of file RPManager.h.

Referenced by for_each_RPWorker(), invoke(), and makeRPs_().

std::size_t art::RPManager::size_
private

Definition at line 47 of file RPManager.h.

Referenced by empty(), and size().


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