TestAnalyzerSelect_module.cc
Go to the documentation of this file.
1 // vim: set sw=2 expandtab :
4 #include "cetlib_except/exception.h"
6 
7 using namespace art;
8 
9 namespace {
10 
11  using namespace fhicl;
12  struct Config {
13  Atom<int> shouldPass{Name("shouldPass")};
14  };
15 
16 } // unnamed namespace
17 
18 namespace arttest {
19 
20  class TestAnalyzerSelect : public EDAnalyzer {
21  public:
23  explicit TestAnalyzerSelect(Parameters const& ps)
24  : EDAnalyzer{ps}, num_pass_{ps().shouldPass()}
25  {}
26 
27  private:
28  void
29  analyze(const Event&) override
30  {
31  ++total_;
32  }
33 
34  void endJob() override;
35 
36  int const num_pass_;
37  int total_{};
38  };
39 
40  void
41  TestAnalyzerSelect::endJob()
42  {
43  mf::LogAbsolute("TestAnalyzerSelectReport")
44  << "TestAnalyzerSelect: should pass " << num_pass_ << ", did pass "
45  << total_ << "\n";
46  if (total_ != num_pass_) {
47  throw cet::exception("TestAnalyzerExceptFailure")
48  << "Number passed should be " << num_pass_ << ", but got " << total_
49  << "\n";
50  }
51  }
52 
53 } // namespace arttest
54 
TestAnalyzerSelect(Parameters const &ps)
static const double ps
Definition: Units.h:103
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
parameter set interface
void analyze(const Event &) override
MaybeLogger_< ELseverityLevel::ELsev_severe, true > LogAbsolute
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
AdcRoiViewer::Name Name