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