CMS 3D CMS Logo

GlobalSchedule.cc
Go to the documentation of this file.
7 
14 
15 
16 #include <algorithm>
17 #include <cassert>
18 #include <cstdlib>
19 #include <functional>
20 #include <map>
21 
22 namespace edm {
23  GlobalSchedule::GlobalSchedule(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),
36  processContext_(processContext)
37  {
38  workerManagers_.reserve(prealloc.numberOfLuminosityBlocks());
39  for(unsigned int i = 0; i<prealloc.numberOfLuminosityBlocks(); ++i) {
40  workerManagers_.emplace_back(modReg,areg,actions);
41  }
42  for (auto const& moduleLabel : iModulesToUse) {
43  bool isTracked;
44  ParameterSet* modpset = proc_pset.getPSetForUpdate(moduleLabel, isTracked);
45  if (modpset != nullptr) { // It will be null for PathStatusInserters, it should
46  // be impossible to be null for anything else
47  assert(isTracked);
48 
49  //side effect keeps this module around
50  for(auto& wm: workerManagers_) {
51  wm.addToAllWorkers(wm.getWorker(*modpset, pregistry, &prealloc,processConfiguration, moduleLabel));
52  }
53  }
54  }
55  if(inserter) {
56  inserter->doPreallocate(prealloc);
57  for(auto& wm: workerManagers_) {
58  auto results_inserter = WorkerPtr(new edm::WorkerT<TriggerResultInserter::ModuleType>(inserter, inserter->moduleDescription(), &actions)); // propagate_const<T> has no reset() function
59  results_inserter->setActivityRegistry(actReg_);
60  wm.addToAllWorkers(results_inserter.get());
61  extraWorkers_.emplace_back(std::move(results_inserter));
62  }
63  }
64 
65  for(auto & pathStatusInserter : pathStatusInserters) {
66  std::shared_ptr<PathStatusInserter> inserterPtr = get_underlying(pathStatusInserter);
67  inserterPtr->doPreallocate(prealloc);
68 
69  for(auto& wm: workerManagers_) {
71  inserterPtr->moduleDescription(),
72  &actions));
73  workerPtr->setActivityRegistry(actReg_);
74  wm.addToAllWorkers(workerPtr.get());
75  extraWorkers_.emplace_back(std::move(workerPtr));
76  }
77  }
78 
79  for(auto & endPathStatusInserter : endPathStatusInserters) {
80  std::shared_ptr<EndPathStatusInserter> inserterPtr = get_underlying(endPathStatusInserter);
81  inserterPtr->doPreallocate(prealloc);
82  for(auto& wm: workerManagers_) {
84  inserterPtr->moduleDescription(),
85  &actions));
86  workerPtr->setActivityRegistry(actReg_);
87  wm.addToAllWorkers(workerPtr.get());
88  extraWorkers_.emplace_back(std::move(workerPtr));
89  }
90  }
91 
92  } // GlobalSchedule::GlobalSchedule
93 
95  workerManagers_[0].endJob(collector);
96  }
97 
98  void GlobalSchedule::beginJob(ProductRegistry const& iRegistry) {
99  workerManagers_[0].beginJob(iRegistry);
100  }
101 
103  std::string const& iLabel) {
104  Worker* found = nullptr;
105  for(auto& wm: workerManagers_) {
106  for (auto const& worker : wm.allWorkers()) {
107  if (worker->description().moduleLabel() == iLabel) {
108  found = worker;
109  break;
110  }
111  }
112  if (nullptr == found) {
113  return;
114  }
115 
116  iMod->replaceModuleFor(found);
117  found->beginJob();
118  }
119  }
120 
121  std::vector<ModuleDescription const*>
123  std::vector<ModuleDescription const*> result;
124  result.reserve(allWorkers().size());
125 
126  for (auto const& worker : allWorkers()) {
127  ModuleDescription const* p = worker->descPtr();
128  result.push_back(p);
129  }
130  return result;
131  }
132 }
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:187
virtual void replaceModuleFor(Worker *) const =0
void beginJob(ProductRegistry const &)
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:289
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_