LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PathsInfo.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
8 #include "range/v3/view.hpp"
9 
10 #include <atomic>
11 #include <cstddef>
12 #include <map>
13 #include <string>
14 
15 using namespace std;
16 
17 namespace art {
18 
19  PathsInfo::~PathsInfo() = default;
20 
21  map<string, std::shared_ptr<Worker>>&
22  PathsInfo::workers()
23  {
24  return workers_;
25  }
26 
27  map<string, std::shared_ptr<Worker>> const&
28  PathsInfo::workers() const
29  {
30  return workers_;
31  }
32 
33  void
34  PathsInfo::add_path(ActionTable const& actions,
35  ActivityRegistry const& registry,
36  PathContext const& pc,
37  std::vector<WorkerInPath>&& wips,
38  GlobalTaskGroup& task_group)
39  {
40  if (pc.pathName() == PathContext::end_path()) {
41  paths_.emplace_back(
42  actions, registry, pc, std::move(wips), nullptr, task_group);
43  } else {
44  paths_.emplace_back(
45  actions, registry, pc, std::move(wips), &pathResults_, task_group);
46  pathResults_ = HLTGlobalStatus(size(paths_));
47  }
48  TDEBUG_FUNC_SI(5, pc.scheduleID())
49  << "Made path " << std::hex << &paths_.back() << std::dec
50  << " pathID: " << to_string(pc.pathID()) << " name: " << pc.pathName();
51  }
52 
53  vector<Path>&
54  PathsInfo::paths()
55  {
56  return paths_;
57  }
58 
59  vector<Path> const&
60  PathsInfo::paths() const
61  {
62  return paths_;
63  }
64 
65  vector<string>
66  PathsInfo::pathNames() const
67  {
68  vector<string> result;
69  std::transform(begin(paths_),
70  end(paths_),
71  back_inserter(result),
72  [](auto const& path) { return path.name(); });
73  return result;
74  }
75 
76  void
77  PathsInfo::reset()
78  {
79  for (auto const& worker : workers_ | ::ranges::views::values) {
80  worker->reset();
81  }
82  }
83 
84  void
85  PathsInfo::reset_for_event()
86  {
87  reset();
88  pathResults_.reset();
89  }
90 
92  PathsInfo::pathResults()
93  {
94  return pathResults_;
95  }
96 
97  void
98  PathsInfo::incrementTotalEventCount()
99  {
100  ++totalEvents_;
101  }
102 
103  void
104  PathsInfo::incrementPassedEventCount()
105  {
106  ++passedEvents_;
107  }
108 
109  size_t
110  PathsInfo::passedEvents() const
111  {
112  return passedEvents_.load();
113  }
114 
115  size_t
116  PathsInfo::failedEvents() const
117  {
118  // MT: This is fragile!
119  return totalEvents_.load() - passedEvents_.load();
120  }
121 
122  size_t
123  PathsInfo::totalEvents() const
124  {
125  return totalEvents_.load();
126  }
127 
128 } // namespace art
STL namespace.
auto scheduleID() const
Definition: PathContext.h:52
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
auto const & pathName() const
Definition: PathContext.h:63
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
#define TDEBUG_FUNC_SI(LEVEL, SI)
PathID pathID() const noexcept
Definition: PathContext.h:68
Definition: MVAAlg.h:12
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69