test_wireparams3d.cxx
Go to the documentation of this file.
2 #include "WireCellUtil/Testing.h"
3 
4 
5 // 3d
6 #include "TView.h"
7 #include "TPolyLine3D.h"
8 #include "TPolyMarker3D.h"
9 
10 // 2d
11 #include "TH1F.h"
12 #include "TArrow.h"
13 #include "TLine.h"
14 #include "TAxis.h"
15 
16 #include "MultiPdf.h"
17 
18 using namespace WireCell;
19 using namespace WireCell::Test;
20 using namespace std;
21 
23 {
24  TView* view = TView::CreateView(1);
25  view->SetRange(0, -10, -10, 5, 10, 10);
26  view->ShowAxis();
27 
28  const Ray pitch_rays[3] = { wp.pitchU(), wp.pitchV(), wp.pitchW() };
29  int colors[3] = {2, 4, 1};
30 
31  const Vector xaxis(1,0,0);
32 
33  for (int ind=0; ind<3; ++ind) {
34  const Ray& pitch_ray = pitch_rays[ind];
35  cout << ind << ": " << pitch_ray << endl;
36 
37  const Vector pitch_dir = ray_vector(pitch_ray);
38  const Vector wire_dir = pitch_dir.cross(xaxis).norm();
39  const Vector wire_point = pitch_ray.second + wire_dir;
40 
41  TPolyLine3D* pl = new TPolyLine3D(3);
42  pl->SetPoint(0, pitch_ray.first.x(), pitch_ray.first.y(), pitch_ray.first.z());
43  pl->SetPoint(1, pitch_ray.second.x(), pitch_ray.second.y(), pitch_ray.second.z());
44  pl->SetPoint(2, wire_point.x(), wire_point.y(), wire_point.z());
45  pl->SetLineColor(colors[ind]);
46  pl->Draw();
47  }
48 
49 }
50 
51 
53 {
54  TH1F* frame = gPad->DrawFrame(0,-10, 20,10);
55  frame->SetTitle("Pitch (thick) and wire (thin) red=U, blue=V, +X (-drift) direction into page");
56  frame->SetXTitle("Transverse Z direction");
57  frame->SetYTitle("Transverse Y (W) direction");
58 
59  frame->GetYaxis()->SetAxisColor(3);
60  frame->GetXaxis()->SetAxisColor(4);
61 
62  int colors[3] = {2, 4, 1};
63 
64  const Vector xaxis(1,0,0);
65  const Ray pitch_rays[3] = { wp.pitchU(), wp.pitchV(), wp.pitchW() };
66 
67  for (int ind=0; ind<3; ++ind) {
68  Ray r_pitch = pitch_rays[ind];
69  r_pitch.first.x(0.0);
70  r_pitch.second.x(0.0);
71 
72 
73  const Vector d_pitch = ray_vector(r_pitch).norm();
74  const Vector d_wire = d_pitch.cross(xaxis).norm();
75  const Ray r_wire(r_pitch.second - d_wire,
76  r_pitch.second + d_wire);
77  // cout << ind
78  // << ": d_pitch=" << d_pitch
79  // << " d_wire=" << d_wire
80  // << " r_wire=" << r_wire
81  // << endl;
82 
83  TArrow* a_pitch = new TArrow(r_pitch.first.z(), r_pitch.first.y(),
84  r_pitch.second.z(), r_pitch.second.y(), 0.01, "|>");
85  a_pitch->SetLineColor(colors[ind]);
86  a_pitch->SetLineWidth(2);
87 
88  TArrow* a_wire = new TArrow(r_wire.first.z(), r_wire.first.y(),
89  r_wire.second.z(), r_wire.second.y(), 0.01);
90  a_wire->SetLineColor(colors[ind]);
91 
92  a_pitch->Draw();
93  a_wire->Draw();
94  }
95 
96 }
97 
98 int main(int argc, char** argv)
99 {
100  MultiPdf pdf(argv[0]);
101 
102  WireParams wp;
103 
104  const Ray& bbox = wp.bounds();
105 
106  cout << "Bounds: " << bbox << endl;
107 
108  cerr << "pU=" << wp.pitchU() << endl;
109  cerr << "pV=" << wp.pitchV() << endl;
110  cerr << "pW=" << wp.pitchW() << endl;
111 
112 
113 
114  pdf.canvas.Divide(2,2);
115 
116  pdf.canvas.cd(1);
117  draw_wires_3d(wp);
118  pdf.canvas.cd(2);
119  draw_wires_2d(wp);
120 
121  double pitch = 10.0;
122  WireParams params;
123  auto cfg = params.default_configuration();
124  put(cfg, "pitch_mm.u", pitch);
125  put(cfg, "pitch_mm.v", pitch);
126  put(cfg, "pitch_mm.w", pitch);
127  params.configure(cfg);
128 
129  pdf.canvas.cd(3);
130  draw_wires_3d(wp);
131  pdf.canvas.cd(4);
132  draw_wires_2d(wp);
133 
134  pdf();
135 
136  return 0;
137 
138 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
const Ray & bounds() const
Definition: WireParams.cxx:149
STL namespace.
void put(Configuration &cfg, const std::string &dotpath, const T &val)
Put value in configuration at the dotted path.
cfg
Definition: dbjson.py:29
virtual void configure(const WireCell::Configuration &config)
Definition: WireParams.cxx:44
const Ray & pitchW() const
Definition: WireParams.cxx:152
D3Vector norm() const
Return a normalized vector in the direction of this vector.
Definition: D3Vector.h:91
const Ray & pitchV() const
Definition: WireParams.cxx:151
int main(int argc, char **argv)
const Ray & pitchU() const
Definition: WireParams.cxx:150
Definition: Main.h:22
std::vector< float > Vector
void draw_wires_2d(WireParams &wp)
void draw_wires_3d(WireParams &wp)
D3Vector cross(const D3Vector &rhs) const
Return the cross product of this vector and the other.
Definition: D3Vector.h:100
Vector ray_vector(const Ray &ray)
Definition: Point.cxx:67
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
Definition: WireParams.cxx:29
QTextStream & endl(QTextStream &s)