]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FLOW/macros/compareFlowResults.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / FLOW / macros / compareFlowResults.C
1 // Macro compareFlowResults.C is used to show a set of predefined plots with results 
2 // of flow analysis. It's usage is very simple: If you have output root file of flow
3 // analysis <outputFileName> in directory <dir>, simply copy the macro in <dir> and
4 // execute it. Remarks: 
5 //  1.) Make sure that the 'TString analysisType' bellow is the same as the one which 
6 //      was used in the analysis which have produced the <outputFileName>;
7 //  2.) Abbreviations used here are: RF = Reference Flow, RP = Reference Particles,
8 //      POI = Particles Of Interest;
9 //  3.) To modify cosmetics of each plot change default settings in function which 
10 //      have produced that plot. Example: If you want to modify marker colors in 
11 //      the plot for reference flow, modify array Int_t methodMarkerColor[nMethods] 
12 //      in the function PlotReferenceFlow().
13
14 // Set name of the output file of flow analysis to be accessed:
15 TString outputFileName = "AnalysisResults.root";
16 //TString outputFileName = "outputCentrality4.root";
17
18 // Set here which plots will be shown by default:
19 //  Results:
20 Bool_t plotReferenceFlow = kTRUE; // reference flow 
21 Bool_t plotIntFlowPOI = kTRUE; // integrated flow of POIs
22 Bool_t plotDiffFlowPtPOI = kTRUE; // differential flow v(pt) for POIs
23 Bool_t plotDiffFlowEtaPOI = kTRUE; // differential flow v(eta) for POIs
24 Bool_t plotIntFlowRP = kTRUE; // integrated flow of RPs
25 Bool_t plotDiffFlowPtRP = kTRUE; // differential flow v(pt) for RPs
26 Bool_t plotDiffFlowEtaRP = kTRUE; // differential flow v(eta) for RPs
27 //  Results relative to MC:
28 Bool_t plotReferenceFlowRelativeToMC = kTRUE; // plot (v{MC}-v{method})/v{MC} for reference flow
29 Bool_t plotIntFlowRelativeToMCPOI = kTRUE; // plot (v{MC}-v{method})/v{MC} for integrated flow of POIs   
30 Bool_t plotDiffFlowPtRelativeToMCPOI = kTRUE; // plot (v{MC}-v{method})/v{MC} as a function of pt for POIs 
31 Bool_t plotDiffFlowEtaRelativeToMCPOI = kTRUE; // plot (v{MC}-v{method})/v{MC} as a function of eta for POIs
32 Bool_t plotIntFlowRelativeToMCRP = kTRUE; // plot (v{MC}-v{method})/v{MC} for integrated flow of RPs
33 Bool_t plotDiffFlowPtRelativeToMCRP = kTRUE; // plot (v{MC}-v{method})/v{MC} as a function of pt for RPs   
34 Bool_t plotDiffFlowEtaRelativeToMCRP = kTRUE; // plot (v{MC}-v{method})/v{MC} as a function of eta for RPs   
35 // Set here if the legends will be shown on the plots:
36 Bool_t showLegend = kTRUE; 
37 Bool_t showLegendDiffFlow = kTRUE;
38 // Some quick settings:
39 Bool_t showOnlyReferenceFlow = kFALSE;
40 Bool_t showResultsRelativeToMC = kFALSE;
41 Bool_t showOnlyPlotsForPOIs = kFALSE;
42 Bool_t showOnlyPlotsForRPs = kFALSE;
43 // Set here if you want to rebin pt bins to reduce the statistical errors in the plots for differential flow vs pt:
44 Bool_t rebinInPt = kTRUE;
45 const Int_t nPtIntervals = 3;
46 Double_t ptInterval[nPtIntervals+1] = {0.,2.,5.,10.}; // in GeV
47 Int_t nMergedBins[nPtIntervals] = {1,2,5}; // for instance in 2nd pt interval (2-5 GeV) 5 pt bins will be merged into 1
48 // Set here if you want to use default values for harmonic, pt and eta binning:
49 Bool_t useDefaultValues = kTRUE;
50 TString methodForSettings = "QC"; // alternatively set here method from whose output files harmonic, pt and eta binning will be accessed
51 // Set here if you want to show error mesh:
52 Bool_t showErrorMesh = kTRUE;
53 Bool_t showErrorMeshDiffFlow = kTRUE;
54 // Set here if both the error mesh and markers will be shown for specified method in the plots for differential flow:
55 Bool_t showBothErrorMeshAndMarkers = kFALSE; 
56
57 // Do not touch this unless you are looking for a trouble:
58 const Int_t nMethods = 12;
59 TString method[nMethods] = {"MCEP","SP","GFC","QC","FQD","LYZ1SUM","LYZ1PROD","LYZ2SUM","LYZ2PROD","LYZEP","MH","NL"};
60 TList *list[nMethods] = {NULL}; // lists holding histograms for each flow analysis method
61
62 enum libModes{mLocal,mLocalSource};
63
64 //void compareFlowResults(TString analysisType="",Int_t analysisMode=mLocalSource)
65 void compareFlowResults(TString analysisType="ESD",Int_t analysisMode=mLocal)
66 {
67  // 1. analysisType: "ESD", "AOD", "MC", "ESDMCkineESD", "ESDMCkineMC", "MK", for analysis 'on the fly' use simply "";
68  // 2. analysisMode: if analysisMode = mLocal -> analyze data on your computer using aliroot
69  //                  if analysisMode = mLocalSource -> analyze data on your computer using root + source files 
70   
71  // Load needed libraries:
72  LoadLibrariesCFR(analysisMode); 
73
74  // Access common output file:
75  TFile *outputFile = AccessOutputFile(outputFileName); 
76  
77  // Access from common output file the TDirectoryFile's for each flow analysis method
78  // and from them the lists holding histograms with final results:
79  GetListsWithHistograms(outputFile,analysisType);
80  
81  // Global settings which will affect all plots:
82  GlobalSettings();
83    
84  // Calling the functions to produce the final plots:
85  if(plotReferenceFlow) PlotReferenceFlow();
86  if(!showOnlyReferenceFlow)
87  { 
88   if(!showOnlyPlotsForRPs)
89   {
90    if(plotIntFlowPOI) PlotIntFlowPOI(); 
91    if(plotDiffFlowPtPOI) PlotDiffFlowPtPOI();
92    if(plotDiffFlowEtaPOI) PlotDiffFlowEtaPOI();
93   }
94   if(!showOnlyPlotsForPOIs)
95   {
96    if(plotIntFlowRP) PlotIntFlowRP(); 
97    if(plotDiffFlowPtRP) PlotDiffFlowPtRP();
98    if(plotDiffFlowEtaRP) PlotDiffFlowEtaRP();  
99   }
100   if(showResultsRelativeToMC)
101   {
102    if(plotReferenceFlowRelativeToMC) PlotReferenceFlowRelativeToMC();
103    if(!showOnlyPlotsForRPs)
104    {
105     if(plotIntFlowRelativeToMCPOI) PlotIntFlowRelativeToMCPOI();
106     if(plotDiffFlowPtRelativeToMCPOI) PlotDiffFlowPtRelativeToMCPOI();
107     if(plotDiffFlowEtaRelativeToMCPOI) PlotDiffFlowEtaRelativeToMCPOI();
108    }
109    if(!showOnlyPlotsForPOIs)
110    {
111     if(plotIntFlowRelativeToMCRP) PlotIntFlowRelativeToMCRP();
112     if(plotDiffFlowPtRelativeToMCRP) PlotDiffFlowPtRelativeToMCRP();
113     if(plotDiffFlowEtaRelativeToMCRP) PlotDiffFlowEtaRelativeToMCRP();
114    }
115   }
116  }
117
118 } // end of void newCompare(TString analysisType="",Int_t analysisMode=mLocal)
119
120 // ===========================================================================================
121
122 void PlotReferenceFlow()
123 {
124  // Make a plot which compares the results for reference flow.
125   
126  // Settings for methods:
127  const Int_t nMethods = 13;
128  TString method[nMethods] = {"MCEP","SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","6,QC","8,GFC","8,QC","FQD","LYZ1SUM","LYZ1PROD"};
129  Int_t methodMarkerStyle[nMethods] = {21,21,21,21,21,21,21,21,21,21,21,21,21}; // see available marker styles in TAttMarker
130  Int_t methodMarkerColor[nMethods] = {kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack};
131  // Settings for error mesh:
132  TString methodUsedToMakeErrorMesh = "MCEP";
133  Int_t meshStyle = 1001;
134  Int_t meshColor = kGray;
135    
136  Plot(nMethods,method,methodMarkerStyle,methodMarkerColor,
137       methodUsedToMakeErrorMesh,meshStyle,meshColor,"RF");
138  
139 } // end of void PlotReferenceFlow()
140
141 // ===========================================================================================
142
143 void PlotIntFlowPOI()
144 {
145  // Make a plot which compares the results for reference flow.
146   
147  // Settings for methods:
148  const Int_t nMethods = 10;
149  TString method[nMethods] = {"MCEP","SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
150  Int_t methodMarkerStyle[nMethods] = {21,21,21,21,21,21,21,21,21,21}; // see available marker styles in TAttMarker
151  Int_t methodMarkerColor[nMethods] = {kRed-3,kRed-3,kRed-3,kRed-3,kRed-3,kRed-3,kRed-3,kRed-3,kRed-3,kRed-3};
152  // Settings for error mesh:
153  TString methodUsedToMakeErrorMesh = "MCEP";
154  Int_t meshStyle = 1001;
155  Int_t meshColor = kRed-10;
156    
157  Plot(nMethods,method,methodMarkerStyle,methodMarkerColor,
158       methodUsedToMakeErrorMesh,meshStyle,meshColor,"POI");
159   
160 } // end of void PlotIntFlowPOI()
161
162 // ===========================================================================================
163
164 void PlotIntFlowRP()
165 {
166  // Make a plot which compares the results for reference flow.
167   
168  // Settings for methods:
169  const Int_t nMethods = 10;
170  TString method[nMethods] = {"MCEP","SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
171  Int_t methodMarkerStyle[nMethods] = {21,21,21,21,21,21,21,21,21,21}; // see available marker styles in TAttMarker
172  Int_t methodMarkerColor[nMethods] = {kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3};
173  // Settings for error mesh:
174  TString methodUsedToMakeErrorMesh = "MCEP";
175  Int_t meshStyle = 1001;
176  Int_t meshColor = kBlue-10;
177    
178  Plot(nMethods,method,methodMarkerStyle,methodMarkerColor,
179       methodUsedToMakeErrorMesh,meshStyle,meshColor,"RP");
180   
181 } // end of void PlotIntFlowRP()
182
183 // ===========================================================================================
184
185 void PlotDiffFlowPtPOI()
186 {
187  // Make a plot which compares the results for differential flow of POIs vs pt.
188
189  // Settings for methods:
190  const Int_t nMethods = 10;
191  TString method[nMethods] = {"MCEP","SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
192  Int_t methodMarkerStyle[nMethods] = {20,3,21,21,20,20,25,24,22,22}; // see available marker styles in TAttMarker
193  Int_t methodMarkerColor[nMethods] = {kRed,kViolet-6,kAzure-7,kOrange-7,kAzure+3,kOrange+3,kAzure-7,kAzure+3,kYellow+3,kGreen+3};
194  // Settings for error mesh:
195  TString methodUsedToMakeErrorMesh = "MCEP";
196  Int_t meshStyle = 1001;
197  Int_t meshColor = kRed-10;
198  
199  PlotDiffFlow(nMethods,method,methodMarkerStyle,methodMarkerColor,
200               methodUsedToMakeErrorMesh,meshStyle,meshColor,"Pt","POI");
201  
202 } // end of void PlotDiffFlowPtPOI()
203
204 // ===========================================================================================
205
206 void PlotDiffFlowEtaPOI()
207 {
208  // Make a plot which compares the results for differential flow of POIs vs eta.
209
210  // Settings for methods:
211  const Int_t nMethods = 10;
212  TString method[nMethods] = {"MCEP","SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
213  Int_t methodMarkerStyle[nMethods] = {20,3,21,21,20,20,25,24,22,22}; // see available marker styles in TAttMarker
214  Int_t methodMarkerColor[nMethods] = {kRed,kViolet-6,kAzure-7,kOrange-7,kAzure+3,kOrange+3,kAzure-7,kAzure+3,kYellow+3,kGreen+3};
215  // Settings for error mesh:
216  TString methodUsedToMakeErrorMesh = "MCEP";
217  Int_t meshStyle = 1001;
218  Int_t meshColor = kRed-10;
219  
220  PlotDiffFlow(nMethods,method,methodMarkerStyle,methodMarkerColor,
221               methodUsedToMakeErrorMesh,meshStyle,meshColor,"Eta","POI");
222  
223 } // end of void PlotDiffFlowEtaPOI()
224
225 // ===========================================================================================
226
227 void PlotDiffFlowPtRP()
228 {
229  // Make a plot which compares the results for differential flow of RPs vs pt.
230  
231  // Settings for methods:
232  const Int_t nMethods = 10;
233  TString method[nMethods] = {"MCEP","SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
234  Int_t methodMarkerStyle[nMethods] = {20,3,21,21,20,20,25,24,22,22}; // see available marker styles in TAttMarker
235  Int_t methodMarkerColor[nMethods] = {kBlue,kViolet-6,kAzure-7,kOrange-7,kAzure+3,kOrange+3,kAzure-7,kAzure+3,kYellow+3,kGreen+3};
236  // Settings for error mesh:
237  TString methodUsedToMakeErrorMesh = "MCEP";
238  Int_t meshStyle = 1001;
239  Int_t meshColor = kBlue-10;
240  
241  PlotDiffFlow(nMethods,method,methodMarkerStyle,methodMarkerColor,
242               methodUsedToMakeErrorMesh,meshStyle,meshColor,"Pt","RP");
243  
244 } // end of void PlotDiffFlowPtRP()
245
246 // ===========================================================================================
247
248 void PlotDiffFlowEtaRP()
249 {
250  // Make a plot which compares the results for differential flow of RPs vs eta.
251
252  // Settings for methods:
253  const Int_t nMethods = 10;
254  TString method[nMethods] = {"MCEP","SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
255  Int_t methodMarkerStyle[nMethods] = {20,3,21,21,20,20,25,24,22,22}; // see available marker styles in TAttMarker
256  Int_t methodMarkerColor[nMethods] = {kBlue,kViolet-6,kAzure-7,kOrange-7,kAzure+3,kOrange+3,kAzure-7,kAzure+3,kYellow+3,kGreen+3};
257  // Settings for error mesh:
258  TString methodUsedToMakeErrorMesh = "MCEP";
259  Int_t meshStyle = 1001;
260  Int_t meshColor = kBlue-10;
261  
262  PlotDiffFlow(nMethods,method,methodMarkerStyle,methodMarkerColor,
263               methodUsedToMakeErrorMesh,meshStyle,meshColor,"Eta","RP");
264  
265 } // end of void PlotDiffFlowEtaRP()
266
267 // ===========================================================================================
268
269 void PlotReferenceFlowRelativeToMC()
270 {
271  // Make a plot (v{MC}-v{method})/v{MC} for reference flow.
272   
273  // Settings for methods:
274  const Int_t nMethods = 12;
275  TString method[nMethods] = {"SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","6,QC","8,GFC","8,QC","FQD","LYZ1SUM","LYZ1PROD"};
276  Int_t methodMarkerStyle[nMethods] = {21,21,21,21,21,21,21,21,21,21,21,21}; // see available marker styles in TAttMarker
277  Int_t methodMarkerColor[nMethods] = {kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack,kBlack};
278    
279  PlotRelativeToMC(nMethods,method,methodMarkerStyle,methodMarkerColor,"RF");
280
281 } // end of void PlotReferenceFlowRelativeToMC()
282
283 // ===========================================================================================
284
285 void PlotIntFlowRelativeToMCPOI()
286 {
287  // Make a plot (v{MC}-v{method})/v{MC} for integrated flow of POIs.
288   
289  // Settings for methods:
290  const Int_t nMethods = 9;
291  TString method[nMethods] = {"SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
292  Int_t methodMarkerStyle[nMethods] = {21,21,21,21,21,21,21,21,21}; // see available marker styles in TAttMarker
293  Int_t methodMarkerColor[nMethods] = {kRed-3,kRed-3,kRed-3,kRed-3,kRed-3,kRed-3,kRed-3,kRed-3,kRed-3};
294    
295  PlotRelativeToMC(nMethods,method,methodMarkerStyle,methodMarkerColor,"POI");
296
297 } // end of void PlotIntFlowRelativeToMCPOI()
298
299 // ===========================================================================================
300
301 void PlotIntFlowRelativeToMCRP()
302 {
303  // Make a plot (v{MC}-v{method})/v{MC} for integrated flow of RPs.
304   
305  // Settings for methods:
306  const Int_t nMethods = 9;
307  TString method[nMethods] = {"SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
308  Int_t methodMarkerStyle[nMethods] = {21,21,21,21,21,21,21,21,21}; // see available marker styles in TAttMarker
309  Int_t methodMarkerColor[nMethods] = {kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3,kBlue-3};
310    
311  PlotRelativeToMC(nMethods,method,methodMarkerStyle,methodMarkerColor,"RP");
312
313 } // end of void PlotIntFlowRelativeToMCRP()
314
315 // ===========================================================================================
316
317 void PlotDiffFlowPtRelativeToMCPOI()
318 {
319  // Make a plot (v{MC}-v{method})/v{MC} for differential flow of POIs vs pt.
320
321  // Settings for methods:
322  const Int_t nMethods = 9;
323  TString method[nMethods] = {"SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
324  Int_t methodMarkerStyle[nMethods] = {3,21,21,20,20,25,24,22,22}; // see available marker styles in TAttMarker
325  Int_t methodMarkerColor[nMethods] = {kViolet-6,kAzure-7,kOrange-7,kAzure+3,kOrange+3,kAzure-7,kAzure+3,kYellow+3,kGreen+3};
326  
327  PlotDiffFlowRelativeToMC(nMethods,method,methodMarkerStyle,methodMarkerColor,"Pt","POI");
328
329 } // end of void PlotDiffFlowPtRelativeToMCPOI()
330
331 // ===========================================================================================
332   
333 void PlotDiffFlowEtaRelativeToMCPOI()
334 {
335  // Make a plot (v{MC}-v{method})/v{MC} for differential flow of POIs vs eta.
336
337  // Settings for methods:
338  const Int_t nMethods = 9;
339  TString method[nMethods] = {"SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
340  Int_t methodMarkerStyle[nMethods] = {3,21,21,20,20,25,24,22,22}; // see available marker styles in TAttMarker
341  Int_t methodMarkerColor[nMethods] = {kViolet-6,kAzure-7,kOrange-7,kAzure+3,kOrange+3,kAzure-7,kAzure+3,kYellow+3,kGreen+3};
342  
343  PlotDiffFlowRelativeToMC(nMethods,method,methodMarkerStyle,methodMarkerColor,"Eta","POI");
344
345 } // end of void PlotDiffFlowEtaRelativeToMCPOI()
346
347 // ===========================================================================================
348   
349 void PlotDiffFlowPtRelativeToMCRP()
350 {
351  // Make a plot (v{MC}-v{method})/v{MC} for differential flow of RPs vs pt.
352
353  // Settings for methods:
354  const Int_t nMethods = 9;
355  TString method[nMethods] = {"SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
356  Int_t methodMarkerStyle[nMethods] = {3,21,21,20,20,25,24,22,22}; // see available marker styles in TAttMarker
357  Int_t methodMarkerColor[nMethods] = {kViolet-6,kAzure-7,kOrange-7,kAzure+3,kOrange+3,kAzure-7,kAzure+3,kYellow+3,kGreen+3};
358  
359  PlotDiffFlowRelativeToMC(nMethods,method,methodMarkerStyle,methodMarkerColor,"Pt","RP");
360
361 } // end of void PlotDiffFlowPtRelativeToMCRP()
362
363 // ===========================================================================================
364   
365 void PlotDiffFlowEtaRelativeToMCRP()
366 {
367  // Make a plot (v{MC}-v{method})/v{MC} for differential flow of RPs vs eta.
368
369  // Settings for methods:
370  const Int_t nMethods = 9;
371  TString method[nMethods] = {"SP","2,GFC","2,QC","4,GFC","4,QC","6,GFC","8,GFC","LYZ2SUM","LYZ2PROD"};
372  Int_t methodMarkerStyle[nMethods] = {3,21,21,20,20,25,24,22,22}; // see available marker styles in TAttMarker
373  Int_t methodMarkerColor[nMethods] = {kViolet-6,kAzure-7,kOrange-7,kAzure+3,kOrange+3,kAzure-7,kAzure+3,kYellow+3,kGreen+3};
374  
375  PlotDiffFlowRelativeToMC(nMethods,method,methodMarkerStyle,methodMarkerColor,"Eta","RP");
376
377 } // end of void PlotDiffFlowPtRelativeToMCRP()
378
379 // ===========================================================================================
380         
381 TGraph* GetErrorMesh(Int_t nPts, Double_t result, Double_t error, Int_t meshStyle, Int_t meshColor)
382 {
383  // Make an error mesh from the specified method.
384  
385  TGraph *g = new TGraph(nPts);
386  g->SetPoint(1,0,result+error);
387  g->SetPoint(2,nPts+1,result+error);
388  g->SetPoint(3,nPts+1,result-error);
389  g->SetPoint(4,0,result-error);
390  g->SetPoint(5,0,result-error);    
391  g->SetFillStyle(meshStyle);
392  g->SetFillColor(meshColor);
393
394  return g;
395
396 } // end of GetErrorMesh(Int_t nPoints, Double_t result,Double_t error)
397
398 // ===========================================================================================
399
400 TGraphErrors* GetGraphErrors(Double_t x, Double_t result, Double_t error, Int_t markerStyle, Int_t markerColor)
401 {
402  // From the result and error for each method make TGraphErrors.
403  
404  TGraphErrors *ge = NULL;
405  
406  ge = new TGraphErrors(1);
407  ge->SetPoint(0,x,result);
408  ge->SetPointError(0,0,error);
409  ge->SetMarkerStyle(markerStyle);
410  ge->SetMarkerColor(markerColor);
411
412  return ge;
413
414 } // end of TGraphErrors* GetGraphErrors(Double_t x, Double_t result, Double_t error, Int_t markerStyle, Int_t markerColor)
415
416 // ===========================================================================================
417  
418 void PlotDiffFlow(Int_t nMethods, TString *method, Int_t *methodMarkerStyle, Int_t *methodMarkerColor,
419                   TString methodUsedToMakeErrorMesh, Int_t meshStyle, Int_t meshColor, TString ptEta, TString rpPoi)
420 {
421  // Make plot for differential flow.
422
423  TCanvas *c = NULL;
424  Int_t sizeX = 1000; // canvas size in pixels along x
425  Int_t sizeY = 600; // canvas size in pixels along y
426  TString title = Form("Differential Flow vs %s (%s)",ptEta.Data(),rpPoi.Data()); 
427  if(!showLegendDiffFlow) sizeX = 0.75*sizeX;
428  c = new TCanvas(title.Data(),title.Data(),sizeX,sizeY);
429  if(showLegendDiffFlow)
430  {
431   c->Divide(2,1);
432   c->cd(1)->SetPad(0.0,0.0,0.75,1.0);
433  } 
434  // Style histogram:
435  StyleHistDiffFlow(ptEta.Data(),rpPoi.Data())->Draw();
436  // Error mesh:  
437  TGraph *errorMesh = GetErrorMeshDiffFlow(methodUsedToMakeErrorMesh.Data(),rpPoi.Data(),ptEta.Data()); 
438  if(errorMesh && showErrorMeshDiffFlow) 
439  {
440   errorMesh->SetFillStyle(meshStyle);
441   errorMesh->SetFillColor(meshColor);
442   errorMesh->Draw("lfsame");
443  }
444  // Results of methods:
445  for(Int_t b=0;b<nMethods;b++)
446  {
447   if(method[b]==methodUsedToMakeErrorMesh && !showBothErrorMeshAndMarkers) continue;
448   TH1D *hist = GetResultHistogram(method[b].Data(),rpPoi.Data(),ptEta.Data());
449   if(hist)
450   {
451    if(rebinInPt && ptEta == "Pt"){hist = RebinInPt(hist);}
452    hist->SetMarkerStyle(methodMarkerStyle[b]);
453    hist->SetMarkerColor(methodMarkerColor[b]);
454    hist->Draw("e1psamex0");
455   }
456  } 
457  if(showLegendDiffFlow)
458  {
459   c->cd(2)->SetPad(0.73,0.0,0.97,1.0);
460   DefaultTextInLegend()->Draw();
461   LegendDiffFlow(nMethods,method,methodMarkerStyle,methodMarkerColor,
462                  methodUsedToMakeErrorMesh,meshStyle,meshColor,ptEta,rpPoi)->Draw();
463  }
464 } // end of void PlotDiffFlow(...)
465
466 // ===========================================================================================
467
468 void PlotDiffFlowRelativeToMC(Int_t nMethods, TString *method, Int_t *methodMarkerStyle,
469                               Int_t *methodMarkerColor, TString ptEta, TString rpPoi)
470 {
471  // Make plot for differential flow.
472  
473  TString title = Form("Differential Flow vs %s (%s) relative to MCEP",ptEta.Data(),rpPoi.Data()); 
474  // MCEP:
475  TH1D *mcep = GetResultHistogram("MCEP",rpPoi.Data(),ptEta.Data()); // MCEP result and error:
476  if(!mcep)
477  {
478   cout<<"WARNING: MCEP histogram not available in making the plot for "<<title.Data()<<" !!!!"<<endl;   
479   return;    
480  } 
481  TCanvas *c = NULL;
482  Int_t sizeX = 1000; // canvas size in pixels along x
483  Int_t sizeY = 600; // canvas size in pixels along y
484  if(!showLegendDiffFlow) sizeX = 0.75*sizeX;
485  c = new TCanvas(title.Data(),title.Data(),sizeX,sizeY);
486  if(showLegendDiffFlow)
487  {
488   c->Divide(2,1);
489   c->cd(1)->SetPad(0.0,0.0,0.75,1.0);
490  } 
491  // Style histogram:
492  Int_t n = 2; // default harmonic
493  if(!useDefaultValues){n = GetHarmonic(methodForSettings);}
494  TH1D *styleHist = StyleHistDiffFlow(ptEta.Data(),rpPoi.Data());
495  styleHist->GetYaxis()->SetTitle(Form("(v_{%d}\{MCEP\}-v_{%d}\{method\})/v_{%d}\{MCEP\}",n,n,n));
496  styleHist->SetTitle(Form("Differential Flow #font[72]{vs} %s (%s) relative to MCEP",ptEta.Data(),rpPoi.Data())); 
497  styleHist->SetMinimum(-10.); // to be improved
498  styleHist->SetMaximum(10.); // to be improved
499  styleHist->SetTitle(title.Data());
500  styleHist->Draw();
501  // Methods:
502  for(Int_t nm=0;nm<nMethods;nm++)
503  {
504   TH1D *hist = NULL;
505   if(GetResultHistogram(method[nm].Data(),rpPoi.Data(),ptEta.Data()))
506   {
507    hist = (TH1D*)(GetResultHistogram(method[nm].Data(),rpPoi.Data(),ptEta.Data())->Clone());
508   }
509   if(hist)
510   {
511    Int_t nBins = hist->GetNbinsX(); 
512    for(Int_t b=1;b<=nBins;b++)
513    { 
514     Double_t mcepResult = mcep->GetBinContent(b);
515     Double_t mcepError = mcep->GetBinError(b);
516     if((TMath::Abs(mcepResult) > 1.e-44) && (TMath::Abs(mcepError) > 1.e-44)) 
517     {
518      Double_t result = hist->GetBinContent(b);
519      Double_t error = hist->GetBinError(b); 
520      //if((TMath::Abs(result)>1.e-44) && TMath::Abs(error)>1.e-44)) 
521      if(TMath::Abs(result)>1.e-44)
522      {
523       error = pow(pow(error/mcepResult,2.)+pow(result*mcepError/pow(mcepResult,2.),2.),0.5); // Do not switch with the next line!
524       result = (mcepResult-result)/mcepResult;
525       hist->SetBinContent(b,result);
526       hist->SetBinError(b,error);
527      } else // end of if((TMath::Abs(result)>1.e-44) && TMath::Abs(error)>1.e-44))
528        {
529         hist->SetBinContent(b,0.);
530         hist->SetBinError(b,0.);          
531        }
532     } else // end of if(TMath::Abs(mcepResult) > 1.e-44 && TMath::Abs(mcepError) > 1.e-44)  
533       {
534        hist->SetBinContent(b,0.);
535        hist->SetBinError(b,0.);     
536       }
537    } // end of for(b=1;b<=nBins;b++) 
538    hist->SetMarkerStyle(methodMarkerStyle[nm]);
539    hist->SetMarkerColor(methodMarkerColor[nm]);
540    hist->Draw("e1psame");
541   } // end of if(hist)
542  } // end of for(Int_t nm=0;nm<nMethods;nm++)  
543  if(showLegendDiffFlow)
544  {
545   c->cd(2)->SetPad(0.73,0.0,0.97,1.0);
546   DefaultTextInLegend()->Draw();
547   LegendDiffFlow(nMethods,method,methodMarkerStyle,methodMarkerColor,"",-1,-1,ptEta,rpPoi)->Draw();
548  }
549 } // end of void PlotDiffFlowRelativeToMC(...)
550
551 // ===========================================================================================
552
553 TGraph* GetErrorMeshDiffFlow(TString methodUsedToMakeErrorMesh, TString rpPoi, TString ptEta)
554 {
555  // Error mesh for differential flow.
556  
557  TH1D *hist = GetResultHistogram(methodUsedToMakeErrorMesh.Data(),rpPoi.Data(),ptEta.Data());
558  
559  // Rebin higher pt bins:
560  if(hist && rebinInPt && ptEta == "Pt")
561  {
562   hist = RebinInPt(hist);
563  }
564   
565  // Make a mesh: 
566  TGraph *errorMesh = NULL;
567  if(hist)
568  {
569   Int_t nBins = hist->GetNbinsX();
570   Double_t value = 0.;
571   Double_t error = 0.;
572   // Counting the non-empty bins: 
573   Int_t nNonEmptyBins = 0;
574   for(Int_t i=1;i<nBins+1;i++)
575   {
576    value = hist->GetBinContent(i);
577    error = hist->GetBinError(i);
578    if(TMath::Abs(value)>0.0 && error>0.0)
579    {
580     nNonEmptyBins++;
581    }
582   } // end of for(Int_t i=1;i<nBins+1;i++)  
583   // Error mesh:
584   errorMesh = new TGraph(2*nNonEmptyBins+1); 
585   Int_t count = 0;
586   Double_t binCenter = 0.;
587   for(Int_t i=1;i<nBins+1;i++)
588   {
589    value = hist->GetBinContent(i);
590    error = hist->GetBinError(i);
591    // Setting up the the mesh:
592    if(TMath::Abs(value)>0.0 && error>0.0)
593    {    
594     binCenter = hist->GetBinCenter(i);   
595     errorMesh->SetPoint(count,binCenter,value+error);
596     errorMesh->SetPoint(2*nNonEmptyBins-(count+1),binCenter,value-error);
597     count++;
598    }
599   } // end of for(Int_t i=1;i<nBins+1;i++)
600   // Closing the mesh area:
601   Double_t xStart = 0.;
602   Double_t yStart = 0.;
603   errorMesh->GetPoint(0,xStart,yStart);
604   errorMesh->SetPoint(2*nNonEmptyBins,xStart,yStart);   
605  } // end if(hist)
606  
607  return errorMesh;
608  
609 } // end of TGraph* GetErrorMeshDiffFlow(TString methodUsedToMakeErrorMesh, TString ptEta, TString rpPoi)
610
611 // ===========================================================================================
612
613 Int_t GetHarmonic(TString method)
614 {
615  // Get harmonic used in analysis from the output file of specified method.
616  Int_t n = -44; // harmonic
617  
618  AliFlowCommonHist *commonHist = NULL;
619  for(Int_t l=0;l<nMethods;l++)
620  {
621   TString temp = "";
622   if(list[l]) 
623   {
624    temp = TString(list[l]->GetName());
625   }
626   if(temp.Contains(method.Data()))
627   {
628    commonHist = dynamic_cast<AliFlowCommonHist*> list[l]->FindObject(Form("AliFlowCommonHist%s",method.Data()));
629    if(commonHist && commonHist->GetHarmonic())
630    {
631     n = commonHist->GetHarmonic()->GetBinContent(1);
632    } else
633      {
634       cout<<endl;
635       cout<<" WARNING: commonHist && commonHist->GetHarmonic() is NULL !!!!"<<endl;
636       cout<<endl;
637      }
638   } 
639  } // end of for(Int_t l=0;l<nMethods;l++)
640  
641  if(n==-44)
642  {
643   cout<<endl;
644   cout<<" WARNING: Couldn't access harmonic from common control histogram of specified method."<<endl;
645   cout<<           "Try with another method in 'TString methodForSettings'."<<endl;
646   cout<<endl;
647  }
648  
649  return n;
650
651 } // end of Int_t GetHarmonic(TString method)
652
653 // ===========================================================================================
654
655 TH1D* RebinInPt(TH1D *hist)
656 {
657  // Rebin original histograms.
658  
659  if(!hist)
660  {
661   cout<<endl;
662   cout<<" WARNING: hist is NULL in RebinInPt() !!!!"<<endl;
663   cout<<endl;
664   exit(0); 
665  } 
666  
667  Double_t binWidthOld = hist->GetXaxis()->GetBinWidth(4);
668  Int_t nBinsOld = hist->GetXaxis()->GetNbins(); 
669  for(Int_t b=1;b<=nBinsOld;b++)
670  {
671   if(TMath::Abs(hist->GetXaxis()->GetBinWidth(b)-binWidthOld)>1.e-44)
672   {
673    cout<<endl;
674    cout<<Form(" WARNING: %s have bins of unequal width !!!!",hist->GetName())<<endl;
675    cout<<"               Do not trust rebinning for high pt." <<endl;
676    cout<<endl;
677   }
678  } // end of for(Int_t b=1;b<=nBinsOld;b++)
679  if(binWidthOld<1.e-44)
680  {
681   cout<<endl;
682   cout<<Form(" WARNING: in %s bin width is 0 !!!!",hist->GetName())<<endl;
683   cout<<"               Cannot do rebinning in pt." <<endl;
684   cout<<endl;
685   exit(0);
686  }
687    
688  // Book rebinned histogram:
689  Int_t nBinsNew = 0;
690  for(Int_t i=0;i<nPtIntervals;i++)
691  {
692   Double_t xMin = TMath::Nint(ptInterval[i]/binWidthOld)*binWidthOld;
693   Double_t xMax = TMath::Nint(ptInterval[i+1]/binWidthOld)*binWidthOld;
694   Int_t nBins = TMath::Nint((xMax-xMin)/binWidthOld); 
695   if(nBins <= 0)
696   {
697    cout<<endl;
698    cout<<Form(" WARNING: nBins <=0 when rebinning %s !!!!",hist->GetName())<<endl;
699    cout<<"               Check entries in array ptInterval." <<endl;
700    cout<<endl;
701    exit(0);
702   }
703   if(nBins % nMergedBins[i] == 0)
704   {
705    nBinsNew += nBins/nMergedBins[i];
706   } else
707     {
708      nBinsNew += (nBins/nMergedBins[i] + 1);  
709     }      
710  } // end of for(Int_t i=0;i<nPtIntervals;i++) 
711  const Int_t nBinsRebinned = nBinsNew;
712  Double_t binEdges[nBinsRebinned+1] = {0.};
713  Int_t counterForRebinnedBins = 0; 
714  for(Int_t i=0;i<nPtIntervals;i++)
715  {
716   Double_t xMin = TMath::Nint(ptInterval[i]/binWidthOld)*binWidthOld;
717   Double_t xMax = TMath::Nint(ptInterval[i+1]/binWidthOld)*binWidthOld;
718   Int_t nBins = TMath::Nint((xMax-xMin)/binWidthOld); 
719   if(nBins % nMergedBins[i] == 0)
720   {
721    nBins = nBins/nMergedBins[i];
722   } else
723     {
724      nBins = (nBins/nMergedBins[i] + 1);  
725     }      
726   for(Int_t b=0;b<nBins;b++)
727   {
728    binEdges[counterForRebinnedBins] = xMin + b*binWidthOld*nMergedBins[i];
729    counterForRebinnedBins++;
730   }          
731  } // end of for(Int_t i=0;i<nPtIntervals;i++) 
732  // Last bin edge:
733  binEdges[counterForRebinnedBins] = hist->GetXaxis()->GetXmax(); 
734
735  TH1D *temp = new TH1D("","",nBinsRebinned,binEdges); // rebinned histogram 
736  for(Int_t br=0;br<nBinsRebinned;br++) // bins in rebinned histogram
737  { 
738   Double_t value = 0.;
739   Double_t error = 0.;
740   Double_t dSum1 = 0.; // sum value_i/(error_i)^2
741   Double_t dSum2 = 0.; // sum 1/(error_i)^2
742   Int_t startingBin = hist->FindBin(binEdges[br]);
743   Int_t endingBin = hist->FindBin(binEdges[br+1]);  
744   for(Int_t bo=startingBin;bo<endingBin;bo++) // bins in original histogram
745   {
746    value = hist->GetBinContent(bo);  
747    error = hist->GetBinError(bo);  
748    if(error>0.)
749    {
750     dSum1+=value/(error*error);
751     dSum2+=1./(error*error);
752    }
753   } 
754   if(dSum2>0.)
755   {
756    temp->SetBinContent(br+1,dSum1/dSum2);
757    temp->SetBinError(br+1,pow(1./dSum2,0.5));
758   }
759  } // end of for(Int_t b=1;b<=nBinsOld;b++)
760     
761  return temp;
762       
763 } // end of RebinInPt()
764
765 // ===========================================================================================
766
767 TH1D* StyleHistDiffFlow(TString ptEta, TString rpPoi)
768 {
769  // Style histogram for differential flow.
770  
771  Int_t n = 2; // default harmonic
772  if(!useDefaultValues){n = GetHarmonic(methodForSettings);}
773  TH1D *styleHistDiffFlow = NULL;
774  if(ptEta == "Pt")
775  {
776   Int_t iNbinsPt  = AliFlowCommonConstants::GetMaster()->GetNbinsPt();
777   Double_t dPtMin = AliFlowCommonConstants::GetMaster()->GetPtMin();
778   Double_t dPtMax = AliFlowCommonConstants::GetMaster()->GetPtMax();
779   if(!useDefaultValues)
780   {
781    AliFlowCommonHist *commonHist = NULL;
782    for(Int_t l=0;l<nMethods;l++)
783    {
784     TString temp = "";
785     if(list[l]) 
786     {
787      temp = TString(list[l]->GetName());
788     }
789     if(temp.Contains(methodForSettings.Data()))
790     {
791      commonHist = dynamic_cast<AliFlowCommonHist*> list[l]->FindObject(Form("AliFlowCommonHist%s",methodForSettings.Data()));
792      if(commonHist && commonHist->GetHistPtRP() && rpPoi == "RP")
793      {
794       iNbinsPt = commonHist->GetHistPtRP()->GetNbinsX();
795       dPtMin = commonHist->GetHistPtRP()->GetXaxis()->GetXmin();
796       dPtMax = commonHist->GetHistPtRP()->GetXaxis()->GetXmax();
797      } else if(commonHist && commonHist->GetHistPtPOI() && rpPoi == "POI")
798        {
799         iNbinsPt = commonHist->GetHistPtPOI()->GetNbinsX();
800         dPtMin = commonHist->GetHistPtPOI()->GetXaxis()->GetXmin();
801         dPtMax = commonHist->GetHistPtPOI()->GetXaxis()->GetXmax();      
802        } 
803        else
804        {
805         cout<<endl;
806         cout<<" WARNING: Coudn't access common control histogram for pt yield !!!!"<<endl;
807         cout<<endl;
808        }
809     } 
810    } // end of for(Int_t l=0;l<nMethods;l++)
811   } // end of if(!useDefaultValues)
812   styleHistDiffFlow = new TH1D("","styleHistDiffFlow",iNbinsPt,dPtMin,dPtMax);
813   styleHistDiffFlow->SetTitle(Form("Differential Flow #font[72]{vs} p_{t} (%s)",rpPoi.Data()));
814   styleHistDiffFlow->SetXTitle("p_{t} [GeV]");
815   styleHistDiffFlow->SetYTitle(Form("v_{%d}",n));
816  } 
817  else if(ptEta == "Eta")
818  {
819   Int_t iNbinsEta  = AliFlowCommonConstants::GetMaster()->GetNbinsEta();
820   Double_t dEtaMin = AliFlowCommonConstants::GetMaster()->GetEtaMin();
821   Double_t dEtaMax = AliFlowCommonConstants::GetMaster()->GetEtaMax();
822   if(!useDefaultValues)
823   {
824    AliFlowCommonHist *commonHist = NULL;
825    for(Int_t l=0;l<nMethods;l++)
826    {
827     TString temp = "";
828     if(list[l]) 
829     {
830      temp = TString(list[l]->GetName());
831     }
832     if(temp.Contains(methodForSettings.Data()))
833     {
834      commonHist = dynamic_cast<AliFlowCommonHist*> list[l]->FindObject(Form("AliFlowCommonHist%s",methodForSettings.Data()));
835      if(commonHist && commonHist->GetHistEtaRP() && rpPoi == "RP")
836      {
837       iNbinsEta = commonHist->GetHistEtaRP()->GetNbinsX();
838       dEtaMin = commonHist->GetHistEtaRP()->GetXaxis()->GetXmin();
839       dEtaMax = commonHist->GetHistEtaRP()->GetXaxis()->GetXmax();
840      } else if(commonHist && commonHist->GetHistEtaPOI() && rpPoi == "POI")
841        {
842         iNbinsEta = commonHist->GetHistEtaPOI()->GetNbinsX();
843         dEtaMin = commonHist->GetHistEtaPOI()->GetXaxis()->GetXmin();
844         dEtaMax = commonHist->GetHistEtaPOI()->GetXaxis()->GetXmax();      
845        } 
846        else
847        {
848         cout<<endl;
849         cout<<" WARNING: Coudn't access common control histogram for eta distribution !!!!"<<endl;
850         cout<<endl;
851        }
852     } 
853    } // end of for(Int_t l=0;l<nMethods;l++)
854   } // end of if(!useDefaultValues)
855   styleHistDiffFlow = new TH1D("","",iNbinsEta,dEtaMin,dEtaMax);
856   styleHistDiffFlow->SetTitle(Form("Differential Flow #font[72]{vs} #eta (%s)",rpPoi.Data()));
857   styleHistDiffFlow->SetXTitle("#eta");
858   styleHistDiffFlow->SetYTitle(Form("v_{%d}",n));
859  }
860  if(styleHistDiffFlow)
861  {
862   styleHistDiffFlow->SetMinimum(-0.25); // to be improved - implement algorithm for this 
863   styleHistDiffFlow->SetMaximum(1.); // to be improved - implement algorithm for this 
864   //styleHistDiffFlow->GetYaxis()->SetLabelSize(0.05);
865   //styleHistDiffFlow->GetYaxis()->SetTitleSize(0.06);
866   //styleHistDiffFlow->GetYaxis()->SetTitleOffset(0.55);
867   //styleHistDiffFlow->GetXaxis()->SetLabelSize(0.05);
868   //styleHistDiffFlow->GetXaxis()->SetTitleSize(0.06);
869   //styleHistDiffFlow->GetXaxis()->SetTitleOffset(0.6);
870   //styleHistDiffFlow->GetXaxis()->SetLabelOffset(0.02);
871  }
872  
873  return styleHistDiffFlow;
874
875 } // end of TH1D* StyleHistDiffFlow(TString ptEta, TString rpPoi)
876
877 // ===========================================================================================
878
879 void Plot(const Int_t nMethods,TString *method,Int_t *methodMarkerStyle,Int_t *methodMarkerColor,
880          TString methodUsedToMakeErrorMesh,Int_t meshStyle,Int_t meshColor,TString rfRpPoi)
881 {
882  // Make a plot for reference and integrated flow.
883  
884  TString title = "";
885  if(rfRpPoi == "RF")
886  {
887   title = "Reference Flow";
888  } else if(rfRpPoi == "POI") 
889    {
890     title = "Integrated Flow (POI)";
891    } else if(rfRpPoi == "RP") 
892      {
893       title = "Integrated Flow (RP)";
894      }
895
896  Double_t x = 0.; // determines position of the marker on x axis
897  Double_t results[nMethods] = {0.};
898  Double_t errors[nMethods] = {0.};
899  TGraphErrors *ge[nMethods] = {NULL};
900  TGraph *errorMesh = NULL;
901  for(Int_t b=0;b<nMethods;b++)
902  {
903   x = b+0.5; 
904   TH1D *hist = NULL;
905   hist = GetResultHistogram(method[b].Data(),rfRpPoi.Data()); 
906   if(hist)
907   {
908    results[b] = hist->GetBinContent(1);
909    errors[b] = hist->GetBinError(1);
910    if(TMath::Abs(results[b])>1.e-44) 
911    {
912     ge[b] = GetGraphErrors(x,results[b],errors[b],methodMarkerStyle[b],methodMarkerColor[b]);
913    }
914    if(strcmp(method[b].Data(),methodUsedToMakeErrorMesh.Data()) == 0)
915    {
916     errorMesh = GetErrorMesh(nMethods+1,results[b],errors[b],meshStyle,meshColor);
917    }
918   } else
919     {
920      //cout<<"WARNING: For a method "<<method[b].Data()<<" couldn't get the histogram with result"<<endl;
921      //cout<<"         for "<<title.Data()<<" !!!! "<<endl;
922     } 
923  } // end of for(Int_t b=0;b<nMethods;b++)
924
925  // Final drawing:
926  TCanvas *c = NULL;
927  // Settings for canvas:
928  Int_t sizeX = 1000; // canvas size in pixels along x
929  Int_t sizeY = 600; // canvas size in pixels along y
930  if(!showLegend) sizeX = 0.75*sizeX;
931  c = new TCanvas(title.Data(),title.Data(),sizeX,sizeY);
932  if(showLegend)
933  {
934   c->Divide(2,1);
935   c->cd(1)->SetPad(0.0,0.0,0.75,1.0);
936  } 
937  StyleHist(title,nMethods,method,results,errors)->Draw();
938  if(errorMesh && showErrorMesh){errorMesh->Draw("lfsame");}
939  for(Int_t b=0;b<nMethods;b++)
940  {
941   if(ge[b])ge[b]->Draw("psame");
942  } 
943  if(showLegend)
944  {
945   c->cd(2)->SetPad(0.73,0.0,0.97,1.0);
946   DefaultTextInLegend()->Draw();
947   Legend(nMethods,method,rfRpPoi)->Draw();
948  }
949  
950  return;
951
952 } // end of Plot(...)
953
954 // ===========================================================================================
955     
956 void PlotRelativeToMC(const Int_t nMethods, TString *method, Int_t *methodMarkerStyle,
957                       Int_t *methodMarkerColor, TString rfRpPoi)
958 {
959  // Make a plot (v{MC}-v{method})/v{MC} for reference and integrated flow.
960
961  TString title = "";
962  if(rfRpPoi == "RF")
963  {
964   title = "Reference Flow relative to MCEP";
965  } else if(rfRpPoi == "POI") 
966    {
967     title = "Integrated Flow (POI) relative to MCEP";
968    } else if(rfRpPoi == "RP") 
969      {
970       title = "Integrated Flow (RP) relative to MCEP";
971      }
972
973  Double_t x = 0.; // determines position of the marker on x axis
974  Double_t results[nMethods] = {0.};
975  Double_t errors[nMethods] = {0.};
976  // MCEP result and error:
977  TH1D *mcep = GetResultHistogram("MCEP","RF");
978  Double_t mcepResult = 0.;
979  Double_t mcepError = 0.;
980  if(mcep)
981  {
982   mcepResult = mcep->GetBinContent(1);
983   mcepError = mcep->GetBinError(1);
984  } else
985    {
986     cout<<"WARNING: MCEP histogram not available in making the plot for "<<title.Data()<<" !!!!"<<endl;   
987     return;    
988    }
989  if(TMath::Abs(mcepResult) < 1.e-44 || TMath::Abs(mcepError) < 1.e-44) 
990  {
991   cout<<"WARNING: Result or error for v{MCEP} is zero in making the plot for "<<title.Data()<<" !!!!"<<endl;   
992   return;
993  } 
994  TGraphErrors *ge[nMethods] = {NULL};
995  for(Int_t b=0;b<nMethods;b++)
996  {
997   x = b+0.5; 
998   TH1D *hist = NULL;
999   hist = GetResultHistogram(method[b].Data(),rfRpPoi.Data()); 
1000   if(hist)
1001   {
1002    results[b] = hist->GetBinContent(1);
1003    errors[b] = hist->GetBinError(1);
1004    if(TMath::Abs(results[b])>1.e-44) 
1005    {
1006     errors[b] = pow(pow(errors[b]/mcepResult,2.)+pow(results[b]*mcepError/pow(mcepResult,2.),2.),0.5); // Do not switch with the next line!
1007     results[b] = (mcepResult-results[b])/mcepResult;
1008     ge[b] = GetGraphErrors(x,results[b],errors[b],methodMarkerStyle[b],methodMarkerColor[b]);
1009    }
1010   } else
1011     {
1012      //cout<<"WARNING: For a method "<<method[b].Data()<<" couldn't get the histogram with result"<<endl;
1013      //cout<<"         for "<<title.Data()<<" !!!! "<<endl;
1014     } 
1015  } // end of for(Int_t b=0;b<nMethods;b++)
1016
1017  // Final drawing:
1018  TCanvas *c = NULL;
1019  // Settings for canvas:
1020  Int_t sizeX = 1000; // canvas size in pixels along x
1021  Int_t sizeY = 600; // canvas size in pixels along y
1022  if(!showLegend) sizeX = 0.75*sizeX;
1023  c = new TCanvas(title.Data(),title.Data(),sizeX,sizeY);
1024  if(showLegend)
1025  {
1026   c->Divide(2,1);
1027   c->cd(1)->SetPad(0.0,0.0,0.75,1.0);
1028  } 
1029  // Style histogram:
1030  Int_t n = 2; // default harmonic
1031  if(!useDefaultValues){n = GetHarmonic(methodForSettings);}
1032  TH1D *styleHist = StyleHist(title,nMethods,method,results,errors);
1033  styleHist->GetYaxis()->SetTitleOffset(1.25);
1034  styleHist->GetYaxis()->SetTitleSize(0.03);
1035  styleHist->GetYaxis()->SetLabelSize(0.03);
1036  styleHist->GetYaxis()->SetTitle(Form("(v_{%d}\{MCEP\}-v_{%d}\{method\})/v_{%d}\{MCEP\}",n,n,n));
1037  styleHist->Draw();
1038  // Methods:
1039  for(Int_t b=0;b<nMethods;b++)
1040  {
1041   if(ge[b])ge[b]->Draw("psame");
1042  } 
1043  if(showLegend)
1044  {
1045   c->cd(2)->SetPad(0.73,0.0,0.97,1.0);
1046   DefaultTextInLegend()->Draw();
1047   Legend(nMethods,method,rfRpPoi)->Draw();
1048  }
1049  
1050  return;
1051
1052 } // end of void PlotRelativeToMC(...) 
1053
1054 // ===========================================================================================
1055
1056 TPaveText* DefaultTextInLegend()
1057 {
1058  // Determine the default text in legend.
1059  
1060  TPaveText *textDefault = new TPaveText(0.05,0.77,0.95,0.90,"NDC");
1061  textDefault->SetTextFont(72);
1062  textDefault->SetTextSize(0.08);
1063  textDefault->AddText("Average Multiplicity");
1064  textDefault->AddText("and");
1065  textDefault->AddText("Number of Events");
1066  textDefault->SetFillStyle(0); // white instead of default grey
1067
1068  return textDefault;
1069  
1070 } // end of TPaveText* DefaultTextInLegend()
1071  
1072 // =========================================================================================== 
1073
1074 TPaveText* Legend(Int_t nMethods, TString *method, TString rfRpPoi)
1075 {
1076  // Make a legend.
1077  
1078  TPaveText *legend = new TPaveText(0.05,0.12,0.95,0.70,"NDC");
1079  legend->SetTextFont(72);
1080  legend->SetTextSize(0.06);
1081  legend->SetFillStyle(0); // white instead of default grey
1082  const Int_t nLegendEntries = 11;
1083  TString legendEntries[nLegendEntries] = {"MCEP ...... ","SP ........ ","GFC ....... ",
1084                                           "QC{2} ..... ","QC{4} ..... ","QC{6} ..... ",
1085                                           "QC{8} ..... ","FQD ....... ","LYZ{sum} .. ",
1086                                           "LYZ{prod} . ","LYZEP ..... "}; 
1087  TString temp = "";
1088  Int_t gfcCounter = 0; // represent "2,GFC", "4,GFC", "6,GFC" and "8,GFC" with the same entry GFC
1089  for(Int_t b=0;b<nMethods;b++)
1090  {
1091   for(Int_t le=0;le<nLegendEntries;le++)
1092   {
1093    if(legendEntries[le].Contains(method[b].Data())) // this is either MCEP, FQD, SP or LYZEP
1094    { 
1095     temp = legendEntries[le]+GetAvMultiplicityAndNoOfEvents(method[b].Data(),rfRpPoi);
1096     legend->AddText(temp.Data());
1097    }
1098    else if(method[b].Contains("GFC") && gfcCounter == 0 && legendEntries[le].Contains("GFC")) // GFC
1099    {
1100     temp = legendEntries[le]+GetAvMultiplicityAndNoOfEvents(method[b].Data(),rfRpPoi);
1101     legend->AddText(temp.Data()); 
1102     gfcCounter++;  
1103    } 
1104    else if(method[b].Contains("QC") && legendEntries[le].Contains("QC")) // QC
1105    {
1106     for(Int_t o=1;o<=4;o++) // QC order
1107     {
1108      if(method[b].Contains(Form("%d",2*o)) && legendEntries[le].Contains(Form("%d",2*o)))
1109      {
1110       temp = legendEntries[le]+GetAvMultiplicityAndNoOfEvents(method[b].Data(),rfRpPoi);
1111       legend->AddText(temp.Data());
1112      }
1113     } // end of for(Int o=1;o<=4;o++) // QC order
1114    }
1115    else if((method[b].Contains("LYZ1SUM")||method[b].Contains("LYZ2SUM")) && legendEntries[le].Contains("LYZ{sum}"))
1116    {
1117     temp = legendEntries[le]+GetAvMultiplicityAndNoOfEvents(method[b].Data(),rfRpPoi);
1118     legend->AddText(temp.Data());
1119    }
1120    else if((method[b].Contains("LYZ1PROD")||method[b].Contains("LYZ2PROD")) && legendEntries[le].Contains("LYZ{prod}"))
1121    {
1122     temp = legendEntries[le]+GetAvMultiplicityAndNoOfEvents(method[b].Data(),rfRpPoi);
1123     legend->AddText(temp.Data());
1124    }
1125   } // end of for(Int_t le=0;le<nLegendEntries;le++)
1126  } // end of for(Int_t b=0;b<nMethods;b++)
1127   
1128  return legend;
1129
1130 } // end of TPaveText* Legend(Int_t nMethods, TString *method, TString rfRpPoi)
1131 // =========================================================================================== 
1132
1133 TLegend* LegendDiffFlow(Int_t nMethods, TString *method, Int_t *methodMarkerStyle, Int_t *methodMarkerColor,
1134                         TString methodUsedToMakeErrorMesh, Int_t meshStyle, Int_t meshColor, TString ptEta, TString rpPoi)
1135 {
1136  // Make a legend for differential flow.
1137  
1138  TLegend *legend = new TLegend(0.0,0.12,0.99,0.70);
1139  legend->SetMargin(0.15);
1140  legend->SetTextFont(72);
1141  legend->SetTextSize(0.06);
1142  legend->SetFillStyle(0); // white instead of default grey
1143  const Int_t nLegendEntries = 14;
1144  TString legendEntries[nLegendEntries] = {"MCEP ...... ","SP ........ ","GFC{2} .... ","QC{2} ..... ",
1145                                           "GFC{4} .... ","QC{4} ..... ","GFC{6} .... ","QC{6} ..... ",
1146                                           "GFC{8} .... ","QC{8} ..... ","FQD ....... ","LYZ{sum} .. ",
1147                                           "LYZ{prod} . ","LYZEP ..... "};                                                                                     
1148  
1149  TH1D *hist = NULL;
1150  TString temp = "";
1151  for(Int_t b=0;b<nMethods;b++)
1152  {
1153   for(Int_t le=0;le<nLegendEntries;le++)
1154   {
1155    if(legendEntries[le].Contains(method[b].Data())) // this is either MCEP, FQD, SP or LYZEP
1156    { 
1157     temp = legendEntries[le]+GetAvMultiplicityAndNoOfEvents(method[b].Data(),rpPoi);
1158     hist = GetResultHistogram(method[b].Data(),rpPoi.Data(),ptEta.Data());
1159     if(hist)
1160     {
1161      hist->SetMarkerStyle(methodMarkerStyle[b]);
1162      hist->SetMarkerColor(methodMarkerColor[b]);  
1163      if(methodUsedToMakeErrorMesh == method[b].Data())
1164      {
1165       hist->SetFillStyle(meshStyle);
1166       hist->SetFillColor(meshColor);
1167       legend->AddEntry(hist,temp.Data(),"f");    
1168      } else
1169        {
1170         legend->AddEntry(hist,temp.Data(),"p");    
1171        }
1172     } // end of if(hist)   
1173    }       
1174    else if(method[b].Contains("GFC") && legendEntries[le].Contains("GFC")) // GFC
1175    {
1176     for(Int_t o=1;o<=4;o++) // GFC order
1177     {
1178      if(method[b].Contains(Form("%d",2*o)) && legendEntries[le].Contains(Form("%d",2*o)))
1179      { 
1180       temp = legendEntries[le]+GetAvMultiplicityAndNoOfEvents(method[b].Data(),rpPoi);
1181       hist = GetResultHistogram(method[b].Data(),rpPoi.Data(),ptEta.Data());
1182       if(hist)
1183       {
1184        hist->SetMarkerStyle(methodMarkerStyle[b]);
1185        hist->SetMarkerColor(methodMarkerColor[b]); 
1186        if(methodUsedToMakeErrorMesh == method[b].Data())
1187        {
1188         hist->SetFillStyle(meshStyle);
1189         hist->SetFillColor(meshColor);
1190         legend->AddEntry(hist,temp.Data(),"f");    
1191        } else
1192          {
1193           legend->AddEntry(hist,temp.Data(),"p");    
1194          }
1195       } // end of if(hist)           
1196      }
1197     }
1198    } 
1199    else if(method[b].Contains("QC") && legendEntries[le].Contains("QC")) // QC
1200    {
1201     for(Int_t o=1;o<=4;o++) // QC order
1202     {
1203      if(method[b].Contains(Form("%d",2*o)) && legendEntries[le].Contains(Form("%d",2*o)))
1204      {
1205       temp = legendEntries[le]+GetAvMultiplicityAndNoOfEvents(method[b].Data(),rpPoi);
1206       hist = GetResultHistogram(method[b].Data(),rpPoi.Data(),ptEta.Data());
1207       if(hist)
1208       {
1209        hist->SetMarkerStyle(methodMarkerStyle[b]);
1210        hist->SetMarkerColor(methodMarkerColor[b]);   
1211        if(methodUsedToMakeErrorMesh == method[b].Data())
1212        {
1213         hist->SetFillStyle(meshStyle);
1214         hist->SetFillColor(meshColor);
1215         legend->AddEntry(hist,temp.Data(),"f");    
1216        } else
1217          {
1218           legend->AddEntry(hist,temp.Data(),"p");    
1219          }
1220       } // end of if(hist)             
1221      }
1222     } // end of for(Int o=1;o<=4;o++) // QC order
1223    }
1224    else if((method[b].Contains("LYZ1SUM")||method[b].Contains("LYZ2SUM")) && legendEntries[le].Contains("LYZ{sum}"))
1225    {
1226     temp = legendEntries[le]+GetAvMultiplicityAndNoOfEvents(method[b].Data(),rpPoi);
1227     hist = GetResultHistogram(method[b].Data(),rpPoi.Data(),ptEta.Data());
1228     if(hist)
1229     {
1230      hist->SetMarkerStyle(methodMarkerStyle[b]);
1231      hist->SetMarkerColor(methodMarkerColor[b]);  
1232      if(methodUsedToMakeErrorMesh == method[b].Data())
1233      {
1234       hist->SetFillStyle(meshStyle);
1235       hist->SetFillColor(meshColor);
1236       legend->AddEntry(hist,temp.Data(),"f");    
1237      } else
1238        {
1239         legend->AddEntry(hist,temp.Data(),"p");    
1240        }         
1241     } // end of if(hist)
1242    }
1243    else if((method[b].Contains("LYZ1PROD")||method[b].Contains("LYZ2PROD")) && legendEntries[le].Contains("LYZ{prod}"))
1244    {
1245     temp = legendEntries[le]+GetAvMultiplicityAndNoOfEvents(method[b].Data(),rpPoi);
1246     hist = GetResultHistogram(method[b].Data(),rpPoi.Data(),ptEta.Data());
1247     if(hist)
1248     {
1249      hist->SetMarkerStyle(methodMarkerStyle[b]);
1250      hist->SetMarkerColor(methodMarkerColor[b]);  
1251      if(methodUsedToMakeErrorMesh == method[b].Data())
1252      {
1253       hist->SetFillStyle(meshStyle);
1254       hist->SetFillColor(meshColor);
1255       legend->AddEntry(hist,temp.Data(),"f");    
1256      } else
1257        {
1258         legend->AddEntry(hist,temp.Data(),"p");    
1259        }      
1260     } // end of if(hist)      
1261    }
1262   } // end of for(Int_t le=0;le<nLegendEntries;le++)
1263  } // end of for(Int_t b=0;b<nMethods;b++)
1264    
1265  return legend;
1266
1267 } // end of TLegend* Legend(...)
1268
1269 // =========================================================================================== 
1270
1271 TString GetAvMultiplicityAndNoOfEvents(TString method, TString rfRpPoi)
1272 {
1273  // Get average multiplicity and number of events for specified method and return it as "M = <AvM>, N = <N>".
1274  
1275  TString MN = ""; // string to hold "M = <AvM>, N = <N>"
1276  Long_t N = 0; // number of events 
1277  Double_t M = 0.; // average multiplicity
1278  
1279  TH1F *hist = GetControlHistogram(method,rfRpPoi); 
1280  if(hist)
1281  {
1282   N = hist->GetEntries();
1283   M = hist->GetMean();
1284   MN.Append("M = ");
1285   MN+=(Long_t)M;
1286   MN.Append(", N = ");
1287   MN+=N;
1288  } else 
1289    {
1290     MN.Append("n/a");
1291    }
1292  
1293  return MN;
1294  
1295 } // end of TString GetAvMultiplicityAndNoOfEvents(TString *method, TString rfRpPoi)
1296
1297 // ===========================================================================================
1298
1299 TH1F* GetControlHistogram(TString method, TString rfRpPoi)
1300 {
1301  // Get the control histogram for specified method holding the average multiplicity and number of events.
1302  
1303  AliFlowCommonHist *commonHist = NULL; 
1304  TString methodName = method.Data(); 
1305  Int_t cumulantOrder = 0;
1306  if(method.Contains("GFC"))
1307  {
1308   TString methodNameTemp1 = method;   
1309   TString methodNameTemp2 = method;   
1310   methodName = methodNameTemp1.Remove(0,2);
1311   cumulantOrder = methodNameTemp2.Remove(1,4).Atoi();      
1312  } else if(method.Contains("QC"))
1313    {
1314     TString methodNameTemp1 = method;   
1315     TString methodNameTemp2 = method;   
1316     methodName = methodNameTemp1.Remove(0,2);
1317     cumulantOrder = methodNameTemp2.Remove(1,3).Atoi();      
1318    }
1319
1320  // Get for specified methodName (and cumulantOrder, if needed) the common control histogram:
1321  // (to be improved - this can certainly be implemented better, but some redesign of the flow code is first in order)
1322  for(Int_t l=0;l<nMethods;l++)
1323  {
1324   TString temp = "";
1325   if(list[l]) 
1326   {
1327    temp = TString(list[l]->GetName());
1328   }
1329   if(temp.Contains(methodName.Data()))
1330   {
1331    // Access from the common list the needed common result histogram:
1332    if(!(methodName.Contains("QC")))
1333    {
1334     commonHist = dynamic_cast<AliFlowCommonHist*> list[l]->FindObject(Form("AliFlowCommonHist%s",methodName.Data()));
1335    } 
1336    else if(methodName=="QC")
1337    {
1338     if(cumulantOrder==2)
1339     {
1340      commonHist = dynamic_cast<AliFlowCommonHist*> list[l]->FindObject("AliFlowCommonHist2ndOrderQC");    
1341     } 
1342     else if(cumulantOrder==4)
1343     {
1344      commonHist = dynamic_cast<AliFlowCommonHist*> list[l]->FindObject("AliFlowCommonHist4thOrderQC");    
1345     }
1346     else if(cumulantOrder==6)
1347     {
1348      commonHist = dynamic_cast<AliFlowCommonHist*> list[l]->FindObject("AliFlowCommonHist6thOrderQC");    
1349     }
1350     else if(cumulantOrder==8)
1351     {
1352      commonHist = dynamic_cast<AliFlowCommonHist*> list[l]->FindObject("AliFlowCommonHist8thOrderQC");    
1353     }
1354     else
1355     {
1356      cout<<"WARNING: You have specified cumulant order to be "<<cumulantOrder<<" !!!!"<<endl;
1357      cout<<"         There are no results for this cumulant order. "<<endl;
1358     }
1359    } // end of else if(methodName=="QC")
1360   } // end of if(temp.Contains(methodName.Data()))
1361  } // end of for(Int_t l=0;l<nMethods;l++)
1362  
1363  if(!commonHist)
1364  {
1365   //cout<<"WARNING: For a method "<<method.Data()<<" couldn't access the common hist result !!!!"<<endl;
1366   //cout<<"         File absent? Or perhaps a typo in the method's name?"<<endl;
1367   if(methodName.Contains("QC"))
1368   {
1369    //cout<<"         Or impossible cumulant order? Otherwise.... :'( "<<endl;
1370   }
1371  }
1372
1373  // Finally, from commonHist access the required histogram: 
1374  TH1F *hist = NULL;
1375  if(commonHist) 
1376  { 
1377   if(rfRpPoi == "RF" || rfRpPoi == "RP")
1378   {
1379    hist = commonHist->GetHistMultRP();
1380   } else if(rfRpPoi == "POI")
1381     {
1382      hist = commonHist->GetHistMultPOI(); 
1383     } else 
1384       {
1385        cout<<"WARNING: Impossible TString rfRpPoi in GetControlHistogram() !!!!"<<endl;
1386        exit(0);
1387       } 
1388  }
1389
1390  return hist;
1391
1392 } // end of TH1D* GetControlHistogram(TString method, TString rfRpPoi)
1393
1394 // =========================================================================================== 
1395
1396 TH1D* StyleHist(TString title, Int_t nMethods, TString *method, Double_t *results, Double_t *errors)
1397 {
1398  // Make style histogram.
1399  TH1D *styleHist = new TH1D("",title.Data(),nMethods,0,nMethods);
1400  Int_t n = 2; // default harmonic
1401  if(!useDefaultValues){n = GetHarmonic(methodForSettings);}
1402  Double_t styleHistMin = 44.;
1403  Double_t styleHistMax = -44.;
1404  for(Int_t b=0;b<nMethods;b++)
1405  {
1406   // Form bin labels from method's names:
1407   styleHist->GetXaxis()->SetBinLabel(b+1,Form("v_{%d}\{%s\}",n,method[b].Data()));
1408   if(method[b].Contains("LYZ1SUM") || method[b].Contains("LYZ2SUM"))
1409   {
1410    styleHist->GetXaxis()->SetBinLabel(b+1,Form("v_{%d}\{LYZ,sum\}",n)); 
1411   }
1412   if(method[b].Contains("LYZ1PROD") || method[b].Contains("LYZ2PROD"))
1413   {
1414    styleHist->GetXaxis()->SetBinLabel(b+1,Form("v_{%d}\{LYZ,prod\}",n)); 
1415   }
1416   // Establish min and max values for style histograms:
1417   if(TMath::Abs(results[b])>1.e-44)
1418   {
1419    if(styleHistMin > results[b]-errors[b]) styleHistMin = results[b]-errors[b]; // min value
1420    if(styleHistMax < results[b]+errors[b]) styleHistMax = results[b]+errors[b]; // max value    
1421   }
1422  }
1423  
1424  styleHist->SetMinimum(0.99*styleHistMin);
1425  styleHist->SetMaximum(1.01*styleHistMax);
1426  /*
1427  styleHist->GetYaxis()->SetNdivisions(5,5,0);
1428  styleHist->GetYaxis()->SetLabelSize(0.05);
1429  styleHist->GetXaxis()->SetLabelSize(0.07);
1430  styleHist->GetXaxis()->SetLabelOffset(0.01);
1431  */
1432  
1433  return styleHist;
1434
1435 } // end of TH1D* StyleHist(TString *title, Int_t nMethods, TString *method, Double_t *results, Double_t *errors)
1436
1437 // ===========================================================================================
1438
1439 TFile* AccessOutputFile(TString outputFileName)
1440 {
1441  // Access the common output file.
1442     
1443  TFile *outputFile = NULL;
1444  if(!(gSystem->AccessPathName(Form("%s%s%s",gSystem->pwd(),"/",outputFileName.Data()),kFileExists)))
1445  {
1446   outputFile = TFile::Open(outputFileName.Data(),"READ");
1447  } else
1448    {
1449     cout<<endl;
1450     cout<<"WARNING: Couldn't find the file "<<outputFileName.Data()<<" in "<<endl;
1451     cout<<"         directory "<<gSystem->pwd()<<" !!!!"<<endl;
1452     cout<<endl;
1453     exit(0);
1454    }
1455   
1456  return outputFile;
1457  
1458 } // end of TFile* AccessOutputFile(TString outputFileName)
1459   
1460 // ===========================================================================================
1461  
1462 void GetListsWithHistograms(TFile *outputFile, TString analysisType)
1463 {
1464  // Access from common output file the TDirectoryFile's for each flow analysis method
1465  // and from them the TList's holding histograms with final results:
1466  
1467  TString fileName[nMethods]; 
1468  TDirectoryFile *dirFile[nMethods] = {NULL}; 
1469  TString listName[nMethods]; 
1470  Int_t failureCounter = 0;
1471  for(Int_t i=0;i<nMethods;i++)
1472  {
1473   // Form a file name for each method:
1474   fileName[i]+="output";
1475   fileName[i]+=method[i].Data();
1476   fileName[i]+="analysis";
1477   fileName[i]+=analysisType.Data();
1478   // Access this file:
1479   dirFile[i] = (TDirectoryFile*)outputFile->FindObjectAny(fileName[i].Data());
1480   // Form a list name for each method:
1481   if(dirFile[i])
1482   {
1483    TList* listTemp = dirFile[i]->GetListOfKeys();
1484    if(listTemp && listTemp->GetEntries() == 1)
1485    {
1486     listName[i] = listTemp->At(0)->GetName(); // to be improved - implemented better (use dynamic_cast instead)
1487     dirFile[i]->GetObject(listName[i].Data(),list[i]);
1488    } else
1489      {
1490       cout<<" WARNING: Accessing TList from TDirectoryFile failed for method "<<method[i].Data()<<" !!!!"<<endl;
1491       cout<<"          Did you actually use "<<method[i].Data()<<" in the analysis?"<<endl;
1492       cout<<endl;
1493      }
1494   } else 
1495     {
1496      cout<<" WARNING: Couldn't find a TDirectoryFile "<<fileName[i].Data()<<".root !!!!"<<endl;
1497      failureCounter++;
1498     }   
1499  } // end of for(Int_t i=0;i<nMethods;i++) 
1500  
1501  // If no files were found most probably the 'TString analysisType' was specified wrongly:
1502  if(failureCounter == nMethods)
1503  {
1504   cout<<endl; 
1505   cout<<"Did you specify 'TString analysisType' correctly? Can be \"\", \"ESD\", \"AOD\", etc."<<endl;
1506   cout<<endl; 
1507   exit(0);
1508  }
1509     
1510 } // end of void GetListsWithHistograms(TFile *outputFile, TString analysisType)
1511  
1512 // ===========================================================================================
1513
1514 TH1D* GetResultHistogram(TString method, TString rfRpPoi, TString ptEta="")
1515 {
1516  // Get the specified histogram holding result.
1517  
1518  AliFlowCommonHistResults *commonHistRes = NULL; 
1519  TString methodName = method.Data(); 
1520  Int_t cumulantOrder = 0;
1521  if(method.Contains("GFC"))
1522  {
1523   TString methodNameTemp1 = method;   
1524   TString methodNameTemp2 = method;   
1525   methodName = methodNameTemp1.Remove(0,2);
1526   cumulantOrder = methodNameTemp2.Remove(1,4).Atoi();      
1527  } else if(method.Contains("QC"))
1528    {
1529     TString methodNameTemp1 = method;   
1530     TString methodNameTemp2 = method;   
1531     methodName = methodNameTemp1.Remove(0,2);
1532     cumulantOrder = methodNameTemp2.Remove(1,3).Atoi();      
1533    }
1534  // Get for specified methodName (and cumulantOrder, if needed) the common hist result:
1535  // (to be improved - this can certainly be implemented better, but some redesign of the flow code is first in order)
1536  for(Int_t l=0;l<nMethods;l++)
1537  {
1538   TString temp = "";
1539   if(list[l]) 
1540   {
1541    temp = TString(list[l]->GetName());
1542   }
1543   if(temp.Contains(methodName.Data()))
1544   {
1545    // Access from the common list the needed common result histogram:
1546    if(!(methodName.Contains("GFC") || methodName.Contains("QC")))
1547    {
1548     commonHistRes = dynamic_cast<AliFlowCommonHistResults*> list[l]->FindObject(Form("AliFlowCommonHistResults%s",methodName.Data()));
1549    } 
1550    else if(methodName=="GFC")
1551    {
1552     if(cumulantOrder==2)
1553     {
1554      commonHistRes = dynamic_cast<AliFlowCommonHistResults*> list[l]->FindObject("AliFlowCommonHistResults2ndOrderGFC");    
1555     } 
1556     else if(cumulantOrder==4)
1557     {
1558      commonHistRes = dynamic_cast<AliFlowCommonHistResults*> list[l]->FindObject("AliFlowCommonHistResults4thOrderGFC");    
1559     }
1560     else if(cumulantOrder==6)
1561     {
1562      commonHistRes = dynamic_cast<AliFlowCommonHistResults*> list[l]->FindObject("AliFlowCommonHistResults6thOrderGFC");    
1563     }
1564     else if(cumulantOrder==8)
1565     {
1566      commonHistRes = dynamic_cast<AliFlowCommonHistResults*> list[l]->FindObject("AliFlowCommonHistResults8thOrderGFC");    
1567     } 
1568     else
1569     {
1570      cout<<"WARNING: You have specified cumulant order to be "<<cumulantOrder<<" !!!!"<<endl;
1571      cout<<"         That is really not funny.... "<<endl;
1572     }
1573    } // end of else if(methodName=="GFC")
1574    else if(methodName=="QC")
1575    {
1576     if(cumulantOrder==2)
1577     {
1578      commonHistRes = dynamic_cast<AliFlowCommonHistResults*> list[l]->FindObject("AliFlowCommonHistResults2ndOrderQC");    
1579     } 
1580     else if(cumulantOrder==4)
1581     {
1582      commonHistRes = dynamic_cast<AliFlowCommonHistResults*> list[l]->FindObject("AliFlowCommonHistResults4thOrderQC");    
1583     }
1584     else if(cumulantOrder==6)
1585     {
1586      commonHistRes = dynamic_cast<AliFlowCommonHistResults*> list[l]->FindObject("AliFlowCommonHistResults6thOrderQC");    
1587     }
1588     else if(cumulantOrder==8)
1589     {
1590      commonHistRes = dynamic_cast<AliFlowCommonHistResults*> list[l]->FindObject("AliFlowCommonHistResults8thOrderQC");    
1591     }
1592     else
1593     {
1594      cout<<"WARNING: You have specified cumulant order to be "<<cumulantOrder<<" !!!!"<<endl;
1595      cout<<"         There are no results for this cumulant order. "<<endl;
1596     }
1597    } // end of else if(methodName=="QC")
1598   } // end of if(temp.Contains(methodName.Data()))
1599  } // end of for(Int_t l=0;l<nMethods;l++)
1600  
1601  if(!commonHistRes)
1602  {
1603   //cout<<"WARNING: For a method "<<method.Data()<<" couldn't access the common hist result !!!!"<<endl;
1604   //cout<<"         File absent? Or perhaps a typo in the method's name?"<<endl;
1605   if(methodName.Contains("GFC") || methodName.Contains("QC"))
1606   {
1607    //cout<<"         Or impossible cumulant order? Otherwise.... :'( "<<endl;
1608   }
1609  }
1610  
1611
1612  // Finally, from commonHistRes access the required histogram: 
1613  TH1D *hist = NULL;
1614  if(commonHistRes) 
1615  { 
1616   if(rfRpPoi == "RF")
1617   {
1618    hist = commonHistRes->GetHistIntFlow();
1619   } else if(rfRpPoi == "RP")
1620     {
1621      if(ptEta == "")
1622      {
1623       hist = commonHistRes->GetHistIntFlowRP(); 
1624      } else if(ptEta == "Pt")
1625        {
1626         hist = commonHistRes->GetHistDiffFlowPtRP();      
1627        } else if(ptEta == "Eta")
1628          {
1629           hist = commonHistRes->GetHistDiffFlowEtaRP();
1630          }
1631     } else if(rfRpPoi == "POI")
1632       {
1633        if(ptEta == "")
1634        {
1635         hist = commonHistRes->GetHistIntFlowPOI(); 
1636        } else if(ptEta == "Pt") 
1637          {
1638           hist = commonHistRes->GetHistDiffFlowPtPOI();
1639          } else if(ptEta == "Eta")
1640            {
1641             hist = commonHistRes->GetHistDiffFlowEtaPOI();
1642            }  
1643       }
1644  }
1645   
1646  return hist;
1647
1648 } // end of TH1D* GetResultHistogram(TString method, TString rfRpPoi, TString ptEta="")
1649
1650 // ===========================================================================================
1651
1652 void GlobalSettings()
1653 {
1654  // Settings which will affect all plots.
1655  
1656  gROOT->SetStyle("Plain"); // default color is white instead of gray
1657  gStyle->SetOptStat(0); // remove stat. box from all histos
1658  TGaxis::SetMaxDigits(4); // prefer exp notation for 5 and more significant digits
1659  
1660 } // end of void GlobalSettings()
1661
1662 // ===========================================================================================
1663
1664 void LoadLibrariesCFR(const libModes analysisMode) {
1665   
1666   //--------------------------------------
1667   // Load the needed libraries most of them already loaded by aliroot
1668   //--------------------------------------
1669   //gSystem->Load("libTree");
1670   gSystem->Load("libGeom");
1671   gSystem->Load("libVMC");
1672   gSystem->Load("libXMLIO");
1673   gSystem->Load("libPhysics");
1674   
1675   //----------------------------------------------------------
1676   // >>>>>>>>>>> Local mode <<<<<<<<<<<<<< 
1677   //----------------------------------------------------------
1678   if (analysisMode==mLocal) {
1679     //--------------------------------------------------------
1680     // If you want to use already compiled libraries 
1681     // in the aliroot distribution
1682     //--------------------------------------------------------
1683     
1684     //==================================================================================  
1685     //load needed libraries:
1686     gSystem->AddIncludePath("-I$ROOTSYS/include");
1687     //gSystem->Load("libTree");
1688     
1689     // for AliRoot
1690     gSystem->AddIncludePath("-I$ALICE_ROOT/include");
1691     gSystem->Load("libANALYSIS");
1692     gSystem->Load("libPWGflowBase");
1693     //cerr<<"libPWGflowBase loaded ..."<<endl;
1694     
1695   }
1696   
1697   else if (analysisMode==mLocalSource) {
1698     
1699     // In root inline compile
1700    
1701    // Constants  
1702     gROOT->LoadMacro("BaseAliFlowCommonConstants.cxx+");
1703     gROOT->LoadMacro("BaseAliFlowLYZConstants.cxx+");
1704     
1705     // Flow event
1706     gROOT->LoadMacro("BaseAliFlowVector.cxx+"); 
1707     gROOT->LoadMacro("BaseAliFlowTrackSimple.cxx+");    
1708     gROOT->LoadMacro("BaseAliFlowTrackSimpleCuts.cxx+");    
1709     gROOT->LoadMacro("BaseAliFlowEventSimple.cxx+");
1710     
1711     // Output histosgrams
1712     gROOT->LoadMacro("BaseAliFlowCommonHist.cxx+");
1713     gROOT->LoadMacro("BaseAliFlowCommonHistResults.cxx+");
1714     gROOT->LoadMacro("BaseAliFlowLYZHist1.cxx+");
1715     gROOT->LoadMacro("BaseAliFlowLYZHist2.cxx+");
1716     
1717     cout << "finished loading macros!" << endl;  
1718     
1719   }  
1720   
1721 } // end of void LoadLibrariesCFR(const libModes analysisMode) 
1722