All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
StubBuilder.cxx File Reference
#include "StubBuilder.h"
#include "sbncode/TPCReco/VertexStub/StubMergeAlgorithms.h"

Go to the source code of this file.

Functions

bool HitOnTrack (const art::Ptr< recob::Hit > &hit, const art::Ptr< recob::Track > &trk, const std::vector< art::Ptr< recob::Hit >> &trk_hits, const std::vector< const recob::TrackHitMeta * > &trk_thms)
 
int FindPFPInd (const std::vector< art::Ptr< recob::Hit >> &hits, const std::vector< art::Ptr< recob::PFParticle >> &pfps, const std::vector< std::vector< art::Ptr< recob::Hit >>> &pfp_hits)
 
std::vector< art::Ptr
< recob::Hit > > 
CollectHits (const std::vector< art::Ptr< recob::Hit >> &hits, const sbn::VertexHit &vhit, const recob::Hit &vhit_hit, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
 

Function Documentation

std::vector<art::Ptr<recob::Hit> > CollectHits ( const std::vector< art::Ptr< recob::Hit >> &  hits,
const sbn::VertexHit vhit,
const recob::Hit vhit_hit,
const geo::GeometryCore geo,
const detinfo::DetectorPropertiesData dprop 
)

Definition at line 56 of file StubBuilder.cxx.

61  {
62 
63  // project the vertex onto the wireplane
64  float vert_wf = vhit.vtxw;
65  float vert_x = vhit.vtxx;
66 
67  // get the vertex hit-coordinates
68  int hit_w = vhit_hit.WireID().Wire;
69  float hit_x = dprop.ConvertTicksToX(vhit_hit.PeakTime(), vhit_hit.WireID());
70  geo::PlaneID vhit_plane = vhit_hit.WireID();
71 
72  // get the line-segment slope / intercept
73  float slope = (hit_x - vert_x) / (hit_w - vert_wf);
74  float intercept = hit_x - slope * hit_w;
75 
76  // check for "bad" (infinite) slope
77  //
78  // In this case, only hits overlapping with the vertex hit should be
79  // included in the returned list
80  bool badslope = abs(hit_w - vert_wf) < 1e-5;
81  if (badslope) {
82  std::vector<art::Ptr<recob::Hit>> ret;
83  for (art::Ptr<recob::Hit> h: hits) {
84  int this_hit_w = h->WireID().Wire;
85  geo::PlaneID this_hit_plane = h->WireID();
86  if (this_hit_plane == vhit_plane && // check plane
87  this_hit_w == hit_w /* check wire */) {
88  float h_time_lo = h->PeakTime() - h->RMS();
89  float h_time_hi = h->PeakTime() + h->RMS();
90 
91  if (h_time_lo < vhit_hit.PeakTime() && h_time_hi > vhit_hit.PeakTime()) {
92  ret.push_back(h);
93  }
94  }
95  }
96  return ret;
97  }
98 
99  // Include wires one after the hit and one before the vtx
100  int vert_w = (int)((hit_w > vert_wf) ? std::floor(vert_wf) : std::ceil(vert_wf));
101  hit_w = hit_w + ((hit_w > vert_wf) ? 1 : -1);
102 
103  // get all the hits that overlap between these two points
104  std::vector<art::Ptr<recob::Hit>> ret;
105  for (art::Ptr<recob::Hit> h: hits) {
106  int this_hit_w = h->WireID().Wire;
107  geo::PlaneID this_hit_plane = h->WireID();
108  if (this_hit_plane == vhit_plane && // check plane
109  ((this_hit_w <= hit_w && this_hit_w >= vert_w) || // check overlap
110  (this_hit_w >= hit_w && this_hit_w <= vert_w))) {
111  float this_proj_x = slope * this_hit_w + intercept;
112 
113  float h_time_lo = h->PeakTime() - h->RMS();
114  float h_x_A = dprop.ConvertTicksToX(h_time_lo, h->WireID());
115  float h_time_hi = h->PeakTime() + h->RMS();
116  float h_x_B = dprop.ConvertTicksToX(h_time_hi, h->WireID());
117 
118  if ((h_x_A >= this_proj_x && h_x_B <= this_proj_x) ||
119  (h_x_A <= this_proj_x && h_x_B >= this_proj_x)) {
120  ret.push_back(h);
121  }
122  }
123  }
124 
125  return ret;
126 }
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
geo::WireID WireID() const
Definition: Hit.h:233
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
while getopts h
T abs(T value)
float vtxx
X-Position of the vertex associated with this hit as seen by wire-planes. Not space charge corrected...
Definition: VertexHit.h:15
double ConvertTicksToX(double ticks, int p, int t, int c) const
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
do i e
float vtxw
Wire of the vertex associated with this hit. Not space charge corrected. [cm].
Definition: VertexHit.h:14
int FindPFPInd ( const std::vector< art::Ptr< recob::Hit >> &  hits,
const std::vector< art::Ptr< recob::PFParticle >> &  pfps,
const std::vector< std::vector< art::Ptr< recob::Hit >>> &  pfp_hits 
)

Definition at line 25 of file StubBuilder.cxx.

28  {
29 
30  std::vector<unsigned> pfp_nhit(pfps.size(), 0);
31 
32  for (const art::Ptr<recob::Hit> h: hits) {
33  for (unsigned i_pfp = 0; i_pfp < pfps.size(); i_pfp++) {
34  const std::vector<art::Ptr<recob::Hit>> &thispfpHits = pfp_hits[i_pfp];
35  bool found = false;
36  for (const art::Ptr<recob::Hit> &pfp_h: thispfpHits) {
37  if (h == pfp_h) {
38  found = true;
39  pfp_nhit[i_pfp] ++;
40  break;
41  }
42  }
43  if (found) break;
44  }
45  }
46 
47  // Look to see if more than half of the hits on the stub match to a single
48  // PFParticle
49  for (unsigned i_pfp = 0; i_pfp < pfps.size(); i_pfp++) {
50  if (pfp_nhit[i_pfp] >= hits.size() / 2) return i_pfp;
51  }
52 
53  return -1;
54 }
while getopts h
bool HitOnTrack ( const art::Ptr< recob::Hit > &  hit,
const art::Ptr< recob::Track > &  trk,
const std::vector< art::Ptr< recob::Hit >> &  trk_hits,
const std::vector< const recob::TrackHitMeta * > &  trk_thms 
)

Definition at line 5 of file StubBuilder.cxx.

8  {
9 
10  if (!trk) return false; // no track: hit can't be on a track
11 
12  for (unsigned i = 0; i < trk_hits.size(); i++) {
13  // Found the hit on the track!
14  if (hit == trk_hits[i]) {
15  // Is the hit part of the track Calo?
16  if (trk->HasValidPoint(trk_thms[i]->Index())) {
17  return true;
18  }
19  break;
20  }
21  }
22  return false;
23 }
process_name hit
Definition: cheaterreco.fcl:51