18 info(
"-----dumping {} blobs:", blobs.size());
19 for (
const auto&
b : blobs) {
20 info(
"\t{}",
b.as_string());
29 m.SetMarkerColor(color);
30 m.SetMarkerSize(size);
31 m.SetMarkerStyle(style);
32 m.DrawMarker(p.z(), p.y());
37 l.SetLineColor(
color);
38 l.SetLineWidth(
width);
39 l.DrawLine(ray.first.z(), ray.first.y(),
40 ray.second.z(), ray.second.y());
45 l.SetLineColor(
color);
46 l.SetLineWidth(
width);
47 l.DrawArrow(ray.first.z(), ray.first.y(),
48 ray.second.z(), ray.second.y(),
55 frame->SetTitle(title.c_str());
62 const Vector& raydir,
int color,
bool outline=
true);
67 std::vector<Point>
points {
74 TPolyLine* pl =
new TPolyLine;
75 pl->SetLineColor(color);
76 pl->SetFillColorAlpha(color, 0.1);
77 for (
const auto& p :
points) {
78 pl->SetNextPoint(p.z(), p.y());
80 pl->SetNextPoint(points.front().z(), points.front().y());
91 const std::vector<double>& measure)
94 const auto raydir = ecks.cross(pitch);
97 for (
size_t ind=0; ind<measure.size(); ++ind) {
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;
112 for (
const auto& strip : strips) {
114 const auto& pitch = coords.pitch_dirs()[strip.layer];
115 const auto raydir = ecks.cross(pitch);
116 const auto&
center = coords.centers()[strip.layer];
118 const double pitch_mag = coords.pitch_mags()[strip.layer];
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;
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);
133 const auto& corners = blob.corners();
134 if (corners.empty()) {
138 std::vector<Point>
points;
140 for (
const auto& corn : corners) {
141 const auto p = coords.ray_crossing(corn.first, corn.second);
145 center = center * (1.0/points.size());
146 sort(points.begin(), points.end(),
150 const double anga = atan2(ac.y(), ac.z());
151 const double angb = atan2(bc.y(), bc.z());
155 TPolyLine* pl =
new TPolyLine;
156 pl->SetLineColor(
color);
159 for (
const auto& p : points) {
160 pl->SetNextPoint(p.z(), p.y());
162 pl->SetNextPoint(points.front().z(), points.front().y());
174 : canvas(
"test_raytiling",
"Ray Tiling", 500, 500)
178 canvas.Print((fname +
".pdf[").c_str(),
"pdf");
180 ~Printer() { canvas.Print((fname+
".pdf]").c_str(),
"pdf"); }
182 canvas.Print((fname+
".pdf").c_str(),
"pdf");
183 canvas.Print(Form(
"%s-%02d.png", fname.c_str(),
count),
"png");
184 canvas.Print(Form(
"%s-%02d.svg", fname.c_str(),
count),
"svg");
191 const std::vector<Point>&
points,
195 for (
const auto&
b : blobs) {
196 nstrips +=
b.strips().size();
200 (
int)points.size(), (
int)blobs.size(), nstrips));
201 for (
size_t ipt=0; ipt<points.size(); ++ipt ) {
202 const auto& p = points[ipt];
205 for (
size_t ib = 0; ib<blobs.size(); ++ib) {
211 const std::vector<Point>&
points,
213 const std::unordered_map<size_t, float>& blob_charge)
216 for (
const auto&
b : blobs) {
217 nstrips +=
b.strips().size();
222 (
int)points.size(), (
int)blobs.size(), nstrips));
224 for (
size_t ipt=0; ipt<points.size(); ++ipt ) {
225 const auto& p = points[ipt];
229 for (
auto it : blob_charge) {
230 size_t ind = it.first;
231 const auto& blob = blobs[ind];
244 info(
"center:{} ind:{} q:[]",
center, ind, q);
251 l.SetTextAlign(align);
254 l.SetTextColor(color);
255 l.DrawLatex(pt.z(), pt.y(), text.c_str());
259 auto* frame = print.
canvas.DrawFrame(-110, 50-110, 110, 50+110);
260 frame->SetTitle(
"Ray Grid");
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};
268 for (
int ind=0; ind<3; ++ind) {
271 auto r0 = raypairs[ri].first;
272 auto r1 = raypairs[ri].second;
278 auto cen = 0.5*(r0.first + r0.second);
279 centers0.push_back(cen);
280 centers1.push_back(0.5*(r1.first + r1.second));
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});
288 const auto r01 = coords.ray_crossing({ui,0}, {vi,1});
289 const auto r10 = coords.ray_crossing({ui,1}, {vi,0});
291 const int i=10, j=16;
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});
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;
303 const double wpind = wpij / wpit.magnitude();
337 draw_ray(
Ray(wtail + wpind*wpit, whead + wpind*wpit), colors[2], 1.0);
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
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_strip(const Point &head, const Point &tail, const Vector &raydir, int color, bool outline=true)
std::vector< Strip > strips_t
const std::vector< int > layer_colors
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
void draw_raygrid(Printer &print, const Coordinates &coords, const ray_pair_vector_t &raypairs)
void draw_text(const Point &pt, const std::string text, int color=1, int align=22)
void draw_strips(Coordinates &coords, const strips_t &strips, bool outline=true)
Point draw_blob(Coordinates &coords, const Blob &blob, int color=1)
std::enable_if< internal::is_string< String >::value >::type print(std::FILE *f, const text_style &ts, const String &format_str, const Args &...args)
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
static int max(int a, int b)
void draw_points_blobs(Coordinates &coords, Printer &print, const std::vector< Point > &points, const blobs_t &blobs)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
std::vector< ray_pair_t > ray_pair_vector_t
TH1F * draw_frame(TCanvas &canvas, std::string title)
std::vector< float > Vector
std::vector< Blob > blobs_t
Ray ray_pitch(const Ray &ray1, const Ray &ray2)
void draw_layer(Coordinates &coords, int ilayer, double pitch_mag, const Point &pitch, const Point ¢er, const std::vector< double > &measure)
void dump(const blobs_t &blobs)
static QCString align(DocHtmlCell *cell)
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)
Vector ray_vector(const Ray &ray)
void draw_arrow(const Ray &ray, int color=1, float width=1.0, float asize=0, const char *opt="")