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 const> 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  ProcessBlockHelperBase const& processBlockHelperBase) {
96  workerManagers_[0].beginJob(iRegistry, iESIndices, processBlockHelperBase);
97  }
98 
100  Worker* found = nullptr;
101  for (auto& wm : workerManagers_) {
102  for (auto const& worker : wm.allWorkers()) {
103  if (worker->description()->moduleLabel() == iLabel) {
104  found = worker;
105  break;
106  }
107  }
108  if (nullptr == found) {
109  return;
110  }
111 
112  iMod->replaceModuleFor(found);
113  found->beginJob();
114  }
115  }
116 
118  for (auto& wm : workerManagers_) {
119  wm.deleteModuleIfExists(iLabel);
120  }
121  }
122 
123  std::vector<ModuleDescription const*> GlobalSchedule::getAllModuleDescriptions() const {
124  std::vector<ModuleDescription const*> result;
125  result.reserve(allWorkers().size());
126 
127  for (auto const& worker : allWorkers()) {
128  ModuleDescription const* p = worker->description();
129  result.push_back(p);
130  }
131  return result;
132  }
133 } // 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
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
void deleteModule(std::string const &iLabel)
Delete the module with label iLabel.
assert(be >=bs)
std::vector< ModuleDescription const * > getAllModuleDescriptions() 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 const > processConfiguration, ProcessContext const *processContext)
std::shared_ptr< Worker > WorkerPtr
void endJob(ExceptionCollector &collector)
std::shared_ptr< ActivityRegistry > actReg_
constexpr T & get_underlying(propagate_const< T > &)
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &, ProcessBlockHelperBase const &)
HLT enums.
def move(src, dest)
Definition: eostools.py:511
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)
std::vector< edm::propagate_const< WorkerPtr > > extraWorkers_