Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
draw_hists.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file draw_hists.C
1 #include "sPhenixStyle.h"
2 #include "sPhenixStyle.C"
3 
4 
5 void draw_hists()
6 {
7 
8 
10  TH1::SetDefaultSumw2();
11  TH2::SetDefaultSumw2();
12 
13  TFile *f = new TFile("hists.root","READ");
14  TFile *f_pp = new TFile("hists_pp.root","READ");
15  int ppExists = f_pp->IsOpen();
16 
17  TCanvas *c = new TCanvas("c","c");
18  gPad->SetLogy();
19 
20  TLegend *leg = new TLegend(.25,.2,.6,.5);
21  leg->SetFillStyle(0);
22  leg->AddEntry("","#it{#bf{sPHENIX}} Internal","");
23  leg->AddEntry("","Au+Au #sqrt{s_{NN}}=200 GeV","");
24  leg->AddEntry("","anti-#it{k}_{#it{t}} #it{R} = 0.4, |#eta| < 1.1","");
25 
26 
27  TLegend *cleg = new TLegend(.7,.2,.9,.45);
28  cleg->SetFillStyle(0);
29 
30 
31  int colors[] = {1,2,4,kGreen+2, kViolet,kCyan,kOrange+2,kMagenta+2,kAzure-2};
32  string labels[] = {"pp","0-10%","10-30%","30-50%","50-80%"};
33  TGraphErrors *g_jes[11];
34  TGraphErrors *g_jer[11];
35  int ncent = 0;
36  for(int i = 0; i < 11; i++){
37  if(!(f->GetListOfKeys()->Contains(Form("g_jes_cent%i",i)))) continue;
38  g_jes[i] = (TGraphErrors*) f->Get(Form("g_jes_cent%i",i));
39  g_jer[i] = (TGraphErrors*) f->Get(Form("g_jer_cent%i",i));
40  ncent++;
41  }
42  TGraphErrors *g_jes_pp;
43  TGraphErrors *g_jer_pp;
44  if(ppExists)
45  {
46  g_jes_pp = (TGraphErrors*) f_pp->Get("g_jes_cent0");
47  g_jer_pp = (TGraphErrors*) f_pp->Get("g_jer_cent0");
48  }
49 
50  TCanvas * c2 = new TCanvas("c2","c2");
51  TMultiGraph *mg1 = new TMultiGraph();
52  for(int i = 0; i < ncent; i++){
53  g_jes[i]->SetMarkerColor(colors[i+1]);
54  g_jes[i]->SetLineColor(colors[i+1]);
55  mg1->Add(g_jes[i],"p");
56  cleg->AddEntry(g_jes[i],labels[i].c_str(),"p");
57 
58  }
59  if(ppExists)
60  {
61  mg1->Add(g_jes_pp,"p");
62  cleg->AddEntry(g_jes_pp,"pp","p");
63  }
64  mg1->Draw("a");
65  mg1->SetMinimum(0.);
66  mg1->SetMaximum(1.);
67 
68  mg1->GetXaxis()->SetRangeUser(5,100);
69  mg1->GetXaxis()->SetTitle("p_{T,truth} [GeV]");
70  mg1->GetYaxis()->SetTitle("#LTp_{T,reco}/p_{T,truth}#GT");
71 
72  leg->Draw();
73  cleg->Draw();
74 
75  TCanvas * c3 = new TCanvas("c3","c3");
76  TMultiGraph *mg2 = new TMultiGraph();
77  TLegend *cleg2 = new TLegend(.3,.6,.5,.9);
78  cleg2->SetFillStyle(0);
79 
80  for(int i = 0; i < ncent; i++){
81  g_jer[i]->SetMarkerColor(colors[i]);
82  g_jer[i]->SetLineColor(colors[i]);
83  mg2->Add(g_jer[i],"p");
84  cleg2->AddEntry(g_jes[i],labels[i].c_str(),"p");
85  }
86  if(ppExists)
87  {
88  mg2->Add(g_jer_pp,"p");
89  cleg2->AddEntry(g_jes_pp,"pp","p");
90  }
91  mg2->Draw("a");
92  mg2->SetMinimum(0.);
93  mg2->SetMaximum(1.0);
94 
95  mg2->GetXaxis()->SetTitle("p_{T,truth} [GeV]");
96  mg2->GetYaxis()->SetTitle("#sigma(p_{T,reco}/p_{T,truth}) / #LTp_{T,reco}/p_{T,truth}#GT");
97 
98  TLegend *leg2 = new TLegend(.4,.6,.8,.9);
99  leg2->SetFillStyle(0);
100  leg2->AddEntry("","#it{#bf{sPHENIX}} Internal","");
101  leg2->AddEntry("","Au+Au #sqrt{s_{NN}}=200 GeV","");
102  leg2->AddEntry("","anti-#it{k}_{#it{t}} #it{R} = 0.4, |#eta| < 1.1","");
103  leg2->Draw();
104  cleg2->Draw();
105 
106 
107  c2->SaveAs(Form("plots/AuAu_JES_R04.pdf"));
108  c3->SaveAs(Form("plots/AuAu_JER_R04.pdf"));
109 
110  TLegend *cleg3 = new TLegend(.3,.8,.5,.93);
111  cleg3->SetFillStyle(0);
112  TLegend *leg3 = new TLegend(.4,.7,.8,.93);
113  leg3->SetFillStyle(0);
114  leg3->AddEntry("","#it{#bf{sPHENIX}} Internal","");
115  leg3->AddEntry("","Au+Au #sqrt{s_{NN}}=200 GeV","");
116  leg3->AddEntry("","anti-#it{k}_{#it{t}} #it{R} = 0.4, |#eta| < 1.1","");
117 
118  //draw some subtracted et
119  TH3F *h_subEt = (TH3F*) f->Get("h_subEt_pt");
120  string cent[] = {"Inclusive","0-10%","10-30%","30-50%","50-80%"};
121  for(int i = 0; i < ncent; i++){
122  h_subEt->GetZaxis()->SetRange(i+1,i+1);
123  TH2F *h_proj = (TH2F*) h_subEt->Project3D("yx");
124  h_proj->Draw("COLZ");
125  TH1F *h_prof = (TH1F*)h_proj->ProfileX();
126  h_prof->Draw("SAME");
127  h_proj->GetXaxis()->SetTitle("p_{T}^{reco} [GeV]");
128  h_proj->GetYaxis()->SetTitle("Subtracted E_{T}");
129  h_proj->GetYaxis()->SetRangeUser(0,h_prof->GetBinContent(1)*2);
130 
131  cleg3->AddEntry("%s",cent[i].c_str());
132  cleg3->Draw();
133  leg3->Draw();
134  c3->SaveAs(Form("plots/AuAu_subtracted_Et_cent%i.pdf",i));
135  cleg3->Clear();
136  }
137 
138 }
139