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 processBlockLookup = iRegistry.productLookup(InProcess);
84  auto const runLookup = iRegistry.productLookup(InRun);
85  auto const lumiLookup = iRegistry.productLookup(InLumi);
86  auto const eventLookup = iRegistry.productLookup(InEvent);
87  if (!allWorkers_.empty()) {
88  auto const& processName = allWorkers_[0]->description().processName();
89  auto processBlockModuleToIndicies = processBlockLookup->indiciesForModulesInProcess(processName);
90  auto runModuleToIndicies = runLookup->indiciesForModulesInProcess(processName);
91  auto lumiModuleToIndicies = lumiLookup->indiciesForModulesInProcess(processName);
92  auto eventModuleToIndicies = eventLookup->indiciesForModulesInProcess(processName);
93  for (auto& worker : allWorkers_) {
94  worker->updateLookup(InProcess, *processBlockLookup);
95  worker->updateLookup(InRun, *runLookup);
96  worker->updateLookup(InLumi, *lumiLookup);
97  worker->updateLookup(InEvent, *eventLookup);
98  worker->updateLookup(iESIndices);
99  worker->resolvePutIndicies(InProcess, processBlockModuleToIndicies);
100  worker->resolvePutIndicies(InRun, runModuleToIndicies);
101  worker->resolvePutIndicies(InLumi, lumiModuleToIndicies);
102  worker->resolvePutIndicies(InEvent, eventModuleToIndicies);
103  }
104 
105  for_all(allWorkers_, std::bind(&Worker::beginJob, std::placeholders::_1));
106  }
107  }
108 
110  for (auto& worker : allWorkers_) {
111  worker->beginStream(iID, streamContext);
112  }
113  }
114 
115  void WorkerManager::endStream(StreamID iID, StreamContext& streamContext) {
116  for (auto& worker : allWorkers_) {
117  worker->endStream(iID, streamContext);
118  }
119  }
120 
121  void WorkerManager::resetAll() { for_all(allWorkers_, std::bind(&Worker::reset, std::placeholders::_1)); }
122 
124  if (!search_all(allWorkers_, w)) {
125  allWorkers_.push_back(w);
126  }
127  }
128 
130  this->resetAll();
131  if (&ep != lastSetupEventPrincipal_) {
133  ep.setupUnscheduled(config);
135  }
136  }
137 
140  }
141 
142 } // 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:123
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:121
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Worker::beginJob
void beginJob()
Definition: Worker.cc:349
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
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:91
ProductRegistry.h
edm::InRun
Definition: BranchType.h:11
edm::Worker::reset
void reset()
Definition: Worker.h:178
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:91
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:102
edm::InEvent
Definition: BranchType.h:11
edm::UnscheduledCallProducer::setEventTransitionInfo
void setEventTransitionInfo(EventTransitionInfo const &info)
Definition: UnscheduledCallProducer.h:54
ExceptionCollector.h
edm::Worker
Definition: Worker.h:88
edm::WorkerManager::actionTable_
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:100
edm::WorkerManager::workerReg_
WorkerRegistry workerReg_
Definition: WorkerManager.h:99
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:109
edm::ParameterSet
Definition: ParameterSet.h:47
edm::InLumi
Definition: BranchType.h:11
edm::WorkerManager::setupOnDemandSystem
void setupOnDemandSystem(EventTransitionInfo const &)
Definition: WorkerManager.cc:138
edm::UnscheduledCallProducer::addWorker
void addWorker(Worker *aWorker)
Definition: UnscheduledCallProducer.h:46
edm::WorkerManager::allWorkers_
AllWorkers allWorkers_
Definition: WorkerManager.h:101
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:56
edm::WorkerManager::setupResolvers
void setupResolvers(Principal &principal)
Definition: WorkerManager.cc:129
edm::WorkerManager::endStream
void endStream(StreamID iID, StreamContext &streamContext)
Definition: WorkerManager.cc:115
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:103
edm::WorkerManager::endJob
void endJob()
Definition: WorkerManager.cc:65