]>
Commit | Line | Data |
---|---|---|
f4b109c4 | 1 | #include "TCanvas.h" |
2 | #include <TH1.h> | |
3 | #include <TF1.h> | |
4 | #include <TFile.h> | |
5 | #include <Rtypes.h> | |
6 | #include <TLegend.h> | |
7 | #include <TString.h> | |
6c3d03d7 | 8 | #include <TAttMarker.h> |
9 | #include <RtypesCint.h> | |
10 | #include <TNamed.h> | |
11 | #include "TDirectoryFile.h" | |
12 | #include <TPRegexp.h> | |
13 | #include <X3DDefs.h> | |
f4b109c4 | 14 | |
15 | namespace RawProduction { | |
16 | class Output; | |
17 | } | |
18 | ||
6c3d03d7 | 19 | enum EffVersion { LHC10h_1234_Apr_10 }; |
20 | EffVersion effVersion = LHC10h_1234_Apr_10; | |
21 | bool canvHalfWidth=false; | |
22 | ||
23 | TF1* GetEfficency(const TString& trigger, int fromCent, int toCent, const TString& pid, const TString& methode) | |
f4b109c4 | 24 | { |
6c3d03d7 | 25 | // Dmitri LHC10h Apr. 10 Efficiencies |
26 | // avalible pids: Allcore Disp2core CPVcore Both2core Disp2 All CPV Both2 | |
27 | if( effVersion == LHC10h_1234_Apr_10 ) { | |
28 | if( ! methode.Contains("yr1") ) { | |
29 | Printf("ERROR:GetEfficency: only pol1 efficiancies avalible"); | |
30 | return 0x0; | |
31 | } | |
32 | ||
33 | // Cent bin defintion as extracted from PHOS_embedding/ | |
34 | int cent = -1; | |
35 | if( 0 == fromCent && 5 == toCent ) cent = 0; | |
36 | if( 5 == fromCent && 10 == toCent ) cent = 1; | |
37 | if( 10 == fromCent && 20 == toCent ) cent = 2; | |
38 | if( 20 == fromCent && 40 == toCent ) cent = 3; | |
39 | if( 40 == fromCent && 60 == toCent ) cent = 4; | |
40 | if( 60 == fromCent && 80 == toCent ) cent = 5; | |
41 | if( cent < 0 ) { | |
42 | Printf("ERROR:GetEfficency not avalible for centrality [%i,%i)", fromCent, toCent); | |
43 | return 0x0; | |
44 | } | |
45 | ||
46 | // determine name and return efficiancy function | |
47 | TDirectory* pastDir = gDirectory; | |
48 | TFile* file = TFile::Open("PHOS_eff_Full_PbPb_1234.root", "READ"); | |
49 | char funcName[256]; | |
50 | if ( methode.Contains("int") ) | |
51 | sprintf(funcName, "eff_int_Pi0_Gaus_PbPb_%s_cen%i", pid.Data(), cent); | |
52 | else | |
53 | sprintf(funcName, "eff_int_Pi0_Gaus_PbPb_%s_cen%i", pid.Data(), cent); | |
54 | TF1* func = dynamic_cast<TF1*> ( file->Get(funcName) ); | |
55 | pastDir->cd(); | |
56 | ||
57 | if( ! func ) | |
58 | Printf("ERROR:GetEfficency: efficiancy function %s does not exist", funcName); | |
59 | return func; | |
60 | } | |
61 | return 0x0; // should not be reached | |
f4b109c4 | 62 | } |
63 | ||
6c3d03d7 | 64 | TH1* GetRawProduction(const RawProduction::Output& rawOutput, const TString& trigger="kMB", int fromCent=0, int toCent=10, |
65 | const TString& pid="All", const TString& graphName="yr1", Color_t color=kBlack, Style_t style=kFullDotSmall) | |
f4b109c4 | 66 | { |
1c471965 | 67 | TString newName = Form("raw_%s_%02i-%02i_%s_%s", trigger.Data(), fromCent, toCent, pid.Data(), graphName.Data()); |
68 | TH1* hist = dynamic_cast<TH1*> ( gDirectory->Get(newName.Data()) ); | |
69 | ||
70 | if( ! hist ) { | |
71 | TString oldName(Form("%s/c%02i-%02i/%s/%s", trigger.Data(), fromCent, toCent, pid.Data(), graphName.Data())); | |
72 | TH1* hist = rawOutput.GetHistogram(oldName.Data()); | |
73 | hist->SetName(newName.Data()); | |
74 | hist->SetTitle(Form("%s, %02i-%02i%%, %s", trigger.Data(), fromCent, toCent, graphName.Data())); | |
75 | hist->GetXaxis()->SetTitle("p_{T}"); | |
76 | } | |
6c3d03d7 | 77 | hist->SetLineColor(color); |
78 | hist->SetMarkerColor(color); | |
79 | hist->SetMarkerStyle(style); | |
6c3d03d7 | 80 | return hist; |
81 | } | |
f4b109c4 | 82 | |
6c3d03d7 | 83 | TH1* MakeProduction(const RawProduction::Output& rawOutput, const TString& trigger="kMB", int fromCent=0, int toCent=10, |
84 | const TString& pid="All", const TString& graphName="yr1", Color_t color=kBlack, Style_t style=kFullDotSmall) | |
85 | { | |
86 | // First, check if production histogram allready exist in cd. | |
87 | TString name = Form("prod_%s_%02i-%02i_%s_%s", trigger.Data(), fromCent, toCent, pid.Data(), graphName.Data()); | |
88 | TH1* hist = dynamic_cast<TH1*> ( gDirectory->Get(name.Data()) ); | |
f4b109c4 | 89 | |
1c471965 | 90 | if( ! hist ) { // else clone raw and correct for efficiancy |
91 | const TH1* rawHist = GetRawProduction(rawOutput, trigger, fromCent, toCent, pid, graphName, color, style); | |
92 | hist = (TH1*) rawHist->Clone(name.Data()); | |
93 | hist->Divide(GetEfficency(trigger, fromCent, toCent, pid, graphName)); | |
94 | hist->GetYaxis()->SetTitle("#frac{d^{2}N_{#pi^{0}}}{p_{T}dp_{T}dy N_{ev}}"); | |
95 | } | |
96 | hist->SetLineColor(color); | |
97 | hist->SetMarkerColor(color); | |
98 | hist->SetMarkerStyle(style); | |
6c3d03d7 | 99 | return hist; |
100 | } | |
f4b109c4 | 101 | |
6c3d03d7 | 102 | TH1* MakeRatio(TH1* h1, TH1* h2, const TString& title ="") |
103 | { | |
104 | TString name = Form("%s_%s", h1->GetName(), h2->GetName()); | |
105 | TH1* hist = dynamic_cast<TH1*> ( gDirectory->Get(name.Data()) ); | |
106 | if( hist ) | |
107 | return hist; | |
f4b109c4 | 108 | |
6c3d03d7 | 109 | hist = (TH1*)h1->Clone(name.Data()); |
110 | hist->Divide(h2); | |
111 | hist->SetTitle(title.Data()); | |
112 | hist->GetYaxis()->SetTitle("Ratio"); | |
113 | return hist; | |
114 | } | |
f4b109c4 | 115 | |
f4b109c4 | 116 | |
6c3d03d7 | 117 | TCanvas* DrawPIDProductionWithRatios(const RawProduction::Output& rawOutput, const TString& trigger, |
118 | int fromCent, int toCent, const TString& methode="yr1", | |
119 | const TString& pids = TString("Allcore CPVcore Disp2core Both2core"), bool raw = false) | |
120 | { | |
121 | const int capacity = 8; | |
122 | const int nHists = TMath::Min( pids.CountChar(' ')+1, capacity); | |
123 | TStringToken pidst = TStringToken(pids, " "); | |
124 | char pidsa[capacity][64] ={""}; | |
f4b109c4 | 125 | |
6c3d03d7 | 126 | TH1* hists[capacity] = {0x0}; |
127 | const Style_t markers[capacity] = {22, 22, 23, 33, 24, 26, 32, 27}; | |
128 | const Color_t colors[capacity] = {kBlack, kRed, kBlue, kGreen, kGray, kMagenta, kCyan, kOrange}; | |
f4b109c4 | 129 | |
6c3d03d7 | 130 | int index = 0; |
131 | while(pidst.NextToken() && index < capacity) { | |
132 | sprintf(pidsa[index], "%s", pidst.Data()); | |
133 | if(raw) | |
134 | hists[index] = GetRawProduction(rawOutput, trigger, fromCent, toCent, pidst, methode, colors[index], markers[index]); | |
135 | else | |
136 | hists[index] = MakeProduction(rawOutput, trigger, fromCent, toCent, pidst, methode, colors[index], markers[index]); | |
137 | index++; | |
138 | } | |
f4b109c4 | 139 | |
6c3d03d7 | 140 | //TString pids_underscore = TString(pids); pids_underscore.ReplaceAll(" ", "_"); |
141 | TString key = Form("PIDRatios_%s_c%02i-%02i_%s_%s_raw%i_h%i", trigger.Data(), fromCent, toCent, methode.Data(), TString(pids).ReplaceAll(" ", "_").Data(), raw, canvHalfWidth); | |
142 | //TString key = Form("PIDRatios_%s_c%02i-%02i_%s_raw%i", trigger.Data(), fromCent, toCent, methode.Data(), raw); | |
f4b109c4 | 143 | |
6c3d03d7 | 144 | TCanvas* canv = 0x0; |
145 | if( canvHalfWidth) | |
146 | canv = new TCanvas(key.Data(), key.Data(), 1024/2, 768); | |
147 | else | |
148 | canv = new TCanvas(key.Data(), key.Data(), 1024, 768); | |
149 | ||
150 | // Direct | |
151 | canv->cd(); | |
152 | TPad *pad1 = new TPad("pad1","pad1",0,0.4,1,1); | |
153 | pad1->SetBottomMargin(0); | |
154 | pad1->SetLogy(); | |
155 | pad1->Draw(); | |
156 | pad1->cd(); | |
157 | if( canvHalfWidth ) { | |
158 | hists[0]->GetYaxis()->SetLabelFont(63); //font in pixels | |
159 | hists[0]->GetYaxis()->SetLabelSize(10); //in pixels | |
160 | hists[0]->GetYaxis()->SetTitleSize(0.03); | |
161 | hists[0]->GetYaxis()->SetTitleOffset(1.2); | |
162 | } else { | |
163 | hists[0]->GetYaxis()->SetLabelFont(63); //font in pixels | |
164 | hists[0]->GetYaxis()->SetLabelSize(20); //in pixels | |
165 | hists[0]->GetYaxis()->SetTitleSize(0.055); | |
166 | hists[0]->GetYaxis()->SetTitleOffset(0.7); | |
f4b109c4 | 167 | } |
6c3d03d7 | 168 | if( raw ) |
169 | hists[0]->GetYaxis()->SetRangeUser(1.e-7, 1.e1); | |
170 | else | |
171 | hists[0]->GetYaxis()->SetRangeUser(1.e-5, 1.e3); | |
172 | // Draw | |
173 | hists[0]->DrawCopy(); | |
174 | for(int i=1;i<nHists;++i) | |
175 | hists[i]->DrawCopy("same"); | |
176 | // Legend | |
177 | TLegend* leg1 = new TLegend(0.7,0.6,0.85,0.88); | |
178 | for(int i=0;i<nHists;++i) | |
179 | leg1->AddEntry(hists[i], pidsa[i] , "lep"); | |
180 | leg1->Draw(); | |
181 | ||
182 | // Ratios | |
183 | canv->cd(); | |
184 | TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.4); | |
185 | pad2->SetTopMargin(0); | |
186 | pad2->Draw(); | |
187 | pad2->cd(); | |
188 | pad2->SetGridy(); | |
189 | TH1* firstRatio = MakeRatio(hists[1], hists[0]); | |
190 | if ( raw ) | |
191 | firstRatio->GetYaxis()->SetRangeUser(0., 2.); | |
192 | else | |
193 | firstRatio->GetYaxis()->SetRangeUser(0.6, 1.4); | |
194 | firstRatio->GetYaxis()->SetTitle(""); | |
195 | firstRatio->GetYaxis()->SetLabelFont(63); | |
196 | firstRatio->GetYaxis()->SetLabelSize(25); | |
197 | firstRatio->GetXaxis()->SetLabelFont(63); | |
198 | firstRatio->GetXaxis()->SetLabelSize(20); | |
199 | firstRatio->SetTitle("Ratio"); | |
200 | // Draw | |
201 | firstRatio->DrawCopy("AXIS"); | |
202 | firstRatio->DrawCopy("AXIGsame"); | |
203 | firstRatio->DrawCopy("same"); | |
204 | for(int i=2;i<nHists;++i) | |
205 | MakeRatio(hists[i],hists[0])->DrawCopy("same"); | |
206 | // Ratios | |
207 | TLegend* leg2 = new TLegend(0.7,0.63,0.85,0.98); | |
208 | for(int i=1;i<nHists;++i) | |
209 | leg2->AddEntry(MakeRatio(hists[i],hists[0]), Form("%s/%s", pidsa[i], pidsa[0]), "lep"); | |
210 | leg2->Draw(); | |
211 | ||
212 | canv->SaveAs(Form("imgs/%s.pdf", key.Data())); | |
213 | canv->SaveAs(Form("imgs/%s.png", key.Data())); | |
214 | ||
215 | return canv; | |
216 | //delete canv; | |
f4b109c4 | 217 | } |
218 | ||
219 | ||
6c3d03d7 | 220 | void DrawPIDRatios(const RawProduction::Output& rawOutput) |
f4b109c4 | 221 | { |
6c3d03d7 | 222 | const int nCent = 2; |
223 | int centBins[nCent][2] = {{0,5}, {5,10}/*, {10,20}, {20,40}, {40,60}, {60,80}*/}; | |
224 | TStringToken methodes("yr1 yr1int", " "); | |
225 | while( methodes.NextToken() ) { | |
226 | for(int ic=0; ic<nCent; ++ic) { | |
1c471965 | 227 | DrawPIDProductionWithRatios(rawOutput, "kCentral", centBins[ic][0], centBins[ic][1], methodes.Data(), "Allcore CPVcore Disp2core Both2core All CPV Disp2 Both2", true ); |
228 | DrawPIDProductionWithRatios(rawOutput, "kCentral", centBins[ic][0], centBins[ic][1], methodes.Data(), "Allcore CPVcore Disp2core Both2core All CPV Disp2 Both2", false ); | |
6c3d03d7 | 229 | DrawPIDProductionWithRatios(rawOutput, "kCentral", centBins[ic][0], centBins[ic][1], methodes.Data(), "Allcore CPVcore Disp2core Both2core", true ); |
230 | DrawPIDProductionWithRatios(rawOutput, "kCentral", centBins[ic][0], centBins[ic][1], methodes.Data(), "Allcore CPVcore Disp2core Both2core", false ); | |
1c471965 | 231 | DrawPIDProductionWithRatios(rawOutput, "kCentral", centBins[ic][0], centBins[ic][1], methodes.Data(), "All Disp2 CPV Both2 Allcore", true ); |
232 | DrawPIDProductionWithRatios(rawOutput, "kCentral", centBins[ic][0], centBins[ic][1], methodes.Data(), "All Disp2 CPV Both2 Allcore", false ); | |
6c3d03d7 | 233 | } |
234 | } | |
f4b109c4 | 235 | } |
236 | ||
237 | void DrawProduction() | |
238 | { | |
239 | gROOT->LoadMacro("MakeRawProduction.C+g"); | |
6c3d03d7 | 240 | RawProduction::Output rawOutput; |
f4b109c4 | 241 | gStyle->SetOptStat(0); |
242 | ||
6c3d03d7 | 243 | DrawPIDRatios(rawOutput); |
f4b109c4 | 244 | } |