All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PtrMakerProducer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: PtrMakerProducer
3 // Plugin Type: producer (art v2_05_00)
4 // File: PtrMakerProducer_module.cc
5 //
6 // Generated at Tue Nov 22 22:44:53 2016 by Saba Sehrish using cetskelgen
7 // from cetlib version v1_21_00.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "canvas/Persistency/Common/Ptr.h"
15 #include "canvas/Persistency/Common/PtrVector.h"
16 #include "fhiclcpp/ParameterSet.h"
17 
18 #include "art/Persistency/Common/PtrMaker.h"
19 
20 #include <iostream>
21 #include <memory>
22 
23 namespace lartest {
24  class PtrMakerProducer;
25 }
26 
28 
29 class lartest::PtrMakerProducer : public art::EDProducer {
30 public:
31  typedef std::vector<int> intvector_t;
32  typedef art::PtrVector<int> intPtrvector_t;
33 
34  explicit PtrMakerProducer(fhicl::ParameterSet const & p);
35 
36  // The compiler-generated destructor is fine for non-base
37  // classes without bare pointers or other resource use.
38 
39  // Plugins should not be copied or assigned.
40  PtrMakerProducer(PtrMakerProducer const &) = delete;
42  PtrMakerProducer & operator = (PtrMakerProducer const &) = delete;
44 
45  // Required functions.
46  void produce(art::Event & e) override;
47 
48 private:
49 
50  // Declare member data here.
51  std::string fInputLabel;
52 
53 };
54 
55 
56 PtrMakerProducer::PtrMakerProducer(fhicl::ParameterSet const & p)
57  : EDProducer{p}, fInputLabel( p.get<std::string>("input_label") )
58  {
59  produces<intPtrvector_t>();
60  }
61 
62 void PtrMakerProducer::produce(art::Event & e)
63 {
64  std::cerr << "PtrMakerProducer::produce is running!\n";
65  art::Handle<std::vector<int>> h;
66  e.getByLabel(fInputLabel, h);
67  art::PtrMaker<int> make_intptr(e, h.id());
68  auto intptrs = std::make_unique<intPtrvector_t>();
69  for ( size_t i = 0; i < h->size(); ++i ) {
70  auto p = make_intptr(i);
71  intptrs->push_back(p);
72  }
73  e.put(std::move(intptrs));
74 }
75 
76 DEFINE_ART_MODULE(PtrMakerProducer)
BEGIN_PROLOG could also be cerr
pdgs p
Definition: selectors.fcl:22
PtrMakerProducer & operator=(PtrMakerProducer const &)=delete
while getopts h
art::PtrVector< int > intPtrvector_t
void produce(art::Event &e) override
do i e
PtrMakerProducer(fhicl::ParameterSet const &p)