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

#include "PathManager.h"

Public Types

using Workers = std::vector< Worker * >
 
using vstring = std::vector< std::string >
 

Public Member Functions

 PathManager (PathManager const &)=delete
 
PathManageroperator= (PathManager const &)=delete
 
 PathManager (fhicl::ParameterSet const &procPS, MasterProductRegistry &preg, ProductDescriptions &productsToProduce, ActionTable &exceptActions, ActivityRegistry &areg)
 
vstring const & triggerPathNames () const
 
PathsInfoendPathInfo ()
 
PathsInfotriggerPathsInfo (ScheduleID sID)
 
void resetAll ()
 

Private Types

using ModInfos = PathsInfo::ModInfos
 

Private Member Functions

detail::ModuleConfigInfoMap fillAllModules_ ()
 
vstring processPathConfigs_ ()
 
bool processOnePathConfig_ (std::string const &path_name, vstring const &path_seq, vstring &trigger_path_names, std::ostream &error_stream)
 

Private Attributes

fhicl::ParameterSet procPS_
 
MasterProductRegistrypreg_
 
ProductDescriptionsproductsToProduce_
 
ActionTableexceptActions_
 
ActivityRegistryareg_
 
std::unique_ptr< std::set< std::string > > trigger_paths_config_
 
std::unique_ptr< std::set< std::string > > end_paths_config_
 
detail::ModuleFactory fact_ {}
 
detail::ModuleConfigInfoMap allModules_
 
std::map< std::string, ModInfosprotoTrigPathMap_ {}
 
ModInfos protoEndPathInfo_ {}
 
vstring triggerPathNames_
 
PathsInfo endPathInfo_
 
std::map< ScheduleID, PathsInfotriggerPathsInfo_ {}
 

Detailed Description

Definition at line 36 of file PathManager.h.

Member Typedef Documentation

Definition at line 59 of file PathManager.h.

using art::PathManager::vstring = std::vector<std::string>

Definition at line 42 of file PathManager.h.

using art::PathManager::Workers = std::vector<Worker*>

Definition at line 41 of file PathManager.h.

Constructor & Destructor Documentation

art::PathManager::PathManager ( PathManager const &  )
delete
art::PathManager::PathManager ( fhicl::ParameterSet const &  procPS,
MasterProductRegistry preg,
ProductDescriptions productsToProduce,
ActionTable exceptActions,
ActivityRegistry areg 
)

Definition at line 108 of file PathManager.cc.

References allModules_, areg_, end_paths_config_, endPathInfo_, exceptActions_, fact_, fillAllModules_(), preg_, processPathConfigs_(), procPS_, productsToProduce_, trigger_paths_config_, and triggerPathNames_.

113  : procPS_{procPS}
114  , preg_{preg}
115  , productsToProduce_{productsToProduce}
116  , exceptActions_{exceptActions}
117  , areg_{areg}
118  , trigger_paths_config_{findLegacyConfig(procPS_, "physics.trigger_paths")}
119  , end_paths_config_{findLegacyConfig(procPS_, "physics.end_paths")}
122  , endPathInfo_{0,
123  fact_,
124  procPS_,
125  preg_,
128  areg_}
129 {}
detail::ModuleConfigInfoMap allModules_
Definition: PathManager.h:82
std::unique_ptr< std::set< std::string > > end_paths_config_
Definition: PathManager.h:79
ProductDescriptions & productsToProduce_
Definition: PathManager.h:71
vstring triggerPathNames_
Definition: PathManager.h:85
detail::ModuleConfigInfoMap fillAllModules_()
Definition: PathManager.cc:169
vstring processPathConfigs_()
Definition: PathManager.cc:213
ActivityRegistry & areg_
Definition: PathManager.h:73
detail::ModuleFactory fact_
Definition: PathManager.h:81
std::unique_ptr< std::set< std::string > > trigger_paths_config_
Definition: PathManager.h:78
ActionTable & exceptActions_
Definition: PathManager.h:72
PathsInfo endPathInfo_
Definition: PathManager.h:86
MasterProductRegistry & preg_
Definition: PathManager.h:70
fhicl::ParameterSet procPS_
Definition: PathManager.h:69

Member Function Documentation

art::PathsInfo & art::PathManager::endPathInfo ( )

Definition at line 132 of file PathManager.cc.

References endPathInfo_, art::PathsInfo::makeAndAppendPath(), art::PathsInfo::pathPtrs(), and protoEndPathInfo_.

Referenced by art::EndPathExecutor::EndPathExecutor(), art::EventProcessor::invokePostBeginJobWorkers_(), and art::detail::writeSummary().

133 {
134  if (!protoEndPathInfo_.empty() && endPathInfo_.pathPtrs().empty()) {
135  // Need to create path from proto information. No trigger results
136  // needed for end path.
138  }
139  return endPathInfo_;
140 }
PathsInfo endPathInfo_
Definition: PathManager.h:86
void makeAndAppendPath(std::string const &pathName, ModInfos const &modInfos, bool trigResultsNeeded=true)
Definition: PathsInfo.cc:29
ModInfos protoEndPathInfo_
Definition: PathManager.h:84
PathPtrs const & pathPtrs() const
Definition: PathsInfo.h:87
art::detail::ModuleConfigInfoMap art::PathManager::fillAllModules_ ( )
private

Definition at line 169 of file PathManager.cc.

References art::detail::ModuleConfigInfo::allModulePathRoots(), art::errors::Configuration, e, fact_, fhicl::ParameterSet::get(), art::detail::ModuleFactory::moduleType(), procPS_, and art::to_string().

Referenced by PathManager().

170 {
171  detail::ModuleConfigInfoMap all_modules;
172  std::ostringstream error_stream;
173  for (auto const& pathRootName :
175  auto const pathRoot = procPS_.get<ParameterSet>(pathRootName, {});
176  for (auto const& name : pathRoot.get_names()) {
177  try {
178  detail::ModuleConfigInfo const mci{procPS_, name, pathRootName};
179  auto actualModType = fact_.moduleType(mci.libSpec());
180  if (actualModType != mci.moduleType()) {
181  error_stream << " ERROR: Module with label " << mci.label()
182  << " of type " << mci.libSpec() << " is configured as a "
183  << to_string(mci.moduleType())
184  << " but defined in code as a "
185  << to_string(actualModType) << ".\n";
186  }
187  auto result = all_modules.emplace(mci.label(), mci);
188  if (!result.second) {
189  error_stream << " ERROR: Module label " << mci.label()
190  << " has been used in "
191  << result.first->second.configPath() << " and "
192  << pathRootName << ".\n";
193  }
194  }
195  catch (std::exception const& e) {
196  error_stream << " ERROR: Configuration of module with label " << name
197  << " encountered the following error:\n"
198  << e.what() << "\n";
199  }
200  }
201  }
202  auto error_messages = error_stream.str();
203  if (!error_messages.empty()) {
205  << "The following were encountered while processing the module "
206  "configurations:\n"
207  << error_messages;
208  }
209  return all_modules;
210 }
ModuleType moduleType(std::string const &libspec)
detail::ModuleFactory fact_
Definition: PathManager.h:81
T get(std::string const &key) const
Definition: ParameterSet.h:231
static std::vector< std::string > const & allModulePathRoots()
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
Float_t e
Definition: plot.C:34
fhicl::ParameterSet procPS_
Definition: PathManager.h:69
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::map< std::string, ModuleConfigInfo > ModuleConfigInfoMap
PathManager& art::PathManager::operator= ( PathManager const &  )
delete
bool art::PathManager::processOnePathConfig_ ( std::string const &  path_name,
vstring const &  path_seq,
vstring trigger_path_names,
std::ostream &  error_stream 
)
private

Definition at line 302 of file PathManager.cc.

References allModules_, end_paths_config_, art::FILTER, art::is_observer(), label, art::WorkerInPath::Normal, protoEndPathInfo_, protoTrigPathMap_, art::to_string(), and trigger_paths_config_.

Referenced by processPathConfigs_().

306 {
307  enum class mod_cat_t { UNSET, OBSERVER, MODIFIER };
308  mod_cat_t cat{mod_cat_t::UNSET};
309  for (auto const& modname : path_seq) {
310  auto const label = stripLabel(modname);
311  auto const it = allModules_.find(label);
312  if (it == cend(allModules_)) {
313  error_stream << " ERROR: Entry " << modname << " in path " << path_name
314  << " refers to a module label " << label
315  << " which is not configured.\n";
316  continue;
317  }
318  auto const& mci = it->second;
319  auto mtype =
320  is_observer(mci.moduleType()) ? mod_cat_t::OBSERVER : mod_cat_t::MODIFIER;
321  if (cat == mod_cat_t::UNSET) {
322  cat = mtype;
323  // Efficiency.
324  if (cat == mod_cat_t::MODIFIER) {
325  if (trigger_paths_config_ && (trigger_paths_config_->find(path_name) ==
326  trigger_paths_config_->cend())) {
327  mf::LogInfo("DeactivatedPath")
328  << "Detected trigger path \"" << path_name
329  << "\" which was not found in\n"
330  << "parameter \"physics.trigger_paths\". "
331  << "Path will be ignored.";
332  return false;
333  }
334  // Handle case where user accidentally specified a trigger
335  // path as an end path.
336  if (end_paths_config_ &&
337  (end_paths_config_->find(path_name) != end_paths_config_->cend())) {
338  error_stream
339  << " ERROR: Path "
340  << "'" << path_name << "'"
341  << " is configured as an end path but is actually a trigger path.";
342  }
343  trigger_path_names.push_back(path_name);
344  protoTrigPathMap_[path_name].reserve(path_seq.size());
345  } else {
346  if (end_paths_config_ &&
347  (end_paths_config_->find(path_name) == end_paths_config_->cend())) {
348  mf::LogInfo("DeactivatedPath") << "Detected end path \"" << path_name
349  << "\" which was not found in\n"
350  << "parameter \"physics.end_paths\". "
351  << "Path will be ignored.";
352  return false;
353  }
354  // Handle case where user accidentally specified an end path
355  // as a trigger path.
356  if (trigger_paths_config_ && (trigger_paths_config_->find(path_name) !=
357  trigger_paths_config_->cend())) {
358  error_stream
359  << " ERROR: Path "
360  << "'" << path_name << "'"
361  << " is configured as a trigger path but is actually an end path.";
362  }
363  protoEndPathInfo_.reserve(protoEndPathInfo_.size() + path_seq.size());
364  }
365  } else if (cat != mtype) {
366  error_stream << " ERROR: Entry " << modname << " in path " << path_name
367  << " is a"
368  << (cat == mod_cat_t::OBSERVER ? " modifier" : "n observer")
369  << " while previous entries in the same path are all "
370  << (cat == mod_cat_t::OBSERVER ? "observers" : "modifiers")
371  << ".\n";
372  }
373 
374  auto const filtAction = filterAction(modname);
375  if (mci.moduleType() != ModuleType::FILTER &&
376  filtAction != WorkerInPath::Normal) {
377  error_stream << " ERROR: Module " << stripLabel(modname) << " in path "
378  << path_name << " is"
379  << (cat == mod_cat_t::OBSERVER ? " an " : " a ")
380  << to_string(mci.moduleType())
381  << " and cannot have a '!' or '-' prefix.\n";
382  }
383 
384  if (cat == mod_cat_t::MODIFIER) {
385  protoTrigPathMap_[path_name].emplace_back(mci, filtAction);
386  } else { // Only one end path.
387  protoEndPathInfo_.emplace_back(mci, filtAction);
388  }
389  }
390  return (cat == mod_cat_t::OBSERVER);
391 }
detail::ModuleConfigInfoMap allModules_
Definition: PathManager.h:82
std::unique_ptr< std::set< std::string > > end_paths_config_
Definition: PathManager.h:79
const std::string label
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::unique_ptr< std::set< std::string > > trigger_paths_config_
Definition: PathManager.h:78
std::map< std::string, ModInfos > protoTrigPathMap_
Definition: PathManager.h:83
bool is_observer(ModuleType mt)
Definition: ModuleType.h:53
ModInfos protoEndPathInfo_
Definition: PathManager.h:84
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
art::PathManager::vstring art::PathManager::processPathConfigs_ ( )
private

Definition at line 213 of file PathManager.cc.

References allModules_, art::errors::Configuration, e, end_paths_config_, fhicl::ParameterSet::get(), fhicl::ParameterSet::get_names(), processOnePathConfig_(), procPS_, and trigger_paths_config_.

Referenced by PathManager().

214 {
215  vstring trigger_path_names;
216  auto nSchedules[[gnu::unused]] =
217  procPS_.get<size_t>("services.scheduler.num_schedules", 1);
218  // Identify and process paths.
219  std::set<std::string> known_pars{
220  "analyzers", "filters", "producers", "trigger_paths", "end_paths"};
221  ParameterSet empty;
222  auto const physics = procPS_.get<ParameterSet>("physics", empty);
223  auto const keys = physics.get_names();
224  vstring path_names;
225  std::set_difference(keys.cbegin(),
226  keys.cend(),
227  known_pars.cbegin(),
228  known_pars.cend(),
229  std::back_inserter(path_names));
230  std::set<std::string> specified_modules;
231  std::ostringstream error_stream;
232 
233  // Check for missing specified paths.
234  if (trigger_paths_config_) {
235  check_missing_paths(
236  *trigger_paths_config_, path_names, "trigger_paths", error_stream);
237  }
238  if (end_paths_config_) {
239  check_missing_paths(
240  *end_paths_config_, path_names, "end_paths", error_stream);
241  }
242 
243  check_misspecified_paths(physics, path_names);
244 
245  // Process each path.
246  size_t num_end_paths{0};
247  for (auto const& path_name : path_names) {
248  auto const path_seq = physics.get<vstring>(path_name);
250  path_name, path_seq, trigger_path_names, error_stream)) {
251  ++num_end_paths;
252  }
253  for (auto const& mod : path_seq) {
254  specified_modules.insert(stripLabel(mod));
255  }
256  }
257  if (num_end_paths > 1) {
258  mf::LogInfo("PathConfiguration")
259  << "Multiple end paths have been combined into one end path,\n"
260  << "\"end_path\" since order is irrelevant.\n";
261  }
262 
263  vstring unused_modules;
264  std::set<std::string> all_module_labels;
265  for (auto const& val : allModules_) {
266  all_module_labels.insert(val.first);
267  }
268 
269  std::set_difference(all_module_labels.cbegin(),
270  all_module_labels.cend(),
271  specified_modules.cbegin(),
272  specified_modules.cend(),
273  std::back_inserter(unused_modules));
274 
275  // Complain about unused modules.
276  if (!unused_modules.empty()) {
277  std::ostringstream unusedStream;
278  unusedStream << "The following module label"
279  << ((unused_modules.size() == 1) ? " is" : "s are")
280  << " not assigned to any path:\n"
281  << "'" << unused_modules.front() << "'";
282  for (auto i = unused_modules.cbegin() + 1, e = unused_modules.cend();
283  i != e;
284  ++i) {
285  unusedStream << ", '" << *i << "'";
286  }
287  mf::LogInfo("path") << unusedStream.str() << "\n";
288  }
289 
290  // Check for fatal errors.
291  auto error_messages = error_stream.str();
292  if (!error_messages.empty()) {
293  throw Exception(errors::Configuration, "Path configuration: ")
294  << "The following were encountered while processing path "
295  "configurations:\n"
296  << error_messages;
297  }
298  return trigger_path_names;
299 }
detail::ModuleConfigInfoMap allModules_
Definition: PathManager.h:82
std::unique_ptr< std::set< std::string > > end_paths_config_
Definition: PathManager.h:79
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::unique_ptr< std::set< std::string > > trigger_paths_config_
Definition: PathManager.h:78
std::vector< std::string > vstring
Definition: PathManager.h:42
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool processOnePathConfig_(std::string const &path_name, vstring const &path_seq, vstring &trigger_path_names, std::ostream &error_stream)
Definition: PathManager.cc:302
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< std::string > get_names() const
Float_t e
Definition: plot.C:34
fhicl::ParameterSet procPS_
Definition: PathManager.h:69
void art::PathManager::resetAll ( )
art::PathManager::vstring const & art::PathManager::triggerPathNames ( ) const
inline

Definition at line 91 of file PathManager.h.

References triggerPathNames_.

Referenced by art::EventProcessor::initServices_().

92 {
93  return triggerPathNames_;
94 }
vstring triggerPathNames_
Definition: PathManager.h:85
art::PathsInfo & art::PathManager::triggerPathsInfo ( ScheduleID  sID)

Definition at line 143 of file PathManager.cc.

References protoTrigPathMap_, and triggerPathsInfo_.

Referenced by art::EventProcessor::invokePostBeginJobWorkers_(), and art::detail::writeSummary().

144 {
145  auto it = triggerPathsInfo_.find(sID);
146  if (it != triggerPathsInfo_.end())
147  return it->second;
148 
149  it = triggerPathsInfo_
150  .emplace(sID,
151  PathsInfo{triggerPathNames_.size(),
152  fact_,
153  procPS_,
154  preg_,
155  productsToProduce_,
156  exceptActions_,
157  areg_})
158  .first;
159  auto& pathsInfo = it->second;
160 
161  for (auto const& val : protoTrigPathMap_) {
162  pathsInfo.makeAndAppendPath(val.first, val.second);
163  };
164 
165  return pathsInfo;
166 }
std::map< ScheduleID, PathsInfo > triggerPathsInfo_
Definition: PathManager.h:87
std::map< std::string, ModInfos > protoTrigPathMap_
Definition: PathManager.h:83

Member Data Documentation

detail::ModuleConfigInfoMap art::PathManager::allModules_
private

Definition at line 82 of file PathManager.h.

Referenced by PathManager(), processOnePathConfig_(), and processPathConfigs_().

ActivityRegistry& art::PathManager::areg_
private

Definition at line 73 of file PathManager.h.

Referenced by PathManager().

std::unique_ptr<std::set<std::string> > art::PathManager::end_paths_config_
private

Definition at line 79 of file PathManager.h.

Referenced by PathManager(), processOnePathConfig_(), and processPathConfigs_().

PathsInfo art::PathManager::endPathInfo_
private

Definition at line 86 of file PathManager.h.

Referenced by endPathInfo(), and PathManager().

ActionTable& art::PathManager::exceptActions_
private

Definition at line 72 of file PathManager.h.

Referenced by PathManager().

detail::ModuleFactory art::PathManager::fact_ {}
private

Definition at line 81 of file PathManager.h.

Referenced by fillAllModules_(), and PathManager().

MasterProductRegistry& art::PathManager::preg_
private

Definition at line 70 of file PathManager.h.

Referenced by PathManager().

fhicl::ParameterSet art::PathManager::procPS_
private

Definition at line 69 of file PathManager.h.

Referenced by fillAllModules_(), PathManager(), and processPathConfigs_().

ProductDescriptions& art::PathManager::productsToProduce_
private

Definition at line 71 of file PathManager.h.

Referenced by PathManager().

ModInfos art::PathManager::protoEndPathInfo_ {}
private

Definition at line 84 of file PathManager.h.

Referenced by endPathInfo(), and processOnePathConfig_().

std::map<std::string, ModInfos> art::PathManager::protoTrigPathMap_ {}
private

Definition at line 83 of file PathManager.h.

Referenced by processOnePathConfig_(), and triggerPathsInfo().

std::unique_ptr<std::set<std::string> > art::PathManager::trigger_paths_config_
private

Definition at line 78 of file PathManager.h.

Referenced by PathManager(), processOnePathConfig_(), and processPathConfigs_().

vstring art::PathManager::triggerPathNames_
private

Definition at line 85 of file PathManager.h.

Referenced by PathManager(), and triggerPathNames().

std::map<ScheduleID, PathsInfo> art::PathManager::triggerPathsInfo_ {}
private

Definition at line 87 of file PathManager.h.

Referenced by triggerPathsInfo().


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