PtrmvAnalyzer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: PtrmvAnalyzer
3 // Module Type: analyzer
4 // File: PtrmvAnalyzer_module.cc
5 //
6 // Generated at Tue May 31 08:01:04 2011 by Chris Green using artmod
7 // from art v0_07_07.
8 ////////////////////////////////////////////////////////////////////////
9 
11 
18 
19 #include "cetlib/map_vector.h"
20 
21 #include <string>
22 
23 namespace arttest {
24  class PtrmvAnalyzer;
25 }
26 
27 namespace {
28  typedef cet::map_vector<std::string> mv_t;
29  typedef typename mv_t::value_type mvp_t;
30 } // namespace
31 
33 public:
34  struct Config {
36  };
38  explicit PtrmvAnalyzer(Parameters const& p);
39 
40 private:
41  void analyze(art::Event const& e) override;
43 };
44 
46  : art::EDAnalyzer{p}, inputLabel_{p().input_label()}
47 {}
48 
49 void
51 {
52  // map_vector retrieval.
55  std::string const* item;
56  item = mv->getOrNull(cet::map_vector_key(0));
57  BOOST_CHECK_EQUAL(*item, "ONE");
58  item = mv->getOrNull(cet::map_vector_key(3));
59  BOOST_CHECK_EQUAL(*item, "TWO");
60  item = mv->getOrNull(cet::map_vector_key(5));
61  BOOST_CHECK_EQUAL(*item, "THREE");
62  item = mv->getOrNull(cet::map_vector_key(7));
63  BOOST_CHECK_EQUAL(*item, "FOUR");
64  item = mv->getOrNull(cet::map_vector_key(9));
65  BOOST_CHECK(item == nullptr); // Not using EQUAL to avoid stream badness.
66 
67  // Ptr<std::string> retrieval.
69  assert(e.getByLabel(inputLabel_, ptr));
70  assert(**ptr == "TWO");
71 
72  // PtrVector<std::string> retrieval.
75  BOOST_CHECK_EQUAL(*(*pv)[0], "THREE");
76  BOOST_CHECK_EQUAL(*(*pv)[1], "ONE");
77  BOOST_CHECK_EQUAL(*(*pv)[2], "FOUR");
78  BOOST_CHECK_EQUAL(*(*pv)[3], "TWO");
79 
80  // Ptr<std::string> retrieval.
83  BOOST_CHECK_EQUAL((*ptr_p)->first, cet::map_vector_key(3));
84  BOOST_CHECK_EQUAL((*ptr_p)->second, "TWO");
85 
86  // PtrVector<std::string> retrieval.
89  BOOST_CHECK_EQUAL((*pvp)[0]->first, cet::map_vector_key(5));
90  BOOST_CHECK_EQUAL((*pvp)[0]->second, "THREE");
91  BOOST_CHECK_EQUAL((*pvp)[1]->first, cet::map_vector_key(0));
92  BOOST_CHECK_EQUAL((*pvp)[1]->second, "ONE");
93  BOOST_CHECK_EQUAL((*pvp)[2]->first, cet::map_vector_key(7));
94  BOOST_CHECK_EQUAL((*pvp)[2]->second, "FOUR");
95  BOOST_CHECK_EQUAL((*pvp)[3]->first, cet::map_vector_key(3));
96  BOOST_CHECK_EQUAL((*pvp)[3]->second, "TWO");
97 }
98 
static const double second
Definition: Units.h:35
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
fhicl::Atom< std::string > input_label
void analyze(art::Event const &e) override
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:435
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
PtrmvAnalyzer(Parameters const &p)
BOOST_REQUIRE(inFile)
p
Definition: test.py:228