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