LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
Path.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_Path_h
2 #define art_Framework_Core_Path_h
3 
4 /*
5  An object of this type represents one path in a job configuration.
6  It holds the assigned bit position and the list of workers that are
7  an event must pass through when this parh is processed. The workers
8  are held in WorkerInPath wrappers so that per path execution statistics
9  can be kept for each worker.
10 */
11 
18 #include "fhiclcpp/ParameterSet.h"
19 
20 #include <memory>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 
25 // ----------------------------------------------------------------------
26 
27 namespace art {
28  class Path;
29  using PathPtrs = std::vector<std::unique_ptr<Path>>;
30 }
31 
32 class art::Path {
33 public:
35 
36  using WorkersInPath = std::vector<WorkerInPath>;
37  using size_type = WorkersInPath::size_type;
38  using TrigResPtr = cet::exempt_ptr<HLTGlobalStatus>;
39 
40  Path(int bitpos,
41  std::string const& path_name,
42  WorkersInPath&& workers,
43  TrigResPtr pathResults,
44  ActionTable const& actions,
45  ActivityRegistry& reg,
46  bool isEndPath);
47 
48  template <typename T>
49  void process(typename T::MyPrincipal&);
50 
51  int
52  bitPosition() const
53  {
54  return bitpos_;
55  }
56  std::string const&
57  name() const
58  {
59  return name_;
60  }
61 
62  void clearCounters();
63 
64  std::size_t
65  timesRun() const
66  {
67  return timesRun_;
68  }
69  std::size_t
70  timesPassed() const
71  {
72  return timesPassed_;
73  }
74  std::size_t
75  timesFailed() const
76  {
77  return timesFailed_;
78  }
79  std::size_t
80  timesExcept() const
81  {
82  return timesExcept_;
83  }
84  State
85  state() const
86  {
87  return state_;
88  }
89 
90  auto const&
91  workersInPath() const
92  {
93  return workers_;
94  }
95 
96  void findEventModifiers(std::vector<std::string>& foundLabels) const;
97  void findEventObservers(std::vector<std::string>& foundLabels) const;
98 
99 private:
100  void findByModifiesEvent(bool modifies,
101  std::vector<std::string>& foundLabels) const;
102 
103  std::size_t timesRun_{};
104  std::size_t timesPassed_{};
105  std::size_t timesFailed_{};
106  std::size_t timesExcept_{};
108 
109  int bitpos_;
110  std::string name_;
114 
116 
118 
119  // Helper functions
120  // nwrwue = numWorkersRunWithoutUnhandledException (really!)
121  bool handleWorkerFailure(cet::exception const& e, int nwrwue, bool isEvent);
122  void recordUnknownException(int nwrwue, bool isEvent);
123  void recordStatus(int nwrwue, bool isEvent);
124  void updateCounters(bool succeed, bool isEvent);
125 };
126 
127 template <typename T>
128 void
129 art::Path::process(typename T::MyPrincipal& ep)
130 {
131  int nwrwue{-1}; // numWorkersRunWithoutUnhandledException
132  T::prePathSignal(actReg_, name_);
133 
134  if (T::level == Level::Event) {
135  ++timesRun_;
136  }
137  state_ = hlt::Ready;
138 
139  bool should_continue{true};
141 
142  for (auto it = workers_.begin(), end = workers_.end();
143  it != end && should_continue;
144  ++it) {
145  ++nwrwue;
146  try {
147  cpc.activate(nwrwue, it->getWorker()->descPtr());
148  should_continue = it->runWorker<T>(ep, &cpc);
149  }
150  catch (cet::exception& e) {
151  // handleWorkerFailure may throw a new exception.
152  should_continue =
153  handleWorkerFailure(e, nwrwue, T::level == Level::Event);
154  }
155  catch (...) {
156  recordUnknownException(nwrwue, T::level == Level::Event);
157  throw;
158  }
159  }
160  updateCounters(should_continue, T::level == Level::Event);
161  recordStatus(nwrwue, T::level == Level::Event);
162  HLTPathStatus const status(state_, nwrwue);
163  T::postPathSignal(actReg_, name_, status);
164 }
165 
166  // ======================================================================
167 
168 #endif /* art_Framework_Core_Path_h */
169 
170 // Local Variables:
171 // mode: c++
172 // End:
void recordStatus(int nwrwue, bool isEvent)
Definition: Path.cc:79
std::size_t timesExcept() const
Definition: Path.h:80
void recordUnknownException(int nwrwue, bool isEvent)
Definition: Path.cc:68
int bitpos_
Definition: Path.h:109
WorkersInPath::size_type size_type
Definition: Path.h:37
Path(int bitpos, std::string const &path_name, WorkersInPath &&workers, TrigResPtr pathResults, ActionTable const &actions, ActivityRegistry &reg, bool isEndPath)
Definition: Path.cc:15
void findByModifiesEvent(bool modifies, std::vector< std::string > &foundLabels) const
Definition: Path.cc:120
State state() const
Definition: Path.h:85
cet::exempt_ptr< HLTGlobalStatus > TrigResPtr
Definition: Path.h:38
ActionTable const & act_table_
Definition: Path.h:113
std::vector< WorkerInPath > WorkersInPath
Definition: Path.h:36
void findEventObservers(std::vector< std::string > &foundLabels) const
Definition: Path.cc:114
HLTState
status of a trigger path
Definition: HLTenums.h:14
void updateCounters(bool succeed, bool isEvent)
Definition: Path.cc:87
ActivityRegistry & actReg_
Definition: Path.h:112
std::size_t timesExcept_
Definition: Path.h:106
std::size_t timesFailed_
Definition: Path.h:105
not [yet] run
Definition: HLTenums.h:15
void clearCounters()
Definition: Path.cc:101
void process(typename T::MyPrincipal &)
Definition: Path.h:129
std::string name_
Definition: Path.h:110
std::vector< std::unique_ptr< Path >> PathPtrs
Definition: Path.h:29
std::size_t timesRun() const
Definition: Path.h:65
std::size_t timesFailed() const
Definition: Path.h:75
std::string const & name() const
Definition: Path.h:57
bool handleWorkerFailure(cet::exception const &e, int nwrwue, bool isEvent)
Definition: Path.cc:32
std::size_t timesRun_
Definition: Path.h:103
Definition: Path.h:32
TrigResPtr trptr_
Definition: Path.h:111
int bitPosition() const
Definition: Path.h:52
auto const & workersInPath() const
Definition: Path.h:91
HLT enums.
std::size_t timesPassed_
Definition: Path.h:104
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
WorkersInPath workers_
Definition: Path.h:115
std::size_t timesPassed() const
Definition: Path.h:70
bool isEndPath_
Definition: Path.h:117
void findEventModifiers(std::vector< std::string > &foundLabels) const
Definition: Path.cc:108
Float_t e
Definition: plot.C:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
State state_
Definition: Path.h:107