CMS 3D CMS Logo

Schedule.cc
Go to the documentation of this file.
2 
34 
35 
36 #include <algorithm>
37 #include <cassert>
38 #include <cstdlib>
39 #include <functional>
40 #include <iomanip>
41 #include <list>
42 #include <map>
43 #include <set>
44 #include <exception>
45 #include <sstream>
46 
47 namespace edm {
48 
49  class Maker;
50 
51  namespace {
52  using std::placeholders::_1;
53 
54  bool binary_search_string(std::vector<std::string> const& v, std::string const& s) {
55  return std::binary_search(v.begin(), v.end(), s);
56  }
57 
58  // Here we make the trigger results inserter directly. This should
59  // probably be a utility in the WorkerRegistry or elsewhere.
60 
61  std::shared_ptr<TriggerResultInserter>
62  makeInserter(ParameterSet& proc_pset,
63  PreallocationConfiguration const& iPrealloc,
64  ProductRegistry& preg,
65  ExceptionToActionTable const& actions,
66  std::shared_ptr<ActivityRegistry> areg,
67  std::shared_ptr<ProcessConfiguration> processConfiguration) {
68 
69  ParameterSet* trig_pset = proc_pset.getPSetForUpdate("@trigger_paths");
70  trig_pset->registerIt();
71 
72  WorkerParams work_args(trig_pset, preg, &iPrealloc, processConfiguration, actions);
73  ModuleDescription md(trig_pset->id(),
74  "TriggerResultInserter",
75  "TriggerResults",
76  processConfiguration.get(),
78 
79  areg->preModuleConstructionSignal_(md);
80  bool postCalled = false;
81  std::shared_ptr<TriggerResultInserter> returnValue;
82  try {
83  maker::ModuleHolderT<TriggerResultInserter> holder(std::make_shared<TriggerResultInserter>(*trig_pset, iPrealloc.numberOfStreams()),static_cast<Maker const*>(nullptr));
84  holder.setModuleDescription(md);
85  holder.registerProductsAndCallbacks(&preg);
86  returnValue =holder.module();
87  postCalled = true;
88  // if exception then post will be called in the catch block
89  areg->postModuleConstructionSignal_(md);
90  }
91  catch (...) {
92  if(!postCalled) {
93  try {
94  areg->postModuleConstructionSignal_(md);
95  }
96  catch (...) {
97  // If post throws an exception ignore it because we are already handling another exception
98  }
99  }
100  throw;
101  }
102  return returnValue;
103  }
104 
105  template <typename T>
106  void
107  makePathStatusInserters(std::vector<edm::propagate_const<std::shared_ptr<T>>>& pathStatusInserters,
108  std::vector<std::string> const& pathNames,
109  PreallocationConfiguration const& iPrealloc,
110  ProductRegistry& preg,
111  std::shared_ptr<ActivityRegistry> areg,
112  std::shared_ptr<ProcessConfiguration> processConfiguration,
113  std::string const& moduleTypeName) {
114 
116  pset.addParameter<std::string>("@module_type", moduleTypeName);
117  pset.addParameter<std::string>("@module_edm_type", "EDProducer");
118  pset.registerIt();
119 
120  pathStatusInserters.reserve(pathNames.size());
121 
122  for (auto const& pathName : pathNames) {
123 
124  ModuleDescription md(pset.id(),
125  moduleTypeName,
126  pathName,
127  processConfiguration.get(),
129 
130  areg->preModuleConstructionSignal_(md);
131  bool postCalled = false;
132 
133  try {
134  maker::ModuleHolderT<T> holder(std::make_shared<T>(iPrealloc.numberOfStreams()),
135  static_cast<Maker const*>(nullptr));
136  holder.setModuleDescription(md);
137  holder.registerProductsAndCallbacks(&preg);
138  pathStatusInserters.emplace_back(holder.module());
139  postCalled = true;
140  // if exception then post will be called in the catch block
141  areg->postModuleConstructionSignal_(md);
142  }
143  catch (...) {
144  if(!postCalled) {
145  try {
146  areg->postModuleConstructionSignal_(md);
147  }
148  catch (...) {
149  // If post throws an exception ignore it because we are already handling another exception
150  }
151  }
152  throw;
153  }
154  }
155  }
156 
157  void
158  checkAndInsertAlias(std::string const& friendlyClassName,
159  std::string const& moduleLabel,
160  std::string const& productInstanceName,
161  std::string const& processName,
162  std::string const& alias,
163  std::string const& instanceAlias,
164  ProductRegistry const& preg,
165  std::multimap<BranchKey, BranchKey>& aliasMap,
166  std::map<BranchKey, BranchKey>& aliasKeys) {
167  std::string const star("*");
168 
169  BranchKey key(friendlyClassName, moduleLabel, productInstanceName, processName);
170  if(preg.productList().find(key) == preg.productList().end()) {
171  // No product was found matching the alias.
172  // We throw an exception only if a module with the specified module label was created in this process.
173  for(auto const& product : preg.productList()) {
174  if(moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
175  throw Exception(errors::Configuration, "EDAlias does not match data\n")
176  << "There are no products of type '" << friendlyClassName << "'\n"
177  << "with module label '" << moduleLabel << "' and instance name '" << productInstanceName << "'.\n";
178  }
179  }
180  }
181 
182  std::string const& theInstanceAlias(instanceAlias == star ? productInstanceName : instanceAlias);
183  BranchKey aliasKey(friendlyClassName, alias, theInstanceAlias, processName);
184  if(preg.productList().find(aliasKey) != preg.productList().end()) {
185  throw Exception(errors::Configuration, "EDAlias conflicts with data\n")
186  << "A product of type '" << friendlyClassName << "'\n"
187  << "with module label '" << alias << "' and instance name '" << theInstanceAlias << "'\n"
188  << "already exists.\n";
189  }
190  auto iter = aliasKeys.find(aliasKey);
191  if(iter != aliasKeys.end()) {
192  // The alias matches a previous one. If the same alias is used for different product, throw.
193  if(iter->second != key) {
194  throw Exception(errors::Configuration, "EDAlias conflict\n")
195  << "The module label alias '" << alias << "' and product instance alias '" << theInstanceAlias << "'\n"
196  << "are used for multiple products of type '" << friendlyClassName << "'\n"
197  << "One has module label '" << moduleLabel << "' and product instance name '" << productInstanceName << "',\n"
198  << "the other has module label '" << iter->second.moduleLabel() << "' and product instance name '" << iter->second.productInstanceName() << "'.\n";
199  }
200  } else {
201  auto prodIter = preg.productList().find(key);
202  if(prodIter != preg.productList().end()) {
203  if (!prodIter->second.produced()) {
204  throw Exception(errors::Configuration, "EDAlias\n")
205  << "The module label alias '" << alias << "' and product instance alias '" << theInstanceAlias << "'\n"
206  << "are used for a product of type '" << friendlyClassName << "'\n"
207  << "with module label '" << moduleLabel << "' and product instance name '" << productInstanceName << "',\n"
208  << "An EDAlias can only be used for products produced in the current process. This one is not.\n";
209  }
210  aliasMap.insert(std::make_pair(key, aliasKey));
211  aliasKeys.insert(std::make_pair(aliasKey, key));
212  }
213  }
214  }
215 
216  void
217  processEDAliases(ParameterSet const& proc_pset, std::string const& processName, ProductRegistry& preg) {
218  std::vector<std::string> aliases = proc_pset.getParameter<std::vector<std::string> >("@all_aliases");
219  if(aliases.empty()) {
220  return;
221  }
222  std::string const star("*");
223  std::string const empty("");
225  desc.add<std::string>("type");
226  desc.add<std::string>("fromProductInstance", star);
227  desc.add<std::string>("toProductInstance", star);
228 
229  std::multimap<BranchKey, BranchKey> aliasMap;
230 
231  std::map<BranchKey, BranchKey> aliasKeys; // Used to search for duplicates or clashes.
232 
233  // Now, loop over the alias information and store it in aliasMap.
234  for(std::string const& alias : aliases) {
235  ParameterSet const& aliasPSet = proc_pset.getParameterSet(alias);
236  std::vector<std::string> vPSetNames = aliasPSet.getParameterNamesForType<VParameterSet>();
237  for(std::string const& moduleLabel : vPSetNames) {
238  VParameterSet vPSet = aliasPSet.getParameter<VParameterSet>(moduleLabel);
239  for(ParameterSet& pset : vPSet) {
240  desc.validate(pset);
241  std::string friendlyClassName = pset.getParameter<std::string>("type");
242  std::string productInstanceName = pset.getParameter<std::string>("fromProductInstance");
243  std::string instanceAlias = pset.getParameter<std::string>("toProductInstance");
244  if(productInstanceName == star) {
245  bool match = false;
246  BranchKey lowerBound(friendlyClassName, moduleLabel, empty, empty);
247  for(ProductRegistry::ProductList::const_iterator it = preg.productList().lower_bound(lowerBound);
248  it != preg.productList().end() && it->first.friendlyClassName() == friendlyClassName && it->first.moduleLabel() == moduleLabel;
249  ++it) {
250  if(it->first.processName() != processName) {
251  continue;
252  }
253  match = true;
254 
255  checkAndInsertAlias(friendlyClassName, moduleLabel, it->first.productInstanceName(), processName, alias, instanceAlias, preg, aliasMap, aliasKeys);
256  }
257  if(!match) {
258  // No product was found matching the alias.
259  // We throw an exception only if a module with the specified module label was created in this process.
260  for(auto const& product : preg.productList()) {
261  if(moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
262  throw Exception(errors::Configuration, "EDAlias parameter set mismatch\n")
263  << "There are no products of type '" << friendlyClassName << "'\n"
264  << "with module label '" << moduleLabel << "'.\n";
265  }
266  }
267  }
268  } else {
269  checkAndInsertAlias(friendlyClassName, moduleLabel, productInstanceName, processName, alias, instanceAlias, preg, aliasMap, aliasKeys);
270  }
271  }
272  }
273  }
274 
275 
276  // Now add the new alias entries to the product registry.
277  for(auto const& aliasEntry : aliasMap) {
278  ProductRegistry::ProductList::const_iterator it = preg.productList().find(aliasEntry.first);
279  assert(it != preg.productList().end());
280  preg.addLabelAlias(it->second, aliasEntry.second.moduleLabel(), aliasEntry.second.productInstanceName());
281  }
282 
283  }
284 
285  typedef std::vector<std::string> vstring;
286 
287  void reduceParameterSet(ParameterSet& proc_pset,
288  vstring const& end_path_name_list,
289  vstring& modulesInConfig,
290  std::set<std::string> const& usedModuleLabels,
291  std::map<std::string, std::vector<std::pair<std::string, int> > >& outputModulePathPositions) {
292  // Before calculating the ParameterSetID of the top level ParameterSet or
293  // saving it in the registry drop from the top level ParameterSet all
294  // OutputModules and EDAnalyzers not on trigger paths. If unscheduled
295  // production is not enabled also drop all the EDFilters and EDProducers
296  // that are not scheduled. Drop the ParameterSet used to configure the module
297  // itself. Also drop the other traces of these labels in the top level
298  // ParameterSet: Remove that labels from @all_modules and from all the
299  // end paths. If this makes any end paths empty, then remove the end path
300  // name from @end_paths, and @paths.
301 
302  // First make a list of labels to drop
303  vstring outputModuleLabels;
304  std::string edmType;
305  std::string const moduleEdmType("@module_edm_type");
306  std::string const outputModule("OutputModule");
307  std::string const edAnalyzer("EDAnalyzer");
308  std::string const edFilter("EDFilter");
309  std::string const edProducer("EDProducer");
310 
311  std::set<std::string> modulesInConfigSet(modulesInConfig.begin(), modulesInConfig.end());
312 
313  //need a list of all modules on paths in order to determine
314  // if an EDAnalyzer only appears on an end path
315  vstring scheduledPaths = proc_pset.getParameter<vstring>("@paths");
316  std::set<std::string> modulesOnPaths;
317  {
318  std::set<std::string> noEndPaths(scheduledPaths.begin(),scheduledPaths.end());
319  for(auto const& endPath: end_path_name_list) {
320  noEndPaths.erase(endPath);
321  }
322  {
323  vstring labels;
324  for(auto const& path: noEndPaths) {
325  labels = proc_pset.getParameter<vstring>(path);
326  modulesOnPaths.insert(labels.begin(),labels.end());
327  }
328  }
329  }
330  //Initially fill labelsToBeDropped with all module mentioned in
331  // the configuration but which are not being used by the system
332  std::vector<std::string> labelsToBeDropped;
333  labelsToBeDropped.reserve(modulesInConfigSet.size());
334  std::set_difference(modulesInConfigSet.begin(),modulesInConfigSet.end(),
335  usedModuleLabels.begin(),usedModuleLabels.end(),
336  std::back_inserter(labelsToBeDropped));
337 
338  const unsigned int sizeBeforeOutputModules = labelsToBeDropped.size();
339  for (auto const& modLabel: usedModuleLabels) {
340  // Do nothing for modules that do not have a ParameterSet. Modules of type
341  // PathStatusInserter and EndPathStatusInserter will not have a ParameterSet.
342  if (proc_pset.existsAs<ParameterSet>(modLabel)) {
343  edmType = proc_pset.getParameterSet(modLabel).getParameter<std::string>(moduleEdmType);
344  if (edmType == outputModule) {
345  outputModuleLabels.push_back(modLabel);
346  labelsToBeDropped.push_back(modLabel);
347  }
348  if(edmType == edAnalyzer) {
349  if(modulesOnPaths.end()==modulesOnPaths.find(modLabel)) {
350  labelsToBeDropped.push_back(modLabel);
351  }
352  }
353  }
354  }
355  //labelsToBeDropped must be sorted
356  std::inplace_merge(labelsToBeDropped.begin(),
357  labelsToBeDropped.begin()+sizeBeforeOutputModules,
358  labelsToBeDropped.end());
359 
360  // drop the parameter sets used to configure the modules
361  for_all(labelsToBeDropped, std::bind(&ParameterSet::eraseOrSetUntrackedParameterSet, std::ref(proc_pset), _1));
362 
363  // drop the labels from @all_modules
364  vstring::iterator endAfterRemove = std::remove_if(modulesInConfig.begin(), modulesInConfig.end(), std::bind(binary_search_string, std::ref(labelsToBeDropped), _1));
365  modulesInConfig.erase(endAfterRemove, modulesInConfig.end());
366  proc_pset.addParameter<vstring>(std::string("@all_modules"), modulesInConfig);
367 
368  // drop the labels from all end paths
369  vstring endPathsToBeDropped;
370  vstring labels;
371  for (vstring::const_iterator iEndPath = end_path_name_list.begin(), endEndPath = end_path_name_list.end();
372  iEndPath != endEndPath;
373  ++iEndPath) {
374  labels = proc_pset.getParameter<vstring>(*iEndPath);
375  vstring::iterator iSave = labels.begin();
376  vstring::iterator iBegin = labels.begin();
377 
378  for (vstring::iterator iLabel = labels.begin(), iEnd = labels.end();
379  iLabel != iEnd; ++iLabel) {
380  if (binary_search_string(labelsToBeDropped, *iLabel)) {
381  if (binary_search_string(outputModuleLabels, *iLabel)) {
382  outputModulePathPositions[*iLabel].emplace_back(*iEndPath, iSave - iBegin);
383  }
384  } else {
385  if (iSave != iLabel) {
386  iSave->swap(*iLabel);
387  }
388  ++iSave;
389  }
390  }
391  labels.erase(iSave, labels.end());
392  if (labels.empty()) {
393  // remove empty end paths and save their names
394  proc_pset.eraseSimpleParameter(*iEndPath);
395  endPathsToBeDropped.push_back(*iEndPath);
396  } else {
397  proc_pset.addParameter<vstring>(*iEndPath, labels);
398  }
399  }
400  sort_all(endPathsToBeDropped);
401 
402  // remove empty end paths from @paths
403  endAfterRemove = std::remove_if(scheduledPaths.begin(), scheduledPaths.end(), std::bind(binary_search_string, std::ref(endPathsToBeDropped), _1));
404  scheduledPaths.erase(endAfterRemove, scheduledPaths.end());
405  proc_pset.addParameter<vstring>(std::string("@paths"), scheduledPaths);
406 
407  // remove empty end paths from @end_paths
408  vstring scheduledEndPaths = proc_pset.getParameter<vstring>("@end_paths");
409  endAfterRemove = std::remove_if(scheduledEndPaths.begin(), scheduledEndPaths.end(), std::bind(binary_search_string, std::ref(endPathsToBeDropped), _1));
410  scheduledEndPaths.erase(endAfterRemove, scheduledEndPaths.end());
411  proc_pset.addParameter<vstring>(std::string("@end_paths"), scheduledEndPaths);
412 
413  }
414 
415  class RngEDConsumer : public EDConsumerBase {
416  public:
417  explicit RngEDConsumer(std::set<TypeID>& typesConsumed) {
419  if(rng.isAvailable()) {
420  rng->consumes(consumesCollector());
421  for (auto const& consumesInfo : this->consumesInfo()) {
422  typesConsumed.emplace(consumesInfo.type());
423  }
424  }
425  }
426  };
427  }
428  // -----------------------------
429 
430  typedef std::vector<std::string> vstring;
431 
432  // -----------------------------
433 
435  service::TriggerNamesService const& tns,
436  ProductRegistry& preg,
437  BranchIDListHelper& branchIDListHelper,
438  ThinnedAssociationsHelper& thinnedAssociationsHelper,
439  SubProcessParentageHelper const* subProcessParentageHelper,
440  ExceptionToActionTable const& actions,
441  std::shared_ptr<ActivityRegistry> areg,
442  std::shared_ptr<ProcessConfiguration> processConfiguration,
443  bool hasSubprocesses,
444  PreallocationConfiguration const& prealloc,
445  ProcessContext const* processContext) :
446  //Only create a resultsInserter if there is a trigger path
447  resultsInserter_{tns.getTrigPaths().empty()? std::shared_ptr<TriggerResultInserter>{} :makeInserter(proc_pset,prealloc,preg,actions,areg,processConfiguration)},
450  preallocConfig_(prealloc),
451  pathNames_(&tns.getTrigPaths()),
452  endPathNames_(&tns.getEndPaths()),
453  wantSummary_(tns.wantSummary()),
454  endpathsAreActive_(true)
455  {
456  makePathStatusInserters(pathStatusInserters_,
457  *pathNames_,
458  prealloc,
459  preg,
460  areg,
461  processConfiguration,
462  std::string("PathStatusInserter"));
463 
464  makePathStatusInserters(endPathStatusInserters_,
465  *endPathNames_,
466  prealloc,
467  preg,
468  areg,
469  processConfiguration,
470  std::string("EndPathStatusInserter"));
471 
472  assert(0<prealloc.numberOfStreams());
473  streamSchedules_.reserve(prealloc.numberOfStreams());
474  for(unsigned int i=0; i<prealloc.numberOfStreams();++i) {
475  streamSchedules_.emplace_back(std::make_shared<StreamSchedule>(
476  resultsInserter(),
479  moduleRegistry(),
480  proc_pset,tns,prealloc,preg,
481  branchIDListHelper,actions,
482  areg,processConfiguration,
483  !hasSubprocesses,
484  StreamID{i},
485  processContext));
486  }
487 
488  //TriggerResults are injected automatically by StreamSchedules and are
489  // unknown to the ModuleRegistry
490  const std::string kTriggerResults("TriggerResults");
491  std::vector<std::string> modulesToUse;
492  modulesToUse.reserve(streamSchedules_[0]->allWorkers().size());
493  for(auto const& worker : streamSchedules_[0]->allWorkers()) {
494  if(worker->description().moduleLabel() != kTriggerResults) {
495  modulesToUse.push_back(worker->description().moduleLabel());
496  }
497  }
498  //The unscheduled modules are at the end of the list, but we want them at the front
499  unsigned int n = streamSchedules_[0]->numberOfUnscheduledModules();
500  if(n>0) {
501  std::vector<std::string> temp;
502  temp.reserve(modulesToUse.size());
503  auto itBeginUnscheduled = modulesToUse.begin()+modulesToUse.size()-n;
504  std::copy(itBeginUnscheduled,modulesToUse.end(),
505  std::back_inserter(temp));
506  std::copy(modulesToUse.begin(),itBeginUnscheduled,std::back_inserter(temp));
507  temp.swap(modulesToUse);
508  }
509 
510  // propagate_const<T> has no reset() function
511  globalSchedule_ = std::make_unique<GlobalSchedule>(
512  resultsInserter(),
515  moduleRegistry(),
516  modulesToUse,
517  proc_pset, preg, prealloc,
518  actions,areg,processConfiguration,processContext);
519 
520  //TriggerResults is not in the top level ParameterSet so the call to
521  // reduceParameterSet would fail to find it. Just remove it up front.
522  std::set<std::string> usedModuleLabels;
523  for(auto const& worker: allWorkers()) {
524  if(worker->description().moduleLabel() != kTriggerResults) {
525  usedModuleLabels.insert(worker->description().moduleLabel());
526  }
527  }
528  std::vector<std::string> modulesInConfig(proc_pset.getParameter<std::vector<std::string> >("@all_modules"));
529  std::map<std::string, std::vector<std::pair<std::string, int> > > outputModulePathPositions;
530  reduceParameterSet(proc_pset, tns.getEndPaths(), modulesInConfig, usedModuleLabels,
531  outputModulePathPositions);
532  processEDAliases(proc_pset, processConfiguration->processName(), preg);
533  proc_pset.registerIt();
534  processConfiguration->setParameterSetID(proc_pset.id());
535  processConfiguration->setProcessConfigurationID();
536 
537  // This is used for a little sanity-check to make sure no code
538  // modifications alter the number of workers at a later date.
539  size_t all_workers_count = allWorkers().size();
540 
541  moduleRegistry_->forAllModuleHolders([this](maker::ModuleHolder* iHolder){
542  auto comm = iHolder->createOutputModuleCommunicator();
543  if (comm) {
544  all_output_communicators_.emplace_back(std::shared_ptr<OutputModuleCommunicator>{comm.release()});
545  }
546  });
547  // Now that the output workers are filled in, set any output limits or information.
548  limitOutput(proc_pset, branchIDListHelper.branchIDLists(), subProcessParentageHelper);
549 
550  // Sanity check: make sure nobody has added a worker after we've
551  // already relied on the WorkerManager being full.
552  assert (all_workers_count == allWorkers().size());
553 
554  branchIDListHelper.updateFromRegistry(preg);
555 
556  for(auto const& worker : streamSchedules_[0]->allWorkers()) {
557  worker->registerThinnedAssociations(preg, thinnedAssociationsHelper);
558  }
559  thinnedAssociationsHelper.sort();
560 
561  // The output modules consume products in kept branches.
562  // So we must set this up before freezing.
563  for (auto& c : all_output_communicators_) {
564  c->selectProducts(preg, thinnedAssociationsHelper);
565  }
566 
567  {
568  // We now get a collection of types that may be consumed.
569  std::set<TypeID> productTypesConsumed;
570  std::set<TypeID> elementTypesConsumed;
571  // Loop over all modules
572  for (auto const& worker : allWorkers()) {
573  for (auto const& consumesInfo : worker->consumesInfo()) {
574  if (consumesInfo.kindOfType() == PRODUCT_TYPE) {
575  productTypesConsumed.emplace(consumesInfo.type());
576  } else {
577  elementTypesConsumed.emplace(consumesInfo.type());
578  }
579  }
580  }
581  // The SubProcess class is not a module, yet it may consume.
582  if(hasSubprocesses) {
583  productTypesConsumed.emplace(typeid(TriggerResults));
584  }
585  // The RandomNumberGeneratorService is not a module, yet it consumes.
586  {
587  RngEDConsumer rngConsumer = RngEDConsumer(productTypesConsumed);
588  }
589  preg.setFrozen(productTypesConsumed, elementTypesConsumed, processConfiguration->processName());
590  }
591 
592  for (auto& c : all_output_communicators_) {
593  c->setEventSelectionInfo(outputModulePathPositions, preg.anyProductProduced());
594  }
595 
596  if(wantSummary_) {
597  std::vector<const ModuleDescription*> modDesc;
598  const auto& workers = allWorkers();
599  modDesc.reserve(workers.size());
600 
601  std::transform(workers.begin(),workers.end(),
602  std::back_inserter(modDesc),
603  [](const Worker* iWorker) -> const ModuleDescription* {
604  return iWorker->descPtr();
605  });
606 
607  // propagate_const<T> has no reset() function
608  summaryTimeKeeper_ = std::make_unique<SystemTimeKeeper>(
609  prealloc.numberOfStreams(),
610  modDesc,
611  tns,
612  processContext);
613  auto timeKeeperPtr = summaryTimeKeeper_.get();
614 
615  areg->watchPreModuleEvent(timeKeeperPtr, &SystemTimeKeeper::startModuleEvent);
616  areg->watchPostModuleEvent(timeKeeperPtr, &SystemTimeKeeper::stopModuleEvent);
617  areg->watchPreModuleEventDelayedGet(timeKeeperPtr, &SystemTimeKeeper::pauseModuleEvent);
618  areg->watchPostModuleEventDelayedGet(timeKeeperPtr,&SystemTimeKeeper::restartModuleEvent);
619 
620  areg->watchPreSourceEvent(timeKeeperPtr, &SystemTimeKeeper::startEvent);
621  areg->watchPostEvent(timeKeeperPtr, &SystemTimeKeeper::stopEvent);
622 
623  areg->watchPrePathEvent(timeKeeperPtr, &SystemTimeKeeper::startPath);
624  areg->watchPostPathEvent(timeKeeperPtr, &SystemTimeKeeper::stopPath);
625 
626  areg->watchPostBeginJob(timeKeeperPtr, &SystemTimeKeeper::startProcessingLoop);
627  areg->watchPreEndJob(timeKeeperPtr, &SystemTimeKeeper::stopProcessingLoop);
628  //areg->preModuleEventSignal_.connect([timeKeeperPtr](StreamContext const& iContext, ModuleCallingContext const& iMod) {
629  //timeKeeperPtr->startModuleEvent(iContext,iMod);
630  //});
631  }
632 
633  } // Schedule::Schedule
634 
635 
636  void
638  BranchIDLists const& branchIDLists,
639  SubProcessParentageHelper const* subProcessParentageHelper) {
640  std::string const output("output");
641 
642  ParameterSet const& maxEventsPSet = proc_pset.getUntrackedParameterSet("maxEvents", ParameterSet());
643  int maxEventSpecs = 0;
644  int maxEventsOut = -1;
645  ParameterSet const* vMaxEventsOut = nullptr;
646  std::vector<std::string> intNamesE = maxEventsPSet.getParameterNamesForType<int>(false);
647  if (search_all(intNamesE, output)) {
648  maxEventsOut = maxEventsPSet.getUntrackedParameter<int>(output);
649  ++maxEventSpecs;
650  }
651  std::vector<std::string> psetNamesE;
652  maxEventsPSet.getParameterSetNames(psetNamesE, false);
653  if (search_all(psetNamesE, output)) {
654  vMaxEventsOut = &maxEventsPSet.getUntrackedParameterSet(output);
655  ++maxEventSpecs;
656  }
657 
658  if (maxEventSpecs > 1) {
660  "\nAt most, one form of 'output' may appear in the 'maxEvents' parameter set";
661  }
662 
663  for (auto& c : all_output_communicators_) {
664  OutputModuleDescription desc(branchIDLists, maxEventsOut, subProcessParentageHelper);
665  if (vMaxEventsOut != nullptr && !vMaxEventsOut->empty()) {
666  std::string const& moduleLabel = c->description().moduleLabel();
667  try {
668  desc.maxEvents_ = vMaxEventsOut->getUntrackedParameter<int>(moduleLabel);
669  } catch (Exception const&) {
671  "\nNo entry in 'maxEvents' for output module label '" << moduleLabel << "'.\n";
672  }
673  }
674  c->configure(desc);
675  }
676  }
677 
678  bool Schedule::terminate() const {
679  if (all_output_communicators_.empty()) {
680  return false;
681  }
682  for (auto& c : all_output_communicators_) {
683  if (!c->limitReached()) {
684  // Found an output module that has not reached output event count.
685  return false;
686  }
687  }
688  LogInfo("SuccessfulTermination")
689  << "The job is terminating successfully because each output module\n"
690  << "has reached its configured limit.\n";
691  return true;
692  }
693 
695  globalSchedule_->endJob(collector);
696  if (collector.hasThrown()) {
697  return;
698  }
699 
700  if (wantSummary_ == false) return;
701  {
702  TriggerReport tr;
703  getTriggerReport(tr);
704 
705  // The trigger report (pass/fail etc.):
706 
707  LogVerbatim("FwkSummary") << "";
708  if(streamSchedules_[0]->context().processContext()->isSubProcess()) {
709  LogVerbatim("FwkSummary") << "TrigReport Process: "<<streamSchedules_[0]->context().processContext()->processName();
710  }
711  LogVerbatim("FwkSummary") << "TrigReport " << "---------- Event Summary ------------";
712  if(!tr.trigPathSummaries.empty()) {
713  LogVerbatim("FwkSummary") << "TrigReport"
714  << " Events total = " << tr.eventSummary.totalEvents
715  << " passed = " << tr.eventSummary.totalEventsPassed
716  << " failed = " << tr.eventSummary.totalEventsFailed
717  << "";
718  } else {
719  LogVerbatim("FwkSummary") << "TrigReport"
720  << " Events total = " << tr.eventSummary.totalEvents
721  << " passed = " << tr.eventSummary.totalEvents
722  << " failed = 0";
723  }
724 
725  LogVerbatim("FwkSummary") << "";
726  LogVerbatim("FwkSummary") << "TrigReport " << "---------- Path Summary ------------";
727  LogVerbatim("FwkSummary") << "TrigReport "
728  << std::right << std::setw(10) << "Trig Bit#" << " "
729  << std::right << std::setw(10) << "Executed" << " "
730  << std::right << std::setw(10) << "Passed" << " "
731  << std::right << std::setw(10) << "Failed" << " "
732  << std::right << std::setw(10) << "Error" << " "
733  << "Name" << "";
734  for (auto const& p: tr.trigPathSummaries) {
735  LogVerbatim("FwkSummary") << "TrigReport "
736  << std::right << std::setw(5) << 1
737  << std::right << std::setw(5) << p.bitPosition << " "
738  << std::right << std::setw(10) << p.timesRun << " "
739  << std::right << std::setw(10) << p.timesPassed << " "
740  << std::right << std::setw(10) << p.timesFailed << " "
741  << std::right << std::setw(10) << p.timesExcept << " "
742  << p.name << "";
743  }
744 
745  /*
746  std::vector<int>::const_iterator epi = empty_trig_paths_.begin();
747  std::vector<int>::const_iterator epe = empty_trig_paths_.end();
748  std::vector<std::string>::const_iterator epn = empty_trig_path_names_.begin();
749  for (; epi != epe; ++epi, ++epn) {
750 
751  LogVerbatim("FwkSummary") << "TrigReport "
752  << std::right << std::setw(5) << 1
753  << std::right << std::setw(5) << *epi << " "
754  << std::right << std::setw(10) << totalEvents() << " "
755  << std::right << std::setw(10) << totalEvents() << " "
756  << std::right << std::setw(10) << 0 << " "
757  << std::right << std::setw(10) << 0 << " "
758  << *epn << "";
759  }
760  */
761 
762  LogVerbatim("FwkSummary") << "";
763  LogVerbatim("FwkSummary") << "TrigReport " << "-------End-Path Summary ------------";
764  LogVerbatim("FwkSummary") << "TrigReport "
765  << std::right << std::setw(10) << "Trig Bit#" << " "
766  << std::right << std::setw(10) << "Executed" << " "
767  << std::right << std::setw(10) << "Passed" << " "
768  << std::right << std::setw(10) << "Failed" << " "
769  << std::right << std::setw(10) << "Error" << " "
770  << "Name" << "";
771  for (auto const& p: tr.endPathSummaries) {
772  LogVerbatim("FwkSummary") << "TrigReport "
773  << std::right << std::setw(5) << 0
774  << std::right << std::setw(5) << p.bitPosition << " "
775  << std::right << std::setw(10) << p.timesRun << " "
776  << std::right << std::setw(10) << p.timesPassed << " "
777  << std::right << std::setw(10) << p.timesFailed << " "
778  << std::right << std::setw(10) << p.timesExcept << " "
779  << p.name << "";
780  }
781 
782  for (auto const& p: tr.trigPathSummaries) {
783  LogVerbatim("FwkSummary") << "";
784  LogVerbatim("FwkSummary") << "TrigReport " << "---------- Modules in Path: " << p.name << " ------------";
785  LogVerbatim("FwkSummary") << "TrigReport "
786  << std::right << std::setw(10) << "Trig Bit#" << " "
787  << std::right << std::setw(10) << "Visited" << " "
788  << std::right << std::setw(10) << "Passed" << " "
789  << std::right << std::setw(10) << "Failed" << " "
790  << std::right << std::setw(10) << "Error" << " "
791  << "Name" << "";
792 
793  unsigned int bitpos = 0;
794  for (auto const& mod: p.moduleInPathSummaries) {
795  LogVerbatim("FwkSummary") << "TrigReport "
796  << std::right << std::setw(5) << 1
797  << std::right << std::setw(5) << bitpos << " "
798  << std::right << std::setw(10) << mod.timesVisited << " "
799  << std::right << std::setw(10) << mod.timesPassed << " "
800  << std::right << std::setw(10) << mod.timesFailed << " "
801  << std::right << std::setw(10) << mod.timesExcept << " "
802  << mod.moduleLabel << "";
803  ++bitpos;
804  }
805  }
806 
807  for (auto const& p: tr.endPathSummaries) {
808  LogVerbatim("FwkSummary") << "";
809  LogVerbatim("FwkSummary") << "TrigReport " << "------ Modules in End-Path: " << p.name << " ------------";
810  LogVerbatim("FwkSummary") << "TrigReport "
811  << std::right << std::setw(10) << "Trig Bit#" << " "
812  << std::right << std::setw(10) << "Visited" << " "
813  << std::right << std::setw(10) << "Passed" << " "
814  << std::right << std::setw(10) << "Failed" << " "
815  << std::right << std::setw(10) << "Error" << " "
816  << "Name" << "";
817 
818  unsigned int bitpos=0;
819  for (auto const& mod: p.moduleInPathSummaries) {
820  LogVerbatim("FwkSummary") << "TrigReport "
821  << std::right << std::setw(5) << 0
822  << std::right << std::setw(5) << bitpos << " "
823  << std::right << std::setw(10) << mod.timesVisited << " "
824  << std::right << std::setw(10) << mod.timesPassed << " "
825  << std::right << std::setw(10) << mod.timesFailed << " "
826  << std::right << std::setw(10) << mod.timesExcept << " "
827  << mod.moduleLabel << "";
828  ++bitpos;
829  }
830  }
831 
832  LogVerbatim("FwkSummary") << "";
833  LogVerbatim("FwkSummary") << "TrigReport " << "---------- Module Summary ------------";
834  LogVerbatim("FwkSummary") << "TrigReport "
835  << std::right << std::setw(10) << "Visited" << " "
836  << std::right << std::setw(10) << "Executed" << " "
837  << std::right << std::setw(10) << "Passed" << " "
838  << std::right << std::setw(10) << "Failed" << " "
839  << std::right << std::setw(10) << "Error" << " "
840  << "Name" << "";
841  for (auto const& worker : tr.workerSummaries) {
842  LogVerbatim("FwkSummary") << "TrigReport "
843  << std::right << std::setw(10) << worker.timesVisited << " "
844  << std::right << std::setw(10) << worker.timesRun << " "
845  << std::right << std::setw(10) << worker.timesPassed << " "
846  << std::right << std::setw(10) << worker.timesFailed << " "
847  << std::right << std::setw(10) << worker.timesExcept << " "
848  << worker.moduleLabel << "";
849  }
850  LogVerbatim("FwkSummary") << "";
851  }
852  // The timing report (CPU and Real Time):
855 
856  const int totalEvents = std::max(1, tr.eventSummary.totalEvents);
857 
858  LogVerbatim("FwkSummary") << "TimeReport " << "---------- Event Summary ---[sec]----";
859  LogVerbatim("FwkSummary") << "TimeReport"
860  << std::setprecision(6) << std::fixed
861  << " event loop CPU/event = " << tr.eventSummary.cpuTime/totalEvents;
862  LogVerbatim("FwkSummary") << "TimeReport"
863  << std::setprecision(6) << std::fixed
864  << " event loop Real/event = " << tr.eventSummary.realTime/totalEvents;
865  LogVerbatim("FwkSummary") << "TimeReport"
866  << std::setprecision(6) << std::fixed
867  << " sum Streams Real/event = " << tr.eventSummary.sumStreamRealTime/totalEvents;
868  LogVerbatim("FwkSummary") << "TimeReport"
869  << std::setprecision(6) << std::fixed
870  << " efficiency CPU/Real/thread = " << tr.eventSummary.cpuTime/tr.eventSummary.realTime/preallocConfig_.numberOfThreads();
871 
872  constexpr int kColumn1Size = 10;
873  constexpr int kColumn2Size = 12;
874  constexpr int kColumn3Size = 12;
875  LogVerbatim("FwkSummary") << "";
876  LogVerbatim("FwkSummary") << "TimeReport " << "---------- Path Summary ---[Real sec]----";
877  LogVerbatim("FwkSummary") << "TimeReport "
878  << std::right << std::setw(kColumn1Size) << "per event"<<" "
879  << std::right << std::setw(kColumn2Size) << "per exec"
880  << " Name";
881  for (auto const& p: tr.trigPathSummaries) {
882  const int timesRun = std::max(1, p.timesRun);
883  LogVerbatim("FwkSummary") << "TimeReport "
884  << std::setprecision(6) << std::fixed
885  << std::right << std::setw(kColumn1Size) << p.realTime/totalEvents << " "
886  << std::right << std::setw(kColumn2Size) << p.realTime/timesRun << " "
887  << p.name << "";
888  }
889  LogVerbatim("FwkSummary") << "TimeReport "
890  << std::right << std::setw(kColumn1Size) << "per event"<<" "
891  << std::right << std::setw(kColumn2Size) << "per exec"
892  << " Name" << "";
893 
894  LogVerbatim("FwkSummary") << "";
895  LogVerbatim("FwkSummary") << "TimeReport " << "-------End-Path Summary ---[Real sec]----";
896  LogVerbatim("FwkSummary") << "TimeReport "
897  << std::right << std::setw(kColumn1Size) << "per event" <<" "
898  << std::right << std::setw(kColumn2Size) << "per exec"
899  << " Name" << "";
900  for (auto const& p: tr.endPathSummaries) {
901  const int timesRun = std::max(1, p.timesRun);
902 
903  LogVerbatim("FwkSummary") << "TimeReport "
904  << std::setprecision(6) << std::fixed
905  << std::right << std::setw(kColumn1Size) << p.realTime/totalEvents << " "
906  << std::right << std::setw(kColumn2Size) << p.realTime/timesRun << " "
907  << p.name << "";
908  }
909  LogVerbatim("FwkSummary") << "TimeReport "
910  << std::right << std::setw(kColumn1Size) << "per event" <<" "
911  << std::right << std::setw(kColumn2Size) << "per exec"
912  << " Name" << "";
913 
914  for (auto const& p: tr.trigPathSummaries) {
915  LogVerbatim("FwkSummary") << "";
916  LogVerbatim("FwkSummary") << "TimeReport " << "---------- Modules in Path: " << p.name << " ---[Real sec]----";
917  LogVerbatim("FwkSummary") << "TimeReport "
918  << std::right << std::setw(kColumn1Size) << "per event" <<" "
919  << std::right << std::setw(kColumn2Size) << "per visit"
920  << " Name" << "";
921  for (auto const& mod: p.moduleInPathSummaries) {
922  LogVerbatim("FwkSummary") << "TimeReport "
923  << std::setprecision(6) << std::fixed
924  << std::right << std::setw(kColumn1Size) << mod.realTime/totalEvents << " "
925  << std::right << std::setw(kColumn2Size) << mod.realTime/std::max(1, mod.timesVisited) << " "
926  << mod.moduleLabel << "";
927  }
928  }
929  if(not tr.trigPathSummaries.empty()) {
930  LogVerbatim("FwkSummary") << "TimeReport "
931  << std::right << std::setw(kColumn1Size) << "per event" <<" "
932  << std::right << std::setw(kColumn2Size) << "per visit"
933  << " Name" << "";
934  }
935  for (auto const& p: tr.endPathSummaries) {
936  LogVerbatim("FwkSummary") << "";
937  LogVerbatim("FwkSummary") << "TimeReport " << "------ Modules in End-Path: " << p.name << " ---[Real sec]----";
938  LogVerbatim("FwkSummary") << "TimeReport "
939  << std::right << std::setw(kColumn1Size) << "per event" <<" "
940  << std::right << std::setw(kColumn2Size) << "per visit"
941  << " Name" << "";
942  for (auto const& mod: p.moduleInPathSummaries) {
943  LogVerbatim("FwkSummary") << "TimeReport "
944  << std::setprecision(6) << std::fixed
945  << std::right << std::setw(kColumn1Size) << mod.realTime/totalEvents << " "
946  << std::right << std::setw(kColumn2Size) << mod.realTime/std::max(1, mod.timesVisited) << " "
947  << mod.moduleLabel << "";
948  }
949  }
950  if(not tr.endPathSummaries.empty()) {
951  LogVerbatim("FwkSummary") << "TimeReport "
952  << std::right << std::setw(kColumn1Size) << "per event" <<" "
953  << std::right << std::setw(kColumn2Size) << "per visit"
954  << " Name" << "";
955  }
956  LogVerbatim("FwkSummary") << "";
957  LogVerbatim("FwkSummary") << "TimeReport " << "---------- Module Summary ---[Real sec]----";
958  LogVerbatim("FwkSummary") << "TimeReport "
959  << std::right << std::setw(kColumn1Size) << "per event" <<" "
960  << std::right << std::setw(kColumn2Size) << "per exec" <<" "
961  << std::right << std::setw(kColumn3Size) << "per visit"
962  << " Name" << "";
963  for (auto const& worker : tr.workerSummaries) {
964  LogVerbatim("FwkSummary") << "TimeReport "
965  << std::setprecision(6) << std::fixed
966  << std::right << std::setw(kColumn1Size) << worker.realTime/totalEvents << " "
967  << std::right << std::setw(kColumn2Size) << worker.realTime/std::max(1, worker.timesRun) << " "
968  << std::right << std::setw(kColumn3Size) << worker.realTime/std::max(1, worker.timesVisited) << " "
969  << worker.moduleLabel << "";
970  }
971  LogVerbatim("FwkSummary") << "TimeReport "
972  << std::right << std::setw(kColumn1Size) << "per event" <<" "
973  << std::right << std::setw(kColumn2Size) << "per exec" <<" "
974  << std::right << std::setw(kColumn3Size) << "per visit"
975  << " Name" << "";
976 
977  LogVerbatim("FwkSummary") << "";
978  LogVerbatim("FwkSummary") << "T---Report end!" << "";
979  LogVerbatim("FwkSummary") << "";
980  }
981 
983  using std::placeholders::_1;
985  }
986 
988  using std::placeholders::_1;
990  }
991 
992  void Schedule::writeRun(RunPrincipal const& rp, ProcessContext const* processContext) {
993  using std::placeholders::_1;
994  for_all(all_output_communicators_, std::bind(&OutputModuleCommunicator::writeRun, _1, std::cref(rp), processContext));
995  }
996 
997  void Schedule::writeLumi(LuminosityBlockPrincipal const& lbp, ProcessContext const* processContext) {
998  using std::placeholders::_1;
999  for_all(all_output_communicators_, std::bind(&OutputModuleCommunicator::writeLumi, _1, std::cref(lbp), processContext));
1000  }
1001 
1003  using std::placeholders::_1;
1004  // Return true iff at least one output module returns true.
1005  return (std::find_if (all_output_communicators_.begin(), all_output_communicators_.end(),
1007  != all_output_communicators_.end());
1008  }
1009 
1011  using std::placeholders::_1;
1012  for_all(allWorkers(), std::bind(&Worker::respondToOpenInputFile, _1, std::cref(fb)));
1013  }
1014 
1016  using std::placeholders::_1;
1017  for_all(allWorkers(), std::bind(&Worker::respondToCloseInputFile, _1, std::cref(fb)));
1018  }
1019 
1020  void Schedule::beginJob(ProductRegistry const& iRegistry) {
1021  globalSchedule_->beginJob(iRegistry);
1022  }
1023 
1024  void Schedule::beginStream(unsigned int iStreamID) {
1025  assert(iStreamID<streamSchedules_.size());
1026  streamSchedules_[iStreamID]->beginStream();
1027  }
1028 
1029  void Schedule::endStream(unsigned int iStreamID) {
1030  assert(iStreamID<streamSchedules_.size());
1031  streamSchedules_[iStreamID]->endStream();
1032  }
1033 
1035  unsigned int iStreamID,
1036  EventPrincipal& ep,
1037  EventSetup const& es) {
1038  assert(iStreamID<streamSchedules_.size());
1039  streamSchedules_[iStreamID]->processOneEventAsync(std::move(iTask),ep,es,pathStatusInserters_);
1040  }
1041 
1043  ParameterSet const& iPSet,
1044  const ProductRegistry& iRegistry) {
1045  Worker* found = nullptr;
1046  for (auto const& worker : allWorkers()) {
1047  if (worker->description().moduleLabel() == iLabel) {
1048  found = worker;
1049  break;
1050  }
1051  }
1052  if (nullptr == found) {
1053  return false;
1054  }
1055 
1056  auto newMod = moduleRegistry_->replaceModule(iLabel,iPSet,preallocConfig_);
1057 
1058  globalSchedule_->replaceModule(newMod,iLabel);
1059 
1060  for(auto& s: streamSchedules_) {
1061  s->replaceModule(newMod,iLabel);
1062  }
1063 
1064  {
1065  //Need to updateLookup in order to make getByToken work
1066  auto const runLookup = iRegistry.productLookup(InRun);
1067  auto const lumiLookup = iRegistry.productLookup(InLumi);
1068  auto const eventLookup = iRegistry.productLookup(InEvent);
1069  found->updateLookup(InRun,*runLookup);
1070  found->updateLookup(InLumi,*lumiLookup);
1071  found->updateLookup(InEvent,*eventLookup);
1072 
1073  auto const& processName = newMod->moduleDescription().processName();
1074  auto const& runModuleToIndicies = runLookup->indiciesForModulesInProcess(processName);
1075  auto const& lumiModuleToIndicies = lumiLookup->indiciesForModulesInProcess(processName);
1076  auto const& eventModuleToIndicies = eventLookup->indiciesForModulesInProcess(processName);
1077  found->resolvePutIndicies(InRun,runModuleToIndicies);
1078  found->resolvePutIndicies(InLumi,lumiModuleToIndicies);
1079  found->resolvePutIndicies(InEvent,eventModuleToIndicies);
1080 
1081 
1082  }
1083 
1084  return true;
1085  }
1086 
1087  std::vector<ModuleDescription const*>
1089  std::vector<ModuleDescription const*> result;
1090  result.reserve(allWorkers().size());
1091 
1092  for (auto const& worker : allWorkers()) {
1093  ModuleDescription const* p = worker->descPtr();
1094  result.push_back(p);
1095  }
1096  return result;
1097  }
1098 
1099  Schedule::AllWorkers const&
1101  return globalSchedule_->allWorkers();
1102  }
1103 
1105  for (auto const& worker : allWorkers()) {
1106  worker->convertCurrentProcessAlias(processName);
1107  }
1108  }
1109 
1110  void
1111  Schedule::availablePaths(std::vector<std::string>& oLabelsToFill) const {
1112  streamSchedules_[0]->availablePaths(oLabelsToFill);
1113  }
1114 
1115  void
1116  Schedule::triggerPaths(std::vector<std::string>& oLabelsToFill) const {
1117  oLabelsToFill = *pathNames_;
1118 
1119  }
1120 
1121  void
1122  Schedule::endPaths(std::vector<std::string>& oLabelsToFill) const {
1123  oLabelsToFill = *endPathNames_;
1124  }
1125 
1126  void
1128  std::vector<std::string>& oLabelsToFill) const {
1129  streamSchedules_[0]->modulesInPath(iPathLabel,oLabelsToFill);
1130  }
1131 
1132  void
1134  std::vector<ModuleDescription const*>& descriptions,
1135  unsigned int hint) const {
1136  streamSchedules_[0]->moduleDescriptionsInPath(iPathLabel, descriptions, hint);
1137  }
1138 
1139  void
1141  std::vector<ModuleDescription const*>& descriptions,
1142  unsigned int hint) const {
1143  streamSchedules_[0]->moduleDescriptionsInEndPath(iEndPathLabel, descriptions, hint);
1144  }
1145 
1146  void
1147  Schedule::fillModuleAndConsumesInfo(std::vector<ModuleDescription const*>& allModuleDescriptions,
1148  std::vector<std::pair<unsigned int, unsigned int> >& moduleIDToIndex,
1149  std::vector<std::vector<ModuleDescription const*> >& modulesWhoseProductsAreConsumedBy,
1150  ProductRegistry const& preg) const {
1151  allModuleDescriptions.clear();
1152  moduleIDToIndex.clear();
1153  modulesWhoseProductsAreConsumedBy.clear();
1154 
1155  allModuleDescriptions.reserve(allWorkers().size());
1156  moduleIDToIndex.reserve(allWorkers().size());
1157  modulesWhoseProductsAreConsumedBy.resize(allWorkers().size());
1158 
1159  std::map<std::string, ModuleDescription const*> labelToDesc;
1160  unsigned int i = 0;
1161  for (auto const& worker : allWorkers()) {
1162  ModuleDescription const* p = worker->descPtr();
1163  allModuleDescriptions.push_back(p);
1164  moduleIDToIndex.push_back(std::pair<unsigned int, unsigned int>(p->id(), i));
1165  labelToDesc[p->moduleLabel()] = p;
1166  ++i;
1167  }
1168  sort_all(moduleIDToIndex);
1169 
1170  i = 0;
1171  for (auto const& worker : allWorkers()) {
1172  std::vector<ModuleDescription const*>& modules = modulesWhoseProductsAreConsumedBy.at(i);
1173  worker->modulesWhoseProductsAreConsumed(modules, preg, labelToDesc);
1174  ++i;
1175  }
1176  }
1177 
1178  void
1180  endpathsAreActive_ = active;
1181  for(auto& s : streamSchedules_) {
1182  s->enableEndPaths(active);
1183  }
1184  }
1185 
1186  bool
1188  return endpathsAreActive_;
1189  }
1190 
1191  void
1193  rep.eventSummary.totalEvents = 0;
1196  for(auto& s: streamSchedules_) {
1197  s->getTriggerReport(rep);
1198  }
1200  }
1201 
1202  void
1204  rep.eventSummary.totalEvents = 0;
1205  rep.eventSummary.cpuTime = 0.;
1206  rep.eventSummary.realTime = 0.;
1207  summaryTimeKeeper_->fillTriggerTimingReport(rep);
1208  }
1209 
1210  int
1212  int returnValue = 0;
1213  for(auto& s: streamSchedules_) {
1214  returnValue += s->totalEvents();
1215  }
1216  return returnValue;
1217  }
1218 
1219  int
1221  int returnValue = 0;
1222  for(auto& s: streamSchedules_) {
1223  returnValue += s->totalEventsPassed();
1224  }
1225  return returnValue;
1226  }
1227 
1228  int
1230  int returnValue = 0;
1231  for(auto& s: streamSchedules_) {
1232  returnValue += s->totalEventsFailed();
1233  }
1234  return returnValue;
1235  }
1236 
1237 
1238  void
1240  for(auto& s: streamSchedules_) {
1241  s->clearCounters();
1242  }
1243  }
1244 }
size
Write out results.
bool empty() const
Definition: ParameterSet.h:218
std::vector< PathSummary > endPathSummaries
Definition: TriggerReport.h:68
T getUntrackedParameter(std::string const &, T const &) const
std::vector< PathTimingSummary > endPathSummaries
void stopEvent(StreamContext const &)
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void fillModuleAndConsumesInfo(std::vector< ModuleDescription const * > &allModuleDescriptions, std::vector< std::pair< unsigned int, unsigned int > > &moduleIDToIndex, std::vector< std::vector< ModuleDescription const * > > &modulesWhoseProductsAreConsumedBy, ProductRegistry const &preg) const
Definition: Schedule.cc:1147
virtual void openFile(FileBlock const &fb)=0
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
Definition: Schedule.cc:1100
roAction_t actions[nactions]
Definition: GenABIO.cc:187
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
Definition: Schedule.cc:1111
virtual void writeRun(RunPrincipal const &rp, ProcessContext const *)=0
void restartModuleEvent(StreamContext const &, ModuleCallingContext const &)
bool endPathsEnabled() const
Definition: Schedule.cc:1187
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:1015
void startModuleEvent(StreamContext const &, ModuleCallingContext const &)
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:277
std::vector< Worker * > AllWorkers
Definition: Schedule.h:121
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
std::vector< std::string > const * pathNames_
Definition: Schedule.h:293
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name...
Definition: Schedule.cc:1104
virtual bool shouldWeCloseFile() const =0
void writeRun(RunPrincipal const &rp, ProcessContext const *)
Definition: Schedule.cc:992
void endStream(unsigned int)
Definition: Schedule.cc:1029
void writeLumi(LuminosityBlockPrincipal const &lbp, ProcessContext const *)
Definition: Schedule.cc:997
void enableEndPaths(bool active)
Definition: Schedule.cc:1179
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
virtual void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &)=0
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:1140
std::vector< WorkerSummary > workerSummaries
Definition: TriggerReport.h:69
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:291
std::string const & moduleLabel() const
static unsigned int getUniqueID()
Returns a unique id each time called. Intended to be passed to ModuleDescription&#39;s constructor&#39;s modI...
#define constexpr
int totalEventsFailed() const
Definition: Schedule.cc:1229
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:286
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry)
Definition: Schedule.cc:1042
void eraseOrSetUntrackedParameterSet(std::string const &name)
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:194
int totalEventsPassed() const
Definition: Schedule.cc:1220
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:1116
std::vector< PathSummary > trigPathSummaries
Definition: TriggerReport.h:67
EventSummary eventSummary
Definition: TriggerReport.h:66
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:281
int totalEvents() const
Definition: Schedule.cc:1211
virtual void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies)=0
EventTimingSummary eventSummary
void clearCounters()
Clear all the counters in the trigger report.
Definition: Schedule.cc:1239
Schedule(ParameterSet &proc_pset, service::TriggerNamesService const &tns, ProductRegistry &pregistry, BranchIDListHelper &branchIDListHelper, ThinnedAssociationsHelper &thinnedAssociationsHelper, SubProcessParentageHelper const *subProcessParentageHelper, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration > processConfiguration, bool hasSubprocesses, PreallocationConfiguration const &config, ProcessContext const *processContext)
Definition: Schedule.cc:434
std::vector< PathTimingSummary > trigPathSummaries
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists, SubProcessParentageHelper const *subProcessParentageHelper)
Definition: Schedule.cc:637
bool terminate() const
Return whether each output module has reached its maximum count.
Definition: Schedule.cc:678
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:1010
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:283
rep
Definition: cuy.py:1188
virtual void writeLumi(LuminosityBlockPrincipal const &lbp, ProcessContext const *)=0
void stopPath(StreamContext const &, PathContext const &, HLTPathStatus const &)
void stopModuleEvent(StreamContext const &, ModuleCallingContext const &)
void getTriggerReport(TriggerReport &rep) const
Definition: Schedule.cc:1192
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:289
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:284
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
volatile bool endpathsAreActive_
Definition: Schedule.h:297
void respondToOpenInputFile(FileBlock const &fb)
Definition: Worker.h:152
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:275
void startPath(StreamContext const &, PathContext const &)
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:46
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:282
virtual std::unique_ptr< OutputModuleCommunicator > createOutputModuleCommunicator()=0
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:288
void modulesInPath(std::string const &iPathLabel, std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill in execution order the labels of all modules in path iPathLabel ...
Definition: Schedule.cc:1127
void pauseModuleEvent(StreamContext const &, ModuleCallingContext const &)
std::shared_ptr< ProductResolverIndexHelper const > productLookup(BranchType branchType) const
void beginStream(unsigned int)
Definition: Schedule.cc:1024
void respondToCloseInputFile(FileBlock const &fb)
Definition: Worker.h:153
bool wantSummary_
Definition: Schedule.h:295
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:294
HLT enums.
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:1088
Strings const & getTrigPaths() const
void processOneEventAsync(WaitingTaskHolder iTask, unsigned int iStreamID, EventPrincipal &principal, EventSetup const &eventSetup)
Definition: Schedule.cc:1034
void beginJob(ProductRegistry const &)
Definition: Schedule.cc:1020
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:987
std::vector< WorkerTimingSummary > workerSummaries
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:694
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1203
bool shouldWeCloseOutput() const
Definition: Schedule.cc:1002
std::vector< std::string > vstring
Definition: Schedule.cc:430
def move(src, dest)
Definition: eostools.py:510
void closeOutputFiles()
Definition: Schedule.cc:982
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
Definition: Schedule.cc:1122
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:1133
unsigned int id() const
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)