PtrMakerAnalyzer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: PtrMakerAnalyzer
3 // Plugin Type: analyzer (art v2_05_00)
4 // File: PtrMakerAnalyzer_module.cc
5 //
6 // Generated at Wed Nov 23 21:29:25 2016 by Saba Sehrish using cetskelgen
7 // from cetlib version v1_21_00.
8 ////////////////////////////////////////////////////////////////////////
9 
14 #include "fhiclcpp/ParameterSet.h"
15 
17 public:
19 
20  explicit PtrMakerAnalyzer(fhicl::ParameterSet const & p);
21  // The compiler-generated destructor is fine for non-base
22  // classes without bare pointers or other resource use.
23 
24  // Plugins should not be copied or assigned.
25  PtrMakerAnalyzer(PtrMakerAnalyzer const &) = delete;
27  PtrMakerAnalyzer & operator = (PtrMakerAnalyzer const &) = delete;
29 
30  // Required functions.
31  void analyze(art::Event const & e) override;
32 
33 private:
35  int nvalues;
36 
37 };
38 
39 
41  : EDAnalyzer(p)
42  , fInputLabel(p.get<std::string>("input_label"))
43  , nvalues (p.get<int> ("nvalues"))
44 {}
45 
47 {
48  std::cerr << "PtrMakerAnalyzer is running\n";
50  e.getByLabel(fInputLabel, h);
51  size_t sz = h->size();
52  if( sz != (size_t)nvalues ) {
53  throw cet::exception("SizeMismatch")
54  << "Expected a PtrVector of size " << nvalues
55  << " but the obtained size is " << sz
56  << '\n';
57  }
58 
59  int eid = e.id().event();
60 
61  //now check the values
62  intptrvector_t local(*h);
63  for (int i = 0; i < nvalues; ++i) {
64  assert(*local[i] == eid*i);
65  }
66 }
67 
std::string string
Definition: nybbler.cc:12
STL namespace.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
PtrMakerAnalyzer(fhicl::ParameterSet const &p)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
p
Definition: test.py:223
PtrMakerAnalyzer & operator=(PtrMakerAnalyzer const &)=delete
size_type size() const
Definition: PtrVector.h:302
EventNumber_t event() const
Definition: EventID.h:116
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
EventID id() const
Definition: Event.cc:34
void analyze(art::Event const &e) override
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
art::PtrVector< int > intptrvector_t