CMS 3D CMS Logo

GlobalSchedule.cc
Go to the documentation of this file.
7 
14 
15 #include <algorithm>
16 #include <cassert>
17 #include <cstdlib>
18 #include <functional>
19 #include <map>
20 
21 namespace edm {
23  std::shared_ptr<TriggerResultInserter> inserter,
24  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>>& pathStatusInserters,
25  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>>& endPathStatusInserters,
26  std::shared_ptr<ModuleRegistry> modReg,
27  std::vector<std::string> const& iModulesToUse,
28  ParameterSet& proc_pset,
29  ProductRegistry& pregistry,
30  PreallocationConfiguration const& prealloc,
32  std::shared_ptr<ActivityRegistry> areg,
33  std::shared_ptr<ProcessConfiguration> processConfiguration,
34  ProcessContext const* processContext)
35  : actReg_(areg), processContext_(processContext) {
36  workerManagers_.reserve(prealloc.numberOfLuminosityBlocks());
37  for (unsigned int i = 0; i < prealloc.numberOfLuminosityBlocks(); ++i) {
38  workerManagers_.emplace_back(modReg, areg, actions);
39  }
40  for (auto const& moduleLabel : iModulesToUse) {
41  bool isTracked;
42  ParameterSet* modpset = proc_pset.getPSetForUpdate(moduleLabel, isTracked);
43  if (modpset != nullptr) { // It will be null for PathStatusInserters, it should
44  // be impossible to be null for anything else
45  assert(isTracked);
46 
47  //side effect keeps this module around
48  for (auto& wm : workerManagers_) {
49  wm.addToAllWorkers(wm.getWorker(*modpset, pregistry, &prealloc, processConfiguration, moduleLabel));
50  }
51  }
52  }
53  if (inserter) {
54  inserter->doPreallocate(prealloc);
55  for (auto& wm : workerManagers_) {
57  inserter, inserter->moduleDescription(), &actions)); // propagate_const<T> has no reset() function
58  results_inserter->setActivityRegistry(actReg_);
59  wm.addToAllWorkers(results_inserter.get());
60  extraWorkers_.emplace_back(std::move(results_inserter));
61  }
62  }
63 
64  for (auto& pathStatusInserter : pathStatusInserters) {
65  std::shared_ptr<PathStatusInserter> inserterPtr = get_underlying(pathStatusInserter);
66  inserterPtr->doPreallocate(prealloc);
67 
68  for (auto& wm : workerManagers_) {
69  WorkerPtr workerPtr(
70  new edm::WorkerT<PathStatusInserter::ModuleType>(inserterPtr, inserterPtr->moduleDescription(), &actions));
71  workerPtr->setActivityRegistry(actReg_);
72  wm.addToAllWorkers(workerPtr.get());
73  extraWorkers_.emplace_back(std::move(workerPtr));
74  }
75  }
76 
77  for (auto& endPathStatusInserter : endPathStatusInserters) {
78  std::shared_ptr<EndPathStatusInserter> inserterPtr = get_underlying(endPathStatusInserter);
79  inserterPtr->doPreallocate(prealloc);
80  for (auto& wm : workerManagers_) {
82  inserterPtr, inserterPtr->moduleDescription(), &actions));
83  workerPtr->setActivityRegistry(actReg_);
84  wm.addToAllWorkers(workerPtr.get());
85  extraWorkers_.emplace_back(std::move(workerPtr));
86  }
87  }
88 
89  } // GlobalSchedule::GlobalSchedule
90 
91  void GlobalSchedule::endJob(ExceptionCollector& collector) { workerManagers_[0].endJob(collector); }
92 
94  eventsetup::ESRecordsToProxyIndices const& iESIndices) {
95  workerManagers_[0].beginJob(iRegistry, iESIndices);
96  }
97 
99  Worker* found = nullptr;
100  for (auto& wm : workerManagers_) {
101  for (auto const& worker : wm.allWorkers()) {
102  if (worker->description().moduleLabel() == iLabel) {
103  found = worker;
104  break;
105  }
106  }
107  if (nullptr == found) {
108  return;
109  }
110 
111  iMod->replaceModuleFor(found);
112  found->beginJob();
113  }
114  }
115 
116  std::vector<ModuleDescription const*> GlobalSchedule::getAllModuleDescriptions() const {
117  std::vector<ModuleDescription const*> result;
118  result.reserve(allWorkers().size());
119 
120  for (auto const& worker : allWorkers()) {
121  ModuleDescription const* p = worker->descPtr();
122  result.push_back(p);
123  }
124  return result;
125  }
126 } // namespace edm
size
Write out results.
void replaceModule(maker::ModuleHolder *iMod, std::string const &iLabel)
clone the type of module with label iLabel but configure with iPSet.
std::vector< WorkerManager > workerManagers_
roAction_t actions[nactions]
Definition: GenABIO.cc:181
virtual void replaceModuleFor(Worker *) const =0
T & get_underlying(propagate_const< T > &)
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
std::shared_ptr< Worker > WorkerPtr
void endJob(ExceptionCollector &collector)
std::shared_ptr< ActivityRegistry > actReg_
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
HLT enums.
void beginJob()
Definition: Worker.cc:284
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &)
GlobalSchedule(std::shared_ptr< TriggerResultInserter > inserter, std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter >>> &pathStatusInserters, std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter >>> &endPathStatusInserters, std::shared_ptr< ModuleRegistry > modReg, std::vector< std::string > const &modulesToUse, ParameterSet &proc_pset, ProductRegistry &pregistry, PreallocationConfiguration const &prealloc, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration > processConfiguration, ProcessContext const *processContext)
def move(src, dest)
Definition: eostools.py:511
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)
std::vector< edm::propagate_const< WorkerPtr > > extraWorkers_