Classes | Functions | Variables
raygrid_draw.h File Reference
#include "TCanvas.h"
#include "TMarker.h"
#include "TText.h"
#include "TLatex.h"
#include "TLine.h"
#include "TPolyLine.h"
#include "TArrow.h"
#include "TH1F.h"
#include "TStyle.h"

Go to the source code of this file.

Classes

struct  Printer
 

Functions

void draw_text (const Point &pt, const std::string text, int color=1, int align=22)
 
void dump (const blobs_t &blobs)
 
void draw_point (const Point &p, float size=1, int style=20, int color=1)
 
void draw_ray (const Ray &ray, int color=1, float width=1.0)
 
void draw_arrow (const Ray &ray, int color=1, float width=1.0, float asize=0, const char *opt="")
 
TH1F * draw_frame (TCanvas &canvas, std::string title)
 
void draw_strip (const Point &head, const Point &tail, const Vector &raydir, int color, bool outline=true)
 
void draw_layer (Coordinates &coords, int ilayer, double pitch_mag, const Point &pitch, const Point &center, const std::vector< double > &measure)
 
void draw_strips (Coordinates &coords, const strips_t &strips, bool outline=true)
 
Point draw_blob (Coordinates &coords, const Blob &blob, int color=1)
 
void draw_points_blobs (Coordinates &coords, Printer &print, const std::vector< Point > &points, const blobs_t &blobs)
 
void draw_points_blobs_solved (Coordinates &coords, Printer &print, const std::vector< Point > &points, const blobs_t &blobs, const std::unordered_map< size_t, float > &blob_charge)
 
void draw_raygrid (Printer &print, const Coordinates &coords, const ray_pair_vector_t &raypairs)
 

Variables

const std::vector< int > layer_colors {1,1,2,3,4}
 

Function Documentation

void draw_arrow ( const Ray &  ray,
int  color = 1,
float  width = 1.0,
float  asize = 0,
const char *  opt = "" 
)

Definition at line 42 of file raygrid_draw.h.

43 {
44  TArrow l;
45  l.SetLineColor(color);
46  l.SetLineWidth(width);
47  l.DrawArrow(ray.first.z(), ray.first.y(),
48  ray.second.z(), ray.second.y(),
49  asize, opt);
50 }
opt
Definition: train.py:196
static QStrList * l
Definition: config.cpp:1044
const double width
color
Definition: color.h:50
Point draw_blob ( Coordinates &  coords,
const Blob &  blob,
int  color = 1 
)

Definition at line 131 of file raygrid_draw.h.

132 {
133  const auto& corners = blob.corners();
134  if (corners.empty()) {
135  return Point();
136  }
137 
138  std::vector<Point> points;
139  Point center;
140  for (const auto& corn : corners) {
141  const auto p = coords.ray_crossing(corn.first, corn.second);
142  center += p;
143  points.push_back(p);
144  }
145  center = center * (1.0/points.size());
146  sort(points.begin(), points.end(),
147  [&](const Point& a, const Point&b) {
148  const Point ac = a-center;
149  const Point bc = b-center;
150  const double anga = atan2(ac.y(), ac.z());
151  const double angb = atan2(bc.y(), bc.z());
152  return anga > angb;
153  });
154 
155  TPolyLine* pl = new TPolyLine; // like a sieve
156  pl->SetLineColor(color);
157  pl->SetLineWidth(2);
158 
159  for (const auto& p : points) {
160  pl->SetNextPoint(p.z(), p.y());
161  }
162  pl->SetNextPoint(points.front().z(), points.front().y());
163  pl->Draw();
164  return center;
165 }
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:34
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
p
Definition: test.py:223
color
Definition: color.h:50
def center(depos, point)
Definition: depos.py:117
static bool * b
Definition: config.cpp:1043
def points(jdat)
Definition: rendertvtk.py:105
TH1F* draw_frame ( TCanvas &  canvas,
std::string  title 
)

Definition at line 52 of file raygrid_draw.h.

53 {
54  auto* frame = canvas.DrawFrame(-1.0*border, -1.0*border, width+border, height+border);
55  frame->SetTitle(title.c_str());
56  return frame;
57 }
const double width
const double border
const double height
void draw_layer ( Coordinates &  coords,
int  ilayer,
double  pitch_mag,
const Point pitch,
const Point center,
const std::vector< double > &  measure 
)

Definition at line 87 of file raygrid_draw.h.

92 {
93  const Vector ecks(1,0,0);
94  const auto raydir = ecks.cross(pitch);
95 
96 
97  for (size_t ind=0; ind<measure.size(); ++ind) {
98  int color = layer_colors[ilayer];
99  if (measure[ind] <= 0.0) { continue; }
100  const auto tail = center + ind*pitch_mag*pitch;
101  const auto head = center + (ind+1)*pitch_mag*pitch;
102  draw_strip(tail, head, raydir, color);
103  }
104 }
void draw_strip(const Point &head, const Point &tail, const Vector &raydir, int color, bool outline=true)
Definition: raygrid_draw.h:63
const std::vector< int > layer_colors
Definition: raygrid_draw.h:59
std::vector< float > Vector
color
Definition: color.h:50
void draw_point ( const Point p,
float  size = 1,
int  style = 20,
int  color = 1 
)

Definition at line 26 of file raygrid_draw.h.

27 {
28  TMarker m;
29  m.SetMarkerColor(color);
30  m.SetMarkerSize(size);
31  m.SetMarkerStyle(style);
32  m.DrawMarker(p.z(), p.y());
33 }
static const double m
Definition: Units.h:79
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:87
color
Definition: color.h:50
void draw_points_blobs ( Coordinates &  coords,
Printer print,
const std::vector< Point > &  points,
const blobs_t &  blobs 
)

Definition at line 190 of file raygrid_draw.h.

193 {
194  int nstrips = 0;
195  for (const auto& b : blobs) {
196  nstrips += b.strips().size();
197  }
198 
199  draw_frame(print.canvas, Form("%d points, %d blobs, %d strips",
200  (int)points.size(), (int)blobs.size(), nstrips));
201  for (size_t ipt=0; ipt<points.size(); ++ipt ) {
202  const auto& p = points[ipt];
203  draw_point(p, 1, 24, ipt+1);
204  }
205  for (size_t ib = 0; ib<blobs.size(); ++ib) {
206  draw_blob(coords, blobs[ib],1);
207  }
208 }
def blobs(cm, hist)
Definition: plots.py:79
Point draw_blob(Coordinates &coords, const Blob &blob, int color=1)
Definition: raygrid_draw.h:131
TCanvas canvas
Definition: raygrid_draw.h:170
TH1F * draw_frame(TCanvas &canvas, std::string title)
Definition: raygrid_draw.h:52
p
Definition: test.py:223
static bool * b
Definition: config.cpp:1043
void draw_point(const Point &p, float size=1, int style=20, int color=1)
Definition: raygrid_draw.h:26
void draw_points_blobs_solved ( Coordinates &  coords,
Printer print,
const std::vector< Point > &  points,
const blobs_t &  blobs,
const std::unordered_map< size_t, float > &  blob_charge 
)

Definition at line 210 of file raygrid_draw.h.

214 {
215  int nstrips = 0;
216  for (const auto& b : blobs) {
217  nstrips += b.strips().size();
218  }
219 
220 
221  draw_frame(print.canvas, Form("%d points, %d blobs, %d strips",
222  (int)points.size(), (int)blobs.size(), nstrips));
223 
224  for (size_t ipt=0; ipt<points.size(); ++ipt ) {
225  const auto& p = points[ipt];
226  draw_point(p, 1, 24, ipt+1);
227  }
228 
229  for (auto it : blob_charge) {
230  size_t ind = it.first;
231  const auto& blob = blobs[ind];
232  float q = it.second;
233  int color = 1;
234  if (q<1.0) {
235  color = 2;
236  }
237  auto center = draw_blob(coords, blob, color);
238  if (q<1.0 ) {
239  draw_text(center, Form("s%d", (int)ind), color, 22);
240  }
241  else {
242  draw_text(center, Form("s%d:%.1f", (int)ind, q), color, 22);
243  }
244  info("center:{} ind:{} q:[]", center, ind, q);
245  }
246 }
def blobs(cm, hist)
Definition: plots.py:79
void draw_text(const Point &pt, const std::string text, int color=1, int align=22)
Definition: raygrid_draw.h:248
Point draw_blob(Coordinates &coords, const Blob &blob, int color=1)
Definition: raygrid_draw.h:131
TCanvas canvas
Definition: raygrid_draw.h:170
TH1F * draw_frame(TCanvas &canvas, std::string title)
Definition: raygrid_draw.h:52
p
Definition: test.py:223
color
Definition: color.h:50
def center(depos, point)
Definition: depos.py:117
static bool * b
Definition: config.cpp:1043
void draw_point(const Point &p, float size=1, int style=20, int color=1)
Definition: raygrid_draw.h:26
void draw_ray ( const Ray &  ray,
int  color = 1,
float  width = 1.0 
)

Definition at line 34 of file raygrid_draw.h.

35 {
36  TArrow l;
37  l.SetLineColor(color);
38  l.SetLineWidth(width);
39  l.DrawLine(ray.first.z(), ray.first.y(),
40  ray.second.z(), ray.second.y());
41 }
static QStrList * l
Definition: config.cpp:1044
const double width
color
Definition: color.h:50
void draw_raygrid ( Printer print,
const Coordinates &  coords,
const ray_pair_vector_t &  raypairs 
)

Definition at line 257 of file raygrid_draw.h.

258 {
259  auto* frame = print.canvas.DrawFrame(-110, 50-110, 110, 50+110);
260  frame->SetTitle("Ray Grid");
261 
262  info("got {} ray pairs", raypairs.size());
263  std:: vector<Point> centers0;
264  std:: vector<Point> centers1;
265  const int ui = 2, vi = 3, wi = 4;
266  int index[] = {2, 3, 4};
267  int colors[] = {2,4,1};
268  for (int ind=0; ind<3; ++ind) {
269  int ri = index[ind];
270 
271  auto r0 = raypairs[ri].first;
272  auto r1 = raypairs[ri].second;
273 
274  draw_ray(r0, colors[ind], 2.0);
275  draw_ray(r1, colors[ind], 2.0);
276  //auto dir = ray_direction(raypairs[ind].first).norm();
277  auto pit = ray_vector(ray_pitch(r0, r1));
278  auto cen = 0.5*(r0.first + r0.second);
279  centers0.push_back(cen);
280  centers1.push_back(0.5*(r1.first + r1.second));
281  draw_arrow(Ray(cen, cen+pit), colors[ind], 1, 0.01, ">");
282  }
283 
284  const auto r00 = coords.zero_crossing(ui, vi);
285  const auto r0n = coords.ray_crossing({ui,-1}, {vi,1});
286  const auto r1n = coords.ray_crossing({ui,1}, {vi,-1});
287 
288  const auto r01 = coords.ray_crossing({ui,0}, {vi,1});
289  const auto r10 = coords.ray_crossing({ui,1}, {vi,0});
290 
291  const int i=10, j=16;
292 
293  const auto rij = coords.ray_crossing({ui,i}, {vi,j});
294  const auto r0j = coords.ray_crossing({ui,0}, {vi,j});
295  const auto ri0 = coords.ray_crossing({ui,i}, {vi,0});
296 
297  const double wpij = coords.pitch_location({ui,i}, {vi,j}, wi);
298  const auto wray0 = raypairs[wi].first;
299  const auto wray1 = raypairs[wi].second;
300  const auto wtail = wray0.first;
301  const auto whead = wray0.second;
302  const auto wpit = ray_vector(ray_pitch(wray0, wray1));
303  const double wpind = wpij / wpit.magnitude();
304 
305 
306  draw_point(r00, 1, 24, 1);
307  draw_text(r00+Point(0,0,-15), "r^{01}_{00}");
308  draw_text(r00+Point(0,5,5), "w^{01}",2);
309  draw_text(r00+Point(0,-15,0), "w^{10}",4);
310 
311  //draw_point(r01, 1, 24, 2);
312  //draw_point(r10, 1, 24, 4);
313  draw_point(rij, 1, 20, 1);
314  draw_text(rij+Point(0,0,5), "r^{01}_{ij}");
315 
316  draw_ray(Ray(r00, centers0[0]), colors[0], 1.0);
317  draw_ray(Ray(r00, centers0[1]), colors[1], 1.0);
318 
319  draw_ray(Ray(r1n, centers1[0]), colors[0], 1.0);
320  draw_ray(Ray(r0n, centers1[1]), colors[1], 1.0);
321 
322  draw_text(centers0[0]+Point(0,10,0), "p^{0}", colors[0]);
323 
324  draw_arrow(Ray(r00, r01), colors[0], 2.0, 0.01, ">");
325  draw_arrow(Ray(r00, r10), colors[1], 2.0, 0.01, ">");
326 
327 
328 
329  draw_arrow(Ray(r00, rij), 1, 1.0, 0.01, ">");
330  //draw_arrow(Ray(r00, r0j), colors[0], 2.0, 0.01, ">");
331  draw_arrow(Ray(r00, ri0), colors[1], 2.0, 0.01, ">");
332  draw_arrow(Ray(ri0, rij), colors[0], 2.0, 0.01, ">");
333 
334  draw_text(ri0+Point(0,-10,-20), "iw^{10}", 4);
335  draw_text(0.5*(ri0+rij)+Point(0,-10,0), "jw^{01}", 2);
336 
337  draw_ray(Ray(wtail + wpind*wpit, whead + wpind*wpit), colors[2], 1.0);
338 
339  print();
340 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
void draw_text(const Point &pt, const std::string text, int color=1, int align=22)
Definition: raygrid_draw.h:248
std::enable_if< internal::is_string< String >::value >::type print(std::FILE *f, const text_style &ts, const String &format_str, const Args &...args)
Definition: color.h:549
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:34
TCanvas canvas
Definition: raygrid_draw.h:170
Ray ray_pitch(const Ray &ray1, const Ray &ray2)
Definition: Point.cxx:76
void draw_point(const Point &p, float size=1, int style=20, int color=1)
Definition: raygrid_draw.h:26
void draw_ray(const Ray &ray, int color=1, float width=1.0)
Definition: raygrid_draw.h:34
Vector ray_vector(const Ray &ray)
Definition: Point.cxx:67
void draw_arrow(const Ray &ray, int color=1, float width=1.0, float asize=0, const char *opt="")
Definition: raygrid_draw.h:42
void draw_strip ( const Point head,
const Point tail,
const Vector raydir,
int  color,
bool  outline = true 
)

Definition at line 63 of file raygrid_draw.h.

65 {
66  const double shoot = 2*std::max(width,height);
67  std::vector<Point> points {
68  tail+raydir*shoot,
69  tail-raydir*shoot,
70  head-raydir*shoot,
71  head+raydir*shoot
72  };
73 
74  TPolyLine* pl = new TPolyLine; // like a sieve
75  pl->SetLineColor(color);
76  pl->SetFillColorAlpha(color, 0.1);
77  for (const auto& p : points) {
78  pl->SetNextPoint(p.z(), p.y());
79  }
80  pl->SetNextPoint(points.front().z(), points.front().y());
81  pl->Draw("f");
82  if (outline) {
83  pl->Draw("");
84  }
85 }
const double width
const double height
static int max(int a, int b)
p
Definition: test.py:223
color
Definition: color.h:50
def points(jdat)
Definition: rendertvtk.py:105
void draw_strips ( Coordinates &  coords,
const strips_t &  strips,
bool  outline = true 
)

Definition at line 108 of file raygrid_draw.h.

109 {
110  const Vector ecks(1,0,0);
111 
112  for (const auto& strip : strips) {
113  int color = layer_colors[strip.layer];
114  const auto& pitch = coords.pitch_dirs()[strip.layer];
115  const auto raydir = ecks.cross(pitch);
116  const auto& center = coords.centers()[strip.layer];
117 
118  const double pitch_mag = coords.pitch_mags()[strip.layer];
119 
120  const auto pind1 = strip.bounds.first;
121  const auto pind2 = strip.bounds.second;
122  const double pitch_dist = std::abs(pind1-pind2)*pitch_mag;
123 
124  const auto tail = center + pind1*pitch_mag*pitch;
125  const auto head = tail + pitch_dist*pitch;
126  draw_strip(tail, head, raydir, color, outline);
127  }
128 }
void draw_strip(const Point &head, const Point &tail, const Vector &raydir, int color, bool outline=true)
Definition: raygrid_draw.h:63
const std::vector< int > layer_colors
Definition: raygrid_draw.h:59
T abs(T value)
std::vector< float > Vector
color
Definition: color.h:50
def center(depos, point)
Definition: depos.py:117
void draw_text ( const Point pt,
const std::string  text,
int  color = 1,
int  align = 22 
)

Definition at line 248 of file raygrid_draw.h.

249 {
250  TLatex l;
251  l.SetTextAlign(align);
252  l.SetTextFont(52);
253  l.SetTextSize(0.03);
254  l.SetTextColor(color);
255  l.DrawLatex(pt.z(), pt.y(), text.c_str());
256 }
static QStrList * l
Definition: config.cpp:1044
color
Definition: color.h:50
static QCString align(DocHtmlCell *cell)
void dump ( const blobs_t &  blobs)

Definition at line 16 of file raygrid_draw.h.

17 {
18  info("-----dumping {} blobs:", blobs.size());
19  for (const auto& b : blobs) {
20  info("\t{}",b.as_string());
21  }
22  info("------");
23 }
def blobs(cm, hist)
Definition: plots.py:79
static bool * b
Definition: config.cpp:1043

Variable Documentation

const std::vector<int> layer_colors {1,1,2,3,4}

Definition at line 59 of file raygrid_draw.h.