Pimpos.h
Go to the documentation of this file.
1 #ifndef WIRECELLUTIL_PIMPOS
2 #define WIRECELLUTIL_PIMPOS
3 
4 #include "WireCellUtil/Binning.h"
5 #include "WireCellUtil/Point.h"
6 #include "WireCellUtil/Units.h"
7 
8 namespace WireCell {
9 
10 
11  /** \brief Pitch-Impact-Position.
12 
13  A Pimpos object encapsulates information and methods related
14  to geometry and binning of a plane of parallel and equidistant
15  wires and a further uniform sub division along their pitch
16  directions.
17 
18  A wire region or wire bin is the locus *centered* on a wire
19  and which extends +/- 1/2 pitch from the wire position.
20 
21  An impact region or impact bin is the smaller locus of pitch
22  formed by uniformly splitting a wire region. It is *bound* by
23  two (not centered on one) impact positions.
24 
25  Impact positions are "in phase" with wires" such that there is
26  one impact position coincident with a wire position.
27 
28  For 3D "lab" to "plane" coordinate transformations there is a
29  plane coordinate system which has these three orthogonal axes:
30 
31  axis0) anti nominal drift direction (normal to the wire plane) and
32  axis1) along the wire direction such that,
33  axis2) the pitch direction is the cross product of axis0 X axis1.
34  */
35 
36  class Pimpos {
37  public:
38  /** Create a Pimpos object for a particular plane.
39 
40  \param nwires is the number of wires in the plane.
41 
42  \param minwirepitch is the location in the pitch
43  coordinate of the first (zero index) wire.
44 
45  \param maxwirepitch is the location in the pitch
46  coordinate of the last wire (ie, index=nwires-1).
47 
48  \param wire is a Vector which sets the direction of the
49  wires in the plane. If the underlying wires are not
50  exactly parallel, this should be some representative
51  average wire direction.
52 
53  \param pitch is a Vector which sets the direction and of
54  the pitch of the wires in the plane. The pitch should be
55  such that the cross product, wire (x) pitch, points in the
56  anti-drift direction for the region this plane services.
57  If the underlying wires are not exactly parallel, this
58  pitcvector should be some representative average pitch
59  direction.
60 
61  \param origin is a Point which sets an origin for all
62  transforms. In particular, the projection of this origin
63  point along the drift direction to the plane of wires sets
64  the origin for the pitch coordinate.
65 
66  \param nbins gives the number of of impact bins covering
67  one wire region.
68 
69  The pitch extents and the origin vector must be expressed
70  in the WCT system of (length) units.
71  */
72  Pimpos(int nwires, double minwirepitch, double maxwirepitch,
73  const Vector& wire = Vector(0,1,0),
74  const Vector& pitch = Vector(0,0,1),
75  const Point& origin = Point(0,0,0),
76  int nimpact_bins_per_wire_region=10);
77 
78  /// Trivial accessor
79  int nimpbins_per_wire() const { return m_nimpbins_per_wire; }
80 
81 
82  //// Geometry related:
83 
84  /// Return given 3-point origin for plane pitch.
85  const Point& origin() const { return m_origin; }
86 
87  /// Return an axis of the plan. 0=normal to plane (aka
88  /// anti-drift), 1=wire direction, 2=pitch direction.
89  const Vector& axis(int i) const { return m_axis[i]; }
90 
91 
92  /// Return the vector from the origin to the given point.
93  Vector relative(const Point& pt) const;
94 
95  /// Return the distance from origin to point along the given
96  /// axis. Default is pitch distance.
97  double distance(const Point& pt, int axis=2) const;
98 
99  /// Transform the given point into the Pimpos coordinate
100  /// system.
101  Point transform(const Point& pt) const;
102 
103 
104  //// Binning related:
105 
106  /// Return wire region binning. Each bin is centered on the
107  /// wire. Bin edges extend a distance of 1/2 pitch between
108  /// neighboring wires.
109  const Binning& region_binning() const { return m_regionbins; }
110 
111  /// Return impact position binning. Bin edges are at impact
112  /// positions and are in-phase with wire centers.
113  const Binning& impact_binning() const { return m_impactbins; }
114 
115  /// Return a pair of indices. The first is the index of the
116  /// wire closest to the given pitch. The second is the
117  /// *relative* index of the impact closest impact position
118  /// (index=0 means the impact position coincident with the
119  /// wire).
120  std::pair<int, int> closest(double pitch) const;
121 
122  /// Return the impact position index coincident with the wire index.
123  int wire_impact(int wireind) const;
124 
125  /// Return the impact position indices (bin edges) at either
126  /// extreme of the wire region. The smaller index for this
127  /// wire is the larger index of wireind-1's values and vice
128  /// versa.
129  std::pair<int,int> wire_impacts(int wireind) const;
130 
131  /// Return the impact position index which is the reflection
132  /// of the given impact position index through the given wire
133  /// index.
134  int reflect(int wireind, int impind) const;
135 
136 
137 
138  private:
143  };
144 
145 }
146 
147 
148 #endif
Vector m_axis[3]
Definition: Pimpos.h:141
Point m_origin
Definition: Pimpos.h:140
const int nwires
std::pair< int, int > closest(double pitch) const
Definition: Pimpos.cxx:34
Point transform(const Point &pt) const
Definition: Pimpos.cxx:76
D3Vector< double > Point
A 3D Cartesian point in double precision.
Definition: Point.h:15
const Point & origin() const
Return given 3-point origin for plane pitch.
Definition: Pimpos.h:85
const Binning & region_binning() const
Definition: Pimpos.h:109
double distance(const Point &pt, int axis=2) const
Definition: Pimpos.cxx:71
int reflect(int wireind, int impind) const
Definition: Pimpos.cxx:56
Binning m_impactbins
Definition: Pimpos.h:142
const Binning & impact_binning() const
Definition: Pimpos.h:113
int m_nimpbins_per_wire
Definition: Pimpos.h:139
Pimpos(int nwires, double minwirepitch, double maxwirepitch, const Vector &wire=Vector(0, 1, 0), const Vector &pitch=Vector(0, 0, 1), const Point &origin=Point(0, 0, 0), int nimpact_bins_per_wire_region=10)
Definition: Pimpos.cxx:5
int nimpbins_per_wire() const
Trivial accessor.
Definition: Pimpos.h:79
Point Vector
An alias for Point.
Definition: Point.h:18
Definition: Main.h:22
int wire_impact(int wireind) const
Return the impact position index coincident with the wire index.
Definition: Pimpos.cxx:43
Binning m_regionbins
Definition: Pimpos.h:142
std::pair< int, int > wire_impacts(int wireind) const
Definition: Pimpos.cxx:48
Pitch-Impact-Position.
Definition: Pimpos.h:36
Vector relative(const Point &pt) const
Return the vector from the origin to the given point.
Definition: Pimpos.cxx:66
const Vector & axis(int i) const
Definition: Pimpos.h:89