DropTestAnalyzer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: DropTestAnalyzer
3 // Module Type: analyzer
4 // File: DropTestAnalyzer_module.cc
5 //
6 // Generated at Mon Aug 1 13:28:48 2011 by Chris Green using artmod
7 // from art v0_07_12.
8 ////////////////////////////////////////////////////////////////////////
9 
11 
16 #include "fhiclcpp/types/Atom.h"
17 
18 #include <string>
19 
20 namespace arttest {
21  class DropTestAnalyzer;
22 }
23 
25 public:
26  struct Config {
28  fhicl::Atom<bool> keepString{fhicl::Name("keepString"), false};
29  fhicl::Atom<bool> keepMapVector{fhicl::Name("keepMapVector"), true};
30  };
32  explicit DropTestAnalyzer(Parameters const& p);
33 
34 private:
35  void analyze(art::Event const& e) override;
36 
42 };
43 
45  : art::EDAnalyzer{p}
46  , ptrToken_{consumes<art::Ptr<std::string>>(p().input_label())}
47  , mapToken_{consumes<mv_t>(p().input_label())}
48  , keepString_{p().keepString()}
49  , keepMapVector_{p().keepMapVector()}
50 {}
51 
52 void
54 {
56  BOOST_CHECK_EQUAL((e.getByToken(ptrToken_, sh)), keepString_);
57  BOOST_REQUIRE_EQUAL(sh.isValid(), keepString_);
58  if (keepString_ && keepMapVector_) {
59  BOOST_CHECK_EQUAL(**sh, "TWO");
60  }
61 
62  art::Handle<mv_t> mvth;
63  BOOST_CHECK_EQUAL((e.getByToken(mapToken_, mvth)), keepMapVector_);
64  BOOST_REQUIRE_EQUAL(mvth.isValid(), keepMapVector_);
65 
66  if (!keepMapVector_)
67  return;
68 
69  mv_t const& mapvec = *mvth;
70  BOOST_REQUIRE(mapvec[cet::map_vector_key(7)] == "FOUR");
71  BOOST_REQUIRE(mapvec[cet::map_vector_key(5)] == "THREE");
72  BOOST_REQUIRE(mapvec[cet::map_vector_key(3)] == "TWO");
73  BOOST_REQUIRE(mapvec[cet::map_vector_key(0)] == "ONE");
74 }
75 
fhicl::Atom< std::string > input_label
bool getByToken(ProductToken< PROD > const &, Handle< PROD > &result) const
Definition: DataViewImpl.h:451
art::ProductToken< mv_t > mapToken_
art::ProductToken< art::Ptr< std::string > > ptrToken_
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
bool isValid() const
Definition: Handle.h:190
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
void analyze(art::Event const &e) override
BOOST_REQUIRE(inFile)
p
Definition: test.py:228
DropTestAnalyzer(Parameters const &p)
AdcRoiViewer::Name Name