369void Draw2DCore(
const std::vector<int> &bundle_ids,
const std::vector<VisPoint2D> &extraPoints,
370 const std::function<
void(TMultiGraph *, TMultiGraph *, TMultiGraph *, TMultiGraph *)>
375 TCanvas *c_phiz = (TCanvas *)gROOT->FindObject(
"c_phiz");
377 c_phiz =
new TCanvas(
"c_phiz",
"Map Phi-Z", 750, 850);
381 c_phiz->SetLeftMargin(0.15);
384 TMultiGraph *mg_phiz =
new TMultiGraph();
387 TCanvas *c_lat = (TCanvas *)gROOT->FindObject(
"c_lat");
389 c_lat =
new TCanvas(
"c_lat",
"Projections ZX / ZY", 1200, 750);
393 TPad *pad_zx =
new TPad(
"pad_zx",
"ZX", 0.01, 0.01, 0.42, 1);
394 TPad *pad_zy =
new TPad(
"pad_zy",
"ZY", 0.4, 0.15, 1, 0.8);
395 pad_zx->SetLeftMargin(0.15);
396 pad_zy->SetBottomMargin(0.15);
400 TMultiGraph *mg_zx =
new TMultiGraph();
401 TMultiGraph *mg_zy =
new TMultiGraph();
404 TCanvas *c_xy = (TCanvas *)gROOT->FindObject(
"c_xy");
406 c_xy =
new TCanvas(
"c_xy",
"Transverse View XY", 700, 700);
411 TMultiGraph *mg_xy =
new TMultiGraph();
414 for(
int b_id : bundle_ids)
419 std::vector<double> vz, vphi, vx, vy;
426 for(
int i = 0; i < 500; ++i)
433 vx.push_back(p.
r * std::cos(ph));
434 vy.push_back(p.
r * std::sin(ph));
438 TGraph *l_zx =
new TGraph(500, &vx[0], &vz[0]);
439 l_zx->SetLineColor(p.
color);
440 l_zx->SetLineWidth(2);
441 mg_zx->Add(l_zx,
"L");
443 TGraph *l_zy =
new TGraph(500, &vz[0], &vy[0]);
444 l_zy->SetLineColor(p.
color);
445 l_zy->SetLineWidth(2);
446 mg_zy->Add(l_zy,
"L");
449 std::vector<double> sz, sf;
450 for(
size_t i = 0; i < 500; ++i)
458 TGraph *h =
new TGraph();
460 for(
int j = 0; j < nn; ++j)
461 h->SetPoint(j, sf[j] + d_phi_w, sz[j]);
462 for(
int j = 0; j < nn; ++j)
463 h->SetPoint(nn + j, sf[nn - 1 - j] - d_phi_w, sz[nn - 1 - j]);
465 h->SetFillColorAlpha(p.
color, 0.3);
467 mg_phiz->Add(h,
"F");
469 TGraph *l =
new TGraph(nn, &sf[0], &sz[0]);
470 l->SetLineColor(p.
color);
472 mg_phiz->Add(l,
"L");
484 TGraph *hf =
new TGraph();
486 for(
int j = 0; j < nn; ++j)
487 hf->SetPoint(j, sf[j] + d_phi_w, sz[j]);
488 for(
int j = 0; j < nn; ++j)
489 hf->SetPoint(nn + j, sf[nn - 1 - j] - d_phi_w, sz[nn - 1 - j]);
491 hf->SetFillColorAlpha(p.
color, 0.3);
493 mg_phiz->Add(hf,
"F");
495 TGraph *lf =
new TGraph(nn, &sf[0], &sz[0]);
496 lf->SetLineColor(p.
color);
498 mg_phiz->Add(lf,
"L");
504 trackDrawer(mg_xy, mg_zx, mg_zy, mg_phiz);
507 for(
const auto &pt : extraPoints)
509 TGraph *gp =
new TGraph(1);
510 gp->SetPoint(0, pt.x, pt.y);
511 gp->SetMarkerColor(pt.color);
512 gp->SetMarkerStyle(pt.markerStyle);
513 gp->SetMarkerSize(pt.size);
522 TGraph *gi_xy =
new TGraph();
523 for(
size_t i = 0; i < inters.size(); ++i)
524 gi_xy->SetPoint(i, inters[i].x_loc, inters[i].y_loc);
525 gi_xy->SetMarkerStyle(20);
526 gi_xy->SetMarkerSize(0.8);
527 gi_xy->SetMarkerColor(kBlack);
528 mg_xy->Add(gi_xy,
"P");
531 TGraph *gi_zx =
new TGraph();
532 for(
size_t i = 0; i < inters.size(); ++i)
533 gi_zx->SetPoint(i, inters[i].x_loc, inters[i].z_loc);
534 gi_zx->SetMarkerStyle(20);
535 gi_zx->SetMarkerSize(0.8);
536 gi_zx->SetMarkerColor(kBlack);
537 mg_zx->Add(gi_zx,
"P");
540 TGraph *gi_zy =
new TGraph();
541 for(
size_t i = 0; i < inters.size(); ++i)
542 gi_zy->SetPoint(i, inters[i].z_loc, inters[i].y_loc);
543 gi_zy->SetMarkerStyle(20);
544 gi_zy->SetMarkerSize(0.8);
545 gi_zy->SetMarkerColor(kBlack);
546 mg_zy->Add(gi_zy,
"P");
549 TGraph *gi_phiz =
new TGraph();
550 for(
size_t i = 0; i < inters.size(); ++i)
552 double phi = std::atan2(inters[i].y_loc, inters[i].x_loc);
553 if(wrap_phi && phi < 0)
555 gi_phiz->SetPoint(i, phi, inters[i].z_loc);
557 gi_phiz->SetMarkerStyle(20);
558 gi_phiz->SetMarkerSize(0.8);
559 gi_phiz->SetMarkerColor(kBlack);
560 mg_phiz->Add(gi_phiz,
"P");
568 mg_phiz->SetTitle(
"Detector Map #phi-z; #phi [rad]; z [mm]");
571 mg_phiz->GetXaxis()->SetLimits(0, 2 *
M_PI);
572 mg_phiz->GetXaxis()->SetNdivisions(-504);
575 TAxis *ax = mg_phiz->GetXaxis();
576 ax->ChangeLabel(1, -1, -1, -1, -1, -1,
"0");
577 ax->ChangeLabel(2, -1, -1, -1, -1, -1,
"#pi/2");
578 ax->ChangeLabel(3, -1, -1, -1, -1, -1,
"#pi");
579 ax->ChangeLabel(4, -1, -1, -1, -1, -1,
"3#pi/2");
580 ax->ChangeLabel(5, -1, -1, -1, -1, -1,
"2#pi");
587 for(
const auto &cyl : cyls)
589 if(cyl.outer.radius > max_R)
590 max_R = cyl.outer.radius;
595 double margin = 10.0;
596 double limit = max_R + margin;
601 mg_zx->SetTitle(
"Top View ZX; x [mm]; z [mm]");
602 mg_zx->GetXaxis()->SetLimits(-limit, limit);
609 b->SetLineColor(kGray + 1);
616 mg_zy->SetTitle(
"Lateral View ZY; z [mm]; y [mm]");
618 mg_zy->GetYaxis()->SetRangeUser(-limit, limit);
624 b->SetLineColor(kGray + 1);
631 mg_xy->SetTitle(
"XY View; x [mm]; y [mm]");
632 mg_xy->GetXaxis()->SetLimits(-limit, limit);
633 mg_xy->GetYaxis()->SetRangeUser(-limit, limit);
636 TEllipse *e =
new TEllipse(0, 0, c.nominalRadius);
646void Draw3DCore(
const std::vector<int> &hit_ids,
const std::vector<VisPoint3D> &points,
647 bool drawSkeleton,
const std::function<
void(
double[6])> &trackDrawer)
651 TCanvas *c_3d = (TCanvas *)gROOT->FindObject(
"c_3d");
653 c_3d =
new TCanvas(
"c_3d",
"Detector 3D View", 1200, 800);
658 double min_x_phys = 1e9, max_x_phys = -1e9;
659 double min_y_phys = 1e9, max_y_phys = -1e9;
660 double min_z_phys = 1e9, max_z_phys = -1e9;
664 for(
const auto &cyl : cylinders)
666 if(cyl.outer.radius > max_R)
667 max_R = cyl.outer.radius;
678 for(
int i = 0; i < 8; ++i)
680 double x = corners[i][0];
681 double y = corners[i][1];
682 double z = corners[i][2];
699 double margin = 20.0;
700 min_x_phys -= margin;
701 max_x_phys += margin;
702 min_y_phys -= margin;
703 max_y_phys += margin;
704 min_z_phys -= margin;
705 max_z_phys += margin;
710 bool isRotated = (std::abs(rx) > 1e-9 || std::abs(ry) > 1e-9 || std::abs(rz) > 1e-9);
714 double dx = max_x_phys - min_x_phys;
715 double dy = max_y_phys - min_y_phys;
716 double dz = max_z_phys - min_z_phys;
717 double max_dim = std::max({ dx, dy, dz });
719 double cx = (min_x_phys + max_x_phys) / 2.0;
720 double cy = (min_y_phys + max_y_phys) / 2.0;
721 double cz = (min_z_phys + max_z_phys) / 2.0;
723 min_x_phys = cx - max_dim / 2.0;
724 max_x_phys = cx + max_dim / 2.0;
725 min_y_phys = cy - max_dim / 2.0;
726 max_y_phys = cy + max_dim / 2.0;
727 min_z_phys = cz - max_dim / 2.0;
728 max_z_phys = cz + max_dim / 2.0;
731 double bounds[6] = { min_x_phys, max_x_phys, min_y_phys, max_y_phys, min_z_phys, max_z_phys };
734 TH3F *h_frame =
new TH3F(
"h_frame",
"; Z [mm]; X [mm]; Y [mm]", 1, min_z_phys, max_z_phys, 1,
735 min_x_phys, max_x_phys, 1, min_y_phys, max_y_phys);
736 h_frame->SetDirectory(0);
737 h_frame->SetStats(0);
738 h_frame->GetXaxis()->SetTitleOffset(1.5);
739 h_frame->GetYaxis()->SetTitleOffset(1.5);
740 h_frame->GetZaxis()->SetTitleOffset(1.);
747 for(
const auto &cyl : cylinders)
750 for(
int l = 0; l < 2; ++l)
752 for(
int b = 0; b < layers[l]->
nBundles; ++b)
758 TPolyLine3D *bg_f =
new TPolyLine3D(10);
759 for(
int i = 0; i < 10; ++i)
765 double x3 = p.
r * std::cos(ph);
766 double y3 = p.
r * std::sin(ph);
771 bg_f->SetPoint(i, z3, x3, y3);
773 bg_f->SetLineColorAlpha(p.
color, 0.1);
781 for(
int id : hit_ids)
787 TPolyLine3D *fl =
new TPolyLine3D(50);
788 for(
int i = 0; i < 50; ++i)
794 double x3 = p.
r * std::cos(ph);
795 double y3 = p.
r * std::sin(ph);
800 fl->SetPoint(i, z3, x3, y3);
802 fl->SetLineColor(p.
color);
812 for(
const auto &pt_in : points)
820 TPolyMarker3D *pm =
new TPolyMarker3D(1);
825 pm->SetPoint(0, pt.
z, pt.
x, pt.
y);
827 pm->SetMarkerColor(pt.
color);
829 pm->SetMarkerSize(pt.
size);