3 // Set how many output analysis files in total you want to access:
4 const Int_t nFiles = 1;
6 // Set how many of those output analysis files you want to represent with a mesh (usually used to represent results of simulations):
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))
10 TString files[nFiles] = {"data"};
12 // Set analysis types for all output analysis files (can be "ESD","AOD","MC",""):
13 TString type[nFiles] = {"ESD"};
16 Int_t meshColor[nSim] = {};
19 Int_t markerStyle[nFiles-nSim] = {kStar};
22 Int_t markerColor[nFiles-nSim] = {kBlack};
24 // Set legend entries:
25 TString legendEntry[nFiles] = {"pp example run"};
27 // Set if you whish to plot cumulants versus <reference multiplicity> (by default they are plotted versus # of RPs):
28 Bool_t plotCumulantsVsReferenceMultiplicity = kTRUE;
30 // Set flow values whose theoretical contribution to cumulants will be shown on the plots with the straight coloured lines:
31 Bool_t showTheoreticalLines = kFALSE;
32 const Int_t nFlowValues = 2;
33 Double_t v[nFlowValues] = {0.1,0.05};
34 Int_t lineColor[nFlowValues] = {kRed,kBlue};
36 // If the statistical error of 6th and 8th order cumulant is huge you may prefer not to show them:
37 Bool_t plotOnly2ndAnd4thOrderCumulant = kTRUE;
39 // For comparison sake show also GFC results with dotted line:
40 Bool_t showAlsoGFCResults = kFALSE;
41 Int_t gfcLineStyle = 3;
43 // Set method names which calculate cumulants vs multiplicity:
44 const Int_t nMethods = 2;
45 TString method[nMethods] = {"QC","GFC"};
47 TFile *commonOutputFiles[nFiles] = {NULL}; // common output files "AnalysisResults.root"
48 TList *lists[nFiles][nMethods] = {{NULL}}; // lists cobj<method> holding objects with results for each method
49 TH1D *cumulantsVsM[nFiles][nMethods][4] = {{{NULL}}}; // histograms with results for cumulants vs multiplicity (4 stands for 4 cumulant orders)
50 TLine *lines[nFlowValues][4] = {{NULL}}; // lines denoting theoretical flow contribution to cumulants
51 TProfile *refMultVsNoOfRPs = NULL; // <reference multipicity> versus # of RPs
54 Double_t xMin[4]={0.};
55 Double_t xMax[4]={0.};
56 Double_t yMin[4]={0.};
57 Double_t yMax[4]={0.};
59 enum libModes {mLocal,mLocalSource};
61 void plotCumulants(Int_t analysisMode=mLocal)
63 // analysisMode: if analysisMode = mLocal -> analyze data on your computer using aliroot
64 // if analysisMode = mLocalSource -> analyze data on your computer using root + source files
66 // Load needed libraries:
67 LoadLibrariesPC(analysisMode);
69 // Access all common output files:
70 TString commonOutputFileName = "AnalysisResults.root";
71 AccessCommonOutputFiles(commonOutputFileName);
73 // Get from common output files the lists holding histograms for each method:
76 // Get histograms with results for cumulants vs multiplicity:
79 // Determine ranges for plots:
82 // Make lines which indicate theoretical contributions of flow to cumulants:
85 // Print number of events and average multiplicities for each common output file:
91 // Global settings which will affect all plots:
94 } // end of void plotCumulants(Int_t analysisMode=mLocal)
96 // =====================================================================================
104 if(!plotOnly2ndAnd4thOrderCumulant)
106 c = new TCanvas("c","cumulants");
111 c = new TCanvas("c","cumulants",1200,500);
116 TLegend *legend = new TLegend(0.1,0.7,0.33,0.9);
117 legend->SetFillStyle(0);
119 TString qcFlag[4] = {"QC{2}","QC{4}","QC{6}","QC{8}"};
121 for(Int_t co=0;co<coMax;co++) // cumulant order
124 StyleHist(qcFlag[co].Data(),co)->Draw();
126 for(Int_t s=0;s<nSim;s++)
128 TGraph *errorMesh = GetErrorMesh(cumulantsVsM[s][0][co]);
131 errorMesh->SetFillColor(meshColor[s]);
132 errorMesh->Draw("lfsame");
134 if(co==0){legend->AddEntry(errorMesh,legendEntry[s].Data(),"f");}
135 } // end of if(Int_t s=0;s<nSim;s++)
137 for(Int_t f=nSim;f<nFiles;f++)
139 // Theoretical lines:
140 if(showTheoreticalLines)
142 if(f==nSim) // plot them only once
144 for(Int_t fv=0;fv<nFlowValues;fv++)
146 lines[fv][co]->Draw("same");
147 if(co==0){legend->AddEntry(lines[fv][co],Form("v_{2} = %g",v[fv]),"l");}
152 if(cumulantsVsM[f][0][co])
154 cumulantsVsM[f][0][co]->Draw("e1same");
155 cumulantsVsM[f][0][co]->SetMarkerStyle(markerStyle[f-nSim]);
156 cumulantsVsM[f][0][co]->SetMarkerColor(markerColor[f-nSim]);
159 if(showAlsoGFCResults)
161 legend->AddEntry(cumulantsVsM[f][0][co],Form("%s (QC)",legendEntry[f].Data()),"p");
164 legend->AddEntry(cumulantsVsM[f][0][co],legendEntry[f].Data(),"p");
169 if(showAlsoGFCResults && cumulantsVsM[f][1][co])
171 cumulantsVsM[f][1][co]->Draw("lsame");
172 cumulantsVsM[f][1][co]->SetLineStyle(gfcLineStyle);
173 if(co==0){legend->AddEntry(cumulantsVsM[f][1][co],Form("%s (GFC)",legendEntry[f].Data()),"l");}
177 if(co==0){legend->Draw("same");}
178 } // end of for(Int_t co=0;co<4;co++) // cumulant order
180 // Plot also <reference multiplicity> vs # of RPs:
181 if(plotCumulantsVsReferenceMultiplicity)
185 TCanvas *cRefMultVsNoOfRPs = new TCanvas("cRefMultVsNoOfRPs","#LTreference multiplicity#GT vs # of RPs");
186 refMultVsNoOfRPs->SetTitle("");
187 refMultVsNoOfRPs->GetXaxis()->SetRangeUser(0,refMultVsNoOfRPs->FindLastBinAbove());
188 refMultVsNoOfRPs->Draw();
192 cout<<"WARNING: refMultVsNoOfRPs is NULL in Plot() !!!!"<<endl;
197 } // end of void Plot()
199 // =====================================================================================
203 // Make lines denoting theoretical contribution of flow to cumulants.
205 for(Int_t co=0;co<4;co++)
211 for(Int_t fv=0;fv<nFlowValues;fv++)
213 lines[fv][0] = new TLine(xMin[0],pow(v[fv],2),xMax[0]+0.5,pow(v[fv],2));
214 lines[fv][0]->SetLineColor(lineColor[fv]);
215 lines[fv][1] = new TLine(xMin[1],-pow(v[fv],4),xMax[1]+0.5,-pow(v[fv],4));
216 lines[fv][1]->SetLineColor(lineColor[fv]);
217 lines[fv][2] = new TLine(xMin[2],4.*pow(v[fv],6),xMax[2]+0.5,4.*pow(v[fv],6));
218 lines[fv][2]->SetLineColor(lineColor[fv]);
219 lines[fv][3] = new TLine(xMin[3],-33.*pow(v[fv],8),xMax[3]+0.5,-33.*pow(v[fv],8));
220 lines[fv][3]->SetLineColor(lineColor[fv]);
223 } // end of void Lines()
225 // =====================================================================================
229 // Print number of events and average multiplicities for each common output file.
232 cout<<"Accessed files:"<<endl;
234 for(Int_t f=0;f<nFiles;f++)
236 cout<<commonOutputFiles[f]->GetName()<<endl;
237 for(Int_t m=0;m<nMethods;m++)
239 AliFlowCommonHist *commonHist = dynamic_cast<AliFlowCommonHist*> (lists[f][m]->FindObject(Form("AliFlowCommonHist%s",method[m].Data())));
240 Double_t nEvts = -1.;
242 if(commonHist && commonHist->GetHistMultRP())
244 nEvts = commonHist->GetHistMultRP()->GetEntries();
245 AvM = commonHist->GetHistMultRP()->GetMean();
247 if(!(strcmp(method[m].Data(),"QC")))
249 cout<<Form("%s:",method[m].Data())<<" <M> = "<<AvM<<", N = "<<nEvts<<endl;
251 if(!(strcmp(method[m].Data(),"GFC")) && showAlsoGFCResults)
253 cout<<Form("%s:",method[m].Data())<<" <M> = "<<AvM<<", N = "<<nEvts<<endl;
257 } // end of for(Int_t f=0;f<nFiles;f++)
259 } // end of void Print()
261 // =====================================================================================
263 void DetermineMinMax()
265 // Determine ranges for plots.
267 for(Int_t co=0;co<4;co++)
269 xMin[co] = 0.; yMin[co] = 44.;
270 xMax[co] = -440000.; yMax[co] = -44.;
273 Double_t tfc[nFlowValues][4] = {{0.}}; // theoretical flow contribution
274 for(Int_t fv=0;fv<nFlowValues;fv++)
276 tfc[fv][0] = pow(v[fv],2);
277 tfc[fv][1] = -pow(v[fv],4);
278 tfc[fv][2] = 4.*pow(v[fv],6);
279 tfc[fv][3] = -33.*pow(v[fv],8);
282 for(Int_t f=0;f<nFiles;f++)
284 for(Int_t m=0;m<nMethods;m++)
286 for(Int_t co=0;co<4;co++)
288 if(cumulantsVsM[f][m][co])
290 for(Int_t b=1;b<=cumulantsVsM[f][m][co]->GetXaxis()->GetNbins();b++)
292 Double_t result = cumulantsVsM[f][m][co]->GetBinContent(b);
293 Double_t error = cumulantsVsM[f][m][co]->GetBinError(b);
294 if(TMath::Abs(result)>1.e-44 && TMath::Abs(error)>1.e-44)
297 if(yMin[co] > result-error){yMin[co] = result-error;} // min value
298 if(yMax[co] < result+error) {yMax[co] = result+error;} // max value
302 } // end of for(Int_t b=1;b<=cumulantsVsM[f][m][co]->GetXaxis()->GetNbins();b++)
303 // theoretical contributions:
304 for(Int_t fv=0;fv<nFlowValues;fv++)
306 //if(yMin[co] > tfc[fv][0]) {yMin[co] = tfc[fv][0];} // min value
307 //if(yMax[co] < tfc[fv][0]) {yMax[co] = tfc[fv][0];} // max value
308 } // end of for(Int_t fv=0;fv<nFlowValues;fv++)
309 } // end of if(cumulantsVsM[f][m][co])
310 } // end of for(Int_t co=0;co<4;co++)
311 } // end of for(Int_t m=0;m<nMethods;m++)
312 } // end of for(Int_t f=0;f<nFiles;f++)
314 } // end of void DetermineMinMax()
316 // =====================================================================================
320 // Get histograms with results for cumulants vs multiplicity.
322 if(plotCumulantsVsReferenceMultiplicity) {GetProfileForRefMultVsNoOfRPs();}
324 TString qcFlag[4] = {"QC{2}","QC{4}","QC{6}","QC{8}"};
325 TString gfcFlag[4] = {"GFC{2}","GFC{4}","GFC{6}","GFC{8}"};
326 for(Int_t f=0;f<nFiles;f++)
328 for(Int_t m=0;m<nMethods;m++)
331 if(!(strcmp(method[m].Data(),"QC")))
333 temp = dynamic_cast<TList*> (lists[f][m]->FindObject("Integrated Flow"));
334 if(temp) {temp = dynamic_cast<TList*> (temp->FindObject("Results"));}
337 for(Int_t co=0;co<4;co++)
339 cumulantsVsM[f][m][co] = dynamic_cast<TH1D*> (temp->FindObject(Form("fIntFlowQcumulantsVsM, %s",qcFlag[co].Data())));
340 if(plotCumulantsVsReferenceMultiplicity)
342 Map(cumulantsVsM[f][m][co]);
346 } // end of if(!(strcmp(method[m].Data(),"QC")))
347 else if(!(strcmp(method[m].Data(),"GFC")))
349 temp = dynamic_cast<TList*> (lists[f][m]->FindObject("Reference Flow"));
350 if(temp) {temp = dynamic_cast<TList*> (temp->FindObject("Results"));}
353 for(Int_t co=0;co<4;co++)
355 cumulantsVsM[f][m][co] = dynamic_cast<TH1D*> (temp->FindObject(Form("fReferenceFlowCumulantsVsM, %s",gfcFlag[co].Data())));
356 if(plotCumulantsVsReferenceMultiplicity)
358 Map(cumulantsVsM[f][m][co]);
362 } // end of else if(!(strcmp(method[m].Data(),"QC")))
363 } // end of for(Int_t m=0;m<nMethods;m++)
364 } // end of for(Int_t f=0;f<nFiles;f++)
366 } // end of void GetHistograms()
368 // =====================================================================================
370 void GetProfileForRefMultVsNoOfRPs()
372 // Get profile holding <reference multiplicity> versus # of RPs.
374 AliFlowCommonHist *commonHist = dynamic_cast<AliFlowCommonHist*> (lists[0][0]->FindObject("AliFlowCommonHistQC"));
375 if(commonHist && commonHist->GetRefMultVsNoOfRPs())
377 refMultVsNoOfRPs = commonHist->GetRefMultVsNoOfRPs();
381 cout<<"WARNING: commonHist && commonHist->GetRefMultVsNoOfRPs() is NULL in method"<<endl;
382 cout<<" GetProfileForRefMultVsNoOfRPs() !!!! But was searching only in the file"<<endl;
383 cout<<" "<<commonOutputFiles[0]->GetName()<<", though."<<endl;
384 cout<<" Do you have this file available?"<<endl;
388 } // end of void GetProfileForRefMultVsNoOfRPs()
390 // =====================================================================================
394 // Map cumulant versus # of RPs into cumulants versus <reference multiplicity>.
399 temp = (TH1D*) hist->Clone();
401 Int_t nBins = hist->GetNbinsX();
402 for(Int_t b=1;b<=nBins;b++)
404 temp->SetBinContent((Int_t)refMultVsNoOfRPs->GetBinContent(b),hist->GetBinContent(b));
405 temp->SetBinError((Int_t)refMultVsNoOfRPs->GetBinContent(b),hist->GetBinError(b));
415 // =====================================================================================
417 TGraphErrors* GetGraphErrors(Int_t bin, Int_t nFiles, TH1D** qc)
419 TGraphErrors *ge = new TGraphErrors(nFiles);
420 for(Int_t f=0;f<nFiles;f++)
422 ge->SetPoint(f,f+0.5,qc[f]->GetBinContent(bin+1));
423 ge->SetPointError(f,0,qc[f]->GetBinError(bin+1));
428 } // end of TGraphErrors* GetGraphErrors(Int_t bin, Int_t nFiles, TH1D** qc)
430 // =====================================================================================
432 TH1D* StyleHist(TString yAxisTitle, Int_t co)
436 TH1D *styleHist = new TH1D("","",10000,0,10000); // to be improved (hardwired 10000)
438 styleHist->GetXaxis()->SetRangeUser(xMin[co],xMax[co]);
440 styleHist->GetYaxis()->SetRangeUser(yMin[co],yMax[co]);
442 if(plotCumulantsVsReferenceMultiplicity)
444 styleHist->GetXaxis()->SetTitle("#LTreference multiplicity#GT");
447 styleHist->GetXaxis()->SetTitle("# of RPs");
450 styleHist->GetYaxis()->SetTitle(yAxisTitle.Data());
454 } // end of TH1D* StyleHist(TString yAxisTitle, Int_t co)
456 // ===========================================================================================
458 TGraph* GetErrorMesh(TH1D *hist)
462 TGraph* errorMesh = NULL;
465 Int_t nBins = hist->GetNbinsX();
466 Double_t binWidth = hist->GetBinWidth(1); // assuming that all bins have the same width
467 // Counting the non-empty bins:
468 Int_t nNonEmptyBins=0;
469 for(Int_t i=1;i<nBins+1;i++)
471 if(!(hist)->GetBinError(i)==0.0))
476 errorMesh = new TGraph(2*nNonEmptyBins+1);
477 Double_t value=0.,error=0.;
479 Double_t xFirst=0.,yUpFirst=0.; // needed to close up the mesh
480 for(Int_t i=1;i<nBins+1;i++)
482 // Setting up the upper limit of the mesh:
483 value = hist->GetBinContent(i);
484 error = hist->GetBinError(i);
487 errorMesh->SetPoint(count++,(i-0.5)*binWidth,value+error);
490 xFirst=(i-0.5)*binWidth;
491 yUpFirst=value+error;
495 for(Int_t i=nBins+1;i<2*nBins+1;i++)
497 // Setting up the lower limit of the mesh:
498 value = hist->GetBinContent(2*nBins+1-i);
499 error = hist->GetBinError(2*nBins+1-i);
502 errorMesh->SetPoint(count++,(2*nBins-i+0.5)*binWidth,value-error);
505 // Closing the mesh area:
506 errorMesh->SetPoint(2*nNonEmptyBins+1,xFirst,yUpFirst);
509 errorMesh->SetFillStyle(1001);
513 } // end of TGraph* GetErrorMesh(TH1D *hist)
515 // ===========================================================================================
517 void GlobalSettings()
519 // Settings which will affect all plots.
521 gROOT->SetStyle("Plain"); // default color is white instead of gray
522 gStyle->SetOptStat(0); // remove stat. box from all histos
524 } // end of void GlobalSettings()
526 // ===========================================================================================
530 // Get from common output files the lists holding histograms for each method.
532 TString fileName[nFiles][nMethods];
533 TDirectoryFile *dirFile[nFiles][nMethods] = {{NULL}};
534 TString listName[nFiles][nMethods];
535 for(Int_t f=0;f<nFiles;f++)
537 for(Int_t i=0;i<nMethods;i++)
539 // Form a file name for each method:
540 fileName[f][i]+="output";
541 fileName[f][i]+=method[i].Data();
542 fileName[f][i]+="analysis";
543 fileName[f][i]+=type[f].Data();
545 if(commonOutputFiles[f]){dirFile[f][i] = (TDirectoryFile*)commonOutputFiles[f]->FindObjectAny(fileName[f][i].Data());}
546 // Form a list name for each method:
547 listName[f][i]+="cobj";
548 listName[f][i]+=method[i].Data();
549 // Access this lists:
552 dirFile[f][i]->GetObject(listName[f][i].Data(),lists[f][i]);
555 cout<<"WARNING: Couldn't find a file "<<fileName[f][i].Data()<<".root in "<<commonOutputFiles[f]->GetName()<<" !!!!"<<endl;exit(0);
557 } // end of for(Int_t i=0;i<nMethods;i++)
558 } // end of for(Int_t f=0;f<nFiles;f++)
560 } // end of void GetLists()
562 // ===========================================================================================
564 void AccessCommonOutputFiles(TString commonOutputFileName)
566 // Access all output files.
567 for(Int_t f=0;f<nFiles;f++)
569 if(!(gSystem->AccessPathName(Form("%s/%s/%s",gSystem->pwd(),files[f].Data(),commonOutputFileName.Data()),kFileExists)))
571 commonOutputFiles[f] = TFile::Open(Form("%s/%s/%s",gSystem->pwd(),files[f].Data(),commonOutputFileName.Data()),"READ");
575 cout<<"WARNING: Couldn't find the file "<<Form("%s/%s/%s",gSystem->pwd(),files[f].Data(),commonOutputFileName.Data())<<" !!!!"<<endl;
579 } // end of for(Int_t f=0;f<nFiles;f++)
581 } // void AccessCommonOutputFiles(TString commonOutputFileName);
583 // ===========================================================================================
585 void LoadLibrariesPC(const libModes analysisMode) {
587 //--------------------------------------
588 // Load the needed libraries most of them already loaded by aliroot
589 //--------------------------------------
590 //gSystem->Load("libTree");
591 gSystem->Load("libGeom");
592 gSystem->Load("libVMC");
593 gSystem->Load("libXMLIO");
594 gSystem->Load("libPhysics");
596 //----------------------------------------------------------
597 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
598 //----------------------------------------------------------
599 if (analysisMode==mLocal) {
600 //--------------------------------------------------------
601 // If you want to use already compiled libraries
602 // in the aliroot distribution
603 //--------------------------------------------------------
605 //==================================================================================
606 //load needed libraries:
607 gSystem->AddIncludePath("-I$ROOTSYS/include");
608 //gSystem->Load("libTree");
611 gSystem->AddIncludePath("-I$ALICE_ROOT/include");
612 //gSystem->Load("libANALYSIS");
613 gSystem->Load("libPWG2flowCommon");
614 //cerr<<"libPWG2flowCommon loaded ..."<<endl;
618 else if (analysisMode==mLocalSource) {
620 // In root inline compile
623 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
624 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
625 gROOT->LoadMacro("AliFlowCommon/AliFlowCumuConstants.cxx+");
628 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
629 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
630 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
633 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
635 // Output histosgrams
636 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
637 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
638 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
639 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
641 cout << "finished loading macros!" << endl;
645 } // end of void LoadLibraries(const libModes analysisMode)