LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
BlockingPrescaler_module.cc
Go to the documentation of this file.
1 // BlockingPrescaler.
3 //
4 // Accept m in n events with offset. So, for blockSize (m) = 5,
5 // stepSize (n) = 7 and offset = 4, the filter will accept events 5-9
6 // inclusive, 12-16 inclusive, 19-23 inclusive, etc.
7 //
8 // Note that BlockingPrescaler prescales based on the number of events
9 // seen by this module, *not* the event number as recorded by EventID.
10 //
12 
16 #include "fhiclcpp/types/Atom.h"
17 
18 using namespace fhicl;
19 
20 namespace art {
21  class BlockingPrescaler;
22 }
23 
24 // ======================================================================
25 
27 public:
28  struct Config {
29  Atom<size_t> blockSize{Name("blockSize"), 1};
30  Atom<size_t> stepSize{Name("stepSize")};
31  Atom<size_t> offset{Name("offset"), 0};
32  };
33 
35  explicit BlockingPrescaler(Parameters const&);
36 
37  virtual bool filter(Event&) override;
38 
39 private:
40  size_t count_{};
41  size_t const m_; // accept m in n (sequentially).
42  size_t const n_;
43  size_t const offset_; // First accepted event is 1 + offset.
44 
45 }; // BlockingPrescaler
46 
47 // ======================================================================
48 
50  : m_{config().blockSize()}
51  , n_{config().stepSize()}
52  , offset_{config().offset()}
53 {}
54 
55 bool
57 {
58  bool const result{(count_ >= offset_) && ((count_ - offset_) % n_) < m_};
59  ++count_;
60  return result;
61 }
62 
Framework includes.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
parameter set interface
BlockingPrescaler(Parameters const &)
virtual bool filter(Event &) override
HLT enums.