CheckTriggerBits_module.cc
Go to the documentation of this file.
1 #include "boost/test/unit_test.hpp"
2 
7 
8 namespace {
9  class CheckTriggerBits : public art::SharedAnalyzer {
10  public:
11  struct Config {
12  fhicl::Sequence<std::string> ordered_paths{fhicl::Name{"ordered_paths"}};
13  fhicl::Atom<bool> expected_a{fhicl::Name{"expected_a"}};
14  fhicl::Atom<bool> expected_b{fhicl::Name{"expected_b"}};
15  };
16  using Parameters = Table<Config>;
17  explicit CheckTriggerBits(Parameters const& p, art::ProcessingFrame const&);
18 
19  private:
20  void analyze(art::Event const&, art::ProcessingFrame const&) override;
21  std::vector<std::string> const orderedPaths_;
22  bool const expectedA_;
23  bool const expectedB_;
26  };
27 
28  CheckTriggerBits::CheckTriggerBits(Parameters const& p,
29  art::ProcessingFrame const&)
30  : SharedAnalyzer{p}
31  , orderedPaths_{p().ordered_paths()}
32  , expectedA_{p().expected_a()}
33  , expectedB_{p().expected_b()}
34  , token_{consumes<art::TriggerResults>("TriggerResults")}
35  {
36  async<art::InEvent>();
37 
38  auto const& trigger_paths = triggerNames_->getTrigPaths();
39  auto const num_paths = size(trigger_paths);
40  BOOST_TEST(num_paths == size(orderedPaths_));
41 
42  for (std::size_t i{}; i != num_paths; ++i) {
43  BOOST_TEST(trigger_paths[i] == orderedPaths_[i]);
44  }
45  }
46 
47  void
49  {
50  auto const results = triggerNames_->pathResults(e);
51  BOOST_TEST(size(results) == 2ull);
52  BOOST_TEST(results.at("a").accept() == expectedA_);
53  BOOST_TEST(results.at("b").accept() == expectedB_);
54  }
55 }
56 
57 DEFINE_ART_MODULE(CheckTriggerBits)
def analyze(root, level, gtrees, gbranches, doprint)
Definition: rootstat.py:69
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
p
Definition: test.py:223