Functions
test_paramwires3d.cxx File Reference
#include "WireCellIface/IWireSelectors.h"
#include "WireCellGen/WireGenerator.h"
#include "WireCellGen/WireParams.h"
#include "WireCellUtil/Testing.h"
#include "WireCellUtil/Persist.h"
#include "TView.h"
#include "TPolyLine3D.h"
#include "TPolyMarker3D.h"
#include "MultiPdf.h"
#include <boost/range.hpp>
#include <iostream>
#include <cmath>

Go to the source code of this file.

Functions

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

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 130 of file test_paramwires3d.cxx.

131 {
132  MultiPdf pdf(argv[0]);
133  test1();
134  test2();
135  test3D(pdf,argc>1);
136 
137 
138  return 0;
139 }
void test3D(MultiPdf &pdf, bool interactive)
void test1()
void test2()
void test1 ( )

Definition at line 21 of file test_paramwires3d.cxx.

22 {
23  WireParams *params = new WireParams;
24  IWireParameters::pointer iwp(params);
25 
26  WireGenerator wg;
27  IWire::shared_vector wires;
28  bool ok = wg(iwp, wires);
29  Assert(ok);
30  Assert(wires);
31 
32  cerr << "Got " << wires->size() << " wires" <<endl;
33  Assert(wires->size());
34  int last_plane = -1;
35  int last_index = -1;
36  for (auto wit = wires->begin(); wit != wires->end(); ++wit) {
37  IWire::pointer wire = *wit;
38  int iplane = wire->planeid().index();
39  int ident = (1+iplane)*100000 + wire->index();
40  Assert(ident == wire->ident());
41 
42  if (iplane == last_plane) {
43  ++last_index;
44  }
45  else {
46  last_plane = iplane;
47  last_index = 0;
48  }
49  Assert(last_index == wire->index());
50 
51  }
52 }
#define Assert
Definition: Testing.h:7
const GenericPointer< typename T::ValueType > & pointer
Definition: pointer.h:1124
QTextStream & endl(QTextStream &s)
void test2 ( )

Definition at line 54 of file test_paramwires3d.cxx.

55 {
56  double pitches[] = {10.0, 5.0, 3.0, -1};
57  int want[] = {371, 747, 1243, 0};
58  for (int ind=0; pitches[ind] > 0.0; ++ind) {
59  WireParams *params = new WireParams;
61  put(cfg, "pitch_mm.u", pitches[ind]);
62  put(cfg, "pitch_mm.v", pitches[ind]);
63  put(cfg, "pitch_mm.w", pitches[ind]);
64  params->configure(cfg);
65  IWireParameters::pointer iwp(params);
66  WireGenerator wg;
67  IWire::shared_vector wires;
68  bool ok = wg(iwp, wires);
69  Assert(ok);
70  Assert(wires);
71 
72  int nwires = wires->size();
73  cout << ind << ": pitch=" << pitches[ind] << " nwires=" << nwires << " (want=" << want[ind] << ")" << endl;
74  AssertMsg(nwires == want[ind], "Wrong number of wires");
75  AssertMsg(Persist::dumps(cfg).size(), "Failed to dump cfg");
76  }
77 }
const int nwires
def dumps(spectra, indent=4)
Definition: persist.py:8
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
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:87
Json::Value Configuration
Definition: Configuration.h:50
#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
QTextStream & endl(QTextStream &s)
void test3D ( MultiPdf pdf,
bool  interactive 
)

Definition at line 79 of file test_paramwires3d.cxx.

80 {
81  WireParams* params = new WireParams;
82  IWireParameters::pointer iwp(params);
83  WireGenerator wg;
84  IWire::shared_vector wires;
85  bool ok = wg(iwp, wires);
86  Assert(ok);
87  Assert(wires);
88  AssertMsg(wires->size(), "Got no wires");
89 
90  const Ray& bbox = params->bounds();
91 
92  TView* view = TView::CreateView(1);
93  view->SetRange(bbox.first.x(),bbox.first.y(),bbox.first.z(),
94  bbox.second.x(),bbox.second.y(),bbox.second.z());
95  view->ShowAxis();
96  int colors[3] = {2, 4, 1};
97 
98 
99  IWire::vector u_wires, v_wires, w_wires;
100  copy_if(wires->begin(), wires->end(), back_inserter(u_wires), select_u_wires);
101  copy_if(wires->begin(), wires->end(), back_inserter(v_wires), select_v_wires);
102  copy_if(wires->begin(), wires->end(), back_inserter(w_wires), select_w_wires);
103  size_t n_wires[3] = {
104  u_wires.size(),
105  v_wires.size(),
106  w_wires.size()
107  };
108 
109  double max_width = 5;
110  for (auto wit = wires->begin(); wit != wires->end(); ++wit) {
111  IWire::pointer wire = *wit;
112  int iplane = wire->planeid().index();
113  int index = wire->index();
114 
115  AssertMsg(n_wires[iplane], "Empty plane");
116  double width = ((index+1)*max_width)/n_wires[iplane];
117 
118  const Ray ray = wire->ray();
119  TPolyLine3D* pl = new TPolyLine3D(2);
120  pl->SetPoint(0, ray.first.x(), ray.first.y(), ray.first.z());
121  pl->SetPoint(1, ray.second.x(), ray.second.y(), ray.second.z());
122  pl->SetLineColor(colors[iplane]);
123  pl->SetLineWidth(width);
124  pl->Draw();
125  }
126 
127  pdf();
128 }
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
struct vector vector
#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