marcro updates
[u/mrichter/AliRoot.git] / PWGCF / Correlations / macros / dphicorrelations / correct.C
1 Float_t gpTMin = 0.51;
2 Float_t gpTMax = 49.99;
3 Int_t gUEHist = 0;
4 Bool_t gCache = 0;
5 void* gFirst = 0;
6 void* gSecond = 0;
7 Float_t gForceRange = -1;
8 Int_t gEnergy = 900;
9 Int_t gRegion = 0;
10 const char* gText = "";
11 TString Sign[]={"Plus","Minus"};
12 enum ECharge_t {
13   kPositive,
14   kNegative,
15   kNCharges
16 };
17
18 void SetRanges(TAxis* axis)
19 {
20   if (strcmp(axis->GetTitle(), "leading p_{T} (GeV/c)") == 0)
21     axis->SetRangeUser(0, (gEnergy == 900) ? 10 : 25);
22
23   if (strcmp(axis->GetTitle(), "multiplicity") == 0)
24     axis->SetRangeUser(0, 10);
25 }
26
27 void SetRanges(TH1* hist)
28 {
29   SetRanges(hist->GetXaxis());
30   SetRanges(hist->GetYaxis());
31   SetRanges(hist->GetZaxis());
32 }
33
34 void Prepare1DPlot(TH1* hist)
35 {
36   if (!hist)
37     return;
38
39   hist->SetLineWidth(2);
40   hist->SetStats(kFALSE);
41
42   hist->GetXaxis()->SetLabelOffset(0.02);
43   hist->GetXaxis()->SetTitleOffset(1.3);
44   hist->GetYaxis()->SetTitleOffset(1.3);
45
46   SetRanges(hist);
47 }
48
49 TH1* GetSystematicUncertainty(TH1* corr, TH1* trackHist)
50 {
51   if (!trackHist)
52   {
53     systError = (TH1*) corr->Clone("systError");
54     systError->Reset();
55   }
56   else  // for dphi evaluation
57     systError = new TH1F("systError", "", 100, 0, 50);
58   
59   Float_t constantUnc = 0;
60   
61   // particle composition
62   constantUnc += 0.8 ** 2;
63   
64   // tpc efficiency
65   if (gEnergy == 900 && gpTMin < 1.0)
66     constantUnc += 1.0 ** 2;
67   else if (gEnergy == 900 && gpTMin < 1.5)
68     constantUnc += 0.5 ** 2;
69   if (gEnergy == 7000 && gpTMin < 1.0)
70     constantUnc += 1.0 ** 2;
71   else if (gEnergy == 7000 && gpTMin < 1.5)
72     constantUnc += 0.6 ** 2;
73   
74   // track cuts
75   if (gEnergy == 900 && gpTMin < 1.0)
76     constantUnc += 2.5 ** 2;
77   else if (gEnergy == 900 && gpTMin < 1.5)
78     constantUnc += 2.0 ** 2;
79   if (gEnergy == 7000)
80     constantUnc += 3.0 ** 2;
81
82   // difference corrected with pythia and phojet
83   if (gEnergy == 900 && gpTMin < 1.0)
84     constantUnc += 0.6 ** 2;
85   else if (gEnergy == 900 && gpTMin < 1.5)
86     constantUnc += 0.8 ** 2;
87   
88   if (gEnergy == 7000 && gpTMin < 1.0)
89   {
90     if (gUEHist == 0)
91       constantUnc += 0.6 ** 2;
92     if (gUEHist == 1)
93       constantUnc += 0.8 ** 2;
94     if (gUEHist == 2)
95       constantUnc += 1.0 ** 2;
96   }
97   else if (gEnergy == 7000 && gpTMin < 1.5)
98     constantUnc += 1.0 ** 2;
99     
100   for (Int_t bin=1; bin<=systError->GetNbinsX(); bin++)
101     systError->SetBinContent(bin, constantUnc);
102
103   // mis id bias
104   if (gUEHist == 0 || gUEHist == 2)
105     systError->Fill(0.75, 4.0 ** 2);
106   if (gUEHist == 1)
107     systError->Fill(0.75, 5.0 ** 2);
108
109   if (gEnergy == 900)
110   {
111     if (gpTMin < 1.0)
112       systError->Fill(1.25, 1.0 ** 2);
113     else if (gpTMin < 1.5)
114       systError->Fill(1.25, 2.0 ** 2);
115   }
116   
117   // non-closure in MC
118   if (gEnergy == 900)
119     for (Int_t bin=1; bin<=systError->GetNbinsX(); bin++)
120       systError->Fill(systError->GetXaxis()->GetBinCenter(bin), 1.0 ** 2);
121       
122   if (gEnergy == 7000)
123   {
124     if (gUEHist == 0 && gUEHist == 1)
125       systError->Fill(0.75, 2.0 ** 2);
126     if (gUEHist == 2)
127       systError->Fill(0.75, 1.2 ** 2);
128   }
129   
130   // vertex efficiency
131   systError->Fill(0.75, 1.0 ** 2);
132
133   // strangeness
134   for (Int_t bin=1; bin<=systError->GetNbinsX(); bin++)
135   {
136     if (gEnergy == 900)
137       systError->Fill(systError->GetXaxis()->GetBinCenter(bin), 0.5 ** 2);
138     if (gEnergy == 7000 && systError->GetXaxis()->GetBinCenter(bin) < 1.5)
139       systError->Fill(systError->GetXaxis()->GetBinCenter(bin), 2.0 ** 2);
140     else if (gEnergy == 7000)
141       systError->Fill(systError->GetXaxis()->GetBinCenter(bin), 1.0 ** 2);
142   }  
143     
144   for (Int_t bin=1; bin<=systError->GetNbinsX(); bin++)
145     systError->SetBinContent(bin, TMath::Sqrt(systError->GetBinContent(bin)));
146   
147   if (trackHist)
148   {
149     //new TCanvas; trackHist->Draw();
150     //new TCanvas; systError->DrawCopy("");
151     
152     Float_t uncFlat = 0;
153     for (Int_t i=1; i<=trackHist->GetNbinsX(); i++)
154       uncFlat += trackHist->GetBinContent(i) * systError->GetBinContent(systError->FindBin(trackHist->GetBinCenter(i)));
155     if (trackHist->Integral() > 0)
156       uncFlat /= trackHist->Integral();
157     
158     systError = (TH1F*) corr->Clone("systError");
159     systError->Reset();
160   
161     for (Int_t i=1; i<=systError->GetNbinsX(); i++)
162       systError->SetBinContent(i, uncFlat);
163       
164     //new TCanvas; systError->DrawCopy("");
165   }
166   
167   systError->SetFillColor(kGray);
168   systError->SetFillStyle(1001);
169   systError->SetMarkerStyle(0);
170   systError->SetLineColor(0);
171   
172   return systError;
173 }
174
175 void DrawRatio(TH1* corr, TH1* mc, const char* name, TH1* syst = 0)
176 {
177   mc->SetLineColor(2);
178
179   TCanvas* canvas3 = new TCanvas(name, name, 600, 600);
180   canvas3->Range(0, 0, 1, 1);
181
182   TPad* pad1 = new TPad(Form("%s_1", name), "", 0, 0.5, 0.98, 0.98);
183   pad1->Draw();
184
185   TPad* pad2 = new TPad(Form("%s_2", name), "", 0, 0.02, 0.98, 0.5);
186   pad2->Draw();
187
188   pad1->SetRightMargin(0.01);
189   pad2->SetRightMargin(0.01);
190   pad1->SetTopMargin(0.05);
191   pad1->SetLeftMargin(0.13);
192   pad2->SetLeftMargin(0.13);
193   pad2->SetBottomMargin(0.22);
194   
195   // no border between them
196   pad1->SetBottomMargin(0);
197   pad2->SetTopMargin(0);
198
199   pad1->cd();
200   pad1->SetGridx();
201   pad1->SetGridy();
202
203   if (gUEHist != 2)
204     TLegend* legend = new TLegend(0.15, 0.65, 0.55, 0.90);
205   else
206     TLegend* legend = new TLegend(0.55, 0.65, 0.95, 0.90);
207
208   legend->SetFillColor(0);
209   legend->AddEntry(corr, "Corrected");
210   legend->AddEntry(mc, "MC prediction");
211   legend->SetTextSize(0.08);
212
213   Prepare1DPlot(corr);
214
215   TH2F* dummy = new TH2F("dummy", "", 100, corr->GetXaxis()->GetBinLowEdge(1), corr->GetXaxis()->GetBinUpEdge(corr->GetNbinsX()), 1000, 0, TMath::Max(corr->GetMaximum(), mc->GetMaximum()) * 1.1);
216   dummy->SetYTitle(corr->GetYaxis()->GetTitle());
217   
218   //dummy = new TH2F("dummy", "", 100, corr->GetXaxis()->GetBinLowEdge(1), corr->GetXaxis()->GetBinUpEdge(corr->GetNbinsX()), 1000, 13.5, 20.5);
219   //dummy->SetYTitle("1/N_{trig} dN/d#Delta#phi");
220   
221   dummy->SetStats(kFALSE);
222   dummy->SetXTitle(corr->GetXaxis()->GetTitle());
223   dummy->GetYaxis()->SetTitleOffset(1);
224   Prepare1DPlot(dummy);
225
226   dummy->GetXaxis()->SetLabelSize(0.08);
227   dummy->GetYaxis()->SetLabelSize(0.08);
228   dummy->GetXaxis()->SetTitleSize(0.08);
229   dummy->GetYaxis()->SetTitleSize(0.08);
230   dummy->GetYaxis()->SetTitleOffset(0.8);
231   
232   if (gForceRange > 0)
233     dummy->GetYaxis()->SetRangeUser(0, gForceRange);
234   
235   dummy->DrawCopy();
236   
237   if (0 && gUEHist != 2)
238   {
239     const char* regionStr[] = { "Toward Region", "Away Region", "Transverse Region" };
240     latex = new TLatex(0.65, 0.1, regionStr[gRegion]);
241     latex->SetTextSize(0.075);
242     latex->SetNDC();
243     latex->Draw();
244   }
245   
246   if (syst)
247   {
248     systError = (TH1*) syst->Clone("corrSystError");
249     for (Int_t bin=1; bin<=systError->GetNbinsX(); bin++)
250     {
251       systError->SetBinError(bin, corr->GetBinContent(bin) * syst->GetBinContent(bin) / 100);
252       systError->SetBinContent(bin, corr->GetBinContent(bin));
253     }
254     
255     systError->Draw("E2 ][ SAME");
256   }
257   
258   corr->Draw("SAME");
259   mc->Draw("SAME");
260   
261   if (strlen(gText) > 0)
262   {
263     latex = new TLatex(0.2, 0.2, gText);
264     latex->SetNDC();
265     latex->SetTextSize(0.06);
266     latex->Draw();
267   }
268
269   //legend->Draw();
270
271   pad2->cd();
272   //pad2->SetBottomMargin(0.15);
273   //pad2->SetGridx();
274   //pad2->SetGridy();
275
276   TH1* ratio = (TH1*) mc->Clone("ratio");
277   ratio->Divide(corr);
278
279   Float_t minR = TMath::Min(0.91, ratio->GetMinimum() * 0.95);
280   Float_t maxR = TMath::Max(1.09, ratio->GetMaximum() * 1.05);
281   
282   minR = 0.8;
283   maxR = 1.2;
284
285   TH1F dummy3("dummy3", ";;Ratio: MC / corr", 100, corr->GetXaxis()->GetBinLowEdge(1), corr->GetXaxis()->GetBinUpEdge(corr->GetNbinsX()));
286   dummy3.SetXTitle(corr->GetXaxis()->GetTitle());
287   Prepare1DPlot(&dummy3);
288   dummy3.SetStats(kFALSE);
289   for (Int_t i=1; i<=100; ++i)
290         dummy3.SetBinContent(i, 1);
291   dummy3.GetYaxis()->SetRangeUser(minR, maxR);
292   dummy3.SetLineWidth(2);
293   dummy3.GetXaxis()->SetLabelSize(0.08);
294   dummy3.GetYaxis()->SetLabelSize(0.08);
295   dummy3.GetXaxis()->SetTitleSize(0.08);
296   dummy3.GetYaxis()->SetTitleSize(0.08);
297   dummy3.GetYaxis()->SetTitleOffset(0.8);
298   dummy3.DrawCopy();
299   
300   if (syst)
301   {
302     // for the ratio add in quadrature
303     for (Int_t bin=1; bin<=syst->GetNbinsX(); bin++)
304     {
305       if (corr->GetBinError(bin) > 0)
306         syst->SetBinError(bin, TMath::Sqrt(TMath::Power(syst->GetBinContent(bin) / 100, 2) + TMath::Power(corr->GetBinError(bin) / corr->GetBinContent(bin), 2)));
307       else
308         syst->SetBinError(bin, 0);
309       syst->SetBinContent(bin, 1);
310     }
311     
312     syst->Draw("E2 ][ SAME");
313     dummy3.DrawCopy("SAME");
314   }
315
316   ratio->Draw("SAME");
317   
318   ratio->Fit("pol0", "N");
319
320   canvas3->Modified();
321   //canvas3->SaveAs(Form("%s.eps", canvas3->GetTitle()));
322 }
323
324 void loadlibs()
325 {
326   gSystem->Load("libANALYSIS");
327   gSystem->Load("libANALYSISalice");
328   gSystem->Load("libCORRFW");
329   gSystem->Load("libPWGTools");
330   gSystem->Load("libPWGCFCorrelationsBase");
331 }
332
333 const char* lastFileName = 0;
334 void* cacheSameEvent = 0;
335 void* cacheMixedEvent = 0;
336
337 void* GetUEHistogram(const char* fileName, TList** listRef = 0, Bool_t mixed = kFALSE, const char* tag = "")
338 {
339   if (!lastFileName || strcmp(lastFileName, fileName) != 0)
340   {
341     lastFileName = fileName;
342     file = TFile::Open(fileName);
343     if (!file)
344       return 0;
345     
346     list = (TList*) gFile->Get("PWG4_LeadingTrackUE/histosLeadingTrackUE");
347     if (!list)
348       list = (TList*) gFile->Get(Form("PWG4_PhiCorrelations/histosPhiCorrelations%s", tag));
349     if (!list)
350       list = (TList*) gFile->Get("PWG4_PhiCorrelations/histosPhiCorrelations_Syst");
351       
352     if (!list)
353       return 0;
354       
355     if (listRef)
356       *listRef = list;
357       
358     cacheMixedEvent = list->FindObject("AliUEHistogramsMixed");
359     cacheSameEvent = list->FindObject("AliUEHistogramsSame");
360
361     if (mixed)
362       return cacheMixedEvent;
363     
364     if (list->FindObject("AliUEHistograms"))
365       return list->FindObject("AliUEHistograms");
366       
367     return cacheSameEvent;
368   }
369   else
370   {
371     Printf("GetUEHistogram --> Using cache for %s", fileName);
372     
373     if (mixed)
374       return cacheMixedEvent;
375     else
376       return cacheSameEvent;
377   }
378 }
379
380 void CompareBias(const char* mcFile = "PWG4_JetTasksOutput.root", Int_t region, Int_t ueHist)
381 {
382   loadlibs();
383
384   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(mcFile);
385   SetupRanges(h);
386   
387   const char* axis = "z";
388   Float_t ptLeadMin = 0;
389   Float_t ptLeadMax = -1;
390   
391   if (ueHist == 2)
392   {
393     ptLeadMin = 0.51 + 0;
394     ptLeadMax = 1.99 + 0;
395     axis = "y";
396   }
397   
398   biasFromData = (TH1*) h->GetUEHist(ueHist)->GetBias(AliUEHist::kCFStepBiasStudy, AliUEHist::kCFStepReconstructed, region, axis, ptLeadMin, ptLeadMax)->Clone("biasFromData");
399   biasFromData2 = (TH1*) h->GetUEHist(ueHist)->GetBias(AliUEHist::kCFStepBiasStudy2, AliUEHist::kCFStepReconstructed, region, axis, ptLeadMin, ptLeadMax)->Clone("biasFromData2");
400   //biasFromData = (TH1*) h->GetUEHist(ueHist)->GetBias(AliUEHist::kCFStepReconstructed, AliUEHist::kCFStepRealLeading, region, axis)->Clone("biasFromData");
401   biasFromMC   = (TH1*) h->GetUEHist(ueHist)->GetBias(AliUEHist::kCFStepReconstructed, AliUEHist::kCFStepTracked, region, axis, ptLeadMin, ptLeadMax)->Clone("biasFromMC");
402   //biasFromMC   = (TH1*) h->GetUEHist(ueHist)->GetBias(AliUEHist::kCFStepReconstructed, AliUEHist::kCFStepRealLeading, region, axis)->Clone("biasFromMC");
403   
404 /*  biasFromData->Draw();
405   biasFromMC->SetLineColor(2);
406   biasFromMC->Draw("SAME");
407   return;*/
408   
409   DrawRatio(biasFromData, biasFromMC, "bias: data vs MC");
410   DrawRatio(biasFromData, biasFromData2, "bias: data vs data two step");
411 }
412   
413 void CompareBiasWithData(const char* mcFile = "PWG4_JetTasksOutput.root", const char* dataFile = "esd.root", Int_t region = 2)
414 {
415   loadlibs();
416
417   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(mcFile);
418   SetupRanges(h);
419   
420   biasFromMC   = (TH1*) h->GetNumberDensitypT()->GetBias(AliUEHist::kCFStepReconstructed, AliUEHist::kCFStepTracked, region, "z")->Clone("biasFromMC");
421   
422   AliUEHistograms* h2 = (AliUEHistograms*) GetUEHistogram(dataFile);
423   SetupRanges(h2);
424   
425   biasFromData = (TH1*) h2->GetNumberDensitypT()->GetBias(AliUEHist::kCFStepBiasStudy, AliUEHist::kCFStepReconstructed, region, "z")->Clone("biasFromData");
426   biasFromData2 = (TH1*) h2->GetNumberDensitypT()->GetBias(AliUEHist::kCFStepBiasStudy2, AliUEHist::kCFStepReconstructed, region, "z")->Clone("biasFromData2");
427   
428   DrawRatio(biasFromData, biasFromMC, "bias: data vs MC");
429   DrawRatio(biasFromData, biasFromData2, "bias: data vs data two step");
430 }
431
432 Int_t count = 0;
433
434 void Compare(const char* fileName1, const char* fileName2, Int_t id, Int_t step1, Int_t step2, Int_t region, Float_t ptLeadMin = -1, Float_t ptLeadMax = -1, Int_t centralityBegin = 0, Int_t centralityEnd = -1)
435 {
436   loadlibs();
437   
438   if (!gCache || !gFirst)
439   {
440     AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName1);
441     AliUEHistograms* h2 = (AliUEHistograms*) GetUEHistogram(fileName2);
442   }
443   
444   if (gCache)
445   {
446     if (!gFirst)
447     {
448       gFirst = h;
449       gSecond = h2;
450     }
451     else
452     {
453       AliUEHistograms* h = (AliUEHistograms*) gFirst;
454       AliUEHistograms* h2 = (AliUEHistograms*) gSecond;
455     }
456   }
457   
458   SetupRanges(h);
459   SetupRanges(h2);
460   
461   TH1* hist1 = h->GetUEHist(id)->GetUEHist(step1, region, ptLeadMin, ptLeadMax, centralityBegin, centralityEnd);
462   //TH1* hist1 = h->GetUEHist(id)->GetUEHist(step1, region, ptLeadMin, ptLeadMax);
463   TH1* hist2 = h2->GetUEHist(id)->GetUEHist(step2, region, ptLeadMin, ptLeadMax, centralityBegin, centralityEnd);
464
465   //hist1->Scale(1.0 / hist1->Integral());
466   //hist2->Scale(1.0 / hist2->Integral());
467
468   TH1* trackHist = 0;
469   if (id == 2)
470   {
471     trackHist = h->GetUEHist(id)->GetTrackHist(region)->ShowProjection(2, 0);
472     // only keep bins under consideration
473     for (Int_t bin=1; bin<=trackHist->GetNbinsX(); bin++)
474       if (bin < trackHist->FindBin(ptLeadMin) || bin > trackHist->FindBin(ptLeadMax))
475         trackHist->SetBinContent(bin, 0);
476   }
477
478   // systematic uncertainty
479   TH1* syst = 0; //GetSystematicUncertainty(hist1, trackHist);
480   
481   DrawRatio(hist1, hist2, Form("%d_%s_%d_%d_%d_%.2f_%.2f", count++, TString(gSystem->BaseName(fileName1)).Tokenize(".")->First()->GetName(), id, step1, region, ptLeadMin, ptLeadMax), syst);
482 }  
483
484 void CompareEventHist(const char* fileName1, const char* fileName2, Int_t id, Int_t step, Int_t var)
485 {
486   loadlibs();
487
488   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName1);
489   SetupRanges(h);
490
491   AliUEHistograms* h2 = (AliUEHistograms*) GetUEHistogram(fileName2);
492   SetupRanges(h2);
493
494   TH1* hist1 = h->GetUEHist(id)->GetEventHist()->ShowProjection(var, step);
495   TH1* hist2 = h2->GetUEHist(id)->GetEventHist()->ShowProjection(var, step);
496   
497 //   hist1 = hist1->Rebin(hist2->GetNbinsX(), "new", hist2->GetXaxis()->GetXbins()->GetArray());
498   
499 //   hist2 = hist2->Rebin(hist1->GetNbinsX(), "new", hist1->GetXaxis()->GetXbins()->GetArray());
500  
501   DrawRatio(hist1, hist2, "compare");
502 }
503
504 void CompareEventHist(const char* fileName1, const char* fileName2, Int_t id, Int_t step1, Int_t step2, Int_t var)
505 {
506   loadlibs();
507
508   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName1);
509   SetupRanges(h);
510
511   AliUEHistograms* h2 = (AliUEHistograms*) GetUEHistogram(fileName2);
512   SetupRanges(h2);
513   
514 //   h->GetUEHist(id)->GetEventHist()->GetGrid(step1)->GetGrid()->GetAxis(1)->SetRange(1, 5);
515 //   h2->GetUEHist(id)->GetEventHist()->GetGrid(step2)->GetGrid()->GetAxis(1)->SetRange(1, 5);
516   
517   TH1* hist1 = h->GetUEHist(id)->GetEventHist()->ShowProjection(var, step1);
518   TH1* hist2 = h2->GetUEHist(id)->GetEventHist()->ShowProjection(var, step2);
519  
520   DrawRatio(hist1, hist2, "compare");
521 }
522
523 void CompareStep(const char* fileName1, const char* fileName2, Int_t id, Int_t step, Int_t region, Float_t ptLeadMin = -1, Float_t ptLeadMax = -1)
524 {
525   // fileName1 is labelled Corrected in the plot
526
527   loadlibs();
528
529   gUEHist = id;
530   gRegion = region;
531   Compare(fileName1, fileName2, id, step, step, region, ptLeadMin, ptLeadMax);
532 }
533
534 void CompareStep(const char* fileName1, const char* fileName2, Int_t id, Int_t step1, Int_t step2, Int_t region, Float_t ptLeadMin = -1, Float_t ptLeadMax = -1, Int_t centralityBegin = 0, Int_t centralityEnd = -1)
535 {
536   // fileName1 is labelled Corrected in the plot
537
538   loadlibs();
539
540   gUEHist = id;
541   gRegion = region;
542   Compare(fileName1, fileName2, id, step1, step2, region, ptLeadMin, ptLeadMax, centralityBegin, centralityEnd);
543 }
544
545 TH1* DrawStep(const char* fileName, Int_t id, Int_t step, Int_t region, Float_t ptLeadMin = -1, Float_t ptLeadMax = -1, Int_t centralityBegin = 0, Int_t centralityEnd = -1, Int_t twoD = 0, Bool_t mixed = kFALSE)
546 {
547   loadlibs();
548
549   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName, 0, mixed);
550   SetupRanges(h);
551
552   new TCanvas;
553   return h->GetUEHist(id)->GetUEHist(step, region, ptLeadMin, ptLeadMax, centralityBegin, centralityEnd, twoD)->DrawCopy();
554 }
555
556 void DrawProjectionsRidge(const char* fileName, const char* fileNamePbPbMix = 0)
557 {
558   if (!fileNamePbPbMix)
559     fileNamePbPbMix = fileName;
560   
561   gpTMin = 1.01;
562   gpTMax = 2.99;
563   
564   loadlibs();
565   
566   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
567   hMixed = (AliUEHistograms*) GetUEHistogram(fileNamePbPbMix, 0, kTRUE);
568   
569   SetupRanges(h);
570   SetupRanges(hMixed);
571
572   TH1* hist1 = 0;
573   GetDistAndFlow(h, hMixed, &hist1,  0, 8, 0,  100, 3.01, 3.99, 1, kTRUE, 0, kTRUE); 
574   
575 //   ((TH2*) hist1)->Rebin2D(2, 2); hist1->Scale(0.25);
576
577 //   NormalizeToBinWidth(hist1);
578   
579   proj1y = ((TH2*) hist1)->ProjectionY("proj1y", hist1->GetXaxis()->FindBin(-0.5), hist1->GetXaxis()->FindBin(0.5));
580   proj1x = ((TH2*) hist1)->ProjectionX("proj1x", hist1->GetYaxis()->FindBin(-1.79), hist1->GetYaxis()->FindBin(1.79));
581   
582   proj1y->Scale(1.0 / (hist1->GetXaxis()->FindBin(0.5) - hist1->GetXaxis()->FindBin(-0.5) + 1));
583   proj1x->Scale(1.0 / (hist1->GetYaxis()->FindBin(1.79) - hist1->GetYaxis()->FindBin(-1.79) + 1));
584   
585   proj1y->GetXaxis()->SetTitleOffset(1);
586   proj1x->GetXaxis()->SetTitleOffset(1);
587   
588   Float_t zyam = proj1x->GetBinContent(proj1x->GetXaxis()->FindBin(TMath::Pi()/2));
589   proj1x->Add(new TF1("func", "-1", -100, 100), zyam);
590   proj1y->Add(new TF1("func", "-1", -100, 100), zyam);
591   
592   new TCanvas("c", "c", 800, 800);
593   gPad->SetLeftMargin(0.15);
594   hist1->SetTitle("");
595   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
596   hist1->GetXaxis()->SetTitleOffset(1.5);
597   hist1->GetYaxis()->SetTitleOffset(2);
598   hist1->SetStats(kFALSE);
599   hist1->DrawCopy("SURF1");
600   
601 //   new TCanvas; proj1y->Draw(); new TCanvas; proj1x->Draw();  return;
602   
603   TH1* hist2 = 0;
604   GetDistAndFlow(h, hMixed, &hist2,  0, 8, 40,  100, 4.01, 5.99, 1, kTRUE, 0, kTRUE); 
605   
606 //   ((TH2*) hist2)->Rebin2D(2, 2); hist2->Scale(0.25);
607 //   NormalizeToBinWidth(hist2);
608   
609   proj2y = ((TH2*) hist2)->ProjectionY("proj2y", hist1->GetXaxis()->FindBin(-0.5), hist1->GetXaxis()->FindBin(0.5));
610   proj2x = ((TH2*) hist2)->ProjectionX("proj2x", hist1->GetYaxis()->FindBin(-1.79), hist1->GetYaxis()->FindBin(1.79));
611
612   proj2y->Scale(1.0 / (hist1->GetXaxis()->FindBin(0.5) - hist1->GetXaxis()->FindBin(-0.5) + 1));
613   proj2x->Scale(1.0 / (hist1->GetYaxis()->FindBin(1.79) - hist1->GetYaxis()->FindBin(-1.79) + 1));
614  
615   zyam = proj2x->GetBinContent(proj2x->GetXaxis()->FindBin(TMath::Pi()/2));
616   proj2x->Add(new TF1("func", "-1", -100, 100), zyam);
617   proj2y->Add(new TF1("func", "-1", -100, 100), zyam);
618
619   proj2y->SetLineColor(2); proj2x->SetLineColor(2);
620   
621   new TCanvas; proj1y->Draw(); proj2y->Draw("SAME");
622   new TCanvas; proj1x->Draw(); proj2x->Draw("SAME");
623   
624   new TCanvas("c2", "c2", 800, 800);
625   gPad->SetLeftMargin(0.15);
626   hist2->SetTitle("");
627   hist2->GetYaxis()->SetRangeUser(-1.79, 1.79);
628   hist2->GetXaxis()->SetTitleOffset(1.5);
629   hist2->GetYaxis()->SetTitleOffset(2);
630   hist2->SetStats(kFALSE);
631   hist2->DrawCopy("SURF1");
632 }
633
634 void DrawExample(const char* fileName, const char* fileNamePbPbMix = 0)
635 {
636   if (!fileNamePbPbMix)
637     fileNamePbPbMix = fileName;
638   
639   gpTMin = 1.01;
640   gpTMax = 1.99;
641   
642   loadlibs();
643   
644   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
645   hMixed = (AliUEHistograms*) GetUEHistogram(fileNamePbPbMix, 0, kTRUE);
646   
647   SetupRanges(h);
648   SetupRanges(hMixed);
649
650   TH1* hist1 = 0;
651   GetDistAndFlow(h, hMixed, &hist1,  0, 8, 0,  40, 1.01, 1.99, 1, kTRUE, 0, kTRUE); 
652   
653   ((TH2*) hist1)->Rebin2D(2, 2);
654   hist1->Scale(0.25);
655
656 //   NormalizeToBinWidth(hist1);
657   
658   new TCanvas("c", "c", 800, 800);
659   gPad->SetLeftMargin(0.15);
660   hist1->SetTitle("");
661   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
662   hist1->GetXaxis()->SetTitleOffset(1.5);
663   hist1->GetYaxis()->SetTitleOffset(2);
664   hist1->SetStats(kFALSE);
665   hist1->DrawCopy("SURF1");
666   
667   TH1* hist2 = 0;
668   GetDistAndFlow(h, hMixed, &hist2,  0, 8, 40,  100, 1.01, 1.99, 1, kTRUE, 0, kTRUE); 
669   
670   ((TH2*) hist2)->Rebin2D(2, 2); hist2->Scale(0.25);
671
672 //   NormalizeToBinWidth(hist1);
673   
674   new TCanvas("c2", "c2", 800, 800);
675   gPad->SetLeftMargin(0.15);
676   hist2->SetTitle("");
677   hist2->GetYaxis()->SetRangeUser(-1.79, 1.79);
678   hist2->GetXaxis()->SetTitleOffset(1.5);
679   hist2->GetYaxis()->SetTitleOffset(2);
680   hist2->SetStats(kFALSE);
681   hist2->DrawCopy("SURF1");
682   
683   
684
685   return;
686   
687   hist2 = hist1;
688   /*
689   GetDistAndFlow(h, hMixed, &hist1,  0, 0, 0,  10, 2.01, 3.99, 1, kTRUE, 0, kTRUE); 
690
691   ((TH2*) hist1)->Rebin2D(2, 2);
692 //   NormalizeToBinWidth(hist1);
693
694   new TCanvas("c2", "c2", 800, 800);
695   gPad->SetLeftMargin(0.15);
696   hist1->SetTitle("");
697   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
698   hist1->GetXaxis()->SetTitleOffset(1.5);
699   hist1->GetYaxis()->SetTitleOffset(2);
700   hist1->SetStats(kFALSE);
701   hist1->DrawCopy("SURF1");  
702   
703   hist1->Divide(hist2);
704
705   new TCanvas("c5", "c5", 800, 800);
706   gPad->SetLeftMargin(0.15);
707   hist1->SetTitle("");
708   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
709   hist1->GetXaxis()->SetTitleOffset(1.5);
710   hist1->GetYaxis()->SetTitleOffset(2);
711   hist1->SetStats(kFALSE);
712   hist1->DrawCopy("SURF1");    
713   
714   return;
715
716   GetDistAndFlow(h, hMixed, &hist1,  0, 6, 0,  10, 2.01, 3.99, 1, kTRUE, 0, kTRUE, 6); 
717
718   ((TH2*) hist1)->Rebin2D(2, 2);
719 //   NormalizeToBinWidth(hist1);
720
721   new TCanvas("c3", "c3", 800, 800);
722   gPad->SetLeftMargin(0.15);
723   hist1->SetTitle("");
724   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
725   hist1->GetXaxis()->SetTitleOffset(1.5);
726   hist1->GetYaxis()->SetTitleOffset(2);
727   hist1->SetStats(kFALSE);
728   hist1->DrawCopy("SURF1");  
729   
730 //   return;
731   
732 //   TH1* hist1 = 0;
733 //   GetDistAndFlow(h, hMixed, &hist1,  0, 4, 0,  10, 2.01, 3.99, 1, kTRUE, 0, kTRUE, 6); 
734 //   
735 //   ((TH2*) hist1)->Rebin2D(2, 2);
736 // //   hist1->Scale(0.25);
737 // 
738 // //   NormalizeToBinWidth(hist1);
739 //   
740 //   new TCanvas("c1b", "c1b", 800, 800);
741 //   gPad->SetLeftMargin(0.15);
742 //   hist1->SetTitle("");
743 //   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
744 //   hist1->GetXaxis()->SetTitleOffset(1.5);
745 //   hist1->GetYaxis()->SetTitleOffset(2);
746 //   hist1->SetStats(kFALSE);
747 //   hist1->DrawCopy("SURF1");
748 //   hist2 = hist1;
749   
750 //   return;
751   
752 //   GetDistAndFlow(h, 0, &hist1,  0, 8, 0,  10, 2.01, 3.99, 1, kTRUE, 0, kTRUE); 
753 // 
754 //   NormalizeToBinWidth(hist1);
755 // //   
756 //   for (Int_t i=1; i<=hist1->GetNbinsX(); ++i)
757 //   {
758 //     for (Int_t j=1; j<=hist1->GetNbinsY(); ++j)
759 //     {
760 //       Float_t factor = 1.0 / (2.0 - TMath::Abs(hist1->GetYaxis()->GetBinCenter(j)));
761 //       hist1->SetBinContent(i, j, hist1->GetBinContent(i, j) * factor);
762 //       hist1->SetBinError(i, j, hist1->GetBinError(i, j) * factor);
763 //     }
764 //   }
765
766 /*  new TCanvas("c4", "c4", 800, 800);
767   gPad->SetLeftMargin(0.15);
768   hist1->SetTitle("");
769   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
770   hist1->GetXaxis()->SetTitleOffset(1.5);
771   hist1->GetYaxis()->SetTitleOffset(2);
772   hist1->SetStats(kFALSE);
773   hist1->DrawCopy("SURF1");  */
774   
775   AliUEHistograms* h2 = (AliUEHistograms*) GetUEHistogram("corrected.root");
776   AliUEHistograms* h2Mixed = (AliUEHistograms*) GetUEHistogram("corrected.root", 0, kTRUE);
777   SetupRanges(h2);
778   SetupRanges(h2Mixed);
779  
780   GetDistAndFlow(h2, h2Mixed, &hist1,  0, 8, 0,  10, 2.01, 3.99, 1, kTRUE, 0, kTRUE); 
781   ((TH2*) hist1)->Rebin2D(2, 2);
782
783   new TCanvas("c4", "c4", 800, 800);
784   gPad->SetLeftMargin(0.15);
785   hist1->SetTitle("");
786   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
787   hist1->GetXaxis()->SetTitleOffset(1.5);
788   hist1->GetYaxis()->SetTitleOffset(2);
789   hist1->SetStats(kFALSE);
790   hist1->DrawCopy("SURF1");  
791   
792   hist1->Divide(hist2);
793
794   new TCanvas("c5", "c5", 800, 800);
795   gPad->SetLeftMargin(0.15);
796   hist1->SetTitle("");
797   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
798   hist1->GetXaxis()->SetTitleOffset(1.5);
799   hist1->GetYaxis()->SetTitleOffset(2);
800   hist1->SetStats(kFALSE);
801   hist1->DrawCopy("SURF1");  
802
803 //   hist1->Divide(histMixed);
804   
805 //   NormalizeToBinWidth(hist1);
806 // //   
807 //   for (Int_t i=1; i<=hist1->GetNbinsX(); ++i)
808 //   {
809 //     for (Int_t j=1; j<=hist1->GetNbinsY(); ++j)
810 //     {
811 //       Float_t factor = 1.0 / (2.0 - TMath::Abs(hist1->GetYaxis()->GetBinCenter(j)));
812 //       hist1->SetBinContent(i, j, hist1->GetBinContent(i, j) * factor);
813 //       hist1->SetBinError(i, j
814 //   }, hist1->GetBinError(i, j) * factor);
815 //     }
816
817 //   new TCanvas("c6", "c6", 800, 800);
818 //   gPad->SetLeftMargin(0.15);
819 //   hist1->SetTitle("");
820 //   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
821 //   hist1->GetXaxis()->SetTitleOffset(1.5);
822 //   hist1->GetYaxis()->SetTitleOffset(2);
823 //   hist1->SetStats(kFALSE);
824 //   hist1->DrawCopy("SURF1");  
825   
826   return;
827   
828   GetSumOfRatios(h, hMixed, &hist1,  6, 60,  90, 8.01, 9.99, kTRUE); 
829   new TCanvas("c2", "c2", 800, 800);
830   gPad->SetLeftMargin(0.15);
831   hist1->SetTitle("");
832   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
833   hist1->GetXaxis()->SetTitleOffset(1.5);
834   hist1->GetYaxis()->SetTitleOffset(2);
835   hist1->SetStats(kFALSE);
836   hist1->Draw("SURF1");
837
838   return;
839   
840   latex = new TLatex(0.82, 0.74, "ALICE performance");
841   latex->SetTextSize(0.02);
842   latex->SetTextAlign(22);
843   latex->SetNDC();
844   latex->Draw();
845   latex = new TLatex(0.82, 0.72, "Pb-Pb 2.76 TeV");
846   latex->SetTextSize(0.02);
847   latex->SetTextAlign(22);
848   latex->SetNDC();
849   latex->Draw();
850   latex = new TLatex(0.82, 0.70, "28.09.11");
851   latex->SetTextSize(0.02);
852   latex->SetTextAlign(22);
853   latex->SetNDC();
854   latex->Draw();
855
856   DrawALICELogo(0.75, 0.75, 0.9, 0.9);
857 }
858
859 void DrawExample2(const char* fileName)
860 {
861   loadlibs();
862   
863   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
864   hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);
865   
866   gpTMin = 0.51;
867   gpTMax = 0.99;
868   SetupRanges(h);
869   SetupRanges(hMixed);
870
871   TH1* hist1 = 0;
872   GetSumOfRatios(h, hMixed, &hist1,  8, 0,  5, 0.51, 0.99);
873   
874   new TCanvas("c", "c", 800, 800);
875   gPad->SetLeftMargin(0.15);
876   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
877   hist1->GetXaxis()->SetTitleOffset(1.5);
878   hist1->GetYaxis()->SetTitleOffset(2);
879   hist1->SetStats(kFALSE);
880   hist1->DrawCopy("SURF1"); 
881 }  
882
883 void CompareZVtxWeighting(const char* fileName, Int_t step = 8)
884 {
885   gpTMin = 1.01;
886   gpTMax = 1.99;
887   
888   loadlibs();
889   
890   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
891   hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);
892   
893   SetupRanges(h);
894   SetupRanges(hMixed);
895   
896   TH1* hist1 = 0;
897   GetDistAndFlow(h, hMixed, &hist1,  0, step, 0,  10, 5.01, 9.99, 1, kTRUE, 0, kTRUE); 
898   hist1->Scale(1.0 / 0.972222);
899   
900   TH1* hist2 = 0;
901   GetSumOfRatios(h, hMixed, &hist2,  step, 0,  10, 5.01, 9.99, kTRUE);
902   
903   c = new TCanvas("c", "c", 1200, 400);
904   c->Divide(3, 1);
905   
906   c->cd(1); hist1->DrawCopy("SURF1");
907   c->cd(2); hist2->DrawCopy("SURF1");
908   
909   hist1->SetStats(0);
910   hist1->Divide(hist2);
911   
912   c->cd(3); hist1->DrawCopy("COLZ");
913 }
914
915 void DrawSameMixed(const char* fileName, const char* fileNamePbPbMix = 0, Int_t step = 6)
916 {
917   if (!fileNamePbPbMix)
918     fileNamePbPbMix = fileName;
919   
920   gpTMin = 1.01;
921   gpTMax = 1.99;
922   
923   loadlibs();
924   
925   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
926   hMixed = (AliUEHistograms*) GetUEHistogram(fileNamePbPbMix, 0, kTRUE);
927   
928   SetupRanges(h);
929   SetupRanges(hMixed);
930   
931   TH1* hist1 = 0;
932   GetDistAndFlow(h, 0, &hist1,  0, step, 0,  80, 2.01, 3.99, 1, kTRUE, 0, kTRUE); 
933   
934 //   ((TH2*) hist1)->Rebin2D(2, 2);
935 //   hist1->Scale(0.25);
936
937   NormalizeToBinWidth(hist1);
938   
939 //   for (Int_t i=1; i<=hist1->GetNbinsX(); ++i)
940 //   {
941 //     for (Int_t j=1; j<=hist1->GetNbinsY(); ++j)
942 //     {
943 //       Float_t factor = 1.0 / (2.0 - TMath::Abs(hist1->GetYaxis()->GetBinCenter(j) / 0.9));
944 //       hist1->SetBinContent(i, j, hist1->GetBinContent(i, j) * factor);
945 //       hist1->SetBinError(i, j, hist1->GetBinError(i, j) * factor);
946 //     }
947 //   }
948
949   c = new TCanvas("c", "c", 1600, 800);
950   c->Divide(2, 1);
951   c->cd(1);
952   gPad->SetLeftMargin(0.15);
953   hist1->SetTitle("");
954   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
955   hist1->GetZaxis()->SetTitleOffset(1.8);
956   hist1->GetXaxis()->SetTitleOffset(1.5);
957   hist1->GetYaxis()->SetTitleOffset(2);
958   hist1->GetZaxis()->SetTitle("same event pairs (a.u.)");
959   hist1->SetStats(kFALSE);
960   hist1->DrawCopy("SURF1");
961   
962   DrawALICELogo(kFALSE, 0.2, 0.7, 0.4, 0.9);
963   
964   hist2 = hist1;
965   
966   GetDistAndFlow(hMixed, 0, &hist1,  0, step, 0,  80, 2.01, 3.99, 1, kTRUE, 0, kTRUE); 
967   
968 //   ((TH2*) hist1)->Rebin2D(2, 2);
969   NormalizeToBinWidth(hist1);
970   
971 //   for (Int_t j=1; j<=hist1->GetNbinsY(); ++j)
972 //   {
973 //     Float_t factor = 1.0 / (1.0 - TMath::Abs(hist1->GetYaxis()->GetBinCenter(j)) / 6.0);
974 //     Printf("%d %f", j, factor);
975 //     for (Int_t i=1; i<=hist1->GetNbinsX(); ++i)
976 //     {
977 //       hist1->SetBinContent(i, j, hist1->GetBinContent(i, j) * factor);
978 //       hist1->SetBinError(i, j, hist1->GetBinError(i, j) * factor);
979 //     }
980 //   }
981
982   c->cd(2);
983   gPad->SetLeftMargin(0.15);
984   hist1->SetTitle("");
985   hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
986   hist1->GetZaxis()->SetTitleOffset(1.8);
987   hist1->GetXaxis()->SetTitleOffset(1.5);
988   hist1->GetYaxis()->SetTitleOffset(2);
989   hist1->GetZaxis()->SetTitle("mixed event pairs (a.u.)");
990   hist1->SetStats(kFALSE);
991   hist1->DrawCopy("SURF1");
992   
993   DrawALICELogo(kFALSE, 0.2, 0.7, 0.4, 0.9);
994
995   c->SaveAs(Form("samemixed_%d.eps", step));
996   c->SaveAs(Form("samemixed_%d.png", step));
997
998   new TCanvas("c3", "c3", 800, 800);
999   gPad->SetLeftMargin(0.15);
1000   hist2->Divide(hist1);
1001   hist2->DrawCopy("SURF1");
1002 }
1003
1004 void Validation2DAllStepsNew(const char* fileName, Int_t bin = 0)
1005 {
1006   Int_t centralityFrom = 0;
1007   Int_t centralityTo = 80;
1008   
1009   gpTMin = 1.01;
1010   gpTMax = 1.99;
1011   
1012   Float_t ptTrigBegin = 2.01;
1013   Float_t ptTrigEnd = 3.99;
1014   
1015   if (bin == 1)
1016   {
1017     gpTMin = 0.51;
1018     gpTMax = 0.99;
1019     ptTrigBegin = 1.01;
1020     ptTrigEnd = 1.99;
1021   }
1022   else if (bin == 2)
1023   {
1024     gpTMin = 0.51;
1025     gpTMax = 0.99;
1026     ptTrigBegin = 0.51;
1027     ptTrigEnd = 0.99;
1028   }
1029   else if (bin == 3)
1030   {
1031 /*    gpTMin = 0.51;
1032     gpTMax = 0.99;
1033     ptTrigBegin = 0.51;
1034     ptTrigEnd = 0.99;*/
1035     centralityFrom = 0;
1036     centralityTo = 20;
1037   }
1038   else if (bin == 4)
1039   {
1040 /*    gpTMin = 0.51;
1041     gpTMax = 0.99;
1042     ptTrigBegin = 0.51;
1043     ptTrigEnd = 0.99;*/
1044     centralityFrom = 60;
1045     centralityTo = 80;
1046   }
1047   else if (bin == 5)
1048   {
1049     gpTMin = 0.51;
1050     gpTMax = 0.74;
1051     ptTrigBegin = 0.51;
1052     ptTrigEnd = 0.99;
1053   }
1054   
1055   loadlibs();
1056   
1057   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
1058   hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);
1059   
1060   SetupRanges(h);
1061   SetupRanges(hMixed);
1062
1063   TH1* hist[6];
1064
1065   GetSumOfRatios(h, hMixed, &hist[0],  0, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1066   GetSumOfRatios(h, hMixed, &hist[1],  4, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1067   GetSumOfRatios(h, hMixed, &hist[2],  5, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1068   GetSumOfRatios(h, hMixed, &hist[3],  6, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1069   GetSumOfRatios(h, hMixed, &hist[4],  8, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1070   GetSumOfRatios(h, hMixed, &hist[5],  10, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1071
1072   c = new TCanvas("c", "c", 1600, 1000);
1073   c->Divide(6, 4);
1074   
1075   Float_t peakYield1[6];
1076   Float_t baselineValues1[6];
1077
1078   for (Int_t i=0; i<6; i++)
1079   {
1080     if (!hist[i])
1081       continue;
1082     
1083     // NOTE fix normalization. these 2d correlations come out of AliUEHist normalized by dphi bin width, but not deta
1084     hist[i]->Scale(1.0 / hist[i]->GetYaxis()->GetBinWidth(1));
1085
1086     ((TH2*) hist[i])->Rebin2D(2, 2); hist[i]->Scale(0.25);
1087   }
1088   
1089   for (Int_t i=0; i<6; i++)
1090   {
1091     if (!hist[i])
1092       continue;
1093
1094     c->cd(i+1);
1095     hist[i]->GetYaxis()->SetRangeUser(-1.99, 1.99);
1096     hist[i]->GetXaxis()->SetTitleOffset(1.5);
1097     hist[i]->GetYaxis()->SetTitleOffset(2);
1098     hist[i]->GetZaxis()->SetTitleOffset(1.8);
1099     hist[i]->GetZaxis()->SetTitle("1/N_{trig} dN_{assoc}/d#Delta#etad#Delta#varphi (1/rad.)");
1100     hist[i]->SetStats(kFALSE);
1101     hist[i]->DrawCopy("SURF1");    
1102     
1103     if (hist[5])
1104     {
1105       c->cd(i+1+6);
1106       TH2* clone = (TH2*) hist[i]->Clone();
1107       clone->Divide(hist[5]);
1108       clone->DrawCopy("COLZ");
1109       gPad->SetRightMargin(0.15);
1110     }
1111     
1112     c->cd(i+1+12);
1113     proj1 = ((TH2*) hist[i])->ProjectionX(Form("proj1_%d", i), hist[i]->GetYaxis()->FindBin(-0.99), hist[i]->GetYaxis()->FindBin(0.99));
1114     proj1->DrawCopy();
1115     
1116     baselineValues1[i] = proj1->Integral(proj1->FindBin(TMath::Pi()/2 - 0.2), proj1->FindBin(TMath::Pi()/2 + 0.2)) / (proj1->FindBin(TMath::Pi()/2 + 0.2) - proj1->FindBin(TMath::Pi()/2 - 0.2) + 1);
1117     peakYield1[i] = proj1->Integral(proj1->GetXaxis()->FindBin(-1), proj1->GetXaxis()->FindBin(1)) / (proj1->GetXaxis()->FindBin(0.99) - proj1->GetXaxis()->FindBin(-0.99) + 1) - baselineValues1[i];
1118     Printf("%d: %f %f", i, peakYield1[i], baselineValues1[i]);
1119
1120     if (hist[5])
1121     {
1122       proj2 = ((TH2*) hist[5])->ProjectionX(Form("proj2_%d", i), hist[5]->GetYaxis()->FindBin(-0.99), hist[5]->GetYaxis()->FindBin(0.99));
1123       proj2->SetLineColor(2);
1124       proj2->DrawCopy("SAME");
1125     
1126       c->cd(i+1+18);
1127       proj1->Divide(proj1, proj2, 1, 1, "B");
1128       proj1->Draw();
1129     }
1130   }
1131   
1132   c = new TCanvas("c2", "c2", 1600, 1000);
1133   c->Divide(6, 4);
1134
1135   for (Int_t i=0; i<6; i++)
1136   {
1137     if (!hist[i])
1138       continue;
1139
1140     c->cd(i+1);
1141     hist[i]->GetYaxis()->SetRangeUser(-1.99, 1.99);
1142     hist[i]->GetXaxis()->SetTitleOffset(1.5);
1143     hist[i]->GetYaxis()->SetTitleOffset(2);
1144     hist[i]->GetZaxis()->SetTitleOffset(1.8);
1145     hist[i]->GetZaxis()->SetTitle("1/N_{trig} dN_{assoc}/d#Delta#etad#Delta#varphi (1/rad.)");
1146     hist[i]->SetStats(kFALSE);
1147     hist[i]->DrawCopy("SURF1");    
1148     
1149     c->cd(i+1+6);
1150     TH2* clone = (TH2*) hist[i]->Clone();
1151     clone->Divide(hist[0]);
1152     clone->DrawCopy("COLZ");
1153     gPad->SetRightMargin(0.15);
1154     
1155     c->cd(i+1+12);
1156     proj1 = ((TH2*) hist[i])->ProjectionX(Form("proj3_%d", i), hist[i]->GetYaxis()->FindBin(-0.99), hist[i]->GetYaxis()->FindBin(0.99));
1157     proj1->DrawCopy();
1158     
1159     proj2 = ((TH2*) hist[0])->ProjectionX(Form("proj4_%d", i), hist[0]->GetYaxis()->FindBin(-0.99), hist[0]->GetYaxis()->FindBin(0.99));
1160     proj2->SetLineColor(2);
1161     proj2->DrawCopy("SAME");
1162     
1163     c->cd(i+1+18);
1164     proj1->Divide(proj1, proj2, 1, 1, "B");
1165     proj1->Draw();
1166   }
1167
1168   c = new TCanvas("c3", "c3", 1600, 1000);
1169   c->Divide(6, 4);
1170
1171   for (Int_t i=3; i<4; i++)
1172   {
1173     if (!hist[i])
1174       continue;
1175
1176     c->cd(i+1);
1177     hist[i]->GetYaxis()->SetRangeUser(-1.99, 1.99);
1178     hist[i]->GetXaxis()->SetTitleOffset(1.5);
1179     hist[i]->GetYaxis()->SetTitleOffset(2);
1180     hist[i]->GetZaxis()->SetTitleOffset(1.8);
1181     hist[i]->GetZaxis()->SetTitle("1/N_{trig} dN_{assoc}/d#Delta#etad#Delta#varphi (1/rad.)");
1182     hist[i]->SetStats(kFALSE);
1183     hist[i]->DrawCopy("SURF1");    
1184     
1185     c->cd(i+1+6);
1186     TH2* clone = (TH2*) hist[i]->Clone();
1187     clone->Divide(hist[4]);
1188     clone->DrawCopy("COLZ");
1189     gPad->SetRightMargin(0.15);
1190     
1191     c->cd(i+1+12);
1192     proj1 = ((TH2*) hist[i])->ProjectionX(Form("proj4_%d", i), hist[i]->GetYaxis()->FindBin(-0.99), hist[i]->GetYaxis()->FindBin(0.99));
1193     proj1->DrawCopy();
1194     
1195     proj2 = ((TH2*) hist[4])->ProjectionX(Form("proj5_%d", i), hist[4]->GetYaxis()->FindBin(-0.99), hist[4]->GetYaxis()->FindBin(0.99));
1196     proj2->SetLineColor(2);
1197     proj2->DrawCopy("SAME");
1198     
1199     c->cd(i+1+18);
1200     proj1->Divide(proj1, proj2, 1, 1, "B");
1201     proj1->Draw();
1202   }
1203   
1204   c = new TCanvas("c4", "c4", 1200, 400);
1205   c->Divide(3, 1);
1206  
1207   for (Int_t i=0; i<1; i++)
1208   {
1209     if (!hist[i])
1210       continue;
1211
1212     if (hist[5])
1213     {
1214       c->cd(1);
1215       TH2* clone = (TH2*) hist[i]->Clone();
1216       clone->Divide(hist[5]);
1217       clone->DrawCopy("COLZ");
1218       gPad->SetRightMargin(0.15);
1219     }
1220     
1221     c->cd(2);
1222     proj1 = ((TH2*) hist[i])->ProjectionX(Form("proj1_%d", i), hist[i]->GetYaxis()->FindBin(-0.99), hist[i]->GetYaxis()->FindBin(0.99));
1223     proj1->DrawCopy();
1224     
1225     baselineValues1[i] = proj1->Integral(proj1->FindBin(TMath::Pi()/2 - 0.2), proj1->FindBin(TMath::Pi()/2 + 0.2)) / (proj1->FindBin(TMath::Pi()/2 + 0.2) - proj1->FindBin(TMath::Pi()/2 - 0.2) + 1);
1226     peakYield1[i] = proj1->Integral(proj1->GetXaxis()->FindBin(-1), proj1->GetXaxis()->FindBin(1)) / (proj1->GetXaxis()->FindBin(0.99) - proj1->GetXaxis()->FindBin(-0.99) + 1) - baselineValues1[i];
1227     Printf("%d: %f %f", i, peakYield1[i], baselineValues1[i]);
1228
1229     if (hist[5])
1230     {
1231       proj2 = ((TH2*) hist[5])->ProjectionX(Form("proj2_%d", i), hist[5]->GetYaxis()->FindBin(-0.99), hist[5]->GetYaxis()->FindBin(0.99));
1232       proj2->SetLineColor(2);
1233       proj2->DrawCopy("SAME");
1234     
1235       c->cd(3);
1236       proj1->Divide(proj1, proj2, 1, 1, "B");
1237       proj1->Draw();
1238     }
1239   }
1240   
1241   for (Int_t i=0; i<6; i++)
1242     Printf("%d/%d: %f %f", i, 0, peakYield1[i] / peakYield1[0] - 1, baselineValues1[i] / baselineValues1[0] - 1);
1243
1244   if (hist[5])
1245   {
1246     for (Int_t i=0; i<6; i++)
1247       Printf("%d/%d: %f %f", i, 5, peakYield1[i] / peakYield1[5] - 1, baselineValues1[i] / baselineValues1[5] - 1);
1248   }
1249 }
1250
1251 void Validation2DAllBins(const char* fileName, const char *fileName2)
1252 {
1253   /* Int_t is[] = { 0, 1, 2, 3, 4, 5};
1254   Int_t js[] = { 1, 2, 3, 4, 5, 6 };
1255   Int_t n = 5;*/
1256 /*  Int_t is[] = { 0, 1, 1, 2, 2, 2, 3, 3, 3 };
1257   Int_t js[] = { 1, 1, 2, 1, 2, 3, 1, 2, 3 };*/
1258   Int_t is[] = { 0, 1, 1, 2, 2, 2, 3 };
1259   Int_t js[] = { 1, 1, 2, 1, 2, 3, 3 };
1260   Int_t n = 6;
1261   
1262   file1 = TFile::Open(fileName);
1263   TFile* file2 = 0;
1264   if (fileName2)
1265     file2 = TFile::Open(fileName2);
1266   
1267   file3 = TFile::Open("non_closure.root", "RECREATE");
1268   file3->Close();
1269   
1270   Float_t baselineValues1, baselineValues2, peakYield1, peakYield2;
1271   
1272   Int_t padID = 0;
1273   Int_t padN = 4;
1274   for (Int_t centr=0; centr<4; centr++)
1275   {
1276     for (Int_t i=0; i<n; i++)
1277     {
1278       if (padN == 4)
1279       {
1280         c = new TCanvas(Form("c%d", padID), Form("c%d", padID), 1100, 750);
1281         c->Divide(3, 3);
1282         padN = 1;
1283         padID++;
1284       }
1285
1286       TH2* hist1 = (TH2*) file1->Get(Form("dphi_%d_%d_%d", is[i], js[i], centr));
1287       if (!hist1)
1288         continue;
1289       TH2* hist2 = 0;
1290       if (file2)
1291         hist2 = (TH2*) file2->Get(Form("dphi_%d_%d_%d", is[i], js[i], centr));
1292       else
1293         hist2 = (TH2*) file1->Get(Form("dphi_%d_%d_%d", is[i], js[i], centr+4));
1294     
1295       // NOTE fix normalization. these 2d correlations come out of AliUEHist normalized by dphi bin width, but not deta
1296       hist1->Scale(1.0 / hist1->GetYaxis()->GetBinWidth(1));
1297       hist2->Scale(1.0 / hist2->GetYaxis()->GetBinWidth(1));
1298
1299       ((TH2*) hist1)->Rebin2D(2, 2); hist1->Scale(0.25);
1300       ((TH2*) hist2)->Rebin2D(2, 2); hist2->Scale(0.25);
1301
1302       const Float_t outerEta = 1.8;
1303       const Float_t exclusion = 0.5;
1304       
1305       c->cd(padN);
1306       proj1 = ((TH2*) hist1)->ProjectionX(Form("proj1a_%d_%d", centr, i), hist1->GetYaxis()->FindBin(-outerEta + 0.01), hist1->GetYaxis()->FindBin(-exclusion - 0.01));
1307       proj1b = ((TH2*) hist1)->ProjectionX(Form("proj1b_%d_%d", centr, i), hist1->GetYaxis()->FindBin(exclusion + 0.01), hist1->GetYaxis()->FindBin(outerEta - 0.01));
1308       proj1->Add(proj1b);
1309       copy = proj1->DrawCopy();
1310       copy->GetYaxis()->SetRangeUser(proj1->GetMinimum() * 0.9, proj1->GetMaximum() * 1.2);
1311       proj1c = ((TH2*) hist1)->ProjectionX(Form("proj1c_%d_%d", centr, i), hist1->GetYaxis()->FindBin(-outerEta + 0.01), hist1->GetYaxis()->FindBin(outerEta - 0.01));
1312       proj1c->SetLineColor(2);
1313       proj1c->DrawCopy("SAME");
1314       copy->SetMinimum(TMath::Min(copy->GetMinimum(), proj1c->GetMinimum()));
1315       copy->SetMaximum(1.2 * TMath::Max(copy->GetMaximum(), proj1c->GetMaximum()));
1316       
1317       Double_t baselineValues1E, peakYield1E;
1318       baselineValues1 = proj1->IntegralAndError(proj1->FindBin(TMath::Pi()/2 - 0.2), proj1->FindBin(TMath::Pi()/2 + 0.2), baselineValues1E);
1319       baselineValues1 /= (proj1->FindBin(TMath::Pi()/2 + 0.2) - proj1->FindBin(TMath::Pi()/2 - 0.2) + 1);
1320       baselineValues1E /= (proj1->FindBin(TMath::Pi()/2 + 0.2) - proj1->FindBin(TMath::Pi()/2 - 0.2) + 1);
1321       peakYield1 = proj1->IntegralAndError(proj1->GetXaxis()->FindBin(-1), proj1->GetXaxis()->FindBin(1), peakYield1E);
1322       peakYield1 /= (proj1->GetXaxis()->FindBin(0.99) - proj1->GetXaxis()->FindBin(-0.99) + 1);
1323       peakYield1E /= (proj1->GetXaxis()->FindBin(0.99) - proj1->GetXaxis()->FindBin(-0.99) + 1);
1324       peakYield1 -= baselineValues1;
1325       peakYield1E = TMath::Sqrt(peakYield1E * peakYield1E + baselineValues1E * baselineValues1E);
1326
1327       proj2 = ((TH2*) hist2)->ProjectionX(Form("proj2a_%d_%d", centr, i), hist2->GetYaxis()->FindBin(-outerEta + 0.01), hist2->GetYaxis()->FindBin(-exclusion - 0.01));
1328       proj2b = ((TH2*) hist2)->ProjectionX(Form("proj2b_%d_%d", centr, i), hist2->GetYaxis()->FindBin(exclusion + 0.01), hist2->GetYaxis()->FindBin(outerEta - 0.01));
1329       proj2->Add(proj2b);
1330       proj2->SetLineColor(3);
1331       proj2->DrawCopy("SAME");
1332       proj2c = ((TH2*) hist2)->ProjectionX(Form("proj2c_%d_%d", centr, i), hist2->GetYaxis()->FindBin(-outerEta + 0.01), hist2->GetYaxis()->FindBin(outerEta - 0.01));
1333       proj2c->SetLineColor(4);
1334       proj2c->DrawCopy("SAME");
1335       
1336       Double_t baselineValues2E, peakYield2E;
1337       baselineValues2 = proj2->IntegralAndError(proj1->FindBin(TMath::Pi()/2 - 0.2), proj2->FindBin(TMath::Pi()/2 + 0.2), baselineValues2E);
1338       baselineValues2 /= (proj2->FindBin(TMath::Pi()/2 + 0.2) - proj2->FindBin(TMath::Pi()/2 - 0.2) + 1);
1339       baselineValues2E /= (proj2->FindBin(TMath::Pi()/2 + 0.2) - proj2->FindBin(TMath::Pi()/2 - 0.2) + 1);
1340       peakYield2 = proj2->IntegralAndError(proj2->GetXaxis()->FindBin(-1), proj2->GetXaxis()->FindBin(1), peakYield2E);
1341       peakYield2 /= (proj2->GetXaxis()->FindBin(0.99) - proj2->GetXaxis()->FindBin(-0.99) + 1);
1342       peakYield2E /= (proj2->GetXaxis()->FindBin(0.99) - proj2->GetXaxis()->FindBin(-0.99) + 1);
1343       peakYield2 -= baselineValues2;
1344       peakYield2E = TMath::Sqrt(peakYield2E * peakYield2E + baselineValues2E * baselineValues2E);
1345       
1346   //     Printf("%d: %f %f %f %f %.2f%% %.2f%%", i, peakYield1, baselineValues1, peakYield2, baselineValues2, 100.0 * peakYield1 / peakYield2 - 100, 100.0 * baselineValues1 / baselineValues2 - 100);
1347       Printf("%s: %.2f%% +- %.2f%%    %.2f%% +- %.2f%%", 
1348              hist1->GetTitle(), 
1349              100.0 * peakYield1 / peakYield2 - 100, 
1350              100.0 * peakYield1 / peakYield2 * TMath::Sqrt(TMath::Power(peakYield1E / peakYield1, 2) + TMath::Power(peakYield2E / peakYield2, 2)),
1351              100.0 * baselineValues1 / baselineValues2 - 100,
1352              100.0 * baselineValues1 / baselineValues2 * TMath::Sqrt(TMath::Power(baselineValues1E / baselineValues1, 2) + TMath::Power(baselineValues2E / baselineValues2, 2))
1353             );
1354       
1355       c->cd(padN+3);
1356       proj1->Divide(proj1, proj2, 1, 1, "B");
1357       proj1c->Divide(proj1c, proj2c, 1, 1, "B");
1358   //     proj1->Add(proj2, -1);
1359       proj1->Draw();
1360       proj1c->SetLineColor(2);
1361       proj1c->Draw("SAME");
1362       
1363       c->cd(padN+6);
1364       hist1->Divide(hist2);
1365       hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
1366       hist1->Draw("COLZ");
1367       
1368       file3 = TFile::Open("non_closure.root", "UPDATE");
1369       proj1->Write(Form("non_closure_%d_%d_%d", is[i], js[i], centr));
1370       proj1c->Write(Form("non_closure_all_%d_%d_%d", is[i], js[i], centr));
1371       hist1->Write(Form("non_closure_2d_%d_%d_%d", is[i], js[i], centr));
1372       file3->Close();
1373       
1374       padN++;
1375     }
1376   }
1377 }
1378
1379 void Validation2DAllSteps(const char* fileName, const char* fileNameCorrected = "corrected.root", Int_t startStep = 8)
1380 {
1381   Int_t centralityFrom = 0;
1382   Int_t centralityTo = 80;
1383   
1384   gpTMin = 1.01;
1385   gpTMax = 1.99;
1386   
1387   Float_t ptTrigBegin = 2.01;
1388   Float_t ptTrigEnd = 2.99;
1389   
1390   loadlibs();
1391   
1392   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
1393   hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);
1394   
1395   AliUEHistograms* h2 = (AliUEHistograms*) GetUEHistogram(fileNameCorrected);
1396   hMixed2 = (AliUEHistograms*) GetUEHistogram(fileNameCorrected, 0, kTRUE);
1397
1398   SetupRanges(h);
1399   SetupRanges(hMixed);
1400   SetupRanges(h2);
1401   SetupRanges(hMixed2);
1402
1403   TH1* hist[6];
1404   TH1* hist2[6];
1405
1406 //   GetSumOfRatios(h, hMixed,   &hist[0],  0, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, kTRUE); 
1407   
1408   GetDistAndFlow(h, hMixed,   &hist[0],  0, 0, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, 0); 
1409   GetDistAndFlow(h, hMixed,   &hist[1],  0, 4, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, 6); 
1410   GetDistAndFlow(h, hMixed,   &hist[2],  0, 5, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, 6); 
1411   GetDistAndFlow(h, hMixed,   &hist[3],  0, startStep, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, startStep); 
1412   GetDistAndFlow(h2, hMixed2, &hist2[0],  0, 0, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, startStep); 
1413   GetDistAndFlow(h2, hMixed2, &hist2[1],  0, 4, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, startStep); 
1414   GetDistAndFlow(h2, hMixed2, &hist2[2],  0, 5, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, startStep); 
1415   GetDistAndFlow(h2, hMixed2, &hist2[3],  0, startStep, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, startStep); 
1416
1417   c = new TCanvas("c", "c", 1600, 1000);
1418   c->Divide(4, 5);
1419   
1420   Float_t peakYield1[4];
1421   Float_t baselineValues1[4];
1422   Float_t peakYield2[4];
1423   Float_t baselineValues2[4];
1424   for (Int_t i=0; i<4; i++)
1425   {
1426     // NOTE fix normalization. these 2d correlations come out of AliUEHist normalized by dphi bin width, but not deta
1427     hist[i]->Scale(1.0 / hist[i]->GetYaxis()->GetBinWidth(1));
1428     hist2[i]->Scale(1.0 / hist2[i]->GetYaxis()->GetBinWidth(1));
1429
1430     ((TH2*) hist[i])->Rebin2D(2, 2); hist[i]->Scale(0.25);
1431 //     ((TH2*) hist[i])->Rebin2D(2, 2); hist[i]->Scale(0.25);
1432     
1433     c->cd(i+1);
1434     hist[i]->GetYaxis()->SetRangeUser(-1.59, 1.59);
1435     hist[i]->GetXaxis()->SetTitleOffset(1.5);
1436     hist[i]->GetYaxis()->SetTitleOffset(2);
1437     hist[i]->GetZaxis()->SetTitleOffset(1.8);
1438     hist[i]->GetZaxis()->SetTitle("1/N_{trig} dN_{assoc}/d#Delta#etad#Delta#varphi (1/rad.)");
1439     hist[i]->SetStats(kFALSE);
1440     hist[i]->DrawCopy("SURF1");    
1441     
1442     ((TH2*) hist2[i])->Rebin2D(2, 2); hist2[i]->Scale(0.25);
1443 //     ((TH2*) hist2[i])->Rebin2D(2, 2); hist2[i]->Scale(0.25);
1444     
1445 //     TF2* func2 = new TF2("func2", "[0]+[1]*exp(-0.5*((x/[2])**2+(y/[3])**2))", -1, 1, -0.99, 0.99);
1446 //     func2->SetParameters(0, 1, 0.5, 0.5);
1447 //     hist[i]->Fit(func2, "0R");
1448 //     hist[i]->Fit(func2, "0R");
1449 //     
1450 //     c->cd(i+1+4);
1451 //     func2->DrawClone("SURF1");
1452 //     
1453 //     baselineValues1[i] = func2->GetParameter(0);
1454 //     func2->SetParameter(0, 0);
1455 //     peakYield1[i] = func2->Integral(-0.5 * TMath::Pi(), 0.5 * TMath::Pi(), -1.4, 1.4);
1456 //     Printf("%f %f", peakYield1[i], baselineValues1[i]);
1457
1458     c->cd(i+1+4);
1459     hist2[i]->GetYaxis()->SetRangeUser(-1.59, 1.59);
1460     hist2[i]->GetXaxis()->SetTitleOffset(1.5);
1461     hist2[i]->GetYaxis()->SetTitleOffset(2);
1462     hist2[i]->GetZaxis()->SetTitleOffset(1.8);
1463     hist2[i]->GetZaxis()->SetTitle("1/N_{trig} dN_{assoc}/d#Delta#etad#Delta#varphi (1/rad.)");
1464     hist2[i]->SetStats(kFALSE);
1465     hist2[i]->DrawCopy("SURF1");        
1466     
1467     c->cd(i+1+12);
1468     proj1 = ((TH2*) hist[i])->ProjectionX(Form("proj1_%d", i), hist[i]->GetYaxis()->FindBin(-0.99), hist[i]->GetYaxis()->FindBin(0.99));
1469     proj1->DrawCopy();
1470     
1471     baselineValues1[i] = proj1->GetMinimum();
1472     peakYield1[i] = proj1->Integral(proj1->GetXaxis()->FindBin(-1), proj1->GetXaxis()->FindBin(1)) / (proj1->GetXaxis()->FindBin(0.99) - proj1->GetXaxis()->FindBin(-0.99) + 1) - baselineValues1[i];
1473     Printf("%f %f", peakYield1[i], baselineValues1[i]);
1474
1475     proj2 = ((TH2*) hist2[i])->ProjectionX(Form("proj2_%d", i), hist2[i]->GetYaxis()->FindBin(-0.99), hist2[i]->GetYaxis()->FindBin(0.99));
1476     proj2->SetLineColor(2);
1477     proj2->DrawCopy("SAME");
1478     
1479     baselineValues2[i] = proj2->GetMinimum();
1480     peakYield2[i] = proj2->Integral(proj2->GetXaxis()->FindBin(-1), proj2->GetXaxis()->FindBin(1)) / (proj2->GetXaxis()->FindBin(0.99) - proj2->GetXaxis()->FindBin(-0.99) + 1) - baselineValues2[i];
1481     Printf("%f %f", peakYield2[i], baselineValues2[i]);
1482
1483     c->cd(i+1+16);
1484     proj1->Divide(proj2);
1485     proj1->Draw();
1486     
1487 //     func2 = new TF2("func2", "[0]+[1]*exp(-0.5*((x/[2])**2+(y/[3])**2))", -1, 1, -0.99, 0.99);
1488 //     func2->SetParameters(0, 1, 0.5, 0.5);
1489 //     hist2[i]->Fit(func2, "0R");
1490 //     hist2[i]->Fit(func2, "0R");
1491 //     
1492 //     c->cd(i+1+12);
1493 //     func2->DrawClone("SURF1");
1494 //     
1495 //     baselineValues2[i] = func2->GetParameter(0);
1496 //     func2->SetParameter(0, 0);
1497 //     peakYield2[i] = func2->Integral(-0.5 * TMath::Pi(), 0.5 * TMath::Pi(), -1.4, 1.4);
1498 //     Printf("%f %f", peakYield2[i], baselineValues2[i]);
1499
1500     c->cd(i+1+8);
1501     TH2* clone = (TH2*) hist[i]->Clone();
1502     clone->Divide(hist2[i]);
1503 //     clone->Add(hist2[i], -1);
1504     clone->DrawCopy("COLZ");
1505     gPad->SetRightMargin(0.15);
1506     
1507 /*    baselineValues1[i] = clone->Integral(1, clone->GetNbinsX(), clone->GetYaxis()->FindBin(-0.99), clone->GetYaxis()->FindBin(0.99)) / clone->GetNbinsX() / (clone->GetYaxis()->FindBin(0.99) - clone->GetYaxis()->FindBin(-0.99) + 1);
1508     peakYield1[i] = clone->Integral(clone->GetXaxis()->FindBin(-0.5), clone->GetXaxis()->FindBin(0.5), clone->GetYaxis()->FindBin(-0.49), clone->GetYaxis()->FindBin(0.49)) / (clone->GetXaxis()->FindBin(0.5) - clone->GetXaxis()->FindBin(-0.5) + 1) / (clone->GetYaxis()->FindBin(0.49) - clone->GetYaxis()->FindBin(-0.49) + 1);*/
1509     
1510 //     break;
1511   }
1512
1513   for (Int_t i=0; i<4; i++)
1514   {
1515     Printf("%d: %f %f", i, peakYield1[i] / peakYield2[i] - 1, baselineValues1[i] / baselineValues2[i] - 1);
1516 //     Printf("%d: %f %f", i, peakYield1[i] - 1, baselineValues1[i] - 1);
1517   }
1518 }
1519
1520 void CorrelatedContaminationEffect(const char* fileName, const char* fileNameCorrected = "corrected.root", Int_t bin = 0, Int_t startStep = 8)
1521 {
1522   Int_t centralityFrom = 0;
1523   Int_t centralityTo = 80;
1524   
1525   gpTMin = 1.01;
1526   gpTMax = 1.99;
1527   
1528   Float_t ptTrigBegin = 2.01;
1529   Float_t ptTrigEnd = 3.99;
1530   
1531   if (bin == 1)
1532   {
1533     ptTrigBegin = 1.01;
1534     ptTrigEnd = 1.99;
1535   }
1536   else if (bin == 2)
1537   {
1538     gpTMin = 0.51;
1539     gpTMax = 0.99;
1540     ptTrigBegin = 1.01;
1541     ptTrigEnd = 1.99;  
1542   }
1543   else if (bin == 3)
1544   {
1545     ptTrigBegin = 4.01;
1546     ptTrigEnd = 7.99;  
1547   }
1548   
1549   loadlibs();
1550   
1551   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
1552   hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);
1553   
1554   AliUEHistograms* h2 = (AliUEHistograms*) GetUEHistogram(fileNameCorrected);
1555   hMixed2 = (AliUEHistograms*) GetUEHistogram(fileNameCorrected, 0, kTRUE);
1556
1557   SetupRanges(h);
1558   SetupRanges(hMixed);
1559   SetupRanges(h2);
1560   SetupRanges(hMixed2);
1561
1562   TH1* hist[6];
1563
1564   Int_t maxFilled = 5;
1565   GetSumOfRatios(h, hMixed, &hist[0],  0, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1566   GetSumOfRatios(h, hMixed, &hist[1],  4, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1567   GetSumOfRatios(h, hMixed, &hist[2],  5, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1568   GetSumOfRatios(h, hMixed, &hist[3],  6, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1569   GetSumOfRatios(h, hMixed, &hist[4],  startStep, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1570 //   GetSumOfRatios(h2, hMixed2, &hist[5],  startStep, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd); 
1571   
1572 //   GetDistAndFlow(h, hMixed, &hist[0],  0, 0, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, 0); 
1573 //   GetDistAndFlow(h, hMixed, &hist[1],  0, 4, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, 6); 
1574 //   GetDistAndFlow(h, hMixed, &hist[2],  0, 5, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, 6); 
1575 //   GetDistAndFlow(h, hMixed, &hist[3],  0, 6, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, 6); 
1576 //   GetDistAndFlow(h, hMixed, &hist[4],  0, startStep, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, startStep); 
1577 //   GetDistAndFlow(h2, hMixed2, &hist[5],  0, 0, centralityFrom, centralityTo, ptTrigBegin, ptTrigEnd, 1, kTRUE, 0, kTRUE, startStep); 
1578
1579   c = new TCanvas("c", "c", 1600, 1000);
1580   c->Divide(6, 2);
1581   
1582   for (Int_t i=0; i<maxFilled; i++)
1583   {
1584     // NOTE fix normalization. these 2d correlations come out of AliUEHist normalized by dphi bin width, but not deta
1585     hist[i]->Scale(1.0 / hist[i]->GetYaxis()->GetBinWidth(1));
1586
1587     ((TH2*) hist[i])->Rebin2D(2, 2); hist[i]->Scale(0.25);
1588 //     ((TH2*) hist[i])->Rebin2D(2, 2); hist[i]->Scale(0.25);
1589     
1590     c->cd(i+1);
1591     hist[i]->GetYaxis()->SetRangeUser(-1.59, 1.59);
1592     hist[i]->GetXaxis()->SetTitleOffset(1.5);
1593     hist[i]->GetYaxis()->SetTitleOffset(2);
1594     hist[i]->GetZaxis()->SetTitleOffset(1.8);
1595     hist[i]->GetZaxis()->SetTitle("1/N_{trig} dN_{assoc}/d#Delta#etad#Delta#varphi (1/rad.)");
1596     hist[i]->SetStats(kFALSE);
1597     hist[i]->DrawCopy("SURF1");    
1598   }
1599   
1600   for (Int_t i=1; i<maxFilled; i++)
1601   {
1602     TH2* clone = (TH2*) hist[i]->Clone();
1603     if (i < 4)
1604       clone->Divide(hist[i-1]);
1605     else if (i < 5)
1606       clone->Divide(hist[2]);
1607     else 
1608       clone->Divide(hist[0]);
1609   
1610     c->cd(6+i);
1611     gPad->SetRightMargin(0.15);
1612   //   hist1->SetTitle("");
1613 //     clone->GetZaxis()->SetRangeUser(0.8, 1.2);
1614     clone->GetZaxis()->SetTitle("1/N_{trig} dN_{assoc}/d#Delta#etad#Delta#varphi (1/rad.)");
1615     clone->SetStats(kFALSE);
1616     clone->DrawCopy("COLZ");
1617   }
1618
1619   Float_t peakYield[6];
1620   Float_t baselineValues[6];
1621   for (Int_t i=0; i<maxFilled; i++)
1622   {
1623     Int_t phi1 = hist[i]->GetXaxis()->FindBin(-1);
1624     Int_t phi2 = hist[i]->GetXaxis()->FindBin(1);
1625     Int_t eta1 = hist[i]->GetYaxis()->FindBin(-1.59);
1626     Int_t eta2 = hist[i]->GetYaxis()->FindBin(1.01);
1627     Int_t eta3 = hist[i]->GetYaxis()->FindBin(1.59);
1628     Float_t baseline = ((TH2*) hist[i])->Integral(phi1, phi2, eta2, eta3, "width") / (phi2 - phi1 + 1) / (eta3 - eta2 + 1);
1629     Float_t peak = ((TH2*) hist[i])->Integral(phi1, phi2, eta1, eta3, "width");
1630     Printf("%f %f", baseline, peak);
1631     peak -= baseline * (eta3 - eta1 + 1) * (phi2 - phi1 + 1);
1632     Printf("%f", peak);
1633     peakYield[i] = peak;
1634     baselineValues[i] = baseline;
1635   }
1636   
1637   for (Int_t i=1; i<maxFilled; i++)
1638   {
1639     if (i < 4)
1640       Printf("%d/%d: %f %f", i, i-1, peakYield[i] / peakYield[i-1] - 1, baselineValues[i] / baselineValues[i-1] - 1);
1641     else if (i < 5)
1642       Printf("%d/%d: %f %f", i, 2, peakYield[i] / peakYield[2] - 1, baselineValues[i] / baselineValues[2] - 1);
1643     else
1644       Printf("%d/%d: %f %f", 0, i, peakYield[0] / peakYield[i] - 1, baselineValues[0] / baselineValues[i] - 1);
1645   }
1646   
1647   c = new TCanvas("c2", "c2", 1600, 1000);
1648   c->Divide(6, 2);
1649   for (Int_t i=0; i<maxFilled; i++)
1650   {
1651     c->cd(i+1);
1652     hist[i]->DrawCopy("SURF1");
1653     
1654     TF2* func2 = new TF2("func2", "[0]+[1]*exp(-0.5*((x/[2])**2+(y/[3])**2))", -0.5 * TMath::Pi(), 0.5 * TMath::Pi(), -1.4, 1.4);
1655     func2->SetParameters(0, 1, 0.5, 0.5);
1656 //     func2->SetParLimits(1, 0, 10);
1657 //     func2->SetParLimits(2, sigmaFitLimit, 1);
1658 //     func2->SetParLimits(3, sigmaFitLimit, 1);
1659     hist[i]->Fit(func2, "0R");
1660     
1661     c->cd(i+7);
1662     func2->DrawClone("SURF1");
1663     
1664     baselineValues[i] = func2->GetParameter(0);
1665     func2->SetParameter(0, 0);
1666     peakYield[i] = func2->Integral(-0.5 * TMath::Pi(), 0.5 * TMath::Pi(), -1.4, 1.4);
1667     Printf("%f %f", peakYield[i], baselineValues[i]);
1668   }
1669
1670   for (Int_t i=1; i<maxFilled; i++)
1671   {
1672     if (i < 4)
1673       Printf("%d/%d: %f %f", i, i-1, peakYield[i] / peakYield[i-1] - 1, baselineValues[i] / baselineValues[i-1] - 1);
1674     else if (i < 5)
1675       Printf("%d/%d: %f %f", i, 2, peakYield[i] / peakYield[2] - 1, baselineValues[i] / baselineValues[2] - 1);
1676     else
1677       Printf("%d/%d: %f %f", 0, i, peakYield[0] / peakYield[i] - 1, baselineValues[0] / baselineValues[i] - 1);
1678   }
1679
1680   for (Int_t i=1; i<maxFilled; i++)
1681   {
1682     Printf("%d/%d: %f %f", 0, i, peakYield[0] / peakYield[i] - 1, baselineValues[0] / baselineValues[i] - 1);
1683   }
1684 }
1685
1686 void DrawValidation2D(const char* fileName, const char* fileNameCorrected = "corrected.root", Int_t startStep = 8)
1687 {
1688   Int_t centralityTo = 80;
1689   
1690   gpTMin = 1.01;
1691   gpTMax = 1.99;
1692   
1693   loadlibs();
1694   
1695   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
1696   hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);
1697   
1698   SetupRanges(h);
1699   SetupRanges(hMixed);
1700
1701   TH1* hist1 = 0;
1702   GetDistAndFlow(h, hMixed, &hist1,  0, 0, 0,  centralityTo, 2.01, 3.99, 1, kTRUE, 0, kTRUE, 0); 
1703   // NOTE fix normalization. these 2d correlations come out of AliUEHist normalized by dphi bin width, but not deta
1704   hist1->Scale(1.0 / hist1->GetYaxis()->GetBinWidth(1));
1705   
1706 //   ((TH2*) hist1)->Rebin2D(2, 2); hist1->Scale(0.25);
1707   ((TH2*) hist1)->Rebin2D(2, 2); hist1->Scale(0.25);
1708
1709 //   NormalizeToBinWidth(hist1);
1710   
1711   c = new TCanvas("c", "c", 1000, 1000);
1712   c->Divide(2, 2);
1713   
1714   c->cd(1);
1715   gPad->SetLeftMargin(0.15);
1716 //   hist1->SetTitle("");
1717   hist1->GetYaxis()->SetRangeUser(-1.59, 1.59);
1718   hist1->GetXaxis()->SetTitleOffset(1.5);
1719   hist1->GetYaxis()->SetTitleOffset(2);
1720   hist1->GetZaxis()->SetTitleOffset(1.8);
1721   hist1->GetZaxis()->SetTitle("1/N_{trig} dN_{assoc}/d#Delta#etad#Delta#varphi (1/rad.)");
1722   hist1->SetStats(kFALSE);
1723   hist1->DrawCopy("SURF1");
1724   DrawLatex(0.1, 0.85, 1, "MC", 0.04);
1725 //   DrawALICELogo(kFALSE, 0.7, 0.7, 0.9, 0.9);
1726   
1727   hist2 = hist1;
1728   hist1 = 0;
1729   GetDistAndFlow(h, hMixed, &hist1,  0, startStep, 0,  centralityTo, 2.01, 3.99, 1, kTRUE, 0, kTRUE, startStep); 
1730   // NOTE fix normalization. these 2d correlations come out of AliUEHist normalized by dphi bin width, but not deta
1731   hist1->Scale(1.0 / hist1->GetYaxis()->GetBinWidth(1));
1732
1733 //   ((TH2*) hist1)->Rebin2D(2, 2); hist1->Scale(0.25);
1734   ((TH2*) hist1)->Rebin2D(2, 2); hist1->Scale(0.25);
1735 //   NormalizeToBinWidth(hist1);
1736
1737   c->cd(2);
1738   gPad->SetLeftMargin(0.15);
1739   hist1->SetTitle("");
1740   hist1->GetYaxis()->SetRangeUser(-1.59, 1.59);
1741   hist1->GetXaxis()->SetTitleOffset(1.5);
1742   hist1->GetYaxis()->SetTitleOffset(2);
1743   hist1->GetZaxis()->SetTitleOffset(1.8);
1744   hist1->SetStats(kFALSE);
1745   hist1->GetZaxis()->SetTitle("1/N_{trig} dN_{assoc}/d#Delta#etad#Delta#varphi (1/rad.)");
1746   hist1->DrawCopy("SURF1");  
1747   DrawLatex(0.1, 0.85, 1, "Uncorrected", 0.04);
1748 //   DrawALICELogo(kFALSE, 0.7, 0.7, 0.9, 0.9);
1749
1750   c2 = new TCanvas("c3", "c3", 800, 800);
1751 //   hist2->Scale(1.09);
1752   hist1->Divide(hist2);
1753 //   hist1->Add(hist2, -1);
1754   hist1->DrawCopy("SURF1");  
1755   
1756 //   return;
1757   
1758 //   AliUEHistograms* h2 = (AliUEHistograms*) GetUEHistogram("LHC11a10a_bis_AOD090_120406_zvtx_rebinned_corrected.root");
1759   AliUEHistograms* h2 = (AliUEHistograms*) GetUEHistogram(fileNameCorrected);
1760   SetupRanges(h2);
1761  
1762   GetDistAndFlow(h2, hMixed, &hist1,  0, 0, 0,  centralityTo, 2.01, 3.99, 1, kTRUE, 0, kTRUE, startStep); 
1763   // NOTE fix normalization. these 2d correlations come out of AliUEHist normalized by dphi bin width, but not deta
1764   hist1->Scale(1.0 / hist1->GetYaxis()->GetBinWidth(1));
1765
1766   ((TH2*) hist1)->Rebin2D(2, 2); hist1->Scale(0.25);
1767 //   ((TH2*) hist1)->Rebin2D(2, 2); hist1->Scale(0.25);
1768
1769   c->cd(3);
1770   gPad->SetLeftMargin(0.15);
1771   hist1->SetTitle("");
1772   hist1->GetYaxis()->SetRangeUser(-1.59, 1.59);
1773   hist1->GetXaxis()->SetTitleOffset(1.5);
1774   hist1->GetZaxis()->SetTitleOffset(1.8);
1775   hist1->GetZaxis()->SetTitle("1/N_{trig} dN_{assoc}/d#Delta#etad#Delta#varphi (1/rad.)");
1776   hist1->GetYaxis()->SetTitleOffset(2);
1777   hist1->SetStats(kFALSE);
1778   hist1->DrawCopy("SURF1");  
1779   DrawLatex(0.1, 0.85, 1, "Corrected", 0.04);
1780 //   DrawALICELogo(kFALSE, 0.7, 0.7, 0.9, 0.9);
1781   
1782   hist1->Divide(hist2);
1783
1784   c->cd(4);
1785   gPad->SetRightMargin(0.15);
1786   hist1->SetTitle("");
1787   hist1->GetYaxis()->SetRangeUser(-1.59, 1.59);
1788   hist1->GetXaxis()->SetTitleOffset(1.2);
1789   hist1->GetYaxis()->SetTitleOffset(1.2);
1790   hist1->GetZaxis()->SetTitle("Ratio: Corrected / MC");
1791   hist1->SetStats(kFALSE);
1792   hist1->GetZaxis()->SetRangeUser(0.99, 1.01);
1793   hist1->DrawCopy("COLZ");  
1794
1795 //   DrawALICELogo(kFALSE, 0.7, 0.7, 0.9, 0.9);
1796   
1797   c->SaveAs("validation.eps");
1798   c->SaveAs("validation.gif");
1799 }
1800
1801 void DrawValidation(const char* fileName1, const char* fileName2)
1802 {
1803   gpTMin = 1.01;
1804   gpTMax = 3.99;
1805   
1806   CompareStep(fileName1, fileName2, 2, 6, 4, 0, 4.01, 19.99);
1807   CompareStep(fileName1, fileName2, 2, 4, 4, 0, 4.01, 19.99);
1808
1809   CompareStep(fileName1, fileName2, 2, 4, 2, 0, 4.01, 19.99);
1810   CompareStep(fileName1, fileName2, 2, 2, 2, 0, 4.01, 19.99);
1811 }
1812
1813 void ProfileMultiplicity(const char* fileName = "PWG4_JetTasksOutput.root")
1814 {
1815   loadlibs();
1816
1817   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
1818
1819   new TCanvas;
1820   h->GetCorrelationMultiplicity()->Draw("colz");
1821   gPad->SetLogz();
1822
1823   new TCanvas;
1824   h->GetCorrelationMultiplicity()->ProfileX()->DrawCopy()->Fit("pol1", "", "", 1, 10);
1825 }
1826
1827 void SetupRanges(void* obj)
1828 {
1829   if (!obj)
1830     return;
1831   ((AliUEHistograms*) obj)->SetEtaRange(0, 0);
1832 //   ((AliUEHistograms*) obj)->SetEtaRange(-0.99, 0.99); Printf("WARNING: Setting eta Range!");
1833   ((AliUEHistograms*) obj)->SetPtRange(gpTMin, gpTMax);
1834   ((AliUEHistograms*) obj)->SetCombineMinMax(kTRUE);
1835 }
1836
1837 void DrawRatios(const char* name, void* correctedVoid, void* comparisonVoid, Int_t compareStep = -1, Int_t compareRegion = 2, Float_t ptLeadMin = -1, Float_t ptLeadMax = -1)
1838 {
1839   AliUEHist* corrected = (AliUEHist*) correctedVoid;
1840   AliUEHist* comparison = (AliUEHist*) comparisonVoid;
1841
1842   Int_t beginStep = AliUEHist::kCFStepAll;
1843   Int_t endStep = AliUEHist::kCFStepReconstructed;
1844   
1845   if (compareStep != -1)
1846   {
1847     beginStep = compareStep;
1848     endStep = compareStep;
1849   }
1850   
1851   Int_t beginRegion = 0;
1852   Int_t endRegion = 2;
1853   
1854   if (compareRegion != -1)
1855   {
1856     beginRegion = compareRegion;
1857     endRegion = compareRegion;
1858   }
1859
1860   for (Int_t step=beginStep; step<=endStep; step++)
1861   {
1862     if (compareStep == -1 && (step == AliUEHist::kCFStepAnaTopology || step == AliUEHist::kCFStepTriggered))
1863       continue;
1864       
1865     for (Int_t region=beginRegion; region <= endRegion; region++)
1866     {
1867       Printf("%f %f", ptLeadMin, ptLeadMax);
1868       TH1* corrHist = corrected->GetUEHist(step, region, ptLeadMin, ptLeadMax);
1869       TH1* mcHist   = comparison->GetUEHist(step, region, ptLeadMin, ptLeadMax);
1870       
1871       DrawRatio(corrHist, mcHist, TString(Form("%s: step %d %s %s", name, step, corrected->GetStepTitle(step), corrected->GetRegionTitle(region))));
1872     }
1873   }
1874 }
1875
1876 void DrawRatios(void* correctedVoid, void* comparisonVoid, Int_t compareStep = -1, Int_t compareRegion = 2, Int_t compareUEHist = 0)
1877 {
1878   AliUEHistograms* corrected = (AliUEHistograms*) correctedVoid;
1879   AliUEHistograms* comparison = (AliUEHistograms*) comparisonVoid;
1880
1881   if (1 && compareUEHist == 2)
1882   {
1883     for (Float_t ptMin = 2.01; ptMin < 8; ptMin += 2)
1884     {
1885       ((AliUEHistograms*) corrected)->SetPtRange(ptMin, ptMin + 1.98);
1886       ((AliUEHistograms*) comparison)->SetPtRange(ptMin, ptMin + 1.98);
1887       
1888       DrawRatios(TString(Form("Dphi %d pT %f", compareUEHist, ptMin)), corrected->GetUEHist(compareUEHist), comparison->GetUEHist(compareUEHist), compareStep, compareRegion, 8.01, 19.99);      
1889     }
1890     return;
1891   }
1892
1893   if (compareUEHist == -1)
1894   {
1895     for (Int_t i=0; i<2; i++)
1896       DrawRatios(TString(Form("UE %d", i)), corrected->GetUEHist(i), comparison->GetUEHist(i), compareStep, compareRegion);
1897   }
1898   else
1899     DrawRatios(TString(Form("UE %d", compareUEHist)), corrected->GetUEHist(compareUEHist), comparison->GetUEHist(compareUEHist), compareStep, compareRegion);
1900 }
1901
1902 void CompareEventsTracks(void* corrVoid, void* mcVoid, Int_t compareStep, Int_t compareRegion, Int_t compareUEHist = 0)
1903 {
1904   AliUEHist* corr = ((AliUEHistograms*) corrVoid)->GetUEHist(compareUEHist);
1905   AliUEHist* mc   = ((AliUEHistograms*) mcVoid)->GetUEHist(compareUEHist);
1906
1907   Float_t ptLeadMin = 0;
1908   Float_t ptLeadMax = -1;
1909   Int_t axis = 2;
1910   
1911   if (compareUEHist == 2)
1912   {
1913     ptLeadMin = 1.01;
1914     ptLeadMax = 1.49;
1915     axis = 4;
1916   }
1917
1918   TH1* corrHist = corr->GetUEHist(compareStep, compareRegion, ptLeadMin, ptLeadMax);
1919   TH1* mcHist   = mc  ->GetUEHist(compareStep, compareRegion, ptLeadMin, ptLeadMax);
1920   
1921   DrawRatio(corrHist, mcHist, Form("check"));
1922   
1923   corr->SetBinLimits(corr->GetTrackHist(compareRegion)->GetGrid(compareStep));
1924   mc->SetBinLimits(corr->GetTrackHist(compareRegion)->GetGrid(compareStep));
1925
1926   corrHist =  corr->GetTrackHist(compareRegion)->GetGrid(compareStep)->Project(axis);
1927   mcHist   =  mc  ->GetTrackHist(compareRegion)->GetGrid(compareStep)->Project(axis);
1928   DrawRatio(corrHist, mcHist, Form("check2"));
1929   
1930   corrHist =  corr->GetEventHist()->GetGrid(compareStep)->Project(0);
1931   mcHist   =  mc  ->GetEventHist()->GetGrid(compareStep)->Project(0);
1932   DrawRatio(corrHist, mcHist, Form("check3"));
1933 }
1934
1935 void CopyReconstructedData(const char* fileName)
1936 {
1937   loadlibs();
1938   
1939   AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
1940   AliUEHistograms* hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);  
1941
1942   // copy
1943   AliUEHistograms* onlyRec = (AliUEHistograms*) h->Clone();
1944   onlyRec->Reset();
1945   onlyRec->CopyReconstructedData(h);
1946   
1947   AliUEHistograms* onlyRecMixed = (AliUEHistograms*) hMixed->Clone();
1948   onlyRecMixed->Reset();
1949   onlyRecMixed->CopyReconstructedData(hMixed);
1950
1951   TString newFileName(fileName);
1952   newFileName.ReplaceAll(".root", "");
1953   newFileName += "_onlyreco.root";
1954
1955   list = new TList;
1956   list->Add(onlyRec);
1957   list->Add(onlyRecMixed);
1958
1959   file3 = TFile::Open(newFileName, "RECREATE");
1960   file3->mkdir("PWG4_PhiCorrelations");
1961   file3->cd("PWG4_PhiCorrelations");
1962   list->Write("histosPhiCorrelations", TObject::kSingleKey);
1963   file3->Close();  
1964 }
1965
1966 void correctMC(const char* fileNameCorrections, const char* fileNameESD = 0, Int_t compareStep = -1, Int_t compareRegion = 2, Int_t compareUEHist = 0)
1967 {
1968   // corrects the reconstructed step in fileNameESD with fileNameCorr
1969   // if fileNameESD is 0 data from fileNameCorr is taken
1970   // afterwards the corrected distributions are compared with the MC stored in fileNameESD
1971   
1972   loadlibs();
1973   
1974   AliUEHistograms* corr = (AliUEHistograms*) GetUEHistogram(fileNameCorrections);
1975   SetupRanges(corr);
1976   
1977   corr->ExtendTrackingEfficiency();
1978   
1979   AliUEHistograms* testSample = corr;
1980   if (fileNameESD)
1981     testSample = (AliUEHistograms*) GetUEHistogram(fileNameESD);
1982       
1983   // copy to esd object
1984   AliUEHistograms* esd = (AliUEHistograms*) corr->Clone();
1985   esd->Reset();
1986   esd->CopyReconstructedData(testSample);
1987   
1988   SetupRanges(corr);
1989   SetupRanges(testSample);
1990   SetupRanges(esd);
1991   
1992   esd->Correct(corr);
1993   
1994   list = new TList;
1995   list->Add(esd);
1996   
1997   file3 = TFile::Open("correctedMC.root", "RECREATE");
1998   file3->mkdir("PWG4_PhiCorrelations");
1999   file3->cd("PWG4_PhiCorrelations");
2000   list->Write("histosPhiCorrelations", TObject::kSingleKey);
2001   file3->Close();
2002   
2003   if (1)
2004     DrawRatios(esd, testSample, compareStep, compareRegion, compareUEHist);
2005   
2006   if (1)
2007   {
2008     esd->SetPtRange(2.01, 3.99);
2009     corrected = esd->GetUEHist(2)->GetUEHist(0, 0, 4.01, 7.99, 0, -1, 1);
2010     testSample->SetPtRange(2.01, 3.99);
2011     mc = testSample->GetUEHist(2)->GetUEHist(0, 0, 4.01, 7.99, 0, -1, 1);
2012     new TCanvas; corrected->DrawCopy("SURF1");
2013     new TCanvas; mc->DrawCopy("SURF1");
2014     new TCanvas; mc->DrawCopy("SURF1")->Divide(corrected);
2015   }
2016   
2017   //CompareEventsTracks(esd, testSample, compareStep, compareRegion, compareUEHist);
2018 }
2019
2020 // function to compare only final step for all regions and distributions
2021
2022 void correctData(const char* fileNameCorrections, const char* fileNameESD, const char* contEnhancement = 0, Float_t contEncUpTo = 1.0, Int_t compareStep = 0, Int_t compareRegion = 0, Int_t compareUEHist = 2)
2023 {
2024   // corrects fileNameESD with fileNameCorrections and compares the two
2025   
2026   loadlibs();
2027   
2028   AliUEHistograms* corr = (AliUEHistograms*) GetUEHistogram(fileNameCorrections);
2029   
2030   TList* list = 0;
2031   AliUEHistograms* esd = (AliUEHistograms*) GetUEHistogram(fileNameESD, &list);
2032   
2033   SetupRanges(corr);
2034   SetupRanges(esd);
2035   
2036   Float_t etaRange = 1.2;
2037   Printf(">>>>> Using eta range: |eta| < %f", etaRange);
2038   corr->SetEtaRange(-etaRange+0.01, etaRange-0.01);
2039   corr->ExtendTrackingEfficiency(0);
2040   
2041 //   corr->GetUEHist(2)->GetTrackEfficiency(AliUEHist::kCFStepTracked, AliUEHist::kCFStepTrackedOnlyPrim, 1, -1, 2);
2042 //   return;
2043   
2044   if (contEnhancement)
2045   {
2046     TFile::Open(contEnhancement);
2047     contEncHist = (TH1*) gFile->Get("histo");
2048     contEncHistFullRange = (TH1*) corr->GetUEHist(0)->GetTrackingEfficiency(1)->Clone("contEncHistFullRange");
2049     
2050     contEncHistFullRange->Reset();
2051     for (Int_t i=1; i<=contEncHistFullRange->GetNbinsX(); i++)
2052     {
2053       contEncHistFullRange->SetBinContent(i, 1);
2054       if (i <= contEncHist->GetNbinsX() && contEncHist->GetXaxis()->GetBinCenter(i) < contEncUpTo && contEncHist->GetBinContent(i) > 0)
2055         contEncHistFullRange->SetBinContent(i, contEncHist->GetBinContent(i));
2056     }
2057     corr->SetContaminationEnhancement((TH1F*) contEncHistFullRange);
2058   }
2059   
2060   esd->Correct(corr);
2061   //esd->GetUEHist(2)->AdditionalDPhiCorrection(0);
2062   
2063   file3 = TFile::Open("corrected.root", "RECREATE");
2064   file3->mkdir("PWG4_PhiCorrelations");
2065   file3->cd("PWG4_PhiCorrelations");
2066   list->Write("histosPhiCorrelations", TObject::kSingleKey);
2067   file3->Close();
2068   
2069 //   DrawRatios(esd, corr, compareStep, compareRegion, compareUEHist);
2070 }
2071
2072 void ITSTPCEfficiency(const char* fileNameData, Int_t id, Int_t itsTPC = 0)
2073 {
2074   // its = 0; tpc = 1
2075
2076   // uncertainty from dN/dpT paper
2077   Double_t pTBins[] =  {0.0, 0.1, 0.15,  0.2,  0.25,  0.3,   0.35,  0.4,   0.45,  0.5,   0.6,   0.7,   0.8,   0.9,   1.0,   1.5,   2.0,   2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 100.0};
2078   Float_t effITS[] =   {0.,  0.,  0.995, 0.98, 0.986, 0.996, 1,     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,    };  // the last three are the same because i don't have entries
2079   Float_t effTPC[] =   {0.,  0,   1.042, 1.026,1.021, 1.018, 1.015, 1.015, 1.012, 1.012, 1.007, 1.0075,1.006, 1.006, 1.004, 1.004, 1.009 }; // the last bins put as if they were the same
2080
2081   TH1F* effHist = new TH1F("effHist", "effHist", 39, pTBins);
2082   for (Int_t i=0; i<39; i++)
2083   {
2084     Int_t bin = i;
2085     if (i > 16)
2086       bin = 16;
2087     effHist->SetBinContent(i+1, (itsTPC == 0) ? effITS[bin] : effTPC[bin]);
2088   }
2089
2090   new TCanvas; effHist->Draw();
2091
2092   EffectOfModifiedTrackingEfficiency(fileNameData, id, 2, effHist, 1, -1, (itsTPC == 0) ? "ITS" : "TPC");
2093
2094
2095
2096 void EffectOfModifiedTrackingEfficiency(const char* fileNameData, Int_t id, Int_t region, TH1* trackingEff, Int_t axis1, Int_t axis2 = -1, const char* name = "EffectOfModifiedTrackingEfficiency")
2097 {
2098   // trackingEff should contain the change in tracking efficiency, i.e. between before and after in the eta-pT plane
2099
2100   loadlibs();
2101   
2102   AliUEHistograms* corrected = (AliUEHistograms*) GetUEHistogram(fileNameData);
2103   SetupRanges(corrected);
2104   
2105   AliUEHist* ueHist = corrected->GetUEHist(id);
2106   
2107   Float_t ptLeadMin = -1;
2108   Float_t ptLeadMax = -1;
2109   if (id == 2)
2110   {
2111     // the uncertainty is flat in delta phi, so use this trick to get directly the uncertainty as function of leading pT
2112     //ptLeadMin = 1.01;
2113     //ptLeadMax = 1.99;
2114   }
2115     
2116   // histogram before
2117   TH1* before = ueHist->GetUEHist(AliUEHist::kCFStepAll, region, ptLeadMin, ptLeadMax);
2118
2119   // copy histogram
2120   // the CFStepTriggered step is overwritten here and cannot be used for comparison afterwards anymore
2121   ueHist->CorrectTracks(AliUEHist::kCFStepAll, AliUEHist::kCFStepTriggered, (TH1*) 0, 0, -1);
2122
2123   // reapply tracking efficiency
2124   ueHist->CorrectTracks(AliUEHist::kCFStepTriggered, AliUEHist::kCFStepAll, trackingEff, axis1, axis2);
2125
2126   // histogram after
2127   TH1* after = ueHist->GetUEHist(AliUEHist::kCFStepAll, region, ptLeadMin, ptLeadMax);
2128   
2129   DrawRatio(before, after, name);
2130   gPad->GetCanvas()->SaveAs(Form("%s.png", name));
2131 }
2132
2133 void EffectOfTrackCuts(const char* fileNameData, Int_t id, const char* systFile)
2134 {
2135   loadlibs();
2136
2137   AliUEHistograms* corrected = (AliUEHistograms*) GetUEHistogram(fileNameData);
2138   effHist = (TH2D*) corrected->GetUEHist(0)->GetTrackingEfficiency()->Clone("effHist");
2139
2140   file = TFile::Open(systFile);
2141
2142   Int_t maxSyst = 3;
2143   const char* systNames[] = { "NClusTPC", "Chi2TPC", "SigmaDCA" };
2144
2145   for (Int_t i=0; i<maxSyst; i++)
2146   {
2147     for (Int_t j=0; j<2; j++)
2148     {
2149       TString histName;
2150       histName.Form("%s_syst_%s", systNames[i], (j == 0) ? "up" : "down");
2151       systEffect = (TH2*) file->Get(histName);
2152
2153       // rebin
2154       effHist->Reset();
2155       for (Int_t x=1; x <= effHist->GetNbinsX(); x++)
2156         for (Int_t y=1; y <= effHist->GetNbinsY(); y++)
2157           effHist->SetBinContent(x, y, 1);
2158
2159       for (Int_t x=1; x <= systEffect->GetNbinsX(); x++)
2160         for (Int_t y=1; y <= systEffect->GetNbinsY(); y++)
2161           if (systEffect->GetBinContent(x, y) != 0)
2162             effHist->SetBinContent(effHist->GetXaxis()->FindBin(systEffect->GetYaxis()->GetBinCenter(y)), effHist->GetYaxis()->FindBin(systEffect->GetXaxis()->GetBinCenter(x)), systEffect->GetBinContent(x, y));
2163            
2164    
2165       //new TCanvas; systEffect->Draw("COLZ"); new TCanvas; effHist->Draw("COLZ");
2166  
2167       EffectOfModifiedTrackingEfficiency(fileNameData, id, (id == 2) ? 0 : 2, effHist, 0, 1, histName);
2168
2169       //return;
2170     }
2171   } 
2172 }
2173
2174 void ModifyComposition(const char* fileNameData, const char* fileNameCorrections, Int_t id, Bool_t verbose = kFALSE)
2175 {
2176   loadlibs();
2177   
2178   AliUEHistograms* corrected = (AliUEHistograms*) GetUEHistogram(fileNameData);
2179   SetupRanges(corrected);
2180   
2181   AliUEHistograms* corrections = (AliUEHistograms*) GetUEHistogram(fileNameCorrections);
2182   SetupRanges(corrections);
2183   
2184   ueHistData        = (AliUEHist*) corrected->GetUEHist(id);
2185   ueHistCorrections = (AliUEHist*) corrections->GetUEHist(id);
2186   
2187   // copy histogram
2188   // the CFStepTriggered step is overwritten here and cannot be used for comparison afterwards anymore
2189   ueHistData->CorrectTracks(AliUEHist::kCFStepAll, AliUEHist::kCFStepTriggered, (TH1*) 0, 0);
2190   
2191   Int_t maxRegion = 3;
2192   Float_t ptLeadMin = -1;
2193   Float_t ptLeadMax = -1;
2194   if (id == 2)
2195   {
2196     maxRegion = 1;
2197     // the uncertainty is flat in delta phi, so use this trick to get directly the uncertainty as function of leading pT
2198     //ptLeadMin = 1.01;
2199     //ptLeadMax = 1.99;
2200   }
2201   
2202   // histogram before
2203   TH1* before[3];
2204   for (Int_t region=0; region<maxRegion; region++)
2205     before[region] = ueHistData->GetUEHist(AliUEHist::kCFStepAll, region, ptLeadMin, ptLeadMax);
2206   
2207   //defaultEff = ueHistCorrections->GetTrackingEfficiency();
2208   defaultEff = ueHistCorrections->GetTrackingCorrection();
2209   //defaultEffpT = ueHistCorrections->GetTrackingEfficiency(1);
2210   defaultEffpT = ueHistCorrections->GetTrackingCorrection(1);
2211   defaultContainer = ueHistCorrections->GetTrackHistEfficiency();
2212   
2213   c = new TCanvas;
2214   defaultEffpT->Draw("");
2215   
2216   Float_t largestDeviation[3];
2217   for (Int_t i=0; i<maxRegion; i++)
2218     largestDeviation[i] = 0;  
2219   
2220   for (Int_t i=0; i<7; i++)
2221   {
2222     // case 0: // default
2223     // case 1: // + 30% kaons
2224     // case 2: // - 30% kaons
2225     // case 3: // + 30% protons
2226     // case 4: // - 30% protons
2227     // case 5: // + 30% others
2228     // case 6: // - 30% others
2229     Int_t correctionIndex = (i+1) / 2 + 1; // bin 1 == protons, bin 2 == kaons, ...
2230     Double_t scaleFactor = (i % 2 == 1) ? 1.3 : 0.7;
2231     if (i == 0)
2232       scaleFactor = 1;
2233     
2234     newContainer = (AliCFContainer*) defaultContainer->Clone();
2235     
2236     // modify, change all steps
2237     for (Int_t j=0; j<newContainer->GetNStep(); j++)
2238     {
2239       THnSparse* grid = newContainer->GetGrid(j)->GetGrid();
2240       
2241       for (Int_t binIdx = 0; binIdx < grid->GetNbins(); binIdx++)
2242       {
2243         Int_t bins[5];
2244         Double_t value = grid->GetBinContent(binIdx, bins);
2245         Double_t error = grid->GetBinError(binIdx);
2246         
2247         if (bins[2] != correctionIndex)
2248           continue;
2249     
2250         value *= scaleFactor;
2251         error *= scaleFactor;
2252     
2253         grid->SetBinContent(bins, value);
2254         grid->SetBinError(bins, error);      
2255       }
2256     }
2257     
2258     // put in corrections
2259     ueHistCorrections->SetTrackHistEfficiency(newContainer);
2260     
2261     // ratio
2262     //modifiedEff = ueHistCorrections->GetTrackingEfficiency();
2263     modifiedEff = ueHistCorrections->GetTrackingCorrection();
2264     modifiedEff->Divide(modifiedEff, defaultEff);
2265     //modifiedEff->Draw("COLZ");
2266     
2267     c->cd();
2268     //modifiedEffpT = ueHistCorrections->GetTrackingEfficiency(1);
2269     modifiedEffpT = ueHistCorrections->GetTrackingCorrection(1);
2270     modifiedEffpT->SetLineColor(i+1);
2271     modifiedEffpT->Draw("SAME");
2272     
2273     // apply change in tracking efficiency
2274     ueHistData->CorrectTracks(AliUEHist::kCFStepTriggered, AliUEHist::kCFStepAll, modifiedEff, 0, 1);
2275   
2276     for (Int_t region=0; region<maxRegion; region++)
2277     {
2278       // histogram after
2279       TH1* after = ueHistData->GetUEHist(AliUEHist::kCFStepAll, region, ptLeadMin, ptLeadMax);
2280       
2281       if (verbose)
2282         DrawRatio(before[region], (TH1*) after->Clone(), Form("Region %d Composition %d", region, i));
2283       
2284       // ratio is flat, extract deviation
2285       after->Divide(before[region]);
2286       after->Fit("pol0", "0");
2287       Float_t deviation = 100.0 - 100.0 * after->GetFunction("pol0")->GetParameter(0);
2288       Printf("Deviation for region %d case %d is %.2f %%", region, i, deviation);
2289       
2290       if (TMath::Abs(deviation) > largestDeviation[region])
2291         largestDeviation[region] = TMath::Abs(deviation);
2292     }
2293     //return;
2294   }
2295   
2296   for (Int_t i=0; i<maxRegion; i++)
2297     Printf("Largest deviation in region %d is %f", i, largestDeviation[i]);
2298 }    
2299
2300 void MergeList(const char* prefix = "", Bool_t copy = kFALSE)
2301 {
2302   loadlibs();
2303   gSystem->Load("libPWGflowBase");
2304   gSystem->Load("libPWGflowTasks");
2305
2306   ifstream in;
2307   in.open("list");
2308
2309   TFileMerger m(copy);
2310
2311   TString line;
2312   while (in.good())
2313   {
2314     in >> line;
2315
2316     if (line.Length() == 0)
2317       continue;
2318
2319     TString fileName;
2320     fileName.Form("%s%s", prefix, line.Data());
2321 //     fileName.Form("alien://%s", line.Data());
2322     Printf("%s", fileName.Data());
2323     
2324     m.AddFile(fileName);
2325   }
2326   
2327   m.SetFastMethod();
2328   m.OutputFile("merged.root");
2329   m.Merge();
2330 }
2331
2332 void Merge2(const char* file1, const char* file2)
2333 {
2334   loadlibs();
2335   TFileMerger m(0);
2336
2337   m.AddFile(file1);
2338   m.AddFile(file2);
2339   
2340   m.SetFastMethod();
2341   m.OutputFile("merged.root");
2342   m.Merge();
2343 }
2344
2345 void Merge3(const char* file1, const char* file2, const char* file3)
2346 {
2347   loadlibs();
2348   TFileMerger m(1);
2349
2350   m.AddFile(file1);
2351   m.AddFile(file2);
2352   m.AddFile(file3);
2353   
2354   m.SetFastMethod();
2355   m.OutputFile("merged.root");
2356   m.Merge();
2357 }
2358
2359 void MergeList2(const char* listFile, const char* dir, Bool_t onlyPrintEvents = kFALSE, const char* targetDir = "PWG4_LeadingTrackUE")
2360 {
2361   loadlibs();
2362
2363   ifstream in;
2364   in.open(listFile);
2365   
2366   AliUEHistograms* final = 0;
2367   TList* finalList = 0;
2368
2369   TString line;
2370   while (in.good())
2371   {
2372     in >> line;
2373
2374     if (line.Length() == 0)
2375       continue;
2376
2377     TString fileName;
2378     fileName.Form("%s/%s/PWG4_JetTasksOutput.root", dir, line.Data());
2379     Printf("%s", fileName.Data());
2380     
2381     TList* list = 0;
2382     AliUEHistograms* obj = (AliUEHistograms*) GetUEHistogram(fileName, &list);
2383     if (!obj)
2384       continue;
2385     
2386     if (!final)
2387     {
2388       final = (AliUEHistograms*) obj;
2389       //final->GetEventCount()->Draw(); return;
2390       Printf("Events: %d", (Int_t) final->GetEventCount()->ProjectionX()->GetBinContent(4));
2391       finalList = list;
2392     }
2393     else
2394     {
2395       additional = (AliUEHistograms*) obj;
2396       Printf("Events: %d", (Int_t) additional->GetEventCount()->ProjectionX()->GetBinContent(4));
2397       
2398       if (!onlyPrintEvents)
2399       {
2400         TList list2;
2401         list2.Add(additional);
2402         final->Merge(&list2);
2403       }
2404       delete additional;
2405       gFile->Close();
2406     }
2407   }
2408   
2409   if (onlyPrintEvents)
2410     return;
2411     
2412   Printf("Total events (at step 0): %d", (Int_t) final->GetEventCount()->ProjectionX()->GetBinContent(4));
2413   
2414   file3 = TFile::Open("merged.root", "RECREATE");
2415   file3->mkdir(targetDir);
2416   file3->cd(targetDir);
2417   finalList->Write(0, TObject::kSingleKey);
2418   file3->Close();
2419 }
2420
2421 void PlotAll(const char* correctedFile, const char* mcFile)
2422 {
2423   gCache = 1;
2424   
2425   if (gEnergy == 900)
2426   {
2427     Float_t range[] = { 1.5, 2 };
2428   }
2429   else
2430   {
2431     Float_t range[] = { 3, 10 };
2432   }
2433   
2434   for (Int_t id=0; id<3; id++)
2435   {
2436     if (id < 2)
2437       gForceRange = range[id];
2438     else
2439       gForceRange = -1;
2440       
2441     if (id < 2)
2442     {
2443       for (Int_t region=0; region<3; region++)
2444       {
2445         CompareStep(correctedFile, mcFile, id, 0, region);
2446         gPad->GetCanvas()->SaveAs(Form("%s_%s_%d_%d.png", TString(correctedFile).Tokenize(".")->First()->GetName(), TString(mcFile).Tokenize(".")->First()->GetName(), id, region));
2447       }
2448     }
2449     else
2450     {
2451       Float_t leadingPtArr[] = { 0.50, 2.0, 4.0, 6.0, 10.0, 20.0, 50.0 };
2452       for (Int_t leadingPtID=0; leadingPtID<6; leadingPtID++)
2453       {
2454         CompareStep(correctedFile, mcFile, id, 0, 0, leadingPtArr[leadingPtID] + 0.01, leadingPtArr[leadingPtID+1] - 0.01);
2455         gPad->GetCanvas()->SaveAs(Form("%s_%s_%d_%.2f_%.2f.png", TString(correctedFile).Tokenize(".")->First()->GetName(), TString(mcFile).Tokenize(".")->First()->GetName(), id, leadingPtArr[leadingPtID], leadingPtArr[leadingPtID+1]));
2456       }
2457     }
2458   }
2459 }
2460
2461 /*
2462 TGraph* GetFlow2040()
2463 {
2464   // from first ALICE flow paper (provided by Raimond)
2465   // http://www-library.desy.de/spires/find/hep/www?eprint=arXiv:1011.3914
2466   
2467   // centrality 20-30% 
2468   Double_t xCumulant4th2030ALICE[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2469   1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000,
2470   5.500000,7.000000,9.000000};
2471   Double_t yCumulant4th2030ALICE[] = {0.000000,0.000000,0.030926,0.041076,0.052063,0.059429,0.070500,0.084461,0.086745,0.099254,
2472   0.109691,0.116398,0.130831,0.141959,0.158932,0.169680,0.171387,0.178858,0.171475,0.140358,
2473   0.000000,0.000000,0.000000};
2474   Double_t xErrCumulant4th2030ALICE[23] = {0.};
2475   Double_t yErrCumulant4th2030ALICE[] = {0.000000,0.000000,0.002857,0.003451,0.003567,0.003859,0.004609,0.004976,0.005412,0.006277,
2476   0.004748,0.005808,0.006896,0.007987,0.008683,0.008080,0.013278,0.018413,0.024873,0.026057,
2477   0.000000,0.000000,0.000000};
2478   Int_t nPointsCumulant4th2030ALICE = sizeof(xCumulant4th2030ALICE)/sizeof(Double_t);                                      
2479   TGraphErrors *Cumulant4th2030ALICE = new TGraphErrors(nPointsCumulant4th2030ALICE,xCumulant4th2030ALICE,yCumulant4th2030ALICE,
2480                                                         xErrCumulant4th2030ALICE,yErrCumulant4th2030ALICE);
2481   Cumulant4th2030ALICE->SetMarkerStyle(kFullSquare);
2482   Cumulant4th2030ALICE->SetMarkerColor(kRed);
2483   Cumulant4th2030ALICE->SetMarkerSize(1.2);
2484   Cumulant4th2030ALICE->SetFillStyle(1001);
2485   Cumulant4th2030ALICE->SetFillColor(kRed-10);
2486   
2487   //===================================================================================================================
2488   // centrality 30-40% 
2489   Double_t xCumulant4th3040ALICE[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2490   1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000,
2491   5.500000,7.000000,9.000000};
2492   Double_t yCumulant4th3040ALICE[] = {0.000000,0.000000,0.037071,0.048566,0.061083,0.070910,0.078831,0.091396,0.102026,0.109691,
2493   0.124449,0.139819,0.155561,0.165701,0.173678,0.191149,0.202015,0.204540,0.212560,0.195885,
2494   0.000000,0.000000,0.000000};
2495   Double_t xErrCumulant4th3040ALICE[23] = {0.};
2496   Double_t yErrCumulant4th3040ALICE[] = {0.000000,0.000000,0.002992,0.003364,0.003669,0.003931,0.004698,0.005261,0.005446,0.006151,
2497   0.004980,0.005741,0.007198,0.008576,0.010868,0.009926,0.015269,0.020691,0.027601,0.031834,
2498   0.000000,0.000000,0.000000};
2499   Int_t nPointsCumulant4th3040ALICE = sizeof(xCumulant4th3040ALICE)/sizeof(Double_t);
2500   TGraphErrors *Cumulant4th3040ALICE = new TGraphErrors(nPointsCumulant4th3040ALICE,xCumulant4th3040ALICE,yCumulant4th3040ALICE,
2501                                                         xErrCumulant4th3040ALICE,yErrCumulant4th3040ALICE);
2502   Cumulant4th3040ALICE->SetMarkerStyle(kFullTriangleUp);
2503   Cumulant4th3040ALICE->SetMarkerColor(kGreen+2);
2504   Cumulant4th3040ALICE->SetMarkerSize(1.2);
2505   Cumulant4th3040ALICE->SetFillStyle(1001);
2506   Cumulant4th3040ALICE->SetFillColor(kGreen+2);
2507   
2508   // build average between the two (for class 20-40%)
2509   Double_t* yAverage = new Double_t[nPointsCumulant4th3040ALICE];
2510   for (Int_t i=0; i<nPointsCumulant4th3040ALICE; i++)
2511     yAverage[i] = (yCumulant4th2030ALICE[i] + yCumulant4th3040ALICE[i]) / 2;
2512     
2513   // assume flow constant above highest pT; not neccessarily physically sound ;)
2514   if (1)
2515   {
2516     yAverage[20] = yAverage[19];
2517     xCumulant4th3040ALICE[20] = 100;
2518     nPointsCumulant4th3040ALICE -= 2;
2519   }
2520   
2521   TGraph *flow2040 = new TGraph(nPointsCumulant4th3040ALICE,xCumulant4th3040ALICE,yAverage);
2522   
2523   if (0)
2524   {
2525     flow2040->Draw("*A");
2526     Cumulant4th2030ALICE->Draw("PSAME");
2527     Cumulant4th3040ALICE->Draw("PSAME");
2528   }
2529   
2530   return flow2040;
2531 }
2532 */
2533
2534 /*
2535 TGraph* GetFlow1020()
2536 {
2537   // from first ALICE flow paper (provided by Raimond)
2538   // http://www-library.desy.de/spires/find/hep/www?eprint=arXiv:1011.3914
2539   
2540   //===================================================================================================================
2541   // centrality 10-20% 
2542   Double_t xCumulant4th1020ALICE[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2543   1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000,
2544   5.500000,7.000000,9.000000};
2545   Double_t yCumulant4th1020ALICE[] = {0.000000,0.000000,0.024075,0.031505,0.040413,0.044981,0.055358,0.060563,0.063378,0.070030,
2546   0.082692,0.091611,0.099641,0.107223,0.122376,0.131240,0.137425,0.146050,0.131365,0.124708,
2547   0.000000,0.000000,0.000000};
2548   Double_t xErrCumulant4th1020ALICE[23] = {0.};
2549   Double_t yErrCumulant4th1020ALICE[] = {0.000000,0.000000,0.002413,0.002931,0.003444,0.003950,0.004338,0.004835,0.005059,0.005586,
2550   0.004521,0.005278,0.005999,0.007072,0.008260,0.007279,0.011897,0.017409,0.023995,0.025701,
2551   0.000000,0.000000,0.000000};
2552   Int_t nPointsCumulant4th1020ALICE = sizeof(xCumulant4th1020ALICE)/sizeof(Double_t);                                      
2553   
2554   // assume flow constant above highest pT; not neccessarily physically sound ;)
2555   if (1)
2556   {
2557     yCumulant4th1020ALICE[20] = yCumulant4th1020ALICE[19];
2558     xCumulant4th1020ALICE[20] = 100;
2559     nPointsCumulant4th1020ALICE -= 2;
2560   }
2561   
2562   TGraphErrors *Cumulant4th1020ALICE = new TGraphErrors(nPointsCumulant4th1020ALICE,xCumulant4th1020ALICE,yCumulant4th1020ALICE,
2563                                                         xErrCumulant4th1020ALICE,yErrCumulant4th1020ALICE);
2564   
2565  Cumulant4th1020ALICE->SetMarkerStyle(kFullCircle);
2566  Cumulant4th1020ALICE->SetMarkerColor(kBlue);
2567  Cumulant4th1020ALICE->SetMarkerSize(1.2);
2568  Cumulant4th1020ALICE->SetFillStyle(1001);
2569  Cumulant4th1020ALICE->SetFillColor(kBlue-10);
2570   
2571   TGraph *flow1020 = new TGraph(nPointsCumulant4th1020ALICE,xCumulant4th1020ALICE,yCumulant4th1020ALICE);
2572   
2573   if (0)
2574   {
2575     flow1020->Draw("*A");
2576     Cumulant4th1020ALICE->Draw("PSAME");
2577   }
2578   
2579   return flow1020;
2580 }
2581 */
2582
2583 /*
2584 TGraph* GetFlow05()
2585 {
2586   // takes flow measurement from 10-20% and scales by a factor extracted from Fig.3 in the ALICE flow paper
2587   // factor = integrated flow in 0-5% / integrated flow in 10-20%
2588   
2589   graph = GetFlow1020();
2590   for (Int_t i=0; i<graph->GetN(); i++)
2591     graph->GetY()[i] *= 0.016 / 0.055;
2592     
2593   return graph;
2594 }
2595 */
2596 TGraphErrors* GetFlow01_Rap02(Int_t n)
2597 {
2598   // private communication 19.04.11, Raimond / Ante
2599
2600   if (n == 2)
2601   {
2602     //  v2{SP}(pt) for 0-1%, rapidity gap = 0.2:
2603     const Int_t nPointsSP_0001ALICE_v2_etaGap02 = 18;
2604     Double_t xSP_0001ALICE_v2_etaGap02[nPointsSP_0001ALICE_v2_etaGap02] = {0.250000,0.350000,0.450000,0.550000,0.650000,
2605     0.750000,0.850000,0.950000,1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
2606     Double_t ySP_0001ALICE_v2_etaGap02[nPointsSP_0001ALICE_v2_etaGap02] = {0.009235,0.014105,0.017274,0.018245,0.023190,
2607     0.024871,0.028216,0.031506,0.034179,0.035337,0.039836,0.045261,0.043393,0.050693,0.056469,0.055247,0.049718,0.052748};
2608     Double_t xErrSP_0001ALICE_v2_etaGap02[nPointsSP_0001ALICE_v2_etaGap02] = {0.};
2609     Double_t yErrSP_0001ALICE_v2_etaGap02[nPointsSP_0001ALICE_v2_etaGap02] = {0.000515,0.000504,0.000532,0.000585,0.000641,
2610     0.000709,0.000788,0.000876,0.000723,0.000891,0.001098,0.001354,0.001671,0.001485,0.002463,0.004038,0.006441,0.008091};
2611     TGraphErrors *SP_0001ALICE_v2_etaGap02 = new TGraphErrors(nPointsSP_0001ALICE_v2_etaGap02,xSP_0001ALICE_v2_etaGap02,
2612                                                               ySP_0001ALICE_v2_etaGap02,xErrSP_0001ALICE_v2_etaGap02,yErrSP_0001ALICE_v2_etaGap02);
2613     SP_0001ALICE_v2_etaGap02->SetMarkerStyle(kFullCircle);
2614     SP_0001ALICE_v2_etaGap02->SetMarkerColor(kBlue);  
2615     SP_0001ALICE_v2_etaGap02->SetFillStyle(1001);
2616     SP_0001ALICE_v2_etaGap02->SetFillColor(kBlue-10);  
2617     
2618     return SP_0001ALICE_v2_etaGap02;
2619   }
2620   
2621   if (n == 3)
2622   {
2623     //  v3{SP}(pt) for 0-1%, rapidity gap = 0.2:
2624     const Int_t nPointsSP_0001ALICE_v3_etaGap02 = 18;
2625     Double_t xSP_0001ALICE_v3_etaGap02[nPointsSP_0001ALICE_v3_etaGap02] = {0.250000,0.350000,0.450000,0.550000,0.650000,
2626     0.750000,0.850000,0.950000,1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
2627     Double_t ySP_0001ALICE_v3_etaGap02[nPointsSP_0001ALICE_v3_etaGap02] = {0.005688,0.007222,0.010305,0.013795,0.016077,
2628     0.018693,0.022310,0.026991,0.030162,0.035119,0.043097,0.048201,0.058249,0.063273,0.079233,0.083465,0.087807,0.069577};
2629     Double_t xErrSP_0001ALICE_v3_etaGap02[nPointsSP_0001ALICE_v3_etaGap02] = {0.};
2630     Double_t yErrSP_0001ALICE_v3_etaGap02[nPointsSP_0001ALICE_v3_etaGap02] = {0.000585,0.000582,0.000614,0.000667,0.000734,
2631     0.000811,0.000898,0.000989,0.000817,0.001000,0.001234,0.001517,0.001874,0.001669,0.002765,0.004528,0.007202,0.009066};
2632     TGraphErrors *SP_0001ALICE_v3_etaGap02 = new TGraphErrors(nPointsSP_0001ALICE_v3_etaGap02,xSP_0001ALICE_v3_etaGap02,ySP_0001ALICE_v3_etaGap02,
2633                                                               xErrSP_0001ALICE_v3_etaGap02,yErrSP_0001ALICE_v3_etaGap02);
2634     SP_0001ALICE_v3_etaGap02->SetMarkerStyle(kFullTriangleUp);
2635     SP_0001ALICE_v3_etaGap02->SetMarkerSize(1.4);  
2636     SP_0001ALICE_v3_etaGap02->SetMarkerColor(kGreen+2);
2637     SP_0001ALICE_v3_etaGap02->SetFillStyle(1001);
2638     SP_0001ALICE_v3_etaGap02->SetFillColor(kGreen-10);     
2639     
2640     return SP_0001ALICE_v3_etaGap02;
2641   }
2642    
2643   if (n == 4)
2644   {
2645     //  v4{SP}(pt) for 0-1%, rapidity gap = 0.2:
2646     const Int_t nPointsSP_0001ALICE_v4_etaGap02 = 18;
2647     Double_t xSP_0001ALICE_v4_etaGap02[nPointsSP_0001ALICE_v4_etaGap02] = {0.250000,0.350000,0.450000,0.550000,0.650000,
2648     0.750000,0.850000,0.950000,1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
2649     Double_t ySP_0001ALICE_v4_etaGap02[nPointsSP_0001ALICE_v4_etaGap02] = {0.001189,0.003540,0.004682,0.004210,0.007032,
2650     0.008627,0.010226,0.013671,0.016214,0.020054,0.023878,0.033939,0.033693,0.040006,0.055612,0.066287,0.074857,0.078751};
2651     Double_t xErrSP_0001ALICE_v4_etaGap02[nPointsSP_0001ALICE_v4_etaGap02] = {0.};
2652     Double_t yErrSP_0001ALICE_v4_etaGap02[nPointsSP_0001ALICE_v4_etaGap02] = {0.001035,0.001017,0.001081,0.001187,0.001299,
2653     0.001432,0.001590,0.001757,0.001443,0.001769,0.002175,0.002674,0.003296,0.002924,0.004844,0.007921,0.012524,0.015771};
2654     TGraphErrors *SP_0001ALICE_v4_etaGap02 = new TGraphErrors(nPointsSP_0001ALICE_v4_etaGap02,xSP_0001ALICE_v4_etaGap02,ySP_0001ALICE_v4_etaGap02,
2655                                                               xErrSP_0001ALICE_v4_etaGap02,yErrSP_0001ALICE_v4_etaGap02);
2656     SP_0001ALICE_v4_etaGap02->SetMarkerStyle(kFullSquare);
2657     SP_0001ALICE_v4_etaGap02->SetMarkerColor(kRed);
2658     SP_0001ALICE_v4_etaGap02->SetFillStyle(1001);
2659     SP_0001ALICE_v4_etaGap02->SetFillColor(kRed-10);  
2660     
2661     return SP_0001ALICE_v4_etaGap02;
2662   }
2663   
2664   return 0;
2665 }
2666
2667 TGraphErrors* GetFlow01_Rap10(Int_t n)
2668 {
2669   if (n == 2)
2670   {
2671     //  v2{SP}(pt) for 0-1%, rapidity gap = 1.0:
2672     const Int_t nPointsSP_0001ALICE_v2_etaGap10 = 21;
2673     Double_t xSP_0001ALICE_v2_etaGap10[nPointsSP_0001ALICE_v2_etaGap10] = {0.250000,0.350000,0.450000,0.550000,0.650000,
2674     0.750000,0.850000,0.950000,1.100000,1.300000,1.500000,1.700000,1.900000,2.100000,2.300000,2.500000,2.700000,2.900000,
2675     3.250000,3.750000,4.500000};
2676     Double_t ySP_0001ALICE_v2_etaGap10[nPointsSP_0001ALICE_v2_etaGap10] = {0.009129,0.013461,0.017567,0.018041,0.020384,
2677     0.023780,0.021647,0.029543,0.028912,0.029464,0.037016,0.044131,0.043135,0.047286,0.051983,0.049311,0.050472,0.046569,
2678     0.036905,0.054836,0.030527};
2679     Double_t xErrSP_0001ALICE_v2_etaGap10[nPointsSP_0001ALICE_v2_etaGap10] = {0.};
2680     Double_t yErrSP_0001ALICE_v2_etaGap10[nPointsSP_0001ALICE_v2_etaGap10] = {0.001179,0.001152,0.001219,0.001339,0.001480,
2681     0.001644,0.001831,0.002016,0.001662,0.002033,0.002497,0.003056,0.003777,0.004645,0.005713,0.007069,0.008540,0.010447,
2682     0.009145,0.014749,0.018698};
2683     TGraphErrors *SP_0001ALICE_v2_etaGap10 = new TGraphErrors(nPointsSP_0001ALICE_v2_etaGap10,xSP_0001ALICE_v2_etaGap10,
2684                                                               ySP_0001ALICE_v2_etaGap10,xErrSP_0001ALICE_v2_etaGap10,yErrSP_0001ALICE_v2_etaGap10);
2685     SP_0001ALICE_v2_etaGap10->SetMarkerStyle(kOpenCircle);
2686     SP_0001ALICE_v2_etaGap10->SetMarkerColor(kBlue);  
2687     SP_0001ALICE_v2_etaGap10->SetFillStyle(1001);
2688     SP_0001ALICE_v2_etaGap10->SetFillColor(kBlue-10);  
2689     
2690     return SP_0001ALICE_v2_etaGap10;
2691   }
2692
2693   if (n == 3)
2694   {
2695     //  v3{SP}(pt) for 0-1%, rapidity gap = 1.0:
2696     const Int_t nPointsSP_0001ALICE_v3_etaGap10 = 18;
2697     Double_t xSP_0001ALICE_v3_etaGap10[nPointsSP_0001ALICE_v3_etaGap10] = {0.250000,0.350000,0.450000,0.550000,0.650000,
2698     0.750000,0.850000,0.950000,1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
2699     Double_t ySP_0001ALICE_v3_etaGap10[nPointsSP_0001ALICE_v3_etaGap10] = {0.006373,0.008403,0.010848,0.011505,0.016728,
2700     0.018519,0.020163,0.027119,0.029315,0.036832,0.040974,0.043287,0.054395,0.060676,0.081763,0.074333,0.096016,0.074909};
2701     Double_t xErrSP_0001ALICE_v3_etaGap10[nPointsSP_0001ALICE_v3_etaGap10] = {0.};
2702     Double_t yErrSP_0001ALICE_v3_etaGap10[nPointsSP_0001ALICE_v3_etaGap10] = {0.001286,0.001269,0.001346,0.001474,0.001620,
2703     0.001796,0.001991,0.002187,0.001803,0.002203,0.002697,0.003316,0.004078,0.003640,0.006050,0.009873,0.015824,0.020174};
2704     TGraphErrors *SP_0001ALICE_v3_etaGap10 = new TGraphErrors(nPointsSP_0001ALICE_v3_etaGap10,xSP_0001ALICE_v3_etaGap10,ySP_0001ALICE_v3_etaGap10,
2705                                                               xErrSP_0001ALICE_v3_etaGap10,yErrSP_0001ALICE_v3_etaGap10);
2706     SP_0001ALICE_v3_etaGap10->SetMarkerStyle(kOpenTriangleUp);
2707     SP_0001ALICE_v3_etaGap10->SetMarkerSize(1.2);  
2708     SP_0001ALICE_v3_etaGap10->SetMarkerColor(kGreen+2);
2709     SP_0001ALICE_v3_etaGap10->SetFillStyle(1001);
2710     SP_0001ALICE_v3_etaGap10->SetFillColor(kGreen-10);     
2711     
2712     return SP_0001ALICE_v3_etaGap10;
2713   }
2714
2715   if (n == 4)
2716   {
2717     //  v4{SP}(pt) for 0-1%, rapidity gap = 1.0:
2718     const Int_t nPointsSP_0001ALICE_v4_etaGap10 = 11;
2719     Double_t xSP_0001ALICE_v4_etaGap10[nPointsSP_0001ALICE_v4_etaGap10] = {0.300000,0.500000,0.700000,0.900000,1.200000,1.600000,2.000000,2.400000,2.800000,3.500000,4.500000};
2720     Double_t ySP_0001ALICE_v4_etaGap10[nPointsSP_0001ALICE_v4_etaGap10] = {-0.000458,0.006444,0.005490,0.010870,0.018866,0.024370,0.029703,0.052505,0.060334,0.048189,0.128184};
2721     Double_t xErrSP_0001ALICE_v4_etaGap10[nPointsSP_0001ALICE_v4_etaGap10] = {0.};
2722     Double_t yErrSP_0001ALICE_v4_etaGap10[nPointsSP_0001ALICE_v4_etaGap10] = {0.001901,0.002012,0.002477,0.003014,0.002852,0.004297,0.006491,0.009846,0.014623,0.017120,0.040568};
2723     TGraphErrors *SP_0001ALICE_v4_etaGap10 = new TGraphErrors(nPointsSP_0001ALICE_v4_etaGap10,xSP_0001ALICE_v4_etaGap10,ySP_0001ALICE_v4_etaGap10,
2724                                                               xErrSP_0001ALICE_v4_etaGap10,yErrSP_0001ALICE_v4_etaGap10);
2725     SP_0001ALICE_v4_etaGap10->SetMarkerStyle(kOpenSquare);
2726     SP_0001ALICE_v4_etaGap10->SetMarkerColor(kRed);
2727     SP_0001ALICE_v4_etaGap10->SetFillStyle(1001);
2728     SP_0001ALICE_v4_etaGap10->SetFillColor(kRed-10);  
2729     
2730     return SP_0001ALICE_v4_etaGap10;
2731   }
2732   
2733   if (n == 5)
2734   {
2735     //  v5{SP}(pt) for 0-1%, rapidity gap = 1.0:
2736     const Int_t nPointsSP_0001ALICE_v5_etaGap10 = 11;
2737     Double_t xSP_0001ALICE_v5_etaGap10[nPointsSP_0001ALICE_v5_etaGap10] = {0.300000,0.500000,0.700000,0.900000,1.200000,1.600000,2.000000,2.400000,2.800000,3.500000,4.500000};
2738     Double_t ySP_0001ALICE_v5_etaGap10[nPointsSP_0001ALICE_v5_etaGap10] = {0.007022,0.001344,0.008380,0.004298,-0.001444,0.014114,0.015012,0.041880,0.019820,0.042083,0.015268};
2739     Double_t xErrSP_0001ALICE_v5_etaGap10[nPointsSP_0001ALICE_v5_etaGap10] = {0.};
2740     Double_t yErrSP_0001ALICE_v5_etaGap10[nPointsSP_0001ALICE_v5_etaGap10] = {0.002713,0.003167,0.003741,0.004650,0.004525,0.006578,0.009986,0.015185,0.022535,0.026356,0.064773};
2741     TGraphErrors *SP_0001ALICE_v5_etaGap10 = new TGraphErrors(nPointsSP_0001ALICE_v5_etaGap10,xSP_0001ALICE_v5_etaGap10,ySP_0001ALICE_v5_etaGap10,
2742                                                               xErrSP_0001ALICE_v5_etaGap10,yErrSP_0001ALICE_v5_etaGap10);
2743     return SP_0001ALICE_v5_etaGap10;
2744   }
2745 }
2746
2747 TGraphErrors* GetFlow02_Rap10(Int_t n)
2748 {
2749   // private communication 20.04.11, Ante B. / Raimond
2750
2751   if (n == 2)
2752   {
2753      //  v2{SP}(pt) for 00-02%, eta gap = 1.0:
2754     const Int_t nPointsSP_0002_v2_etaGap10 = 15;
2755     Double_t xSP_0002_v2_etaGap10[nPointsSP_0002_v2_etaGap10] = {0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,
2756     0.900000,1.100000,1.350000,1.650000,1.950000,2.250000,2.700000,3.500000,4.500000};
2757     Double_t ySP_0002_v2_etaGap10[nPointsSP_0002_v2_etaGap10] = {0.010171,0.013190,0.017342,0.020629,0.022617,0.026549,
2758     0.027423,0.032261,0.037467,0.041001,0.045763,0.049327,0.049688,0.051480,0.038527};
2759     Double_t xErrSP_0002_v2_etaGap10[nPointsSP_0002_v2_etaGap10] = {0.};
2760     Double_t yErrSP_0002_v2_etaGap10[nPointsSP_0002_v2_etaGap10] = {0.000600,0.000590,0.000625,0.000683,0.000757,0.000839,
2761     0.000692,0.000848,0.000888,0.001209,0.001653,0.002252,0.002465,0.003968,0.009391};
2762     TGraphErrors *SP_0002_v2_etaGap10 = new TGraphErrors(nPointsSP_0002_v2_etaGap10,xSP_0002_v2_etaGap10,ySP_0002_v2_etaGap10,
2763                                                   xErrSP_0002_v2_etaGap10,yErrSP_0002_v2_etaGap10);
2764                                                   
2765     return SP_0002_v2_etaGap10;
2766   }
2767   
2768   if (n == 3)
2769   {
2770     const Int_t nPointsSP_0002_v3_etaGap10 = 15;
2771     Double_t xSP_0002_v3_etaGap10[nPointsSP_0002_v3_etaGap10] = {0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,
2772     0.900000,1.100000,1.350000,1.650000,1.950000,2.250000,2.700000,3.500000,4.500000};
2773     Double_t ySP_0002_v3_etaGap10[nPointsSP_0002_v3_etaGap10] = {0.006592,0.007286,0.012180,0.012242,0.017416,0.018393,
2774     0.024716,0.030980,0.037703,0.046558,0.051285,0.064613,0.074831,0.077093,0.082442};
2775     Double_t xErrSP_0002_v3_etaGap10[nPointsSP_0002_v3_etaGap10] = {0.};
2776     Double_t yErrSP_0002_v3_etaGap10[nPointsSP_0002_v3_etaGap10] = {0.000682,0.000676,0.000713,0.000782,0.000860,0.000953,
2777     0.000782,0.000957,0.001002,0.001361,0.001862,0.002541,0.002767,0.004466,0.010586};
2778     TGraphErrors *SP_0002_v3_etaGap10 = new TGraphErrors(nPointsSP_0002_v3_etaGap10,xSP_0002_v3_etaGap10,ySP_0002_v3_etaGap10,
2779                                                           xErrSP_0002_v3_etaGap10,yErrSP_0002_v3_etaGap10);    
2780                                                           
2781     return SP_0002_v3_etaGap10;
2782   }
2783   
2784   if (n == 4)
2785   {
2786     const Int_t nPointsSP_0002_v4_etaGap10 = 15;
2787     Double_t xSP_0002_v4_etaGap10[nPointsSP_0002_v4_etaGap10] = {0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,
2788     0.900000,1.100000,1.350000,1.650000,1.950000,2.250000,2.700000,3.500000,4.500000};
2789     Double_t ySP_0002_v4_etaGap10[nPointsSP_0002_v4_etaGap10] = {-0.000533,0.001167,0.002081,0.005218,0.006826,0.008440,
2790     0.013009,0.014812,0.017125,0.030106,0.038279,0.050488,0.067640,0.071637,0.084239};
2791     Double_t xErrSP_0002_v4_etaGap10[nPointsSP_0002_v4_etaGap10] = {0.};
2792     Double_t yErrSP_0002_v4_etaGap10[nPointsSP_0002_v4_etaGap10] = {0.001427,0.001398,0.001482,0.001594,0.001758,0.001945,
2793     0.001593,0.001951,0.002046,0.002787,0.003802,0.005182,0.005663,0.009064,0.021449};
2794     TGraphErrors *SP_0002_v4_etaGap10 = new TGraphErrors(nPointsSP_0002_v4_etaGap10,xSP_0002_v4_etaGap10,ySP_0002_v4_etaGap10,
2795                                                       xErrSP_0002_v4_etaGap10,yErrSP_0002_v4_etaGap10);
2796     return SP_0002_v4_etaGap10;
2797   }
2798   
2799   if (n == 5)
2800   {
2801     //  v5{SP}(pt) for 00-02%, eta gap = 0.2:
2802     const Int_t nPointsSP_0002_v5_etaGap02 = 13;
2803     Double_t xSP_0002_v5_etaGap02[nPointsSP_0002_v5_etaGap02] = {0.300000,0.500000,0.700000,0.900000,1.100000,1.300000,1.500000,
2804     1.700000,2.000000,2.550000,3.250000,3.950000,4.650000};
2805     Double_t ySP_0002_v5_etaGap02[nPointsSP_0002_v5_etaGap02] = {0.000570,0.002922,0.002151,0.005256,0.006287,0.005849,0.009399,
2806     0.011420,0.012455,0.032134,0.057009,0.020607,0.013551};
2807     Double_t xErrSP_0002_v5_etaGap02[nPointsSP_0002_v5_etaGap02] = {0.};
2808     Double_t yErrSP_0002_v5_etaGap02[nPointsSP_0002_v5_etaGap02] = {0.001074,0.001155,0.001433,0.001725,0.002123,0.002608,0.003196,
2809     0.003930,0.003755,0.004869,0.009719,0.018353,0.031814};
2810     TGraphErrors *SP_0002_v5_etaGap02 = new TGraphErrors(nPointsSP_0002_v5_etaGap02,xSP_0002_v5_etaGap02,ySP_0002_v5_etaGap02,
2811                                                           xErrSP_0002_v5_etaGap02,yErrSP_0002_v5_etaGap02);
2812     return SP_0002_v5_etaGap02;
2813   }
2814 }
2815
2816 TGraphErrors* GetFlow02(Int_t n)
2817 {
2818   // private communication 28.01.11, Ante B. / Raimond
2819
2820   if (n == 2)
2821   {
2822     // v2{2}(pt):
2823     Double_t xCumulant2nd0002ALICE_v2[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2824     1.050000,1.150000,1.250000,1.350000,1.450000,1.550000,1.650000,1.750000,1.850000,1.950000,
2825     2.250000,2.750000,3.250000,3.750000,4.250000,4.750000,5.500000,6.500000,7.500000,8.500000,
2826     9.500000};
2827     Double_t yCumulant2nd0002ALICE_v2[] = {0.000000,0.000000,0.012173,0.015186,0.018580,0.021114,0.024646,0.027040,0.030269,0.032677,
2828     0.035332,0.037382,0.039228,0.040614,0.042460,0.044658,0.046246,0.050392,0.051436,0.054669,
2829     0.057330,0.063439,0.067425,0.060144,0.071260,0.070206,0.000000,0.000000,0.000000,0.000000,
2830     0.000000};
2831     Double_t xErrCumulant2nd0002ALICE_v2[31] = {0.};
2832     Double_t yErrCumulant2nd0002ALICE_v2[] = {0.000000,0.000000,0.000256,0.000259,0.000271,0.000296,0.000322,0.000357,0.000397,0.000438,
2833     0.000483,0.000529,0.000590,0.000639,0.000713,0.000793,0.000877,0.000976,0.001070,0.001197,
2834     0.000725,0.001265,0.002069,0.003156,0.004605,0.006543,0.000000,0.000000,0.000000,0.000000,
2835     0.000000};
2836     Int_t nPointsCumulant2nd0002ALICE_v2 = sizeof(xCumulant2nd0002ALICE_v2)/sizeof(Double_t);                                      
2837     TGraphErrors *Cumulant2nd0002ALICE_v2 = new TGraphErrors(nPointsCumulant2nd0002ALICE_v2,xCumulant2nd0002ALICE_v2,yCumulant2nd0002ALICE_v2,
2838                                                           xErrCumulant2nd0002ALICE_v2,yErrCumulant2nd0002ALICE_v2);
2839     Cumulant2nd0002ALICE_v2->SetMarkerStyle(kFullCircle);
2840     Cumulant2nd0002ALICE_v2->SetMarkerColor(kBlue);
2841     
2842     return Cumulant2nd0002ALICE_v2;
2843   }
2844   
2845   if (n == 3)
2846   {
2847     // v3{2}(pt):
2848     Double_t xCumulant2nd0002ALICE_v3[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2849     1.050000,1.150000,1.250000,1.350000,1.450000,1.550000,1.650000,1.750000,1.850000,1.950000,
2850     2.250000,2.750000,3.250000,3.750000,4.250000,4.750000,5.500000,6.500000,7.500000,8.500000,
2851     9.500000};
2852     Double_t yCumulant2nd0002ALICE_v3[] = {0.000000,0.000000,0.007696,0.008994,0.010544,0.013269,0.016330,0.019234,0.023465,0.026803,
2853     0.029906,0.032211,0.035300,0.038158,0.041861,0.046002,0.049382,0.053574,0.055773,0.059420,
2854     0.069373,0.079922,0.090265,0.103583,0.111358,0.090740,0.000000,0.000000,0.000000,0.000000,
2855     0.000000};
2856     Double_t xErrCumulant2nd0002ALICE_v3[31] = {0.};
2857     Double_t yErrCumulant2nd0002ALICE_v3[] = {0.000000,0.000000,0.000318,0.000317,0.000333,0.000360,0.000392,0.000431,0.000476,0.000523,
2858     0.000575,0.000637,0.000707,0.000785,0.000878,0.000964,0.001064,0.001175,0.001320,0.001459,
2859     0.000889,0.001539,0.002530,0.003826,0.005614,0.007892,0.000000,0.000000,0.000000,0.000000,
2860     0.000000};
2861     Int_t nPointsCumulant2nd0002ALICE_v3 = sizeof(xCumulant2nd0002ALICE_v3)/sizeof(Double_t);                                      
2862     TGraphErrors *Cumulant2nd0002ALICE_v3 = new TGraphErrors(nPointsCumulant2nd0002ALICE_v3,xCumulant2nd0002ALICE_v3,yCumulant2nd0002ALICE_v3,
2863                                                           xErrCumulant2nd0002ALICE_v3,yErrCumulant2nd0002ALICE_v3);
2864     Cumulant2nd0002ALICE_v3->SetMarkerStyle(kFullTriangleUp);
2865     Cumulant2nd0002ALICE_v3->SetMarkerSize(1.2);
2866     Cumulant2nd0002ALICE_v3->SetMarkerColor(kGreen+2); 
2867     
2868     return Cumulant2nd0002ALICE_v3;
2869   }
2870   
2871   if (n == 4)
2872   {
2873     // v4{2}(pt):
2874     Double_t xCumulant2nd0002ALICE_v4[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2875     1.050000,1.150000,1.250000,1.350000,1.450000,1.550000,1.650000,1.750000,1.850000,1.950000,
2876     2.250000,2.750000,3.250000,3.750000,4.250000,4.750000,5.500000,6.500000,7.500000,8.500000,
2877     9.500000};
2878     Double_t yCumulant2nd0002ALICE_v4[] = {0.000000,0.000000,0.005710,0.006014,0.004483,0.005453,0.007714,0.006837,0.009721,0.011288,
2879     0.012531,0.016461,0.016606,0.018587,0.022722,0.025497,0.025832,0.030994,0.030349,0.034730,
2880     0.045529,0.061153,0.074238,0.079307,0.088885,0.085218,0.000000,0.000000,0.000000,0.000000,
2881     0.000000};
2882     Double_t xErrCumulant2nd0002ALICE_v4[31] = {0.};
2883     Double_t yErrCumulant2nd0002ALICE_v4[] = {0.000000,0.000000,0.000488,0.000493,0.000523,0.000571,0.000609,0.000678,0.000742,0.000805,
2884     0.000903,0.000985,0.001100,0.001219,0.001352,0.001503,0.001682,0.001847,0.002060,0.002303,
2885     0.001400,0.002431,0.003974,0.006040,0.008901,0.012343,0.000000,0.000000,0.000000,0.000000,
2886     0.000000};
2887     Int_t nPointsCumulant2nd0002ALICE_v4 = sizeof(xCumulant2nd0002ALICE_v4)/sizeof(Double_t);                                      
2888     TGraphErrors *Cumulant2nd0002ALICE_v4 = new TGraphErrors(nPointsCumulant2nd0002ALICE_v4,xCumulant2nd0002ALICE_v4,yCumulant2nd0002ALICE_v4,
2889                                                           xErrCumulant2nd0002ALICE_v4,yErrCumulant2nd0002ALICE_v4);
2890     Cumulant2nd0002ALICE_v4->SetMarkerStyle(kFullSquare);
2891     Cumulant2nd0002ALICE_v4->SetMarkerColor(kRed);  
2892     
2893     return Cumulant2nd0002ALICE_v4;
2894   }
2895   
2896   return 0;
2897 }
2898
2899 /* results up to 5 GeV/c
2900
2901 TGraphErrors* GetFlow05(Int_t n)
2902 {
2903   // private communication 02.02.11, Ante B. / Raimond
2904
2905   if (n == 2)
2906   {
2907     // v2{2}(pt) for 0-5%:
2908     Double_t xCumulant2nd0005ALICE_v2[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2909     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
2910     Double_t yCumulant2nd0005ALICE_v2[] = {0.000000,0.000000,0.013891,0.017693,0.021693,0.025323,0.029131,0.032443,0.035781,0.038256,
2911     0.042801,0.047705,0.053229,0.057387,0.062677,0.068815,0.077695,0.082058,0.082511,0.079791};
2912     Double_t xErrCumulant2nd0005ALICE_v2[20] = {0.};
2913     Double_t yErrCumulant2nd0005ALICE_v2[] = {0.000000,0.000000,0.000149,0.000150,0.000160,0.000174,0.000191,0.000211,0.000233,0.000257,
2914     0.000208,0.000254,0.000311,0.000377,0.000464,0.000419,0.000726,0.001180,0.001791,0.002131};
2915     Int_t nPointsCumulant2nd0005ALICE_v2 = sizeof(xCumulant2nd0005ALICE_v2)/sizeof(Double_t);                                      
2916     TGraphErrors *Cumulant2nd0005ALICE_v2 = new TGraphErrors(nPointsCumulant2nd0005ALICE_v2,xCumulant2nd0005ALICE_v2,yCumulant2nd0005ALICE_v2,
2917                                                           xErrCumulant2nd0005ALICE_v2,yErrCumulant2nd0005ALICE_v2);
2918     Cumulant2nd0005ALICE_v2->SetMarkerStyle(kFullCircle);
2919     Cumulant2nd0005ALICE_v2->SetMarkerColor(kBlue);    
2920     
2921     return Cumulant2nd0005ALICE_v2;
2922   }
2923   
2924   if (n == 3)
2925   {
2926     // v3{2}(pt) for 0-5%:
2927     Double_t xCumulant2nd0005ALICE_v3[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2928     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
2929     Double_t yCumulant2nd0005ALICE_v3[] = {0.000000,0.000000,0.007788,0.009472,0.011596,0.014618,0.017540,0.021020,0.024946,0.028004,
2930     0.032330,0.039491,0.046368,0.053620,0.060662,0.071750,0.086746,0.097857,0.103111,0.104796};
2931     Double_t xErrCumulant2nd0005ALICE_v3[20] = {0.};
2932     Double_t yErrCumulant2nd0005ALICE_v3[] = {0.000000,0.000000,0.000194,0.000192,0.000204,0.000221,0.000241,0.000265,0.000293,0.000323,
2933     0.000266,0.000323,0.000397,0.000486,0.000601,0.000545,0.000947,0.001541,0.002328,0.002777};
2934     Int_t nPointsCumulant2nd0005ALICE_v3 = sizeof(xCumulant2nd0005ALICE_v3)/sizeof(Double_t);                                      
2935     TGraphErrors *Cumulant2nd0005ALICE_v3 = new TGraphErrors(nPointsCumulant2nd0005ALICE_v3,xCumulant2nd0005ALICE_v3,yCumulant2nd0005ALICE_v3,
2936                                                           xErrCumulant2nd0005ALICE_v3,yErrCumulant2nd0005ALICE_v3);
2937     Cumulant2nd0005ALICE_v3->SetMarkerStyle(kFullCircle);
2938     Cumulant2nd0005ALICE_v3->SetMarkerColor(kBlue);
2939
2940     return Cumulant2nd0005ALICE_v3;
2941   }
2942   
2943   if (n == 4)
2944   {
2945     // v4{2}(pt) for 0-5%:
2946     Double_t xCumulant2nd0005ALICE_v4[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2947     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
2948     Double_t yCumulant2nd0005ALICE_v4[] = {0.000000,0.000000,0.006121,0.006137,0.005598,0.005956,0.007262,0.007991,0.009159,0.012062,
2949     0.015085,0.019225,0.024782,0.030092,0.035708,0.046542,0.060077,0.076088,0.082964,0.085405};
2950     Double_t xErrCumulant2nd0005ALICE_v4[20] = {0.};
2951     Double_t yErrCumulant2nd0005ALICE_v4[] = {0.000000,0.000000,0.000275,0.000278,0.000294,0.000319,0.000346,0.000380,0.000419,0.000459,
2952     0.000378,0.000460,0.000570,0.000700,0.000865,0.000789,0.001370,0.002227,0.003370,0.004018};
2953     Int_t nPointsCumulant2nd0005ALICE_v4 = sizeof(xCumulant2nd0005ALICE_v4)/sizeof(Double_t);                                      
2954     TGraphErrors *Cumulant2nd0005ALICE_v4 = new TGraphErrors(nPointsCumulant2nd0005ALICE_v4,xCumulant2nd0005ALICE_v4,yCumulant2nd0005ALICE_v4,
2955                                                           xErrCumulant2nd0005ALICE_v4,yErrCumulant2nd0005ALICE_v4);
2956     Cumulant2nd0005ALICE_v4->SetMarkerStyle(kFullCircle);
2957     Cumulant2nd0005ALICE_v4->SetMarkerColor(kBlue); 
2958     
2959     return Cumulant2nd0005ALICE_v4;
2960   }
2961   
2962   return 0;
2963 }
2964
2965 TGraphErrors* GetFlow510(Int_t n)
2966 {
2967   // private communication 02.02.11, Ante B. / Raimond
2968
2969   if (n == 2)
2970   {
2971     // v2{2}(pt) for 5-10%:
2972     Double_t xCumulant2nd0510ALICE_v2[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2973     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
2974     Double_t yCumulant2nd0510ALICE_v2[] = {0.000000,0.000000,0.019872,0.026451,0.032901,0.039085,0.044930,0.050200,0.054887,0.060253,
2975     0.066587,0.075080,0.083303,0.090298,0.098782,0.109632,0.124486,0.129621,0.132076,0.120697};
2976     Double_t xErrCumulant2nd0510ALICE_v2[20] = {0.};
2977     Double_t yErrCumulant2nd0510ALICE_v2[] = {0.000000,0.000000,0.000150,0.000152,0.000163,0.000178,0.000196,0.000215,0.000237,0.000261,
2978     0.000213,0.000256,0.000313,0.000381,0.000468,0.000423,0.000727,0.001157,0.001741,0.002064};
2979     Int_t nPointsCumulant2nd0510ALICE_v2 = sizeof(xCumulant2nd0510ALICE_v2)/sizeof(Double_t);                                      
2980     TGraphErrors *Cumulant2nd0510ALICE_v2 = new TGraphErrors(nPointsCumulant2nd0510ALICE_v2,xCumulant2nd0510ALICE_v2,yCumulant2nd0510ALICE_v2,
2981                                                           xErrCumulant2nd0510ALICE_v2,yErrCumulant2nd0510ALICE_v2);
2982     Cumulant2nd0510ALICE_v2->SetMarkerStyle(kOpenCircle);
2983     Cumulant2nd0510ALICE_v2->SetMarkerColor(kBlue);   
2984      
2985     return Cumulant2nd0510ALICE_v2;
2986   }
2987   
2988   if (n == 3)
2989   {
2990     // v3{2}(pt) for 5-10%:
2991     Double_t xCumulant2nd0510ALICE_v3[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
2992     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
2993     Double_t yCumulant2nd0510ALICE_v3[] = {0.000000,0.000000,0.008596,0.010700,0.013820,0.017524,0.021507,0.024316,0.028491,0.032880,
2994     0.038741,0.045830,0.052486,0.059560,0.067990,0.081006,0.097402,0.107050,0.111743,0.116434};
2995     Double_t xErrCumulant2nd0510ALICE_v3[20] = {0.};
2996     Double_t yErrCumulant2nd0510ALICE_v3[] = {0.000000,0.000000,0.000208,0.000207,0.000218,0.000235,0.000258,0.000284,0.000314,0.000347,
2997     0.000285,0.000345,0.000426,0.000521,0.000642,0.000586,0.001008,0.001611,0.002421,0.002853};
2998     Int_t nPointsCumulant2nd0510ALICE_v3 = sizeof(xCumulant2nd0510ALICE_v3)/sizeof(Double_t);                                      
2999     TGraphErrors *Cumulant2nd0510ALICE_v3 = new TGraphErrors(nPointsCumulant2nd0510ALICE_v3,xCumulant2nd0510ALICE_v3,yCumulant2nd0510ALICE_v3,
3000                                                           xErrCumulant2nd0510ALICE_v3,yErrCumulant2nd0510ALICE_v3);
3001     Cumulant2nd0510ALICE_v3->SetMarkerStyle(kOpenCircle);
3002     Cumulant2nd0510ALICE_v3->SetMarkerColor(kBlue);
3003     
3004     return Cumulant2nd0510ALICE_v3;
3005   }
3006   
3007   if (n == 4)
3008   {
3009     // v4{2}(pt) for 5-10%:
3010     Double_t xCumulant2nd0510ALICE_v4[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
3011     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
3012     Double_t yCumulant2nd0510ALICE_v4[] = {0.000000,0.000000,0.006466,0.006731,0.006344,0.007374,0.008775,0.010324,0.012323,0.014533,
3013     0.017261,0.022507,0.028776,0.035403,0.041936,0.051491,0.070340,0.080081,0.095077,0.088526};
3014     Double_t xErrCumulant2nd0510ALICE_v4[20] = {0.};
3015     Double_t yErrCumulant2nd0510ALICE_v4[] = {0.000000,0.000000,0.000292,0.000295,0.000312,0.000336,0.000366,0.000403,0.000443,0.000485,
3016     0.000399,0.000486,0.000603,0.000738,0.000914,0.000836,0.001443,0.002303,0.003448,0.004078};
3017     Int_t nPointsCumulant2nd0510ALICE_v4 = sizeof(xCumulant2nd0510ALICE_v4)/sizeof(Double_t);                                      
3018     TGraphErrors *Cumulant2nd0510ALICE_v4 = new TGraphErrors(nPointsCumulant2nd0510ALICE_v4,xCumulant2nd0510ALICE_v4,yCumulant2nd0510ALICE_v4,
3019                                                           xErrCumulant2nd0510ALICE_v4,yErrCumulant2nd0510ALICE_v4);
3020     Cumulant2nd0510ALICE_v4->SetMarkerStyle(kOpenCircle);
3021     Cumulant2nd0510ALICE_v4->SetMarkerColor(kBlue);    
3022     
3023     return Cumulant2nd0510ALICE_v4;
3024   }
3025   
3026   return 0;
3027 }
3028
3029 TGraphErrors* GetFlow1020(Int_t n)
3030 {
3031   // private communication 02.02.11, Ante B. / Raimond
3032
3033   if (n == 2)
3034   {
3035     // v2{2}(pt) for 10-20%:
3036     Double_t xCumulant2nd1020ALICE_v2[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
3037     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
3038     Double_t yCumulant2nd1020ALICE_v2[] = {0.000000,0.000000,0.027683,0.037083,0.046511,0.055519,0.063979,0.071626,0.078537,0.085975,
3039     0.095001,0.106979,0.118456,0.129721,0.140641,0.155161,0.173402,0.179870,0.180616,0.168921};
3040     Double_t xErrCumulant2nd1020ALICE_v2[20] = {0.};
3041     Double_t yErrCumulant2nd1020ALICE_v2[] = {0.000000,0.000000,0.000121,0.000124,0.000134,0.000147,0.000163,0.000179,0.000198,0.000217,
3042     0.000177,0.000212,0.000257,0.000311,0.000380,0.000341,0.000569,0.000882,0.001309,0.001537};
3043     Int_t nPointsCumulant2nd1020ALICE_v2 = sizeof(xCumulant2nd1020ALICE_v2)/sizeof(Double_t);                                      
3044     TGraphErrors *Cumulant2nd1020ALICE_v2 = new TGraphErrors(nPointsCumulant2nd1020ALICE_v2,xCumulant2nd1020ALICE_v2,yCumulant2nd1020ALICE_v2,
3045                                                           xErrCumulant2nd1020ALICE_v2,yErrCumulant2nd1020ALICE_v2);
3046     Cumulant2nd1020ALICE_v2->SetMarkerStyle(kFullSquare);
3047     Cumulant2nd1020ALICE_v2->SetMarkerColor(kRed);     
3048     
3049     return Cumulant2nd1020ALICE_v2;
3050   }
3051   
3052   if (n == 3)
3053   {
3054     // v3{2}(pt) for 10-20%:
3055     Double_t xCumulant2nd1020ALICE_v3[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
3056     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
3057     Double_t yCumulant2nd1020ALICE_v3[] = {0.000000,0.000000,0.009830,0.012858,0.016111,0.020120,0.023948,0.028349,0.032741,0.037244,
3058     0.043385,0.051803,0.059374,0.068686,0.076763,0.090151,0.106530,0.117448,0.121383,0.118247};
3059     Double_t xErrCumulant2nd1020ALICE_v3[20] = {0.};
3060     Double_t yErrCumulant2nd1020ALICE_v3[] = {0.000000,0.000000,0.000171,0.000170,0.000180,0.000195,0.000215,0.000236,0.000261,0.000287,
3061     0.000236,0.000288,0.000353,0.000434,0.000536,0.000488,0.000823,0.001277,0.001892,0.002224};
3062     Int_t nPointsCumulant2nd1020ALICE_v3 = sizeof(xCumulant2nd1020ALICE_v3)/sizeof(Double_t);                                      
3063     TGraphErrors *Cumulant2nd1020ALICE_v3 = new TGraphErrors(nPointsCumulant2nd1020ALICE_v3,xCumulant2nd1020ALICE_v3,yCumulant2nd1020ALICE_v3,
3064                                                           xErrCumulant2nd1020ALICE_v3,yErrCumulant2nd1020ALICE_v3);
3065     Cumulant2nd1020ALICE_v3->SetMarkerStyle(kFullSquare);
3066     Cumulant2nd1020ALICE_v3->SetMarkerColor(kRed); 
3067     
3068     return Cumulant2nd1020ALICE_v3;
3069   }
3070   
3071   if (n == 4)
3072   {
3073     // v4{2}(pt) for 10-20%:
3074     Double_t xCumulant2nd1020ALICE_v4[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
3075     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
3076     Double_t yCumulant2nd1020ALICE_v4[] = {0.000000,0.000000,0.007423,0.007647,0.008189,0.008592,0.009489,0.011671,0.013739,0.017199,
3077     0.020084,0.026004,0.031843,0.038388,0.047357,0.057251,0.072433,0.086326,0.094282,0.097432};
3078     Double_t xErrCumulant2nd1020ALICE_v4[20] = {0.};
3079     Double_t yErrCumulant2nd1020ALICE_v4[] = {0.000000,0.000000,0.000243,0.000244,0.000257,0.000279,0.000306,0.000335,0.000368,0.000405,
3080     0.000333,0.000406,0.000502,0.000618,0.000770,0.000701,0.001185,0.001845,0.002730,0.003193};
3081     Int_t nPointsCumulant2nd1020ALICE_v4 = sizeof(xCumulant2nd1020ALICE_v4)/sizeof(Double_t);                                      
3082     TGraphErrors *Cumulant2nd1020ALICE_v4 = new TGraphErrors(nPointsCumulant2nd1020ALICE_v4,xCumulant2nd1020ALICE_v4,yCumulant2nd1020ALICE_v4,
3083                                                           xErrCumulant2nd1020ALICE_v4,yErrCumulant2nd1020ALICE_v4);
3084     Cumulant2nd1020ALICE_v4->SetMarkerStyle(kFullSquare);
3085     Cumulant2nd1020ALICE_v4->SetMarkerColor(kRed); 
3086         
3087     return Cumulant2nd1020ALICE_v4;
3088   }
3089   
3090   return 0;
3091 }
3092
3093 TGraphErrors* GetFlow2030(Int_t n)
3094 {
3095   // private communication 02.02.11, Ante B. / Raimond
3096
3097   if (n == 2)
3098   {
3099     Double_t xCumulant2nd2030ALICE_v2[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
3100     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
3101     Double_t yCumulant2nd2030ALICE_v2[] = {0.000000,0.000000,0.035557,0.048064,0.060768,0.072585,0.083808,0.093772,0.103310,0.112602,
3102     0.124846,0.140603,0.155345,0.169450,0.183077,0.200173,0.219693,0.225741,0.223318,0.207356};
3103     Double_t xErrCumulant2nd2030ALICE_v2[20] = {0.};
3104     Double_t yErrCumulant2nd2030ALICE_v2[] = {0.000000,0.000000,0.000144,0.000147,0.000159,0.000175,0.000194,0.000214,0.000235,0.000259,
3105     0.000211,0.000254,0.000310,0.000377,0.000464,0.000418,0.000677,0.001027,0.001513,0.001761};
3106     Int_t nPointsCumulant2nd2030ALICE_v2 = sizeof(xCumulant2nd2030ALICE_v2)/sizeof(Double_t);                                      
3107     TGraphErrors *Cumulant2nd2030ALICE_v2 = new TGraphErrors(nPointsCumulant2nd2030ALICE_v2,xCumulant2nd2030ALICE_v2,yCumulant2nd2030ALICE_v2,
3108                                                           xErrCumulant2nd2030ALICE_v2,yErrCumulant2nd2030ALICE_v2);
3109     Cumulant2nd2030ALICE_v2->SetMarkerStyle(kOpenSquare);
3110     Cumulant2nd2030ALICE_v2->SetMarkerColor(kRed); 
3111         
3112     return Cumulant2nd2030ALICE_v2;
3113   }
3114   
3115   if (n == 3)
3116   {
3117     // v3{2}(pt) for 20-30%:
3118     Double_t xCumulant2nd2030ALICE_v3[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
3119     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
3120     Double_t yCumulant2nd2030ALICE_v3[] = {0.000000,0.000000,0.011287,0.014937,0.018479,0.022962,0.027854,0.031938,0.037038,0.041443,
3121     0.049872,0.058720,0.068353,0.077692,0.087859,0.099863,0.116141,0.124486,0.124786,0.119520};
3122     Double_t xErrCumulant2nd2030ALICE_v3[20] = {0.};
3123     Double_t yErrCumulant2nd2030ALICE_v3[] = {0.000000,0.000000,0.000215,0.000216,0.000228,0.000248,0.000272,0.000300,0.000332,0.000366,
3124     0.000301,0.000369,0.000456,0.000561,0.000700,0.000636,0.001038,0.001574,0.002307,0.002676};
3125     Int_t nPointsCumulant2nd2030ALICE_v3 = sizeof(xCumulant2nd2030ALICE_v3)/sizeof(Double_t);                                      
3126     TGraphErrors *Cumulant2nd2030ALICE_v3 = new TGraphErrors(nPointsCumulant2nd2030ALICE_v3,xCumulant2nd2030ALICE_v3,yCumulant2nd2030ALICE_v3,
3127                                                           xErrCumulant2nd2030ALICE_v3,yErrCumulant2nd2030ALICE_v3);
3128     Cumulant2nd2030ALICE_v3->SetMarkerStyle(kOpenSquare);
3129     Cumulant2nd2030ALICE_v3->SetMarkerColor(kRed); 
3130     
3131     return Cumulant2nd2030ALICE_v3;
3132   }
3133   
3134   if (n == 4)
3135   {
3136     // v4{2}(pt) for 20-30%:
3137     Double_t xCumulant2nd2030ALICE_v4[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
3138     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
3139     Double_t yCumulant2nd2030ALICE_v4[] = {0.000000,0.000000,0.008435,0.009824,0.009387,0.010408,0.011458,0.013770,0.016335,0.019165,
3140     0.023770,0.030071,0.036231,0.043950,0.051803,0.065222,0.082155,0.091864,0.105061,0.105167};
3141     Double_t xErrCumulant2nd2030ALICE_v4[20] = {0.};
3142     Double_t yErrCumulant2nd2030ALICE_v4[] = {0.000000,0.000000,0.000308,0.000308,0.000328,0.000355,0.000391,0.000430,0.000473,0.000524,
3143     0.000430,0.000524,0.000652,0.000807,0.001006,0.000919,0.001502,0.002277,0.003339,0.003871};
3144     Int_t nPointsCumulant2nd2030ALICE_v4 = sizeof(xCumulant2nd2030ALICE_v4)/sizeof(Double_t);                                      
3145     TGraphErrors *Cumulant2nd2030ALICE_v4 = new TGraphErrors(nPointsCumulant2nd2030ALICE_v4,xCumulant2nd2030ALICE_v4,yCumulant2nd2030ALICE_v4,
3146                                                           xErrCumulant2nd2030ALICE_v4,yErrCumulant2nd2030ALICE_v4);
3147     Cumulant2nd2030ALICE_v4->SetMarkerStyle(kOpenSquare);
3148     Cumulant2nd2030ALICE_v4->SetMarkerColor(kRed); 
3149         
3150     return Cumulant2nd2030ALICE_v4;
3151   }
3152   
3153   return 0;
3154 }
3155
3156 TGraphErrors* GetFlow3040(Int_t n)
3157 {
3158   // private communication 02.02.11, Ante B. / Raimond
3159
3160   if (n == 2)
3161   {
3162     // v2{2}(pt) for 30-40%:
3163     Double_t xCumulant2nd3040ALICE_v2[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
3164     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
3165     Double_t yCumulant2nd3040ALICE_v2[] = {0.000000,0.000000,0.040797,0.055427,0.070543,0.084024,0.096562,0.109411,0.119853,0.130964,
3166     0.145377,0.163806,0.179825,0.196178,0.210377,0.226556,0.245686,0.247898,0.240058,0.225011};
3167     Double_t xErrCumulant2nd3040ALICE_v2[20] = {0.};
3168     Double_t yErrCumulant2nd3040ALICE_v2[] = {0.000000,0.000000,0.000177,0.000182,0.000197,0.000216,0.000239,0.000265,0.000293,0.000325,
3169     0.000266,0.000321,0.000395,0.000486,0.000603,0.000536,0.000840,0.001258,0.001843,0.002118};
3170     Int_t nPointsCumulant2nd3040ALICE_v2 = sizeof(xCumulant2nd3040ALICE_v2)/sizeof(Double_t);                                      
3171     TGraphErrors *Cumulant2nd3040ALICE_v2 = new TGraphErrors(nPointsCumulant2nd3040ALICE_v2,xCumulant2nd3040ALICE_v2,yCumulant2nd3040ALICE_v2,
3172                                                           xErrCumulant2nd3040ALICE_v2,yErrCumulant2nd3040ALICE_v2);
3173     Cumulant2nd3040ALICE_v2->SetMarkerStyle(kFullTriangleUp);
3174     Cumulant2nd3040ALICE_v2->SetMarkerSize(1.2);
3175     Cumulant2nd3040ALICE_v2->SetMarkerColor(kGreen+2);     
3176     
3177     return Cumulant2nd3040ALICE_v2;
3178   }
3179   
3180   if (n == 3)
3181   {
3182     // v3{2}(pt) for 30-40%:
3183     Double_t xCumulant2nd3040ALICE_v3[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
3184     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
3185     Double_t yCumulant2nd3040ALICE_v3[] = {0.000000,0.000000,0.012226,0.016391,0.020792,0.026208,0.030380,0.035710,0.041025,0.047062,
3186     0.053075,0.064201,0.074116,0.085314,0.094391,0.106819,0.124012,0.129388,0.134315,0.132330};
3187     Double_t xErrCumulant2nd3040ALICE_v3[20] = {0.};
3188     Double_t yErrCumulant2nd3040ALICE_v3[] = {0.000000,0.000000,0.000284,0.000286,0.000303,0.000329,0.000364,0.000403,0.000443,0.000492,
3189     0.000408,0.000500,0.000627,0.000778,0.000973,0.000874,0.001375,0.002050,0.002992,0.003438};
3190     Int_t nPointsCumulant2nd3040ALICE_v3 = sizeof(xCumulant2nd3040ALICE_v3)/sizeof(Double_t);                                      
3191     TGraphErrors *Cumulant2nd3040ALICE_v3 = new TGraphErrors(nPointsCumulant2nd3040ALICE_v3,xCumulant2nd3040ALICE_v3,yCumulant2nd3040ALICE_v3,
3192                                                           xErrCumulant2nd3040ALICE_v3,yErrCumulant2nd3040ALICE_v3);
3193     Cumulant2nd3040ALICE_v3->SetMarkerStyle(kFullTriangleUp);
3194     Cumulant2nd3040ALICE_v3->SetMarkerSize(1.2);
3195     Cumulant2nd3040ALICE_v3->SetMarkerColor(kGreen+2); 
3196     
3197     return Cumulant2nd3040ALICE_v3;
3198   }
3199   
3200   if (n == 4)
3201   {
3202     // v4{2}(pt) for 30-40%:
3203     Double_t xCumulant2nd3040ALICE_v4[] = {0.050000,0.150000,0.250000,0.350000,0.450000,0.550000,0.650000,0.750000,0.850000,0.950000,
3204     1.100000,1.300000,1.500000,1.700000,1.900000,2.250000,2.750000,3.250000,3.750000,4.500000};
3205     Double_t yCumulant2nd3040ALICE_v4[] = {0.000000,0.000000,0.010718,0.011490,0.010994,0.012527,0.013748,0.016425,0.018857,0.021622,
3206     0.026853,0.034636,0.042651,0.049892,0.057795,0.070865,0.088486,0.101656,0.113886,0.118202};
3207     Double_t xErrCumulant2nd3040ALICE_v4[20] = {0.};
3208     Double_t yErrCumulant2nd3040ALICE_v4[] = {0.000000,0.000000,0.000401,0.000406,0.000433,0.000472,0.000521,0.000575,0.000634,0.000704,
3209     0.000580,0.000714,0.000890,0.001114,0.001398,0.001253,0.001974,0.002945,0.004290,0.004909};
3210     Int_t nPointsCumulant2nd3040ALICE_v4 = sizeof(xCumulant2nd3040ALICE_v4)/sizeof(Double_t);                                      
3211     TGraphErrors *Cumulant2nd3040ALICE_v4 = new TGraphErrors(nPointsCumulant2nd3040ALICE_v4,xCumulant2nd3040ALICE_v4,yCumulant2nd3040ALICE_v4,
3212                                                           xErrCumulant2nd3040ALICE_v4,yErrCumulant2nd3040ALICE_v4);
3213     Cumulant2nd3040ALICE_v4->SetMarkerStyle(kFullTriangleUp);
321