CMS 3D CMS Logo

SecondaryEventProvider.cc
Go to the documentation of this file.
9 #include "tbb/task_arena.h"
10 
11 namespace {
12  template <typename T, typename U>
13  void processOneOccurrence(edm::WorkerManager& manager,
14  typename T::TransitionInfoType& info,
15  edm::StreamID streamID,
16  typename T::Context const* topContext,
17  U const* context,
18  bool cleaningUpAfterException = false) {
19  manager.resetAll();
20 
21  if (manager.allWorkers().empty())
22  return;
23 
25  //we need the arena to guarantee that the syncWait will return to this thread
26  // and not cause this callstack to possibly be moved to a new thread
27  tbb::task_arena localArena{tbb::this_task_arena::max_concurrency()};
28  std::exception_ptr exceptPtr = localArena.execute([&]() {
29  return edm::syncWait([&](edm::WaitingTaskHolder&& iHolder) {
30  manager.processOneOccurrenceAsync<T, U>(std::move(iHolder), info, token, streamID, topContext, context);
31  });
32  });
33 
34  if (exceptPtr) {
35  try {
36  edm::convertException::wrap([&]() { std::rethrow_exception(exceptPtr); });
37  } catch (cms::Exception& ex) {
38  if (ex.context().empty()) {
39  edm::addContextAndPrintException("Calling SecondaryEventProvider", ex, cleaningUpAfterException);
40  } else {
41  edm::addContextAndPrintException("", ex, cleaningUpAfterException);
42  }
43  throw;
44  }
45  }
46  }
47 } // namespace
48 
49 namespace edm {
50  SecondaryEventProvider::SecondaryEventProvider(std::vector<ParameterSet>& psets,
51  ProductRegistry& preg,
52  std::shared_ptr<ProcessConfiguration> processConfiguration)
53  : exceptionToActionTable_(new ExceptionToActionTable),
54  workerManager_(std::make_shared<ActivityRegistry>(), *exceptionToActionTable_) {
55  std::vector<std::string> shouldBeUsedLabels;
56  std::set<std::string> unscheduledLabels;
57  const PreallocationConfiguration preallocConfig;
58  for (auto& pset : psets) {
59  std::string label = pset.getParameter<std::string>("@module_label");
61  pset, preg, &preallocConfig, processConfiguration, label, unscheduledLabels, shouldBeUsedLabels);
62  }
63  if (!unscheduledLabels.empty()) {
64  preg.setUnscheduledProducts(unscheduledLabels);
65  }
66  } // SecondaryEventProvider::SecondaryEventProvider
67 
69  eventsetup::ESRecordsToProxyIndices const& iIndices) {
70  workerManager_.beginJob(iRegistry, iIndices);
71  }
72 
73  //NOTE: When the Stream interfaces are propagated to the modules, this code must be updated
74  // to also send the stream based transitions
76  const EventSetupImpl& setup,
77  ModuleCallingContext const* mcc,
78  StreamContext& sContext) {
80  processOneOccurrence<OccurrenceTraits<RunPrincipal, BranchActionGlobalBegin> >(
82  processOneOccurrence<OccurrenceTraits<RunPrincipal, BranchActionStreamBegin> >(
83  workerManager_, info, sContext.streamID(), &sContext, mcc);
84  }
85 
87  const EventSetupImpl& setup,
88  ModuleCallingContext const* mcc,
89  StreamContext& sContext) {
91  processOneOccurrence<OccurrenceTraits<LuminosityBlockPrincipal, BranchActionGlobalBegin> >(
93  processOneOccurrence<OccurrenceTraits<LuminosityBlockPrincipal, BranchActionStreamBegin> >(
94  workerManager_, info, sContext.streamID(), &sContext, mcc);
95  }
96 
98  const EventSetupImpl& setup,
99  ModuleCallingContext const* mcc,
100  StreamContext& sContext) {
102  processOneOccurrence<OccurrenceTraits<RunPrincipal, BranchActionStreamEnd> >(
103  workerManager_, info, sContext.streamID(), &sContext, mcc);
104  processOneOccurrence<OccurrenceTraits<RunPrincipal, BranchActionGlobalEnd> >(
105  workerManager_, info, StreamID::invalidStreamID(), nullptr, mcc);
106  }
107 
109  const EventSetupImpl& setup,
110  ModuleCallingContext const* mcc,
111  StreamContext& sContext) {
113  processOneOccurrence<OccurrenceTraits<LuminosityBlockPrincipal, BranchActionStreamEnd> >(
114  workerManager_, info, sContext.streamID(), &sContext, mcc);
115  processOneOccurrence<OccurrenceTraits<LuminosityBlockPrincipal, BranchActionGlobalEnd> >(
116  workerManager_, info, StreamID::invalidStreamID(), nullptr, mcc);
117  }
118 
120  const EventSetupImpl& setup,
121  StreamContext& sContext) {
125  }
127  workerManager_.beginStream(iID, sContext);
128  }
129 
131  workerManager_.endStream(iID, sContext);
132  }
133 } // namespace edm
edm::EventTransitionInfo
Definition: TransitionInfoTypes.h:26
edm::StreamID
Definition: StreamID.h:30
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::SecondaryEventProvider::endStream
void endStream(edm::StreamID iID, StreamContext &sContext)
Definition: SecondaryEventProvider.cc:130
edm::LumiTransitionInfo
Definition: TransitionInfoTypes.h:42
edm::EventSetupImpl
Definition: EventSetupImpl.h:49
edm::SecondaryEventProvider::setupPileUpEvent
void setupPileUpEvent(EventPrincipal &ep, const EventSetupImpl &setup, StreamContext &sContext)
Definition: SecondaryEventProvider.cc:119
edm::WorkerManager::resetAll
void resetAll()
Definition: WorkerManager.cc:131
edm
HLT enums.
Definition: AlignableModifier.h:19
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
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
PreallocationConfiguration.h
ProductRegistry.h
edm::RunTransitionInfo
Definition: TransitionInfoTypes.h:64
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::ProductRegistry
Definition: ProductRegistry.h:37
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::StreamContext
Definition: StreamContext.h:31
edm::convertException::wrap
auto wrap(F iFunc) -> decltype(iFunc())
Definition: ConvertException.h:19
edm::ActivityRegistry
Definition: ActivityRegistry.h:134
edm::WorkerManager::allWorkers
AllWorkers const & allWorkers() const
Definition: WorkerManager.h:82
edm::SecondaryEventProvider::beginStream
void beginStream(edm::StreamID iID, StreamContext &sContext)
Definition: SecondaryEventProvider.cc:126
edm::SecondaryEventProvider::beginJob
void beginJob(ProductRegistry const &iRegistry, eventsetup::ESRecordsToProxyIndices const &)
Definition: SecondaryEventProvider.cc:68
edm::SecondaryEventProvider::endLuminosityBlock
void endLuminosityBlock(LuminosityBlockPrincipal &lumi, const edm::EventSetupImpl &setup, ModuleCallingContext const *, StreamContext &sContext)
Definition: SecondaryEventProvider.cc:108
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
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
include_first_syncWait.h
edm::SecondaryEventProvider::endRun
void endRun(RunPrincipal &run, const edm::EventSetupImpl &setup, ModuleCallingContext const *, StreamContext &sContext)
Definition: SecondaryEventProvider.cc:97
cms::Exception::context
std::list< std::string > const & context() const
Definition: Exception.cc:147
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:32
edm::StreamContext::streamID
StreamID const & streamID() const
Definition: StreamContext.h:54
edm::WorkerManager::setupOnDemandSystem
void setupOnDemandSystem(EventTransitionInfo const &)
Definition: WorkerManager.cc:148
edm::ServiceRegistry::presentToken
ServiceToken presentToken() const
Definition: ServiceRegistry.cc:63
edm::StreamID::invalidStreamID
static StreamID invalidStreamID()
Definition: StreamID.h:45
edm::addContextAndPrintException
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
Definition: ExceptionHelpers.cc:11
ExceptionActions.h
edm::SecondaryEventProvider::beginRun
void beginRun(RunPrincipal &run, const edm::EventSetupImpl &setup, ModuleCallingContext const *, StreamContext &sContext)
Definition: SecondaryEventProvider.cc:75
edm::ExceptionToActionTable
Definition: ExceptionActions.h:16
edm::ServiceRegistry::instance
static ServiceRegistry & instance()
Definition: ServiceRegistry.cc:90
edm::SecondaryEventProvider::workerManager_
WorkerManager workerManager_
Definition: SecondaryEventProvider.h:48
edm::PreallocationConfiguration
Definition: PreallocationConfiguration.h:27
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
T
long double T
Definition: Basic3DVectorLD.h:48
edm::SecondaryEventProvider::SecondaryEventProvider
SecondaryEventProvider(std::vector< ParameterSet > &psets, ProductRegistry &pregistry, std::shared_ptr< ProcessConfiguration > processConfiguration)
Definition: SecondaryEventProvider.cc:50
SecondaryEventProvider.h
edm::SecondaryEventProvider::beginLuminosityBlock
void beginLuminosityBlock(LuminosityBlockPrincipal &lumi, const edm::EventSetupImpl &setup, ModuleCallingContext const *, StreamContext &sContext)
Definition: SecondaryEventProvider.cc:86
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::processOneOccurrenceAsync
void processOneOccurrenceAsync(WaitingTaskHolder, typename T::TransitionInfoType &, ServiceToken const &, StreamID, typename T::Context const *topContext, U const *context)
Definition: WorkerManager.h:105
edm::syncWait
std::exception_ptr syncWait(F &&iFunc)
Definition: include_first_syncWait.h:17
cms::Exception
Definition: Exception.h:70
TransitionInfoTypes.h
ParameterSet.h
edm::RunPrincipal
Definition: RunPrincipal.h:34
lumi
Definition: LumiSectionData.h:20
StreamID.h
edm::WorkerManager
Definition: WorkerManager.h:35
edm::ProductRegistry::setUnscheduledProducts
void setUnscheduledProducts(std::set< std::string > const &unscheduledLabels)
Definition: ProductRegistry.cc:221
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::ModuleCallingContext
Definition: ModuleCallingContext.h:29
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316