Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/tracking_performances/NhitsvsEta_ePIC.C
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void NhitsvsEta_ePIC(TString filePath="", TString label="", TString output_prefi
hits->SetLineWidth(2);
hits->Draw("hist");
TPaveText *pt = new TPaveText(0.1, 0.95, 0.9, 1.0, "NDC");
pt->AddText(Form("p_{mc} = %1.1f GeV/c",pmc));
pt->AddText(Form("MC Truth-Level Hits; p_{mc} = %1.1f GeV/c",pmc));
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->SetTextAlign(23);
Expand Down
15 changes: 14 additions & 1 deletion benchmarks/tracking_performances/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ rule tracking_performance_summary_at_eta:
"{CAMPAIGN}/truthseed/pi-/dca/final_hist_dca_truthseed.root",
"{CAMPAIGN}/realseed/pi-/dca/final_hist_dca_realseed.root",
script_mom="benchmarks/tracking_performances/doCompare_truth_real_widebins_mom.C",
script_pulls="benchmarks/tracking_performances/draw_Pulls.C",
script_dcaT="benchmarks/tracking_performances/doCompare_truth_real_widebins_dcaT.C",
script_dcaz="benchmarks/tracking_performances/doCompare_truth_real_widebins_dcaz.C",
output:
Expand All @@ -186,6 +187,14 @@ rule tracking_performance_summary_at_eta:
),
"{CAMPAIGN}/Final_Results/pi-/mom/mom_resol_{ETA_MIN}_eta_{ETA_MAX}.png",
"{CAMPAIGN}/Final_Results/pi-/mom/mom_resol_{ETA_MIN}_eta_{ETA_MAX}.root",
"{CAMPAIGN}/Final_Results/pi-/mom/hpulls_{ETA_MIN}_eta_{ETA_MAX}_pmax_0.5.png",
"{CAMPAIGN}/Final_Results/pi-/mom/hpulls_{ETA_MIN}_eta_{ETA_MAX}_pmax_0.5.root",
"{CAMPAIGN}/Final_Results/pi-/mom/hpulls_{ETA_MIN}_eta_{ETA_MAX}_pmax_1.0.png",
"{CAMPAIGN}/Final_Results/pi-/mom/hpulls_{ETA_MIN}_eta_{ETA_MAX}_pmax_1.0.root",
"{CAMPAIGN}/Final_Results/pi-/mom/hpulls_{ETA_MIN}_eta_{ETA_MAX}_pmax_2.0.png",
"{CAMPAIGN}/Final_Results/pi-/mom/hpulls_{ETA_MIN}_eta_{ETA_MAX}_pmax_2.0.root",
"{CAMPAIGN}/Final_Results/pi-/mom/hpulls_{ETA_MIN}_eta_{ETA_MAX}_pmax_20.0.png",
"{CAMPAIGN}/Final_Results/pi-/mom/hpulls_{ETA_MIN}_eta_{ETA_MAX}_pmax_20.0.root",
"{CAMPAIGN}/Final_Results/pi-/dca/dcaxy_resol_{ETA_MIN}_eta_{ETA_MAX}.png",
"{CAMPAIGN}/Final_Results/pi-/dca/dcaxy_resol_{ETA_MIN}_eta_{ETA_MAX}.root",
"{CAMPAIGN}/Final_Results/pi-/dca/dcaz_resol_{ETA_MIN}_eta_{ETA_MAX}.png",
Expand All @@ -208,6 +217,7 @@ else
fi
cd {wildcards.CAMPAIGN}
root -l -b -q ../{input.script_mom}'("pi-", {wildcards.ETA_MIN}, {wildcards.ETA_MAX}, 1., true, "'"$EXTRA_LEGEND"'")'
root -l -b -q ../{input.script_pulls}'("pi-", {wildcards.ETA_MIN}, {wildcards.ETA_MAX})'
root -l -b -q ../{input.script_dcaT}'("pi-", {wildcards.ETA_MIN}, {wildcards.ETA_MAX}, true, "'"$EXTRA_LEGEND"'")'
root -l -b -q ../{input.script_dcaz}'("pi-", {wildcards.ETA_MIN}, {wildcards.ETA_MAX}, true, "'"$EXTRA_LEGEND"'")'
"""
Expand Down Expand Up @@ -239,9 +249,12 @@ rule tracking_performance:
[
"{{CAMPAIGN}}/Final_Results/pi-/mom/mom_resol_{ETA_BIN}.png",
"{{CAMPAIGN}}/Final_Results/pi-/mom/mom_resol_{ETA_BIN}.root",
"{{CAMPAIGN}}/Final_Results/pi-/mom/hpulls_{ETA_BIN}_pmax_{PMAX}.png",
"{{CAMPAIGN}}/Final_Results/pi-/mom/hpulls_{ETA_BIN}_pmax_{PMAX}.root",
"{{CAMPAIGN}}/Debug_Plots/pi-/mom/mom_resol_debug_{ETA_BIN}.png",
],
ETA_BIN=[f"{eta_min:.1f}_eta_{eta_max:.1f}" for eta_min, eta_max in zip(TRACKING_PERFORMANCE_ETA_BINS[:-1], TRACKING_PERFORMANCE_ETA_BINS[1:])],
PMAX=["0.5","1.0","2.0","20.0"],
),
lambda wildcards: branch(
wildcards.CAMPAIGN == "local",
Expand Down Expand Up @@ -274,8 +287,8 @@ rule tracking_performance_campaigns:
expand(
"results/tracking_performances/{CAMPAIGN}",
CAMPAIGN=[
"24.10.1",
"25.07.0",
"25.08.0",
"25.10.4",
],
)
65 changes: 56 additions & 9 deletions benchmarks/tracking_performances/Tracking_Performances.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Code to extract the Tracking Performances
// Shyam Kumar; INFN Bari, Italy
// [email protected]; [email protected]
// Pull distributions: https://indico.bnl.gov/event/28544/contributions/109057/attachments/62799/108633/ePIC_Tracking_Meeting_30June2025_ShyamKumar.pdf

#include "TGraphErrors.h"
#include "TF1.h"
Expand Down Expand Up @@ -30,7 +31,7 @@ void Tracking_Performances(TString filename="tracking_output",TString particle="
int nfiles = 100;
double eta[nbins_eta+1]={-3.5,-2.5,-1.0,1.0,2.5,3.5};
double pt[nbins_eta+1]={0.5,1.0,2.0,5.0,10.0,20.1};
TH1D *histp[nbins_eta];
TH1D *histp[nbins_eta], *hpull_invp[nbins_eta], *hpull_d0xy[nbins_eta], *hpull_d0z[nbins_eta], *hpull_phi[nbins_eta], *hpull_theta[nbins_eta];

TH3D *h_d0xy_3d= new TH3D("h_d0xy_3d","Transverse Pointing Resolution",500,-0.1,0.1,70,-3.5,3.5,201,0.,20.1);
TH3D *h_d0z_3d= new TH3D("h_d0z_3d","Longitudinal Pointing Resolution",500,-0.1,0.1,70,-3.5,3.5,201,0.,20.1);
Expand All @@ -39,6 +40,26 @@ void Tracking_Performances(TString filename="tracking_output",TString particle="
histp[i] = new TH1D(Form("hist_etabin%d",i),Form("hist_etabin%d",i),600,-0.3,0.3);
histp[i]->SetTitle(Form("%1.1f < #eta < %1.1f && p = %1.1f ",eta[i],eta[i+1],mom));
histp[i]->SetName(Form("hist_mom_%1.1f_%1.1f_pmax_%1.1f",mom,eta[i],eta[i+1]));

hpull_invp[i] = new TH1D(Form("hpull_invp_etabin%d",i),Form("hist_etabin%d",i),100,-10.0,10.0);
hpull_invp[i]->SetTitle(Form("%1.1f < #eta < %1.1f && p = %1.1f (GeV/c);Pull (q/p);Entries (a.u.)",eta[i],eta[i+1],mom));
hpull_invp[i]->SetName(Form("hpull_invp_%1.1f_%1.1f_pmax_%1.1f",mom,eta[i],eta[i+1]));

hpull_d0xy[i] = new TH1D(Form("hpull_d0xy_etabin%d",i),Form("hist_etabin%d",i),100,-10.0,10.0);
hpull_d0xy[i]->SetTitle(Form("%1.1f < #eta < %1.1f && p = %1.1f (GeV/c);Pull (d0_{xy});Entries (a.u.)",eta[i],eta[i+1],mom));
hpull_d0xy[i]->SetName(Form("hpull_d0xy_%1.1f_%1.1f_pmax_%1.1f",mom,eta[i],eta[i+1]));

hpull_d0z[i] = new TH1D(Form("hpull_d0z_etabin%d",i),Form("hist_etabin%d",i),100,-10.0,10.0);
hpull_d0z[i]->SetTitle(Form("%1.1f < #eta < %1.1f && p = %1.1f (GeV/c);Pull (d0_{z});Entries (a.u.)",eta[i],eta[i+1],mom));
hpull_d0z[i]->SetName(Form("hpull_d0z_%1.1f_%1.1f_pmax_%1.1f",mom,eta[i],eta[i+1]));

hpull_phi[i] = new TH1D(Form("hpull_phi_etabin%d",i),Form("hist_etabin%d",i),100,-10.0,10.0);
hpull_phi[i]->SetTitle(Form("%1.1f < #eta < %1.1f && p = %1.1f (GeV/c);Pull (#phi);Entries (a.u.)",eta[i],eta[i+1],mom));
hpull_phi[i]->SetName(Form("hpull_phi_%1.1f_%1.1f_pmax_%1.1f",mom,eta[i],eta[i+1]));

hpull_theta[i] = new TH1D(Form("hpull_theta_etabin%d",i),Form("hist_etabin%d",i),100,-10.0,10.0);
hpull_theta[i]->SetTitle(Form("%1.1f < #eta < %1.1f && p = %1.1f (GeV/c);Pull (#theta);Entries (a.u.)",eta[i],eta[i+1],mom));
hpull_theta[i]->SetName(Form("hpull_theta_%1.1f_%1.1f_pmax_%1.1f",mom,eta[i],eta[i+1]));
}

TFile* file = TFile::Open(filename.Data());
Expand Down Expand Up @@ -88,6 +109,7 @@ void Tracking_Performances(TString filename="tracking_output",TString particle="
TTreeReaderArray<Float_t> theta(myReader, Form("CentralCKF%sTrackParameters.theta",tag.Data()));
TTreeReaderArray<Float_t> phi(myReader, Form("CentralCKF%sTrackParameters.phi",tag.Data()));
TTreeReaderArray<Float_t> qoverp(myReader, Form("CentralCKF%sTrackParameters.qOverP",tag.Data()));
TTreeReaderArray<std::array<float, 21>> rcTrkCov(myReader, Form("CentralCKF%sTrackParameters.covariance.covariance[21]",tag.Data()));

int count =0;
int matchId = 1; // Always matched track assigned the index 0
Expand All @@ -99,21 +121,39 @@ void Tracking_Performances(TString filename="tracking_output",TString particle="
for (int j = 0; j < pdg.GetSize(); ++j){

if (status[j] !=1 && pdg.GetSize()!=1) continue;
Double_t ptmc = sqrt(px_mc[j]*px_mc[j]+py_mc[j]*py_mc[j]);

if (fabs(ptmc) < pTcut) continue;

Double_t pmc = (1./charge[j])*sqrt(px_mc[j]*px_mc[j]+py_mc[j]*py_mc[j]+pz_mc[j]*pz_mc[j]); // 1./(q/p); similar to prec
TVector3 mom_MC(px_mc[j],py_mc[j],pz_mc[j]);
Double_t theta_mc = mom_MC.Theta();
Double_t phi_mc = mom_MC.Phi();
Double_t ptmc = mom_MC.Pt();
Double_t etamc = mom_MC.Eta();

if (fabs(ptmc) < pTcut) continue;
Double_t pmc = mom_MC.Mag() / charge[j]; // 1./(q/p); similar to prec
Double_t prec = 1./qoverp[j];

Double_t pzrec = prec*TMath::Cos(theta[j]); Double_t pt_rec = sqrt(prec*prec-pzrec*pzrec);
Double_t pzmc = pz_mc[j];

Double_t etamc = -1.0*TMath::Log(TMath::Tan((TMath::ACos(pzmc/fabs(pmc)))/2));
// Double_t etamc = -1.0*TMath::Log(TMath::Tan((TMath::ACos(pzmc/fabs(pmc)))/2));
Double_t p_resol = (prec-pmc)/pmc;
// Accessing the pull distributions
std::array<float, 21>& cov = rcTrkCov.At(j); // access covariance
Double_t pull_invmom = (fabs(1./prec)-fabs(1./pmc))/sqrt(cov[14]); // cov[14] = sigma_1/p^2
Double_t pull_dcaxy = d0xy[j]/sqrt(cov[0]); // cov[0] = sigma_l0^2
Double_t pull_dcaz = d0z[j]/sqrt(cov[2]); // cov[2] = sigma_l1^2
Double_t pull_phi = (phi[j]-phi_mc)/sqrt(cov[5]); // cov[5] = sigma_phi^2
Double_t pull_theta = (theta[j]-theta_mc)/sqrt(cov[9]); // cov[9] = sigma_theta^2


for (int ibin=0; ibin<nbins_eta; ++ibin){
if(etamc>eta[ibin] && etamc<eta[ibin+1]) histp[ibin]->Fill(p_resol);
if(etamc>eta[ibin] && etamc<eta[ibin+1]){
histp[ibin]->Fill(p_resol);
hpull_invp[ibin]->Fill(pull_invmom);
hpull_d0xy[ibin]->Fill(pull_dcaxy);
hpull_d0z[ibin]->Fill(pull_dcaz);
hpull_phi[ibin]->Fill(pull_phi);
hpull_theta[ibin]->Fill(pull_theta);
}
}
h_d0xy_3d->Fill(d0xy[j]*0.1, etamc, ptmc); // cm
h_d0z_3d->Fill(d0z[j]*0.1, etamc, ptmc); // cm
Expand All @@ -124,7 +164,14 @@ void Tracking_Performances(TString filename="tracking_output",TString particle="

TFile *fout_mom = new TFile(Form("%s/%s/mom/Performances_mom_%1.1f_%s_%s.root",dir.Data(),particle.Data(),mom,dist_dir_mom.Data(),particle.Data()),"recreate");
fout_mom->cd();
for (int ibin=0; ibin<nbins_eta; ++ibin) histp[ibin]->Write();
for (int ibin=0; ibin<nbins_eta; ++ibin){
histp[ibin]->Write();
hpull_invp[ibin]->Write();
hpull_d0xy[ibin]->Write();
hpull_d0z[ibin]->Write();
hpull_phi[ibin]->Write();
hpull_theta[ibin]->Write();
}
fout_mom->Close();

TFile *fout_dca = new TFile(Form("%s/%s/dca/Performances_dca_%1.1f_%s_%s.root",dir.Data(),particle.Data(),mom,dist_dir_dca.Data(),particle.Data()),"recreate");
Expand Down
71 changes: 71 additions & 0 deletions benchmarks/tracking_performances/draw_Pulls.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Macro to draw the pulls of the track parameters
// Shyam Kumar; INFN Bari, [email protected]

void draw_Pulls(TString particle = "pi-", double etamin = -1.0, double etamax = 1.0){

gStyle->SetPalette(kRainBow);
gStyle->SetTitleSize(0.045,"XY");
gStyle->SetTitleSize(0.04,"XY");
gStyle->SetLabelSize(0.04,"XY");
gStyle->SetTitleOffset(1.0,"XY");
gStyle->SetOptStat(1);
gStyle->SetOptFit(1);
gStyle->SetOptTitle(1);
gStyle->SetGridColor(kBlack);
gStyle->SetGridWidth(2);
gStyle->SetGridStyle(2);

const Int_t nfiles = 6;
double mom[nfiles] ={0.5,1.0,2.0,5.0,10.0,20.0};
TFile *fmom_real[nfiles];

for (int i =0; i<nfiles; ++i){

TCanvas *can = new TCanvas("can","can",2000,1000);
can->Divide(3,2);

fmom_real[i] = TFile::Open(Form("./realseed/pi-/mom/Performances_mom_%1.1f_mom_resol_realseed_%s.root",mom[i],particle.Data()));
TH1D *hpull_invp = (TH1D*) fmom_real[i]->Get(Form("hpull_invp_%1.1f_%1.1f_pmax_%1.1f",mom[i],etamin,etamax));
TH1D *hpull_d0xy = (TH1D*) fmom_real[i]->Get(Form("hpull_d0xy_%1.1f_%1.1f_pmax_%1.1f",mom[i],etamin,etamax));
TH1D *hpull_d0z = (TH1D*) fmom_real[i]->Get(Form("hpull_d0z_%1.1f_%1.1f_pmax_%1.1f",mom[i],etamin,etamax));
TH1D *hpull_phi = (TH1D*) fmom_real[i]->Get(Form("hpull_phi_%1.1f_%1.1f_pmax_%1.1f",mom[i],etamin,etamax));
TH1D *hpull_theta = (TH1D*) fmom_real[i]->Get(Form("hpull_theta_%1.1f_%1.1f_pmax_%1.1f",mom[i],etamin,etamax));

can->cd(1);
hpull_invp->Draw("hist");

can->cd(2);
hpull_d0xy->Draw("hist");

can->cd(3);
hpull_d0z->Draw("hist");

can->cd(4);
hpull_phi->Draw("hist");

can->cd(5);
hpull_theta->Draw("hist");
can->SaveAs(Form("Final_Results/%s/mom/hpulls_%1.1f_eta_%1.1f_pmax_%1.1f.png",particle.Data(),etamin,etamax,mom[i]));
can->SaveAs(Form("Final_Results/%s/mom/hpulls_%1.1f_eta_%1.1f_pmax_%1.1f.root",particle.Data(),etamin,etamax,mom[i]));
}

}