PtrVectorSimpleAnalyzer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: PtrVectorSimpleAnalyzer
3 // Module Type: analyzer
4 // File: PtrVectorSimpleAnalyzer_module.cc
5 //
6 // Generated at Fri Oct 5 15:02:19 2012 by Chris Green using artmod
7 // from art v1_02_04.
8 ////////////////////////////////////////////////////////////////////////
9 
15 
16 namespace arttest {
17  class PtrVectorSimpleAnalyzer;
18 }
19 
21 public:
22  struct Config {
24  };
26  explicit PtrVectorSimpleAnalyzer(Parameters const& p,
27  art::ProcessingFrame const&);
28 
29 private:
30  void analyze(art::Event const& e, art::ProcessingFrame const&) override;
31 
33 };
34 
36  Parameters const& p,
37  art::ProcessingFrame const&)
38  : art::SharedAnalyzer{p}, input_label_{p().input_label()}
39 {
40  async<art::InEvent>();
41 }
42 
43 void
45  art::ProcessingFrame const&)
46 {
47  using SimplePtrVector = art::PtrVector<arttest::Simple>;
48 
49  auto p = e.getPointerByLabel<SimplePtrVector>(input_label_);
50  assert(p);
51  assert(p->size() > 0);
52  // assert( p->pop_back()); // This fails to compile, because *p is const.
53 
55  bool const status = e.getByLabel(input_label_, h);
56  assert(status);
57 
58  int const event_num = e.id().event();
59  size_t const sz = h->size();
60  size_t i = 0;
61  for (auto const ptr : *h) {
62  assert((unsigned)ptr->key == sz - i + event_num);
63  double const expect = 1.5 * i + 100.0;
64  assert(ptr->value == expect);
65  assert(ptr->dummy() == 16.25);
66  ++i;
67  }
68 }
69 
PROD const * getPointerByLabel(InputTag const &tag) const
Definition: DataViewImpl.h:471
std::string string
Definition: nybbler.cc:12
SharedAnalyzer(fhicl::ParameterSet const &pset)
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
p
Definition: test.py:228
EventNumber_t event() const
Definition: EventID.h:117
PtrVectorSimpleAnalyzer(Parameters const &p, art::ProcessingFrame const &)
void analyze(art::Event const &e, art::ProcessingFrame const &) override
EventID id() const
Definition: Event.cc:37
h
training ###############################
Definition: train_cnn.py:186