Functions
test_wireparams3d.cxx File Reference
#include "WireCellGen/WireParams.h"
#include "WireCellUtil/Testing.h"
#include "TView.h"
#include "TPolyLine3D.h"
#include "TPolyMarker3D.h"
#include "TH1F.h"
#include "TArrow.h"
#include "TLine.h"
#include "TAxis.h"
#include "MultiPdf.h"

Go to the source code of this file.

Functions

void draw_wires_3d (WireParams &wp)
 
void draw_wires_2d (WireParams &wp)
 
int main (int argc, char **argv)
 

Function Documentation

void draw_wires_2d ( WireParams wp)

Definition at line 52 of file test_wireparams3d.cxx.

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 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
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
const Ray & pitchU() const
Definition: WireParams.cxx:150
std::vector< float > Vector
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
void draw_wires_3d ( WireParams wp)

Definition at line 22 of file test_wireparams3d.cxx.

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 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
const Ray & pitchW() const
Definition: WireParams.cxx:152
const Ray & pitchV() const
Definition: WireParams.cxx:151
const Ray & pitchU() const
Definition: WireParams.cxx:150
std::vector< float > Vector
Vector ray_vector(const Ray &ray)
Definition: Point.cxx:67
QTextStream & endl(QTextStream &s)
int main ( int  argc,
char **  argv 
)

Definition at line 98 of file test_wireparams3d.cxx.

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
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
const Ray & pitchV() const
Definition: WireParams.cxx:151
const Ray & pitchU() const
Definition: WireParams.cxx:150
void draw_wires_2d(WireParams &wp)
void draw_wires_3d(WireParams &wp)
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
Definition: WireParams.cxx:29
QTextStream & endl(QTextStream &s)