CMS 3D CMS Logo

WorkerManager.cc
Go to the documentation of this file.
3 
10 
11 static const std::string kFilterType("EDFilter");
12 static const std::string kProducerType("EDProducer");
13 
14 namespace edm {
15  // -----------------------------
16 
17  WorkerManager::WorkerManager(std::shared_ptr<ActivityRegistry> areg, ExceptionToActionTable const& actions)
18  : workerReg_(areg),
19  actionTable_(&actions),
20  allWorkers_(),
21  unscheduled_(*areg),
22  lastSetupEventPrincipal_(nullptr) {} // WorkerManager::WorkerManager
23 
24  WorkerManager::WorkerManager(std::shared_ptr<ModuleRegistry> modReg,
25  std::shared_ptr<ActivityRegistry> areg,
27  : workerReg_(areg, modReg),
28  actionTable_(&actions),
29  allWorkers_(),
30  unscheduled_(*areg),
31  lastSetupEventPrincipal_(nullptr) {} // WorkerManager::WorkerManager
32 
34  auto worker = workerReg_.get(moduleLabel);
35  if (worker != nullptr) {
36  auto eraseBeg = std::remove(allWorkers_.begin(), allWorkers_.end(), worker);
37  allWorkers_.erase(eraseBeg, allWorkers_.end());
38  unscheduled_.removeWorker(worker);
40  }
41  }
42 
44  ProductRegistry& preg,
45  PreallocationConfiguration const* prealloc,
46  std::shared_ptr<ProcessConfiguration const> processConfiguration,
47  std::string const& label) {
48  WorkerParams params(&pset, preg, prealloc, processConfiguration, *actionTable_);
50  }
51 
53  ProductRegistry& preg,
54  PreallocationConfiguration const* prealloc,
55  std::shared_ptr<ProcessConfiguration> processConfiguration,
57  std::set<std::string>& unscheduledLabels,
58  std::vector<std::string>& shouldBeUsedLabels) {
59  //Need to
60  // 1) create worker
61  // 2) if it is a WorkerT<EDProducer>, add it to our list
62  auto modType = pset.getParameter<std::string>("@module_edm_type");
63  if (modType == kProducerType || modType == kFilterType) {
64  Worker* newWorker = getWorker(pset, preg, prealloc, processConfiguration, label);
65  assert(newWorker->moduleType() == Worker::kProducer || newWorker->moduleType() == Worker::kFilter);
66  unscheduledLabels.insert(label);
67  unscheduled_.addWorker(newWorker);
68  //add to list so it gets reset each new event
69  addToAllWorkers(newWorker);
70  } else {
71  shouldBeUsedLabels.push_back(label);
72  }
73  }
74 
76  for (auto& worker : allWorkers_) {
77  worker->endJob();
78  }
79  }
80 
82  for (auto& worker : allWorkers_) {
83  try {
84  convertException::wrap([&]() { worker->endJob(); });
85  } catch (cms::Exception const& ex) {
86  collector.addException(ex);
87  }
88  }
89  }
90 
92  eventsetup::ESRecordsToProxyIndices const& iESIndices) {
93  auto const processBlockLookup = iRegistry.productLookup(InProcess);
94  auto const runLookup = iRegistry.productLookup(InRun);
95  auto const lumiLookup = iRegistry.productLookup(InLumi);
96  auto const eventLookup = iRegistry.productLookup(InEvent);
97  if (!allWorkers_.empty()) {
98  auto const& processName = allWorkers_[0]->description()->processName();
99  auto processBlockModuleToIndicies = processBlockLookup->indiciesForModulesInProcess(processName);
100  auto runModuleToIndicies = runLookup->indiciesForModulesInProcess(processName);
101  auto lumiModuleToIndicies = lumiLookup->indiciesForModulesInProcess(processName);
102  auto eventModuleToIndicies = eventLookup->indiciesForModulesInProcess(processName);
103  for (auto& worker : allWorkers_) {
104  worker->updateLookup(InProcess, *processBlockLookup);
105  worker->updateLookup(InRun, *runLookup);
106  worker->updateLookup(InLumi, *lumiLookup);
107  worker->updateLookup(InEvent, *eventLookup);
108  worker->updateLookup(iESIndices);
109  worker->resolvePutIndicies(InProcess, processBlockModuleToIndicies);
110  worker->resolvePutIndicies(InRun, runModuleToIndicies);
111  worker->resolvePutIndicies(InLumi, lumiModuleToIndicies);
112  worker->resolvePutIndicies(InEvent, eventModuleToIndicies);
113  }
114 
115  for_all(allWorkers_, std::bind(&Worker::beginJob, std::placeholders::_1));
116  }
117  }
118 
120  for (auto& worker : allWorkers_) {
121  worker->beginStream(iID, streamContext);
122  }
123  }
124 
125  void WorkerManager::endStream(StreamID iID, StreamContext& streamContext) {
126  for (auto& worker : allWorkers_) {
127  worker->endStream(iID, streamContext);
128  }
129  }
130 
131  void WorkerManager::resetAll() { for_all(allWorkers_, std::bind(&Worker::reset, std::placeholders::_1)); }
132 
134  if (!search_all(allWorkers_, w)) {
135  allWorkers_.push_back(w);
136  }
137  }
138 
140  this->resetAll();
141  if (&ep != lastSetupEventPrincipal_) {
143  ep.setupUnscheduled(config);
145  }
146  }
147 
150  }
151 
152 } // namespace edm
kProducerType
static const std::string kProducerType("EDProducer")
edm::EventTransitionInfo
Definition: TransitionInfoTypes.h:26
edm::StreamID
Definition: StreamID.h:30
edm::WorkerManager::addToAllWorkers
void addToAllWorkers(Worker *w)
Definition: WorkerManager.cc:133
WorkerManager.h
ProductResolverIndexHelper.h
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::ExceptionCollector::addException
void addException(cms::Exception const &exception)
Definition: ExceptionCollector.cc:51
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::WorkerManager::resetAll
void resetAll()
Definition: WorkerManager.cc:131
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Worker::beginJob
void beginJob()
Definition: Worker.cc:347
edm::WorkerManager::addToUnscheduledWorkers
void addToUnscheduledWorkers(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration > processConfiguration, std::string label, std::set< std::string > &unscheduledLabels, std::vector< std::string > &shouldBeUsedLabels)
Definition: WorkerManager.cc:52
Algorithms.h
kFilterType
static const std::string kFilterType("EDFilter")
cms::cuda::assert
assert(be >=bs)
edm::Principal
Definition: Principal.h:56
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
UnscheduledConfigurator.h
edm::ProductRegistry::productLookup
std::shared_ptr< ProductResolverIndexHelper const > productLookup(BranchType branchType) const
Definition: ProductRegistry.cc:145
edm::Worker::kProducer
Definition: Worker.h:93
ProductRegistry.h
edm::InRun
Definition: BranchType.h:11
edm::Worker::reset
void reset()
Definition: Worker.h:176
edm::for_all
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
edm::ProductRegistry
Definition: ProductRegistry.h:37
ActivityRegistry.h
config
Definition: config.py:1
edm::InProcess
Definition: BranchType.h:11
edm::WorkerRegistry::getWorker
Worker * getWorker(WorkerParams const &p, std::string const &moduleLabel)
Retrieve the particular instance of the worker.
Definition: WorkerRegistry.cc:28
edm::Worker::kFilter
Definition: Worker.h:93
edm::StreamContext
Definition: StreamContext.h:31
edm::ExceptionCollector
Definition: ExceptionCollector.h:33
w
const double w
Definition: UKUtility.cc:23
submitPVResolutionJobs.config
config
parse the configuration file
Definition: submitPVResolutionJobs.py:281
edm::convertException::wrap
auto wrap(F iFunc) -> decltype(iFunc())
Definition: ConvertException.h:19
edm::WorkerManager::unscheduled_
UnscheduledCallProducer unscheduled_
Definition: WorkerManager.h:100
edm::WorkerRegistry::get
Worker const * get(std::string const &moduleLabel) const
Definition: WorkerRegistry.cc:48
edm::InEvent
Definition: BranchType.h:11
edm::UnscheduledCallProducer::setEventTransitionInfo
void setEventTransitionInfo(EventTransitionInfo const &info)
Definition: UnscheduledCallProducer.h:62
ExceptionCollector.h
edm::Worker
Definition: Worker.h:90
edm::WorkerManager::actionTable_
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:98
edm::WorkerManager::workerReg_
WorkerRegistry workerReg_
Definition: WorkerManager.h:97
edm::WorkerManager::beginJob
void beginJob(ProductRegistry const &iRegistry, eventsetup::ESRecordsToProxyIndices const &)
Definition: WorkerManager.cc:91
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::WorkerManager::beginStream
void beginStream(StreamID iID, StreamContext &streamContext)
Definition: WorkerManager.cc:119
edm::ParameterSet
Definition: ParameterSet.h:47
edm::InLumi
Definition: BranchType.h:11
edm::WorkerManager::setupOnDemandSystem
void setupOnDemandSystem(EventTransitionInfo const &)
Definition: WorkerManager.cc:148
edm::UnscheduledCallProducer::addWorker
void addWorker(Worker *aWorker)
Definition: UnscheduledCallProducer.h:47
edm::WorkerManager::allWorkers_
AllWorkers allWorkers_
Definition: WorkerManager.h:99
edm::UnscheduledCallProducer::removeWorker
void removeWorker(Worker const *worker)
Definition: UnscheduledCallProducer.h:55
edm::UnscheduledConfigurator
Definition: UnscheduledConfigurator.h:32
edm::ExceptionToActionTable
Definition: ExceptionActions.h:16
edm::WorkerParams
Definition: WorkerParams.h:22
edm::Worker::moduleType
virtual Types moduleType() const =0
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
edm::PreallocationConfiguration
Definition: PreallocationConfiguration.h:27
edm::UnscheduledCallProducer::auxiliary
UnscheduledAuxiliary const & auxiliary() const
Definition: UnscheduledCallProducer.h:64
edm::WorkerRegistry::deleteModule
void deleteModule(std::string const &moduleLabel)
Deletes the module of the Worker, but the Worker continues to exist.
Definition: WorkerRegistry.cc:56
MatrixUtil.remove
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:219
edm::WorkerManager::setupResolvers
void setupResolvers(Principal &principal)
Definition: WorkerManager.cc:139
edm::WorkerManager::endStream
void endStream(StreamID iID, StreamContext &streamContext)
Definition: WorkerManager.cc:125
edm::WorkerManager::getWorker
Worker * getWorker(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &label)
Definition: WorkerManager.cc:43
actions
roAction_t actions[nactions]
Definition: GenABIO.cc:181
edm::search_all
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:36
cms::Exception
Definition: Exception.h:70
ParameterSet.h
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::WorkerManager::deleteModuleIfExists
void deleteModuleIfExists(std::string const &moduleLabel)
Definition: WorkerManager.cc:33
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
label
const char * label
Definition: PFTauDecayModeTools.cc:11
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::WorkerManager::WorkerManager
WorkerManager(std::shared_ptr< ActivityRegistry > actReg, ExceptionToActionTable const &actions)
Definition: WorkerManager.cc:17
edm::WorkerManager::lastSetupEventPrincipal_
void const * lastSetupEventPrincipal_
Definition: WorkerManager.h:101
edm::WorkerManager::endJob
void endJob()
Definition: WorkerManager.cc:75