IntArrayAnalyzer_module.cc
Go to the documentation of this file.
1 // ======================================================================
2 // Verifies the values of an IntArray instance.
3 // ======================================================================
4 
10 
11 #include <cassert>
12 
13 namespace {
14  constexpr std::size_t sz{4u};
15 }
16 
17 namespace arttest {
18  class IntArrayAnalyzer;
19 }
20 
23 
24 public:
25  struct Config {
27  };
29 
30  explicit IntArrayAnalyzer(Parameters const& p)
31  : art::EDAnalyzer{p}, arrayToken_{consumes<IntArray<sz>>(p().moduleLabel())}
32  {}
33 
34  void
35  analyze(art::Event const& e) override
36  {
37  // Produce reference
38  int const value = e.id().event();
39  std::array<int, sz> ref{{}};
40  auto p = std::make_unique<IntArray<sz>>();
41  for (int k = 0; k != sz; ++k) {
42  ref[k] = value + k;
43  }
44 
45  auto const& prod = *e.getValidHandle(arrayToken_);
46  for (int k = 0; k != sz; ++k) {
47  assert(ref[k] == prod.arr[k]);
48  }
49  }
50 
51 }; // IntArrayAnalyzer
52 
IntArrayAnalyzer(Parameters const &p)
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:480
void analyze(art::Event const &e) override
art::ProductToken< IntArray< sz > > arrayToken_
p
Definition: test.py:228
EventNumber_t event() const
Definition: EventID.h:117
fhicl::Atom< std::string > moduleLabel
EventID id() const
Definition: Event.cc:37