Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plot_histos.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file plot_histos.C
1 #include "sPhenixStyle.h"
2 #include "sPhenixStyle.C"
3 
4 
5 void plot_histos(const char *filename = "output.root", const float jetparameter = 0.4)
6 {
7 
8 
10  TH1::SetDefaultSumw2();
11  TH2::SetDefaultSumw2();
12 
13  TFile *f = new TFile(filename,"READ");
14 
15 
16  TH1D *h_nconst = (TH1D*) f->Get("h1d_nConsituents");
17  TH1D *h_nconst_IHCal = (TH1D*) f->Get("h1d_nConsituents_IHCal");
18  TH1D *h_nconst_OHCal = (TH1D*) f->Get("h1d_nConsituents_OHCal");
19  TH1D *h_nconst_EMCal = (TH1D*) f->Get("h1d_nConsituents_EMCal");
20  TH1D *h_FracEnergy_EMCal = (TH1D*) f->Get("h1d_FracEnergy_EMCal");
21  TH1D *h_FracEnergy_IHCal = (TH1D*) f->Get("h1d_FracEnergy_IHCal");
22  TH1D *h_FracEnergy_OHCal = (TH1D*) f->Get("h1d_FracEnergy_OHCal");
23 
24  TH2D *h_FracEnergy_vs_CaloLayer = (TH2D*) f->Get("h2d_FracEnergy_vs_CaloLayer");
25  TH2D *h_nConstituent_vs_CaloLayer = (TH2D*) f->Get("h2d_nConstituent_vs_CaloLayer");
26 
27  TCanvas *c = new TCanvas("c","c");
28  TLegend *leg = new TLegend(0.5,0.5,0.9,0.9);
29  leg->SetFillStyle(0);
30  leg->AddEntry("","#it{#bf{sPHENIX}} Internal","");
31  leg->AddEntry("","Au+Au #sqrt{s_{NN}}=200 GeV","");
32  leg->AddEntry("",Form("anti-#it{k}_{#it{t}} #it{R} = %.1f, |#eta| < 1.1",jetparameter),"");
33  int colors[] = {1,2,4};
34  string labels[] = {"iHCal","oHCal","EMCal"};
35 
36  c->SetTitle("Number of Constituents per Calo layer");
37 
38  h_nconst_IHCal->SetLineColor(colors[0]);
39  h_nconst_IHCal->SetMarkerColor(colors[0]);
40 
41  h_nconst_OHCal->SetLineColor(colors[1]);
42  h_nconst_OHCal->SetMarkerColor(colors[1]);
43 
44  h_nconst_EMCal->SetLineColor(colors[2]);
45  h_nconst_EMCal->SetMarkerColor(colors[2]);
46 
47  leg->AddEntry(h_nconst_IHCal,labels[0].c_str(),"l");
48  leg->AddEntry(h_nconst_OHCal,labels[1].c_str(),"l");
49  leg->AddEntry(h_nconst_EMCal,labels[2].c_str(),"l");
50 
51  h_nconst_IHCal->GetXaxis()->SetTitle("Number of Constituents");
52  h_nconst_IHCal->GetYaxis()->SetTitle("Counts");
53 
54 
55  h_nconst_IHCal->Draw("hist");
56  h_nconst_OHCal->Draw("hist same");
57  h_nconst_EMCal->Draw("hist same");
58 
59  leg->Draw("same");
60 
61  c->Update();
62  string outputfilename = string(filename);
63  outputfilename.erase(outputfilename.find(".root"));
64  c->SaveAs(Form("h_nconst_%s.pdf",outputfilename.c_str()));
65 
66 
67  TCanvas *c2 = new TCanvas("c2","c2");
68  TLegend *leg2 = new TLegend(0.5,0.5,0.9,0.9);
69  leg2->SetFillStyle(0);
70  leg2->AddEntry("","#it{#bf{sPHENIX}} Internal","");
71  leg2->AddEntry("","Au+Au #sqrt{s_{NN}}=200 GeV","");
72  leg2->AddEntry("",Form("anti-#it{k}_{#it{t}} #it{R} = %.1f, |#eta| < 1.1",jetparameter),"");
73 
74  c2->SetTitle("Fraction of Energy per Calo layer");
75 
76  h_FracEnergy_IHCal->GetXaxis()->SetTitle("Fraction of Energy");
77  h_FracEnergy_IHCal->GetYaxis()->SetTitle("Counts");
78 
79  h_FracEnergy_IHCal->SetLineColor(colors[0]);
80  h_FracEnergy_IHCal->SetMarkerColor(colors[0]);
81 
82  h_FracEnergy_OHCal->SetLineColor(colors[1]);
83  h_FracEnergy_OHCal->SetMarkerColor(colors[1]);
84 
85  h_FracEnergy_EMCal->SetLineColor(colors[2]);
86  h_FracEnergy_EMCal->SetMarkerColor(colors[2]);
87 
88  leg2->AddEntry(h_FracEnergy_IHCal,labels[0].c_str(),"l");
89  leg2->AddEntry(h_FracEnergy_OHCal,labels[1].c_str(),"l");
90  leg2->AddEntry(h_FracEnergy_EMCal,labels[2].c_str(),"l");
91 
92  h_FracEnergy_IHCal->Draw("hist");
93  h_FracEnergy_OHCal->Draw("hist same");
94  h_FracEnergy_EMCal->Draw("hist same");
95 
96  leg2->Draw("same");
97 
98  c2->Update();
99 
100  c2->SaveAs(Form("h_FracEnergy_%s.pdf",outputfilename.c_str()));
101 
102 
103  TCanvas *c3 = new TCanvas("c3","c3");
104  c3->SetTitle("Total of Constituents");
105 
106  h_nconst->GetXaxis()->SetTitle("Number of Constituents");
107  h_nconst->GetYaxis()->SetTitle("Counts");
108  h_nconst->Draw("hist");
109 
110  c3->Update();
111 
112  c3->SaveAs(Form("h_nconst_total_%s.pdf",outputfilename.c_str()));
113 
114  TCanvas *c4 = new TCanvas("c4","c4");
115  c4->SetTitle("Fraction of Energy");
116 
117  h_FracEnergy_vs_CaloLayer->GetXaxis()->SetTitle("Calo Layer");
118  h_FracEnergy_vs_CaloLayer->GetYaxis()->SetTitle("Fraction of Energy");
119  h_FracEnergy_vs_CaloLayer->GetXaxis()->SetBinLabel(1,"EMCal");
120  h_FracEnergy_vs_CaloLayer->GetXaxis()->SetBinLabel(2,"IHCal");
121  h_FracEnergy_vs_CaloLayer->GetXaxis()->SetBinLabel(3,"OHCal");
122  h_FracEnergy_vs_CaloLayer->Draw("COLZ");
123  TLine *line = new TLine(1,0,1,1);
124  line->SetLineColor(kRed);
125  line->Draw("same");
126  TLine *line2 = new TLine(2,0,2,1);
127  line2->SetLineColor(kRed);
128  line2->Draw("same");
129 
130  c4->Update();
131  c4->SaveAs(Form("h_FracEnergy_vs_calolayer_%s.pdf",outputfilename.c_str()));
132 
133  TCanvas *c5 = new TCanvas("c5","c5");
134  c5->SetTitle("Number of Constituents");
135 
136  h_nConstituent_vs_CaloLayer->GetXaxis()->SetTitle("Calo Layer");
137  h_nConstituent_vs_CaloLayer->GetYaxis()->SetTitle("Number of Constituents");
138  h_nConstituent_vs_CaloLayer->GetXaxis()->SetBinLabel(1,"EMCal");
139  h_nConstituent_vs_CaloLayer->GetXaxis()->SetBinLabel(2,"IHCal");
140  h_nConstituent_vs_CaloLayer->GetXaxis()->SetBinLabel(3,"OHCal");
141  h_nConstituent_vs_CaloLayer->Draw("COLZ");
142  TLine *line3 = new TLine(1,0,1,1);
143  line3->SetLineColor(kRed);
144  line3->Draw("same");
145  TLine *line4 = new TLine(2,0,2,1);
146  line4->SetLineColor(kRed);
147  line4->Draw("same");
148 
149  c5->Update();
150 
151  c5->SaveAs(Form("h_nconst_vs_calolayer_%s.pdf",outputfilename.c_str()));
152 
153 
154 
155 
156 
157 
158 
159 
160 }
161 
162