TestFilter_module.cc
Go to the documentation of this file.
3 
4 #include "fhiclcpp/types/Atom.h"
5 
6 #include <cassert>
7 
8 namespace {
9  using namespace fhicl;
10  struct Config {
11  Atom<unsigned> acceptValue{Name("acceptValue"), 1};
12  Atom<bool> onlyOne{Name("onlyOne"), false};
13  };
14 } // namespace
15 
16 namespace arttest {
17  class TestFilter;
18 }
19 
21 public:
23  explicit TestFilter(Parameters const&);
24 
25 private:
26  bool filter(art::Event& e) override;
27 
28  unsigned count_{};
29  unsigned const acceptRate_; // how many out of 100 will be accepted?
30  bool const onlyOne_;
31 };
32 
33 // -------
34 
35 // -----------------------------------------------------------------
36 
38  : EDFilter{ps}, acceptRate_{ps().acceptValue()}, onlyOne_{ps().onlyOne()}
39 {}
40 
41 bool
43 {
44  ++count_;
45  if (onlyOne_)
46  return count_ % acceptRate_ == 0;
47  else
48  return count_ % 100 <= acceptRate_;
49 }
50 
static const double ps
Definition: Units.h:103
Framework includes.
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
parameter set interface
bool filter(art::Event &e) override
unsigned const acceptRate_
TestFilter(Parameters const &)
AdcRoiViewer::Name Name