Functions
test_pimpos_draw.cxx File Reference
#include "WireCellUtil/Pimpos.h"
#include "WireCellUtil/Units.h"
#include "WireCellUtil/Point.h"
#include "WireCellUtil/Testing.h"
#include "TCanvas.h"
#include "TArrow.h"
#include "TH1F.h"
#include "TLine.h"
#include <iostream>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 21 of file test_pimpos_draw.cxx.

22 {
23  // Match Garfield extent
24  const int nwiresperplane = 21;
25 
26  // protoDUNE
27  const double pitch = 5*units::mm;
28  const double angle = 35.707*units::degree;
29  const double wire_extent = pitch * 0.5 * (nwiresperplane - 1);
30 
31  std::vector<Vector> uvw_wire{Vector(0, cos(angle), sin(angle)), // points Y>0, Z>0
32  Vector(0, cos(angle), -sin(angle)), // points Y>0, Z<0
33  Vector(0, 1, 0)};
34 
35  // Pitch direction points generally in +Z direction (for "front" faces)
36  std::vector<Vector> uvw_pitch{Vector(0, -sin(angle), cos(angle)),
37  Vector(0, sin(angle), cos(angle)),
38  Vector(0, 0, 1)};
39 
40 
41  std::vector<Pimpos> pimpos;
42  for (int iplane=0; iplane<3; ++iplane) {
43  Pimpos p(nwiresperplane, -wire_extent, wire_extent, uvw_wire[iplane], uvw_pitch[iplane]);
44  pimpos.push_back(p);
45 
46  const double wpdot = uvw_wire[iplane].dot(uvw_pitch[iplane]);
47  Assert(std::abs(wpdot) < 1.0e-6);
48 
49  }
50 
51  TCanvas canvas("c","c",500,500);
52 
53  canvas.SetFixedAspectRatio(true);
54  canvas.SetGridx();
55  canvas.SetGridy();
56 
57  const double fsize_mm = 0.8*2.0*wire_extent/units::mm;
58  TH1F* frame = canvas.DrawFrame(-fsize_mm, -fsize_mm, fsize_mm, fsize_mm);
59  frame->SetTitle("Pitch (thick) and wire (thin) red=U, blue=V, +X (-drift) direction into page");
60  frame->SetXTitle("Transverse Z [mm]");
61  frame->SetYTitle("Transverse Y [mm]");
62  int colors[3] = {2, 4, 1};
63 
64  for (int iplane=0; iplane<3; ++iplane) {
65 
66  const Vector wiredir = pimpos[iplane].axis(1);
67  const Vector pitchdir = pimpos[iplane].axis(2);
68  const Point origin = pimpos[iplane].origin();
69  const Binning& binning = pimpos[iplane].region_binning();
70 
71  for (int ipitch = 0; ipitch <= binning.nbins(); ++ipitch) {
72  const double pitch1 = binning.edge(ipitch);
73  const double pitch2 = binning.edge(ipitch+1);
74 
75  const Vector vpitch1 = origin + pitchdir * pitch1;
76  const Vector vpitch2 = origin + pitchdir * pitch2;
77  const Ray r_pitch(vpitch1, vpitch2);
78  const Vector vwire = 1.2*wiredir * wire_extent;
79  const Ray r_wire(origin + vpitch1 - vwire,
80  origin + vpitch1 + vwire);
81 
82  if (ipitch < binning.nbins()) { // pitch is bin, wire is edge
83  TArrow* a_pitch = new TArrow(r_pitch.first.z()/units::mm, r_pitch.first.y()/units::mm,
84  r_pitch.second.z()/units::mm, r_pitch.second.y()/units::mm,
85  0.01, "|>");
86  a_pitch->SetLineColor(colors[iplane]);
87  a_pitch->SetLineWidth(2);
88  a_pitch->Draw();
89  }
90  TArrow* a_wire = new TArrow(r_wire.first.z()/units::mm, r_wire.first.y()/units::mm,
91  r_wire.second.z()/units::mm, r_wire.second.y()/units::mm, 0.01);
92  a_wire->SetLineColor(colors[iplane]);
93 
94  a_wire->Draw();
95  }
96  }
97 
98  canvas.Print(Form("%s.pdf", argv[0]));
99 
100  return 0;
101 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
static const double degree
Definition: Units.h:162
static Ray pitch2(const IWire::vector &wires)
Definition: WireSummary.cxx:13
#define Assert
Definition: Testing.h:7
T abs(T value)
const double e
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:34
static const double mm
Definition: Units.h:73
p
Definition: test.py:223
std::vector< float > Vector
Pimpos pimpos(nwires, min_wire_pitch, max_wire_pitch)
Pitch-Impact-Position.
Definition: Pimpos.h:36
double edge(int ind) const
Definition: Binning.h:99
int nbins() const
Definition: Binning.h:42
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227