]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/scripts/DrawFlowPDF.C
f4190d18e1f00c4c5fb077c10becdc92c9130eb8
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / scripts / DrawFlowPDF.C
1 #include <TFile.h>
2 #include <TProfile.h>
3 #include <TList.h>
4 #include <TError.h>
5 #include <TCanvas.h>
6 #include <TPad.h>
7 #include <TStyle.h>
8 #include <TLegend.h>
9 #include <TMath.h>
10 #include <TLatex.h>
11
12 // Data members
13 const char* pdfName = "Flow.pdf";
14
15 TCanvas* SetupCanvas(TString name)
16 {
17   TCanvas* c = new TCanvas("c","c",640,960);
18
19   c->SetFillColor(0);
20   c->SetBorderMode(0);
21   c->SetBorderSize(0);
22   c->cd();
23
24   if (name.Contains("Monitoring")) return c;
25
26   TPad* p1 = new TPad("p1", "p1", 0, 0.5, 1.0, 1.0, 0, 0);
27   p1->SetTopMargin(0.1);
28   p1->SetBottomMargin(0.1);
29   p1->SetRightMargin(0.05);
30   p1->SetGridx();
31   p1->SetTicks(1, 1);
32   p1->Draw();
33   p1->cd();
34
35   TProfile* p = new TProfile(name, "p", 48, -6, 6);
36   p->GetYaxis()->SetRangeUser(0, 0.083);
37   p->GetXaxis()->SetTitleFont(22);
38   p->GetXaxis()->SetLabelFont(22);
39   p->GetYaxis()->SetTitleFont(22);
40   p->GetYaxis()->SetLabelFont(22);
41   p->SetXTitle("#eta");
42   p->SetYTitle("v_{2}");
43   p->Draw();
44
45   TLatex* pt = new TLatex(.12, .87, "FMD Preliminary");
46   pt->SetNDC();
47   pt->SetTextFont(22);
48   pt->SetTextSize(0.07);
49   pt->SetTextColor(kRed+1);
50   pt->SetTextAlign(13);
51   pt->Draw();
52
53   c->cd();
54
55   TPad* p2 = new TPad("p2", "p2", 0, 0.25, 1.0, 0.5, 0, 0);
56   p2->SetTopMargin(0.);
57   p2->SetRightMargin(0.05);
58   p2->SetBottomMargin(0.2);
59   p2->SetGridx();
60   p2->SetGridy();
61   p2->SetTicks(1,1);
62   p2->Draw();
63   p2->cd();
64
65   TProfile* pp = new TProfile(Form("%s_diff", name.Data()), "p", 48, -6, 6);
66   pp->GetXaxis()->SetTitleFont(22);
67   pp->GetXaxis()->SetLabelFont(22);
68   pp->GetYaxis()->SetTitleFont(22);
69   pp->GetYaxis()->SetLabelFont(22);
70   pp->SetXTitle("#eta");
71   if ( name.Contains("MC")) {
72     pp->SetYTitle("measured / truth");
73     pp->GetYaxis()->SetRangeUser(0.51, 1.15);
74   }
75   if (!name.Contains("MC")) {
76     pp->SetYTitle("v_{2}{2} / v_{2}{4}");
77     pp->GetYaxis()->SetRangeUser(0.98, 1.17);
78   }
79   pp->GetXaxis()->SetTitleSize(2.*p->GetXaxis()->GetTitleSize());
80   pp->GetXaxis()->SetLabelSize(2.*p->GetXaxis()->GetLabelSize());
81   pp->GetYaxis()->SetTitleSize(2.*p->GetYaxis()->GetTitleSize());
82   pp->GetYaxis()->SetLabelSize(2.*p->GetYaxis()->GetLabelSize());
83   pp->GetYaxis()->SetTitleOffset(0.5);
84   pp->Draw();
85
86   TF1* oneLine = new TF1("oneLine","1",-6,6);
87   oneLine->SetLineWidth(0.5);
88   oneLine->Draw("same");
89
90   if (!name.Contains("MC")) return c;
91
92   c->cd();
93
94   TPad* p3 = new TPad("p3", "p3", 0, 0, 1.0, 0.25, 0, 0);
95   p3->SetTopMargin(0.);
96   p3->SetRightMargin(0.05);
97   p3->SetBottomMargin(0.2);
98   p3->SetGridx();
99   p3->SetGridy();
100   p3->SetTicks(1,1);
101   p3->Draw();
102   p3->cd();
103
104   TProfile* ppp = new TProfile(Form("%s_trdiff", name.Data()), "p", 48, -6, 6);
105   ppp->GetXaxis()->SetTitleFont(22);
106   ppp->GetXaxis()->SetLabelFont(22);
107   ppp->GetYaxis()->SetTitleFont(22);
108   ppp->GetYaxis()->SetLabelFont(22);
109   ppp->GetYaxis()->SetRangeUser(0.66, 1.19);
110   ppp->SetXTitle("#eta");
111   ppp->SetYTitle("measured / track ref");
112   ppp->GetXaxis()->SetTitleSize(2.*p->GetXaxis()->GetTitleSize());
113   ppp->GetXaxis()->SetLabelSize(2.*p->GetXaxis()->GetLabelSize());
114   ppp->GetYaxis()->SetTitleSize(2.*p->GetYaxis()->GetTitleSize());
115   ppp->GetYaxis()->SetLabelSize(2.*p->GetYaxis()->GetLabelSize());
116   ppp->GetYaxis()->SetTitleOffset(0.5);
117   ppp->Draw();
118
119   oneLine->Draw("same");
120
121   return c;
122 }
123
124 void MakeFmdAndSpdPlots(TFile* f) 
125 {
126   TList* qList = static_cast<TList*>(f->Get("FlowResults/QCumulants"));
127   TList* aList = static_cast<TList*>(qList->FindObject("FMD"));
128   TList* fmdList = static_cast<TList*>(aList->FindObject("v2"));
129   aList = static_cast<TList*>(qList->FindObject("SPD"));
130   TList* spdList = static_cast<TList*>(aList->FindObject("v2"));
131
132   TPad*     pad = 0;
133    
134   Int_t y[11] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 100 };
135   for (Int_t c = -2; c < 10; c++) {
136     TProfile* fmd2DiffHist = 0;
137     TProfile* spd2DiffHist = 0;
138     TProfile* fmd4DiffHist = 0;
139     TProfile* spd4DiffHist = 0;
140     TH1D*       fmdDiff = 0;
141     TH1D*       spdDiff = 0;
142     TH1D*       fmd = 0;
143     TH1D*       spd = 0;
144  
145      if (c == -2) {
146       fmd2DiffHist = (TProfile*)fmdList->FindObject("hQ2Cumulant2DiffFlowFMD_mb");
147       spd2DiffHist = (TProfile*)spdList->FindObject("hQ2Cumulant2DiffFlowSPD_mb");
148       fmd4DiffHist = (TProfile*)fmdList->FindObject("hQ2Cumulant4DiffFlowFMD_mb");
149       spd4DiffHist = (TProfile*)spdList->FindObject("hQ2Cumulant4DiffFlowSPD_mb");
150     }
151     else if (c == -1) {
152       fmd2DiffHist = (TProfile*)fmdList->FindObject("hQ2Cumulant2DiffFlowFMD_0_40");
153       spd2DiffHist = (TProfile*)spdList->FindObject("hQ2Cumulant2DiffFlowSPD_0_40");
154       fmd4DiffHist = (TProfile*)fmdList->FindObject("hQ2Cumulant4DiffFlowFMD_0_40");
155       spd4DiffHist = (TProfile*)spdList->FindObject("hQ2Cumulant4DiffFlowSPD_0_40");
156     }
157     else {
158       fmd2DiffHist = (TProfile*)fmdList->FindObject(Form("hQ2Cumulant2DiffFlowFMD_%d_%d", y[c], y[c+1]));
159       spd2DiffHist = (TProfile*)spdList->FindObject(Form("hQ2Cumulant2DiffFlowSPD_%d_%d", y[c], y[c+1]));
160       fmd4DiffHist = (TProfile*)fmdList->FindObject(Form("hQ2Cumulant4DiffFlowFMD_%d_%d", y[c], y[c+1]));
161       spd4DiffHist = (TProfile*)spdList->FindObject(Form("hQ2Cumulant4DiffFlowSPD_%d_%d", y[c], y[c+1]));
162     }
163     
164     TString name = "v_{2}{2} and v_{2}{4} ";
165     if (c == -2)      name += "Minimum Bias";
166     else if (c == -1) name += "0-40% Centrality"; 
167     else {
168                       name += TString::Format("%d-%d", y[c], y[c+1]);
169                       name += "% Centrality";
170     }
171
172     TCanvas* c1 = SetupCanvas(name);
173     pad = (TPad*)c1->GetPrimitive("p1");
174     pad->cd();
175     
176     TLatex* tit = new TLatex(0.10, 0.95, name);
177     tit->SetNDC();
178     tit->SetTextFont(132);
179     tit->SetTextSize(0.07);
180     tit->Draw();
181
182     Int_t nEvs = (Int_t)fmd2DiffHist->GetBinContent(fmd2DiffHist->GetNbinsX()+1);
183     TLatex* et = new TLatex(.93, .87, Form("%d events", nEvs));
184     et->SetNDC();
185     et->SetTextFont(132);
186     et->SetTextAlign(33);
187     et->Draw();
188
189     fmd2DiffHist->SetMarkerStyle(22);
190     spd2DiffHist->SetMarkerStyle(23);
191     fmd4DiffHist->SetMarkerStyle(22);
192     spd4DiffHist->SetMarkerStyle(23);
193
194     fmd2DiffHist->SetMarkerColor(kRed);
195     spd2DiffHist->SetMarkerColor(kRed);
196     fmd4DiffHist->SetMarkerColor(kBlue);
197     spd4DiffHist->SetMarkerColor(kBlue);
198
199     fmd2DiffHist->SetLineColor(kRed);
200     spd2DiffHist->SetLineColor(kRed);
201     fmd4DiffHist->SetLineColor(kBlue);
202     spd4DiffHist->SetLineColor(kBlue);
203
204     spd2DiffHist->Draw("same e1");
205     fmd2DiffHist->Draw("same e1");
206     spd4DiffHist->Draw("same e1");
207     fmd4DiffHist->Draw("same e1");
208
209     TLegend* l = new TLegend(.12,.40,.35,.80);
210 //    l->SetNColumns(2);
211     l->SetFillColor(0);
212     l->SetFillStyle(0);
213     l->SetBorderSize(0);
214     l->SetTextFont(132);
215     l->AddEntry(fmd2DiffHist, "FMD v_{2}{2}", "lpe");
216     l->AddEntry(spd2DiffHist, "SPD v_{2}{2}", "lpe");
217     l->AddEntry(fmd4DiffHist, "FMD v_{2}{4}", "lpe");
218     l->AddEntry(spd4DiffHist, "SPD v_{2}{4}", "lpe");
219     l->Draw();
220
221     pad = (TPad*)c1->GetPrimitive("p2");
222     pad->cd();
223
224     fmdDiff = fmd2DiffHist->ProjectionX("fmdDiff", "e");
225     fmd = fmd4DiffHist->ProjectionX("fmd4Diff", "e");
226     fmdDiff->Divide(fmd);
227     fmdDiff->SetLineColor(kBlue);
228     fmdDiff->Draw("same e1");
229
230     spdDiff = spd2DiffHist->ProjectionX("spdDiff", "e");
231     spd = spd4DiffHist->ProjectionX("spd4Diff", "e");
232     spdDiff->Divide(spd);
233     spdDiff->SetLineColor(kRed);
234     spdDiff->Draw("same e1");
235
236     name.Prepend("Title:");
237     cout<<name<<endl;
238     c1->Print(pdfName, name);
239
240     delete fmd;
241     delete spd;
242     delete fmdDiff;
243     delete spdDiff;
244     delete c1;
245    } // end of c
246 }
247
248 void Make2ParticlePlots(TFile* f) 
249 {
250   TList* qList = static_cast<TList*>(f->Get("FlowResults/QCumulants"));
251   TList* aList = static_cast<TList*>(qList->FindObject("MC"));
252   TList* mcList = static_cast<TList*>(aList->FindObject("v2"));
253   aList = static_cast<TList*>(qList->FindObject("FMDTR"));
254   TList* fmdtrList = static_cast<TList*>(aList->FindObject("v2"));
255   aList = static_cast<TList*>(qList->FindObject("SPDTR"));
256   TList* spdtrList = static_cast<TList*>(aList->FindObject("v2"));
257   aList = static_cast<TList*>(qList->FindObject("FMD"));
258   TList* fmdList = static_cast<TList*>(aList->FindObject("v2"));
259   aList = static_cast<TList*>(qList->FindObject("SPD"));
260   TList* spdList = static_cast<TList*>(aList->FindObject("v2"));
261
262   TProfile2D* mcProfile = (TProfile2D*)qList->FindObject("pMCTruth");
263   TPad*       pad = 0;
264
265   Int_t y[11] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 100 };
266   for (Int_t c = -2; c < 10; c++) {
267     TProfile*   mcDiffHist = 0;
268     TProfile*   fmdtrDiffHist = 0;
269     TProfile*   spdtrDiffHist = 0;
270     TProfile*   fmdDiffHist = 0;
271     TProfile*   spdDiffHist = 0;
272     TH1D*       mcTruth = 0;
273     TH1D*       fmdDiff = 0;
274     TH1D*       spdDiff = 0;
275     TH1D*       fmdTrDiff = 0;
276     TH1D*       spdTrDiff = 0;
277
278     if (c == -2) {
279       mcDiffHist = (TProfile*)mcList->FindObject("hQ2Cumulant2DiffFlowMC_mb");
280       fmdtrDiffHist = (TProfile*)fmdtrList->FindObject("hQ2Cumulant2DiffFlowFMDTR_mb");
281       spdtrDiffHist = (TProfile*)spdtrList->FindObject("hQ2Cumulant2DiffFlowSPDTR_mb");
282       fmdDiffHist = (TProfile*)fmdList->FindObject("hQ2Cumulant2DiffFlowFMD_mb");
283       spdDiffHist = (TProfile*)spdList->FindObject("hQ2Cumulant2DiffFlowSPD_mb");
284       mcTruth = (TH1D*)mcProfile->ProjectionX("mcTruth", 1, 9, "E");
285       mcTruth->Scale(1./9.);
286     }
287     else if (c == -1) {
288       mcDiffHist = (TProfile*)mcList->FindObject("hQ2Cumulant2DiffFlowMC_0_40");
289       fmdtrDiffHist = (TProfile*)fmdtrList->FindObject("hQ2Cumulant2DiffFlowFMDTR_0_40");
290       spdtrDiffHist = (TProfile*)spdtrList->FindObject("hQ2Cumulant2DiffFlowSPDTR_0_40");
291       fmdDiffHist = (TProfile*)fmdList->FindObject("hQ2Cumulant2DiffFlowFMD_0_40");
292       spdDiffHist = (TProfile*)spdList->FindObject("hQ2Cumulant2DiffFlowSPD_0_40");
293       mcTruth = (TH1D*)mcProfile->ProjectionX("mcTruth", 1, 5, "E");
294       mcTruth->Scale(1./5.);
295     }
296     else {
297       mcDiffHist = (TProfile*)mcList->FindObject(Form("hQ2Cumulant2DiffFlowMC_%d_%d", y[c], y[c+1]));
298       fmdtrDiffHist = (TProfile*)fmdtrList->FindObject(Form("hQ2Cumulant2DiffFlowFMDTR_%d_%d", y[c], y[c+1]));
299       spdtrDiffHist = (TProfile*)spdtrList->FindObject(Form("hQ2Cumulant2DiffFlowSPDTR_%d_%d", y[c], y[c+1]));
300       fmdDiffHist = (TProfile*)fmdList->FindObject(Form("hQ2Cumulant2DiffFlowFMD_%d_%d", y[c], y[c+1]));
301       spdDiffHist = (TProfile*)spdList->FindObject(Form("hQ2Cumulant2DiffFlowSPD_%d_%d", y[c], y[c+1]));
302       mcTruth = (TH1D*)mcProfile->ProjectionX("mcTruth", c+1, c+1, "E");
303     }
304
305     TString name = "v_{2}{2} MC ";
306     if (c == -2)      name += "Minimum Bias";
307     else if (c == -1) name += "0-40% Centrality"; 
308     else {
309                       name += TString::Format("%d-%d", y[c], y[c+1]);
310                       name += "% Centrality";
311     }
312     
313     TCanvas* c1 = SetupCanvas(name);
314     pad = (TPad*)c1->GetPrimitive("p1");
315     pad->cd();
316
317     TLatex* tit = new TLatex(0.10, 0.95, name);
318     tit->SetNDC();
319     tit->SetTextFont(132);
320     tit->SetTextSize(0.07);
321     tit->Draw();
322
323     Int_t nEvs = (Int_t)fmdDiffHist->GetBinContent(fmdDiffHist->GetNbinsX()+1);
324     TLatex* et = new TLatex(.93, .87, Form("%d events", nEvs));
325     et->SetNDC();
326     et->SetTextFont(132);
327     et->SetTextAlign(33);
328     et->Draw();
329
330     mcDiffHist->SetMarkerStyle(21);
331     fmdDiffHist->SetLineColor(kBlue);
332     spdDiffHist->SetLineColor(kRed);
333     fmdtrDiffHist->SetLineColor(kGreen+1);
334     spdtrDiffHist->SetLineColor(kCyan+1);
335     mcTruth->SetFillColor(kGray);
336
337     mcTruth->Draw("same e3");
338     mcDiffHist->Draw("same e1");
339     fmdDiffHist->Draw("same e1");
340     spdDiffHist->Draw("same e1");
341     fmdtrDiffHist->Draw("same e1");
342     spdtrDiffHist->Draw("same e1");
343  
344     TLegend* l = new TLegend(.12,.40,.35,.80);
345     l->SetFillColor(0);
346     l->SetFillStyle(0);
347     l->SetBorderSize(0);
348     l->SetTextFont(132);
349     l->AddEntry(fmdDiffHist, "FMD", "lpe");
350     l->AddEntry(spdDiffHist, "SPD", "lpe");
351     l->AddEntry(fmdtrDiffHist, "FMD TrackRefs", "lpe");
352     l->AddEntry(spdtrDiffHist, "SPD TrackRefs", "lpe");
353     l->AddEntry(mcDiffHist, "MC Truth", "lpe");
354     l->AddEntry(mcTruth, "cos(2(#varphi-#Psi_{rp}))", "f");
355     l->Draw();
356
357     pad = (TPad*)c1->GetPrimitive("p2");
358     pad->cd();
359
360     fmdDiff = fmdDiffHist->ProjectionX("fmdDiff", "e");
361     mcDiff1 = mcDiffHist->ProjectionX("mcDiff1", "e");
362     fmdDiff->Divide(mcDiff1);
363     fmdDiff->SetLineColor(kBlue);
364     fmdDiff->Draw("same e1");
365
366     spdDiff = spdDiffHist->ProjectionX("spdDiff", "e");
367     mcDiff2 = mcDiffHist->ProjectionX("mcDiff2", "e");
368     spdDiff->Divide(mcDiff2);
369     spdDiff->SetLineColor(kRed);
370     spdDiff->Draw("same e1");
371
372     pad = (TPad*)c1->GetPrimitive("p3");
373     pad->cd();
374
375     fmdTrDiff = fmdDiffHist->ProjectionX("fmdTrDiff", "e");
376     mcDiff3 = fmdtrDiffHist->ProjectionX("mcDiff3", "e");
377     fmdTrDiff->Divide(mcDiff3);
378     fmdTrDiff->SetLineColor(kBlue);
379     fmdTrDiff->Draw("same e1");
380
381     spdTrDiff = spdDiffHist->ProjectionX("spdTrDiff", "e");
382     mcDiff4 = spdtrDiffHist->ProjectionX("mcDiff4", "e");
383     spdTrDiff->Divide(mcDiff4);
384     spdTrDiff->SetLineColor(kRed);
385     spdTrDiff->Draw("same e1");
386
387     name.Prepend("Title:");
388     cout<<name<<endl;
389     c1->Print(pdfName, name);
390   
391     delete mcDiff1;
392     delete mcDiff2;
393     delete mcDiff3;
394     delete mcDiff4; 
395     delete fmdDiff;
396     delete spdDiff;
397     delete fmdTrDiff;
398     delete spdTrDiff;
399     delete c1;
400    } // end of c
401 }
402
403 void Make4ParticlePlots(TFile* f) 
404 {
405   TList* qList = static_cast<TList*>(f->Get("FlowResults/QCumulants"));
406   TList* aList = static_cast<TList*>(qList->FindObject("MC"));
407   TList* mcList = static_cast<TList*>(aList->FindObject("v2"));
408   aList = static_cast<TList*>(qList->FindObject("FMDTR"));
409   TList* fmdtrList = static_cast<TList*>(aList->FindObject("v2"));
410   aList = static_cast<TList*>(qList->FindObject("SPDTR"));
411   TList* spdtrList = static_cast<TList*>(aList->FindObject("v2"));
412   aList = static_cast<TList*>(qList->FindObject("FMD"));
413   TList* fmdList = static_cast<TList*>(aList->FindObject("v2"));
414   aList = static_cast<TList*>(qList->FindObject("SPD"));
415   TList* spdList = static_cast<TList*>(aList->FindObject("v2"));
416
417   TProfile2D* mcProfile = (TProfile2D*)qList->FindObject("pMCTruth");
418   TPad*       pad = 0;
419  
420   Int_t y[11] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 100 };
421   for (Int_t c = -2; c < 10; c++) {
422     TProfile* mcDiffHist = 0;
423     TProfile* fmdtrDiffHist = 0;
424     TProfile* spdtrDiffHist = 0;
425     TProfile* fmdDiffHist = 0;
426     TProfile* spdDiffHist = 0;
427     TH1D*       mcTruth = 0;
428     TH1D*       fmdDiff = 0;
429     TH1D*       spdDiff = 0;
430     TH1D*       fmdTrDiff = 0;
431     TH1D*       spdTrDiff = 0;
432     TH1D*       mcDiff1 = 0;
433     TH1D*       mcDiff2 = 0;
434     TH1D*       mcDiff3 = 0;
435     TH1D*       mcDiff4 = 0;
436
437     if (c == -2) {
438       mcDiffHist = (TProfile*)mcList->FindObject("hQ2Cumulant4DiffFlowMC_mb");
439       fmdtrDiffHist = (TProfile*)fmdtrList->FindObject("hQ2Cumulant4DiffFlowFMDTR_mb");
440       spdtrDiffHist = (TProfile*)spdtrList->FindObject("hQ2Cumulant4DiffFlowSPDTR_mb");
441       fmdDiffHist = (TProfile*)fmdList->FindObject("hQ2Cumulant4DiffFlowFMD_mb");
442       spdDiffHist = (TProfile*)spdList->FindObject("hQ2Cumulant4DiffFlowSPD_mb");
443       mcTruth = (TH1D*)mcProfile->ProjectionX("mcTruth", 1, 9, "E");
444       mcTruth->Scale(1./9.);
445     }
446     else if (c == -1) {
447       mcDiffHist = (TProfile*)mcList->FindObject("hQ2Cumulant4DiffFlowMC_0_40");
448       fmdtrDiffHist = (TProfile*)fmdtrList->FindObject("hQ2Cumulant4DiffFlowFMDTR_0_40");
449       spdtrDiffHist = (TProfile*)spdtrList->FindObject("hQ2Cumulant4DiffFlowSPDTR_0_40");
450       fmdDiffHist = (TProfile*)fmdList->FindObject("hQ2Cumulant4DiffFlowFMD_0_40");
451       spdDiffHist = (TProfile*)spdList->FindObject("hQ2Cumulant4DiffFlowSPD_0_40");
452       mcTruth = (TH1D*)mcProfile->ProjectionX("mcTruth", 1, 5, "E");
453       mcTruth->Scale(1./5.);
454     }
455     else {
456       mcDiffHist = (TProfile*)mcList->FindObject(Form("hQ2Cumulant4DiffFlowMC_%d_%d", y[c], y[c+1]));
457       fmdtrDiffHist = (TProfile*)fmdtrList->FindObject(Form("hQ2Cumulant4DiffFlowFMDTR_%d_%d", y[c], y[c+1]));
458       spdtrDiffHist = (TProfile*)spdtrList->FindObject(Form("hQ2Cumulant4DiffFlowSPDTR_%d_%d", y[c], y[c+1]));
459       fmdDiffHist = (TProfile*)fmdList->FindObject(Form("hQ2Cumulant4DiffFlowFMD_%d_%d", y[c], y[c+1]));
460       spdDiffHist = (TProfile*)spdList->FindObject(Form("hQ2Cumulant4DiffFlowSPD_%d_%d", y[c], y[c+1]));
461       mcTruth = (TH1D*)mcProfile->ProjectionX("mcTruth", c+1, c+1, "E");
462     }
463  
464     TString name = "v_{2}{4} MC ";
465     if (c == -2)      name += "Minimum Bias";
466     else if (c == -1) name += "0-40% Centrality"; 
467     else {
468                       name += TString::Format("%d-%d", y[c], y[c+1]);
469                       name += "% Centrality";
470     }    
471      
472     TCanvas* c1 = SetupCanvas(name);
473     pad = (TPad*)c1->GetPrimitive("p1");
474     pad->cd();
475
476     TLatex* tit = new TLatex(0.10, 0.95, name);
477     tit->SetNDC();
478     tit->SetTextFont(132);
479     tit->SetTextSize(0.07);
480     tit->Draw();
481
482     Int_t nEvs = (Int_t)fmdDiffHist->GetBinContent(fmdDiffHist->GetNbinsX()+1);
483     TLatex* et = new TLatex(.93, .87, Form("%d events", nEvs));
484     et->SetNDC();
485     et->SetTextFont(132);
486     et->SetTextAlign(33);
487     et->Draw();
488
489     mcDiffHist->SetMarkerStyle(21);
490     fmdDiffHist->SetLineColor(kBlue);
491     spdDiffHist->SetLineColor(kRed);
492     fmdtrDiffHist->SetLineColor(kGreen+1);
493     spdtrDiffHist->SetLineColor(kCyan+1);
494     mcTruth->SetFillColor(kGray);
495
496     mcTruth->Draw("same e3");
497     mcDiffHist->Draw("same e1");
498     fmdDiffHist->Draw("same e1");
499     spdDiffHist->Draw("same e1");
500     fmdtrDiffHist->Draw("same e1");
501     spdtrDiffHist->Draw("same e1");
502  
503     TLegend* l = new TLegend(.12,.40,.35,.80);
504 //    l->SetNColumns(2);
505     l->SetFillColor(0);
506     l->SetFillStyle(0);
507     l->SetBorderSize(0);
508     l->SetTextFont(132);
509     l->AddEntry(fmdDiffHist, "FMD", "lpe");
510     l->AddEntry(spdDiffHist, "SPD", "lpe");
511     l->AddEntry(fmdtrDiffHist, "FMD TrackRefs", "lpe");
512     l->AddEntry(spdtrDiffHist, "SPD TrackRefs", "lpe");
513     l->AddEntry(mcDiffHist, "MC Truth", "lpe");
514     l->AddEntry(mcTruth, "cos(2(#varphi-#Psi_{rp}))", "f");
515     l->Draw();
516
517     pad = (TPad*)c1->GetPrimitive("p2");
518     pad->cd();
519
520     fmdDiff = fmdDiffHist->ProjectionX("fmdDiff", "e");
521     mcDiff1 = mcDiffHist->ProjectionX("mcDiff1", "e");
522     fmdDiff->Divide(mcDiff1);
523     fmdDiff->SetLineColor(kBlue);
524     fmdDiff->Draw("same e1");
525
526     spdDiff = spdDiffHist->ProjectionX("spdDiff", "e");
527     mcDiff2 = mcDiffHist->ProjectionX("mcDiff2", "e");
528     spdDiff->Divide(mcDiff2);
529     spdDiff->SetLineColor(kRed);
530     spdDiff->Draw("same e1");
531
532     pad = (TPad*)c1->GetPrimitive("p3");
533     pad->cd();
534
535     fmdTrDiff = fmdDiffHist->ProjectionX("fmdTrDiff", "e");
536     mcDiff3 = fmdtrDiffHist->ProjectionX("mcDiff3", "e");
537     fmdTrDiff->Divide(mcDiff3);
538     fmdTrDiff->SetLineColor(kBlue);
539     fmdTrDiff->Draw("same e1");
540
541     spdTrDiff = spdDiffHist->ProjectionX("spdTrDiff", "e");
542     mcDiff4 = spdtrDiffHist->ProjectionX("mcDiff4", "e");
543     spdTrDiff->Divide(mcDiff4);
544     spdTrDiff->SetLineColor(kRed);
545     spdTrDiff->Draw("same e1");
546
547     name.Prepend("Title:");
548     cout<<name<<endl;
549     c1->Print(pdfName, name);
550   
551     delete mcDiff1;
552     delete mcDiff2;
553     delete mcDiff3;
554     delete mcDiff4;
555     delete fmdDiff;
556     delete spdDiff;
557     delete fmdTrDiff;
558     delete spdTrDiff;
559     delete c1;
560   } // end of c
561 }
562
563 void MakeMonitoringPlots(TFile* f) 
564 {
565   TList* qList = static_cast<TList*>(f->Get("FlowResults/QCumulants"));
566
567   TH1D* cent = (TH1D*)qList->FindObject("Centralities");
568   TH2D* vert = (TH2D*)qList->FindObject("CoverageVsVertex");
569
570   TCanvas* c1 = SetupCanvas("Monitoring");
571   c1->Divide(1,2);
572   c1->cd(1);
573   cent->GetXaxis()->SetTitleFont(22);
574   cent->GetXaxis()->SetLabelFont(22);
575   cent->GetYaxis()->SetTitleFont(22);
576   cent->GetYaxis()->SetLabelFont(22);
577   cent->SetXTitle("Centrality %");
578   cent->SetYTitle("# of events");
579   cent->Draw();
580   c1->cd(2);
581   vert->GetXaxis()->SetTitleFont(22);
582   vert->GetXaxis()->SetLabelFont(22);
583   vert->GetYaxis()->SetTitleFont(22);
584   vert->GetYaxis()->SetLabelFont(22);
585   vert->SetXTitle("#eta");
586   vert->SetYTitle("Vertex z coordinate [cm]");
587   vert->Draw("colz");
588
589   c1->Print(pdfName, "Title:Monitoring Plots");
590 }
591
592
593 void DrawFlowPDF(char* file = "AnalysisResults.root") 
594 {
595   gStyle->SetOptStat(0);
596   gStyle->SetOptTitle(0);
597
598   TFile* f = TFile::Open(file, "READ");
599   TCanvas* c0 = SetupCanvas("empty");
600   c0->SetName("empty");
601   c0->Print(Form("%s[", pdfName));
602   MakeFmdAndSpdPlots(f);
603   Make2ParticlePlots(f);
604   Make4ParticlePlots(f);
605   MakeMonitoringPlots(f);
606   c0->Print(Form("%s]", pdfName));
607 }