All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stub.cxx
Go to the documentation of this file.
2 
3 int sbn::Stub::PlaneIndex(const geo::PlaneID &p) const {
4  for (unsigned i_p = 0; i_p < plane.size(); i_p++) {
5  if (plane[i_p] == p) return i_p;
6  }
7 
8  return -1;
9 }
10 
11 float sbn::Stub::CoreCharge(const geo::PlaneID &p) const {
12  int plane_index = PlaneIndex(p);
13  if (plane_index < 0) return 0.;
14 
15  return CoreCharge(plane_index);
16 }
17 
18 int sbn::Stub::CoreNHit(const geo::PlaneID &p) const {
19  int plane_index = PlaneIndex(p);
20  if (plane_index < 0) return 0;
21 
22  return CoreNHit(plane_index);
23 }
24 
25 float sbn::Stub::CoreCharge(unsigned plane_index) const {
26  if (plane_index >= plane.size()) return -1;
27  float ret = 0.;
28 
29  int stubdir = vtx_w[plane_index] <= hit_w[plane_index] ? 1 : -1;
30  for (const sbn::StubHit &h: hits[plane_index]) {
31  bool before_vtx = ((h.wire - vtx_w[plane_index]) * stubdir) < 0;
32  bool after_hit = ((h.wire - hit_w[plane_index]) * stubdir) > 0;
33  if (!before_vtx && !after_hit) {
34  ret += h.charge;
35  }
36  }
37 
38  return ret;
39 }
40 
41 int sbn::Stub::CoreNHit(unsigned plane_index) const {
42  if (plane_index >= plane.size()) return -1;
43  int ret = 0;
44 
45  int stubdir = vtx_w[plane_index] <= hit_w[plane_index] ? 1 : -1;
46  for (const sbn::StubHit &h: hits[plane_index]) {
47  bool before_vtx = ((h.wire - vtx_w[plane_index]) * stubdir) < 0;
48  bool after_hit = ((h.wire - hit_w[plane_index]) * stubdir) > 0;
49  if (!before_vtx && !after_hit) {
50  ret ++;
51  }
52  }
53 
54  return ret;
55 }
56 
57 bool sbn::Stub::OnCore(const geo::WireID &w) const {
58  int plane_index = PlaneIndex(w);
59  if (plane_index < 0) return -1;
60 
61  int stubdir = vtx_w[plane_index] <= hit_w[plane_index] ? 1 : -1;
62  bool before_vtx = (((int)w.Wire - vtx_w[plane_index]) * stubdir) < 0;
63  bool after_hit = (((int)w.Wire - hit_w[plane_index]) * stubdir) > 0;
64 
65  return !before_vtx && !after_hit;
66 }
std::vector< geo::PlaneID > plane
The plane ID.
Definition: Stub.h:25
pdgs p
Definition: selectors.fcl:22
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
bool OnCore(const geo::WireID &w) const
Returns whether the input wire-ID is on the core of the stub.
Definition: Stub.cxx:57
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
float CoreCharge(unsigned plane_index=0) const
Helper functions.
Definition: Stub.cxx:25
while getopts h
int PlaneIndex(const geo::PlaneID &p) const
Definition: Stub.cxx:3
int CoreNHit(unsigned plane_index=0) const
Returns the number of hits along the core of the stub on the given plane index.
Definition: Stub.cxx:41