All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackHitFilter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: TrackHitFilter
3 // Plugin Type: producer (art v3_02_06)
4 // File: TrackHitFilter_module.cc
5 //
6 // Generated at Wed Feb 19 17:38:21 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 
34 
35 #include <memory>
36 
37 namespace sbn {
38  class TrackHitFilter;
39 }
40 
41 
42 class sbn::TrackHitFilter : public art::EDProducer {
43 public:
44  explicit TrackHitFilter(fhicl::ParameterSet const& p);
45  // The compiler-generated destructor is fine for non-base
46  // classes without bare pointers or other resource use.
47 
48  // Plugins should not be copied or assigned.
49  TrackHitFilter(TrackHitFilter const&) = delete;
50  TrackHitFilter(TrackHitFilter&&) = delete;
51  TrackHitFilter& operator=(TrackHitFilter const&) = delete;
53 
54  // Required functions.
55  void produce(art::Event& e) override;
56 
57 private:
58 
59  art::InputTag fTrackLabel;
61 
62 };
63 
64 sbn::TrackHitFilter::TrackHitFilter(fhicl::ParameterSet const& p)
65  : EDProducer{p},
66  fTrackLabel(p.get<art::InputTag>("TrackLabel", "pandoraTrack")),
67  fPassBadHits(p.get<bool>("PassBadHits", false))
68 {
69  produces<std::vector<recob::Hit>>();
70  produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
71  // produces<art::Assns<recob::Wire, recob::Hit>>();
72 }
73 
75 {
76  // output data products
77  std::unique_ptr<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>> assn(new art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>);
78  std::unique_ptr<std::vector<recob::Hit>> outHits(new std::vector<recob::Hit>);
79  // std::unique_ptr<art::Assns<recob::Wire, recob::Hit>> wireAssn(new art::Assns<recob::Wire, recob::Hit>);
80 
81  art::PtrMaker<recob::Hit> hitPtrMaker{e};
82 
83  // input data
84  art::Handle<std::vector<recob::Track>> track_handle;
85  e.getByLabel(fTrackLabel, track_handle);
86 
87  std::vector<art::Ptr<recob::Track>> tracks;
88  art::fill_ptr_vector(tracks, track_handle);
89 
90  art::FindManyP<recob::Hit, recob::TrackHitMeta> fmHits(tracks, e, fTrackLabel);
91 
92  for (unsigned i = 0; i < tracks.size(); i++) {
93  const recob::Track &track = *tracks[i];
94 
95  // get the input hits
96  const std::vector<art::Ptr<recob::Hit>> &trkHits = fmHits.at(i);
97  const std::vector<const recob::TrackHitMeta*> &trkHitMetas = fmHits.data(i);
98 
99  for (unsigned i_hit = 0; i_hit < trkHits.size(); i_hit++) {
100  const recob::Hit &hit = *trkHits[i_hit];
101  const recob::TrackHitMeta &meta = *trkHitMetas[i_hit];
102 
103  // figure out if bad hit -- copy of what Calorimetry module does
104  bool badhit = (meta.Index() == std::numeric_limits<unsigned int>::max()) ||
105  (!track.HasValidPoint(meta.Index()));
106  if (!badhit || fPassBadHits) {
107  // save to output data
108  outHits->push_back(hit);
109  art::Ptr<recob::Hit> thisHitPtr = hitPtrMaker(outHits->size()-1);
110  // add to the association
111  assn->addSingle(tracks[i], thisHitPtr, meta);
112  // wireAssn->addSingle(hitWires.at(i_hit).at(0), thisHitPtr);
113  }
114  }
115  }
116 
117  e.put(std::move(outHits));
118  e.put(std::move(assn));
119  // e.put(std::move(wireAssn));
120 
121 }
122 
123 DEFINE_ART_MODULE(sbn::TrackHitFilter)
Data product for reconstructed trajectory in space.
ClusterModuleLabel join with tracks
Declaration of signal hit object.
pdgs p
Definition: selectors.fcl:22
bool HasValidPoint(size_t i) const
Class to keep data related to recob::Hit associated with recob::Track.
process_name use argoneut_mc_hitfinder track
Data related to recob::Hit associated with recob::Track.The purpose is to collect several variables t...
Definition: TrackHitMeta.h:43
process_name hit
Definition: cheaterreco.fcl:51
TrackHitFilter(fhicl::ParameterSet const &p)
Access the description of detector geometry.
Collection of exceptions for Geometry system.
Data product for reconstructed trajectory in space.
TrackHitFilter & operator=(TrackHitFilter const &)=delete
Provides recob::Track data product.
void produce(art::Event &e) override
do i e
unsigned int Index() const
Hit index along the track trajectory.
Definition: TrackHitMeta.h:55
Declaration of basic channel signal object.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
Class defining a sparse vector (holes are zeroes)
art framework interface to geometry description
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track: