Functions
test_paramwires.cxx File Reference
#include "WireCellIface/IWireSelectors.h"
#include "WireCellGen/WireGenerator.h"
#include "WireCellGen/WireParams.h"
#include "WireCellUtil/Testing.h"
#include "TH1F.h"
#include "TArrow.h"
#include "TLine.h"
#include "MultiPdf.h"
#include <boost/range.hpp>
#include <iostream>
#include <cmath>

Go to the source code of this file.

Functions

void test3D (MultiPdf &pdf, bool interactive)
 
int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 83 of file test_paramwires.cxx.

84 {
85  MultiPdf pdf(argv[0]);
86  test3D(pdf, argc>1);
87  return 0;
88 }
void test3D(MultiPdf &pdf, bool interactive)
void test3D ( MultiPdf pdf,
bool  interactive 
)

Definition at line 22 of file test_paramwires.cxx.

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;
35  WireGenerator::output_pointer wires;
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 }
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
#define Assert
Definition: Testing.h:7
const double width
wire_selector select_u_wires
wire_selector select_w_wires
wire_selector select_v_wires
#define AssertMsg
Definition: Testing.h:8
const GenericPointer< typename T::ValueType > & pointer
Definition: pointer.h:1124
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
Definition: WireParams.cxx:29