Functions
test_anodeplane_draw.cxx File Reference
#include "WireCellUtil/Pimpos.h"
#include "TCanvas.h"
#include "TArrow.h"
#include "TH1F.h"
#include "TLine.h"
#include <iostream>
#include "anode_loader.h"

Go to the source code of this file.

Functions

void draw_pimpos (TCanvas &canvas, const std::string &detector, std::vector< const Pimpos * > &pimposes)
 
int main (int argc, char *argv[])
 

Function Documentation

void draw_pimpos ( TCanvas &  canvas,
const std::string detector,
std::vector< const Pimpos * > &  pimposes 
)

Definition at line 16 of file test_anodeplane_draw.cxx.

17 {
18  canvas.SetFixedAspectRatio(true);
19  canvas.SetGridx();
20  canvas.SetGridy();
21 
22  const double wire_extent = 5*units::cm; // half-length of wires
23  const double fsize_mm = 1.5*wire_extent/units::mm;
24 
25  const Point worigin = pimposes[2]->origin();
26 
27  TH1F* frame = canvas.DrawFrame(worigin[2]-fsize_mm, worigin[1]-fsize_mm,
28  worigin[2]+fsize_mm, worigin[1]+fsize_mm);
29  frame->SetTitle(Form("%s: Pitch (thick) and wire (thin) red=U, blue=V, xorigin=%.3fcm",
30  detector.c_str(), worigin[0]/units::cm));
31  frame->SetXTitle("Transverse Z [mm]");
32  frame->SetYTitle("Transverse Y [mm]");
33  int colors[3] = {2, 4, 1};
34 
35  for (int iplane=0; iplane<3; ++iplane) {
36  const Pimpos* pimpos = pimposes[iplane];
37 
38  const Vector wiredir = pimpos->axis(1);
39  const Vector pitchdir = pimpos->axis(2);
40  const Point origin = pimpos->origin();
41  const Binning& binning = pimpos->region_binning();
42  const double middle = binning.min() + 0.5*binning.span();
43 
44 
45  for (int ipitch = 0; ipitch <= binning.nbins(); ++ipitch) {
46  const double pitch1 = binning.edge(ipitch);
47  const double pitch2 = binning.edge(ipitch+1);
48 
49  if (std::abs(middle-pitch1) > wire_extent) {
50  continue; // stupid way to limit the drawing
51  }
52  if (std::abs(middle-pitch2) > wire_extent) {
53  continue; // stupid way to limit the drawing
54  }
55 
56  const Vector vpitch1 = origin + pitchdir * pitch1;
57  const Vector vpitch2 = origin + pitchdir * pitch2;
58  const Ray r_pitch(vpitch1, vpitch2);
59  const Vector vwire = 1.2*wiredir * wire_extent;
60  const Ray r_wire(vpitch1 - vwire,
61  vpitch1 + vwire);
62 
63  if (ipitch < binning.nbins()) { // pitch is bin, wire is edge
64  TArrow* a_pitch = new TArrow(r_pitch.first.z()/units::mm, r_pitch.first.y()/units::mm,
65  r_pitch.second.z()/units::mm, r_pitch.second.y()/units::mm,
66  0.01, "|>");
67  a_pitch->SetLineColor(colors[iplane]);
68  a_pitch->SetLineWidth(2);
69  a_pitch->Draw();
70  }
71  TArrow* a_wire = new TArrow(r_wire.first.z()/units::mm, r_wire.first.y()/units::mm,
72  r_wire.second.z()/units::mm, r_wire.second.y()/units::mm, 0.01);
73  a_wire->SetLineColor(colors[iplane]);
74 
75  a_wire->Draw();
76  }
77  }
78 
79 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
double span() const
Return the max-min.
Definition: Binning.h:57
const Point & origin() const
Return given 3-point origin for plane pitch.
Definition: Pimpos.h:85
const Binning & region_binning() const
Definition: Pimpos.h:109
static Ray pitch2(const IWire::vector &wires)
Definition: WireSummary.cxx:13
T abs(T value)
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:34
double min() const
Definition: Binning.h:47
static const double mm
Definition: Units.h:73
std::vector< float > Vector
Pimpos pimpos(nwires, min_wire_pitch, max_wire_pitch)
Pitch-Impact-Position.
Definition: Pimpos.h:36
static const double cm
Definition: Units.h:76
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
const Vector & axis(int i) const
Definition: Pimpos.h:89
int main ( int  argc,
char *  argv[] 
)

Definition at line 82 of file test_anodeplane_draw.cxx.

83 {
84  std::string detector = "uboone";
85  if (argc > 1) {
86  detector = argv[1];
87  }
88  auto anode_tns = anode_loader(detector);
89 
90 
91  // output PDF
93  pdffile += "-" + detector + ".pdf";
94  cerr << "Drawing to " << pdffile << endl;
95 
96  TCanvas canvas("c","c",500,500);
97 
98  canvas.Print((pdffile+"[").c_str(), "pdf");
99 
100  for (const auto& anode_tn : anode_tns) {
101  cerr << "Getting: " << anode_tn << "\n";
102  auto iap = Factory::find_tn<IAnodePlane>(anode_tn);
103 
104  for (auto face : iap->faces()) {
105  std::vector<const Pimpos*> pimposes;
106  for (auto plane : face->planes()) {
107  pimposes.push_back(plane->pimpos());
108  }
109  draw_pimpos(canvas, detector, pimposes);
110  canvas.Print(pdffile.c_str(), "pdf");
111  }
112  }
113 
114  canvas.Print((pdffile+"]").c_str(), "pdf");
115  return 0;
116 }
std::string string
Definition: nybbler.cc:12
std::vector< std::string > anode_loader(std::string detector)
Definition: anode_loader.h:35
void draw_pimpos(TCanvas &canvas, const std::string &detector, std::vector< const Pimpos * > &pimposes)
QTextStream & endl(QTextStream &s)