]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FLOW/papers/arXiv_1306.4145/CorrelationQpiQtj_hepData.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / FLOW / papers / arXiv_1306.4145 / CorrelationQpiQtj_hepData.C
1 const int nTerms = 4;
2
3 TGraphErrors*ResolutionXY[nTerms];
4 TString title[nTerms]={"#LTQ_{x}^{p}Q_{x}^{t}#GT","#LTQ_{y}^{p}Q_{y}^{t}#GT","#LTQ_{x}^{p}Q_{y}^{t}#GT","#LTQ_{y}^{p}Q_{x}^{t}#GT"};
5 TString name[nTerms]={"Qpx_Qtx","Qpy_Qty","Qpx_Qty","Qpy_Qtx"};
6 int color[nTerms]={kBlue,kMagenta+2,kBlue+2,kGreen+2};
7 int symbol[nTerms]={kFullSquare,kFullDiamond,kOpenTriangleUp,kOpenTriangleDown};
8 float myMarkerSize=1.5;
9 float markerSize[nTerms]={myMarkerSize,1.5*myMarkerSize,myMarkerSize,myMarkerSize};
10 float mainFont = 20;
11 int fillStyle = 1001;
12 float myShift =0.;
13 float shift[nTerms]={-myShift,myShift,-myShift,myShift};
14 TString centrality_name[9]={"0-5","5-10","10-20","20-30","30-40","40-50","50-60","60-70","70-80"};
15 void CorrelationQpiQtj_hepData(bool rWrite = false, bool dumpHepData=false,TString dataFileName="ALICE_v1_arxiv_1306_4145.root")
16 {
17   TGaxis::SetMaxDigits(3);
18   myOptions();
19   gROOT->ForceStyle();
20   TCanvas *myCan = new TCanvas("myCan","Resolution",800,600);
21   TPad *myPad1 = new TPad("myPad1","myPad1",0.,0,1,1);
22   myPadSetUp(myPad1,0.08, 0.05, 0.01, 0.1);
23   myPad1->Draw();
24   myPad1->cd();
25   TFile *dataFile = TFile::Open(dataFileName,"READ");
26   ResolutionXY[0] = (TGraphErrors*)dataFile->Get("Qpx_Qtx");
27   ResolutionXY[1] = (TGraphErrors*)dataFile->Get("Qpy_Qty");
28   ResolutionXY[2] = (TGraphErrors*)dataFile->Get("Qpx_Qty");
29   ResolutionXY[3] = (TGraphErrors*)dataFile->Get("Qpy_Qtx");
30   
31   TH1F* myBlankHisto = new TH1F("myBlankHisto","#LTQ_{i}^{p}Q_{j}^{t}#GT",10,0,82);
32   myHistoSetUp(myBlankHisto,"centrality (%)","#LTQ_{r}^{p}Q_{r'}^{t}#GT",-1.05e-2,2.5e-3, 1, 2, 315, 505);
33   TLegend* myLegend = new TLegend(0.35,0.45,0.6,0.7);
34   myLegendSetUp(myLegend,mainFont);
35   myBlankHisto->Draw();
36   for (int i=0; i<nTerms; i++)
37   {
38     myTGraphSetUp(ResolutionXY[i],symbol[i],color[i],markerSize[i],1,color[i],2,fillStyle,color[i]);
39     TString draw_opt = "p,eZ,same";
40     myLegend->AddEntry(ResolutionXY[i],title[i],"P");
41     ResolutionXY[i]->Draw(draw_opt);
42     if (dumpHepData)
43     {
44       cout<< name[i] <<endl; cout <<"x" << "\t" <<"xlow" << "\t"<< "xhigh"<< "\t"<< "y"<< "\t\t"<<"dy+"<< "\t\t"<<"dy-"<< "\t\t"<<"dy+"<< "\t"<<"dy-"<<endl;
45       Double_t x = 0.;
46       Double_t y = 0.;
47       for (int j=0; j< ResolutionXY[i]->GetN(); j++)
48       {
49         ResolutionXY[i]->GetPoint(j,x,y);
50         cout<< x<< "\t" << x-ResolutionXY[i]->GetErrorXlow(j)<< "\t" << x+ResolutionXY[i]->GetErrorXhigh(j)<< "\t" << y << "\t"<< ResolutionXY[i]->GetErrorY(j)<< "\t"<< ResolutionXY[i]->GetErrorY(j)<<"\tN/A\tN/A" <<endl;
51       }
52     }   
53     ShiftAlongXaxis(ResolutionXY[i], shift[i]);
54   }
55   myLegend->Draw();
56   TLatex *myText = new TLatex();
57   myText->SetNDC();
58   myText->SetTextSize(mainFont);
59   myText->DrawLatex(0.12,0.9,"ALICE Pb-Pb #sqrt{s_{NN}}=2.76TeV");
60   myText->DrawLatex(0.57,0.9,"Q^{p,t}_{x,y} from Neutron ZDCs (|#eta|>8.78)");
61   
62   TString fileName="Correlation_QpQt";
63   myCan->Update();
64   if (rWrite)  
65   {
66     myCan->SaveAs(fileName+".png");
67     myCan->SaveAs(fileName+".eps");
68     myCan->SaveAs(fileName+".pdf");
69   }
70 }
71
72 void myLegendSetUp(TLegend *currentLegend=0,float currentTextSize=0.07){
73   currentLegend->SetBorderSize(0);
74   currentLegend->SetFillStyle(0);
75   currentLegend->SetFillColor(0);
76   currentLegend->SetMargin(0.25);
77   currentLegend->SetTextSize(currentTextSize);
78   currentLegend->SetEntrySeparation(0.5);
79   return;
80 }
81 //   myTGraphSetUp(v1etaStat_cent10_20,kFullTriangleUp,kRed+2,myMarkerSize,1,kRed+2,2,fillStyle,kRed+2);
82
83 void myPadSetUp(TPad *currentPad, float currentLeft=0.11, float currentTop=0.04, float currentRight=0.04, float currentBottom=0.15){
84   currentPad->SetLeftMargin(currentLeft);
85   currentPad->SetTopMargin(currentTop);
86   currentPad->SetRightMargin(currentRight);
87   currentPad->SetBottomMargin(currentBottom);
88   return;
89 }
90
91 void myGraphSetUp(TGraphErrors *currentGraph=0, Float_t currentMarkerSize = 1.0,
92                   int currentMarkerStyle=20, int currentMarkerColor=0,
93                   int currentLineStyle=1, int currentLineColor=0)
94 {
95   currentGraph->SetMarkerSize(currentMarkerSize);
96   currentGraph->SetMarkerStyle(currentMarkerStyle);
97   currentGraph->SetMarkerColor(currentMarkerColor);
98   currentGraph->SetLineStyle(currentLineStyle);
99   currentGraph->SetLineColor(currentLineColor);
100   return;
101 }
102
103 void myOptions(Int_t lStat=0){
104   // Set gStyle
105   int font = 43;
106   // From plain
107   gStyle->SetFrameBorderMode(0);
108   gStyle->SetFrameFillColor(0);
109   gStyle->SetCanvasBorderMode(0);
110   gStyle->SetPadBorderMode(0);
111   gStyle->SetPadColor(10);
112   gStyle->SetCanvasColor(10);
113   gStyle->SetTitleFillColor(10);
114   gStyle->SetTitleBorderSize(1);
115   gStyle->SetStatColor(10);
116   gStyle->SetStatBorderSize(1);
117   gStyle->SetLegendBorderSize(1);
118   //
119   gStyle->SetDrawBorder(0);
120   gStyle->SetTextFont(font);
121   gStyle->SetStatFont(font);
122   gStyle->SetLegendFont(font);
123   gStyle->SetStatFontSize(20);
124   gStyle->SetStatX(0.97);
125   gStyle->SetStatY(0.98);
126   gStyle->SetStatH(0.03);
127   gStyle->SetStatW(0.3);
128   gStyle->SetTickLength(0.02,"y");
129   gStyle->SetEndErrorSize(3);
130   gStyle->SetLabelSize(20,"xyz");
131   gStyle->SetLabelFont(font,"xyz"); 
132   gStyle->SetLabelOffset(0.01,"xyz");
133   gStyle->SetTitleFont(font,"xyz");
134   gStyle->SetTitleOffset(.8,"y");  
135   gStyle->SetTitleOffset(1.,"xz");  
136   gStyle->SetTitleSize(24,"x");  
137   gStyle->SetTitleSize(24,"y");  
138   gStyle->SetMarkerSize(1); 
139   gStyle->SetPalette(1,0); 
140   
141   if (lStat){
142     gStyle->SetOptTitle(1);
143     gStyle->SetOptStat(1111);
144     gStyle->SetOptFit(1111);
145   }
146   else {
147     gStyle->SetOptTitle(0);
148     gStyle->SetOptStat(0);
149     gStyle->SetOptFit(0);
150   }
151 }
152
153 TGraphErrors* makeGraphH1(TH1* hist, TString name="")
154 {
155   name.ReplaceAll(" ","");
156   Int_t nbins = hist->GetNbinsX();
157   Double_t* x = new Double_t[nbins];
158   Double_t* y = new Double_t[nbins];
159   Double_t* xerr = new Double_t[nbins]; 
160   Double_t* yerr = new Double_t[nbins];
161   Int_t n=0;
162   for (Int_t i=0; i<nbins; i++)
163   {
164     //if (hist->GetBinContent(i+1)==0.0) continue;
165     
166     x[n] = hist->GetXaxis()->GetBinCenter(i+1);
167     y[n] = hist->GetBinContent(i+1);
168     xerr[n] = 0.0;
169     yerr[n] = hist->GetBinError(i+1);
170     n++;
171   }
172   TGraphErrors* gr = new TGraphErrors(n,x,y,xerr,yerr);
173   delete [] x;
174   delete [] y;
175   delete [] xerr;
176   delete [] yerr;
177   return gr;
178 }
179
180 TGraphErrors* makeGraphPr(TProfile* hist, TString name="")
181 {
182   name.ReplaceAll(" ","");
183   Int_t nbins = hist->GetNbinsX();
184   Double_t* x = new Double_t[nbins];
185   Double_t* y = new Double_t[nbins];
186   Double_t* xerr = new Double_t[nbins]; 
187   Double_t* yerr = new Double_t[nbins];
188   Int_t n=0;
189   for (Int_t i=0; i<nbins; i++)
190   {
191     //if (hist->GetBinContent(i+1)==0.0) continue;
192     
193     x[n] = hist->GetXaxis()->GetBinCenter(i+1);
194     y[n] = hist->GetBinContent(i+1);
195     xerr[n] = 0.0;
196     yerr[n] = hist->GetBinError(i+1);
197     n++;
198   }
199   TGraphErrors* gr = new TGraphErrors(n,x,y,xerr,yerr);
200   delete [] x;
201   delete [] y;
202   delete [] xerr;
203   delete [] yerr;
204   return gr;
205 }
206
207 void myHistoSetUp
208 (
209   TH1F *hist=0, TString xTitle="xTitle", TString yTitle="yTitle", float minY=-1, float maxY=1, int lineColor=1, int lineStyle=2,
210  int nDivisionsX=305,int nDivisionsY=305
211 )
212 {
213   hist->GetXaxis()->SetTitle(xTitle);
214   hist->GetYaxis()->SetTitle(yTitle);
215   hist->SetMinimum(minY);
216   hist->SetMaximum(maxY);
217   hist->SetLineColor(lineColor);
218   hist->SetLineStyle(lineStyle);
219   hist->SetNdivisions(nDivisionsX,"x");
220   hist->SetNdivisions(nDivisionsY,"y");
221   return;
222 }
223
224 // Shift original TGraphErrors along x-axis by amount determined by 'shift'.
225 void ShiftAlongXaxis(TGraphErrors *ge, Double_t shift)
226 {
227   if(!ge)
228   {
229     printf("\n WARNING: ge is NULL in ShiftAlongXaxis() !!!! \n\n");
230     return;
231   }
232   Int_t nPoints = ge->GetN();
233   Double_t x = 0.;
234   Double_t y = 0.;
235   for(Int_t p=0;p<nPoints;p++)
236   {
237     ge->GetPoint(p,x,y);
238     x+=shift;
239     ge->SetPoint(p,x,y);
240   }
241 }
242
243 void ScaleXaxis(TGraphErrors *ge, Double_t scale)
244 {
245   if(!ge)
246   {
247     printf("\n WARNING: ge is NULL in ShiftAlongXaxis() !!!! \n\n");
248     return;
249   }
250   Int_t nPoints = ge->GetN();
251   Double_t x = 0.;
252   Double_t y = 0.;
253   for(Int_t p=0;p<nPoints;p++)
254   {
255     ge->GetPoint(p,x,y);
256     x*=scale;
257     ge->SetPoint(p,x,y);
258   }
259 }
260
261
262 void myTGraphSetUp
263 (
264   TGraphErrors *currentGraph=0,
265  int myMarkerStyle=8,
266  int myMarkerColor=1,
267  float myMarkerSize=1,
268  int myLineStyle=1,
269  int myLineColor=1,
270  float myLineWidth=1,
271  int myFillStyle =fillStyle,
272  int myFillColor =1 
273 )
274 {
275   currentGraph->SetMarkerStyle(myMarkerStyle);
276   currentGraph->SetMarkerColor(myMarkerColor);
277   currentGraph->SetMarkerSize(myMarkerSize);
278   currentGraph->SetLineColor(myLineColor);
279   currentGraph->SetLineStyle(myLineStyle);
280   currentGraph->SetLineWidth(myLineWidth);
281   currentGraph->SetFillStyle(myFillStyle);
282   currentGraph->SetFillColor(myFillColor);
283   //   currentGraph->Set();
284 }