Public Member Functions | Private Attributes | List of all members
WireCell::RayGrid::Coordinates Class Reference

#include <RayGrid.h>

Public Member Functions

 Coordinates (const ray_pair_vector_t &rays, int normal_axis=0, double normal_location=0.0)
 
Vector zero_crossing (layer_index_t one, layer_index_t two) const
 
Vector ray_crossing (const coordinate_t &one, const coordinate_t &two) const
 
double pitch_location (const coordinate_t &one, const coordinate_t &two, layer_index_t other) const
 
int pitch_index (double pitch, layer_index_t layer) const
 
int nlayers () const
 
const std::vector< double > & pitch_mags () const
 
const vector_array1d_tpitch_dirs () const
 
const vector_array1d_tcenters () const
 
const vector_array2d_tray_jumps () const
 
const tensor_t a () const
 
const tensor_t b () const
 

Private Attributes

int m_nlayers
 
std::vector< double > m_pitch_mag
 
vector_array1d_t m_pitch_dir
 
vector_array1d_t m_center
 
vector_array2d_t m_zero_crossing
 
vector_array2d_t m_ray_jump
 
tensor_t m_a
 
tensor_t m_b
 

Detailed Description

Definition at line 66 of file RayGrid.h.

Constructor & Destructor Documentation

Coordinates::Coordinates ( const ray_pair_vector_t rays,
int  normal_axis = 0,
double  normal_location = 0.0 
)

Definition at line 7 of file RayGrid.cxx.

9  : m_nlayers(rays.size())
10  , m_pitch_mag(m_nlayers, 0.0)
15  , m_a(boost::extents[m_nlayers][m_nlayers][m_nlayers])
16  , m_b(boost::extents[m_nlayers][m_nlayers][m_nlayers])
17 {
18 
19  // really we are working in 2D space, so project all vectors into the plane.
20  auto project = [&](Vector v) { v[normal_axis]=normal_location; return v; };
21 
22  // must go through 1, 2 and 3 combonations
23 
24  // First, find the per-layer things
25  for (layer_index_t ilayer=0; ilayer<m_nlayers; ++ilayer) {
26  const auto& rpair = rays[ilayer];
27  const auto& r0 = rpair.first;
28  const auto& r1 = rpair.second;
29 
30  // vector of closest approach between the two parallel rays
31  const auto rpitch = ray_pitch(r0, r1);
32 
33  // relative pitch vector
34  auto rpv = project(rpitch.second - rpitch.first);
35 
36  m_pitch_mag[ilayer] = rpv.magnitude();
37  m_pitch_dir[ilayer] = rpv.norm();
38 
39  // center point of ray 0
40  m_center[ilayer] = 0.5*(project(r0.first + r0.second));
41  }
42 
43  // Next find cross-layer things
44  for (layer_index_t il=0; il<m_nlayers; ++il) {
45  for (layer_index_t im=0; im<m_nlayers; ++im) {
46 
47  // ray pairs for layer l and m
48  const auto& rpl = rays[il];
49  const auto& rpm = rays[im];
50 
51  const auto& rl0 = rpl.first;
52  const auto& rl1 = rpl.second;
53  const auto& rm0 = rpm.first;
54  const auto& rm1 = rpm.second;
55 
56  // Iterate only over triangle of indices to avoid extra work.
57  if (il < im) {
58  const auto r00 = ray_pitch(rl0, rm0);
59  const auto& pl0 = r00.first;
60  const auto& pm0 = r00.second;
61 
62  // These really should be the same after projection.
63  m_zero_crossing(il,im) = project(pl0);
64  m_zero_crossing(im,il) = project(pm0);
65 
66  // along l-layer ray 0, crossing of m-layer ray 1.
67  {
68  const auto ray = ray_pitch(rl0, rm1);
69  const auto jump = project(ray.first - pl0);
70  m_ray_jump(il, im) = jump;
71  }
72  // along m-layer ray 0, crossing of l-layer ray 1.
73  {
74  const auto ray = ray_pitch(rm0, rl1);
75  const auto jump = project(ray.first - pm0);
76  m_ray_jump(im, il) = jump;
77  }
78 
79  }
80  if (il == im) {
81  m_zero_crossing(il,im).invalidate();
82  m_ray_jump(il,im).invalidate();
83  }
84  }
85  }
86 
87  // Finally, find triple-layer things (coefficients for
88  // P^{lmn}_{ij}). Needs some of the above completed.
89  for (layer_index_t in=0; in<m_nlayers; ++in) {
90  const auto& pn = m_pitch_dir[in];
91  const double cp = m_center[in].dot(pn);
92 
93  for (layer_index_t il=0; il<m_nlayers; ++il) {
94  if (il == in) { continue; }
95 
96  // triangle iteration
97  for (layer_index_t im=0; im<il; ++im) {
98  if (im == in) { continue; }
99 
100  const double rlmpn = m_zero_crossing(il,im).dot(pn);
101 
102  const double wlmpn = m_ray_jump(il,im).dot(pn);
103  const double wmlpn = m_ray_jump(im,il).dot(pn);
104 
105  m_a[il][im][in] = wlmpn;
106  m_a[im][il][in] = wmlpn;
107  // b is symmetric.
108  m_b[il][im][in] = rlmpn - cp;
109  m_b[im][il][in] = rlmpn - cp;
110 
111  // j*a{lmn} + i*a{mln} + b{lmn}
112  }
113  }
114  }
115 }
vector_array2d_t m_ray_jump
Definition: RayGrid.h:116
vector_array2d_t m_zero_crossing
Definition: RayGrid.h:111
vector_array1d_t m_pitch_dir
Definition: RayGrid.h:104
std::vector< double > m_pitch_mag
Definition: RayGrid.h:101
vector_array1d_t m_center
Definition: RayGrid.h:107
std::vector< float > Vector
Ray ray_pitch(const Ray &ray1, const Ray &ray2)
Definition: Point.cxx:76

Member Function Documentation

const tensor_t WireCell::RayGrid::Coordinates::a ( ) const
inline

Definition at line 93 of file RayGrid.h.

93 { return m_a; }
const tensor_t WireCell::RayGrid::Coordinates::b ( ) const
inline

Definition at line 94 of file RayGrid.h.

94 { return m_b; }
const vector_array1d_t& WireCell::RayGrid::Coordinates::centers ( ) const
inline

Definition at line 89 of file RayGrid.h.

89 { return m_center; }
vector_array1d_t m_center
Definition: RayGrid.h:107
int WireCell::RayGrid::Coordinates::nlayers ( ) const
inline

Definition at line 86 of file RayGrid.h.

86 { return m_nlayers; }
const vector_array1d_t& WireCell::RayGrid::Coordinates::pitch_dirs ( ) const
inline

Definition at line 88 of file RayGrid.h.

88 { return m_pitch_dir; }
vector_array1d_t m_pitch_dir
Definition: RayGrid.h:104
int WireCell::RayGrid::Coordinates::pitch_index ( double  pitch,
layer_index_t  layer 
) const
inline

Definition at line 82 of file RayGrid.h.

82  {
83  return std::floor(pitch/m_pitch_mag[layer]);
84  }
std::vector< double > m_pitch_mag
Definition: RayGrid.h:101
double Coordinates::pitch_location ( const coordinate_t one,
const coordinate_t two,
layer_index_t  other 
) const

Definition at line 133 of file RayGrid.cxx.

134 {
135  const tensor_t::index il=one.layer, im=two.layer, in=other;
136  const tensor_t::index i=one.grid, j=two.grid;
137  return j*m_a[il][im][in] + i*m_a[im][il][in] + m_b[il][im][in];
138 }
const std::vector<double>& WireCell::RayGrid::Coordinates::pitch_mags ( ) const
inline

Definition at line 87 of file RayGrid.h.

87 { return m_pitch_mag; }
std::vector< double > m_pitch_mag
Definition: RayGrid.h:101
Vector Coordinates::ray_crossing ( const coordinate_t one,
const coordinate_t two 
) const

Definition at line 122 of file RayGrid.cxx.

123 {
124  const layer_index_t l = one.layer, m = two.layer;
125  const auto r00 = m_zero_crossing(l,m);
126  const auto& wlm = m_ray_jump(l,m);
127  const auto& wml = m_ray_jump(m,l);
128  const double i = one.grid, j = two.grid;
129  Vector res = r00 + j*wlm + i*wml;
130  return res;
131 }
static const double m
Definition: Units.h:79
vector_array2d_t m_ray_jump
Definition: RayGrid.h:116
vector_array2d_t m_zero_crossing
Definition: RayGrid.h:111
static QStrList * l
Definition: config.cpp:1044
std::vector< float > Vector
const vector_array2d_t& WireCell::RayGrid::Coordinates::ray_jumps ( ) const
inline

Definition at line 91 of file RayGrid.h.

91 { return m_ray_jump; }
vector_array2d_t m_ray_jump
Definition: RayGrid.h:116
Vector Coordinates::zero_crossing ( layer_index_t  one,
layer_index_t  two 
) const

Definition at line 117 of file RayGrid.cxx.

118 {
119  return m_zero_crossing(one, two);
120 }
vector_array2d_t m_zero_crossing
Definition: RayGrid.h:111

Member Data Documentation

tensor_t WireCell::RayGrid::Coordinates::m_a
private

Definition at line 121 of file RayGrid.h.

tensor_t WireCell::RayGrid::Coordinates::m_b
private

Definition at line 121 of file RayGrid.h.

vector_array1d_t WireCell::RayGrid::Coordinates::m_center
private

Definition at line 107 of file RayGrid.h.

int WireCell::RayGrid::Coordinates::m_nlayers
private

Definition at line 98 of file RayGrid.h.

vector_array1d_t WireCell::RayGrid::Coordinates::m_pitch_dir
private

Definition at line 104 of file RayGrid.h.

std::vector<double> WireCell::RayGrid::Coordinates::m_pitch_mag
private

Definition at line 101 of file RayGrid.h.

vector_array2d_t WireCell::RayGrid::Coordinates::m_ray_jump
private

Definition at line 116 of file RayGrid.h.

vector_array2d_t WireCell::RayGrid::Coordinates::m_zero_crossing
private

Definition at line 111 of file RayGrid.h.


The documentation for this class was generated from the following files: