Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:17

0001 void draw_clusterMutualDeltaR()
0002 {
0003 std::string plotdir = "./clusterMutualDeltaR";
0004     system(Form("mkdir -p %s", plotdir.c_str()));
0005 
0006     // data histogram
0007     TFile *fdata = new TFile("/sphenix/user/hjheng/sPHENIXRepo/analysis/dNdEta_Run2023/analysis_INTT/plot/hists/Data_Run54280_20250117_ProdA2024/Cluster/hists_merged.root", "READ");
0008     TH1F *hdata = (TH1F *)fdata->Get("hM_mutualdRcluster_all");
0009     hdata->SetDirectory(0);
0010     fdata->Close();
0011 
0012     TFile *fsim = new TFile("/sphenix/user/hjheng/sPHENIXRepo/analysis/dNdEta_Run2023/analysis_INTT/plot/hists/Sim_HIJING_ananew_20250131/Cluster/hists_merged.root", "READ");
0013     TH1F *hsim = (TH1F *)fsim->Get("hM_mutualdRcluster_all");
0014     hsim->SetDirectory(0);
0015     fsim->Close();
0016 
0017     // normalize the histograms
0018     hdata->Scale(1.0 / hdata->Integral());
0019     hsim->Scale(1.0 / hsim->Integral());
0020     // rebin 
0021     // hdata->Rebin(2);
0022     // hsim->Rebin(2);
0023 
0024     // draw the histograms
0025     TCanvas *c = new TCanvas("c", "c", 800, 700);
0026     c->cd();
0027     hsim->SetLineColor(kRed);
0028     hsim->SetLineWidth(2);
0029     hsim->GetXaxis()->SetTitle("#DeltaR(cluster_{i}, cluster_{j})");
0030     hsim->GetXaxis()->SetNdivisions(505);
0031     hsim->GetYaxis()->SetTitle("Normalized entries");
0032     hsim->GetYaxis()->SetTitleOffset(1.7);
0033     hsim->GetYaxis()->SetRangeUser(0, max(hdata->GetMaximum(), hsim->GetMaximum()) * 1.2);
0034     hsim->Draw("hist");
0035     hdata->SetLineColor(kBlack);
0036     hdata->SetLineWidth(2);
0037     hdata->SetMarkerStyle(20);
0038     hdata->SetMarkerSize(0.8);
0039     hdata->SetMarkerColor(kBlack);
0040     hdata->Draw("E1 same");
0041     TLegend *leg = new TLegend(gPad->GetLeftMargin() + 0.05, 1 - gPad->GetTopMargin() - 0.1, gPad->GetLeftMargin() + 0.5, 1 - gPad->GetTopMargin() - 0.05);
0042     leg->SetNColumns(2);
0043     leg->AddEntry(hdata, "Data", "lep");
0044     leg->AddEntry(hsim, "Simulation", "l");
0045     leg->SetTextSize(0.04);
0046     leg->SetBorderSize(0);
0047     leg->SetFillStyle(0);
0048     leg->Draw();
0049     c->SaveAs(Form("%s/clusterMutualDeltaR.pdf", plotdir.c_str()));
0050     c->SaveAs(Form("%s/clusterMutualDeltaR.png", plotdir.c_str()));
0051 }