ImplicitRSAssignmentAnalyzer_module.cc
Go to the documentation of this file.
7 
8 #include <string>
9 
10 namespace {
11 
12  struct TagBuilder {
13  TagBuilder(std::string const& label, std::string const& process)
14  : label_{label}, process_{process}
15  {}
16 
18  operator()(std::string const& instance)
19  {
20  return {label_ + ":" + instance + ":" + process_};
21  }
22 
23  std::string label_;
24  std::string process_;
25  };
26 
27  struct Config {
29  fhicl::Name("tagInfo"),
30  fhicl::Comment("First argument is the module label.\n"
31  "Second argument is the process name")};
32  };
33 
34 } // namespace
35 
36 namespace arttest {
37 
39  TagBuilder tagInfo_;
40 
41  public:
42  using Parameters = EDAnalyzer::Table<Config>;
44  : art::EDAnalyzer{config}, tagInfo_{config().tagInfo()}
45  {}
46 
47  void
48  beginRun(art::Run const& r) override
49  {
50  auto const& numH = r.getValidHandle<unsigned>(tagInfo_("bgnRunNum"));
51  auto const& denomH = r.getValidHandle<unsigned>(tagInfo_("bgnRunDenom"));
52  BOOST_CHECK(art::same_ranges(numH, denomH));
53  BOOST_CHECK(numH.provenance()->rangeOfValidity().is_full_run());
54  }
55 
56  void
57  beginSubRun(art::SubRun const& sr) override
58  {
59  auto const& numH = sr.getValidHandle<unsigned>(tagInfo_("bgnSubRunNum"));
60  auto const& denomH =
61  sr.getValidHandle<unsigned>(tagInfo_("bgnSubRunDenom"));
62  BOOST_CHECK(art::same_ranges(numH, denomH));
63  BOOST_CHECK(numH.provenance()->rangeOfValidity().is_full_subRun());
64  }
65 
66  void
67  analyze(art::Event const&) override
68  {}
69 
70  void
71  endSubRun(art::SubRun const& sr) override
72  {
73  auto const& numH = sr.getValidHandle<unsigned>(tagInfo_("endSubRunNum"));
74  auto const& denomH =
75  sr.getValidHandle<unsigned>(tagInfo_("endSubRunDenom"));
76  BOOST_CHECK(art::same_ranges(numH, denomH));
77  BOOST_CHECK(!numH.provenance()->rangeOfValidity().is_full_subRun());
78  }
79 
80  void
81  endRun(art::Run const& r) override
82  {
83  auto const& numH = r.getValidHandle<unsigned>(tagInfo_("endRunNum"));
84  auto const& denomH = r.getValidHandle<unsigned>(tagInfo_("endRunDenom"));
85  BOOST_CHECK(art::same_ranges(numH, denomH));
86  BOOST_CHECK(!numH.provenance()->rangeOfValidity().is_full_run());
87  }
88 
89  }; // ImplicitRSAssignmentAnalyzer
90 
91 } // namespace arttest
92 
std::string string
Definition: nybbler.cc:12
const std::string instance
Definition: Run.h:21
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:480
std::enable_if_t< detail::are_handles< T, U >::value, bool > same_ranges(T const &a, U const &b)
static const double sr
Definition: Units.h:167
AdcRoiViewer::Name Name