artdaq_demo  v3_04_00
NthEvent_module.cc
1 // Class: NthEvent
3 // Module Type: filter
4 // File: NthEvent_module.cc
5 //
6 // Generated at Tue Jan 6 11:52:08 2015 by John Freeman using artmod
7 // from cetpkgsupport v1_07_01.
9 
10 #include "art/Framework/Core/EDFilter.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 
18 #include "fhiclcpp/ParameterSet.h"
19 #include "messagefacility/MessageLogger/MessageLogger.h"
20 
21 #include <memory>
22 
23 class NthEvent;
24 
28 class NthEvent : public art::EDFilter
29 {
30 public:
35  explicit NthEvent(fhicl::ParameterSet const& p);
36 
37  // The destructor generated by the compiler is fine for classes
38  // without bare pointers or other resource use.
39 
41  NthEvent(NthEvent const&) = delete;
42 
44  NthEvent(NthEvent&&) = delete;
45 
47  NthEvent& operator =(NthEvent const&) = delete;
48 
50  NthEvent& operator =(NthEvent&&) = delete;
51 
57  bool filter(art::Event& e) override;
58 
59 
60 private:
61 
62  uint32_t nth_;
63 };
64 
65 
66 NthEvent::NthEvent(fhicl::ParameterSet const& p)
67  : nth_(p.get<uint32_t>("nth")) {}
68 
69 inline
70 bool NthEvent::filter(art::Event& e)
71 {
72  return e.event() % nth_ == 0 ? true : false;
73 }
74 
75 DEFINE_ART_MODULE(NthEvent)
NthEvent & operator=(NthEvent const &)=delete
Plugins should not be copied or assigned.
An art::EDFilter module that passes one out of N events.
bool filter(art::Event &e) override
Perform the filtering. NthEvent module passes events where event number % nth == 0.
NthEvent(fhicl::ParameterSet const &p)
Construct the NthEvent Filter.