WireParams.cxx
Go to the documentation of this file.
2 
4 #include "WireCellUtil/Persist.h"
5 
6 #include <iostream>
7 
10 
11 using namespace WireCell;
12 using namespace std;
13 
14 
15 //static int n_wireparams = 0;
16 
18 {
19  //++n_wireparams;
20  //cerr << "WireParams(" << n_wireparams << ")" << endl;
21  this->set();
22 }
23 WireParams::~WireParams()
24 {
25  //--n_wireparams;
26  //cerr << "~WireParams(" << n_wireparams << ")" << endl;
27 }
28 
29 Configuration WireParams::default_configuration() const
30 {
31  std::string json = R"(
32 {
33 "center_mm":{"x":0.0, "y":0.0, "z":0.0},
34 "size_mm":{"x":10.0, "y":1000.0, "z":1000.0},
35 "pitch_mm":{"u":3.0, "v":3.0, "w":3.0},
36 "angle_deg":{"u":60.0, "v":-60.0, "w":0.0},
37 "offset_mm":{"u":0.0, "v":0.0, "w":0.0},
38 "plane_mm":{"u":3.0, "v":2.0, "w":1.0}
39 }
40 )";
41  return Persist::loads(json);
42 }
43 
45 {
46  // The local origin about which all else is measured.
47  double cx = get<double>(cfg, "center_mm.x")*units::mm;
48  double cy = get<double>(cfg,"center_mm.y")*units::mm;
49  double cz = get<double>(cfg, "center_mm.z")*units::mm;
50  const Point center(cx,cy,cz);
51 
52  // The full width sizes
53  double dx = get<double>(cfg, "size_mm.x")*units::mm;
54  double dy = get<double>(cfg, "size_mm.y")*units::mm;
55  double dz = get<double>(cfg, "size_mm.z")*units::mm;
56  const Point deltabb(dx,dy,dz);
57  const Point bbmax = center + 0.5*deltabb;
58  const Point bbmin = center - 0.5*deltabb;
59 
60  // The angles of the wires w.r.t. the positive Y axis
61  double angU = get<double>(cfg, "angle_deg.u")*units::degree;
62  double angV = get<double>(cfg, "angle_deg.v")*units::degree;
63  double angW = get<double>(cfg, "angle_deg.w")*units::degree;
64 
65  const Vector wU(0, std::cos(angU), std::sin(angU));
66  const Vector wV(0, std::cos(angV), std::sin(angV));
67  const Vector wW(0, std::cos(angW), std::sin(angW));
68 
69  // The pitch magnitudes.
70  double pitU = get<double>(cfg, "pitch_mm.u")*units::mm;
71  double pitV = get<double>(cfg, "pitch_mm.v")*units::mm;
72  double pitW = get<double>(cfg, "pitch_mm.w")*units::mm;
73 
74  // Pitch vectors
75  const Vector xaxis(1,0,0);
76  const Vector pU = pitU*xaxis.cross(wU);
77  const Vector pV = pitV*xaxis.cross(wV);
78  const Vector pW = pitW*xaxis.cross(wW);
79 
80  // The offset in the pitch direction from the center to a wire
81  double offU = get<double>(cfg, "offset_mm.u")*units::mm;
82  double offV = get<double>(cfg, "offset_mm.v")*units::mm;
83  double offW = get<double>(cfg, "offset_mm.w")*units::mm;
84 
85  Point oU = center + pU.norm() * offU;
86  Point oV = center + pV.norm() * offV;
87  Point oW = center + pW.norm() * offW;
88 
89  // Force X location of plane along the X axis.
90  oU.x(get<double>(cfg, "plane_mm.u")*units::mm);
91  oV.x(get<double>(cfg, "plane_mm.v")*units::mm);
92  oW.x(get<double>(cfg, "plane_mm.w")*units::mm);
93 
94 
95  const Ray bounds(bbmin, bbmax);
96  const Ray U(oU, oU+pU), V(oV, oV+pV), W(oW, oW+pW);
97  this->set(bounds, U, V, W);
98 }
99 
100 void WireParams::set(const Ray& bounds,
101  const Ray& U, const Ray& V, const Ray& W)
102 {
103  // save for posterity
104  m_bounds = bounds;
105  m_pitchU = U;
106  m_pitchV = V;
107  m_pitchW = W;
108 }
109 
110 void WireParams::set(double dx, double dy, double dz,
111  double pitch, double angle)
112 {
113  // The local origin about which all else is measured.
114  const Point center;
115  const Point deltabb(dx,dy,dz);
116  const Point bbmax = center + 0.5*deltabb;
117  const Point bbmin = center - 0.5*deltabb;
118 
119  double angU = +angle;
120  double angV = -angle;
121  //double angW = 0.0;
122 
123  // Wire directions
124  const Vector wU(0, std::cos(angU), std::sin(angU));
125  const Vector wV(0, std::cos(angV), std::sin(angV));
126  const Vector wW(0, 1, 0);
127 
128  const Vector xaxis(1,0,0);
129  const Vector pU = pitch*xaxis.cross(wU);
130  const Vector pV = pitch*xaxis.cross(wV);
131  const Vector pW = pitch*xaxis.cross(wW);
132 
133  // cerr << "pU=" << pU << endl;
134  // cerr << "pV=" << pV << endl;
135  // cerr << "pW=" << pW << endl;
136 
137  const Point oU(0.375*dx, 0.0, 0.0);
138  const Point oV(0.250*dx, 0.0, 0.0);
139  const Point oW(0.125*dx, 0.0, 0.0);
140 
141  const Ray bounds(bbmin, bbmax);
142  const Ray U(oU, oU+pU);
143  const Ray V(oV, oV+pV);
144  const Ray W(oW, oW+pW);
145  this->set(bounds, U, V, W);
146 
147 }
148 
149 const Ray& WireParams::bounds() const { return m_bounds; }
150 const Ray& WireParams::pitchU() const { return m_pitchU; }
151 const Ray& WireParams::pitchV() const { return m_pitchV; }
152 const Ray& WireParams::pitchW() const { return m_pitchW; }
153 
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
std::string string
Definition: nybbler.cc:12
static const double degree
Definition: Units.h:162
STL namespace.
cfg
Definition: dbjson.py:29
def configure(cfg)
Definition: cuda.py:34
D3Vector norm() const
Return a normalized vector in the direction of this vector.
Definition: D3Vector.h:91
WIRECELL_FACTORY(WireParams, WireCell::WireParams, WireCell::IWireParameters, WireCell::IConfigurable) using namespace WireCell
BoundingBox bounds(int x, int y, int w, int h)
Definition: main.cpp:37
static const double mm
Definition: Units.h:73
T x(const T &val)
Definition: D3Vector.h:55
Definition: Main.h:22
def center(depos, point)
Definition: depos.py:117
Json::Value Configuration
Definition: Configuration.h:50
D3Vector cross(const D3Vector &rhs) const
Return the cross product of this vector and the other.
Definition: D3Vector.h:100