LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
PathsInfo.cc
Go to the documentation of this file.
7 #include "cetlib/HorizontalRule.h"
10 
11 art::PathsInfo::PathsInfo(std::size_t const numPaths,
12  detail::ModuleFactory& factory,
13  fhicl::ParameterSet const& procPS,
15  ProductDescriptions& productsToProduce,
16  ActionTable& actions,
17  ActivityRegistry& areg)
18  : pathResults_{numPaths}
19  , fact_{factory}
20  , procPS_{procPS}
21  , preg_{preg}
22  , productsToProduce_{productsToProduce}
23  , exceptActions_{actions}
24  , areg_{areg}
25 {}
26 
27 // Precondition: !modInfos.empty();
28 void
29 art::PathsInfo::makeAndAppendPath(std::string const& pathName,
30  ModInfos const& modInfos,
31  bool const trigResultsNeeded)
32 {
33  assert(!modInfos.empty());
34  std::vector<WorkerInPath> pathWorkers;
35  for (auto const& mci : modInfos) {
36  makeWorker_(mci, pathWorkers);
37  }
38 
39  if (!configErrMsgs_.empty()) {
40  constexpr cet::HorizontalRule rule{100};
41  std::ostringstream err_msg;
42  err_msg << "\n"
43  << rule('=') << "\n\n"
44  << "!! The following modules have been misconfigured: !!"
45  << "\n";
46  for (auto const& err : configErrMsgs_) {
47  err_msg << "\n" << rule('-') << "\n" << err;
48  }
49  err_msg << "\n" << rule('=') << "\n\n";
50 
51  throw art::Exception(art::errors::Configuration) << err_msg.str();
52  }
53 
54  cet::exempt_ptr<HLTGlobalStatus> pathResults{
55  trigResultsNeeded ? &pathResults_ : nullptr};
56  auto const bit_position_for_new_path = pathPtrs_.size();
57  auto path = std::make_unique<art::Path>(
58  bit_position_for_new_path,
59  pathName,
60  std::move(pathWorkers),
61  std::move(pathResults),
63  areg_,
64  is_observer(modInfos.front().moduleConfigInfo().moduleType()));
65  pathPtrs_.push_back(std::move(path));
66 }
67 
68 void
70  std::vector<WorkerInPath>& pathWorkers)
71 {
72  auto w = makeWorker_(mipi.moduleConfigInfo());
73  pathWorkers.emplace_back(w, mipi.filterAction());
74 }
75 
76 cet::exempt_ptr<art::Worker>
78 {
79  auto it = workers_.find(mci.label());
80  if (it == workers_.end()) { // Need worker.
81  auto moduleConfig =
82  procPS_.get<fhicl::ParameterSet>(mci.configPath() + '.' + mci.label());
83  WorkerParams const p{
84  procPS_,
85  moduleConfig,
86  preg_,
89  ServiceHandle<TriggerNamesService const>{}->getProcessName()};
90  ModuleDescription const md{
91  moduleConfig.id(),
92  p.pset_.get<std::string>("module_type"),
93  p.pset_.get<std::string>("module_label"),
95  areg_.sPreModuleConstruction.invoke(md);
96  try {
97  auto worker = fact_.makeWorker(p, md);
98  areg_.sPostModuleConstruction.invoke(md);
99  it = workers_.emplace(mci.label(), std::move(worker)).first;
100  it->second->setActivityRegistry(&areg_);
101  }
102  catch (fhicl::detail::validationException const& e) {
103  std::ostringstream err_stream;
104  err_stream << "\n\nModule label: "
105  << detail::bold_fontify(md.moduleLabel())
106  << "\nmodule_type : " << detail::bold_fontify(md.moduleName())
107  << "\n\n"
108  << e.what();
109  configErrMsgs_.push_back(err_stream.str());
110  }
111  }
112  return cet::exempt_ptr<Worker>{it->second.get()};
113 }
std::string bold_fontify(std::string const &s)
Definition: bold_fontify.h:9
std::string const & configPath() const
void makeWorker_(detail::ModuleInPathInfo const &mipi, std::vector< WorkerInPath > &pathWorkers)
Definition: PathsInfo.cc:69
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleConstruction
std::vector< BranchDescription > ProductDescriptions
GlobalSignal< detail::SignalResponseType::LIFO, void(ModuleDescription const &)> sPostModuleConstruction
fhicl::ParameterSet const & procPS_
Definition: PathsInfo.h:54
std::vector< std::string > configErrMsgs_
Definition: PathsInfo.h:59
ModuleConfigInfo const & moduleConfigInfo() const
std::vector< detail::ModuleInPathInfo > ModInfos
Definition: PathsInfo.h:26
ActivityRegistry & areg_
Definition: PathsInfo.h:58
PathsInfo(std::size_t const numPaths, detail::ModuleFactory &factory, fhicl::ParameterSet const &procPS, MasterProductRegistry &preg, ProductDescriptions &productsToProduce, ActionTable &actions, ActivityRegistry &areg)
Definition: PathsInfo.cc:11
T get(std::string const &key) const
Definition: ParameterSet.h:231
ActionTable & exceptActions_
Definition: PathsInfo.h:57
ProductDescriptions & productsToProduce_
Definition: PathsInfo.h:56
std::string const & getReleaseVersion()
detail::ModuleFactory & fact_
Definition: PathsInfo.h:53
WorkerMap workers_
Definition: PathsInfo.h:46
ParameterSetID id() const
ModuleDescriptionID id() const
bool is_observer(ModuleType mt)
Definition: ModuleType.h:53
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::unique_ptr< Worker > makeWorker(WorkerParams const &wp, ModuleDescription const &md)
void makeAndAppendPath(std::string const &pathName, ModInfos const &modInfos, bool trigResultsNeeded=true)
Definition: PathsInfo.cc:29
char const * what() const noexcept override
WorkerInPath::FilterAction filterAction() const
HLTGlobalStatus & pathResults()
Definition: PathsInfo.h:63
PathPtrs pathPtrs_
Definition: PathsInfo.h:47
HLTGlobalStatus pathResults_
Definition: PathsInfo.h:48
Float_t e
Definition: plot.C:34
std::string const & label() const
Float_t w
Definition: plot.C:23
MasterProductRegistry & preg_
Definition: PathsInfo.h:55