AssnsAnalyzerFEG_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: AssnsAnalyzerFEG
3 // Plugin Type: analyzer (art v2_05_00)
4 // File: AssnsAnalyzerFEG_module.cc
5 //
6 // Generated at Fri Dec 9 00:12:59 2016 by Saba Sehrish using cetskelgen
7 // from cetlib version v1_21_00.
8 ////////////////////////////////////////////////////////////////////////
9 
20 #include "fhiclcpp/ParameterSet.h"
22 
23 #include <algorithm> // std::copy()
24 #include <iterator> // std::inserter()
25 #include <set>
26 
27 class AssnsAnalyzerFEG;
28 
30 public:
31  typedef std::vector<int> intvec_t;
32  typedef std::vector<std::string> strvec_t;
34 
35  explicit AssnsAnalyzerFEG(fhicl::ParameterSet const& p);
36 
37  // Plugins should not be copied or assigned.
38  AssnsAnalyzerFEG(AssnsAnalyzerFEG const&) = delete;
42 
43 private:
44  void analyze(art::Event const& e) override;
45  void for_each_group_test(art::Event const& e) const;
47 };
48 
50  : EDAnalyzer(p), fInputLabel(p.get<art::InputTag>("input_label"))
51 // More initializers here.
52 {}
53 
54 void
56 {
58 }
59 
60 void
62 {
63  typedef art::Assns<int, std::string> istr_assns;
64  auto const& int_to_str_assns = *e.getValidHandle<istr_assns>(fInputLabel);
65  auto vs = strvec_t{"one", "one-a", "two", "two-a", "three", "three-a"};
66 
67  strvec_t strvec;
68  auto strings = [&strvec](auto strs) {
69  for (auto s = begin(strs); s != end(strs); ++s) {
70  std::cout << *s << std::flush << " \"" << **s << "\"" << std::endl;
71  strvec.push_back(**s);
72  }
73  };
74 
75  art::for_each_group(int_to_str_assns, strings);
76 
77  // strings should be same as vs
78  for (auto k = 0; k < 6; ++k) {
79  if (strvec[k] != vs[k]) {
81  << "String #" << k << " expected to be '" << vs[k] << "', got '"
82  << strvec[k] << "' instead!\n";
83  }
84  }
85 
86 } // for_each_group_test()
87 
std::vector< std::string > strings
void for_each_group_test(art::Event const &e) const
AssnsAnalyzerFEG(fhicl::ParameterSet const &p)
AssnsAnalyzerFEG & operator=(AssnsAnalyzerFEG const &)=delete
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
auto begin(Data< Value > const &data)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:480
std::vector< int > intvec_t
p
Definition: test.py:228
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void for_each_group(art::Assns< A, B, D > const &assns, F func)
Helper functions to access associations in order.
end
Definition: test.py:8
static const double s
Definition: Units.h:99
art::Assns< std::string, int > strintAssns_t
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
void analyze(art::Event const &e) override
std::vector< std::string > strvec_t