All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TransferPFParticleT0_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: TransferPFParticleT0
3 // Plugin Type: producer (art v3_02_06)
4 // File: TransferPFParticleT0_module.cc
5 //
6 // Generated at Wed Feb 19 17:38:15 2020 by Gray Putnam using cetskelgen
7 // from cetlib version v3_07_02.
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 "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
22 
23 #include <memory>
24 
25 namespace sbn {
26  class TransferPFParticleT0;
27 }
28 
29 
30 class sbn::TransferPFParticleT0 : public art::EDProducer {
31 public:
32  explicit TransferPFParticleT0(fhicl::ParameterSet const& p);
33  // The compiler-generated destructor is fine for non-base
34  // classes without bare pointers or other resource use.
35 
36  // Plugins should not be copied or assigned.
41 
42  // Required functions.
43  void produce(art::Event& e) override;
44 
45 private:
46 
47  art::InputTag fPFParticleLabelIn;
48  art::InputTag fT0Label;
49 
50  art::InputTag fPFParticleLabelOut;
51 };
52 
53 
55  : EDProducer{p},
56  fPFParticleLabelIn(p.get<art::InputTag>("PFParticleLabelIn")),
57  fT0Label(p.get<art::InputTag>("T0Label")),
58  fPFParticleLabelOut(p.get<art::InputTag>("PFParticleLabelOut"))
59 {
60  produces<art::Assns<recob::PFParticle, anab::T0>>();
61 }
62 
64 {
65  // define output data
66  std::unique_ptr<art::Assns<recob::PFParticle, anab::T0>> assn(new art::Assns<recob::PFParticle, anab::T0>);
67 
68  // Collect input data
69  art::Handle<std::vector<recob::PFParticle>> inpfp_handle;
70  e.getByLabel(fPFParticleLabelIn, inpfp_handle);
71 
72  std::vector<art::Ptr<recob::PFParticle>> inpfps;
73  art::fill_ptr_vector(inpfps, inpfp_handle);
74 
75  art::FindManyP<anab::T0> fmT0s(inpfps, e, fT0Label);
76 
77  art::Handle<std::vector<recob::PFParticle>> outpfp_handle;
78  e.getByLabel(fPFParticleLabelOut, outpfp_handle);
79 
80  std::vector<art::Ptr<recob::PFParticle>> outpfps;
81  art::fill_ptr_vector(outpfps, outpfp_handle);
82 
83  // process input data
84  for (unsigned i_in = 0; i_in < inpfps.size(); i_in++) {
85  const recob::PFParticle &pfp = *inpfps[i_in];
86  const std::vector<art::Ptr<anab::T0>> &t0s = fmT0s.at(i_in);
87  if (!t0s.size()) continue; // ignore pfps without T0's
88 
89  for (unsigned i_out = 0; i_out < outpfps.size(); i_out++) {
90  const recob::PFParticle &out_pfp = *outpfps[i_out];
91  if (pfp.Self() == out_pfp.Self()) { // The pfps match!
92  // Transfer over the T0 association
93  assn->addMany(outpfps.at(i_out), t0s);
94  break; // done with this input pfp
95  }
96  }
97  }
98 
99  e.put(std::move(assn));
100 }
101 
102 DEFINE_ART_MODULE(sbn::TransferPFParticleT0)
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
TransferPFParticleT0(fhicl::ParameterSet const &p)
pdgs p
Definition: selectors.fcl:22
fT0Label(p.get< art::InputTag >("T0Label",""))
TransferPFParticleT0 & operator=(TransferPFParticleT0 const &)=delete
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
do i e
void produce(art::Event &e) override