LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Producer.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
12 
13 namespace art::detail {
14 
15  Producer::~Producer() noexcept = default;
16 
17  Producer::Producer(fhicl::ParameterSet const& pset)
18  : checkPutProducts_{pset.get<bool>("errorOnFailureToPut", true)}
19  {}
20 
21  void
23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
28 
29  void
31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
35 
36  void
38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
42 
43  void
45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
49 
50  void
52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
56 
57  void
59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
63 
64  bool
66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
73 
74  bool
76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
83 
84  bool
86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
93 
94  bool
96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
103 
104  bool
106  ModuleContext const& mc,
107  std::atomic<size_t>& counts_run,
108  std::atomic<size_t>& counts_passed,
109  std::atomic<size_t>& /*counts_failed*/)
110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
119 
120 } // namespace art::detail
TRandom r
Definition: spectrum.C:23
void doBeginJob(SharedResources const &resources)
Definition: Producer.cc:22
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
void doRespondToOpenInputFile(FileBlock const &fb)
Definition: Producer.cc:37
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
Event makeEvent(ModuleContext const &mc)
void doRespondToOpenOutputFiles(FileBlock const &fb)
Definition: Producer.cc:51
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
auto scheduleID() const
Definition: ModuleContext.h:28
bool doBeginRun(RunPrincipal &rp, ModuleContext const &mc)
Definition: Producer.cc:65
virtual void endJobWithFrame(ProcessingFrame const &)=0
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
void doRespondToCloseOutputFiles(FileBlock const &fb)
Definition: Producer.cc:58
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
bool const checkPutProducts_
Definition: Producer.h:70
RangeSet seenRanges() const
Definition: Principal.cc:701
bool doEndSubRun(SubRunPrincipal &srp, ModuleContext const &mc)
Definition: Producer.cc:95
Run makeRun(ModuleContext const &mc, RangeSet const &rs=RangeSet::invalid())
Definition: RunPrincipal.cc:24
parameter set interface
void doRespondToCloseInputFile(FileBlock const &fb)
Definition: Producer.cc:44
bool doEndRun(RunPrincipal &rp, ModuleContext const &mc)
Definition: Producer.cc:75
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
bool doBeginSubRun(SubRunPrincipal &srp, ModuleContext const &mc)
Definition: Producer.cc:85
TFile fb("Li6.root")
bool doEvent(EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
Definition: Producer.cc:105
virtual void setupQueues(SharedResources const &)=0
SubRun makeSubRun(ModuleContext const &mc, RangeSet const &rs=RangeSet::invalid())
virtual void beginJobWithFrame(ProcessingFrame const &)=0
virtual ~Producer() noexcept
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
SubRunID subRunID() const
RunID runID() const
Definition: RunPrincipal.cc:54