Skip to content

Commit 94799ff

Browse files
authored
[ALICE3] TRK: fix macro CheckDigits.C (#15136)
1 parent 095ccb4 commit 94799ff

File tree

1 file changed

+82
-30
lines changed

1 file changed

+82
-30
lines changed

Detectors/Upgrades/ALICE3/TRK/macros/test/CheckDigits.C

Lines changed: 82 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
#include <TNtuple.h>
2020
#include <TString.h>
2121
#include <TTree.h>
22+
#include <TLine.h>
23+
#include <TStyle.h>
2224

2325
#include "TRKBase/SegmentationChip.h"
2426
#include "TRKBase/GeometryTGeo.h"
2527
#include "DataFormatsITSMFT/Digit.h"
26-
#include "ITSMFTSimulation/Hit.h"
28+
#include "TRKSimulation/Hit.h"
2729
#include "MathUtils/Utils.h"
2830
#include "SimulationDataFormat/ConstMCTruthContainer.h"
2931
#include "SimulationDataFormat/IOMCTruthContainerView.h"
@@ -36,14 +38,50 @@
3638

3739
#define ENABLE_UPGRADES
3840

39-
void CheckDigits(std::string digifile = "trkdigits.root", std::string hitfile = "o2sim_HitsTRK.root", std::string inputGeom = "", std::string paramfile = "o2sim_par.root")
41+
void addTLines(float pitch)
4042
{
43+
// Add grid lines at multiples of pitch on the current pad
44+
if (!gPad)
45+
return;
46+
47+
gPad->Update();
48+
49+
Double_t xmin = gPad->GetUxmin();
50+
Double_t xmax = gPad->GetUxmax();
51+
Double_t ymin = gPad->GetUymin();
52+
Double_t ymax = gPad->GetUymax();
53+
54+
// Calculate the first vertical line position (multiple of pitch)
55+
int nLinesX = 0;
56+
for (float x = xmin; x <= xmax && nLinesX < 1000; x += pitch, nLinesX++) {
57+
TLine* line = new TLine(x, ymin, x, ymax);
58+
line->SetLineStyle(2);
59+
line->SetLineColor(kGray);
60+
line->Draw("same");
61+
}
62+
63+
// Calculate the first horizontal line position (multiple of pitch)
64+
int nLinesY = 0;
65+
for (float y = ymin; y <= ymax && nLinesY < 1000; y += pitch, nLinesY++) {
66+
TLine* line = new TLine(xmin, y, xmax, y);
67+
line->SetLineStyle(2);
68+
line->SetLineColor(kGray);
69+
line->Draw("same");
70+
}
71+
72+
gPad->Modified();
73+
gPad->Update();
74+
}
75+
76+
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")
77+
{
78+
gStyle->SetPalette(55);
4179

4280
using namespace o2::base;
4381
using namespace o2::trk;
4482

4583
using o2::itsmft::Digit;
46-
using o2::itsmft::Hit;
84+
using o2::trk::Hit;
4785

4886
using o2::trk::SegmentationChip;
4987

@@ -64,7 +102,7 @@ void CheckDigits(std::string digifile = "trkdigits.root", std::string hitfile =
64102
TFile* hitFile = TFile::Open(hitfile.data());
65103
TTree* hitTree = (TTree*)hitFile->Get("o2sim");
66104
int nevH = hitTree->GetEntries(); // hits are stored as one event per entry
67-
std::vector<std::vector<o2::itsmft::Hit>*> hitArray(nevH, nullptr);
105+
std::vector<std::vector<o2::trk::Hit>*> hitArray(nevH, nullptr);
68106

69107
std::vector<std::unordered_map<uint64_t, int>> mc2hitVec(nevH);
70108

@@ -273,110 +311,124 @@ void CheckDigits(std::string digifile = "trkdigits.root", std::string hitfile =
273311
auto canvXY = new TCanvas("canvXY", "", 1600, 2400);
274312
canvXY->Divide(2, 3);
275313
canvXY->cd(1);
276-
nt->Draw("y:x >>h_y_vs_x_VD(1000, -3, 3, 1000, -3, 3)", "id < 36 ", "colz");
314+
nt->Draw("y:x >>h_y_vs_x_VD(1000, -3, 3, 1000, -3, 3)", "id < 12 ", "colz");
277315
canvXY->cd(2);
278-
nt->Draw("y:z>>h_y_vs_z_VD(1000, -26, 26, 1000, -3, 3)", "id < 36 ", "colz");
316+
nt->Draw("y:z>>h_y_vs_z_VD(1000, -26, 26, 1000, -3, 3)", "id < 12 ", "colz");
279317
canvXY->cd(3);
280-
nt->Draw("y:x>>h_y_vs_x_ML(1000, -25, 25, 1000, -25, 25)", "id >= 36 && id < 106 ", "colz");
318+
nt->Draw("y:x>>h_y_vs_x_ML(1000, -25, 25, 1000, -25, 25)", "id >= 12 && id < 5132 ", "colz");
281319
canvXY->cd(4);
282-
nt->Draw("y:z>>h_y_vs_z_ML(1000, -70, 70, 1000, -25, 25)", "id >= 36 && id < 106 ", "colz");
320+
nt->Draw("y:z>>h_y_vs_z_ML(1000, -70, 70, 1000, -25, 25)", "id >= 12 && id < 5132 ", "colz");
283321
canvXY->cd(5);
284-
nt->Draw("y:x>>h_y_vs_x_OT(1000, -85, 85, 1000, -85, 85)", "id >= 106 ", "colz");
322+
nt->Draw("y:x>>h_y_vs_x_OT(1000, -85, 85, 1000, -85, 85)", "id >= 5132 ", "colz");
285323
canvXY->cd(6);
286-
nt->Draw("y:z>>h_y_vs_z_OT(1000, -85, 85, 1000, -130, 130)", "id >= 106 ", "colz");
324+
nt->Draw("y:z>>h_y_vs_z_OT(1000, -85, 85, 1000, -130, 130)", "id >= 5132 ", "colz");
287325
canvXY->SaveAs("trkdigits_y_vs_x_vs_z.pdf");
288326

289327
// z distributions
290328
auto canvZ = new TCanvas("canvZ", "", 800, 2400);
291329
canvZ->Divide(1, 3);
292330
canvZ->cd(1);
293-
nt->Draw("z>>h_z_VD(500, -26, 26)", "id < 36 ");
331+
nt->Draw("z>>h_z_VD(500, -26, 26)", "id < 12 ");
294332
canvZ->cd(2);
295-
nt->Draw("z>>h_z_ML(500, -70, 70)", "id >= 36 && id < 106 ");
333+
nt->Draw("z>>h_z_ML(500, -70, 70)", "id >= 12 && id < 5132 ");
296334
canvZ->cd(3);
297-
nt->Draw("z>>h_z_OT(500, -85, 85)", "id >= 106 ");
335+
nt->Draw("z>>h_z_OT(500, -85, 85)", "id >= 5132 ");
298336
canvZ->SaveAs("trkdigits_z.pdf");
299337

300338
// dz distributions (difference between local position of digits and hits in x and z)
301339
auto canvdZ = new TCanvas("canvdZ", "", 800, 2400);
302340
canvdZ->Divide(1, 3);
303341
canvdZ->cd(1);
304-
nt->Draw("dz>>h_dz_VD(500, -0.05, 0.05)", "id < 36 ");
342+
nt->Draw("dz>>h_dz_VD(500, -0.05, 0.05)", "id < 12 ");
305343
canvdZ->cd(2);
306-
nt->Draw("dz>>h_dz_ML(500, -0.05, 0.05)", "id >= 36 && id < 106 ");
344+
nt->Draw("dz>>h_dz_ML(500, -0.05, 0.05)", "id >= 12 && id < 5132 ");
307345
canvdZ->cd(3);
308-
nt->Draw("dz>>h_dz_OT(500, -0.05, 0.05)", "id >= 106 ");
346+
nt->Draw("dz>>h_dz_OT(500, -0.05, 0.05)", "id >= 5132 ");
309347
canvdZ->SaveAs("trkdigits_dz.pdf");
348+
canvdZ->SaveAs("trkdigits_dz.root");
310349

311350
// distributions of differences between local positions of digits and hits in x and z
312351
auto canvdXdZ = new TCanvas("canvdXdZ", "", 1600, 2400);
313352
canvdXdZ->Divide(2, 3);
314353
canvdXdZ->cd(1);
315-
nt->Draw("dx:dz>>h_dx_vs_dz_VD(300, -0.03, 0.03, 300, -0.03, 0.03)", "id < 36", "colz");
354+
nt->Draw("dx:dz>>h_dx_vs_dz_VD(500, -0.005, 0.005, 500, -0.005, 0.005)", "id < 12", "colz");
355+
addTLines(o2::trk::SegmentationChip::PitchRowVD);
316356
auto h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_VD");
317357
LOG(info) << "dx, dz";
318358
Info("VD", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4);
319359
Info("VD", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4);
320360
canvdXdZ->cd(2);
321-
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");
361+
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");
362+
addTLines(o2::trk::SegmentationChip::PitchRowVD);
322363
h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_VD_z");
323-
Info("VD |z|<2", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4);
324-
Info("VD |z|<2", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4);
364+
Info("VD |z|<1", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4);
365+
Info("VD |z|<1", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4);
325366
canvdXdZ->cd(3);
326-
nt->Draw("dx:dz>>h_dx_vs_dz_ML(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 36 && id < 106", "colz");
367+
nt->Draw("dx:dz>>h_dx_vs_dz_ML(600, -0.03, 0.03, 600, -0.03, 0.03)", "id >= 12 && id < 5132", "colz");
368+
addTLines(o2::trk::SegmentationChip::PitchRowMLOT);
327369
h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_ML");
328370
Info("ML", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4);
329371
Info("ML", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4);
330372
canvdXdZ->cd(4);
331-
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");
373+
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");
374+
addTLines(o2::trk::SegmentationChip::PitchRowMLOT);
332375
h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_ML_z");
333376
Info("ML |z|<2", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4);
334377
Info("ML |z|<2", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4);
335378
canvdXdZ->SaveAs("trkdigits_dx_vs_dz.pdf");
336379
canvdXdZ->cd(5);
337-
nt->Draw("dx:dz>>h_dx_vs_dz_OT(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 106", "colz");
380+
nt->Draw("dx:dz>>h_dx_vs_dz_OT(600, -0.03, 0.03, 600, -0.03, 0.03)", "id >= 5132", "colz");
381+
addTLines(o2::trk::SegmentationChip::PitchRowMLOT);
338382
h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_OT");
339383
Info("OT", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4);
340384
Info("OT", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4);
341385
canvdXdZ->cd(6);
342-
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");
386+
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");
343387
h = (TH2F*)gPad->GetPrimitive("h_dx_vs_dz_OT_z");
388+
addTLines(o2::trk::SegmentationChip::PitchRowMLOT);
344389
Info("OT |z|<2", "RMS(dx)=%.1f mu", h->GetRMS(2) * 1e4);
345390
Info("OT |z|<2", "RMS(dz)=%.1f mu", h->GetRMS(1) * 1e4);
346391
canvdXdZ->SaveAs("trkdigits_dx_vs_dz.pdf");
392+
canvdXdZ->SaveAs("trkdigits_dx_vs_dz.root");
347393

348394
// distribution of differences between hit start and hit end in local coordinates
349395
auto canvdXdZHit = new TCanvas("canvdXdZHit", "", 1600, 2400);
350396
canvdXdZHit->Divide(2, 3);
351397
canvdXdZHit->cd(1);
352-
nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_VD(300, -0.03, 0.03, 300, -0.03, 0.03)", "id < 36", "colz");
398+
nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_VD(300, -0.03, 0.03, 300, -0.03, 0.03)", "id < 12", "colz");
399+
addTLines(o2::trk::SegmentationChip::PitchRowVD);
353400
LOG(info) << "dxH, dzH";
354401
h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_VD");
355402
Info("VD", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4);
356403
Info("VD", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4);
357404
canvdXdZHit->cd(2);
358-
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");
405+
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");
406+
addTLines(o2::trk::SegmentationChip::PitchRowVD);
359407
h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_VD_z");
360408
Info("VD |z|<2", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4);
361409
Info("VD |z|<2", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4);
362410
canvdXdZHit->cd(3);
363-
nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_ML(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 36 && id < 106", "colz");
411+
nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_ML(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 12 && id < 5132", "colz");
412+
addTLines(o2::trk::SegmentationChip::PitchRowMLOT);
364413
h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_ML");
365414
Info("ML", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4);
366415
Info("ML", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4);
367416
canvdXdZHit->cd(4);
368-
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");
417+
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");
418+
addTLines(o2::trk::SegmentationChip::PitchRowMLOT);
369419
h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_ML_z");
370420
Info("ML |z|<2", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4);
371421
Info("ML |z|<2", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4);
372422
canvdXdZHit->SaveAs("trkdigits_dxH_vs_dzH.pdf");
373423
canvdXdZHit->cd(5);
374-
nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_OT(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 106", "colz");
424+
nt2->Draw("dxH:dzH>>h_dxH_vs_dzH_OT(300, -0.03, 0.03, 300, -0.03, 0.03)", "id >= 5132", "colz");
425+
addTLines(o2::trk::SegmentationChip::PitchRowMLOT);
375426
h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_OT");
376427
Info("OT", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4);
377428
Info("OT", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4);
378429
canvdXdZHit->cd(6);
379-
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");
430+
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");
431+
addTLines(o2::trk::SegmentationChip::PitchRowMLOT);
380432
h = (TH2F*)gPad->GetPrimitive("h_dxH_vs_dzH_OT_z");
381433
Info("OT |z|<2", "RMS(dxH)=%.1f mu", h->GetRMS(2) * 1e4);
382434
Info("OT |z|<2", "RMS(dzH)=%.1f mu", h->GetRMS(1) * 1e4);

0 commit comments

Comments
 (0)