]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx
correction for non-uniform acceptance for 2nd and 4th order differential flow
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowAnalysisWithQCumulants.cxx
1 /*************************************************************************\r
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *\r
3 *                                                                        *\r
4 * Author: The ALICE Off-line Project.                                    *\r
5 * Contributors are mentioned in the code where appropriate.              *\r
6 *                                                                        *\r
7 * Permission to use, copy, modify and distribute this software and its   *\r
8 * documentation strictly for non-commercial purposes is hereby granted   *\r
9 * without fee, provided that the above copyright notice appears in all   *\r
10 * copies and that both the copyright notice and this permission notice   *\r
11 * appear in the supporting documentation. The authors make no claims     *\r
12 * about the suitability of this software for any purpose. It is          *\r
13 * provided "as is" without express or implied warranty.                  * \r
14 **************************************************************************/\r
15 \r
16 /********************************** \r
17  * flow analysis with Q-cumulants * \r
18  *                                * \r
19  * author:  Ante Bilandzic        * \r
20  *           (anteb@nikhef.nl)    *\r
21  *********************************/ \r
22 \r
23 #define AliFlowAnalysisWithQCumulants_cxx\r
24 \r
25 #include "Riostream.h"\r
26 #include "AliFlowCommonConstants.h"\r
27 #include "AliFlowCommonHist.h"\r
28 #include "AliFlowCommonHistResults.h"\r
29 #include "TChain.h"
30 \r
31 #include "TFile.h"\r
32 #include "TList.h"\r
33 #include "TGraph.h"\r
34 #include "TParticle.h"\r
35 #include "TRandom3.h"\r
36 #include "TStyle.h"\r
37 #include "TProfile.h"\r
38 #include "TProfile2D.h" \r
39 #include "TProfile3D.h"\r
40 #include "TMath.h"\r
41 #include "TArrow.h"\r
42 #include "TPaveLabel.h"\r
43 #include "TCanvas.h"\r
44 #include "AliFlowEventSimple.h"\r
45 #include "AliFlowTrackSimple.h"\r
46 #include "AliFlowAnalysisWithQCumulants.h"\r
47 #include "TArrayD.h"\r
48 #include "TRandom.h"\r
49 #include "TF1.h"\r
50 \r
51 class TH1;\r
52 class TH2;\r
53 class TGraph;\r
54 class TPave;\r
55 class TLatex;\r
56 class TMarker;\r
57 class TRandom3;\r
58 class TObjArray;\r
59 class TList;\r
60 class TCanvas;\r
61 class TSystem;\r
62 class TROOT;\r
63 class AliFlowVector;\r
64 class TVector;\r
65 \r
66 \r
67 //================================================================================================================\r
68 \r
69 \r
70 ClassImp(AliFlowAnalysisWithQCumulants)\r
71 \r
72 AliFlowAnalysisWithQCumulants::AliFlowAnalysisWithQCumulants(): \r
73  // 0.) base:\r
74  fHistList(NULL),\r
75  // 1.) common:\r
76  fCommonHists(NULL),\r
77  fCommonHists2nd(NULL), \r
78  fCommonHists4th(NULL),\r
79  fCommonHists6th(NULL),\r
80  fCommonHists8th(NULL),\r
81  fCommonHistsResults2nd(NULL),\r
82  fCommonHistsResults4th(NULL),\r
83  fCommonHistsResults6th(NULL),\r
84  fCommonHistsResults8th(NULL),\r
85  fnBinsPhi(0),\r
86  fPhiMin(0),\r
87  fPhiMax(0),\r
88  fPhiBinWidth(0),\r
89  fnBinsPt(0),\r
90  fPtMin(0),\r
91  fPtMax(0),\r
92  fPtBinWidth(0),\r
93  fnBinsEta(0),\r
94  fEtaMin(0),\r
95  fEtaMax(0),\r
96  fEtaBinWidth(0),\r
97  fHarmonic(2),\r
98  fAnalysisLabel(NULL),\r
99  // 2.) weights:\r
100  fWeightsList(NULL),\r
101  fUsePhiWeights(kFALSE),\r
102  fUsePtWeights(kFALSE),\r
103  fUseEtaWeights(kFALSE),\r
104  fUseParticleWeights(NULL),\r
105  fPhiWeights(NULL),\r
106  fPtWeights(NULL),\r
107  fEtaWeights(NULL),\r
108  // 3.) integrated flow:\r
109  fIntFlowList(NULL), \r
110  fIntFlowProfiles(NULL),\r
111  fIntFlowResults(NULL),\r
112  fIntFlowFlags(NULL),\r
113  fApplyCorrectionForNUA(kTRUE), \r
114  fReQ(NULL),\r
115  fImQ(NULL),\r
116  fSMpk(NULL),\r
117  fIntFlowCorrelationsEBE(NULL),\r
118  fIntFlowEventWeightsForCorrelationsEBE(NULL),\r
119  fIntFlowCorrelationsAllEBE(NULL),\r
120  fAvMultiplicity(NULL),\r
121  fIntFlowCorrelationsPro(NULL),\r
122  fIntFlowCorrelationsAllPro(NULL),
123  fIntFlowExtraCorrelationsPro(NULL),\r
124  fIntFlowProductOfCorrelationsPro(NULL),\r
125  fIntFlowCorrelationsHist(NULL),\r
126  fIntFlowCorrelationsAllHist(NULL),\r
127  fIntFlowCovariances(NULL),\r
128  fIntFlowSumOfProductOfEventWeights(NULL),\r
129  fIntFlowQcumulants(NULL),\r
130  fIntFlow(NULL),\r
131  // 4.) differential flow:\r
132  fDiffFlowList(NULL),\r
133  fDiffFlowProfiles(NULL),\r
134  fDiffFlowResults(NULL),\r
135  fDiffFlowFlags(NULL),\r
136  fCalculate2DFlow(kFALSE),\r
137  // 5.) distributions:\r
138  fDistributionsList(NULL),\r
139  // x.) debugging and cross-checking:\r
140  fNestedLoopsList(NULL),\r
141  fEvaluateIntFlowNestedLoops(kFALSE),\r
142  fEvaluateDiffFlowNestedLoops(kFALSE),
143  fMaxAllowedMultiplicity(10),\r
144  fEvaluateNestedLoops(NULL),\r
145  fIntFlowDirectCorrelations(NULL),\r
146  fIntFlowExtraDirectCorrelations(NULL),
147  fCrossCheckInPtBinNo(10),
148  fCrossCheckInEtaBinNo(20)
149  {\r
150   // constructor  \r
151   \r
152   // base list to hold all output objects:\r
153   fHistList = new TList();\r
154   fHistList->SetName("cobjQC");\r
155   fHistList->SetOwner(kTRUE);\r
156   \r
157   // list to hold histograms with phi, pt and eta weights:      \r
158   fWeightsList = new TList();\r
159     \r
160   // analysis label;\r
161   fAnalysisLabel = new TString();\r
162       \r
163   // initialize all arrays:  \r
164   this->InitializeArraysForIntFlow();\r
165   this->InitializeArraysForDiffFlow();\r
166   this->InitializeArraysForDistributions();
167   this->InitializeArraysForNestedLoops();\r
168   \r
169  } // end of constructor\r
170  \r
171 \r
172 //================================================================================================================  \r
173 \r
174 \r
175 AliFlowAnalysisWithQCumulants::~AliFlowAnalysisWithQCumulants()\r
176 {\r
177  // destructor\r
178  \r
179  delete fHistList;\r
180 \r
181 } // end of AliFlowAnalysisWithQCumulants::~AliFlowAnalysisWithQCumulants()\r
182 \r
183 \r
184 //================================================================================================================\r
185 \r
186 \r
187 void AliFlowAnalysisWithQCumulants::Init()\r
188 {\r
189  // a) Access all common constants;\r
190  // b) Book all objects;\r
191  // c) Store flags for integrated and differential flow;\r
192  // d) Store harmonic which will be estimated.\r
193   \r
194  // a) Access all common constants:\r
195  this->AccessConstants();\r
196  \r
197  // b) Book all objects:\r
198  this->BookAndFillWeightsHistograms();\r
199  this->BookAndNestAllLists();\r
200  this->BookCommonHistograms();\r
201  this->BookEverythingForIntegratedFlow(); \r
202  this->BookEverythingForDifferentialFlow(); \r
203  this->BookEverythingForDistributions();\r
204  this->BookEverythingForNestedLoops();\r
205  \r
206  // c) Store flags for integrated and differential flow:\r
207  this->StoreIntFlowFlags();\r
208  this->StoreDiffFlowFlags();\r
209 \r
210  // d) Store harmonic which will be estimated:\r
211  this->StoreHarmonic();\r
212  \r
213 } // end of void AliFlowAnalysisWithQCumulants::Init()\r
214 \r
215 \r
216 //================================================================================================================\r
217 \r
218 \r
219 void AliFlowAnalysisWithQCumulants::Make(AliFlowEventSimple* anEvent)\r
220 {\r
221  // Running over data only in this method.\r
222  \r
223  //  a) Fill the common control histograms and call the method to fill fAvMultiplicity;\r
224  //  b) Loop over data and calculate e-b-e quantities;\r
225  //  c) call the methods;\r
226  //  d) Debugging and cross-checking (evaluate nested loops);\r
227  //  e) Reset all event by event quantities. \r
228  \r
229  Double_t dPhi = 0.; // azimuthal angle in the laboratory frame\r
230  Double_t dPt  = 0.; // transverse momentum\r
231  Double_t dEta = 0.; // pseudorapidity\r
232 \r
233  Double_t wPhi = 1.; // phi weight\r
234  Double_t wPt  = 1.; // pt weight\r
235  Double_t wEta = 1.; // eta weight\r
236  \r
237  Int_t nRP = anEvent->GetEventNSelTracksRP(); // number of RPs (i.e. number of particles used to determine the reaction plane)\r
238  \r
239  // a) Fill the common control histograms and call the method to fill fAvMultiplicity:\r
240  this->FillCommonControlHistograms(anEvent);                                                               \r
241  this->FillAverageMultiplicities(nRP);                                                                  \r
242                                                                                                                                                                                                                                                                                         \r
243  // b) Loop over data and calculate e-b-e quantities:\r
244  Int_t nPrim = anEvent->NumberOfTracks();  // nPrim = total number of primary tracks, i.e. nPrim = nRP + nPOI + rest, where:\r
245                                            // nRP   = # of particles used to determine the reaction plane;\r
246                                            // nPOI  = # of particles of interest for a detailed flow analysis;\r
247                                            // rest  = # of particles which are not niether RPs nor POIs.  \r
248  \r
249  AliFlowTrackSimple *aftsTrack = NULL;\r
250  \r
251  for(Int_t i=0;i<nPrim;i++) \r
252  { \r
253   aftsTrack=anEvent->GetTrack(i);\r
254   if(aftsTrack)\r
255   {\r
256    if(!(aftsTrack->InRPSelection() || aftsTrack->InPOISelection())) continue; // consider only tracks which are RPs or POIs\r
257    Int_t n = fHarmonic; // shortcut for the harmonic\r
258    if(aftsTrack->InRPSelection()) // RP condition:\r
259    {    \r
260     dPhi = aftsTrack->Phi();\r
261     dPt  = aftsTrack->Pt();\r
262     dEta = aftsTrack->Eta();\r
263     if(fUsePhiWeights && fPhiWeights && fnBinsPhi) // determine phi weight for this particle:\r
264     {\r
265      wPhi = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*fnBinsPhi/TMath::TwoPi())));\r
266     }\r
267     if(fUsePtWeights && fPtWeights && fnBinsPt) // determine pt weight for this particle:\r
268     {\r
269      wPt = fPtWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-fPtMin)/fPtBinWidth))); \r
270     }              \r
271     if(fUseEtaWeights && fEtaWeights && fEtaBinWidth) // determine eta weight for this particle: \r
272     {\r
273      wEta = fEtaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-fEtaMin)/fEtaBinWidth))); \r
274     } \r
275       \r
276     // integrated flow: \r
277     // calculate Re[Q_{m*n,k}] and Im[Q_{m*n,k}], m = 1,2,3,4, for this event:\r
278     for(Int_t m=0;m<4;m++)\r
279     {\r
280      for(Int_t k=0;k<9;k++)\r
281      {\r
282       (*fReQ)(m,k)+=pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1)*n*dPhi); \r
283       (*fImQ)(m,k)+=pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1)*n*dPhi); \r
284      } \r
285     }\r
286     // calculate S^{M}_{p,k} for this event \r
287     // Remark: final calculation of S^{M}_{p,k} follows after the loop over data bellow:\r
288     for(Int_t p=0;p<8;p++)\r
289     {\r
290      for(Int_t k=0;k<9;k++)\r
291      {     \r
292       (*fSMpk)(p,k)+=pow(wPhi*wPt*wEta,k);\r
293      }\r
294     } \r
295     \r
296     // differential flow:\r
297     // 1D (pt):\r
298     // (r_{m*m,k}(pt)): \r
299     for(Int_t m=0;m<4;m++)\r
300     {\r
301      for(Int_t k=0;k<9;k++)\r
302      {\r
303       fReRPQ1dEBE[0][0][m][k]->Fill(dPt,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
304       fImRPQ1dEBE[0][0][m][k]->Fill(dPt,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
305      }\r
306     }\r
307            \r
308     // s_{k}(pt) for RPs // to be improved (clarified)\r
309     // Remark: final calculation of s_{p,k}(pt) follows after the loop over data bellow:\r
310     for(Int_t k=0;k<9;k++)\r
311     {\r
312      fs1dEBE[0][0][k]->Fill(dPt,pow(wPhi*wPt*wEta,k),1.);\r
313     }\r
314     // 1D (eta):\r
315     // (r_{m*m,k}(eta)): \r
316     for(Int_t m=0;m<4;m++)\r
317     {\r
318      for(Int_t k=0;k<9;k++)\r
319      {\r
320       fReRPQ1dEBE[0][1][m][k]->Fill(dEta,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
321       fImRPQ1dEBE[0][1][m][k]->Fill(dEta,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
322      }\r
323     }   \r
324     // s_{k}(eta) for RPs // to be improved (clarified)\r
325     // Remark: final calculation of s_{p,k}(eta) follows after the loop over data bellow:\r
326     for(Int_t k=0;k<9;k++)\r
327     {\r
328      fs1dEBE[0][1][k]->Fill(dEta,pow(wPhi*wPt*wEta,k),1.);\r
329     }\r
330     \r
331     \r
332     \r
333     /*\r
334     // 2D (pt,eta):\r
335     if(fCalculate2DFlow)\r
336     {\r
337      // (r_{m*m,k}(pt,eta)): \r
338      for(Int_t m=0;m<4;m++)\r
339      {\r
340       for(Int_t k=0;k<9;k++)\r
341       {\r
342        fReRPQ2dEBE[0][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
343        fImRPQ2dEBE[0][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
344       }\r
345      }    \r
346      // s_{k}(pt,eta) for RPs // to be improved (clarified)\r
347      // Remark: final calculation of s_{p,k}(pt,eta) follows after the loop over data bellow:\r
348      for(Int_t k=0;k<9;k++)\r
349      {\r
350       fs2dEBE[0][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k),1.);\r
351      }\r
352     } // end of if(fCalculate2DFlow)  \r
353     */ \r
354     \r
355       \r
356      \r
357     if(aftsTrack->InPOISelection())\r
358     {\r
359      // 1D (pt): \r
360      // (q_{m*m,k}(pt)): \r
361      for(Int_t m=0;m<4;m++)\r
362      {\r
363       for(Int_t k=0;k<9;k++)\r
364       {\r
365        fReRPQ1dEBE[2][0][m][k]->Fill(dPt,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
366        fImRPQ1dEBE[2][0][m][k]->Fill(dPt,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
367       }\r
368      } \r
369      // s_{k}(pt) for RP&&POIs // to be improved (clarified)\r
370      // Remark: final calculation of s_{p,k}(pt,eta) follows after the loop over data bellow:\r
371      for(Int_t k=0;k<9;k++)\r
372      {\r
373       fs1dEBE[2][0][k]->Fill(dPt,pow(wPhi*wPt*wEta,k),1.);\r
374      }\r
375      // 1D (eta): \r
376      // (q_{m*m,k}(eta)): \r
377      for(Int_t m=0;m<4;m++)\r
378      {\r
379       for(Int_t k=0;k<9;k++)\r
380       {\r
381        fReRPQ1dEBE[2][1][m][k]->Fill(dEta,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
382        fImRPQ1dEBE[2][1][m][k]->Fill(dEta,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
383       }\r
384      } \r
385      // s_{k}(eta) for RP&&POIs // to be improved (clarified)\r
386      // Remark: final calculation of s_{p,k}(pt,eta) follows after the loop over data bellow:\r
387      for(Int_t k=0;k<9;k++)\r
388      {\r
389       fs1dEBE[2][1][k]->Fill(dEta,pow(wPhi*wPt*wEta,k),1.);\r
390      }\r
391      \r
392      /*\r
393      // 2D (pt,eta) \r
394      if(fCalculate2DFlow)\r
395      {\r
396       // (q_{m*m,k}(pt,eta)): \r
397       for(Int_t m=0;m<4;m++)\r
398       {\r
399        for(Int_t k=0;k<9;k++)\r
400        {\r
401         fReRPQ2dEBE[2][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
402         fImRPQ2dEBE[2][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
403        }\r
404       } \r
405       // s_{k}(pt,eta) for RP&&POIs // to be improved (clarified)\r
406       // Remark: final calculation of s_{p,k}(pt,eta) follows after the loop over data bellow:\r
407       for(Int_t k=0;k<9;k++)\r
408       {\r
409        fs2dEBE[2][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k),1.);\r
410       }\r
411      } // end of if(fCalculate2DFlow) \r
412      */\r
413       \r
414     } // end of if(aftsTrack->InPOISelection())\r
415     \r
416 \r
417      \r
418    } // end of if(pTrack->InRPSelection())\r
419 \r
420   \r
421   \r
422    if(aftsTrack->InPOISelection())\r
423    {\r
424     dPhi = aftsTrack->Phi();\r
425     dPt  = aftsTrack->Pt();\r
426     dEta = aftsTrack->Eta();\r
427     \r
428     // 1D (pt)\r
429     // p_n(m*n,0):   \r
430     for(Int_t m=0;m<4;m++)\r
431     {\r
432      fReRPQ1dEBE[1][0][m][0]->Fill(dPt,TMath::Cos((m+1.)*n*dPhi),1.);\r
433      fImRPQ1dEBE[1][0][m][0]->Fill(dPt,TMath::Sin((m+1.)*n*dPhi),1.);\r
434     }\r
435     // 1D (eta)\r
436     // p_n(m*n,0):   \r
437     for(Int_t m=0;m<4;m++)\r
438     {\r
439      fReRPQ1dEBE[1][1][m][0]->Fill(dEta,TMath::Cos((m+1.)*n*dPhi),1.);\r
440      fImRPQ1dEBE[1][1][m][0]->Fill(dEta,TMath::Sin((m+1.)*n*dPhi),1.);\r
441     }\r
442     \r
443     \r
444     /*\r
445     // 2D (pt,eta):\r
446     if(fCalculate2DFlow)\r
447     {      \r
448      // p_n(m*n,0):   \r
449      for(Int_t m=0;m<4;m++)\r
450      {\r
451       fReRPQ2dEBE[1][m][0]->Fill(dPt,dEta,TMath::Cos((m+1.)*n*dPhi),1.);\r
452       fImRPQ2dEBE[1][m][0]->Fill(dPt,dEta,TMath::Sin((m+1.)*n*dPhi),1.);\r
453      }\r
454     } // end of if(fCalculate2DFlow)  \r
455     */\r
456     \r
457     \r
458    } // end of if(pTrack->InPOISelection() )   \r
459  \r
460   \r
461   } else // to if(aftsTrack)\r
462     {\r
463      cout<<endl;\r
464      cout<<" WARNING: no particle! (i.e. aftsTrack is a NULL pointer in AFAWQC::Make().)"<<endl;\r
465      cout<<endl;       \r
466     }\r
467  } // end of for(Int_t i=0;i<nPrim;i++) \r
468 \r
469  // calculate the final expressions for S^{M}_{p,k}:\r
470  for(Int_t p=0;p<8;p++)\r
471  {\r
472   for(Int_t k=0;k<9;k++)\r
473   {\r
474    (*fSMpk)(p,k)=pow((*fSMpk)(p,k),p+1);\r
475   }  \r
476  } \r
477  \r
478  // *****************************\r
479  // **** CALL THE METHODS *******\r
480  // *****************************\r
481  // integrated flow:\r
482  if(!fEvaluateIntFlowNestedLoops)\r
483  {\r
484   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
485   {\r
486    if(nRP>1) this->CalculateIntFlowCorrelations(); // without using particle weights\r
487   } else \r
488     {\r
489      if(nRP>1) this->CalculateIntFlowCorrelationsUsingParticleWeights(); // with using particle weights   \r
490     } \r
491        \r
492   if(nRP>3) this->CalculateIntFlowProductOfCorrelations();\r
493   if(nRP>1) this->CalculateIntFlowSumOfEventWeights();\r
494   if(nRP>1) this->CalculateIntFlowSumOfProductOfEventWeights();\r
495   if(fApplyCorrectionForNUA && !(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (enable correction for NUA also when particle weights are used?)\r
496   {\r
497    if(nRP>0) this->CalculateIntFlowCorrectionsForNUASinTerms();\r
498    if(nRP>0) this->CalculateIntFlowCorrectionsForNUACosTerms();\r
499   }\r
500  } // end of if(!fEvaluateIntFlowNestedLoops)\r
501 \r
502  // differential flow:\r
503  if(!fEvaluateDiffFlowNestedLoops)\r
504  {\r
505   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
506   {\r
507    if(nRP>1) // to be improved (move this if somewhere else)\r
508    {\r
509     // without using particle weights:\r
510     this->CalculateDiffFlowCorrelations("RP","Pt"); \r
511     this->CalculateDiffFlowCorrelations("RP","Eta");\r
512     this->CalculateDiffFlowCorrelations("POI","Pt");\r
513     this->CalculateDiffFlowCorrelations("POI","Eta");\r
514    }  \r
515   } else\r
516     {\r
517      // with using particle weights:   \r
518      this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Pt"); \r
519      this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Eta"); \r
520      this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Pt"); \r
521      this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Eta"); \r
522     } \r
523     \r
524   this->CalculateDiffFlowProductOfCorrelations("RP","Pt");\r
525   this->CalculateDiffFlowProductOfCorrelations("RP","Eta");\r
526   this->CalculateDiffFlowProductOfCorrelations("POI","Pt");\r
527   this->CalculateDiffFlowProductOfCorrelations("POI","Eta");\r
528   this->CalculateDiffFlowSumOfEventWeights("RP","Pt");\r
529   this->CalculateDiffFlowSumOfEventWeights("RP","Eta");\r
530   this->CalculateDiffFlowSumOfEventWeights("POI","Pt");\r
531   this->CalculateDiffFlowSumOfEventWeights("POI","Eta");\r
532   this->CalculateDiffFlowSumOfProductOfEventWeights("RP","Pt");\r
533   this->CalculateDiffFlowSumOfProductOfEventWeights("RP","Eta");\r
534   this->CalculateDiffFlowSumOfProductOfEventWeights("POI","Pt");\r
535   this->CalculateDiffFlowSumOfProductOfEventWeights("POI","Eta");\r
536   if(fApplyCorrectionForNUA && !(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (enable correction for NUA also when particle weights are used?)\r
537   {\r
538    this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Pt");\r
539    this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Eta");\r
540    this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Pt");\r
541    this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Eta");\r
542    this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Pt");\r
543    this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Eta");\r
544    this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Pt");\r
545    this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Eta");\r
546   }\r
547   \r
548  } // end of if(!fEvaluateDiffFlowNestedLoops)\r
549 \r
550 \r
551    \r
552   // with weights:\r
553   // ... \r
554   \r
555   /*\r
556   // 2D differential flow\r
557   if(fCalculate2DFlow)\r
558   {\r
559    // without weights:\r
560    if(nRP>1) this->CalculateCorrelationsForDifferentialFlow2D("RP");\r
561    if(nRP>1) this->CalculateCorrelationsForDifferentialFlow2D("POI");\r
562   \r
563    // with weights:\r
564    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
565    {\r
566     if(nRP>1) this->CalculateWeightedCorrelationsForDifferentialFlow2D("RP");\r
567     if(nRP>1) this->CalculateWeightedCorrelationsForDifferentialFlow2D("POI");\r
568    } \r
569   } // end of if(fCalculate2DFlow)\r
570   */\r
571   \r
572  \r
573  // d) Debugging and cross-checking (evaluate nested loops):\r
574  //  d1) cross-checking results for integrated flow:
575  if(fEvaluateIntFlowNestedLoops)\r
576  {\r
577   if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity) // by default fMaxAllowedMultiplicity = 10 \r
578   {\r
579    // without using particle weights:\r
580    if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
581    {\r
582     // correlations:
583     this->CalculateIntFlowCorrelations(); // from Q-vectors
584     this->EvaluateIntFlowCorrelationsWithNestedLoops(anEvent); // from nested loops (to be improved: do I have to pass here anEvent or not?)\r
585     // correction for non-uniform acceptance:\r
586     this->CalculateIntFlowCorrectionsForNUASinTerms(); // from Q-vectors (sin terms)\r
587     this->CalculateIntFlowCorrectionsForNUACosTerms(); // from Q-vectors (cos terms)
588     this->EvaluateIntFlowCorrectionsForNUAWithNestedLoops(anEvent); // from nested loops (both sin and cos terms)\r
589    }\r
590    // using particle weights:\r
591    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
592    {
593     // correlations:\r
594     this->CalculateIntFlowCorrelationsUsingParticleWeights(); // from Q-vectors\r
595     this->EvaluateIntFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent); // from nested loops (to be improved: do I have to pass here anEvent or not?)\r
596    }\r
597   } else if (nPrim>fMaxAllowedMultiplicity) // to if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity)
598     {
599      cout<<endl;
600      cout<<"Skipping the event because multiplicity is "<<nPrim<<". Too high to evaluate nested loops!"<<endl;
601     } else
602       {
603        cout<<endl;
604        cout<<"Skipping the event because multiplicity is "<<nPrim<<"."<<endl;      
605       } \r
606  } // end of if(fEvaluateIntFlowNestedLoops) \r
607  \r
608  //  d2) cross-checking results for differential flow:
609  if(fEvaluateDiffFlowNestedLoops)\r
610  {\r
611   if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity) // by default fMaxAllowedMultiplicity = 10\r
612   {\r
613    // without using particle weights:\r
614    if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
615    {
616     // reduced correlations:\r
617     // Q-vectors:
618     this->CalculateDiffFlowCorrelations("RP","Pt");\r
619     this->CalculateDiffFlowCorrelations("RP","Eta");\r
620     this->CalculateDiffFlowCorrelations("POI","Pt");\r
621     this->CalculateDiffFlowCorrelations("POI","Eta");
622     // nested loops:
623     //this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"RP","Pt"); // to be improved (enabled eventually)
624     //this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"RP","Eta"); // to be improved (enabled eventually)
625     this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"POI","Pt"); // to be improved (do I need to pass here anEvent?)
626     this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"POI","Eta"); // to be improved (do I need to pass here anEvent?)
627     // reduced corrections for non-uniform acceptance:\r    // Q-vectors:
628     this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Pt");\r
629     this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Eta");\r
630     this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Pt");\r
631     this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Eta");\r
632     this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Pt");\r
633     this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Eta");\r
634     this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Pt");\r
635     this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Eta");
636     // nested loops:
637     //this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"RP","Pt"); // to be improved (enabled eventually)\r
638     //this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"RP","Eta"); // to be improved (enabled eventually)\r
639     this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"POI","Pt"); // to be improved (do I need to pass here anEvent?)\r
640     this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"POI","Eta"); // to be improved (do I need to pass here anEvent?)\r
641    } // end of if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
642    // using particle weights:\r
643    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
644    {\r
645     this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Pt"); \r
646     this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Eta"); \r
647     this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Pt"); \r
648     this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Eta"); \r
649     this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"RP","Pt"); // to be improved (enabled eventually)
650     this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"RP","Eta"); // to be improved (enabled eventually)
651     this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"POI","Pt"); // to be improved (do I need to pass here anEvent?)
652     this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"POI","Eta"); // to be improved (do I need to pass here anEvent?)
653    } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r  } // end of if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity) // by default fMaxAllowedMultiplicity = 10\r
654  } // end of if(fEvaluateDiffFlowNestedLoops) \r
655  \r
656  // e) Reset all event by event quantities: \r
657  this->ResetEventByEventQuantities();\r
658  \r
659 } // end of AliFlowAnalysisWithQCumulants::Make(AliFlowEventSimple* anEvent)\r
660 \r
661 \r
662 //================================================================================================================================\r
663 \r
664 \r
665 void AliFlowAnalysisWithQCumulants::Finish()\r
666 {\r
667  // Calculate the final results.\r
668  //  a) acces the constants;\r
669  //  b) access the flags;\r
670  //  c) calculate the final results for integrated flow (without and with weights);\r
671  //  d) store in AliFlowCommonHistResults and print the final results for integrated flow;\r
672  //  e) calculate the final results for differential flow (without and with weights);\r
673  //  f) print the final results for integrated flow obtained from differential flow (to be improved (terminology));\r
674  //  g) cross-check the results: results from Q-vectors vs results from nested loops\r
675  \r
676  // ******************************\r
677  // **** ACCESS THE CONSTANTS ****\r
678  // ******************************\r
679  \r
680  this->AccessConstants();          \r
681  \r
682  if(fCommonHists && fCommonHists->GetHarmonic())\r
683  {\r
684   fHarmonic = (Int_t)(fCommonHists->GetHarmonic())->GetBinContent(1); // to be improved (moved somewhere else)\r
685  } \r
686 \r
687  // **************************\r
688  // **** ACCESS THE FLAGS ****\r
689  // **************************    \r
690  fUsePhiWeights = (Int_t)fUseParticleWeights->GetBinContent(1); \r
691  fUsePtWeights = (Int_t)fUseParticleWeights->GetBinContent(2); \r
692  fUseEtaWeights = (Int_t)fUseParticleWeights->GetBinContent(3);  \r
693  fApplyCorrectionForNUA = (Int_t)fIntFlowFlags->GetBinContent(3); 
694  fEvaluateIntFlowNestedLoops = (Int_t)fEvaluateNestedLoops->GetBinContent(1);\r
695  fEvaluateDiffFlowNestedLoops = (Int_t)fEvaluateNestedLoops->GetBinContent(2); \r
696  fCrossCheckInPtBinNo = (Int_t)fEvaluateNestedLoops->GetBinContent(3);\r
697  fCrossCheckInEtaBinNo = (Int_t)fEvaluateNestedLoops->GetBinContent(4); \r
698     \r
699  // *********************************************************\r
700  // **** CALCULATE THE FINAL RESULTS FOR INTEGRATED FLOW ****\r
701  // *********************************************************     \r
702  \r
703  this->FinalizeCorrelationsIntFlow();\r
704  this->CalculateCovariancesIntFlow();\r
705  this->CalculateCumulantsIntFlow();\r
706  this->CalculateIntFlow(); \r
707 \r
708  if(fApplyCorrectionForNUA && !(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (reorganized, etc)\r
709  {\r
710   this->FinalizeCorrectionTermsForNUAIntFlow();\r
711   this->CalculateQcumulantsCorrectedForNUAIntFlow();   \r
712   this->CalculateIntFlowCorrectedForNUA(); \r
713  }\r
714   \r
715  // ***************************************************************\r
716  // **** STORE AND PRINT THE FINAL RESULTS FOR INTEGRATED FLOW ****\r
717  // ***************************************************************\r
718  \r
719  this->FillCommonHistResultsIntFlow();  \r
720   \r
721  this->PrintFinalResultsForIntegratedFlow("NONAME"); // to be improved (name)\r
722  \r
723  // ***********************************************************\r
724  // **** CALCULATE THE FINAL RESULTS FOR DIFFERENTIAL FLOW ****\r
725  // ***********************************************************    \r
726  \r
727  this->FinalizeReducedCorrelations("RP","Pt"); \r
728  this->FinalizeReducedCorrelations("RP","Eta"); \r
729  this->FinalizeReducedCorrelations("POI","Pt"); \r
730  this->FinalizeReducedCorrelations("POI","Eta");\r
731  this->CalculateDiffFlowCovariances("RP","Pt");\r
732  this->CalculateDiffFlowCovariances("RP","Eta");\r
733  this->CalculateDiffFlowCovariances("POI","Pt");\r
734  this->CalculateDiffFlowCovariances("POI","Eta");\r
735  this->CalculateDiffFlowCumulants("RP","Pt");\r
736  this->CalculateDiffFlowCumulants("RP","Eta");\r
737  this->CalculateDiffFlowCumulants("POI","Pt");\r
738  this->CalculateDiffFlowCumulants("POI","Eta");\r
739  this->CalculateDiffFlow("RP","Pt");\r
740  this->CalculateDiffFlow("RP","Eta");\r
741  this->CalculateDiffFlow("POI","Pt");\r
742  this->CalculateDiffFlow("POI","Eta");\r
743  \r
744  if(fApplyCorrectionForNUA && !(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (reorganized, etc)\r
745  {\r
746   this->FinalizeCorrectionTermsForNUADiffFlow("RP","Pt");\r
747   this->FinalizeCorrectionTermsForNUADiffFlow("RP","Eta");\r
748   this->FinalizeCorrectionTermsForNUADiffFlow("POI","Pt");\r
749   this->FinalizeCorrectionTermsForNUADiffFlow("POI","Eta");      \r
750   this->CalculateDiffFlowCumulantsCorrectedForNUA("RP","Pt");   \r
751   this->CalculateDiffFlowCumulantsCorrectedForNUA("RP","Eta");   \r
752   this->CalculateDiffFlowCumulantsCorrectedForNUA("POI","Pt");   \r
753   this->CalculateDiffFlowCumulantsCorrectedForNUA("POI","Eta");  \r
754   this->CalculateDiffFlowCorrectedForNUA("RP","Pt"); \r
755   this->CalculateDiffFlowCorrectedForNUA("RP","Eta"); \r
756   this->CalculateDiffFlowCorrectedForNUA("POI","Pt"); \r
757   this->CalculateDiffFlowCorrectedForNUA("POI","Eta"); \r
758  }\r
759  \r
760  this->CalculateFinalResultsForRPandPOIIntegratedFlow("RP");\r
761  this->CalculateFinalResultsForRPandPOIIntegratedFlow("POI");\r
762 \r
763  // *****************************************************************\r
764  // **** STORE AND PRINT THE FINAL RESULTS FOR DIFFERENTIAL FLOW ****\r
765  // *****************************************************************\r
766  this->FillCommonHistResultsDiffFlow("RP");\r
767  this->FillCommonHistResultsDiffFlow("POI");\r
768 \r
769  this->PrintFinalResultsForIntegratedFlow("RP"); \r
770  this->PrintFinalResultsForIntegratedFlow("POI"); \r
771   \r
772  // g) cross-check the results: results from Q-vectors vs results from nested loops\r
773  //  g1) integrated flow:
774  if(fEvaluateIntFlowNestedLoops)
775  {
776   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) \r
777   {\r
778    this->CrossCheckIntFlowCorrelations();
779    this->CrossCheckIntFlowCorrectionTermsForNUA(); \r
780   } else
781     {
782      this->CrossCheckIntFlowCorrelations();     
783      this->CrossCheckIntFlowExtraCorrelations();     
784     }
785  } // end of if(fEvaluateIntFlowNestedLoops)  \r
786  //  g2) differential flow: \r
787  if(fEvaluateDiffFlowNestedLoops) \r
788  {\r
789   // correlations:
790   //this->CrossCheckDiffFlowCorrelations("RP","Pt"); // to be improved (enabled eventually)  \r
791   //this->CrossCheckDiffFlowCorrelations("RP","Eta"); // to be improved (enabled eventually)  \r
792   this->CrossCheckDiffFlowCorrelations("POI","Pt");  \r
793   this->CrossCheckDiffFlowCorrelations("POI","Eta");
794   // correction terms for non-uniform acceptance:
795   //this->CrossCheckDiffFlowCorrectionTermsForNUA("RP","Pt"); // to be improved (enabled eventually)      \r
796   //this->CrossCheckDiffFlowCorrectionTermsForNUA("RP","Eta"); // to be improved (enabled eventually)      \r
797   this->CrossCheckDiffFlowCorrectionTermsForNUA("POI","Pt");      \r
798   this->CrossCheckDiffFlowCorrectionTermsForNUA("POI","Eta");      \r
799   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) \r
800   {
801   } else
802     {
803      // ...
804     }
805  } // end of if(fEvaluateDiffFlowNestedLoops)\r
806                                                                                                                                                                                                                                                                                                                                    \r
807 } // end of AliFlowAnalysisWithQCumulants::Finish()\r
808 \r
809 \r
810 //================================================================================================================================\r
811 \r
812 \r
813 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUACosTerms()\r
814 {\r
815  // calculate corrections for non-uniform acceptance of the detector for no-name integrated flow (cos terms)\r
816  \r
817  // multiplicity:\r
818  Double_t dMult = (*fSMpk)(0,0);\r
819  \r
820  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
821  Double_t dReQ1n = (*fReQ)(0,0);\r
822  Double_t dReQ2n = (*fReQ)(1,0);\r
823  //Double_t dReQ3n = (*fReQ)(2,0);\r
824  //Double_t dReQ4n = (*fReQ)(3,0);\r
825  Double_t dImQ1n = (*fImQ)(0,0);\r
826  Double_t dImQ2n = (*fImQ)(1,0);\r
827  //Double_t dImQ3n = (*fImQ)(2,0);\r
828  //Double_t dImQ4n = (*fImQ)(3,0);\r
829         \r
830  //                                  *************************************************************\r
831  //                                  **** corrections for non-uniform acceptance (cos terms): ****\r
832  //                                  *************************************************************\r
833  //\r
834  // Remark 1: corrections for non-uniform acceptance (cos terms) calculated with non-weighted Q-vectors \r
835  //           are stored in 1D profile fQCorrectionsCos.\r
836  // Remark 2: binning of fIntFlowCorrectionTermsForNUAPro[1] is organized as follows:\r
837  // --------------------------------------------------------------------------------------------------------------------\r
838  // 1st bin: <<cos(n*(phi1))>> = cosP1n\r
839  // 2nd bin: <<cos(n*(phi1+phi2))>> = cosP1nP1n\r
840  // 3rd bin: <<cos(n*(phi1-phi2-phi3))>> = cosP1nM1nM1n\r
841  // ...\r
842  // --------------------------------------------------------------------------------------------------------------------\r
843   \r
844  // 1-particle:\r
845  Double_t cosP1n = 0.; // <<cos(n*(phi1))>>\r
846    \r
847  if(dMult>0)\r
848  {\r
849   cosP1n = dReQ1n/dMult; \r
850   \r
851   // average non-weighted 1-particle correction (cos terms) for non-uniform acceptance for single event:\r
852   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(1,cosP1n);\r
853   \r
854   // final average non-weighted 1-particle correction (cos terms) for non-uniform acceptance for all events:\r
855   fIntFlowCorrectionTermsForNUAPro[1]->Fill(0.5,cosP1n,dMult);  \r
856  } \r
857  \r
858  // 2-particle:\r
859  Double_t cosP1nP1n = 0.; // <<cos(n*(phi1+phi2))>>\r
860  \r
861  if(dMult>1)\r
862  {\r
863   cosP1nP1n = (pow(dReQ1n,2)-pow(dImQ1n,2)-dReQ2n)/(dMult*(dMult-1)); \r
864   \r
865   // average non-weighted 2-particle correction (cos terms) for non-uniform acceptance for single event:\r
866   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(2,cosP1nP1n);\r
867   \r
868   // final average non-weighted 2-particle correction (cos terms) for non-uniform acceptance for all events:\r
869   fIntFlowCorrectionTermsForNUAPro[1]->Fill(1.5,cosP1nP1n,dMult*(dMult-1));  \r
870  } \r
871  \r
872  // 3-particle:\r
873  Double_t cosP1nM1nM1n = 0.; // <<cos(n*(phi1-phi2-phi3))>>\r
874  \r
875  if(dMult>2)\r
876  {\r
877   cosP1nM1nM1n = (dReQ1n*(pow(dReQ1n,2)+pow(dImQ1n,2))-dReQ1n*dReQ2n-dImQ1n*dImQ2n-2.*(dMult-1)*dReQ1n)\r
878                / (dMult*(dMult-1)*(dMult-2)); \r
879   \r
880   // average non-weighted 3-particle correction (cos terms) for non-uniform acceptance for single event:\r
881   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(3,cosP1nM1nM1n);\r
882   \r
883   // final average non-weighted 3-particle correction (cos terms) for non-uniform acceptance for all events:\r
884   fIntFlowCorrectionTermsForNUAPro[1]->Fill(2.5,cosP1nM1nM1n,dMult*(dMult-1)*(dMult-2));  \r
885  } \r
886  \r
887 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUACosTerms()\r
888 \r
889 \r
890 //================================================================================================================================\r
891 \r
892 \r
893 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUASinTerms()\r
894 {\r
895  // calculate corrections for non-uniform acceptance of the detector for no-name integrated flow (sin terms)\r
896  \r
897  // multiplicity:\r
898  Double_t dMult = (*fSMpk)(0,0);\r
899  \r
900  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
901  Double_t dReQ1n = (*fReQ)(0,0);\r
902  Double_t dReQ2n = (*fReQ)(1,0);\r
903  //Double_t dReQ3n = (*fReQ)(2,0);\r
904  //Double_t dReQ4n = (*fReQ)(3,0);\r
905  Double_t dImQ1n = (*fImQ)(0,0);\r
906  Double_t dImQ2n = (*fImQ)(1,0);\r
907  //Double_t dImQ3n = (*fImQ)(2,0);\r
908  //Double_t dImQ4n = (*fImQ)(3,0);\r
909         \r
910  //                                  *************************************************************\r
911  //                                  **** corrections for non-uniform acceptance (sin terms): ****\r
912  //                                  *************************************************************\r
913  //\r
914  // Remark 1: corrections for non-uniform acceptance (sin terms) calculated with non-weighted Q-vectors \r
915  //           are stored in 1D profile fQCorrectionsSin.\r
916  // Remark 2: binning of fIntFlowCorrectionTermsForNUAPro[0] is organized as follows:\r
917  // --------------------------------------------------------------------------------------------------------------------\r
918  // 1st bin: <<sin(n*(phi1))>> = sinP1n\r
919  // 2nd bin: <<sin(n*(phi1+phi2))>> = sinP1nP1n\r
920  // 3rd bin: <<sin(n*(phi1-phi2-phi3))>> = sinP1nM1nM1n\r
921  // ...\r
922  // --------------------------------------------------------------------------------------------------------------------\r
923  \r
924  // 1-particle:\r
925  Double_t sinP1n = 0.; // <sin(n*(phi1))>\r
926  \r
927  if(dMult>0)\r
928  {\r
929   sinP1n = dImQ1n/dMult; \r
930      \r
931   // average non-weighted 1-particle correction (sin terms) for non-uniform acceptance for single event:\r
932   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(1,sinP1n);\r
933   \r
934   // final average non-weighted 1-particle correction (sin terms) for non-uniform acceptance for all events:   \r
935   fIntFlowCorrectionTermsForNUAPro[0]->Fill(0.5,sinP1n,dMult);  \r
936  } \r
937  \r
938  // 2-particle:\r
939  Double_t sinP1nP1n = 0.; // <<sin(n*(phi1+phi2))>>\r
940  \r
941  if(dMult>1)\r
942  {\r
943   sinP1nP1n = (2.*dReQ1n*dImQ1n-dImQ2n)/(dMult*(dMult-1)); \r
944      \r
945   // average non-weighted 2-particle correction (sin terms) for non-uniform acceptance for single event:\r
946   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(2,sinP1nP1n);\r
947   \r
948   // final average non-weighted 1-particle correction (sin terms) for non-uniform acceptance for all events:      \r
949   fIntFlowCorrectionTermsForNUAPro[0]->Fill(1.5,sinP1nP1n,dMult*(dMult-1));  \r
950  } \r
951  \r
952  // 3-particle:\r
953  Double_t sinP1nM1nM1n = 0.; // <<sin(n*(phi1-phi2-phi3))>>\r
954  \r
955  if(dMult>2)\r
956  {\r
957   sinP1nM1nM1n = (-dImQ1n*(pow(dReQ1n,2)+pow(dImQ1n,2))+dReQ1n*dImQ2n-dImQ1n*dReQ2n+2.*(dMult-1)*dImQ1n)\r
958                / (dMult*(dMult-1)*(dMult-2)); \r
959   \r
960   // average non-weighted 3-particle correction (sin terms) for non-uniform acceptance for single event:\r
961   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(3,sinP1nM1nM1n);\r
962   \r
963   // final average non-weighted 3-particle correction (sin terms) for non-uniform acceptance for all events:  \r
964   fIntFlowCorrectionTermsForNUAPro[0]->Fill(2.5,sinP1nM1nM1n,dMult*(dMult-1)*(dMult-2));  \r
965  } \r
966  \r
967 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUASinTerms()\r
968 \r
969 \r
970 //================================================================================================================================\r
971 \r
972 \r
973 void AliFlowAnalysisWithQCumulants::GetOutputHistograms(TList *outputListHistos)\r
974 {\r
975  // a) Get pointers for common control and common result histograms and profiles.\r
976  // b) Get pointers for histograms with particle weights.\r
977  // c) Get pointers for histograms and profiles relevant for integrated flow.\r
978  // d) Get pointers for histograms and profiles relevant for differental flow.\r
979  // e) Get pointers for histograms and profiles holding results obtained with nested loops.\r
980  \r
981  if(outputListHistos)\r
982  {      \r
983   this->GetPointersForCommonHistograms(outputListHistos); // to be improved (no need to pass here argument, use setter for base list instead)\r
984   this->GetPointersForParticleWeightsHistograms(outputListHistos); // to be improved (no need to pass here argument, use setter for base list instead)\r
985   this->GetPointersForIntFlowHistograms(outputListHistos); // to be improved (no need to pass here argument, use setter for base list instead)\r
986   this->GetPointersForDiffFlowHistograms(outputListHistos); // to be improved (no need to pass here argument, use setter for base list instead)\r
987   this->GetPointersForNestedLoopsHistograms(outputListHistos); // to be improved (no need to pass here argument, use setter for base list instead)\r
988  }\r
989    \r
990 } // end of void AliFlowAnalysisWithQCumulants::GetOutputHistograms(TList *outputListHistos)\r
991 \r
992 \r
993 //================================================================================================================================\r
994 \r
995 \r
996 TProfile* AliFlowAnalysisWithQCumulants::MakePtProjection(TProfile2D *profilePtEta) const\r
997 {\r
998  // project 2D profile onto pt axis to get 1D profile\r
999  \r
1000  Int_t nBinsPt   = profilePtEta->GetNbinsX();\r
1001  Double_t dPtMin = (profilePtEta->GetXaxis())->GetXmin();\r
1002  Double_t dPtMax = (profilePtEta->GetXaxis())->GetXmax();\r
1003  \r
1004  Int_t nBinsEta   = profilePtEta->GetNbinsY();\r
1005  \r
1006  TProfile *profilePt = new TProfile("","",nBinsPt,dPtMin,dPtMax); \r
1007  \r
1008  for(Int_t p=1;p<=nBinsPt;p++)\r
1009  {\r
1010   Double_t contentPt = 0.;\r
1011   Double_t entryPt = 0.;\r
1012   Double_t spreadPt = 0.;\r
1013   Double_t sum1 = 0.;\r
1014   Double_t sum2 = 0.;\r
1015   Double_t sum3 = 0.;\r
1016   for(Int_t e=1;e<=nBinsEta;e++)\r
1017   {\r
1018    contentPt += (profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)))\r
1019               * (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));\r
1020    entryPt   += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));\r
1021    \r
1022    sum1 += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)))\r
1023          * (pow(profilePtEta->GetBinError(profilePtEta->GetBin(p,e)),2.)\r
1024             + pow(profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)),2.)); \r
1025    sum2 += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));\r
1026    sum3 += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)))\r
1027          * (profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)));            \r
1028   }\r
1029   if(sum2>0. && sum1/sum2-pow(sum3/sum2,2.) > 0.)\r
1030   {\r
1031    spreadPt = pow(sum1/sum2-pow(sum3/sum2,2.),0.5);\r
1032   }\r
1033   profilePt->SetBinContent(p,contentPt);\r
1034   profilePt->SetBinEntries(p,entryPt);\r
1035   {\r
1036    profilePt->SetBinError(p,spreadPt);\r
1037   }\r
1038   \r
1039  }\r
1040  \r
1041  return profilePt;\r
1042  \r
1043 } // end of TProfile* AliFlowAnalysisWithQCumulants::MakePtProjection(TProfile2D *profilePtEta)\r
1044 \r
1045 \r
1046 //================================================================================================================================\r
1047 \r
1048 \r
1049 TProfile* AliFlowAnalysisWithQCumulants::MakeEtaProjection(TProfile2D *profilePtEta) const\r
1050 {\r
1051  // project 2D profile onto eta axis to get 1D profile\r
1052  \r
1053  Int_t nBinsEta   = profilePtEta->GetNbinsY();\r
1054  Double_t dEtaMin = (profilePtEta->GetYaxis())->GetXmin();\r
1055  Double_t dEtaMax = (profilePtEta->GetYaxis())->GetXmax();\r
1056  \r
1057  Int_t nBinsPt = profilePtEta->GetNbinsX();\r
1058  \r
1059  TProfile *profileEta = new TProfile("","",nBinsEta,dEtaMin,dEtaMax); \r
1060  \r
1061  for(Int_t e=1;e<=nBinsEta;e++)\r
1062  {\r
1063   Double_t contentEta = 0.;\r
1064   Double_t entryEta = 0.;\r
1065   for(Int_t p=1;p<=nBinsPt;p++)\r
1066   {\r
1067    contentEta += (profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)))\r
1068               * (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));\r
1069    entryEta   += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));\r
1070   }\r
1071   profileEta->SetBinContent(e,contentEta);\r
1072   profileEta->SetBinEntries(e,entryEta);\r
1073  }\r
1074  \r
1075  return profileEta;\r
1076  \r
1077 } // end of TProfile* AliFlowAnalysisWithQCumulants::MakeEtaProjection(TProfile2D *profilePtEta)\r
1078 \r
1079 \r
1080 //================================================================================================================================\r
1081 \r
1082 \r
1083 void AliFlowAnalysisWithQCumulants::PrintFinalResultsForIntegratedFlow(TString type)\r
1084 {\r
1085  // printing on the screen the final results for integrated flow (NONAME, POI and RP) // to be improved (NONAME) \r
1086  \r
1087  Int_t n = fHarmonic; \r
1088  \r
1089  if(type == "NONAME" || type == "RP" || type == "POI")\r
1090  {\r
1091   if(!(fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th))\r
1092   {\r
1093    cout<<"WARNING: fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th"<<endl;\r
1094    cout<<"         is NULL in AFAWQC::PFRFIF() !!!!"<<endl;\r
1095   }\r
1096  } else\r
1097    {\r
1098     cout<<"WARNING: type in not from {NONAME, RP, POI} in AFAWQC::PFRFIF() !!!!"<<endl;\r
1099     exit(0);\r
1100    }\r
1101  \r
1102  Double_t dVn[4] = {0.}; // array to hold Vn{2}, Vn{4}, Vn{6} and Vn{8}   \r
1103  Double_t dVnErr[4] = {0.}; // array to hold errors of Vn{2}, Vn{4}, Vn{6} and Vn{8}   \r
1104  \r
1105  if(type == "NONAME")\r
1106  {\r
1107   dVn[0] = (fCommonHistsResults2nd->GetHistIntFlow())->GetBinContent(1); \r
1108   dVnErr[0] = (fCommonHistsResults2nd->GetHistIntFlow())->GetBinError(1); \r
1109   dVn[1] = (fCommonHistsResults4th->GetHistIntFlow())->GetBinContent(1); \r
1110   dVnErr[1] = (fCommonHistsResults4th->GetHistIntFlow())->GetBinError(1); \r
1111   dVn[2] = (fCommonHistsResults6th->GetHistIntFlow())->GetBinContent(1); \r
1112   dVnErr[2] = (fCommonHistsResults6th->GetHistIntFlow())->GetBinError(1); \r
1113   dVn[3] = (fCommonHistsResults8th->GetHistIntFlow())->GetBinContent(1); \r
1114   dVnErr[3] = (fCommonHistsResults8th->GetHistIntFlow())->GetBinError(1); \r
1115  } else if(type == "RP")\r
1116    {\r
1117     dVn[0] = (fCommonHistsResults2nd->GetHistIntFlowRP())->GetBinContent(1); \r
1118     dVnErr[0] = (fCommonHistsResults2nd->GetHistIntFlowRP())->GetBinError(1); \r
1119     dVn[1] = (fCommonHistsResults4th->GetHistIntFlowRP())->GetBinContent(1); \r
1120     dVnErr[1] = (fCommonHistsResults4th->GetHistIntFlowRP())->GetBinError(1); \r
1121     dVn[2] = (fCommonHistsResults6th->GetHistIntFlowRP())->GetBinContent(1); \r
1122     dVnErr[2] = (fCommonHistsResults6th->GetHistIntFlowRP())->GetBinError(1); \r
1123     dVn[3] = (fCommonHistsResults8th->GetHistIntFlowRP())->GetBinContent(1); \r
1124     dVnErr[3] = (fCommonHistsResults8th->GetHistIntFlowRP())->GetBinError(1); \r
1125    } else if(type == "POI")\r
1126      {\r
1127       dVn[0] = (fCommonHistsResults2nd->GetHistIntFlowPOI())->GetBinContent(1); \r
1128       dVnErr[0] = (fCommonHistsResults2nd->GetHistIntFlowPOI())->GetBinError(1); \r
1129       dVn[1] = (fCommonHistsResults4th->GetHistIntFlowPOI())->GetBinContent(1); \r
1130       dVnErr[1] = (fCommonHistsResults4th->GetHistIntFlowPOI())->GetBinError(1); \r
1131       dVn[2] = (fCommonHistsResults6th->GetHistIntFlowPOI())->GetBinContent(1); \r
1132       dVnErr[2] = (fCommonHistsResults6th->GetHistIntFlowPOI())->GetBinError(1); \r
1133       dVn[3] = (fCommonHistsResults8th->GetHistIntFlowPOI())->GetBinContent(1); \r
1134       dVnErr[3] = (fCommonHistsResults8th->GetHistIntFlowPOI())->GetBinError(1); \r
1135      }\r
1136  \r
1137  TString title = " flow estimates from Q-cumulants"; \r
1138  TString subtitle = "    ("; \r
1139  \r
1140  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
1141  {\r
1142   subtitle.Append(type);\r
1143   subtitle.Append(", without weights)");\r
1144  } else  \r
1145    {\r
1146     subtitle.Append(type);\r
1147     subtitle.Append(", with weights)");\r
1148    }\r
1149   \r
1150  cout<<endl;\r
1151  cout<<"*************************************"<<endl;\r
1152  cout<<"*************************************"<<endl;\r
1153  cout<<title.Data()<<endl; \r
1154  cout<<subtitle.Data()<<endl; \r
1155  cout<<endl;\r
1156   \r
1157  for(Int_t i=0;i<4;i++)\r
1158  {\r
1159   if(dVn[i]>=0.)\r
1160   {\r
1161    cout<<"  v_"<<n<<"{"<<2*(i+1)<<"} = "<<dVn[i]<<" +/- "<<dVnErr[i]<<endl;\r
1162   }\r
1163   else\r
1164   {\r
1165    cout<<"  v_"<<n<<"{"<<2*(i+1)<<"} = Im"<<endl;\r
1166   }  \r
1167  }\r
1168 \r
1169  cout<<endl;\r
1170  /*\r
1171  if(type == "NONAME")\r
1172  {\r
1173   cout<<"     nEvts = "<<nEvtsNoName<<", AvM = "<<dMultNoName<<endl; // to be improved\r
1174  }\r
1175  else if (type == "RP")\r
1176  {\r
1177   cout<<"     nEvts = "<<nEvtsRP<<", AvM = "<<dMultRP<<endl; // to be improved  \r
1178  } \r
1179  else if (type == "POI")\r
1180  {\r
1181   cout<<"     nEvts = "<<nEvtsPOI<<", AvM = "<<dMultPOI<<endl; // to be improved  \r
1182  } \r
1183  */\r
1184  cout<<"*************************************"<<endl;\r
1185  cout<<"*************************************"<<endl;\r
1186  cout<<endl; \r
1187   \r
1188 }// end of AliFlowAnalysisWithQCumulants::PrintFinalResultsForIntegratedFlow(TString type="NONAME");\r
1189 \r
1190 \r
1191 //================================================================================================================================\r
1192 \r
1193 \r
1194 void AliFlowAnalysisWithQCumulants::WriteHistograms(TString outputFileName)\r
1195 {\r
1196  //store the final results in output .root file\r
1197  TFile *output = new TFile(outputFileName.Data(),"RECREATE");\r
1198  //output->WriteObject(fHistList, "cobjQC","SingleKey");\r
1199  fHistList->Write(fHistList->GetName(), TObject::kSingleKey);\r
1200  delete output;\r
1201 }\r
1202 \r
1203 \r
1204 //================================================================================================================================\r
1205 \r
1206 \r
1207 void AliFlowAnalysisWithQCumulants::BookCommonHistograms()\r
1208 {\r
1209  // Book common control histograms and common histograms for final results.\r
1210  // common control histogram (ALL events)\r
1211  TString commonHistsName = "AliFlowCommonHistQC";\r
1212  commonHistsName += fAnalysisLabel->Data();\r
1213  fCommonHists = new AliFlowCommonHist(commonHistsName.Data());\r
1214  fHistList->Add(fCommonHists);  \r
1215  // common control histogram (for events with 2 and more particles)\r
1216  TString commonHists2ndOrderName = "AliFlowCommonHist2ndOrderQC";\r
1217  commonHists2ndOrderName += fAnalysisLabel->Data();\r
1218  fCommonHists2nd = new AliFlowCommonHist(commonHists2ndOrderName.Data());\r
1219  fHistList->Add(fCommonHists2nd);  \r
1220  // common control histogram (for events with 4 and more particles)\r
1221  TString commonHists4thOrderName = "AliFlowCommonHist4thOrderQC";\r
1222  commonHists4thOrderName += fAnalysisLabel->Data();\r
1223  fCommonHists4th = new AliFlowCommonHist(commonHists4thOrderName.Data());\r
1224  fHistList->Add(fCommonHists4th);  \r
1225  // common control histogram (for events with 6 and more particles)\r
1226  TString commonHists6thOrderName = "AliFlowCommonHist6thOrderQC";\r
1227  commonHists6thOrderName += fAnalysisLabel->Data();\r
1228  fCommonHists6th = new AliFlowCommonHist(commonHists6thOrderName.Data());\r
1229  fHistList->Add(fCommonHists6th);  \r
1230  // common control histogram (for events with 8 and more particles)\r
1231  TString commonHists8thOrderName = "AliFlowCommonHist8thOrderQC";\r
1232  commonHists8thOrderName += fAnalysisLabel->Data();\r
1233  fCommonHists8th = new AliFlowCommonHist(commonHists8thOrderName.Data());\r
1234  fHistList->Add(fCommonHists8th);    \r
1235  // common histograms for final results (calculated for events with 2 and more particles)\r
1236  TString commonHistResults2ndOrderName = "AliFlowCommonHistResults2ndOrderQC";\r
1237  commonHistResults2ndOrderName += fAnalysisLabel->Data();\r
1238  fCommonHistsResults2nd = new AliFlowCommonHistResults(commonHistResults2ndOrderName.Data());\r
1239  fHistList->Add(fCommonHistsResults2nd);  \r
1240  // common histograms for final results (calculated for events with 4 and more particles)\r
1241  TString commonHistResults4thOrderName = "AliFlowCommonHistResults4thOrderQC";\r
1242  commonHistResults4thOrderName += fAnalysisLabel->Data();\r
1243  fCommonHistsResults4th = new AliFlowCommonHistResults(commonHistResults4thOrderName.Data());\r
1244  fHistList->Add(fCommonHistsResults4th); \r
1245  // common histograms for final results (calculated for events with 6 and more particles)\r
1246  TString commonHistResults6thOrderName = "AliFlowCommonHistResults6thOrderQC";\r
1247  commonHistResults6thOrderName += fAnalysisLabel->Data();\r
1248  fCommonHistsResults6th = new AliFlowCommonHistResults(commonHistResults6thOrderName.Data());\r
1249  fHistList->Add(fCommonHistsResults6th);  \r
1250  // common histograms for final results (calculated for events with 8 and more particles)\r
1251  TString commonHistResults8thOrderName = "AliFlowCommonHistResults8thOrderQC";\r
1252  commonHistResults8thOrderName += fAnalysisLabel->Data();\r
1253  fCommonHistsResults8th = new AliFlowCommonHistResults(commonHistResults8thOrderName.Data());\r
1254  fHistList->Add(fCommonHistsResults8th); \r
1255  \r
1256 } // end of void AliFlowAnalysisWithQCumulants::BookCommonHistograms()\r
1257 \r
1258 \r
1259 //================================================================================================================================\r
1260 \r
1261 \r
1262 void AliFlowAnalysisWithQCumulants::BookAndFillWeightsHistograms()\r
1263 {\r
1264  // book and fill histograms which hold phi, pt and eta weights\r
1265 \r
1266  if(!fWeightsList)\r
1267  {\r
1268   cout<<"WARNING: fWeightsList is NULL in AFAWQC::BAFWH() !!!!"<<endl;\r
1269   exit(0);  \r
1270  }\r
1271     \r
1272  TString fUseParticleWeightsName = "fUseParticleWeightsQC";\r
1273  fUseParticleWeightsName += fAnalysisLabel->Data();\r
1274  fUseParticleWeights = new TProfile(fUseParticleWeightsName.Data(),"0 = particle weight not used, 1 = particle weight used ",3,0,3);\r
1275  fUseParticleWeights->SetLabelSize(0.06);\r
1276  (fUseParticleWeights->GetXaxis())->SetBinLabel(1,"w_{#phi}");\r
1277  (fUseParticleWeights->GetXaxis())->SetBinLabel(2,"w_{p_{T}}");\r
1278  (fUseParticleWeights->GetXaxis())->SetBinLabel(3,"w_{#eta}");\r
1279  fUseParticleWeights->Fill(0.5,(Int_t)fUsePhiWeights);\r
1280  fUseParticleWeights->Fill(1.5,(Int_t)fUsePtWeights);\r
1281  fUseParticleWeights->Fill(2.5,(Int_t)fUseEtaWeights);\r
1282  fWeightsList->Add(fUseParticleWeights); \r
1283   \r
1284  if(fUsePhiWeights)\r
1285  {\r
1286   if(fWeightsList->FindObject("phi_weights"))\r
1287   {\r
1288    fPhiWeights = dynamic_cast<TH1F*>(fWeightsList->FindObject("phi_weights"));\r
1289    if(fPhiWeights->GetBinWidth(1) != fPhiBinWidth)\r
1290    {\r
1291     cout<<"WARNING: fPhiWeights->GetBinWidth(1) != fPhiBinWidth in AFAWQC::BAFWH() !!!!        "<<endl;\r
1292     cout<<"         This indicates inconsistent binning in phi histograms throughout the code."<<endl;\r
1293     exit(0);\r
1294    }\r
1295   } else \r
1296     {\r
1297      cout<<"WARNING: fWeightsList->FindObject(\"phi_weights\") is NULL in AFAWQC::BAFWH() !!!!"<<endl;\r
1298      exit(0);\r
1299     }\r
1300  } // end of if(fUsePhiWeights)\r
1301  \r
1302  if(fUsePtWeights) \r
1303  {\r
1304   if(fWeightsList->FindObject("pt_weights"))\r
1305   {\r
1306    fPtWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("pt_weights"));\r
1307    if(fPtWeights->GetBinWidth(1) != fPtBinWidth)\r
1308    {\r
1309     cout<<"WARNING: fPtWeights->GetBinWidth(1) != fPtBinWidth in AFAWQC::BAFWH() !!!!         "<<endl;\r
1310     cout<<"         This indicates insconsistent binning in pt histograms throughout the code."<<endl;\r
1311     exit(0);\r
1312    }\r
1313   } else \r
1314     {\r
1315      cout<<"WARNING: fWeightsList->FindObject(\"pt_weights\") is NULL in AFAWQC::BAFWH() !!!!"<<endl;\r
1316      exit(0);\r
1317     }\r
1318  } // end of if(fUsePtWeights)    \r
1319 \r
1320  if(fUseEtaWeights) \r
1321  {\r
1322   if(fWeightsList->FindObject("eta_weights"))\r
1323   {\r
1324    fEtaWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("eta_weights"));\r
1325    if(fEtaWeights->GetBinWidth(1) != fEtaBinWidth)\r
1326    {\r
1327     cout<<"WARNING: fEtaWeights->GetBinWidth(1) != fEtaBinWidth in AFAWQC::BAFWH() !!!!        "<<endl;\r
1328     cout<<"         This indicates insconsistent binning in eta histograms throughout the code."<<endl;\r
1329     exit(0);\r
1330    }\r
1331   } else \r
1332     {\r
1333      cout<<"WARNING: fUseEtaWeights && fWeightsList->FindObject(\"eta_weights\") is NULL in AFAWQC::BAFWH() !!!!"<<endl;\r
1334      exit(0);\r
1335     }\r
1336  } // end of if(fUseEtaWeights)\r
1337  \r
1338 } // end of AliFlowAnalysisWithQCumulants::BookAndFillWeightsHistograms()\r
1339 \r
1340 \r
1341 //================================================================================================================================\r
1342 \r
1343 \r
1344 void AliFlowAnalysisWithQCumulants::BookEverythingForIntegratedFlow()\r
1345 {\r
1346  // Book all objects for integrated flow:\r
1347  //  a) Book profile to hold all flags for integrated flow.\r
1348  //  b) Book event-by-event quantities.\r
1349  //  c) Book profiles. // to be improved (comment)\r
1350  //  d) Book histograms holding the final results.\r
1351  \r
1352  TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data members?)\r
1353  TString powerFlag[2] = {"linear","quadratic"}; // to be improved (should I promote this to data members?)\r
1354  \r
1355  // a) Book profile to hold all flags for integrated flow:\r
1356  TString intFlowFlagsName = "fIntFlowFlags";\r
1357  intFlowFlagsName += fAnalysisLabel->Data();\r
1358  fIntFlowFlags = new TProfile(intFlowFlagsName.Data(),"Flags for Integrated Flow",3,0,3);\r
1359  fIntFlowFlags->SetTickLength(-0.01,"Y");\r
1360  fIntFlowFlags->SetMarkerStyle(25);\r
1361  fIntFlowFlags->SetLabelSize(0.05);\r
1362  fIntFlowFlags->SetLabelOffset(0.02,"Y");\r
1363  (fIntFlowFlags->GetXaxis())->SetBinLabel(1,"Particle Weights");\r
1364  (fIntFlowFlags->GetXaxis())->SetBinLabel(2,"Event Weights");\r
1365  (fIntFlowFlags->GetXaxis())->SetBinLabel(3,"Corrected for NUA?");\r
1366  fIntFlowList->Add(fIntFlowFlags);\r
1367 \r
1368  // b) Book event-by-event quantities:\r
1369  // Re[Q_{m*n,k}], Im[Q_{m*n,k}] and S_{p,k}^M: \r
1370  fReQ  = new TMatrixD(4,9);\r
1371  fImQ  = new TMatrixD(4,9);\r
1372  fSMpk = new TMatrixD(8,9);\r
1373  // average correlations <2>, <4>, <6> and <8> for single event (bining is the same as in fIntFlowCorrelationsPro and fIntFlowCorrelationsHist):\r
1374  TString intFlowCorrelationsEBEName = "fIntFlowCorrelationsEBE";\r
1375  intFlowCorrelationsEBEName += fAnalysisLabel->Data();\r
1376  fIntFlowCorrelationsEBE = new TH1D(intFlowCorrelationsEBEName.Data(),intFlowCorrelationsEBEName.Data(),4,0,4);\r
1377  // weights for average correlations <2>, <4>, <6> and <8> for single event:\r
1378  TString intFlowEventWeightsForCorrelationsEBEName = "fIntFlowEventWeightsForCorrelationsEBE";\r
1379  intFlowEventWeightsForCorrelationsEBEName += fAnalysisLabel->Data();\r
1380  fIntFlowEventWeightsForCorrelationsEBE = new TH1D(intFlowEventWeightsForCorrelationsEBEName.Data(),intFlowEventWeightsForCorrelationsEBEName.Data(),4,0,4);\r
1381  // average all correlations for single event (bining is the same as in fIntFlowCorrelationsAllPro and fIntFlowCorrelationsAllHist):\r
1382  TString intFlowCorrelationsAllEBEName = "fIntFlowCorrelationsAllEBE";\r
1383  intFlowCorrelationsAllEBEName += fAnalysisLabel->Data();\r
1384  fIntFlowCorrelationsAllEBE = new TH1D(intFlowCorrelationsAllEBEName.Data(),intFlowCorrelationsAllEBEName.Data(),32,0,32);\r
1385  // average correction terms for non-uniform acceptance for single event \r
1386  // (binning is the same as in fIntFlowCorrectionTermsForNUAPro[2] and fIntFlowCorrectionTermsForNUAHist[2]):\r
1387  TString fIntFlowCorrectionTermsForNUAEBEName = "fIntFlowCorrectionTermsForNUAEBE";\r
1388  fIntFlowCorrectionTermsForNUAEBEName += fAnalysisLabel->Data();\r
1389  for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1390  {\r
1391   fIntFlowCorrectionTermsForNUAEBE[sc] = new TH1D(Form("%s: %s terms",fIntFlowCorrectionTermsForNUAEBEName.Data(),sinCosFlag[sc].Data()),Form("Correction terms for non-uniform acceptance (%s terms)",sinCosFlag[sc].Data()),10,0,10);  \r
1392  }\r
1393  \r
1394  // c) Book profiles: // to be improved (comment)\r
1395  // profile to hold average multiplicities and number of events for events with nRP>=0, nRP>=1, ... , and nRP>=8:\r
1396  TString avMultiplicityName = "fAvMultiplicity";\r
1397  avMultiplicityName += fAnalysisLabel->Data();\r
1398  fAvMultiplicity = new TProfile(avMultiplicityName.Data(),"Average Multiplicities of RPs",9,0,9);\r
1399  fAvMultiplicity->SetTickLength(-0.01,"Y");\r
1400  fAvMultiplicity->SetMarkerStyle(25);\r
1401  fAvMultiplicity->SetLabelSize(0.05);\r
1402  fAvMultiplicity->SetLabelOffset(0.02,"Y");\r
1403  fAvMultiplicity->SetYTitle("Average Multiplicity");\r
1404  (fAvMultiplicity->GetXaxis())->SetBinLabel(1,"all evts");\r
1405  (fAvMultiplicity->GetXaxis())->SetBinLabel(2,"n_{RP} #geq 1");\r
1406  (fAvMultiplicity->GetXaxis())->SetBinLabel(3,"n_{RP} #geq 2");\r
1407  (fAvMultiplicity->GetXaxis())->SetBinLabel(4,"n_{RP} #geq 3");\r
1408  (fAvMultiplicity->GetXaxis())->SetBinLabel(5,"n_{RP} #geq 4");\r
1409  (fAvMultiplicity->GetXaxis())->SetBinLabel(6,"n_{RP} #geq 5");\r
1410  (fAvMultiplicity->GetXaxis())->SetBinLabel(7,"n_{RP} #geq 6");\r
1411  (fAvMultiplicity->GetXaxis())->SetBinLabel(8,"n_{RP} #geq 7");\r
1412  (fAvMultiplicity->GetXaxis())->SetBinLabel(9,"n_{RP} #geq 8");\r
1413  fIntFlowProfiles->Add(fAvMultiplicity);\r
1414  // average correlations <<2>>, <<4>>, <<6>> and <<8>> for all events (with wrong errors!):\r
1415  TString intFlowCorrelationsProName = "fIntFlowCorrelationsPro";\r
1416  intFlowCorrelationsProName += fAnalysisLabel->Data();\r
1417  fIntFlowCorrelationsPro = new TProfile(intFlowCorrelationsProName.Data(),"Average correlations for all events",4,0,4,"s");\r
1418  fIntFlowCorrelationsPro->SetTickLength(-0.01,"Y");\r
1419  fIntFlowCorrelationsPro->SetMarkerStyle(25);\r
1420  fIntFlowCorrelationsPro->SetLabelSize(0.06);\r
1421  fIntFlowCorrelationsPro->SetLabelOffset(0.01,"Y");\r
1422  (fIntFlowCorrelationsPro->GetXaxis())->SetBinLabel(1,"<<2>>");\r
1423  (fIntFlowCorrelationsPro->GetXaxis())->SetBinLabel(2,"<<4>>");\r
1424  (fIntFlowCorrelationsPro->GetXaxis())->SetBinLabel(3,"<<6>>");\r
1425  (fIntFlowCorrelationsPro->GetXaxis())->SetBinLabel(4,"<<8>>");\r
1426  fIntFlowProfiles->Add(fIntFlowCorrelationsPro);\r
1427  // averaged all correlations for all events (with wrong errors!):\r
1428  TString intFlowCorrelationsAllProName = "fIntFlowCorrelationsAllPro";\r
1429  intFlowCorrelationsAllProName += fAnalysisLabel->Data();\r
1430  fIntFlowCorrelationsAllPro = new TProfile(intFlowCorrelationsAllProName.Data(),"Average correlations for all events",32,0,32,"s");\r
1431  fIntFlowCorrelationsAllPro->SetTickLength(-0.01,"Y");\r
1432  fIntFlowCorrelationsAllPro->SetMarkerStyle(25);\r
1433  fIntFlowCorrelationsAllPro->SetLabelSize(0.03);\r
1434  fIntFlowCorrelationsAllPro->SetLabelOffset(0.01,"Y");\r
1435  // 2-p correlations:\r
1436  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(1,"<<2>>_{n|n}");\r
1437  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(2,"<<2>>_{2n|2n}");\r
1438  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(3,"<<2>>_{3n|3n}");\r
1439  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(4,"<<2>>_{4n|4n}");\r
1440  // 3-p correlations:\r
1441  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(6,"<<3>>_{2n|n,n}");\r
1442  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(7,"<<3>>_{3n|2n,n}");\r
1443  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(8,"<<3>>_{4n|2n,2n}");\r
1444  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(9,"<<3>>_{4n|3n,n}");\r
1445  // 4-p correlations:\r
1446  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(11,"<<4>>_{n,n|n,n}"); \r
1447  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(12,"<<4>>_{2n,n|2n,n}");\r
1448  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(13,"<<4>>_{2n,2n|2n,2n}");\r
1449  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(14,"<<4>>_{3n|n,n,n}");\r
1450  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(15,"<<4>>_{3n,n|3n,n}");\r
1451  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(16,"<<4>>_{3n,n|2n,2n}"); \r
1452  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(17,"<<4>>_{4n|2n,n,n}");\r
1453  // 5-p correlations:\r
1454  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(19,"<<5>>_{2n|n,n,n,n}"); \r
1455  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(20,"<<5>>_{2n,2n|2n,n,n}");\r
1456  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(21,"<<5>>_{3n,n|2n,n,n}");\r
1457  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(22,"<<5>>_{4n|n,n,n,n}");\r
1458  // 6-p correlations:\r
1459  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(24,"<<6>>_{n,n,n|n,n,n}");\r
1460  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(25,"<<6>>_{2n,n,n|2n,n,n}");\r
1461  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(26,"<<6>>_{2n,2n|n,n,n,n}");\r
1462  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(27,"<<6>>_{3n,n|n,n,n,n}");\r
1463  // 7-p correlations:  \r
1464  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(29,"<<7>>_{2n,n,n|n,n,n,n}");\r
1465  // 8-p correlations:\r
1466  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(31,"<<8>>_{n,n,n,n|n,n,n,n}");\r
1467  fIntFlowProfiles->Add(fIntFlowCorrelationsAllPro);
1468  // when particle weights are used some extra correlations appear:\r
1469  if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights) 
1470  {
1471   TString intFlowExtraCorrelationsProName = "fIntFlowExtraCorrelationsPro";\r
1472   intFlowExtraCorrelationsProName += fAnalysisLabel->Data();\r
1473   fIntFlowExtraCorrelationsPro = new TProfile(intFlowExtraCorrelationsProName.Data(),"Average extra correlations for all events",100,0,100,"s");\r
1474   fIntFlowExtraCorrelationsPro->SetTickLength(-0.01,"Y");\r
1475   fIntFlowExtraCorrelationsPro->SetMarkerStyle(25);\r
1476   fIntFlowExtraCorrelationsPro->SetLabelSize(0.03);\r
1477   fIntFlowExtraCorrelationsPro->SetLabelOffset(0.01,"Y");\r
1478   // extra 2-p correlations:\r
1479   (fIntFlowExtraCorrelationsPro->GetXaxis())->SetBinLabel(1,"<<w1^3 w2 cos(n*(phi1-phi2))>>");\r
1480   (fIntFlowExtraCorrelationsPro->GetXaxis())->SetBinLabel(2,"<<w1 w2 w3^2 cos(n*(phi1-phi2))>>");\r
1481   // ...
1482   fIntFlowProfiles->Add(fIntFlowExtraCorrelationsPro);
1483  } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)
1484  // average product of correlations <2>, <4>, <6> and <8>:  \r
1485  TString intFlowProductOfCorrelationsProName = "fIntFlowProductOfCorrelationsPro";\r
1486  intFlowProductOfCorrelationsProName += fAnalysisLabel->Data();\r
1487  fIntFlowProductOfCorrelationsPro = new TProfile(intFlowProductOfCorrelationsProName.Data(),"Average products of correlations",6,0,6);\r
1488  fIntFlowProductOfCorrelationsPro->SetTickLength(-0.01,"Y");\r
1489  fIntFlowProductOfCorrelationsPro->SetMarkerStyle(25); \r
1490  fIntFlowProductOfCorrelationsPro->SetLabelSize(0.05);\r
1491  fIntFlowProductOfCorrelationsPro->SetLabelOffset(0.01,"Y");\r
1492  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(1,"<<2><4>>");\r
1493  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(2,"<<2><6>>");\r
1494  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(3,"<<2><8>>");\r
1495  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(4,"<<4><6>>");\r
1496  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(5,"<<4><8>>");\r
1497  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(6,"<<6><8>>");\r
1498  fIntFlowProfiles->Add(fIntFlowProductOfCorrelationsPro);\r
1499  // average correction terms for non-uniform acceptance (with wrong errors!):\r
1500  for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1501  {\r
1502   TString intFlowCorrectionTermsForNUAProName = "fIntFlowCorrectionTermsForNUAPro";\r
1503   intFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();\r
1504   fIntFlowCorrectionTermsForNUAPro[sc] = new TProfile(Form("%s: %s terms",intFlowCorrectionTermsForNUAProName.Data(),sinCosFlag[sc].Data()),Form("Correction terms for non-uniform acceptance (%s terms)",sinCosFlag[sc].Data()),10,0,10,"s");\r
1505   fIntFlowCorrectionTermsForNUAPro[sc]->SetTickLength(-0.01,"Y");\r
1506   fIntFlowCorrectionTermsForNUAPro[sc]->SetMarkerStyle(25);\r
1507   fIntFlowCorrectionTermsForNUAPro[sc]->SetLabelSize(0.03);\r
1508   fIntFlowCorrectionTermsForNUAPro[sc]->SetLabelOffset(0.01,"Y");\r
1509   // 1-particle terms:\r
1510   (fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->SetBinLabel(1,Form("<<%s(n(phi1))>>",sinCosFlag[sc].Data()));\r
1511   // 2-particle terms:
1512   (fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->SetBinLabel(2,Form("<<%s(n(phi1+phi2))>>",sinCosFlag[sc].Data()));  \r
1513   // 3-particle terms:\r
1514   (fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->SetBinLabel(3,Form("<<%s(n(phi1-phi2-phi3))>>",sinCosFlag[sc].Data()));  \r
1515   // ... \r
1516   fIntFlowProfiles->Add(fIntFlowCorrectionTermsForNUAPro[sc]);\r
1517  } // end of for(Int_t sc=0;sc<2;sc++) \r
1518  \r
1519  // d) Book histograms holding the final results:\r
1520  // average correlations <<2>>, <<4>>, <<6>> and <<8>> for all events (with correct errors!):\r
1521  TString intFlowCorrelationsHistName = "fIntFlowCorrelationsHist";\r
1522  intFlowCorrelationsHistName += fAnalysisLabel->Data();\r
1523  fIntFlowCorrelationsHist = new TH1D(intFlowCorrelationsHistName.Data(),"Average correlations for all events",4,0,4);\r
1524  fIntFlowCorrelationsHist->SetTickLength(-0.01,"Y");\r
1525  fIntFlowCorrelationsHist->SetMarkerStyle(25);\r
1526  fIntFlowCorrelationsHist->SetLabelSize(0.06);\r
1527  fIntFlowCorrelationsHist->SetLabelOffset(0.01,"Y");\r
1528  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(1,"<<2>>");\r
1529  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(2,"<<4>>");\r
1530  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(3,"<<6>>");\r
1531  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(4,"<<8>>");\r
1532  fIntFlowResults->Add(fIntFlowCorrelationsHist);\r
1533  // average all correlations for all events (with correct errors!):\r
1534  TString intFlowCorrelationsAllHistName = "fIntFlowCorrelationsAllHist";\r
1535  intFlowCorrelationsAllHistName += fAnalysisLabel->Data();\r
1536  fIntFlowCorrelationsAllHist = new TH1D(intFlowCorrelationsAllHistName.Data(),"Average correlations for all events",32,0,32);\r
1537  fIntFlowCorrelationsAllHist->SetTickLength(-0.01,"Y");\r
1538  fIntFlowCorrelationsAllHist->SetMarkerStyle(25);\r
1539  fIntFlowCorrelationsAllHist->SetLabelSize(0.03);\r
1540  fIntFlowCorrelationsAllHist->SetLabelOffset(0.01,"Y");\r
1541  // 2-p correlations:\r
1542  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(1,"<<2>>_{n|n}");\r
1543  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(2,"<<2>>_{2n|2n}");\r
1544  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(3,"<<2>>_{3n|3n}");\r
1545  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(4,"<<2>>_{4n|4n}");\r
1546  // 3-p correlations:\r
1547  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(6,"<<3>>_{2n|n,n}");\r
1548  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(7,"<<3>>_{3n|2n,n}");\r
1549  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(8,"<<3>>_{4n|2n,2n}");\r
1550  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(9,"<<3>>_{4n|3n,n}");\r
1551  // 4-p correlations:\r
1552  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(11,"<<4>>_{n,n|n,n}"); \r
1553  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(12,"<<4>>_{2n,n|2n,n}");\r
1554  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(13,"<<4>>_{2n,2n|2n,2n}");\r
1555  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(14,"<<4>>_{3n|n,n,n}");\r
1556  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(15,"<<4>>_{3n,n|3n,n}");\r
1557  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(16,"<<4>>_{3n,n|2n,2n}"); \r
1558  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(17,"<<4>>_{4n|2n,n,n}");\r
1559  // 5-p correlations:\r
1560  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(19,"<<5>>_{2n|n,n,n,n}"); \r
1561  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(20,"<<5>>_{2n,2n|2n,n,n}");\r
1562  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(21,"<<5>>_{3n,n|2n,n,n}");\r
1563  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(22,"<<5>>_{4n|n,n,n,n}");\r
1564  // 6-p correlations:\r
1565  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(24,"<<6>>_{n,n,n|n,n,n}");\r
1566  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(25,"<<6>>_{2n,n,n|2n,n,n}");\r
1567  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(26,"<<6>>_{2n,2n|n,n,n,n}");\r
1568  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(27,"<<6>>_{3n,n|n,n,n,n}");\r
1569  // 7-p correlations:  \r
1570  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(29,"<<7>>_{2n,n,n|n,n,n,n}");\r
1571  // 8-p correlations:\r
1572  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(31,"<<8>>_{n,n,n,n|n,n,n,n}");\r
1573  fIntFlowResults->Add(fIntFlowCorrelationsAllHist);\r
1574  // average correction terms for non-uniform acceptance (with correct errors!):\r
1575  for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1576  {\r
1577   TString intFlowCorrectionTermsForNUAHistName = "fIntFlowCorrectionTermsForNUAHist";\r
1578   intFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();\r
1579   fIntFlowCorrectionTermsForNUAHist[sc] = new TH1D(Form("%s: %s terms",intFlowCorrectionTermsForNUAHistName.Data(),sinCosFlag[sc].Data()),Form("Correction terms for non-uniform acceptance (%s terms)",sinCosFlag[sc].Data()),10,0,10);\r
1580   fIntFlowCorrectionTermsForNUAHist[sc]->SetTickLength(-0.01,"Y");\r
1581   fIntFlowCorrectionTermsForNUAHist[sc]->SetMarkerStyle(25);\r
1582   fIntFlowCorrectionTermsForNUAHist[sc]->SetLabelSize(0.03);\r
1583   fIntFlowCorrectionTermsForNUAHist[sc]->SetLabelOffset(0.01,"Y");\r
1584   // ......................................................................... \r
1585   // 1-p terms:\r
1586   (fIntFlowCorrectionTermsForNUAHist[sc]->GetXaxis())->SetBinLabel(1,Form("%s(n(#phi_{1}))>",sinCosFlag[sc].Data()));\r
1587   // 2-p terms:\r
1588   // 3-p terms:\r
1589   // ...\r
1590   // ......................................................................... \r
1591   fIntFlowResults->Add(fIntFlowCorrectionTermsForNUAHist[sc]);\r
1592  } // end of for(Int_t sc=0;sc<2;sc++) \r
1593  // covariances (multiplied with weight dependent prefactor):\r
1594  TString intFlowCovariancesName = "fIntFlowCovariances";\r
1595  intFlowCovariancesName += fAnalysisLabel->Data();\r
1596  fIntFlowCovariances = new TH1D(intFlowCovariancesName.Data(),"Covariances (multiplied with weight dependent prefactor)",6,0,6);\r
1597  fIntFlowCovariances->SetLabelSize(0.04);\r
1598  fIntFlowCovariances->SetMarkerStyle(25);\r
1599  (fIntFlowCovariances->GetXaxis())->SetBinLabel(1,"Cov(<2>,<4>)");\r
1600  (fIntFlowCovariances->GetXaxis())->SetBinLabel(2,"Cov(<2>,<6>)");\r
1601  (fIntFlowCovariances->GetXaxis())->SetBinLabel(3,"Cov(<2>,<8>)");\r
1602  (fIntFlowCovariances->GetXaxis())->SetBinLabel(4,"Cov(<4>,<6>)");\r
1603  (fIntFlowCovariances->GetXaxis())->SetBinLabel(5,"Cov(<4>,<8>)");\r
1604  (fIntFlowCovariances->GetXaxis())->SetBinLabel(6,"Cov(<6>,<8>)");  \r
1605  fIntFlowResults->Add(fIntFlowCovariances);\r
1606  // sum of linear and quadratic event weights for <2>, <4>, <6> and <8>:\r
1607  TString intFlowSumOfEventWeightsName = "fIntFlowSumOfEventWeights";\r
1608  intFlowSumOfEventWeightsName += fAnalysisLabel->Data();\r
1609  for(Int_t power=0;power<2;power++)\r
1610  {\r
1611   fIntFlowSumOfEventWeights[power] = new TH1D(Form("%s: %s",intFlowSumOfEventWeightsName.Data(),powerFlag[power].Data()),Form("Sum of %s event weights for correlations",powerFlag[power].Data()),4,0,4);\r
1612   fIntFlowSumOfEventWeights[power]->SetLabelSize(0.05);\r
1613   fIntFlowSumOfEventWeights[power]->SetMarkerStyle(25);\r
1614   if(power == 0)\r
1615   {\r
1616    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(1,"#sum_{i=1}^{N} w_{<2>}");\r
1617    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(2,"#sum_{i=1}^{N} w_{<4>}");\r
1618    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(3,"#sum_{i=1}^{N} w_{<6>}");\r
1619    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(4,"#sum_{i=1}^{N} w_{<8>}");\r
1620   } else if (power == 1) \r
1621     {\r
1622      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(1,"#sum_{i=1}^{N} w_{<2>}^{2}");\r
1623      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(2,"#sum_{i=1}^{N} w_{<4>}^{2}");\r
1624      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(3,"#sum_{i=1}^{N} w_{<6>}^{2}");\r
1625      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(4,"#sum_{i=1}^{N} w_{<8>}^{2}");\r
1626     }\r
1627   fIntFlowResults->Add(fIntFlowSumOfEventWeights[power]);\r
1628  } \r
1629  // sum of products of event weights for correlations <2>, <4>, <6> and <8>:  \r
1630  TString intFlowSumOfProductOfEventWeightsName = "fIntFlowSumOfProductOfEventWeights";\r
1631  intFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();\r
1632  fIntFlowSumOfProductOfEventWeights = new TH1D(intFlowSumOfProductOfEventWeightsName.Data(),"Sum of product of event weights for correlations",6,0,6);\r
1633  fIntFlowSumOfProductOfEventWeights->SetLabelSize(0.05);\r
1634  fIntFlowSumOfProductOfEventWeights->SetMarkerStyle(25);\r
1635  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(1,"#sum_{i=1}^{N} w_{<2>} w_{<4>}");\r
1636  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(2,"#sum_{i=1}^{N} w_{<2>} w_{<6>}");\r
1637  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(3,"#sum_{i=1}^{N} w_{<2>} w_{<8>}");\r
1638  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(4,"#sum_{i=1}^{N} w_{<4>} w_{<6>}");\r
1639  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(5,"#sum_{i=1}^{N} w_{<4>} w_{<8>}");\r
1640  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(6,"#sum_{i=1}^{N} w_{<6>} w_{<8>}");\r
1641  fIntFlowResults->Add(fIntFlowSumOfProductOfEventWeights);\r
1642  // final results for integrated Q-cumulants:\r
1643  TString intFlowQcumulantsName = "fIntFlowQcumulants";\r
1644  intFlowQcumulantsName += fAnalysisLabel->Data();\r
1645  fIntFlowQcumulants = new TH1D(intFlowQcumulantsName.Data(),"Integrated Q-cumulants",4,0,4);\r
1646  fIntFlowQcumulants->SetLabelSize(0.05);\r
1647  fIntFlowQcumulants->SetMarkerStyle(25);\r
1648  (fIntFlowQcumulants->GetXaxis())->SetBinLabel(1,"QC{2}");\r
1649  (fIntFlowQcumulants->GetXaxis())->SetBinLabel(2,"QC{4}");\r
1650  (fIntFlowQcumulants->GetXaxis())->SetBinLabel(3,"QC{6}");\r
1651  (fIntFlowQcumulants->GetXaxis())->SetBinLabel(4,"QC{8}");\r
1652  fIntFlowResults->Add(fIntFlowQcumulants);\r
1653  // final integrated flow estimates from Q-cumulants:\r
1654  TString intFlowName = "fIntFlow";\r
1655  intFlowName += fAnalysisLabel->Data();  \r
1656  // integrated flow from Q-cumulants:\r
1657  fIntFlow = new TH1D(intFlowName.Data(),"Integrated flow estimates from Q-cumulants",4,0,4);\r
1658  fIntFlow->SetLabelSize(0.05);\r
1659  fIntFlow->SetMarkerStyle(25);\r
1660  (fIntFlow->GetXaxis())->SetBinLabel(1,"v_{2}{2,QC}");\r
1661  (fIntFlow->GetXaxis())->SetBinLabel(2,"v_{2}{4,QC}");\r
1662  (fIntFlow->GetXaxis())->SetBinLabel(3,"v_{2}{6,QC}");\r
1663  (fIntFlow->GetXaxis())->SetBinLabel(4,"v_{2}{8,QC}");\r
1664  fIntFlowResults->Add(fIntFlow);\r
1665 \r
1666  /* // to be improved (removed):\r
1667   // final average weighted multi-particle correlations for all events calculated from Q-vectors\r
1668   fQCorrelations[1] = new TProfile("Weighted correlations","final average multi-particle correlations from weighted Q-vectors",200,0,200,"s");\r
1669   fQCorrelations[1]->SetTickLength(-0.01,"Y");\r
1670   fQCorrelations[1]->SetMarkerStyle(25);\r
1671   fQCorrelations[1]->SetLabelSize(0.03);\r
1672   fQCorrelations[1]->SetLabelOffset(0.01,"Y");\r
1673   // 2-particle correlations:\r
1674   (fQCorrelations[1]->GetXaxis())->SetBinLabel(1,"<w_{1}w_{2}cos(n(#phi_{1}-#phi_{2}))>");\r
1675   (fQCorrelations[1]->GetXaxis())->SetBinLabel(2,"<w_{1}^{2}w_{2}^{2}cos(2n(#phi_{1}-#phi_{2}))>");\r
1676   (fQCorrelations[1]->GetXaxis())->SetBinLabel(3,"<w_{1}^{3}w_{2}^{3}cos(3n(#phi_{1}-#phi_{2}))>");\r
1677   (fQCorrelations[1]->GetXaxis())->SetBinLabel(4,"<w_{1}^{4}w_{2}^{4}cos(4n(#phi_{1}-#phi_{2}))>");\r
1678   (fQCorrelations[1]->GetXaxis())->SetBinLabel(5,"<w_{1}^{3}w_{2}cos(n(#phi_{1}-#phi_{2}))>");\r
1679   (fQCorrelations[1]->GetXaxis())->SetBinLabel(6,"<w_{1}^{2}w_{2}w_{3}cos(n(#phi_{1}-#phi_{2}))>");\r
1680   // 3-particle correlations:\r
1681   (fQCorrelations[1]->GetXaxis())->SetBinLabel(21,"<w_{1}w_{2}w_{3}^{2}cos(n(2#phi_{1}-#phi_{2}-#phi_{3}))>");\r
1682   // 4-particle correlations:\r
1683   (fQCorrelations[1]->GetXaxis())->SetBinLabel(41,"<w_{1}w_{2}w_{3}w_{4}cos(n(#phi_{1}+#phi_{2}-#phi_{3}-#phi_{4}))>");\r
1684   // add fQCorrelations[1] to the list fIntFlowList:\r
1685   fIntFlowList->Add(fQCorrelations[1]); \r
1686  */\r
1687   \r
1688 } // end of AliFlowAnalysisWithQCumulants::BookEverythingForIntegratedFlow()\r
1689 \r
1690 \r
1691 //================================================================================================================================\r
1692 \r
1693
1694 void AliFlowAnalysisWithQCumulants::InitializeArraysForNestedLoops()
1695 {
1696  // Initialize arrays of all objects relevant for calculations with nested loops.
1697  
1698  // integrated flow:
1699  for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1700  {\r
1701   fIntFlowDirectCorrectionTermsForNUA[sc] = NULL;
1702  } 
1703
1704  // differential flow:  
1705  // correlations:
1706  for(Int_t t=0;t<2;t++) // type: RP or POI\r
1707  { \r
1708   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1709   {\r
1710    for(Int_t ci=0;ci<4;ci++) // correlation index\r
1711    {\r
1712     fDiffFlowDirectCorrelations[t][pe][ci] = NULL;\r
1713    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index  \r
1714   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1715  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
1716  // correction terms for non-uniform acceptance:
1717  for(Int_t t=0;t<2;t++) // type: RP or POI\r
1718  { \r
1719   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1720   {\r
1721    for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1722    {\r
1723     for(Int_t cti=0;cti<9;cti++) // correction term index\r
1724     {\r
1725      fDiffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti] = NULL;\r
1726     }   \r
1727    }\r
1728   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1729  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
1730 \r
1731
1732 } // end of void AliFlowAnalysisWithQCumulants::InitializeArraysForNestedLoops()
1733
1734
1735 //================================================================================================================================\r
1736
1737 \r
1738 void AliFlowAnalysisWithQCumulants::BookEverythingForNestedLoops()\r
1739 {\r
1740  // Book all objects relevant for calculations with nested loops.
1741  
1742  TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data members?)\r
1743  TString typeFlag[2] = {"RP","POI"}; // to be improved (should I promote this to data members?)\r
1744  TString ptEtaFlag[2] = {"p_{T}","#eta"}; // to be improved (should I promote this to data members?)
1745  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"}; // to be improved (should I promote this to data members?)
1746  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
1747  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
1748 \r
1749  TString evaluateNestedLoopsName = "fEvaluateNestedLoops";\r
1750  evaluateNestedLoopsName += fAnalysisLabel->Data();\r
1751  fEvaluateNestedLoops = new TProfile(evaluateNestedLoopsName.Data(),"Flags for nested loops",4,0,4);\r
1752  fEvaluateNestedLoops->SetLabelSize(0.03);\r
1753  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(1,"fEvaluateIntFlowNestedLoops");\r
1754  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(2,"fEvaluateDiffFlowNestedLoops");\r
1755  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(3,"fCrossCheckInPtBinNo");\r
1756  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(4,"fCrossCheckInEtaBinNo");\r
1757  fEvaluateNestedLoops->Fill(0.5,(Int_t)fEvaluateIntFlowNestedLoops);\r
1758  fEvaluateNestedLoops->Fill(1.5,(Int_t)fEvaluateDiffFlowNestedLoops);\r
1759  fEvaluateNestedLoops->Fill(2.5,fCrossCheckInPtBinNo);\r
1760  fEvaluateNestedLoops->Fill(3.5,fCrossCheckInEtaBinNo);\r
1761  fNestedLoopsList->Add(fEvaluateNestedLoops);\r
1762  // nested loops for integrated flow:\r
1763  if(fEvaluateIntFlowNestedLoops)\r
1764  {\r
1765   // correlations:
1766   TString intFlowDirectCorrelationsName = "fIntFlowDirectCorrelations";\r
1767   intFlowDirectCorrelationsName += fAnalysisLabel->Data();\r
1768   fIntFlowDirectCorrelations = new TProfile(intFlowDirectCorrelationsName.Data(),"Multiparticle correlations calculated with nested loops (for int. flow)",32,0,32,"s");\r
1769   fNestedLoopsList->Add(fIntFlowDirectCorrelations);
1770   if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)
1771   {
1772    TString intFlowExtraDirectCorrelationsName = "fIntFlowExtraDirectCorrelations";\r
1773    intFlowExtraDirectCorrelationsName += fAnalysisLabel->Data();\r
1774    fIntFlowExtraDirectCorrelations = new TProfile(intFlowExtraDirectCorrelationsName.Data(),"Extra multiparticle correlations calculated with nested loops (for int. flow)",100,0,100,"s");\r
1775    fNestedLoopsList->Add(fIntFlowExtraDirectCorrelations);  
1776   } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)
1777   // correction terms for non-uniform acceptance:\r
1778   for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1779   {\r
1780    TString intFlowDirectCorrectionTermsForNUAName = "fIntFlowDirectCorrectionTermsForNUA";\r
1781    intFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();\r
1782    fIntFlowDirectCorrectionTermsForNUA[sc] = new TProfile(Form("%s: %s terms",intFlowDirectCorrectionTermsForNUAName.Data(),sinCosFlag[sc].Data()),Form("Correction terms for non-uniform acceptance (%s terms)",sinCosFlag[sc].Data()),10,0,10,"s");\r
1783    fNestedLoopsList->Add(fIntFlowDirectCorrectionTermsForNUA[sc]);\r
1784   } // end of for(Int_t sc=0;sc<2;sc++) \r
1785  } // end of if(fEvaluateIntFlowNestedLoops)
1786  \r
1787  // nested loops for differential flow: \r
1788  if(fEvaluateDiffFlowNestedLoops)\r
1789  {
1790   // reduced correlations:\r
1791   TString diffFlowDirectCorrelationsName = "fDiffFlowDirectCorrelations";\r
1792   diffFlowDirectCorrelationsName += fAnalysisLabel->Data();\r
1793   for(Int_t t=0;t<2;t++) // type: RP or POI\r
1794   { \r
1795    for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1796    {\r
1797     for(Int_t rci=0;rci<4;rci++) // reduced correlation index\r
1798     {\r
1799      // reduced correlations:\r
1800      fDiffFlowDirectCorrelations[t][pe][rci] = new TProfile(Form("%s, %s, %s, %s",diffFlowDirectCorrelationsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[rci].Data()),Form("%s, %s, %s, %s",diffFlowDirectCorrelationsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[rci].Data()),1,lowerPtEtaEdge[pe],upperPtEtaEdge[pe],"s");\r
1801      fDiffFlowDirectCorrelations[t][pe][rci]->SetXTitle(ptEtaFlag[pe].Data());\r
1802      fNestedLoopsList->Add(fDiffFlowDirectCorrelations[t][pe][rci]); // to be improved (add dedicated list to hold reduced correlations)\r
1803     } // end of for(Int_t rci=0;rci<4;rci++) // correlation index\r
1804    } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
1805   } // end of for(Int_t t=0;t<2;t++) // type: RP or POI \r
1806  } // end of if(fEvaluateDiffFlowNestedLoops)
1807  // correction terms for non-uniform acceptance:\r
1808  TString diffFlowDirectCorrectionTermsForNUAName = "fDiffFlowDirectCorrectionTermsForNUA";\r
1809  diffFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();\r
1810  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)\r
1811  { \r
1812   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1813   {\r
1814    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
1815    {\r
1816     for(Int_t cti=0;cti<9;cti++) // correction term index\r
1817     {\r
1818      fDiffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti] = new TProfile(Form("%s, %s, %s, %s, cti = %d",diffFlowDirectCorrectionTermsForNUAName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),cti+1),Form("%s, %s, %s, %s, cti = %d",diffFlowDirectCorrectionTermsForNUAName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),cti+1),1,lowerPtEtaEdge[pe],upperPtEtaEdge[pe],"s"); \r
1819      fNestedLoopsList->Add(fDiffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti]);\r
1820     }\r
1821    }\r
1822   }\r
1823  } \r
1824 \r
1825 } // end of AliFlowAnalysisWithQCumulants::BookEverythingForNestedLoops()\r
1826 \r
1827 \r
1828 //================================================================================================================================\r
1829 \r
1830 \r
1831 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelations()\r
1832 {\r
1833  // calculate all correlations needed for integrated flow\r
1834  \r
1835  // multiplicity:\r
1836  Double_t dMult = (*fSMpk)(0,0);\r
1837  \r
1838  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
1839  Double_t dReQ1n = (*fReQ)(0,0);\r
1840  Double_t dReQ2n = (*fReQ)(1,0);\r
1841  Double_t dReQ3n = (*fReQ)(2,0);\r
1842  Double_t dReQ4n = (*fReQ)(3,0);\r
1843  Double_t dImQ1n = (*fImQ)(0,0);\r
1844  Double_t dImQ2n = (*fImQ)(1,0);\r
1845  Double_t dImQ3n = (*fImQ)(2,0);\r
1846  Double_t dImQ4n = (*fImQ)(3,0);\r
1847   \r
1848  // real and imaginary parts of some expressions involving various combinations of Q-vectors evaluated in harmonics n, 2n, 3n and 4n:\r
1849  // (these expression appear in the Eqs. for the multi-particle correlations bellow)\r
1850  \r
1851  // Re[Q_{2n} Q_{n}^* Q_{n}^*]\r
1852  Double_t reQ2nQ1nstarQ1nstar = pow(dReQ1n,2.)*dReQ2n + 2.*dReQ1n*dImQ1n*dImQ2n - pow(dImQ1n,2.)*dReQ2n; \r
1853  \r
1854  // Im[Q_{2n} Q_{n}^* Q_{n}^*]\r
1855  //Double_t imQ2nQ1nstarQ1nstar = pow(dReQ1n,2.)*dImQ2n-2.*dReQ1n*dImQ1n*dReQ2n-pow(dImQ1n,2.)*dImQ2n; \r
1856  \r
1857  // Re[Q_{n} Q_{n} Q_{2n}^*] = Re[Q_{2n} Q_{n}^* Q_{n}^*]\r
1858  Double_t reQ1nQ1nQ2nstar = reQ2nQ1nstarQ1nstar; \r
1859  \r
1860  // Re[Q_{3n} Q_{n} Q_{2n}^* Q_{2n}^*]\r
1861  Double_t reQ3nQ1nQ2nstarQ2nstar = (pow(dReQ2n,2.)-pow(dImQ2n,2.))*(dReQ3n*dReQ1n-dImQ3n*dImQ1n) \r
1862                                  + 2.*dReQ2n*dImQ2n*(dReQ3n*dImQ1n+dImQ3n*dReQ1n);\r
1863 \r
1864  // Im[Q_{3n} Q_{n} Q_{2n}^* Q_{2n}^*]                                                                  \r
1865  //Double_t imQ3nQ1nQ2nstarQ2nstar = calculate and implement this (deleteMe)\r
1866   \r
1867  // Re[Q_{2n} Q_{2n} Q_{3n}^* Q_{1n}^*] = Re[Q_{3n} Q_{n} Q_{2n}^* Q_{2n}^*]\r
1868  Double_t reQ2nQ2nQ3nstarQ1nstar = reQ3nQ1nQ2nstarQ2nstar;\r
1869   \r
1870  // Re[Q_{4n} Q_{2n}^* Q_{2n}^*]\r
1871  Double_t reQ4nQ2nstarQ2nstar = pow(dReQ2n,2.)*dReQ4n+2.*dReQ2n*dImQ2n*dImQ4n-pow(dImQ2n,2.)*dReQ4n;\r
1872 \r
1873  // Im[Q_{4n} Q_{2n}^* Q_{2n}^*]\r
1874  //Double_t imQ4nQ2nstarQ2nstar = calculate and implement this (deleteMe)\r
1875  \r
1876  // Re[Q_{2n} Q_{2n} Q_{4n}^*] =  Re[Q_{4n} Q_{2n}^* Q_{2n}^*]\r
1877  Double_t reQ2nQ2nQ4nstar = reQ4nQ2nstarQ2nstar;\r
1878  \r
1879  // Re[Q_{4n} Q_{3n}^* Q_{n}^*]\r
1880  Double_t reQ4nQ3nstarQ1nstar = dReQ4n*(dReQ3n*dReQ1n-dImQ3n*dImQ1n)+dImQ4n*(dReQ3n*dImQ1n+dImQ3n*dReQ1n);\r
1881  \r
1882  // Re[Q_{3n} Q_{n} Q_{4n}^*] = Re[Q_{4n} Q_{3n}^* Q_{n}^*]\r
1883  Double_t reQ3nQ1nQ4nstar = reQ4nQ3nstarQ1nstar;\r
1884  \r
1885  // Im[Q_{4n} Q_{3n}^* Q_{n}^*]\r
1886  //Double_t imQ4nQ3nstarQ1nstar = calculate and implement this (deleteMe)\r
1887 \r
1888  // Re[Q_{3n} Q_{2n}^* Q_{n}^*]\r
1889  Double_t reQ3nQ2nstarQ1nstar = dReQ3n*dReQ2n*dReQ1n-dReQ3n*dImQ2n*dImQ1n+dImQ3n*dReQ2n*dImQ1n\r
1890                               + dImQ3n*dImQ2n*dReQ1n;\r
1891                               \r
1892  // Re[Q_{2n} Q_{n} Q_{3n}^*] = Re[Q_{3n} Q_{2n}^* Q_{n}^*]\r
1893  Double_t reQ2nQ1nQ3nstar = reQ3nQ2nstarQ1nstar;\r
1894  \r
1895  // Im[Q_{3n} Q_{2n}^* Q_{n}^*]\r
1896  //Double_t imQ3nQ2nstarQ1nstar; //calculate and implement this (deleteMe)\r
1897  \r
1898  // Re[Q_{3n} Q_{n}^* Q_{n}^* Q_{n}^*]\r
1899  Double_t reQ3nQ1nstarQ1nstarQ1nstar = dReQ3n*pow(dReQ1n,3)-3.*dReQ1n*dReQ3n*pow(dImQ1n,2)\r
1900                                      + 3.*dImQ1n*dImQ3n*pow(dReQ1n,2)-dImQ3n*pow(dImQ1n,3);\r
1901 \r
1902  // Im[Q_{3n} Q_{n}^* Q_{n}^* Q_{n}^*]\r
1903  //Double_t imQ3nQ1nstarQ1nstarQ1nstar; //calculate and implement this (deleteMe)\r
1904  \r
1905  // |Q_{2n}|^2 |Q_{n}|^2\r
1906  Double_t dQ2nQ1nQ2nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.));\r
1907  \r
1908  // Re[Q_{4n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1909  Double_t reQ4nQ2nstarQ1nstarQ1nstar = (dReQ4n*dReQ2n+dImQ4n*dImQ2n)*(pow(dReQ1n,2)-pow(dImQ1n,2))\r
1910                                      + 2.*dReQ1n*dImQ1n*(dImQ4n*dReQ2n-dReQ4n*dImQ2n); \r
1911  \r
1912  // Im[Q_{4n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1913  //Double_t imQ4nQ2nstarQ1nstarQ1nstar; //calculate and implement this (deleteMe)\r
1914  \r
1915  // Re[Q_{2n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^*]\r
1916  Double_t reQ2nQ1nQ1nstarQ1nstarQ1nstar = (dReQ2n*dReQ1n-dImQ2n*dImQ1n)*(pow(dReQ1n,3)-3.*dReQ1n*pow(dImQ1n,2))\r
1917                                         + (dReQ2n*dImQ1n+dReQ1n*dImQ2n)*(3.*dImQ1n*pow(dReQ1n,2)-pow(dImQ1n,3));\r
1918 \r
1919  // Im[Q_{2n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^*] \r
1920  //Double_t imQ2nQ1nQ1nstarQ1nstarQ1nstar; //calculate and implement this (deleteMe)\r
1921  \r
1922  // Re[Q_{2n} Q_{2n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1923  Double_t reQ2nQ2nQ2nstarQ1nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
1924                                         * (dReQ2n*(pow(dReQ1n,2.)-pow(dImQ1n,2.)) + 2.*dImQ2n*dReQ1n*dImQ1n);\r
1925 \r
1926  // Im[Q_{2n} Q_{2n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1927  //Double_t imQ2nQ2nQ2nstarQ1nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
1928  //                                       * (dImQ2n*(pow(dReQ1n,2.)-pow(dImQ1n,2.)) - 2.*dReQ2n*dReQ1n*dImQ1n);\r
1929  \r
1930  // Re[Q_{4n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1931  Double_t reQ4nQ1nstarQ1nstarQ1nstarQ1nstar = pow(dReQ1n,4.)*dReQ4n-6.*pow(dReQ1n,2.)*dReQ4n*pow(dImQ1n,2.)\r
1932                                             + pow(dImQ1n,4.)*dReQ4n+4.*pow(dReQ1n,3.)*dImQ1n*dImQ4n\r
1933                                             - 4.*pow(dImQ1n,3.)*dReQ1n*dImQ4n;\r
1934                                             \r
1935  // Im[Q_{4n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1936  //Double_t imQ4nQ1nstarQ1nstarQ1nstarQ1nstar = pow(dReQ1n,4.)*dImQ4n-6.*pow(dReQ1n,2.)*dImQ4n*pow(dImQ1n,2.)\r
1937  //                                           + pow(dImQ1n,4.)*dImQ4n+4.*pow(dImQ1n,3.)*dReQ1n*dReQ4n\r
1938  //                                           - 4.*pow(dReQ1n,3.)*dImQ1n*dReQ4n;\r
1939  \r
1940  // Re[Q_{3n} Q_{n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1941  Double_t reQ3nQ1nQ2nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
1942                                         * (dReQ1n*dReQ2n*dReQ3n-dReQ3n*dImQ1n*dImQ2n+dReQ2n*dImQ1n*dImQ3n+dReQ1n*dImQ2n*dImQ3n);\r
1943  \r
1944  // Im[Q_{3n} Q_{n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1945  //Double_t imQ3nQ1nQ2nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
1946  //                                       * (-dReQ2n*dReQ3n*dImQ1n-dReQ1n*dReQ3n*dImQ2n+dReQ1n*dReQ2n*dImQ3n-dImQ1n*dImQ2n*dImQ3n);\r
1947  \r
1948  \r
1949  // Re[Q_{2n} Q_{2n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1950  Double_t reQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)*dReQ2n-2.*dReQ1n*dReQ2n*dImQ1n-dReQ2n*pow(dImQ1n,2.)\r
1951                                                + dImQ2n*pow(dReQ1n,2.)+2.*dReQ1n*dImQ1n*dImQ2n-pow(dImQ1n,2.)*dImQ2n)\r
1952                                                * (pow(dReQ1n,2.)*dReQ2n+2.*dReQ1n*dReQ2n*dImQ1n-dReQ2n*pow(dImQ1n,2.)\r
1953                                                - dImQ2n*pow(dReQ1n,2.)+2.*dReQ1n*dImQ1n*dImQ2n+pow(dImQ1n,2.)*dImQ2n);\r
1954  \r
1955  // Im[Q_{2n} Q_{2n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1956  //Double_t imQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar = 2.*(pow(dReQ1n,2.)*dReQ2n-dReQ2n*pow(dImQ1n,2.)\r
1957  //                                              + 2.*dReQ1n*dImQ1n*dImQ2n)*(pow(dReQ1n,2.)*dImQ2n\r
1958  //                                              - 2.*dReQ1n*dImQ1n*dReQ2n-pow(dImQ1n,2.)*dImQ2n);\r
1959  \r
1960  // Re[Q_{3n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1961  Double_t reQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
1962                                                * (pow(dReQ1n,3.)*dReQ3n-3.*dReQ1n*dReQ3n*pow(dImQ1n,2.)\r
1963                                                + 3.*pow(dReQ1n,2.)*dImQ1n*dImQ3n-pow(dImQ1n,3.)*dImQ3n);\r
1964   \r
1965  // Im[Q_{3n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]                                                                                           \r
1966  //Double_t imQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
1967  //                                              * (pow(dImQ1n,3.)*dReQ3n-3.*dImQ1n*dReQ3n*pow(dReQ1n,2.)\r
1968  //                                              - 3.*pow(dImQ1n,2.)*dReQ1n*dImQ3n+pow(dReQ1n,3.)*dImQ3n);\r
1969  \r
1970  // |Q_{2n}|^2 |Q_{n}|^4\r
1971  Double_t dQ2nQ1nQ1nQ2nstarQ1nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))*pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.);\r
1972  \r
1973  // Re[Q_{2n} Q_{n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1974  Double_t reQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)\r
1975                                                   * (pow(dReQ1n,2.)*dReQ2n-dReQ2n*pow(dImQ1n,2.)\r
1976                                                   + 2.*dReQ1n*dImQ1n*dImQ2n);\r
1977                                                   \r
1978  // Im[Q_{2n} Q_{n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]                                                  \r
1979  //Double_t imQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)\r
1980  //                                                 * (pow(dReQ1n,2.)*dImQ2n-dImQ2n*pow(dImQ1n,2.)\r
1981  //                                                 - 2.*dReQ1n*dReQ2n*dImQ1n);\r
1982  \r
1983   \r
1984  \r
1985        \r
1986  //                                        **************************************\r
1987  //                                        **** multi-particle correlations: ****\r
1988  //                                        **************************************\r
1989  //\r
1990  // Remark 1: multi-particle correlations calculated with non-weighted Q-vectors are stored in 1D profile fQCorrelations[0]. // to be improved (wrong profiles)\r
1991  // Remark 2: binning of fQCorrelations[0] is organized as follows: // to be improved (wrong profiles)\r
1992  // --------------------------------------------------------------------------------------------------------------------\r
1993  //  1st bin: <2>_{1n|1n} = two1n1n = cos(n*(phi1-phi2))>\r
1994  //  2nd bin: <2>_{2n|2n} = two2n2n = cos(2n*(phi1-phi2))>\r
1995  //  3rd bin: <2>_{3n|3n} = two3n3n = cos(3n*(phi1-phi2))> \r
1996  //  4th bin: <2>_{4n|4n} = two4n4n = cos(4n*(phi1-phi2))>\r
1997  //  5th bin:           ----  EMPTY ----\r
1998  //  6th bin: <3>_{2n|1n,1n} = three2n1n1n = <cos(n*(2.*phi1-phi2-phi3))>\r
1999  //  7th bin: <3>_{3n|2n,1n} = three3n2n1n = <cos(n*(3.*phi1-2.*phi2-phi3))>\r
2000  //  8th bin: <3>_{4n|2n,2n} = three4n2n2n = <cos(n*(4.*phi1-2.*phi2-2.*phi3))>\r
2001  //  9th bin: <3>_{4n|3n,1n} = three4n3n1n = <cos(n*(4.*phi1-3.*phi2-phi3))>\r
2002  // 10th bin:           ----  EMPTY ----\r
2003  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1n = <cos(n*(phi1+phi2-phi3-phi4))>\r
2004  // 12th bin: <4>_{2n,1n|2n,1n} = four2n1n2n1n = <cos(2.*n*(phi1+phi2-phi3-phi4))>\r
2005  // 13th bin: <4>_{2n,2n|2n,2n} = four2n2n2n2n = <cos(n*(2.*phi1+phi2-2.*phi3-phi4))>\r
2006  // 14th bin: <4>_{3n|1n,1n,1n} = four3n1n1n1n = <cos(n*(3.*phi1-phi2-phi3-phi4))> \r
2007  // 15th bin: <4>_{3n,1n|3n,1n} = four3n1n3n1n = <cos(n*(4.*phi1-2.*phi2-phi3-phi4))>\r
2008  // 16th bin: <4>_{3n,1n|2n,2n} = four3n1n2n2n = <cos(n*(3.*phi1+phi2-2.*phi3-2.*phi4))>\r
2009  // 17th bin: <4>_{4n|2n,1n,1n} = four4n2n1n1n = <cos(n*(3.*phi1+phi2-3.*phi3-phi4))> \r
2010  // 18th bin:           ----  EMPTY ----\r
2011  // 19th bin: <5>_{2n|1n,1n,1n,1n} = five2n1n1n1n1n = <cos(n*(2.*phi1+phi2-phi3-phi4-phi5))>\r
2012  // 20th bin: <5>_{2n,2n|2n,1n,1n} = five2n2n2n1n1n = <cos(n*(2.*phi1+2.*phi2-2.*phi3-phi4-phi5))>\r
2013  // 21st bin: <5>_{3n,1n|2n,1n,1n} = five3n1n2n1n1n = <cos(n*(3.*phi1+phi2-2.*phi3-phi4-phi5))>\r
2014  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = five4n1n1n1n1n = <cos(n*(4.*phi1-phi2-phi3-phi4-phi5))>\r
2015  // 23rd bin:           ----  EMPTY ----\r
2016  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = six1n1n1n1n1n1n = <cos(n*(phi1+phi2+phi3-phi4-phi5-phi6))>\r
2017  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = six2n1n1n2n1n1n = <cos(n*(2.*phi1+2.*phi2-phi3-phi4-phi5-phi6))>\r
2018  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = six2n2n1n1n1n1n = <cos(n*(3.*phi1+phi2-phi3-phi4-phi5-phi6))>\r
2019  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = six3n1n1n1n1n1n = <cos(n*(2.*phi1+phi2+phi3-2.*phi4-phi5-phi6))>\r
2020  // 28th bin:           ----  EMPTY ----\r
2021  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = seven2n1n1n1n1n1n1n =  <cos(n*(2.*phi1+phi2+phi3-phi4-phi5-phi6-phi7))>\r
2022  // 30th bin:           ----  EMPTY ----\r
2023  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = eight1n1n1n1n1n1n1n1n = <cos(n*(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>\r
2024  // --------------------------------------------------------------------------------------------------------------------\r
2025     \r
2026  // 2-particle:\r
2027  Double_t two1n1n = 0.; // <cos(n*(phi1-phi2))>\r
2028  Double_t two2n2n = 0.; // <cos(2n*(phi1-phi2))>\r
2029  Double_t two3n3n = 0.; // <cos(3n*(phi1-phi2))>\r
2030  Double_t two4n4n = 0.; // <cos(4n*(phi1-phi2))>\r
2031  \r
2032  if(dMult>1)\r
2033  {\r
2034   two1n1n = (pow(dReQ1n,2.)+pow(dImQ1n,2.)-dMult)/(dMult*(dMult-1.)); \r
2035   two2n2n = (pow(dReQ2n,2.)+pow(dImQ2n,2.)-dMult)/(dMult*(dMult-1.)); \r
2036   two3n3n = (pow(dReQ3n,2.)+pow(dImQ3n,2.)-dMult)/(dMult*(dMult-1.)); \r
2037   two4n4n = (pow(dReQ4n,2.)+pow(dImQ4n,2.)-dMult)/(dMult*(dMult-1.)); \r
2038   \r
2039   // average 2-particle correlations for single event: \r
2040   fIntFlowCorrelationsAllEBE->SetBinContent(1,two1n1n);\r
2041   fIntFlowCorrelationsAllEBE->SetBinContent(2,two2n2n);\r
2042   fIntFlowCorrelationsAllEBE->SetBinContent(3,two3n3n);\r
2043   fIntFlowCorrelationsAllEBE->SetBinContent(4,two4n4n);\r
2044           \r
2045   // average 2-particle correlations for all events:      \r
2046   fIntFlowCorrelationsAllPro->Fill(0.5,two1n1n,dMult*(dMult-1.));  \r
2047   fIntFlowCorrelationsAllPro->Fill(1.5,two2n2n,dMult*(dMult-1.)); \r
2048   fIntFlowCorrelationsAllPro->Fill(2.5,two3n3n,dMult*(dMult-1.)); \r
2049   fIntFlowCorrelationsAllPro->Fill(3.5,two4n4n,dMult*(dMult-1.)); \r
2050   \r
2051   // store separetately <2> (to be improved: do I really need this?)\r
2052   fIntFlowCorrelationsEBE->SetBinContent(1,two1n1n); // <2>\r
2053   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(1,dMult*(dMult-1.)); // eW_<2>\r
2054   fIntFlowCorrelationsPro->Fill(0.5,two1n1n,dMult*(dMult-1.));\r
2055   \r
2056   // distribution of <cos(n*(phi1-phi2))>:\r
2057   //f2pDistribution->Fill(two1n1n,dMult*(dMult-1.)); \r
2058  } // end of if(dMult>1)\r
2059  \r
2060  // 3-particle:\r
2061  Double_t three2n1n1n = 0.; // <cos(n*(2.*phi1-phi2-phi3))>\r
2062  Double_t three3n2n1n = 0.; // <cos(n*(3.*phi1-2.*phi2-phi3))>\r
2063  Double_t three4n2n2n = 0.; // <cos(n*(4.*phi1-2.*phi2-2.*phi3))>\r
2064  Double_t three4n3n1n = 0.; // <cos(n*(4.*phi1-3.*phi2-phi3))>\r
2065  \r
2066  if(dMult>2)\r
2067  {\r
2068   three2n1n1n = (reQ2nQ1nstarQ1nstar-2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
2069               - (pow(dReQ2n,2.)+pow(dImQ2n,2.))+2.*dMult)\r
2070               / (dMult*(dMult-1.)*(dMult-2.));              \r
2071   three3n2n1n = (reQ3nQ2nstarQ1nstar-(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2072               - (pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
2073               - (pow(dReQ1n,2.)+pow(dImQ1n,2.))+2.*dMult)\r
2074               / (dMult*(dMult-1.)*(dMult-2.));\r
2075   three4n2n2n = (reQ4nQ2nstarQ2nstar-2.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
2076               - (pow(dReQ4n,2.)+pow(dImQ4n,2.))+2.*dMult)\r
2077               / (dMult*(dMult-1.)*(dMult-2.)); \r
2078   three4n3n1n = (reQ4nQ3nstarQ1nstar-(pow(dReQ4n,2.)+pow(dImQ4n,2.))\r
2079               - (pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2080               - (pow(dReQ1n,2.)+pow(dImQ1n,2.))+2.*dMult)\r
2081               / (dMult*(dMult-1.)*(dMult-2.)); \r
2082               \r
2083   // average 3-particle correlations for single event: \r
2084   fIntFlowCorrelationsAllEBE->SetBinContent(6,three2n1n1n);\r
2085   fIntFlowCorrelationsAllEBE->SetBinContent(7,three3n2n1n);\r
2086   fIntFlowCorrelationsAllEBE->SetBinContent(8,three4n2n2n);\r
2087   fIntFlowCorrelationsAllEBE->SetBinContent(9,three4n3n1n);\r
2088         \r
2089   // average 3-particle correlations for all events:                \r
2090   fIntFlowCorrelationsAllPro->Fill(5.5,three2n1n1n,dMult*(dMult-1.)*(dMult-2.)); \r
2091   fIntFlowCorrelationsAllPro->Fill(6.5,three3n2n1n,dMult*(dMult-1.)*(dMult-2.));\r
2092   fIntFlowCorrelationsAllPro->Fill(7.5,three4n2n2n,dMult*(dMult-1.)*(dMult-2.)); \r
2093   fIntFlowCorrelationsAllPro->Fill(8.5,three4n3n1n,dMult*(dMult-1.)*(dMult-2.));    \r
2094  } // end of if(dMult>2)\r
2095  \r
2096  // 4-particle:\r
2097  Double_t four1n1n1n1n = 0.; // <cos(n*(phi1+phi2-phi3-phi4))>\r
2098  Double_t four2n2n2n2n = 0.; // <cos(2.*n*(phi1+phi2-phi3-phi4))>\r
2099  Double_t four2n1n2n1n = 0.; // <cos(n*(2.*phi1+phi2-2.*phi3-phi4))> \r
2100  Double_t four3n1n1n1n = 0.; // <cos(n*(3.*phi1-phi2-phi3-phi4))> \r
2101  Double_t four4n2n1n1n = 0.; // <cos(n*(4.*phi1-2.*phi2-phi3-phi4))> \r
2102  Double_t four3n1n2n2n = 0.; // <cos(n*(3.*phi1+phi2-2.*phi3-2.*phi4))> \r
2103  Double_t four3n1n3n1n = 0.; // <cos(n*(3.*phi1+phi2-3.*phi3-phi4))>   \r
2104  \r
2105  if(dMult>3)\r
2106  {\r
2107   four1n1n1n1n = (2.*dMult*(dMult-3.)+pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)-4.*(dMult-2.)*(pow(dReQ1n,2.)\r
2108                + pow(dImQ1n,2.))-2.*reQ2nQ1nstarQ1nstar+(pow(dReQ2n,2.)+pow(dImQ2n,2.)))\r
2109                / (dMult*(dMult-1)*(dMult-2.)*(dMult-3.));     \r
2110   four2n2n2n2n = (2.*dMult*(dMult-3.)+pow((pow(dReQ2n,2.)+pow(dImQ2n,2.)),2.)-4.*(dMult-2.)*(pow(dReQ2n,2.)\r
2111                + pow(dImQ2n,2.))-2.*reQ4nQ2nstarQ2nstar+(pow(dReQ4n,2.)+pow(dImQ4n,2.)))\r
2112                / (dMult*(dMult-1)*(dMult-2.)*(dMult-3.));\r
2113   four2n1n2n1n = (dQ2nQ1nQ2nstarQ1nstar-2.*reQ3nQ2nstarQ1nstar-2.*reQ2nQ1nstarQ1nstar)\r
2114                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2115                - ((dMult-5.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
2116                + (dMult-4.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-(pow(dReQ3n,2.)+pow(dImQ3n,2.)))\r
2117                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2118                + (dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.));\r
2119   four3n1n1n1n = (reQ3nQ1nstarQ1nstarQ1nstar-3.*reQ3nQ2nstarQ1nstar-3.*reQ2nQ1nstarQ1nstar)\r
2120                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2121                + (2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+3.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
2122                + 6.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-6.*dMult)\r
2123                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2124   four4n2n1n1n = (reQ4nQ2nstarQ1nstarQ1nstar-2.*reQ4nQ3nstarQ1nstar-reQ4nQ2nstarQ2nstar-2.*reQ3nQ2nstarQ1nstar)\r
2125                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2126                - (reQ2nQ1nstarQ1nstar-2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))-2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2127                - 3.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2128                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2129                - 6./((dMult-1.)*(dMult-2.)*(dMult-3.));\r
2130   four3n1n2n2n = (reQ3nQ1nQ2nstarQ2nstar-reQ4nQ2nstarQ2nstar-reQ3nQ1nQ4nstar-2.*reQ3nQ2nstarQ1nstar)\r
2131                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2132                - (2.*reQ1nQ1nQ2nstar-(pow(dReQ4n,2.)+pow(dImQ4n,2.))-2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2133                - 4.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2134                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2135                - 6./((dMult-1.)*(dMult-2.)*(dMult-3.)); \r
2136   four3n1n3n1n = ((pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
2137                - 2.*reQ4nQ3nstarQ1nstar-2.*reQ3nQ2nstarQ1nstar)\r
2138                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2139                + ((pow(dReQ4n,2.)+pow(dImQ4n,2.))-(dMult-4.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2140                + (pow(dReQ2n,2.)+pow(dImQ2n,2.))-(dMult-4.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2141                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2142                + (dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.));\r
2143                \r
2144   // average 4-particle correlations for single event: \r
2145   fIntFlowCorrelationsAllEBE->SetBinContent(11,four1n1n1n1n);\r
2146   fIntFlowCorrelationsAllEBE->SetBinContent(12,four2n1n2n1n);\r
2147   fIntFlowCorrelationsAllEBE->SetBinContent(13,four2n2n2n2n);\r
2148   fIntFlowCorrelationsAllEBE->SetBinContent(14,four3n1n1n1n);\r
2149   fIntFlowCorrelationsAllEBE->SetBinContent(15,four3n1n3n1n);\r
2150   fIntFlowCorrelationsAllEBE->SetBinContent(16,four3n1n2n2n);\r
2151   fIntFlowCorrelationsAllEBE->SetBinContent(17,four4n2n1n1n);\r
2152         \r
2153   // average 4-particle correlations for all events:                \r
2154   fIntFlowCorrelationsAllPro->Fill(10.5,four1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2155   fIntFlowCorrelationsAllPro->Fill(11.5,four2n1n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2156   fIntFlowCorrelationsAllPro->Fill(12.5,four2n2n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2157   fIntFlowCorrelationsAllPro->Fill(13.5,four3n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2158   fIntFlowCorrelationsAllPro->Fill(14.5,four3n1n3n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2159   fIntFlowCorrelationsAllPro->Fill(15.5,four3n1n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));  \r
2160   fIntFlowCorrelationsAllPro->Fill(16.5,four4n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)); \r
2161   \r
2162   // store separetately <4> (to be improved: do I really need this?)\r
2163   fIntFlowCorrelationsEBE->SetBinContent(2,four1n1n1n1n); // <4>\r
2164   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(2,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)); // eW_<4>\r
2165   fIntFlowCorrelationsPro->Fill(1.5,four1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2166   \r
2167   // distribution of <cos(n*(phi1+phi2-phi3-phi4))>\r
2168   //f4pDistribution->Fill(four1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2169   \r
2170  } // end of if(dMult>3)\r
2171 \r
2172  // 5-particle:\r
2173  Double_t five2n1n1n1n1n = 0.; // <cos(n*(2.*phi1+phi2-phi3-phi4-phi5))>\r
2174  Double_t five2n2n2n1n1n = 0.; // <cos(n*(2.*phi1+2.*phi2-2.*phi3-phi4-phi5))>\r
2175  Double_t five3n1n2n1n1n = 0.; // <cos(n*(3.*phi1+phi2-2.*phi3-phi4-phi5))>\r
2176  Double_t five4n1n1n1n1n = 0.; // <cos(n*(4.*phi1-phi2-phi3-phi4-phi5))>\r
2177  \r
2178  if(dMult>4)\r
2179  {\r
2180   five2n1n1n1n1n = (reQ2nQ1nQ1nstarQ1nstarQ1nstar-reQ3nQ1nstarQ1nstarQ1nstar+6.*reQ3nQ2nstarQ1nstar)\r
2181                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2182                  - (reQ2nQ1nQ3nstar+3.*(dMult-6.)*reQ2nQ1nstarQ1nstar+3.*reQ1nQ1nQ2nstar)\r
2183                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2184                  - (2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2185                  + 3.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))     \r
2186                  - 3.*(dMult-4.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.)))\r
2187                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2188                  - 3.*(pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)\r
2189                  - 2.*(2*dMult-5.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))+2.*dMult*(dMult-4.))\r
2190                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2191                  \r
2192   five2n2n2n1n1n = (reQ2nQ2nQ2nstarQ1nstarQ1nstar-reQ4nQ2nstarQ1nstarQ1nstar-2.*reQ2nQ2nQ3nstarQ1nstar)\r
2193                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2194                  + 2.*(reQ4nQ2nstarQ2nstar+4.*reQ3nQ2nstarQ1nstar+reQ3nQ1nQ4nstar)\r
2195                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2196                  + (reQ2nQ2nQ4nstar-2.*(dMult-5.)*reQ2nQ1nstarQ1nstar+2.*reQ1nQ1nQ2nstar)\r
2197                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2198                  - (2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+4.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2199                  + 1.*pow((pow(dReQ2n,2.)+pow(dImQ2n,2.)),2.)\r
2200                  - 2.*(3.*dMult-10.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.)))\r
2201                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2202                  - (4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
2203                  - 4.*(dMult-5.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))+4.*dMult*(dMult-6.))\r
2204                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)); \r
2205 \r
2206   five4n1n1n1n1n = (reQ4nQ1nstarQ1nstarQ1nstarQ1nstar-6.*reQ4nQ2nstarQ1nstarQ1nstar-4.*reQ3nQ1nstarQ1nstarQ1nstar)\r
2207                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2208                  + (8.*reQ4nQ3nstarQ1nstar+3.*reQ4nQ2nstarQ2nstar+12.*reQ3nQ2nstarQ1nstar+12.*reQ2nQ1nstarQ1nstar)\r
2209                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2210                  - (6.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+8.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2211                  + 12.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))+24.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-24.*dMult)\r
2212                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2213   \r
2214   five3n1n2n1n1n = (reQ3nQ1nQ2nstarQ1nstarQ1nstar-reQ4nQ2nstarQ1nstarQ1nstar-reQ3nQ1nstarQ1nstarQ1nstar)\r
2215                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2216                  - (reQ3nQ1nQ2nstarQ2nstar-3.*reQ4nQ3nstarQ1nstar-reQ4nQ2nstarQ2nstar)\r
2217                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2218                  - ((2.*dMult-13.)*reQ3nQ2nstarQ1nstar-reQ3nQ1nQ4nstar-9.*reQ2nQ1nstarQ1nstar)\r
2219                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2220                  - (2.*reQ1nQ1nQ2nstar+2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))\r
2221                  - 2.*(dMult-5.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+2.*(pow(dReQ3n,2.)\r
2222                  + pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2223                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2224                  + (2.*(dMult-6.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
2225                  - 2.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
2226                  - pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)\r
2227                  + 2.*(3.*dMult-11.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2228                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2229                  - 4.*(dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2230                  \r
2231   // average 5-particle correlations for single event: \r
2232   fIntFlowCorrelationsAllEBE->SetBinContent(19,five2n1n1n1n1n);\r
2233   fIntFlowCorrelationsAllEBE->SetBinContent(20,five2n2n2n1n1n);\r
2234   fIntFlowCorrelationsAllEBE->SetBinContent(21,five3n1n2n1n1n);\r
2235   fIntFlowCorrelationsAllEBE->SetBinContent(22,five4n1n1n1n1n);\r
2236         \r
2237   // average 5-particle correlations for all events:                         \r
2238   fIntFlowCorrelationsAllPro->Fill(18.5,five2n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)); \r
2239   fIntFlowCorrelationsAllPro->Fill(19.5,five2n2n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2240   fIntFlowCorrelationsAllPro->Fill(20.5,five3n1n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2241   fIntFlowCorrelationsAllPro->Fill(21.5,five4n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2242  } // end of if(dMult>4)\r
2243     \r
2244  // 6-particle:\r
2245  Double_t six1n1n1n1n1n1n = 0.; // <cos(n*(phi1+phi2+phi3-phi4-phi5-phi6))>\r
2246  Double_t six2n2n1n1n1n1n = 0.; // <cos(n*(2.*phi1+2.*phi2-phi3-phi4-phi5-phi6))>\r
2247  Double_t six3n1n1n1n1n1n = 0.; // <cos(n*(3.*phi1+phi2-phi3-phi4-phi5-phi6))>\r
2248  Double_t six2n1n1n2n1n1n = 0.; // <cos(n*(2.*phi1+phi2+phi3-2.*phi4-phi5-phi6))>\r
2249  \r
2250  if(dMult>5)\r
2251  {\r
2252   six1n1n1n1n1n1n = (pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),3.)+9.*dQ2nQ1nQ2nstarQ1nstar-6.*reQ2nQ1nQ1nstarQ1nstarQ1nstar)\r
2253                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.))\r
2254                   + 4.*(reQ3nQ1nstarQ1nstarQ1nstar-3.*reQ3nQ2nstarQ1nstar)\r
2255                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.))\r
2256                   + 2.*(9.*(dMult-4.)*reQ2nQ1nstarQ1nstar+2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.)))\r
2257                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.))\r
2258                   - 9.*(pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)+(pow(dReQ2n,2.)+pow(dImQ2n,2.)))\r
2259                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-5.))\r
2260                   + (18.*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2261                   / (dMult*(dMult-1)*(dMult-3)*(dMult-4))\r
2262                   - 6./((dMult-1.)*(dMult-2.)*(dMult-3.));\r
2263                   \r
2264   six2n1n1n2n1n1n = (dQ2nQ1nQ1nQ2nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)\r
2265                   * (2.*five2n2n2n1n1n+4.*five2n1n1n1n1n+4.*five3n1n2n1n1n+4.*four2n1n2n1n+1.*four1n1n1n1n)\r
2266                   - dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(4.*four1n1n1n1n+4.*two1n1n\r
2267                   + 2.*three2n1n1n+2.*three2n1n1n+4.*four3n1n1n1n+8.*three2n1n1n+2.*four4n2n1n1n\r
2268                   + 4.*four2n1n2n1n+2.*two2n2n+8.*four2n1n2n1n+4.*four3n1n3n1n+8.*three3n2n1n\r
2269                   + 4.*four3n1n2n2n+4.*four1n1n1n1n+4.*four2n1n2n1n+1.*four2n2n2n2n)\r
2270                   - dMult*(dMult-1.)*(dMult-2.)*(2.*three2n1n1n+8.*two1n1n+4.*two1n1n+2.\r
2271                   + 4.*two1n1n+4.*three2n1n1n+2.*two2n2n+4.*three2n1n1n+8.*three3n2n1n\r
2272                   + 8.*two2n2n+4.*three4n3n1n+4.*two3n3n+4.*three3n2n1n+4.*two1n1n\r
2273                   + 8.*three2n1n1n+4.*two1n1n+4.*three3n2n1n+4.*three2n1n1n+2.*two2n2n\r
2274                   + 4.*three3n2n1n+2.*three4n2n2n)-dMult*(dMult-1.)\r
2275                   * (4.*two1n1n+4.+4.*two1n1n+2.*two2n2n+1.+4.*two1n1n+4.*two2n2n+4.*two3n3n\r
2276                   + 1.+2.*two2n2n+1.*two4n4n)-dMult)\r
2277                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); // to be improved (direct formula needed)\r
2278  \r
2279   six2n2n1n1n1n1n = (reQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)\r
2280                   * (five4n1n1n1n1n+8.*five2n1n1n1n1n+6.*five2n2n2n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)\r
2281                   * (4.*four3n1n1n1n+6.*four4n2n1n1n+12.*three2n1n1n+12.*four1n1n1n1n+24.*four2n1n2n1n\r
2282                   + 4.*four3n1n2n2n+3.*four2n2n2n2n)-dMult*(dMult-1.)*(dMult-2.)*(6.*three2n1n1n+12.*three3n2n1n\r
2283                   + 4.*three4n3n1n+3.*three4n2n2n+8.*three2n1n1n+24.*two1n1n+12.*two2n2n+12.*three2n1n1n+8.*three3n2n1n\r
2284                   + 1.*three4n2n2n)-dMult*(dMult-1.)*(4.*two1n1n+6.*two2n2n+4.*two3n3n+1.*two4n4n+2.*two2n2n+8.*two1n1n+6.)-dMult)\r
2285                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); // to be improved (direct formula needed)\r
2286    \r
2287   six3n1n1n1n1n1n = (reQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)\r
2288                   * (five4n1n1n1n1n+4.*five2n1n1n1n1n+6.*five3n1n2n1n1n+4.*four3n1n1n1n)\r
2289                   - dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(4.*four3n1n1n1n+6.*four4n2n1n1n+6.*four1n1n1n1n\r
2290                   + 12.*three2n1n1n+12.*four2n1n2n1n+6.*four3n1n1n1n+12.*three3n2n1n+4.*four3n1n3n1n+3.*four3n1n2n2n)\r
2291                   - dMult*(dMult-1.)*(dMult-2.)*(6.*three2n1n1n+12.*three3n2n1n+4.*three4n3n1n+3.*three4n2n2n+4.*two1n1n\r
2292                   + 12.*two1n1n+6.*three2n1n1n+12.*three2n1n1n+4.*three3n2n1n+12.*two2n2n+4.*three3n2n1n+4.*two3n3n+1.*three4n3n1n\r
2293                   + 6.*three3n2n1n)-dMult*(dMult-1.)*(4.*two1n1n+6.*two2n2n+4.*two3n3n+1.*two4n4n+1.*two1n1n+4.+6.*two1n1n+4.*two2n2n\r
2294                   + 1.*two3n3n)-dMult)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); // to be improved (direct formula needed)\r
2295                                  \r
2296   // average 6-particle correlations for single event: \r
2297   fIntFlowCorrelationsAllEBE->SetBinContent(24,six1n1n1n1n1n1n);\r
2298   fIntFlowCorrelationsAllEBE->SetBinContent(25,six2n1n1n2n1n1n);\r
2299   fIntFlowCorrelationsAllEBE->SetBinContent(26,six2n2n1n1n1n1n);\r
2300   fIntFlowCorrelationsAllEBE->SetBinContent(27,six3n1n1n1n1n1n);\r
2301         \r
2302   // average 6-particle correlations for all events:         \r
2303   fIntFlowCorrelationsAllPro->Fill(23.5,six1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); \r
2304   fIntFlowCorrelationsAllPro->Fill(24.5,six2n1n1n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); \r
2305   fIntFlowCorrelationsAllPro->Fill(25.5,six2n2n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));\r
2306   fIntFlowCorrelationsAllPro->Fill(26.5,six3n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); \r
2307 \r
2308   // store separetately <6> (to be improved: do I really need this?)\r
2309   fIntFlowCorrelationsEBE->SetBinContent(3,six1n1n1n1n1n1n); // <6>\r
2310   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(3,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); // eW_<6>\r
2311   fIntFlowCorrelationsPro->Fill(2.5,six1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));\r
2312  \r
2313   // distribution of <cos(n*(phi1+phi2+phi3-phi4-phi5-phi6))>\r
2314   //f6pDistribution->Fill(six1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); \r
2315  } // end of if(dMult>5)\r
2316  \r
2317  // 7-particle:\r
2318  Double_t seven2n1n1n1n1n1n1n = 0.; // <cos(n*(2.*phi1+phi2+phi3-phi4-phi5-phi6-phi7))>\r
2319  \r
2320  if(dMult>6)\r
2321  {\r
2322   seven2n1n1n1n1n1n1n = (reQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)\r
2323                       * (2.*six3n1n1n1n1n1n+4.*six1n1n1n1n1n1n+1.*six2n2n1n1n1n1n+6.*six2n1n1n2n1n1n+8.*five2n1n1n1n1n)\r
2324                       - dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(1.*five4n1n1n1n1n +8.*five2n1n1n1n1n+8.*four3n1n1n1n\r
2325                       + 12.*five3n1n2n1n1n+4.*five2n1n1n1n1n+3.*five2n2n2n1n1n+6.*five2n2n2n1n1n+6.*four1n1n1n1n+24.*four1n1n1n1n\r
2326                       + 12.*five2n1n1n1n1n+12.*five2n1n1n1n1n+12.*three2n1n1n+24.*four2n1n2n1n+4.*five3n1n2n1n1n+4.*five2n1n1n1n1n)\r
2327                       - dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(4.*four3n1n1n1n+6.*four4n2n1n1n+12.*four1n1n1n1n+24.*three2n1n1n\r
2328                       + 24.*four2n1n2n1n+12.*four3n1n1n1n+24.*three3n2n1n+8.*four3n1n3n1n+6.*four3n1n2n2n+6.*three2n1n1n+12.*four1n1n1n1n\r
2329                       + 12.*four2n1n2n1n+6.*three2n1n1n+12.*four2n1n2n1n+4.*four3n1n2n2n+3.*four2n2n2n2n+4.*four1n1n1n1n+6.*three2n1n1n\r
2330                       + 24.*two1n1n+24.*four1n1n1n1n+4.*four3n1n1n1n+24.*two1n1n+24.*three2n1n1n+12.*two2n2n+24.*three2n1n1n+12.*four2n1n2n1n\r
2331                       + 8.*three3n2n1n+8.*four2n1n2n1n+1.*four4n2n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(6.*three2n1n1n+1.*three2n1n1n+8.*two1n1n\r
2332                       + 12.*three3n2n1n+24.*two1n1n+12.*three2n1n1n+4.*three2n1n1n+8.*two1n1n+4.*three4n3n1n+24.*three2n1n1n+8.*three3n2n1n\r
2333                       + 12.*two1n1n+12.*two1n1n+3.*three4n2n2n+24.*two2n2n+6.*two2n2n+12.+12.*three3n2n1n+8.*two3n3n+12.*three2n1n1n+24.*two1n1n\r
2334                       + 4.*three3n2n1n+8.*three3n2n1n+2.*three4n3n1n+12.*two1n1n+8.*three2n1n1n+4.*three2n1n1n+2.*three3n2n1n+6.*two2n2n+8.*two2n2n\r
2335                       + 1.*three4n2n2n+4.*three3n2n1n+6.*three2n1n1n)-dMult*(dMult-1.)*(4.*two1n1n+2.*two1n1n+6.*two2n2n+8.+1.*two2n2n+4.*two3n3n\r
2336                       + 12.*two1n1n+4.*two1n1n+1.*two4n4n+8.*two2n2n+6.+2.*two3n3n+4.*two1n1n+1.*two2n2n)-dMult)\r
2337                       / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)); // to be improved (direct formula needed)\r
2338         \r
2339   // average 7-particle correlations for single event: \r
2340   fIntFlowCorrelationsAllEBE->SetBinContent(29,seven2n1n1n1n1n1n1n);\r
2341        \r
2342   // average 7-particle correlations for all events:                      \r
2343   fIntFlowCorrelationsAllPro->Fill(28.5,seven2n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.));\r
2344  } // end of if(dMult>6)\r
2345  \r
2346  // 8-particle:\r
2347  Double_t eight1n1n1n1n1n1n1n1n = 0.; // <cos(n*(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>\r
2348  if(dMult>7)\r
2349  {\r
2350   eight1n1n1n1n1n1n1n1n = (pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),4.)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)\r
2351                         * (12.*seven2n1n1n1n1n1n1n+16.*six1n1n1n1n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)\r
2352                         * (8.*six3n1n1n1n1n1n+48.*six1n1n1n1n1n1n+6.*six2n2n1n1n1n1n+96.*five2n1n1n1n1n+72.*four1n1n1n1n+36.*six2n1n1n2n1n1n)\r
2353                         - dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(2.*five4n1n1n1n1n+32.*five2n1n1n1n1n+36.*four1n1n1n1n\r
2354                         + 32.*four3n1n1n1n+48.*five2n1n1n1n1n+48.*five3n1n2n1n1n+144.*five2n1n1n1n1n+288.*four1n1n1n1n+36.*five2n2n2n1n1n\r
2355                         + 144.*three2n1n1n+96.*two1n1n+144.*four2n1n2n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)\r
2356                         * (8.*four3n1n1n1n+48.*four1n1n1n1n+12.*four4n2n1n1n+96.*four2n1n2n1n+96.*three2n1n1n+72.*three2n1n1n+144.*two1n1n\r
2357                         + 16.*four3n1n3n1n+48.*four3n1n1n1n+144.*four1n1n1n1n+72.*four1n1n1n1n+96.*three3n2n1n+24.*four3n1n2n2n+144.*four2n1n2n1n\r
2358                         + 288.*two1n1n+288.*three2n1n1n+9.*four2n2n2n2n+72.*two2n2n+24.)-dMult*(dMult-1.)*(dMult-2.)*(12.*three2n1n1n+16.*two1n1n\r
2359                         + 24.*three3n2n1n+48.*three2n1n1n+96.*two1n1n+8.*three4n3n1n+32.*three3n2n1n+96.*three2n1n1n+144.*two1n1n+6.*three4n2n2n\r
2360                         + 96.*two2n2n+36.*two2n2n+72.+48.*three3n2n1n+16.*two3n3n+72.*three2n1n1n+144.*two1n1n)-dMult*(dMult-1.)*(8.*two1n1n\r
2361                         + 12.*two2n2n+16.+8.*two3n3n+48.*two1n1n+1.*two4n4n+16.*two2n2n+18.)-dMult)\r
2362                         / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.)); // to be improved (direct formula needed)\r
2363   \r
2364   // average 8-particle correlations for single event: \r
2365   fIntFlowCorrelationsAllEBE->SetBinContent(31,eight1n1n1n1n1n1n1n1n);\r
2366        \r
2367   // average 8-particle correlations for all events:                       \r
2368   fIntFlowCorrelationsAllPro->Fill(30.5,eight1n1n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));\r
2369  \r
2370   // store separetately <8> (to be improved: do I really need this?)\r
2371   fIntFlowCorrelationsEBE->SetBinContent(4,eight1n1n1n1n1n1n1n1n); // <8>\r
2372   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(4,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.)); // eW_<8>\r
2373   fIntFlowCorrelationsPro->Fill(3.5,eight1n1n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));\r
2374   \r
2375   // distribution of <cos(n*(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>\r
2376   //f8pDistribution->Fill(eight1n1n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));\r
2377  } // end of if(dMult>7) \r
2378  \r
2379 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelations()\r
2380 \r
2381 \r
2382 //================================================================================================================================\r
2383 \r
2384 \r
2385 void AliFlowAnalysisWithQCumulants::CalculateIntFlowProductOfCorrelations()\r
2386 {\r
2387  // Calculate averages of products of correlations for integrated flow  // to be improved (this method can be implemented better)\r
2388  \r
2389  // a) Binning of fIntFlowProductOfCorrelationsPro is organized as follows:\r
2390  //     1st bin: <<2><4>> \r
2391  //     2nd bin: <<2><6>>\r
2392  //     3rd bin: <<2><8>>\r
2393  //     4th bin: <<4><6>>\r
2394  //     5th bin: <<4><8>>\r
2395  //     6th bin: <<6><8>>\r
2396 \r
2397  /*\r
2398  Double_t dMult = (*fSMpk)(0,0); // multiplicity \r
2399 \r
2400  Double_t twoEBE = fIntFlowCorrelationsEBE->GetBinContent(1); // <2>\r
2401  Double_t fourEBE = fIntFlowCorrelationsEBE->GetBinContent(2); // <4>\r
2402  Double_t sixEBE = fIntFlowCorrelationsEBE->GetBinContent(3); // <6>\r
2403  Double_t eightEBE = fIntFlowCorrelationsEBE->GetBinContent(4); // <8>\r
2404  \r
2405  Double_t eW2 = 0.; // event weight for <2>\r
2406  Double_t eW4 = 0.; // event weight for <4>\r
2407  Double_t eW6 = 0.; // event weight for <6>\r
2408  Double_t eW8 = 0.; // event weight for <8>\r
2409  \r
2410  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
2411  {\r
2412   eW2 = dMult*(dMult-1);\r
2413   eW4 = dMult*(dMult-1)*(dMult-2)*(dMult-3);\r
2414   eW6 = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5);\r
2415   eW8 = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5)*(dMult-6)*(dMult-7);\r
2416  } else \r
2417    {\r
2418     eW2 = (*fSMpk)(1,1)-(*fSMpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j;\r
2419     eW4 = (*fSMpk)(3,1)-6.*(*fSMpk)(0,2)*(*fSMpk)(1,1)  \r
2420         + 8.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
2421         + 3.*(*fSMpk)(1,2)-6.*(*fSMpk)(0,4); // dM1111 = sum_{i,j,k,l=1,i!=j!=k!=l}^M w_i w_j w_k w_l\r
2422    }\r
2423   \r
2424  fIntFlowProductOfCorrelationsPro->Fill(0.5,twoEBE*fourEBE,eW2*eW4); // <<2><4>> \r
2425  fIntFlowProductOfCorrelationsPro->Fill(1.5,twoEBE*sixEBE,eW2*eW6); // <<2><6>>\r
2426  fIntFlowProductOfCorrelationsPro->Fill(2.5,twoEBE*eightEBE,eW2*eW8); // <<2><8>>\r
2427  fIntFlowProductOfCorrelationsPro->Fill(3.5,fourEBE*sixEBE,eW4*eW6); // <<4><6>>\r
2428  fIntFlowProductOfCorrelationsPro->Fill(4.5,fourEBE*eightEBE,eW4*eW8); // <<4><8>>\r
2429  fIntFlowProductOfCorrelationsPro->Fill(5.5,sixEBE*eightEBE,eW6*eW8); // <<6><8>>\r
2430  */\r
2431  \r
2432  \r
2433  Int_t counter = 0;\r
2434  \r
2435  for(Int_t ci1=1;ci1<4;ci1++)\r
2436  {\r
2437   for(Int_t ci2=ci1+1;ci2<=4;ci2++)\r
2438   {\r
2439    fIntFlowProductOfCorrelationsPro->Fill(0.5+counter++,\r
2440                                           fIntFlowCorrelationsEBE->GetBinContent(ci1)*fIntFlowCorrelationsEBE->GetBinContent(ci2),\r
2441                                           fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci1)*fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci2));\r
2442   }\r
2443  }\r
2444  \r
2445 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowProductOfCorrelations()\r
2446 \r
2447 \r
2448 //================================================================================================================================\r
2449 \r
2450 \r
2451 void AliFlowAnalysisWithQCumulants::CalculateCovariancesIntFlow()\r
2452 {\r
2453  // a) Calculate unbiased estimators Cov(<2>,<4>), Cov(<2>,<6>), Cov(<2>,<8>), Cov(<4>,<6>), Cov(<4>,<8>) and Cov(<6>,<8>)\r
2454  //    for covariances V_(<2>,<4>), V_(<2>,<6>), V_(<2>,<8>), V_(<4>,<6>), V_(<4>,<8>) and V_(<6>,<8>).\r
2455  // b) Store in histogram fIntFlowCovariances for instance the following: \r
2456  //\r
2457  //             Cov(<2>,<4>) * (sum_{i=1}^{N} w_{<2>}_i w_{<4>}_i )/[(sum_{i=1}^{N} w_{<2>}_i) * (sum_{j=1}^{N} w_{<4>}_j)]\r
2458  // \r
2459  //    where N is the number of events, w_{<2>} is event weight for <2> and w_{<4>} is event weight for <4>.\r
2460  // c) Binning of fIntFlowCovariances is organized as follows:\r
2461  // \r
2462  //     1st bin: Cov(<2>,<4>) * (sum_{i=1}^{N} w_{<2>}_i w_{<4>}_i )/[(sum_{i=1}^{N} w_{<2>}_i) * (sum_{j=1}^{N} w_{<4>}_j)] \r
2463  //     2nd bin: Cov(<2>,<6>) * (sum_{i=1}^{N} w_{<2>}_i w_{<6>}_i )/[(sum_{i=1}^{N} w_{<2>}_i) * (sum_{j=1}^{N} w_{<6>}_j)]\r
2464  //     3rd bin: Cov(<2>,<8>) * (sum_{i=1}^{N} w_{<2>}_i w_{<8>}_i )/[(sum_{i=1}^{N} w_{<2>}_i) * (sum_{j=1}^{N} w_{<8>}_j)]\r
2465  //     4th bin: Cov(<4>,<6>) * (sum_{i=1}^{N} w_{<4>}_i w_{<6>}_i )/[(sum_{i=1}^{N} w_{<4>}_i) * (sum_{j=1}^{N} w_{<6>}_j)]\r
2466  //     5th bin: Cov(<4>,<8>) * (sum_{i=1}^{N} w_{<4>}_i w_{<8>}_i )/[(sum_{i=1}^{N} w_{<4>}_i) * (sum_{j=1}^{N} w_{<8>}_j)]\r
2467  //     6th bin: Cov(<6>,<8>) * (sum_{i=1}^{N} w_{<6>}_i w_{<8>}_i )/[(sum_{i=1}^{N} w_{<6>}_i) * (sum_{j=1}^{N} w_{<8>}_j)]\r
2468     \r
2469  for(Int_t power=0;power<2;power++)\r
2470  { \r
2471   if(!(fIntFlowCorrelationsPro && fIntFlowProductOfCorrelationsPro \r
2472        && fIntFlowSumOfEventWeights[power] && fIntFlowSumOfProductOfEventWeights\r
2473        && fIntFlowCovariances)) \r
2474   {\r
2475    cout<<"WARNING: fIntFlowCorrelationsPro && fIntFlowProductOfCorrelationsPro "<<endl;\r
2476    cout<<"         && fIntFlowSumOfEventWeights[power] && fIntFlowSumOfProductOfEventWeights"<<endl;\r
2477    cout<<"         && fIntFlowCovariances is NULL in AFAWQC::FCIF() !!!!"<<endl;\r
2478    cout<<"power = "<<power<<endl;\r
2479    exit(0);\r
2480   }\r
2481  }\r
2482    \r
2483  // average 2-, 4-, 6- and 8-particle correlations for all events:\r
2484  Double_t correlation[4] = {0.};\r
2485  for(Int_t ci=0;ci<4;ci++)\r
2486  {\r
2487   correlation[ci] = fIntFlowCorrelationsPro->GetBinContent(ci+1);\r
2488  } \r
2489  // average products of 2-, 4-, 6- and 8-particle correlations: \r
2490  Double_t productOfCorrelations[4][4] = {{0.}};\r
2491  Int_t productOfCorrelationsLabel = 1;\r
2492  // denominators in the expressions for the unbiased estimator for covariance:\r
2493  Double_t denominator[4][4] = {{0.}};\r
2494  Int_t sumOfProductOfEventWeightsLabel1 = 1;\r
2495  // weight dependent prefactor which multiply unbiased estimators for covariances:\r
2496  Double_t wPrefactor[4][4] = {{0.}}; \r
2497  Int_t sumOfProductOfEventWeightsLabel2 = 1;\r
2498  for(Int_t c1=0;c1<4;c1++)\r
2499  {\r
2500   for(Int_t c2=c1+1;c2<4;c2++)\r
2501   {\r
2502    productOfCorrelations[c1][c2] = fIntFlowProductOfCorrelationsPro->GetBinContent(productOfCorrelationsLabel);\r
2503    if(fIntFlowSumOfEventWeights[0]->GetBinContent(c1+1) && fIntFlowSumOfEventWeights[0]->GetBinContent(c2+1))\r
2504    {\r
2505     denominator[c1][c2] = 1.-(fIntFlowSumOfProductOfEventWeights->GetBinContent(sumOfProductOfEventWeightsLabel1))/\r
2506                              (fIntFlowSumOfEventWeights[0]->GetBinContent(c1+1) \r
2507                               * fIntFlowSumOfEventWeights[0]->GetBinContent(c2+1));\r
2508                               \r
2509     wPrefactor[c1][c2] =  fIntFlowSumOfProductOfEventWeights->GetBinContent(sumOfProductOfEventWeightsLabel2)/ \r
2510                           (fIntFlowSumOfEventWeights[0]->GetBinContent(c1+1)\r
2511                             * fIntFlowSumOfEventWeights[0]->GetBinContent(c2+1));\r
2512                           \r
2513                               \r
2514    }\r
2515    productOfCorrelationsLabel++;\r
2516    sumOfProductOfEventWeightsLabel1++;\r
2517    sumOfProductOfEventWeightsLabel2++;  \r
2518   }\r
2519  }\r
2520  \r
2521  // covariance label:\r
2522  Int_t covarianceLabel = 1;\r
2523  for(Int_t c1=0;c1<4;c1++)\r
2524  {\r
2525   for(Int_t c2=c1+1;c2<4;c2++)\r
2526   {\r
2527    if(denominator[c1][c2])\r
2528    {\r
2529     // covariances:\r
2530     Double_t cov = (productOfCorrelations[c1][c2]-correlation[c1]*correlation[c2])/denominator[c1][c2]; \r
2531     // covarianced multiplied with weight dependent prefactor:\r
2532     Double_t wCov = cov * wPrefactor[c1][c2];\r
2533     fIntFlowCovariances->SetBinContent(covarianceLabel,wCov);\r
2534    }\r
2535    covarianceLabel++;\r
2536   }\r
2537  }\r
2538  \r
2539 } // end of AliFlowAnalysisWithQCumulants::CalculateCovariancesIntFlow()\r
2540 \r
2541 \r
2542 //================================================================================================================================\r
2543 \r
2544 \r
2545 void AliFlowAnalysisWithQCumulants::FinalizeCorrelationsIntFlow() \r
2546 {\r
2547  // From profile fIntFlowCorrelationsPro access measured correlations and spread, \r
2548  // correctly calculate the statistical errors and store the final results and \r
2549  // statistical errors for correlations in histogram fIntFlowCorrelationsHist.\r
2550  //\r
2551  // Remark: Statistical error of correlation is calculated as:\r
2552  //\r
2553  //          statistical error = termA * spread * termB:\r
2554  //          termA = sqrt{sum_{i=1}^{N} w^2}/(sum_{i=1}^{N} w)\r
2555  //          termB = 1/sqrt(1-termA^2)   \r
2556  \r
2557  for(Int_t power=0;power<2;power++)\r
2558  { \r
2559   if(!(fIntFlowCorrelationsHist && fIntFlowCorrelationsPro && fIntFlowSumOfEventWeights[power])) \r
2560   {\r
2561    cout<<"WARNING: fIntFlowCorrelationsHist && fIntFlowCorrelationsPro && fIntFlowSumOfEventWeights[power] is NULL in AFAWQC::FCIF() !!!!"<<endl;\r
2562    cout<<"power = "<<power<<endl;\r
2563    exit(0);\r
2564   }\r
2565  }\r
2566   \r
2567  for(Int_t ci=1;ci<=4;ci++) // correlation index\r
2568  {\r
2569   Double_t correlation = fIntFlowCorrelationsPro->GetBinContent(ci);\r
2570   Double_t spread = fIntFlowCorrelationsPro->GetBinError(ci);\r
2571   Double_t sumOfLinearEventWeights = fIntFlowSumOfEventWeights[0]->GetBinContent(ci);\r
2572   Double_t sumOfQuadraticEventWeights = fIntFlowSumOfEventWeights[1]->GetBinContent(ci);\r
2573   Double_t termA = 0.;\r
2574   Double_t termB = 0.;\r
2575   if(sumOfLinearEventWeights)\r
2576   {\r
2577    termA = pow(sumOfQuadraticEventWeights,0.5)/sumOfLinearEventWeights;\r
2578   } else\r
2579     {\r
2580      cout<<"WARNING: sumOfLinearEventWeights == 0 in AFAWQC::FCIF() !!!!"<<endl;\r
2581      cout<<"         (for "<<2*ci<<"-particle correlation)"<<endl;\r
2582     }\r
2583   if(1.-pow(termA,2.) > 0.)\r
2584   {\r
2585    termB = 1./pow(1-pow(termA,2.),0.5);\r
2586   } else\r
2587     {\r
2588      cout<<"WARNING: 1.-pow(termA,2.) <= 0 in AFAWQC::FCIF() !!!!"<<endl;   \r
2589      cout<<"         (for "<<2*ci<<"-particle correlation)"<<endl;\r
2590     }     \r
2591   Double_t statisticalError = termA * spread * termB;\r
2592   fIntFlowCorrelationsHist->SetBinContent(ci,correlation);\r
2593   fIntFlowCorrelationsHist->SetBinError(ci,statisticalError);\r
2594  } // end of for(Int_t ci=1;ci<=4;ci++) // correlation index                                                                \r
2595                                                                                                                               \r
2596 } // end of AliFlowAnalysisWithQCumulants::FinalizeCorrelationsIntFlow()\r
2597 \r
2598 \r
2599 //================================================================================================================================\r
2600 \r
2601 \r
2602 void AliFlowAnalysisWithQCumulants::FillAverageMultiplicities(Int_t nRP)\r
2603 {\r
2604  // Fill profile fAverageMultiplicity to hold average multiplicities and number of events for events with nRP>=0, nRP>=1, ... , and nRP>=8\r
2605  \r
2606  // Binning of fAverageMultiplicity is organized as follows:\r
2607  //  1st bin: all events (including the empty ones)\r
2608  //  2nd bin: event with # of RPs greater or equal to 1\r
2609  //  3rd bin: event with # of RPs greater or equal to 2\r
2610  //  4th bin: event with # of RPs greater or equal to 3\r
2611  //  5th bin: event with # of RPs greater or equal to 4\r
2612  //  6th bin: event with # of RPs greater or equal to 5\r
2613  //  7th bin: event with # of RPs greater or equal to 6\r
2614  //  8th bin: event with # of RPs greater or equal to 7\r
2615  //  9th bin: event with # of RPs greater or equal to 8\r
2616  \r
2617  if(!fAvMultiplicity)\r
2618  {\r
2619   cout<<"WARNING: fAvMultiplicity is NULL in AFAWQC::FAM() !!!!"<<endl;\r
2620   exit(0);\r
2621  }\r
2622  \r
2623  if(nRP<0)\r
2624  {\r
2625   cout<<"WARNING: nRP<0 in in AFAWQC::FAM() !!!!"<<endl;\r
2626   exit(0);\r
2627  }\r
2628  \r
2629  for(Int_t i=0;i<9;i++)\r
2630  {\r
2631   if(nRP>=i) fAvMultiplicity->Fill(i+0.5,nRP,1);\r
2632  }\r
2633  \r
2634 } // end of AliFlowAnalysisWithQCumulants::FillAverageMultiplicities(nRP)\r
2635 \r
2636 \r
2637 //================================================================================================================================\r
2638 \r
2639 \r
2640 void AliFlowAnalysisWithQCumulants::CalculateCumulantsIntFlow()\r
2641 {\r
2642  // a) Calculate Q-cumulants from the measured multiparticle correlations.\r
2643  // b) Propagate the statistical errors of measured multiparticle correlations to statistical errors of Q-cumulants.  \r
2644  // c) REMARK: Q-cumulants calculated in this method are biased by non-uniform acceptance of detector !!!! \r
2645  //            Method ApplyCorrectionForNonUniformAcceptance* (to be improved: finalize the name here)\r
2646  //            is called afterwards to correct for this bias.   \r
2647  // d) Store the results and statistical error of Q-cumulants in histogram fCumulants.\r
2648  //    Binning of fCumulants is organized as follows:\r
2649  //\r
2650  //     1st bin: QC{2}\r
2651  //     2nd bin: QC{4}\r
2652  //     3rd bin: QC{6}\r
2653  //     4th bin: QC{8}\r
2654  \r
2655  if(!(fIntFlowCorrelationsHist && fIntFlowCovariances && fIntFlowQcumulants))\r
2656  {\r
2657   cout<<"WARNING: fIntFlowCorrelationsHist && fIntFlowCovariances && fIntFlowQcumulants is NULL in AFAWQC::CCIF() !!!!"<<endl;\r
2658   exit(0);\r
2659  }\r
2660  \r
2661  // correlations:\r
2662  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>> \r
2663  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>  \r
2664  Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>> \r
2665  Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>  \r
2666  \r
2667  // statistical errors of average 2-, 4-, 6- and 8-particle azimuthal correlations:\r
2668  Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1); // statistical error of <2>  \r
2669  Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2); // statistical error of <4>   \r
2670  Double_t sixError = fIntFlowCorrelationsHist->GetBinError(3); // statistical error of <6> \r
2671  Double_t eightError = fIntFlowCorrelationsHist->GetBinError(4); // statistical error of <8> \r
2672  \r
2673  // covariances (multiplied by prefactor depending on weights - see comments in CalculateCovariancesIntFlow()):\r
2674  Double_t wCov24 = fIntFlowCovariances->GetBinContent(1); // Cov(<2>,<4>) * prefactor(w_<2>,w_<4>)\r
2675  Double_t wCov26 = fIntFlowCovariances->GetBinContent(2); // Cov(<2>,<6>) * prefactor(w_<2>,w_<6>)\r
2676  Double_t wCov28 = fIntFlowCovariances->GetBinContent(3); // Cov(<2>,<8>) * prefactor(w_<2>,w_<8>)\r
2677  Double_t wCov46 = fIntFlowCovariances->GetBinContent(4); // Cov(<4>,<6>) * prefactor(w_<4>,w_<6>)\r
2678  Double_t wCov48 = fIntFlowCovariances->GetBinContent(5); // Cov(<4>,<8>) * prefactor(w_<4>,w_<8>)\r
2679  Double_t wCov68 = fIntFlowCovariances->GetBinContent(6); // Cov(<6>,<8>) * prefactor(w_<6>,w_<8>)\r
2680  \r
2681  // Q-cumulants: \r
2682  Double_t qc2 = 0.; // QC{2}\r
2683  Double_t qc4 = 0.; // QC{4}\r
2684  Double_t qc6 = 0.; // QC{6}\r
2685  Double_t qc8 = 0.; // QC{8}\r
2686  if(two) qc2 = two; \r
2687  if(four) qc4 = four-2.*pow(two,2.); \r
2688  if(six) qc6 = six-9.*two*four+12.*pow(two,3.); \r
2689  if(eight) qc8 = eight-16.*two*six-18.*pow(four,2.)+144.*pow(two,2.)*four-144.*pow(two,4.); \r
2690  \r
2691  // statistical errors of Q-cumulants:       \r
2692  Double_t qc2Error = 0.;\r
2693  Double_t qc4Error = 0.;\r
2694  Double_t qc6Error = 0.;\r
2695  Double_t qc8Error = 0.;\r
2696  \r
2697  // squared statistical errors of Q-cumulants:       \r
2698  //Double_t qc2ErrorSquared = 0.;\r
2699  Double_t qc4ErrorSquared = 0.;\r
2700  Double_t qc6ErrorSquared = 0.;\r
2701  Double_t qc8ErrorSquared = 0.;\r
2702         \r
2703  // statistical error of QC{2}:              \r
2704  qc2Error = twoError;                     \r
2705                              \r
2706  // statistical error of QC{4}:              \r
2707  qc4ErrorSquared = 16.*pow(two,2.)*pow(twoError,2)+pow(fourError,2.)\r
2708                  - 8.*two*wCov24;                     \r
2709  if(qc4ErrorSquared>0.)\r
2710  {\r
2711   qc4Error = pow(qc4ErrorSquared,0.5);\r
2712  } else \r
2713    {\r
2714     cout<<"WARNING: Statistical error of QC{4} is imaginary !!!!"<<endl;\r
2715    }\r
2716                                            \r
2717  // statistical error of QC{6}:              \r
2718  qc6ErrorSquared = 81.*pow(4.*pow(two,2.)-four,2.)*pow(twoError,2.)\r
2719                  + 81.*pow(two,2.)*pow(fourError,2.)\r
2720                  + pow(sixError,2.)\r
2721                  - 162.*two*(4.*pow(two,2.)-four)*wCov24\r
2722                  + 18.*(4.*pow(two,2.)-four)*wCov26\r
2723                  - 18.*two*wCov46; \r
2724                     \r
2725  if(qc6ErrorSquared>0.)\r
2726  {\r
2727   qc6Error = pow(qc6ErrorSquared,0.5);\r
2728  } else \r
2729    {\r
2730     cout<<"WARNING: Statistical error of QC{6} is imaginary !!!!"<<endl;\r
2731    }\r
2732                             \r
2733  // statistical error of QC{8}:              \r
2734  qc8ErrorSquared = 256.*pow(36.*pow(two,3.)-18.*four*two+six,2.)*pow(twoError,2.)\r
2735                  + 1296.*pow(4.*pow(two,2.)-four,2.)*pow(fourError,2.)\r
2736                  + 256.*pow(two,2.)*pow(sixError,2.)\r
2737                  + pow(eightError,2.)\r
2738                  - 1152.*(36.*pow(two,3.)-18.*four*two+six)*(4.*pow(two,2.)-four)*wCov24\r
2739                  + 512.*two*(36.*pow(two,3.)-18.*four*two+six)*wCov26\r
2740                  - 32.*(36.*pow(two,3.)-18.*four*two+six)*wCov28\r
2741                  - 1152.*two*(4.*pow(two,2.)-four)*wCov46\r
2742                  + 72.*(4.*pow(two,2.)-four)*wCov48\r
2743                  - 32.*two*wCov68;      \r
2744  if(qc8ErrorSquared>0.)\r
2745  {\r
2746   qc8Error = pow(qc8ErrorSquared,0.5);\r
2747  } else \r
2748    {\r
2749     cout<<"WARNING: Statistical error of QC{8} is imaginary !!!!"<<endl;\r
2750    }\r
2751 \r
2752  // store the results and statistical errors for Q-cumulants:\r
2753  fIntFlowQcumulants->SetBinContent(1,qc2);\r
2754  fIntFlowQcumulants->SetBinError(1,qc2Error);\r
2755  fIntFlowQcumulants->SetBinContent(2,qc4);\r
2756  fIntFlowQcumulants->SetBinError(2,qc4Error);\r
2757  fIntFlowQcumulants->SetBinContent(3,qc6);\r
2758  fIntFlowQcumulants->SetBinError(3,qc6Error);\r
2759  fIntFlowQcumulants->SetBinContent(4,qc8); \r
2760  fIntFlowQcumulants->SetBinError(4,qc8Error); \r
2761   \r
2762 } // end of AliFlowAnalysisWithQCumulants::CalculateCumulantsIntFlow()\r
2763 \r
2764 \r
2765 //================================================================================================================================ \r
2766 \r
2767 \r
2768 void AliFlowAnalysisWithQCumulants::CalculateIntFlow()\r
2769 {\r
2770  // a) Calculate the final results for integrated flow estimates from Q-cumulants.\r
2771  // b) Propagate the statistical errors of measured multiparticle correlations to statistical errors of integrated flow estimates.  \r
2772  // c) Store the results and statistical errors of integrated flow estimates in histogram fIntFlow.\r
2773  //    Binning of fIntFlow is organized as follows:\r
2774  //\r
2775  //     1st bin: v{2,QC}\r
2776  //     2nd bin: v{4,QC}\r
2777  //     3rd bin: v{6,QC}\r
2778  //     4th bin: v{8,QC}\r
2779  \r
2780  if(!(fIntFlowCorrelationsHist && fIntFlowCovariances && fIntFlowQcumulants && fIntFlow))\r
2781  {\r
2782   cout<<"WARNING: fIntFlowCorrelationsHist && fIntFlowCovariances && fIntFlowQcumulants && fIntFlow is NULL in AFAWQC::CCIF() !!!!"<<endl;\r
2783   exit(0);\r
2784  }\r
2785    \r
2786  // Q-cumulants:\r
2787  Double_t qc2 = fIntFlowQcumulants->GetBinContent(1); // QC{2}  \r
2788  Double_t qc4 = fIntFlowQcumulants->GetBinContent(2); // QC{4}  \r
2789  Double_t qc6 = fIntFlowQcumulants->GetBinContent(3); // QC{6}  \r
2790  Double_t qc8 = fIntFlowQcumulants->GetBinContent(4); // QC{8}\r
2791   \r
2792  // correlations:\r
2793  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>> \r
2794  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>  \r
2795  Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>> \r
2796  Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>  \r
2797  \r
2798  // statistical errors of average 2-, 4-, 6- and 8-particle azimuthal correlations:\r
2799  Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1); // statistical error of <2>  \r
2800  Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2); // statistical error of <4>   \r
2801  Double_t sixError = fIntFlowCorrelationsHist->GetBinError(3); // statistical error of <6> \r
2802  Double_t eightError = fIntFlowCorrelationsHist->GetBinError(4); // statistical error of <8> \r
2803  \r
2804  // covariances (multiplied by prefactor depending on weights - see comments in CalculateCovariancesIntFlow()):\r
2805  Double_t wCov24 = fIntFlowCovariances->GetBinContent(1); // Cov(<2>,<4>) * prefactor(w_<2>,w_<4>)\r
2806  Double_t wCov26 = fIntFlowCovariances->GetBinContent(2); // Cov(<2>,<6>) * prefactor(w_<2>,w_<6>)\r
2807  Double_t wCov28 = fIntFlowCovariances->GetBinContent(3); // Cov(<2>,<8>) * prefactor(w_<2>,w_<8>)\r
2808  Double_t wCov46 = fIntFlowCovariances->GetBinContent(4); // Cov(<4>,<6>) * prefactor(w_<4>,w_<6>)\r
2809  Double_t wCov48 = fIntFlowCovariances->GetBinContent(5); // Cov(<4>,<8>) * prefactor(w_<4>,w_<8>)\r
2810  Double_t wCov68 = fIntFlowCovariances->GetBinContent(6); // Cov(<6>,<8>) * prefactor(w_<6>,w_<8>)\r
2811   \r
2812  // integrated flow estimates:\r
2813  Double_t v2 = 0.; // v{2,QC}  \r
2814  Double_t v4 = 0.; // v{4,QC}  \r
2815  Double_t v6 = 0.; // v{6,QC}  \r
2816  Double_t v8 = 0.; // v{8,QC}\r
2817  \r
2818  // calculate integrated flow estimates from Q-cumulants: \r
2819  if(qc2>=0.) v2 = pow(qc2,1./2.); \r
2820  if(qc4<=0.) v4 = pow(-1.*qc4,1./4.); \r
2821  if(qc6>=0.) v6 = pow((1./4.)*qc6,1./6.); \r
2822  if(qc8<=0.) v8 = pow((-1./33.)*qc8,1./8.); \r
2823    \r
2824  // statistical errors of integrated flow estimates:\r
2825  Double_t v2Error = 0.; // statistical error of v{2,QC}  \r
2826  Double_t v4Error = 0.; // statistical error of v{4,QC}  \r
2827  Double_t v6Error = 0.; // statistical error of v{6,QC}  \r
2828  Double_t v8Error = 0.; // statistical error of v{8,QC}\r
2829    \r
2830  // squares of statistical errors of integrated flow estimates:\r
2831  Double_t v2ErrorSquared = 0.; // squared statistical error of v{2,QC} \r
2832  Double_t v4ErrorSquared = 0.; // squared statistical error of v{4,QC}   \r
2833  Double_t v6ErrorSquared = 0.; // squared statistical error of v{6,QC}   \r
2834  Double_t v8ErrorSquared = 0.; // squared statistical error of v{8,QC} \r
2835  \r
2836  // calculate squared statistical errors of integrated flow estimates:\r
2837  if(two != 0.) \r
2838  { \r
2839   v2ErrorSquared = (1./(4.*two))*pow(twoError,2.);\r
2840  } \r
2841  if(2.*pow(two,2.)-four > 0.)\r
2842  {\r
2843   v4ErrorSquared = (1./pow(2.*pow(two,2.)-four,3./2.))*\r
2844                    (pow(two,2.)*pow(twoError,2.)+(1./16.)*pow(fourError,2.)-(1./2.)*two*wCov24);\r
2845  }\r
2846  if(six-9.*four*two+12.*pow(two,3.) > 0.) \r
2847  {\r
2848   v6ErrorSquared = ((1./2.)*(1./pow(2.,2./3.))*(1./pow(six-9.*four*two+12.*pow(two,3.),5./3.)))*\r
2849                    ((9./2.)*pow(4.*pow(two,2.)-four,2.)*pow(twoError,2.) \r
2850                     + (9./2.)*pow(two,2.)*pow(fourError,2.)+(1./18.)*pow(sixError,2.)\r
2851                     - 9.*two*(4.*pow(two,2.)-four)*wCov24+(4.*pow(two,2.)-four)*wCov26-two*wCov46); \r
2852  }\r
2853  if(-1.*eight+16.*six*two+18.*pow(four,2.)-144.*four*pow(two,2.)+144.*pow(two,4.) > 0.) \r
2854  {\r
2855   v8ErrorSquared = (4./pow(33,1./4.))*(1./pow(-1.*eight+16.*six*two+18.*pow(four,2.)-144.*four*pow(two,2.)+144.*pow(two,4.),7./4.))*\r
2856                    (pow(36.*pow(two,3.)-18.*four*two+six,2.)*pow(twoError,2.)\r
2857                     + (81./16.)*pow(4.*pow(two,2.)-four,2.)*pow(fourError,2.)\r
2858                     + pow(two,2.)*pow(sixError,2.)\r
2859                     + (1./256.)*pow(eightError,2.)\r
2860                     - (9./2.)*(36.*pow(two,3.)-18.*four*two+six)*(4.*pow(two,2.)-four)*wCov24\r
2861                     + 2.*two*(36.*pow(two,3.)-18.*four*two+six)*wCov26\r
2862                     - (1./8.)*(36.*pow(two,3.)-18.*four*two+six)*wCov28                    \r
2863                     - (9./2.)*two*(4.*pow(two,2.)-four)*wCov46                   \r
2864                     + (9./32.)*(4.*pow(two,2.)-four)*wCov48                    \r
2865                     - (1./8.)*two*wCov68);\r
2866  } \r
2867 \r
2868  // calculate statistical errors of integrated flow estimates: \r
2869  if(v2ErrorSquared > 0.)\r
2870  {\r
2871   v2Error = pow(v2ErrorSquared,0.5);\r
2872  } else\r
2873    {\r
2874     cout<<"WARNING: Statistical error of v{2,QC} is imaginary !!!!"<<endl;\r
2875    }    \r
2876  if(v4ErrorSquared > 0.)\r
2877  {\r
2878   v4Error = pow(v4ErrorSquared,0.5);\r
2879  } else\r
2880    {\r
2881     cout<<"WARNING: Statistical error of v{4,QC} is imaginary !!!!"<<endl;\r
2882    }     \r
2883  if(v6ErrorSquared > 0.)\r
2884  {\r
2885   v6Error = pow(v6ErrorSquared,0.5);\r
2886  } else\r
2887    {\r
2888     cout<<"WARNING: Statistical error of v{6,QC} is imaginary !!!!"<<endl;\r
2889    }     \r
2890  if(v8ErrorSquared > 0.)\r
2891  {\r
2892   v8Error = pow(v8ErrorSquared,0.5);\r
2893  } else\r
2894    {\r
2895     cout<<"WARNING: Statistical error of v{8,QC} is imaginary !!!!"<<endl;\r
2896    }    \r
2897                      \r
2898  // store the results and statistical errors of integrated flow estimates:\r
2899  fIntFlow->SetBinContent(1,v2);\r
2900  fIntFlow->SetBinError(1,v2Error);\r
2901  fIntFlow->SetBinContent(2,v4);\r
2902  fIntFlow->SetBinError(2,v4Error);\r
2903  fIntFlow->SetBinContent(3,v6);\r
2904  fIntFlow->SetBinError(3,v6Error);\r
2905  fIntFlow->SetBinContent(4,v8);\r
2906  fIntFlow->SetBinError(4,v8Error);\r
2907        \r
2908 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlow()\r
2909 \r
2910 \r
2911 //================================================================================================================================ \r
2912 \r
2913 \r
2914 void AliFlowAnalysisWithQCumulants::FillCommonHistResultsIntFlow()\r
2915 {\r
2916  // Fill in AliFlowCommonHistResults histograms relevant for 'NONAME' integrated flow (to be improved (name))\r
2917  \r
2918  if(!fIntFlow)\r
2919  {\r
2920   cout<<"WARNING: fIntFlow is NULL in AFAWQC::FCHRIF() !!!!"<<endl;\r
2921   exit(0); \r
2922  }  \r
2923     \r
2924  if(!(fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th))\r
2925  {\r
2926   cout<<"WARNING: fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th"<<endl; \r
2927   cout<<"         is NULL in AFAWQC::FCHRIF() !!!!"<<endl;\r
2928   exit(0);\r
2929  }\r
2930  \r
2931  Double_t v2 = fIntFlow->GetBinContent(1);\r
2932  Double_t v4 = fIntFlow->GetBinContent(2);\r
2933  Double_t v6 = fIntFlow->GetBinContent(3);\r
2934  Double_t v8 = fIntFlow->GetBinContent(4);\r
2935   \r
2936  Double_t v2Error = fIntFlow->GetBinError(1);\r
2937  Double_t v4Error = fIntFlow->GetBinError(2);\r
2938  Double_t v6Error = fIntFlow->GetBinError(3);\r
2939  Double_t v8Error = fIntFlow->GetBinError(4);\r
2940  \r
2941  fCommonHistsResults2nd->FillIntegratedFlow(v2,v2Error); // to be improved (hardwired 2nd in the name)  \r
2942  fCommonHistsResults4th->FillIntegratedFlow(v4,v4Error); // to be improved (hardwired 4th in the name)\r
2943  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (calculate also 6th and 8th order)\r
2944  {\r
2945   fCommonHistsResults6th->FillIntegratedFlow(v6,v6Error); // to be improved (hardwired 6th in the name)\r
2946   fCommonHistsResults8th->FillIntegratedFlow(v8,v8Error); // to be improved (hardwired 8th in the name) \r
2947  }\r
2948  \r
2949 } // end of AliFlowAnalysisWithQCumulants::FillCommonHistResultsIntFlow()\r
2950 \r
2951 \r
2952 //================================================================================================================================ \r
2953 \r
2954 \r
2955 /*\r
2956 void AliFlowAnalysisWithQCumulants::ApplyCorrectionForNonUniformAcceptanceToCumulantsForIntFlow(Bool_t useParticleWeights, TString eventWeights)\r
2957 {\r
2958  // apply correction for non-uniform acceptance to cumulants for integrated flow \r
2959  // (Remark: non-corrected cumulants are accessed from fCumulants[pW][0], corrected cumulants are stored in fCumulants[pW][1])\r
2960  \r
2961  // shortcuts for the flags:\r
2962  Int_t pW = (Int_t)(useParticleWeights); // 0=pWeights not used, 1=pWeights used\r
2963  Int_t eW = -1;\r
2964  \r
2965  if(eventWeights == "exact")\r
2966  {\r
2967   eW = 0;\r
2968  }\r
2969  \r
2970  if(!(fCumulants[pW][eW][0] && fCumulants[pW][eW][1] && fCorrections[pW][eW]))\r
2971  {\r
2972   cout<<"WARNING: fCumulants[pW][eW][0] && fCumulants[pW][eW][1] && fCorrections[pW][eW] is NULL in AFAWQC::ACFNUATCFIF() !!!!"<<endl;\r
2973   cout<<"pW = "<<pW<<endl;\r
2974   cout<<"eW = "<<eW<<endl;\r
2975   exit(0);\r
2976  } \r
2977   \r
2978  // non-corrected cumulants:\r
2979  Double_t qc2 = fCumulants[pW][eW][0]->GetBinContent(1); \r
2980  Double_t qc4 = fCumulants[pW][eW][0]->GetBinContent(2); \r
2981  Double_t qc6 = fCumulants[pW][eW][0]->GetBinContent(3); \r
2982  Double_t qc8 = fCumulants[pW][eW][0]->GetBinContent(4); \r
2983  // statistical error of non-corrected cumulants:  \r
2984  Double_t qc2Error = fCumulants[pW][eW][0]->GetBinError(1); \r
2985  Double_t qc4Error = fCumulants[pW][eW][0]->GetBinError(2); \r
2986  Double_t qc6Error = fCumulants[pW][eW][0]->GetBinError(3); \r
2987  Double_t qc8Error = fCumulants[pW][eW][0]->GetBinError(4); \r
2988  // corrections for non-uniform acceptance:\r
2989  Double_t qc2Correction = fCorrections[pW][eW]->GetBinContent(1); \r
2990  Double_t qc4Correction = fCorrections[pW][eW]->GetBinContent(2); \r
2991  Double_t qc6Correction = fCorrections[pW][eW]->GetBinContent(3); \r
2992  Double_t qc8Correction = fCorrections[pW][eW]->GetBinContent(4); \r
2993  // corrected cumulants:\r
2994  Double_t qc2Corrected = qc2 + qc2Correction;\r
2995  Double_t qc4Corrected = qc4 + qc4Correction;\r
2996  Double_t qc6Corrected = qc6 + qc6Correction;\r
2997  Double_t qc8Corrected = qc8 + qc8Correction;\r
2998   \r
2999  // ... to be improved (I need here also to correct error of QCs for NUA. \r
3000  // For simplicity sake I assume at the moment that this correction is negliglible, but it will be added eventually...)\r
3001  \r
3002  // store corrected results and statistical errors for cumulants:   \r
3003  fCumulants[pW][eW][1]->SetBinContent(1,qc2Corrected);\r
3004  fCumulants[pW][eW][1]->SetBinContent(2,qc4Corrected);\r
3005  fCumulants[pW][eW][1]->SetBinContent(3,qc6Corrected);\r
3006  fCumulants[pW][eW][1]->SetBinContent(4,qc8Corrected);\r
3007  fCumulants[pW][eW][1]->SetBinError(1,qc2Error); // to be improved (correct also qc2Error for NUA)\r
3008  fCumulants[pW][eW][1]->SetBinError(2,qc4Error); // to be improved (correct also qc4Error for NUA)\r
3009  fCumulants[pW][eW][1]->SetBinError(3,qc6Error); // to be improved (correct also qc6Error for NUA)\r
3010  fCumulants[pW][eW][1]->SetBinError(4,qc8Error); // to be improved (correct also qc8Error for NUA)  \r
3011   \r
3012 } // end of AliFlowAnalysisWithQCumulants::ApplyCorrectionForNonUniformAcceptanceToCumulantsForIntFlow(Bool_t useParticleWeights, TString eventWeights)\r
3013 */\r
3014 \r
3015 \r
3016 //================================================================================================================================\r
3017 \r
3018 \r
3019 /*  \r
3020 void AliFlowAnalysisWithQCumulants::PrintQuantifyingCorrectionsForNonUniformAcceptance(Bool_t useParticleWeights, TString eventWeights)\r
3021 {\r
3022  // print on the screen QC{n,biased}/QC{n,corrected}\r
3023  \r
3024  // shortcuts for the flags:\r
3025  Int_t pW = (Int_t)(useParticleWeights); // 0=pWeights not used, 1=pWeights used\r
3026  \r
3027  Int_t eW = -1;\r
3028  \r
3029  if(eventWeights == "exact")\r
3030  {\r
3031   eW = 0;\r
3032  } \r
3033  \r
3034  if(!(fCumulants[pW][eW][0] && fCumulants[pW][eW][1]))\r
3035  {\r
3036   cout<<"WARNING: fCumulants[pW][eW][0] && fCumulants[pW][eW][1] is NULL in AFAWQC::PQCFNUA() !!!!"<<endl;\r
3037   cout<<"pW = "<<pW<<endl;\r
3038   cout<<"eW = "<<eW<<endl;\r
3039   exit(0);\r
3040  }\r
3041    \r
3042  cout<<endl;\r
3043  cout<<" Quantifying the bias to Q-cumulants from"<<endl;\r
3044  cout<<"  non-uniform acceptance of the detector:"<<endl;\r
3045  cout<<endl;\r
3046   \r
3047  if(fCumulants[pW][eW][1]->GetBinContent(1)) \r
3048  { \r
3049   cout<<"  QC{2,biased}/QC{2,corrected} = "<<(fCumulants[pW][eW][0]->GetBinContent(1))/(fCumulants[pW][eW][1]->GetBinContent(1))<<endl;   \r
3050  }\r
3051  if(fCumulants[pW][eW][1]->GetBinContent(2)) \r
3052  { \r
3053   cout<<"  QC{4,biased}/QC{4,corrected} = "<<fCumulants[pW][eW][0]->GetBinContent(2)/fCumulants[pW][eW][1]->GetBinContent(2)<<endl;   \r
3054  }\r
3055  \r
3056  cout<<endl;\r
3057             \r
3058 } // end of AliFlowAnalysisWithQCumulants::PrintQuantifyingCorrectionsForNonUniformAcceptance(Bool_t useParticleWeights, TString eventWeights)\r
3059 */\r
3060 \r
3061 \r
3062 //================================================================================================================================\r
3063 \r
3064 \r
3065 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelationsUsingParticleWeights()\r
3066 {\r
3067  // Calculate all correlations needed for integrated flow using particle weights.\r
3068   
3069  // Remark 1: When particle weights are used the binning of fIntFlowCorrelationAllPro is organized as follows:
3070  //
3071  //  1st bin: <2>_{1n|1n} = two1n1nW1W1 = <w1 w2 cos(n*(phi1-phi2))>\r
3072  //  2nd bin: <2>_{2n|2n} = two2n2nW2W2 = <w1^2 w2^2 cos(2n*(phi1-phi2))>\r
3073  //  3rd bin: <2>_{3n|3n} = two3n3nW3W3 = <w1^3 w2^3 cos(3n*(phi1-phi2))> \r
3074  //  4th bin: <2>_{4n|4n} = two4n4nW4W4 = <w1^4 w2^4 cos(4n*(phi1-phi2))>\r
3075  //  5th bin:           ----  EMPTY ----\r
3076  //  6th bin: <3>_{2n|1n,1n} = three2n1n1nW2W1W1 = <w1^2 w2 w3 cos(n*(2phi1-phi2-phi3))>\r
3077  //  7th bin: <3>_{3n|2n,1n} = ...\r
3078  //  8th bin: <3>_{4n|2n,2n} = ...\r
3079  //  9th bin: <3>_{4n|3n,1n} = ...
3080  // 10th bin:           ----  EMPTY ----\r
3081  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1nW1W1W1W1 = <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))>\r
3082  // 12th bin: <4>_{2n,1n|2n,1n} = ...\r
3083  // 13th bin: <4>_{2n,2n|2n,2n} = ...\r
3084  // 14th bin: <4>_{3n|1n,1n,1n} = ... \r
3085  // 15th bin: <4>_{3n,1n|3n,1n} = ...\r
3086  // 16th bin: <4>_{3n,1n|2n,2n} = ...\r
3087  // 17th bin: <4>_{4n|2n,1n,1n} = ... \r
3088  // 18th bin:           ----  EMPTY ----\r
3089  // 19th bin: <5>_{2n|1n,1n,1n,1n} = ...\r
3090  // 20th bin: <5>_{2n,2n|2n,1n,1n} = ...\r
3091  // 21st bin: <5>_{3n,1n|2n,1n,1n} = ...\r
3092  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = ...\r
3093  // 23rd bin:           ----  EMPTY ----\r
3094  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = ...\r
3095  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = ...\r
3096  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = ...\r
3097  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = ...\r
3098  // 28th bin:           ----  EMPTY ----\r
3099  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = ...\r
3100  // 30th bin:           ----  EMPTY ----\r
3101  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = ...\r
3102  
3103  // Remark 2: When particle weights are used there are some extra correlations. They are stored in 
3104  // fIntFlowExtraCorrelationsPro binning of which is organized as follows:
3105  
3106  // 1st bin: two1n1nW3W1 = <w1^3 w2 cos(n*(phi1-phi2))>\r
3107  // 2nd bin: two1n1nW1W1W2 = <w1 w2 w3^2 cos(n*(phi1-phi2))>  \r
3108  // ...
3109   \r
3110  // multiplicity (number of particles used to determine the reaction plane)\r
3111  Double_t dMult = (*fSMpk)(0,0);\r
3112  \r
3113  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
3114  Double_t dReQ1n1k = (*fReQ)(0,1);\r
3115  Double_t dReQ2n2k = (*fReQ)(1,2);\r
3116  Double_t dReQ3n3k = (*fReQ)(2,3);\r
3117  Double_t dReQ4n4k = (*fReQ)(3,4);\r
3118  Double_t dReQ1n3k = (*fReQ)(0,3);\r
3119  Double_t dImQ1n1k = (*fImQ)(0,1);\r
3120  Double_t dImQ2n2k = (*fImQ)(1,2);\r
3121  Double_t dImQ3n3k = (*fImQ)(2,3);\r
3122  Double_t dImQ4n4k = (*fImQ)(3,4);\r
3123  Double_t dImQ1n3k = (*fImQ)(0,3);\r
3124 \r
3125  // dMs are variables introduced in order to simplify some Eqs. bellow:\r
3126  //..............................................................................................\r
3127  Double_t dM11 = (*fSMpk)(1,1)-(*fSMpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j\r
3128  Double_t dM22 = (*fSMpk)(1,2)-(*fSMpk)(0,4); // dM22 = sum_{i,j=1,i!=j}^M w_i^2 w_j^2\r
3129  Double_t dM33 = (*fSMpk)(1,3)-(*fSMpk)(0,6); // dM33 = sum_{i,j=1,i!=j}^M w_i^3 w_j^3\r
3130  Double_t dM44 = (*fSMpk)(1,4)-(*fSMpk)(0,8); // dM44 = sum_{i,j=1,i!=j}^M w_i^4 w_j^4\r
3131  Double_t dM31 = (*fSMpk)(0,3)*(*fSMpk)(0,1)-(*fSMpk)(0,4); // dM31 = sum_{i,j=1,i!=j}^M w_i^3 w_j\r
3132  Double_t dM211 = (*fSMpk)(0,2)*(*fSMpk)(1,1)-2.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
3133                 - (*fSMpk)(1,2)+2.*(*fSMpk)(0,4); // dM211 = sum_{i,j,k=1,i!=j!=k}^M w_i^2 w_j w_k\r
3134  Double_t dM1111 = (*fSMpk)(3,1)-6.*(*fSMpk)(0,2)*(*fSMpk)(1,1)  \r
3135                  + 8.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
3136                  + 3.*(*fSMpk)(1,2)-6.*(*fSMpk)(0,4); // dM1111 = sum_{i,j,k,l=1,i!=j!=k!=l}^M w_i w_j w_k w_l\r
3137  //..............................................................................................\r
3138 \r
3139  // 2-particle correlations:\r
3140  Double_t two1n1nW1W1 = 0.; // <w1 w2 cos(n*(phi1-phi2))>\r
3141  Double_t two2n2nW2W2 = 0.; // <w1^2 w2^2 cos(2n*(phi1-phi2))>\r
3142  Double_t two3n3nW3W3 = 0.; // <w1^3 w2^3 cos(3n*(phi1-phi2))>\r
3143  Double_t two4n4nW4W4 = 0.; // <w1^4 w2^4 cos(4n*(phi1-phi2))>\r
3144  if(dMult>1) \r
3145  { \r
3146   if(dM11)\r
3147   {\r
3148    two1n1nW1W1 = (pow(dReQ1n1k,2)+pow(dImQ1n1k,2)-(*fSMpk)(0,2))/dM11;    \r
3149    // average correlation <w1 w2 cos(n*(phi1-phi2))> for single event: \r
3150    fIntFlowCorrelationsEBE->SetBinContent(1,two1n1nW1W1);\r
3151    fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(1,dM11);\r
3152    // average correlation <w1 w2 cos(n*(phi1-phi2))> for all events:\r
3153    fIntFlowCorrelationsPro->Fill(0.5,two1n1nW1W1,dM11);   \r
3154    fIntFlowCorrelationsAllPro->Fill(0.5,two1n1nW1W1,dM11);   \r
3155   }\r
3156   if(dM22)\r
3157   {\r
3158    two2n2nW2W2 = (pow(dReQ2n2k,2)+pow(dImQ2n2k,2)-(*fSMpk)(0,4))/dM22; 
3159    // ...
3160    // average correlation <w1^2 w2^2 cos(2n*(phi1-phi2))> for all events:\r
3161    fIntFlowCorrelationsAllPro->Fill(1.5,two2n2nW2W2,dM22);   \r
3162   }\r
3163   if(dM33)\r
3164   {\r
3165    two3n3nW3W3 = (pow(dReQ3n3k,2)+pow(dImQ3n3k,2)-(*fSMpk)(0,6))/dM33;\r
3166    // ...
3167    // average correlation <w1^3 w2^3 cos(3n*(phi1-phi2))> for all events:\r
3168    fIntFlowCorrelationsAllPro->Fill(2.5,two3n3nW3W3,dM33);   \r
3169   }\r
3170   if(dM44)\r
3171   {\r
3172    two4n4nW4W4 = (pow(dReQ4n4k,2)+pow(dImQ4n4k,2)-(*fSMpk)(0,8))/dM44; \r
3173    // ...
3174    // average correlation <w1^4 w2^4 cos(4n*(phi1-phi2))> for all events:\r
3175    fIntFlowCorrelationsAllPro->Fill(3.5,two4n4nW4W4,dM44);      
3176   }
3177  } // end of if(dMult>1) \r
3178
3179  // extra 2-particle correlations:\r
3180  Double_t two1n1nW3W1 = 0.; // <w1^3 w2 cos(n*(phi1-phi2))>\r
3181  Double_t two1n1nW1W1W2 = 0.; // <w1 w2 w3^2 cos(n*(phi1-phi2))> \r
3182  if(dMult>1) \r
3183  {    \r
3184   if(dM31)\r
3185   {\r
3186    two1n1nW3W1 = (dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k-(*fSMpk)(0,4))/dM31; \r
3187    fIntFlowExtraCorrelationsPro->Fill(0.5,two1n1nW3W1,dM31);  \r
3188   } \r
3189   if(dM211)\r
3190   {\r
3191    two1n1nW1W1W2 = ((*fSMpk)(0,2)*(pow(dReQ1n1k,2)+pow(dImQ1n1k,2)-(*fSMpk)(0,2))\r
3192                  - 2.*(dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k\r
3193                  - (*fSMpk)(0,4)))/dM211;\r
3194    fIntFlowExtraCorrelationsPro->Fill(1.5,two1n1nW1W1W2,dM211);  \r
3195   }  \r
3196  } // end of if(dMult>1)\r
3197  //..............................................................................................\r
3198  \r
3199  //..............................................................................................\r
3200  // 3-particle correlations:\r
3201  Double_t three2n1n1nW2W1W1 = 0.; // <w1^2 w2 w3 cos(n*(2phi1-phi2-phi3))>\r
3202  \r
3203  if(dMult>2) \r
3204  { \r
3205   if(dM211)\r
3206   {                                                       \r
3207    three2n1n1nW2W1W1 = (pow(dReQ1n1k,2.)*dReQ2n2k+2.*dReQ1n1k*dImQ1n1k*dImQ2n2k-pow(dImQ1n1k,2.)*dReQ2n2k\r
3208                      - 2.*(dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k)\r
3209                      - pow(dReQ2n2k,2)-pow(dImQ2n2k,2)\r
3210                      + 2.*(*fSMpk)(0,4))/dM211;                                                                               \r
3211    fIntFlowCorrelationsAllPro->Fill(5.5,three2n1n1nW2W1W1,dM211);\r
3212   } \r
3213  } // end of if(dMult>2) \r
3214  //..............................................................................................\r
3215  \r
3216  //..............................................................................................\r
3217  // 4-particle correlations:\r
3218  Double_t four1n1n1n1nW1W1W1W1 = 0.; // <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))>\r
3219  if(dMult>3) \r
3220  { \r
3221   if(dM1111)\r
3222   {      \r
3223    four1n1n1n1nW1W1W1W1 = (pow(pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.),2)\r
3224                         - 2.*(pow(dReQ1n1k,2.)*dReQ2n2k+2.*dReQ1n1k*dImQ1n1k*dImQ2n2k-pow(dImQ1n1k,2.)*dReQ2n2k)\r
3225                         + 8.*(dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k)\r
3226                         + (pow(dReQ2n2k,2)+pow(dImQ2n2k,2))\r
3227                         - 4.*(*fSMpk)(0,2)*(pow(dReQ1n1k,2)+pow(dImQ1n1k,2))\r
3228                         - 6.*(*fSMpk)(0,4)+2.*(*fSMpk)(1,2))/dM1111;  \r
3229                           \r
3230    // average correlation <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))> for single event: \r
3231    fIntFlowCorrelationsEBE->SetBinContent(2,four1n1n1n1nW1W1W1W1);\r
3232    fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(2,dM1111);\r
3233    // average correlation <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))> for all events:\r
3234    fIntFlowCorrelationsPro->Fill(1.5,four1n1n1n1nW1W1W1W1,dM1111);   \r
3235    fIntFlowCorrelationsAllPro->Fill(10.5,four1n1n1n1nW1W1W1W1,dM1111);   \r
3236   } \r
3237  } // end of if(dMult>3) \r
3238  //..............................................................................................\r
3239  \r
3240 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelationsUsingParticleWeights()\r
3241 \r
3242 \r
3243 //================================================================================================================================\r
3244 \r
3245 \r
3246 void AliFlowAnalysisWithQCumulants::CalculateWeightedQProductsForIntFlow() // to be improved (completed)\r
3247 {\r
3248  // calculate averages like <<2><4>>, <<2><6>>, <<4><6>>, etc. which are needed to calculate covariances \r
3249  // Remark: here we take weighted correlations!\r
3250  \r
3251  /*\r
3252  \r
3253  // binning of fQProductsW is organized as follows:\r
3254  // \r
3255  // 1st bin: <2><4> \r
3256  // 2nd bin: <2><6>\r
3257  // 3rd bin: <2><8>\r
3258  // 4th bin: <4><6>\r
3259  // 5th bin: <4><8>\r
3260  // 6th bin: <6><8>\r
3261  \r
3262  Double_t dMult = (*fSMpk)(0,0); // multiplicity (number of particles used to determine the reaction plane)\r
3263 \r
3264  Double_t dM11 = (*fSMpk)(1,1)-(*fSMpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j\r
3265  Double_t dM1111 = (*fSMpk)(3,1)-6.*(*fSMpk)(0,2)*(*fSMpk)(1,1)  \r
3266                  + 8.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
3267                  + 3.*(*fSMpk)(1,2)-6.*(*fSMpk)(0,4); // dM1111 = sum_{i,j,k,l=1,i!=j!=k!=l}^M w_i w_j w_k w_l\r
3268 \r
3269  Double_t twoEBEW = 0.; // <2>\r
3270  Double_t fourEBEW = 0.; // <4>\r
3271  \r
3272  twoEBEW = fQCorrelationsEBE[1]->GetBinContent(1);\r
3273  fourEBEW = fQCorrelationsEBE[1]->GetBinContent(11);\r
3274  \r
3275  // <2><4>\r
3276  if(dMult>3)\r
3277  {\r
3278   fQProducts[1][0]->Fill(0.5,twoEBEW*fourEBEW,dM11*dM1111);\r
3279  }\r
3280  \r
3281  */\r
3282  \r
3283 } // end of AliFlowAnalysisWithQCumulants::CalculateWeightedQProductsForIntFlow()  \r
3284 \r
3285 \r
3286 //================================================================================================================================\r
3287 \r
3288 \r
3289 void AliFlowAnalysisWithQCumulants::InitializeArraysForIntFlow()\r
3290 {\r
3291  // Initialize all arrays used to calculate integrated flow.\r
3292  \r
3293  for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
3294  {\r
3295   fIntFlowCorrectionTermsForNUAEBE[sc] = NULL;\r
3296   fIntFlowCorrectionTermsForNUAPro[sc] = NULL;\r
3297   fIntFlowCorrectionTermsForNUAHist[sc] = NULL;\r
3298  }\r
3299    \r
3300  for(Int_t power=0;power<2;power++) // linear or quadratic \r
3301  {\r
3302   fIntFlowSumOfEventWeights[power] = NULL;    \r
3303  }\r
3304  \r
3305 } // end of void AliFlowAnalysisWithQCumulants::InitializeArraysForIntFlow()\r
3306 \r
3307 \r
3308 //================================================================================================================================\r
3309 \r
3310 \r
3311 void AliFlowAnalysisWithQCumulants::InitializeArraysForDiffFlow()\r
3312 {\r
3313  // Initialize all arrays needed to calculate differential flow.\r
3314  //  a) Initialize lists holding profiles;\r
3315  //  b) Initialize lists holding histograms;\r
3316  //  c) Initialize event-by-event quantities;\r
3317  //  d) Initialize profiles;\r
3318  //  e) Initialize histograms holding final results.\r
3319  \r
3320  // a) Initialize lists holding profiles;\r
3321  for(Int_t t=0;t<2;t++) // type (RP, POI)\r
3322  {\r
3323   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3324   {\r
3325    fDiffFlowCorrelationsProList[t][pe] = NULL;\r
3326    fDiffFlowProductOfCorrelationsProList[t][pe] = NULL;\r
3327    fDiffFlowCorrectionsProList[t][pe] = NULL;\r
3328   }\r
3329  }  \r
3330  \r
3331  // b) Initialize lists holding histograms;\r
3332  for(Int_t t=0;t<2;t++) // type (RP, POI)\r
3333  {\r
3334   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3335   {\r
3336    fDiffFlowCorrelationsHistList[t][pe] = NULL;\r
3337    for(Int_t power=0;power<2;power++)\r
3338    {\r
3339     fDiffFlowSumOfEventWeightsHistList[t][pe][power] = NULL;\r
3340    } // end of for(Int_t power=0;power<2;power++)  \r
3341    fDiffFlowSumOfProductOfEventWeightsHistList[t][pe] = NULL;\r
3342    fDiffFlowCorrectionsHistList[t][pe] = NULL;\r
3343    fDiffFlowCovariancesHistList[t][pe] = NULL;\r
3344    fDiffFlowCumulantsHistList[t][pe] = NULL;\r
3345    fDiffFlowHistList[t][pe] = NULL;\r
3346   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3347  } // enf of for(Int_t t=0;t<2;t++) // type (RP, POI) \r
3348  \r
3349  // c) Initialize event-by-event quantities:\r
3350  // 1D:\r
3351  for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)\r
3352  {\r
3353   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3354   { \r
3355    for(Int_t m=0;m<4;m++) // multiple of harmonic\r
3356    {\r
3357     for(Int_t k=0;k<9;k++) // power of weight\r
3358     {\r
3359      fReRPQ1dEBE[t][pe][m][k] = NULL;\r
3360      fImRPQ1dEBE[t][pe][m][k] = NULL;\r
3361      fs1dEBE[t][pe][k] = NULL; // to be improved (this doesn't need to be within loop over m)\r
3362     }   \r
3363    }\r
3364   }\r
3365  }\r
3366  // 1D:\r
3367  for(Int_t t=0;t<2;t++) // type (RP or POI)\r
3368  {\r
3369   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3370   { \r
3371    for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
3372    {\r
3373     for(Int_t cti=0;cti<9;cti++) // correction term index\r
3374     {\r
3375      fDiffFlowCorrectionTermsForNUAEBE[t][pe][sc][cti] = NULL;\r
3376     }   \r
3377    }\r
3378   }\r
3379  }\r
3380  // 2D:  \r
3381  for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)\r
3382  {\r
3383   for(Int_t m=0;m<4;m++) // multiple of harmonic\r
3384   {\r
3385    for(Int_t k=0;k<9;k++) // power of weight\r
3386    {\r
3387     fReRPQ2dEBE[t][m][k] = NULL;\r
3388     fImRPQ2dEBE[t][m][k] = NULL;\r
3389     fs2dEBE[t][k] = NULL; // to be improved (this doesn't need to be within loop over m)\r
3390    }   \r
3391   }\r
3392  }\r
3393  \r
3394  // d) Initialize profiles:\r
3395  for(Int_t t=0;t<2;t++) // type: RP or POI\r
3396  { \r
3397   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3398   {\r
3399    for(Int_t ci=0;ci<4;ci++) // correlation index\r
3400    {\r
3401     fDiffFlowCorrelationsPro[t][pe][ci] = NULL;\r
3402    } // end of for(Int_t ci=0;ci<4;ci++)   \r
3403    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
3404    {\r
3405     for(Int_t mci2=0;mci2<8;mci2++) // mixed correlation index\r
3406     {\r
3407      fDiffFlowProductOfCorrelationsPro[t][pe][mci1][mci2] = NULL;\r
3408     } // end of for(Int_t mci2=0;mci2<8;mci2++) // mixed correlation index\r
3409    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index  \r
3410    // correction terms for nua:\r
3411    for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
3412    {\r
3413     for(Int_t cti=0;cti<9;cti++) // correction term index\r
3414     {\r
3415      fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti] = NULL;\r
3416     }   \r
3417    }\r
3418   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3419  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
3420   \r
3421  // e) Initialize histograms holding final results.\r
3422  for(Int_t t=0;t<2;t++) // type: RP or POI\r
3423  { \r
3424   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3425   {\r
3426    for(Int_t ci=0;ci<4;ci++) // correlation index\r
3427    {\r
3428     fDiffFlowCorrelationsHist[t][pe][ci] = NULL;\r
3429     fDiffFlowCumulants[t][pe][ci] = NULL;\r
3430     fDiffFlow[t][pe][ci] = NULL;\r
3431    } // end of for(Int_t ci=0;ci<4;ci++)    \r
3432    for(Int_t covarianceIndex=0;covarianceIndex<5;covarianceIndex++) \r
3433    {\r
3434     fDiffFlowCovariances[t][pe][covarianceIndex] = NULL;     \r
3435    } // end of for(Int_t covarianceIndex=0;covarianceIndex<5;covarianceIndex++) \r
3436    // correction terms for nua:\r
3437    for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
3438    {\r
3439     for(Int_t cti=0;cti<9;cti++) // correction term index\r
3440     {\r
3441      fDiffFlowCorrectionTermsForNUAHist[t][pe][sc][cti] = NULL;\r
3442     }   \r
3443    }\r
3444   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3445  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
3446  \r
3447  // sum of event weights for reduced correlations:\r
3448  for(Int_t t=0;t<2;t++) // type = RP or POI\r
3449  {\r
3450   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3451   {\r
3452    for(Int_t p=0;p<2;p++) // power of weight is 1 or 2\r
3453    {\r
3454     for(Int_t ew=0;ew<4;ew++) // event weight index for reduced correlations\r
3455     {\r
3456      fDiffFlowSumOfEventWeights[t][pe][p][ew] = NULL;\r
3457     } \r
3458    }   \r
3459   }\r
3460  }\r
3461  // product of event weights for both types of correlations:\r
3462  for(Int_t t=0;t<2;t++) // type = RP or POI\r
3463  {\r
3464   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3465   {\r
3466    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
3467    {\r
3468     for(Int_t mci2=0;mci2<8;mci2++) // mixed correlation index\r
3469     {\r
3470      fDiffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2] = NULL;\r
3471     } \r
3472    }   \r
3473   }\r
3474  }\r
3475 \r
3476  \r
3477  \r
3478  \r
3479  /*\r
3480  \r
3481  // nested lists in fDiffFlowProfiles:\r
3482  for(Int_t t=0;t<2;t++)\r
3483  {\r
3484   fDFPType[t] = NULL;\r
3485   for(Int_t pW=0;pW<2;pW++) // particle weights not used (0) or used (1)\r
3486   {\r
3487    fDFPParticleWeights[t][pW] = NULL;\r
3488    for(Int_t eW=0;eW<2;eW++)\r
3489    {   \r
3490     fDFPEventWeights[t][pW][eW] = NULL;\r
3491     fDiffFlowCorrelations[t][pW][eW] = NULL;\r
3492     fDiffFlowProductsOfCorrelations[t][pW][eW] = NULL;\r
3493     for(Int_t sc=0;sc<2;sc++)\r
3494     {\r
3495      fDiffFlowCorrectionTerms[t][pW][eW][sc] = NULL;\r
3496     }\r
3497    } \r
3498   }\r
3499  }  \r
3500  \r
3501  \r
3502  */\r
3503  \r
3504   \r
3505   \r
3506   /*\r
3507   for(Int_t pW=0;pW<2;pW++) // particle weights not used (0) or used (1)\r
3508   {\r
3509    for(Int_t eW=0;eW<2;eW++)\r
3510    {\r
3511     // correlations:\r
3512     for(Int_t correlationIndex=0;correlationIndex<4;correlationIndex++)\r
3513     {\r
3514      fCorrelationsPro[t][pW][eW][correlationIndex] = NULL;\r
3515     }\r
3516     // products of correlations:\r
3517     for(Int_t productOfCorrelationsIndex=0;productOfCorrelationsIndex<6;productOfCorrelationsIndex++)\r
3518     {\r
3519      fProductsOfCorrelationsPro[t][pW][eW][productOfCorrelationsIndex] = NULL;\r
3520     }\r
3521     // correction terms:\r
3522     for(Int_t sc=0;sc<2;sc++)\r
3523     {\r
3524      for(Int_t correctionsIndex=0;correctionsIndex<2;correctionsIndex++)\r
3525      {\r
3526       fCorrectionTermsPro[t][pW][eW][sc][correctionsIndex] = NULL;\r
3527      } \r
3528     } \r
3529    }\r
3530   } \r
3531   */\r
3532     \r
3533 } // end of AliFlowAnalysisWithQCumulants::InitializeArraysForDiffFlow()\r
3534 \r
3535 \r
3536 //================================================================================================================================\r
3537  /*\r
3538 \r
3539 \r
3540 void AliFlowAnalysisWithQCumulants::CalculateCorrelationsForDifferentialFlow2D(TString type)\r
3541 {\r
3542  // calculate all reduced correlations needed for differential flow for each (pt,eta) bin: \r
3543  \r
3544  if(type == "RP") // to be improved (removed)\r
3545  {\r
3546   cout<<endl;\r
3547  }\r
3548  // ... \r
3549  \r
3550  \r
3551  Int_t typeFlag = -1; \r
3552   \r
3553  // reduced correlations ares stored in fCorrelationsPro[t][pW][index] and are indexed as follows:\r
3554  // index:\r
3555  // 0: <2'>\r
3556  // 1: <4'>\r
3557 \r
3558  // multiplicity:\r
3559  Double_t dMult = (*fSMpk)(0,0);\r
3560  \r
3561  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
3562  Double_t dReQ1n = (*fReQ)(0,0);\r
3563  Double_t dReQ2n = (*fReQ)(1,0);\r
3564  //Double_t dReQ3n = (*fReQ)(2,0);\r
3565  //Double_t dReQ4n = (*fReQ)(3,0);\r
3566  Double_t dImQ1n = (*fImQ)(0,0);\r
3567  Double_t dImQ2n = (*fImQ)(1,0);\r
3568  //Double_t dImQ3n = (*fImQ)(2,0);\r
3569  //Double_t dImQ4n = (*fImQ)(3,0);\r
3570 \r
3571  // looping over all (pt,eta) bins and calculating correlations needed for differential flow: \r
3572  for(Int_t p=1;p<=fnBinsPt;p++)\r
3573  {\r
3574   for(Int_t e=1;e<=fnBinsEta;e++)\r
3575   {\r
3576    // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular (pt,eta) bin): \r
3577    Double_t p1n0kRe = 0.;\r
3578    Double_t p1n0kIm = 0.;\r
3579 \r
3580    // number of POIs in particular (pt,eta) bin:\r
3581    Double_t mp = 0.;\r
3582 \r
3583    // real and imaginary parts of q_{m*n,0} (non-weighted Q-vector evaluated for particles which are both RPs and POIs in particular (pt,eta) bin):\r
3584    Double_t q1n0kRe = 0.;\r
3585    Double_t q1n0kIm = 0.;\r
3586    Double_t q2n0kRe = 0.;\r
3587    Double_t q2n0kIm = 0.;\r
3588 \r
3589    // number of particles which are both RPs and POIs in particular (pt,eta) bin:\r
3590    Double_t mq = 0.;\r
3591    \r
3592    // q_{m*n,0}:\r
3593    q1n0kRe = fReEBE2D[2][0][0]->GetBinContent(fReEBE2D[2][0][0]->GetBin(p,e))\r
3594            * fReEBE2D[2][0][0]->GetBinEntries(fReEBE2D[2][0][0]->GetBin(p,e));\r
3595    q1n0kIm = fImEBE2D[2][0][0]->GetBinContent(fImEBE2D[2][0][0]->GetBin(p,e))\r
3596            * fImEBE2D[2][0][0]->GetBinEntries(fImEBE2D[2][0][0]->GetBin(p,e));\r
3597    q2n0kRe = fReEBE2D[2][1][0]->GetBinContent(fReEBE2D[2][1][0]->GetBin(p,e))\r
3598            * fReEBE2D[2][1][0]->GetBinEntries(fReEBE2D[2][1][0]->GetBin(p,e));\r
3599    q2n0kIm = fImEBE2D[2][1][0]->GetBinContent(fImEBE2D[2][1][0]->GetBin(p,e))\r
3600            * fImEBE2D[2][1][0]->GetBinEntries(fImEBE2D[2][1][0]->GetBin(p,e));\r
3601            \r
3602    mq = fReEBE2D[2][0][0]->GetBinEntries(fReEBE2D[2][0][0]->GetBin(p,e)); // to be improved (cross-checked by accessing other profiles here)\r
3603    \r
3604    if(type == "POI")\r
3605    {\r
3606     // p_{m*n,0}:\r
3607     p1n0kRe = fReEBE2D[1][0][0]->GetBinContent(fReEBE2D[1][0][0]->GetBin(p,e))\r
3608             * fReEBE2D[1][0][0]->GetBinEntries(fReEBE2D[1][0][0]->GetBin(p,e));\r
3609     p1n0kIm = fImEBE2D[1][0][0]->GetBinContent(fImEBE2D[1][0][0]->GetBin(p,e))  \r
3610             * fImEBE2D[1][0][0]->GetBinEntries(fImEBE2D[1][0][0]->GetBin(p,e));\r
3611             \r
3612     mp = fReEBE2D[1][0][0]->GetBinEntries(fReEBE2D[1][0][0]->GetBin(p,e)); // to be improved (cross-checked by accessing other profiles here)\r
3613     \r
3614     typeFlag = 1;\r
3615    }\r
3616    else if(type == "RP")\r
3617    {\r
3618     // p_{m*n,0} = q_{m*n,0}:\r
3619     p1n0kRe = q1n0kRe; \r
3620     p1n0kIm = q1n0kIm; \r
3621     mp = mq; \r
3622     \r
3623     typeFlag = 0;\r
3624    }\r
3625    \r
3626    // count events with non-empty (pt,eta) bin:\r
3627    if(mp>0)\r
3628    {\r
3629     fNonEmptyBins2D[typeFlag]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,1);\r
3630    }\r
3631    \r
3632    // 2'-particle correlation for particular (pt,eta) bin:\r
3633    Double_t two1n1nPtEta = 0.;\r
3634    if(mp*dMult-mq)\r
3635    {\r
3636     two1n1nPtEta = (p1n0kRe*dReQ1n+p1n0kIm*dImQ1n-mq)\r
3637                  / (mp*dMult-mq);\r
3638    \r
3639     // fill the 2D profile to get the average correlation for each (pt,eta) bin:\r
3640     if(type == "POI")\r
3641     { \r
3642      //f2pPtEtaPOI->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nPtEta,mp*dMult-mq);\r
3643      \r
3644      fCorrelationsPro[1][0][0][0]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nPtEta,mp*dMult-mq);\r
3645     }\r
3646     else if(type == "RP")\r
3647     {\r
3648      //f2pPtEtaRP->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nPtEta,mp*dMult-mq);   \r
3649      fCorrelationsPro[0][0][0][0]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nPtEta,mp*dMult-mq);\r
3650     }\r
3651    } // end of if(mp*dMult-mq)\r
3652   \r
3653    // 4'-particle correlation:\r
3654    Double_t four1n1n1n1nPtEta = 0.;\r
3655    if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3656        + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)) // to be improved (introduce a new variable for this expression)\r
3657    {\r
3658     four1n1n1n1nPtEta = ((pow(dReQ1n,2.)+pow(dImQ1n,2.))*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)\r
3659                       - q2n0kRe*(pow(dReQ1n,2.)-pow(dImQ1n,2.))\r
3660                       - 2.*q2n0kIm*dReQ1n*dImQ1n\r
3661                       - p1n0kRe*(dReQ1n*dReQ2n+dImQ1n*dImQ2n)\r
3662                       + p1n0kIm*(dImQ1n*dReQ2n-dReQ1n*dImQ2n)\r
3663                       - 2.*dMult*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)\r
3664                       - 2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*mq                      \r
3665                       + 6.*(q1n0kRe*dReQ1n+q1n0kIm*dImQ1n)                                            \r
3666                       + 1.*(q2n0kRe*dReQ2n+q2n0kIm*dImQ2n)                      \r
3667                       + 2.*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)                       \r
3668                       + 2.*mq*dMult                      \r
3669                       - 6.*mq)        \r
3670                       / ((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3671                           + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)); \r
3672     \r
3673     // fill the 2D profile to get the average correlation for each (pt, eta) bin:\r
3674     if(type == "POI")\r
3675     {\r
3676      //f4pPtEtaPOI->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nPtEta,\r
3677      //                  (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3678      //                   + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
3679      \r
3680      fCorrelationsPro[1][0][0][1]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nPtEta,\r
3681                                      (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3682                                      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
3683     }\r
3684     else if(type == "RP")\r
3685     {\r
3686      //f4pPtEtaRP->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nPtEta,\r
3687      //                 (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3688      //                  + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));   \r
3689                        \r
3690      fCorrelationsPro[0][0][0][1]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nPtEta,\r
3691                                        (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3692                                        + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));                   \r
3693     }\r
3694    } // end of if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3695      //            +mq*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
3696    \r
3697   } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
3698  } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
3699 \r
3700  \r
3701    \r
3702     \r
3703       \r
3704 } // end of AliFlowAnalysisWithQCumulants::CalculateCorrelationsForDifferentialFlow2D()\r
3705
3706
3707
3708  \r
3709  \r
3710 \r
3711 //================================================================================================================================\r
3712 \r
3713 \r
3714 void AliFlowAnalysisWithQCumulants::CalculateWeightedCorrelationsForDifferentialFlow2D(TString type)\r
3715 {\r
3716  // calculate all weighted correlations needed for differential flow \r
3717  \r
3718   if(type == "RP") // to be improved (removed)\r
3719  {\r
3720   cout<<endl;\r
3721  }\r
3722  // ... \r
3723  \r
3724  \r
3725  \r
3726  \r
3727  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
3728  Double_t dReQ1n1k = (*fReQ)(0,1);\r
3729  Double_t dReQ2n2k = (*fReQ)(1,2);\r
3730  Double_t dReQ1n3k = (*fReQ)(0,3);\r
3731  //Double_t dReQ4n4k = (*fReQ)(3,4);\r
3732  Double_t dImQ1n1k = (*fImQ)(0,1);\r
3733  Double_t dImQ2n2k = (*fImQ)(1,2);\r
3734  Double_t dImQ1n3k = (*fImQ)(0,3);\r
3735  //Double_t dImQ4n4k = (*fImQ)(3,4);\r
3736  \r
3737  // S^M_{p,k} (see .h file for the definition of fSMpk):\r
3738  Double_t dSM1p1k = (*fSMpk)(0,1);\r
3739  Double_t dSM1p2k = (*fSMpk)(0,2);\r
3740  Double_t dSM1p3k = (*fSMpk)(0,3);\r
3741  Double_t dSM2p1k = (*fSMpk)(1,1);\r
3742  Double_t dSM3p1k = (*fSMpk)(2,1);\r
3743  \r
3744  // looping over all (pt,eta) bins and calculating weighted correlations needed for differential flow: \r
3745  for(Int_t p=1;p<=fnBinsPt;p++)\r
3746  {\r
3747   for(Int_t e=1;e<=fnBinsEta;e++)\r
3748   {\r
3749    // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular (pt,eta) bin):  \r
3750    Double_t p1n0kRe = 0.;\r
3751    Double_t p1n0kIm = 0.;\r
3752 \r
3753    // number of POIs in particular (pt,eta) bin):\r
3754    Double_t mp = 0.;\r
3755 \r
3756    // real and imaginary parts of q_{m*n,k}: \r
3757    // (weighted Q-vector evaluated for particles which are both RPs and POIs in particular (pt,eta) bin)\r
3758    Double_t q1n2kRe = 0.;\r
3759    Double_t q1n2kIm = 0.;\r
3760    Double_t q2n1kRe = 0.;\r
3761    Double_t q2n1kIm = 0.;\r
3762 \r
3763    // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
3764    Double_t s1p1k = 0.; \r
3765    Double_t s1p2k = 0.; \r
3766    Double_t s1p3k = 0.; \r
3767    \r
3768    // M0111 from Eq. (118) in QC2c (to be improved (notation))\r
3769    Double_t dM0111 = 0.;\r
3770  \r
3771    if(type == "POI")\r
3772    {\r
3773     // p_{m*n,0}:\r
3774     p1n0kRe = fReEBE2D[1][0][0]->GetBinContent(fReEBE2D[1][0][0]->GetBin(p,e))\r
3775             * fReEBE2D[1][0][0]->GetBinEntries(fReEBE2D[1][0][0]->GetBin(p,e));\r
3776     p1n0kIm = fImEBE2D[1][0][0]->GetBinContent(fImEBE2D[1][0][0]->GetBin(p,e))\r
3777             * fImEBE2D[1][0][0]->GetBinEntries(fImEBE2D[1][0][0]->GetBin(p,e)); \r
3778             \r
3779     mp = fReEBE2D[1][0][0]->GetBinEntries(fReEBE2D[1][0][0]->GetBin(p,e));\r
3780     \r
3781     // q_{m*n,k}: \r
3782     q1n2kRe = fReEBE2D[2][0][2]->GetBinContent(fReEBE2D[2][0][2]->GetBin(p,e))\r
3783             * fReEBE2D[2][0][2]->GetBinEntries(fReEBE2D[2][0][2]->GetBin(p,e));\r
3784     q1n2kIm = fImEBE2D[2][0][2]->GetBinContent(fImEBE2D[2][0][2]->GetBin(p,e))\r
3785             * fImEBE2D[2][0][2]->GetBinEntries(fImEBE2D[2][0][2]->GetBin(p,e));\r
3786     q2n1kRe = fReEBE2D[2][1][1]->GetBinContent(fReEBE2D[2][1][1]->GetBin(p,e))\r
3787             * fReEBE2D[2][1][1]->GetBinEntries(fReEBE2D[2][1][1]->GetBin(p,e)); \r
3788     q2n1kIm = fImEBE2D[2][1][1]->GetBinContent(fImEBE2D[2][1][1]->GetBin(p,e))\r
3789             * fImEBE2D[2][1][1]->GetBinEntries(fImEBE2D[2][1][1]->GetBin(p,e));\r
3790        \r
3791     // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
3792     s1p1k = pow(fs2D[2][1]->GetBinContent(fs2D[2][1]->GetBin(p,e)),1.); \r
3793     s1p2k = pow(fs2D[2][2]->GetBinContent(fs2D[2][2]->GetBin(p,e)),1.); \r
3794     s1p3k = pow(fs2D[2][3]->GetBinContent(fs2D[2][3]->GetBin(p,e)),1.); \r
3795    \r
3796     // M0111 from Eq. (118) in QC2c (to be improved (notation)):\r
3797     dM0111 = mp*(dSM3p1k-3.*dSM1p1k*dSM1p2k+2.*dSM1p3k)\r
3798            - 3.*(s1p1k*(dSM2p1k-dSM1p2k)\r
3799            + 2.*(s1p3k-s1p2k*dSM1p1k));\r
3800    }\r
3801    else if(type == "RP")\r
3802    {\r
3803     p1n0kRe = fReEBE2D[0][0][0]->GetBinContent(fReEBE2D[0][0][0]->GetBin(p,e))\r
3804             * fReEBE2D[0][0][0]->GetBinEntries(fReEBE2D[0][0][0]->GetBin(p,e));\r
3805     p1n0kIm = fImEBE2D[0][0][0]->GetBinContent(fImEBE2D[0][0][0]->GetBin(p,e))\r
3806             * fImEBE2D[0][0][0]->GetBinEntries(fImEBE2D[0][0][0]->GetBin(p,e));\r
3807             \r
3808     mp = fReEBE2D[0][0][0]->GetBinEntries(fReEBE2D[0][0][0]->GetBin(p,e));\r
3809     \r
3810     // q_{m*n,k}: \r
3811     q1n2kRe = fReEBE2D[0][0][2]->GetBinContent(fReEBE2D[0][0][2]->GetBin(p,e))\r
3812             * fReEBE2D[0][0][2]->GetBinEntries(fReEBE2D[0][0][2]->GetBin(p,e));\r
3813     q1n2kIm = fImEBE2D[0][0][2]->GetBinContent(fImEBE2D[0][0][2]->GetBin(p,e))\r
3814             * fImEBE2D[0][0][2]->GetBinEntries(fImEBE2D[0][0][2]->GetBin(p,e));\r
3815     q2n1kRe = fReEBE2D[0][1][1]->GetBinContent(fReEBE2D[0][1][1]->GetBin(p,e))\r
3816             * fReEBE2D[0][1][1]->GetBinEntries(fReEBE2D[0][1][1]->GetBin(p,e));\r
3817     q2n1kIm = fImEBE2D[0][1][1]->GetBinContent(fImEBE2D[0][1][1]->GetBin(p,e))\r
3818             * fImEBE2D[0][1][1]->GetBinEntries(fImEBE2D[0][1][1]->GetBin(p,e));\r
3819    \r
3820     // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
3821     s1p1k = pow(fs2D[0][1]->GetBinContent(fs2D[0][1]->GetBin(p,e)),1.); \r
3822     s1p2k = pow(fs2D[0][2]->GetBinContent(fs2D[0][2]->GetBin(p,e)),1.); \r
3823     s1p3k = pow(fs2D[0][3]->GetBinContent(fs2D[0][3]->GetBin(p,e)),1.); \r
3824    \r
3825     // M0111 from Eq. (118) in QC2c (to be improved (notation)):\r
3826     dM0111 = mp*(dSM3p1k-3.*dSM1p1k*dSM1p2k+2.*dSM1p3k)\r
3827            - 3.*(s1p1k*(dSM2p1k-dSM1p2k)\r
3828            + 2.*(s1p3k-s1p2k*dSM1p1k));\r
3829     //...............................................................................................   \r
3830    }\r
3831    \r
3832    // 2'-particle correlation:\r
3833    Double_t two1n1nW0W1PtEta = 0.;\r
3834    if(mp*dSM1p1k-s1p1k)\r
3835    {\r
3836     two1n1nW0W1PtEta = (p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k-s1p1k)\r
3837                  / (mp*dSM1p1k-s1p1k);\r
3838    \r
3839     // fill the 2D profile to get the average correlation for each (pt, eta) bin:\r
3840     if(type == "POI")\r
3841     {\r
3842      //f2pPtEtaPOIW->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nW0W1PtEta,\r
3843      //                   mp*dSM1p1k-s1p1k);\r
3844      fCorrelationsPro[1][1][0][0]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nW0W1PtEta,mp*dSM1p1k-s1p1k);\r
3845     }\r
3846     else if(type == "RP")\r
3847     {\r
3848      //f2pPtEtaRPW->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nW0W1PtEta,\r
3849      //                  mp*dSM1p1k-s1p1k); \r
3850      fCorrelationsPro[0][1][0][0]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nW0W1PtEta,mp*dSM1p1k-s1p1k);  \r
3851     }\r
3852    } // end of if(mp*dMult-dmPrimePrimePtEta)\r
3853    \r
3854    // 4'-particle correlation:\r
3855    Double_t four1n1n1n1nW0W1W1W1PtEta = 0.;\r
3856    if(dM0111)\r
3857    {\r
3858     four1n1n1n1nW0W1W1W1PtEta = ((pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.))*(p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k)\r
3859                       - q2n1kRe*(pow(dReQ1n1k,2.)-pow(dImQ1n1k,2.))\r
3860                       - 2.*q2n1kIm*dReQ1n1k*dImQ1n1k\r
3861                       - p1n0kRe*(dReQ1n1k*dReQ2n2k+dImQ1n1k*dImQ2n2k)\r
3862                       + p1n0kIm*(dImQ1n1k*dReQ2n2k-dReQ1n1k*dImQ2n2k)\r
3863                       - 2.*dSM1p2k*(p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k)\r
3864                       - 2.*(pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.))*s1p1k                                            \r
3865                       + 6.*(q1n2kRe*dReQ1n1k+q1n2kIm*dImQ1n1k)                                           \r
3866                       + 1.*(q2n1kRe*dReQ2n2k+q2n1kIm*dImQ2n2k)                         \r
3867                       + 2.*(p1n0kRe*dReQ1n3k+p1n0kIm*dImQ1n3k)                      \r
3868                       + 2.*s1p1k*dSM1p2k                                      \r
3869                       - 6.*s1p3k)        \r
3870                       / dM0111; // to be imropoved (notation of dM0111)\r
3871    \r
3872     // fill the 2D profile to get the average correlation for each (pt, eta) bin:\r
3873     if(type == "POI")\r
3874     {\r
3875      //f4pPtEtaPOIW->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nW0W1W1W1PtEta,dM0111);\r
3876      fCorrelationsPro[1][1][0][1]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nW0W1W1W1PtEta,dM0111);\r
3877     }\r
3878     else if(type == "RP")\r
3879     {\r
3880      //f4pPtEtaRPW->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nW0W1W1W1PtEta,dM0111); \r
3881      fCorrelationsPro[0][1][0][1]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nW0W1W1W1PtEta,dM0111); \r
3882     }\r
3883    } // end of if(dM0111)\r
3884   \r
3885   } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
3886  } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
3887  \r
3888   \r
3889     \r
3890       \r
3891 } // end of AliFlowAnalysisWithQCumulants::CalculateWeightedCorrelationsForDifferentialFlow2D(TString type)\r
3892 \r
3893 \r
3894 //================================================================================================================================\r
3895 \r
3896  */  \r
3897 \r
3898 /*\r
3899 void AliFlowAnalysisWithQCumulants::FinalizeCorrelationsForDiffFlow(TString type, Bool_t useParticleWeights, TString eventWeights)\r
3900 {\r
3901  // 1.) Access average for 2D correlations from profiles and store them in 2D final results histograms;\r
3902  // 2.) Access spread for 2D correlations from profiles, calculate error and store it in 2D final results histograms;\r
3903  // 3.) Make projections along pt and eta axis and store results and errors in 1D final results histograms. \r
3904  \r
3905  Int_t typeFlag = -1;\r
3906  Int_t pWeightsFlag = -1;\r
3907  Int_t eWeightsFlag = -1;\r
3908 \r
3909  if(type == "RP")\r
3910  {\r
3911   typeFlag = 0;\r
3912  } else if(type == "POI")\r
3913    {\r
3914     typeFlag = 1;\r
3915    } else \r
3916      {\r
3917       cout<<"WARNING: type must be either RP or POI in AFAWQC::FCFDF() !!!!"<<endl;\r
3918       exit(0);\r
3919      }\r
3920      \r
3921  if(!useParticleWeights)\r
3922  {\r
3923   pWeightsFlag = 0;\r
3924  } else \r
3925    {\r
3926     pWeightsFlag = 1;   \r
3927    }   \r
3928    \r
3929  if(eventWeights == "exact")\r
3930  {\r
3931   eWeightsFlag = 0;\r
3932  }          \r
3933   \r
3934  // shortcuts:\r
3935  Int_t t = typeFlag;\r
3936  Int_t pW = pWeightsFlag;\r
3937  Int_t eW = eWeightsFlag;\r
3938  \r
3939  // from 2D histogram fNonEmptyBins2D make two 1D histograms fNonEmptyBins1D in pt and eta (to be improved (i.e. moved somewhere else))  \r
3940  // pt:\r
3941  for(Int_t p=1;p<fnBinsPt;p++)\r
3942  {\r
3943   Double_t contentPt = 0.;\r
3944   for(Int_t e=1;e<=fnBinsEta;e++)\r
3945   {\r
3946    contentPt += (fNonEmptyBins2D[t]->GetBinContent(fNonEmptyBins2D[t]->GetBin(p,e)));          \r
3947   }\r
3948   fNonEmptyBins1D[t][0]->SetBinContent(p,contentPt);\r
3949  }\r
3950  // eta:\r
3951  for(Int_t e=1;e<fnBinsEta;e++)\r
3952  {\r
3953   Double_t contentEta = 0.;\r
3954   for(Int_t p=1;p<=fnBinsPt;p++)\r
3955   {\r
3956    contentEta += (fNonEmptyBins2D[t]->GetBinContent(fNonEmptyBins2D[t]->GetBin(p,e)));          \r
3957   }\r
3958   fNonEmptyBins1D[t][1]->SetBinContent(e,contentEta);\r
3959  }\r
3960  \r
3961  // from 2D profile in (pt,eta) make two 1D profiles in (pt) and (eta):\r
3962  TProfile *profile[2][4]; // [0=pt,1=eta][correlation index] // to be improved (do not hardwire the correlation index)\r
3963  \r
3964  for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3965  {\r
3966   for(Int_t ci=0;ci<4;ci++) // correlation index\r
3967   {\r
3968    if(pe==0) profile[pe][ci] = this->MakePtProjection(fCorrelationsPro[t][pW][eW][ci]);\r
3969    if(pe==1) profile[pe][ci] = this->MakeEtaProjection(fCorrelationsPro[t][pW][eW][ci]);\r
3970   }\r
3971  }\r
3972   \r
3973  // transfer 2D profile into 2D histogram:\r
3974  // to be improved (see in documentation if there is a method to transfer values from 2D profile into 2D histogram)    \r
3975  for(Int_t ci=0;ci<4;ci++)\r
3976  {\r
3977   for(Int_t p=1;p<=fnBinsPt;p++)\r
3978   {\r
3979    for(Int_t e=1;e<=fnBinsEta;e++)\r
3980    {\r
3981     Double_t correlation = fCorrelationsPro[t][pW][eW][ci]->GetBinContent(fCorrelationsPro[t][pW][eW][ci]->GetBin(p,e)); \r
3982     Double_t spread = fCorrelationsPro[t][pW][eW][ci]->GetBinError(fCorrelationsPro[t][pW][eW][ci]->GetBin(p,e));\r
3983     Double_t nEvts = fNonEmptyBins2D[t]->GetBinContent(fNonEmptyBins2D[t]->GetBin(p,e));\r
3984     Double_t error = 0.;\r
3985     fFinalCorrelations2D[t][pW][eW][ci]->SetBinContent(fFinalCorrelations2D[t][pW][eW][ci]->GetBin(p,e),correlation);          \r
3986     if(nEvts>0)\r
3987     {\r
3988      error = spread/pow(nEvts,0.5);\r
3989      fFinalCorrelations2D[t][pW][eW][ci]->SetBinError(fFinalCorrelations2D[t][pW][eW][ci]->GetBin(p,e),error);\r
3990     }\r
3991    } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
3992   } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
3993  } // end of for(Int_t ci=0;ci<4;ci++)\r
3994  \r
3995  // transfer 1D profile into 1D histogram (pt):\r
3996  // to be improved (see in documentation if there is a method to transfer values from 1D profile into 1D histogram)    \r
3997  for(Int_t ci=0;ci<4;ci++)\r
3998  {\r
3999   for(Int_t p=1;p<=fnBinsPt;p++)\r
4000   {\r
4001    if(profile[0][ci])\r
4002    {\r
4003     Double_t correlation = profile[0][ci]->GetBinContent(p); \r
4004     Double_t spread = profile[0][ci]->GetBinError(p);\r
4005     Double_t nEvts = fNonEmptyBins1D[t][0]->GetBinContent(p);\r
4006     Double_t error = 0.;\r
4007     fFinalCorrelations1D[t][pW][eW][0][ci]->SetBinContent(p,correlation); \r
4008     if(nEvts>0)\r
4009     {\r
4010      error = spread/pow(nEvts,0.5);\r
4011      fFinalCorrelations1D[t][pW][eW][0][ci]->SetBinError(p,error);\r
4012     }  \r
4013    }   \r
4014   } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
4015  } // end of for(Int_t ci=0;ci<4;ci++)\r
4016  \r
4017  // transfer 1D profile into 1D histogram (eta):\r
4018  // to be improved (see in documentation if there is a method to transfer values from 1D profile into 1D histogram)    \r
4019  for(Int_t ci=0;ci<4;ci++)\r
4020  {\r
4021   for(Int_t e=1;e<=fnBinsEta;e++)\r
4022   {\r
4023    if(profile[1][ci])\r
4024    {\r
4025     Double_t correlation = profile[1][ci]->GetBinContent(e); \r
4026     fFinalCorrelations1D[t][pW][eW][1][ci]->SetBinContent(e,correlation);      \r
4027    }    \r
4028   } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
4029  } // end of for(Int_t ci=0;ci<4;ci++)\r
4030         \r
4031 } // end of void AliFlowAnalysisWithQCumulants::FinalizeCorrelationsForDiffFlow(TString type, Bool_t useParticleWeights, TString eventWeights)\r
4032 */\r
4033 \r
4034 \r
4035 //================================================================================================================================\r
4036 \r
4037 \r
4038 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulants(TString type, TString ptOrEta)\r
4039 {\r
4040  // calcualate cumulants for differential flow from measured correlations\r
4041  // Remark: cumulants calculated here are NOT corrected for non-uniform acceptance. This correction is applied in the method ...\r
4042  // to be improved (description) \r
4043  \r
4044  Int_t typeFlag = -1;\r
4045  Int_t ptEtaFlag = -1;\r
4046 \r
4047  if(type == "RP")\r
4048  {\r
4049   typeFlag = 0;\r
4050  } else if(type == "POI")\r
4051    {\r
4052     typeFlag = 1;\r
4053    } \r
4054      \r
4055  if(ptOrEta == "Pt")\r
4056  {\r
4057   ptEtaFlag = 0;\r
4058  } else if(ptOrEta == "Eta")\r
4059    {\r
4060     ptEtaFlag = 1;\r
4061    } \r
4062   \r
4063  // shortcuts:\r
4064  Int_t t = typeFlag;\r
4065  Int_t pe = ptEtaFlag;\r
4066      \r
4067  // common:\r
4068  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
4069  \r
4070  // correlation <<2>>: \r
4071  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1);\r
4072  \r
4073  // 1D:\r
4074  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
4075  {\r
4076   // reduced correlations:   \r
4077   Double_t twoPrime = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b); // <<2'>>(pt)\r
4078   Double_t fourPrime = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b); // <<4'>>(pt)\r
4079   // final statistical error of reduced correlations:\r
4080   //Double_t twoPrimeError = fFinalCorrelations1D[t][pW][eW][0][0]->GetBinError(p); \r
4081   // QC{2'}:\r
4082   Double_t qc2Prime = twoPrime; // QC{2'}\r
4083   //Double_t qc2PrimeError = twoPrimeError; // final stat. error of QC{2'}\r
4084   fDiffFlowCumulants[t][pe][0]->SetBinContent(b,qc2Prime); \r
4085   //fFinalCumulantsPt[t][pW][eW][nua][0]->SetBinError(p,qc2PrimeError);   \r
4086   // QC{4'}:\r
4087   Double_t qc4Prime = fourPrime - 2.*twoPrime*two; // QC{4'} = <<4'>> - 2*<<2'>><<2>>\r
4088   fDiffFlowCumulants[t][pe][1]->SetBinContent(b,qc4Prime); \r
4089  } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
4090  \r
4091     \r
4092  /* \r
4093  // 2D (pt,eta):\r
4094  // to be improved (see documentation if I can do all this without looping)\r
4095  for(Int_t p=1;p<=fnBinsPt;p++)\r
4096  {\r
4097   for(Int_t e=1;e<=fnBinsEta;e++) \r
4098   {  \r
4099    // reduced correlations:   \r
4100    Double_t twoPrime = fFinalCorrelations2D[t][pW][eW][0]->GetBinContent(fFinalCorrelations2D[t][pW][eW][0]->GetBin(p,e)); // <<2'>>(pt,eta)\r
4101    Double_t fourPrime = fFinalCorrelations2D[t][pW][eW][1]->GetBinContent(fFinalCorrelations2D[t][pW][eW][1]->GetBin(p,e)); // <<4'>>(pt,eta)\r
4102    for(Int_t nua=0;nua<2;nua++)\r
4103    {\r
4104     // QC{2'}:\r
4105     Double_t qc2Prime = twoPrime; // QC{2'} = <<2'>>\r
4106     fFinalCumulants2D[t][pW][eW][nua][0]->SetBinContent(fFinalCumulants2D[t][pW][eW][nua][0]->GetBin(p,e),qc2Prime);    \r
4107     // QC{4'}:\r
4108     Double_t qc4Prime = fourPrime - 2.*twoPrime*two; // QC{4'} = <<4'>> - 2*<<2'>><<2>>\r
4109     fFinalCumulants2D[t][pW][eW][nua][1]->SetBinContent(fFinalCumulants2D[t][pW][eW][nua][1]->GetBin(p,e),qc4Prime);   \r
4110    } // end of for(Int_t nua=0;nua<2;nua++)   \r
4111   } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
4112  } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
4113  */\r
4114    \r
4115 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulants(TString type, Bool_t useParticleWeights, TString eventWeights); \r
4116 \r
4117 \r
4118 //================================================================================================================================\r
4119 \r
4120 \r
4121 void AliFlowAnalysisWithQCumulants::CalculateFinalResultsForRPandPOIIntegratedFlow(TString type)\r
4122 {\r
4123  // calculate final results for integrated flow of RPs and POIs \r
4124   \r
4125  Int_t typeFlag = -1;\r
4126 \r
4127  if(type == "RP")\r
4128  {\r
4129   typeFlag = 0;\r
4130  } else if(type == "POI")\r
4131    {\r
4132     typeFlag = 1;\r
4133    } else \r
4134      {\r
4135       cout<<"WARNING: type must be either RP or POI in AFAWQC::CDF() !!!!"<<endl;\r
4136       exit(0);\r
4137      }\r
4138      \r
4139  // shortcuts:\r
4140  Int_t t = typeFlag;\r
4141   \r
4142  // pt yield:    \r
4143  TH1F *yield2ndPt = NULL;\r
4144  TH1F *yield4thPt = NULL;\r
4145  TH1F *yield6thPt = NULL;\r
4146  TH1F *yield8thPt = NULL;\r
4147  \r
4148  if(type == "POI")\r
4149  {\r
4150   yield2ndPt = (TH1F*)(fCommonHists2nd->GetHistPtPOI())->Clone();\r
4151   yield4thPt = (TH1F*)(fCommonHists4th->GetHistPtPOI())->Clone();\r
4152   yield6thPt = (TH1F*)(fCommonHists6th->GetHistPtPOI())->Clone();\r
4153   yield8thPt = (TH1F*)(fCommonHists8th->GetHistPtPOI())->Clone();  \r
4154  } \r
4155  else if(type == "RP")\r
4156  {\r
4157   yield2ndPt = (TH1F*)(fCommonHists2nd->GetHistPtRP())->Clone();\r
4158   yield4thPt = (TH1F*)(fCommonHists4th->GetHistPtRP())->Clone();\r
4159   yield6thPt = (TH1F*)(fCommonHists6th->GetHistPtRP())->Clone();\r
4160   yield8thPt = (TH1F*)(fCommonHists8th->GetHistPtRP())->Clone();  \r
4161  } \r
4162  \r
4163  Int_t nBinsPt = yield2ndPt->GetNbinsX();\r
4164  \r
4165  TH1D *flow2ndPt = NULL;\r
4166  TH1D *flow4thPt = NULL;\r
4167  TH1D *flow6thPt = NULL;\r
4168  TH1D *flow8thPt = NULL;\r
4169  \r
4170  // to be improved (hardwired pt index)\r
4171  flow2ndPt = (TH1D*)fDiffFlow[t][0][0]->Clone();\r
4172  flow4thPt = (TH1D*)fDiffFlow[t][0][1]->Clone();\r
4173  flow6thPt = (TH1D*)fDiffFlow[t][0][2]->Clone();\r
4174  flow8thPt = (TH1D*)fDiffFlow[t][0][3]->Clone(); \r
4175    \r
4176  Double_t dvn2nd = 0., dvn4th = 0., dvn6th = 0., dvn8th = 0.; // differential flow\r
4177  Double_t dErrvn2nd = 0., dErrvn4th = 0., dErrvn6th = 0., dErrvn8th = 0.; // error on differential flow\r
4178  \r
4179  Double_t dVn2nd = 0., dVn4th = 0., dVn6th = 0., dVn8th = 0.; // integrated flow \r
4180  Double_t dErrVn2nd = 0., dErrVn4th = 0., dErrVn6th = 0., dErrVn8th = 0.; // error on integrated flow\r
4181 \r
4182  Double_t dYield2nd = 0., dYield4th = 0., dYield6th = 0., dYield8th = 0.; // pt yield \r
4183  Double_t dSum2nd = 0., dSum4th = 0., dSum6th = 0., dSum8th = 0.; // needed for normalizing integrated flow\r
4184  \r
4185  // looping over pt bins:\r
4186  for(Int_t p=1;p<nBinsPt+1;p++)\r
4187  {\r
4188   dvn2nd = flow2ndPt->GetBinContent(p);\r
4189   dvn4th = flow4thPt->GetBinContent(p);\r
4190   dvn6th = flow6thPt->GetBinContent(p);\r
4191   dvn8th = flow8thPt->GetBinContent(p);\r
4192   \r
4193   dErrvn2nd = flow2ndPt->GetBinError(p);\r
4194   dErrvn4th = flow4thPt->GetBinError(p);\r
4195   dErrvn6th = flow6thPt->GetBinError(p);\r
4196   dErrvn8th = flow8thPt->GetBinError(p);\r
4197 \r
4198   dYield2nd = yield2ndPt->GetBinContent(p);  \r
4199   dYield4th = yield4thPt->GetBinContent(p);\r
4200   dYield6th = yield6thPt->GetBinContent(p);\r
4201   dYield8th = yield8thPt->GetBinContent(p);\r
4202   \r
4203   dVn2nd += dvn2nd*dYield2nd;\r
4204   dVn4th += dvn4th*dYield4th;\r
4205   dVn6th += dvn6th*dYield6th;\r
4206   dVn8th += dvn8th*dYield8th;\r
4207   \r
4208   dSum2nd += dYield2nd;\r
4209   dSum4th += dYield4th;\r
4210   dSum6th += dYield6th;\r
4211   dSum8th += dYield8th;\r
4212   \r
4213   dErrVn2nd += dYield2nd*dYield2nd*dErrvn2nd*dErrvn2nd; // ro be improved (check this relation)\r
4214   dErrVn4th += dYield4th*dYield4th*dErrvn4th*dErrvn4th;\r
4215   dErrVn6th += dYield6th*dYield6th*dErrvn6th*dErrvn6th;\r
4216   dErrVn8th += dYield8th*dYield8th*dErrvn8th*dErrvn8th;\r
4217     \r
4218  } // end of for(Int_t p=1;p<nBinsPt+1;p++)\r
4219 \r
4220  // normalizing the results for integrated flow:\r
4221  if(dSum2nd) \r
4222  {\r
4223   dVn2nd /= dSum2nd;\r
4224   dErrVn2nd /= (dSum2nd*dSum2nd);\r
4225   dErrVn2nd = TMath::Sqrt(dErrVn2nd);\r
4226  } \r
4227  if(dSum4th) \r
4228  {\r
4229   dVn4th /= dSum4th;\r
4230   dErrVn4th /= (dSum4th*dSum4th);\r
4231   dErrVn4th = TMath::Sqrt(dErrVn4th);\r
4232  } \r
4233  //if(dSum6th) dVn6th/=dSum6th;\r
4234  //if(dSum8th) dVn8th/=dSum8th;\r
4235   \r
4236  // storing the results for integrated flow in common histos: (to be improved: new method for this?)\r
4237  if(type == "POI")\r
4238  {\r
4239   fCommonHistsResults2nd->FillIntegratedFlowPOI(dVn2nd,dErrVn2nd); \r
4240   fCommonHistsResults4th->FillIntegratedFlowPOI(dVn4th,dErrVn4th); \r
4241   fCommonHistsResults6th->FillIntegratedFlowPOI(dVn6th,0.); // to be improved (errors)\r
4242   fCommonHistsResults8th->FillIntegratedFlowPOI(dVn8th,0.); // to be improved (errors)\r
4243  }\r
4244  else if (type == "RP")\r
4245  {\r
4246   fCommonHistsResults2nd->FillIntegratedFlowRP(dVn2nd,dErrVn2nd); \r
4247   fCommonHistsResults4th->FillIntegratedFlowRP(dVn4th,dErrVn4th);\r
4248   fCommonHistsResults6th->FillIntegratedFlowRP(dVn6th,0.); // to be improved (errors)\r
4249   fCommonHistsResults8th->FillIntegratedFlowRP(dVn8th,0.); // to be improved (errors)\r
4250  }\r
4251  \r
4252  delete flow2ndPt;\r
4253  delete flow4thPt;\r
4254  //delete flow6thPt;\r
4255  //delete flow8thPt;\r
4256  \r
4257  delete yield2ndPt;\r
4258  delete yield4thPt;\r
4259  delete yield6thPt;\r
4260  delete yield8thPt;\r
4261            \r
4262 } // end of AliFlowAnalysisWithQCumulants::CalculateFinalResultsForRPandPOIIntegratedFlow(TString type)\r
4263 \r
4264 \r
4265 //================================================================================================================================\r
4266 \r
4267 \r
4268 void AliFlowAnalysisWithQCumulants::InitializeArraysForDistributions()\r
4269 {\r
4270  // initialize arrays used for distributions:\r
4271  \r
4272  /*\r
4273  \r
4274  for(Int_t pW=0;pW<2;pW++) // particle weights not used (0) or used (1)\r
4275  {\r
4276   for(Int_t eW=0;eW<2;eW++)\r
4277   {\r
4278    for(Int_t di=0;di<4;di++) // distribution index\r
4279    {\r
4280     fDistributions[pW][eW][di] = NULL;\r
4281    }\r
4282   } \r
4283  }\r
4284  \r
4285  */\r
4286  \r
4287 } // end of void AliFlowAnalysisWithQCumulants::InitializeArraysForDistributions()\r
4288 \r
4289 \r
4290 //================================================================================================================================\r
4291 \r
4292 \r
4293 void AliFlowAnalysisWithQCumulants::BookEverythingForDistributions()\r
4294 {\r
4295  // book all histograms for distributions\r
4296  \r
4297  /*\r
4298  //weighted <2>_{n|n} distribution\r
4299  f2pDistribution = new TH1D("f2pDistribution","<2>_{n|n} distribution",100000,-0.02,0.1);\r
4300  f2pDistribution->SetXTitle("<2>_{n|n}");\r
4301  f2pDistribution->SetYTitle("Counts");\r
4302  fHistList->Add(f2pDistribution);\r
4303 \r
4304  //weighted <4>_{n,n|n,n} distribution\r
4305  f4pDistribution = new TH1D("f4pDistribution","<4>_{n,n|n,n} distribution",100000,-0.00025,0.002);\r
4306  f4pDistribution->SetXTitle("<4>_{n,n|n,n}");\r
4307  f4pDistribution->SetYTitle("Counts");\r
4308  fHistList->Add(f4pDistribution); \r
4309  \r
4310  //weighted <6>_{n,n,n|n,n,n} distribution\r
4311  f6pDistribution = new TH1D("f6pDistribution","<6>_{n,n,n|n,n,n} distribution",100000,-0.000005,0.000025);\r
4312  f6pDistribution->SetXTitle("<6>_{n,n,n|n,n,n}");\r
4313  f6pDistribution->SetYTitle("Counts");\r
4314  fHistList->Add(f6pDistribution);\r
4315  \r
4316  //weighted <8>_{n,n,n,n|n,n,n,n} distribution\r
4317  f8pDistribution = new TH1D("f8pDistribution","<8>_{n,n,n,n|n,n,n,n} distribution",100000,-0.000000001,0.00000001);\r
4318  f8pDistribution->SetXTitle("<8>_{n,n,n,n|n,n,n,n}");\r
4319  f8pDistribution->SetYTitle("Counts");\r
4320  fHistList->Add(f8pDistribution);\r
4321  */\r
4322  \r
4323 } // end of void AliFlowAnalysisWithQCumulants::BookEverythingForDistributions()\r
4324 \r
4325 \r
4326 //================================================================================================================================\r
4327 \r
4328 \r
4329 void AliFlowAnalysisWithQCumulants::BookAndNestAllLists()\r
4330 {\r
4331  // Book and nest all lists nested in the base list fHistList.\r
4332  //  a) Book and nest lists for integrated flow;\r
4333  //  b) Book and nest lists for differential flow;\r
4334  //  c) Book and nest list for particle weights;\r
4335  //  d) Book and nest list for distributions;\r
4336  //  e) Book and nest list for nested loops;\r
4337  \r
4338  // a) Book and nest all lists for integrated flow:\r
4339  // base list for integrated flow:\r
4340  fIntFlowList = new TList();\r
4341  fIntFlowList->SetName("Integrated Flow");\r
4342  fIntFlowList->SetOwner(kTRUE);\r
4343  fHistList->Add(fIntFlowList);\r
4344  // list holding profiles: \r
4345  fIntFlowProfiles = new TList();\r
4346  fIntFlowProfiles->SetName("Profiles");\r
4347  fIntFlowProfiles->SetOwner(kTRUE);\r
4348  fIntFlowList->Add(fIntFlowProfiles);\r
4349  // list holding histograms with results:\r
4350  fIntFlowResults = new TList();\r
4351  fIntFlowResults->SetName("Results");\r
4352  fIntFlowResults->SetOwner(kTRUE);\r
4353  fIntFlowList->Add(fIntFlowResults);\r
4354  \r
4355  // b) Book and nest lists for differential flow;\r
4356  fDiffFlowList = new TList();\r
4357  fDiffFlowList->SetName("Differential Flow");\r
4358  fDiffFlowList->SetOwner(kTRUE); \r
4359  fHistList->Add(fDiffFlowList);\r
4360  // list holding profiles: \r
4361  fDiffFlowProfiles = new TList(); \r
4362  fDiffFlowProfiles->SetName("Profiles");\r
4363  fDiffFlowProfiles->SetOwner(kTRUE);\r
4364  fDiffFlowList->Add(fDiffFlowProfiles);\r
4365  // list holding histograms with results: \r
4366  fDiffFlowResults = new TList();\r
4367  fDiffFlowResults->SetName("Results");\r
4368  fDiffFlowResults->SetOwner(kTRUE);\r
4369  fDiffFlowList->Add(fDiffFlowResults);\r
4370  // flags used for naming nested lists in list fDiffFlowProfiles and fDiffFlowResults:  \r
4371  TList list;\r
4372  list.SetOwner(kTRUE);\r
4373  TString typeFlag[2] = {"RP","POI"};  \r
4374  TString ptEtaFlag[2] = {"p_{T}","#eta"}; \r
4375  TString powerFlag[2] = {"linear","quadratic"};   \r
4376  // nested lists in fDiffFlowProfiles (~/Differential Flow/Profiles):\r
4377  for(Int_t t=0;t<2;t++) // type: RP or POI\r
4378  {\r
4379   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
4380   {\r
4381    // list holding profiles with correlations:\r
4382    fDiffFlowCorrelationsProList[t][pe] = (TList*)list.Clone();\r
4383    fDiffFlowCorrelationsProList[t][pe]->SetName(Form("Profiles with correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4384    fDiffFlowProfiles->Add(fDiffFlowCorrelationsProList[t][pe]);\r
4385    // list holding profiles with products of correlations:\r
4386    fDiffFlowProductOfCorrelationsProList[t][pe] = (TList*)list.Clone();\r
4387    fDiffFlowProductOfCorrelationsProList[t][pe]->SetName(Form("Profiles with products of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4388    fDiffFlowProfiles->Add(fDiffFlowProductOfCorrelationsProList[t][pe]);\r
4389    // list holding profiles with corrections:\r
4390    fDiffFlowCorrectionsProList[t][pe] = (TList*)list.Clone();\r
4391    fDiffFlowCorrectionsProList[t][pe]->SetName(Form("Profiles with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4392    fDiffFlowProfiles->Add(fDiffFlowCorrectionsProList[t][pe]);   \r
4393   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
4394  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI   \r
4395  // nested lists in fDiffFlowResults (~/Differential Flow/Results):\r
4396  for(Int_t t=0;t<2;t++) // type: RP or POI\r
4397  {\r
4398   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
4399   {\r
4400    // list holding histograms with correlations:\r
4401    fDiffFlowCorrelationsHistList[t][pe] = (TList*)list.Clone();\r
4402    fDiffFlowCorrelationsHistList[t][pe]->SetName(Form("Correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4403    fDiffFlowResults->Add(fDiffFlowCorrelationsHistList[t][pe]);\r
4404    // list holding histograms with corrections:\r
4405    fDiffFlowCorrectionsHistList[t][pe] = (TList*)list.Clone();\r
4406    fDiffFlowCorrectionsHistList[t][pe]->SetName(Form("Histograms with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4407    fDiffFlowResults->Add(fDiffFlowCorrectionsHistList[t][pe]);   \r
4408    for(Int_t power=0;power<2;power++)\r
4409    {\r
4410     // list holding histograms with sums of event weights:\r
4411     fDiffFlowSumOfEventWeightsHistList[t][pe][power] = (TList*)list.Clone();\r
4412     fDiffFlowSumOfEventWeightsHistList[t][pe][power]->SetName(Form("Sum of %s event weights (%s, %s)",powerFlag[power].Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4413     fDiffFlowResults->Add(fDiffFlowSumOfEventWeightsHistList[t][pe][power]);    \r
4414    } // end of for(Int_t power=0;power<2;power++)\r
4415    // list holding histograms with sums of products of event weights:\r
4416    fDiffFlowSumOfProductOfEventWeightsHistList[t][pe] = (TList*)list.Clone();\r
4417    fDiffFlowSumOfProductOfEventWeightsHistList[t][pe]->SetName(Form("Sum of products of event weights (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4418    fDiffFlowResults->Add(fDiffFlowSumOfProductOfEventWeightsHistList[t][pe]);\r
4419    // list holding histograms with covariances of correlations:\r
4420    fDiffFlowCovariancesHistList[t][pe] = (TList*)list.Clone();\r
4421    fDiffFlowCovariancesHistList[t][pe]->SetName(Form("Covariances of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4422    fDiffFlowResults->Add(fDiffFlowCovariancesHistList[t][pe]);\r
4423    // list holding histograms with differential Q-cumulants:\r
4424    fDiffFlowCumulantsHistList[t][pe] = (TList*)list.Clone();\r
4425    fDiffFlowCumulantsHistList[t][pe]->SetName(Form("Differential Q-cumulants (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4426    fDiffFlowResults->Add(fDiffFlowCumulantsHistList[t][pe]);   \r
4427    // list holding histograms with differential flow estimates from Q-cumulants:\r
4428    fDiffFlowHistList[t][pe] = (TList*)list.Clone();\r
4429    fDiffFlowHistList[t][pe]->SetName(Form("Differential flow (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4430    fDiffFlowResults->Add(fDiffFlowHistList[t][pe]);      \r
4431   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
4432  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
4433   \r
4434  // c) Book and nest list for particle weights:\r
4435  fWeightsList->SetName("Weights");\r
4436  fWeightsList->SetOwner(kTRUE);   \r
4437  fHistList->Add(fWeightsList); \r
4438 \r
4439  // d) Book and nest list for distributions:\r
4440  fDistributionsList = new TList();\r
4441  fDistributionsList->SetName("Distributions");\r
4442  fDistributionsList->SetOwner(kTRUE);\r
4443  fHistList->Add(fDistributionsList);\r
4444  \r
4445  // e) Book and nest list for nested loops:\r
4446  fNestedLoopsList = new TList();\r
4447  fNestedLoopsList->SetName("Nested Loops");\r
4448  fNestedLoopsList->SetOwner(kTRUE);\r
4449  fHistList->Add(fNestedLoopsList);\r
4450  \r
4451 } // end of void AliFlowAnalysisWithQCumulants::BookAndNestAllLists()\r
4452 \r
4453 \r
4454 //================================================================================================================================\r
4455 \r
4456 \r
4457 void AliFlowAnalysisWithQCumulants::FillCommonHistResultsDiffFlow(TString type)\r
4458 {\r
4459  // fill common result histograms for differential flow\r
4460  \r
4461  Int_t typeFlag = -1;\r
4462  //Int_t ptEtaFlag = -1;\r
4463 \r
4464  if(type == "RP")\r
4465  {\r
4466   typeFlag = 0;\r
4467  } else if(type == "POI")\r
4468    {\r
4469     typeFlag = 1;\r
4470    } \r
4471   \r
4472  // shortcuts:\r
4473  Int_t t = typeFlag;\r
4474  //Int_t pe = ptEtaFlag;\r
4475 \r
4476  // to be improved (implement protection here)\r
4477      \r
4478  if(!(fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th))\r
4479  {\r
4480   cout<<"WARNING: fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th"<<endl; \r
4481   cout<<"         is NULL in AFAWQC::FCHRIF() !!!!"<<endl;\r
4482   exit(0);\r
4483  }\r
4484  \r
4485  // pt:\r
4486  for(Int_t p=1;p<=fnBinsPt;p++)\r
4487  {\r
4488   Double_t v2 = fDiffFlow[t][0][0]->GetBinContent(p);\r
4489   Double_t v4 = fDiffFlow[t][0][1]->GetBinContent(p);\r
4490   Double_t v6 = fDiffFlow[t][0][2]->GetBinContent(p);\r
4491   Double_t v8 = fDiffFlow[t][0][3]->GetBinContent(p);\r
4492   \r
4493   Double_t v2Error = fDiffFlow[t][0][0]->GetBinError(p);\r
4494   Double_t v4Error = fDiffFlow[t][0][1]->GetBinError(p);\r
4495   //Double_t v6Error = fFinalFlow1D[t][pW][nua][0][2]->GetBinError(p);\r
4496   //Double_t v8Error = fFinalFlow1D[t][pW][nua][0][3]->GetBinError(p);\r
4497  \r
4498   if(type == "RP")\r
4499   {\r
4500    fCommonHistsResults2nd->FillDifferentialFlowPtRP(p,v2,v2Error);\r
4501    fCommonHistsResults4th->FillDifferentialFlowPtRP(p,v4,v4Error);\r
4502    fCommonHistsResults6th->FillDifferentialFlowPtRP(p,v6,0.);\r
4503    fCommonHistsResults8th->FillDifferentialFlowPtRP(p,v8,0.);\r
4504   } else if(type == "POI")\r
4505     {\r
4506      fCommonHistsResults2nd->FillDifferentialFlowPtPOI(p,v2,v2Error);\r
4507      fCommonHistsResults4th->FillDifferentialFlowPtPOI(p,v4,v4Error);\r
4508      fCommonHistsResults6th->FillDifferentialFlowPtPOI(p,v6,0.);\r
4509      fCommonHistsResults8th->FillDifferentialFlowPtPOI(p,v8,0.);\r
4510     }\r
4511  } // end of for(Int_t p=1;p<=fnBinsPt;p++)   \r
4512  \r
4513  // eta:\r
4514  for(Int_t e=1;e<=fnBinsEta;e++)\r
4515  {\r
4516   Double_t v2 = fDiffFlow[t][1][0]->GetBinContent(e);\r
4517   Double_t v4 = fDiffFlow[t][1][1]->GetBinContent(e);\r
4518   Double_t v6 = fDiffFlow[t][1][2]->GetBinContent(e);\r
4519   Double_t v8 = fDiffFlow[t][1][3]->GetBinContent(e);\r
4520   \r
4521   Double_t v2Error = fDiffFlow[t][1][0]->GetBinError(e);\r
4522   Double_t v4Error = fDiffFlow[t][1][1]->GetBinError(e);\r
4523   //Double_t v6Error = fDiffFlow[t][1][2]->GetBinError(e);\r
4524   //Double_t v8Error = fDiffFlow[t][1][3]->GetBinError(e);\r
4525  \r
4526   if(type == "RP")\r
4527   {\r
4528    fCommonHistsResults2nd->FillDifferentialFlowEtaRP(e,v2,v2Error);\r
4529    fCommonHistsResults4th->FillDifferentialFlowEtaRP(e,v4,v4Error);\r
4530    fCommonHistsResults6th->FillDifferentialFlowEtaRP(e,v6,0.);\r
4531    fCommonHistsResults8th->FillDifferentialFlowEtaRP(e,v8,0.);\r
4532   } else if(type == "POI")\r
4533     {\r
4534      fCommonHistsResults2nd->FillDifferentialFlowEtaPOI(e,v2,v2Error);\r
4535      fCommonHistsResults4th->FillDifferentialFlowEtaPOI(e,v4,v4Error);\r
4536      fCommonHistsResults6th->FillDifferentialFlowEtaPOI(e,v6,0.);\r
4537      fCommonHistsResults8th->FillDifferentialFlowEtaPOI(e,v8,0.);\r
4538     }\r
4539  } // end of for(Int_t e=1;e<=fnBinsEta;e++)    \r
4540  \r
4541 } // end of void AliFlowAnalysisWithQCumulants::FillCommonHistResultsDiffFlow(TString type, Bool_t useParticleWeights, TString eventWeights, Bool_t correctedForNUA)\r
4542 \r
4543 \r
4544 //================================================================================================================================\r
4545 \r
4546 \r
4547 void AliFlowAnalysisWithQCumulants::AccessConstants()\r
4548 {\r
4549  // access needed common constants from AliFlowCommonConstants\r
4550  \r
4551  fnBinsPhi = AliFlowCommonConstants::GetNbinsPhi();\r
4552  fPhiMin = AliFlowCommonConstants::GetPhiMin();      \r
4553  fPhiMax = AliFlowCommonConstants::GetPhiMax();\r
4554  if(fnBinsPhi) fPhiBinWidth = (fPhiMax-fPhiMin)/fnBinsPhi;  \r
4555  fnBinsPt = AliFlowCommonConstants::GetNbinsPt();\r
4556  fPtMin = AliFlowCommonConstants::GetPtMin();        \r
4557  fPtMax = AliFlowCommonConstants::GetPtMax();\r
4558  if(fnBinsPt) fPtBinWidth = (fPtMax-fPtMin)/fnBinsPt;  \r
4559  fnBinsEta = AliFlowCommonConstants::GetNbinsEta();\r
4560  fEtaMin = AliFlowCommonConstants::GetEtaMin();      \r
4561  fEtaMax = AliFlowCommonConstants::GetEtaMax();\r
4562  if(fnBinsEta) fEtaBinWidth = (fEtaMax-fEtaMin)/fnBinsEta;  \r
4563  \r
4564 } // end of void AliFlowAnalysisWithQCumulants::AccessConstants()\r
4565 \r
4566 \r
4567 //================================================================================================================================\r
4568 \r
4569 \r
4570 void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfEventWeights()\r
4571 {\r
4572  // Calculate sum of linear and quadratic event weights for correlations\r
4573  \r
4574  \r
4575  /*\r
4576  Double_t dMult = (*fSMpk)(0,0); // multiplicity \r
4577 \r
4578  Double_t eventWeight[4] = {0}; \r
4579  \r
4580  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
4581  {\r
4582   eventWeight[0] = dMult*(dMult-1); // event weight for <2> \r
4583   eventWeight[1] = dMult*(dMult-1)*(dMult-2)*(dMult-3); // event weight for <4> \r
4584   eventWeight[2] = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5); // event weight for <6> \r
4585   eventWeight[3] = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5)*(dMult-6)*(dMult-7); // event weight for <8> \r
4586  } else\r
4587    {\r
4588     eventWeight[0] = (*fSMpk)(1,1)-(*fSMpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j;\r
4589     eventWeight[1] = (*fSMpk)(3,1)-6.*(*fSMpk)(0,2)*(*fSMpk)(1,1)  \r
4590                    + 8.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
4591                    + 3.*(*fSMpk)(1,2)-6.*(*fSMpk)(0,4); // dM1111 = sum_{i,j,k,l=1,i!=j!=k!=l}^M w_i w_j w_k w_l\r
4592     //eventWeight[2] = ... // to be improved (calculated)               \r
4593     //eventWeight[3] = ... // to be improved (calculated)              \r
4594    }\r
4595  */\r
4596         \r
4597                       \r
4598  for(Int_t p=0;p<2;p++) // power-1\r
4599  {\r
4600   for(Int_t ci=0;ci<4;ci++) // correlation index\r
4601   { \r
4602    fIntFlowSumOfEventWeights[p]->Fill(ci+0.5,pow(fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci+1),p+1)); \r
4603   }\r
4604  }\r
4605   \r
4606 } // end of void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfEventWeights()\r
4607 \r
4608 \r
4609 //================================================================================================================================\r
4610 \r
4611 \r
4612 void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfProductOfEventWeights()\r
4613 {\r
4614  // Calculate sum of product of event weights for correlations\r
4615  \r
4616  \r
4617  /*\r
4618  Double_t dMult = (*fSMpk)(0,0); // multiplicity \r
4619 \r
4620  Double_t eventWeight[4] = {0}; \r
4621  \r
4622  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
4623  {\r
4624   eventWeight[0] = dMult*(dMult-1); // event weight for <2> \r
4625   eventWeight[1] = dMult*(dMult-1)*(dMult-2)*(dMult-3); // event weight for <4> \r
4626   eventWeight[2] = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5); // event weight for <6> \r
4627   eventWeight[3] = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5)*(dMult-6)*(dMult-7); // event weight for <8> \r
4628  } else\r
4629    {\r
4630     eventWeight[0] = (*fSMpk)(1,1)-(*fSMpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j;\r
4631     eventWeight[1] = (*fSMpk)(3,1)-6.*(*fSMpk)(0,2)*(*fSMpk)(1,1)  \r
4632                    + 8.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
4633                    + 3.*(*fSMpk)(1,2)-6.*(*fSMpk)(0,4); // dM1111 = sum_{i,j,k,l=1,i!=j!=k!=l}^M w_i w_j w_k w_l\r
4634     //eventWeight[2] = ... // to be improved (calculated)               \r
4635     //eventWeight[3] = ... // to be improved (calculated)              \r
4636    }\r
4637 \r
4638  fIntFlowSumOfProductOfEventWeights->Fill(0.5,eventWeight[0]*eventWeight[1]); \r
4639  fIntFlowSumOfProductOfEventWeights->Fill(1.5,eventWeight[0]*eventWeight[2]); \r
4640  fIntFlowSumOfProductOfEventWeights->Fill(2.5,eventWeight[0]*eventWeight[3]); \r
4641  fIntFlowSumOfProductOfEventWeights->Fill(3.5,eventWeight[1]*eventWeight[2]); \r
4642  fIntFlowSumOfProductOfEventWeights->Fill(4.5,eventWeight[1]*eventWeight[3]); \r
4643  fIntFlowSumOfProductOfEventWeights->Fill(5.5,eventWeight[2]*eventWeight[3]); \r
4644  */\r
4645   \r
4646  \r
4647  Int_t counter = 0;\r
4648  \r
4649  for(Int_t ci1=1;ci1<4;ci1++)\r
4650  {\r
4651   for(Int_t ci2=ci1+1;ci2<=4;ci2++)\r
4652   {\r
4653    fIntFlowSumOfProductOfEventWeights->Fill(0.5+counter++,\r
4654                                             fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci1)*fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci2));\r
4655   }\r
4656  }\r
4657 \r
4658  \r
4659 \r
4660 } // end of void AliFlowAnalysisWithQCumulants::CalculateIntFlowIntFlowSumOfProductOfEventWeights()\r
4661 \r
4662 \r
4663 //================================================================================================================================\r
4664 \r
4665 \r
4666 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelations(TString type, TString ptOrEta)\r
4667 {\r
4668  // calculate reduced correlations for RPs or POIs in pt or eta bins\r
4669 \r
4670  // multiplicity:\r
4671  Double_t dMult = (*fSMpk)(0,0);\r
4672  \r
4673  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
4674  Double_t dReQ1n = (*fReQ)(0,0);\r
4675  Double_t dReQ2n = (*fReQ)(1,0);\r
4676  //Double_t dReQ3n = (*fReQ)(2,0);\r
4677  //Double_t dReQ4n = (*fReQ)(3,0);\r
4678  Double_t dImQ1n = (*fImQ)(0,0);\r
4679  Double_t dImQ2n = (*fImQ)(1,0);\r
4680  //Double_t dImQ3n = (*fImQ)(2,0);\r
4681  //Double_t dImQ4n = (*fImQ)(3,0);\r
4682 \r
4683  // reduced correlations are stored in fDiffFlowCorrelationsPro[0=RP,1=POI][0=pt,1=eta][correlation index]. Correlation index runs as follows:\r
4684  // \r
4685  // 0: <<2'>>\r
4686  // 1: <<4'>>\r
4687  // 2: <<6'>>\r
4688  // 3: <<8'>>\r
4689  \r
4690  Int_t t = -1; // type flag \r
4691  Int_t pe = -1; // ptEta flag\r
4692  \r
4693  if(type == "RP")\r
4694  {\r
4695   t = 0;\r
4696  } else if(type == "POI")\r
4697    {\r
4698     t = 1;\r
4699    }\r
4700 \r
4701  if(ptOrEta == "Pt")\r
4702  {\r
4703   pe = 0;\r
4704  } else if(ptOrEta == "Eta")\r
4705    {\r
4706     pe = 1;\r
4707    }\r
4708     \r
4709  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
4710  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
4711  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
4712  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
4713 \r
4714  // looping over all bins and calculating reduced correlations: \r
4715  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
4716  {\r
4717   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): \r
4718   Double_t p1n0kRe = 0.;\r
4719   Double_t p1n0kIm = 0.;\r
4720 \r
4721   // number of POIs in particular pt or eta bin:\r
4722   Double_t mp = 0.;\r
4723 \r
4724   // real and imaginary parts of q_{m*n,0} (non-weighted Q-vector evaluated for particles which are both RPs and POIs in particular pt or eta bin):\r
4725   Double_t q1n0kRe = 0.;\r
4726   Double_t q1n0kIm = 0.;\r
4727   Double_t q2n0kRe = 0.;\r
4728   Double_t q2n0kIm = 0.;\r
4729 \r
4730   // number of particles which are both RPs and POIs in particular pt or eta bin:\r
4731   Double_t mq = 0.;\r
4732    \r
4733   if(type == "POI")\r
4734   {\r
4735    // q_{m*n,0}:\r
4736    q1n0kRe = fReRPQ1dEBE[2][pe][0][0]->GetBinContent(fReRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
4737            * fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
4738    q1n0kIm = fImRPQ1dEBE[2][pe][0][0]->GetBinContent(fImRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
4739            * fImRPQ1dEBE[2][pe][0][0]->GetBinEntries(fImRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
4740    q2n0kRe = fReRPQ1dEBE[2][pe][1][0]->GetBinContent(fReRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
4741            * fReRPQ1dEBE[2][pe][1][0]->GetBinEntries(fReRPQ1dEBE[2][pe][1][0]->GetBin(b));\r
4742    q2n0kIm = fImRPQ1dEBE[2][pe][1][0]->GetBinContent(fImRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
4743            * fImRPQ1dEBE[2][pe][1][0]->GetBinEntries(fImRPQ1dEBE[2][pe][1][0]->GetBin(b));         \r
4744                  \r
4745    mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)\r
4746   } \r
4747   else if(type == "RP")\r
4748   {\r
4749    // q_{m*n,0}:\r
4750    q1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
4751            * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
4752    q1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
4753            * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
4754    q2n0kRe = fReRPQ1dEBE[0][pe][1][0]->GetBinContent(fReRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
4755            * fReRPQ1dEBE[0][pe][1][0]->GetBinEntries(fReRPQ1dEBE[0][pe][1][0]->GetBin(b));\r
4756    q2n0kIm = fImRPQ1dEBE[0][pe][1][0]->GetBinContent(fImRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
4757            * fImRPQ1dEBE[0][pe][1][0]->GetBinEntries(fImRPQ1dEBE[0][pe][1][0]->GetBin(b));         \r
4758                  \r
4759    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)  \r
4760   }\r
4761       \r
4762    if(type == "POI")\r
4763    {\r
4764     // p_{m*n,0}:\r
4765     p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))\r
4766             * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
4767     p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  \r
4768             * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
4769             \r
4770     mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)\r
4771     \r
4772     t = 1; // typeFlag = RP or POI\r
4773    }\r
4774    else if(type == "RP")\r
4775    {\r
4776     // p_{m*n,0} = q_{m*n,0}:\r
4777     p1n0kRe = q1n0kRe; \r
4778     p1n0kIm = q1n0kIm; \r
4779             \r
4780     mp = mq; \r
4781     \r
4782     t = 0; // typeFlag = RP or POI\r
4783    }\r
4784       \r
4785    // 2'-particle correlation for particular (pt,eta) bin:\r
4786    Double_t two1n1nPtEta = 0.;\r
4787    if(mp*dMult-mq)\r
4788    {\r
4789     two1n1nPtEta = (p1n0kRe*dReQ1n+p1n0kIm*dImQ1n-mq)\r
4790                  / (mp*dMult-mq);\r
4791    \r
4792     if(type == "POI") // to be improved (I do not this if)\r
4793     { \r
4794      // fill profile to get <<2'>> for POIs\r
4795      fDiffFlowCorrelationsPro[1][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nPtEta,mp*dMult-mq);\r
4796      // histogram to store <2'> for POIs e-b-e (needed in some other methods):\r
4797      fDiffFlowCorrelationsEBE[1][pe][0]->SetBinContent(b,two1n1nPtEta);      \r
4798      fDiffFlowEventWeightsForCorrelationsEBE[1][pe][0]->SetBinContent(b,mp*dMult-mq);      \r
4799     }\r
4800     else if(type == "RP") // to be improved (I do not this if)\r
4801     {\r
4802      // profile to get <<2'>> for RPs:\r
4803      fDiffFlowCorrelationsPro[0][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nPtEta,mp*dMult-mq);\r
4804      // histogram to store <2'> for RPs e-b-e (needed in some other methods):\r
4805      fDiffFlowCorrelationsEBE[0][pe][0]->SetBinContent(b,two1n1nPtEta); \r
4806      fDiffFlowEventWeightsForCorrelationsEBE[0][pe][0]->SetBinContent(b,mp*dMult-mq); \r
4807     }\r
4808    } // end of if(mp*dMult-mq)\r
4809   \r
4810    // 4'-particle correlation:\r
4811    Double_t four1n1n1n1nPtEta = 0.;\r
4812    if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4813        + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)) // to be improved (introduce a new variable for this expression)\r
4814    {\r
4815     four1n1n1n1nPtEta = ((pow(dReQ1n,2.)+pow(dImQ1n,2.))*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)\r
4816                       - q2n0kRe*(pow(dReQ1n,2.)-pow(dImQ1n,2.))\r
4817                       - 2.*q2n0kIm*dReQ1n*dImQ1n\r
4818                       - p1n0kRe*(dReQ1n*dReQ2n+dImQ1n*dImQ2n)\r
4819                       + p1n0kIm*(dImQ1n*dReQ2n-dReQ1n*dImQ2n)\r
4820                       - 2.*dMult*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)\r
4821                       - 2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*mq                      \r
4822                       + 6.*(q1n0kRe*dReQ1n+q1n0kIm*dImQ1n)                                            \r
4823                       + 1.*(q2n0kRe*dReQ2n+q2n0kIm*dImQ2n)                      \r
4824                       + 2.*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)                       \r
4825                       + 2.*mq*dMult                      \r
4826                       - 6.*mq)        \r
4827                       / ((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4828                           + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)); \r
4829     \r
4830     if(type == "POI")\r
4831     {\r
4832      // profile to get <<4'>> for POIs:\r
4833      fDiffFlowCorrelationsPro[1][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nPtEta,\r
4834                                      (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4835                                      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)); \r
4836      // histogram to store <4'> for POIs e-b-e (needed in some other methods):\r
4837      fDiffFlowCorrelationsEBE[1][pe][1]->SetBinContent(b,four1n1n1n1nPtEta);                               \r
4838      fDiffFlowEventWeightsForCorrelationsEBE[1][pe][1]->SetBinContent(b,(mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4839                                                                         + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));                               \r
4840     }\r
4841     else if(type == "RP")\r
4842     {\r
4843      // profile to get <<4'>> for RPs:\r
4844      fDiffFlowCorrelationsPro[0][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nPtEta,\r
4845                                        (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4846                                        + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));                   \r
4847      // histogram to store <4'> for RPs e-b-e (needed in some other methods):\r
4848      fDiffFlowCorrelationsEBE[0][pe][1]->SetBinContent(b,four1n1n1n1nPtEta);                   \r
4849      fDiffFlowEventWeightsForCorrelationsEBE[0][pe][1]->SetBinContent(b,(mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4850                                                                         + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));                   \r
4851     }\r
4852    } // end of if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4853      //            +mq*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
4854    \r
4855  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
4856  \r
4857    \r
4858 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelations(TString type, TString ptOrEta);\r
4859 \r
4860 \r
4861 //================================================================================================================================\r
4862 \r
4863 \r
4864 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfEventWeights(TString type, TString ptOrEta)\r
4865 {\r
4866  // Calculate sums of various event weights for reduced correlations. \r
4867  // (These quantitites are needed in expressions for unbiased estimators relevant for the statistical errors.)\r
4868 \r
4869  Int_t typeFlag = -1;\r
4870  Int_t ptEtaFlag = -1;\r
4871 \r
4872  if(type == "RP")\r
4873  {\r
4874   typeFlag = 0;\r
4875  } else if(type == "POI")\r
4876    {\r
4877     typeFlag = 1;\r
4878    } \r
4879      \r
4880  if(ptOrEta == "Pt")\r
4881  {\r
4882   ptEtaFlag = 0;\r
4883  } else if(ptOrEta == "Eta")\r
4884    {\r
4885     ptEtaFlag = 1;\r
4886    } \r
4887    \r
4888  // shortcuts:\r
4889  Int_t t = typeFlag;\r
4890  Int_t pe = ptEtaFlag;\r
4891  \r
4892  // binning:\r
4893  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
4894  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
4895  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
4896  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
4897  \r
4898  for(Int_t rpq=0;rpq<3;rpq++)\r
4899  {\r
4900   for(Int_t m=0;m<4;m++)\r
4901   {\r
4902    for(Int_t k=0;k<9;k++)\r
4903    {\r
4904     if(!fReRPQ1dEBE[rpq][pe][m][k])\r
4905     {\r
4906      cout<<"WARNING: fReRPQ1dEBE[rpq][pe][m][k] is NULL in AFAWQC::CSAPOEWFDF() !!!!"<<endl;\r
4907      cout<<"pe  = "<<pe<<endl;\r
4908      cout<<"rpq = "<<rpq<<endl;\r
4909      cout<<"m   = "<<m<<endl;\r
4910      cout<<"k   = "<<k<<endl;\r
4911      exit(0); \r
4912     }\r
4913    }\r
4914   }\r
4915  }  \r
4916 \r
4917  // multiplicities:\r
4918  Double_t dMult = (*fSMpk)(0,0); // total event multiplicity\r
4919  //Double_t mr = 0.; // number of RPs in particular pt or eta bin\r
4920  Double_t mp = 0.; // number of POIs in particular pt or eta bin \r
4921  Double_t mq = 0.; // number of particles which are both RPs and POIs in particular pt or eta bin\r
4922  \r
4923  // event weights for reduced correlations:\r
4924  Double_t dw2 = 0.; // event weight for <2'>\r
4925  Double_t dw4 = 0.; // event weight for <4'>\r
4926  //Double_t dw6 = 0.; // event weight for <6'>\r
4927  //Double_t dw8 = 0.; // event weight for <8'>\r
4928 \r
4929  // looping over bins:\r
4930  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
4931  {\r
4932   if(type == "RP")\r
4933   {\r
4934    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(b);\r
4935    mp = mq; // trick to use the very same Eqs. bellow both for RP's and POI's diff. flow\r
4936   } else if(type == "POI")\r
4937     {\r
4938      mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(b);\r
4939      mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(b);    \r
4940     }\r
4941   \r
4942   // event weight for <2'>:\r
4943   dw2 = mp*dMult-mq;  \r
4944   fDiffFlowSumOfEventWeights[t][pe][0][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2);\r
4945   fDiffFlowSumOfEventWeights[t][pe][1][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw2,2.));\r
4946   \r
4947   // event weight for <4'>:\r
4948   dw4 = (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4949      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.);  \r
4950   fDiffFlowSumOfEventWeights[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4);\r
4951   fDiffFlowSumOfEventWeights[t][pe][1][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw4,2.));\r
4952   \r
4953   // event weight for <6'>:\r
4954   //dw6 = ...;  \r
4955   //fDiffFlowSumOfEventWeights[t][pe][0][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6);\r
4956   //fDiffFlowSumOfEventWeights[t][pe][t][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw6,2.));\r
4957   \r
4958   // event weight for <8'>:\r
4959   //dw8 = ...;  \r
4960   //fDiffFlowSumOfEventWeights[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw8);\r
4961   //fDiffFlowSumOfEventWeights[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw8,2.));   \r
4962  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++) \r
4963  \r
4964 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfEventWeights()\r
4965 \r
4966 \r
4967 //================================================================================================================================\r
4968 \r
4969 \r
4970 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfProductOfEventWeights(TString type, TString ptOrEta)\r
4971 {\r
4972  // Calculate sum of products of various event weights for both types of correlations (the ones for int. and diff. flow). \r
4973  // (These quantitites are needed in expressions for unbiased estimators relevant for the statistical errors.)\r
4974  //\r
4975  // Important: To fill fDiffFlowSumOfProductOfEventWeights[][][][] use bellow table (i,j) with following constraints: \r
4976  // 1.) i<j  \r
4977  // 2.) do not store terms which DO NOT include reduced correlations;\r
4978  // Table:\r
4979  // [0=<2>,1=<2'>,2=<4>,3=<4'>,4=<6>,5=<6'>,6=<8>,7=<8'>] x [0=<2>,1=<2'>,2=<4>,3=<4'>,4=<6>,5=<6'>,6=<8>,7=<8'>]\r
4980   \r
4981  Int_t typeFlag = -1;\r
4982  Int_t ptEtaFlag = -1;\r
4983 \r
4984  if(type == "RP")\r
4985  {\r
4986   typeFlag = 0;\r
4987  } else if(type == "POI")\r
4988    {\r
4989     typeFlag = 1;\r
4990    } \r
4991      \r
4992  if(ptOrEta == "Pt")\r
4993  {\r
4994   ptEtaFlag = 0;\r
4995  } else if(ptOrEta == "Eta")\r
4996    {\r
4997     ptEtaFlag = 1;\r
4998    } \r
4999      \r
5000  // shortcuts:\r
5001  Int_t t = typeFlag;\r
5002  Int_t pe = ptEtaFlag;\r
5003   \r
5004  // binning:\r
5005  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
5006  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
5007  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
5008  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
5009  \r
5010  // protection:\r
5011  for(Int_t rpq=0;rpq<3;rpq++)\r
5012  {\r
5013   for(Int_t m=0;m<4;m++)\r
5014   {\r
5015    for(Int_t k=0;k<9;k++)\r
5016    {\r
5017     if(!fReRPQ1dEBE[rpq][pe][m][k])\r
5018     {\r
5019      cout<<"WARNING: fReRPQ1dEBE[rpq][pe][m][k] is NULL in AFAWQC::CSAPOEWFDF() !!!!"<<endl;\r
5020      cout<<"pe  = "<<pe<<endl;\r
5021      cout<<"rpq = "<<rpq<<endl;\r
5022      cout<<"m   = "<<m<<endl;\r
5023      cout<<"k   = "<<k<<endl;\r
5024      exit(0); \r
5025     }\r
5026    }\r
5027   }\r
5028  }  \r
5029  \r
5030  // multiplicities:\r
5031  Double_t dMult = (*fSMpk)(0,0); // total event multiplicity\r
5032  //Double_t mr = 0.; // number of RPs in particular pt or eta bin\r
5033  Double_t mp = 0.; // number of POIs in particular pt or eta bin \r
5034  Double_t mq = 0.; // number of particles which are both RPs and POIs in particular pt or eta bin\r
5035  \r
5036  // event weights for correlations:\r
5037  Double_t dW2 = dMult*(dMult-1); // event weight for <2> \r
5038  Double_t dW4 = dMult*(dMult-1)*(dMult-2)*(dMult-3); // event weight for <4> \r
5039  Double_t dW6 = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5); // event weight for <6> \r
5040  Double_t dW8 = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5)*(dMult-6)*(dMult-7); // event weight for <8> \r
5041 \r
5042  // event weights for reduced correlations:\r
5043  Double_t dw2 = 0.; // event weight for <2'>\r
5044  Double_t dw4 = 0.; // event weight for <4'>\r
5045  //Double_t dw6 = 0.; // event weight for <6'>\r
5046  //Double_t dw8 = 0.; // event weight for <8'>\r
5047  \r
5048  // looping over bins:\r
5049  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5050  {\r
5051   if(type == "RP")\r
5052   {\r
5053    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(b);\r
5054    mp = mq; // trick to use the very same Eqs. bellow both for RP's and POI's diff. flow\r
5055   } else if(type == "POI")\r
5056     {\r
5057      mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(b);\r
5058      mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(b);    \r
5059     }\r
5060   \r
5061   // event weight for <2'>:\r
5062   dw2 = mp*dMult-mq;  \r
5063   fDiffFlowSumOfProductOfEventWeights[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw2); // storing product of even weights for <2> and <2'>\r
5064   fDiffFlowSumOfProductOfEventWeights[t][pe][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dW4); // storing product of even weights for <4> and <2'>\r
5065   fDiffFlowSumOfProductOfEventWeights[t][pe][1][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dW6); // storing product of even weights for <6> and <2'>\r
5066   fDiffFlowSumOfProductOfEventWeights[t][pe][1][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dW8); // storing product of even weights for <8> and <2'>\r
5067   \r
5068   // event weight for <4'>:\r
5069   dw4 = (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
5070      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.);  \r
5071   fDiffFlowSumOfProductOfEventWeights[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw4); // storing product of even weights for <2> and <4'>\r
5072   fDiffFlowSumOfProductOfEventWeights[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dw4); // storing product of even weights for <2'> and <4'>\r
5073   fDiffFlowSumOfProductOfEventWeights[t][pe][2][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW4*dw4); // storing product of even weights for <4> and <4'>\r
5074   fDiffFlowSumOfProductOfEventWeights[t][pe][3][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dW6); // storing product of even weights for <6> and <4'> \r
5075   fDiffFlowSumOfProductOfEventWeights[t][pe][3][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dW8); // storing product of even weights for <8> and <4'>\r
5076 \r
5077   // event weight for <6'>:\r
5078   //dw6 = ...;  \r
5079   //fDiffFlowSumOfProductOfEventWeights[t][pe][0][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw6); // storing product of even weights for <2> and <6'>\r
5080   //fDiffFlowSumOfProductOfEventWeights[t][pe][1][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dw6); // storing product of even weights for <2'> and <6'>\r
5081   //fDiffFlowSumOfProductOfEventWeights[t][pe][2][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW4*dw6); // storing product of even weights for <4> and <6'>\r
5082   //fDiffFlowSumOfProductOfEventWeights[t][pe][3][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dw6); // storing product of even weights for <4'> and <6'> \r
5083   //fDiffFlowSumOfProductOfEventWeights[t][pe][4][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW6*dw6); // storing product of even weights for <6> and <6'>\r
5084   //fDiffFlowSumOfProductOfEventWeights[t][pe][5][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6*dW8); // storing product of even weights for <6'> and <8>\r
5085   //fDiffFlowSumOfProductOfEventWeights[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6*dw8); // storing product of even weights for <6'> and <8'>\r
5086 \r
5087   // event weight for <8'>:\r
5088   //dw8 = ...;  \r
5089   //fDiffFlowSumOfProductOfEventWeights[t][pe][0][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw8); // storing product of even weights for <2> and <8'>\r
5090   //fDiffFlowSumOfProductOfEventWeights[t][pe][1][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dw8); // storing product of even weights for <2'> and <8'>\r
5091   //fDiffFlowSumOfProductOfEventWeights[t][pe][2][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW4*dw8); // storing product of even weights for <4> and <8'>\r
5092   //fDiffFlowSumOfProductOfEventWeights[t][pe][3][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dw8); // storing product of even weights for <4'> and <8'> \r
5093   //fDiffFlowSumOfProductOfEventWeights[t][pe][4][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW6*dw8); // storing product of even weights for <6> and <8'>\r
5094   //fDiffFlowSumOfProductOfEventWeights[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6*dw8); // storing product of even weights for <6'> and <8'>\r
5095   //fDiffFlowSumOfProductOfEventWeights[t][pe][6][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW8*dw8); // storing product of even weights for <8> and <8'>\r
5096   \r
5097   // Table:\r
5098   // [0=<2>,1=<2'>,2=<4>,3=<4'>,4=<6>,5=<6'>,6=<8>,7=<8'>] x [0=<2>,1=<2'>,2=<4>,3=<4'>,4=<6>,5=<6'>,6=<8>,7=<8'>]\r
5099    \r
5100  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5101  \r
5102 \r
5103 \r
5104 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfProductOfEventWeights(TString type, TString ptOrEta)\r
5105 \r
5106 \r
5107 //================================================================================================================================\r
5108 \r
5109 \r
5110 void AliFlowAnalysisWithQCumulants::FinalizeReducedCorrelations(TString type, TString ptOrEta)\r
5111 {\r
5112  // Transfer profiles into histograms and calculate statistical errors correctly.\r
5113 \r
5114  Int_t typeFlag = -1;\r
5115  Int_t ptEtaFlag = -1;\r
5116 \r
5117  if(type == "RP")\r
5118  {\r
5119   typeFlag = 0;\r
5120  } else if(type == "POI")\r
5121    {\r
5122     typeFlag = 1;\r
5123    } \r
5124      \r
5125  if(ptOrEta == "Pt")\r
5126  {\r
5127   ptEtaFlag = 0;\r
5128  } else if(ptOrEta == "Eta")\r
5129    {\r
5130     ptEtaFlag = 1;\r
5131    } \r
5132   \r
5133  // shortcuts:\r
5134  Int_t t = typeFlag;\r
5135  Int_t pe = ptEtaFlag;\r
5136              \r
5137  for(Int_t rci=0;rci<4;rci++)\r
5138  {\r
5139   if(!fDiffFlowCorrelationsPro[t][pe][rci])\r
5140   {\r
5141    cout<<"WARNING: fDiffFlowCorrelationsPro[t][pe][rci] is NULL in AFAWQC::FRC() !!!!"<<endl;\r
5142    cout<<"t   = "<<t<<endl; \r
5143    cout<<"pe  = "<<pe<<endl; \r
5144    cout<<"rci = "<<rci<<endl;\r
5145    exit(0); \r
5146   }\r
5147   for(Int_t power=0;power<2;power++)\r
5148   {\r
5149    if(!fDiffFlowSumOfEventWeights[t][pe][power][rci])\r
5150    {\r
5151     cout<<"WARNING: fDiffFlowSumOfEventWeights[t][pe][power][rci] is NULL in AFAWQC::FRC() !!!!"<<endl;\r
5152     cout<<"t     = "<<t<<endl; \r
5153     cout<<"pe    = "<<pe<<endl;\r
5154     cout<<"power = "<<power<<endl; \r
5155     cout<<"rci   = "<<rci<<endl;\r
5156     exit(0); \r
5157    }   \r
5158   } // end of for(Int_t power=0;power<2;power++)\r
5159  } // end of for(Int_t rci=0;rci<4;rci++)\r
5160     \r
5161  // common:\r
5162  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
5163  \r
5164  // transfer 1D profile into 1D histogram:\r
5165  Double_t correlation = 0.;\r
5166  Double_t spread = 0.;\r
5167  Double_t sumOfWeights = 0.; // sum of weights for particular reduced correlations for particular pt or eta bin\r
5168  Double_t sumOfSquaredWeights = 0.; // sum of squared weights for particular reduced correlations for particular pt or eta bin\r
5169  Double_t error = 0.; // error = termA * spread * termB\r
5170                       // termA = (sqrt(sumOfSquaredWeights)/sumOfWeights) \r
5171                       // termB = 1/pow(1-termA^2,0.5)\r
5172  Double_t termA = 0.;                      \r
5173  Double_t termB = 0.;                      \r
5174  for(Int_t rci=0;rci<4;rci++) // index of reduced correlation\r
5175  {\r
5176   for(Int_t b=1;b<=nBinsPtEta[pe];b++) // number of pt or eta bins\r
5177   {\r
5178    correlation = fDiffFlowCorrelationsPro[t][pe][rci]->GetBinContent(b); \r
5179    spread = fDiffFlowCorrelationsPro[t][pe][rci]->GetBinError(b);\r
5180    sumOfWeights = fDiffFlowSumOfEventWeights[t][pe][0][rci]->GetBinContent(b);\r
5181    sumOfSquaredWeights = fDiffFlowSumOfEventWeights[t][pe][1][rci]->GetBinContent(b);\r
5182    if(sumOfWeights) termA = (pow(sumOfSquaredWeights,0.5)/sumOfWeights);\r
5183    if(1.-pow(termA,2.)>0.) termB = 1./pow(1.-pow(termA,2.),0.5); \r
5184    error = termA*spread*termB; // final error (unbiased estimator for standard deviation)\r
5185    fDiffFlowCorrelationsHist[t][pe][rci]->SetBinContent(b,correlation); \r
5186    fDiffFlowCorrelationsHist[t][pe][rci]->SetBinError(b,error); \r
5187   } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5188  } // end of for(Int_t rci=0;rci<4;rci++)\r
5189  \r
5190 } // end of void AliFlowAnalysisWithQCumulants::FinalizeReducedCorrelations(TString type, TString ptOrEta)\r
5191 \r
5192 \r
5193 //================================================================================================================================\r
5194 \r
5195 \r
5196 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowProductOfCorrelations(TString type, TString ptOrEta)\r
5197 {\r
5198  // store products: <2><2'>, <2><4'>, <2><6'>, <2><8'>, <2'><4>, \r
5199  //                 <2'><4'>, <2'><6>, <2'><6'>, <2'><8>, <2'><8'>,\r
5200  //                 <4><4'>, <4><6'>, <4><8'>, <4'><6>, <4'><6'>, \r
5201  //                 <4'><8>, <4'><8'>, <6><6'>, <6><8'>, <6'><8>, \r
5202  //                 <6'><8'>, <8><8'>.\r
5203   \r
5204  Int_t typeFlag = -1;\r
5205  Int_t ptEtaFlag = -1;\r
5206 \r
5207  if(type == "RP")\r
5208  {\r
5209   typeFlag = 0;\r
5210  } else if(type == "POI")\r
5211    {\r
5212     typeFlag = 1;\r
5213    } \r
5214      \r
5215  if(ptOrEta == "Pt")\r
5216  {\r
5217   ptEtaFlag = 0;\r
5218  } else if(ptOrEta == "Eta")\r
5219    {\r
5220     ptEtaFlag = 1;\r
5221    } \r
5222   \r
5223  // shortcuts:\r
5224  Int_t t = typeFlag;\r
5225  Int_t pe = ptEtaFlag;\r
5226      \r
5227  // common:\r
5228  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
5229  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
5230  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
5231    \r
5232  // protections // to be improved (add protection for all pointers in this method)\r
5233  if(!fIntFlowCorrelationsEBE)\r
5234  {\r
5235   cout<<"WARNING: fIntFlowCorrelationsEBE is NULL in AFAWQC::CDFPOC() !!!!"<<endl;\r
5236   exit(0);\r
5237  } \r
5238  \r
5239  /*    \r
5240  Double_t dMult = (*fSMpk)(0,0); // multiplicity (number of particles used to determine the reaction plane)\r
5241  //Double_t mr = 0.; // number of RPs in particular pt or eta bin\r
5242  Double_t mp = 0.; // number of POIs in particular pt or eta bin \r
5243  Double_t mq = 0.; // number of particles which are both RPs and POIs in particular pt or eta bin\r
5244  */\r
5245 \r
5246  // e-b-e correlations:\r
5247  Double_t twoEBE = fIntFlowCorrelationsEBE->GetBinContent(1); // <2>\r
5248  Double_t fourEBE = fIntFlowCorrelationsEBE->GetBinContent(2); // <4>\r
5249  Double_t sixEBE = fIntFlowCorrelationsEBE->GetBinContent(3); // <6>\r
5250  Double_t eightEBE = fIntFlowCorrelationsEBE->GetBinContent(4); // <8>\r
5251  \r
5252  // event weights for correlations:\r
5253  Double_t dW2 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1); // event weight for <2> \r
5254  Double_t dW4 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2); // event weight for <4> \r
5255  Double_t dW6 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(3); // event weight for <6> \r
5256  Double_t dW8 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(4); // event weight for <8> \r
5257   \r
5258  // e-b-e reduced correlations:\r
5259  Double_t twoReducedEBE = 0.; // <2'>\r
5260  Double_t fourReducedEBE = 0.; // <4'>\r
5261  Double_t sixReducedEBE = 0.; // <6'>\r
5262  Double_t eightReducedEBE = 0.; // <8'> \r
5263  \r
5264  // event weights for reduced correlations:\r
5265  Double_t dw2 = 0.; // event weight for <2'>\r
5266  Double_t dw4 = 0.; // event weight for <4'>\r
5267  //Double_t dw6 = 0.; // event weight for <6'>\r
5268  //Double_t dw8 = 0.; // event weight for <8'>\r
5269 \r
5270  // looping over bins:\r
5271  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5272  {\r
5273   // e-b-e reduced correlations:\r
5274   twoReducedEBE = fDiffFlowCorrelationsEBE[t][pe][0]->GetBinContent(b);\r
5275   fourReducedEBE = fDiffFlowCorrelationsEBE[t][pe][1]->GetBinContent(b);\r
5276   sixReducedEBE = fDiffFlowCorrelationsEBE[t][pe][2]->GetBinContent(b);\r
5277   eightReducedEBE = fDiffFlowCorrelationsEBE[t][pe][3]->GetBinContent(b);\r
5278   \r
5279   /*\r
5280   // to be improved (I should not do this here again)\r
5281   if(type == "RP")\r
5282   {\r
5283    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(b);\r
5284    mp = mq; // trick to use the very same Eqs. bellow both for RP's and POI's diff. flow\r
5285   } else if(type == "POI")\r
5286     {\r
5287      mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(b);\r
5288      mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(b);    \r
5289     }\r
5290   \r
5291   // event weights for reduced correlations:\r
5292   dw2 = mp*dMult-mq; // weight for <2'> \r
5293   dw4 = (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
5294      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.); // weight for <4'>\r
5295   //dw6 = ...     \r
5296   //dw8 = ...     \r
5297   \r
5298   */\r
5299   \r
5300   dw2 = fDiffFlowEventWeightsForCorrelationsEBE[t][pe][0]->GetBinContent(b);\r
5301   dw4 = fDiffFlowEventWeightsForCorrelationsEBE[t][pe][1]->GetBinContent(b);\r
5302  \r
5303   // storing all products:\r
5304   fDiffFlowProductOfCorrelationsPro[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*twoReducedEBE,dW2*dw2); // storing <2><2'>\r
5305   fDiffFlowProductOfCorrelationsPro[t][pe][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*twoReducedEBE,dW4*dw2); // storing <4><2'>\r
5306   fDiffFlowProductOfCorrelationsPro[t][pe][1][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*twoReducedEBE,dW6*dw2); // storing <6><2'>\r
5307   fDiffFlowProductOfCorrelationsPro[t][pe][1][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],eightEBE*twoReducedEBE,dW8*dw2); // storing <8><2'>\r
5308   \r
5309   // event weight for <4'>:\r
5310   fDiffFlowProductOfCorrelationsPro[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*fourReducedEBE,dW2*dw4); // storing <2><4'>\r
5311   fDiffFlowProductOfCorrelationsPro[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoReducedEBE*fourReducedEBE,dw2*dw4); // storing <2'><4'>\r
5312   fDiffFlowProductOfCorrelationsPro[t][pe][2][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*fourReducedEBE,dW4*dw4); // storing <4><4'>\r
5313   fDiffFlowProductOfCorrelationsPro[t][pe][3][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*fourReducedEBE,dW6*dw4); // storing <6><4'> \r
5314   fDiffFlowProductOfCorrelationsPro[t][pe][3][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],eightEBE*fourReducedEBE,dW8*dw4); // storing <8><4'>\r
5315 \r
5316   // event weight for <6'>:\r
5317   //dw6 = ...;  \r
5318   //fDiffFlowProductOfCorrelationsPro[t][pe][0][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*sixReducedEBE,dW2*dw6); // storing <2><6'>\r
5319   //fDiffFlowProductOfCorrelationsPro[t][pe][1][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoReducedEBE*sixReducedEBE,dw2*dw6); // storing <2'><6'>\r
5320   //fDiffFlowProductOfCorrelationsPro[t][pe][2][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*sixReducedEBE,dW4*dw6); // storing <4><6'>\r
5321   //fDiffFlowProductOfCorrelationsPro[t][pe][3][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourReducedEBE*sixReducedEBE,dw4*dw6); // storing <4'><6'> \r
5322   //fDiffFlowProductOfCorrelationsPro[t][pe][4][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*sixReducedEBE,dW6*dw6); // storing <6><6'>\r
5323   //fDiffFlowProductOfCorrelationsPro[t][pe][5][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixReducedEBE*eightEBE,dw6*dW8); // storing <6'><8>\r
5324   //fDiffFlowProductOfCorrelationsPro[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixReducedEBE*eightReducedEBE,dw6*dw8); // storing <6'><8'>\r
5325 \r
5326   // event weight for <8'>:\r
5327   //dw8 = ...;  \r
5328   //fDiffFlowProductOfCorrelationsPro[t][pe][0][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*eightReducedEBE,dW2*dw8); // storing <2><8'>\r
5329   //fDiffFlowProductOfCorrelationsPro[t][pe][1][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoReducedEBE*eightReducedEBE,dw2*dw8); // storing <2'><8'>\r
5330   //fDiffFlowProductOfCorrelationsPro[t][pe][2][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*eightReducedEBE,dW4*dw8); // storing <4><8'>\r
5331   //fDiffFlowProductOfCorrelationsPro[t][pe][3][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourReducedEBE*eightReducedEBE,dw4*dw8); // storing <4'><8'> \r
5332   //fDiffFlowProductOfCorrelationsPro[t][pe][4][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*eightReducedEBE,dW6*dw8); // storing <6><8'>\r
5333   //fDiffFlowProductOfCorrelationsPro[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixReducedEBE*eightReducedEBE,dw6*dw8); // storing <6'><8'>\r
5334   //fDiffFlowProductOfCorrelationsPro[t][pe][6][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],eightEBE*eightReducedEBE,dW8*dw8); // storing <8><8'> \r
5335  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++       \r
5336      \r
5337 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowProductOfCorrelations(TString type, TString ptOrEta)\r
5338 \r
5339 \r
5340 //================================================================================================================================\r
5341     \r
5342     \r
5343 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCovariances(TString type, TString ptOrEta) // to be improved (reimplemented)\r
5344 {\r
5345  // a) Calculate unbiased estimators Cov(<2>,<2'>), Cov(<2>,<4'>), Cov(<4>,<2'>), Cov(<4>,<4'>) and Cov(<2'>,<4'>)\r
5346  //    for covariances V(<2>,<2'>), V(<2>,<4'>), V(<4>,<2'>), V(<4>,<4'>) and V(<2'>,<4'>).  \r
5347  // b) Store in histogram fDiffFlowCovariances[t][pe][index] for instance the following: \r
5348  //\r
5349  //             Cov(<2>,<2'>) * (sum_{i=1}^{N} w_{<2>}_i w_{<2'>}_i )/[(sum_{i=1}^{N} w_{<2>}_i) * (sum_{j=1}^{N} w_{<2'>}_j)]\r
5350  // \r
5351  //     where N is the number of events, w_{<2>} is event weight for <2> and w_{<2'>} is event weight for <2'>.\r
5352  // c) Binning of fDiffFlowCovariances[t][pe][index] is organized as follows:\r
5353  // \r
5354  //     1st bin: Cov(<2>,<2'>) * (sum_{i=1}^{N} w_{<2>}_i w_{<2'>}_i )/[(sum_{i=1}^{N} w_{<2>}_i) * (sum_{j=1}^{N} w_{<2'>}_j)] \r
5355  //     2nd bin: Cov(<2>,<4'>) * (sum_{i=1}^{N} w_{<2>}_i w_{<4'>}_i )/[(sum_{i=1}^{N} w_{<2>}_i) * (sum_{j=1}^{N} w_{<4'>}_j)] \r
5356  //     3rd bin: Cov(<4>,<2'>) * (sum_{i=1}^{N} w_{<4>}_i w_{<2'>}_i )/[(sum_{i=1}^{N} w_{<4>}_i) * (sum_{j=1}^{N} w_{<2'>}_j)] \r
5357  //     4th bin: Cov(<4>,<4'>) * (sum_{i=1}^{N} w_{<4>}_i w_{<4'>}_i )/[(sum_{i=1}^{N} w_{<4>}_i) * (sum_{j=1}^{N} w_{<4'>}_j)] \r
5358  //     5th bin: Cov(<2'>,<4'>) * (sum_{i=1}^{N} w_{<2'>}_i w_{<4'>}_i )/[(sum_{i=1}^{N} w_{<2'>}_i) * (sum_{j=1}^{N} w_{<4'>}_j)] \r
5359  //     ...\r
5360   \r
5361  Int_t typeFlag = -1;\r
5362  Int_t ptEtaFlag = -1;\r
5363 \r
5364  if(type == "RP")\r
5365  {\r
5366   typeFlag = 0;\r
5367  } else if(type == "POI")\r
5368    {\r
5369     typeFlag = 1;\r
5370    } \r
5371      \r
5372  if(ptOrEta == "Pt")\r
5373  {\r
5374   ptEtaFlag = 0;\r
5375  } else if(ptOrEta == "Eta")\r
5376    {\r
5377     ptEtaFlag = 1;\r
5378    } \r
5379   \r
5380  // shortcuts:\r
5381  Int_t t = typeFlag;\r
5382  Int_t pe = ptEtaFlag;\r
5383      \r
5384  // common:\r
5385  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
5386  //Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
5387  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
5388  //Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
5389  \r
5390  // average correlations:\r
5391  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>\r
5392  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>\r
5393  //Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>>\r
5394  //Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>\r
5395  \r
5396  // sum of weights for correlation:\r
5397  Double_t sumOfWeightsForTwo = fIntFlowSumOfEventWeights[0]->GetBinContent(1); // sum_{i=1}^{N} w_{<2>}\r
5398  Double_t sumOfWeightsForFour = fIntFlowSumOfEventWeights[0]->GetBinContent(2); // sum_{i=1}^{N} w_{<4>}\r
5399  //Double_t sumOfWeightsForSix = fIntFlowSumOfEventWeights[0]->GetBinContent(3); // sum_{i=1}^{N} w_{<6>}\r
5400  //Double_t sumOfWeightsForEight = fIntFlowSumOfEventWeights[0]->GetBinContent(4); // sum_{i=1}^{N} w_{<8>}\r
5401  \r
5402  // average reduced correlations:\r
5403  Double_t twoReduced = 0.; // <<2'>> \r
5404  Double_t fourReduced = 0.; // <<4'>>\r
5405  //Double_t sixReduced = 0.; // <<6'>>\r
5406  //Double_t eightReduced = 0.; // <<8'>>\r
5407 \r
5408  // sum of weights for reduced correlation:\r
5409  Double_t sumOfWeightsForTwoReduced = 0.; // sum_{i=1}^{N} w_{<2'>}\r
5410  Double_t sumOfWeightsForFourReduced = 0.; // sum_{i=1}^{N} w_{<4'>}\r
5411  //Double_t sumOfWeightsForSixReduced = 0.; // sum_{i=1}^{N} w_{<6'>}\r
5412  //Double_t sumOfWeightsForEightReduced = 0.; // sum_{i=1}^{N} w_{<8'>}\r
5413   \r
5414  // product of weights for reduced correlation:\r
5415  Double_t productOfWeightsForTwoTwoReduced = 0.; // sum_{i=1}^{N} w_{<2>}w_{<2'>}\r
5416  Double_t productOfWeightsForTwoFourReduced = 0.; // sum_{i=1}^{N} w_{<2>}w_{<4'>}\r
5417  Double_t productOfWeightsForFourTwoReduced = 0.; // sum_{i=1}^{N} w_{<4>}w_{<2'>}\r
5418  Double_t productOfWeightsForFourFourReduced = 0.; // sum_{i=1}^{N} w_{<4>}w_{<4'>}\r
5419  Double_t productOfWeightsForTwoReducedFourReduced = 0.; // sum_{i=1}^{N} w_{<2'>}w_{<4'>}\r
5420  // ...\r
5421  \r
5422  // products for differential flow:\r
5423  Double_t twoTwoReduced = 0; // <<2><2'>> \r
5424  Double_t twoFourReduced = 0; // <<2><4'>> \r
5425  Double_t fourTwoReduced = 0; // <<4><2'>> \r
5426  Double_t fourFourReduced = 0; // <<4><4'>> \r
5427  Double_t twoReducedFourReduced = 0; // <<2'><4'>> \r
5428 \r
5429  // denominators in the expressions for the unbiased estimators for covariances:\r
5430  // denominator = 1 - term1/(term2*term3)\r
5431  // prefactor = term1/(term2*term3)\r
5432  Double_t denominator = 0.; \r
5433  Double_t prefactor = 0.;\r
5434  Double_t term1 = 0.; \r
5435  Double_t term2 = 0.; \r
5436  Double_t term3 = 0.; \r
5437  \r
5438  // unbiased estimators for covariances for differential flow:\r
5439  Double_t covTwoTwoReduced = 0.; // Cov(<2>,<2'>)\r
5440  Double_t wCovTwoTwoReduced = 0.; // Cov(<2>,<2'>) * prefactor(w_{<2>},w_{<2'>})\r
5441  Double_t covTwoFourReduced = 0.; // Cov(<2>,<4'>)\r
5442  Double_t wCovTwoFourReduced = 0.; // Cov(<2>,<4'>) * prefactor(w_{<2>},w_{<4'>})\r
5443  Double_t covFourTwoReduced = 0.; // Cov(<4>,<2'>)\r
5444  Double_t wCovFourTwoReduced = 0.; // Cov(<4>,<2'>) * prefactor(w_{<4>},w_{<2'>})\r
5445  Double_t covFourFourReduced = 0.; // Cov(<4>,<4'>)\r
5446  Double_t wCovFourFourReduced = 0.; // Cov(<4>,<4'>) * prefactor(w_{<4>},w_{<4'>})\r
5447  Double_t covTwoReducedFourReduced = 0.; // Cov(<2'>,<4'>)\r
5448  Double_t wCovTwoReducedFourReduced = 0.; // Cov(<2'>,<4'>) * prefactor(w_{<2'>},w_{<4'>})\r
5449  \r
5450  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5451  {\r
5452   // average reduced corelations:\r
5453   twoReduced = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b);\r
5454   fourReduced = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b);\r
5455   // average products:\r
5456   twoTwoReduced = fDiffFlowProductOfCorrelationsPro[t][pe][0][1]->GetBinContent(b);\r
5457   twoFourReduced = fDiffFlowProductOfCorrelationsPro[t][pe][0][3]->GetBinContent(b);\r
5458   fourTwoReduced = fDiffFlowProductOfCorrelationsPro[t][pe][1][2]->GetBinContent(b);\r
5459   fourFourReduced = fDiffFlowProductOfCorrelationsPro[t][pe][2][3]->GetBinContent(b);\r
5460   twoReducedFourReduced = fDiffFlowProductOfCorrelationsPro[t][pe][1][3]->GetBinContent(b);  \r
5461   // sum of weights for reduced correlations:\r
5462   sumOfWeightsForTwoReduced = fDiffFlowSumOfEventWeights[t][pe][0][0]->GetBinContent(b);\r
5463   sumOfWeightsForFourReduced = fDiffFlowSumOfEventWeights[t][pe][0][1]->GetBinContent(b);\r
5464   // products of weights for correlations:\r
5465   productOfWeightsForTwoTwoReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][0][1]->GetBinContent(b); \r
5466   productOfWeightsForTwoFourReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][0][3]->GetBinContent(b);\r
5467   productOfWeightsForFourTwoReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][1][2]->GetBinContent(b);\r
5468   productOfWeightsForFourFourReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][2][3]->GetBinContent(b);\r
5469   productOfWeightsForTwoReducedFourReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][1][3]->GetBinContent(b);\r
5470   // denominator for the unbiased estimator for covariances: 1 - term1/(term2*term3) \r
5471   // prefactor (multiplies Cov's) = term1/(term2*term3)       \r
5472   // <2>,<2'>:\r
5473   term1 = productOfWeightsForTwoTwoReduced;      \r
5474   term2 = sumOfWeightsForTwo;\r
5475   term3 = sumOfWeightsForTwoReduced;        \r
5476   if(term2*term3>0.)\r
5477   {\r
5478    denominator = 1.-term1/(term2*term3);\r
5479    prefactor = term1/(term2*term3);\r
5480    if(denominator!=0.)\r
5481    {\r
5482     covTwoTwoReduced = (twoTwoReduced-two*twoReduced)/denominator;            \r
5483     wCovTwoTwoReduced = covTwoTwoReduced*prefactor; \r
5484     fDiffFlowCovariances[t][pe][0]->SetBinContent(b,wCovTwoTwoReduced);\r
5485    }\r
5486   }\r
5487   // <2>,<4'>:\r
5488   term1 = productOfWeightsForTwoFourReduced;      \r
5489   term2 = sumOfWeightsForTwo;\r
5490   term3 = sumOfWeightsForFourReduced;        \r
5491   if(term2*term3>0.)\r
5492   {\r
5493    denominator = 1.-term1/(term2*term3);\r
5494    prefactor = term1/(term2*term3);\r
5495    if(denominator!=0.)\r
5496    {\r
5497     covTwoFourReduced = (twoFourReduced-two*fourReduced)/denominator;            \r
5498     wCovTwoFourReduced = covTwoFourReduced*prefactor; \r
5499     fDiffFlowCovariances[t][pe][1]->SetBinContent(b,wCovTwoFourReduced);\r
5500    }\r
5501   }\r
5502   // <4>,<2'>:\r
5503   term1 = productOfWeightsForFourTwoReduced;      \r
5504   term2 = sumOfWeightsForFour;\r
5505   term3 = sumOfWeightsForTwoReduced;        \r
5506   if(term2*term3>0.)\r
5507   {\r
5508    denominator = 1.-term1/(term2*term3);\r
5509    prefactor = term1/(term2*term3);\r
5510    if(denominator!=0.)\r
5511    {\r
5512     covFourTwoReduced = (fourTwoReduced-four*twoReduced)/denominator;            \r
5513     wCovFourTwoReduced = covFourTwoReduced*prefactor; \r
5514     fDiffFlowCovariances[t][pe][2]->SetBinContent(b,wCovFourTwoReduced);\r
5515    }\r
5516   }\r
5517   // <4>,<4'>:\r
5518   term1 = productOfWeightsForFourFourReduced;      \r
5519   term2 = sumOfWeightsForFour;\r
5520   term3 = sumOfWeightsForFourReduced;        \r
5521   if(term2*term3>0.)\r
5522   {\r
5523    denominator = 1.-term1/(term2*term3);\r
5524    prefactor = term1/(term2*term3);\r
5525    if(denominator!=0.)\r
5526    {\r
5527     covFourFourReduced = (fourFourReduced-four*fourReduced)/denominator;            \r
5528     wCovFourFourReduced = covFourFourReduced*prefactor; \r
5529     fDiffFlowCovariances[t][pe][3]->SetBinContent(b,wCovFourFourReduced);\r
5530    }\r
5531   }\r
5532   // <2'>,<4'>:\r
5533   term1 = productOfWeightsForTwoReducedFourReduced;      \r
5534   term2 = sumOfWeightsForTwoReduced;\r
5535   term3 = sumOfWeightsForFourReduced;        \r
5536   if(term2*term3>0.)\r
5537   {\r
5538    denominator = 1.-term1/(term2*term3);\r
5539    prefactor = term1/(term2*term3);\r
5540    if(denominator!=0.)\r
5541    {\r
5542     covTwoReducedFourReduced = (twoReducedFourReduced-twoReduced*fourReduced)/denominator;            \r
5543     wCovTwoReducedFourReduced = covTwoReducedFourReduced*prefactor; \r
5544     fDiffFlowCovariances[t][pe][4]->SetBinContent(b,wCovTwoReducedFourReduced);\r
5545    }\r
5546   }   \r
5547  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5548   \r
5549 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCovariances(TString type, TString ptOrEta)\r
5550 \r
5551 \r
5552 //================================================================================================================================\r
5553 \r
5554 \r
5555 void AliFlowAnalysisWithQCumulants::CalculateDiffFlow(TString type, TString ptOrEta)\r
5556 {\r
5557  // calculate differential flow from differential cumulants and previously obtained integrated flow: (to be improved: description)\r
5558  \r
5559  Int_t typeFlag = -1;\r
5560  Int_t ptEtaFlag = -1;\r
5561 \r
5562  if(type == "RP")\r
5563  {\r
5564   typeFlag = 0;\r
5565  } else if(type == "POI")\r
5566    {\r
5567     typeFlag = 1;\r
5568    } \r
5569      \r
5570  if(ptOrEta == "Pt")\r
5571  {\r
5572   ptEtaFlag = 0;\r
5573  } else if(ptOrEta == "Eta")\r
5574    {\r
5575     ptEtaFlag = 1;\r
5576    } \r
5577   \r
5578  // shortcuts:\r
5579  Int_t t = typeFlag;\r
5580  Int_t pe = ptEtaFlag;\r
5581      \r
5582  // common:\r
5583  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
5584    \r
5585  // correlations:\r
5586  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>\r
5587  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>\r
5588  \r
5589  // statistical errors of correlations:\r
5590  Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1);\r
5591  Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2);   \r
5592     \r
5593  // reduced correlations:\r
5594  Double_t twoReduced = 0.; // <<2'>>\r
5595  Double_t fourReduced = 0.; // <<4'>>\r
5596  \r
5597  // statistical errors of reduced correlations:\r
5598  Double_t twoReducedError = 0.; \r
5599  Double_t fourReducedError = 0.; \r
5600 \r
5601  // covariances:\r
5602  Double_t wCovTwoFour = fIntFlowCovariances->GetBinContent(1);// // Cov(<2>,<4>) * prefactor(<2>,<4>)\r
5603  Double_t wCovTwoTwoReduced = 0.; // Cov(<2>,<2'>) * prefactor(<2>,<2'>)\r
5604  Double_t wCovTwoFourReduced = 0.; // Cov(<2>,<4'>) * prefactor(<2>,<4'>)\r
5605  Double_t wCovFourTwoReduced = 0.; // Cov(<4>,<2'>) * prefactor(<4>,<2'>)\r
5606  Double_t wCovFourFourReduced = 0.; // Cov(<4>,<4'>) * prefactor(<4>,<4'>)\r
5607  Double_t wCovTwoReducedFourReduced = 0.; // Cov(<2'>,<4'>) * prefactor(<2'>,<4'>)\r
5608  \r
5609  // differential flow:\r
5610  Double_t v2Prime = 0.; // v'{2}                   \r
5611  Double_t v4Prime = 0.; // v'{4}\r
5612  \r
5613  // statistical error of differential flow:\r
5614  Double_t v2PrimeError = 0.;                    \r
5615  Double_t v4PrimeError = 0.; \r
5616  \r
5617  // squared statistical error of differential flow:\r
5618  Double_t v2PrimeErrorSquared = 0.;                    \r
5619  Double_t v4PrimeErrorSquared = 0.; \r
5620  \r
5621  // loop over pt or eta bins:\r
5622  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5623  {\r
5624   // reduced correlations and statistical errors:\r
5625   twoReduced = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b);\r
5626   twoReducedError = fDiffFlowCorrelationsHist[t][pe][0]->GetBinError(b);\r
5627   fourReduced = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b);\r
5628   fourReducedError = fDiffFlowCorrelationsHist[t][pe][1]->GetBinError(b);\r
5629   // covariances:\r
5630   wCovTwoTwoReduced = fDiffFlowCovariances[t][pe][0]->GetBinContent(b);\r
5631   wCovTwoFourReduced = fDiffFlowCovariances[t][pe][1]->GetBinContent(b);\r
5632   wCovFourTwoReduced = fDiffFlowCovariances[t][pe][2]->GetBinContent(b);\r
5633   wCovFourFourReduced = fDiffFlowCovariances[t][pe][3]->GetBinContent(b);\r
5634   wCovTwoReducedFourReduced = fDiffFlowCovariances[t][pe][4]->GetBinContent(b);\r
5635   // differential flow:\r
5636   // v'{2}:\r
5637   if(two>0.) \r
5638   {\r
5639    v2Prime = twoReduced/pow(two,0.5);\r
5640    v2PrimeErrorSquared = (1./4.)*pow(two,-3.)*\r
5641                          (pow(twoReduced,2.)*pow(twoError,2.)\r
5642                           + 4.*pow(two,2.)*pow(twoReducedError,2.)\r
5643                           - 4.*two*twoReduced*wCovTwoTwoReduced);\r
5644      \r
5645                                                             \r
5646    if(v2PrimeErrorSquared>0.) v2PrimeError = pow(v2PrimeErrorSquared,0.5);\r
5647    fDiffFlow[t][pe][0]->SetBinContent(b,v2Prime); \r
5648    fDiffFlow[t][pe][0]->SetBinError(b,v2PrimeError);     \r
5649   }\r
5650   // differential flow:\r
5651   // v'{4}\r
5652   if(2.*pow(two,2.)-four > 0.) \r
5653   {\r
5654    v4Prime = (2.*two*twoReduced-fourReduced)/pow(2.*pow(two,2.)-four,3./4.);\r
5655    v4PrimeErrorSquared = pow(2.*pow(two,2.)-four,-7./2.)*\r
5656                          (pow(2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced,2.)*pow(twoError,2.)\r
5657                           + (9./16.)*pow(2.*two*twoReduced-fourReduced,2.)*pow(fourError,2.)\r
5658                           + 4.*pow(two,2.)*pow(2.*pow(two,2.)-four,2.)*pow(twoReducedError,2.)\r
5659                           + pow(2.*pow(two,2.)-four,2.)*pow(fourReducedError,2.)                          \r
5660                           - (3./2.)*(2.*two*twoReduced-fourReduced)\r
5661                           * (2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced)*wCovTwoFour\r
5662                           - 4.*two*(2.*pow(two,2.)-four)\r
5663                           * (2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced)*wCovTwoTwoReduced\r
5664                           + 2.*(2.*pow(two,2.)-four)\r
5665                           * (2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced)*wCovTwoFourReduced\r
5666                           + 3.*two*(2.*pow(two,2.)-four)*(2.*two*twoReduced-fourReduced)*wCovFourTwoReduced\r
5667                           - (3./2.)*(2.*pow(two,2.)-four)*(2.*two*twoReduced-fourReduced)*wCovFourFourReduced \r
5668                           - 4.*two*pow(2.*pow(two,2.)-four,2.)*wCovTwoReducedFourReduced);  \r
5669    if(v4PrimeErrorSquared>0.) v4PrimeError = pow(v4PrimeErrorSquared,0.5);        \r
5670    fDiffFlow[t][pe][1]->SetBinContent(b,v4Prime);\r
5671    fDiffFlow[t][pe][1]->SetBinError(b,v4PrimeError);     \r
5672   }\r
5673   \r
5674  } // end of for(Int_t b=1;b<=fnBinsPtEta[pe];b++)\r
5675  \r
5676    \r
5677  \r
5678  \r
5679  /*\r
5680  // 2D:\r
5681  for(Int_t nua=0;nua<2;nua++)\r
5682  {\r
5683   for(Int_t p=1;p<=fnBinsPt;p++)\r
5684   {\r
5685    for(Int_t e=1;e<=fnBinsEta;e++) \r
5686    { \r
5687     // differential cumulants:\r
5688     Double_t qc2Prime = fFinalCumulants2D[t][pW][eW][nua][0]->GetBinContent(fFinalCumulants2D[t][pW][eW][nua][0]->GetBin(p,e)); // QC{2'}                    \r
5689     Double_t qc4Prime = fFinalCumulants2D[t][pW][eW][nua][1]->GetBinContent(fFinalCumulants2D[t][pW][eW][nua][1]->GetBin(p,e)); // QC{4'}\r
5690     // differential flow:\r
5691     Double_t v2Prime = 0.;                    \r
5692     Double_t v4Prime = 0.; \r
5693     if(v2) \r
5694     {\r
5695      v2Prime = qc2Prime/v2;\r
5696      fFinalFlow2D[t][pW][eW][nua][0]->SetBinContent(fFinalFlow2D[t][pW][eW][nua][0]->GetBin(p,e),v2Prime);  \r
5697     }                   \r
5698     if(v4)\r
5699     {\r
5700      v4Prime = -qc4Prime/pow(v4,3.); \r
5701      fFinalFlow2D[t][pW][eW][nua][1]->SetBinContent(fFinalFlow2D[t][pW][eW][nua][1]->GetBin(p,e),v4Prime);  \r
5702     }                    \r
5703    } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
5704   } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
5705  } // end of for(Int_t nua=0;nua<2;nua++)\r
5706  */\r
5707 \r
5708 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlow(TString type, Bool_t useParticleWeights)\r
5709 \r
5710 \r
5711 //================================================================================================================================\r
5712 \r
5713 \r
5714 void AliFlowAnalysisWithQCumulants::StoreIntFlowFlags()\r
5715 {\r
5716  // a) Store all flags for integrated flow in profile fIntFlowFlags.\r
5717  \r
5718  if(!fIntFlowFlags)\r
5719  {\r
5720   cout<<"WARNING: fIntFlowFlags is NULL in AFAWQC::SFFIF() !!!!"<<endl;\r
5721   exit(0);\r
5722  } \r
5723 \r
5724  fIntFlowFlags->Fill(0.5,(Int_t)fUsePhiWeights||fUsePtWeights||fUseEtaWeights); // particle weights used or not\r
5725  //fIntFlowFlags->Fill(1.5,""); // which event weight was used? // to be improved\r
5726  fIntFlowFlags->Fill(2.5,(Int_t)fApplyCorrectionForNUA); // corrected for non-uniform acceptance or not\r
5727   \r
5728 } // end of void AliFlowAnalysisWithQCumulants::StoreIntFlowFlags()\r
5729 \r
5730 \r
5731 //================================================================================================================================\r
5732 \r
5733 \r
5734 void AliFlowAnalysisWithQCumulants::StoreDiffFlowFlags()\r
5735 {\r
5736  // Store all flags for differential flow in the profile fDiffFlowFlags.\r
5737   \r
5738  if(!fDiffFlowFlags)\r
5739  {\r
5740   cout<<"WARNING: fDiffFlowFlags is NULL in AFAWQC::SFFDF() !!!!"<<endl;\r
5741   exit(0);\r
5742  } \r
5743  \r
5744  fDiffFlowFlags->Fill(0.5,fUsePhiWeights||fUsePtWeights||fUseEtaWeights); // particle weights used or not\r
5745  //fDiffFlowFlags->Fill(1.5,""); // which event weight was used? // to be improved\r
5746  fDiffFlowFlags->Fill(2.5,fApplyCorrectionForNUA); // corrected for non-uniform acceptance or not\r
5747  fDiffFlowFlags->Fill(3.5,fCalculate2DFlow); // calculate also 2D differential flow in (pt,eta) or not\r
5748     \r
5749 } // end of void AliFlowAnalysisWithQCumulants::StoreDiffFlowFlags()\r
5750 \r
5751 \r
5752 //================================================================================================================================\r
5753 \r
5754 \r
5755 void AliFlowAnalysisWithQCumulants::GetPointersForCommonHistograms(TList *outputListHistos) \r
5756 {\r
5757  // Access all pointers to common control and common result histograms and profiles.\r
5758  \r
5759  if(outputListHistos)  \r
5760  {\r
5761   TString commonHistsName = "AliFlowCommonHistQC";\r
5762   commonHistsName += fAnalysisLabel->Data();\r
5763   AliFlowCommonHist *commonHist = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHistsName.Data()));\r
5764   if(commonHist) this->SetCommonHists(commonHist); \r
5765   TString commonHists2ndOrderName = "AliFlowCommonHist2ndOrderQC";\r
5766   commonHists2ndOrderName += fAnalysisLabel->Data();\r
5767   AliFlowCommonHist *commonHist2nd = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHists2ndOrderName.Data()));\r
5768   if(commonHist2nd) this->SetCommonHists2nd(commonHist2nd);   \r
5769   TString commonHists4thOrderName = "AliFlowCommonHist4thOrderQC";\r
5770   commonHists4thOrderName += fAnalysisLabel->Data();\r
5771   AliFlowCommonHist *commonHist4th = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHists4thOrderName.Data()));\r
5772   if(commonHist4th) this->SetCommonHists4th(commonHist4th);  \r
5773   TString commonHists6thOrderName = "AliFlowCommonHist6thOrderQC";\r
5774   commonHists6thOrderName += fAnalysisLabel->Data();\r
5775   AliFlowCommonHist *commonHist6th = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHists6thOrderName.Data()));\r
5776   if(commonHist6th) this->SetCommonHists6th(commonHist6th);  \r
5777   TString commonHists8thOrderName = "AliFlowCommonHist8thOrderQC";\r
5778   commonHists8thOrderName += fAnalysisLabel->Data();\r
5779   AliFlowCommonHist *commonHist8th = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHists8thOrderName.Data()));\r
5780   if(commonHist8th) this->SetCommonHists8th(commonHist8th);  \r
5781   TString commonHistResults2ndOrderName = "AliFlowCommonHistResults2ndOrderQC"; \r
5782   commonHistResults2ndOrderName += fAnalysisLabel->Data(); \r
5783   AliFlowCommonHistResults *commonHistRes2nd = dynamic_cast<AliFlowCommonHistResults*>\r
5784                                                (outputListHistos->FindObject(commonHistResults2ndOrderName.Data()));\r
5785   if(commonHistRes2nd) this->SetCommonHistsResults2nd(commonHistRes2nd);   \r
5786   TString commonHistResults4thOrderName = "AliFlowCommonHistResults4thOrderQC";\r
5787   commonHistResults4thOrderName += fAnalysisLabel->Data();\r
5788   AliFlowCommonHistResults *commonHistRes4th = dynamic_cast<AliFlowCommonHistResults*>\r
5789                                                (outputListHistos->FindObject(commonHistResults4thOrderName.Data()));\r
5790   if(commonHistRes4th) this->SetCommonHistsResults4th(commonHistRes4th);  \r
5791   TString commonHistResults6thOrderName = "AliFlowCommonHistResults6thOrderQC";\r
5792   commonHistResults6thOrderName += fAnalysisLabel->Data();\r
5793   AliFlowCommonHistResults *commonHistRes6th = dynamic_cast<AliFlowCommonHistResults*>\r
5794                                                (outputListHistos->FindObject(commonHistResults6thOrderName.Data()));\r
5795   if(commonHistRes6th) this->SetCommonHistsResults6th(commonHistRes6th);  \r
5796   TString commonHistResults8thOrderName = "AliFlowCommonHistResults8thOrderQC";\r
5797   commonHistResults8thOrderName += fAnalysisLabel->Data();\r
5798   AliFlowCommonHistResults *commonHistRes8th = dynamic_cast<AliFlowCommonHistResults*>\r
5799                                                (outputListHistos->FindObject(commonHistResults8thOrderName.Data()));  \r
5800   if(commonHistRes8th) this->SetCommonHistsResults8th(commonHistRes8th);\r
5801  } else\r
5802    {\r
5803     cout<<"WARNING: outputListHistos is NULL in AFAWQC::GPFCH() !!!!"<<endl;\r
5804     exit(0);\r
5805    }\r
5806         \r
5807 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForCommonHistograms(TList *outputListHistos) \r
5808 \r
5809 \r
5810 //================================================================================================================================\r
5811 \r
5812 \r
5813 void AliFlowAnalysisWithQCumulants::GetPointersForParticleWeightsHistograms(TList *outputListHistos) \r
5814 {\r
5815  // Get pointers for histograms with particle weights.\r
5816 \r
5817  if(outputListHistos)\r
5818  {\r
5819   TList *weightsList = dynamic_cast<TList*>(outputListHistos->FindObject("Weights"));\r
5820   if(weightsList) this->SetWeightsList(weightsList);\r
5821   TString fUseParticleWeightsName = "fUseParticleWeightsQC"; // to be improved (hirdwired label QC)\r
5822   fUseParticleWeightsName += fAnalysisLabel->Data();\r
5823   TProfile *useParticleWeights = dynamic_cast<TProfile*>(weightsList->FindObject(fUseParticleWeightsName.Data()));\r
5824   if(useParticleWeights)\r
5825   {\r
5826    this->SetUseParticleWeights(useParticleWeights);  \r
5827    fUsePhiWeights = (Int_t)fUseParticleWeights->GetBinContent(1); \r
5828    fUsePtWeights = (Int_t)fUseParticleWeights->GetBinContent(2); \r
5829    fUseEtaWeights = (Int_t)fUseParticleWeights->GetBinContent(3);  \r
5830   }\r
5831  } else\r
5832    {\r
5833     cout<<"WARNING: outputListHistos is NULL in AFAWQC::GPFPWH() !!!!"<<endl;\r
5834     exit(0);\r
5835    }\r
5836 \r
5837 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForParticleWeightsHistograms(TList *outputListHistos); \r
5838 \r
5839 \r
5840 //================================================================================================================================\r
5841 \r
5842 \r
5843 void AliFlowAnalysisWithQCumulants::GetPointersForIntFlowHistograms(TList *outputListHistos) \r
5844 {\r
5845  // Get pointers for histograms and profiles relevant for integrated flow:\r
5846  //  a) Get pointer to base list for integrated flow holding profile fIntFlowFlags and lists fIntFlowProfiles and fIntFlowResults.\r
5847  //  b) Get pointer to profile fIntFlowFlags holding all flags for integrated flow.\r
5848  //  c) Get pointer to list fIntFlowProfiles and pointers to all objects that she holds. \r
5849  //  d) Get pointer to list fIntFlowResults and pointers to all objects that she holds. \r
5850   \r
5851  TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data member?)\r
5852  TString powerFlag[2] = {"linear","quadratic"}; // to be improved (should I promote this to data member?)\r
5853  \r
5854  if(outputListHistos)\r
5855  {\r
5856   // a) Get pointer to base list for integrated flow holding profile fIntFlowFlags and lists fIntFlowProfiles and fIntFlowResults:\r
5857   TList *intFlowList = NULL;\r
5858   intFlowList = dynamic_cast<TList*>(outputListHistos->FindObject("Integrated Flow"));\r
5859   if(!intFlowList) \r
5860   {\r
5861    cout<<"WARNING: intFlowList is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5862    exit(0); \r
5863   }  \r
5864   \r
5865   // b) Get pointer to profile fIntFlowFlags holding all flags for integrated flow:\r
5866   TString intFlowFlagsName = "fIntFlowFlags";\r
5867   intFlowFlagsName += fAnalysisLabel->Data();\r
5868   TProfile *intFlowFlags = dynamic_cast<TProfile*>(intFlowList->FindObject(intFlowFlagsName.Data()));\r
5869   Bool_t bApplyCorrectionForNUA = kFALSE;\r
5870   if(intFlowFlags)\r
5871   {\r
5872    this->SetIntFlowFlags(intFlowFlags);  \r
5873    bApplyCorrectionForNUA = (Int_t)intFlowFlags->GetBinContent(3); \r
5874    this->SetApplyCorrectionForNUA(bApplyCorrectionForNUA);      \r
5875   } else \r
5876     {\r
5877      cout<<"WARNING: intFlowFlags is NULL in FAWQC::GPFIFH() !!!!"<<endl;\r
5878     }\r
5879   \r
5880   // c) Get pointer to list fIntFlowProfiles and pointers to all objects that she holds:\r
5881   TList *intFlowProfiles = NULL;\r
5882   intFlowProfiles = dynamic_cast<TList*>(intFlowList->FindObject("Profiles"));\r
5883   if(intFlowProfiles)  \r
5884   {\r
5885    // average multiplicities:\r
5886    TString avMultiplicityName = "fAvMultiplicity";\r
5887    avMultiplicityName += fAnalysisLabel->Data();\r
5888    TProfile *avMultiplicity = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(avMultiplicityName.Data()));\r
5889    if(avMultiplicity) \r
5890    {\r
5891     this->SetAvMultiplicity(avMultiplicity);\r
5892    } else \r
5893      {\r
5894       cout<<"WARNING: avMultiplicity is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5895      }\r
5896    // average correlations <<2>>, <<4>>, <<6>> and <<8>> (with wrong errors!):\r
5897    TString intFlowCorrelationsProName = "fIntFlowCorrelationsPro";\r
5898    intFlowCorrelationsProName += fAnalysisLabel->Data();\r
5899    TProfile *intFlowCorrelationsPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowCorrelationsProName.Data()));\r
5900    if(intFlowCorrelationsPro) \r
5901    {\r
5902     this->SetIntFlowCorrelationsPro(intFlowCorrelationsPro);\r
5903    } else \r
5904      {\r
5905       cout<<"WARNING: intFlowCorrelationsPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5906      } \r
5907    // average all correlations for integrated flow (with wrong errors!):\r
5908    TString intFlowCorrelationsAllProName = "fIntFlowCorrelationsAllPro";\r
5909    intFlowCorrelationsAllProName += fAnalysisLabel->Data();\r
5910    TProfile *intFlowCorrelationsAllPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowCorrelationsAllProName.Data()));\r
5911    if(intFlowCorrelationsAllPro) \r
5912    {\r
5913     this->SetIntFlowCorrelationsAllPro(intFlowCorrelationsAllPro);\r
5914    } else \r
5915      {\r
5916       cout<<"WARNING: intFlowCorrelationsAllPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5917      }     \r
5918    // average extra correlations for integrated flow (which appear only when particle weights are used):
5919    // (to be improved: Weak point in implementation, I am assuming here that method GetPointersForParticleWeightsHistograms() was called)
5920    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)
5921    {
5922     TString intFlowExtraCorrelationsProName = "fIntFlowExtraCorrelationsPro";\r
5923     intFlowExtraCorrelationsProName += fAnalysisLabel->Data();\r
5924     TProfile *intFlowExtraCorrelationsPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowExtraCorrelationsProName.Data()));\r
5925     if(intFlowExtraCorrelationsPro) \r
5926     {\r
5927      this->SetIntFlowExtraCorrelationsPro(intFlowExtraCorrelationsPro);\r
5928     } else \r
5929       {\r
5930        cout<<"WARNING: intFlowExtraCorrelationsPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5931       }
5932    } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)        \r
5933    // average products of correlations <2>, <4>, <6> and <8>:  \r
5934    TString intFlowProductOfCorrelationsProName = "fIntFlowProductOfCorrelationsPro";\r
5935    intFlowProductOfCorrelationsProName += fAnalysisLabel->Data();\r
5936    TProfile *intFlowProductOfCorrelationsPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowProductOfCorrelationsProName.Data()));\r
5937    if(intFlowProductOfCorrelationsPro) \r
5938    {\r
5939     this->SetIntFlowProductOfCorrelationsPro(intFlowProductOfCorrelationsPro);\r
5940    } else \r
5941      {\r
5942       cout<<"WARNING: intFlowProductOfCorrelationsPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5943      }     \r
5944    // average correction terms for non-uniform acceptance (with wrong errors!):\r
5945    for(Int_t sc=0;sc<2;sc++)\r
5946    {\r
5947     TString intFlowCorrectionTermsForNUAProName = "fIntFlowCorrectionTermsForNUAPro";\r
5948     intFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();\r
5949     TProfile *intFlowCorrectionTermsForNUAPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject((Form("%s: %s terms",intFlowCorrectionTermsForNUAProName.Data(),sinCosFlag[sc].Data()))));\r
5950     if(intFlowCorrectionTermsForNUAPro) \r
5951     {\r
5952      this->SetIntFlowCorrectionTermsForNUAPro(intFlowCorrectionTermsForNUAPro,sc);\r
5953     } else \r
5954       {\r
5955        cout<<"WARNING: intFlowCorrectionTermsForNUAPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5956        cout<<"sc = "<<sc<<endl;\r
5957       } \r
5958    } // end of for(Int_t sc=0;sc<2;sc++)           \r
5959   } else // to if(intFlowProfiles)  \r
5960     {\r
5961      cout<<"WARNING: intFlowProfiles is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5962     }\r
5963    \r
5964   //  d) Get pointer to list fIntFlowResults and pointers to all objects that she holds. \r
5965   TList *intFlowResults = NULL;\r
5966   intFlowResults = dynamic_cast<TList*>(intFlowList->FindObject("Results"));\r
5967   if(intFlowResults)\r
5968   {\r
5969    // average correlations <<2>>, <<4>>, <<6>> and <<8>> (with correct errors!):\r
5970    TString intFlowCorrelationsHistName = "fIntFlowCorrelationsHist";\r
5971    intFlowCorrelationsHistName += fAnalysisLabel->Data();\r
5972    TH1D *intFlowCorrelationsHist = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowCorrelationsHistName.Data()));\r
5973    if(intFlowCorrelationsHist) \r
5974    {\r
5975     this->SetIntFlowCorrelationsHist(intFlowCorrelationsHist);\r
5976    } else \r
5977      {\r
5978       cout<<"WARNING: intFlowCorrelationsHist is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5979      } \r
5980    // average all correlations for integrated flow (with correct errors!):\r
5981    TString intFlowCorrelationsAllHistName = "fIntFlowCorrelationsAllHist";\r
5982    intFlowCorrelationsAllHistName += fAnalysisLabel->Data();\r
5983    TH1D *intFlowCorrelationsAllHist = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowCorrelationsAllHistName.Data()));\r
5984    if(intFlowCorrelationsAllHist) \r
5985    {\r
5986     this->SetIntFlowCorrelationsAllHist(intFlowCorrelationsAllHist);\r
5987    } else \r
5988      {\r
5989       cout<<"WARNING: intFlowCorrelationsAllHist is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5990      }  \r
5991    // average correction terms for non-uniform acceptance (with correct errors!):\r
5992    TString intFlowCorrectionTermsForNUAHistName = "fIntFlowCorrectionTermsForNUAHist";\r
5993    intFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();\r
5994    for(Int_t sc=0;sc<2;sc++)\r
5995    {\r
5996     TH1D *intFlowCorrectionTermsForNUAHist = dynamic_cast<TH1D*>(intFlowResults->FindObject((Form("%s: %s terms",intFlowCorrectionTermsForNUAHistName.Data(),sinCosFlag[sc].Data()))));\r
5997     if(intFlowCorrectionTermsForNUAHist) \r
5998     {\r
5999      this->SetIntFlowCorrectionTermsForNUAHist(intFlowCorrectionTermsForNUAHist,sc);\r
6000     } else \r
6001       {\r
6002        cout<<"WARNING: intFlowCorrectionTermsForNUAHist is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6003        cout<<"sc = "<<sc<<endl;\r
6004       } \r
6005    } // end of for(Int_t sc=0;sc<2;sc++)           \r
6006    // covariances (multiplied with weight dependent prefactor):\r
6007    TString intFlowCovariancesName = "fIntFlowCovariances";\r
6008    intFlowCovariancesName += fAnalysisLabel->Data();\r
6009    TH1D *intFlowCovariances = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowCovariancesName.Data()));\r
6010    if(intFlowCovariances) \r
6011    {\r
6012     this->SetIntFlowCovariances(intFlowCovariances); \r
6013    } else \r
6014      {\r
6015       cout<<"WARNING: intFlowCovariances is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6016      } \r
6017    // sum of linear and quadratic event weights for <2>, <4>, <6> and <8>:\r
6018    TString intFlowSumOfEventWeightsName = "fIntFlowSumOfEventWeights";\r
6019    intFlowSumOfEventWeightsName += fAnalysisLabel->Data();\r
6020    for(Int_t power=0;power<2;power++)\r
6021    {\r
6022     TH1D *intFlowSumOfEventWeights = dynamic_cast<TH1D*>(intFlowResults->FindObject(Form("%s: %s",intFlowSumOfEventWeightsName.Data(),powerFlag[power].Data())));\r
6023     if(intFlowSumOfEventWeights) \r
6024     {\r
6025      this->SetIntFlowSumOfEventWeights(intFlowSumOfEventWeights,power);\r
6026     } else \r
6027       {\r
6028        cout<<"WARNING: intFlowSumOfEventWeights is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6029        cout<<"power = "<<power<<endl;\r
6030       }                                   \r
6031    } // end of for(Int_t power=0;power<2;power++)                                                                  \r
6032    // sum of products of event weights for correlations <2>, <4>, <6> and <8>:  \r
6033    TString intFlowSumOfProductOfEventWeightsName = "fIntFlowSumOfProductOfEventWeights";\r
6034    intFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();\r
6035    TH1D *intFlowSumOfProductOfEventWeights = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowSumOfProductOfEventWeightsName.Data()));\r
6036    if(intFlowSumOfProductOfEventWeights) \r
6037    {\r
6038     this->SetIntFlowSumOfProductOfEventWeights(intFlowSumOfProductOfEventWeights);\r
6039    } else \r
6040      {\r
6041       cout<<"WARNING: intFlowSumOfProductOfEventWeights is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6042      } \r
6043    // final results for integrated Q-cumulants:\r
6044    TString intFlowQcumulantsName = "fIntFlowQcumulants";\r
6045    intFlowQcumulantsName += fAnalysisLabel->Data();\r
6046    TH1D *intFlowQcumulants = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowQcumulantsName.Data()));\r
6047    if(intFlowQcumulants) \r
6048    {\r
6049     this->SetIntFlowQcumulants(intFlowQcumulants);\r
6050    } else \r
6051      {\r
6052       cout<<"WARNING: intFlowQcumulants is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6053      }  \r
6054    // final integrated flow estimates from Q-cumulants:\r
6055    TString intFlowName = "fIntFlow";\r
6056    intFlowName += fAnalysisLabel->Data();\r
6057    TH1D *intFlow = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowName.Data()));\r
6058    if(intFlow) \r
6059    {\r
6060     this->SetIntFlow(intFlow);\r
6061    } else \r
6062      {\r
6063       cout<<"WARNING: intFlow is NULL in AFAWQC::GPFIFH() !!!!"<<endl; \r
6064      }   \r
6065   } else // to if(intFlowResults)\r
6066     {\r
6067      cout<<"WARNING: intFlowResults is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6068     }\r
6069  } // end of if(outputListHistos)\r
6070 \r
6071 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForIntFlowHistograms(TList *outputListHistos)\r
6072 \r
6073 \r
6074 //================================================================================================================================\r
6075 \r
6076 \r
6077 void AliFlowAnalysisWithQCumulants::GetPointersForDiffFlowHistograms(TList *outputListHistos)\r
6078 {\r
6079  // Get pointer to all objects relevant for differential flow.\r
6080  //  a) Define flags locally (to be improved: should I promote flags to data members?);\r
6081  //  b) Get pointer to base list for differential flow fDiffFlowList and nested lists fDiffFlowListProfiles and fDiffFlowListResults;\r
6082  //  c) Get pointer to profile fDiffFlowFlags holding all flags for differential flow;\r
6083  //  d) Get pointers to all nested lists in fDiffFlowListProfiles and to profiles which they hold;\r
6084  //  e) Get pointers to all nested lists in fDiffFlowListResults and to histograms which they hold.\r
6085  \r
6086  // a) Define flags locally (to be improved: should I promote flags to data members?): \r
6087  TString typeFlag[2] = {"RP","POI"}; \r
6088  TString ptEtaFlag[2] = {"p_{T}","#eta"};\r
6089  TString powerFlag[2] = {"linear","quadratic"};\r
6090  TString sinCosFlag[2] = {"sin","cos"};\r
6091  TString differentialCumulantIndex[4] = {"QC{2'}","QC{4'}","QC{6'}","QC{8'}"};  \r
6092  TString differentialFlowIndex[4] = {"v'{2}","v'{4}","v'{6}","v'{8}"};  \r
6093  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"};\r
6094  TString mixedCorrelationIndex[8] = {"<2>","<2'>","<4>","<4'>","<6>","<6'>","<8>","<8'>"};\r
6095  TString covarianceName[5] = {"Cov(<2>,<2'>)","Cov(<2>,<4'>)","Cov(<4>,<2'>)","Cov(<4>,<4'>)","Cov(<2'>,<4'>)"}; \r
6096   \r
6097  // b) Get pointer to base list for differential flow fDiffFlowList and nested lists fDiffFlowListProfiles and fDiffFlowListResults:\r
6098  TList *diffFlowList = NULL;\r
6099  diffFlowList = dynamic_cast<TList*>(outputListHistos->FindObject("Differential Flow"));  \r
6100  if(!diffFlowList)\r
6101  { \r
6102   cout<<"WARNING: diffFlowList is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6103   exit(0);\r
6104  }\r
6105  // list holding nested lists containing profiles:\r
6106  TList *diffFlowListProfiles = NULL;\r
6107  diffFlowListProfiles = dynamic_cast<TList*>(diffFlowList->FindObject("Profiles"));\r
6108  if(!diffFlowListProfiles)\r
6109  { \r
6110   cout<<"WARNING: diffFlowListProfiles is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6111   exit(0);\r
6112  }\r
6113  // list holding nested lists containing 2D and 1D histograms with final results:\r
6114  TList *diffFlowListResults = NULL;\r
6115  diffFlowListResults = dynamic_cast<TList*>(diffFlowList->FindObject("Results"));\r
6116  if(!diffFlowListResults)\r
6117  { \r
6118   cout<<"WARNING: diffFlowListResults is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6119   exit(0);\r
6120  }\r
6121  \r
6122  // c) Get pointer to profile holding all flags for differential flow;\r
6123  TString diffFlowFlagsName = "fDiffFlowFlags";\r
6124  diffFlowFlagsName += fAnalysisLabel->Data();\r
6125  TProfile *diffFlowFlags = dynamic_cast<TProfile*>(diffFlowList->FindObject(diffFlowFlagsName.Data()));\r
6126  Bool_t bCalculate2DFlow = kFALSE;\r
6127  if(diffFlowFlags)\r
6128  {\r
6129   this->SetDiffFlowFlags(diffFlowFlags);  \r
6130   bCalculate2DFlow = (Int_t)diffFlowFlags->GetBinContent(4);\r
6131   this->SetCalculate2DFlow(bCalculate2DFlow); // to be improved (shoul I call this setter somewhere else?)     \r
6132  }\r
6133   \r
6134  // d) Get pointers to all nested lists in fDiffFlowListProfiles and to profiles which they hold;\r
6135  // correlations:\r
6136  TList *diffFlowCorrelationsProList[2][2] = {{NULL}};\r
6137  TString diffFlowCorrelationsProName = "fDiffFlowCorrelationsPro";\r
6138  diffFlowCorrelationsProName += fAnalysisLabel->Data();\r
6139  TProfile *diffFlowCorrelationsPro[2][2][4] = {{{NULL}}};   \r
6140  // products of correlations:\r
6141  TList *diffFlowProductOfCorrelationsProList[2][2] = {{NULL}};\r
6142  TString diffFlowProductOfCorrelationsProName = "fDiffFlowProductOfCorrelationsPro";\r
6143  diffFlowProductOfCorrelationsProName += fAnalysisLabel->Data();  \r
6144  TProfile *diffFlowProductOfCorrelationsPro[2][2][8][8] = {{{{NULL}}}};   \r
6145  // corrections:\r
6146  TList *diffFlowCorrectionsProList[2][2] = {{NULL}};\r
6147  TString diffFlowCorrectionTermsForNUAProName = "fDiffFlowCorrectionTermsForNUAPro";\r
6148  diffFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();  \r
6149  TProfile *diffFlowCorrectionTermsForNUAPro[2][2][2][10] = {{{{NULL}}}};   \r
6150  for(Int_t t=0;t<2;t++)\r
6151  {\r
6152   for(Int_t pe=0;pe<2;pe++)\r
6153   {\r
6154    diffFlowCorrelationsProList[t][pe] = dynamic_cast<TList*>(diffFlowListProfiles->FindObject(Form("Profiles with correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6155    if(!diffFlowCorrelationsProList[t][pe])\r
6156    { \r
6157     cout<<"WARNING: diffFlowCorrelationsProList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6158     cout<<"t = "<<t<<endl;\r
6159     cout<<"pe = "<<pe<<endl;\r
6160     exit(0);\r
6161    }\r
6162    for(Int_t ci=0;ci<4;ci++) // correlation index\r
6163    {\r
6164     diffFlowCorrelationsPro[t][pe][ci] = dynamic_cast<TProfile*>(diffFlowCorrelationsProList[t][pe]->FindObject(Form("%s, %s, %s, %s",diffFlowCorrelationsProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[ci].Data())));\r
6165     if(diffFlowCorrelationsPro[t][pe][ci])\r
6166     {\r
6167      this->SetDiffFlowCorrelationsPro(diffFlowCorrelationsPro[t][pe][ci],t,pe,ci);\r
6168     } else\r
6169       {\r
6170        cout<<"WARNING: diffFlowCorrelationsPro[t][pe][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6171        cout<<"t  = "<<t<<endl;\r
6172        cout<<"pe = "<<pe<<endl;   \r
6173        cout<<"ci = "<<ci<<endl;\r
6174       }     \r
6175    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index  \r
6176    // products of correlations:    \r
6177    diffFlowProductOfCorrelationsProList[t][pe] = dynamic_cast<TList*>(diffFlowListProfiles->FindObject(Form("Profiles with products of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()))); \r
6178    if(!diffFlowProductOfCorrelationsProList[t][pe])\r
6179    { \r
6180     cout<<"WARNING: ddiffFlowProductOfCorrelationsProList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6181     cout<<"t = "<<t<<endl;\r
6182     cout<<"pe = "<<pe<<endl;\r
6183     exit(0);\r
6184    }\r
6185    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
6186    {\r
6187     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6188     {\r
6189      diffFlowProductOfCorrelationsPro[t][pe][mci1][mci2] = dynamic_cast<TProfile*>(diffFlowProductOfCorrelationsProList[t][pe]->FindObject(Form("%s, %s, %s, %s, %s",diffFlowProductOfCorrelationsProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),mixedCorrelationIndex[mci1].Data(),mixedCorrelationIndex[mci2].Data())));\r
6190      if(diffFlowProductOfCorrelationsPro[t][pe][mci1][mci2])\r
6191      {\r
6192       this->SetDiffFlowProductOfCorrelationsPro(diffFlowProductOfCorrelationsPro[t][pe][mci1][mci2],t,pe,mci1,mci2);\r
6193      } else\r
6194        {\r
6195         cout<<"WARNING: diffFlowCorrelationsPro[t][pe][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6196         cout<<"t    = "<<t<<endl;\r
6197         cout<<"pe   = "<<pe<<endl;   \r
6198         cout<<"mci1 = "<<mci1<<endl;\r
6199         cout<<"mci2 = "<<mci2<<endl;\r
6200        }\r
6201      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here\r
6202     } // end of for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6203    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index    \r
6204    // corrections:\r
6205    diffFlowCorrectionsProList[t][pe] = dynamic_cast<TList*>(diffFlowListProfiles->FindObject(Form("Profiles with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6206    if(!diffFlowCorrectionsProList[t][pe])\r
6207    { \r
6208     cout<<"WARNING: diffFlowCorrectionsProList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6209     cout<<"t = "<<t<<endl;\r
6210     cout<<"pe = "<<pe<<endl;\r
6211     exit(0);\r
6212    }\r
6213    // correction terms for NUA:\r
6214    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6215    {\r
6216     for(Int_t cti=0;cti<9;cti++) // correction term index\r
6217     {\r
6218      diffFlowCorrectionTermsForNUAPro[t][pe][sc][cti] = dynamic_cast<TProfile*>(diffFlowCorrectionsProList[t][pe]->FindObject(Form("%s, %s, %s, %s, cti = %d",diffFlowCorrectionTermsForNUAProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),cti+1)));\r
6219      if(diffFlowCorrectionTermsForNUAPro[t][pe][sc][cti])\r
6220      {\r
6221       this->SetDiffFlowCorrectionTermsForNUAPro(diffFlowCorrectionTermsForNUAPro[t][pe][sc][cti],t,pe,sc,cti);\r
6222      } else\r
6223        {\r
6224         cout<<"WARNING: diffFlowCorrectionTermsForNUAPro[t][pe][sc][cti] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6225         cout<<"t   = "<<t<<endl;\r
6226         cout<<"pe  = "<<pe<<endl;   \r
6227         cout<<"sc  = "<<sc<<endl;\r
6228         cout<<"cti = "<<cti<<endl;\r
6229        }    \r
6230     } // end of for(Int_t cti=0;cti<9;cti++) // correction term index\r
6231    } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6232    // ...\r
6233   } // end of for(Int_t pe=0;pe<2;pe++)\r
6234  } // end of for(Int_t t=0;t<2;t++)\r
6235   \r
6236  // e) Get pointers to all nested lists in fDiffFlowListResults and to histograms which they hold.\r
6237  // reduced correlations:\r
6238  TList *diffFlowCorrelationsHistList[2][2] = {{NULL}};\r
6239  TString diffFlowCorrelationsHistName = "fDiffFlowCorrelationsHist";\r
6240  diffFlowCorrelationsHistName += fAnalysisLabel->Data();  \r
6241  TH1D *diffFlowCorrelationsHist[2][2][4] = {{{NULL}}};\r
6242  // corrections for NUA:\r
6243  TList *diffFlowCorrectionsHistList[2][2] = {{NULL}};\r
6244  TString diffFlowCorrectionTermsForNUAHistName = "fDiffFlowCorrectionTermsForNUAHist";\r
6245  diffFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();  \r
6246  TH1D *diffFlowCorrectionTermsForNUAHist[2][2][2][10] = {{{{NULL}}}};\r
6247  // differential Q-cumulants:\r
6248  TList *diffFlowCumulantsHistList[2][2] = {{NULL}};\r
6249  TString diffFlowCumulantsName = "fDiffFlowCumulants";\r
6250  diffFlowCumulantsName += fAnalysisLabel->Data();  \r
6251  TH1D *diffFlowCumulants[2][2][4] = {{{NULL}}};\r
6252  // differential flow estimates from Q-cumulants:\r
6253  TList *diffFlowHistList[2][2] = {{NULL}};\r
6254  TString diffFlowName = "fDiffFlow";\r
6255  diffFlowName += fAnalysisLabel->Data();  \r
6256  TH1D *diffFlow[2][2][4] = {{{NULL}}};\r
6257  // differential covariances:\r
6258  TList *diffFlowCovariancesHistList[2][2] = {{NULL}};\r
6259  TString diffFlowCovariancesName = "fDiffFlowCovariances";\r
6260  diffFlowCovariancesName += fAnalysisLabel->Data();  \r
6261  TH1D *diffFlowCovariances[2][2][5] = {{{NULL}}};\r
6262  for(Int_t t=0;t<2;t++) // type: RP or POI\r
6263  { \r
6264   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6265   {\r
6266    // reduced correlations:\r
6267    diffFlowCorrelationsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6268    if(!diffFlowCorrelationsHistList[t][pe])\r
6269    { \r
6270     cout<<"WARNING: diffFlowCorrelationsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6271     cout<<"t = "<<t<<endl;\r
6272     cout<<"pe = "<<pe<<endl;\r
6273     exit(0);\r
6274    }\r
6275    for(Int_t index=0;index<4;index++) \r
6276    {\r
6277     diffFlowCorrelationsHist[t][pe][index] = dynamic_cast<TH1D*>(diffFlowCorrelationsHistList[t][pe]->FindObject(Form("%s, %s, %s, %s",diffFlowCorrelationsHistName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[index].Data())));\r
6278     if(diffFlowCorrelationsHist[t][pe][index])\r
6279     {\r
6280      this->SetDiffFlowCorrelationsHist(diffFlowCorrelationsHist[t][pe][index],t,pe,index);\r
6281     } else \r
6282       {\r
6283        cout<<"WARNING: diffFlowCorrelationsHist[t][pe][index] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6284        cout<<"t     = "<<t<<endl;\r
6285        cout<<"pe    = "<<pe<<endl;\r
6286        cout<<"index = "<<index<<endl;\r
6287        exit(0);       \r
6288       } \r
6289    } // end of for(Int_t index=0;index<4;index++)\r
6290    // corrections:\r
6291    diffFlowCorrectionsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Histograms with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6292    if(!diffFlowCorrectionsHistList[t][pe])\r
6293    { \r
6294     cout<<"WARNING: diffFlowCorrectionsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6295     cout<<"t = "<<t<<endl;\r
6296     cout<<"pe = "<<pe<<endl;\r
6297     exit(0);\r
6298    }\r
6299    // correction terms for NUA:\r
6300    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6301    {\r
6302     for(Int_t cti=0;cti<9;cti++) // correction term index\r
6303     {\r
6304      diffFlowCorrectionTermsForNUAHist[t][pe][sc][cti] = dynamic_cast<TH1D*>(diffFlowCorrectionsHistList[t][pe]->FindObject(Form("%s, %s, %s, %s, cti = %d",diffFlowCorrectionTermsForNUAHistName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),cti+1)));\r
6305      if(diffFlowCorrectionTermsForNUAHist[t][pe][sc][cti])\r
6306      {\r
6307       this->SetDiffFlowCorrectionTermsForNUAHist(diffFlowCorrectionTermsForNUAHist[t][pe][sc][cti],t,pe,sc,cti);\r
6308      } else\r
6309        {\r
6310         cout<<"WARNING: diffFlowCorrectionTermsForNUAHist[t][pe][sc][cti] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6311         cout<<"t   = "<<t<<endl;\r
6312         cout<<"pe  = "<<pe<<endl;   \r
6313         cout<<"sc  = "<<sc<<endl;\r
6314         cout<<"cti = "<<cti<<endl;\r
6315        }    \r
6316     } // end of for(Int_t cti=0;cti<9;cti++) // correction term index\r
6317    } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6318    // ...\r
6319    // differential Q-cumulants:\r
6320    diffFlowCumulantsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Differential Q-cumulants (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6321    if(!diffFlowCumulantsHistList[t][pe])\r
6322    { \r
6323     cout<<"WARNING: diffFlowCumulantsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6324     cout<<"t  = "<<t<<endl;\r
6325     cout<<"pe = "<<pe<<endl;\r
6326     exit(0);\r
6327    }\r
6328    for(Int_t index=0;index<4;index++) \r
6329    {\r
6330     diffFlowCumulants[t][pe][index] = dynamic_cast<TH1D*>(diffFlowCumulantsHistList[t][pe]->FindObject(Form("%s, %s, %s, %s",diffFlowCumulantsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),differentialCumulantIndex[index].Data())));\r
6331     if(diffFlowCumulants[t][pe][index])\r
6332     {\r
6333      this->SetDiffFlowCumulants(diffFlowCumulants[t][pe][index],t,pe,index);\r
6334     } else \r
6335       {\r
6336        cout<<"WARNING: diffFlowCumulants[t][pe][index] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6337        cout<<"t     = "<<t<<endl;\r
6338        cout<<"pe    = "<<pe<<endl;\r
6339        cout<<"index = "<<index<<endl;\r
6340        exit(0);       \r
6341       } \r
6342    } // end of for(Int_t index=0;index<4;index++)\r
6343    // differential flow estimates from Q-cumulants:\r
6344    diffFlowHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Differential flow (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6345    if(!diffFlowHistList[t][pe])\r
6346    { \r
6347     cout<<"WARNING: diffFlowHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6348     cout<<"t  = "<<t<<endl;\r
6349     cout<<"pe = "<<pe<<endl;\r
6350     exit(0);\r
6351    }\r
6352    for(Int_t index=0;index<4;index++) \r
6353    {\r
6354     diffFlow[t][pe][index] = dynamic_cast<TH1D*>(diffFlowHistList[t][pe]->FindObject(Form("%s, %s, %s, %s",diffFlowName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),differentialFlowIndex[index].Data())));\r
6355     if(diffFlow[t][pe][index])\r
6356     {\r
6357      this->SetDiffFlow(diffFlow[t][pe][index],t,pe,index);\r
6358     } else \r
6359       {\r
6360        cout<<"WARNING: diffFlow[t][pe][index] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6361        cout<<"t     = "<<t<<endl;\r
6362        cout<<"pe    = "<<pe<<endl;\r
6363        cout<<"index = "<<index<<endl;\r
6364        exit(0);       \r
6365       } \r
6366    } // end of for(Int_t index=0;index<4;index++)\r
6367    // differential covariances:\r
6368    diffFlowCovariancesHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Covariances of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6369    if(!diffFlowCovariancesHistList[t][pe])\r
6370    { \r
6371     cout<<"WARNING: diffFlowCovariancesHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6372     cout<<"t  = "<<t<<endl;\r
6373     cout<<"pe = "<<pe<<endl;\r
6374     exit(0);\r
6375    }\r
6376    for(Int_t covIndex=0;covIndex<5;covIndex++) \r
6377    {\r
6378     diffFlowCovariances[t][pe][covIndex] = dynamic_cast<TH1D*>(diffFlowCovariancesHistList[t][pe]->FindObject(Form("%s, %s, %s, %s",diffFlowCovariancesName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),covarianceName[covIndex].Data())));\r
6379     if(diffFlowCovariances[t][pe][covIndex])\r
6380     {\r
6381      this->SetDiffFlowCovariances(diffFlowCovariances[t][pe][covIndex],t,pe,covIndex);\r
6382     } else \r
6383       {\r
6384        cout<<"WARNING: diffFlowCovariances[t][pe][covIndex] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6385        cout<<"t        = "<<t<<endl;\r
6386        cout<<"pe       = "<<pe<<endl;\r
6387        cout<<"covIndex = "<<covIndex<<endl;\r
6388        exit(0);       \r
6389       } \r
6390    } // end of for(Int_t covIndex=0;covIndex<5;covIndex++) // covariance index    \r
6391   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6392  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI \r
6393  // sum of event weights for reduced correlations:\r
6394  TList *diffFlowSumOfEventWeightsHistList[2][2][2] = {{{NULL}}};\r
6395  TString diffFlowSumOfEventWeightsName = "fDiffFlowSumOfEventWeights";\r
6396  diffFlowSumOfEventWeightsName += fAnalysisLabel->Data();  \r
6397  TH1D *diffFlowSumOfEventWeights[2][2][2][4] = {{{{NULL}}}};\r
6398  for(Int_t t=0;t<2;t++) // type is RP or POI\r
6399  { \r
6400   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6401   { \r
6402    for(Int_t p=0;p<2;p++) // power of event weights is either 1 or 2\r
6403    {\r
6404     diffFlowSumOfEventWeightsHistList[t][pe][p] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Sum of %s event weights (%s, %s)",powerFlag[p].Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6405     if(!diffFlowSumOfEventWeightsHistList[t][pe][p])\r
6406     { \r
6407      cout<<"WARNING: diffFlowSumOfEventWeightsHistList[t][pe][p] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6408      cout<<"t     = "<<t<<endl;\r
6409      cout<<"pe    = "<<pe<<endl;\r
6410      cout<<"power = "<<p<<endl;\r
6411      exit(0);\r
6412     }\r
6413     for(Int_t ew=0;ew<4;ew++) // index of reduced correlation\r
6414     {\r
6415      diffFlowSumOfEventWeights[t][pe][p][ew] = dynamic_cast<TH1D*>(diffFlowSumOfEventWeightsHistList[t][pe][p]->FindObject(Form("%s, %s, %s, %s, %s",diffFlowSumOfEventWeightsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),powerFlag[p].Data(),reducedCorrelationIndex[ew].Data())));    \r
6416      if(diffFlowSumOfEventWeights[t][pe][p][ew])\r
6417      {\r
6418       this->SetDiffFlowSumOfEventWeights(diffFlowSumOfEventWeights[t][pe][p][ew],t,pe,p,ew);\r
6419      } else \r
6420        {\r
6421         cout<<"WARNING: diffFlowSumOfEventWeights[t][pe][p][ew] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6422         cout<<"t     = "<<t<<endl;\r
6423         cout<<"pe    = "<<pe<<endl;\r
6424         cout<<"power = "<<p<<endl;\r
6425         cout<<"ew    = "<<ew<<endl;\r
6426         exit(0);       \r
6427        } \r
6428     }\r
6429    } // end of for(Int_t p=0;p<2;p++) // power of event weights is either 1 or 2\r
6430   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6431  } // end of for(Int_t t=0;t<2;t++) // type is RP or POI\r
6432  //  \r
6433  TList *diffFlowSumOfProductOfEventWeightsHistList[2][2] = {{NULL}};\r
6434  TString diffFlowSumOfProductOfEventWeightsName = "fDiffFlowSumOfProductOfEventWeights";\r
6435  diffFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();  \r
6436  TH1D *diffFlowSumOfProductOfEventWeights[2][2][8][8] = {{{{NULL}}}};\r
6437  for(Int_t t=0;t<2;t++) // type is RP or POI\r
6438  { \r
6439   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6440   { \r
6441    diffFlowSumOfProductOfEventWeightsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Sum of products of event weights (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6442    if(!diffFlowSumOfProductOfEventWeightsHistList[t][pe])\r
6443    { \r
6444     cout<<"WARNING: diffFlowSumOfProductOfEventWeightsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6445     cout<<"t     = "<<t<<endl;\r
6446     cout<<"pe    = "<<pe<<endl;\r
6447     exit(0);\r
6448    }\r
6449    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
6450    {\r
6451     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6452     {\r
6453      diffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2] = dynamic_cast<TH1D*>(diffFlowSumOfProductOfEventWeightsHistList[t][pe]->FindObject(Form("%s, %s, %s, %s, %s",diffFlowSumOfProductOfEventWeightsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),mixedCorrelationIndex[mci1].Data(),mixedCorrelationIndex[mci2].Data())));    \r
6454       if(diffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2])\r
6455       {\r
6456        this->SetDiffFlowSumOfProductOfEventWeights(diffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2],t,pe,mci1,mci2);\r
6457       } else \r
6458         {\r
6459          cout<<"WARNING: diffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6460          cout<<"t    = "<<t<<endl;\r
6461          cout<<"pe   = "<<pe<<endl;\r
6462          cout<<"mci1 = "<<mci1<<endl;\r
6463          cout<<"mci2 = "<<mci2<<endl;\r
6464          exit(0);       \r
6465         } \r
6466      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here\r
6467     } // end of for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6468    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
6469   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6470  } // end of for(Int_t t=0;t<2;t++) // type is RP or POI\r
6471 \r
6472 } // end void AliFlowAnalysisWithQCumulants::GetPointersForDiffFlowHistograms(TList *outputListHistos)\r
6473 \r
6474 \r
6475 //================================================================================================================================\r
6476 \r
6477 \r
6478 void AliFlowAnalysisWithQCumulants::BookEverythingForDifferentialFlow()\r
6479 {\r
6480  // Book all histograms and profiles needed for differential flow.\r
6481  //  a) Define flags locally (to be improved: should I promote flags to data members?);\r
6482  //  b) Book profile to hold all flags for differential flow;\r
6483  //  c) Book e-b-e quantities;\r
6484  //  d) Book profiles;\r
6485  //  e) Book histograms holding final results. \r
6486  \r
6487  // a) Define flags locally (to be improved: should I promote flags to data members?): \r
6488  TString typeFlag[2] = {"RP","POI"}; \r
6489  TString ptEtaFlag[2] = {"p_{T}","#eta"};\r
6490  TString powerFlag[2] = {"linear","quadratic"};\r
6491  TString sinCosFlag[2] = {"sin","cos"};\r
6492  TString differentialCumulantIndex[4] = {"QC{2'}","QC{4'}","QC{6'}","QC{8'}"};  \r
6493  TString differentialFlowIndex[4] = {"v'{2}","v'{4}","v'{6}","v'{8}"};  \r
6494  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"};\r
6495  TString mixedCorrelationIndex[8] = {"<2>","<2'>","<4>","<4'>","<6>","<6'>","<8>","<8'>"};\r
6496  TString covarianceName[5] = {"Cov(<2>,<2'>)","Cov(<2>,<4'>)","Cov(<4>,<2'>)","Cov(<4>,<4'>)","Cov(<2'>,<4'>)"}; \r
6497  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
6498  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
6499  Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
6500   \r
6501  // b) Book profile to hold all flags for differential flow:\r
6502  TString diffFlowFlagsName = "fDiffFlowFlags";\r
6503  diffFlowFlagsName += fAnalysisLabel->Data();\r
6504  fDiffFlowFlags = new TProfile(diffFlowFlagsName.Data(),"Flags for Differential Flow",4,0,4);\r
6505  fDiffFlowFlags->SetTickLength(-0.01,"Y");\r
6506  fDiffFlowFlags->SetMarkerStyle(25);\r
6507  fDiffFlowFlags->SetLabelSize(0.05);\r
6508  fDiffFlowFlags->SetLabelOffset(0.02,"Y");\r
6509  (fDiffFlowFlags->GetXaxis())->SetBinLabel(1,"Particle Weights");\r
6510  (fDiffFlowFlags->GetXaxis())->SetBinLabel(2,"Event Weights");\r
6511  (fDiffFlowFlags->GetXaxis())->SetBinLabel(3,"Corrected for NUA?");\r
6512  (fDiffFlowFlags->GetXaxis())->SetBinLabel(4,"Calculated 2D flow?");\r
6513  fDiffFlowList->Add(fDiffFlowFlags);\r
6514 \r
6515  // c) Book e-b-e quantities:\r
6516  // Event-by-event r_{m*n,k}(pt,eta), p_{m*n,k}(pt,eta) and q_{m*n,k}(pt,eta)\r
6517  // Explanantion of notation:\r
6518  //  1.) n is harmonic, m is multiple of harmonic;\r
6519  //  2.) k is power of particle weight;\r
6520  //  3.) r_{m*n,k}(pt,eta) = Q-vector evaluated in harmonic m*n for RPs in particular (pt,eta) bin (i-th RP is weighted with w_i^k);   \r
6521  //  4.) p_{m*n,k}(pt,eta) = Q-vector evaluated in harmonic m*n for POIs in particular (pt,eta) bin \r
6522  //                          (if i-th POI is also RP, than it is weighted with w_i^k);   \r
6523  //  5.) q_{m*n,k}(pt,eta) = Q-vector evaluated in harmonic m*n for particles which are both RPs and POIs in particular (pt,eta) bin \r
6524  //                          (i-th RP&&POI is weighted with w_i^k)            \r
6525   \r
6526  // 1D:\r
6527  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP && POI )\r
6528  { \r
6529   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6530   {\r
6531    for(Int_t m=0;m<4;m++) // multiple of harmonic\r
6532    {\r
6533     for(Int_t k=0;k<9;k++) // power of particle weight\r
6534     {\r
6535      fReRPQ1dEBE[t][pe][m][k] = new TProfile(Form("TypeFlag%dpteta%dmultiple%dpower%dRe",t,pe,m,k),\r
6536                                              Form("TypeFlag%dpteta%dmultiple%dpower%dRe",t,pe,m,k),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6537      fImRPQ1dEBE[t][pe][m][k] = new TProfile(Form("TypeFlag%dpteta%dmultiple%dpower%dIm",t,pe,m,k),\r
6538                                              Form("TypeFlag%dpteta%dmultiple%dpower%dIm",t,pe,m,k),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6539     }\r
6540    }\r
6541   }\r
6542  } \r
6543  // to be improved (add explanation of fs1dEBE[t][pe][k]):   \r
6544  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP&&POI )\r
6545  { \r
6546   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6547   {\r
6548    for(Int_t k=0;k<9;k++) // power of particle weight\r
6549    {\r
6550     fs1dEBE[t][pe][k] = new TProfile(Form("TypeFlag%dpteta%dmultiple%d",t,pe,k),\r
6551                                      Form("TypeFlag%dpteta%dmultiple%d",t,pe,k),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6552    }\r
6553   }\r
6554  }\r
6555  // correction terms for nua:\r
6556  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)\r
6557  { \r
6558   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6559   {\r
6560    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6561    {\r
6562     for(Int_t cti=0;cti<9;cti++) // correction term index\r
6563     {\r
6564      fDiffFlowCorrectionTermsForNUAEBE[t][pe][sc][cti] = new TH1D(Form("typeFlag%d pteta%d sincos%d cti%d",t,pe,sc,cti),\r
6565                                              Form("typeFlag%d pteta%d sincos%d cti%d",t,pe,sc,cti),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6566     }\r
6567    }\r
6568   }\r
6569  } \r
6570  // 2D:\r
6571  TProfile2D styleRe("typeMultiplePowerRe","typeMultiplePowerRe",fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);\r
6572  TProfile2D styleIm("typeMultiplePowerIm","typeMultiplePowerIm",fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);\r
6573  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP&&POI )\r
6574  { \r
6575   for(Int_t m=0;m<4;m++)\r
6576   {\r
6577    for(Int_t k=0;k<9;k++)\r
6578    {\r
6579     fReRPQ2dEBE[t][m][k] = (TProfile2D*)styleRe.Clone(Form("typeFlag%dmultiple%dpower%dRe",t,m,k)); \r
6580     fImRPQ2dEBE[t][m][k] = (TProfile2D*)styleIm.Clone(Form("typeFlag%dmultiple%dpower%dIm",t,m,k));\r
6581    }\r
6582   } \r
6583  } \r
6584  TProfile2D styleS("typePower","typePower",fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);\r
6585  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP&&POI )\r
6586  { \r
6587   for(Int_t k=0;k<9;k++)\r
6588   {\r
6589    fs2dEBE[t][k] = (TProfile2D*)styleS.Clone(Form("typeFlag%dpower%d",t,k));\r
6590   }\r
6591  }\r
6592  // reduced correlations e-b-e:\r
6593  TString diffFlowCorrelationsEBEName = "fDiffFlowCorrelationsEBE";\r
6594  diffFlowCorrelationsEBEName += fAnalysisLabel->Data();\r
6595  for(Int_t t=0;t<2;t++) // type: RP or POI\r
6596  { \r
6597   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6598   {\r
6599    for(Int_t rci=0;rci<4;rci++) // reduced correlation index\r
6600    {\r
6601     fDiffFlowCorrelationsEBE[t][pe][rci] = new TH1D(Form("%s, %s, %s, %s",diffFlowCorrelationsEBEName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[rci].Data()),Form("%s, %s, %s, %s",diffFlowCorrelationsEBEName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[rci].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]);\r
6602    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index\r
6603   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
6604  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
6605  // event weights for reduced correlations e-b-e:\r
6606  TString diffFlowEventWeightsForCorrelationsEBEName = "fDiffFlowEventWeightsForCorrelationsEBE";\r
6607  diffFlowEventWeightsForCorrelationsEBEName += fAnalysisLabel->Data();\r
6608  for(Int_t t=0;t<2;t++) // type: RP or POI\r
6609  { \r
6610   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6611   {\r
6612    for(Int_t rci=0;rci<4;rci++) // event weight for reduced correlation index\r
6613    {\r
6614     fDiffFlowEventWeightsForCorrelationsEBE[t][pe][rci] = new TH1D(Form("%s, %s, %s, eW for %s",diffFlowEventWeightsForCorrelationsEBEName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[rci].Data()),Form("%s, %s, %s, eW for %s",diffFlowEventWeightsForCorrelationsEBEName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[rci].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]);\r
6615    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index\r
6616   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
6617  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
6618       \r
6619  // d) Book profiles;\r
6620  // reduced correlations:\r
6621  TString diffFlowCorrelationsProName = "fDiffFlowCorrelationsPro";\r
6622  diffFlowCorrelationsProName += fAnalysisLabel->Data();\r
6623  // corrections terms:\r
6624  TString diffFlowCorrectionTermsForNUAProName = "fDiffFlowCorrectionTermsForNUAPro";\r
6625  diffFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();\r
6626  for(Int_t t=0;t<2;t++) // type: RP or POI\r
6627  { \r
6628   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6629   {\r
6630    for(Int_t rci=0;rci<4;rci++) // reduced correlation index\r
6631    {\r
6632     // reduced correlations:\r
6633     fDiffFlowCorrelationsPro[t][pe][rci] = new TProfile(Form("%s, %s, %s, %s",diffFlowCorrelationsProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[rci].Data()),Form("%s, %s, %s, %s",diffFlowCorrelationsProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[rci].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe],"s");\r
6634     fDiffFlowCorrelationsPro[t][pe][rci]->SetXTitle(ptEtaFlag[pe].Data());\r
6635     fDiffFlowCorrelationsProList[t][pe]->Add(fDiffFlowCorrelationsPro[t][pe][rci]); // to be improved (add dedicated list to hold reduced correlations)\r
6636    } // end of for(Int_t rci=0;rci<4;rci++) // correlation index\r
6637   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
6638  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
6639  // correction terms for nua:\r
6640  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)\r
6641  { \r
6642   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6643   {\r
6644    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6645    {\r
6646     for(Int_t cti=0;cti<9;cti++) // correction term index\r
6647     {\r
6648      fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti] = new TProfile(Form("%s, %s, %s, %s, cti = %d",diffFlowCorrectionTermsForNUAProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),cti+1),Form("%s, %s, %s, %s, cti = %d",diffFlowCorrectionTermsForNUAProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),cti+1),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6649      fDiffFlowCorrectionsProList[t][pe]->Add(fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti]);\r
6650     }\r
6651    }\r
6652   }\r
6653  } \r
6654  // e) Book histograms holding final results. \r
6655  // reduced correlations:\r
6656  TString diffFlowCorrelationsHistName = "fDiffFlowCorrelationsHist";\r
6657  diffFlowCorrelationsHistName += fAnalysisLabel->Data();\r
6658  // corrections terms:\r
6659  TString diffFlowCorrectionTermsForNUAHistName = "fDiffFlowCorrectionTermsForNUAHist";\r
6660  diffFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();\r
6661  // differential covariances:\r
6662  TString diffFlowCovariancesName = "fDiffFlowCovariances";\r
6663  diffFlowCovariancesName += fAnalysisLabel->Data();\r
6664  // differential Q-cumulants:\r
6665  TString diffFlowCumulantsName = "fDiffFlowCumulants";\r
6666  diffFlowCumulantsName += fAnalysisLabel->Data();\r
6667  // differential flow:\r
6668  TString diffFlowName = "fDiffFlow";\r
6669  diffFlowName += fAnalysisLabel->Data();\r
6670  for(Int_t t=0;t<2;t++) // type: RP or POI\r
6671  { \r
6672   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6673   {\r
6674    for(Int_t index=0;index<4;index++) \r
6675    {\r
6676     // reduced correlations:\r
6677     fDiffFlowCorrelationsHist[t][pe][index] = new TH1D(Form("%s, %s, %s, %s",diffFlowCorrelationsHistName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[index].Data()),Form("%s, %s, %s, %s",diffFlowCorrelationsHistName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[index].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]);\r
6678     fDiffFlowCorrelationsHist[t][pe][index]->SetXTitle(ptEtaFlag[pe].Data());\r
6679     fDiffFlowCorrelationsHistList[t][pe]->Add(fDiffFlowCorrelationsHist[t][pe][index]); \r
6680     // differential Q-cumulants:\r
6681     fDiffFlowCumulants[t][pe][index] = new TH1D(Form("%s, %s, %s, %s",diffFlowCumulantsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),differentialCumulantIndex[index].Data()),Form("%s, %s, %s, %s",diffFlowCumulantsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),differentialCumulantIndex[index].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]);\r
6682     fDiffFlowCumulants[t][pe][index]->SetXTitle(ptEtaFlag[pe].Data());\r
6683     fDiffFlowCumulantsHistList[t][pe]->Add(fDiffFlowCumulants[t][pe][index]); \r
6684     // differential flow estimates from Q-cumulants:\r
6685     fDiffFlow[t][pe][index] = new TH1D(Form("%s, %s, %s, %s",diffFlowName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),differentialFlowIndex[index].Data()),Form("%s, %s, %s, %s",diffFlowName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),differentialFlowIndex[index].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]);\r
6686     fDiffFlow[t][pe][index]->SetXTitle(ptEtaFlag[pe].Data());\r
6687     fDiffFlowHistList[t][pe]->Add(fDiffFlow[t][pe][index]); \r
6688    } // end of for(Int_t index=0;index<4;index++) \r
6689    for(Int_t covIndex=0;covIndex<5;covIndex++) // covariance index \r
6690    {\r
6691     // differential covariances:\r
6692     fDiffFlowCovariances[t][pe][covIndex] = new TH1D(Form("%s, %s, %s, %s",diffFlowCovariancesName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),covarianceName[covIndex].Data()),Form("%s, %s, %s, %s",diffFlowCovariancesName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),covarianceName[covIndex].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]);\r
6693     fDiffFlowCovariances[t][pe][covIndex]->SetXTitle(ptEtaFlag[pe].Data());\r
6694     fDiffFlowCovariancesHistList[t][pe]->Add(fDiffFlowCovariances[t][pe][covIndex]); \r
6695    } // end of for(Int_t covIndex=0;covIndex<5;covIndex++) // covariance index\r
6696    // products of both types of correlations: \r
6697    TString diffFlowProductOfCorrelationsProName = "fDiffFlowProductOfCorrelationsPro";\r
6698    diffFlowProductOfCorrelationsProName += fAnalysisLabel->Data();  \r
6699    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
6700    {\r
6701     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6702     {\r
6703      fDiffFlowProductOfCorrelationsPro[t][pe][mci1][mci2] = new TProfile(Form("%s, %s, %s, %s, %s",diffFlowProductOfCorrelationsProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),mixedCorrelationIndex[mci1].Data(),mixedCorrelationIndex[mci2].Data()),Form("%s, %s, %s, %s #times %s",diffFlowProductOfCorrelationsProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),mixedCorrelationIndex[mci1].Data(),mixedCorrelationIndex[mci2].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6704      fDiffFlowProductOfCorrelationsPro[t][pe][mci1][mci2]->SetXTitle(ptEtaFlag[pe].Data());\r
6705      fDiffFlowProductOfCorrelationsProList[t][pe]->Add(fDiffFlowProductOfCorrelationsPro[t][pe][mci1][mci2]); \r
6706      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here\r
6707     } // end of for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6708    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index    \r
6709   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
6710  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
6711  // sums of event weights for reduced correlations: \r
6712  TString diffFlowSumOfEventWeightsName = "fDiffFlowSumOfEventWeights";\r
6713  diffFlowSumOfEventWeightsName += fAnalysisLabel->Data();  \r
6714  for(Int_t t=0;t<2;t++) // type is RP or POI\r
6715  { \r
6716   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6717   { \r
6718    for(Int_t p=0;p<2;p++) // power of weights is either 1 or 2\r
6719    {\r
6720     for(Int_t ew=0;ew<4;ew++) // index of reduced correlation\r
6721     {\r
6722      fDiffFlowSumOfEventWeights[t][pe][p][ew] = new TH1D(Form("%s, %s, %s, %s, %s",diffFlowSumOfEventWeightsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),powerFlag[p].Data(),reducedCorrelationIndex[ew].Data()),Form("%s, %s, %s, power = %s, %s",diffFlowSumOfEventWeightsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),powerFlag[p].Data(),reducedCorrelationIndex[ew].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6723      fDiffFlowSumOfEventWeights[t][pe][p][ew]->SetXTitle(ptEtaFlag[pe].Data());\r
6724      fDiffFlowSumOfEventWeightsHistList[t][pe][p]->Add(fDiffFlowSumOfEventWeights[t][pe][p][ew]); // to be improved (add dedicated list to hold all this)\r
6725     }\r
6726    }\r
6727   }\r
6728  } \r
6729  // sum of products of event weights for both types of correlations: \r
6730  TString diffFlowSumOfProductOfEventWeightsName = "fDiffFlowSumOfProductOfEventWeights";\r
6731  diffFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();  \r
6732  for(Int_t t=0;t<2;t++) // type is RP or POI\r
6733  {\r
6734   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6735   { \r
6736    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
6737    {\r
6738     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6739     {\r
6740      fDiffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2] = new TH1D(Form("%s, %s, %s, %s, %s",diffFlowSumOfProductOfEventWeightsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),mixedCorrelationIndex[mci1].Data(),mixedCorrelationIndex[mci2].Data()),Form("%s, %s, %s, %s #times %s",diffFlowSumOfProductOfEventWeightsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),mixedCorrelationIndex[mci1].Data(),mixedCorrelationIndex[mci2].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6741      fDiffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2]->SetXTitle(ptEtaFlag[pe].Data());\r
6742      fDiffFlowSumOfProductOfEventWeightsHistList[t][pe]->Add(fDiffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2]); \r
6743      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here\r
6744     }\r
6745    }\r
6746   }\r
6747  } \r
6748  // correction terms for nua:\r
6749  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)\r
6750  { \r
6751   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6752   {\r
6753    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6754    {\r
6755     for(Int_t cti=0;cti<9;cti++) // correction term index\r
6756     {\r
6757      fDiffFlowCorrectionTermsForNUAHist[t][pe][sc][cti] = new TH1D(Form("%s, %s, %s, %s, cti = %d",diffFlowCorrectionTermsForNUAHistName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),cti+1),Form("%s, %s, %s, %s, cti = %d",diffFlowCorrectionTermsForNUAHistName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),cti+1),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6758      fDiffFlowCorrectionsHistList[t][pe]->Add(fDiffFlowCorrectionTermsForNUAHist[t][pe][sc][cti]);\r
6759     }\r
6760    }\r
6761   }\r
6762  } \r
6763           \r
6764 } // end of AliFlowAnalysisWithQCumulants::BookEverythingForDifferentialFlow()\r
6765 \r
6766 \r
6767 //================================================================================================================================\r
6768 \r
6769 /*\r
6770 void AliFlowAnalysisWithQCumulants::CalculateCorrectionsForNUAForIntQcumulants() // to be improved (do I really need this method?)\r
6771 {\r
6772  // Calculate final corrections for non-uniform acceptance for Q-cumulants.\r
6773   \r
6774  // Corrections for non-uniform acceptance are stored in histogram fCorrectionsForNUA,\r
6775  // binning of fCorrectionsForNUA is organized as follows:\r
6776  //\r
6777  // 1st bin: correction to QC{2}\r
6778  // 2nd bin: correction to QC{4}\r
6779  // 3rd bin: correction to QC{6}\r
6780  // 4th bin: correction to QC{8}\r
6781   \r
6782  // shortcuts flags:\r
6783  Int_t pW = (Int_t)(useParticleWeights);\r
6784  \r
6785  Int_t eW = -1;\r
6786  \r
6787  if(eventWeights == "exact")\r
6788  {\r
6789   eW = 0;\r
6790  }\r
6791 \r
6792  for(Int_t sc=0;sc<2;sc++) // sin or cos terms flag\r
6793  {\r
6794   if(!(fQCorrelations[pW][eW] && fQCorrections[pW][eW][sc] && fCorrections[pW][eW]))\r
6795   {\r
6796    cout<<"WARNING: fQCorrelations[pW][eW] && fQCorrections[pW][eW][sc] && fCorrections[pW][eW] is NULL in AFAWQC::CFCFNUAFIF() !!!!"<<endl;\r
6797    cout<<"pW = "<<pW<<endl;\r
6798    cout<<"eW = "<<eW<<endl;\r
6799    cout<<"sc = "<<sc<<endl;\r
6800    exit(0);\r
6801   }\r
6802  }  \r
6803 \r
6804  // measured 2-, 4-, 6- and 8-particle azimuthal correlations (biased with non-uniform acceptance!):\r
6805  Double_t two = fQCorrelations[pW][eW]->GetBinContent(1); // <<2>>\r
6806  //Double_t four = fQCorrelations[pW][eW]->GetBinContent(11); // <<4>>\r
6807  //Double_t six = fQCorrelations[pW][eW]->GetBinContent(24); // <<6>>\r
6808  //Double_t eight = fQCorrelations[pW][eW]->GetBinContent(31); // <<8>>\r
6809  \r
6810  // correction terms to QC{2}:\r
6811  // <<cos(n*phi1)>>^2\r
6812  Double_t two1stTerm = pow(fQCorrections[pW][eW][1]->GetBinContent(1),2); \r
6813  // <<sin(n*phi1)>>^2\r
6814  Double_t two2ndTerm = pow(fQCorrections[pW][eW][0]->GetBinContent(1),2); \r
6815  // final corrections for non-uniform acceptance to QC{2}:\r
6816  Double_t correctionQC2 = -1.*two1stTerm-1.*two2ndTerm;\r
6817  fCorrections[pW][eW]->SetBinContent(1,correctionQC2); \r
6818  \r
6819  // correction terms to QC{4}:\r
6820  // <<cos(n*phi1)>> <<cos(n*(phi1-phi2-phi3))>>\r
6821  Double_t four1stTerm = fQCorrections[pW][eW][1]->GetBinContent(1)*fQCorrections[pW][eW][1]->GetBinContent(3);  \r
6822  // <<sin(n*phi1)>> <<sin(n*(phi1-phi2-phi3))>>\r
6823  Double_t four2ndTerm = fQCorrections[pW][eW][0]->GetBinContent(1)*fQCorrections[pW][eW][0]->GetBinContent(3);  \r
6824  // <<cos(n*(phi1+phi2))>>^2\r
6825  Double_t four3rdTerm = pow(fQCorrections[pW][eW][1]->GetBinContent(2),2); \r
6826  // <<sin(n*(phi1+phi2))>>^2\r
6827  Double_t four4thTerm = pow(fQCorrections[pW][eW][0]->GetBinContent(2),2); \r
6828  // <<cos(n*(phi1+phi2))>> (<<cos(n*phi1)>>^2 - <<sin(n*phi1)>>^2)\r
6829  Double_t four5thTerm = fQCorrections[pW][eW][1]->GetBinContent(2)\r
6830                       * (pow(fQCorrections[pW][eW][1]->GetBinContent(1),2)-pow(fQCorrections[pW][eW][0]->GetBinContent(1),2));\r
6831  // <<sin(n*(phi1+phi2))>> <<cos(n*phi1)>> <<sin(n*phi1)>>\r
6832  Double_t four6thTerm = fQCorrections[pW][eW][0]->GetBinContent(2)\r
6833                       * fQCorrections[pW][eW][1]->GetBinContent(1)\r
6834                       * fQCorrections[pW][eW][0]->GetBinContent(1);         \r
6835  // <<cos(n*(phi1-phi2))>> (<<cos(n*phi1)>>^2 + <<sin(n*phi1)>>^2)\r
6836  Double_t four7thTerm = two*(pow(fQCorrections[pW][eW][1]->GetBinContent(1),2)+pow(fQCorrections[pW][eW][0]->GetBinContent(1),2));  \r
6837  // (<<cos(n*phi1)>>^2 + <<sin(n*phi1)>>^2)^2\r
6838  Double_t four8thTerm = pow(pow(fQCorrections[pW][eW][1]->GetBinContent(1),2)+pow(fQCorrections[pW][eW][0]->GetBinContent(1),2),2);      \r
6839  // final correction to QC{4}:\r
6840  Double_t correctionQC4 = -4.*four1stTerm+4.*four2ndTerm-four3rdTerm-four4thTerm\r
6841                         + 4.*four5thTerm+8.*four6thTerm+8.*four7thTerm-6.*four8thTerm;                            \r
6842  fCorrections[pW][eW]->SetBinContent(2,correctionQC4);   \r
6843 \r
6844  // ... to be improved (continued for 6th and 8th order)                                                    \r
6845 \r
6846 \r
6847 } // end of AliFlowAnalysisWithQCumulants::CalculateCorrectionsForNUAForIntQcumulants()\r
6848 */\r
6849 \r
6850 //================================================================================================================================\r
6851 \r
6852 \r
6853 void AliFlowAnalysisWithQCumulants::CalculateQcumulantsCorrectedForNUAIntFlow()\r
6854 {\r
6855  // Calculate generalized Q-cumulants (cumulants corrected for non-unifom acceptance).\r
6856  \r
6857  // measured 2-, 4-, 6- and 8-particle correlations (biased by non-uniform acceptance!):\r
6858  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>\r
6859  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>\r
6860  //Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>>\r
6861  //Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>\r
6862  \r
6863  // statistical error of measured 2-, 4-, 6- and 8-particle correlations:\r
6864  //Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1); // statistical error of <<2>>\r
6865  //Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2); // statistical error of <<4>>\r
6866  //Double_t sixError = fIntFlowCorrelationsHist->GetBinError(3); // statistical error of <<6>>\r
6867  //Double_t eightError = fIntFlowCorrelationsHist->GetBinError(4); // statistical error of <<8>>\r
6868 \r
6869  // QC{2}:\r
6870  // <<cos(n*phi1)>>^2\r
6871  Double_t two1stTerm = pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1),2); \r
6872  //Double_t two1stTermErrorSquared = pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinError(1),2); \r
6873  // <<sin(n*phi1)>>^2\r
6874  Double_t two2ndTerm = pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1),2); \r
6875  //Double_t two2ndTermErrorSquared = pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinError(1),2); \r
6876  // generalized QC{2}:\r
6877  Double_t gQC2 = two - two1stTerm - two2ndTerm; // to be improved (terminology, notation)\r
6878  fIntFlowQcumulants->SetBinContent(1,gQC2); \r
6879  //fIntFlowQcumulants->SetBinError(1,0.); // to be improved (propagate error) \r
6880  \r
6881  // QC{4}:\r
6882  // <<cos(n*phi1)>> <<cos(n*(phi1-phi2-phi3))>>\r
6883  Double_t four1stTerm = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1)\r
6884                       * fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(3);  \r
6885  // <<sin(n*phi1)>> <<sin(n*(phi1-phi2-phi3))>>\r
6886  Double_t four2ndTerm = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1)\r
6887                       * fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(3);  \r
6888  // <<cos(n*(phi1+phi2))>>^2\r
6889  Double_t four3rdTerm = pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(2),2); \r
6890  // <<sin(n*(phi1+phi2))>>^2\r
6891  Double_t four4thTerm = pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(2),2); \r
6892  // <<cos(n*(phi1+phi2))>> (<<cos(n*phi1)>>^2 - <<sin(n*phi1)>>^2)\r
6893  Double_t four5thTerm = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(2)\r
6894                       * (pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1),2)\r
6895                       - pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1),2));\r
6896  // <<sin(n*(phi1+phi2))>> <<cos(n*phi1)>> <<sin(n*phi1)>>\r
6897  Double_t four6thTerm = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(2)\r
6898                       * fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1)\r
6899                       * fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1);         \r
6900  // <<cos(n*(phi1-phi2))>> (<<cos(n*phi1)>>^2 + <<sin(n*phi1)>>^2)\r
6901  Double_t four7thTerm = two*(pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1),2)\r
6902                       + pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1),2));  \r
6903  // (<<cos(n*phi1)>>^2 + <<sin(n*phi1)>>^2)^2\r
6904  Double_t four8thTerm = pow(pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1),2)\r
6905                       + pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1),2),2);      \r
6906  // generalized QC{4}:\r
6907  Double_t gQC4 = four-2.*pow(two,2.)-4.*four1stTerm+4.*four2ndTerm-four3rdTerm\r
6908                - four4thTerm+4.*four5thTerm+8.*four6thTerm+8.*four7thTerm-6.*four8thTerm;                            \r
6909  fIntFlowQcumulants->SetBinContent(2,gQC4);   \r
6910  //fIntFlowQcumulants->SetBinError(2,0.); // to be improved (propagate error) \r
6911 \r
6912  // ... to be improved (continued for 6th and 8th order)                                                    \r
6913     \r
6914 } // end of void AliFlowAnalysisWithQCumulants::CalculateQcumulantsCorrectedForNUAIntFlow()\r
6915 \r
6916 \r
6917 //================================================================================================================================\r
6918 \r
6919 \r
6920 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectedForNUA()\r
6921 {\r
6922  // Calculate integrated flow from generalized Q-cumulants (corrected for non-uniform acceptance).\r
6923  \r
6924  // to be improved: add protection for NULL pointers, propagate statistical errors from \r
6925  // measured correlations and correction terms\r
6926  \r
6927  // generalized Q-cumulants:\r
6928  Double_t qc2 = fIntFlowQcumulants->GetBinContent(1); // QC{2}  \r
6929  Double_t qc4 = fIntFlowQcumulants->GetBinContent(2); // QC{4}  \r
6930  //Double_t qc6 = fIntFlowQcumulants->GetBinContent(3); // QC{6}  \r
6931  //Double_t qc8 = fIntFlowQcumulants->GetBinContent(4); // QC{8}\r
6932  \r
6933  // integrated flow estimates:\r
6934  Double_t v2 = 0.; // v{2,QC}  \r
6935  Double_t v4 = 0.; // v{4,QC}  \r
6936  //Double_t v6 = 0.; // v{6,QC}  \r
6937  //Double_t v8 = 0.; // v{8,QC}\r
6938 \r
6939  // calculate integrated flow estimates from generalized Q-cumulants: \r
6940  if(qc2>=0.) v2 = pow(qc2,1./2.); \r
6941  if(qc4<=0.) v4 = pow(-1.*qc4,1./4.); \r
6942  //if(qc6>=0.) v6 = pow((1./4.)*qc6,1./6.); \r
6943  //if(qc8<=0.) v8 = pow((-1./33.)*qc8,1./8.); \r
6944 \r
6945  // store integrated flow estimates from generalized Q-cumulants:\r
6946  fIntFlow->SetBinContent(1,v2);\r
6947  fIntFlow->SetBinContent(2,v4);\r
6948  //fIntFlow->SetBinContent(3,v6);\r
6949  //fIntFlow->SetBinContent(4,v8);\r
6950 \r
6951 } // end of void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectedForNUA()\r
6952 \r
6953    \r
6954 //================================================================================================================================\r
6955 \r
6956 \r
6957 void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUAIntFlow() \r
6958 {\r
6959  // From profile fIntFlowCorrectionTermsForNUAPro[2] access measured corretion terms\r
6960  // and their spread, correctly calculate the statistical errors and store the final \r
6961  // results and statistical errors for correction terms in histogram fIntFlowCorrectionTermsForNUAHist[2].\r
6962  //\r
6963  // Remark: Statistical error of correction temrs is calculated as:\r
6964  //\r
6965  //          statistical error = termA * spread * termB:\r
6966  //          termA = sqrt{sum_{i=1}^{N} w^2}/(sum_{i=1}^{N} w)\r
6967  //          termB = 1/sqrt(1-termA^2)   \r
6968  \r
6969  /* // to be improved (implement protection here)\r
6970  for(Int_t power=0;power<2;power++)\r
6971  { \r
6972   if(!(fIntFlowCorrelationsHist && fIntFlowCorrelationsPro && fIntFlowSumOfEventWeights[power])) \r
6973   {\r
6974    cout<<"WARNING: fIntFlowCorrelationsHist && fIntFlowCorrelationsPro && fIntFlowSumOfEventWeights[power] is NULL in AFAWQC::FCIF() !!!!"<<endl;\r
6975    cout<<"power = "<<power<<endl;\r
6976    exit(0);\r
6977   }\r
6978  }\r
6979  */\r
6980   \r
6981  for(Int_t sc=0;sc<2;sc++) // sin or cos correction terms \r
6982  {\r
6983   for(Int_t ci=1;ci<=10;ci++) // correction term index\r
6984   {\r
6985    Double_t correction = fIntFlowCorrectionTermsForNUAPro[sc]->GetBinContent(ci);\r
6986    //Double_t spread = fIntFlowCorrectionTermsForNUAPro[sc]->GetBinError(ci);\r
6987    //Double_t sumOfLinearEventWeights = fIntFlowSumOfEventWeights[0]->GetBinContent(ci);\r
6988    //Double_t sumOfQuadraticEventWeights = fIntFlowSumOfEventWeights[1]->GetBinContent(ci);\r
6989    //Double_t termA = 0.;\r
6990    //Double_t termB = 0.;\r
6991    //if(sumOfLinearEventWeights)\r
6992    //{\r
6993    // termA = pow(sumOfQuadraticEventWeights,0.5)/sumOfLinearEventWeights;\r
6994    //} else\r
6995    // {\r
6996    //  cout<<"WARNING: sumOfLinearEventWeights == 0 in AFAWQC::FCIF() !!!!"<<endl;\r
6997    //  cout<<"         (for "<<2*ci<<"-particle correlation)"<<endl;\r
6998    // }\r
6999    /*\r
7000    if(1.-pow(termA,2.) > 0.)\r
7001    {\r
7002     termB = 1./pow(1-pow(termA,2.),0.5);\r
7003    } else\r
7004      {\r
7005       cout<<"WARNING: 1.-pow(termA,2.) <= 0 in AFAWQC::FCIF() !!!!"<<endl;   \r
7006       cout<<"         (for "<<2*ci<<"-particle correlation)"<<endl;\r
7007      }     \r
7008    Double_t statisticalError = termA * spread * termB;\r
7009    */\r
7010    fIntFlowCorrectionTermsForNUAHist[sc]->SetBinContent(ci,correction);\r
7011    //fIntFlowCorrectionTermsForNUAHist[sc]->SetBinError(ci,statisticalError);\r
7012   } // end of for(Int_t ci=1;ci<=10;ci++) // correction term index\r
7013  } // end of for(Int sc=0;sc<2;sc++) // sin or cos correction terms \r
7014                                                                                                                                                                                                \r
7015 } // end of void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUAIntFlow()\r
7016 \r
7017 \r
7018 //================================================================================================================================\r
7019 \r
7020 \r
7021 void AliFlowAnalysisWithQCumulants::GetPointersForNestedLoopsHistograms(TList *outputListHistos)\r
7022 {\r
7023  // Get pointers to all objects relevant for calculations with nested loops.\r
7024    \r
7025  if(outputListHistos)\r
7026  {\r
7027   TList *nestedLoopsList = dynamic_cast<TList*>(outputListHistos->FindObject("Nested Loops"));\r
7028   if(nestedLoopsList) \r
7029   {\r
7030    this->SetNestedLoopsList(nestedLoopsList);\r
7031   } else\r
7032     {\r
7033      cout<<"WARNING: nestedLoopsList is NULL in AFAWQC::GPFNLH() !!!!"<<endl;\r
7034      exit(0);\r
7035     }
7036     
7037   TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data members?)
7038   TString typeFlag[2] = {"RP","POI"}; // to be improved (should I promote this to data members?)\r
7039   TString ptEtaFlag[2] = {"p_{T}","#eta"}; // to be improved (should I promote this to data members?)\r
7040   TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"}; // to be improved (should I promote this to data members?)
7041    \r
7042   TString evaluateNestedLoopsName = "fEvaluateNestedLoops";\r
7043   evaluateNestedLoopsName += fAnalysisLabel->Data();  \r
7044   TProfile *evaluateNestedLoops = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(evaluateNestedLoopsName.Data()));\r
7045   Bool_t bEvaluateIntFlowNestedLoops = kFALSE;\r
7046   Bool_t bEvaluateDiffFlowNestedLoops = kFALSE;\r
7047   if(evaluateNestedLoops)\r
7048   {\r
7049    this->SetEvaluateNestedLoops(evaluateNestedLoops);\r
7050    bEvaluateIntFlowNestedLoops = (Int_t)evaluateNestedLoops->GetBinContent(1);\r
7051    bEvaluateDiffFlowNestedLoops = (Int_t)evaluateNestedLoops->GetBinContent(2);\r
7052   }\r
7053   // nested loops relevant for integrated flow:  \r
7054   if(bEvaluateIntFlowNestedLoops)\r
7055   {\r
7056    // correlations:
7057    TString intFlowDirectCorrelationsName = "fIntFlowDirectCorrelations";\r
7058    intFlowDirectCorrelationsName += fAnalysisLabel->Data();
7059    TProfile *intFlowDirectCorrelations = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(intFlowDirectCorrelationsName.Data()));\r
7060    if(intFlowDirectCorrelations) 
7061    { 
7062     this->SetIntFlowDirectCorrelations(intFlowDirectCorrelations);\r
7063    } else
7064      {
7065       cout<<"WARNING: intFlowDirectCorrelations is NULL in AFAWQC::GPFNLH() !!!!"<<endl;\r
7066       exit(0);\r
7067      }
7068    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)  
7069    {
7070     TString intFlowExtraDirectCorrelationsName = "fIntFlowExtraDirectCorrelations";\r
7071     intFlowExtraDirectCorrelationsName += fAnalysisLabel->Data();
7072     TProfile *intFlowExtraDirectCorrelations = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(intFlowExtraDirectCorrelationsName.Data()));\r
7073     if(intFlowExtraDirectCorrelations) 
7074     { 
7075      this->SetIntFlowExtraDirectCorrelations(intFlowExtraDirectCorrelations);\r
7076     } else
7077       {
7078        cout<<"WARNING: intFlowExtraDirectCorrelations is NULL in AFAWQC::GPFNLH() !!!!"<<endl;\r
7079        exit(0);\r
7080       }       
7081    } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)  
7082    // correction terms for non-uniform acceptance:\r
7083    TString intFlowDirectCorrectionTermsForNUAName = "fIntFlowDirectCorrectionTermsForNUA";\r
7084    intFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();
7085    TProfile *intFlowDirectCorrectionTermsForNUA[2] = {NULL};\r
7086    for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
7087    {\r
7088     intFlowDirectCorrectionTermsForNUA[sc] = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(Form("%s: %s terms",intFlowDirectCorrectionTermsForNUAName.Data(),sinCosFlag[sc].Data())));\r
7089     if(intFlowDirectCorrectionTermsForNUA[sc]) 
7090     { 
7091      this->SetIntFlowDirectCorrectionTermsForNUA(intFlowDirectCorrectionTermsForNUA[sc],sc);\r
7092     } else
7093       {
7094        cout<<"WARNING: intFlowDirectCorrectionTermsForNUA[sc] is NULL in AFAWQC::GPFNLH() !!!!"<<endl;
7095        cout<<"sc = "<<sc<<endl;\r
7096        exit(0);\r
7097       }
7098    } // end of for(Int_t sc=0;sc<2;sc++) \r
7099   } // end of if(bEvaluateIntFlowNestedLoops)\r
7100     
7101   // nested loops relevant for differential flow:  \r
7102   if(bEvaluateDiffFlowNestedLoops)\r
7103   {
7104    // correlations:
7105    TString diffFlowDirectCorrelationsName = "fDiffFlowDirectCorrelations";\r
7106    diffFlowDirectCorrelationsName += fAnalysisLabel->Data();\r
7107    TProfile *diffFlowDirectCorrelations[2][2][4] = {{{NULL}}};
7108    for(Int_t t=0;t<2;t++)\r
7109    {\r
7110     for(Int_t pe=0;pe<2;pe++)\r
7111     {\r
7112      for(Int_t ci=0;ci<4;ci++) // correlation index\r
7113      {\r
7114       diffFlowDirectCorrelations[t][pe][ci] = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(Form("%s, %s, %s, %s",diffFlowDirectCorrelationsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedCorrelationIndex[ci].Data())));\r
7115       if(diffFlowDirectCorrelations[t][pe][ci])\r
7116       {\r
7117        this->SetDiffFlowDirectCorrelations(diffFlowDirectCorrelations[t][pe][ci],t,pe,ci);\r
7118       } else\r
7119         {\r
7120          cout<<"WARNING: diffFlowDirectCorrelations[t][pe][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
7121          cout<<"t  = "<<t<<endl;\r
7122          cout<<"pe = "<<pe<<endl;   \r
7123          cout<<"ci = "<<ci<<endl;\r
7124         }     \r
7125      } // end of for(Int_t ci=0;ci<4;ci++) // correlation index  \r
7126     } // end of for(Int_t pe=0;pe<2;pe++)\r
7127    } // end of for(Int_t t=0;t<2;t++)   
7128    // correction terms for non-uniform acceptance:\r
7129    TString diffFlowDirectCorrectionTermsForNUAName = "fDiffFlowDirectCorrectionTermsForNUA";\r
7130    diffFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();  \r
7131    TProfile *diffFlowDirectCorrectionTermsForNUA[2][2][2][10] = {{{{NULL}}}};   \r
7132    for(Int_t t=0;t<2;t++)\r
7133    {\r
7134     for(Int_t pe=0;pe<2;pe++)\r
7135     {\r
7136      // correction terms for NUA:\r
7137      for(Int_t sc=0;sc<2;sc++) // sin or cos\r
7138      {\r
7139       for(Int_t cti=0;cti<9;cti++) // correction term index\r
7140       {\r
7141        diffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti] = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(Form("%s, %s, %s, %s, cti = %d",diffFlowDirectCorrectionTermsForNUAName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),cti+1)));\r
7142        if(diffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti])\r
7143        {\r
7144         this->SetDiffFlowDirectCorrectionTermsForNUA(diffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti],t,pe,sc,cti);\r
7145        } else\r
7146          {\r
7147           cout<<"WARNING: diffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
7148           cout<<"t   = "<<t<<endl;\r
7149           cout<<"pe  = "<<pe<<endl;   \r
7150           cout<<"sc  = "<<sc<<endl;\r
7151           cout<<"cti = "<<cti<<endl;\r
7152          }    \r
7153       } // end of for(Int_t cti=0;cti<9;cti++) // correction term index\r
7154      } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos\r
7155     } // end of for(Int_t pe=0;pe<2;pe++)\r
7156    } // end of for(Int_t t=0;t<2;t++)\r
7157   } // end of if(bEvaluateDiffFlowNestedLoops)\r
7158  } else // to if(outputListHistos)\r
7159    {\r
7160     cout<<"WARNING: outputListHistos is NULL in AFAWQC::GPFNLH() !!!!"<<endl;\r
7161     exit(0);\r
7162    }\r
7163 \r
7164 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForNestedLoopsHistograms(TList *outputListHistos)\r
7165 \r
7166 \r
7167 //================================================================================================================================\r
7168 \r
7169 \r
7170 void AliFlowAnalysisWithQCumulants::StoreHarmonic()\r
7171 {\r
7172  // Store flow harmonic in common control histograms.\r
7173 \r
7174  (fCommonHists->GetHarmonic())->Fill(0.5,fHarmonic);\r
7175  (fCommonHists2nd->GetHarmonic())->Fill(0.5,fHarmonic);\r
7176  (fCommonHists4th->GetHarmonic())->Fill(0.5,fHarmonic);\r
7177  (fCommonHists6th->GetHarmonic())->Fill(0.5,fHarmonic);\r
7178  (fCommonHists8th->GetHarmonic())->Fill(0.5,fHarmonic);\r
7179 \r
7180 } // end of void AliFlowAnalysisWithQCumulants::StoreHarmonic()\r
7181 \r
7182 \r
7183 //================================================================================================================================\r
7184 \r
7185 \r
7186 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelationsUsingParticleWeights(TString type, TString ptOrEta) // type = RP or POI \r
7187 {\r
7188  // Calculate all correlations needed for differential flow using particle weights.\r
7189  \r
7190  Int_t t = -1; // type flag \r
7191  Int_t pe = -1; // ptEta flag\r
7192  \r
7193  if(type == "RP")\r
7194  {\r
7195   t = 0;\r
7196  } else if(type == "POI")\r
7197    {\r
7198     t = 1;\r
7199    }\r
7200 \r
7201  if(ptOrEta == "Pt")\r
7202  {\r
7203   pe = 0;\r
7204  } else if(ptOrEta == "Eta")\r
7205    {\r
7206     pe = 1;\r
7207    }\r
7208     \r
7209  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
7210  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
7211  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
7212  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
7213 \r
7214  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
7215  Double_t dReQ1n1k = (*fReQ)(0,1);\r
7216  Double_t dReQ2n2k = (*fReQ)(1,2);\r
7217  Double_t dReQ1n3k = (*fReQ)(0,3);\r
7218  //Double_t dReQ4n4k = (*fReQ)(3,4);\r
7219  Double_t dImQ1n1k = (*fImQ)(0,1);\r
7220  Double_t dImQ2n2k = (*fImQ)(1,2);\r
7221  Double_t dImQ1n3k = (*fImQ)(0,3);\r
7222  //Double_t dImQ4n4k = (*fImQ)(3,4);\r
7223  \r
7224  // S^M_{p,k} (see .h file for the definition of fSMpk):\r
7225  Double_t dSM1p1k = (*fSMpk)(0,1);\r
7226  Double_t dSM1p2k = (*fSMpk)(0,2);\r
7227  Double_t dSM1p3k = (*fSMpk)(0,3);\r
7228  Double_t dSM2p1k = (*fSMpk)(1,1);\r
7229  Double_t dSM3p1k = (*fSMpk)(2,1);\r
7230  \r
7231  // looping over all bins and calculating reduced correlations: \r
7232  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7233  {\r
7234   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular (pt,eta) bin):  \r
7235   Double_t p1n0kRe = 0.;\r
7236   Double_t p1n0kIm = 0.;\r
7237 \r
7238   // number of POIs in particular (pt,eta) bin):\r
7239   Double_t mp = 0.;\r
7240 \r
7241   // real and imaginary parts of q_{m*n,k}: \r
7242   // (weighted Q-vector evaluated for particles which are both RPs and POIs in particular (pt,eta) bin)\r
7243   Double_t q1n2kRe = 0.;\r
7244   Double_t q1n2kIm = 0.;\r
7245   Double_t q2n1kRe = 0.;\r
7246   Double_t q2n1kIm = 0.;\r
7247 \r
7248   // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
7249   Double_t s1p1k = 0.; \r
7250   Double_t s1p2k = 0.; \r
7251   Double_t s1p3k = 0.; \r
7252    \r
7253   // M0111 from Eq. (118) in QC2c (to be improved (notation))\r
7254   Double_t dM0111 = 0.;\r
7255  \r
7256   if(type == "POI")\r
7257   {\r
7258    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))\r
7259            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7260    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  \r
7261            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7262             \r
7263    mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)\r
7264     \r
7265    t = 1; // typeFlag = RP or POI\r
7266     \r
7267    // q_{m*n,k}: (Remark: m=1 is 0, k=0 iz zero (to be improved!)) \r
7268    q1n2kRe = fReRPQ1dEBE[2][pe][0][2]->GetBinContent(fReRPQ1dEBE[2][pe][0][2]->GetBin(b))\r
7269            * fReRPQ1dEBE[2][pe][0][2]->GetBinEntries(fReRPQ1dEBE[2][pe][0][2]->GetBin(b));\r
7270    q1n2kIm = fImRPQ1dEBE[2][pe][0][2]->GetBinContent(fImRPQ1dEBE[2][pe][0][2]->GetBin(b))\r
7271            * fImRPQ1dEBE[2][pe][0][2]->GetBinEntries(fImRPQ1dEBE[2][pe][0][2]->GetBin(b));\r
7272    q2n1kRe = fReRPQ1dEBE[2][pe][1][1]->GetBinContent(fReRPQ1dEBE[2][pe][1][1]->GetBin(b))\r
7273            * fReRPQ1dEBE[2][pe][1][1]->GetBinEntries(fReRPQ1dEBE[2][pe][1][1]->GetBin(b));\r
7274    q2n1kIm = fImRPQ1dEBE[2][pe][1][1]->GetBinContent(fImRPQ1dEBE[2][pe][1][1]->GetBin(b))\r
7275            * fImRPQ1dEBE[2][pe][1][1]->GetBinEntries(fImRPQ1dEBE[2][pe][1][1]->GetBin(b));\r
7276        \r
7277    // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
7278    s1p1k = pow(fs1dEBE[2][pe][1]->GetBinContent(b),1.); \r
7279    s1p2k = pow(fs1dEBE[2][pe][2]->GetBinContent(b),1.); \r
7280    s1p3k = pow(fs1dEBE[2][pe][3]->GetBinContent(b),1.); \r
7281      \r
7282    // M0111 from Eq. (118) in QC2c (to be improved (notation)):\r
7283    dM0111 = mp*(dSM3p1k-3.*dSM1p1k*dSM1p2k+2.*dSM1p3k)\r
7284           - 3.*(s1p1k*(dSM2p1k-dSM1p2k)\r
7285           + 2.*(s1p3k-s1p2k*dSM1p1k));\r
7286   }\r
7287    else if(type == "RP")\r
7288    {\r
7289     // q_{m*n,k}: (Remark: m=1 is 0, k=0 iz zero (to be improved!)) \r
7290     q1n2kRe = fReRPQ1dEBE[0][pe][0][2]->GetBinContent(fReRPQ1dEBE[0][pe][0][2]->GetBin(b))\r
7291             * fReRPQ1dEBE[0][pe][0][2]->GetBinEntries(fReRPQ1dEBE[0][pe][0][2]->GetBin(b));\r
7292     q1n2kIm = fImRPQ1dEBE[0][pe][0][2]->GetBinContent(fImRPQ1dEBE[0][pe][0][2]->GetBin(b))\r
7293             * fImRPQ1dEBE[0][pe][0][2]->GetBinEntries(fImRPQ1dEBE[0][pe][0][2]->GetBin(b));\r
7294     q2n1kRe = fReRPQ1dEBE[0][pe][1][1]->GetBinContent(fReRPQ1dEBE[0][pe][1][1]->GetBin(b))\r
7295             * fReRPQ1dEBE[0][pe][1][1]->GetBinEntries(fReRPQ1dEBE[0][pe][1][1]->GetBin(b));\r
7296     q2n1kIm = fImRPQ1dEBE[0][pe][1][1]->GetBinContent(fImRPQ1dEBE[0][pe][1][1]->GetBin(b))\r
7297             * fImRPQ1dEBE[0][pe][1][1]->GetBinEntries(fImRPQ1dEBE[0][pe][1][1]->GetBin(b));\r
7298 \r
7299     // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
7300     s1p1k = pow(fs1dEBE[0][pe][1]->GetBinContent(b),1.); \r
7301     s1p2k = pow(fs1dEBE[0][pe][2]->GetBinContent(b),1.); \r
7302     s1p3k = pow(fs1dEBE[0][pe][3]->GetBinContent(b),1.); \r
7303     \r
7304     // to be improved (cross-checked):\r
7305     p1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
7306             * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7307     p1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))  \r
7308             * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7309             \r
7310     mp = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)\r
7311      \r
7312     t = 0; // typeFlag = RP or POI\r
7313     \r
7314     // M0111 from Eq. (118) in QC2c (to be improved (notation)):\r
7315     dM0111 = mp*(dSM3p1k-3.*dSM1p1k*dSM1p2k+2.*dSM1p3k)\r
7316            - 3.*(s1p1k*(dSM2p1k-dSM1p2k)\r
7317            + 2.*(s1p3k-s1p2k*dSM1p1k));\r
7318     //...............................................................................................   \r
7319    }\r
7320    \r
7321    // 2'-particle correlation:\r
7322    Double_t two1n1nW0W1 = 0.;\r
7323    if(mp*dSM1p1k-s1p1k)\r
7324    {\r
7325     two1n1nW0W1 = (p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k-s1p1k)\r
7326                 / (mp*dSM1p1k-s1p1k);\r
7327    \r
7328     // fill profile to get <<2'>>     \r
7329     fDiffFlowCorrelationsPro[t][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nW0W1,mp*dSM1p1k-s1p1k);\r
7330     // histogram to store <2'> e-b-e (needed in some other methods):\r
7331     fDiffFlowCorrelationsEBE[t][pe][0]->SetBinContent(b,two1n1nW0W1);      \r
7332     fDiffFlowEventWeightsForCorrelationsEBE[t][pe][0]->SetBinContent(b,mp*dSM1p1k-s1p1k);      \r
7333    } // end of if(mp*dSM1p1k-s1p1k)\r
7334    \r
7335    // 4'-particle correlation:\r
7336    Double_t four1n1n1n1nW0W1W1W1 = 0.;\r
7337    if(dM0111)\r
7338    {\r
7339     four1n1n1n1nW0W1W1W1 = ((pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.))*(p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k)\r
7340                          - q2n1kRe*(pow(dReQ1n1k,2.)-pow(dImQ1n1k,2.))\r
7341                          - 2.*q2n1kIm*dReQ1n1k*dImQ1n1k\r
7342                          - p1n0kRe*(dReQ1n1k*dReQ2n2k+dImQ1n1k*dImQ2n2k)\r
7343                          + p1n0kIm*(dImQ1n1k*dReQ2n2k-dReQ1n1k*dImQ2n2k)\r
7344                          - 2.*dSM1p2k*(p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k)\r
7345                          - 2.*(pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.))*s1p1k                                            \r
7346                          + 6.*(q1n2kRe*dReQ1n1k+q1n2kIm*dImQ1n1k)                                           \r
7347                          + 1.*(q2n1kRe*dReQ2n2k+q2n1kIm*dImQ2n2k)                         \r
7348                          + 2.*(p1n0kRe*dReQ1n3k+p1n0kIm*dImQ1n3k)                      \r
7349                          + 2.*s1p1k*dSM1p2k                                      \r
7350                          - 6.*s1p3k)        \r
7351                          / dM0111; // to be improved (notation of dM0111)\r
7352    \r
7353     // fill profile to get <<4'>>     \r
7354     fDiffFlowCorrelationsPro[t][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nW0W1W1W1,dM0111);\r
7355     // histogram to store <4'> e-b-e (needed in some other methods):\r
7356     fDiffFlowCorrelationsEBE[t][pe][1]->SetBinContent(b,four1n1n1n1nW0W1W1W1);      \r
7357     fDiffFlowEventWeightsForCorrelationsEBE[t][pe][1]->SetBinContent(b,dM0111);      \r
7358    } // end of if(dM0111)\r
7359  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7360 \r
7361 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelationsUsingParticleWeights(TString type, TString ptOrEta); // type = RP or POI \r
7362 \r
7363 \r
7364 //================================================================================================================================\r
7365 \r
7366 \r
7367 void AliFlowAnalysisWithQCumulants::FillCommonControlHistograms(AliFlowEventSimple *anEvent)\r
7368 {\r
7369  // Fill common control histograms.\r
7370  \r
7371  Int_t nRP = anEvent->GetEventNSelTracksRP(); // number of RPs (i.e. number of particles used to determine the reaction plane)\r
7372  fCommonHists->FillControlHistograms(anEvent); \r
7373  if(nRP>1)\r
7374  {\r
7375   fCommonHists2nd->FillControlHistograms(anEvent);                                        \r
7376   if(nRP>3)\r
7377   {\r
7378    fCommonHists4th->FillControlHistograms(anEvent);                                        \r
7379    if(nRP>5)\r
7380    {\r
7381     fCommonHists6th->FillControlHistograms(anEvent);                                        \r
7382     if(nRP>7)\r
7383     {\r
7384      fCommonHists8th->FillControlHistograms(anEvent);                                        \r
7385     } // end of if(nRP>7)  \r
7386    } // end of if(nRP>5) \r
7387   } // end of if(nRP>3)                                                                                                                      \r
7388  } // end of if(nRP>1) \r
7389  \r
7390 } // end of void AliFlowAnalysisWithQCumulants::FillCommonControlHistograms(AliFlowEventSimple *anEvent)\r
7391 \r
7392 \r
7393 //================================================================================================================================\r
7394 \r
7395 \r
7396 void AliFlowAnalysisWithQCumulants::ResetEventByEventQuantities()\r
7397 {\r
7398  // Reset all event by event quantities.\r
7399  \r
7400  // integrated flow:\r
7401  fReQ->Zero();\r
7402  fImQ->Zero();\r
7403  fSMpk->Zero();\r
7404  fIntFlowCorrelationsEBE->Reset();\r
7405  fIntFlowEventWeightsForCorrelationsEBE->Reset();\r
7406  fIntFlowCorrelationsAllEBE->Reset();\r
7407  \r
7408  if(fApplyCorrectionForNUA)  \r
7409  {\r
7410   for(Int_t sc=0;sc<2;sc++)\r
7411   {\r
7412    fIntFlowCorrectionTermsForNUAEBE[sc]->Reset();\r
7413   } \r
7414  }\r
7415     \r
7416  // differential flow:\r
7417  // 1D:\r
7418  for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)\r
7419  {\r
7420   for(Int_t pe=0;pe<2;pe++) // 1D in pt or eta\r
7421   {\r
7422    for(Int_t m=0;m<4;m++) // multiple of harmonic\r
7423    {\r
7424     for(Int_t k=0;k<9;k++) // power of weight\r
7425     {\r
7426      if(fReRPQ1dEBE[t][pe][m][k]) fReRPQ1dEBE[t][pe][m][k]->Reset();\r
7427      if(fImRPQ1dEBE[t][pe][m][k]) fImRPQ1dEBE[t][pe][m][k]->Reset();\r
7428     }   \r
7429    }\r
7430   }\r
7431  }\r
7432   \r
7433  for(Int_t t=0;t<3;t++) // type (0 = RP, 1 = POI, 2 = RP&&POI )\r
7434  { \r
7435   for(Int_t pe=0;pe<2;pe++) // 1D in pt or eta\r
7436   {\r
7437    for(Int_t k=0;k<9;k++)\r
7438    {\r
7439     if(fs1dEBE[t][pe][k]) fs1dEBE[t][pe][k]->Reset();\r
7440    }\r
7441   }\r
7442  }\r
7443 \r
7444  // e-b-e reduced correlations:\r
7445  for(Int_t t=0;t<2;t++) // type (0 = RP, 1 = POI)\r
7446  {  \r
7447   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
7448   {\r
7449    for(Int_t rci=0;rci<4;rci++) // reduced correlation index\r
7450    {\r
7451     if(fDiffFlowCorrelationsEBE[t][pe][rci]) fDiffFlowCorrelationsEBE[t][pe][rci]->Reset();\r
7452     if(fDiffFlowEventWeightsForCorrelationsEBE[t][pe][rci]) fDiffFlowEventWeightsForCorrelationsEBE[t][pe][rci]->Reset();\r
7453    }\r
7454   }\r
7455  }\r
7456     \r
7457  // correction terms for NUA:\r
7458  for(Int_t t=0;t<2;t++) // type (0 = RP, 1 = POI)\r
7459  {  \r
7460   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
7461   {\r
7462    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
7463    {\r
7464     for(Int_t cti=0;cti<9;cti++) // correction term index\r
7465     {\r
7466      fDiffFlowCorrectionTermsForNUAEBE[t][pe][sc][cti]->Reset();  \r
7467     }\r
7468    }\r
7469   }      \r
7470  }\r
7471     \r
7472  // 2D (pt,eta)\r
7473  if(fCalculate2DFlow)\r
7474  {\r
7475   for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)\r
7476   {\r
7477    for(Int_t m=0;m<4;m++) // multiple of harmonic\r
7478    {\r
7479     for(Int_t k=0;k<9;k++) // power of weight\r
7480     {\r
7481      if(fReRPQ2dEBE[t][m][k]) fReRPQ2dEBE[t][m][k]->Reset();\r
7482      if(fImRPQ2dEBE[t][m][k]) fImRPQ2dEBE[t][m][k]->Reset();\r
7483     }   \r
7484    }\r
7485   }\r
7486   for(Int_t t=0;t<3;t++) // type (0 = RP, 1 = POI, 2 = RP&&POI )\r
7487   { \r
7488    for(Int_t k=0;k<9;k++)\r
7489    {\r
7490     if(fs2dEBE[t][k]) fs2dEBE[t][k]->Reset();\r
7491    }\r
7492   }  \r
7493  } // end of if(fCalculate2DFlow) \r
7494 \r
7495 } // end of void AliFlowAnalysisWithQCumulants::ResetEventByEventQuantities();\r
7496 \r
7497 \r
7498 //================================================================================================================================\r
7499 \r
7500 \r
7501 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUASinTerms(TString type, TString ptOrEta)\r
7502 {\r
7503  // Calculate correction terms for non-uniform acceptance for differential flow (sin terms).\r
7504  \r
7505  // Results are stored in fDiffFlowCorrectionTermsForNUAPro[t][pe][0][cti], where cti runs as follows:\r
7506  //  0: <<sin n(psi1)>>\r
7507  //  1: <<sin n(psi1+phi2)>>\r
7508  //  2: <<sin n(psi1+phi2-phi3)>>\r
7509  //  3: <<sin n(psi1-phi2-phi3)>>:\r
7510  //  4:\r
7511  //  5:\r
7512  //  6:\r
7513  \r
7514  // multiplicity:\r
7515  Double_t dMult = (*fSMpk)(0,0);\r
7516  \r
7517  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
7518  Double_t dReQ1n = (*fReQ)(0,0);\r
7519  Double_t dReQ2n = (*fReQ)(1,0);\r
7520  //Double_t dReQ3n = (*fReQ)(2,0);\r
7521  //Double_t dReQ4n = (*fReQ)(3,0);\r
7522  Double_t dImQ1n = (*fImQ)(0,0);\r
7523  Double_t dImQ2n = (*fImQ)(1,0);\r
7524  //Double_t dImQ3n = (*fImQ)(2,0);\r
7525  //Double_t dImQ4n = (*fImQ)(3,0);\r
7526 \r
7527  Int_t t = -1; // type flag \r
7528  Int_t pe = -1; // ptEta flag\r
7529  \r
7530  if(type == "RP")\r
7531  {\r
7532   t = 0;\r
7533  } else if(type == "POI")\r
7534    {\r
7535     t = 1;\r
7536    }\r
7537 \r
7538  if(ptOrEta == "Pt")\r
7539  {\r
7540   pe = 0;\r
7541  } else if(ptOrEta == "Eta")\r
7542    {\r
7543     pe = 1;\r
7544    }\r
7545     \r
7546  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
7547  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
7548  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
7549  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
7550 \r
7551  // looping over all bins and calculating correction terms: \r
7552  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7553  {\r
7554   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): \r
7555   Double_t p1n0kRe = 0.;\r
7556   Double_t p1n0kIm = 0.;\r
7557 \r
7558   // number of POIs in particular pt or eta bin:\r
7559   Double_t mp = 0.;\r
7560 \r
7561   // real and imaginary parts of q_{m*n,0} (non-weighted Q-vector evaluated for particles which are both RPs and POIs in particular pt or eta bin):\r
7562   Double_t q1n0kRe = 0.;\r
7563   Double_t q1n0kIm = 0.;\r
7564   Double_t q2n0kRe = 0.;\r
7565   Double_t q2n0kIm = 0.;\r
7566 \r
7567   // number of particles which are both RPs and POIs in particular pt or eta bin:\r
7568   Double_t mq = 0.;\r
7569    \r
7570   if(type == "POI")\r
7571   {\r
7572    // q_{m*n,0}:\r
7573    q1n0kRe = fReRPQ1dEBE[2][pe][0][0]->GetBinContent(fReRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
7574            * fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
7575    q1n0kIm = fImRPQ1dEBE[2][pe][0][0]->GetBinContent(fImRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
7576            * fImRPQ1dEBE[2][pe][0][0]->GetBinEntries(fImRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
7577    q2n0kRe = fReRPQ1dEBE[2][pe][1][0]->GetBinContent(fReRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
7578            * fReRPQ1dEBE[2][pe][1][0]->GetBinEntries(fReRPQ1dEBE[2][pe][1][0]->GetBin(b));\r
7579    q2n0kIm = fImRPQ1dEBE[2][pe][1][0]->GetBinContent(fImRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
7580            * fImRPQ1dEBE[2][pe][1][0]->GetBinEntries(fImRPQ1dEBE[2][pe][1][0]->GetBin(b));         \r
7581                  \r
7582    mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)\r
7583   } \r
7584   else if(type == "RP")\r
7585   {\r
7586    // q_{m*n,0}:\r
7587    q1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
7588            * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7589    q1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
7590            * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7591    q2n0kRe = fReRPQ1dEBE[0][pe][1][0]->GetBinContent(fReRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
7592            * fReRPQ1dEBE[0][pe][1][0]->GetBinEntries(fReRPQ1dEBE[0][pe][1][0]->GetBin(b));\r
7593    q2n0kIm = fImRPQ1dEBE[0][pe][1][0]->GetBinContent(fImRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
7594            * fImRPQ1dEBE[0][pe][1][0]->GetBinEntries(fImRPQ1dEBE[0][pe][1][0]->GetBin(b));         \r
7595                  \r
7596    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)  \r
7597   }    \r
7598   if(type == "POI")\r
7599   {\r
7600    // p_{m*n,0}:\r
7601    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))\r
7602            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7603    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  \r
7604            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7605             \r
7606    mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)\r
7607     \r
7608    t = 1; // typeFlag = RP or POI\r
7609   }\r
7610   else if(type == "RP")\r
7611   {\r
7612    // p_{m*n,0} = q_{m*n,0}:\r
7613    p1n0kRe = q1n0kRe; \r
7614    p1n0kIm = q1n0kIm; \r
7615            \r
7616    mp = mq; \r
7617    \r
7618    t = 0; // typeFlag = RP or POI\r
7619   }\r
7620 \r
7621   // <<sin n(psi1)>>:\r
7622   Double_t sinP1nPsi = 0.;\r
7623   if(mp)\r
7624   {\r
7625    sinP1nPsi = p1n0kIm/mp;\r
7626    // fill profile for <<sin n(psi1)>>:\r
7627    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi,mp);\r
7628    // histogram to store <sin n(psi1)> e-b-e (needed in some other methods):\r
7629    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][0]->SetBinContent(b,sinP1nPsi);\r
7630   } // end of if(mp)   \r
7631   \r
7632   // <<sin n(psi1+phi2)>>:\r
7633   Double_t sinP1nPsiP1nPhi = 0.;\r
7634   if(mp*dMult-mq)\r
7635   {\r
7636    sinP1nPsiP1nPhi = (p1n0kRe*dImQ1n+p1n0kIm*dReQ1n-q2n0kIm)/(mp*dMult-mq);\r
7637    // fill profile for <<sin n(psi1+phi2)>>:\r
7638    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsiP1nPhi,mp*dMult-mq);\r
7639    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7640    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][1]->SetBinContent(b,sinP1nPsiP1nPhi);\r
7641   } // end of if(mp*dMult-mq)   \r
7642   \r
7643   // <<sin n(psi1+phi2-phi3)>>:\r
7644   Double_t sinP1nPsi1P1nPhi2MPhi3 = 0.;\r
7645   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))\r
7646   {\r
7647    sinP1nPsi1P1nPhi2MPhi3 = (p1n0kIm*(pow(dImQ1n,2.)+pow(dReQ1n,2.)-dMult)
7648                           - 1.*(q2n0kIm*dReQ1n-q2n0kRe*dImQ1n)  
7649                           - mq*dImQ1n+2.*q1n0kIm)
7650                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7651    // fill profile for <<sin n(psi1+phi2)>>:\r
7652    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi1P1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7653    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7654    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][2]->SetBinContent(b,sinP1nPsi1P1nPhi2MPhi3);\r
7655   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   \r
7656   \r
7657   // <<sin n(psi1-phi2-phi3)>>:\r
7658   Double_t sinP1nPsi1M1nPhi2MPhi3 = 0.;\r
7659   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))\r
7660   {\r
7661    sinP1nPsi1M1nPhi2MPhi3 = (p1n0kIm*(pow(dReQ1n,2.)-pow(dImQ1n,2.))-2.*p1n0kRe*dReQ1n*dImQ1n
7662                           - 1.*(p1n0kIm*dReQ2n-p1n0kRe*dImQ2n)
7663                           + 2.*mq*dImQ1n-2.*q1n0kIm)
7664                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7665    // fill profile for <<sin n(psi1+phi2)>>:\r
7666    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi1M1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7667    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7668    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][3]->SetBinContent(b,sinP1nPsi1M1nPhi2MPhi3);\r
7669   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   \r
7670  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7671  \r
7672 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUASinTerms(TString type, TString ptOrEta)\r
7673 \r
7674 \r
7675 //================================================================================================================================\r
7676 \r
7677 \r
7678 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUACosTerms(TString type, TString ptOrEta)\r
7679 {\r
7680  // Calculate correction terms for non-uniform acceptance for differential flow (cos terms).\r
7681  \r
7682  // Results are stored in fDiffFlowCorrectionTermsForNUAPro[t][pe][1][cti], where cti runs as follows:\r
7683  //  0: <<cos n(psi)>>\r
7684  //  1: <<cos n(psi1+phi2)>>\r
7685  //  2: <<cos n(psi1+phi2-phi3)>>\r
7686  //  3: <<cos n(psi1-phi2-phi3)>>\r
7687  //  4:\r
7688  //  5:\r
7689  //  6:\r
7690  \r
7691  // multiplicity:\r
7692  Double_t dMult = (*fSMpk)(0,0);\r
7693  \r
7694  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
7695  Double_t dReQ1n = (*fReQ)(0,0);\r
7696  Double_t dReQ2n = (*fReQ)(1,0);\r
7697  //Double_t dReQ3n = (*fReQ)(2,0);\r
7698  //Double_t dReQ4n = (*fReQ)(3,0);\r
7699  Double_t dImQ1n = (*fImQ)(0,0);\r
7700  Double_t dImQ2n = (*fImQ)(1,0);\r
7701  //Double_t dImQ3n = (*fImQ)(2,0);\r
7702  //Double_t dImQ4n = (*fImQ)(3,0);\r
7703 \r
7704  Int_t t = -1; // type flag \r
7705  Int_t pe = -1; // ptEta flag\r
7706  \r
7707  if(type == "RP")\r
7708  {\r
7709   t = 0;\r
7710  } else if(type == "POI")\r
7711    {\r
7712     t = 1;\r
7713    }\r
7714 \r
7715  if(ptOrEta == "Pt")\r
7716  {\r
7717   pe = 0;\r
7718  } else if(ptOrEta == "Eta")\r
7719    {\r
7720     pe = 1;\r
7721    }\r
7722     \r
7723  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
7724  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
7725  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
7726  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
7727 \r
7728  // looping over all bins and calculating correction terms: \r
7729  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7730  {\r
7731   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): \r
7732   Double_t p1n0kRe = 0.;\r
7733   Double_t p1n0kIm = 0.;\r
7734 \r
7735   // number of POIs in particular pt or eta bin:\r
7736   Double_t mp = 0.;\r
7737 \r
7738   // real and imaginary parts of q_{m*n,0} (non-weighted Q-vector evaluated for particles which are both RPs and POIs in particular pt or eta bin):\r
7739   Double_t q1n0kRe = 0.;\r
7740   Double_t q1n0kIm = 0.;\r
7741   Double_t q2n0kRe = 0.;\r
7742   Double_t q2n0kIm = 0.;\r
7743 \r
7744   // number of particles which are both RPs and POIs in particular pt or eta bin:\r
7745   Double_t mq = 0.;\r
7746    \r
7747   if(type == "POI")\r
7748   {\r
7749    // q_{m*n,0}:\r
7750    q1n0kRe = fReRPQ1dEBE[2][pe][0][0]->GetBinContent(fReRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
7751            * fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
7752    q1n0kIm = fImRPQ1dEBE[2][pe][0][0]->GetBinContent(fImRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
7753            * fImRPQ1dEBE[2][pe][0][0]->GetBinEntries(fImRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
7754    q2n0kRe = fReRPQ1dEBE[2][pe][1][0]->GetBinContent(fReRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
7755            * fReRPQ1dEBE[2][pe][1][0]->GetBinEntries(fReRPQ1dEBE[2][pe][1][0]->GetBin(b));\r
7756    q2n0kIm = fImRPQ1dEBE[2][pe][1][0]->GetBinContent(fImRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
7757            * fImRPQ1dEBE[2][pe][1][0]->GetBinEntries(fImRPQ1dEBE[2][pe][1][0]->GetBin(b));         \r
7758                  \r
7759    mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)\r
7760   } \r
7761   else if(type == "RP")\r
7762   {\r
7763    // q_{m*n,0}:\r
7764    q1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
7765            * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7766    q1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
7767            * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7768    q2n0kRe = fReRPQ1dEBE[0][pe][1][0]->GetBinContent(fReRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
7769            * fReRPQ1dEBE[0][pe][1][0]->GetBinEntries(fReRPQ1dEBE[0][pe][1][0]->GetBin(b));\r
7770    q2n0kIm = fImRPQ1dEBE[0][pe][1][0]->GetBinContent(fImRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
7771            * fImRPQ1dEBE[0][pe][1][0]->GetBinEntries(fImRPQ1dEBE[0][pe][1][0]->GetBin(b));         \r
7772                  \r
7773    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)  \r
7774   }    \r
7775   if(type == "POI")\r
7776   {\r
7777    // p_{m*n,0}:\r
7778    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))\r
7779            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7780    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  \r
7781            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7782             \r
7783    mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)\r
7784     \r
7785    t = 1; // typeFlag = RP or POI\r
7786   }\r
7787   else if(type == "RP")\r
7788   {\r
7789    // p_{m*n,0} = q_{m*n,0}:\r
7790    p1n0kRe = q1n0kRe; \r
7791    p1n0kIm = q1n0kIm; \r
7792            \r
7793    mp = mq; \r
7794    \r
7795    t = 0; // typeFlag = RP or POI\r
7796   }\r
7797 \r
7798   // <<cos n(psi1)>>:\r
7799   Double_t cosP1nPsi = 0.;\r
7800   if(mp)\r
7801   {\r
7802    cosP1nPsi = p1n0kRe/mp;\r
7803    \r
7804    // fill profile for <<cos n(psi1)>>:\r
7805    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi,mp);\r
7806    // histogram to store <cos n(psi1)> e-b-e (needed in some other methods):\r
7807    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][0]->SetBinContent(b,cosP1nPsi);\r
7808   } // end of if(mp)   \r
7809   \r
7810   // <<cos n(psi1+phi2)>>:\r
7811   Double_t cosP1nPsiP1nPhi = 0.;\r
7812   if(mp*dMult-mq)\r
7813   {\r
7814    cosP1nPsiP1nPhi = (p1n0kRe*dReQ1n-p1n0kIm*dImQ1n-q2n0kRe)/(mp*dMult-mq);\r
7815    // fill profile for <<sin n(psi1+phi2)>>:\r
7816    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsiP1nPhi,mp*dMult-mq);\r
7817    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7818    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][1]->SetBinContent(b,cosP1nPsiP1nPhi);\r
7819   } // end of if(mp*dMult-mq)   \r
7820   \r
7821   // <<cos n(psi1+phi2-phi3)>>:\r
7822   Double_t cosP1nPsi1P1nPhi2MPhi3 = 0.;\r
7823   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))\r
7824   {\r
7825    cosP1nPsi1P1nPhi2MPhi3 = (p1n0kRe*(pow(dImQ1n,2.)+pow(dReQ1n,2.)-dMult)
7826                           - 1.*(q2n0kRe*dReQ1n+q2n0kIm*dImQ1n)  
7827                           - mq*dReQ1n+2.*q1n0kRe)
7828                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7829    // fill profile for <<sin n(psi1+phi2)>>:\r
7830    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi1P1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7831    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7832    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][2]->SetBinContent(b,cosP1nPsi1P1nPhi2MPhi3);\r
7833   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   \r
7834   
7835   // <<cos n(psi1-phi2-phi3)>>:\r
7836   Double_t cosP1nPsi1M1nPhi2MPhi3 = 0.;\r
7837   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))\r
7838   {\r
7839    cosP1nPsi1M1nPhi2MPhi3 = (p1n0kRe*(pow(dReQ1n,2.)-pow(dImQ1n,2.))+2.*p1n0kIm*dReQ1n*dImQ1n
7840                           - 1.*(p1n0kRe*dReQ2n+p1n0kIm*dImQ2n)  
7841                           - 2.*mq*dReQ1n+2.*q1n0kRe)
7842                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7843    // fill profile for <<sin n(psi1+phi2)>>:\r
7844    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi1M1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7845    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7846    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][3]->SetBinContent(b,cosP1nPsi1M1nPhi2MPhi3);\r
7847   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   \r
7848  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7849  \r
7850 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUACosTerms(TString type, TString ptOrEta)\r
7851 \r
7852 \r
7853 //==================================================================================================================================\r
7854 \r
7855 \r
7856 void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUADiffFlow(TString type, TString ptOrEta)\r
7857 {\r
7858  // Transfer prolfiles into histogams and correctly propagate the error (to be improved: description)\r
7859  \r
7860  // to be improved: debugged - I do not correctly transfer all profiles into histos (bug appears only after merging) \r
7861   \r
7862  Int_t t = -1; // type flag \r
7863  Int_t pe = -1; // ptEta flag\r
7864  \r
7865  if(type == "RP")\r
7866  {\r
7867   t = 0;\r
7868  } else if(type == "POI")\r
7869    {\r
7870     t = 1;\r
7871    }\r
7872 \r
7873  if(ptOrEta == "Pt")\r
7874  {\r
7875   pe = 0;\r
7876  } else if(ptOrEta == "Eta")\r
7877    {\r
7878     pe = 1;\r
7879    }\r
7880     \r
7881  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
7882  //Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
7883  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
7884  //Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
7885 \r
7886  for(Int_t sc=0;sc<2;sc++) // sin or cos\r
7887  {\r
7888   for(Int_t cti=0;cti<9;cti++) // correction term index\r
7889   {\r
7890    for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7891    {\r
7892     Double_t correctionTerm = fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti]->GetBinContent(b);\r
7893     fDiffFlowCorrectionTermsForNUAHist[t][pe][sc][cti]->SetBinContent(b,correctionTerm);\r
7894     // to be improved (propagate error correctly)\r
7895     // ...\r
7896    } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7897   } // correction term index\r
7898  } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos\r
7899 \r
7900 }// end of void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUADiffFlow(TString type, TString ptOrEta)\r
7901 \r
7902 \r
7903 //==================================================================================================================================\r
7904 \r
7905 \r
7906 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulantsCorrectedForNUA(TString type, TString ptOrEta)\r
7907\r
7908  // Calculate generalized differential flow Q-cumulants (corrected for non-uniform acceptance)\r
7909   \r
7910  Int_t typeFlag = -1;\r
7911  Int_t ptEtaFlag = -1;\r
7912 \r
7913  if(type == "RP")\r
7914  {\r
7915   typeFlag = 0;\r
7916  } else if(type == "POI")\r
7917    {\r
7918     typeFlag = 1;\r
7919    } \r
7920      \r
7921  if(ptOrEta == "Pt")\r
7922  {\r
7923   ptEtaFlag = 0;\r
7924  } else if(ptOrEta == "Eta")\r
7925    {\r
7926     ptEtaFlag = 1;\r
7927    } \r
7928   \r
7929  // shortcuts:\r
7930  Int_t t = typeFlag;\r
7931  Int_t pe = ptEtaFlag;\r
7932      \r
7933  // common:\r
7934  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
7935  
7936  // 2-particle correlation:
7937  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>
7938  // sin term coming from integrated flow: 
7939  Double_t sinP1nPhi = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1); // <<sin(n*phi1)>>\r
7940  Double_t sinP1nPhi1P1nPhi2 = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(2); // <<sin(n*(phi1+phi2))>>\r
7941  Double_t sinP1nPhi1M1nPhi2M1nPhi3 = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(3); // <<sin(n*(phi1-phi2-phi3))>>\r
7942  // cos term coming from integrated flow: 
7943  Double_t cosP1nPhi = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1); // <<cos(n*phi1)>>\r
7944  Double_t cosP1nPhi1P1nPhi2 = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(2); // <<cos(n*(phi1+phi2))>>\r
7945  Double_t cosP1nPhi1M1nPhi2M1nPhi3 = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(3); // <<cos(n*(phi1-phi2-phi3))>>\r
7946 \r
7947  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7948  {\r
7949   Double_t twoPrime = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b); // <<2'>>\r
7950   Double_t fourPrime = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b); // <<4'>>\r
7951   Double_t sinP1nPsi = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][0]->GetBinContent(b); // <<sin n(Psi)>> \r
7952   Double_t cosP1nPsi = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][0]->GetBinContent(b); // <<cos n(Psi)>> \r
7953   Double_t sinP1nPsi1P1nPhi2 = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][1]->GetBinContent(b); // <<sin n(psi1+phi2)>> \r
7954   Double_t cosP1nPsi1P1nPhi2 = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][1]->GetBinContent(b); // <<cos n(psi1+phi2)>> \r
7955   Double_t sinP1nPsi1P1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][2]->GetBinContent(b); // <<sin n(psi1+phi2-phi3)>> \r
7956   Double_t cosP1nPsi1P1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][2]->GetBinContent(b); // <<cos n(psi1+phi2-phi3)>> \r
7957   Double_t sinP1nPsi1M1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][3]->GetBinContent(b); // <<sin n(psi1-phi2-phi3)>> \r
7958   Double_t cosP1nPsi1M1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][3]->GetBinContent(b); // <<cos n(psi1-phi2-phi3)>> \r
7959   // generalized QC{2'}:\r
7960   Double_t qc2Prime = twoPrime - sinP1nPsi*sinP1nPhi - cosP1nPsi*cosP1nPhi;\r
7961   fDiffFlowCumulants[t][pe][0]->SetBinContent(b,qc2Prime);
7962   // generalized QC{4'}:\r
7963   Double_t qc4Prime = fourPrime-2.*twoPrime*two
7964                     - cosP1nPsi*cosP1nPhi1M1nPhi2M1nPhi3
7965                     + sinP1nPsi*sinP1nPhi1M1nPhi2M1nPhi3
7966                     - cosP1nPhi*cosP1nPsi1M1nPhi2M1nPhi3
7967                     + sinP1nPhi*sinP1nPsi1M1nPhi2M1nPhi3
7968                     - 2.*cosP1nPhi*cosP1nPsi1P1nPhi2M1nPhi3
7969                     - 2.*sinP1nPhi*sinP1nPsi1P1nPhi2M1nPhi3
7970                     - cosP1nPsi1P1nPhi2*cosP1nPhi1P1nPhi2
7971                     - sinP1nPsi1P1nPhi2*sinP1nPhi1P1nPhi2
7972                     + 2.*cosP1nPhi1P1nPhi2*(cosP1nPsi*cosP1nPhi-sinP1nPsi*sinP1nPhi)
7973                     + 2.*sinP1nPhi1P1nPhi2*(cosP1nPsi*sinP1nPhi+sinP1nPsi*cosP1nPhi)
7974                     + 4.*two*(cosP1nPsi*cosP1nPhi+sinP1nPsi*sinP1nPhi)
7975                     + 2.*cosP1nPsi1P1nPhi2*(pow(cosP1nPhi,2.)-pow(sinP1nPhi,2.))
7976                     + 4.*sinP1nPsi1P1nPhi2*cosP1nPhi*sinP1nPhi
7977                     + 4.*twoPrime*(pow(cosP1nPhi,2.)+pow(sinP1nPhi,2.))
7978                     - 6.*(pow(cosP1nPhi,2.)-pow(sinP1nPhi,2.)) 
7979                     * (cosP1nPsi*cosP1nPhi-sinP1nPsi*sinP1nPhi)
7980                     - 12.*cosP1nPhi*sinP1nPhi
7981                     * (sinP1nPsi*cosP1nPhi+cosP1nPsi*sinP1nPhi);
7982   fDiffFlowCumulants[t][pe][1]->SetBinContent(b,qc4Prime);   \r
7983  } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
7984  \r
7985 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulantsCorrectedForNUA(TString type, TString ptOrEta)\r
7986 \r
7987 \r
7988 //==================================================================================================================================\r
7989     \r
7990 \r
7991 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectedForNUA(TString type, TString ptOrEta)\r
7992 {\r
7993  // Calculate differential flow corrected for non-uniform acceptance.\r
7994  \r
7995  // to be improved (rewritten completely)\r
7996  \r
7997  Int_t typeFlag = -1;\r
7998  Int_t ptEtaFlag = -1;\r
7999 \r
8000  if(type == "RP")\r
8001  {\r
8002   typeFlag = 0;\r
8003  } else if(type == "POI")\r
8004    {\r
8005     typeFlag = 1;\r
8006    } \r
8007      \r
8008  if(ptOrEta == "Pt")\r
8009  {\r
8010   ptEtaFlag = 0;\r
8011  } else if(ptOrEta == "Eta")\r
8012    {\r
8013     ptEtaFlag = 1;\r
8014    } \r
8015   \r
8016  // shortcuts:\r
8017  Int_t t = typeFlag;\r
8018  Int_t pe = ptEtaFlag;\r
8019      \r
8020  // common:\r
8021  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
8022    \r
8023  // to be improved: access here generalized QC{2} and QC{4} instead: \r
8024  Double_t dV2 = fIntFlow->GetBinContent(1); \r
8025  Double_t dV4 = fIntFlow->GetBinContent(2); \r
8026  \r
8027  // loop over pt or eta bins:\r
8028  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
8029  {\r
8030   // generalized QC{2'}:\r
8031   Double_t gQC2Prime = fDiffFlowCumulants[t][pe][0]->GetBinContent(b);\r
8032   // v'{2}:\r
8033   if(dV2>0)\r
8034   { \r
8035    Double_t v2Prime = gQC2Prime/dV2;\r
8036    fDiffFlow[t][pe][0]->SetBinContent(b,v2Prime); \r
8037   }  \r
8038   // generalized QC{4'}:\r
8039   Double_t gQC4Prime = fDiffFlowCumulants[t][pe][1]->GetBinContent(b);\r
8040   // v'{4}:\r
8041   if(dV4>0)\r
8042   { \r
8043    Double_t v4Prime = -gQC4Prime/pow(dV4,3.);\r
8044    fDiffFlow[t][pe][1]->SetBinContent(b,v4Prime); \r
8045   }  \r
8046  } // end of for(Int_t b=1;b<=fnBinsPtEta[pe];b++)\r
8047   \r
8048 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectedForNUA(TString type, TString ptOrEta); \r
8049 \r
8050 \r
8051 //==================================================================================================================================
8052
8053 \r
8054 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoops(AliFlowEventSimple* anEvent)\r
8055 {\r
8056  // Evaluate with nested loops multiparticle correlations for integrated flow (without using the particle weights). 
8057 \r
8058  // Remark: Results are stored in profile fIntFlowDirectCorrelations whose binning is organized as follows:
8059  // \r
8060  //  1st bin: <2>_{1n|1n} = two1n1n = cos(n*(phi1-phi2))>\r
8061  //  2nd bin: <2>_{2n|2n} = two2n2n = cos(2n*(phi1-phi2))>\r
8062  //  3rd bin: <2>_{3n|3n} = two3n3n = cos(3n*(phi1-phi2))> \r
8063  //  4th bin: <2>_{4n|4n} = two4n4n = cos(4n*(phi1-phi2))>\r
8064  //  5th bin:           ----  EMPTY ----\r
8065  //  6th bin: <3>_{2n|1n,1n} = three2n1n1n = <cos(n*(2.*phi1-phi2-phi3))>\r
8066  //  7th bin: <3>_{3n|2n,1n} = three3n2n1n = <cos(n*(3.*phi1-2.*phi2-phi3))>\r
8067  //  8th bin: <3>_{4n|2n,2n} = three4n2n2n = <cos(n*(4.*phi1-2.*phi2-2.*phi3))>\r
8068  //  9th bin: <3>_{4n|3n,1n} = three4n3n1n = <cos(n*(4.*phi1-3.*phi2-phi3))>\r
8069  // 10th bin:           ----  EMPTY ----\r
8070  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1n = <cos(n*(phi1+phi2-phi3-phi4))>\r
8071  // 12th bin: <4>_{2n,1n|2n,1n} = four2n1n2n1n = <cos(2.*n*(phi1+phi2-phi3-phi4))>\r
8072  // 13th bin: <4>_{2n,2n|2n,2n} = four2n2n2n2n = <cos(n*(2.*phi1+phi2-2.*phi3-phi4))>\r
8073  // 14th bin: <4>_{3n|1n,1n,1n} = four3n1n1n1n = <cos(n*(3.*phi1-phi2-phi3-phi4))> \r
8074  // 15th bin: <4>_{3n,1n|3n,1n} = four3n1n3n1n = <cos(n*(4.*phi1-2.*phi2-phi3-phi4))>\r
8075  // 16th bin: <4>_{3n,1n|2n,2n} = four3n1n2n2n = <cos(n*(3.*phi1+phi2-2.*phi3-2.*phi4))>\r
8076  // 17th bin: <4>_{4n|2n,1n,1n} = four4n2n1n1n = <cos(n*(3.*phi1+phi2-3.*phi3-phi4))> \r
8077  // 18th bin:           ----  EMPTY ----\r
8078  // 19th bin: <5>_{2n|1n,1n,1n,1n} = five2n1n1n1n1n = <cos(n*(2.*phi1+phi2-phi3-phi4-phi5))>\r
8079  // 20th bin: <5>_{2n,2n|2n,1n,1n} = five2n2n2n1n1n = <cos(n*(2.*phi1+2.*phi2-2.*phi3-phi4-phi5))>\r
8080  // 21st bin: <5>_{3n,1n|2n,1n,1n} = five3n1n2n1n1n = <cos(n*(3.*phi1+phi2-2.*phi3-phi4-phi5))>\r
8081  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = five4n1n1n1n1n = <cos(n*(4.*phi1-phi2-phi3-phi4-phi5))>\r
8082  // 23rd bin:           ----  EMPTY ----\r
8083  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = six1n1n1n1n1n1n = <cos(n*(phi1+phi2+phi3-phi4-phi5-phi6))>\r
8084  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = six2n1n1n2n1n1n = <cos(n*(2.*phi1+2.*phi2-phi3-phi4-phi5-phi6))>\r
8085  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = six2n2n1n1n1n1n = <cos(n*(3.*phi1+phi2-phi3-phi4-phi5-phi6))>\r
8086  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = six3n1n1n1n1n1n = <cos(n*(2.*phi1+phi2+phi3-2.*phi4-phi5-phi6))>\r
8087  // 28th bin:           ----  EMPTY ----\r
8088  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = seven2n1n1n1n1n1n1n =  <cos(n*(2.*phi1+phi2+phi3-phi4-phi5-phi6-phi7))>\r
8089  // 30th bin:           ----  EMPTY ----\r
8090  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = eight1n1n1n1n1n1n1n1n = <cos(n*(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>\r
8091  \r
8092  Int_t nPrim = anEvent->NumberOfTracks(); \r
8093  AliFlowTrackSimple *aftsTrack = NULL; \r
8094  Double_t phi1=0., phi2=0., phi3=0., phi4=0., phi5=0., phi6=0., phi7=0., phi8=0.; \r
8095  Int_t n = fHarmonic; \r
8096  Int_t eventNo = (Int_t)fAvMultiplicity->GetBinEntries(1); // to be improved (is this casting safe in general?)
8097  Double_t dMult = (*fSMpk)(0,0);
8098  cout<<endl;
8099  cout<<"Multiparticle correlations: Event number: "<<eventNo<<", multiplicity is "<<dMult<<endl;
8100  if(dMult<2)
8101  {
8102   cout<<"... skipping this event (multiplicity too low) ..."<<endl;
8103  } else if (dMult>fMaxAllowedMultiplicity)
8104    {
8105     cout<<"... skipping this event (multiplicity too high) ..."<<endl;
8106    } else 
8107      { 
8108       cout<<"... evaluating nested loops (without using particle weights)..."<<endl;\r
8109      } 
8110  
8111  // 2-particle correlations:       \r
8112  if(nPrim>=2 && nPrim<=fMaxAllowedMultiplicity)
8113  {
8114   for(Int_t i1=0;i1<nPrim;i1++)\r
8115   {\r
8116    aftsTrack=anEvent->GetTrack(i1);\r
8117    if(!(aftsTrack->InRPSelection())) continue;\r
8118    phi1=aftsTrack->Phi(); \r
8119    for(Int_t i2=0;i2<nPrim;i2++)\r
8120    {\r
8121     if(i2==i1)continue;\r
8122     aftsTrack=anEvent->GetTrack(i2);\r
8123     if(!(aftsTrack->InRPSelection())) continue;\r
8124     phi2=aftsTrack->Phi();
8125     if(nPrim==2) cout<<i1<<" "<<i2<<"\r"<<flush;\r
8126     // fill the profile with 2-p correlations: \r
8127     fIntFlowDirectCorrelations->Fill(0.5,cos(n*(phi1-phi2)),1.);    // <cos(n*(phi1-phi2))>\r
8128     fIntFlowDirectCorrelations->Fill(1.5,cos(2.*n*(phi1-phi2)),1.); // <cos(2n*(phi1-phi2))>\r
8129     fIntFlowDirectCorrelations->Fill(2.5,cos(3.*n*(phi1-phi2)),1.); // <cos(3n*(phi1-phi2))>\r
8130     fIntFlowDirectCorrelations->Fill(3.5,cos(4.*n*(phi1-phi2)),1.); // <cos(4n*(phi1-phi2))>   \r
8131    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8132   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8133  } // end of if(nPrim>=2)
8134  \r
8135  // 3-particle correlations:         \r
8136  if(nPrim>=3 && nPrim<=fMaxAllowedMultiplicity)
8137  {
8138   for(Int_t i1=0;i1<nPrim;i1++)\r
8139   {\r
8140    aftsTrack=anEvent->GetTrack(i1);\r
8141    if(!(aftsTrack->InRPSelection())) continue;\r
8142    phi1=aftsTrack->Phi();\r
8143    for(Int_t i2=0;i2<nPrim;i2++)\r
8144    {\r
8145     if(i2==i1)continue;\r
8146     aftsTrack=anEvent->GetTrack(i2);\r
8147     if(!(aftsTrack->InRPSelection())) continue;\r
8148     phi2=aftsTrack->Phi();\r
8149     for(Int_t i3=0;i3<nPrim;i3++)\r
8150     {\r
8151      if(i3==i1||i3==i2)continue;\r
8152      aftsTrack=anEvent->GetTrack(i3);\r
8153      if(!(aftsTrack->InRPSelection())) continue;\r
8154      phi3=aftsTrack->Phi();\r
8155      if(nPrim==3) cout<<i1<<" "<<i2<<" "<<i3<<"\r"<<flush;\r
8156      // fill the profile with 3-p correlations:   
8157      fIntFlowDirectCorrelations->Fill(5.,cos(2.*n*phi1-n*(phi2+phi3)),1.);       //<3>_{2n|nn,n}\r
8158      fIntFlowDirectCorrelations->Fill(6.,cos(3.*n*phi1-2.*n*phi2-n*phi3),1.);    //<3>_{3n|2n,n}\r
8159      fIntFlowDirectCorrelations->Fill(7.,cos(4.*n*phi1-2.*n*phi2-2.*n*phi3),1.); //<3>_{4n|2n,2n}\r
8160      fIntFlowDirectCorrelations->Fill(8.,cos(4.*n*phi1-3.*n*phi2-n*phi3),1.);    //<3>_{4n|3n,n}\r
8161     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8162    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8163   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8164  } // end of if(nPrim>=3)
8165 \r
8166  // 4-particle correlations:
8167  if(nPrim>=4 && nPrim<=fMaxAllowedMultiplicity)
8168  {       \r
8169   for(Int_t i1=0;i1<nPrim;i1++)\r
8170   { \r
8171    aftsTrack=anEvent->GetTrack(i1);\r
8172    if(!(aftsTrack->InRPSelection())) continue;\r
8173    phi1=aftsTrack->Phi();\r
8174    for(Int_t i2=0;i2<nPrim;i2++)\r
8175    {\r
8176     if(i2==i1)continue;\r
8177     aftsTrack=anEvent->GetTrack(i2);\r
8178     if(!(aftsTrack->InRPSelection())) continue;\r
8179     phi2=aftsTrack->Phi();\r
8180     for(Int_t i3=0;i3<nPrim;i3++)\r
8181     {\r
8182      if(i3==i1||i3==i2)continue;\r
8183      aftsTrack=anEvent->GetTrack(i3);\r
8184      if(!(aftsTrack->InRPSelection())) continue;\r
8185      phi3=aftsTrack->Phi();\r
8186      for(Int_t i4=0;i4<nPrim;i4++)\r
8187      {\r
8188       if(i4==i1||i4==i2||i4==i3)continue;\r
8189       aftsTrack=anEvent->GetTrack(i4);\r
8190       if(!(aftsTrack->InRPSelection())) continue;\r
8191       phi4=aftsTrack->Phi();\r
8192       if(nPrim==4) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<"\r"<<flush;\r
8193       // fill the profile with 4-p correlations:   
8194       fIntFlowDirectCorrelations->Fill(10.,cos(n*phi1+n*phi2-n*phi3-n*phi4),1.);            // <4>_{n,n|n,n} \r
8195       fIntFlowDirectCorrelations->Fill(11.,cos(2.*n*phi1+n*phi2-2.*n*phi3-n*phi4),1.);      // <4>_{2n,n|2n,n}\r
8196       fIntFlowDirectCorrelations->Fill(12.,cos(2.*n*phi1+2*n*phi2-2.*n*phi3-2.*n*phi4),1.); // <4>_{2n,2n|2n,2n}\r
8197       fIntFlowDirectCorrelations->Fill(13.,cos(3.*n*phi1-n*phi2-n*phi3-n*phi4),1.);         // <4>_{3n|n,n,n}\r
8198       fIntFlowDirectCorrelations->Fill(14.,cos(3.*n*phi1+n*phi2-3.*n*phi3-n*phi4),1.);      // <4>_{3n,n|3n,n}   \r
8199       fIntFlowDirectCorrelations->Fill(15.,cos(3.*n*phi1+n*phi2-2.*n*phi3-2.*n*phi4),1.);   // <4>_{3n,n|2n,2n}\r
8200       fIntFlowDirectCorrelations->Fill(16.,cos(4.*n*phi1-2.*n*phi2-n*phi3-n*phi4),1.);      // <4>_{4n|2n,n,n}     \r
8201      } // end of for(Int_t i4=0;i4<nPrim;i4++) \r
8202     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8203    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8204   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8205  } // end of if(nPrim>=)
8206 \r
8207  // 5-particle correlations:      \r
8208  if(nPrim>=5 && nPrim<=fMaxAllowedMultiplicity)
8209  {
8210   for(Int_t i1=0;i1<nPrim;i1++)\r
8211   {\r
8212    aftsTrack=anEvent->GetTrack(i1);\r
8213    if(!(aftsTrack->InRPSelection())) continue;  \r
8214    phi1=aftsTrack->Phi();\r
8215    for(Int_t i2=0;i2<nPrim;i2++)\r
8216    {\r
8217     if(i2==i1)continue;\r
8218     aftsTrack=anEvent->GetTrack(i2);\r
8219     if(!(aftsTrack->InRPSelection())) continue;\r
8220     phi2=aftsTrack->Phi();\r
8221     for(Int_t i3=0;i3<nPrim;i3++)\r
8222     {\r
8223      if(i3==i1||i3==i2)continue;\r
8224      aftsTrack=anEvent->GetTrack(i3);\r
8225      if(!(aftsTrack->InRPSelection())) continue;\r
8226      phi3=aftsTrack->Phi();\r
8227      for(Int_t i4=0;i4<nPrim;i4++)\r
8228      {\r
8229       if(i4==i1||i4==i2||i4==i3)continue;\r
8230       aftsTrack=anEvent->GetTrack(i4);\r
8231       if(!(aftsTrack->InRPSelection())) continue;\r
8232       phi4=aftsTrack->Phi();\r
8233       for(Int_t i5=0;i5<nPrim;i5++)\r
8234       {\r
8235        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;\r
8236        aftsTrack=anEvent->GetTrack(i5);\r
8237        if(!(aftsTrack->InRPSelection())) continue;\r
8238        phi5=aftsTrack->Phi();\r
8239        if(nPrim==5) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<"\r"<<flush;\r
8240        // fill the profile with 5-p correlations:   
8241        fIntFlowDirectCorrelations->Fill(18.,cos(2.*n*phi1+n*phi2-n*phi3-n*phi4-n*phi5),1.);       //<5>_{2n,n|n,n,n}\r
8242        fIntFlowDirectCorrelations->Fill(19.,cos(2.*n*phi1+2.*n*phi2-2.*n*phi3-n*phi4-n*phi5),1.); //<5>_{2n,2n|2n,n,n}\r
8243        fIntFlowDirectCorrelations->Fill(20.,cos(3.*n*phi1+n*phi2-2.*n*phi3-n*phi4-n*phi5),1.);    //<5>_{3n,n|2n,n,n}\r
8244        fIntFlowDirectCorrelations->Fill(21.,cos(4.*n*phi1-n*phi2-n*phi3-n*phi4-n*phi5),1.);       //<5>_{4n|n,n,n,n}\r
8245       } // end of for(Int_t i5=0;i5<nPrim;i5++)\r
8246      } // end of for(Int_t i4=0;i4<nPrim;i4++)  \r
8247     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8248    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8249   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8250  } // end of if(nPrim>=5)
8251   \r
8252  // 6-particle correlations:
8253  if(nPrim>=6 && nPrim<=fMaxAllowedMultiplicity)\r
8254  {
8255   for(Int_t i1=0;i1<nPrim;i1++)\r
8256   {\r
8257    aftsTrack=anEvent->GetTrack(i1);\r
8258    if(!(aftsTrack->InRPSelection())) continue;\r
8259    phi1=aftsTrack->Phi();\r
8260    for(Int_t i2=0;i2<nPrim;i2++)\r
8261    {\r
8262     if(i2==i1)continue;\r
8263     aftsTrack=anEvent->GetTrack(i2);\r
8264     if(!(aftsTrack->InRPSelection())) continue;\r
8265     phi2=aftsTrack->Phi();\r
8266     for(Int_t i3=0;i3<nPrim;i3++)\r
8267     {\r
8268      if(i3==i1||i3==i2)continue;\r
8269      aftsTrack=anEvent->GetTrack(i3);\r
8270      if(!(aftsTrack->InRPSelection())) continue;\r
8271      phi3=aftsTrack->Phi();\r
8272      for(Int_t i4=0;i4<nPrim;i4++)\r
8273      {\r
8274       if(i4==i1||i4==i2||i4==i3)continue;\r
8275       aftsTrack=anEvent->GetTrack(i4);\r
8276       if(!(aftsTrack->InRPSelection())) continue;\r
8277       phi4=aftsTrack->Phi();\r
8278       for(Int_t i5=0;i5<nPrim;i5++)\r
8279       {\r
8280        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;\r
8281        aftsTrack=anEvent->GetTrack(i5);\r
8282        if(!(aftsTrack->InRPSelection())) continue;\r
8283        phi5=aftsTrack->Phi();\r
8284        for(Int_t i6=0;i6<nPrim;i6++)\r
8285        {\r
8286         if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;\r
8287         aftsTrack=anEvent->GetTrack(i6);\r
8288         if(!(aftsTrack->InRPSelection())) continue;\r
8289         phi6=aftsTrack->Phi(); \r
8290         if(nPrim==6) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<" "<<i6<<"\r"<<flush;\r
8291         // fill the profile with 6-p correlations:   
8292         fIntFlowDirectCorrelations->Fill(23.,cos(n*phi1+n*phi2+n*phi3-n*phi4-n*phi5-n*phi6),1.);       //<6>_{n,n,n|n,n,n}\r
8293         fIntFlowDirectCorrelations->Fill(24.,cos(2.*n*phi1+n*phi2+n*phi3-2.*n*phi4-n*phi5-n*phi6),1.); //<6>_{2n,n,n|2n,n,n}\r
8294         fIntFlowDirectCorrelations->Fill(25.,cos(2.*n*phi1+2.*n*phi2-n*phi3-n*phi4-n*phi5-n*phi6),1.); //<6>_{2n,2n|n,n,n,n}\r
8295         fIntFlowDirectCorrelations->Fill(26.,cos(3.*n*phi1+n*phi2-n*phi3-n*phi4-n*phi5-n*phi6),1.);    //<6>_{3n,n|n,n,n,n}  \r
8296        } // end of for(Int_t i6=0;i6<nPrim;i6++)\r
8297       } // end of for(Int_t i5=0;i5<nPrim;i5++)\r
8298      } // end of for(Int_t i4=0;i4<nPrim;i4++)\r
8299     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8300    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8301   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8302  } // end of if(nPrim>=6)
8303   \r
8304  // 7-particle correlations:\r
8305  if(nPrim>=7 && nPrim<=fMaxAllowedMultiplicity)
8306  {
8307   for(Int_t i1=0;i1<nPrim;i1++)\r
8308   { \r
8309    aftsTrack=anEvent->GetTrack(i1);\r
8310    if(!(aftsTrack->InRPSelection())) continue;\r
8311    phi1=aftsTrack->Phi();\r
8312    for(Int_t i2=0;i2<nPrim;i2++)\r
8313    {\r
8314     if(i2==i1)continue;\r
8315     aftsTrack=anEvent->GetTrack(i2);\r
8316     if(!(aftsTrack->InRPSelection())) continue;\r
8317     phi2=aftsTrack->Phi();\r
8318     for(Int_t i3=0;i3<nPrim;i3++)\r
8319     {\r
8320      if(i3==i1||i3==i2)continue;\r
8321      aftsTrack=anEvent->GetTrack(i3);\r
8322      if(!(aftsTrack->InRPSelection())) continue;\r
8323      phi3=aftsTrack->Phi();\r
8324      for(Int_t i4=0;i4<nPrim;i4++)\r
8325      {\r
8326       if(i4==i1||i4==i2||i4==i3)continue;\r
8327       aftsTrack=anEvent->GetTrack(i4);\r
8328       if(!(aftsTrack->InRPSelection())) continue;\r
8329       phi4=aftsTrack->Phi();\r
8330       for(Int_t i5=0;i5<nPrim;i5++)\r
8331       {\r
8332        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;\r
8333        aftsTrack=anEvent->GetTrack(i5);\r
8334        if(!(aftsTrack->InRPSelection())) continue;\r
8335        phi5=aftsTrack->Phi();\r
8336        for(Int_t i6=0;i6<nPrim;i6++)\r
8337        {\r
8338         if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;\r
8339         aftsTrack=anEvent->GetTrack(i6);\r
8340         if(!(aftsTrack->InRPSelection())) continue;\r
8341         phi6=aftsTrack->Phi(); \r
8342         for(Int_t i7=0;i7<nPrim;i7++)\r
8343         {\r
8344          if(i7==i1||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6)continue;\r
8345          aftsTrack=anEvent->GetTrack(i7);\r
8346          if(!(aftsTrack->InRPSelection())) continue;\r
8347          phi7=aftsTrack->Phi(); \r
8348          if(nPrim==7) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<" "<<i6<<" "<<i7<<"\r"<<flush;\r
8349          // fill the profile with 7-p correlation:   
8350          fIntFlowDirectCorrelations->Fill(28.,cos(2.*n*phi1+n*phi2+n*phi3-n*phi4-n*phi5-n*phi6-n*phi7),1.); // <7>_{2n,n,n|n,n,n,n}\r
8351         } // end of for(Int_t i7=0;i7<nPrim;i7++)\r
8352        } // end of for(Int_t i6=0;i6<nPrim;i6++) \r
8353       } // end of for(Int_t i5=0;i5<nPrim;i5++)\r
8354      } // end of for(Int_t i4=0;i4<nPrim;i4++)  \r
8355     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8356    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8357   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8358  } // end of if(nPrim>=7)
8359  \r
8360  // 8-particle correlations:\r
8361  if(nPrim>=8 && nPrim<=fMaxAllowedMultiplicity)
8362  {
8363   for(Int_t i1=0;i1<nPrim;i1++)\r
8364   {\r
8365    aftsTrack=anEvent->GetTrack(i1);\r
8366    if(!(aftsTrack->InRPSelection())) continue;\r
8367    phi1=aftsTrack->Phi();\r
8368    for(Int_t i2=0;i2<nPrim;i2++)\r
8369    {\r
8370     if(i2==i1)continue;\r
8371     aftsTrack=anEvent->GetTrack(i2);\r
8372     if(!(aftsTrack->InRPSelection())) continue;\r
8373     phi2=aftsTrack->Phi();\r
8374     for(Int_t i3=0;i3<nPrim;i3++)\r
8375     {\r
8376      if(i3==i1||i3==i2)continue;\r
8377      aftsTrack=anEvent->GetTrack(i3);\r
8378      if(!(aftsTrack->InRPSelection())) continue;\r
8379      phi3=aftsTrack->Phi();\r
8380      for(Int_t i4=0;i4<nPrim;i4++)\r
8381      {\r
8382       if(i4==i1||i4==i2||i4==i3)continue;\r
8383       aftsTrack=anEvent->GetTrack(i4);\r
8384       if(!(aftsTrack->InRPSelection())) continue;\r
8385       phi4=aftsTrack->Phi();\r
8386       for(Int_t i5=0;i5<nPrim;i5++)\r
8387       {\r
8388        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;\r
8389        aftsTrack=anEvent->GetTrack(i5);\r
8390        if(!(aftsTrack->InRPSelection())) continue;\r
8391        phi5=aftsTrack->Phi();\r
8392        for(Int_t i6=0;i6<nPrim;i6++)\r
8393        {\r
8394         if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;\r
8395         aftsTrack=anEvent->GetTrack(i6);\r
8396         if(!(aftsTrack->InRPSelection())) continue;\r
8397         phi6=aftsTrack->Phi();\r
8398         for(Int_t i7=0;i7<nPrim;i7++)\r
8399         {\r
8400          if(i7==i1||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6)continue;\r
8401          aftsTrack=anEvent->GetTrack(i7);\r
8402          if(!(aftsTrack->InRPSelection())) continue;\r
8403          phi7=aftsTrack->Phi();\r
8404          for(Int_t i8=0;i8<nPrim;i8++)\r
8405          {\r
8406           if(i8==i1||i8==i2||i8==i3||i8==i4||i8==i5||i8==i6||i8==i7)continue;\r
8407           aftsTrack=anEvent->GetTrack(i8);\r
8408           if(!(aftsTrack->InRPSelection())) continue;\r
8409           phi8=aftsTrack->Phi();
8410           cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<" "<<i6<<" "<<i7<<" "<<i8<<"\r"<<flush;\r
8411           // fill the profile with 8-p correlation:   
8412           fIntFlowDirectCorrelations->Fill(30.,cos(n*phi1+n*phi2+n*phi3+n*phi4-n*phi5-n*phi6-n*phi7-n*phi8),1.); // <8>_{n,n,n,n|n,n,n,n}\r
8413          } // end of for(Int_t i8=0;i8<nPrim;i8++)\r
8414         } // end of for(Int_t i7=0;i7<nPrim;i7++) \r
8415        } // end of for(Int_t i6=0;i6<nPrim;i6++) \r
8416       } // end of for(Int_t i5=0;i5<nPrim;i5++)\r
8417      } // end of for(Int_t i4=0;i4<nPrim;i4++)  \r
8418     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8419    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8420   } // end of for(Int_t i1=0;i1<nPrim;i1++)
8421  } // end of if(nPrim>=8)
8422  
8423  cout<<endl;
8424
8425 } // end of AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoops(AliFlowEventSimple* anEvent)\r
8426 \r
8427
8428 //==================================================================================================================================
8429
8430
8431 void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrelations()\r
8432 {\r
8433  // Cross-check results for multiparticle correlations needed for int. flow: results from Q-vectors vs results from nested loops.\r
8434 \r cout<<endl;\r
8435  cout<<endl;\r
8436  cout<<"   *****************************************"<<endl;
8437  cout<<"   **** cross-checking the correlations ****"<<endl;\r
8438  cout<<"   ****       for integrated flow       ****"<<endl;\r
8439  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))
8440  {
8441   cout<<"   ****   (particle weights not used)   ****"<<endl;
8442  } else
8443    {
8444     cout<<"   ****     (particle weights used)     ****"<<endl;
8445    } \r
8446  cout<<"   *****************************************"<<endl;\r
8447  cout<<endl;\r
8448  cout<<endl;\r
8449
8450  Int_t ciMax = 32; // to be improved (removed eventually when I calculate 6th and 8th order with particle weights)
8451  
8452  if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)
8453  {
8454   ciMax = 11;
8455  }
8456 \r
8457  for(Int_t ci=1;ci<=ciMax;ci++)
8458  {
8459   if(strcmp((fIntFlowCorrelationsAllPro->GetXaxis())->GetBinLabel(ci), "") == 0) continue; // to be improved (access finalized histogram here)
8460   cout<<(fIntFlowCorrelationsAllPro->GetXaxis())->GetBinLabel(ci)<<":"<<endl; // to be improved (access finalized histogram here)
8461   cout<<"from Q-vectors    = "<<fIntFlowCorrelationsAllPro->GetBinContent(ci)<<endl; // to be improved (access finalized histogram here)\r
8462   cout<<"from nested loops = "<<fIntFlowDirectCorrelations->GetBinContent(ci)<<endl;\r
8463   cout<<endl;\r
8464  }
8465   \r
8466 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrelations()\r
8467 \r
8468 \r
8469 //================================================================================================================================\r
8470
8471
8472 void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrectionTermsForNUA()\r
8473 {\r
8474  // Cross-check results for corrections terms for non-uniform acceptance needed for int. flow: results from Q-vectors vs results from nested loops.\r
8475 \r cout<<endl;\r
8476  cout<<endl;\r
8477  cout<<"   *********************************************"<<endl;
8478  cout<<"   **** cross-checking the correction terms ****"<<endl;\r
8479  cout<<"   **** for non-uniform acceptance relevant ****"<<endl;\r
8480  cout<<"   ****         for integrated flow         ****"<<endl;\r
8481  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))
8482  {
8483   cout<<"   ****     (particle weights not used)     ****"<<endl;
8484  } else
8485    {
8486     cout<<"   ****       (particle weights used)       ****"<<endl;
8487    } \r
8488  cout<<"   *********************************************"<<endl;\r
8489  cout<<endl;\r
8490  cout<<endl;\r
8491 \r
8492  for(Int_t ci=1;ci<=10;ci++) // correction term index
8493  {
8494   for(Int_t sc=0;sc<2;sc++) // sin or cos term
8495   {
8496    if(strcmp((fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->GetBinLabel(ci), "") == 0) continue; // to be improved (access finalized histogram here)
8497    cout<<(fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->GetBinLabel(ci)<<":"<<endl; // to be improved (access finalized histogram here)
8498    cout<<"from Q-vectors    = "<<fIntFlowCorrectionTermsForNUAPro[sc]->GetBinContent(ci)<<endl; // to be improved (access finalized histogram here)\r
8499    cout<<"from nested loops = "<<fIntFlowDirectCorrectionTermsForNUA[sc]->GetBinContent(ci)<<endl;\r
8500    cout<<endl;\r
8501   } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos term
8502  } // end of for(Int_t ci=1;ci<=10;ci++) // correction term index
8503   \r
8504 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrectionTermsForNUA() 
8505 \r
8506
8507 //================================================================================================================================
8508
8509
8510 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent)\r
8511 {
8512  // Evaluate with nested loops multiparticle correlations for integrated flow (using the particle weights). 
8513 \r
8514  // Results are stored in profile fIntFlowDirectCorrelations. 
8515  // Remark 1: When particle weights are used the binning of fIntFlowDirectCorrelations is organized as follows:
8516  //
8517  //  1st bin: <2>_{1n|1n} = two1n1nW1W1 = <w1 w2 cos(n*(phi1-phi2))>\r
8518  //  2nd bin: <2>_{2n|2n} = two2n2nW2W2 = <w1^2 w2^2 cos(2n*(phi1-phi2))>\r
8519  //  3rd bin: <2>_{3n|3n} = two3n3nW3W3 = <w1^3 w2^3 cos(3n*(phi1-phi2))> \r
8520  //  4th bin: <2>_{4n|4n} = two4n4nW4W4 = <w1^4 w2^4 cos(4n*(phi1-phi2))>\r
8521  //  5th bin:           ----  EMPTY ----\r
8522  //  6th bin: <3>_{2n|1n,1n} = three2n1n1nW2W1W1 = <w1^2 w2 w3 cos(n*(2phi1-phi2-phi3))>\r
8523  //  7th bin: <3>_{3n|2n,1n} = ...\r
8524  //  8th bin: <3>_{4n|2n,2n} = ...\r
8525  //  9th bin: <3>_{4n|3n,1n} = ...
8526  // 10th bin:           ----  EMPTY ----\r
8527  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1nW1W1W1W1 = <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))>\r
8528  // 12th bin: <4>_{2n,1n|2n,1n} = ...\r
8529  // 13th bin: <4>_{2n,2n|2n,2n} = ...\r
8530  // 14th bin: <4>_{3n|1n,1n,1n} = ... \r
8531  // 15th bin: <4>_{3n,1n|3n,1n} = ...\r
8532  // 16th bin: <4>_{3n,1n|2n,2n} = ...\r
8533  // 17th bin: <4>_{4n|2n,1n,1n} = ... \r
8534  // 18th bin:           ----  EMPTY ----\r
8535  // 19th bin: <5>_{2n|1n,1n,1n,1n} = ...\r
8536  // 20th bin: <5>_{2n,2n|2n,1n,1n} = ...\r
8537  // 21st bin: <5>_{3n,1n|2n,1n,1n} = ...\r
8538  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = ...\r
8539  // 23rd bin:           ----  EMPTY ----\r
8540  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = ...\r
8541  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = ...\r
8542  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = ...\r
8543  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = ...\r
8544  // 28th bin:           ----  EMPTY ----\r
8545  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = ...\r
8546  // 30th bin:           ----  EMPTY ----\r
8547  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = ...\r
8548  
8549  // Remark 2: When particle weights are used there are some extra correlations. They are stored in 
8550  // fIntFlowExtraDirectCorrelations binning of which is organized as follows:
8551  
8552  // 1st bin: two1n1nW3W1 = <w1^3 w2 cos(n*(phi1-phi2))>\r
8553  // 2nd bin: two1n1nW1W1W2 = <w1 w2 w3^2 cos(n*(phi1-phi2))>  \r
8554  // ...
8555  
8556  Int_t nPrim = anEvent->NumberOfTracks(); \r
8557  AliFlowTrackSimple *aftsTrack = NULL;\r
8558  //Double_t phi1=0., phi2=0., phi3=0., phi4=0., phi5=0., phi6=0., phi7=0., phi8=0.;\r
8559  //Double_t wPhi1=1., wPhi2=1., wPhi3=1., wPhi4=1., wPhi5=1., wPhi6=1., wPhi7=1., wPhi8=1.;\r
8560  Double_t phi1=0., phi2=0., phi3=0., phi4=0.;\r
8561  Double_t wPhi1=1., wPhi2=1., wPhi3=1., wPhi4=1.;\r
8562  Int_t n = fHarmonic; \r Int_t eventNo = (Int_t)fAvMultiplicity->GetBinEntries(1); // to be improved (is this casting safe in general?)
8563  Double_t dMult = (*fSMpk)(0,0);
8564  cout<<endl;
8565  cout<<"Multiparticle correlations: Event number: "<<eventNo<<", multiplicity is "<<dMult<<endl;
8566  if(dMult<2)
8567  {
8568   cout<<"... skipping this event (multiplicity too low) ..."<<endl;
8569  } else if (dMult>fMaxAllowedMultiplicity)
8570    {
8571     cout<<"... skipping this event (multiplicity too high) ..."<<endl;
8572    } else 
8573      { 
8574       cout<<"... evaluating nested loops (using particle weights) ..."<<endl;\r
8575      } 
8576       
8577  // 2-particle correlations:       \r
8578  if(nPrim>=2 && nPrim<=fMaxAllowedMultiplicity)
8579  {\r
8580   // 2 nested loops multiparticle correlations using particle weights:       \r
8581   for(Int_t i1=0;i1<nPrim;i1++)\r
8582   {\r
8583    aftsTrack=anEvent->GetTrack(i1);\r
8584    if(!(aftsTrack->InRPSelection())) continue;\r
8585    phi1=aftsTrack->Phi();\r
8586    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));\r
8587    for(Int_t i2=0;i2<nPrim;i2++)\r
8588    {\r
8589     if(i2==i1)continue;\r
8590     aftsTrack=anEvent->GetTrack(i2);\r
8591     if(!(aftsTrack->InRPSelection())) continue;\r
8592     phi2=aftsTrack->Phi();\r
8593     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));   \r
8594     if(nPrim==2) cout<<i1<<" "<<i2<<"\r"<<flush;\r
8595     // 2-p correlations using particle weights:\r
8596     if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(0.5,cos(n*(phi1-phi2)),wPhi1*wPhi2);                  // <w1   w2   cos( n*(phi1-phi2))>\r
8597     if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(1.5,cos(2.*n*(phi1-phi2)),pow(wPhi1,2)*pow(wPhi2,2)); // <w1^2 w2^2 cos(2n*(phi1-phi2))>\r
8598     if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(2.5,cos(3.*n*(phi1-phi2)),pow(wPhi1,3)*pow(wPhi2,3)); // <w1^3 w2^3 cos(3n*(phi1-phi2))>\r
8599     if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(3.5,cos(4.*n*(phi1-phi2)),pow(wPhi1,4)*pow(wPhi2,4)); // <w1^4 w2^4 cos(4n*(phi1-phi2))> \r
8600     // extra correlations: 
8601     // 2-p extra correlations (do not appear if particle weights are not used):
8602     if(fUsePhiWeights) fIntFlowExtraDirectCorrelations->Fill(0.5,cos(n*(phi1-phi2)),pow(wPhi1,3)*wPhi2); // <w1^3 w2 cos(n*(phi1-phi2))>
8603     // ...\r
8604    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8605   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8606  } // end of if(nPrim>=2)
8607
8608  if(nPrim>=3 && nPrim<=fMaxAllowedMultiplicity)
8609  { \r
8610   // 3 nested loops multiparticle correlations using particle weights:       \r
8611   for(Int_t i1=0;i1<nPrim;i1++)\r
8612   {\r
8613    aftsTrack=anEvent->GetTrack(i1);\r
8614    if(!(aftsTrack->InRPSelection())) continue;\r
8615    phi1=aftsTrack->Phi();\r
8616    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));\r
8617    for(Int_t i2=0;i2<nPrim;i2++)\r
8618    {\r
8619     if(i2==i1)continue;\r
8620     aftsTrack=anEvent->GetTrack(i2);\r
8621     if(!(aftsTrack->InRPSelection())) continue;\r
8622     phi2=aftsTrack->Phi();\r
8623     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));\r
8624     for(Int_t i3=0;i3<nPrim;i3++)\r
8625     {\r
8626      if(i3==i1||i3==i2)continue;\r
8627      aftsTrack=anEvent->GetTrack(i3);\r
8628      if(!(aftsTrack->InRPSelection())) continue;\r
8629      phi3=aftsTrack->Phi();\r
8630      if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));
8631      if(nPrim==3) cout<<i1<<" "<<i2<<" "<<i3<<"\r"<<flush;\r
8632      // 3-p correlations using particle weights:\r
8633      if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(5.5,cos(2.*n*phi1-n*(phi2+phi3)),pow(wPhi1,2)*wPhi2*wPhi3); // <w1^2 w2 w3 cos(n*(2phi1-phi2-phi3))>\r
8634      // ...
8635      // extra correlations: 
8636      // 2-p extra correlations (do not appear if particle weights are not used):
8637       if(fUsePhiWeights) fIntFlowExtraDirectCorrelations->Fill(1.5,cos(n*(phi1-phi2)),wPhi1*wPhi2*pow(wPhi3,2)); // <w1 w2 w3^2 cos(n*(phi1-phi2))>\r
8638      // ...\r
8639      // 3-p extra correlations (do not appear if particle weights are not used):
8640      // ...
8641     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8642    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8643   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8644  } // end of if(nPrim>=3)
8645  \r
8646  if(nPrim>=4 && nPrim<=fMaxAllowedMultiplicity)
8647  {
8648   // 4 nested loops multiparticle correlations using particle weights:       \r
8649   for(Int_t i1=0;i1<nPrim;i1++)\r
8650   {\r
8651    aftsTrack=anEvent->GetTrack(i1);\r
8652    if(!(aftsTrack->InRPSelection())) continue;\r
8653    phi1=aftsTrack->Phi();\r
8654    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));\r
8655    for(Int_t i2=0;i2<nPrim;i2++)\r
8656    {\r
8657     if(i2==i1)continue;\r
8658     aftsTrack=anEvent->GetTrack(i2);\r
8659     if(!(aftsTrack->InRPSelection())) continue;\r
8660     phi2=aftsTrack->Phi();\r
8661     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));\r
8662     for(Int_t i3=0;i3<nPrim;i3++)\r
8663     {\r
8664      if(i3==i1||i3==i2)continue;\r
8665      aftsTrack=anEvent->GetTrack(i3);\r
8666      if(!(aftsTrack->InRPSelection())) continue;\r
8667      phi3=aftsTrack->Phi();\r
8668      if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));\r
8669      for(Int_t i4=0;i4<nPrim;i4++)\r
8670      {\r
8671       if(i4==i1||i4==i2||i4==i3)continue;\r
8672       aftsTrack=anEvent->GetTrack(i4);\r
8673       if(!(aftsTrack->InRPSelection())) continue;\r
8674       phi4=aftsTrack->Phi();\r
8675       if(fUsePhiWeights && fPhiWeights) wPhi4 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi4*fnBinsPhi/TMath::TwoPi())));\r
8676       if(nPrim>=4) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<"\r"<<flush; // to be improved (replace eventually this if statement with if(nPrim==4))
8677       // 4-p correlations using particle weights:\r
8678       if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(10.5,cos(n*phi1+n*phi2-n*phi3-n*phi4),wPhi1*wPhi2*wPhi3*wPhi4); \r
8679       // extra correlations: 
8680       // 2-p extra correlations (do not appear if particle weights are not used):
8681       // ...
8682       // 3-p extra correlations (do not appear if particle weights are not used):
8683       // ...
8684       // 4-p extra correlations (do not appear if particle weights are not used):
8685       // ...\r
8686      } // end of for(Int_t i4=0;i4<nPrim;i4++) \r
8687     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8688    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8689   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8690  } // end of if(nPrim>=4)
8691
8692  cout<<endl; \r
8693 \r
8694 } // end of void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent)\r
8695
8696
8697 //================================================================================================================================\r
8698
8699
8700 void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowExtraCorrelations()
8701 {
8702  // Cross-check results for extra multiparticle correlations needed for int. flow 
8703  // which appear only when particle weights are used: results from Q-vectors vs results from nested loops.\r
8704 \r cout<<endl;\r
8705  cout<<endl;\r
8706  cout<<"   ***********************************************"<<endl;\r
8707  cout<<"   **** cross-checking the extra correlations ****"<<endl;\r
8708  cout<<"   ****          for integrated flow          ****"<<endl;\r
8709  cout<<"   ***********************************************"<<endl;\r
8710  cout<<endl;\r
8711  cout<<endl;\r
8712  
8713  for(Int_t eci=1;eci<=2;eci++) // to be improved (increased eciMax eventually when I calculate 6th and 8th)
8714  {
8715   if(strcmp((fIntFlowExtraCorrelationsPro->GetXaxis())->GetBinLabel(eci), "") == 0) continue;
8716   cout<<(fIntFlowExtraCorrelationsPro->GetXaxis())->GetBinLabel(eci)<<":"<<endl;
8717   cout<<"from Q-vectors    = "<<fIntFlowExtraCorrelationsPro->GetBinContent(eci)<<endl;\r
8718   cout<<"from nested loops = "<<fIntFlowExtraDirectCorrelations->GetBinContent(eci)<<endl;\r
8719   cout<<endl;\r
8720  }
8721
8722 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowExtraCorrelations()
8723
8724
8725 //================================================================================================================================\r
8726
8727
8728 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrectionsForNUAWithNestedLoops(AliFlowEventSimple* anEvent)
8729 {
8730  // Evaluate with nested loops correction terms for non-uniform acceptance relevant for NONAME integrated flow (to be improved (name)).
8731  //
8732  // Remark: Both sin and cos correction terms are calculated in this method. Sin terms are stored in fIntFlowDirectCorrectionTermsForNUA[0],
8733  // and cos terms in fIntFlowCorrectionTermsForNUAPro[sc]fIntFlowDirectCorrectionTermsForNUA[1]. Binning of fIntFlowDirectCorrectionTermsForNUA[sc] is organized as follows 
8734  // (sc stands for either sin or cos):
8735  
8736  //  1st bin: <<sc(n*(phi1))>> \r
8737  //  2nd bin: <<sc(n*(phi1+phi2))>> \r
8738  //  3rd bin: <<sc(n*(phi1-phi2-phi3))>>\r
8739  //  ...\r
8740  
8741  Int_t nPrim = anEvent->NumberOfTracks(); \r
8742  AliFlowTrackSimple *aftsTrack = NULL;\r
8743  Double_t phi1=0., phi2=0., phi3=0.;\r
8744  Int_t n = fHarmonic; \r Int_t eventNo = (Int_t)fAvMultiplicity->GetBinEntries(1); // to be improved (is this casting safe in general?)
8745  Double_t dMult = (*fSMpk)(0,0);
8746  cout<<endl;
8747  cout<<"Correction terms for non-uniform acceptance: Event number: "<<eventNo<<", multiplicity is "<<dMult<<endl;
8748  if(dMult<1)
8749  {
8750   cout<<"... skipping this event (multiplicity too low) ..."<<endl;
8751  } else if (dMult>fMaxAllowedMultiplicity)
8752    {
8753     cout<<"... skipping this event (multiplicity too high) ..."<<endl;
8754    } else 
8755      { 
8756       cout<<"... evaluating nested loops (without using particle weights)..."<<endl;\r
8757      }
8758  
8759  if(nPrim>=1 && nPrim<=fMaxAllowedMultiplicity)
8760  {
8761   // 1-particle correction terms for non-uniform acceptance:       \r
8762   for(Int_t i1=0;i1<nPrim;i1++)\r
8763   {\r
8764    aftsTrack=anEvent->GetTrack(i1);\r
8765    if(!(aftsTrack->InRPSelection())) continue;\r
8766    phi1=aftsTrack->Phi();\r
8767    if(nPrim==1) cout<<i1<<"\r"<<flush;\r
8768    // sin terms:
8769    fIntFlowDirectCorrectionTermsForNUA[0]->Fill(0.5,sin(n*phi1),1.); // <sin(n*phi1)>  \r
8770    // cos terms:
8771    fIntFlowDirectCorrectionTermsForNUA[1]->Fill(0.5,cos(n*phi1),1.); // <cos(n*phi1)>\r
8772   } // end of for(Int_t i1=0;i1<nPrim;i1++)
8773  } // end of if(nPrim>=1) 
8774   
8775  if(nPrim>=2 && nPrim<=fMaxAllowedMultiplicity)
8776  {
8777   // 2-particle correction terms for non-uniform acceptance:       \r
8778   for(Int_t i1=0;i1<nPrim;i1++)\r
8779   {\r
8780    aftsTrack=anEvent->GetTrack(i1);\r
8781    if(!(aftsTrack->InRPSelection())) continue;\r
8782    phi1=aftsTrack->Phi();  \r
8783    for(Int_t i2=0;i2<nPrim;i2++)\r
8784    {\r
8785     if(i2==i1)continue;\r
8786     aftsTrack=anEvent->GetTrack(i2);\r
8787     if(!(aftsTrack->InRPSelection())) continue;\r
8788     phi2=aftsTrack->Phi();\r
8789     if(nPrim==2) cout<<i1<<" "<<i2<<"\r"<<flush;\r
8790     // sin terms:
8791     fIntFlowDirectCorrectionTermsForNUA[0]->Fill(1.5,sin(n*(phi1+phi2)),1.); // <<sin(n*(phi1+phi2))>>\r
8792     // cos terms:
8793     fIntFlowDirectCorrectionTermsForNUA[1]->Fill(1.5,cos(n*(phi1+phi2)),1.); // <<cos(n*(phi1+phi2))>>\r
8794    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8795   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8796  } // end of if(nPrim>=2)
8797
8798  if(nPrim>=3 && nPrim<=fMaxAllowedMultiplicity)
8799  {
8800   // 3-particle correction terms for non-uniform acceptance:       \r
8801   for(Int_t i1=0;i1<nPrim;i1++)\r
8802   {\r
8803    aftsTrack=anEvent->GetTrack(i1);\r
8804    if(!(aftsTrack->InRPSelection())) continue;\r
8805    phi1=aftsTrack->Phi();\r
8806    for(Int_t i2=0;i2<nPrim;i2++)\r
8807    {\r
8808     if(i2==i1)continue;\r
8809     aftsTrack=anEvent->GetTrack(i2);\r
8810     if(!(aftsTrack->InRPSelection())) continue;\r
8811     phi2=aftsTrack->Phi();\r
8812     for(Int_t i3=0;i3<nPrim;i3++)\r
8813     {\r
8814      if(i3==i1||i3==i2)continue;\r
8815      aftsTrack=anEvent->GetTrack(i3);\r
8816      if(!(aftsTrack->InRPSelection())) continue;\r
8817      phi3=aftsTrack->Phi();\r
8818      if(nPrim>=3) cout<<i1<<" "<<i2<<" "<<i3<<"\r"<<flush; // to be improved (eventually I will change this if statement)\r
8819      // sin terms:
8820      fIntFlowDirectCorrectionTermsForNUA[0]->Fill(2.5,sin(n*(phi1-phi2-phi3)),1.); // <<sin(n*(phi1-phi2-phi3))>>\r
8821      // cos terms:\r
8822      fIntFlowDirectCorrectionTermsForNUA[1]->Fill(2.5,cos(n*(phi1-phi2-phi3)),1.); // <<cos(n*(phi1-phi2-phi3))>>\r
8823     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8824    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8825   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8826  } // end of if(nPrim>=3)
8827
8828  cout<<endl;
8829
8830 } // end of void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrectionsForNUAWithNestedLoops(AliFlowEventSimple* anEvent)
8831
8832
8833 //================================================================================================================================\r
8834
8835
8836 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoops(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)\r
8837 {\r
8838  // Evaluate reduced correlations with nested loops without using the particle weights.\r
8839  
8840  // Remark 1: Reduced correlations are evaluated in pt bin number fCrossCheckInPtBinNo and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.
8841  // Remark 2: Results are stored in 1 bin profiles fDiffFlowDirectCorrelations[t][pe][ci], where indices runs as follows:
8842  //           [0=RP,1=POI][0=Pt,1=Eta][0=<2'>,1=<4'>,2=<6'>,3=<8'>] 
8843  // Remark 3: <2'> = <cos(n*(psi1-phi2))>\r
8844  //           <4'> = <cos(n*(psi1+phi2-phi3-phi4))>\r
8845  // ...
8846  
8847  Int_t typeFlag = -1;\r
8848  Int_t ptEtaFlag = -1;\r
8849  if(type == "RP")\r
8850  {\r
8851   typeFlag = 0;\r
8852  } else if(type == "POI")\r
8853    {\r
8854     typeFlag = 1;\r
8855    }      \r
8856  if(ptOrEta == "Pt")\r
8857  {\r
8858   ptEtaFlag = 0;\r
8859  } else if(ptOrEta == "Eta")\r
8860    {\r
8861     ptEtaFlag = 1;\r
8862    } \r
8863  // shortcuts:\r
8864  Int_t t = typeFlag;\r
8865  Int_t pe = ptEtaFlag;\r
8866       \r
8867  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
8868  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
8869  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
8870  
8871  Int_t nPrim = anEvent->NumberOfTracks(); \r
8872  AliFlowTrackSimple *aftsTrack = NULL;\r
8873  \r
8874  Double_t psi1=0., phi2=0., phi3=0., phi4=0.;// phi5=0., phi6=0., phi7=0., phi8=0.;\r
8875  \r
8876  Int_t n = fHarmonic; \r
8877  \r
8878  // 2'-particle correlations:\r
8879  for(Int_t i1=0;i1<nPrim;i1++)\r
8880  {\r
8881   aftsTrack=anEvent->GetTrack(i1);\r
8882   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
8883   if(ptOrEta == "Pt")
8884   { \r
8885    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;\r
8886   } else if (ptOrEta == "Eta")
8887     {
8888      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
8889     }
8890   psi1=aftsTrack->Phi(); \r
8891   for(Int_t i2=0;i2<nPrim;i2++)\r
8892   {\r
8893    if(i2==i1)continue;\r
8894    aftsTrack=anEvent->GetTrack(i2);\r
8895    // RP condition (!(first) particle in the correlator must be RP):\r
8896    if(!(aftsTrack->InRPSelection()))continue;\r
8897    phi2=aftsTrack->Phi();   \r
8898    // 2'-particle correlations: 
8899    fDiffFlowDirectCorrelations[t][pe][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(1.*n*(psi1-phi2)),1.); // <cos(n*(psi1-phi2))  \r
8900   }//end of for(Int_t i2=0;i2<nPrim;i2++)\r
8901  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
8902  \r
8903  /*\r
8904  \r
8905  // 3'-particle correlations:\r
8906  for(Int_t i1=0;i1<nPrim;i1++)\r
8907  {\r
8908   aftsTrack=anEvent->GetTrack(i1);\r
8909   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
8910   if(ptOrEta == "Pt")
8911   { \r
8912    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;\r
8913   } else if (ptOrEta == "Eta")
8914     {
8915      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
8916     }
8917   psi1=aftsTrack->Phi();\r
8918   for(Int_t i2=0;i2<nPrim;i2++)\r
8919   {\r
8920    if(i2==i1)continue;\r
8921    aftsTrack=anEvent->GetTrack(i2);\r
8922    // RP condition (!(first) particle in the correlator must be RP):
8923    if(!(aftsTrack->InRPSelection())) continue;\r
8924    phi2=aftsTrack->Phi();\r
8925    for(Int_t i3=0;i3<nPrim;i3++)\r
8926    {\r
8927     if(i3==i1||i3==i2)continue;\r
8928     aftsTrack=anEvent->GetTrack(i3);\r
8929     // RP condition (!(first) particle in the correlator must be RP):
8930     if(!(aftsTrack->InRPSelection())) continue;\r
8931     phi3=aftsTrack->Phi();\r
8932     // to be improved : where to store it? ->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(2.*phi1-phi2-phi3)),1.); // <w1 w2 w3 cos(n(2psi1-phi2-phi3))> 
8933    }//end of for(Int_t i3=0;i3<nPrim;i3++)  \r
8934   }//end of for(Int_t i2=0;i2<nPrim;i2++)  \r
8935  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
8936  
8937  */
8938  
8939  // 4'-particle correlations:\r
8940  for(Int_t i1=0;i1<nPrim;i1++)\r
8941  {\r
8942   aftsTrack=anEvent->GetTrack(i1);\r
8943   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
8944   if(ptOrEta == "Pt")
8945   { \r
8946    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;\r
8947   } else if (ptOrEta == "Eta")
8948     {
8949      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
8950     }
8951   psi1=aftsTrack->Phi();\r
8952   for(Int_t i2=0;i2<nPrim;i2++)\r
8953   {\r
8954    if(i2==i1) continue;\r
8955    aftsTrack=anEvent->GetTrack(i2);\r
8956    // RP condition (!(first) particle in the correlator must be RP): \r
8957    if(!(aftsTrack->InRPSelection())) continue;\r
8958    phi2=aftsTrack->Phi();\r
8959    for(Int_t i3=0;i3<nPrim;i3++)\r
8960    { \r
8961     if(i3==i1||i3==i2) continue;\r
8962     aftsTrack=anEvent->GetTrack(i3);\r
8963     // RP condition (!(first) particle in the correlator must be RP):\r
8964     if(!(aftsTrack->InRPSelection())) continue;\r
8965     phi3=aftsTrack->Phi();\r
8966     for(Int_t i4=0;i4<nPrim;i4++)\r
8967     {\r
8968      if(i4==i1||i4==i2||i4==i3) continue;\r
8969      aftsTrack=anEvent->GetTrack(i4);\r
8970      // RP condition (!(first) particle in the correlator must be RP):\r
8971      if(!(aftsTrack->InRPSelection())) continue;  \r
8972      phi4=aftsTrack->Phi();\r
8973      // 4'-particle correlations:\r
8974      fDiffFlowDirectCorrelations[t][pe][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2-phi3-phi4)),1.); // <cos(n(psi1+phi2-phi3-phi4))>     \r    }//end of for(Int_t i4=0;i4<nPrim;i4++)\r
8975    }//end of for(Int_t i3=0;i3<nPrim;i3++)\r
8976   }//end of for(Int_t i2=0;i2<nPrim;i2++) \r
8977  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
8978       \r \r
8979 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoops(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)\r
8980 \r
8981 \r
8982 //================================================================================================================================\r
8983 \r
8984 \r
8985 void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrelations(TString type, TString ptOrEta)\r
8986 {\r
8987  // Compare correlations needed for diff. flow calculated with nested loops and those calculated from Q-vectors\r
8988  
8989  Int_t typeFlag = -1;\r
8990  Int_t ptEtaFlag = -1;\r
8991  if(type == "RP")\r
8992  {\r
8993   typeFlag = 0;\r
8994  } else if(type == "POI")\r
8995    {\r
8996     typeFlag = 1;\r
8997    }      \r
8998  if(ptOrEta == "Pt")\r
8999  {\r
9000   ptEtaFlag = 0;\r
9001  } else if(ptOrEta == "Eta")\r
9002    {\r
9003     ptEtaFlag = 1;\r
9004    } \r
9005  // shortcuts:\r
9006  Int_t t = typeFlag;\r
9007  Int_t pe = ptEtaFlag;\r
9008       
9009  TString RPorPOIString[2] = {"RP ","POI"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) \r
9010  TString PtOrEtaString[2] = {"pt","eta"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) \r
9011  TString reducedCorrelations[4] = {"<<cos(n(psi1-phi2))>>","<<cos(n(psi1+phi2-phi3-phi4))>>","",""}; // to be improved (access this from pro or hist)\r
9012  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
9013  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
9014  
9015  Int_t crossCheckInPtEtaBinNo[2] = {fCrossCheckInPtBinNo,fCrossCheckInEtaBinNo};
9016  
9017
9018  cout<<endl;\r
9019  cout<<"   *****************************************"<<endl;\r
9020  cout<<"   **** cross-checking the correlations ****"<<endl;\r
9021  cout<<"   ****      for differential flow      ****"<<endl;\r
9022  cout<<"   ****               "<<RPorPOIString[t]<<"               ****"<<endl;\r
9023  cout<<"   *****************************************"<<endl; 
9024  cout<<endl;
9025  cout<<"           "<<PtOrEtaString[pe]<<" bin: "<<lowerPtEtaEdge[pe]<<" <= "<<PtOrEtaString[pe]<<" < "<<upperPtEtaEdge[pe]<<endl;
9026  cout<<endl;\r
9027  
9028  for(Int_t rci=0;rci<2;rci++) // to be improved (calculate 6th and 8th order)
9029  {
9030   cout<<"      "<<reducedCorrelations[rci].Data()<<":"<<endl;
9031   cout<<"      from Q-vectors    = "<<fDiffFlowCorrelationsPro[t][pe][rci]->GetBinContent(crossCheckInPtEtaBinNo[pe])<<endl;\r
9032   cout<<"      from nested loops = "<<fDiffFlowDirectCorrelations[t][pe][rci]->GetBinContent(1)<<endl;\r
9033   cout<<endl;  \r
9034  } // end of for(Int_t rci=0;rci<4;rci++)
9035        \r
9036 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrelations(TString type, TString ptOrEta)\r
9037
9038
9039 //================================================================================================================================\r
9040
9041
9042 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)\r
9043 {
9044  // Evaluate reduced correlations with nested loops without using the particle weights.\r
9045  
9046  // Remark 1: Reduced correlations are evaluated in pt bin number fCrossCheckInPtBinNo and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.
9047  // Remark 2: Results are stored in 1 bin profiles fDiffFlowDirectCorrelations[t][pe][ci], where indices runs as follows:
9048  //           [0=RP,1=POI][0=Pt,1=Eta][0=<2'>,1=<4'>,2=<6'>,3=<8'>] 
9049  // Remark 3: <2'> = <w2 cos(n*(psi1-phi2))>\r
9050  //           <4'> = <w2 w3 w4 cos(n*(psi1+phi2-phi3-phi4))>\r
9051  // ...
9052   
9053  Int_t typeFlag = -1;\r
9054  Int_t ptEtaFlag = -1;\r
9055  if(type == "RP")\r
9056  {\r
9057   typeFlag = 0;\r
9058  } else if(type == "POI")\r
9059    {\r
9060     typeFlag = 1;\r
9061    }      \r
9062  if(ptOrEta == "Pt")\r
9063  {\r
9064   ptEtaFlag = 0;\r
9065  } else if(ptOrEta == "Eta")\r
9066    {\r
9067     ptEtaFlag = 1;\r
9068    } \r
9069  // shortcuts:\r
9070  Int_t t = typeFlag;\r
9071  Int_t pe = ptEtaFlag;\r
9072       \r
9073  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
9074  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
9075  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
9076  
9077  Int_t nPrim = anEvent->NumberOfTracks(); \r
9078  AliFlowTrackSimple *aftsTrack = NULL;\r
9079  \r
9080  Double_t psi1=0., phi2=0., phi3=0., phi4=0.;// phi5=0., phi6=0., phi7=0., phi8=0.;\r
9081  Double_t wPhi2=1., wPhi3=1., wPhi4=1.;// wPhi5=1., wPhi6=1., wPhi7=1., wPhi8=1.;\r
9082  \r
9083  Int_t n = fHarmonic; \r
9084  \r
9085  // 2'-particle correlations:\r
9086  for(Int_t i1=0;i1<nPrim;i1++)\r
9087  {\r
9088   aftsTrack=anEvent->GetTrack(i1);\r
9089   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
9090   if(ptOrEta == "Pt")
9091   { \r
9092    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;\r
9093   } else if (ptOrEta == "Eta")
9094     {
9095      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;    
9096     }
9097   psi1=aftsTrack->Phi(); \r
9098   for(Int_t i2=0;i2<nPrim;i2++)\r
9099   {\r
9100    if(i2==i1) continue;\r
9101    aftsTrack=anEvent->GetTrack(i2);\r
9102    // RP condition (!(first) particle in the correlator must be RP):\r
9103    if(!(aftsTrack->InRPSelection())) continue;\r
9104    phi2=aftsTrack->Phi();   \r
9105    if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));\r
9106    // 2'-particle correlations: 
9107    fDiffFlowDirectCorrelations[t][pe][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(1.*n*(psi1-phi2)),wPhi2); // <w2 cos(n*(psi1-phi2))  \r
9108   }//end of for(Int_t i2=0;i2<nPrim;i2++)\r
9109  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
9110  \r
9111  // 4'-particle correlations:\r
9112  for(Int_t i1=0;i1<nPrim;i1++)\r
9113  {\r
9114   aftsTrack=anEvent->GetTrack(i1);\r
9115   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
9116   if(ptOrEta == "Pt")
9117   { \r
9118    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;\r
9119   } else if (ptOrEta == "Eta")
9120     {
9121      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;    
9122     }
9123   psi1=aftsTrack->Phi();\r
9124   for(Int_t i2=0;i2<nPrim;i2++)\r
9125   {\r
9126    if(i2==i1) continue;\r
9127    aftsTrack=anEvent->GetTrack(i2);\r
9128    // RP condition (!(first) particle in the correlator must be RP): \r
9129    if(!(aftsTrack->InRPSelection())) continue;\r
9130    phi2=aftsTrack->Phi();\r
9131    if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));\r
9132    for(Int_t i3=0;i3<nPrim;i3++)\r
9133    { \r
9134     if(i3==i1||i3==i2) continue;\r
9135     aftsTrack=anEvent->GetTrack(i3);\r
9136     // RP condition (!(first) particle in the correlator must be RP):\r
9137     if(!(aftsTrack->InRPSelection())) continue;\r
9138     phi3=aftsTrack->Phi();\r
9139     if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));\r
9140     for(Int_t i4=0;i4<nPrim;i4++)\r
9141     {\r
9142      if(i4==i1||i4==i2||i4==i3) continue;\r
9143      aftsTrack=anEvent->GetTrack(i4);\r
9144      // RP condition (!(first) particle in the correlator must be RP):\r
9145      if(!(aftsTrack->InRPSelection())) continue;  \r
9146      phi4=aftsTrack->Phi();\r
9147      if(fUsePhiWeights && fPhiWeights) wPhi4 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi4*fnBinsPhi/TMath::TwoPi())));\r
9148      // 4'-particle correlations <w2 w3 w4 cos(n(psi1+phi2-phi3-phi4))>:\r
9149      fDiffFlowDirectCorrelations[t][pe][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2-phi3-phi4)),wPhi2*wPhi3*wPhi4); \r    }//end of for(Int_t i4=0;i4<nPrim;i4++)\r
9150    }//end of for(Int_t i3=0;i3<nPrim;i3++)\r
9151   }//end of for(Int_t i2=0;i2<nPrim;i2++) \r
9152  }//end of for(Int_t i1=0;i1<nPrim;i1++)      \r \r
9153 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)\r
9154
9155
9156 //================================================================================================================================\r
9157
9158    
9159 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)
9160 {
9161  // Evaluate with nested loops correction terms for non-uniform acceptance (both sin and cos terms) relevant for differential flow.
9162  
9163  // Remark 1: Reduced correction terms for non-uniform acceptance are evaluated in pt bin number fCrossCheckInPtBinNo 
9164  //           and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.
9165  // Remark 2: Results are stored in 1 bin profiles fDiffFlowDirectCorrections[t][pe][sc][cti], where first three indices runs as: 
9166  //           [0=RP,1=POI][0=Pt,1=Eta][0=sin terms,1=cos terms], whilst the cti (correction term index) runs as follows: \r
9167  //  cti: 
9168  //    0: <<sc n(psi1)>>\r
9169  //    1: <<sc n(psi1+phi2)>> \r
9170  //    2: <<sc n(psi1+phi2-phi3)>>\r
9171  //    3: <<sc n(psi1-phi2-phi3)>>\r
9172  //    4:\r
9173  //    5:\r
9174  //    6:\r
9175   
9176  Int_t typeFlag = -1;\r
9177  Int_t ptEtaFlag = -1;\r
9178  if(type == "RP")\r
9179  {\r
9180   typeFlag = 0;\r
9181  } else if(type == "POI")\r
9182    {\r
9183     typeFlag = 1;\r
9184    }      \r
9185  if(ptOrEta == "Pt")\r
9186  {\r
9187   ptEtaFlag = 0;\r
9188  } else if(ptOrEta == "Eta")\r
9189    {\r
9190     ptEtaFlag = 1;\r
9191    } \r
9192  // shortcuts:\r
9193  Int_t t = typeFlag;\r
9194  Int_t pe = ptEtaFlag;\r
9195       \r
9196  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
9197  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
9198  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
9199  
9200  Int_t nPrim = anEvent->NumberOfTracks(); \r
9201  AliFlowTrackSimple *aftsTrack = NULL;\r
9202  \r
9203  Double_t psi1=0., phi2=0., phi3=0.;// phi4=0.;// phi5=0., phi6=0., phi7=0., phi8=0.;\r
9204  \r
9205  Int_t n = fHarmonic; \r
9206  \r
9207  // 1-particle correction terms:\r
9208  for(Int_t i1=0;i1<nPrim;i1++)\r
9209  {\r
9210   aftsTrack=anEvent->GetTrack(i1);\r
9211   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
9212   if(ptOrEta == "Pt")
9213   { \r
9214    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;\r
9215   } else if (ptOrEta == "Eta")
9216     {
9217      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;    
9218     }
9219   psi1=aftsTrack->Phi(); \r
9220   // sin terms: 
9221   fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*psi1),1.); // <<sin(n*(psi1))>>  \r
9222   // cos terms: 
9223   fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*psi1),1.); // <<cos(n*(psi1))>>  \r
9224  }//end of for(Int_t i1=0;i1<nPrim;i1++)
9225    
9226  // 2-particle correction terms:\r
9227  for(Int_t i1=0;i1<nPrim;i1++)\r
9228  {\r
9229   aftsTrack=anEvent->GetTrack(i1);\r
9230   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
9231   if(ptOrEta == "Pt")
9232   { \r
9233    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;\r
9234   } else if (ptOrEta == "Eta")
9235     {
9236      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;    
9237     }
9238   psi1=aftsTrack->Phi(); \r
9239   for(Int_t i2=0;i2<nPrim;i2++)\r
9240   {\r
9241    if(i2==i1) continue;\r
9242    aftsTrack=anEvent->GetTrack(i2);\r
9243    // RP condition (!(first) particle in the correlator must be RP):\r
9244    if(!(aftsTrack->InRPSelection())) continue;\r
9245    phi2=aftsTrack->Phi();   \r
9246    // sin terms: 
9247    fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1+phi2)),1.); // <<sin(n*(psi1+phi2))>>  \r
9248    // cos terms: 
9249    fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2)),1.); // <<cos(n*(psi1+phi2))>>  \r
9250   }//end of for(Int_t i2=0;i2<nPrim;i2++)\r
9251  }//end of for(Int_t i1=0;i1<nPrim;i1++)   
9252  
9253  // 3-particle correction terms:\r
9254  for(Int_t i1=0;i1<nPrim;i1++)\r
9255  {\r
9256   aftsTrack=anEvent->GetTrack(i1);\r
9257   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
9258   if(ptOrEta == "Pt")
9259   { \r
9260    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;\r
9261   } else if (ptOrEta == "Eta")
9262     {
9263      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
9264     }
9265   psi1=aftsTrack->Phi();\r
9266   for(Int_t i2=0;i2<nPrim;i2++)\r
9267   {\r
9268    if(i2==i1) continue;\r
9269    aftsTrack=anEvent->GetTrack(i2);\r
9270    // RP condition (!(first) particle in the correlator must be RP):
9271    if(!(aftsTrack->InRPSelection())) continue;\r
9272    phi2=aftsTrack->Phi();\r
9273    for(Int_t i3=0;i3<nPrim;i3++)\r
9274    {\r
9275     if(i3==i1||i3==i2) continue;\r
9276     aftsTrack=anEvent->GetTrack(i3);\r
9277     // RP condition (!(first) particle in the correlator must be RP):
9278     if(!(aftsTrack->InRPSelection())) continue;\r
9279     phi3=aftsTrack->Phi();\r
9280     // sin terms: 
9281     fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][2]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1+phi2-phi3)),1.); // <<sin(n*(psi1+phi2-phi3))>>  \r
9282     fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][3]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1-phi2-phi3)),1.); // <<sin(n*(psi1-phi2-phi3))>>  \r
9283     // cos terms: 
9284     fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][2]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2-phi3)),1.); // <<cos(n*(psi1+phi2-phi3))>>  \r
9285     fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][3]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1-phi2-phi3)),1.); // <<cos(n*(psi1-phi2-phi3))>>  \r
9286    }//end of for(Int_t i3=0;i3<nPrim;i3++)  \r
9287   }//end of for(Int_t i2=0;i2<nPrim;i2++)  \r
9288  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
9289    
9290 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)
9291
9292
9293 //================================================================================================================================\r
9294
9295
9296 void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrectionTermsForNUA(TString type, TString ptOrEta)
9297 {
9298  // Compare corrections temrs for non-uniform acceptance needed for diff. flow calculated with nested loops and those calculated from Q-vectors\r
9299  
9300  Int_t typeFlag = -1;\r
9301  Int_t ptEtaFlag = -1;\r
9302  if(type == "RP")\r
9303  {\r
9304   typeFlag = 0;\r
9305  } else if(type == "POI")\r
9306    {\r
9307     typeFlag = 1;\r
9308    }      \r
9309  if(ptOrEta == "Pt")\r
9310  {\r
9311   ptEtaFlag = 0;\r
9312  } else if(ptOrEta == "Eta")\r
9313    {\r
9314     ptEtaFlag = 1;\r
9315    } \r
9316  // shortcuts:\r
9317  Int_t t = typeFlag;\r
9318  Int_t pe = ptEtaFlag;\r
9319       
9320  TString RPorPOIString[2] = {"RP ","POI"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) \r
9321  TString PtOrEtaString[2] = {"pt","eta"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) 
9322  //TString sinCosFlag[2] = {"sin","cos"}; // to be improved (eventually promote to data member)\r
9323  TString reducedCorrectionSinTerms[4] = {"<<sin(n(psi1))>>","<<sin(n(psi1+phi2))>>","<<sin(n*(psi1+phi2-phi3))>>","<<sin(n*(psi1-phi2-phi3))>>"}; // to be improved (access this from pro or hist)\r
9324  TString reducedCorrectionCosTerms[4] = {"<<cos(n(psi1))>>","<<cos(n(psi1+phi2))>>","<<cos(n*(psi1+phi2-phi3))>>","<<cos(n*(psi1-phi2-phi3))>>"}; // to be improved (access this from pro or hist)\r
9325  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
9326  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
9327  
9328  Int_t crossCheckInPtEtaBinNo[2] = {fCrossCheckInPtBinNo,fCrossCheckInEtaBinNo};
9329  
9330  cout<<endl;\r
9331  cout<<"   ******************************************"<<endl;\r
9332  cout<<"   ****  cross-checking the correction   ****"<<endl;\r
9333  cout<<"   **** terms for non-uniform acceptance ****"<<endl;\r
9334  cout<<"   ****      for differential flow       ****"<<endl;\r
9335  cout<<"   ****              "<<RPorPOIString[t]<<"                 ****"<<endl;\r
9336  cout<<"   ******************************************"<<endl; 
9337  cout<<endl;
9338  cout<<"           "<<PtOrEtaString[pe]<<" bin: "<<lowerPtEtaEdge[pe]<<" <= "<<PtOrEtaString[pe]<<" < "<<upperPtEtaEdge[pe]<<endl;
9339  cout<<endl;\r
9340  
9341  for(Int_t cti=0;cti<4;cti++) // correction term index
9342  {
9343   for(Int_t sc=0;sc<2;sc++) // sin or cos terms
9344   {
9345    if(sc==0) // to be improved (this can be implemented better)
9346    { 
9347     cout<<"      "<<reducedCorrectionSinTerms[cti].Data()<<":"<<endl;
9348    } else
9349      {
9350       cout<<"      "<<reducedCorrectionCosTerms[cti].Data()<<":"<<endl;     
9351      }
9352    cout<<"      from Q-vectors    = "<<fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti]->GetBinContent(crossCheckInPtEtaBinNo[pe])<<endl;\r
9353    cout<<"      from nested loops = "<<fDiffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti]->GetBinContent(1)<<endl;\r
9354    cout<<endl;  \r
9355   } 
9356  } // end of for(Int_t rci=0;rci<4;rci++)
9357
9358 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrectionTermsForNUA(TString type, TString ptOrEta)
9359
9360
9361 //================================================================================================================================\r