CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
UnscheduledCallProducer.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_UnscheduledCallProducer_h
2 #define FWCore_Framework_UnscheduledCallProducer_h
3 
4 // -*- C++ -*-
5 //
6 // Package: FWCore/Framework
7 // Class : UnscheduledCallProducer
8 //
25 
26 #include <vector>
27 #include <unordered_map>
28 #include <string>
29 #include <sstream>
30 
31 namespace edm {
32 
33  class ModuleCallingContext;
34 
36  public:
37 
38  using worker_container = std::vector<Worker*>;
39  using const_iterator = worker_container::const_iterator;
40 
44  }
45  void addWorker(Worker* aWorker) {
46  assert(0 != aWorker);
47  unscheduledWorkers_.push_back(aWorker);
48  }
49 
50  void setEventSetup(EventSetup const& iSetup) {
51  aux_.setEventSetup(&iSetup);
52  }
53 
54  UnscheduledAuxiliary const& auxiliary() const { return aux_; }
55 
56  const_iterator begin() const { return unscheduledWorkers_.begin(); }
57  const_iterator end() const { return unscheduledWorkers_.end(); }
58 
59  template <typename T, typename U>
60  void runNow(typename T::MyPrincipal& p, EventSetup const& es, StreamID streamID,
61  typename T::Context const* topContext, U const* context) const {
62  //do nothing for event since we will run when requested
63  if(!T::isEvent_) {
64  for(auto worker: unscheduledWorkers_) {
65  try {
66  ParentContext parentContext(context);
67  worker->doWork<T>(p, es, streamID, parentContext, topContext);
68  }
69  catch (cms::Exception & ex) {
70  std::ostringstream ost;
71  if (T::isEvent_) {
72  ost << "Calling event method";
73  }
74  else if (T::begin_ && T::branchType_ == InRun) {
75  ost << "Calling beginRun";
76  }
77  else if (T::begin_ && T::branchType_ == InLumi) {
78  ost << "Calling beginLuminosityBlock";
79  }
80  else if (!T::begin_ && T::branchType_ == InLumi) {
81  ost << "Calling endLuminosityBlock";
82  }
83  else if (!T::begin_ && T::branchType_ == InRun) {
84  ost << "Calling endRun";
85  }
86  else {
87  // It should be impossible to get here ...
88  ost << "Calling unknown function";
89  }
90  ost << " for unscheduled module " << worker->description().moduleName()
91  << "/'" << worker->description().moduleLabel() << "'";
92  ex.addContext(ost.str());
93  ost.str("");
94  ost << "Processing " << p.id();
95  ex.addContext(ost.str());
96  throw;
97  }
98  }
99  }
100  }
101 
102  private:
105  };
106 
107 }
108 
109 #endif
110 
PostModuleEventDelayedGet postModuleEventDelayedGetSignal_
PreModuleEventDelayedGet preModuleEventDelayedGetSignal_
UnscheduledCallProducer(ActivityRegistry &iReg)
assert(m_qm.get())
std::vector< Worker * > worker_container
UnscheduledAuxiliary const & auxiliary() const
void addContext(std::string const &context)
Definition: Exception.cc:227
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preModuleDelayedGetSignal_
void setEventSetup(EventSetup const *iSetup)
void runNow(typename T::MyPrincipal &p, EventSetup const &es, StreamID streamID, typename T::Context const *topContext, U const *context) const
void setEventSetup(EventSetup const &iSetup)
worker_container::const_iterator const_iterator
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postModuleDelayedGetSignal_
long double T
void connect(U iFunc)
Definition: Signal.h:63