CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
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) {
81  RunTransitionInfo info(run, setup);
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) {
92  LumiTransitionInfo info(lumi, setup);
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) {
103  RunTransitionInfo info(run, setup);
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) {
114  LumiTransitionInfo info(lumi, setup);
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) {
125  EventTransitionInfo info(ep, setup);
127  }
129  workerManager_.beginStream(iID, sContext);
130  }
131 
133  workerManager_.endStream(iID, sContext);
134  }
135 } // namespace edm
void endStream(edm::StreamID iID, StreamContext &sContext)
static const TGPicture * info(bool iBackgroundIsBlack)
void setupPileUpEvent(EventPrincipal &ep, const EventSetupImpl &setup, StreamContext &sContext)
std::exception_ptr syncWait(F &&iFunc)
void endStream(StreamID iID, StreamContext &streamContext)
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)
void setupOnDemandSystem(EventTransitionInfo const &)
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
processConfiguration
Definition: Schedule.cc:687
static StreamID invalidStreamID()
Definition: StreamID.h:45
void beginJob(ProductRegistry const &iRegistry, eventsetup::ESRecordsToProxyIndices const &, ProcessBlockHelperBase const &)
ServiceToken presentToken() const
void processOneOccurrenceAsync(WaitingTaskHolder, typename T::TransitionInfoType &, ServiceToken const &, StreamID, typename T::Context const *topContext, U const *context)
char const * label
void setUnscheduledProducts(std::set< std::string > const &unscheduledLabels)
def move
Definition: eostools.py:511
std::list< std::string > const & context() const
Definition: Exception.cc:147
void beginRun(RunPrincipal &run, const edm::EventSetupImpl &setup, ModuleCallingContext const *, StreamContext &sContext)
static ServiceRegistry & instance()
void endLuminosityBlock(LuminosityBlockPrincipal &lumi, const edm::EventSetupImpl &setup, ModuleCallingContext const *, StreamContext &sContext)
void beginJob(ProductRegistry const &iRegistry, eventsetup::ESRecordsToProxyIndices const &)
void endRun(RunPrincipal &run, const edm::EventSetupImpl &setup, ModuleCallingContext const *, StreamContext &sContext)
list lumi
Definition: dqmdumpme.py:53
void beginStream(edm::StreamID iID, StreamContext &sContext)
StreamID const & streamID() const
Definition: StreamContext.h:54
void beginStream(StreamID iID, StreamContext &streamContext)
AllWorkers const & allWorkers() const
Definition: WorkerManager.h:85
SecondaryEventProvider(std::vector< ParameterSet > &psets, ProductRegistry &pregistry, std::shared_ptr< ProcessConfiguration > processConfiguration)
void setupResolvers(Principal &principal)
auto wrap(F iFunc) -> decltype(iFunc())
void beginLuminosityBlock(LuminosityBlockPrincipal &lumi, const edm::EventSetupImpl &setup, ModuleCallingContext const *, StreamContext &sContext)
preg
Definition: Schedule.cc:687
long double T