CMS 3D CMS Logo

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