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>;
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_;
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)
std::size_t timesExcept() const
Definition: Path.h:80
void recordUnknownException(int nwrwue, bool isEvent)
int bitpos_
Definition: Path.h:109
int status
Definition: fabricate.py:1613
set< int >::iterator it
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)
void findByModifiesEvent(bool modifies, std::vector< std::string > &foundLabels) const
State state() const
Definition: Path.h:85
ActionTable const & act_table_
Definition: Path.h:113
std::vector< WorkerInPath > WorkersInPath
Definition: Path.h:36
void findEventObservers(std::vector< std::string > &foundLabels) const
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
HLTState
status of a trigger path
Definition: HLTenums.h:14
void updateCounters(bool succeed, bool isEvent)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Definition: typedefs.hpp:11
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()
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
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string const & name() const
Definition: Path.h:57
bool handleWorkerFailure(cet::exception const &e, int nwrwue, bool isEvent)
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
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
std::size_t timesPassed_
Definition: Path.h:104
WorkersInPath workers_
Definition: Path.h:115
double T
Definition: Xdiff_gwt.C:5
std::size_t timesPassed() const
Definition: Path.h:70
bool isEndPath_
Definition: Path.h:117
void findEventModifiers(std::vector< std::string > &foundLabels) const
Float_t e
Definition: plot.C:35
State state_
Definition: Path.h:107