From 26a5be05a6ffe0e655f9ee7d80f14b1f77fe4185 Mon Sep 17 00:00:00 2001 From: Andrea Sofia Triolo Date: Mon, 9 Mar 2026 14:47:12 +0100 Subject: [PATCH] ALICE3-TRK: fix macro CheckDigits.C --- .../ALICE3/TRK/macros/test/CheckDigits.C | 112 +++++++++++++----- 1 file changed, 82 insertions(+), 30 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/TRK/macros/test/CheckDigits.C b/Detectors/Upgrades/ALICE3/TRK/macros/test/CheckDigits.C index 5d60592a96f41..618dbe929a943 100644 --- a/Detectors/Upgrades/ALICE3/TRK/macros/test/CheckDigits.C +++ b/Detectors/Upgrades/ALICE3/TRK/macros/test/CheckDigits.C @@ -19,11 +19,13 @@ #include #include #include +#include +#include #include "TRKBase/SegmentationChip.h" #include "TRKBase/GeometryTGeo.h" #include "DataFormatsITSMFT/Digit.h" -#include "ITSMFTSimulation/Hit.h" +#include "TRKSimulation/Hit.h" #include "MathUtils/Utils.h" #include "SimulationDataFormat/ConstMCTruthContainer.h" #include "SimulationDataFormat/IOMCTruthContainerView.h" @@ -36,14 +38,50 @@ #define ENABLE_UPGRADES -void CheckDigits(std::string digifile = "trkdigits.root", std::string hitfile = "o2sim_HitsTRK.root", std::string inputGeom = "", std::string paramfile = "o2sim_par.root") +void addTLines(float pitch) { + // Add grid lines at multiples of pitch on the current pad + if (!gPad) + return; + + gPad->Update(); + + Double_t xmin = gPad->GetUxmin(); + Double_t xmax = gPad->GetUxmax(); + Double_t ymin = gPad->GetUymin(); + Double_t ymax = gPad->GetUymax(); + + // Calculate the first vertical line position (multiple of pitch) + int nLinesX = 0; + for (float x = xmin; x <= xmax && nLinesX < 1000; x += pitch, nLinesX++) { + TLine* line = new TLine(x, ymin, x, ymax); + line->SetLineStyle(2); + line->SetLineColor(kGray); + line->Draw("same"); + } + + // Calculate the first horizontal line position (multiple of pitch) + int nLinesY = 0; + for (float y = ymin; y <= ymax && nLinesY < 1000; y += pitch, nLinesY++) { + TLine* line = new TLine(xmin, y, xmax, y); + line->SetLineStyle(2); + line->SetLineColor(kGray); + line->Draw("same"); + } + + gPad->Modified(); + gPad->Update(); +} + +void CheckDigits(std::string digifile = "trkdigits.root", std::string hitfile = "o2sim_HitsTRK.root", std::string inputGeom = "o2sim_geometry.root", std::string paramfile = "o2sim_par.root") +{ + gStyle->SetPalette(55); using namespace o2::base; using namespace o2::trk; using o2::itsmft::Digit; - using o2::itsmft::Hit; + using o2::trk::Hit; using o2::trk::SegmentationChip; @@ -64,7 +102,7 @@ void CheckDigits(std::string digifile = "trkdigits.root", std::string hitfile = TFile* hitFile = TFile::Open(hitfile.data()); TTree* hitTree = (TTree*)hitFile->Get("o2sim"); int nevH = hitTree->GetEntries(); // hits are stored as one event per entry - std::vector*> hitArray(nevH, nullptr); + std::vector*> hitArray(nevH, nullptr); std::vector> mc2hitVec(nevH); @@ -273,110 +311,124 @@ void CheckDigits(std::string digifile = "trkdigits.root", std::string hitfile = auto canvXY = new TCanvas("canvXY", "", 1600, 2400); canvXY->Divide(2, 3); canvXY->cd(1); - nt->Draw("y:x >>h_y_vs_x_VD(1000, -3, 3, 1000, -3, 3)", "id < 36 ", "colz"); + nt->Draw("y:x >>h_y_vs_x_VD(1000, -3, 3, 1000, -3, 3)", "id < 12 ", "colz"); canvXY->cd(2); - nt->Draw("y:z>>h_y_vs_z_VD(1000, -26, 26, 1000, -3, 3)", "id < 36 ", "colz"); + nt->Draw("y:z>>h_y_vs_z_VD(1000, -26, 26, 1000, -3, 3)", "id < 12 ", "colz"); canvXY->cd(3); - nt->Draw("y:x>>h_y_vs_x_ML(1000, -25, 25, 1000, -25, 25)", "id >= 36 && id < 106 ", "colz"); + nt->Draw("y:x>>h_y_vs_x_ML(1000, -25, 25, 1000, -25, 25)", "id >= 12 && id < 5132 ", "colz"); canvXY->cd(4); - nt->Draw("y:z>>h_y_vs_z_ML(1000, -70, 70, 1000, -25, 25)", "id >= 36 && id < 106 ", "colz"); + nt->Draw("y:z>>h_y_vs_z_ML(1000, -70, 70, 1000, -25, 25)", "id >= 12 && id < 5132 ", "colz"); canvXY->cd(5); - nt->Draw("y:x>>h_y_vs_x_OT(1000, -85, 85, 1000, -85, 85)", "id >= 106 ", "colz"); + nt->Draw("y:x>>h_y_vs_x_OT(1000, -85, 85, 1000, -85, 85)", "id >= 5132 ", "colz"); canvXY->cd(6); - nt->Draw("y:z>>h_y_vs_z_OT(1000, -85, 85, 1000, -130, 130)", "id >= 106 ", "colz"); + nt->Draw("y:z>>h_y_vs_z_OT(1000, -85, 85, 1000, -130, 130)", "id >= 5132 ", "colz"); canvXY->SaveAs("trkdigits_y_vs_x_vs_z.pdf"); // z distributions auto canvZ = new TCanvas("canvZ", "", 800, 2400); canvZ->Divide(1, 3); canvZ->cd(1); - nt->Draw("z>>h_z_VD(500, -26, 26)", "id < 36 "); + nt->Draw("z>>h_z_VD(500, -26, 26)", "id < 12 "); canvZ->cd(2); - nt->Draw("z>>h_z_ML(500, -70, 70)", "id >= 36 && id < 106 "); + nt->Draw("z>>h_z_ML(500, -70, 70)", "id >= 12 && id < 5132 "); canvZ->cd(3); - nt->Draw("z>>h_z_OT(500, -85, 85)", "id >= 106 "); + nt->Draw("z>>h_z_OT(500, -85, 85)", "id >= 5132 "); canvZ->SaveAs("trkdigits_z.pdf"); // dz distributions (difference between local position of digits and hits in x and z) auto canvdZ = new TCanvas("canvdZ", "", 800, 2400); canvdZ->Divide(1, 3); canvdZ->cd(1); - nt->Draw("dz>>h_dz_VD(500, -0.05, 0.05)", "id < 36 "); + nt->Draw("dz>>h_dz_VD(500, -0.05, 0.05)", "id < 12 "); canvdZ->cd(2); - nt->Draw("dz>>h_dz_ML(500, -0.05, 0.05)", "id >= 36 && id < 106 "); + nt->Draw("dz>>h_dz_ML(500, -0.05, 0.05)", "id >= 12 && id < 5132 "); canvdZ->cd(3); - nt->Draw("dz>>h_dz_OT(500, -0.05, 0.05)", "id >= 106 "); + nt->Draw("dz>>h_dz_OT(500, -0.05, 0.05)", "id >= 5132 "); canvdZ->SaveAs("trkdigits_dz.pdf"); + canvdZ->SaveAs("trkdigits_dz.root"); // distributions of differences between local positions of digits and hits in x and z auto canvdXdZ = new TCanvas("canvdXdZ", "", 1600, 2400); canvdXdZ->Divide(2, 3); canvdXdZ->cd(1); - nt->Draw("dx:dz>>h_dx_vs_dz_VD(300, -0.03, 0.03, 300, -0.03, 0.03)", "id < 36", "colz"); + nt->Draw("dx:dz>>h_dx_vs_dz_VD(500, -0.005, 0.005, 500, -0.005, 0.005)", "id < 12", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowVD); auto h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_VD"); LOG(info) << "dx, dz"; Info("VD", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4); Info("VD", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZ->cd(2); - nt->Draw("dx:dz>>h_dx_vs_dz_VD_z(300, -0.03, 0.03, 300, -0.03, 0.03)", "id < 36 && abs(z)<2", "colz"); + nt->Draw("dx:dz>>h_dx_vs_dz_VD_z(500, -0.005, 0.005, 500, -0.005, 0.005)", "id < 12 && abs(z)<0.5", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowVD); h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_VD_z"); - Info("VD |z|<2", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4); - Info("VD |z|<2", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4); + Info("VD |z|<1", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4); + Info("VD |z|<1", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZ->cd(3); - nt->Draw("dx:dz>>h_dx_vs_dz_ML(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 36 && id < 106", "colz"); + nt->Draw("dx:dz>>h_dx_vs_dz_ML(600, -0.03, 0.03, 600, -0.03, 0.03)", "id >= 12 && id < 5132", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowMLOT); h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_ML"); Info("ML", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4); Info("ML", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZ->cd(4); - nt->Draw("dx:dz>>h_dx_vs_dz_ML_z(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 36 && id < 106 && abs(z)<2", "colz"); + nt->Draw("dx:dz>>h_dx_vs_dz_ML_z(600, -0.03, 0.03, 600, -0.03, 0.03)", "id >= 12 && id < 5132 && abs(z)<2", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowMLOT); h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_ML_z"); Info("ML |z|<2", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4); Info("ML |z|<2", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZ->SaveAs("trkdigits_dx_vs_dz.pdf"); canvdXdZ->cd(5); - nt->Draw("dx:dz>>h_dx_vs_dz_OT(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 106", "colz"); + nt->Draw("dx:dz>>h_dx_vs_dz_OT(600, -0.03, 0.03, 600, -0.03, 0.03)", "id >= 5132", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowMLOT); h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_OT"); Info("OT", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4); Info("OT", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZ->cd(6); - nt->Draw("dx:dz>>h_dx_vs_dz_OT_z(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 106 && abs(z)<2", "colz"); + nt->Draw("dx:dz>>h_dx_vs_dz_OT_z(600, -0.03, 0.03, 600, -0.03, 0.03)", "id >= 5132 && abs(z)<2", "colz"); h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_OT_z"); + addTLines(o2::trk::SegmentationChip::PitchRowMLOT); Info("OT |z|<2", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4); Info("OT |z|<2", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZ->SaveAs("trkdigits_dx_vs_dz.pdf"); + canvdXdZ->SaveAs("trkdigits_dx_vs_dz.root"); // distribution of differences between hit start and hit end in local coordinates auto canvdXdZHit = new TCanvas("canvdXdZHit", "", 1600, 2400); canvdXdZHit->Divide(2, 3); canvdXdZHit->cd(1); - nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_VD(300, -0.03, 0.03, 300, -0.03, 0.03)", "id < 36", "colz"); + nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_VD(300, -0.03, 0.03, 300, -0.03, 0.03)", "id < 12", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowVD); LOG(info) << "dxH, dzH"; h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_VD"); Info("VD", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4); Info("VD", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZHit->cd(2); - nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_VD_z(300, -0.03, 0.03, 300, -0.03, 0.03)", "id < 36 && abs(z)<2", "colz"); + nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_VD_z(300, -0.03, 0.03, 300, -0.03, 0.03)", "id < 12 && abs(z)<2", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowVD); h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_VD_z"); Info("VD |z|<2", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4); Info("VD |z|<2", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZHit->cd(3); - nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_ML(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 36 && id < 106", "colz"); + nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_ML(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 12 && id < 5132", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowMLOT); h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_ML"); Info("ML", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4); Info("ML", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZHit->cd(4); - nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_ML_z(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 36 && id < 106 && abs(z)<2", "colz"); + nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_ML_z(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 12 && id < 5132 && abs(z)<2", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowMLOT); h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_ML_z"); Info("ML |z|<2", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4); Info("ML |z|<2", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZHit->SaveAs("trkdigits_dxH_vs_dzH.pdf"); canvdXdZHit->cd(5); - nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_OT(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 106", "colz"); + nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_OT(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 5132", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowMLOT); h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_OT"); Info("OT", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4); Info("OT", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4); canvdXdZHit->cd(6); - nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_OT_z(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 106 && abs(z)<2", "colz"); + nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_OT_z(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 5132 && abs(z)<2", "colz"); + addTLines(o2::trk::SegmentationChip::PitchRowMLOT); h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_OT_z"); Info("OT |z|<2", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4); Info("OT |z|<2", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4);