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 
5 
11 
12 #include <map>
13 #include <string>
14 #include <sstream>
15 
16 namespace edm {
17 
18  class ModuleCallingContext;
19 
21  public:
23  void addWorker(Worker* aWorker) {
24  assert(0 != aWorker);
25  labelToWorkers_[aWorker->description().moduleLabel()] = aWorker;
26  }
27 
28  template <typename T, typename U>
29  void runNow(typename T::MyPrincipal& p, EventSetup const& es, StreamID streamID,
30  typename T::Context const* topContext, U const* context) {
31  //do nothing for event since we will run when requested
32  if(!T::isEvent_) {
33  for(std::map<std::string, Worker*>::iterator it = labelToWorkers_.begin(), itEnd=labelToWorkers_.end();
34  it != itEnd;
35  ++it) {
36  CPUTimer timer;
37  try {
38  ParentContext parentContext(context);
39  it->second->doWork<T>(p, es, &timer,streamID, parentContext, topContext);
40  }
41  catch (cms::Exception & ex) {
42  std::ostringstream ost;
43  if (T::isEvent_) {
44  ost << "Calling event method";
45  }
46  else if (T::begin_ && T::branchType_ == InRun) {
47  ost << "Calling beginRun";
48  }
49  else if (T::begin_ && T::branchType_ == InLumi) {
50  ost << "Calling beginLuminosityBlock";
51  }
52  else if (!T::begin_ && T::branchType_ == InLumi) {
53  ost << "Calling endLuminosityBlock";
54  }
55  else if (!T::begin_ && T::branchType_ == InRun) {
56  ost << "Calling endRun";
57  }
58  else {
59  // It should be impossible to get here ...
60  ost << "Calling unknown function";
61  }
62  ost << " for unscheduled module " << it->second->description().moduleName()
63  << "/'" << it->second->description().moduleLabel() << "'";
64  ex.addContext(ost.str());
65  ost.str("");
66  ost << "Processing " << p.id();
67  ex.addContext(ost.str());
68  throw;
69  }
70  }
71  }
72  }
73 
74  private:
75  virtual bool tryToFillImpl(std::string const& moduleLabel,
77  EventSetup const& eventSetup,
78  ModuleCallingContext const* mcc) {
79  std::map<std::string, Worker*>::const_iterator itFound =
80  labelToWorkers_.find(moduleLabel);
81  if(itFound != labelToWorkers_.end()) {
82  CPUTimer timer;
83  try {
84  ParentContext parentContext(mcc);
86  eventSetup, &timer,event.streamID(), parentContext, mcc->getStreamContext());
87  }
88  catch (cms::Exception & ex) {
89  std::ostringstream ost;
90  ost << "Calling produce method for unscheduled module "
91  << itFound->second->description().moduleName() << "/'"
92  << itFound->second->description().moduleLabel() << "'";
93  ex.addContext(ost.str());
94  throw;
95  }
96  return true;
97  }
98  return false;
99  }
100  std::map<std::string, Worker*> labelToWorkers_;
101  };
102 
103 }
104 
105 #endif
106 
ModuleDescription const & description() const
Definition: Worker.h:97
StreamContext const * getStreamContext() const
std::string const & moduleLabel() const
void runNow(typename T::MyPrincipal &p, EventSetup const &es, StreamID streamID, typename T::Context const *topContext, U const *context)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void addContext(std::string const &context)
Definition: Exception.cc:227
long double T
std::map< std::string, Worker * > labelToWorkers_
virtual bool tryToFillImpl(std::string const &moduleLabel, EventPrincipal &event, EventSetup const &eventSetup, ModuleCallingContext const *mcc)