]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/macros/plotCumulants.C
cleanup of structure
[u/mrichter/AliRoot.git] / PWG2 / FLOW / macros / plotCumulants.C
CommitLineData
9dcf9913 1// add comment
2
3// Set how many output analysis files in total you want to access:
c109b8c7 4const Int_t nFiles = 1;
9dcf9913 5
6// Set how many of those output analysis files you want to represent with a mesh (usually used to represent results of simulations):
c109b8c7 7const Int_t nSim = 0;
9dcf9913 8
9// Set paths of all output analysis files (first the ones to be represented with mesh (simulations), then the ones to be represented with markers (real data))
63cdf10a 10TString files[nFiles] = {"data/LHC10bcd"};
11
9dcf9913 12// Set analysis types for all output analysis files (can be "ESD","AOD","MC",""):
c109b8c7 13TString type[nFiles] = {"ESD"};
9dcf9913 14
15// Set mesh color:
c109b8c7 16Int_t meshColor[nSim] = {};
9dcf9913 17
18// Set marker styles:
19Int_t markerStyle[nFiles-nSim] = {kStar};
20
c109b8c7 21// Set marker colors:
22Int_t markerColor[nFiles-nSim] = {kBlack};
23
9dcf9913 24// Set legend entries:
63cdf10a 25TString legendEntry[nFiles] = {"LHC10bcd"};
26
83cac266 27// Set if you want to rebin the histograms into wider multiplicity bins (set for each cumulant order separately):
28Bool_t rebin = kFALSE;
29Int_t nMergedBins[4] = {1,2,4,8}; // set how many original multiplicity bins will be merged into 1 new one
9dcf9913 30
c109b8c7 31// Set if you whish to plot cumulants versus <reference multiplicity> (by default they are plotted versus # of RPs):
63cdf10a 32Bool_t plotCumulantsVsReferenceMultiplicity = kFALSE;
c109b8c7 33
9dcf9913 34// Set flow values whose theoretical contribution to cumulants will be shown on the plots with the straight coloured lines:
63cdf10a 35Bool_t showTheoreticalLines = kTRUE;
36const Int_t nFlowValues = 1;
37Double_t v[nFlowValues] = {0.1,};
38Int_t lineColor[nFlowValues] = {kRed};
9dcf9913 39
40// If the statistical error of 6th and 8th order cumulant is huge you may prefer not to show them:
63cdf10a 41Bool_t plotOnly2ndAnd4thOrderCumulant = kFALSE;
9dcf9913 42
43// For comparison sake show also GFC results with dotted line:
44Bool_t showAlsoGFCResults = kFALSE;
45Int_t gfcLineStyle = 3;
46
47// Set method names which calculate cumulants vs multiplicity:
48const Int_t nMethods = 2;
49TString method[nMethods] = {"QC","GFC"};
50
51TFile *commonOutputFiles[nFiles] = {NULL}; // common output files "AnalysisResults.root"
52TList *lists[nFiles][nMethods] = {{NULL}}; // lists cobj<method> holding objects with results for each method
53TH1D *cumulantsVsM[nFiles][nMethods][4] = {{{NULL}}}; // histograms with results for cumulants vs multiplicity (4 stands for 4 cumulant orders)
63cdf10a 54TGraph *lines[nFlowValues][4] = {{NULL}}; // lines denoting theoretical flow contribution to cumulants
55TProfile *refMultVsNoOfRPs[nFiles] = {NULL}; // <reference multipicity> versus # of RPs
9dcf9913 56
57// Ranges for plots:
58Double_t xMin[4]={0.};
59Double_t xMax[4]={0.};
60Double_t yMin[4]={0.};
61Double_t yMax[4]={0.};
62
63enum libModes {mLocal,mLocalSource};
64
65void plotCumulants(Int_t analysisMode=mLocal)
66{
67 // analysisMode: if analysisMode = mLocal -> analyze data on your computer using aliroot
68 // if analysisMode = mLocalSource -> analyze data on your computer using root + source files
63cdf10a 69
9dcf9913 70 // Load needed libraries:
71 LoadLibrariesPC(analysisMode);
72
73 // Access all common output files:
74 TString commonOutputFileName = "AnalysisResults.root";
75 AccessCommonOutputFiles(commonOutputFileName);
76
77 // Get from common output files the lists holding histograms for each method:
78 GetLists();
79
80 // Get histograms with results for cumulants vs multiplicity:
81 GetHistograms();
82
83 // Determine ranges for plots:
84 DetermineMinMax();
85
86 // Make lines which indicate theoretical contributions of flow to cumulants:
87 Lines();
88
89 // Print number of events and average multiplicities for each common output file:
90 Print();
91
92 // Make plots:
93 Plot();
94
95 // Global settings which will affect all plots:
96 GlobalSettings();
97
98} // end of void plotCumulants(Int_t analysisMode=mLocal)
99
100// =====================================================================================
101
102void Plot()
103{
104 // Make all plots.
105
106 TCanvas *c = NULL;
107 Int_t coMax = 0;
108 if(!plotOnly2ndAnd4thOrderCumulant)
109 {
110 c = new TCanvas("c","cumulants");
111 c->Divide(2,2);
112 coMax = 4;
113 } else
114 {
115 c = new TCanvas("c","cumulants",1200,500);
116 c->Divide(2,1);
117 coMax = 2;
118 }
119
120 TLegend *legend = new TLegend(0.1,0.7,0.33,0.9);
121 legend->SetFillStyle(0);
63cdf10a 122 //legend->SetHeader(" minClustersTpcRP");
9dcf9913 123
124 TString qcFlag[4] = {"QC{2}","QC{4}","QC{6}","QC{8}"};
125
126 for(Int_t co=0;co<coMax;co++) // cumulant order
127 {
128 c->cd(co+1);
129 StyleHist(qcFlag[co].Data(),co)->Draw();
130 // simulations:
131 for(Int_t s=0;s<nSim;s++)
132 {
133 TGraph *errorMesh = GetErrorMesh(cumulantsVsM[s][0][co]);
134 if(errorMesh)
135 {
136 errorMesh->SetFillColor(meshColor[s]);
137 errorMesh->Draw("lfsame");
138 }
139 if(co==0){legend->AddEntry(errorMesh,legendEntry[s].Data(),"f");}
140 } // end of if(Int_t s=0;s<nSim;s++)
141 // data:
142 for(Int_t f=nSim;f<nFiles;f++)
143 {
144 // Theoretical lines:
145 if(showTheoreticalLines)
146 {
147 if(f==nSim) // plot them only once
148 {
149 for(Int_t fv=0;fv<nFlowValues;fv++)
150 {
63cdf10a 151 lines[fv][co]->Draw("lsame");
9dcf9913 152 if(co==0){legend->AddEntry(lines[fv][co],Form("v_{2} = %g",v[fv]),"l");}
153 }
154 }
155 }
156 // QC results:
157 if(cumulantsVsM[f][0][co])
158 {
159 cumulantsVsM[f][0][co]->Draw("e1same");
c109b8c7 160 cumulantsVsM[f][0][co]->SetMarkerStyle(markerStyle[f-nSim]);
161 cumulantsVsM[f][0][co]->SetMarkerColor(markerColor[f-nSim]);
9dcf9913 162 if(co==0)
163 {
164 if(showAlsoGFCResults)
165 {
166 legend->AddEntry(cumulantsVsM[f][0][co],Form("%s (QC)",legendEntry[f].Data()),"p");
167 } else
168 {
169 legend->AddEntry(cumulantsVsM[f][0][co],legendEntry[f].Data(),"p");
170 }
171 }
172 }
173 // GFC results:
174 if(showAlsoGFCResults && cumulantsVsM[f][1][co])
175 {
176 cumulantsVsM[f][1][co]->Draw("lsame");
177 cumulantsVsM[f][1][co]->SetLineStyle(gfcLineStyle);
178 if(co==0){legend->AddEntry(cumulantsVsM[f][1][co],Form("%s (GFC)",legendEntry[f].Data()),"l");}
179 }
180 }
181 // Draw legend:
182 if(co==0){legend->Draw("same");}
183 } // end of for(Int_t co=0;co<4;co++) // cumulant order
c109b8c7 184
185 // Plot also <reference multiplicity> vs # of RPs:
186 if(plotCumulantsVsReferenceMultiplicity)
187 {
63cdf10a 188 TCanvas *cRefMultVsNoOfRPs = new TCanvas("cRefMultVsNoOfRPs","#LTreference multiplicity#GT vs # of RPs",1200,600);
189 cRefMultVsNoOfRPs->Divide(nFiles,1);
190 for(Int_t f=0;f<nFiles;f++)
c109b8c7 191 {
63cdf10a 192 cRefMultVsNoOfRPs->cd(f+1);
193 if(refMultVsNoOfRPs[f])
194 {
195 refMultVsNoOfRPs[f]->SetTitle(legendEntry[f].Data());
196 refMultVsNoOfRPs[f]->GetXaxis()->SetRangeUser(0,refMultVsNoOfRPs[f]->FindLastBinAbove());
197 refMultVsNoOfRPs[f]->Draw();
198 } else
199 {
200 cout<<endl;
201 cout<<"WARNING: refMultVsNoOfRPs[f] is NULL in Plot(), f = "<<f<<" !!!!"<<endl;
202 cout<<endl;
203 }
204 }
c109b8c7 205 }
206
9dcf9913 207} // end of void Plot()
208
209// =====================================================================================
210
211void Lines()
212{
213 // Make lines denoting theoretical contribution of flow to cumulants.
9dcf9913 214
215 for(Int_t fv=0;fv<nFlowValues;fv++)
216 {
63cdf10a 217 lines[fv][0] = new TGraph(2);
218 lines[fv][0]->SetPoint(0,xMin[0],pow(v[fv],2));
219 lines[fv][0]->SetPoint(1,xMax[0]+0.5,pow(v[fv],2));
9dcf9913 220 lines[fv][0]->SetLineColor(lineColor[fv]);
63cdf10a 221 lines[fv][1] = new TGraph(2);
222 lines[fv][1]->SetPoint(0,xMin[1],-pow(v[fv],4));
223 lines[fv][1]->SetPoint(1,xMax[1]+0.5,-pow(v[fv],4));
224 lines[fv][1]->SetLineColor(lineColor[fv]);
225 lines[fv][2] = new TGraph(2);
226 lines[fv][2]->SetPoint(0,xMin[2],4.*pow(v[fv],6));
227 lines[fv][2]->SetPoint(1,xMax[2]+0.5,4.*pow(v[fv],6));
228 lines[fv][2]->SetLineColor(lineColor[fv]);
229 lines[fv][3] = new TGraph(2);
230 lines[fv][3]->SetPoint(0,xMin[3],-33.*pow(v[fv],8));
231 lines[fv][3]->SetPoint(1,xMax[3]+0.5,-33.*pow(v[fv],8));
9dcf9913 232 lines[fv][3]->SetLineColor(lineColor[fv]);
233 }
234
235} // end of void Lines()
236
237// =====================================================================================
238
239void Print()
240{
241 // Print number of events and average multiplicities for each common output file.
242
243 cout<<endl;
244 cout<<"Accessed files:"<<endl;
245 cout<<endl;
246 for(Int_t f=0;f<nFiles;f++)
247 {
248 cout<<commonOutputFiles[f]->GetName()<<endl;
249 for(Int_t m=0;m<nMethods;m++)
250 {
63cdf10a 251 AliFlowCommonHist *commonHist = NULL;
252 if(lists[f][m])
253 {
254 commonHist = dynamic_cast<AliFlowCommonHist*> (lists[f][m]->FindObject(Form("AliFlowCommonHist%s",method[m].Data())));
255 }
256 Double_t nEvts = 0.;
257 Double_t AvM = 0.;
9dcf9913 258 if(commonHist && commonHist->GetHistMultRP())
259 {
260 nEvts = commonHist->GetHistMultRP()->GetEntries();
261 AvM = commonHist->GetHistMultRP()->GetMean();
262 }
263 if(!(strcmp(method[m].Data(),"QC")))
264 {
265 cout<<Form("%s:",method[m].Data())<<" <M> = "<<AvM<<", N = "<<nEvts<<endl;
266 }
267 if(!(strcmp(method[m].Data(),"GFC")) && showAlsoGFCResults)
268 {
269 cout<<Form("%s:",method[m].Data())<<" <M> = "<<AvM<<", N = "<<nEvts<<endl;
270 }
63cdf10a 271 } // end of for(Int_t m=0;m<nMethods;m++)
9dcf9913 272 cout<<endl;
273 } // end of for(Int_t f=0;f<nFiles;f++)
274
275} // end of void Print()
276
277// =====================================================================================
278
279void DetermineMinMax()
280{
281 // Determine ranges for plots.
282
283 for(Int_t co=0;co<4;co++)
284 {
285 xMin[co] = 0.; yMin[co] = 44.;
286 xMax[co] = -440000.; yMax[co] = -44.;
287 }
288
289 Double_t tfc[nFlowValues][4] = {{0.}}; // theoretical flow contribution
290 for(Int_t fv=0;fv<nFlowValues;fv++)
291 {
292 tfc[fv][0] = pow(v[fv],2);
293 tfc[fv][1] = -pow(v[fv],4);
294 tfc[fv][2] = 4.*pow(v[fv],6);
295 tfc[fv][3] = -33.*pow(v[fv],8);
296 }
297
298 for(Int_t f=0;f<nFiles;f++)
299 {
300 for(Int_t m=0;m<nMethods;m++)
301 {
302 for(Int_t co=0;co<4;co++)
303 {
304 if(cumulantsVsM[f][m][co])
305 {
63cdf10a 306 Int_t nBins = cumulantsVsM[f][m][co]->GetXaxis()->GetNbins();
307 for(Int_t b=1;b<=nBins;b++)
9dcf9913 308 {
309 Double_t result = cumulantsVsM[f][m][co]->GetBinContent(b);
310 Double_t error = cumulantsVsM[f][m][co]->GetBinError(b);
311 if(TMath::Abs(result)>1.e-44 && TMath::Abs(error)>1.e-44)
312 {
313 // y-axis:
314 if(yMin[co] > result-error){yMin[co] = result-error;} // min value
315 if(yMax[co] < result+error) {yMax[co] = result+error;} // max value
316 // x-axis:
63cdf10a 317 xMax[co] = cumulantsVsM[f][m][co]->GetBinLowEdge(b+1);
9dcf9913 318 }
319 } // end of for(Int_t b=1;b<=cumulantsVsM[f][m][co]->GetXaxis()->GetNbins();b++)
320 // theoretical contributions:
63cdf10a 321 if(showTheoreticalLines)
9dcf9913 322 {
63cdf10a 323 for(Int_t fv=0;fv<nFlowValues;fv++)
324 {
325 if(yMin[co] > tfc[fv][co]) {yMin[co] = tfc[fv][co];} // min value
326 if(yMax[co] < tfc[fv][co]) {yMax[co] = tfc[fv][co];} // max value
327 } // end of for(Int_t fv=0;fv<nFlowValues;fv++)
328 } // end of if(showTheoreticalLines)
9dcf9913 329 } // end of if(cumulantsVsM[f][m][co])
330 } // end of for(Int_t co=0;co<4;co++)
331 } // end of for(Int_t m=0;m<nMethods;m++)
332 } // end of for(Int_t f=0;f<nFiles;f++)
333
334} // end of void DetermineMinMax()
335
336// =====================================================================================
337
338void GetHistograms()
339{
340 // Get histograms with results for cumulants vs multiplicity.
c109b8c7 341
342 if(plotCumulantsVsReferenceMultiplicity) {GetProfileForRefMultVsNoOfRPs();}
9dcf9913 343
344 TString qcFlag[4] = {"QC{2}","QC{4}","QC{6}","QC{8}"};
345 TString gfcFlag[4] = {"GFC{2}","GFC{4}","GFC{6}","GFC{8}"};
346 for(Int_t f=0;f<nFiles;f++)
347 {
348 for(Int_t m=0;m<nMethods;m++)
349 {
350 TList *temp = NULL;
63cdf10a 351 if(!(strcmp(method[m].Data(),"QC")) && lists[f][m])
9dcf9913 352 {
353 temp = dynamic_cast<TList*> (lists[f][m]->FindObject("Integrated Flow"));
354 if(temp) {temp = dynamic_cast<TList*> (temp->FindObject("Results"));}
355 if(temp)
356 {
357 for(Int_t co=0;co<4;co++)
358 {
359 cumulantsVsM[f][m][co] = dynamic_cast<TH1D*> (temp->FindObject(Form("fIntFlowQcumulantsVsM, %s",qcFlag[co].Data())));
6324dcfd 360 if(rebin && cumulantsVsM[f][m][co])
63cdf10a 361 {
83cac266 362 cumulantsVsM[f][m][co] = Rebin(cumulantsVsM[f][m][co],co);
63cdf10a 363 }
6324dcfd 364 if(plotCumulantsVsReferenceMultiplicity && cumulantsVsM[f][m][co])
c109b8c7 365 {
63cdf10a 366 Map(cumulantsVsM[f][m][co],f);
c109b8c7 367 }
9dcf9913 368 }
369 }
370 } // end of if(!(strcmp(method[m].Data(),"QC")))
63cdf10a 371 else if(!(strcmp(method[m].Data(),"GFC")) && lists[f][m])
9dcf9913 372 {
373 temp = dynamic_cast<TList*> (lists[f][m]->FindObject("Reference Flow"));
374 if(temp) {temp = dynamic_cast<TList*> (temp->FindObject("Results"));}
375 if(temp)
376 {
377 for(Int_t co=0;co<4;co++)
378 {
379 cumulantsVsM[f][m][co] = dynamic_cast<TH1D*> (temp->FindObject(Form("fReferenceFlowCumulantsVsM, %s",gfcFlag[co].Data())));
6324dcfd 380 if(plotCumulantsVsReferenceMultiplicity && cumulantsVsM[f][m][co])
c109b8c7 381 {
63cdf10a 382 Map(cumulantsVsM[f][m][co],f);
c109b8c7 383 }
63cdf10a 384 } // end of for(Int_t co=0;co<4;co++)
385 } // end of if(temp)
9dcf9913 386 } // end of else if(!(strcmp(method[m].Data(),"QC")))
387 } // end of for(Int_t m=0;m<nMethods;m++)
388 } // end of for(Int_t f=0;f<nFiles;f++)
389
6324dcfd 390 Int_t counter = 0;
391 for(Int_t f=0;f<nFiles;f++)
392 {
393 for(Int_t m=0;m<nMethods;m++)
394 {
395 for(Int_t co=0;co<4;co++)
396 {
397 if(cumulantsVsM[f][m][co]){counter++;}
398 }
399 }
400 }
401
402 if(counter == 0)
403 {
404 cout<<endl;
405 cout<<" WARNING: Couldn't access a single histogram with results vs multiplicity !!!!"<<endl;
406 cout<<" Did you enable this calculation before running over data?"<<endl;
407 cout<<endl;
408 exit(0);
409 }
410
9dcf9913 411} // end of void GetHistograms()
412
413// =====================================================================================
414
c109b8c7 415void GetProfileForRefMultVsNoOfRPs()
416{
417 // Get profile holding <reference multiplicity> versus # of RPs.
418
63cdf10a 419 for(Int_t f=0;f<nFiles;f++)
c109b8c7 420 {
63cdf10a 421 AliFlowCommonHist *commonHist = NULL;
422 if(lists[f][0])
423 {
424 commonHist = dynamic_cast<AliFlowCommonHist*> (lists[f][0]->FindObject("AliFlowCommonHistQC"));
425 } else
426 {
427 cout<<endl;
428 cout<<"WARNING: lists[f][0] is NULL in GetProfileForRefMultVsNoOfRPs(), f = "<<f<<" !!!!"<<endl;
429 cout<<endl;
430 }
431 if(commonHist && commonHist->GetRefMultVsNoOfRPs())
432 {
433 refMultVsNoOfRPs[f] = commonHist->GetRefMultVsNoOfRPs();
434 } else
435 {
436 cout<<endl;
437 cout<<"WARNING: commonHist && commonHist->GetRefMultVsNoOfRPs() is NULL in GetProfileForRefMultVsNoOfRPs() !!!!"<<endl;
438 cout<<endl;
439 }
440 }
c109b8c7 441
442} // end of void GetProfileForRefMultVsNoOfRPs()
443
444// =====================================================================================
445
63cdf10a 446void Map(TH1D *hist, Int_t f)
c109b8c7 447{
448 // Map cumulant versus # of RPs into cumulants versus <reference multiplicity>.
449
450 TH1D *temp = NULL;
63cdf10a 451 if(!refMultVsNoOfRPs[f])
452 {
453 cout<<endl;
454 cout<<"WARNING: refMultVsNoOfRPs[f] is NULL in Map(...), f = "<<f<<" !!!!"<<endl;
455 cout<<endl;
456 }
457
c109b8c7 458 if(hist)
459 {
460 temp = (TH1D*) hist->Clone();
c109b8c7 461 Int_t nBins = hist->GetNbinsX();
462 for(Int_t b=1;b<=nBins;b++)
463 {
63cdf10a 464 hist->SetBinContent((Int_t)refMultVsNoOfRPs[f]->GetBinContent(b),temp->GetBinContent(b));
465 hist->SetBinError((Int_t)refMultVsNoOfRPs[f]->GetBinContent(b),temp->GetBinError(b));
c109b8c7 466 }
467 }
63cdf10a 468
469} // end of Map()
470
471// =====================================================================================
472
83cac266 473TH1D* Rebin(TH1D *hist, Int_t co)
63cdf10a 474{
475 // Rebin original histograms.
476
83cac266 477 if(nMergedBins[co] == 0)
63cdf10a 478 {
479 cout<<endl;
83cac266 480 cout<<Form(" WARNING: nMergedBins[%i] == 0 !!!!",co)<<endl;
63cdf10a 481 cout<<endl;
482 exit(0);
483 }
484 if(!hist)
485 {
486 cout<<endl;
487 cout<<" WARNING: hist is NULL in Rebin() !!!!"<<endl;
488 cout<<endl;
489 exit(0);
490 }
491
492 Int_t nBinsOld = hist->GetXaxis()->GetNbins();
493 if(nBinsOld == 0){cout<<" WARNING: nBinsOld == 0 !!!!"<<endl;exit(0);}
494 Double_t xMinOld = hist->GetXaxis()->GetXmin();
495 Double_t xMaxOld = hist->GetXaxis()->GetXmax();
496 Double_t binWidthOld = (xMaxOld-xMinOld)/nBinsOld;
83cac266 497 Int_t nBinsNew = TMath::Floor(nBinsOld/nMergedBins[co]);
63cdf10a 498 Double_t xMinNew = xMinOld;
83cac266 499 Double_t xMaxNew = xMinOld + nBinsNew*nMergedBins[co]*binWidthOld;
c109b8c7 500
63cdf10a 501 TH1D *temp = new TH1D("","",nBinsNew,xMinNew,xMaxNew); // rebinned histogram
502 Int_t binNew = 1;
503 Double_t value = 0.;
504 Double_t error = 0.;
505 Double_t dSum1 = 0.; // sum value_i/(error_i)^2
506 Double_t dSum2 = 0.; // sum 1/(error_i)^2
507 for(Int_t b=1;b<=nBinsOld;b++)
508 {
509 value = hist->GetBinContent(b);
510 error = hist->GetBinError(b);
511 if(error>0.)
512 {
513 dSum1+=value/(error*error);
514 dSum2+=1./(error*error);
515 }
83cac266 516 if(b%nMergedBins[co] == 0)
63cdf10a 517 {
518 if(dSum2>0.)
519 {
520 temp->SetBinContent(binNew,dSum1/dSum2);
521 temp->SetBinError(binNew,pow(1./dSum2,0.5));
522 }
523 binNew++;
524 dSum1 = 0.;
525 dSum2 = 0.;
83cac266 526 } // end of if(b%nMergedBins[co] == 0)
63cdf10a 527 } // end of for(Int_t b=1;b<=nBinsOld;b++)
c109b8c7 528
63cdf10a 529 return temp;
530
83cac266 531} // end of TH1D* Rebin(TH1D *hist, Int_t co)
c109b8c7 532
533// =====================================================================================
534
9dcf9913 535TGraphErrors* GetGraphErrors(Int_t bin, Int_t nFiles, TH1D** qc)
536{
537 TGraphErrors *ge = new TGraphErrors(nFiles);
538 for(Int_t f=0;f<nFiles;f++)
539 {
540 ge->SetPoint(f,f+0.5,qc[f]->GetBinContent(bin+1));
541 ge->SetPointError(f,0,qc[f]->GetBinError(bin+1));
542 }
543
544 return ge;
545
546} // end of TGraphErrors* GetGraphErrors(Int_t bin, Int_t nFiles, TH1D** qc)
547
548// =====================================================================================
549
550TH1D* StyleHist(TString yAxisTitle, Int_t co)
551{
552 // Style histogram.
553
63cdf10a 554 TH1D *styleHist = new TH1D(Form("%d",co),"",(Int_t)xMax[co],0,xMax[co]);
9dcf9913 555 // y-axis:
556 styleHist->GetYaxis()->SetRangeUser(yMin[co],yMax[co]);
63cdf10a 557
c109b8c7 558 if(plotCumulantsVsReferenceMultiplicity)
559 {
560 styleHist->GetXaxis()->SetTitle("#LTreference multiplicity#GT");
561 } else
562 {
563 styleHist->GetXaxis()->SetTitle("# of RPs");
564 }
565
9dcf9913 566 styleHist->GetYaxis()->SetTitle(yAxisTitle.Data());
567
568 return styleHist;
569
570} // end of TH1D* StyleHist(TString yAxisTitle, Int_t co)
571
572// ===========================================================================================
573
574TGraph* GetErrorMesh(TH1D *hist)
575{
576 // Error mesh.
577
578 TGraph* errorMesh = NULL;
579 if(hist)
580 {
581 Int_t nBins = hist->GetNbinsX();
582 Double_t binWidth = hist->GetBinWidth(1); // assuming that all bins have the same width
583 // Counting the non-empty bins:
584 Int_t nNonEmptyBins=0;
585 for(Int_t i=1;i<nBins+1;i++)
586 {
587 if(!(hist)->GetBinError(i)==0.0))
588 {
589 nNonEmptyBins++;
590 }
591 }
592 errorMesh = new TGraph(2*nNonEmptyBins+1);
593 Double_t value=0.,error=0.;
594 Int_t count=1;
595 Double_t xFirst=0.,yUpFirst=0.; // needed to close up the mesh
596 for(Int_t i=1;i<nBins+1;i++)
597 {
598 // Setting up the upper limit of the mesh:
599 value = hist->GetBinContent(i);
600 error = hist->GetBinError(i);
601 if(!(error==0.0))
602 {
603 errorMesh->SetPoint(count++,(i-0.5)*binWidth,value+error);
604 if(xFirst==0.)
605 {
606 xFirst=(i-0.5)*binWidth;
607 yUpFirst=value+error;
608 }
609 }
610 }
611 for(Int_t i=nBins+1;i<2*nBins+1;i++)
612 {
613 // Setting up the lower limit of the mesh:
614 value = hist->GetBinContent(2*nBins+1-i);
615 error = hist->GetBinError(2*nBins+1-i);
616 if(!(error==0.0))
617 {
618 errorMesh->SetPoint(count++,(2*nBins-i+0.5)*binWidth,value-error);
619 }
620 }
621 // Closing the mesh area:
622 errorMesh->SetPoint(2*nNonEmptyBins+1,xFirst,yUpFirst);
623 } // end if(hist)
624
625 errorMesh->SetFillStyle(1001);
626
627 return errorMesh;
628
629} // end of TGraph* GetErrorMesh(TH1D *hist)
630
631// ===========================================================================================
632
633void GlobalSettings()
634{
635 // Settings which will affect all plots.
636
637 gROOT->SetStyle("Plain"); // default color is white instead of gray
638 gStyle->SetOptStat(0); // remove stat. box from all histos
63cdf10a 639 TGaxis::SetMaxDigits(4);
9dcf9913 640
641} // end of void GlobalSettings()
642
643// ===========================================================================================
644
645void GetLists()
646{
647 // Get from common output files the lists holding histograms for each method.
648
649 TString fileName[nFiles][nMethods];
650 TDirectoryFile *dirFile[nFiles][nMethods] = {{NULL}};
651 TString listName[nFiles][nMethods];
652 for(Int_t f=0;f<nFiles;f++)
653 {
654 for(Int_t i=0;i<nMethods;i++)
655 {
656 // Form a file name for each method:
657 fileName[f][i]+="output";
658 fileName[f][i]+=method[i].Data();
659 fileName[f][i]+="analysis";
660 fileName[f][i]+=type[f].Data();
661 // Access this file:
662 if(commonOutputFiles[f]){dirFile[f][i] = (TDirectoryFile*)commonOutputFiles[f]->FindObjectAny(fileName[f][i].Data());}
663 // Form a list name for each method:
664 listName[f][i]+="cobj";
665 listName[f][i]+=method[i].Data();
666 // Access this lists:
667 if(dirFile[f][i])
668 {
669 dirFile[f][i]->GetObject(listName[f][i].Data(),lists[f][i]);
63cdf10a 670 if(!lists[f][i])
671 {
672 cout<<endl;
673 cout<<" WARNING: Couldn't find a list "<<listName[f][i].Data()<<" in "<<commonOutputFiles[f]->GetName()<<" !!!!"<<endl;
674 cout<<" Did you use method "<<method[i].Data()<<" in the analysis which produced this file?"<<endl;
675 cout<<endl;
676 }
9dcf9913 677 } else
678 {
63cdf10a 679 cout<<endl;
680 cout<<" WARNING: Couldn't find a file "<<fileName[f][i].Data()<<".root in "<<commonOutputFiles[f]->GetName()<<" !!!!"<<endl;exit(0);
681 cout<<endl;
9dcf9913 682 }
683 } // end of for(Int_t i=0;i<nMethods;i++)
684 } // end of for(Int_t f=0;f<nFiles;f++)
685
686} // end of void GetLists()
687
688// ===========================================================================================
689
690void AccessCommonOutputFiles(TString commonOutputFileName)
691{
692 // Access all output files.
693 for(Int_t f=0;f<nFiles;f++)
694 {
695 if(!(gSystem->AccessPathName(Form("%s/%s/%s",gSystem->pwd(),files[f].Data(),commonOutputFileName.Data()),kFileExists)))
696 {
697 commonOutputFiles[f] = TFile::Open(Form("%s/%s/%s",gSystem->pwd(),files[f].Data(),commonOutputFileName.Data()),"READ");
698 } else
699 {
700 cout<<endl;
701 cout<<"WARNING: Couldn't find the file "<<Form("%s/%s/%s",gSystem->pwd(),files[f].Data(),commonOutputFileName.Data())<<" !!!!"<<endl;
702 cout<<endl;
703 exit(0);
704 }
705 } // end of for(Int_t f=0;f<nFiles;f++)
706
707} // void AccessCommonOutputFiles(TString commonOutputFileName);
708
709// ===========================================================================================
710
711void LoadLibrariesPC(const libModes analysisMode) {
712
713 //--------------------------------------
714 // Load the needed libraries most of them already loaded by aliroot
715 //--------------------------------------
716 //gSystem->Load("libTree");
717 gSystem->Load("libGeom");
718 gSystem->Load("libVMC");
719 gSystem->Load("libXMLIO");
720 gSystem->Load("libPhysics");
721
722 //----------------------------------------------------------
723 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
724 //----------------------------------------------------------
725 if (analysisMode==mLocal) {
726 //--------------------------------------------------------
727 // If you want to use already compiled libraries
728 // in the aliroot distribution
729 //--------------------------------------------------------
730
731 //==================================================================================
732 //load needed libraries:
733 gSystem->AddIncludePath("-I$ROOTSYS/include");
734 //gSystem->Load("libTree");
735
736 // for AliRoot
737 gSystem->AddIncludePath("-I$ALICE_ROOT/include");
738 //gSystem->Load("libANALYSIS");
739 gSystem->Load("libPWG2flowCommon");
740 //cerr<<"libPWG2flowCommon loaded ..."<<endl;
741
742 }
743
744 else if (analysisMode==mLocalSource) {
745
746 // In root inline compile
747
3b67e1f4 748 // Constants
9dcf9913 749 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
750 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
9dcf9913 751
752 // Flow event
753 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
754 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
9dcf9913 755 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
3b67e1f4 756 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
757
9dcf9913 758 // Output histosgrams
759 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
760 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
761 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
762 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
763
764 cout << "finished loading macros!" << endl;
765
766 }
767
768} // end of void LoadLibraries(const libModes analysisMode)