ConstAssnsIterAnalyzer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ConstAssnsIterAnalyzer
3 // File: ConstAssnsIterAnalyzer_module.cc
4 //
5 ////////////////////////////////////////////////////////////////////////
6 
16 #include "fhiclcpp/ParameterSet.h"
18 
19 //#include "artdata/Utilities/ForEachAssociatedGroup.h"
21 
23 
24 using namespace art;
25 
27 public:
28  typedef std::vector<int> intvec_t;
29  typedef std::vector<std::string> strvec_t;
30  typedef std::vector<float> floatvec_t;
31 
33  // The compiler-generated destructor is fine for non-base
34  // classes without bare pointers or other resource use.
35 
36  // Plugins should not be copied or assigned.
39  ConstAssnsIterAnalyzer& operator=(ConstAssnsIterAnalyzer const&) = delete;
40  ConstAssnsIterAnalyzer& operator=(ConstAssnsIterAnalyzer&&) = delete;
41 
42  // Required functions.
43  void analyze(art::Event const& e) override;
44 
45 private:
47  void test(art::Event const& e) const;
48 };
49 
51  : EDAnalyzer(p), fInputLabel(p.get<art::InputTag>("input_label"))
52 // More initializers here.
53 {}
54 
55 void
57 {
59 }
60 
61 void
63 {
64  typedef typename art::Assns<int, float, std::string> assns_t;
65  typedef typename art::const_AssnsIter<int, float, std::string> assnsiter_t;
66 
67  // vectors to verify values
68  auto const vi = intvec_t{1, 1, 2, 2, 3, 3};
69  auto const vs = strvec_t{"one", "one-a", "two", "two-a", "three", "three-a"};
70  auto const vf = floatvec_t{1.0, 1.1, 2.0, 2.1, 3.0, 3.1};
71 
72  const assns_t assns{*e.getValidHandle<assns_t>(fInputLabel)};
73  // iterator increment and dereference test
74  auto my_begin = assns.begin();
75  auto my_end = assns.end();
76  assert(my_begin != my_end);
77  int k = 0;
78  for (auto p = my_begin; p != my_end; ++p) {
79  assert(*((*p).data) == vs[k]);
80  assert(*((*p).second.get()) == vf[k]);
81  assert(*((*p).first.get()) == vi[k]);
82  ++k;
83  }
84 }
85 
def analyze(root, level, gtrees, gbranches, doprint)
Definition: rootstat.py:67
ConstAssnsIterAnalyzer(fhicl::ParameterSet const &p)
void analyze(art::Event const &e) override
void test(art::Event const &e) const
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:480
p
Definition: test.py:228
test
Definition: test.py:6
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
std::vector< std::string > strvec_t