EventCounter_module.cc
Go to the documentation of this file.
1 #include "boost/test/unit_test.hpp"
2 
6 #include "fhiclcpp/types/Atom.h"
7 
8 namespace {
9  class EventCounter : public art::SharedAnalyzer {
10  public:
11  struct Config {
13  fhicl::Name{"expected"},
15  "The 'expected' parameter specifies the number of events that are\n"
16  "expected to be processed, based on the corresponding "
17  "'SelectEvents'\n"
18  "and 'RejectEvents' parameters."}};
19  };
20  using Parameters = Table<Config>;
21  explicit EventCounter(Parameters const& p, art::ProcessingFrame const&)
22  : SharedAnalyzer{p}, expected_{p().expected()}
23  {
24  async<art::InEvent>();
25  }
26 
27  private:
28  void
29  analyze(art::Event const&, art::ProcessingFrame const&) override
30  {
31  ++n_;
32  }
33 
34  void
35  endJob(art::ProcessingFrame const&) override
36  {
37  BOOST_TEST(n_ == expected_);
38  }
39 
40  unsigned const expected_;
41  std::atomic<unsigned> n_{};
42  };
43 }
44 
45 DEFINE_ART_MODULE(EventCounter)
def analyze(root, level, gtrees, gbranches, doprint)
Definition: rootstat.py:69
const char expected[]
Definition: Exception_t.cc:22
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
p
Definition: test.py:223