test_paramwires.cxx
Go to the documentation of this file.
4 #include "WireCellUtil/Testing.h"
5 
6 #include "TH1F.h"
7 #include "TArrow.h"
8 #include "TLine.h"
9 
10 #include "MultiPdf.h"
11 
12 #include <boost/range.hpp>
13 
14 #include <iostream>
15 #include <cmath>
16 
17 using namespace WireCell;
18 using namespace WireCell::Test;
19 using namespace std;
20 
21 
22 void test3D(MultiPdf& pdf, bool interactive)
23 {
24  WireParams* params = new WireParams;
25  double pitch = 10.0;
26  auto cfg = params->default_configuration();
27  put(cfg, "pitch_mm.u", pitch);
28  put(cfg, "pitch_mm.v", pitch);
29  put(cfg, "pitch_mm.w", pitch);
30  params->configure(cfg);
31 
32  IWireParameters::pointer iwp(params);
33 
34  WireGenerator wg;
36  bool ok = wg(iwp, wires);
37  Assert(ok);
38  Assert(wires);
39  AssertMsg(wires->size(), "Got no wires");
40 
41  const Ray& bbox = params->bounds();
42 
43 
44  TH1F* frame = pdf.canvas.DrawFrame(bbox.first.z(), bbox.first.y(),
45  bbox.second.z(), bbox.second.y());
46  frame->SetTitle("red=U, blue=V, +X (-drift) direction into page");
47  frame->SetXTitle("Transverse Z direction");
48  frame->SetYTitle("Transverse Y (W) direction");
49 
50  int colors[3] = {2, 4, 1};
51 
52 
53  vector<IWire::pointer> u_wires, v_wires, w_wires;
54  copy_if(wires->begin(), wires->end(), back_inserter(u_wires), select_u_wires);
55  copy_if(wires->begin(), wires->end(), back_inserter(v_wires), select_v_wires);
56  copy_if(wires->begin(), wires->end(), back_inserter(w_wires), select_w_wires);
57  size_t n_wires[3] = {
58  u_wires.size(),
59  v_wires.size(),
60  w_wires.size()
61  };
62 
63  double max_width = 5;
64  for (auto wit = wires->begin(); wit != wires->end(); ++wit) {
65  IWire::pointer wire = *wit;
66  int iplane = wire->planeid().index();
67  int index = wire->index();
68 
69  AssertMsg(n_wires[iplane], "Empty plane");
70  double width = 1.0+ (((index+1)*max_width)/n_wires[iplane]);
71 
72  const Ray ray = wire->ray();
73 
74  TArrow* a_wire = new TArrow(ray.first.z(), ray.first.y(),
75  ray.second.z(), ray.second.y(), 0.01, "|>");
76  a_wire->SetLineColor(colors[iplane]);
77  a_wire->SetLineWidth(width);
78  a_wire->Draw();
79  }
80  pdf();
81 }
82 
83 int main(int argc, char** argv)
84 {
85  MultiPdf pdf(argv[0]);
86  test3D(pdf, argc>1);
87  return 0;
88 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
std::shared_ptr< const IWire > pointer
Definition: IData.h:19
std::shared_ptr< IWireParameters > pointer
Access subclass facet by pointer.
Definition: IComponent.h:33
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
int main(int argc, char **argv)
virtual void configure(const WireCell::Configuration &config)
Definition: WireParams.cxx:44
#define Assert
Definition: Testing.h:7
const double width
void test3D(MultiPdf &pdf, bool interactive)
wire_selector select_u_wires
wire_selector select_w_wires
std::shared_ptr< const IWire::vector > output_pointer
Definition: IFunctionNode.h:40
Definition: Main.h:22
wire_selector select_v_wires
#define AssertMsg
Definition: Testing.h:8
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
Definition: WireParams.cxx:29