All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AssnProducer2_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: AssnProducer2
3 // Plugin Type: producer (art v2_05_00)
4 // File: AssnProducer2_module.cc
5 //
6 // Generated at Tue Dec 13 14:04:05 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 "fhiclcpp/ParameterSet.h"
15 #include "art/Persistency/Common/PtrMaker.h"
16 #include "canvas/Persistency/Common/Assns.h"
17 
18 namespace lartest {
19  class AssnProducer2;
20 }
21 
23 
24 class lartest::AssnProducer2 : public art::EDProducer {
25 public:
26  explicit AssnProducer2(fhicl::ParameterSet const & p);
27  // The compiler-generated destructor is fine for non-base
28  // classes without bare pointers or other resource use.
29 
30  // Plugins should not be copied or assigned.
31  AssnProducer2(AssnProducer2 const &) = delete;
32  AssnProducer2(AssnProducer2 &&) = delete;
33  AssnProducer2 & operator = (AssnProducer2 const &) = delete;
35 
36  // Required functions.
37  void produce(art::Event & e) override;
38 
39 private:
40 std::string fInputLabel;
41  // Declare member data here.
42 
43 };
44 
45 
46 AssnProducer2::AssnProducer2(fhicl::ParameterSet const & p)
47  : EDProducer{p}
48  , fInputLabel(p.get<std::string>("input_label"))
49 {
50  produces<art::Assns<int, std::string>>();
51 }
52 
53 void AssnProducer2::produce(art::Event & e)
54 {
55  art::Handle<std::vector<int>> ih;
56  e.getByLabel(fInputLabel, ih);
57  art::Handle<std::vector<std::string>> sh;
58  e.getByLabel(fInputLabel, sh);
59 
60  art::PtrMaker<int> make_intptr(e, ih.id());
61  art::PtrMaker<std::string> make_strptr(e, sh.id());
62 
63  auto assns = std::make_unique<art::Assns<int, std::string>>();
64  for (size_t i=0; i < 3; ++i) {
65  auto p1 = make_intptr(i);
66  for(size_t j=0; j < 2; ++j) {
67  auto p2 = make_strptr(i*2+j);
68  assns -> addSingle(p1, p2);
69  }
70  }
71  e.put(std::move(assns));
72 }
73 
74 DEFINE_ART_MODULE(AssnProducer2)
pdgs p
Definition: selectors.fcl:22
AssnProducer2(fhicl::ParameterSet const &p)
void produce(art::Event &e) override
do i e
physics associatedGroupsWithLeft p1
AssnProducer2 & operator=(AssnProducer2 const &)=delete