CMS 3D CMS Logo

WorkerInPath.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_WorkerInPath_h
2 #define FWCore_Framework_WorkerInPath_h
3 
4 /*
5 
6  Author: Jim Kowalkowski 28-01-06
7 
8 
9  A wrapper around a Worker, so that statistics can be managed
10  per path. A Path holds Workers as these things.
11 
12 */
13 
17 
18 namespace edm {
19 
20  class PathContext;
21  class StreamID;
22  class WaitingTask;
23 
24  class WorkerInPath {
25  public:
27 
28  WorkerInPath(Worker*, FilterAction theAction, unsigned int placeInPath);
29 
30  template <typename T>
31  void runWorkerAsync(WaitingTask* iTask,
32  typename T::MyPrincipal const&, EventSetup const&,
33  StreamID streamID,
34  typename T::Context const* context);
35 
36 
37  bool checkResultsOfRunWorker(bool wasEvent);
38 
39  void skipWorker(EventPrincipal const& iPrincipal) {
41  }
42  void skipWorker(RunPrincipal const&) {}
44 
45  void clearCounters() {
47  }
48 
49  int timesVisited() const { return timesVisited_; }
50  int timesPassed() const { return timesPassed_; }
51  int timesFailed() const { return timesFailed_; }
52  int timesExcept() const { return timesExcept_; }
53 
55  Worker* getWorker() const { return worker_; }
56 
58 
59  private:
64 
67 
69  };
70 
71  inline bool WorkerInPath::checkResultsOfRunWorker(bool wasEvent) {
72  if(not wasEvent) {
73  return true;
74  }
75  auto state = worker_->state();
76  bool rc = true;
77  switch (state) {
78  case Worker::Fail:
79  {
80  rc = false;
81  break;
82  }
83  case Worker::Pass:
84  break;
85  case Worker::Exception:
86  {
87  ++timesExcept_;
88  return true;
89  }
90 
91  default:
92  assert(false);
93  }
94 
95  if(Ignore == filterAction()) {
96  rc = true;
97  } else if(Veto == filterAction()) {
98  rc = !rc;
99  }
100 
101  if(rc) {
102  ++timesPassed_;
103  } else {
104  ++timesFailed_;
105  }
106  return rc;
107 
108  }
109 
110  template <typename T>
112  typename T::MyPrincipal const& ep, EventSetup const & es,
113  StreamID streamID,
114  typename T::Context const* context) {
115  if (T::isEvent_) {
116  ++timesVisited_;
117  }
118 
119  if(T::isEvent_) {
120  ParentContext parentContext(&placeInPathContext_);
121  worker_->doWorkAsync<T>(iTask,ep, es,streamID, parentContext, context);
122  } else {
123  ParentContext parentContext(context);
124  worker_->doWorkNoPrefetchingAsync<T>(iTask,ep, es,streamID, parentContext, context);
125  }
126  }
127 }
128 
129 #endif
130 
int timesVisited() const
Definition: WorkerInPath.h:49
void skipOnPath()
Definition: Worker.cc:325
void setPathContext(PathContext const *v)
bool checkResultsOfRunWorker(bool wasEvent)
Definition: WorkerInPath.h:71
int timesExcept() const
Definition: WorkerInPath.h:52
State state() const
Definition: Worker.h:208
void skipWorker(EventPrincipal const &iPrincipal)
Definition: WorkerInPath.h:39
FilterAction filterAction() const
Definition: WorkerInPath.h:54
void setPathContext(PathContext const *v)
Definition: WorkerInPath.h:57
void skipWorker(RunPrincipal const &)
Definition: WorkerInPath.h:42
Worker * getWorker() const
Definition: WorkerInPath.h:55
void doWorkNoPrefetchingAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetup const &c, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:709
FilterAction filterAction_
Definition: WorkerInPath.h:65
void skipWorker(LuminosityBlockPrincipal const &)
Definition: WorkerInPath.h:43
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:68
HLT enums.
int timesFailed() const
Definition: WorkerInPath.h:51
void doWorkAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetup const &c, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:649
WorkerInPath(Worker *, FilterAction theAction, unsigned int placeInPath)
Definition: WorkerInPath.cc:6
void runWorkerAsync(WaitingTask *iTask, typename T::MyPrincipal const &, EventSetup const &, StreamID streamID, typename T::Context const *context)
Definition: WorkerInPath.h:111
int timesPassed() const
Definition: WorkerInPath.h:50
long double T