Prescaler_module.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Prescaler_plugin
4 //
5 // ======================================================================
6 
10 #include "fhiclcpp/types/Atom.h"
11 
12 namespace art {
13  class Prescaler;
14 }
15 using namespace fhicl;
16 using art::Prescaler;
17 
18 // ======================================================================
19 
20 class art::Prescaler : public EDFilter {
21 public:
22  struct Config {
23  Atom<int> prescaleFactor{Name("prescaleFactor")};
24  Atom<int> prescaleOffset{Name("prescaleOffset")};
25  };
26 
28  explicit Prescaler(Parameters const&);
29 
30  bool filter(Event&) override;
31 
32 private:
33  int count_{};
34  int const n_; // accept one in n
35  int const
36  offset_; // with offset,
37  // i.e. sequence of events does not have to start at first event
38 
39 }; // Prescaler
40 
41 // ======================================================================
42 
44  : n_{config().prescaleFactor()}, offset_{config().prescaleOffset()}
45 {}
46 
47 bool
49 {
50  return ++count_ % n_ == offset_;
51 }
52 
bool filter(Event &) override
Definition: config.py:1
DEFINE_ART_MODULE(TestTMapFile)
Module that kips a configurable number of events between each that it allows through. Note that this module really skips (N-1) events, it uses a simple modular division as its critera. This module will cut down the data sample to 1/N of its original size.
Prescaler(Parameters const &)
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8