LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Schedule.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_Schedule_h
2 #define art_Framework_Core_Schedule_h
3 // vim: set sw=2 expandtab :
4 
5 // ======================================================================
6 // Schedule
7 //
8 // A schedule contains all trigger paths and the end path executor for
9 // a stream of events.
10 //
11 // Processing of an event happens by pushing the event through the
12 // Paths. The scheduler performs the reset() on each of the workers
13 // independent of the Path objects.
14 // ======================================================================
15 
18 #include "art/Framework/Core/fwd.h"
20 
21 #include <atomic>
22 #include <cassert>
23 #include <memory>
24 #include <utility>
25 
26 namespace art {
27  class ActivityRegistry;
28  namespace detail {
29  class SharedResources;
30  }
31 
32  class Schedule {
33  public:
34  Schedule(ScheduleID sid,
35  PathManager& pm,
36  ActionTable const& actions,
37  ActivityRegistry const& aReg,
38  UpdateOutputCallbacks& outputCallbacks,
39  GlobalTaskGroup& task_group);
40 
41  // Disable copy/move operations
42  Schedule(Schedule const&) = delete;
43  Schedule(Schedule&&) = delete;
44  Schedule& operator=(Schedule const&) = delete;
45  Schedule& operator=(Schedule&&) = delete;
46 
47  // API presented to EventProcessor
48  void process(Transition, Principal&);
49  void process_event_modifiers(hep::concurrency::WaitingTaskPtr endPathTask);
50  void process_event_observers(
51  hep::concurrency::WaitingTaskPtr finalizeEventTask);
52  void beginJob(detail::SharedResources const& resources);
53  void endJob();
54  void respondToOpenInputFile(FileBlock const&);
55  void respondToCloseInputFile(FileBlock const&);
56  void respondToOpenOutputFiles(FileBlock const&);
57  void respondToCloseOutputFiles(FileBlock const&);
58 
59  // End-path API
60  bool
61  outputsToOpen() const
62  {
63  return epExec_.outputsToOpen();
64  }
65 
66  bool
68  {
69  return epExec_.outputsToClose();
70  }
71 
72  void
74  {
75  return epExec_.recordOutputClosureRequests(granularity);
76  }
77 
78  bool
80  {
81  return epExec_.someOutputsOpen();
82  }
83 
84  void
86  {
87  epExec_.closeAllOutputFiles();
88  }
89 
90  void
92  {
93  epExec_.openSomeOutputFiles(fb);
94  }
95 
96  void
98  {
99  epExec_.closeSomeOutputFiles();
100  }
101 
102  void
104  {
105  assert(eventPrincipal_);
106  epExec_.writeEvent(*eventPrincipal_);
107  // Delete principal
108  eventPrincipal_.reset();
109  }
110 
111  void
113  {
114  epExec_.incrementInputFileNumber();
115  }
116 
117  void
119  {
120  epExec_.setOutputFileStatus(ofs);
121  }
122 
124  fileStatus() const
125  {
126  return epExec_.fileStatus_.load();
127  }
128 
129  // Run level
130  void
132  {
133  epExec_.seedRunRangeSet(rsh);
134  }
135 
136  void
138  {
139  epExec_.setRunAuxiliaryRangeSetID(rs);
140  }
141 
142  void
144  {
145  epExec_.writeRun(rp);
146  }
147 
148  RangeSetHandler const&
150  {
151  return *epExec_.runRangeSetHandler_.get();
152  }
153 
154  // SubRun level
155  void
157  {
158  epExec_.seedSubRunRangeSet(rsh);
159  }
160  void
162  {
163  epExec_.setSubRunAuxiliaryRangeSetID(rs);
164  }
165  void
167  {
168  epExec_.writeSubRun(srp);
169  }
170 
171  RangeSetHandler const&
173  {
174  return *epExec_.subRunRangeSetHandler_.get();
175  }
176 
177  void
178  accept_principal(std::unique_ptr<EventPrincipal> principal)
179  {
180  assert(principal);
181  eventPrincipal_ = std::move(principal);
182  }
183 
186  {
187  assert(eventPrincipal_);
188  return *eventPrincipal_;
189  }
190 
191  class EndPathRunnerTask;
192 
193  private:
198  std::unique_ptr<EventPrincipal> eventPrincipal_{nullptr};
199  };
200 } // namespace art
201 
202 // Local Variables:
203 // mode: c++
204 // End:
205 
206 #endif /* art_Framework_Core_Schedule_h */
void closeAllOutputFiles()
Definition: Schedule.h:85
void setSubRunAuxiliaryRangeSetID(RangeSet const &rs)
Definition: Schedule.h:161
RangeSetHandler const & runRangeSetHandler()
Definition: Schedule.h:149
EndPathExecutor epExec_
Definition: Schedule.h:196
bool outputsToClose() const
Definition: Schedule.h:67
void seedSubRunRangeSet(RangeSetHandler const &rsh)
Definition: Schedule.h:156
ScheduleContext const context_
Definition: Schedule.h:191
void setRunAuxiliaryRangeSetID(RangeSet const &rs)
Definition: Schedule.h:137
TriggerPathsExecutor tpsExec_
Definition: Schedule.h:197
OutputFileStatus
EventPrincipal & event_principal()
Definition: Schedule.h:185
Transition
Definition: Transition.h:7
void beginJob()
Definition: Breakpoints.cc:14
void writeEvent()
Definition: Schedule.h:103
RangeSetHandler const & subRunRangeSetHandler()
Definition: Schedule.h:172
void recordOutputClosureRequests(Granularity const granularity)
Definition: Schedule.h:73
OutputFileStatus fileStatus() const
Definition: Schedule.h:124
TFile fb("Li6.root")
void incrementInputFileNumber()
Definition: Schedule.h:112
bool outputsToOpen() const
Definition: Schedule.h:61
ActionTable const & actions_
Definition: Schedule.h:195
void closeSomeOutputFiles()
Definition: Schedule.h:97
void accept_principal(std::unique_ptr< EventPrincipal > principal)
Definition: Schedule.h:178
Definition: MVAAlg.h:12
void seedRunRangeSet(RangeSetHandler const &rsh)
Definition: Schedule.h:131
void writeRun(RunPrincipal &rp)
Definition: Schedule.h:143
void openSomeOutputFiles(FileBlock const &fb)
Definition: Schedule.h:91
void writeSubRun(SubRunPrincipal &srp)
Definition: Schedule.h:166
void setOutputFileStatus(OutputFileStatus const ofs)
Definition: Schedule.h:118
bool someOutputsOpen() const
Definition: Schedule.h:79