1 // Macro plotCumulants.C is used to represent true correlations, a.k.a. cumulants,
2 // as a function of reference multiplicity. Different order cumulants provide
3 // independent estimates of the flow harmonics. In the ideal case when only flow
4 // correlations are present we have:
5 // c{2} = v^2, c{4} = -v^4, c{6} = 4v^6 and c{8} = -33v^8.
6 // In practice cumulants can are calculated via Q-vectors (QC) or via formalism
7 // of generating functions (GFC).
9 // Set how many output analysis files in total you want to access:
10 const Int_t nFiles = 2;
12 // Set how many of those output analysis files you want to represent with a mesh (usually used to represent results of simulations):
15 // 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))
16 TString files[nFiles] = {"trackletsCorrectedNUA","default"}; // subdirectory names holding <commonOutputFileName>.root
17 //TString files[nFiles] = {"outputCentrality0","outputCentrality1"}; // file names (use case: centrality train)
19 // Set analysis types for all output analysis files (can be "ESD","AOD","MC","","MK", ....):
20 TString type[nFiles] = {"ESD","ESD"};
21 //TString type[nFiles] = {"MK","MK"};
24 Int_t meshColor[nSim] = {};
27 Int_t markerStyle[nFiles-nSim] = {kFullSquare,kOpenSquare};
30 Int_t markerColor[nFiles-nSim] = {kBlack,kRed};
32 // Set legend entries:
33 TString legendEntry[nFiles] = {"",""};
35 // Set if you want to rebin the histograms into wider multiplicity bins (set for each cumulant order separately):
36 Bool_t rebin = kFALSE;
37 Int_t nMergedBins[4] = {10,10,10,10}; // set how many original multiplicity bins will be merged into 1 new one
39 // Set if you whish to plot cumulants versus <reference multiplicity> (by default they are plotted versus # of RPs):
40 Bool_t plotCumulantsVsReferenceMultiplicity = kFALSE;
41 Bool_t showReferenceMultiplicityVsNoOfRPs = kFALSE;
43 // Set flow values whose theoretical contribution to cumulants will be shown on the plots with the straight coloured lines:
44 Bool_t showTheoreticalLines = kFALSE;
45 const Int_t nFlowValues = 1;
46 Double_t v[nFlowValues] = {0.05};
47 Int_t lineColor[nFlowValues] = {kRed};
49 // If the statistical error of 6th and 8th order cumulant is huge you may prefer not to show them:
50 Bool_t plotOnly2ndAnd4thOrderCumulant = kFALSE;
52 // Set if you want independent canvas with results for reference flow vs multiplicity:
53 Bool_t showRefFlowVsM = kTRUE;
54 Int_t refFlowVsMMarkerStyle[nFiles] = {kFullSquare,kOpenSquare}; // marker style is different for different file
55 Int_t refFlowVsMMarkerColor[4] = {kBlack,kRed,kBlue,kGreen+2}; // marker color is different for different cumulant order
56 Int_t refFlowVsMeshOrder = -1; // set results of which order will be plotted as mesh in all pads [0=2nd, 1=4th, 2=6th, 3=8th, -1=do not show]
57 Int_t refFlowVsMMeshColor = kRed-10; // mesh color for above specified order
58 Double_t refFlowVsMxRange[2] = {1.,11000.}; // x range on the plots for reference multiplicity vs M
59 Double_t refFlowVsMyRange[2] = {0.0,0.194}; // x range on the plots for reference multiplicity vs M
61 // Set if you want to show theoretical curves for the toy model:
62 Bool_t showToyModel = kFALSE;
63 const Int_t nToyModels = 2; // number of toy models with different parameters k, vn, v2n
64 Double_t k[nToyModels] = {2.,4.};
65 Double_t vn[nToyModels] = {0.25,0.25};
66 Double_t v2n[nToyModels] = {0.0,0.0};
67 Int_t lineColorToyModel[nToyModels] = {kBlack,kRed};
69 // For comparison sake show also GFC results with dotted line:
70 Bool_t showAlsoGFCResults = kFALSE;
71 Int_t gfcLineStyle = 3;
73 // For comparison sake show also Monte Carlo QC results with coloured mesh:
74 Bool_t showAlsoMCEPResults = kFALSE;
75 Bool_t showOnlyMCEPResults = kFALSE;
76 Int_t mcepMeshColor[nSim] = {};
78 // Set the naming convention:
79 Bool_t bLookInSubdirectories = kFALSE; // if kTRUE: Look in subdirectories <files[0]>, <files[1]>, ..., for output files <commonOutputFileName>
80 // if kFALSE: Look in <pwd> for files <files[0]>.root, <files[1]>.root, ....
81 TString commonOutputFileName = "AnalysisResults.root";
83 // Set method names which calculate cumulants vs multiplicity (do not touch these settings unless you are looking for a trouble):
84 const Int_t nMethods = 3;
85 TString method[nMethods] = {"QC","GFC","MCEP"};
87 TFile *commonOutputFiles[nFiles] = {NULL}; // common output files "AnalysisResults.root"
88 TList *lists[nFiles][nMethods] = {{NULL}}; // lists cobj<method> holding objects with results for each method
89 TH1D *cumulantsVsM[nFiles][nMethods][4] = {{{NULL}}}; // histograms with results for cumulants vs multiplicity (4 stands for 4 cumulant orders)
90 TH1D *refFlowVsM[nFiles][nMethods][4] = {{{NULL}}}; // histograms with results for reference flow vs multiplicity (4 stands for 4 cumulant orders)
91 TGraph *lines[nFlowValues][4] = {{NULL}}; // lines denoting theoretical flow contribution to cumulants
92 TProfile *refMultVsNoOfRPs[nFiles] = {NULL}; // <reference multipicity> versus # of RPs
93 TF1 *toyModel[2][nToyModels] = {{NULL}}; // [cumulant order][number of toy models]
96 Double_t xMin[4]={0.};
97 Double_t xMax[4]={0.};
98 Double_t yMin[4]={0.};
99 Double_t yMax[4]={0.};
101 enum libModes {mLocal,mLocalSource};
103 void plotCumulants(Int_t analysisMode=mLocal)
105 // analysisMode: if analysisMode = mLocal -> analyze data on your computer using aliroot
106 // if analysisMode = mLocalSource -> analyze data on your computer using root + source files
108 // Cross-check user settings:
109 CrossCheckSettings();
111 // Load needed libraries:
112 LoadLibrariesPC(analysisMode);
114 // Global settings which will affect all plots:
117 // Access all common output files:
118 AccessCommonOutputFiles(commonOutputFileName);
120 // Get from common output files the lists holding histograms for each method:
123 // Get histograms with results for cumulants vs multiplicity:
126 // Determine ranges for plots:
129 // Make lines which indicate theoretical contributions of flow to cumulants:
132 // Print number of events and average multiplicities for each common output file:
135 // Make plots for cumulants vs multiplicity: // to be improved
138 // Make plots for reference flow vs multiplicity:
139 if(showRefFlowVsM){PlotRefFlowVsM();}
141 } // end of void plotCumulants(Int_t analysisMode=mLocal)
143 // =====================================================================================
145 void PlotRefFlowVsM()
147 // Make plots for reference flow vs multiplicity.
149 // Calculate reference flow from cumulants vs M:
150 CalculateReferenceFlowFromCumulantsVsM();
152 TCanvas *cRefFlowVsM = new TCanvas("cRefFlowVsM","Reference Flow");
153 cRefFlowVsM->Divide(2,2);
155 TLegend *lRefFlowVsM = new TLegend(0.1,0.7,0.33,0.9);
156 lRefFlowVsM->SetFillStyle(0);
157 lRefFlowVsM->SetHeader(" Therminator (20-30%)");
159 TString refFlowVsMFlag[4] = {"v_{2}{2,QC}","v_{2}{4,QC}","v_{2}{6,QC}","v_{2}{8,QC}"};
161 for(Int_t f=0;f<nFiles;f++)
163 for(Int_t m=0;m<1+(Int_t)(showAlsoGFCResults)+(Int_t)(showAlsoMCEPResults);m++)
165 for(Int_t co=0;co<4;co++) // cumulant order
167 cRefFlowVsM->cd(co+1);
169 if(f==0) // superimpose histograms from other files on top of this one
171 TH1D *styleHist = (TH1D*)StyleHist(refFlowVsMFlag[co].Data(),co)->Clone();
174 styleHist->GetXaxis()->SetRangeUser(refFlowVsMxRange[0],refFlowVsMxRange[1]);
175 styleHist->GetYaxis()->SetRangeUser(refFlowVsMyRange[0],refFlowVsMyRange[1]);
179 // Plot first the mesh for reference flow of specified order in all pads:
180 if(refFlowVsMeshOrder != -1)
182 TGraph *rfMeshOutOf = GetErrorMesh(refFlowVsM[f][m][refFlowVsMeshOrder]);
185 rfMeshOutOf->SetFillColor(refFlowVsMMeshColor);
186 rfMeshOutOf->Draw("lfsame");
187 if(refFlowVsMeshOrder==co){lRefFlowVsM->AddEntry(rfMeshOutOf,Form("v_{2}{%i,QC} stat. error",2*(refFlowVsMeshOrder+1)),"f");}
189 } // end of if(refFlowVsMeshOrder != -1)
190 // Plot reference flow vs M:
191 refFlowVsM[f][m][co]->SetMarkerStyle(refFlowVsMMarkerStyle[f]);
192 refFlowVsM[f][m][co]->SetMarkerColor(refFlowVsMMarkerColor[co]);
193 refFlowVsM[f][m][co]->Draw("e1same");
194 lRefFlowVsM->AddEntry(refFlowVsM[f][m][co],Form("v_{2}{%i,QC}, %s",2*(co+1),files[f].Data()),"p");
195 } // end of for(Int_t co=0;co<4;co++) // cumulant order
196 } // end of for(Int_t m=0;m<nMethods;m++)
197 } // end of for(Int_t f=0;f<nFiles;f++)
199 // Draw a common legend in the 1st pad:
201 lRefFlowVsM->Draw("same");
203 } // end of void PlotRefFlowVsM()
205 // =====================================================================================
207 void PlotCumulantsVsM()
209 // Make plots for cumulants vs multiplicity: // to be improved
213 if(!plotOnly2ndAnd4thOrderCumulant)
215 c = new TCanvas("c","cumulants");
220 c = new TCanvas("c","cumulants",1200,500);
225 TLegend *legend = new TLegend(0.1,0.7,0.33,0.9);
226 legend->SetFillStyle(0);
227 //legend->SetHeader(" minClustersTpcRP");
229 TString qcFlag[4] = {"QC{2}","QC{4}","QC{6}","QC{8}"};
231 for(Int_t co=0;co<coMax;co++) // cumulant order
234 TH1D *styleHist = (TH1D*) StyleHist(qcFlag[co].Data(),co)->Clone();
235 if(styleHist){styleHist->Draw();}
240 for(Int_t ntm=0;ntm<nToyModels;ntm++)
242 TF1 *tm = ToyModel(co,k[ntm],vn[ntm],v2n[ntm]);
245 tm->SetLineColor(lineColorToyModel[ntm]);
248 } // for(Int_t ntm=0;ntm<nToyModels;ntm++)
249 } // end of if(showToyModel)
250 } // end of if(co==0)
255 for(Int_t ntm=0;ntm<nToyModels;ntm++)
257 TF1 *tm = ToyModel(co,k[ntm],vn[ntm],v2n[ntm]);
260 tm->SetLineColor(lineColorToyModel[ntm]);
263 } // for(Int_t ntm=0;ntm<nToyModels;ntm++)
264 } // end of if(showToyModel)
265 } // end of if(co==1)
268 for(Int_t s=0;s<nSim;s++)
271 if(showAlsoMCEPResults)
273 TGraph *mcepQC = GetErrorMesh(cumulantsVsM[s][2][co]);
276 mcepQC->SetFillColor(mcepMeshColor[s]);
277 mcepQC->Draw("lfsame");
279 if(co==0){legend->AddEntry(mcepQC,Form("%s (MC)",legendEntry[s].Data()),"f");}
280 } // end of if(showAlsoMCEPResults)
282 TGraph *errorMesh = GetErrorMesh(cumulantsVsM[s][0][co]);
285 errorMesh->SetFillColor(meshColor[s]);
286 if(!(showOnlyMCEPResults && showAlsoMCEPResults)){errorMesh->Draw("lfsame");}
288 if(co==0 && !(showOnlyMCEPResults && showAlsoMCEPResults)){legend->AddEntry(errorMesh,legendEntry[s].Data(),"f");}
289 } // end of if(Int_t s=0;s<nSim;s++)
290 // Theoretical lines:
291 if(showTheoreticalLines)
293 for(Int_t fv=0;fv<nFlowValues;fv++)
295 lines[fv][co]->Draw("lsame");
296 if(co==0){legend->AddEntry(lines[fv][co],Form("v_{2} = %g",v[fv]),"l");}
300 for(Int_t f=nSim;f<nFiles;f++)
303 if(cumulantsVsM[f][0][co])
305 cumulantsVsM[f][0][co]->Draw("e1same");
306 cumulantsVsM[f][0][co]->SetMarkerStyle(markerStyle[f-nSim]);
307 cumulantsVsM[f][0][co]->SetMarkerColor(markerColor[f-nSim]);
310 if(showAlsoGFCResults)
312 legend->AddEntry(cumulantsVsM[f][0][co],Form("%s (QC)",legendEntry[f].Data()),"p");
315 legend->AddEntry(cumulantsVsM[f][0][co],legendEntry[f].Data(),"p");
320 if(showAlsoGFCResults && cumulantsVsM[f][1][co])
322 cumulantsVsM[f][1][co]->Draw("lsame");
323 cumulantsVsM[f][1][co]->SetLineStyle(gfcLineStyle);
324 if(co==0){legend->AddEntry(cumulantsVsM[f][1][co],Form("%s (GFC)",legendEntry[f].Data()),"l");}
328 if(co==0){legend->Draw("same");}
329 } // end of for(Int_t co=0;co<4;co++) // cumulant order
331 // Plot also <reference multiplicity> vs # of RPs:
332 if(plotCumulantsVsReferenceMultiplicity && showReferenceMultiplicityVsNoOfRPs)
334 TCanvas *cRefMultVsNoOfRPs = new TCanvas("cRefMultVsNoOfRPs","#LTreference multiplicity#GT vs # of RPs",1200,600);
335 cRefMultVsNoOfRPs->Divide(nFiles,1);
336 for(Int_t f=0;f<nFiles;f++)
338 cRefMultVsNoOfRPs->cd(f+1);
339 if(refMultVsNoOfRPs[f])
341 refMultVsNoOfRPs[f]->SetTitle(legendEntry[f].Data());
342 refMultVsNoOfRPs[f]->GetXaxis()->SetRangeUser(0,refMultVsNoOfRPs[f]->FindLastBinAbove());
343 refMultVsNoOfRPs[f]->Draw();
347 cout<<"WARNING: refMultVsNoOfRPs[f] is NULL in Plot(), f = "<<f<<" !!!!"<<endl;
353 } // end of void PlotCumulantsVsM()
355 // =====================================================================================
357 void CrossCheckSettings()
359 // Cross-check user settings in this method.
361 if(showAlsoGFCResults && rebin)
364 cout<<" WARNING: Rebinning in M not supported for GFC yet !!!!"<<endl;
369 if(showAlsoGFCResults && plotCumulantsVsReferenceMultiplicity)
372 cout<<" WARNING: Showing GFC versus <reference multiplicity> not supported yet !!!!"<<endl;
377 } // end of void CrossCheckSettings()
379 // =====================================================================================
383 // Make lines denoting theoretical contribution of flow to cumulants.
385 for(Int_t fv=0;fv<nFlowValues;fv++)
387 lines[fv][0] = new TGraph(2);
388 lines[fv][0]->SetPoint(0,xMin[0],pow(v[fv],2));
389 lines[fv][0]->SetPoint(1,xMax[0]+0.5,pow(v[fv],2));
390 lines[fv][0]->SetLineColor(lineColor[fv]);
391 lines[fv][1] = new TGraph(2);
392 lines[fv][1]->SetPoint(0,xMin[1],-pow(v[fv],4));
393 lines[fv][1]->SetPoint(1,xMax[1]+0.5,-pow(v[fv],4));
394 lines[fv][1]->SetLineColor(lineColor[fv]);
395 lines[fv][2] = new TGraph(2);
396 lines[fv][2]->SetPoint(0,xMin[2],4.*pow(v[fv],6));
397 lines[fv][2]->SetPoint(1,xMax[2]+0.5,4.*pow(v[fv],6));
398 lines[fv][2]->SetLineColor(lineColor[fv]);
399 lines[fv][3] = new TGraph(2);
400 lines[fv][3]->SetPoint(0,xMin[3],-33.*pow(v[fv],8));
401 lines[fv][3]->SetPoint(1,xMax[3]+0.5,-33.*pow(v[fv],8));
402 lines[fv][3]->SetLineColor(lineColor[fv]);
405 } // end of void Lines()
407 // =====================================================================================
409 TF1* ToyModel(Int_t co, Double_t k, Double_t vn, Double_t v2n)
411 // Make theoretical curves for the toy model.
413 TF1 *function = NULL;
417 function = new TF1("function","([1]*[1]*(x-0.5-[0])+[0]-1)/((x-0.5)-1)",1.5,1000);
418 function->SetParameter(0,k);
419 function->SetParameter(1,vn);
423 function = new TF1("function","-1.*([1]*[1]*[1]*[1]*([0]-(x-0.5))*(12.*[0]-6.*[0]*[0]-12.*(x-0.5)-5.*[0]*(x-0.5)+6.*[0]*[0]*(x-0.5)+9.*(x-0.5)*(x-0.5)-3.*[0]*(x-0.5)*(x-0.5)-(x-0.5)*(x-0.5)*(x-0.5))+[1]*[1]*4.*([0]-1.)*(x-0.5-[0])*([0]*(x-0.5-1.)-2.*(x-0.5-2.))-[1]*[1]*[2]*2.*(x-0.5-1.)*([0]-1.)*(x-0.5-[0])*(x-0.5-2.*[0])-[2]*[2]*([0]-1.)*([0]-1.)*((x-0.5)-[0])*(x-0.5-1.)+([0]-1.)*(-6.+9*[0]-[0]*[0]+2.*(x-0.5)-5.*[0]*(x-0.5)+[0]*[0]*(x-0.5)))/((x-0.5-1.)*(x-0.5-1.)*(x-0.5-2.)*(x-0.5-3.))",3.5,100);
424 function->SetParameter(0,k);
425 function->SetParameter(1,vn);
426 function->SetParameter(2,v2n);
431 } // end of TF1* ToyModel(Int_t co)
433 // =====================================================================================
435 void CalculateReferenceFlowFromCumulantsVsM()
437 // Calculate reference flow from cumulants vs M:
439 for(Int_t f=0;f<nFiles;f++)
441 for(Int_t m=0;m<1+(Int_t)(showAlsoGFCResults)+(Int_t)(showAlsoMCEPResults);m++)
443 for(Int_t co=0;co<4;co++) // cumulant order
445 if(cumulantsVsM[f][m][co])
447 refFlowVsM[f][m][co] = (TH1D*)cumulantsVsM[f][m][co]->Clone(Form("%i,%i,%i",f,m,co));
448 if(!refFlowVsM[f][m][co]){cout<<" WARNING: "<<Form("refFlowVsM[%i][%i][%i]",f,m,co)<<" is NULL in PlotRefFlowVsM() !!!!"<<exit(0)<<endl;}
449 refFlowVsM[f][m][co]->Reset(); // to have empty histogram with the same binning as the one with cumulants
450 Int_t nBins = refFlowVsM[f][m][co]->GetNbinsX();
451 for(Int_t b=1;b<=nBins;b++)
453 Double_t qcVsM = cumulantsVsM[f][m][co]->GetBinContent(b); // QC vs M
454 Double_t qcErrorVsM = cumulantsVsM[f][m][co]->GetBinError(b); // QC vs M stat. error
455 Double_t vVsM = 0.; // reference flow vs M
456 Double_t vErrorVsM = 0.; // reference flow vs M stat. error
457 if(co==0) // 2nd order
461 vVsM = pow(qcVsM,1./2.);
462 vErrorVsM = (1./2.)*pow(qcVsM,-1./2.)*qcErrorVsM;
464 } // end of if(co==0) 2nd order
465 else if(co==1) // 4th order
469 vVsM = pow(-1.*qcVsM,1./4.);
470 vErrorVsM = (1./4.)*pow(-qcVsM,-3./4.)*qcErrorVsM;
472 } // end of if(co==1) 4th order
473 else if(co==2) // 6th order
477 vVsM = pow((1./4.)*qcVsM,1./6.);
478 vErrorVsM = (1./6.)*pow(2.,-1./3.)*pow(qcVsM,-5./6.)*qcErrorVsM;
480 } // end of if(co==2) 6th order
481 else if(co==3) // 8th order
485 vVsM = pow((-1./33.)*qcVsM,1./8.);
486 vErrorVsM = (1./8.)*pow(33.,-1./8.)*pow(-qcVsM,-7./8.)*qcErrorVsM;
488 } // end of if(co==3) 8th order
489 // Store final results and statisticial errror for reference flow:
490 refFlowVsM[f][m][co]->SetBinContent(b,vVsM);
491 refFlowVsM[f][m][co]->SetBinError(b,vErrorVsM);
492 } // end of for(Int_t b=1;b<=nBins;b++)
496 cout<<" WARNING: "<<Form("cumulantsVsM[%i][%i][%i]",f,m,co)<<" is NULL in CalculateReferenceFlowFromCumulantsVsM() !!!!"<<endl;
499 } // end of for(Int_t co=0;co<4;co++) // cumulant order
500 } // end of for(Int_t m=0;m<nMethods;m++)
501 } // end of for(Int_t f=0;f<nFiles;f++)
503 } // end of void CalculateReferenceFlowFromCumulantsVsM()
505 // =====================================================================================
509 // Print number of events and average multiplicities for each common output file.
512 cout<<"Accessed files:"<<endl;
514 for(Int_t f=0;f<nFiles;f++)
516 cout<<commonOutputFiles[f]->GetName()<<endl;
517 for(Int_t m=0;m<nMethods;m++)
519 AliFlowCommonHist *commonHist = NULL;
522 commonHist = dynamic_cast<AliFlowCommonHist*> (lists[f][m]->FindObject(Form("AliFlowCommonHist%s",method[m].Data())));
526 if(commonHist && commonHist->GetHistMultRP())
528 nEvts = commonHist->GetHistMultRP()->GetEntries();
529 AvM = commonHist->GetHistMultRP()->GetMean();
531 if(!(strcmp(method[m].Data(),"QC")))
533 cout<<Form("%s:",method[m].Data())<<" <M> = "<<AvM<<", N = "<<nEvts<<endl;
535 if(!(strcmp(method[m].Data(),"GFC")) && showAlsoGFCResults)
537 cout<<Form("%s:",method[m].Data())<<" <M> = "<<AvM<<", N = "<<nEvts<<endl;
539 } // end of for(Int_t m=0;m<nMethods;m++)
541 } // end of for(Int_t f=0;f<nFiles;f++)
543 } // end of void Print()
545 // =====================================================================================
547 void DetermineMinMax()
549 // Determine ranges for plots.
551 for(Int_t co=0;co<4;co++)
553 xMin[co] = 0.; yMin[co] = 44.;
554 xMax[co] = -440000.; yMax[co] = -44.;
557 Double_t tfc[nFlowValues][4] = {{0.}}; // theoretical flow contribution
558 for(Int_t fv=0;fv<nFlowValues;fv++)
560 tfc[fv][0] = pow(v[fv],2);
561 tfc[fv][1] = -pow(v[fv],4);
562 tfc[fv][2] = 4.*pow(v[fv],6);
563 tfc[fv][3] = -33.*pow(v[fv],8);
566 for(Int_t f=0;f<nFiles;f++)
568 for(Int_t m=0;m<1+(Int_t)(showAlsoGFCResults)+(Int_t)(showAlsoMCEPResults);m++)
570 for(Int_t co=0;co<4;co++)
572 if(cumulantsVsM[f][m][co])
574 Int_t nBins = cumulantsVsM[f][m][co]->GetXaxis()->GetNbins();
575 for(Int_t b=1;b<=nBins;b++)
577 Double_t result = cumulantsVsM[f][m][co]->GetBinContent(b);
578 Double_t error = cumulantsVsM[f][m][co]->GetBinError(b);
579 if(TMath::Abs(result)>1.e-44 && TMath::Abs(error)>1.e-44)
582 if(yMin[co] > result-error){yMin[co] = result-error;} // min value
583 if(yMax[co] < result+error){yMax[co] = result+error;} // max value
585 if(xMax[co] < cumulantsVsM[f][m][co]->GetBinLowEdge(b+1)){xMax[co] = cumulantsVsM[f][m][co]->GetBinLowEdge(b+1);}
587 } // end of for(Int_t b=1;b<=cumulantsVsM[f][m][co]->GetXaxis()->GetNbins();b++)
588 // theoretical contributions:
589 if(showTheoreticalLines)
591 for(Int_t fv=0;fv<nFlowValues;fv++)
593 if(yMin[co] > tfc[fv][co]) {yMin[co] = tfc[fv][co];} // min value
594 if(yMax[co] < tfc[fv][co]) {yMax[co] = tfc[fv][co];} // max value
595 } // end of for(Int_t fv=0;fv<nFlowValues;fv++)
596 } // end of if(showTheoreticalLines)
597 } // end of if(cumulantsVsM[f][m][co])
598 } // end of for(Int_t co=0;co<4;co++)
599 } // end of for(Int_t m=0;m<nMethods;m++)
600 } // end of for(Int_t f=0;f<nFiles;f++)
602 } // end of void DetermineMinMax()
604 // =====================================================================================
608 // Get all histograms and profiles.
610 // a) Get profiles holding results for <refMult> vs number of Reference Particles (RPs);
611 // b) Get histograms holding results for cumulants and reference flow vs multiplicity.
613 // a) Get profiles holding results for <refMult> vs number of Reference Particles (RPs):
614 if(plotCumulantsVsReferenceMultiplicity){GetProfileRefMultVsNoOfRPs();}
616 // b) Get histograms holding results for cumulants and reference flow vs multiplicity:
617 TString qcFlag[4] = {"QC{2}","QC{4}","QC{6}","QC{8}"};
618 TString gfcFlag[4] = {"GFC{2}","GFC{4}","GFC{6}","GFC{8}"};
619 for(Int_t f=0;f<nFiles;f++)
621 for(Int_t m=0;m<nMethods;m++)
624 if(!(strcmp(method[m].Data(),"QC")) && lists[f][m])
626 temp = dynamic_cast<TList*> (lists[f][m]->FindObject("Integrated Flow"));
627 if(temp) {temp = dynamic_cast<TList*> (temp->FindObject("Results"));}
630 for(Int_t co=0;co<4;co++)
632 // Cumulants vs multiplicity:
633 cumulantsVsM[f][m][co] = dynamic_cast<TH1D*> (temp->FindObject(Form("fIntFlowQcumulantsVsM, %s",qcFlag[co].Data())));
634 if(plotCumulantsVsReferenceMultiplicity && cumulantsVsM[f][m][co])
636 cumulantsVsM[f][m][co] = Map(cumulantsVsM[f][m][co],f);
638 if(rebin && cumulantsVsM[f][m][co])
640 cumulantsVsM[f][m][co] = Rebin(cumulantsVsM[f][m][co],co);
642 } // end of for(Int_t co=0;co<4;co++)
644 } // end of if(!(strcmp(method[m].Data(),"QC")))
645 else if(!(strcmp(method[m].Data(),"GFC")) && lists[f][m])
647 temp = dynamic_cast<TList*> (lists[f][m]->FindObject("Reference Flow"));
648 if(temp) {temp = dynamic_cast<TList*> (temp->FindObject("Results"));}
651 for(Int_t co=0;co<4;co++)
653 cumulantsVsM[f][m][co] = dynamic_cast<TH1D*> (temp->FindObject(Form("fReferenceFlowCumulantsVsM, %s",gfcFlag[co].Data())));
654 if(showAlsoGFCResults && !cumulantsVsM[f][m][co])
657 cout<<Form(" WARNING: Couldn't access histogram fReferenceFlowCumulantsVsM, %s in the ",gfcFlag[co].Data())<<endl;
658 cout<<" file "<<commonOutputFiles[f]->GetName()<<" !!!!"<<endl;
659 cout<<" Did you enable calculation of GFC vs M in the analysis which produced this file?"<<endl;
662 if(plotCumulantsVsReferenceMultiplicity && cumulantsVsM[f][m][co])
664 cumulantsVsM[f][m][co] = Map(cumulantsVsM[f][m][co],f);
666 if(rebin && cumulantsVsM[f][m][co])
668 cumulantsVsM[f][m][co] = Rebin(cumulantsVsM[f][m][co],co);
670 } // end of for(Int_t co=0;co<4;co++)
672 } // end of else if(!(strcmp(method[m].Data(),"GFC")))
673 else if(!(strcmp(method[m].Data(),"MCEP")) && lists[f][m])
675 TProfile *mcepVsM = dynamic_cast<TProfile*> (lists[f][m]->FindObject("FlowPro_VsM_MCEP"));
679 cout<<" WARNING: Couldn't access TProfile FlowPro_VsM_MCEP in the file "<<commonOutputFiles[f]->GetName()<<" !!!!"<<endl;
683 for(Int_t co=0;co<4;co++)
685 cumulantsVsM[f][m][co] = new TH1D("",Form("Monte Carlo QC{%i} #font[72]{vs} M",2*(co+1)),
686 mcepVsM->GetNbinsX(),mcepVsM->GetBinLowEdge(1),mcepVsM->GetBinLowEdge(1+mcepVsM->GetNbinsX()));
687 } // end of for(Int_t co=0;co<4;co++)
688 for(Int_t b=1;b<=mcepVsM->GetNbinsX();b++)
690 Double_t v = mcepVsM->GetBinContent(b);
691 Double_t vError = mcepVsM->GetBinError(b);
692 if(TMath::Abs(v)<1.e-44 || TMath::Abs(vError)<1.e-44){continue;}
693 // Monte Carlo QC{2}:
694 Double_t qc2 = pow(v,2.);
695 Double_t qc2Error = 2.*TMath::Abs(v)*vError; // error propagation for f(x) = x^2
696 cumulantsVsM[f][m][0]->SetBinContent(b,qc2);
697 cumulantsVsM[f][m][0]->SetBinError(b,qc2Error);
698 // Monte Carlo QC{4}:
699 Double_t qc4 = -pow(v,4.);
700 Double_t qc4Error = 4.*TMath::Abs(pow(v,3.))*vError; // error propagation for f(x) = -x^4
701 cumulantsVsM[f][m][1]->SetBinContent(b,qc4);
702 cumulantsVsM[f][m][1]->SetBinError(b,qc4Error);
703 // Monte Carlo QC{6}:
704 Double_t qc6 = 4.*pow(v,6.);
705 Double_t qc6Error = 24.*TMath::Abs(pow(v,5.))*vError; // error propagation for f(x) = 4x^6
706 cumulantsVsM[f][m][2]->SetBinContent(b,qc6);
707 cumulantsVsM[f][m][2]->SetBinError(b,qc6Error);
708 // Monte Carlo QC{8}:
709 Double_t qc8 = -33.*pow(v,8.);
710 Double_t qc8Error = 264.*TMath::Abs(pow(v,7.))*vError; // error propagation for f(x) = -33x^8
711 cumulantsVsM[f][m][3]->SetBinContent(b,qc8);
712 cumulantsVsM[f][m][3]->SetBinError(b,qc8Error);
713 } // end of for(Int_t b=1;b<=mcepVsM->GetNbinsX();b++)
714 for(Int_t co=0;co<4;co++)
716 if(plotCumulantsVsReferenceMultiplicity && cumulantsVsM[f][m][co])
718 cumulantsVsM[f][m][co] = Map(cumulantsVsM[f][m][co],f);
720 if(rebin && cumulantsVsM[f][m][co])
722 cumulantsVsM[f][m][co] = Rebin(cumulantsVsM[f][m][co],co);
724 } // end of for(Int_t co=0;co<4;co++)
725 } // end of else if(!(strcmp(method[m].Data(),"MCEP")))
726 } // end of for(Int_t m=0;m<nMethods;m++)
727 } // end of for(Int_t f=0;f<nFiles;f++)
730 for(Int_t f=0;f<nFiles;f++)
732 for(Int_t m=0;m<nMethods;m++)
734 for(Int_t co=0;co<4;co++)
736 if(cumulantsVsM[f][m][co]){counter++;}
744 cout<<" WARNING: Couldn't access a single histogram with results vs multiplicity !!!!"<<endl;
745 cout<<" Did you enable this calculation before running over data?"<<endl;
750 } // end of void GetHistograms()
752 // =====================================================================================
754 void GetProfileRefMultVsNoOfRPs()
756 // Get profiles holding results for <reference multiplicity> vs number of Reference Particles (RPs).
758 // Set here from which method's output file this profile will be accessed:
759 TString methodName = "QC"; // Alternatives are GFC and MCEP
761 for(Int_t m=0;m<nMethods;m++)
763 if(method[m] == methodName){i=m;}
768 cout<<" WARNING: Unknown method name in GetProfileRefMultVsNoOfRPs() !!!!"<<endl;
769 cout<<" Try something else for TString methodName in GetProfileRefMultVsNoOfRPs()."<<endl;
773 for(Int_t f=0;f<nFiles;f++)
775 AliFlowCommonHist *commonHist = NULL;
778 commonHist = dynamic_cast<AliFlowCommonHist*> (lists[f][i]->FindObject(Form("AliFlowCommonHist%s",method[i].Data())));
782 cout<<Form(" WARNING: lists[%i][%i] is NULL in GetProfileRefMultVsNoOfRPs() !!!!",f,i)<<endl;
783 cout<<Form(" Did you use method %s in the analysis which has produced output",method[i].Data())<<endl;
784 cout<<Form(" file %s?",commonOutputFiles[f]->GetName())<<endl;
786 if(commonHist && commonHist->GetRefMultVsNoOfRPs())
788 refMultVsNoOfRPs[f] = commonHist->GetRefMultVsNoOfRPs();
792 cout<<" WARNING: commonHist && commonHist->GetRefMultVsNoOfRPs() is NULL in GetProfileRefMultVsNoOfRPs() !!!!"<<endl;
795 } // end of for(Int_t f=0;f<nFiles;f++)
799 } // end of void GetProfileRefMultVsNoOfRPs()
801 // =====================================================================================
803 TH1D* Map(TH1D *hist, Int_t f)
805 // Map cumulant versus # of RPs into cumulants versus <reference multiplicity>.
807 if(!refMultVsNoOfRPs[f])
810 cout<<Form(" WARNING: refMultVsNoOfRPs[%i] is NULL in Map(...) !!!!",f)<<endl;
814 Int_t rpMinBin = refMultVsNoOfRPs[f]->FindFirstBinAbove(); // FindFirstBinAbove(Double_t threshold = 0, Int_t axis = 1)
815 Int_t rpMaxBin = refMultVsNoOfRPs[f]->FindLastBinAbove(); // FindLastBinAbove(Double_t threshold = 0, Int_t axis = 1)
816 Int_t rmMinBin = 440000;;
817 Int_t rmMaxBin = (Int_t)TMath::Floor(refMultVsNoOfRPs[f]->GetMaximum());
818 for(Int_t rpBin=rpMinBin;rpBin<=rpMaxBin;rpBin++) // non-empty # of RPs bins
820 if(refMultVsNoOfRPs[f]->GetBinContent(rpBin)>0. && refMultVsNoOfRPs[f]->GetBinContent(rpBin)<rmMinBin)
822 rmMinBin = (Int_t)TMath::Floor(refMultVsNoOfRPs[f]->GetBinContent(rpBin));
824 } // end of for(Int_t rpBin=rpMinBin;rpBin<=rpMaxBin;rpBin++) // non-empty # of RPs bins
828 temp = (TH1D*) hist->Clone();
830 for(Int_t rmBin=rmMinBin;rmBin<=rmMaxBin;rmBin++) // reference multiplicity bins
834 Double_t dSum1 = 0.; // sum value_i/(error_i)^2
835 Double_t dSum2 = 0.; // sum 1/(error_i)^2
836 for(Int_t rpBin=rpMinBin;rpBin<=rpMaxBin;rpBin++) // # of RPs bins
838 if((Int_t)TMath::Floor(refMultVsNoOfRPs[f]->GetBinContent(rpBin)) >= temp->GetBinLowEdge(rmBin) &&
839 (Int_t)TMath::Floor(refMultVsNoOfRPs[f]->GetBinContent(rpBin)) < temp->GetBinLowEdge(rmBin+1))
841 value = hist->GetBinContent(rpBin);
842 error = hist->GetBinError(rpBin);
845 dSum1+=value/(error*error);
846 dSum2+=1./(error*error);
849 } // end of for(Int_t rpBin=1;rpBin<=nBins;rpBin++) // # of RPs bins
852 temp->SetBinContent(rmBin,dSum1/dSum2);
853 temp->SetBinError(rmBin,pow(1./dSum2,0.5));
855 } // end of for(Int_t rmBin=1;rmBin<=nBins;rmBin++) // reference multiplicity bins
862 // =====================================================================================
864 TH1D* Rebin(TH1D *hist, Int_t co)
866 // Rebin original histograms.
868 if(nMergedBins[co] == 0)
871 cout<<Form(" WARNING: nMergedBins[%i] == 0 !!!!",co)<<endl;
878 cout<<" WARNING: hist is NULL in Rebin() !!!!"<<endl;
883 Int_t nBinsOld = hist->GetXaxis()->GetNbins();
884 if(nBinsOld == 0){cout<<" WARNING: nBinsOld == 0 !!!!"<<endl;exit(0);}
885 Double_t xMinOld = hist->GetXaxis()->GetXmin();
886 Double_t xMaxOld = hist->GetXaxis()->GetXmax();
887 Double_t binWidthOld = (xMaxOld-xMinOld)/nBinsOld;
888 Int_t nBinsNew = TMath::Floor(nBinsOld/nMergedBins[co]);
889 Double_t xMinNew = xMinOld;
890 Double_t xMaxNew = xMinOld + nBinsNew*nMergedBins[co]*binWidthOld;
892 TH1D *temp = new TH1D("","",nBinsNew,xMinNew,xMaxNew); // rebinned histogram
896 Double_t dSum1 = 0.; // sum value_i/(error_i)^2
897 Double_t dSum2 = 0.; // sum 1/(error_i)^2
898 for(Int_t b=1;b<=nBinsOld;b++)
900 value = hist->GetBinContent(b);
901 error = hist->GetBinError(b);
904 dSum1+=value/(error*error);
905 dSum2+=1./(error*error);
907 if(b%nMergedBins[co] == 0)
911 temp->SetBinContent(binNew,dSum1/dSum2);
912 temp->SetBinError(binNew,pow(1./dSum2,0.5));
917 } // end of if(b%nMergedBins[co] == 0)
918 } // end of for(Int_t b=1;b<=nBinsOld;b++)
922 } // end of TH1D* Rebin(TH1D *hist, Int_t co)
924 // =====================================================================================
926 TGraphErrors* GetGraphErrors(Int_t bin, Int_t nFiles, TH1D** qc)
928 TGraphErrors *ge = new TGraphErrors(nFiles);
929 for(Int_t f=0;f<nFiles;f++)
931 ge->SetPoint(f,f+0.5,qc[f]->GetBinContent(bin+1));
932 ge->SetPointError(f,0,qc[f]->GetBinError(bin+1));
937 } // end of TGraphErrors* GetGraphErrors(Int_t bin, Int_t nFiles, TH1D** qc)
939 // =====================================================================================
941 TH1D* StyleHist(TString yAxisTitle, Int_t co)
945 TH1D *styleHist = new TH1D(yAxisTitle.Data(),"",(Int_t)xMax[co],0,xMax[co]);
947 styleHist->GetYaxis()->SetRangeUser(yMin[co],yMax[co]);
949 if(plotCumulantsVsReferenceMultiplicity)
951 styleHist->GetXaxis()->SetTitle("#LTreference multiplicity#GT");
954 styleHist->GetXaxis()->SetTitle("# of RPs");
957 styleHist->GetYaxis()->SetTitle(yAxisTitle.Data());
961 } // end of TH1D* StyleHist(TString yAxisTitle, Int_t co)
963 // ===========================================================================================
965 TGraph* GetErrorMesh(TH1D *hist)
971 Int_t nBins = hist->GetNbinsX();
974 // Counting the non-empty bins:
975 Int_t nNonEmptyBins = 0;
976 for(Int_t i=1;i<nBins+1;i++)
978 value = hist->GetBinContent(i);
979 error = hist->GetBinError(i);
980 if(TMath::Abs(value)>0.0 && error>0.0)
984 } // end of for(Int_t i=1;i<nBins+1;i++)
986 TGraph *errorMesh = new TGraph(2*nNonEmptyBins+1);
988 Double_t binCenter = 0.;
989 for(Int_t i=1;i<nBins+1;i++)
991 value = hist->GetBinContent(i);
992 error = hist->GetBinError(i);
993 // Setting up the the mesh:
994 if(TMath::Abs(value)>0.0 && error>0.0)
996 binCenter = hist->GetBinCenter(i);
997 errorMesh->SetPoint(count,binCenter,value+error);
998 errorMesh->SetPoint(2*nNonEmptyBins-(count+1),binCenter,value-error);
1001 } // end of for(Int_t i=1;i<nBins+1;i++)
1002 // Closing the mesh area:
1003 Double_t xStart = 0.;
1004 Double_t yStart = 0.;
1005 errorMesh->GetPoint(0,xStart,yStart);
1006 errorMesh->SetPoint(2*nNonEmptyBins,xStart,yStart);
1011 } // end of TGraph* GetErrorMesh(TH1D *hist)
1013 // ===========================================================================================
1015 void GlobalSettings()
1017 // Settings which will affect all plots.
1019 gROOT->SetStyle("Plain"); // default color is white instead of gray
1020 gStyle->SetOptStat(0); // remove stat. box from all histos
1021 TGaxis::SetMaxDigits(4); // prefer exp notation for 5 and more significant digits
1023 } // end of void GlobalSettings()
1025 // ===========================================================================================
1029 // Get from common output files the lists holding histograms for each method.
1031 TString fileName[nFiles][nMethods];
1032 TDirectoryFile *dirFile[nFiles][nMethods] = {{NULL}};
1033 TString listName[nFiles][nMethods];
1034 for(Int_t f=0;f<nFiles;f++)
1036 for(Int_t i=0;i<nMethods;i++)
1038 // Form a file name for each method:
1039 fileName[f][i]+="output";
1040 fileName[f][i]+=method[i].Data();
1041 fileName[f][i]+="analysis";
1042 fileName[f][i]+=type[f].Data();
1043 // Access this file:
1044 if(commonOutputFiles[f]){dirFile[f][i] = (TDirectoryFile*)commonOutputFiles[f]->FindObjectAny(fileName[f][i].Data());}
1045 // Form a list name for each method:
1048 TList* listTemp = dirFile[f][i]->GetListOfKeys();
1049 if(listTemp && listTemp->GetEntries() == 1)
1051 listName[f][i] = listTemp->At(0)->GetName(); // to be improved - implemented better
1052 dirFile[f][i]->GetObject(listName[f][i].Data(),lists[f][i]);
1056 cout<<" WARNING: Couldn't find a list "<<listName[f][i].Data()<<" in "<<commonOutputFiles[f]->GetName()<<" !!!!"<<endl;
1057 cout<<" Did you use method "<<method[i].Data()<<" in the analysis which produced this file?"<<endl;
1061 cout<<" WARNING: Couldn't find a file "<<fileName[f][i].Data()<<".root in "<<commonOutputFiles[f]->GetName()<<" !!!!"<<endl;
1063 } // end of for(Int_t i=0;i<nMethods;i++)
1064 } // end of for(Int_t f=0;f<nFiles;f++)
1066 } // end of void GetLists()
1068 // ===========================================================================================
1070 void AccessCommonOutputFiles(TString commonOutputFileName)
1072 // Access all output files.
1074 for(Int_t f=0;f<nFiles;f++)
1076 if(bLookInSubdirectories)
1078 if(!(gSystem->AccessPathName(Form("%s/%s/%s",gSystem->pwd(),files[f].Data(),commonOutputFileName.Data()),kFileExists)))
1080 commonOutputFiles[f] = TFile::Open(Form("%s/%s/%s",gSystem->pwd(),files[f].Data(),commonOutputFileName.Data()),"READ");
1084 cout<<" WARNING: Couldn't find the file "<<Form("%s/%s/%s",gSystem->pwd(),files[f].Data(),commonOutputFileName.Data())<<" !!!!"<<endl;
1085 cout<<" Did you specify correctly all paths in TString files[nFiles]?"<<endl;
1086 cout<<" Or you are misusing 'Bool_t bLookInSubdirectories'? "<<endl;
1090 } else // to if(bLookInSubdirectories)
1092 if(!(gSystem->AccessPathName(Form("%s/%s%s",gSystem->pwd(),files[f].Data(),".root"),kFileExists)))
1094 commonOutputFiles[f] = TFile::Open(Form("%s/%s%s",gSystem->pwd(),files[f].Data(),".root"),"READ");
1098 cout<<" WARNING: Couldn't find the file "<<Form("%s/%s%s",gSystem->pwd(),files[f].Data(),".root")<<" !!!!"<<endl;
1099 cout<<" Did you specify correctly all file names in TString files[nFiles]?"<<endl;
1104 } // end of for(Int_t f=0;f<nFiles;f++)
1106 } // void AccessCommonOutputFiles(TString commonOutputFileName);
1108 // ===========================================================================================
1110 void LoadLibrariesPC(const libModes analysisMode) {
1112 //--------------------------------------
1113 // Load the needed libraries most of them already loaded by aliroot
1114 //--------------------------------------
1115 //gSystem->Load("libTree");
1116 gSystem->Load("libGeom");
1117 gSystem->Load("libVMC");
1118 gSystem->Load("libXMLIO");
1119 gSystem->Load("libPhysics");
1121 //----------------------------------------------------------
1122 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
1123 //----------------------------------------------------------
1124 if (analysisMode==mLocal) {
1125 //--------------------------------------------------------
1126 // If you want to use already compiled libraries
1127 // in the aliroot distribution
1128 //--------------------------------------------------------
1130 //==================================================================================
1131 //load needed libraries:
1132 gSystem->AddIncludePath("-I$ROOTSYS/include");
1133 //gSystem->Load("libTree");
1136 gSystem->AddIncludePath("-I$ALICE_ROOT/include");
1137 //gSystem->Load("libANALYSIS");
1138 gSystem->Load("libPWGflowBase");
1139 //cerr<<"libPWGflowBase loaded ..."<<endl;
1143 else if (analysisMode==mLocalSource) {
1145 // In root inline compile
1148 gROOT->LoadMacro("Base/AliFlowCommonConstants.cxx+");
1149 gROOT->LoadMacro("Base/AliFlowLYZConstants.cxx+");
1152 gROOT->LoadMacro("Base/AliFlowVector.cxx+");
1153 gROOT->LoadMacro("Base/AliFlowTrackSimple.cxx+");
1154 gROOT->LoadMacro("Base/AliFlowTrackSimpleCuts.cxx+");
1155 gROOT->LoadMacro("Base/AliFlowEventSimple.cxx+");
1157 // Output histosgrams
1158 gROOT->LoadMacro("Base/AliFlowCommonHist.cxx+");
1159 gROOT->LoadMacro("Base/AliFlowCommonHistResults.cxx+");
1160 gROOT->LoadMacro("Base/AliFlowLYZHist1.cxx+");
1161 gROOT->LoadMacro("Base/AliFlowLYZHist2.cxx+");
1163 cout << "finished loading macros!" << endl;
1167 } // end of void LoadLibraries(const libModes analysisMode)