DifferentHistoriesAnalyzer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: DifferentHistoriesAnalyzer
3 // Module Type: analyzer
4 // File: DifferentHistoriesAnalyzer_module.cc
5 //
6 // This analyzer specifically tests that for products that originated
7 // from two different processes with different process names, the
8 // presence bits are set appropriately (present/not-present) for
9 // products that were/were not produced in a given process.
10 ////////////////////////////////////////////////////////////////////////
11 
13 
19 #include "fhiclcpp/types/Atom.h"
20 
21 namespace art {
22  namespace test {
23  class DifferentHistoriesAnalyzer;
24  }
25 } // namespace art
26 
28  struct Config {
31  };
32 
33 public:
35  explicit DifferentHistoriesAnalyzer(Parameters const& p);
36 
37 private:
38  void beginSubRun(SubRun const& sr) override;
39  void analyze(Event const& e) override;
40 
41  using ProductTokens_t = std::vector<ProductToken<Ptr<int>>>;
42 
43  template <typename T>
44  void expected_value_in_ptr(T const& t,
45  ProductTokens_t const&,
46  int expected_value);
47 
50 };
51 
53  Parameters const& p)
54  : EDAnalyzer{p}
55 {
56  auto const& input_label = p().input_label();
57  for (auto const& process_name : p().process_names()) {
58  srPtrTokens_.push_back(
59  mayConsume<Ptr<int>, InSubRun>(InputTag{input_label, "", process_name}));
60  ePtrTokens_.push_back(
61  mayConsume<Ptr<int>, InEvent>(InputTag{input_label, "", process_name}));
62  }
63 }
64 
65 template <typename T>
66 void
68  T const& t,
69  ProductTokens_t const& tokens,
70  int const expected_value)
71 {
72  unsigned present{}, not_present{};
73 
74  for (auto const& token : tokens) {
76  if (t.getByToken(token, h)) {
77  ++present;
78  BOOST_REQUIRE_EQUAL(**h, expected_value);
79  } else {
80  ++not_present;
81  }
82  }
83 
84  BOOST_REQUIRE_EQUAL(present, 1u);
85  BOOST_REQUIRE_EQUAL(not_present, 1u);
86 }
87 
88 void
90 {
92 }
93 
94 void
96 {
98 }
99 
void expected_value_in_ptr(T const &t, ProductTokens_t const &, int expected_value)
Definition: test.py:1
ProductToken< T > mayConsume(InputTag const &)
Definition: ModuleBase.h:92
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
p
Definition: test.py:228
std::vector< ProductToken< Ptr< int >>> ProductTokens_t
ProductStatus present()
Definition: ProductStatus.h:16
static const double sr
Definition: Units.h:167
Definition: fwd.h:26
h
training ###############################
Definition: train_cnn.py:186