Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:13:19

0001 #include "sPhenixStyle.h"
0002 #include "sPhenixStyle.C"
0003 
0004 
0005 void draw_hists() 
0006 {
0007 
0008 
0009   SetsPhenixStyle();
0010   TH1::SetDefaultSumw2();
0011   TH2::SetDefaultSumw2();
0012 
0013   TFile *f = new TFile("hists.root","READ");
0014   TFile *f_pp = new TFile("hists_pp.root","READ");
0015   int ppExists = f_pp->IsOpen();
0016 
0017   TCanvas *c = new TCanvas("c","c");
0018   gPad->SetLogy();
0019 
0020   TLegend *leg = new TLegend(.25,.2,.6,.5);
0021   leg->SetFillStyle(0);
0022   leg->AddEntry("","#it{#bf{sPHENIX}} Internal","");
0023   leg->AddEntry("","Au+Au #sqrt{s_{NN}}=200 GeV","");
0024   leg->AddEntry("","anti-#it{k}_{#it{t}} #it{R} = 0.4, |#eta| < 1.1","");
0025 
0026 
0027   TLegend *cleg = new TLegend(.7,.2,.9,.45);
0028   cleg->SetFillStyle(0);
0029   
0030 
0031   int colors[] = {1,2,4,kGreen+2, kViolet,kCyan,kOrange+2,kMagenta+2,kAzure-2};
0032   string labels[] = {"pp","0-10%","10-30%","30-50%","50-80%"};
0033   TGraphErrors *g_jes[11];
0034   TGraphErrors *g_jer[11];
0035   int ncent = 0;
0036   for(int i = 0; i < 11; i++){
0037     if(!(f->GetListOfKeys()->Contains(Form("g_jes_cent%i",i)))) continue;
0038     g_jes[i] = (TGraphErrors*) f->Get(Form("g_jes_cent%i",i));
0039     g_jer[i] = (TGraphErrors*) f->Get(Form("g_jer_cent%i",i));
0040     ncent++;
0041   }  
0042   TGraphErrors *g_jes_pp;
0043   TGraphErrors *g_jer_pp;
0044   if(ppExists)
0045     {
0046       g_jes_pp = (TGraphErrors*) f_pp->Get("g_jes_cent0");
0047       g_jer_pp = (TGraphErrors*) f_pp->Get("g_jer_cent0");
0048     }
0049 
0050   TCanvas * c2 = new TCanvas("c2","c2");
0051   TMultiGraph *mg1 = new TMultiGraph();
0052   for(int i = 0; i < ncent; i++){
0053     g_jes[i]->SetMarkerColor(colors[i+1]);
0054     g_jes[i]->SetLineColor(colors[i+1]);
0055     mg1->Add(g_jes[i],"p");
0056     cleg->AddEntry(g_jes[i],labels[i].c_str(),"p");
0057     
0058   }
0059   if(ppExists)
0060     {
0061       mg1->Add(g_jes_pp,"p");
0062       cleg->AddEntry(g_jes_pp,"pp","p");
0063     }
0064   mg1->Draw("a");
0065   mg1->SetMinimum(0.);
0066   mg1->SetMaximum(1.);
0067 
0068   mg1->GetXaxis()->SetRangeUser(5,100);
0069   mg1->GetXaxis()->SetTitle("p_{T,truth} [GeV]");
0070   mg1->GetYaxis()->SetTitle("#LTp_{T,reco}/p_{T,truth}#GT");
0071 
0072   leg->Draw();
0073   cleg->Draw();
0074 
0075   TCanvas * c3 = new TCanvas("c3","c3");
0076   TMultiGraph *mg2 = new TMultiGraph();  
0077   TLegend *cleg2 = new TLegend(.3,.6,.5,.9);
0078   cleg2->SetFillStyle(0);
0079 
0080   for(int i = 0; i < ncent; i++){
0081     g_jer[i]->SetMarkerColor(colors[i]);
0082     g_jer[i]->SetLineColor(colors[i]);
0083     mg2->Add(g_jer[i],"p"); 
0084     cleg2->AddEntry(g_jes[i],labels[i].c_str(),"p");
0085   }
0086   if(ppExists)
0087     {
0088       mg2->Add(g_jer_pp,"p");
0089       cleg2->AddEntry(g_jes_pp,"pp","p");
0090     }
0091   mg2->Draw("a");
0092   mg2->SetMinimum(0.);
0093   mg2->SetMaximum(1.0);
0094 
0095   mg2->GetXaxis()->SetTitle("p_{T,truth} [GeV]");
0096   mg2->GetYaxis()->SetTitle("#sigma(p_{T,reco}/p_{T,truth}) / #LTp_{T,reco}/p_{T,truth}#GT");
0097   
0098   TLegend *leg2 = new TLegend(.4,.6,.8,.9);
0099   leg2->SetFillStyle(0);
0100   leg2->AddEntry("","#it{#bf{sPHENIX}} Internal","");
0101   leg2->AddEntry("","Au+Au #sqrt{s_{NN}}=200 GeV","");
0102   leg2->AddEntry("","anti-#it{k}_{#it{t}} #it{R} = 0.4, |#eta| < 1.1","");
0103   leg2->Draw();
0104   cleg2->Draw();
0105 
0106     
0107   c2->SaveAs(Form("plots/AuAu_JES_R04.pdf"));
0108   c3->SaveAs(Form("plots/AuAu_JER_R04.pdf"));
0109 
0110   TLegend *cleg3 = new TLegend(.3,.8,.5,.93);
0111   cleg3->SetFillStyle(0);
0112   TLegend *leg3 = new TLegend(.4,.7,.8,.93);
0113   leg3->SetFillStyle(0);
0114   leg3->AddEntry("","#it{#bf{sPHENIX}} Internal","");
0115   leg3->AddEntry("","Au+Au #sqrt{s_{NN}}=200 GeV","");
0116   leg3->AddEntry("","anti-#it{k}_{#it{t}} #it{R} = 0.4, |#eta| < 1.1","");
0117 
0118   //draw some subtracted et
0119   TH3F *h_subEt = (TH3F*) f->Get("h_subEt_pt");
0120   string cent[] = {"Inclusive","0-10%","10-30%","30-50%","50-80%"};
0121   for(int i = 0; i < ncent; i++){
0122     h_subEt->GetZaxis()->SetRange(i+1,i+1);
0123     TH2F *h_proj = (TH2F*) h_subEt->Project3D("yx");
0124     h_proj->Draw("COLZ");
0125     TH1F *h_prof = (TH1F*)h_proj->ProfileX();
0126     h_prof->Draw("SAME");
0127     h_proj->GetXaxis()->SetTitle("p_{T}^{reco} [GeV]");
0128     h_proj->GetYaxis()->SetTitle("Subtracted E_{T}");
0129     h_proj->GetYaxis()->SetRangeUser(0,h_prof->GetBinContent(1)*2);
0130    
0131     cleg3->AddEntry("%s",cent[i].c_str());
0132     cleg3->Draw();
0133     leg3->Draw();
0134     c3->SaveAs(Form("plots/AuAu_subtracted_Et_cent%i.pdf",i));
0135     cleg3->Clear();
0136   }
0137 
0138 }
0139