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  Run r{rp, mc, RangeSet::forRun(rp.runID())};
75  ProcessingFrame const frame{mc.scheduleID()};
76  bool const rc = beginRunWithFrame(r, frame);
77  r.movePutProductsToPrincipal(rp);
78  return rc;
79  }
80 
81  bool
82  Filter::doEndRun(RunPrincipal& rp, ModuleContext const& mc)
83  {
84  Run r{rp, mc, rp.seenRanges()};
85  ProcessingFrame const frame{mc.scheduleID()};
86  bool const rc = endRunWithFrame(r, frame);
87  r.movePutProductsToPrincipal(rp);
88  return rc;
89  }
90 
91  bool
92  Filter::doBeginSubRun(SubRunPrincipal& srp, ModuleContext const& mc)
93  {
94  SubRun sr{srp, mc, RangeSet::forSubRun(srp.subRunID())};
95  ProcessingFrame const frame{mc.scheduleID()};
96  bool const rc = beginSubRunWithFrame(sr, frame);
97  sr.movePutProductsToPrincipal(srp);
98  return rc;
99  }
100 
101  bool
102  Filter::doEndSubRun(SubRunPrincipal& srp, ModuleContext const& mc)
103  {
104  SubRun sr{srp, mc, srp.seenRanges()};
105  ProcessingFrame const frame{mc.scheduleID()};
106  bool const rc = endSubRunWithFrame(sr, frame);
107  sr.movePutProductsToPrincipal(srp);
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  Event e{ep, mc};
119  ++counts_run;
120  ProcessingFrame const frame{mc.scheduleID()};
121  bool const rc = filterWithFrame(e, frame);
122  e.movePutProductsToPrincipal(
123  ep, checkPutProducts_, &expectedProducts<InEvent>());
124  if (rc) {
125  ++counts_passed;
126  } else {
127  ++counts_failed;
128  }
129  return rc;
130  }
131 
132 } // namespace art::detail
RunID const & runID() const
Definition: Principal.cc:1052
auto scheduleID() const
Definition: ModuleContext.h:28
STL namespace.
Definition: Run.h:17
auto scheduleID() const
const double e
RangeSet seenRanges() const
Definition: Principal.cc:878
SubRunID subRunID() const
Definition: Principal.cc:1058
static constexpr double sr
Definition: Units.h:166