In visualising hits in a event, I try to use the following code. The idea is to have in the same histogram, the origin of a track (black dot), the first hit in a detector (red dot) and the second hit (blue dot). Also, I want to mark a cube (i.e. 12 lines), like a box, around the origin.
The following code does that; however, when I have the plot and want to zoom in by selecting a region with the mouse, it all goes wrong. Parts of the plot move, others don’t and the relative positions go wrong. I guess this is because there are 4 TH3D plots on top of each other and only some of them scale, or something. How can I avoid that and still have only one plot with different colours (and marker styles) for different points?
TH3D* h3d = new TH3D("h3d", "h3d", 100, hmin, hmax, 100, hmin, hmax, 50, hminz, hmaxz);
TH3D* h3d_2 = h3d->Clone();
TH3D* h3d_3 = h3d->Clone();
TH3D* h3d_4 = h3d->Clone();
h3d->Fill(source_x, source_y, source_z);
h3d->SetMarkerColor(kBlack);
h3d->SetMarkerSize(1);
h3d->SetMarkerStyle(20);
h3d->Draw("P");
h3d_2->Fill(hitabs_x, hitabs_y, hitabs_z);
h3d_2->SetMarkerColor(kRed);
h3d_2->SetMarkerSize(1);
h3d_2->SetMarkerStyle(20);
h3d_2->DrawClone("P SAME");
h3d_3->Fill(hitscat_x, hitscat_y, hitscat_z);
h3d_3->SetMarkerColor(kBlue);
h3d_3->SetMarkerSize(1);
h3d_3->SetMarkerStyle(20);
h3d_3->DrawClone("P SAME");
/*
TPolyLine3D* axisFov1 = new TPolyLine3D(6);
axisFov1->SetLineColor(kBlack);
axisFov1->SetLineWidth(1);
axisFov1->SetPoint(0, fov_x_min, fov_y_min, fov_z_min);
axisFov1->SetPoint(1, fov_x_max, fov_y_min, fov_z_min);
// etc ...
axisFov1->Draw("SAME");
*/
double x = fov_x_min; double delx = (fov_x_max - fov_x_min)/100;
double y = fov_y_min; double dely = (fov_y_max - fov_y_min)/100;
double z = fov_z_min; double delz = (fov_z_max - fov_z_min)/100;
for (int istep = 0; istep < 100; istep++)
{
h3d_4->Fill(x, fov_y_min, fov_z_min);
h3d_4->Fill(x, fov_y_max, fov_z_min);
h3d_4->Fill(x, fov_y_min, fov_z_max);
h3d_4->Fill(x, fov_y_max, fov_z_max);
h3d_4->Fill(fov_x_min, y, fov_z_min);
h3d_4->Fill(fov_x_max, y, fov_z_min);
h3d_4->Fill(fov_x_min, y, fov_z_max);
h3d_4->Fill(fov_x_max, y, fov_z_max);
h3d_4->Fill(fov_x_min, fov_y_min, z);
h3d_4->Fill(fov_x_max, fov_y_min, z);
h3d_4->Fill(fov_x_min, fov_y_max, z);
h3d_4->Fill(fov_x_max, fov_y_max, z);
x += delx;
y += dely;
z += delz;
}
h3d_4->SetMarkerColor(kBlack);
h3d_4->DrawClone("SAME");