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  ProductRegistry& preg,
35  PreallocationConfiguration const* prealloc,
36  std::shared_ptr<ProcessConfiguration const> processConfiguration,
37  std::string const& label) {
38  WorkerParams params(&pset, preg, prealloc, processConfiguration, *actionTable_);
40  }
41 
43  ProductRegistry& preg,
44  PreallocationConfiguration const* prealloc,
45  std::shared_ptr<ProcessConfiguration> processConfiguration,
47  std::set<std::string>& unscheduledLabels,
48  std::vector<std::string>& shouldBeUsedLabels) {
49  //Need to
50  // 1) create worker
51  // 2) if it is a WorkerT<EDProducer>, add it to our list
52  auto modType = pset.getParameter<std::string>("@module_edm_type");
53  if (modType == kProducerType || modType == kFilterType) {
54  Worker* newWorker = getWorker(pset, preg, prealloc, processConfiguration, label);
55  assert(newWorker->moduleType() == Worker::kProducer || newWorker->moduleType() == Worker::kFilter);
56  unscheduledLabels.insert(label);
57  unscheduled_.addWorker(newWorker);
58  //add to list so it gets reset each new event
59  addToAllWorkers(newWorker);
60  } else {
61  shouldBeUsedLabels.push_back(label);
62  }
63  }
64 
66  for (auto& worker : allWorkers_) {
67  worker->endJob();
68  }
69  }
70 
72  for (auto& worker : allWorkers_) {
73  try {
74  convertException::wrap([&]() { worker->endJob(); });
75  } catch (cms::Exception const& ex) {
76  collector.addException(ex);
77  }
78  }
79  }
80 
82  eventsetup::ESRecordsToProxyIndices const& iESIndices) {
83  auto const runLookup = iRegistry.productLookup(InRun);
84  auto const lumiLookup = iRegistry.productLookup(InLumi);
85  auto const eventLookup = iRegistry.productLookup(InEvent);
86  if (!allWorkers_.empty()) {
87  auto const& processName = allWorkers_[0]->description().processName();
88  auto runModuleToIndicies = runLookup->indiciesForModulesInProcess(processName);
89  auto lumiModuleToIndicies = lumiLookup->indiciesForModulesInProcess(processName);
90  auto eventModuleToIndicies = eventLookup->indiciesForModulesInProcess(processName);
91  for (auto& worker : allWorkers_) {
92  worker->updateLookup(InRun, *runLookup);
93  worker->updateLookup(InLumi, *lumiLookup);
94  worker->updateLookup(InEvent, *eventLookup);
95  worker->updateLookup(iESIndices);
96  worker->resolvePutIndicies(InRun, runModuleToIndicies);
97  worker->resolvePutIndicies(InLumi, lumiModuleToIndicies);
98  worker->resolvePutIndicies(InEvent, eventModuleToIndicies);
99  }
100 
101  for_all(allWorkers_, std::bind(&Worker::beginJob, std::placeholders::_1));
102  }
103  }
104 
106  for (auto& worker : allWorkers_) {
107  worker->beginStream(iID, streamContext);
108  }
109  }
110 
111  void WorkerManager::endStream(StreamID iID, StreamContext& streamContext) {
112  for (auto& worker : allWorkers_) {
113  worker->endStream(iID, streamContext);
114  }
115  }
116 
117  void WorkerManager::resetAll() { for_all(allWorkers_, std::bind(&Worker::reset, std::placeholders::_1)); }
118 
120  if (!search_all(allWorkers_, w)) {
121  allWorkers_.push_back(w);
122  }
123  }
124 
126  this->resetAll();
128  if (&ep != lastSetupEventPrincipal_) {
130  ep.setupUnscheduled(config);
132  }
133  }
134 
135 } // namespace edm
kProducerType
static const std::string kProducerType("EDProducer")
edm::StreamID
Definition: StreamID.h:30
edm::WorkerManager::addToAllWorkers
void addToAllWorkers(Worker *w)
Definition: WorkerManager.cc:119
WorkerManager.h
ProductResolverIndexHelper.h
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::ExceptionCollector::addException
void addException(cms::Exception const &exception)
Definition: ExceptionCollector.cc:50
edm::EventSetupImpl
Definition: EventSetupImpl.h:44
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::WorkerManager::resetAll
void resetAll()
Definition: WorkerManager.cc:117
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Worker::beginJob
void beginJob()
Definition: Worker.cc:285
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:42
Algorithms.h
kFilterType
static const std::string kFilterType("EDFilter")
cms::cuda::assert
assert(be >=bs)
edm::Principal
Definition: Principal.h:57
UnscheduledConfigurator.h
edm::ProductRegistry::productLookup
std::shared_ptr< ProductResolverIndexHelper const > productLookup(BranchType branchType) const
Definition: ProductRegistry.cc:149
edm::Worker::kProducer
Definition: Worker.h:86
ProductRegistry.h
edm::InRun
Definition: BranchType.h:11
edm::Worker::reset
void reset()
Definition: Worker.h:180
edm::for_all
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
edm::ProductRegistry
Definition: ProductRegistry.h:34
ActivityRegistry.h
config
Definition: config.py:1
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:86
edm::StreamContext
Definition: StreamContext.h:31
edm::ExceptionCollector
Definition: ExceptionCollector.h:33
w
const double w
Definition: UKUtility.cc:23
edm::convertException::wrap
auto wrap(F iFunc) -> decltype(iFunc())
Definition: ConvertException.h:19
edm::WorkerManager::unscheduled_
UnscheduledCallProducer unscheduled_
Definition: WorkerManager.h:103
edm::InEvent
Definition: BranchType.h:11
looper.config
config
Definition: looper.py:291
ExceptionCollector.h
edm::Worker
Definition: Worker.h:83
edm::WorkerManager::actionTable_
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:101
edm::WorkerManager::workerReg_
WorkerRegistry workerReg_
Definition: WorkerManager.h:100
edm::WorkerManager::beginJob
void beginJob(ProductRegistry const &iRegistry, eventsetup::ESRecordsToProxyIndices const &)
Definition: WorkerManager.cc:81
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::WorkerManager::beginStream
void beginStream(StreamID iID, StreamContext &streamContext)
Definition: WorkerManager.cc:105
edm::ParameterSet
Definition: ParameterSet.h:36
edm::InLumi
Definition: BranchType.h:11
edm::UnscheduledCallProducer::addWorker
void addWorker(Worker *aWorker)
Definition: UnscheduledCallProducer.h:44
edm::UnscheduledCallProducer::setEventSetup
void setEventSetup(EventSetupImpl const &iSetup)
Definition: UnscheduledCallProducer.h:52
edm::WorkerManager::allWorkers_
AllWorkers allWorkers_
Definition: WorkerManager.h:102
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:54
edm::WorkerManager::setupOnDemandSystem
void setupOnDemandSystem(Principal &principal, EventSetupImpl const &es)
Definition: WorkerManager.cc:125
edm::WorkerManager::endStream
void endStream(StreamID iID, StreamContext &streamContext)
Definition: WorkerManager.cc:111
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:33
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
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:104
edm::WorkerManager::endJob
void endJob()
Definition: WorkerManager.cc:65