]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/EBYE/macros/drawCorrelationFunctionPsiSummary.C
2d19dbbbf5ebc5773657d2645cce4ae8cc7112bd
[u/mrichter/AliRoot.git] / PWGCF / EBYE / macros / drawCorrelationFunctionPsiSummary.C
1 const Int_t numberOfCentralityBins = 8;
2 TString centralityArray[numberOfCentralityBins] = {"0-10","10-20","20-30","30-40","40-50","50-60","60-70","70-80"};
3
4 const Int_t gRebin = 1;
5
6 void drawCorrelationFunctionPsiSummary(TString histoName = "PN",
7                                        const char* lhcPeriod = "LHC11h",
8                                        Int_t gTrainID = 222,                          
9                                        Int_t gCentrality = 1,
10                                        Double_t psiMin = -0.5, 
11                                        Double_t psiMax = 3.5) {
12   // Macro that draws the fit results for the 
13   // correlation functions from the balance function analysis
14   // Author: m.weber@cern.ch
15
16   gROOT->LoadMacro("~/SetPlotStyle.C");
17   SetPlotStyle();
18   gStyle->SetPalette(1,0);
19
20   //Load the PWG2ebye library
21   gSystem->Load("libANALYSIS.so");
22   gSystem->Load("libANALYSISalice.so");
23   gSystem->Load("libEventMixing.so");
24   gSystem->Load("libCORRFW.so");
25   gSystem->Load("libPWGTools.so");
26   gSystem->Load("libPWGCFebye.so");
27
28   // pt bins
29   // this could also be retrieved directly from AliBalancePsi
30   //const Int_t kNPtBins = 16;
31   //Double_t ptBins[kNPtBins+1] = {0.2,0.6,1.0,1.5,2.0,2.5,3.0,3.5,4.0,5.0,6.0,7.0,8.0,10.,12.,15.,20.};
32   //const Int_t kNPtBins = 5;
33   //Double_t ptBins[kNPtBins+1] = {0.6,1.0,1.5,2.0,4.0,20.0};
34   const Int_t kNPtBins = 4;
35   Double_t ptBins[kNPtBins+1] = {1.0,2.0,3.0,4.0,8.0};
36   //const Int_t kNPtBins = 1;
37   //Double_t ptBins[kNPtBins+1] = {1.0,2.0};
38
39   Double_t pt[kNPtBins*kNPtBins];
40   Double_t ptE[kNPtBins*kNPtBins];
41   for(Int_t i = 0; i < kNPtBins; i++){
42     for(Int_t j = 0; j < kNPtBins; j++){
43       pt[i*kNPtBins+j] = 10*i + (ptBins[j]+ptBins[j+1])/2.;
44       ptE[i*kNPtBins+j] = 0.2;
45     }
46   }
47
48
49   // Canvases
50   TCanvas *cQA[kNPtBins][kNPtBins];
51   for(Int_t i = 0; i < kNPtBins; i++){
52     for(Int_t j = 0; j <= i; j++){
53       cQA[i][j] = new TCanvas(Form("cQA%d%d",i,j),Form("Fitting QA for bin %d %d",i,j),1200,900);
54       cQA[i][j]->Divide(3,3);
55     }
56   }
57
58
59   // Loop over pt bins
60   Double_t ptTriggerMin = 0.0;
61   Double_t ptTriggerMax = 0.;
62   Double_t ptAssociatedMin = 0.0;
63   Double_t ptAssociatedMax = 0.0;
64   TString inFileName = "";
65   
66   //Fit Parameters
67   Double_t p[17][kNPtBins*kNPtBins];
68   Double_t pE[17][kNPtBins*kNPtBins];
69   TString pNames[17] = {
70     "Normalization",
71     "NearSideN",
72     "NearSideSigmaDeltaEta",
73     "NearSideSigmaDeltaPhi",
74     "NearSideSigmaExponent",
75     "AwaySideN",
76     "AwaySideSigmaDeltaPhi",
77     "AwaySideSigmaExponent",
78     "LongRidgeN",
79     "LongRidgeSigma",
80     "LongRidgeExponent",
81     "Wing",
82     "FlowN",
83     "FlowV1",
84     "FlowV2",
85     "FlowV3",
86     "FlowV4"
87   }
88   
89   for(Int_t iPar = 0; iPar < 17; iPar++){
90     for(Int_t i = 0; i < kNPtBins; i++){
91       for(Int_t j = 0; j < kNPtBins; j++){
92         p[iPar][i*kNPtBins+j] = -1.;
93         pE[iPar][i*kNPtBins+j] = 0.;
94       }
95     }
96   }
97
98   TFile *inFile  = NULL; 
99   TH2D *hTMPData = NULL;
100   TH2D *hTMPRes  = NULL;
101   TH2D *hTMPFit  = NULL;
102   TF2 *fFit  = NULL;
103
104   
105   for(Int_t i = 0; i < kNPtBins; i++){
106     for(Int_t j = 0; j <= i; j++){
107
108       cout<<" PROCESSING PT BIN "<<i<<" "<<j<<endl;
109
110       ptTriggerMin = ptBins[i];
111       ptTriggerMax = ptBins[i+1];
112       ptAssociatedMin = ptBins[j];
113       ptAssociatedMax = ptBins[j+1];
114
115
116       //Latex
117       TString centralityLatex = "Centrality: ";
118       centralityLatex += centralityArray[gCentrality-1]; 
119       centralityLatex += "%";
120       
121       TString psiLatex;
122       if((psiMin == -0.5)&&(psiMax == 0.5))
123         psiLatex = " -7.5^{o} < #varphi - #Psi_{2} < 7.5^{o}"; 
124       else if((psiMin == 0.5)&&(psiMax == 1.5))
125         psiLatex = " 37.5^{o} < #varphi - #Psi_{2} < 52.5^{o}"; 
126       else if((psiMin == 1.5)&&(psiMax == 2.5))
127         psiLatex = " 82.5^{o} < #varphi - #Psi_{2} < 97.5^{o}"; 
128       else 
129         psiLatex = " 0^{o} < #varphi - #Psi_{2} < 180^{o}"; 
130       
131       TString pttLatex = Form("%.1f",ptTriggerMin);
132       pttLatex += " < p_{T,trig} < "; pttLatex += Form("%.1f",ptTriggerMax);
133       pttLatex += " GeV/c";
134       
135       TString ptaLatex = Form("%.1f",ptAssociatedMin);
136       ptaLatex += " < p_{T,assoc} < "; ptaLatex += Form("%.1f",ptAssociatedMax);
137       ptaLatex += " GeV/c";
138       
139       TLatex *latexInfo1 = new TLatex();
140       latexInfo1->SetNDC();
141       latexInfo1->SetTextSize(0.045);
142       latexInfo1->SetTextColor(1);
143       
144       // Open input file
145       inFileName = Form("PbPb/%s/Train%d/Fits/correlationFunctionFit",lhcPeriod,gTrainID);
146       if(histoName.Contains("PN")) inFileName += "PN";
147       else if(histoName.Contains("NP")) inFileName += "NP";
148       else if(histoName.Contains("PP")) inFileName += "PP";
149       else if(histoName.Contains("NN")) inFileName += "NN";
150       inFileName += ".Centrality";  
151       inFileName += gCentrality; inFileName += ".Psi";
152       if((psiMin == -0.5)&&(psiMax == 0.5)) inFileName += "InPlane.Ptt";
153       else if((psiMin == 0.5)&&(psiMax == 1.5)) inFileName += "Intermediate.Ptt";
154       else if((psiMin == 1.5)&&(psiMax == 2.5)) inFileName += "OutOfPlane.Ptt";
155       else if((psiMin == 2.5)&&(psiMax == 3.5)) inFileName += "Rest.PttFrom";
156       else inFileName += "All.PttFrom";
157       inFileName += Form("%.1f",ptTriggerMin); inFileName += "To"; 
158       inFileName += Form("%.1f",ptTriggerMax); inFileName += "PtaFrom";
159       inFileName += Form("%.1f",ptAssociatedMin); inFileName += "To"; 
160       inFileName += Form("%.1f",ptAssociatedMax); 
161       inFileName += ".root";
162       inFile = TFile::Open(inFileName.Data(),"read");
163       inFile->ls();
164       hTMPData = (TH2D*)inFile->Get(Form("gHist%sCorrelationFunctions",histoName.Data()));
165       hTMPRes  = (TH2D*)inFile->Get("gHistResidual");
166       hTMPFit  = (TH2D*)inFile->Get(Form("gHist%sCorrelationFunctionsFit",histoName.Data()));
167
168       cQA[i][j]->cd(1);
169       hTMPData->DrawCopy("surf1fb");
170       latexInfo1->DrawLatex(0.2,0.95,"Data");
171
172       latexInfo1->DrawLatex(0.44,0.88,centralityLatex.Data());
173       //latexInfo1->DrawLatex(0.44,0.82,psiLatex.Data());
174       latexInfo1->DrawLatex(0.44,0.82,pttLatex.Data());
175       latexInfo1->DrawLatex(0.44,0.76,ptaLatex.Data());
176
177       cQA[i][j]->cd(2);
178       hTMPFit->DrawCopy("surf1fb");
179       latexInfo1->DrawLatex(0.2,0.95,"Fit");
180
181       cQA[i][j]->cd(3);
182       hTMPRes->DrawCopy("surf1fb");
183       latexInfo1->DrawLatex(0.2,0.95,"Residual");
184
185       cQA[i][j]->cd(4);
186       hTMPData->ProjectionX()->DrawCopy("");
187       latexInfo1->DrawLatex(0.2,0.95,"Data");
188
189       cQA[i][j]->cd(5);
190       hTMPFit->ProjectionX()->DrawCopy("");
191       latexInfo1->DrawLatex(0.2,0.95,"Fit");
192
193       cQA[i][j]->cd(6);
194       hTMPRes->ProjectionX()->DrawCopy("");
195       latexInfo1->DrawLatex(0.2,0.95,"Residual");
196
197       cQA[i][j]->cd(7);
198       hTMPData->ProjectionY()->DrawCopy("");
199       latexInfo1->DrawLatex(0.2,0.95,"Data");
200
201       cQA[i][j]->cd(8);
202       hTMPFit->ProjectionY()->DrawCopy("");
203       latexInfo1->DrawLatex(0.2,0.95,"Fit");
204
205       cQA[i][j]->cd(9);
206       hTMPRes->ProjectionY()->DrawCopy("");
207       latexInfo1->DrawLatex(0.2,0.95,"Residual");
208
209
210       cQA[i][j]->SaveAs(Form(Form("PbPb/%s/Train%d/figs/correlationFunctionFit_%s_PttFrom%.1fTo%.1fPtaFrom%.1fTo%.1f.eps",lhcPeriod,gTrainID,histoName.Data(),ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax)));
211       cQA[i][j]->SaveAs(Form(Form("PbPb/%s/Train%d/figs/correlationFunctionFit_%s_PttFrom%.1fTo%.1fPtaFrom%.1fTo%.1f.pdf",lhcPeriod,gTrainID,histoName.Data(),ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax)));
212
213       // fit parameters
214       fFit = (TF2*)inFile->Get("gFitFunction");
215       for(Int_t iPar = 0; iPar < 17; iPar++){
216         p[iPar][i*kNPtBins+j] = fFit->GetParameter(iPar);
217         pE[iPar][i*kNPtBins+j] = fFit->GetParError(iPar);
218       }
219
220       inFile->Close();
221     }
222   }
223
224   TGraphErrors *gPar[17];
225   for(Int_t iPar = 0; iPar < 17; iPar++){
226     gPar[iPar]  = new TGraphErrors(kNPtBins*kNPtBins,pt,p[iPar],ptE,pE[iPar]);
227     gPar[iPar]->SetTitle(pNames[iPar].Data());
228     gPar[iPar]->GetXaxis()->SetTitle("p_{T}");
229     gPar[iPar]->GetYaxis()->SetTitle(pNames[iPar].Data());
230     gPar[iPar]->SetMinimum(0.01);
231     gPar[iPar]->SetMaximum(2);
232     gPar[iPar]->SetMarkerStyle(20);
233     gPar[iPar]->SetMarkerColor(2);
234     gPar[iPar]->SetLineColor(2);
235   }
236
237   TLatex *latexInfo2 = new TLatex();
238   latexInfo2->SetNDC();
239   latexInfo2->SetTextSize(0.045);
240   latexInfo2->SetTextColor(1);
241
242   TCanvas *cPar = new TCanvas("cPar","parameters",1200,900);
243   cPar->Divide(3,3);
244
245   cPar->cd(1);
246   gPar[1]->Draw("AP");
247
248   cPar->cd(2);
249   gPar[2]->Draw("AP");
250
251   cPar->cd(3);
252   gPar[3]->Draw("AP");
253
254   cPar->cd(4);
255   gPar[6]->Draw("AP");
256
257   cPar->cd(5);
258   gPar[9]->Draw("AP");
259
260   cPar->cd(6);
261   gPar[12]->Draw("AP");
262
263   cPar->cd(7);
264   gPar[13]->Draw("AP");
265
266   cPar->cd(8);
267   gPar[14]->Draw("AP");
268
269   cPar->cd(9);
270   gPar[15]->Draw("AP");
271
272   cPar->SaveAs(Form("PbPb/%s/Train%d/figs/correlationFunctionFit_%s_FitParameters.eps",lhcPeriod,gTrainID,histoName.Data()));
273   cPar->SaveAs(Form("PbPb/%s/Train%d/figs/correlationFunctionFit_%s_FitParameters.pdf",lhcPeriod,gTrainID,histoName.Data()));
274
275   // delete canvases
276   for(Int_t i = 0; i < kNPtBins; i++){
277     for(Int_t j = 0; j <= i; j++){
278       //delete cQA[i][j];
279     }
280   }
281
282 }