All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TransferTrackT0_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: TransferTrackT0
3 // Plugin Type: producer (art v3_02_06)
4 // File: TransferTrackT0_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"
23 
24 #include <memory>
25 
26 namespace sbn {
27  class TransferTrackT0;
28 }
29 
30 
31 class sbn::TransferTrackT0 : public art::EDProducer {
32 public:
33  explicit TransferTrackT0(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.
38  TransferTrackT0(TransferTrackT0 const&) = delete;
39  TransferTrackT0(TransferTrackT0&&) = delete;
40  TransferTrackT0& operator=(TransferTrackT0 const&) = delete;
42 
43  // Required functions.
44  void produce(art::Event& e) override;
45 
46 private:
47 
48  art::InputTag fTrackLabelIn;
49  art::InputTag fT0Label;
50 
51  art::InputTag fTrackLabelOut;
52 };
53 
54 
55 sbn::TransferTrackT0::TransferTrackT0(fhicl::ParameterSet const& p)
56  : EDProducer{p},
57  fTrackLabelIn(p.get<art::InputTag>("TrackLabelIn")),
58  fT0Label(p.get<art::InputTag>("T0Label")),
59  fTrackLabelOut(p.get<art::InputTag>("TrackLabelOut"))
60 {
61  produces<art::Assns<recob::Track, anab::T0>>();
62 }
63 
65 {
66  // define output data
67  std::unique_ptr<art::Assns<recob::Track, anab::T0>> assn(new art::Assns<recob::Track, anab::T0>);
68 
69  // Collect input data
70  art::Handle<std::vector<recob::Track>> intrack_handle;
71  e.getByLabel(fTrackLabelIn, intrack_handle);
72 
73  std::vector<art::Ptr<recob::Track>> intracks;
74  art::fill_ptr_vector(intracks, intrack_handle);
75 
76  art::FindManyP<anab::T0> fmT0s(intracks, e, fT0Label);
77  art::FindManyP<recob::PFParticle> fmInParticles(intracks, e, fTrackLabelIn);
78 
79  art::Handle<std::vector<recob::Track>> outtrack_handle;
80  e.getByLabel(fTrackLabelOut, outtrack_handle);
81 
82  std::vector<art::Ptr<recob::Track>> outtracks;
83  art::fill_ptr_vector(outtracks, outtrack_handle);
84 
85  art::FindManyP<recob::PFParticle> fmOutParticles(outtracks, e, fTrackLabelOut);
86 
87  // process input data
88  for (unsigned i_in = 0; i_in < intracks.size(); i_in++) {
89  const recob::PFParticle &pfp = *fmInParticles.at(i_in).at(0);
90  const std::vector<art::Ptr<anab::T0>> &t0s = fmT0s.at(i_in);
91  if (!t0s.size()) continue; // ignore tracks without T0's
92 
93  for (unsigned i_out = 0; i_out < outtracks.size(); i_out++) {
94  const recob::PFParticle &out_pfp = *fmOutParticles.at(i_out).at(0);
95  if (pfp.Self() == out_pfp.Self()) { // The tracks match!
96  // Transfer over the T0 association
97  assn->addMany(outtracks.at(i_out), t0s);
98  break; // done with this input track
99  }
100  }
101  }
102 
103  e.put(std::move(assn));
104 }
105 
106 DEFINE_ART_MODULE(sbn::TransferTrackT0)
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
pdgs p
Definition: selectors.fcl:22
TransferTrackT0 & operator=(TransferTrackT0 const &)=delete
fT0Label(p.get< art::InputTag >("T0Label",""))
TransferTrackT0(fhicl::ParameterSet const &p)
Provides recob::Track data product.
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
do i e
void produce(art::Event &e) override