]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx
1e6596960538f61900c7109362375f475ba1824e
[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"\r
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  // 2a.) particle 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  // 2b.) event weights:\r
109  fMultiplicityWeight(NULL),\r
110  // 3.) integrated flow:\r
111  fIntFlowList(NULL), \r
112  fIntFlowProfiles(NULL),\r
113  fIntFlowResults(NULL),\r
114  fIntFlowFlags(NULL),\r
115  fApplyCorrectionForNUA(kTRUE), \r
116  fReQ(NULL),\r
117  fImQ(NULL),\r
118  fSMpk(NULL),\r
119  fIntFlowCorrelationsEBE(NULL),\r
120  fIntFlowEventWeightsForCorrelationsEBE(NULL),\r
121  fIntFlowCorrelationsAllEBE(NULL),\r
122  fAvMultiplicity(NULL),\r
123  fIntFlowCorrelationsPro(NULL),\r
124  fIntFlowCorrelationsAllPro(NULL),\r
125  fIntFlowExtraCorrelationsPro(NULL),\r
126  fIntFlowProductOfCorrelationsPro(NULL),\r
127  fIntFlowCorrelationsHist(NULL),\r
128  fIntFlowCorrelationsAllHist(NULL),\r
129  fIntFlowCovariances(NULL),\r
130  fIntFlowSumOfProductOfEventWeights(NULL),\r
131  fIntFlowQcumulants(NULL),\r
132  fIntFlow(NULL),\r
133  // 4.) differential flow:\r
134  fDiffFlowList(NULL),\r
135  fDiffFlowProfiles(NULL),\r
136  fDiffFlowResults(NULL),\r
137  fDiffFlowFlags(NULL),\r
138  fCalculate2DFlow(kFALSE),\r
139  // 5.) distributions:\r
140  fDistributionsList(NULL),\r
141  // x.) debugging and cross-checking:\r
142  fNestedLoopsList(NULL),\r
143  fEvaluateIntFlowNestedLoops(kFALSE),\r
144  fEvaluateDiffFlowNestedLoops(kFALSE),\r
145  fMaxAllowedMultiplicity(10),\r
146  fEvaluateNestedLoops(NULL),\r
147  fIntFlowDirectCorrelations(NULL),\r
148  fIntFlowExtraDirectCorrelations(NULL),\r
149  fCrossCheckInPtBinNo(10),\r
150  fCrossCheckInEtaBinNo(20)\r
151  {\r
152   // constructor  \r
153   \r
154   // base list to hold all output objects:\r
155   fHistList = new TList();\r
156   fHistList->SetName("cobjQC");\r
157   fHistList->SetOwner(kTRUE);\r
158   \r
159   // list to hold histograms with phi, pt and eta weights:      \r
160   fWeightsList = new TList();\r
161   \r
162   // multiplicity weight:\r
163   fMultiplicityWeight = new TString("combinations");\r
164     \r
165   // analysis label;\r
166   fAnalysisLabel = new TString();\r
167       \r
168   // initialize all arrays:  \r
169   this->InitializeArraysForIntFlow();\r
170   this->InitializeArraysForDiffFlow();\r
171   this->InitializeArraysForDistributions();\r
172   this->InitializeArraysForNestedLoops();\r
173   \r
174  } // end of constructor\r
175  \r
176 \r
177 //================================================================================================================  \r
178 \r
179 \r
180 AliFlowAnalysisWithQCumulants::~AliFlowAnalysisWithQCumulants()\r
181 {\r
182  // destructor\r
183  \r
184  delete fHistList;\r
185 \r
186 } // end of AliFlowAnalysisWithQCumulants::~AliFlowAnalysisWithQCumulants()\r
187 \r
188 \r
189 //================================================================================================================\r
190 \r
191 \r
192 void AliFlowAnalysisWithQCumulants::Init()\r
193 {\r
194  // a) Access all common constants;\r
195  // b) Book all objects;\r
196  // c) Store flags for integrated and differential flow;\r
197  // d) Store harmonic which will be estimated.\r
198   \r
199  // a) Access all common constants:\r
200  this->AccessConstants();\r
201  \r
202  // b) Book all objects:\r
203  this->BookAndFillWeightsHistograms();\r
204  this->BookAndNestAllLists();\r
205  this->BookCommonHistograms();\r
206  this->BookEverythingForIntegratedFlow(); \r
207  this->BookEverythingForDifferentialFlow(); \r
208  this->BookEverythingForDistributions();\r
209  this->BookEverythingForNestedLoops();\r
210  \r
211  // c) Store flags for integrated and differential flow:\r
212  this->StoreIntFlowFlags();\r
213  this->StoreDiffFlowFlags();\r
214 \r
215  // d) Store harmonic which will be estimated:\r
216  this->StoreHarmonic();\r
217  \r
218 } // end of void AliFlowAnalysisWithQCumulants::Init()\r
219 \r
220 \r
221 //================================================================================================================\r
222 \r
223 \r
224 void AliFlowAnalysisWithQCumulants::Make(AliFlowEventSimple* anEvent)\r
225 {\r
226  // Running over data only in this method.\r
227  \r
228  //  a) Fill the common control histograms and call the method to fill fAvMultiplicity;\r
229  //  b) Loop over data and calculate e-b-e quantities;\r
230  //  c) call the methods;\r
231  //  d) Debugging and cross-checking (evaluate nested loops);\r
232  //  e) Reset all event by event quantities. \r
233  \r
234  Double_t dPhi = 0.; // azimuthal angle in the laboratory frame\r
235  Double_t dPt  = 0.; // transverse momentum\r
236  Double_t dEta = 0.; // pseudorapidity\r
237 \r
238  Double_t wPhi = 1.; // phi weight\r
239  Double_t wPt  = 1.; // pt weight\r
240  Double_t wEta = 1.; // eta weight\r
241  \r
242  Int_t nRP = anEvent->GetEventNSelTracksRP(); // number of RPs (i.e. number of particles used to determine the reaction plane)\r
243  \r
244  // a) Fill the common control histograms and call the method to fill fAvMultiplicity:\r
245  this->FillCommonControlHistograms(anEvent);                                                               \r
246  this->FillAverageMultiplicities(nRP);                                                                  \r
247                                                                                                                                                                                                                                                                                         \r
248  // b) Loop over data and calculate e-b-e quantities:\r
249  Int_t nPrim = anEvent->NumberOfTracks();  // nPrim = total number of primary tracks, i.e. nPrim = nRP + nPOI + rest, where:\r
250                                            // nRP   = # of particles used to determine the reaction plane;\r
251                                            // nPOI  = # of particles of interest for a detailed flow analysis;\r
252                                            // rest  = # of particles which are not niether RPs nor POIs.  \r
253  \r
254  AliFlowTrackSimple *aftsTrack = NULL;\r
255  \r
256  for(Int_t i=0;i<nPrim;i++) \r
257  { \r
258   aftsTrack=anEvent->GetTrack(i);\r
259   if(aftsTrack)\r
260   {\r
261    if(!(aftsTrack->InRPSelection() || aftsTrack->InPOISelection())) continue; // consider only tracks which are RPs or POIs\r
262    Int_t n = fHarmonic; // shortcut for the harmonic\r
263    if(aftsTrack->InRPSelection()) // RP condition:\r
264    {    \r
265     dPhi = aftsTrack->Phi();\r
266     dPt  = aftsTrack->Pt();\r
267     dEta = aftsTrack->Eta();\r
268     if(fUsePhiWeights && fPhiWeights && fnBinsPhi) // determine phi weight for this particle:\r
269     {\r
270      wPhi = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*fnBinsPhi/TMath::TwoPi())));\r
271     }\r
272     if(fUsePtWeights && fPtWeights && fnBinsPt) // determine pt weight for this particle:\r
273     {\r
274      wPt = fPtWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-fPtMin)/fPtBinWidth))); \r
275     }              \r
276     if(fUseEtaWeights && fEtaWeights && fEtaBinWidth) // determine eta weight for this particle: \r
277     {\r
278      wEta = fEtaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-fEtaMin)/fEtaBinWidth))); \r
279     } \r
280       \r
281     // integrated flow: \r
282     // calculate Re[Q_{m*n,k}] and Im[Q_{m*n,k}], m = 1,2,3,4, for this event:\r
283     for(Int_t m=0;m<4;m++)\r
284     {\r
285      for(Int_t k=0;k<9;k++)\r
286      {\r
287       (*fReQ)(m,k)+=pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1)*n*dPhi); \r
288       (*fImQ)(m,k)+=pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1)*n*dPhi); \r
289      } \r
290     }\r
291     // calculate S^{M}_{p,k} for this event \r
292     // Remark: final calculation of S^{M}_{p,k} follows after the loop over data bellow:\r
293     for(Int_t p=0;p<8;p++)\r
294     {\r
295      for(Int_t k=0;k<9;k++)\r
296      {     \r
297       (*fSMpk)(p,k)+=pow(wPhi*wPt*wEta,k);\r
298      }\r
299     } \r
300     \r
301     // differential flow:\r
302     // 1D (pt):\r
303     // (r_{m*m,k}(pt)): \r
304     for(Int_t m=0;m<4;m++)\r
305     {\r
306      for(Int_t k=0;k<9;k++)\r
307      {\r
308       fReRPQ1dEBE[0][0][m][k]->Fill(dPt,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
309       fImRPQ1dEBE[0][0][m][k]->Fill(dPt,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
310      }\r
311     }\r
312            \r
313     // s_{k}(pt) for RPs // to be improved (clarified)\r
314     // Remark: final calculation of s_{p,k}(pt) follows after the loop over data bellow:\r
315     for(Int_t k=0;k<9;k++)\r
316     {\r
317      fs1dEBE[0][0][k]->Fill(dPt,pow(wPhi*wPt*wEta,k),1.);\r
318     }\r
319     // 1D (eta):\r
320     // (r_{m*m,k}(eta)): \r
321     for(Int_t m=0;m<4;m++)\r
322     {\r
323      for(Int_t k=0;k<9;k++)\r
324      {\r
325       fReRPQ1dEBE[0][1][m][k]->Fill(dEta,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
326       fImRPQ1dEBE[0][1][m][k]->Fill(dEta,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
327      }\r
328     }   \r
329     // s_{k}(eta) for RPs // to be improved (clarified)\r
330     // Remark: final calculation of s_{p,k}(eta) follows after the loop over data bellow:\r
331     for(Int_t k=0;k<9;k++)\r
332     {\r
333      fs1dEBE[0][1][k]->Fill(dEta,pow(wPhi*wPt*wEta,k),1.);\r
334     }\r
335     \r
336     \r
337     \r
338     /*\r
339     // 2D (pt,eta):\r
340     if(fCalculate2DFlow)\r
341     {\r
342      // (r_{m*m,k}(pt,eta)): \r
343      for(Int_t m=0;m<4;m++)\r
344      {\r
345       for(Int_t k=0;k<9;k++)\r
346       {\r
347        fReRPQ2dEBE[0][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
348        fImRPQ2dEBE[0][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
349       }\r
350      }    \r
351      // s_{k}(pt,eta) for RPs // to be improved (clarified)\r
352      // Remark: final calculation of s_{p,k}(pt,eta) follows after the loop over data bellow:\r
353      for(Int_t k=0;k<9;k++)\r
354      {\r
355       fs2dEBE[0][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k),1.);\r
356      }\r
357     } // end of if(fCalculate2DFlow)  \r
358     */ \r
359     \r
360       \r
361      \r
362     if(aftsTrack->InPOISelection())\r
363     {\r
364      // 1D (pt): \r
365      // (q_{m*m,k}(pt)): \r
366      for(Int_t m=0;m<4;m++)\r
367      {\r
368       for(Int_t k=0;k<9;k++)\r
369       {\r
370        fReRPQ1dEBE[2][0][m][k]->Fill(dPt,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
371        fImRPQ1dEBE[2][0][m][k]->Fill(dPt,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
372       }\r
373      } \r
374      // s_{k}(pt) for RP&&POIs // to be improved (clarified)\r
375      // Remark: final calculation of s_{p,k}(pt,eta) follows after the loop over data bellow:\r
376      for(Int_t k=0;k<9;k++)\r
377      {\r
378       fs1dEBE[2][0][k]->Fill(dPt,pow(wPhi*wPt*wEta,k),1.);\r
379      }\r
380      // 1D (eta): \r
381      // (q_{m*m,k}(eta)): \r
382      for(Int_t m=0;m<4;m++)\r
383      {\r
384       for(Int_t k=0;k<9;k++)\r
385       {\r
386        fReRPQ1dEBE[2][1][m][k]->Fill(dEta,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
387        fImRPQ1dEBE[2][1][m][k]->Fill(dEta,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
388       }\r
389      } \r
390      // s_{k}(eta) for RP&&POIs // to be improved (clarified)\r
391      // Remark: final calculation of s_{p,k}(pt,eta) follows after the loop over data bellow:\r
392      for(Int_t k=0;k<9;k++)\r
393      {\r
394       fs1dEBE[2][1][k]->Fill(dEta,pow(wPhi*wPt*wEta,k),1.);\r
395      }\r
396      \r
397      /*\r
398      // 2D (pt,eta) \r
399      if(fCalculate2DFlow)\r
400      {\r
401       // (q_{m*m,k}(pt,eta)): \r
402       for(Int_t m=0;m<4;m++)\r
403       {\r
404        for(Int_t k=0;k<9;k++)\r
405        {\r
406         fReRPQ2dEBE[2][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1.)*n*dPhi),1.);\r
407         fImRPQ2dEBE[2][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1.)*n*dPhi),1.);\r
408        }\r
409       } \r
410       // s_{k}(pt,eta) for RP&&POIs // to be improved (clarified)\r
411       // Remark: final calculation of s_{p,k}(pt,eta) follows after the loop over data bellow:\r
412       for(Int_t k=0;k<9;k++)\r
413       {\r
414        fs2dEBE[2][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta,k),1.);\r
415       }\r
416      } // end of if(fCalculate2DFlow) \r
417      */\r
418       \r
419     } // end of if(aftsTrack->InPOISelection())\r
420     \r
421 \r
422      \r
423    } // end of if(pTrack->InRPSelection())\r
424 \r
425   \r
426   \r
427    if(aftsTrack->InPOISelection())\r
428    {\r
429     dPhi = aftsTrack->Phi();\r
430     dPt  = aftsTrack->Pt();\r
431     dEta = aftsTrack->Eta();\r
432     \r
433     // 1D (pt)\r
434     // p_n(m*n,0):   \r
435     for(Int_t m=0;m<4;m++)\r
436     {\r
437      fReRPQ1dEBE[1][0][m][0]->Fill(dPt,TMath::Cos((m+1.)*n*dPhi),1.);\r
438      fImRPQ1dEBE[1][0][m][0]->Fill(dPt,TMath::Sin((m+1.)*n*dPhi),1.);\r
439     }\r
440     // 1D (eta)\r
441     // p_n(m*n,0):   \r
442     for(Int_t m=0;m<4;m++)\r
443     {\r
444      fReRPQ1dEBE[1][1][m][0]->Fill(dEta,TMath::Cos((m+1.)*n*dPhi),1.);\r
445      fImRPQ1dEBE[1][1][m][0]->Fill(dEta,TMath::Sin((m+1.)*n*dPhi),1.);\r
446     }\r
447     \r
448     \r
449     /*\r
450     // 2D (pt,eta):\r
451     if(fCalculate2DFlow)\r
452     {      \r
453      // p_n(m*n,0):   \r
454      for(Int_t m=0;m<4;m++)\r
455      {\r
456       fReRPQ2dEBE[1][m][0]->Fill(dPt,dEta,TMath::Cos((m+1.)*n*dPhi),1.);\r
457       fImRPQ2dEBE[1][m][0]->Fill(dPt,dEta,TMath::Sin((m+1.)*n*dPhi),1.);\r
458      }\r
459     } // end of if(fCalculate2DFlow)  \r
460     */\r
461     \r
462     \r
463    } // end of if(pTrack->InPOISelection() )   \r
464  \r
465   \r
466   } else // to if(aftsTrack)\r
467     {\r
468      cout<<endl;\r
469      cout<<" WARNING: no particle! (i.e. aftsTrack is a NULL pointer in AFAWQC::Make().)"<<endl;\r
470      cout<<endl;       \r
471     }\r
472  } // end of for(Int_t i=0;i<nPrim;i++) \r
473 \r
474  // calculate the final expressions for S^{M}_{p,k}:\r
475  for(Int_t p=0;p<8;p++)\r
476  {\r
477   for(Int_t k=0;k<9;k++)\r
478   {\r
479    (*fSMpk)(p,k)=pow((*fSMpk)(p,k),p+1);\r
480   }  \r
481  } \r
482  \r
483  // *****************************\r
484  // **** CALL THE METHODS *******\r
485  // *****************************\r
486  // integrated flow:\r
487  if(!fEvaluateIntFlowNestedLoops)\r
488  {\r
489   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
490   {\r
491    if(nRP>1) this->CalculateIntFlowCorrelations(); // without using particle weights\r
492   } else \r
493     {\r
494      if(nRP>1) this->CalculateIntFlowCorrelationsUsingParticleWeights(); // with using particle weights   \r
495     } \r
496        \r
497   if(nRP>3) this->CalculateIntFlowProductOfCorrelations();\r
498   if(nRP>1) this->CalculateIntFlowSumOfEventWeights();\r
499   if(nRP>1) this->CalculateIntFlowSumOfProductOfEventWeights();\r
500   if(fApplyCorrectionForNUA && !(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (enable correction for NUA also when particle weights are used?)\r
501   {\r
502    if(nRP>0) this->CalculateIntFlowCorrectionsForNUASinTerms();\r
503    if(nRP>0) this->CalculateIntFlowCorrectionsForNUACosTerms();\r
504   }\r
505  } // end of if(!fEvaluateIntFlowNestedLoops)\r
506 \r
507  // differential flow:\r
508  if(!fEvaluateDiffFlowNestedLoops)\r
509  {\r
510   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
511   {\r
512    if(nRP>1) // to be improved (move this if somewhere else)\r
513    {\r
514     // without using particle weights:\r
515     this->CalculateDiffFlowCorrelations("RP","Pt"); \r
516     this->CalculateDiffFlowCorrelations("RP","Eta");\r
517     this->CalculateDiffFlowCorrelations("POI","Pt");\r
518     this->CalculateDiffFlowCorrelations("POI","Eta");\r
519    }  \r
520   } else\r
521     {\r
522      // with using particle weights:   \r
523      this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Pt"); \r
524      this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Eta"); \r
525      this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Pt"); \r
526      this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Eta"); \r
527     } \r
528     \r
529   this->CalculateDiffFlowProductOfCorrelations("RP","Pt");\r
530   this->CalculateDiffFlowProductOfCorrelations("RP","Eta");\r
531   this->CalculateDiffFlowProductOfCorrelations("POI","Pt");\r
532   this->CalculateDiffFlowProductOfCorrelations("POI","Eta");\r
533   this->CalculateDiffFlowSumOfEventWeights("RP","Pt");\r
534   this->CalculateDiffFlowSumOfEventWeights("RP","Eta");\r
535   this->CalculateDiffFlowSumOfEventWeights("POI","Pt");\r
536   this->CalculateDiffFlowSumOfEventWeights("POI","Eta");\r
537   this->CalculateDiffFlowSumOfProductOfEventWeights("RP","Pt");\r
538   this->CalculateDiffFlowSumOfProductOfEventWeights("RP","Eta");\r
539   this->CalculateDiffFlowSumOfProductOfEventWeights("POI","Pt");\r
540   this->CalculateDiffFlowSumOfProductOfEventWeights("POI","Eta");\r
541   if(fApplyCorrectionForNUA && !(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (enable correction for NUA also when particle weights are used?)\r
542   {\r
543    this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Pt");\r
544    this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Eta");\r
545    this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Pt");\r
546    this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Eta");\r
547    this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Pt");\r
548    this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Eta");\r
549    this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Pt");\r
550    this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Eta");\r
551   }\r
552   \r
553  } // end of if(!fEvaluateDiffFlowNestedLoops)\r
554 \r
555 \r
556    \r
557   // with weights:\r
558   // ... \r
559   \r
560   /*\r
561   // 2D differential flow\r
562   if(fCalculate2DFlow)\r
563   {\r
564    // without weights:\r
565    if(nRP>1) this->CalculateCorrelationsForDifferentialFlow2D("RP");\r
566    if(nRP>1) this->CalculateCorrelationsForDifferentialFlow2D("POI");\r
567   \r
568    // with weights:\r
569    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
570    {\r
571     if(nRP>1) this->CalculateWeightedCorrelationsForDifferentialFlow2D("RP");\r
572     if(nRP>1) this->CalculateWeightedCorrelationsForDifferentialFlow2D("POI");\r
573    } \r
574   } // end of if(fCalculate2DFlow)\r
575   */\r
576   \r
577  \r
578  // d) Debugging and cross-checking (evaluate nested loops):\r
579  //  d1) cross-checking results for integrated flow:\r
580  if(fEvaluateIntFlowNestedLoops)\r
581  {\r
582   if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity) // by default fMaxAllowedMultiplicity = 10 \r
583   {\r
584    // without using particle weights:\r
585    if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
586    {\r
587     // correlations:\r
588     this->CalculateIntFlowCorrelations(); // from Q-vectors\r
589     this->EvaluateIntFlowCorrelationsWithNestedLoops(anEvent); // from nested loops (to be improved: do I have to pass here anEvent or not?)\r
590     // correction for non-uniform acceptance:\r
591     this->CalculateIntFlowCorrectionsForNUASinTerms(); // from Q-vectors (sin terms)\r
592     this->CalculateIntFlowCorrectionsForNUACosTerms(); // from Q-vectors (cos terms)\r
593     this->EvaluateIntFlowCorrectionsForNUAWithNestedLoops(anEvent); // from nested loops (both sin and cos terms)\r
594    }\r
595    // using particle weights:\r
596    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
597    {\r
598     // correlations:\r
599     this->CalculateIntFlowCorrelationsUsingParticleWeights(); // from Q-vectors\r
600     this->EvaluateIntFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent); // from nested loops (to be improved: do I have to pass here anEvent or not?)\r
601    }\r
602   } else if (nPrim>fMaxAllowedMultiplicity) // to if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity)\r
603     {\r
604      cout<<endl;\r
605      cout<<"Skipping the event because multiplicity is "<<nPrim<<". Too high to evaluate nested loops!"<<endl;\r
606     } else\r
607       {\r
608        cout<<endl;\r
609        cout<<"Skipping the event because multiplicity is "<<nPrim<<"."<<endl;      \r
610       } \r
611  } // end of if(fEvaluateIntFlowNestedLoops) \r
612  \r
613  //  d2) cross-checking results for differential flow:\r
614  if(fEvaluateDiffFlowNestedLoops)\r
615  {\r
616   if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity) // by default fMaxAllowedMultiplicity = 10\r
617   {\r
618    // without using particle weights:\r
619    if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
620    {\r
621     // reduced correlations:\r
622     // Q-vectors:\r
623     this->CalculateDiffFlowCorrelations("RP","Pt");\r
624     this->CalculateDiffFlowCorrelations("RP","Eta");\r
625     this->CalculateDiffFlowCorrelations("POI","Pt");\r
626     this->CalculateDiffFlowCorrelations("POI","Eta");\r
627     // nested loops:\r
628     //this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"RP","Pt"); // to be improved (enabled eventually)\r
629     //this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"RP","Eta"); // to be improved (enabled eventually)\r
630     this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"POI","Pt"); // to be improved (do I need to pass here anEvent?)\r
631     this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"POI","Eta"); // to be improved (do I need to pass here anEvent?)\r
632     // reduced corrections for non-uniform acceptance:\r
633     // Q-vectors:\r
634     this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Pt");\r
635     this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Eta");\r
636     this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Pt");\r
637     this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Eta");\r
638     this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Pt");\r
639     this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Eta");\r
640     this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Pt");\r
641     this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Eta");\r
642     // nested loops:\r
643     //this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"RP","Pt"); // to be improved (enabled eventually)\r
644     //this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"RP","Eta"); // to be improved (enabled eventually)\r
645     this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"POI","Pt"); // to be improved (do I need to pass here anEvent?)\r
646     this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"POI","Eta"); // to be improved (do I need to pass here anEvent?)\r
647    } // end of if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
648    // using particle weights:\r
649    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
650    {\r
651     this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Pt"); \r
652     this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Eta"); \r
653     this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Pt"); \r
654     this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Eta"); \r
655     this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"RP","Pt"); // to be improved (enabled eventually)\r
656     this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"RP","Eta"); // to be improved (enabled eventually)\r
657     this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"POI","Pt"); // to be improved (do I need to pass here anEvent?)\r
658     this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"POI","Eta"); // to be improved (do I need to pass here anEvent?)\r
659    } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
660   } // end of if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity) // by default fMaxAllowedMultiplicity = 10\r
661  } // end of if(fEvaluateDiffFlowNestedLoops) \r
662  \r
663  // e) Reset all event by event quantities: \r
664  this->ResetEventByEventQuantities();\r
665  \r
666 } // end of AliFlowAnalysisWithQCumulants::Make(AliFlowEventSimple* anEvent)\r
667 \r
668 \r
669 //================================================================================================================================\r
670 \r
671 \r
672 void AliFlowAnalysisWithQCumulants::Finish()\r
673 {\r
674  // Calculate the final results.\r
675  //  a) acces the constants;\r
676  //  b) access the flags;\r
677  //  c) calculate the final results for integrated flow (without and with weights);\r
678  //  d) store in AliFlowCommonHistResults and print the final results for integrated flow;\r
679  //  e) calculate the final results for differential flow (without and with weights);\r
680  //  f) print the final results for integrated flow obtained from differential flow (to be improved (terminology));\r
681  //  g) cross-check the results: results from Q-vectors vs results from nested loops\r
682  \r
683  // ******************************\r
684  // **** ACCESS THE CONSTANTS ****\r
685  // ******************************\r
686  \r
687  this->AccessConstants();          \r
688  \r
689  if(fCommonHists && fCommonHists->GetHarmonic())\r
690  {\r
691   fHarmonic = (Int_t)(fCommonHists->GetHarmonic())->GetBinContent(1); // to be improved (moved somewhere else)\r
692  } \r
693 \r
694  // **************************\r
695  // **** ACCESS THE FLAGS ****\r
696  // **************************    \r
697  fUsePhiWeights = (Int_t)fUseParticleWeights->GetBinContent(1); \r
698  fUsePtWeights = (Int_t)fUseParticleWeights->GetBinContent(2); \r
699  fUseEtaWeights = (Int_t)fUseParticleWeights->GetBinContent(3);  \r
700  fApplyCorrectionForNUA = (Int_t)fIntFlowFlags->GetBinContent(3); \r
701  fEvaluateIntFlowNestedLoops = (Int_t)fEvaluateNestedLoops->GetBinContent(1);\r
702  fEvaluateDiffFlowNestedLoops = (Int_t)fEvaluateNestedLoops->GetBinContent(2); \r
703  fCrossCheckInPtBinNo = (Int_t)fEvaluateNestedLoops->GetBinContent(3);\r
704  fCrossCheckInEtaBinNo = (Int_t)fEvaluateNestedLoops->GetBinContent(4); \r
705     \r
706  // *********************************************************\r
707  // **** CALCULATE THE FINAL RESULTS FOR INTEGRATED FLOW ****\r
708  // *********************************************************     \r
709  \r
710  this->FinalizeCorrelationsIntFlow();\r
711  this->CalculateCovariancesIntFlow();\r
712  this->CalculateCumulantsIntFlow();\r
713  this->CalculateIntFlow(); \r
714 \r
715  if(fApplyCorrectionForNUA && !(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (reorganized, etc)\r
716  {\r
717   this->FinalizeCorrectionTermsForNUAIntFlow();\r
718   this->CalculateQcumulantsCorrectedForNUAIntFlow();   \r
719   this->CalculateIntFlowCorrectedForNUA(); \r
720  }\r
721   \r
722  // ***************************************************************\r
723  // **** STORE AND PRINT THE FINAL RESULTS FOR INTEGRATED FLOW ****\r
724  // ***************************************************************\r
725  \r
726  this->FillCommonHistResultsIntFlow();  \r
727   \r
728  this->PrintFinalResultsForIntegratedFlow("NONAME"); // to be improved (name)\r
729  \r
730  // ***********************************************************\r
731  // **** CALCULATE THE FINAL RESULTS FOR DIFFERENTIAL FLOW ****\r
732  // ***********************************************************    \r
733  \r
734  this->FinalizeReducedCorrelations("RP","Pt"); \r
735  this->FinalizeReducedCorrelations("RP","Eta"); \r
736  this->FinalizeReducedCorrelations("POI","Pt"); \r
737  this->FinalizeReducedCorrelations("POI","Eta");\r
738  this->CalculateDiffFlowCovariances("RP","Pt");\r
739  this->CalculateDiffFlowCovariances("RP","Eta");\r
740  this->CalculateDiffFlowCovariances("POI","Pt");\r
741  this->CalculateDiffFlowCovariances("POI","Eta");\r
742  this->CalculateDiffFlowCumulants("RP","Pt");\r
743  this->CalculateDiffFlowCumulants("RP","Eta");\r
744  this->CalculateDiffFlowCumulants("POI","Pt");\r
745  this->CalculateDiffFlowCumulants("POI","Eta");\r
746  this->CalculateDiffFlow("RP","Pt");\r
747  this->CalculateDiffFlow("RP","Eta");\r
748  this->CalculateDiffFlow("POI","Pt");\r
749  this->CalculateDiffFlow("POI","Eta");\r
750  \r
751  if(fApplyCorrectionForNUA && !(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (reorganized, etc)\r
752  {\r
753   this->FinalizeCorrectionTermsForNUADiffFlow("RP","Pt");\r
754   this->FinalizeCorrectionTermsForNUADiffFlow("RP","Eta");\r
755   this->FinalizeCorrectionTermsForNUADiffFlow("POI","Pt");\r
756   this->FinalizeCorrectionTermsForNUADiffFlow("POI","Eta");      \r
757   this->CalculateDiffFlowCumulantsCorrectedForNUA("RP","Pt");   \r
758   this->CalculateDiffFlowCumulantsCorrectedForNUA("RP","Eta");   \r
759   this->CalculateDiffFlowCumulantsCorrectedForNUA("POI","Pt");   \r
760   this->CalculateDiffFlowCumulantsCorrectedForNUA("POI","Eta");  \r
761   this->CalculateDiffFlowCorrectedForNUA("RP","Pt"); \r
762   this->CalculateDiffFlowCorrectedForNUA("RP","Eta"); \r
763   this->CalculateDiffFlowCorrectedForNUA("POI","Pt"); \r
764   this->CalculateDiffFlowCorrectedForNUA("POI","Eta"); \r
765  }\r
766  \r
767  this->CalculateFinalResultsForRPandPOIIntegratedFlow("RP");\r
768  this->CalculateFinalResultsForRPandPOIIntegratedFlow("POI");\r
769 \r
770  // *****************************************************************\r
771  // **** STORE AND PRINT THE FINAL RESULTS FOR DIFFERENTIAL FLOW ****\r
772  // *****************************************************************\r
773  this->FillCommonHistResultsDiffFlow("RP");\r
774  this->FillCommonHistResultsDiffFlow("POI");\r
775 \r
776  this->PrintFinalResultsForIntegratedFlow("RP"); \r
777  this->PrintFinalResultsForIntegratedFlow("POI"); \r
778   \r
779  // g) cross-check the results: results from Q-vectors vs results from nested loops\r
780  //  g1) integrated flow:\r
781  if(fEvaluateIntFlowNestedLoops)\r
782  {\r
783   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) \r
784   {\r
785    this->CrossCheckIntFlowCorrelations();\r
786    this->CrossCheckIntFlowCorrectionTermsForNUA(); \r
787   } else\r
788     {\r
789      this->CrossCheckIntFlowCorrelations();     \r
790      this->CrossCheckIntFlowExtraCorrelations();     \r
791     }\r
792  } // end of if(fEvaluateIntFlowNestedLoops)  \r
793  //  g2) differential flow: \r
794  if(fEvaluateDiffFlowNestedLoops) \r
795  {\r
796   // correlations:\r
797   //this->CrossCheckDiffFlowCorrelations("RP","Pt"); // to be improved (enabled eventually)  \r
798   //this->CrossCheckDiffFlowCorrelations("RP","Eta"); // to be improved (enabled eventually)  \r
799   this->CrossCheckDiffFlowCorrelations("POI","Pt");  \r
800   this->CrossCheckDiffFlowCorrelations("POI","Eta");\r
801   // correction terms for non-uniform acceptance:\r
802   //this->CrossCheckDiffFlowCorrectionTermsForNUA("RP","Pt"); // to be improved (enabled eventually)      \r
803   //this->CrossCheckDiffFlowCorrectionTermsForNUA("RP","Eta"); // to be improved (enabled eventually)      \r
804   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) \r
805   {\r
806    this->CrossCheckDiffFlowCorrectionTermsForNUA("POI","Pt");      \r
807    this->CrossCheckDiffFlowCorrectionTermsForNUA("POI","Eta");      \r
808   } \r
809  } // end of if(fEvaluateDiffFlowNestedLoops)\r
810                                                                                                                                                                                                                                                                                                                                    \r
811 } // end of AliFlowAnalysisWithQCumulants::Finish()\r
812 \r
813 \r
814 //================================================================================================================================\r
815 \r
816 \r
817 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUACosTerms()\r
818 {\r
819  // calculate corrections for non-uniform acceptance of the detector for no-name integrated flow (cos terms)\r
820  \r
821  // multiplicity:\r
822  Double_t dMult = (*fSMpk)(0,0);\r
823  \r
824  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
825  Double_t dReQ1n = (*fReQ)(0,0);\r
826  Double_t dReQ2n = (*fReQ)(1,0);\r
827  //Double_t dReQ3n = (*fReQ)(2,0);\r
828  //Double_t dReQ4n = (*fReQ)(3,0);\r
829  Double_t dImQ1n = (*fImQ)(0,0);\r
830  Double_t dImQ2n = (*fImQ)(1,0);\r
831  //Double_t dImQ3n = (*fImQ)(2,0);\r
832  //Double_t dImQ4n = (*fImQ)(3,0);\r
833         \r
834  //                                  *************************************************************\r
835  //                                  **** corrections for non-uniform acceptance (cos terms): ****\r
836  //                                  *************************************************************\r
837  //\r
838  // Remark 1: corrections for non-uniform acceptance (cos terms) calculated with non-weighted Q-vectors \r
839  //           are stored in 1D profile fQCorrectionsCos.\r
840  // Remark 2: binning of fIntFlowCorrectionTermsForNUAPro[1] is organized as follows:\r
841  // --------------------------------------------------------------------------------------------------------------------\r
842  // 1st bin: <<cos(n*(phi1))>> = cosP1n\r
843  // 2nd bin: <<cos(n*(phi1+phi2))>> = cosP1nP1n\r
844  // 3rd bin: <<cos(n*(phi1-phi2-phi3))>> = cosP1nM1nM1n\r
845  // ...\r
846  // --------------------------------------------------------------------------------------------------------------------\r
847   \r
848  // 1-particle:\r
849  Double_t cosP1n = 0.; // <<cos(n*(phi1))>>\r
850    \r
851  if(dMult>0)\r
852  {\r
853   cosP1n = dReQ1n/dMult; \r
854   \r
855   // average non-weighted 1-particle correction (cos terms) for non-uniform acceptance for single event:\r
856   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(1,cosP1n);\r
857   \r
858   // final average non-weighted 1-particle correction (cos terms) for non-uniform acceptance for all events:\r
859   fIntFlowCorrectionTermsForNUAPro[1]->Fill(0.5,cosP1n,dMult);  \r
860  } \r
861  \r
862  // 2-particle:\r
863  Double_t cosP1nP1n = 0.; // <<cos(n*(phi1+phi2))>>\r
864  \r
865  if(dMult>1)\r
866  {\r
867   cosP1nP1n = (pow(dReQ1n,2)-pow(dImQ1n,2)-dReQ2n)/(dMult*(dMult-1)); \r
868   \r
869   // average non-weighted 2-particle correction (cos terms) for non-uniform acceptance for single event:\r
870   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(2,cosP1nP1n);\r
871   \r
872   // final average non-weighted 2-particle correction (cos terms) for non-uniform acceptance for all events:\r
873   fIntFlowCorrectionTermsForNUAPro[1]->Fill(1.5,cosP1nP1n,dMult*(dMult-1));  \r
874  } \r
875  \r
876  // 3-particle:\r
877  Double_t cosP1nM1nM1n = 0.; // <<cos(n*(phi1-phi2-phi3))>>\r
878  \r
879  if(dMult>2)\r
880  {\r
881   cosP1nM1nM1n = (dReQ1n*(pow(dReQ1n,2)+pow(dImQ1n,2))-dReQ1n*dReQ2n-dImQ1n*dImQ2n-2.*(dMult-1)*dReQ1n)\r
882                / (dMult*(dMult-1)*(dMult-2)); \r
883   \r
884   // average non-weighted 3-particle correction (cos terms) for non-uniform acceptance for single event:\r
885   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(3,cosP1nM1nM1n);\r
886   \r
887   // final average non-weighted 3-particle correction (cos terms) for non-uniform acceptance for all events:\r
888   fIntFlowCorrectionTermsForNUAPro[1]->Fill(2.5,cosP1nM1nM1n,dMult*(dMult-1)*(dMult-2));  \r
889  } \r
890  \r
891 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUACosTerms()\r
892 \r
893 \r
894 //================================================================================================================================\r
895 \r
896 \r
897 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUASinTerms()\r
898 {\r
899  // calculate corrections for non-uniform acceptance of the detector for no-name integrated flow (sin terms)\r
900  \r
901  // multiplicity:\r
902  Double_t dMult = (*fSMpk)(0,0);\r
903  \r
904  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
905  Double_t dReQ1n = (*fReQ)(0,0);\r
906  Double_t dReQ2n = (*fReQ)(1,0);\r
907  //Double_t dReQ3n = (*fReQ)(2,0);\r
908  //Double_t dReQ4n = (*fReQ)(3,0);\r
909  Double_t dImQ1n = (*fImQ)(0,0);\r
910  Double_t dImQ2n = (*fImQ)(1,0);\r
911  //Double_t dImQ3n = (*fImQ)(2,0);\r
912  //Double_t dImQ4n = (*fImQ)(3,0);\r
913         \r
914  //                                  *************************************************************\r
915  //                                  **** corrections for non-uniform acceptance (sin terms): ****\r
916  //                                  *************************************************************\r
917  //\r
918  // Remark 1: corrections for non-uniform acceptance (sin terms) calculated with non-weighted Q-vectors \r
919  //           are stored in 1D profile fQCorrectionsSin.\r
920  // Remark 2: binning of fIntFlowCorrectionTermsForNUAPro[0] is organized as follows:\r
921  // --------------------------------------------------------------------------------------------------------------------\r
922  // 1st bin: <<sin(n*(phi1))>> = sinP1n\r
923  // 2nd bin: <<sin(n*(phi1+phi2))>> = sinP1nP1n\r
924  // 3rd bin: <<sin(n*(phi1-phi2-phi3))>> = sinP1nM1nM1n\r
925  // ...\r
926  // --------------------------------------------------------------------------------------------------------------------\r
927  \r
928  // 1-particle:\r
929  Double_t sinP1n = 0.; // <sin(n*(phi1))>\r
930  \r
931  if(dMult>0)\r
932  {\r
933   sinP1n = dImQ1n/dMult; \r
934      \r
935   // average non-weighted 1-particle correction (sin terms) for non-uniform acceptance for single event:\r
936   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(1,sinP1n);\r
937   \r
938   // final average non-weighted 1-particle correction (sin terms) for non-uniform acceptance for all events:   \r
939   fIntFlowCorrectionTermsForNUAPro[0]->Fill(0.5,sinP1n,dMult);  \r
940  } \r
941  \r
942  // 2-particle:\r
943  Double_t sinP1nP1n = 0.; // <<sin(n*(phi1+phi2))>>\r
944  \r
945  if(dMult>1)\r
946  {\r
947   sinP1nP1n = (2.*dReQ1n*dImQ1n-dImQ2n)/(dMult*(dMult-1)); \r
948      \r
949   // average non-weighted 2-particle correction (sin terms) for non-uniform acceptance for single event:\r
950   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(2,sinP1nP1n);\r
951   \r
952   // final average non-weighted 1-particle correction (sin terms) for non-uniform acceptance for all events:      \r
953   fIntFlowCorrectionTermsForNUAPro[0]->Fill(1.5,sinP1nP1n,dMult*(dMult-1));  \r
954  } \r
955  \r
956  // 3-particle:\r
957  Double_t sinP1nM1nM1n = 0.; // <<sin(n*(phi1-phi2-phi3))>>\r
958  \r
959  if(dMult>2)\r
960  {\r
961   sinP1nM1nM1n = (-dImQ1n*(pow(dReQ1n,2)+pow(dImQ1n,2))+dReQ1n*dImQ2n-dImQ1n*dReQ2n+2.*(dMult-1)*dImQ1n)\r
962                / (dMult*(dMult-1)*(dMult-2)); \r
963   \r
964   // average non-weighted 3-particle correction (sin terms) for non-uniform acceptance for single event:\r
965   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(3,sinP1nM1nM1n);\r
966   \r
967   // final average non-weighted 3-particle correction (sin terms) for non-uniform acceptance for all events:  \r
968   fIntFlowCorrectionTermsForNUAPro[0]->Fill(2.5,sinP1nM1nM1n,dMult*(dMult-1)*(dMult-2));  \r
969  } \r
970  \r
971 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUASinTerms()\r
972 \r
973 \r
974 //================================================================================================================================\r
975 \r
976 \r
977 void AliFlowAnalysisWithQCumulants::GetOutputHistograms(TList *outputListHistos)\r
978 {\r
979  // a) Get pointers for common control and common result histograms and profiles.\r
980  // b) Get pointers for histograms with particle weights.\r
981  // c) Get pointers for histograms and profiles relevant for integrated flow.\r
982  // d) Get pointers for histograms and profiles relevant for differental flow.\r
983  // e) Get pointers for histograms and profiles holding results obtained with nested loops.\r
984  \r
985  if(outputListHistos)\r
986  {      \r
987   this->GetPointersForCommonHistograms(outputListHistos); // to be improved (no need to pass here argument, use setter for base list instead)\r
988   this->GetPointersForParticleWeightsHistograms(outputListHistos); // to be improved (no need to pass here argument, use setter for base list instead)\r
989   this->GetPointersForIntFlowHistograms(outputListHistos); // to be improved (no need to pass here argument, use setter for base list instead)\r
990   this->GetPointersForDiffFlowHistograms(outputListHistos); // to be improved (no need to pass here argument, use setter for base list instead)\r
991   this->GetPointersForNestedLoopsHistograms(outputListHistos); // to be improved (no need to pass here argument, use setter for base list instead)\r
992  }\r
993    \r
994 } // end of void AliFlowAnalysisWithQCumulants::GetOutputHistograms(TList *outputListHistos)\r
995 \r
996 \r
997 //================================================================================================================================\r
998 \r
999 \r
1000 TProfile* AliFlowAnalysisWithQCumulants::MakePtProjection(TProfile2D *profilePtEta) const\r
1001 {\r
1002  // project 2D profile onto pt axis to get 1D profile\r
1003  \r
1004  Int_t nBinsPt   = profilePtEta->GetNbinsX();\r
1005  Double_t dPtMin = (profilePtEta->GetXaxis())->GetXmin();\r
1006  Double_t dPtMax = (profilePtEta->GetXaxis())->GetXmax();\r
1007  \r
1008  Int_t nBinsEta   = profilePtEta->GetNbinsY();\r
1009  \r
1010  TProfile *profilePt = new TProfile("","",nBinsPt,dPtMin,dPtMax); \r
1011  \r
1012  for(Int_t p=1;p<=nBinsPt;p++)\r
1013  {\r
1014   Double_t contentPt = 0.;\r
1015   Double_t entryPt = 0.;\r
1016   Double_t spreadPt = 0.;\r
1017   Double_t sum1 = 0.;\r
1018   Double_t sum2 = 0.;\r
1019   Double_t sum3 = 0.;\r
1020   for(Int_t e=1;e<=nBinsEta;e++)\r
1021   {\r
1022    contentPt += (profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)))\r
1023               * (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));\r
1024    entryPt   += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));\r
1025    \r
1026    sum1 += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)))\r
1027          * (pow(profilePtEta->GetBinError(profilePtEta->GetBin(p,e)),2.)\r
1028             + pow(profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)),2.)); \r
1029    sum2 += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));\r
1030    sum3 += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)))\r
1031          * (profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)));            \r
1032   }\r
1033   if(sum2>0. && sum1/sum2-pow(sum3/sum2,2.) > 0.)\r
1034   {\r
1035    spreadPt = pow(sum1/sum2-pow(sum3/sum2,2.),0.5);\r
1036   }\r
1037   profilePt->SetBinContent(p,contentPt);\r
1038   profilePt->SetBinEntries(p,entryPt);\r
1039   {\r
1040    profilePt->SetBinError(p,spreadPt);\r
1041   }\r
1042   \r
1043  }\r
1044  \r
1045  return profilePt;\r
1046  \r
1047 } // end of TProfile* AliFlowAnalysisWithQCumulants::MakePtProjection(TProfile2D *profilePtEta)\r
1048 \r
1049 \r
1050 //================================================================================================================================\r
1051 \r
1052 \r
1053 TProfile* AliFlowAnalysisWithQCumulants::MakeEtaProjection(TProfile2D *profilePtEta) const\r
1054 {\r
1055  // project 2D profile onto eta axis to get 1D profile\r
1056  \r
1057  Int_t nBinsEta   = profilePtEta->GetNbinsY();\r
1058  Double_t dEtaMin = (profilePtEta->GetYaxis())->GetXmin();\r
1059  Double_t dEtaMax = (profilePtEta->GetYaxis())->GetXmax();\r
1060  \r
1061  Int_t nBinsPt = profilePtEta->GetNbinsX();\r
1062  \r
1063  TProfile *profileEta = new TProfile("","",nBinsEta,dEtaMin,dEtaMax); \r
1064  \r
1065  for(Int_t e=1;e<=nBinsEta;e++)\r
1066  {\r
1067   Double_t contentEta = 0.;\r
1068   Double_t entryEta = 0.;\r
1069   for(Int_t p=1;p<=nBinsPt;p++)\r
1070   {\r
1071    contentEta += (profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)))\r
1072               * (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));\r
1073    entryEta   += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));\r
1074   }\r
1075   profileEta->SetBinContent(e,contentEta);\r
1076   profileEta->SetBinEntries(e,entryEta);\r
1077  }\r
1078  \r
1079  return profileEta;\r
1080  \r
1081 } // end of TProfile* AliFlowAnalysisWithQCumulants::MakeEtaProjection(TProfile2D *profilePtEta)\r
1082 \r
1083 \r
1084 //================================================================================================================================\r
1085 \r
1086 \r
1087 void AliFlowAnalysisWithQCumulants::PrintFinalResultsForIntegratedFlow(TString type)\r
1088 {\r
1089  // printing on the screen the final results for integrated flow (NONAME, POI and RP) // to be improved (NONAME) \r
1090  \r
1091  Int_t n = fHarmonic; \r
1092  \r
1093  if(type == "NONAME" || type == "RP" || type == "POI")\r
1094  {\r
1095   if(!(fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th))\r
1096   {\r
1097    cout<<"WARNING: fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th"<<endl;\r
1098    cout<<"         is NULL in AFAWQC::PFRFIF() !!!!"<<endl;\r
1099   }\r
1100  } else\r
1101    {\r
1102     cout<<"WARNING: type in not from {NONAME, RP, POI} in AFAWQC::PFRFIF() !!!!"<<endl;\r
1103     exit(0);\r
1104    }\r
1105  \r
1106  Double_t dVn[4] = {0.}; // array to hold Vn{2}, Vn{4}, Vn{6} and Vn{8}   \r
1107  Double_t dVnErr[4] = {0.}; // array to hold errors of Vn{2}, Vn{4}, Vn{6} and Vn{8}   \r
1108  \r
1109  if(type == "NONAME")\r
1110  {\r
1111   dVn[0] = (fCommonHistsResults2nd->GetHistIntFlow())->GetBinContent(1); \r
1112   dVnErr[0] = (fCommonHistsResults2nd->GetHistIntFlow())->GetBinError(1); \r
1113   dVn[1] = (fCommonHistsResults4th->GetHistIntFlow())->GetBinContent(1); \r
1114   dVnErr[1] = (fCommonHistsResults4th->GetHistIntFlow())->GetBinError(1); \r
1115   dVn[2] = (fCommonHistsResults6th->GetHistIntFlow())->GetBinContent(1); \r
1116   dVnErr[2] = (fCommonHistsResults6th->GetHistIntFlow())->GetBinError(1); \r
1117   dVn[3] = (fCommonHistsResults8th->GetHistIntFlow())->GetBinContent(1); \r
1118   dVnErr[3] = (fCommonHistsResults8th->GetHistIntFlow())->GetBinError(1); \r
1119  } else if(type == "RP")\r
1120    {\r
1121     dVn[0] = (fCommonHistsResults2nd->GetHistIntFlowRP())->GetBinContent(1); \r
1122     dVnErr[0] = (fCommonHistsResults2nd->GetHistIntFlowRP())->GetBinError(1); \r
1123     dVn[1] = (fCommonHistsResults4th->GetHistIntFlowRP())->GetBinContent(1); \r
1124     dVnErr[1] = (fCommonHistsResults4th->GetHistIntFlowRP())->GetBinError(1); \r
1125     dVn[2] = (fCommonHistsResults6th->GetHistIntFlowRP())->GetBinContent(1); \r
1126     dVnErr[2] = (fCommonHistsResults6th->GetHistIntFlowRP())->GetBinError(1); \r
1127     dVn[3] = (fCommonHistsResults8th->GetHistIntFlowRP())->GetBinContent(1); \r
1128     dVnErr[3] = (fCommonHistsResults8th->GetHistIntFlowRP())->GetBinError(1); \r
1129    } else if(type == "POI")\r
1130      {\r
1131       dVn[0] = (fCommonHistsResults2nd->GetHistIntFlowPOI())->GetBinContent(1); \r
1132       dVnErr[0] = (fCommonHistsResults2nd->GetHistIntFlowPOI())->GetBinError(1); \r
1133       dVn[1] = (fCommonHistsResults4th->GetHistIntFlowPOI())->GetBinContent(1); \r
1134       dVnErr[1] = (fCommonHistsResults4th->GetHistIntFlowPOI())->GetBinError(1); \r
1135       dVn[2] = (fCommonHistsResults6th->GetHistIntFlowPOI())->GetBinContent(1); \r
1136       dVnErr[2] = (fCommonHistsResults6th->GetHistIntFlowPOI())->GetBinError(1); \r
1137       dVn[3] = (fCommonHistsResults8th->GetHistIntFlowPOI())->GetBinContent(1); \r
1138       dVnErr[3] = (fCommonHistsResults8th->GetHistIntFlowPOI())->GetBinError(1); \r
1139      }\r
1140  \r
1141  TString title = " flow estimates from Q-cumulants"; \r
1142  TString subtitle = "    ("; \r
1143  \r
1144  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
1145  {\r
1146   subtitle.Append(type);\r
1147   subtitle.Append(", without weights)");\r
1148  } else  \r
1149    {\r
1150     subtitle.Append(type);\r
1151     subtitle.Append(", with weights)");\r
1152    }\r
1153   \r
1154  cout<<endl;\r
1155  cout<<"*************************************"<<endl;\r
1156  cout<<"*************************************"<<endl;\r
1157  cout<<title.Data()<<endl; \r
1158  cout<<subtitle.Data()<<endl; \r
1159  cout<<endl;\r
1160   \r
1161  for(Int_t i=0;i<4;i++)\r
1162  {\r
1163   if(dVn[i]>=0.)\r
1164   {\r
1165    cout<<"  v_"<<n<<"{"<<2*(i+1)<<"} = "<<dVn[i]<<" +/- "<<dVnErr[i]<<endl;\r
1166   }\r
1167   else\r
1168   {\r
1169    cout<<"  v_"<<n<<"{"<<2*(i+1)<<"} = Im"<<endl;\r
1170   }  \r
1171  }\r
1172 \r
1173  cout<<endl;\r
1174  /*\r
1175  if(type == "NONAME")\r
1176  {\r
1177   cout<<"     nEvts = "<<nEvtsNoName<<", AvM = "<<dMultNoName<<endl; // to be improved\r
1178  }\r
1179  else if (type == "RP")\r
1180  {\r
1181   cout<<"     nEvts = "<<nEvtsRP<<", AvM = "<<dMultRP<<endl; // to be improved  \r
1182  } \r
1183  else if (type == "POI")\r
1184  {\r
1185   cout<<"     nEvts = "<<nEvtsPOI<<", AvM = "<<dMultPOI<<endl; // to be improved  \r
1186  } \r
1187  */\r
1188  cout<<"*************************************"<<endl;\r
1189  cout<<"*************************************"<<endl;\r
1190  cout<<endl; \r
1191   \r
1192 }// end of AliFlowAnalysisWithQCumulants::PrintFinalResultsForIntegratedFlow(TString type="NONAME");\r
1193 \r
1194 \r
1195 //================================================================================================================================\r
1196 \r
1197 \r
1198 void AliFlowAnalysisWithQCumulants::WriteHistograms(TString outputFileName)\r
1199 {\r
1200  //store the final results in output .root file\r
1201  TFile *output = new TFile(outputFileName.Data(),"RECREATE");\r
1202  //output->WriteObject(fHistList, "cobjQC","SingleKey");\r
1203  fHistList->Write(fHistList->GetName(), TObject::kSingleKey);\r
1204  delete output;\r
1205 }\r
1206 \r
1207 \r
1208 //================================================================================================================================\r
1209
1210
1211 void AliFlowAnalysisWithQCumulants::WriteHistograms(TDirectoryFile *outputFileName)
1212 {
1213  //store the final results in output .root file
1214  fHistList->SetName("cobjQC");
1215  fHistList->SetOwner(kTRUE);
1216  outputFileName->Add(fHistList);
1217  outputFileName->Write(outputFileName->GetName(), TObject::kSingleKey);
1218 }
1219 \r
1220
1221 //================================================================================================================================\r
1222
1223 \r
1224 void AliFlowAnalysisWithQCumulants::BookCommonHistograms()\r
1225 {\r
1226  // Book common control histograms and common histograms for final results.\r
1227  // common control histogram (ALL events)\r
1228  TString commonHistsName = "AliFlowCommonHistQC";\r
1229  commonHistsName += fAnalysisLabel->Data();\r
1230  fCommonHists = new AliFlowCommonHist(commonHistsName.Data());\r
1231  fHistList->Add(fCommonHists);  \r
1232  // common control histogram (for events with 2 and more particles)\r
1233  TString commonHists2ndOrderName = "AliFlowCommonHist2ndOrderQC";\r
1234  commonHists2ndOrderName += fAnalysisLabel->Data();\r
1235  fCommonHists2nd = new AliFlowCommonHist(commonHists2ndOrderName.Data());\r
1236  fHistList->Add(fCommonHists2nd);  \r
1237  // common control histogram (for events with 4 and more particles)\r
1238  TString commonHists4thOrderName = "AliFlowCommonHist4thOrderQC";\r
1239  commonHists4thOrderName += fAnalysisLabel->Data();\r
1240  fCommonHists4th = new AliFlowCommonHist(commonHists4thOrderName.Data());\r
1241  fHistList->Add(fCommonHists4th);  \r
1242  // common control histogram (for events with 6 and more particles)\r
1243  TString commonHists6thOrderName = "AliFlowCommonHist6thOrderQC";\r
1244  commonHists6thOrderName += fAnalysisLabel->Data();\r
1245  fCommonHists6th = new AliFlowCommonHist(commonHists6thOrderName.Data());\r
1246  fHistList->Add(fCommonHists6th);  \r
1247  // common control histogram (for events with 8 and more particles)\r
1248  TString commonHists8thOrderName = "AliFlowCommonHist8thOrderQC";\r
1249  commonHists8thOrderName += fAnalysisLabel->Data();\r
1250  fCommonHists8th = new AliFlowCommonHist(commonHists8thOrderName.Data());\r
1251  fHistList->Add(fCommonHists8th);    \r
1252  // common histograms for final results (calculated for events with 2 and more particles)\r
1253  TString commonHistResults2ndOrderName = "AliFlowCommonHistResults2ndOrderQC";\r
1254  commonHistResults2ndOrderName += fAnalysisLabel->Data();\r
1255  fCommonHistsResults2nd = new AliFlowCommonHistResults(commonHistResults2ndOrderName.Data());\r
1256  fHistList->Add(fCommonHistsResults2nd);  \r
1257  // common histograms for final results (calculated for events with 4 and more particles)\r
1258  TString commonHistResults4thOrderName = "AliFlowCommonHistResults4thOrderQC";\r
1259  commonHistResults4thOrderName += fAnalysisLabel->Data();\r
1260  fCommonHistsResults4th = new AliFlowCommonHistResults(commonHistResults4thOrderName.Data());\r
1261  fHistList->Add(fCommonHistsResults4th); \r
1262  // common histograms for final results (calculated for events with 6 and more particles)\r
1263  TString commonHistResults6thOrderName = "AliFlowCommonHistResults6thOrderQC";\r
1264  commonHistResults6thOrderName += fAnalysisLabel->Data();\r
1265  fCommonHistsResults6th = new AliFlowCommonHistResults(commonHistResults6thOrderName.Data());\r
1266  fHistList->Add(fCommonHistsResults6th);  \r
1267  // common histograms for final results (calculated for events with 8 and more particles)\r
1268  TString commonHistResults8thOrderName = "AliFlowCommonHistResults8thOrderQC";\r
1269  commonHistResults8thOrderName += fAnalysisLabel->Data();\r
1270  fCommonHistsResults8th = new AliFlowCommonHistResults(commonHistResults8thOrderName.Data());\r
1271  fHistList->Add(fCommonHistsResults8th); \r
1272  \r
1273 } // end of void AliFlowAnalysisWithQCumulants::BookCommonHistograms()\r
1274 \r
1275 \r
1276 //================================================================================================================================\r
1277 \r
1278 \r
1279 void AliFlowAnalysisWithQCumulants::BookAndFillWeightsHistograms()\r
1280 {\r
1281  // book and fill histograms which hold phi, pt and eta weights\r
1282 \r
1283  if(!fWeightsList)\r
1284  {\r
1285   cout<<"WARNING: fWeightsList is NULL in AFAWQC::BAFWH() !!!!"<<endl;\r
1286   exit(0);  \r
1287  }\r
1288     \r
1289  TString fUseParticleWeightsName = "fUseParticleWeightsQC";\r
1290  fUseParticleWeightsName += fAnalysisLabel->Data();\r
1291  fUseParticleWeights = new TProfile(fUseParticleWeightsName.Data(),"0 = particle weight not used, 1 = particle weight used ",3,0,3);\r
1292  fUseParticleWeights->SetLabelSize(0.06);\r
1293  (fUseParticleWeights->GetXaxis())->SetBinLabel(1,"w_{#phi}");\r
1294  (fUseParticleWeights->GetXaxis())->SetBinLabel(2,"w_{p_{T}}");\r
1295  (fUseParticleWeights->GetXaxis())->SetBinLabel(3,"w_{#eta}");\r
1296  fUseParticleWeights->Fill(0.5,(Int_t)fUsePhiWeights);\r
1297  fUseParticleWeights->Fill(1.5,(Int_t)fUsePtWeights);\r
1298  fUseParticleWeights->Fill(2.5,(Int_t)fUseEtaWeights);\r
1299  fWeightsList->Add(fUseParticleWeights); \r
1300   \r
1301  if(fUsePhiWeights)\r
1302  {\r
1303   if(fWeightsList->FindObject("phi_weights"))\r
1304   {\r
1305    fPhiWeights = dynamic_cast<TH1F*>(fWeightsList->FindObject("phi_weights"));\r
1306    if((fPhiWeights->GetBinWidth(1) > fPhiBinWidth) || (fPhiWeights->GetBinWidth(1) < fPhiBinWidth))\r
1307    {\r
1308     cout<<"WARNING: fPhiWeights->GetBinWidth(1) != fPhiBinWidth in AFAWQC::BAFWH() !!!!        "<<endl;\r
1309     cout<<"         This indicates inconsistent binning in phi histograms throughout the code."<<endl;\r
1310     exit(0);\r
1311    }\r
1312   } else \r
1313     {\r
1314      cout<<"WARNING: fWeightsList->FindObject(\"phi_weights\") is NULL in AFAWQC::BAFWH() !!!!"<<endl;\r
1315      exit(0);\r
1316     }\r
1317  } // end of if(fUsePhiWeights)\r
1318  \r
1319  if(fUsePtWeights) \r
1320  {\r
1321   if(fWeightsList->FindObject("pt_weights"))\r
1322   {\r
1323    fPtWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("pt_weights"));\r
1324    if((fPtWeights->GetBinWidth(1) > fPtBinWidth) || (fPtWeights->GetBinWidth(1) < fPtBinWidth))\r
1325    {\r
1326     cout<<"WARNING: fPtWeights->GetBinWidth(1) != fPtBinWidth in AFAWQC::BAFWH() !!!!         "<<endl;\r
1327     cout<<"         This indicates insconsistent binning in pt histograms throughout the code."<<endl;\r
1328     exit(0);\r
1329    }\r
1330   } else \r
1331     {\r
1332      cout<<"WARNING: fWeightsList->FindObject(\"pt_weights\") is NULL in AFAWQC::BAFWH() !!!!"<<endl;\r
1333      exit(0);\r
1334     }\r
1335  } // end of if(fUsePtWeights)    \r
1336 \r
1337  if(fUseEtaWeights) \r
1338  {\r
1339   if(fWeightsList->FindObject("eta_weights"))\r
1340   {\r
1341    fEtaWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("eta_weights"));\r
1342    if((fEtaWeights->GetBinWidth(1) > fEtaBinWidth) || (fEtaWeights->GetBinWidth(1) < fEtaBinWidth))\r
1343    {\r
1344     cout<<"WARNING: fEtaWeights->GetBinWidth(1) != fEtaBinWidth in AFAWQC::BAFWH() !!!!        "<<endl;\r
1345     cout<<"         This indicates insconsistent binning in eta histograms throughout the code."<<endl;\r
1346     exit(0);\r
1347    }\r
1348   } else \r
1349     {\r
1350      cout<<"WARNING: fUseEtaWeights && fWeightsList->FindObject(\"eta_weights\") is NULL in AFAWQC::BAFWH() !!!!"<<endl;\r
1351      exit(0);\r
1352     }\r
1353  } // end of if(fUseEtaWeights)\r
1354  \r
1355 } // end of AliFlowAnalysisWithQCumulants::BookAndFillWeightsHistograms()\r
1356 \r
1357 \r
1358 //================================================================================================================================\r
1359 \r
1360 \r
1361 void AliFlowAnalysisWithQCumulants::BookEverythingForIntegratedFlow()\r
1362 {\r
1363  // Book all objects for integrated flow:\r
1364  //  a) Book profile to hold all flags for integrated flow.\r
1365  //  b) Book event-by-event quantities.\r
1366  //  c) Book profiles. // to be improved (comment)\r
1367  //  d) Book histograms holding the final results.\r
1368  \r
1369  TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data members?)\r
1370  TString powerFlag[2] = {"linear","quadratic"}; // to be improved (should I promote this to data members?)\r
1371  \r
1372  // a) Book profile to hold all flags for integrated flow:\r
1373  TString intFlowFlagsName = "fIntFlowFlags";\r
1374  intFlowFlagsName += fAnalysisLabel->Data();\r
1375  fIntFlowFlags = new TProfile(intFlowFlagsName.Data(),"Flags for Integrated Flow",3,0,3);\r
1376  fIntFlowFlags->SetTickLength(-0.01,"Y");\r
1377  fIntFlowFlags->SetMarkerStyle(25);\r
1378  fIntFlowFlags->SetLabelSize(0.05);\r
1379  fIntFlowFlags->SetLabelOffset(0.02,"Y");\r
1380  (fIntFlowFlags->GetXaxis())->SetBinLabel(1,"Particle Weights");\r
1381  (fIntFlowFlags->GetXaxis())->SetBinLabel(2,"Event Weights");\r
1382  (fIntFlowFlags->GetXaxis())->SetBinLabel(3,"Corrected for NUA?");\r
1383  fIntFlowList->Add(fIntFlowFlags);\r
1384 \r
1385  // b) Book event-by-event quantities:\r
1386  // Re[Q_{m*n,k}], Im[Q_{m*n,k}] and S_{p,k}^M: \r
1387  fReQ  = new TMatrixD(4,9);\r
1388  fImQ  = new TMatrixD(4,9);\r
1389  fSMpk = new TMatrixD(8,9);\r
1390  // average correlations <2>, <4>, <6> and <8> for single event (bining is the same as in fIntFlowCorrelationsPro and fIntFlowCorrelationsHist):\r
1391  TString intFlowCorrelationsEBEName = "fIntFlowCorrelationsEBE";\r
1392  intFlowCorrelationsEBEName += fAnalysisLabel->Data();\r
1393  fIntFlowCorrelationsEBE = new TH1D(intFlowCorrelationsEBEName.Data(),intFlowCorrelationsEBEName.Data(),4,0,4);\r
1394  // weights for average correlations <2>, <4>, <6> and <8> for single event:\r
1395  TString intFlowEventWeightsForCorrelationsEBEName = "fIntFlowEventWeightsForCorrelationsEBE";\r
1396  intFlowEventWeightsForCorrelationsEBEName += fAnalysisLabel->Data();\r
1397  fIntFlowEventWeightsForCorrelationsEBE = new TH1D(intFlowEventWeightsForCorrelationsEBEName.Data(),intFlowEventWeightsForCorrelationsEBEName.Data(),4,0,4);\r
1398  // average all correlations for single event (bining is the same as in fIntFlowCorrelationsAllPro and fIntFlowCorrelationsAllHist):\r
1399  TString intFlowCorrelationsAllEBEName = "fIntFlowCorrelationsAllEBE";\r
1400  intFlowCorrelationsAllEBEName += fAnalysisLabel->Data();\r
1401  fIntFlowCorrelationsAllEBE = new TH1D(intFlowCorrelationsAllEBEName.Data(),intFlowCorrelationsAllEBEName.Data(),32,0,32);\r
1402  // average correction terms for non-uniform acceptance for single event \r
1403  // (binning is the same as in fIntFlowCorrectionTermsForNUAPro[2] and fIntFlowCorrectionTermsForNUAHist[2]):\r
1404  TString fIntFlowCorrectionTermsForNUAEBEName = "fIntFlowCorrectionTermsForNUAEBE";\r
1405  fIntFlowCorrectionTermsForNUAEBEName += fAnalysisLabel->Data();\r
1406  for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1407  {\r
1408   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
1409  }\r
1410  \r
1411  // c) Book profiles: // to be improved (comment)\r
1412  // profile to hold average multiplicities and number of events for events with nRP>=0, nRP>=1, ... , and nRP>=8:\r
1413  TString avMultiplicityName = "fAvMultiplicity";\r
1414  avMultiplicityName += fAnalysisLabel->Data();\r
1415  fAvMultiplicity = new TProfile(avMultiplicityName.Data(),"Average Multiplicities of RPs",9,0,9);\r
1416  fAvMultiplicity->SetTickLength(-0.01,"Y");\r
1417  fAvMultiplicity->SetMarkerStyle(25);\r
1418  fAvMultiplicity->SetLabelSize(0.05);\r
1419  fAvMultiplicity->SetLabelOffset(0.02,"Y");\r
1420  fAvMultiplicity->SetYTitle("Average Multiplicity");\r
1421  (fAvMultiplicity->GetXaxis())->SetBinLabel(1,"all evts");\r
1422  (fAvMultiplicity->GetXaxis())->SetBinLabel(2,"n_{RP} #geq 1");\r
1423  (fAvMultiplicity->GetXaxis())->SetBinLabel(3,"n_{RP} #geq 2");\r
1424  (fAvMultiplicity->GetXaxis())->SetBinLabel(4,"n_{RP} #geq 3");\r
1425  (fAvMultiplicity->GetXaxis())->SetBinLabel(5,"n_{RP} #geq 4");\r
1426  (fAvMultiplicity->GetXaxis())->SetBinLabel(6,"n_{RP} #geq 5");\r
1427  (fAvMultiplicity->GetXaxis())->SetBinLabel(7,"n_{RP} #geq 6");\r
1428  (fAvMultiplicity->GetXaxis())->SetBinLabel(8,"n_{RP} #geq 7");\r
1429  (fAvMultiplicity->GetXaxis())->SetBinLabel(9,"n_{RP} #geq 8");\r
1430  fIntFlowProfiles->Add(fAvMultiplicity);\r
1431  // average correlations <<2>>, <<4>>, <<6>> and <<8>> for all events (with wrong errors!):\r
1432  TString intFlowCorrelationsProName = "fIntFlowCorrelationsPro";\r
1433  intFlowCorrelationsProName += fAnalysisLabel->Data();\r
1434  fIntFlowCorrelationsPro = new TProfile(intFlowCorrelationsProName.Data(),"Average correlations for all events",4,0,4,"s");\r
1435  fIntFlowCorrelationsPro->SetTickLength(-0.01,"Y");\r
1436  fIntFlowCorrelationsPro->SetMarkerStyle(25);\r
1437  fIntFlowCorrelationsPro->SetLabelSize(0.06);\r
1438  fIntFlowCorrelationsPro->SetLabelOffset(0.01,"Y");\r
1439  (fIntFlowCorrelationsPro->GetXaxis())->SetBinLabel(1,"<<2>>");\r
1440  (fIntFlowCorrelationsPro->GetXaxis())->SetBinLabel(2,"<<4>>");\r
1441  (fIntFlowCorrelationsPro->GetXaxis())->SetBinLabel(3,"<<6>>");\r
1442  (fIntFlowCorrelationsPro->GetXaxis())->SetBinLabel(4,"<<8>>");\r
1443  fIntFlowProfiles->Add(fIntFlowCorrelationsPro);\r
1444  // averaged all correlations for all events (with wrong errors!):\r
1445  TString intFlowCorrelationsAllProName = "fIntFlowCorrelationsAllPro";\r
1446  intFlowCorrelationsAllProName += fAnalysisLabel->Data();\r
1447  fIntFlowCorrelationsAllPro = new TProfile(intFlowCorrelationsAllProName.Data(),"Average correlations for all events",32,0,32,"s");\r
1448  fIntFlowCorrelationsAllPro->SetTickLength(-0.01,"Y");\r
1449  fIntFlowCorrelationsAllPro->SetMarkerStyle(25);\r
1450  fIntFlowCorrelationsAllPro->SetLabelSize(0.03);\r
1451  fIntFlowCorrelationsAllPro->SetLabelOffset(0.01,"Y");\r
1452  // 2-p correlations:\r
1453  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(1,"<<2>>_{n|n}");\r
1454  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(2,"<<2>>_{2n|2n}");\r
1455  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(3,"<<2>>_{3n|3n}");\r
1456  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(4,"<<2>>_{4n|4n}");\r
1457  // 3-p correlations:\r
1458  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(6,"<<3>>_{2n|n,n}");\r
1459  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(7,"<<3>>_{3n|2n,n}");\r
1460  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(8,"<<3>>_{4n|2n,2n}");\r
1461  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(9,"<<3>>_{4n|3n,n}");\r
1462  // 4-p correlations:\r
1463  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(11,"<<4>>_{n,n|n,n}"); \r
1464  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(12,"<<4>>_{2n,n|2n,n}");\r
1465  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(13,"<<4>>_{2n,2n|2n,2n}");\r
1466  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(14,"<<4>>_{3n|n,n,n}");\r
1467  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(15,"<<4>>_{3n,n|3n,n}");\r
1468  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(16,"<<4>>_{3n,n|2n,2n}"); \r
1469  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(17,"<<4>>_{4n|2n,n,n}");\r
1470  // 5-p correlations:\r
1471  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(19,"<<5>>_{2n|n,n,n,n}"); \r
1472  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(20,"<<5>>_{2n,2n|2n,n,n}");\r
1473  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(21,"<<5>>_{3n,n|2n,n,n}");\r
1474  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(22,"<<5>>_{4n|n,n,n,n}");\r
1475  // 6-p correlations:\r
1476  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(24,"<<6>>_{n,n,n|n,n,n}");\r
1477  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(25,"<<6>>_{2n,n,n|2n,n,n}");\r
1478  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(26,"<<6>>_{2n,2n|n,n,n,n}");\r
1479  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(27,"<<6>>_{3n,n|n,n,n,n}");\r
1480  // 7-p correlations:  \r
1481  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(29,"<<7>>_{2n,n,n|n,n,n,n}");\r
1482  // 8-p correlations:\r
1483  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(31,"<<8>>_{n,n,n,n|n,n,n,n}");\r
1484  fIntFlowProfiles->Add(fIntFlowCorrelationsAllPro);\r
1485  // when particle weights are used some extra correlations appear:\r
1486  if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights) \r
1487  {\r
1488   TString intFlowExtraCorrelationsProName = "fIntFlowExtraCorrelationsPro";\r
1489   intFlowExtraCorrelationsProName += fAnalysisLabel->Data();\r
1490   fIntFlowExtraCorrelationsPro = new TProfile(intFlowExtraCorrelationsProName.Data(),"Average extra correlations for all events",100,0,100,"s");\r
1491   fIntFlowExtraCorrelationsPro->SetTickLength(-0.01,"Y");\r
1492   fIntFlowExtraCorrelationsPro->SetMarkerStyle(25);\r
1493   fIntFlowExtraCorrelationsPro->SetLabelSize(0.03);\r
1494   fIntFlowExtraCorrelationsPro->SetLabelOffset(0.01,"Y");\r
1495   // extra 2-p correlations:\r
1496   (fIntFlowExtraCorrelationsPro->GetXaxis())->SetBinLabel(1,"<<w1^3 w2 cos(n*(phi1-phi2))>>");\r
1497   (fIntFlowExtraCorrelationsPro->GetXaxis())->SetBinLabel(2,"<<w1 w2 w3^2 cos(n*(phi1-phi2))>>");\r
1498   // ...\r
1499   fIntFlowProfiles->Add(fIntFlowExtraCorrelationsPro);\r
1500  } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
1501  // average product of correlations <2>, <4>, <6> and <8>:  \r
1502  TString intFlowProductOfCorrelationsProName = "fIntFlowProductOfCorrelationsPro";\r
1503  intFlowProductOfCorrelationsProName += fAnalysisLabel->Data();\r
1504  fIntFlowProductOfCorrelationsPro = new TProfile(intFlowProductOfCorrelationsProName.Data(),"Average products of correlations",6,0,6);\r
1505  fIntFlowProductOfCorrelationsPro->SetTickLength(-0.01,"Y");\r
1506  fIntFlowProductOfCorrelationsPro->SetMarkerStyle(25); \r
1507  fIntFlowProductOfCorrelationsPro->SetLabelSize(0.05);\r
1508  fIntFlowProductOfCorrelationsPro->SetLabelOffset(0.01,"Y");\r
1509  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(1,"<<2><4>>");\r
1510  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(2,"<<2><6>>");\r
1511  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(3,"<<2><8>>");\r
1512  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(4,"<<4><6>>");\r
1513  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(5,"<<4><8>>");\r
1514  (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(6,"<<6><8>>");\r
1515  fIntFlowProfiles->Add(fIntFlowProductOfCorrelationsPro);\r
1516  // average correction terms for non-uniform acceptance (with wrong errors!):\r
1517  for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1518  {\r
1519   TString intFlowCorrectionTermsForNUAProName = "fIntFlowCorrectionTermsForNUAPro";\r
1520   intFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();\r
1521   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
1522   fIntFlowCorrectionTermsForNUAPro[sc]->SetTickLength(-0.01,"Y");\r
1523   fIntFlowCorrectionTermsForNUAPro[sc]->SetMarkerStyle(25);\r
1524   fIntFlowCorrectionTermsForNUAPro[sc]->SetLabelSize(0.03);\r
1525   fIntFlowCorrectionTermsForNUAPro[sc]->SetLabelOffset(0.01,"Y");\r
1526   // 1-particle terms:\r
1527   (fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->SetBinLabel(1,Form("<<%s(n(phi1))>>",sinCosFlag[sc].Data()));\r
1528   // 2-particle terms:\r
1529   (fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->SetBinLabel(2,Form("<<%s(n(phi1+phi2))>>",sinCosFlag[sc].Data()));  \r
1530   // 3-particle terms:\r
1531   (fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->SetBinLabel(3,Form("<<%s(n(phi1-phi2-phi3))>>",sinCosFlag[sc].Data()));  \r
1532   // ... \r
1533   fIntFlowProfiles->Add(fIntFlowCorrectionTermsForNUAPro[sc]);\r
1534  } // end of for(Int_t sc=0;sc<2;sc++) \r
1535  \r
1536  // d) Book histograms holding the final results:\r
1537  // average correlations <<2>>, <<4>>, <<6>> and <<8>> for all events (with correct errors!):\r
1538  TString intFlowCorrelationsHistName = "fIntFlowCorrelationsHist";\r
1539  intFlowCorrelationsHistName += fAnalysisLabel->Data();\r
1540  fIntFlowCorrelationsHist = new TH1D(intFlowCorrelationsHistName.Data(),"Average correlations for all events",4,0,4);\r
1541  fIntFlowCorrelationsHist->SetTickLength(-0.01,"Y");\r
1542  fIntFlowCorrelationsHist->SetMarkerStyle(25);\r
1543  fIntFlowCorrelationsHist->SetLabelSize(0.06);\r
1544  fIntFlowCorrelationsHist->SetLabelOffset(0.01,"Y");\r
1545  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(1,"<<2>>");\r
1546  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(2,"<<4>>");\r
1547  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(3,"<<6>>");\r
1548  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(4,"<<8>>");\r
1549  fIntFlowResults->Add(fIntFlowCorrelationsHist);\r
1550  // average all correlations for all events (with correct errors!):\r
1551  TString intFlowCorrelationsAllHistName = "fIntFlowCorrelationsAllHist";\r
1552  intFlowCorrelationsAllHistName += fAnalysisLabel->Data();\r
1553  fIntFlowCorrelationsAllHist = new TH1D(intFlowCorrelationsAllHistName.Data(),"Average correlations for all events",32,0,32);\r
1554  fIntFlowCorrelationsAllHist->SetTickLength(-0.01,"Y");\r
1555  fIntFlowCorrelationsAllHist->SetMarkerStyle(25);\r
1556  fIntFlowCorrelationsAllHist->SetLabelSize(0.03);\r
1557  fIntFlowCorrelationsAllHist->SetLabelOffset(0.01,"Y");\r
1558  // 2-p correlations:\r
1559  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(1,"<<2>>_{n|n}");\r
1560  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(2,"<<2>>_{2n|2n}");\r
1561  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(3,"<<2>>_{3n|3n}");\r
1562  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(4,"<<2>>_{4n|4n}");\r
1563  // 3-p correlations:\r
1564  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(6,"<<3>>_{2n|n,n}");\r
1565  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(7,"<<3>>_{3n|2n,n}");\r
1566  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(8,"<<3>>_{4n|2n,2n}");\r
1567  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(9,"<<3>>_{4n|3n,n}");\r
1568  // 4-p correlations:\r
1569  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(11,"<<4>>_{n,n|n,n}"); \r
1570  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(12,"<<4>>_{2n,n|2n,n}");\r
1571  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(13,"<<4>>_{2n,2n|2n,2n}");\r
1572  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(14,"<<4>>_{3n|n,n,n}");\r
1573  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(15,"<<4>>_{3n,n|3n,n}");\r
1574  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(16,"<<4>>_{3n,n|2n,2n}"); \r
1575  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(17,"<<4>>_{4n|2n,n,n}");\r
1576  // 5-p correlations:\r
1577  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(19,"<<5>>_{2n|n,n,n,n}"); \r
1578  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(20,"<<5>>_{2n,2n|2n,n,n}");\r
1579  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(21,"<<5>>_{3n,n|2n,n,n}");\r
1580  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(22,"<<5>>_{4n|n,n,n,n}");\r
1581  // 6-p correlations:\r
1582  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(24,"<<6>>_{n,n,n|n,n,n}");\r
1583  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(25,"<<6>>_{2n,n,n|2n,n,n}");\r
1584  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(26,"<<6>>_{2n,2n|n,n,n,n}");\r
1585  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(27,"<<6>>_{3n,n|n,n,n,n}");\r
1586  // 7-p correlations:  \r
1587  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(29,"<<7>>_{2n,n,n|n,n,n,n}");\r
1588  // 8-p correlations:\r
1589  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(31,"<<8>>_{n,n,n,n|n,n,n,n}");\r
1590  fIntFlowResults->Add(fIntFlowCorrelationsAllHist);\r
1591  // average correction terms for non-uniform acceptance (with correct errors!):\r
1592  for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1593  {\r
1594   TString intFlowCorrectionTermsForNUAHistName = "fIntFlowCorrectionTermsForNUAHist";\r
1595   intFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();\r
1596   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
1597   fIntFlowCorrectionTermsForNUAHist[sc]->SetTickLength(-0.01,"Y");\r
1598   fIntFlowCorrectionTermsForNUAHist[sc]->SetMarkerStyle(25);\r
1599   fIntFlowCorrectionTermsForNUAHist[sc]->SetLabelSize(0.03);\r
1600   fIntFlowCorrectionTermsForNUAHist[sc]->SetLabelOffset(0.01,"Y");\r
1601   // ......................................................................... \r
1602   // 1-p terms:\r
1603   (fIntFlowCorrectionTermsForNUAHist[sc]->GetXaxis())->SetBinLabel(1,Form("%s(n(#phi_{1}))>",sinCosFlag[sc].Data()));\r
1604   // 2-p terms:\r
1605   // 3-p terms:\r
1606   // ...\r
1607   // ......................................................................... \r
1608   fIntFlowResults->Add(fIntFlowCorrectionTermsForNUAHist[sc]);\r
1609  } // end of for(Int_t sc=0;sc<2;sc++) \r
1610  // covariances (multiplied with weight dependent prefactor):\r
1611  TString intFlowCovariancesName = "fIntFlowCovariances";\r
1612  intFlowCovariancesName += fAnalysisLabel->Data();\r
1613  fIntFlowCovariances = new TH1D(intFlowCovariancesName.Data(),"Covariances (multiplied with weight dependent prefactor)",6,0,6);\r
1614  fIntFlowCovariances->SetLabelSize(0.04);\r
1615  fIntFlowCovariances->SetMarkerStyle(25);\r
1616  (fIntFlowCovariances->GetXaxis())->SetBinLabel(1,"Cov(<2>,<4>)");\r
1617  (fIntFlowCovariances->GetXaxis())->SetBinLabel(2,"Cov(<2>,<6>)");\r
1618  (fIntFlowCovariances->GetXaxis())->SetBinLabel(3,"Cov(<2>,<8>)");\r
1619  (fIntFlowCovariances->GetXaxis())->SetBinLabel(4,"Cov(<4>,<6>)");\r
1620  (fIntFlowCovariances->GetXaxis())->SetBinLabel(5,"Cov(<4>,<8>)");\r
1621  (fIntFlowCovariances->GetXaxis())->SetBinLabel(6,"Cov(<6>,<8>)");  \r
1622  fIntFlowResults->Add(fIntFlowCovariances);\r
1623  // sum of linear and quadratic event weights for <2>, <4>, <6> and <8>:\r
1624  TString intFlowSumOfEventWeightsName = "fIntFlowSumOfEventWeights";\r
1625  intFlowSumOfEventWeightsName += fAnalysisLabel->Data();\r
1626  for(Int_t power=0;power<2;power++)\r
1627  {\r
1628   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
1629   fIntFlowSumOfEventWeights[power]->SetLabelSize(0.05);\r
1630   fIntFlowSumOfEventWeights[power]->SetMarkerStyle(25);\r
1631   if(power == 0)\r
1632   {\r
1633    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(1,"#sum_{i=1}^{N} w_{<2>}");\r
1634    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(2,"#sum_{i=1}^{N} w_{<4>}");\r
1635    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(3,"#sum_{i=1}^{N} w_{<6>}");\r
1636    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(4,"#sum_{i=1}^{N} w_{<8>}");\r
1637   } else if (power == 1) \r
1638     {\r
1639      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(1,"#sum_{i=1}^{N} w_{<2>}^{2}");\r
1640      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(2,"#sum_{i=1}^{N} w_{<4>}^{2}");\r
1641      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(3,"#sum_{i=1}^{N} w_{<6>}^{2}");\r
1642      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(4,"#sum_{i=1}^{N} w_{<8>}^{2}");\r
1643     }\r
1644   fIntFlowResults->Add(fIntFlowSumOfEventWeights[power]);\r
1645  } \r
1646  // sum of products of event weights for correlations <2>, <4>, <6> and <8>:  \r
1647  TString intFlowSumOfProductOfEventWeightsName = "fIntFlowSumOfProductOfEventWeights";\r
1648  intFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();\r
1649  fIntFlowSumOfProductOfEventWeights = new TH1D(intFlowSumOfProductOfEventWeightsName.Data(),"Sum of product of event weights for correlations",6,0,6);\r
1650  fIntFlowSumOfProductOfEventWeights->SetLabelSize(0.05);\r
1651  fIntFlowSumOfProductOfEventWeights->SetMarkerStyle(25);\r
1652  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(1,"#sum_{i=1}^{N} w_{<2>} w_{<4>}");\r
1653  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(2,"#sum_{i=1}^{N} w_{<2>} w_{<6>}");\r
1654  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(3,"#sum_{i=1}^{N} w_{<2>} w_{<8>}");\r
1655  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(4,"#sum_{i=1}^{N} w_{<4>} w_{<6>}");\r
1656  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(5,"#sum_{i=1}^{N} w_{<4>} w_{<8>}");\r
1657  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(6,"#sum_{i=1}^{N} w_{<6>} w_{<8>}");\r
1658  fIntFlowResults->Add(fIntFlowSumOfProductOfEventWeights);\r
1659  // final results for integrated Q-cumulants:\r
1660  TString intFlowQcumulantsName = "fIntFlowQcumulants";\r
1661  intFlowQcumulantsName += fAnalysisLabel->Data();\r
1662  fIntFlowQcumulants = new TH1D(intFlowQcumulantsName.Data(),"Integrated Q-cumulants",4,0,4);\r
1663  fIntFlowQcumulants->SetLabelSize(0.05);\r
1664  fIntFlowQcumulants->SetMarkerStyle(25);\r
1665  (fIntFlowQcumulants->GetXaxis())->SetBinLabel(1,"QC{2}");\r
1666  (fIntFlowQcumulants->GetXaxis())->SetBinLabel(2,"QC{4}");\r
1667  (fIntFlowQcumulants->GetXaxis())->SetBinLabel(3,"QC{6}");\r
1668  (fIntFlowQcumulants->GetXaxis())->SetBinLabel(4,"QC{8}");\r
1669  fIntFlowResults->Add(fIntFlowQcumulants);\r
1670  // final integrated flow estimates from Q-cumulants:\r
1671  TString intFlowName = "fIntFlow";\r
1672  intFlowName += fAnalysisLabel->Data();  \r
1673  // integrated flow from Q-cumulants:\r
1674  fIntFlow = new TH1D(intFlowName.Data(),"Integrated flow estimates from Q-cumulants",4,0,4);\r
1675  fIntFlow->SetLabelSize(0.05);\r
1676  fIntFlow->SetMarkerStyle(25);\r
1677  (fIntFlow->GetXaxis())->SetBinLabel(1,"v_{2}{2,QC}");\r
1678  (fIntFlow->GetXaxis())->SetBinLabel(2,"v_{2}{4,QC}");\r
1679  (fIntFlow->GetXaxis())->SetBinLabel(3,"v_{2}{6,QC}");\r
1680  (fIntFlow->GetXaxis())->SetBinLabel(4,"v_{2}{8,QC}");\r
1681  fIntFlowResults->Add(fIntFlow);\r
1682 \r
1683  /* // to be improved (removed):\r
1684   // final average weighted multi-particle correlations for all events calculated from Q-vectors\r
1685   fQCorrelations[1] = new TProfile("Weighted correlations","final average multi-particle correlations from weighted Q-vectors",200,0,200,"s");\r
1686   fQCorrelations[1]->SetTickLength(-0.01,"Y");\r
1687   fQCorrelations[1]->SetMarkerStyle(25);\r
1688   fQCorrelations[1]->SetLabelSize(0.03);\r
1689   fQCorrelations[1]->SetLabelOffset(0.01,"Y");\r
1690   // 2-particle correlations:\r
1691   (fQCorrelations[1]->GetXaxis())->SetBinLabel(1,"<w_{1}w_{2}cos(n(#phi_{1}-#phi_{2}))>");\r
1692   (fQCorrelations[1]->GetXaxis())->SetBinLabel(2,"<w_{1}^{2}w_{2}^{2}cos(2n(#phi_{1}-#phi_{2}))>");\r
1693   (fQCorrelations[1]->GetXaxis())->SetBinLabel(3,"<w_{1}^{3}w_{2}^{3}cos(3n(#phi_{1}-#phi_{2}))>");\r
1694   (fQCorrelations[1]->GetXaxis())->SetBinLabel(4,"<w_{1}^{4}w_{2}^{4}cos(4n(#phi_{1}-#phi_{2}))>");\r
1695   (fQCorrelations[1]->GetXaxis())->SetBinLabel(5,"<w_{1}^{3}w_{2}cos(n(#phi_{1}-#phi_{2}))>");\r
1696   (fQCorrelations[1]->GetXaxis())->SetBinLabel(6,"<w_{1}^{2}w_{2}w_{3}cos(n(#phi_{1}-#phi_{2}))>");\r
1697   // 3-particle correlations:\r
1698   (fQCorrelations[1]->GetXaxis())->SetBinLabel(21,"<w_{1}w_{2}w_{3}^{2}cos(n(2#phi_{1}-#phi_{2}-#phi_{3}))>");\r
1699   // 4-particle correlations:\r
1700   (fQCorrelations[1]->GetXaxis())->SetBinLabel(41,"<w_{1}w_{2}w_{3}w_{4}cos(n(#phi_{1}+#phi_{2}-#phi_{3}-#phi_{4}))>");\r
1701   // add fQCorrelations[1] to the list fIntFlowList:\r
1702   fIntFlowList->Add(fQCorrelations[1]); \r
1703  */\r
1704   \r
1705 } // end of AliFlowAnalysisWithQCumulants::BookEverythingForIntegratedFlow()\r
1706 \r
1707 \r
1708 //================================================================================================================================\r
1709 \r
1710 \r
1711 void AliFlowAnalysisWithQCumulants::InitializeArraysForNestedLoops()\r
1712 {\r
1713  // Initialize arrays of all objects relevant for calculations with nested loops.\r
1714  \r
1715  // integrated flow:\r
1716  for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1717  {\r
1718   fIntFlowDirectCorrectionTermsForNUA[sc] = NULL;\r
1719  } \r
1720 \r
1721  // differential flow:  \r
1722  // correlations:\r
1723  for(Int_t t=0;t<2;t++) // type: RP or POI\r
1724  { \r
1725   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1726   {\r
1727    for(Int_t ci=0;ci<4;ci++) // correlation index\r
1728    {\r
1729     fDiffFlowDirectCorrelations[t][pe][ci] = NULL;\r
1730    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index  \r
1731   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1732  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
1733  // correction terms for non-uniform acceptance:\r
1734  for(Int_t t=0;t<2;t++) // type: RP or POI\r
1735  { \r
1736   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1737   {\r
1738    for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1739    {\r
1740     for(Int_t cti=0;cti<9;cti++) // correction term index\r
1741     {\r
1742      fDiffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti] = NULL;\r
1743     }   \r
1744    }\r
1745   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1746  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
1747 \r
1748 \r
1749 } // end of void AliFlowAnalysisWithQCumulants::InitializeArraysForNestedLoops()\r
1750 \r
1751 \r
1752 //================================================================================================================================\r
1753 \r
1754 \r
1755 void AliFlowAnalysisWithQCumulants::BookEverythingForNestedLoops()\r
1756 {\r
1757  // Book all objects relevant for calculations with nested loops.\r
1758  \r
1759  TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data members?)\r
1760  TString typeFlag[2] = {"RP","POI"}; // to be improved (should I promote this to data members?)\r
1761  TString ptEtaFlag[2] = {"p_{T}","#eta"}; // to be improved (should I promote this to data members?)\r
1762  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"}; // to be improved (should I promote this to data members?)\r
1763  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};\r
1764  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};\r
1765 \r
1766  TString evaluateNestedLoopsName = "fEvaluateNestedLoops";\r
1767  evaluateNestedLoopsName += fAnalysisLabel->Data();\r
1768  fEvaluateNestedLoops = new TProfile(evaluateNestedLoopsName.Data(),"Flags for nested loops",4,0,4);\r
1769  fEvaluateNestedLoops->SetLabelSize(0.03);\r
1770  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(1,"fEvaluateIntFlowNestedLoops");\r
1771  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(2,"fEvaluateDiffFlowNestedLoops");\r
1772  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(3,"fCrossCheckInPtBinNo");\r
1773  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(4,"fCrossCheckInEtaBinNo");\r
1774  fEvaluateNestedLoops->Fill(0.5,(Int_t)fEvaluateIntFlowNestedLoops);\r
1775  fEvaluateNestedLoops->Fill(1.5,(Int_t)fEvaluateDiffFlowNestedLoops);\r
1776  fEvaluateNestedLoops->Fill(2.5,fCrossCheckInPtBinNo);\r
1777  fEvaluateNestedLoops->Fill(3.5,fCrossCheckInEtaBinNo);\r
1778  fNestedLoopsList->Add(fEvaluateNestedLoops);\r
1779  // nested loops for integrated flow:\r
1780  if(fEvaluateIntFlowNestedLoops)\r
1781  {\r
1782   // correlations:\r
1783   TString intFlowDirectCorrelationsName = "fIntFlowDirectCorrelations";\r
1784   intFlowDirectCorrelationsName += fAnalysisLabel->Data();\r
1785   fIntFlowDirectCorrelations = new TProfile(intFlowDirectCorrelationsName.Data(),"Multiparticle correlations calculated with nested loops (for int. flow)",32,0,32,"s");\r
1786   fNestedLoopsList->Add(fIntFlowDirectCorrelations);\r
1787   if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
1788   {\r
1789    TString intFlowExtraDirectCorrelationsName = "fIntFlowExtraDirectCorrelations";\r
1790    intFlowExtraDirectCorrelationsName += fAnalysisLabel->Data();\r
1791    fIntFlowExtraDirectCorrelations = new TProfile(intFlowExtraDirectCorrelationsName.Data(),"Extra multiparticle correlations calculated with nested loops (for int. flow)",100,0,100,"s");\r
1792    fNestedLoopsList->Add(fIntFlowExtraDirectCorrelations);  \r
1793   } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
1794   // correction terms for non-uniform acceptance:\r
1795   for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
1796   {\r
1797    TString intFlowDirectCorrectionTermsForNUAName = "fIntFlowDirectCorrectionTermsForNUA";\r
1798    intFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();\r
1799    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
1800    fNestedLoopsList->Add(fIntFlowDirectCorrectionTermsForNUA[sc]);\r
1801   } // end of for(Int_t sc=0;sc<2;sc++) \r
1802  } // end of if(fEvaluateIntFlowNestedLoops)\r
1803  \r
1804  // nested loops for differential flow: \r
1805  if(fEvaluateDiffFlowNestedLoops)\r
1806  {\r
1807   // reduced correlations:\r
1808   TString diffFlowDirectCorrelationsName = "fDiffFlowDirectCorrelations";\r
1809   diffFlowDirectCorrelationsName += fAnalysisLabel->Data();\r
1810   for(Int_t t=0;t<2;t++) // type: RP or POI\r
1811   { \r
1812    for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1813    {\r
1814     for(Int_t rci=0;rci<4;rci++) // reduced correlation index\r
1815     {\r
1816      // reduced correlations:\r
1817      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
1818      fDiffFlowDirectCorrelations[t][pe][rci]->SetXTitle(ptEtaFlag[pe].Data());\r
1819      fNestedLoopsList->Add(fDiffFlowDirectCorrelations[t][pe][rci]); // to be improved (add dedicated list to hold reduced correlations)\r
1820     } // end of for(Int_t rci=0;rci<4;rci++) // correlation index\r
1821    } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
1822   } // end of for(Int_t t=0;t<2;t++) // type: RP or POI \r
1823  } // end of if(fEvaluateDiffFlowNestedLoops)\r
1824  // correction terms for non-uniform acceptance:\r
1825  TString diffFlowDirectCorrectionTermsForNUAName = "fDiffFlowDirectCorrectionTermsForNUA";\r
1826  diffFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();\r
1827  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)\r
1828  { \r
1829   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
1830   {\r
1831    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
1832    {\r
1833     for(Int_t cti=0;cti<9;cti++) // correction term index\r
1834     {\r
1835      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
1836      fNestedLoopsList->Add(fDiffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti]);\r
1837     }\r
1838    }\r
1839   }\r
1840  } \r
1841 \r
1842 } // end of AliFlowAnalysisWithQCumulants::BookEverythingForNestedLoops()\r
1843 \r
1844 \r
1845 //================================================================================================================================\r
1846 \r
1847 \r
1848 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelations()\r
1849 {\r
1850  // calculate all correlations needed for integrated flow\r
1851  \r
1852  // multiplicity:\r
1853  Double_t dMult = (*fSMpk)(0,0);\r
1854  \r
1855  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
1856  Double_t dReQ1n = (*fReQ)(0,0);\r
1857  Double_t dReQ2n = (*fReQ)(1,0);\r
1858  Double_t dReQ3n = (*fReQ)(2,0);\r
1859  Double_t dReQ4n = (*fReQ)(3,0);\r
1860  Double_t dImQ1n = (*fImQ)(0,0);\r
1861  Double_t dImQ2n = (*fImQ)(1,0);\r
1862  Double_t dImQ3n = (*fImQ)(2,0);\r
1863  Double_t dImQ4n = (*fImQ)(3,0);\r
1864   \r
1865  // real and imaginary parts of some expressions involving various combinations of Q-vectors evaluated in harmonics n, 2n, 3n and 4n:\r
1866  // (these expression appear in the Eqs. for the multi-particle correlations bellow)\r
1867  \r
1868  // Re[Q_{2n} Q_{n}^* Q_{n}^*]\r
1869  Double_t reQ2nQ1nstarQ1nstar = pow(dReQ1n,2.)*dReQ2n + 2.*dReQ1n*dImQ1n*dImQ2n - pow(dImQ1n,2.)*dReQ2n; \r
1870  \r
1871  // Im[Q_{2n} Q_{n}^* Q_{n}^*]\r
1872  //Double_t imQ2nQ1nstarQ1nstar = pow(dReQ1n,2.)*dImQ2n-2.*dReQ1n*dImQ1n*dReQ2n-pow(dImQ1n,2.)*dImQ2n; \r
1873  \r
1874  // Re[Q_{n} Q_{n} Q_{2n}^*] = Re[Q_{2n} Q_{n}^* Q_{n}^*]\r
1875  Double_t reQ1nQ1nQ2nstar = reQ2nQ1nstarQ1nstar; \r
1876  \r
1877  // Re[Q_{3n} Q_{n} Q_{2n}^* Q_{2n}^*]\r
1878  Double_t reQ3nQ1nQ2nstarQ2nstar = (pow(dReQ2n,2.)-pow(dImQ2n,2.))*(dReQ3n*dReQ1n-dImQ3n*dImQ1n) \r
1879                                  + 2.*dReQ2n*dImQ2n*(dReQ3n*dImQ1n+dImQ3n*dReQ1n);\r
1880 \r
1881  // Im[Q_{3n} Q_{n} Q_{2n}^* Q_{2n}^*]                                                                  \r
1882  //Double_t imQ3nQ1nQ2nstarQ2nstar = calculate and implement this (deleteMe)\r
1883   \r
1884  // Re[Q_{2n} Q_{2n} Q_{3n}^* Q_{1n}^*] = Re[Q_{3n} Q_{n} Q_{2n}^* Q_{2n}^*]\r
1885  Double_t reQ2nQ2nQ3nstarQ1nstar = reQ3nQ1nQ2nstarQ2nstar;\r
1886   \r
1887  // Re[Q_{4n} Q_{2n}^* Q_{2n}^*]\r
1888  Double_t reQ4nQ2nstarQ2nstar = pow(dReQ2n,2.)*dReQ4n+2.*dReQ2n*dImQ2n*dImQ4n-pow(dImQ2n,2.)*dReQ4n;\r
1889 \r
1890  // Im[Q_{4n} Q_{2n}^* Q_{2n}^*]\r
1891  //Double_t imQ4nQ2nstarQ2nstar = calculate and implement this (deleteMe)\r
1892  \r
1893  // Re[Q_{2n} Q_{2n} Q_{4n}^*] =  Re[Q_{4n} Q_{2n}^* Q_{2n}^*]\r
1894  Double_t reQ2nQ2nQ4nstar = reQ4nQ2nstarQ2nstar;\r
1895  \r
1896  // Re[Q_{4n} Q_{3n}^* Q_{n}^*]\r
1897  Double_t reQ4nQ3nstarQ1nstar = dReQ4n*(dReQ3n*dReQ1n-dImQ3n*dImQ1n)+dImQ4n*(dReQ3n*dImQ1n+dImQ3n*dReQ1n);\r
1898  \r
1899  // Re[Q_{3n} Q_{n} Q_{4n}^*] = Re[Q_{4n} Q_{3n}^* Q_{n}^*]\r
1900  Double_t reQ3nQ1nQ4nstar = reQ4nQ3nstarQ1nstar;\r
1901  \r
1902  // Im[Q_{4n} Q_{3n}^* Q_{n}^*]\r
1903  //Double_t imQ4nQ3nstarQ1nstar = calculate and implement this (deleteMe)\r
1904 \r
1905  // Re[Q_{3n} Q_{2n}^* Q_{n}^*]\r
1906  Double_t reQ3nQ2nstarQ1nstar = dReQ3n*dReQ2n*dReQ1n-dReQ3n*dImQ2n*dImQ1n+dImQ3n*dReQ2n*dImQ1n\r
1907                               + dImQ3n*dImQ2n*dReQ1n;\r
1908                               \r
1909  // Re[Q_{2n} Q_{n} Q_{3n}^*] = Re[Q_{3n} Q_{2n}^* Q_{n}^*]\r
1910  Double_t reQ2nQ1nQ3nstar = reQ3nQ2nstarQ1nstar;\r
1911  \r
1912  // Im[Q_{3n} Q_{2n}^* Q_{n}^*]\r
1913  //Double_t imQ3nQ2nstarQ1nstar; //calculate and implement this (deleteMe)\r
1914  \r
1915  // Re[Q_{3n} Q_{n}^* Q_{n}^* Q_{n}^*]\r
1916  Double_t reQ3nQ1nstarQ1nstarQ1nstar = dReQ3n*pow(dReQ1n,3)-3.*dReQ1n*dReQ3n*pow(dImQ1n,2)\r
1917                                      + 3.*dImQ1n*dImQ3n*pow(dReQ1n,2)-dImQ3n*pow(dImQ1n,3);\r
1918 \r
1919  // Im[Q_{3n} Q_{n}^* Q_{n}^* Q_{n}^*]\r
1920  //Double_t imQ3nQ1nstarQ1nstarQ1nstar; //calculate and implement this (deleteMe)\r
1921  \r
1922  // |Q_{2n}|^2 |Q_{n}|^2\r
1923  Double_t dQ2nQ1nQ2nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.));\r
1924  \r
1925  // Re[Q_{4n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1926  Double_t reQ4nQ2nstarQ1nstarQ1nstar = (dReQ4n*dReQ2n+dImQ4n*dImQ2n)*(pow(dReQ1n,2)-pow(dImQ1n,2))\r
1927                                      + 2.*dReQ1n*dImQ1n*(dImQ4n*dReQ2n-dReQ4n*dImQ2n); \r
1928  \r
1929  // Im[Q_{4n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1930  //Double_t imQ4nQ2nstarQ1nstarQ1nstar; //calculate and implement this (deleteMe)\r
1931  \r
1932  // Re[Q_{2n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^*]\r
1933  Double_t reQ2nQ1nQ1nstarQ1nstarQ1nstar = (dReQ2n*dReQ1n-dImQ2n*dImQ1n)*(pow(dReQ1n,3)-3.*dReQ1n*pow(dImQ1n,2))\r
1934                                         + (dReQ2n*dImQ1n+dReQ1n*dImQ2n)*(3.*dImQ1n*pow(dReQ1n,2)-pow(dImQ1n,3));\r
1935 \r
1936  // Im[Q_{2n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^*] \r
1937  //Double_t imQ2nQ1nQ1nstarQ1nstarQ1nstar; //calculate and implement this (deleteMe)\r
1938  \r
1939  // Re[Q_{2n} Q_{2n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1940  Double_t reQ2nQ2nQ2nstarQ1nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
1941                                         * (dReQ2n*(pow(dReQ1n,2.)-pow(dImQ1n,2.)) + 2.*dImQ2n*dReQ1n*dImQ1n);\r
1942 \r
1943  // Im[Q_{2n} Q_{2n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1944  //Double_t imQ2nQ2nQ2nstarQ1nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
1945  //                                       * (dImQ2n*(pow(dReQ1n,2.)-pow(dImQ1n,2.)) - 2.*dReQ2n*dReQ1n*dImQ1n);\r
1946  \r
1947  // Re[Q_{4n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1948  Double_t reQ4nQ1nstarQ1nstarQ1nstarQ1nstar = pow(dReQ1n,4.)*dReQ4n-6.*pow(dReQ1n,2.)*dReQ4n*pow(dImQ1n,2.)\r
1949                                             + pow(dImQ1n,4.)*dReQ4n+4.*pow(dReQ1n,3.)*dImQ1n*dImQ4n\r
1950                                             - 4.*pow(dImQ1n,3.)*dReQ1n*dImQ4n;\r
1951                                             \r
1952  // Im[Q_{4n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1953  //Double_t imQ4nQ1nstarQ1nstarQ1nstarQ1nstar = pow(dReQ1n,4.)*dImQ4n-6.*pow(dReQ1n,2.)*dImQ4n*pow(dImQ1n,2.)\r
1954  //                                           + pow(dImQ1n,4.)*dImQ4n+4.*pow(dImQ1n,3.)*dReQ1n*dReQ4n\r
1955  //                                           - 4.*pow(dReQ1n,3.)*dImQ1n*dReQ4n;\r
1956  \r
1957  // Re[Q_{3n} Q_{n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1958  Double_t reQ3nQ1nQ2nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
1959                                         * (dReQ1n*dReQ2n*dReQ3n-dReQ3n*dImQ1n*dImQ2n+dReQ2n*dImQ1n*dImQ3n+dReQ1n*dImQ2n*dImQ3n);\r
1960  \r
1961  // Im[Q_{3n} Q_{n} Q_{2n}^* Q_{n}^* Q_{n}^*]\r
1962  //Double_t imQ3nQ1nQ2nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
1963  //                                       * (-dReQ2n*dReQ3n*dImQ1n-dReQ1n*dReQ3n*dImQ2n+dReQ1n*dReQ2n*dImQ3n-dImQ1n*dImQ2n*dImQ3n);\r
1964  \r
1965  \r
1966  // Re[Q_{2n} Q_{2n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1967  Double_t reQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)*dReQ2n-2.*dReQ1n*dReQ2n*dImQ1n-dReQ2n*pow(dImQ1n,2.)\r
1968                                                + dImQ2n*pow(dReQ1n,2.)+2.*dReQ1n*dImQ1n*dImQ2n-pow(dImQ1n,2.)*dImQ2n)\r
1969                                                * (pow(dReQ1n,2.)*dReQ2n+2.*dReQ1n*dReQ2n*dImQ1n-dReQ2n*pow(dImQ1n,2.)\r
1970                                                - dImQ2n*pow(dReQ1n,2.)+2.*dReQ1n*dImQ1n*dImQ2n+pow(dImQ1n,2.)*dImQ2n);\r
1971  \r
1972  // Im[Q_{2n} Q_{2n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1973  //Double_t imQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar = 2.*(pow(dReQ1n,2.)*dReQ2n-dReQ2n*pow(dImQ1n,2.)\r
1974  //                                              + 2.*dReQ1n*dImQ1n*dImQ2n)*(pow(dReQ1n,2.)*dImQ2n\r
1975  //                                              - 2.*dReQ1n*dImQ1n*dReQ2n-pow(dImQ1n,2.)*dImQ2n);\r
1976  \r
1977  // Re[Q_{3n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1978  Double_t reQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
1979                                                * (pow(dReQ1n,3.)*dReQ3n-3.*dReQ1n*dReQ3n*pow(dImQ1n,2.)\r
1980                                                + 3.*pow(dReQ1n,2.)*dImQ1n*dImQ3n-pow(dImQ1n,3.)*dImQ3n);\r
1981   \r
1982  // Im[Q_{3n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]                                                                                           \r
1983  //Double_t imQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
1984  //                                              * (pow(dImQ1n,3.)*dReQ3n-3.*dImQ1n*dReQ3n*pow(dReQ1n,2.)\r
1985  //                                              - 3.*pow(dImQ1n,2.)*dReQ1n*dImQ3n+pow(dReQ1n,3.)*dImQ3n);\r
1986  \r
1987  // |Q_{2n}|^2 |Q_{n}|^4\r
1988  Double_t dQ2nQ1nQ1nQ2nstarQ1nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))*pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.);\r
1989  \r
1990  // Re[Q_{2n} Q_{n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]\r
1991  Double_t reQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)\r
1992                                                   * (pow(dReQ1n,2.)*dReQ2n-dReQ2n*pow(dImQ1n,2.)\r
1993                                                   + 2.*dReQ1n*dImQ1n*dImQ2n);\r
1994                                                   \r
1995  // Im[Q_{2n} Q_{n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]                                                  \r
1996  //Double_t imQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)\r
1997  //                                                 * (pow(dReQ1n,2.)*dImQ2n-dImQ2n*pow(dImQ1n,2.)\r
1998  //                                                 - 2.*dReQ1n*dReQ2n*dImQ1n);\r
1999  \r
2000   \r
2001  \r
2002        \r
2003  //                                        **************************************\r
2004  //                                        **** multi-particle correlations: ****\r
2005  //                                        **************************************\r
2006  //\r
2007  // Remark 1: multi-particle correlations calculated with non-weighted Q-vectors are stored in 1D profile fQCorrelations[0]. // to be improved (wrong profiles)\r
2008  // Remark 2: binning of fQCorrelations[0] is organized as follows: // to be improved (wrong profiles)\r
2009  // --------------------------------------------------------------------------------------------------------------------\r
2010  //  1st bin: <2>_{1n|1n} = two1n1n = cos(n*(phi1-phi2))>\r
2011  //  2nd bin: <2>_{2n|2n} = two2n2n = cos(2n*(phi1-phi2))>\r
2012  //  3rd bin: <2>_{3n|3n} = two3n3n = cos(3n*(phi1-phi2))> \r
2013  //  4th bin: <2>_{4n|4n} = two4n4n = cos(4n*(phi1-phi2))>\r
2014  //  5th bin:           ----  EMPTY ----\r
2015  //  6th bin: <3>_{2n|1n,1n} = three2n1n1n = <cos(n*(2.*phi1-phi2-phi3))>\r
2016  //  7th bin: <3>_{3n|2n,1n} = three3n2n1n = <cos(n*(3.*phi1-2.*phi2-phi3))>\r
2017  //  8th bin: <3>_{4n|2n,2n} = three4n2n2n = <cos(n*(4.*phi1-2.*phi2-2.*phi3))>\r
2018  //  9th bin: <3>_{4n|3n,1n} = three4n3n1n = <cos(n*(4.*phi1-3.*phi2-phi3))>\r
2019  // 10th bin:           ----  EMPTY ----\r
2020  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1n = <cos(n*(phi1+phi2-phi3-phi4))>\r
2021  // 12th bin: <4>_{2n,1n|2n,1n} = four2n1n2n1n = <cos(2.*n*(phi1+phi2-phi3-phi4))>\r
2022  // 13th bin: <4>_{2n,2n|2n,2n} = four2n2n2n2n = <cos(n*(2.*phi1+phi2-2.*phi3-phi4))>\r
2023  // 14th bin: <4>_{3n|1n,1n,1n} = four3n1n1n1n = <cos(n*(3.*phi1-phi2-phi3-phi4))> \r
2024  // 15th bin: <4>_{3n,1n|3n,1n} = four3n1n3n1n = <cos(n*(4.*phi1-2.*phi2-phi3-phi4))>\r
2025  // 16th bin: <4>_{3n,1n|2n,2n} = four3n1n2n2n = <cos(n*(3.*phi1+phi2-2.*phi3-2.*phi4))>\r
2026  // 17th bin: <4>_{4n|2n,1n,1n} = four4n2n1n1n = <cos(n*(3.*phi1+phi2-3.*phi3-phi4))> \r
2027  // 18th bin:           ----  EMPTY ----\r
2028  // 19th bin: <5>_{2n|1n,1n,1n,1n} = five2n1n1n1n1n = <cos(n*(2.*phi1+phi2-phi3-phi4-phi5))>\r
2029  // 20th bin: <5>_{2n,2n|2n,1n,1n} = five2n2n2n1n1n = <cos(n*(2.*phi1+2.*phi2-2.*phi3-phi4-phi5))>\r
2030  // 21st bin: <5>_{3n,1n|2n,1n,1n} = five3n1n2n1n1n = <cos(n*(3.*phi1+phi2-2.*phi3-phi4-phi5))>\r
2031  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = five4n1n1n1n1n = <cos(n*(4.*phi1-phi2-phi3-phi4-phi5))>\r
2032  // 23rd bin:           ----  EMPTY ----\r
2033  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = six1n1n1n1n1n1n = <cos(n*(phi1+phi2+phi3-phi4-phi5-phi6))>\r
2034  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = six2n1n1n2n1n1n = <cos(n*(2.*phi1+2.*phi2-phi3-phi4-phi5-phi6))>\r
2035  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = six2n2n1n1n1n1n = <cos(n*(3.*phi1+phi2-phi3-phi4-phi5-phi6))>\r
2036  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = six3n1n1n1n1n1n = <cos(n*(2.*phi1+phi2+phi3-2.*phi4-phi5-phi6))>\r
2037  // 28th bin:           ----  EMPTY ----\r
2038  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = seven2n1n1n1n1n1n1n =  <cos(n*(2.*phi1+phi2+phi3-phi4-phi5-phi6-phi7))>\r
2039  // 30th bin:           ----  EMPTY ----\r
2040  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = eight1n1n1n1n1n1n1n1n = <cos(n*(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>\r
2041  // --------------------------------------------------------------------------------------------------------------------\r
2042     \r
2043  // 2-particle:\r
2044  Double_t two1n1n = 0.; // <cos(n*(phi1-phi2))>\r
2045  Double_t two2n2n = 0.; // <cos(2n*(phi1-phi2))>\r
2046  Double_t two3n3n = 0.; // <cos(3n*(phi1-phi2))>\r
2047  Double_t two4n4n = 0.; // <cos(4n*(phi1-phi2))>\r
2048  \r
2049  if(dMult>1)\r
2050  {\r
2051   two1n1n = (pow(dReQ1n,2.)+pow(dImQ1n,2.)-dMult)/(dMult*(dMult-1.)); \r
2052   two2n2n = (pow(dReQ2n,2.)+pow(dImQ2n,2.)-dMult)/(dMult*(dMult-1.)); \r
2053   two3n3n = (pow(dReQ3n,2.)+pow(dImQ3n,2.)-dMult)/(dMult*(dMult-1.)); \r
2054   two4n4n = (pow(dReQ4n,2.)+pow(dImQ4n,2.)-dMult)/(dMult*(dMult-1.)); \r
2055   \r
2056   // average 2-particle correlations for single event: \r
2057   fIntFlowCorrelationsAllEBE->SetBinContent(1,two1n1n);\r
2058   fIntFlowCorrelationsAllEBE->SetBinContent(2,two2n2n);\r
2059   fIntFlowCorrelationsAllEBE->SetBinContent(3,two3n3n);\r
2060   fIntFlowCorrelationsAllEBE->SetBinContent(4,two4n4n);\r
2061           \r
2062   // average 2-particle correlations for all events:      \r
2063   fIntFlowCorrelationsAllPro->Fill(0.5,two1n1n,dMult*(dMult-1.));  \r
2064   fIntFlowCorrelationsAllPro->Fill(1.5,two2n2n,dMult*(dMult-1.)); \r
2065   fIntFlowCorrelationsAllPro->Fill(2.5,two3n3n,dMult*(dMult-1.)); \r
2066   fIntFlowCorrelationsAllPro->Fill(3.5,two4n4n,dMult*(dMult-1.)); \r
2067   \r
2068   // store separetately <2> (to be improved: do I really need this?)\r
2069   fIntFlowCorrelationsEBE->SetBinContent(1,two1n1n); // <2>\r
2070   \r
2071   // to be improved (this can be implemented better):\r
2072   Double_t mWeight2p = 0.;\r
2073   if(!strcmp(fMultiplicityWeight->Data(),"combinations"))\r
2074   {\r
2075    mWeight2p = dMult*(dMult-1.);\r
2076   } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))\r
2077     {\r
2078      mWeight2p = 1.;    \r
2079     } else if(!strcmp(fMultiplicityWeight->Data(),"multiplicity"))\r
2080       {\r
2081        mWeight2p = dMult;           \r
2082       }\r
2083             \r
2084   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(1,mWeight2p); // eW_<2>\r
2085   fIntFlowCorrelationsPro->Fill(0.5,two1n1n,mWeight2p);\r
2086     \r
2087   // distribution of <cos(n*(phi1-phi2))>:\r
2088   //f2pDistribution->Fill(two1n1n,dMult*(dMult-1.)); \r
2089  } // end of if(dMult>1)\r
2090  \r
2091  // 3-particle:\r
2092  Double_t three2n1n1n = 0.; // <cos(n*(2.*phi1-phi2-phi3))>\r
2093  Double_t three3n2n1n = 0.; // <cos(n*(3.*phi1-2.*phi2-phi3))>\r
2094  Double_t three4n2n2n = 0.; // <cos(n*(4.*phi1-2.*phi2-2.*phi3))>\r
2095  Double_t three4n3n1n = 0.; // <cos(n*(4.*phi1-3.*phi2-phi3))>\r
2096  \r
2097  if(dMult>2)\r
2098  {\r
2099   three2n1n1n = (reQ2nQ1nstarQ1nstar-2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
2100               - (pow(dReQ2n,2.)+pow(dImQ2n,2.))+2.*dMult)\r
2101               / (dMult*(dMult-1.)*(dMult-2.));              \r
2102   three3n2n1n = (reQ3nQ2nstarQ1nstar-(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2103               - (pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
2104               - (pow(dReQ1n,2.)+pow(dImQ1n,2.))+2.*dMult)\r
2105               / (dMult*(dMult-1.)*(dMult-2.));\r
2106   three4n2n2n = (reQ4nQ2nstarQ2nstar-2.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
2107               - (pow(dReQ4n,2.)+pow(dImQ4n,2.))+2.*dMult)\r
2108               / (dMult*(dMult-1.)*(dMult-2.)); \r
2109   three4n3n1n = (reQ4nQ3nstarQ1nstar-(pow(dReQ4n,2.)+pow(dImQ4n,2.))\r
2110               - (pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2111               - (pow(dReQ1n,2.)+pow(dImQ1n,2.))+2.*dMult)\r
2112               / (dMult*(dMult-1.)*(dMult-2.)); \r
2113               \r
2114   // average 3-particle correlations for single event: \r
2115   fIntFlowCorrelationsAllEBE->SetBinContent(6,three2n1n1n);\r
2116   fIntFlowCorrelationsAllEBE->SetBinContent(7,three3n2n1n);\r
2117   fIntFlowCorrelationsAllEBE->SetBinContent(8,three4n2n2n);\r
2118   fIntFlowCorrelationsAllEBE->SetBinContent(9,three4n3n1n);\r
2119         \r
2120   // average 3-particle correlations for all events:                \r
2121   fIntFlowCorrelationsAllPro->Fill(5.5,three2n1n1n,dMult*(dMult-1.)*(dMult-2.)); \r
2122   fIntFlowCorrelationsAllPro->Fill(6.5,three3n2n1n,dMult*(dMult-1.)*(dMult-2.));\r
2123   fIntFlowCorrelationsAllPro->Fill(7.5,three4n2n2n,dMult*(dMult-1.)*(dMult-2.)); \r
2124   fIntFlowCorrelationsAllPro->Fill(8.5,three4n3n1n,dMult*(dMult-1.)*(dMult-2.));    \r
2125  } // end of if(dMult>2)\r
2126  \r
2127  // 4-particle:\r
2128  Double_t four1n1n1n1n = 0.; // <cos(n*(phi1+phi2-phi3-phi4))>\r
2129  Double_t four2n2n2n2n = 0.; // <cos(2.*n*(phi1+phi2-phi3-phi4))>\r
2130  Double_t four2n1n2n1n = 0.; // <cos(n*(2.*phi1+phi2-2.*phi3-phi4))> \r
2131  Double_t four3n1n1n1n = 0.; // <cos(n*(3.*phi1-phi2-phi3-phi4))> \r
2132  Double_t four4n2n1n1n = 0.; // <cos(n*(4.*phi1-2.*phi2-phi3-phi4))> \r
2133  Double_t four3n1n2n2n = 0.; // <cos(n*(3.*phi1+phi2-2.*phi3-2.*phi4))> \r
2134  Double_t four3n1n3n1n = 0.; // <cos(n*(3.*phi1+phi2-3.*phi3-phi4))>   \r
2135  \r
2136  if(dMult>3)\r
2137  {\r
2138   four1n1n1n1n = (2.*dMult*(dMult-3.)+pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)-4.*(dMult-2.)*(pow(dReQ1n,2.)\r
2139                + pow(dImQ1n,2.))-2.*reQ2nQ1nstarQ1nstar+(pow(dReQ2n,2.)+pow(dImQ2n,2.)))\r
2140                / (dMult*(dMult-1)*(dMult-2.)*(dMult-3.));     \r
2141   four2n2n2n2n = (2.*dMult*(dMult-3.)+pow((pow(dReQ2n,2.)+pow(dImQ2n,2.)),2.)-4.*(dMult-2.)*(pow(dReQ2n,2.)\r
2142                + pow(dImQ2n,2.))-2.*reQ4nQ2nstarQ2nstar+(pow(dReQ4n,2.)+pow(dImQ4n,2.)))\r
2143                / (dMult*(dMult-1)*(dMult-2.)*(dMult-3.));\r
2144   four2n1n2n1n = (dQ2nQ1nQ2nstarQ1nstar-2.*reQ3nQ2nstarQ1nstar-2.*reQ2nQ1nstarQ1nstar)\r
2145                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2146                - ((dMult-5.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
2147                + (dMult-4.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-(pow(dReQ3n,2.)+pow(dImQ3n,2.)))\r
2148                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2149                + (dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.));\r
2150   four3n1n1n1n = (reQ3nQ1nstarQ1nstarQ1nstar-3.*reQ3nQ2nstarQ1nstar-3.*reQ2nQ1nstarQ1nstar)\r
2151                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2152                + (2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+3.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
2153                + 6.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-6.*dMult)\r
2154                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2155   four4n2n1n1n = (reQ4nQ2nstarQ1nstarQ1nstar-2.*reQ4nQ3nstarQ1nstar-reQ4nQ2nstarQ2nstar-2.*reQ3nQ2nstarQ1nstar)\r
2156                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2157                - (reQ2nQ1nstarQ1nstar-2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))-2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2158                - 3.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2159                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2160                - 6./((dMult-1.)*(dMult-2.)*(dMult-3.));\r
2161   four3n1n2n2n = (reQ3nQ1nQ2nstarQ2nstar-reQ4nQ2nstarQ2nstar-reQ3nQ1nQ4nstar-2.*reQ3nQ2nstarQ1nstar)\r
2162                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2163                - (2.*reQ1nQ1nQ2nstar-(pow(dReQ4n,2.)+pow(dImQ4n,2.))-2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2164                - 4.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2165                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2166                - 6./((dMult-1.)*(dMult-2.)*(dMult-3.)); \r
2167   four3n1n3n1n = ((pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
2168                - 2.*reQ4nQ3nstarQ1nstar-2.*reQ3nQ2nstarQ1nstar)\r
2169                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2170                + ((pow(dReQ4n,2.)+pow(dImQ4n,2.))-(dMult-4.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2171                + (pow(dReQ2n,2.)+pow(dImQ2n,2.))-(dMult-4.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2172                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
2173                + (dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.));\r
2174                \r
2175   // average 4-particle correlations for single event: \r
2176   fIntFlowCorrelationsAllEBE->SetBinContent(11,four1n1n1n1n);\r
2177   fIntFlowCorrelationsAllEBE->SetBinContent(12,four2n1n2n1n);\r
2178   fIntFlowCorrelationsAllEBE->SetBinContent(13,four2n2n2n2n);\r
2179   fIntFlowCorrelationsAllEBE->SetBinContent(14,four3n1n1n1n);\r
2180   fIntFlowCorrelationsAllEBE->SetBinContent(15,four3n1n3n1n);\r
2181   fIntFlowCorrelationsAllEBE->SetBinContent(16,four3n1n2n2n);\r
2182   fIntFlowCorrelationsAllEBE->SetBinContent(17,four4n2n1n1n);\r
2183         \r
2184   // average 4-particle correlations for all events:                \r
2185   fIntFlowCorrelationsAllPro->Fill(10.5,four1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2186   fIntFlowCorrelationsAllPro->Fill(11.5,four2n1n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2187   fIntFlowCorrelationsAllPro->Fill(12.5,four2n2n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2188   fIntFlowCorrelationsAllPro->Fill(13.5,four3n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2189   fIntFlowCorrelationsAllPro->Fill(14.5,four3n1n3n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2190   fIntFlowCorrelationsAllPro->Fill(15.5,four3n1n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));  \r
2191   fIntFlowCorrelationsAllPro->Fill(16.5,four4n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)); \r
2192   \r
2193   // store separetately <4> (to be improved: do I really need this?)\r
2194   fIntFlowCorrelationsEBE->SetBinContent(2,four1n1n1n1n); // <4>\r
2195   \r
2196   // to be improved (this can be implemented better):\r
2197   Double_t mWeight4p = 0.;\r
2198   if(!strcmp(fMultiplicityWeight->Data(),"combinations"))\r
2199   {\r
2200    mWeight4p = dMult*(dMult-1.)*(dMult-2.)*(dMult-3.);\r
2201   } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))\r
2202     {\r
2203      mWeight4p = 1.;    \r
2204     } else if(!strcmp(fMultiplicityWeight->Data(),"multiplicity"))\r
2205       {\r
2206        mWeight4p = dMult;           \r
2207       }\r
2208       \r
2209   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(2,mWeight4p); // eW_<4>\r
2210   fIntFlowCorrelationsPro->Fill(1.5,four1n1n1n1n,mWeight4p);\r
2211   \r
2212   // distribution of <cos(n*(phi1+phi2-phi3-phi4))>\r
2213   //f4pDistribution->Fill(four1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
2214   \r
2215  } // end of if(dMult>3)\r
2216 \r
2217  // 5-particle:\r
2218  Double_t five2n1n1n1n1n = 0.; // <cos(n*(2.*phi1+phi2-phi3-phi4-phi5))>\r
2219  Double_t five2n2n2n1n1n = 0.; // <cos(n*(2.*phi1+2.*phi2-2.*phi3-phi4-phi5))>\r
2220  Double_t five3n1n2n1n1n = 0.; // <cos(n*(3.*phi1+phi2-2.*phi3-phi4-phi5))>\r
2221  Double_t five4n1n1n1n1n = 0.; // <cos(n*(4.*phi1-phi2-phi3-phi4-phi5))>\r
2222  \r
2223  if(dMult>4)\r
2224  {\r
2225   five2n1n1n1n1n = (reQ2nQ1nQ1nstarQ1nstarQ1nstar-reQ3nQ1nstarQ1nstarQ1nstar+6.*reQ3nQ2nstarQ1nstar)\r
2226                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2227                  - (reQ2nQ1nQ3nstar+3.*(dMult-6.)*reQ2nQ1nstarQ1nstar+3.*reQ1nQ1nQ2nstar)\r
2228                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2229                  - (2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2230                  + 3.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))     \r
2231                  - 3.*(dMult-4.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.)))\r
2232                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2233                  - 3.*(pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)\r
2234                  - 2.*(2*dMult-5.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))+2.*dMult*(dMult-4.))\r
2235                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2236                  \r
2237   five2n2n2n1n1n = (reQ2nQ2nQ2nstarQ1nstarQ1nstar-reQ4nQ2nstarQ1nstarQ1nstar-2.*reQ2nQ2nQ3nstarQ1nstar)\r
2238                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2239                  + 2.*(reQ4nQ2nstarQ2nstar+4.*reQ3nQ2nstarQ1nstar+reQ3nQ1nQ4nstar)\r
2240                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2241                  + (reQ2nQ2nQ4nstar-2.*(dMult-5.)*reQ2nQ1nstarQ1nstar+2.*reQ1nQ1nQ2nstar)\r
2242                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2243                  - (2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+4.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2244                  + 1.*pow((pow(dReQ2n,2.)+pow(dImQ2n,2.)),2.)\r
2245                  - 2.*(3.*dMult-10.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.)))\r
2246                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2247                  - (4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
2248                  - 4.*(dMult-5.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))+4.*dMult*(dMult-6.))\r
2249                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)); \r
2250 \r
2251   five4n1n1n1n1n = (reQ4nQ1nstarQ1nstarQ1nstarQ1nstar-6.*reQ4nQ2nstarQ1nstarQ1nstar-4.*reQ3nQ1nstarQ1nstarQ1nstar)\r
2252                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2253                  + (8.*reQ4nQ3nstarQ1nstar+3.*reQ4nQ2nstarQ2nstar+12.*reQ3nQ2nstarQ1nstar+12.*reQ2nQ1nstarQ1nstar)\r
2254                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2255                  - (6.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+8.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))\r
2256                  + 12.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))+24.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-24.*dMult)\r
2257                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2258   \r
2259   five3n1n2n1n1n = (reQ3nQ1nQ2nstarQ1nstarQ1nstar-reQ4nQ2nstarQ1nstarQ1nstar-reQ3nQ1nstarQ1nstarQ1nstar)\r
2260                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2261                  - (reQ3nQ1nQ2nstarQ2nstar-3.*reQ4nQ3nstarQ1nstar-reQ4nQ2nstarQ2nstar)\r
2262                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2263                  - ((2.*dMult-13.)*reQ3nQ2nstarQ1nstar-reQ3nQ1nQ4nstar-9.*reQ2nQ1nstarQ1nstar)\r
2264                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2265                  - (2.*reQ1nQ1nQ2nstar+2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))\r
2266                  - 2.*(dMult-5.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+2.*(pow(dReQ3n,2.)\r
2267                  + pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2268                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2269                  + (2.*(dMult-6.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))\r
2270                  - 2.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))\r
2271                  - pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)\r
2272                  + 2.*(3.*dMult-11.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2273                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))\r
2274                  - 4.*(dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2275                  \r
2276   // average 5-particle correlations for single event: \r
2277   fIntFlowCorrelationsAllEBE->SetBinContent(19,five2n1n1n1n1n);\r
2278   fIntFlowCorrelationsAllEBE->SetBinContent(20,five2n2n2n1n1n);\r
2279   fIntFlowCorrelationsAllEBE->SetBinContent(21,five3n1n2n1n1n);\r
2280   fIntFlowCorrelationsAllEBE->SetBinContent(22,five4n1n1n1n1n);\r
2281         \r
2282   // average 5-particle correlations for all events:                         \r
2283   fIntFlowCorrelationsAllPro->Fill(18.5,five2n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)); \r
2284   fIntFlowCorrelationsAllPro->Fill(19.5,five2n2n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2285   fIntFlowCorrelationsAllPro->Fill(20.5,five3n1n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2286   fIntFlowCorrelationsAllPro->Fill(21.5,five4n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));\r
2287  } // end of if(dMult>4)\r
2288     \r
2289  // 6-particle:\r
2290  Double_t six1n1n1n1n1n1n = 0.; // <cos(n*(phi1+phi2+phi3-phi4-phi5-phi6))>\r
2291  Double_t six2n2n1n1n1n1n = 0.; // <cos(n*(2.*phi1+2.*phi2-phi3-phi4-phi5-phi6))>\r
2292  Double_t six3n1n1n1n1n1n = 0.; // <cos(n*(3.*phi1+phi2-phi3-phi4-phi5-phi6))>\r
2293  Double_t six2n1n1n2n1n1n = 0.; // <cos(n*(2.*phi1+phi2+phi3-2.*phi4-phi5-phi6))>\r
2294  \r
2295  if(dMult>5)\r
2296  {\r
2297   six1n1n1n1n1n1n = (pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),3.)+9.*dQ2nQ1nQ2nstarQ1nstar-6.*reQ2nQ1nQ1nstarQ1nstarQ1nstar)\r
2298                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.))\r
2299                   + 4.*(reQ3nQ1nstarQ1nstarQ1nstar-3.*reQ3nQ2nstarQ1nstar)\r
2300                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.))\r
2301                   + 2.*(9.*(dMult-4.)*reQ2nQ1nstarQ1nstar+2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.)))\r
2302                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.))\r
2303                   - 9.*(pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)+(pow(dReQ2n,2.)+pow(dImQ2n,2.)))\r
2304                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-5.))\r
2305                   + (18.*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))\r
2306                   / (dMult*(dMult-1)*(dMult-3)*(dMult-4))\r
2307                   - 6./((dMult-1.)*(dMult-2.)*(dMult-3.));\r
2308                   \r
2309   six2n1n1n2n1n1n = (dQ2nQ1nQ1nQ2nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)\r
2310                   * (2.*five2n2n2n1n1n+4.*five2n1n1n1n1n+4.*five3n1n2n1n1n+4.*four2n1n2n1n+1.*four1n1n1n1n)\r
2311                   - dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(4.*four1n1n1n1n+4.*two1n1n\r
2312                   + 2.*three2n1n1n+2.*three2n1n1n+4.*four3n1n1n1n+8.*three2n1n1n+2.*four4n2n1n1n\r
2313                   + 4.*four2n1n2n1n+2.*two2n2n+8.*four2n1n2n1n+4.*four3n1n3n1n+8.*three3n2n1n\r
2314                   + 4.*four3n1n2n2n+4.*four1n1n1n1n+4.*four2n1n2n1n+1.*four2n2n2n2n)\r
2315                   - dMult*(dMult-1.)*(dMult-2.)*(2.*three2n1n1n+8.*two1n1n+4.*two1n1n+2.\r
2316                   + 4.*two1n1n+4.*three2n1n1n+2.*two2n2n+4.*three2n1n1n+8.*three3n2n1n\r
2317                   + 8.*two2n2n+4.*three4n3n1n+4.*two3n3n+4.*three3n2n1n+4.*two1n1n\r
2318                   + 8.*three2n1n1n+4.*two1n1n+4.*three3n2n1n+4.*three2n1n1n+2.*two2n2n\r
2319                   + 4.*three3n2n1n+2.*three4n2n2n)-dMult*(dMult-1.)\r
2320                   * (4.*two1n1n+4.+4.*two1n1n+2.*two2n2n+1.+4.*two1n1n+4.*two2n2n+4.*two3n3n\r
2321                   + 1.+2.*two2n2n+1.*two4n4n)-dMult)\r
2322                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); // to be improved (direct formula needed)\r
2323  \r
2324   six2n2n1n1n1n1n = (reQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)\r
2325                   * (five4n1n1n1n1n+8.*five2n1n1n1n1n+6.*five2n2n2n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)\r
2326                   * (4.*four3n1n1n1n+6.*four4n2n1n1n+12.*three2n1n1n+12.*four1n1n1n1n+24.*four2n1n2n1n\r
2327                   + 4.*four3n1n2n2n+3.*four2n2n2n2n)-dMult*(dMult-1.)*(dMult-2.)*(6.*three2n1n1n+12.*three3n2n1n\r
2328                   + 4.*three4n3n1n+3.*three4n2n2n+8.*three2n1n1n+24.*two1n1n+12.*two2n2n+12.*three2n1n1n+8.*three3n2n1n\r
2329                   + 1.*three4n2n2n)-dMult*(dMult-1.)*(4.*two1n1n+6.*two2n2n+4.*two3n3n+1.*two4n4n+2.*two2n2n+8.*two1n1n+6.)-dMult)\r
2330                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); // to be improved (direct formula needed)\r
2331    \r
2332   six3n1n1n1n1n1n = (reQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)\r
2333                   * (five4n1n1n1n1n+4.*five2n1n1n1n1n+6.*five3n1n2n1n1n+4.*four3n1n1n1n)\r
2334                   - dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(4.*four3n1n1n1n+6.*four4n2n1n1n+6.*four1n1n1n1n\r
2335                   + 12.*three2n1n1n+12.*four2n1n2n1n+6.*four3n1n1n1n+12.*three3n2n1n+4.*four3n1n3n1n+3.*four3n1n2n2n)\r
2336                   - dMult*(dMult-1.)*(dMult-2.)*(6.*three2n1n1n+12.*three3n2n1n+4.*three4n3n1n+3.*three4n2n2n+4.*two1n1n\r
2337                   + 12.*two1n1n+6.*three2n1n1n+12.*three2n1n1n+4.*three3n2n1n+12.*two2n2n+4.*three3n2n1n+4.*two3n3n+1.*three4n3n1n\r
2338                   + 6.*three3n2n1n)-dMult*(dMult-1.)*(4.*two1n1n+6.*two2n2n+4.*two3n3n+1.*two4n4n+1.*two1n1n+4.+6.*two1n1n+4.*two2n2n\r
2339                   + 1.*two3n3n)-dMult)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); // to be improved (direct formula needed)\r
2340                                  \r
2341   // average 6-particle correlations for single event: \r
2342   fIntFlowCorrelationsAllEBE->SetBinContent(24,six1n1n1n1n1n1n);\r
2343   fIntFlowCorrelationsAllEBE->SetBinContent(25,six2n1n1n2n1n1n);\r
2344   fIntFlowCorrelationsAllEBE->SetBinContent(26,six2n2n1n1n1n1n);\r
2345   fIntFlowCorrelationsAllEBE->SetBinContent(27,six3n1n1n1n1n1n);\r
2346         \r
2347   // average 6-particle correlations for all events:         \r
2348   fIntFlowCorrelationsAllPro->Fill(23.5,six1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); \r
2349   fIntFlowCorrelationsAllPro->Fill(24.5,six2n1n1n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); \r
2350   fIntFlowCorrelationsAllPro->Fill(25.5,six2n2n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));\r
2351   fIntFlowCorrelationsAllPro->Fill(26.5,six3n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); \r
2352 \r
2353   // store separetately <6> (to be improved: do I really need this?)\r
2354   fIntFlowCorrelationsEBE->SetBinContent(3,six1n1n1n1n1n1n); // <6>\r
2355   \r
2356   // to be improved (this can be implemented better):\r
2357   Double_t mWeight6p = 0.;\r
2358   if(!strcmp(fMultiplicityWeight->Data(),"combinations"))\r
2359   {\r
2360    mWeight6p = dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.);\r
2361   } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))\r
2362     {\r
2363      mWeight6p = 1.;    \r
2364     } else if(!strcmp(fMultiplicityWeight->Data(),"multiplicity"))\r
2365       {\r
2366        mWeight6p = dMult;           \r
2367       }\r
2368       \r
2369   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(3,mWeight6p); // eW_<6>\r
2370   fIntFlowCorrelationsPro->Fill(2.5,six1n1n1n1n1n1n,mWeight6p);\r
2371  \r
2372   // distribution of <cos(n*(phi1+phi2+phi3-phi4-phi5-phi6))>\r
2373   //f6pDistribution->Fill(six1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); \r
2374  } // end of if(dMult>5)\r
2375  \r
2376  // 7-particle:\r
2377  Double_t seven2n1n1n1n1n1n1n = 0.; // <cos(n*(2.*phi1+phi2+phi3-phi4-phi5-phi6-phi7))>\r
2378  \r
2379  if(dMult>6)\r
2380  {\r
2381   seven2n1n1n1n1n1n1n = (reQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)\r
2382                       * (2.*six3n1n1n1n1n1n+4.*six1n1n1n1n1n1n+1.*six2n2n1n1n1n1n+6.*six2n1n1n2n1n1n+8.*five2n1n1n1n1n)\r
2383                       - dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(1.*five4n1n1n1n1n +8.*five2n1n1n1n1n+8.*four3n1n1n1n\r
2384                       + 12.*five3n1n2n1n1n+4.*five2n1n1n1n1n+3.*five2n2n2n1n1n+6.*five2n2n2n1n1n+6.*four1n1n1n1n+24.*four1n1n1n1n\r
2385                       + 12.*five2n1n1n1n1n+12.*five2n1n1n1n1n+12.*three2n1n1n+24.*four2n1n2n1n+4.*five3n1n2n1n1n+4.*five2n1n1n1n1n)\r
2386                       - dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(4.*four3n1n1n1n+6.*four4n2n1n1n+12.*four1n1n1n1n+24.*three2n1n1n\r
2387                       + 24.*four2n1n2n1n+12.*four3n1n1n1n+24.*three3n2n1n+8.*four3n1n3n1n+6.*four3n1n2n2n+6.*three2n1n1n+12.*four1n1n1n1n\r
2388                       + 12.*four2n1n2n1n+6.*three2n1n1n+12.*four2n1n2n1n+4.*four3n1n2n2n+3.*four2n2n2n2n+4.*four1n1n1n1n+6.*three2n1n1n\r
2389                       + 24.*two1n1n+24.*four1n1n1n1n+4.*four3n1n1n1n+24.*two1n1n+24.*three2n1n1n+12.*two2n2n+24.*three2n1n1n+12.*four2n1n2n1n\r
2390                       + 8.*three3n2n1n+8.*four2n1n2n1n+1.*four4n2n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(6.*three2n1n1n+1.*three2n1n1n+8.*two1n1n\r
2391                       + 12.*three3n2n1n+24.*two1n1n+12.*three2n1n1n+4.*three2n1n1n+8.*two1n1n+4.*three4n3n1n+24.*three2n1n1n+8.*three3n2n1n\r
2392                       + 12.*two1n1n+12.*two1n1n+3.*three4n2n2n+24.*two2n2n+6.*two2n2n+12.+12.*three3n2n1n+8.*two3n3n+12.*three2n1n1n+24.*two1n1n\r
2393                       + 4.*three3n2n1n+8.*three3n2n1n+2.*three4n3n1n+12.*two1n1n+8.*three2n1n1n+4.*three2n1n1n+2.*three3n2n1n+6.*two2n2n+8.*two2n2n\r
2394                       + 1.*three4n2n2n+4.*three3n2n1n+6.*three2n1n1n)-dMult*(dMult-1.)*(4.*two1n1n+2.*two1n1n+6.*two2n2n+8.+1.*two2n2n+4.*two3n3n\r
2395                       + 12.*two1n1n+4.*two1n1n+1.*two4n4n+8.*two2n2n+6.+2.*two3n3n+4.*two1n1n+1.*two2n2n)-dMult)\r
2396                       / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)); // to be improved (direct formula needed)\r
2397         \r
2398   // average 7-particle correlations for single event: \r
2399   fIntFlowCorrelationsAllEBE->SetBinContent(29,seven2n1n1n1n1n1n1n);\r
2400        \r
2401   // average 7-particle correlations for all events:                      \r
2402   fIntFlowCorrelationsAllPro->Fill(28.5,seven2n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.));\r
2403  } // end of if(dMult>6)\r
2404  \r
2405  // 8-particle:\r
2406  Double_t eight1n1n1n1n1n1n1n1n = 0.; // <cos(n*(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>\r
2407  if(dMult>7)\r
2408  {\r
2409   eight1n1n1n1n1n1n1n1n = (pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),4.)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)\r
2410                         * (12.*seven2n1n1n1n1n1n1n+16.*six1n1n1n1n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)\r
2411                         * (8.*six3n1n1n1n1n1n+48.*six1n1n1n1n1n1n+6.*six2n2n1n1n1n1n+96.*five2n1n1n1n1n+72.*four1n1n1n1n+36.*six2n1n1n2n1n1n)\r
2412                         - dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(2.*five4n1n1n1n1n+32.*five2n1n1n1n1n+36.*four1n1n1n1n\r
2413                         + 32.*four3n1n1n1n+48.*five2n1n1n1n1n+48.*five3n1n2n1n1n+144.*five2n1n1n1n1n+288.*four1n1n1n1n+36.*five2n2n2n1n1n\r
2414                         + 144.*three2n1n1n+96.*two1n1n+144.*four2n1n2n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)\r
2415                         * (8.*four3n1n1n1n+48.*four1n1n1n1n+12.*four4n2n1n1n+96.*four2n1n2n1n+96.*three2n1n1n+72.*three2n1n1n+144.*two1n1n\r
2416                         + 16.*four3n1n3n1n+48.*four3n1n1n1n+144.*four1n1n1n1n+72.*four1n1n1n1n+96.*three3n2n1n+24.*four3n1n2n2n+144.*four2n1n2n1n\r
2417                         + 288.*two1n1n+288.*three2n1n1n+9.*four2n2n2n2n+72.*two2n2n+24.)-dMult*(dMult-1.)*(dMult-2.)*(12.*three2n1n1n+16.*two1n1n\r
2418                         + 24.*three3n2n1n+48.*three2n1n1n+96.*two1n1n+8.*three4n3n1n+32.*three3n2n1n+96.*three2n1n1n+144.*two1n1n+6.*three4n2n2n\r
2419                         + 96.*two2n2n+36.*two2n2n+72.+48.*three3n2n1n+16.*two3n3n+72.*three2n1n1n+144.*two1n1n)-dMult*(dMult-1.)*(8.*two1n1n\r
2420                         + 12.*two2n2n+16.+8.*two3n3n+48.*two1n1n+1.*two4n4n+16.*two2n2n+18.)-dMult)\r
2421                         / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.)); // to be improved (direct formula needed)\r
2422   \r
2423   // average 8-particle correlations for single event: \r
2424   fIntFlowCorrelationsAllEBE->SetBinContent(31,eight1n1n1n1n1n1n1n1n);\r
2425        \r
2426   // average 8-particle correlations for all events:                       \r
2427   fIntFlowCorrelationsAllPro->Fill(30.5,eight1n1n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));\r
2428  \r
2429   // store separetately <8> (to be improved: do I really need this?)\r
2430   fIntFlowCorrelationsEBE->SetBinContent(4,eight1n1n1n1n1n1n1n1n); // <8>\r
2431   \r
2432   // to be improved (this can be implemented better):\r
2433   Double_t mWeight8p = 0.;\r
2434   if(!strcmp(fMultiplicityWeight->Data(),"combinations"))\r
2435   {\r
2436    mWeight8p = dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.);\r
2437   } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))\r
2438     {\r
2439      mWeight8p = 1.;    \r
2440     } else if(!strcmp(fMultiplicityWeight->Data(),"multiplicity"))\r
2441       {\r
2442        mWeight8p = dMult;           \r
2443       }\r
2444         \r
2445   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(4,mWeight8p); // eW_<8>\r
2446   fIntFlowCorrelationsPro->Fill(3.5,eight1n1n1n1n1n1n1n1n,mWeight8p);  \r
2447   \r
2448   // distribution of <cos(n*(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>\r
2449   //f8pDistribution->Fill(eight1n1n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));\r
2450  } // end of if(dMult>7) \r
2451  \r
2452 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelations()\r
2453 \r
2454 \r
2455 //================================================================================================================================\r
2456 \r
2457 \r
2458 void AliFlowAnalysisWithQCumulants::CalculateIntFlowProductOfCorrelations()\r
2459 {\r
2460  // Calculate averages of products of correlations for integrated flow  // to be improved (this method can be implemented better)\r
2461  \r
2462  // a) Binning of fIntFlowProductOfCorrelationsPro is organized as follows:\r
2463  //     1st bin: <<2><4>> \r
2464  //     2nd bin: <<2><6>>\r
2465  //     3rd bin: <<2><8>>\r
2466  //     4th bin: <<4><6>>\r
2467  //     5th bin: <<4><8>>\r
2468  //     6th bin: <<6><8>>\r
2469 \r
2470  /*\r
2471  Double_t dMult = (*fSMpk)(0,0); // multiplicity \r
2472 \r
2473  Double_t twoEBE = fIntFlowCorrelationsEBE->GetBinContent(1); // <2>\r
2474  Double_t fourEBE = fIntFlowCorrelationsEBE->GetBinContent(2); // <4>\r
2475  Double_t sixEBE = fIntFlowCorrelationsEBE->GetBinContent(3); // <6>\r
2476  Double_t eightEBE = fIntFlowCorrelationsEBE->GetBinContent(4); // <8>\r
2477  \r
2478  Double_t eW2 = 0.; // event weight for <2>\r
2479  Double_t eW4 = 0.; // event weight for <4>\r
2480  Double_t eW6 = 0.; // event weight for <6>\r
2481  Double_t eW8 = 0.; // event weight for <8>\r
2482  \r
2483  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
2484  {\r
2485   eW2 = dMult*(dMult-1);\r
2486   eW4 = dMult*(dMult-1)*(dMult-2)*(dMult-3);\r
2487   eW6 = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5);\r
2488   eW8 = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5)*(dMult-6)*(dMult-7);\r
2489  } else \r
2490    {\r
2491     eW2 = (*fSMpk)(1,1)-(*fSMpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j;\r
2492     eW4 = (*fSMpk)(3,1)-6.*(*fSMpk)(0,2)*(*fSMpk)(1,1)  \r
2493         + 8.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
2494         + 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
2495    }\r
2496   \r
2497  fIntFlowProductOfCorrelationsPro->Fill(0.5,twoEBE*fourEBE,eW2*eW4); // <<2><4>> \r
2498  fIntFlowProductOfCorrelationsPro->Fill(1.5,twoEBE*sixEBE,eW2*eW6); // <<2><6>>\r
2499  fIntFlowProductOfCorrelationsPro->Fill(2.5,twoEBE*eightEBE,eW2*eW8); // <<2><8>>\r
2500  fIntFlowProductOfCorrelationsPro->Fill(3.5,fourEBE*sixEBE,eW4*eW6); // <<4><6>>\r
2501  fIntFlowProductOfCorrelationsPro->Fill(4.5,fourEBE*eightEBE,eW4*eW8); // <<4><8>>\r
2502  fIntFlowProductOfCorrelationsPro->Fill(5.5,sixEBE*eightEBE,eW6*eW8); // <<6><8>>\r
2503  */\r
2504  \r
2505  \r
2506  Int_t counter = 0;\r
2507  \r
2508  for(Int_t ci1=1;ci1<4;ci1++)\r
2509  {\r
2510   for(Int_t ci2=ci1+1;ci2<=4;ci2++)\r
2511   {\r
2512    fIntFlowProductOfCorrelationsPro->Fill(0.5+counter++,\r
2513                                           fIntFlowCorrelationsEBE->GetBinContent(ci1)*fIntFlowCorrelationsEBE->GetBinContent(ci2),\r
2514                                           fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci1)*fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci2));\r
2515   }\r
2516  }\r
2517  \r
2518 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowProductOfCorrelations()\r
2519 \r
2520 \r
2521 //================================================================================================================================\r
2522 \r
2523 \r
2524 void AliFlowAnalysisWithQCumulants::CalculateCovariancesIntFlow()\r
2525 {\r
2526  // a) Calculate unbiased estimators Cov(<2>,<4>), Cov(<2>,<6>), Cov(<2>,<8>), Cov(<4>,<6>), Cov(<4>,<8>) and Cov(<6>,<8>)\r
2527  //    for covariances V_(<2>,<4>), V_(<2>,<6>), V_(<2>,<8>), V_(<4>,<6>), V_(<4>,<8>) and V_(<6>,<8>).\r
2528  // b) Store in histogram fIntFlowCovariances for instance the following: \r
2529  //\r
2530  //             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
2531  // \r
2532  //    where N is the number of events, w_{<2>} is event weight for <2> and w_{<4>} is event weight for <4>.\r
2533  // c) Binning of fIntFlowCovariances is organized as follows:\r
2534  // \r
2535  //     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
2536  //     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
2537  //     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
2538  //     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
2539  //     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
2540  //     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
2541     \r
2542  for(Int_t power=0;power<2;power++)\r
2543  { \r
2544   if(!(fIntFlowCorrelationsPro && fIntFlowProductOfCorrelationsPro \r
2545        && fIntFlowSumOfEventWeights[power] && fIntFlowSumOfProductOfEventWeights\r
2546        && fIntFlowCovariances)) \r
2547   {\r
2548    cout<<"WARNING: fIntFlowCorrelationsPro && fIntFlowProductOfCorrelationsPro "<<endl;\r
2549    cout<<"         && fIntFlowSumOfEventWeights[power] && fIntFlowSumOfProductOfEventWeights"<<endl;\r
2550    cout<<"         && fIntFlowCovariances is NULL in AFAWQC::FCIF() !!!!"<<endl;\r
2551    cout<<"power = "<<power<<endl;\r
2552    exit(0);\r
2553   }\r
2554  }\r
2555    \r
2556  // average 2-, 4-, 6- and 8-particle correlations for all events:\r
2557  Double_t correlation[4] = {0.};\r
2558  for(Int_t ci=0;ci<4;ci++)\r
2559  {\r
2560   correlation[ci] = fIntFlowCorrelationsPro->GetBinContent(ci+1);\r
2561  } \r
2562  // average products of 2-, 4-, 6- and 8-particle correlations: \r
2563  Double_t productOfCorrelations[4][4] = {{0.}};\r
2564  Int_t productOfCorrelationsLabel = 1;\r
2565  // denominators in the expressions for the unbiased estimator for covariance:\r
2566  Double_t denominator[4][4] = {{0.}};\r
2567  Int_t sumOfProductOfEventWeightsLabel1 = 1;\r
2568  // weight dependent prefactor which multiply unbiased estimators for covariances:\r
2569  Double_t wPrefactor[4][4] = {{0.}}; \r
2570  Int_t sumOfProductOfEventWeightsLabel2 = 1;\r
2571  for(Int_t c1=0;c1<4;c1++)\r
2572  {\r
2573   for(Int_t c2=c1+1;c2<4;c2++)\r
2574   {\r
2575    productOfCorrelations[c1][c2] = fIntFlowProductOfCorrelationsPro->GetBinContent(productOfCorrelationsLabel);\r
2576    if(fIntFlowSumOfEventWeights[0]->GetBinContent(c1+1) && fIntFlowSumOfEventWeights[0]->GetBinContent(c2+1))\r
2577    {\r
2578     denominator[c1][c2] = 1.-(fIntFlowSumOfProductOfEventWeights->GetBinContent(sumOfProductOfEventWeightsLabel1))/\r
2579                              (fIntFlowSumOfEventWeights[0]->GetBinContent(c1+1) \r
2580                               * fIntFlowSumOfEventWeights[0]->GetBinContent(c2+1));\r
2581                               \r
2582     wPrefactor[c1][c2] =  fIntFlowSumOfProductOfEventWeights->GetBinContent(sumOfProductOfEventWeightsLabel2)/ \r
2583                           (fIntFlowSumOfEventWeights[0]->GetBinContent(c1+1)\r
2584                             * fIntFlowSumOfEventWeights[0]->GetBinContent(c2+1));\r
2585                           \r
2586                               \r
2587    }\r
2588    productOfCorrelationsLabel++;\r
2589    sumOfProductOfEventWeightsLabel1++;\r
2590    sumOfProductOfEventWeightsLabel2++;  \r
2591   }\r
2592  }\r
2593  \r
2594  // covariance label:\r
2595  Int_t covarianceLabel = 1;\r
2596  for(Int_t c1=0;c1<4;c1++)\r
2597  {\r
2598   for(Int_t c2=c1+1;c2<4;c2++)\r
2599   {\r
2600    if(denominator[c1][c2])\r
2601    {\r
2602     // covariances:\r
2603     Double_t cov = (productOfCorrelations[c1][c2]-correlation[c1]*correlation[c2])/denominator[c1][c2]; \r
2604     // covarianced multiplied with weight dependent prefactor:\r
2605     Double_t wCov = cov * wPrefactor[c1][c2];\r
2606     fIntFlowCovariances->SetBinContent(covarianceLabel,wCov);\r
2607    }\r
2608    covarianceLabel++;\r
2609   }\r
2610  }\r
2611  \r
2612 } // end of AliFlowAnalysisWithQCumulants::CalculateCovariancesIntFlow()\r
2613 \r
2614 \r
2615 //================================================================================================================================\r
2616 \r
2617 \r
2618 void AliFlowAnalysisWithQCumulants::FinalizeCorrelationsIntFlow() \r
2619 {\r
2620  // From profile fIntFlowCorrelationsPro access measured correlations and spread, \r
2621  // correctly calculate the statistical errors and store the final results and \r
2622  // statistical errors for correlations in histogram fIntFlowCorrelationsHist.\r
2623  //\r
2624  // Remark: Statistical error of correlation is calculated as:\r
2625  //\r
2626  //          statistical error = termA * spread * termB:\r
2627  //          termA = sqrt{sum_{i=1}^{N} w^2}/(sum_{i=1}^{N} w)\r
2628  //          termB = 1/sqrt(1-termA^2)   \r
2629  \r
2630  for(Int_t power=0;power<2;power++)\r
2631  { \r
2632   if(!(fIntFlowCorrelationsHist && fIntFlowCorrelationsPro && fIntFlowSumOfEventWeights[power])) \r
2633   {\r
2634    cout<<"WARNING: fIntFlowCorrelationsHist && fIntFlowCorrelationsPro && fIntFlowSumOfEventWeights[power] is NULL in AFAWQC::FCIF() !!!!"<<endl;\r
2635    cout<<"power = "<<power<<endl;\r
2636    exit(0);\r
2637   }\r
2638  }\r
2639   \r
2640  for(Int_t ci=1;ci<=4;ci++) // correlation index\r
2641  {\r
2642   Double_t correlation = fIntFlowCorrelationsPro->GetBinContent(ci);\r
2643   Double_t spread = fIntFlowCorrelationsPro->GetBinError(ci);\r
2644   Double_t sumOfLinearEventWeights = fIntFlowSumOfEventWeights[0]->GetBinContent(ci);\r
2645   Double_t sumOfQuadraticEventWeights = fIntFlowSumOfEventWeights[1]->GetBinContent(ci);\r
2646   Double_t termA = 0.;\r
2647   Double_t termB = 0.;\r
2648   if(sumOfLinearEventWeights)\r
2649   {\r
2650    termA = pow(sumOfQuadraticEventWeights,0.5)/sumOfLinearEventWeights;\r
2651   } else\r
2652     {\r
2653      cout<<"WARNING: sumOfLinearEventWeights == 0 in AFAWQC::FCIF() !!!!"<<endl;\r
2654      cout<<"         (for "<<2*ci<<"-particle correlation)"<<endl;\r
2655     }\r
2656   if(1.-pow(termA,2.) > 0.)\r
2657   {\r
2658    termB = 1./pow(1-pow(termA,2.),0.5);\r
2659   } else\r
2660     {\r
2661      cout<<"WARNING: 1.-pow(termA,2.) <= 0 in AFAWQC::FCIF() !!!!"<<endl;   \r
2662      cout<<"         (for "<<2*ci<<"-particle correlation)"<<endl;\r
2663     }     \r
2664   Double_t statisticalError = termA * spread * termB;\r
2665   fIntFlowCorrelationsHist->SetBinContent(ci,correlation);\r
2666   fIntFlowCorrelationsHist->SetBinError(ci,statisticalError);\r
2667  } // end of for(Int_t ci=1;ci<=4;ci++) // correlation index                                                                \r
2668                                                                                                                               \r
2669 } // end of AliFlowAnalysisWithQCumulants::FinalizeCorrelationsIntFlow()\r
2670 \r
2671 \r
2672 //================================================================================================================================\r
2673 \r
2674 \r
2675 void AliFlowAnalysisWithQCumulants::FillAverageMultiplicities(Int_t nRP)\r
2676 {\r
2677  // Fill profile fAverageMultiplicity to hold average multiplicities and number of events for events with nRP>=0, nRP>=1, ... , and nRP>=8\r
2678  \r
2679  // Binning of fAverageMultiplicity is organized as follows:\r
2680  //  1st bin: all events (including the empty ones)\r
2681  //  2nd bin: event with # of RPs greater or equal to 1\r
2682  //  3rd bin: event with # of RPs greater or equal to 2\r
2683  //  4th bin: event with # of RPs greater or equal to 3\r
2684  //  5th bin: event with # of RPs greater or equal to 4\r
2685  //  6th bin: event with # of RPs greater or equal to 5\r
2686  //  7th bin: event with # of RPs greater or equal to 6\r
2687  //  8th bin: event with # of RPs greater or equal to 7\r
2688  //  9th bin: event with # of RPs greater or equal to 8\r
2689  \r
2690  if(!fAvMultiplicity)\r
2691  {\r
2692   cout<<"WARNING: fAvMultiplicity is NULL in AFAWQC::FAM() !!!!"<<endl;\r
2693   exit(0);\r
2694  }\r
2695  \r
2696  if(nRP<0)\r
2697  {\r
2698   cout<<"WARNING: nRP<0 in in AFAWQC::FAM() !!!!"<<endl;\r
2699   exit(0);\r
2700  }\r
2701  \r
2702  for(Int_t i=0;i<9;i++)\r
2703  {\r
2704   if(nRP>=i) fAvMultiplicity->Fill(i+0.5,nRP,1);\r
2705  }\r
2706  \r
2707 } // end of AliFlowAnalysisWithQCumulants::FillAverageMultiplicities(nRP)\r
2708 \r
2709 \r
2710 //================================================================================================================================\r
2711 \r
2712 \r
2713 void AliFlowAnalysisWithQCumulants::CalculateCumulantsIntFlow()\r
2714 {\r
2715  // a) Calculate Q-cumulants from the measured multiparticle correlations.\r
2716  // b) Propagate the statistical errors of measured multiparticle correlations to statistical errors of Q-cumulants.  \r
2717  // c) REMARK: Q-cumulants calculated in this method are biased by non-uniform acceptance of detector !!!! \r
2718  //            Method ApplyCorrectionForNonUniformAcceptance* (to be improved: finalize the name here)\r
2719  //            is called afterwards to correct for this bias.   \r
2720  // d) Store the results and statistical error of Q-cumulants in histogram fCumulants.\r
2721  //    Binning of fCumulants is organized as follows:\r
2722  //\r
2723  //     1st bin: QC{2}\r
2724  //     2nd bin: QC{4}\r
2725  //     3rd bin: QC{6}\r
2726  //     4th bin: QC{8}\r
2727  \r
2728  if(!(fIntFlowCorrelationsHist && fIntFlowCovariances && fIntFlowQcumulants))\r
2729  {\r
2730   cout<<"WARNING: fIntFlowCorrelationsHist && fIntFlowCovariances && fIntFlowQcumulants is NULL in AFAWQC::CCIF() !!!!"<<endl;\r
2731   exit(0);\r
2732  }\r
2733  \r
2734  // correlations:\r
2735  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>> \r
2736  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>  \r
2737  Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>> \r
2738  Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>  \r
2739  \r
2740  // statistical errors of average 2-, 4-, 6- and 8-particle azimuthal correlations:\r
2741  Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1); // statistical error of <2>  \r
2742  Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2); // statistical error of <4>   \r
2743  Double_t sixError = fIntFlowCorrelationsHist->GetBinError(3); // statistical error of <6> \r
2744  Double_t eightError = fIntFlowCorrelationsHist->GetBinError(4); // statistical error of <8> \r
2745  \r
2746  // covariances (multiplied by prefactor depending on weights - see comments in CalculateCovariancesIntFlow()):\r
2747  Double_t wCov24 = fIntFlowCovariances->GetBinContent(1); // Cov(<2>,<4>) * prefactor(w_<2>,w_<4>)\r
2748  Double_t wCov26 = fIntFlowCovariances->GetBinContent(2); // Cov(<2>,<6>) * prefactor(w_<2>,w_<6>)\r
2749  Double_t wCov28 = fIntFlowCovariances->GetBinContent(3); // Cov(<2>,<8>) * prefactor(w_<2>,w_<8>)\r
2750  Double_t wCov46 = fIntFlowCovariances->GetBinContent(4); // Cov(<4>,<6>) * prefactor(w_<4>,w_<6>)\r
2751  Double_t wCov48 = fIntFlowCovariances->GetBinContent(5); // Cov(<4>,<8>) * prefactor(w_<4>,w_<8>)\r
2752  Double_t wCov68 = fIntFlowCovariances->GetBinContent(6); // Cov(<6>,<8>) * prefactor(w_<6>,w_<8>)\r
2753  \r
2754  // Q-cumulants: \r
2755  Double_t qc2 = 0.; // QC{2}\r
2756  Double_t qc4 = 0.; // QC{4}\r
2757  Double_t qc6 = 0.; // QC{6}\r
2758  Double_t qc8 = 0.; // QC{8}\r
2759  if(two) qc2 = two; \r
2760  if(four) qc4 = four-2.*pow(two,2.); \r
2761  if(six) qc6 = six-9.*two*four+12.*pow(two,3.); \r
2762  if(eight) qc8 = eight-16.*two*six-18.*pow(four,2.)+144.*pow(two,2.)*four-144.*pow(two,4.); \r
2763  \r
2764  // statistical errors of Q-cumulants:       \r
2765  Double_t qc2Error = 0.;\r
2766  Double_t qc4Error = 0.;\r
2767  Double_t qc6Error = 0.;\r
2768  Double_t qc8Error = 0.;\r
2769  \r
2770  // squared statistical errors of Q-cumulants:       \r
2771  //Double_t qc2ErrorSquared = 0.;\r
2772  Double_t qc4ErrorSquared = 0.;\r
2773  Double_t qc6ErrorSquared = 0.;\r
2774  Double_t qc8ErrorSquared = 0.;\r
2775         \r
2776  // statistical error of QC{2}:              \r
2777  qc2Error = twoError;                     \r
2778                              \r
2779  // statistical error of QC{4}:              \r
2780  qc4ErrorSquared = 16.*pow(two,2.)*pow(twoError,2)+pow(fourError,2.)\r
2781                  - 8.*two*wCov24;                     \r
2782  if(qc4ErrorSquared>0.)\r
2783  {\r
2784   qc4Error = pow(qc4ErrorSquared,0.5);\r
2785  } else \r
2786    {\r
2787     cout<<"WARNING: Statistical error of QC{4} is imaginary !!!!"<<endl;\r
2788    }\r
2789                                            \r
2790  // statistical error of QC{6}:              \r
2791  qc6ErrorSquared = 81.*pow(4.*pow(two,2.)-four,2.)*pow(twoError,2.)\r
2792                  + 81.*pow(two,2.)*pow(fourError,2.)\r
2793                  + pow(sixError,2.)\r
2794                  - 162.*two*(4.*pow(two,2.)-four)*wCov24\r
2795                  + 18.*(4.*pow(two,2.)-four)*wCov26\r
2796                  - 18.*two*wCov46; \r
2797                     \r
2798  if(qc6ErrorSquared>0.)\r
2799  {\r
2800   qc6Error = pow(qc6ErrorSquared,0.5);\r
2801  } else \r
2802    {\r
2803     cout<<"WARNING: Statistical error of QC{6} is imaginary !!!!"<<endl;\r
2804    }\r
2805                             \r
2806  // statistical error of QC{8}:              \r
2807  qc8ErrorSquared = 256.*pow(36.*pow(two,3.)-18.*four*two+six,2.)*pow(twoError,2.)\r
2808                  + 1296.*pow(4.*pow(two,2.)-four,2.)*pow(fourError,2.)\r
2809                  + 256.*pow(two,2.)*pow(sixError,2.)\r
2810                  + pow(eightError,2.)\r
2811                  - 1152.*(36.*pow(two,3.)-18.*four*two+six)*(4.*pow(two,2.)-four)*wCov24\r
2812                  + 512.*two*(36.*pow(two,3.)-18.*four*two+six)*wCov26\r
2813                  - 32.*(36.*pow(two,3.)-18.*four*two+six)*wCov28\r
2814                  - 1152.*two*(4.*pow(two,2.)-four)*wCov46\r
2815                  + 72.*(4.*pow(two,2.)-four)*wCov48\r
2816                  - 32.*two*wCov68;      \r
2817  if(qc8ErrorSquared>0.)\r
2818  {\r
2819   qc8Error = pow(qc8ErrorSquared,0.5);\r
2820  } else \r
2821    {\r
2822     cout<<"WARNING: Statistical error of QC{8} is imaginary !!!!"<<endl;\r
2823    }\r
2824 \r
2825  // store the results and statistical errors for Q-cumulants:\r
2826  fIntFlowQcumulants->SetBinContent(1,qc2);\r
2827  fIntFlowQcumulants->SetBinError(1,qc2Error);\r
2828  fIntFlowQcumulants->SetBinContent(2,qc4);\r
2829  fIntFlowQcumulants->SetBinError(2,qc4Error);\r
2830  fIntFlowQcumulants->SetBinContent(3,qc6);\r
2831  fIntFlowQcumulants->SetBinError(3,qc6Error);\r
2832  fIntFlowQcumulants->SetBinContent(4,qc8); \r
2833  fIntFlowQcumulants->SetBinError(4,qc8Error); \r
2834   \r
2835 } // end of AliFlowAnalysisWithQCumulants::CalculateCumulantsIntFlow()\r
2836 \r
2837 \r
2838 //================================================================================================================================ \r
2839 \r
2840 \r
2841 void AliFlowAnalysisWithQCumulants::CalculateIntFlow()\r
2842 {\r
2843  // a) Calculate the final results for integrated flow estimates from Q-cumulants.\r
2844  // b) Propagate the statistical errors of measured multiparticle correlations to statistical errors of integrated flow estimates.  \r
2845  // c) Store the results and statistical errors of integrated flow estimates in histogram fIntFlow.\r
2846  //    Binning of fIntFlow is organized as follows:\r
2847  //\r
2848  //     1st bin: v{2,QC}\r
2849  //     2nd bin: v{4,QC}\r
2850  //     3rd bin: v{6,QC}\r
2851  //     4th bin: v{8,QC}\r
2852  \r
2853  if(!(fIntFlowCorrelationsHist && fIntFlowCovariances && fIntFlowQcumulants && fIntFlow))\r
2854  {\r
2855   cout<<"WARNING: fIntFlowCorrelationsHist && fIntFlowCovariances && fIntFlowQcumulants && fIntFlow is NULL in AFAWQC::CCIF() !!!!"<<endl;\r
2856   exit(0);\r
2857  }\r
2858    \r
2859  // Q-cumulants:\r
2860  Double_t qc2 = fIntFlowQcumulants->GetBinContent(1); // QC{2}  \r
2861  Double_t qc4 = fIntFlowQcumulants->GetBinContent(2); // QC{4}  \r
2862  Double_t qc6 = fIntFlowQcumulants->GetBinContent(3); // QC{6}  \r
2863  Double_t qc8 = fIntFlowQcumulants->GetBinContent(4); // QC{8}\r
2864   \r
2865  // correlations:\r
2866  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>> \r
2867  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>  \r
2868  Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>> \r
2869  Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>  \r
2870  \r
2871  // statistical errors of average 2-, 4-, 6- and 8-particle azimuthal correlations:\r
2872  Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1); // statistical error of <2>  \r
2873  Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2); // statistical error of <4>   \r
2874  Double_t sixError = fIntFlowCorrelationsHist->GetBinError(3); // statistical error of <6> \r
2875  Double_t eightError = fIntFlowCorrelationsHist->GetBinError(4); // statistical error of <8> \r
2876  \r
2877  // covariances (multiplied by prefactor depending on weights - see comments in CalculateCovariancesIntFlow()):\r
2878  Double_t wCov24 = fIntFlowCovariances->GetBinContent(1); // Cov(<2>,<4>) * prefactor(w_<2>,w_<4>)\r
2879  Double_t wCov26 = fIntFlowCovariances->GetBinContent(2); // Cov(<2>,<6>) * prefactor(w_<2>,w_<6>)\r
2880  Double_t wCov28 = fIntFlowCovariances->GetBinContent(3); // Cov(<2>,<8>) * prefactor(w_<2>,w_<8>)\r
2881  Double_t wCov46 = fIntFlowCovariances->GetBinContent(4); // Cov(<4>,<6>) * prefactor(w_<4>,w_<6>)\r
2882  Double_t wCov48 = fIntFlowCovariances->GetBinContent(5); // Cov(<4>,<8>) * prefactor(w_<4>,w_<8>)\r
2883  Double_t wCov68 = fIntFlowCovariances->GetBinContent(6); // Cov(<6>,<8>) * prefactor(w_<6>,w_<8>)\r
2884   \r
2885  // integrated flow estimates:\r
2886  Double_t v2 = 0.; // v{2,QC}  \r
2887  Double_t v4 = 0.; // v{4,QC}  \r
2888  Double_t v6 = 0.; // v{6,QC}  \r
2889  Double_t v8 = 0.; // v{8,QC}\r
2890  \r
2891  // calculate integrated flow estimates from Q-cumulants: \r
2892  if(qc2>=0.) v2 = pow(qc2,1./2.); \r
2893  if(qc4<=0.) v4 = pow(-1.*qc4,1./4.); \r
2894  if(qc6>=0.) v6 = pow((1./4.)*qc6,1./6.); \r
2895  if(qc8<=0.) v8 = pow((-1./33.)*qc8,1./8.); \r
2896    \r
2897  // statistical errors of integrated flow estimates:\r
2898  Double_t v2Error = 0.; // statistical error of v{2,QC}  \r
2899  Double_t v4Error = 0.; // statistical error of v{4,QC}  \r
2900  Double_t v6Error = 0.; // statistical error of v{6,QC}  \r
2901  Double_t v8Error = 0.; // statistical error of v{8,QC}\r
2902    \r
2903  // squares of statistical errors of integrated flow estimates:\r
2904  Double_t v2ErrorSquared = 0.; // squared statistical error of v{2,QC} \r
2905  Double_t v4ErrorSquared = 0.; // squared statistical error of v{4,QC}   \r
2906  Double_t v6ErrorSquared = 0.; // squared statistical error of v{6,QC}   \r
2907  Double_t v8ErrorSquared = 0.; // squared statistical error of v{8,QC} \r
2908  \r
2909  // calculate squared statistical errors of integrated flow estimates:\r
2910  if(two > 0.) \r
2911  { \r
2912   v2ErrorSquared = (1./(4.*two))*pow(twoError,2.);\r
2913  } \r
2914  if(2.*pow(two,2.)-four > 0.)\r
2915  {\r
2916   v4ErrorSquared = (1./pow(2.*pow(two,2.)-four,3./2.))*\r
2917                    (pow(two,2.)*pow(twoError,2.)+(1./16.)*pow(fourError,2.)-(1./2.)*two*wCov24);\r
2918  }\r
2919  if(six-9.*four*two+12.*pow(two,3.) > 0.) \r
2920  {\r
2921   v6ErrorSquared = ((1./2.)*(1./pow(2.,2./3.))*(1./pow(six-9.*four*two+12.*pow(two,3.),5./3.)))*\r
2922                    ((9./2.)*pow(4.*pow(two,2.)-four,2.)*pow(twoError,2.) \r
2923                     + (9./2.)*pow(two,2.)*pow(fourError,2.)+(1./18.)*pow(sixError,2.)\r
2924                     - 9.*two*(4.*pow(two,2.)-four)*wCov24+(4.*pow(two,2.)-four)*wCov26-two*wCov46); \r
2925  }\r
2926  if(-1.*eight+16.*six*two+18.*pow(four,2.)-144.*four*pow(two,2.)+144.*pow(two,4.) > 0.) \r
2927  {\r
2928   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
2929                    (pow(36.*pow(two,3.)-18.*four*two+six,2.)*pow(twoError,2.)\r
2930                     + (81./16.)*pow(4.*pow(two,2.)-four,2.)*pow(fourError,2.)\r
2931                     + pow(two,2.)*pow(sixError,2.)\r
2932                     + (1./256.)*pow(eightError,2.)\r
2933                     - (9./2.)*(36.*pow(two,3.)-18.*four*two+six)*(4.*pow(two,2.)-four)*wCov24\r
2934                     + 2.*two*(36.*pow(two,3.)-18.*four*two+six)*wCov26\r
2935                     - (1./8.)*(36.*pow(two,3.)-18.*four*two+six)*wCov28                    \r
2936                     - (9./2.)*two*(4.*pow(two,2.)-four)*wCov46                   \r
2937                     + (9./32.)*(4.*pow(two,2.)-four)*wCov48                    \r
2938                     - (1./8.)*two*wCov68);\r
2939  } \r
2940 \r
2941  // calculate statistical errors of integrated flow estimates: \r
2942  if(v2ErrorSquared > 0.)\r
2943  {\r
2944   v2Error = pow(v2ErrorSquared,0.5);\r
2945  } else\r
2946    {\r
2947     cout<<"WARNING: Statistical error of v{2,QC} is imaginary !!!!"<<endl;\r
2948    }    \r
2949  if(v4ErrorSquared > 0.)\r
2950  {\r
2951   v4Error = pow(v4ErrorSquared,0.5);\r
2952  } else\r
2953    {\r
2954     cout<<"WARNING: Statistical error of v{4,QC} is imaginary !!!!"<<endl;\r
2955    }     \r
2956  if(v6ErrorSquared > 0.)\r
2957  {\r
2958   v6Error = pow(v6ErrorSquared,0.5);\r
2959  } else\r
2960    {\r
2961     cout<<"WARNING: Statistical error of v{6,QC} is imaginary !!!!"<<endl;\r
2962    }     \r
2963  if(v8ErrorSquared > 0.)\r
2964  {\r
2965   v8Error = pow(v8ErrorSquared,0.5);\r
2966  } else\r
2967    {\r
2968     cout<<"WARNING: Statistical error of v{8,QC} is imaginary !!!!"<<endl;\r
2969    }    \r
2970                      \r
2971  // store the results and statistical errors of integrated flow estimates:\r
2972  fIntFlow->SetBinContent(1,v2);\r
2973  fIntFlow->SetBinError(1,v2Error);\r
2974  fIntFlow->SetBinContent(2,v4);\r
2975  fIntFlow->SetBinError(2,v4Error);\r
2976  fIntFlow->SetBinContent(3,v6);\r
2977  fIntFlow->SetBinError(3,v6Error);\r
2978  fIntFlow->SetBinContent(4,v8);\r
2979  fIntFlow->SetBinError(4,v8Error);\r
2980        \r
2981 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlow()\r
2982 \r
2983 \r
2984 //================================================================================================================================ \r
2985 \r
2986 \r
2987 void AliFlowAnalysisWithQCumulants::FillCommonHistResultsIntFlow()\r
2988 {\r
2989  // Fill in AliFlowCommonHistResults histograms relevant for 'NONAME' integrated flow (to be improved (name))\r
2990  \r
2991  if(!fIntFlow)\r
2992  {\r
2993   cout<<"WARNING: fIntFlow is NULL in AFAWQC::FCHRIF() !!!!"<<endl;\r
2994   exit(0); \r
2995  }  \r
2996     \r
2997  if(!(fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th))\r
2998  {\r
2999   cout<<"WARNING: fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th"<<endl; \r
3000   cout<<"         is NULL in AFAWQC::FCHRIF() !!!!"<<endl;\r
3001   exit(0);\r
3002  }\r
3003  \r
3004  Double_t v2 = fIntFlow->GetBinContent(1);\r
3005  Double_t v4 = fIntFlow->GetBinContent(2);\r
3006  Double_t v6 = fIntFlow->GetBinContent(3);\r
3007  Double_t v8 = fIntFlow->GetBinContent(4);\r
3008   \r
3009  Double_t v2Error = fIntFlow->GetBinError(1);\r
3010  Double_t v4Error = fIntFlow->GetBinError(2);\r
3011  Double_t v6Error = fIntFlow->GetBinError(3);\r
3012  Double_t v8Error = fIntFlow->GetBinError(4);\r
3013  \r
3014  fCommonHistsResults2nd->FillIntegratedFlow(v2,v2Error); // to be improved (hardwired 2nd in the name)  \r
3015  fCommonHistsResults4th->FillIntegratedFlow(v4,v4Error); // to be improved (hardwired 4th in the name)\r
3016  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (calculate also 6th and 8th order)\r
3017  {\r
3018   fCommonHistsResults6th->FillIntegratedFlow(v6,v6Error); // to be improved (hardwired 6th in the name)\r
3019   fCommonHistsResults8th->FillIntegratedFlow(v8,v8Error); // to be improved (hardwired 8th in the name) \r
3020  }\r
3021  \r
3022 } // end of AliFlowAnalysisWithQCumulants::FillCommonHistResultsIntFlow()\r
3023 \r
3024 \r
3025 //================================================================================================================================ \r
3026 \r
3027 \r
3028 /*\r
3029 void AliFlowAnalysisWithQCumulants::ApplyCorrectionForNonUniformAcceptanceToCumulantsForIntFlow(Bool_t useParticleWeights, TString eventWeights)\r
3030 {\r
3031  // apply correction for non-uniform acceptance to cumulants for integrated flow \r
3032  // (Remark: non-corrected cumulants are accessed from fCumulants[pW][0], corrected cumulants are stored in fCumulants[pW][1])\r
3033  \r
3034  // shortcuts for the flags:\r
3035  Int_t pW = (Int_t)(useParticleWeights); // 0=pWeights not used, 1=pWeights used\r
3036  Int_t eW = -1;\r
3037  \r
3038  if(eventWeights == "exact")\r
3039  {\r
3040   eW = 0;\r
3041  }\r
3042  \r
3043  if(!(fCumulants[pW][eW][0] && fCumulants[pW][eW][1] && fCorrections[pW][eW]))\r
3044  {\r
3045   cout<<"WARNING: fCumulants[pW][eW][0] && fCumulants[pW][eW][1] && fCorrections[pW][eW] is NULL in AFAWQC::ACFNUATCFIF() !!!!"<<endl;\r
3046   cout<<"pW = "<<pW<<endl;\r
3047   cout<<"eW = "<<eW<<endl;\r
3048   exit(0);\r
3049  } \r
3050   \r
3051  // non-corrected cumulants:\r
3052  Double_t qc2 = fCumulants[pW][eW][0]->GetBinContent(1); \r
3053  Double_t qc4 = fCumulants[pW][eW][0]->GetBinContent(2); \r
3054  Double_t qc6 = fCumulants[pW][eW][0]->GetBinContent(3); \r
3055  Double_t qc8 = fCumulants[pW][eW][0]->GetBinContent(4); \r
3056  // statistical error of non-corrected cumulants:  \r
3057  Double_t qc2Error = fCumulants[pW][eW][0]->GetBinError(1); \r
3058  Double_t qc4Error = fCumulants[pW][eW][0]->GetBinError(2); \r
3059  Double_t qc6Error = fCumulants[pW][eW][0]->GetBinError(3); \r
3060  Double_t qc8Error = fCumulants[pW][eW][0]->GetBinError(4); \r
3061  // corrections for non-uniform acceptance:\r
3062  Double_t qc2Correction = fCorrections[pW][eW]->GetBinContent(1); \r
3063  Double_t qc4Correction = fCorrections[pW][eW]->GetBinContent(2); \r
3064  Double_t qc6Correction = fCorrections[pW][eW]->GetBinContent(3); \r
3065  Double_t qc8Correction = fCorrections[pW][eW]->GetBinContent(4); \r
3066  // corrected cumulants:\r
3067  Double_t qc2Corrected = qc2 + qc2Correction;\r
3068  Double_t qc4Corrected = qc4 + qc4Correction;\r
3069  Double_t qc6Corrected = qc6 + qc6Correction;\r
3070  Double_t qc8Corrected = qc8 + qc8Correction;\r
3071   \r
3072  // ... to be improved (I need here also to correct error of QCs for NUA. \r
3073  // For simplicity sake I assume at the moment that this correction is negliglible, but it will be added eventually...)\r
3074  \r
3075  // store corrected results and statistical errors for cumulants:   \r
3076  fCumulants[pW][eW][1]->SetBinContent(1,qc2Corrected);\r
3077  fCumulants[pW][eW][1]->SetBinContent(2,qc4Corrected);\r
3078  fCumulants[pW][eW][1]->SetBinContent(3,qc6Corrected);\r
3079  fCumulants[pW][eW][1]->SetBinContent(4,qc8Corrected);\r
3080  fCumulants[pW][eW][1]->SetBinError(1,qc2Error); // to be improved (correct also qc2Error for NUA)\r
3081  fCumulants[pW][eW][1]->SetBinError(2,qc4Error); // to be improved (correct also qc4Error for NUA)\r
3082  fCumulants[pW][eW][1]->SetBinError(3,qc6Error); // to be improved (correct also qc6Error for NUA)\r
3083  fCumulants[pW][eW][1]->SetBinError(4,qc8Error); // to be improved (correct also qc8Error for NUA)  \r
3084   \r
3085 } // end of AliFlowAnalysisWithQCumulants::ApplyCorrectionForNonUniformAcceptanceToCumulantsForIntFlow(Bool_t useParticleWeights, TString eventWeights)\r
3086 */\r
3087 \r
3088 \r
3089 //================================================================================================================================\r
3090 \r
3091 \r
3092 /*  \r
3093 void AliFlowAnalysisWithQCumulants::PrintQuantifyingCorrectionsForNonUniformAcceptance(Bool_t useParticleWeights, TString eventWeights)\r
3094 {\r
3095  // print on the screen QC{n,biased}/QC{n,corrected}\r
3096  \r
3097  // shortcuts for the flags:\r
3098  Int_t pW = (Int_t)(useParticleWeights); // 0=pWeights not used, 1=pWeights used\r
3099  \r
3100  Int_t eW = -1;\r
3101  \r
3102  if(eventWeights == "exact")\r
3103  {\r
3104   eW = 0;\r
3105  } \r
3106  \r
3107  if(!(fCumulants[pW][eW][0] && fCumulants[pW][eW][1]))\r
3108  {\r
3109   cout<<"WARNING: fCumulants[pW][eW][0] && fCumulants[pW][eW][1] is NULL in AFAWQC::PQCFNUA() !!!!"<<endl;\r
3110   cout<<"pW = "<<pW<<endl;\r
3111   cout<<"eW = "<<eW<<endl;\r
3112   exit(0);\r
3113  }\r
3114    \r
3115  cout<<endl;\r
3116  cout<<" Quantifying the bias to Q-cumulants from"<<endl;\r
3117  cout<<"  non-uniform acceptance of the detector:"<<endl;\r
3118  cout<<endl;\r
3119   \r
3120  if(fCumulants[pW][eW][1]->GetBinContent(1)) \r
3121  { \r
3122   cout<<"  QC{2,biased}/QC{2,corrected} = "<<(fCumulants[pW][eW][0]->GetBinContent(1))/(fCumulants[pW][eW][1]->GetBinContent(1))<<endl;   \r
3123  }\r
3124  if(fCumulants[pW][eW][1]->GetBinContent(2)) \r
3125  { \r
3126   cout<<"  QC{4,biased}/QC{4,corrected} = "<<fCumulants[pW][eW][0]->GetBinContent(2)/fCumulants[pW][eW][1]->GetBinContent(2)<<endl;   \r
3127  }\r
3128  \r
3129  cout<<endl;\r
3130             \r
3131 } // end of AliFlowAnalysisWithQCumulants::PrintQuantifyingCorrectionsForNonUniformAcceptance(Bool_t useParticleWeights, TString eventWeights)\r
3132 */\r
3133 \r
3134 \r
3135 //================================================================================================================================\r
3136 \r
3137 \r
3138 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelationsUsingParticleWeights()\r
3139 {\r
3140  // Calculate all correlations needed for integrated flow using particle weights.\r
3141   \r
3142  // Remark 1: When particle weights are used the binning of fIntFlowCorrelationAllPro is organized as follows:\r
3143  //\r
3144  //  1st bin: <2>_{1n|1n} = two1n1nW1W1 = <w1 w2 cos(n*(phi1-phi2))>\r
3145  //  2nd bin: <2>_{2n|2n} = two2n2nW2W2 = <w1^2 w2^2 cos(2n*(phi1-phi2))>\r
3146  //  3rd bin: <2>_{3n|3n} = two3n3nW3W3 = <w1^3 w2^3 cos(3n*(phi1-phi2))> \r
3147  //  4th bin: <2>_{4n|4n} = two4n4nW4W4 = <w1^4 w2^4 cos(4n*(phi1-phi2))>\r
3148  //  5th bin:           ----  EMPTY ----\r
3149  //  6th bin: <3>_{2n|1n,1n} = three2n1n1nW2W1W1 = <w1^2 w2 w3 cos(n*(2phi1-phi2-phi3))>\r
3150  //  7th bin: <3>_{3n|2n,1n} = ...\r
3151  //  8th bin: <3>_{4n|2n,2n} = ...\r
3152  //  9th bin: <3>_{4n|3n,1n} = ...\r
3153  // 10th bin:           ----  EMPTY ----\r
3154  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1nW1W1W1W1 = <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))>\r
3155  // 12th bin: <4>_{2n,1n|2n,1n} = ...\r
3156  // 13th bin: <4>_{2n,2n|2n,2n} = ...\r
3157  // 14th bin: <4>_{3n|1n,1n,1n} = ... \r
3158  // 15th bin: <4>_{3n,1n|3n,1n} = ...\r
3159  // 16th bin: <4>_{3n,1n|2n,2n} = ...\r
3160  // 17th bin: <4>_{4n|2n,1n,1n} = ... \r
3161  // 18th bin:           ----  EMPTY ----\r
3162  // 19th bin: <5>_{2n|1n,1n,1n,1n} = ...\r
3163  // 20th bin: <5>_{2n,2n|2n,1n,1n} = ...\r
3164  // 21st bin: <5>_{3n,1n|2n,1n,1n} = ...\r
3165  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = ...\r
3166  // 23rd bin:           ----  EMPTY ----\r
3167  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = ...\r
3168  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = ...\r
3169  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = ...\r
3170  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = ...\r
3171  // 28th bin:           ----  EMPTY ----\r
3172  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = ...\r
3173  // 30th bin:           ----  EMPTY ----\r
3174  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = ...\r
3175  \r
3176  // Remark 2: When particle weights are used there are some extra correlations. They are stored in \r
3177  // fIntFlowExtraCorrelationsPro binning of which is organized as follows:\r
3178  \r
3179  // 1st bin: two1n1nW3W1 = <w1^3 w2 cos(n*(phi1-phi2))>\r
3180  // 2nd bin: two1n1nW1W1W2 = <w1 w2 w3^2 cos(n*(phi1-phi2))>  \r
3181  // ...\r
3182   \r
3183  // multiplicity (number of particles used to determine the reaction plane)\r
3184  Double_t dMult = (*fSMpk)(0,0);\r
3185  \r
3186  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
3187  Double_t dReQ1n1k = (*fReQ)(0,1);\r
3188  Double_t dReQ2n2k = (*fReQ)(1,2);\r
3189  Double_t dReQ3n3k = (*fReQ)(2,3);\r
3190  Double_t dReQ4n4k = (*fReQ)(3,4);\r
3191  Double_t dReQ1n3k = (*fReQ)(0,3);\r
3192  Double_t dImQ1n1k = (*fImQ)(0,1);\r
3193  Double_t dImQ2n2k = (*fImQ)(1,2);\r
3194  Double_t dImQ3n3k = (*fImQ)(2,3);\r
3195  Double_t dImQ4n4k = (*fImQ)(3,4);\r
3196  Double_t dImQ1n3k = (*fImQ)(0,3);\r
3197 \r
3198  // dMs are variables introduced in order to simplify some Eqs. bellow:\r
3199  //..............................................................................................\r
3200  Double_t dM11 = (*fSMpk)(1,1)-(*fSMpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j\r
3201  Double_t dM22 = (*fSMpk)(1,2)-(*fSMpk)(0,4); // dM22 = sum_{i,j=1,i!=j}^M w_i^2 w_j^2\r
3202  Double_t dM33 = (*fSMpk)(1,3)-(*fSMpk)(0,6); // dM33 = sum_{i,j=1,i!=j}^M w_i^3 w_j^3\r
3203  Double_t dM44 = (*fSMpk)(1,4)-(*fSMpk)(0,8); // dM44 = sum_{i,j=1,i!=j}^M w_i^4 w_j^4\r
3204  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
3205  Double_t dM211 = (*fSMpk)(0,2)*(*fSMpk)(1,1)-2.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
3206                 - (*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
3207  Double_t dM1111 = (*fSMpk)(3,1)-6.*(*fSMpk)(0,2)*(*fSMpk)(1,1)  \r
3208                  + 8.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
3209                  + 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
3210  //..............................................................................................\r
3211 \r
3212  // 2-particle correlations:\r
3213  Double_t two1n1nW1W1 = 0.; // <w1 w2 cos(n*(phi1-phi2))>\r
3214  Double_t two2n2nW2W2 = 0.; // <w1^2 w2^2 cos(2n*(phi1-phi2))>\r
3215  Double_t two3n3nW3W3 = 0.; // <w1^3 w2^3 cos(3n*(phi1-phi2))>\r
3216  Double_t two4n4nW4W4 = 0.; // <w1^4 w2^4 cos(4n*(phi1-phi2))>\r
3217  if(dMult>1) \r
3218  { \r
3219   if(dM11)\r
3220   {\r
3221    two1n1nW1W1 = (pow(dReQ1n1k,2)+pow(dImQ1n1k,2)-(*fSMpk)(0,2))/dM11;    \r
3222    // average correlation <w1 w2 cos(n*(phi1-phi2))> for single event: \r
3223    fIntFlowCorrelationsEBE->SetBinContent(1,two1n1nW1W1);\r
3224    fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(1,dM11);\r
3225    // average correlation <w1 w2 cos(n*(phi1-phi2))> for all events:\r
3226    fIntFlowCorrelationsPro->Fill(0.5,two1n1nW1W1,dM11);   \r
3227    fIntFlowCorrelationsAllPro->Fill(0.5,two1n1nW1W1,dM11);   \r
3228   }\r
3229   if(dM22)\r
3230   {\r
3231    two2n2nW2W2 = (pow(dReQ2n2k,2)+pow(dImQ2n2k,2)-(*fSMpk)(0,4))/dM22; \r
3232    // ...\r
3233    // average correlation <w1^2 w2^2 cos(2n*(phi1-phi2))> for all events:\r
3234    fIntFlowCorrelationsAllPro->Fill(1.5,two2n2nW2W2,dM22);   \r
3235   }\r
3236   if(dM33)\r
3237   {\r
3238    two3n3nW3W3 = (pow(dReQ3n3k,2)+pow(dImQ3n3k,2)-(*fSMpk)(0,6))/dM33;\r
3239    // ...\r
3240    // average correlation <w1^3 w2^3 cos(3n*(phi1-phi2))> for all events:\r
3241    fIntFlowCorrelationsAllPro->Fill(2.5,two3n3nW3W3,dM33);   \r
3242   }\r
3243   if(dM44)\r
3244   {\r
3245    two4n4nW4W4 = (pow(dReQ4n4k,2)+pow(dImQ4n4k,2)-(*fSMpk)(0,8))/dM44; \r
3246    // ...\r
3247    // average correlation <w1^4 w2^4 cos(4n*(phi1-phi2))> for all events:\r
3248    fIntFlowCorrelationsAllPro->Fill(3.5,two4n4nW4W4,dM44);      \r
3249   }\r
3250  } // end of if(dMult>1) \r
3251 \r
3252  // extra 2-particle correlations:\r
3253  Double_t two1n1nW3W1 = 0.; // <w1^3 w2 cos(n*(phi1-phi2))>\r
3254  Double_t two1n1nW1W1W2 = 0.; // <w1 w2 w3^2 cos(n*(phi1-phi2))> \r
3255  if(dMult>1) \r
3256  {    \r
3257   if(dM31)\r
3258   {\r
3259    two1n1nW3W1 = (dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k-(*fSMpk)(0,4))/dM31; \r
3260    fIntFlowExtraCorrelationsPro->Fill(0.5,two1n1nW3W1,dM31);  \r
3261   } \r
3262   if(dM211)\r
3263   {\r
3264    two1n1nW1W1W2 = ((*fSMpk)(0,2)*(pow(dReQ1n1k,2)+pow(dImQ1n1k,2)-(*fSMpk)(0,2))\r
3265                  - 2.*(dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k\r
3266                  - (*fSMpk)(0,4)))/dM211;\r
3267    fIntFlowExtraCorrelationsPro->Fill(1.5,two1n1nW1W1W2,dM211);  \r
3268   }  \r
3269  } // end of if(dMult>1)\r
3270  //..............................................................................................\r
3271  \r
3272  //..............................................................................................\r
3273  // 3-particle correlations:\r
3274  Double_t three2n1n1nW2W1W1 = 0.; // <w1^2 w2 w3 cos(n*(2phi1-phi2-phi3))>\r
3275  \r
3276  if(dMult>2) \r
3277  { \r
3278   if(dM211)\r
3279   {                                                       \r
3280    three2n1n1nW2W1W1 = (pow(dReQ1n1k,2.)*dReQ2n2k+2.*dReQ1n1k*dImQ1n1k*dImQ2n2k-pow(dImQ1n1k,2.)*dReQ2n2k\r
3281                      - 2.*(dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k)\r
3282                      - pow(dReQ2n2k,2)-pow(dImQ2n2k,2)\r
3283                      + 2.*(*fSMpk)(0,4))/dM211;                                                                               \r
3284    fIntFlowCorrelationsAllPro->Fill(5.5,three2n1n1nW2W1W1,dM211);\r
3285   } \r
3286  } // end of if(dMult>2) \r
3287  //..............................................................................................\r
3288  \r
3289  //..............................................................................................\r
3290  // 4-particle correlations:\r
3291  Double_t four1n1n1n1nW1W1W1W1 = 0.; // <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))>\r
3292  if(dMult>3) \r
3293  { \r
3294   if(dM1111)\r
3295   {      \r
3296    four1n1n1n1nW1W1W1W1 = (pow(pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.),2)\r
3297                         - 2.*(pow(dReQ1n1k,2.)*dReQ2n2k+2.*dReQ1n1k*dImQ1n1k*dImQ2n2k-pow(dImQ1n1k,2.)*dReQ2n2k)\r
3298                         + 8.*(dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k)\r
3299                         + (pow(dReQ2n2k,2)+pow(dImQ2n2k,2))\r
3300                         - 4.*(*fSMpk)(0,2)*(pow(dReQ1n1k,2)+pow(dImQ1n1k,2))\r
3301                         - 6.*(*fSMpk)(0,4)+2.*(*fSMpk)(1,2))/dM1111;  \r
3302                           \r
3303    // average correlation <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))> for single event: \r
3304    fIntFlowCorrelationsEBE->SetBinContent(2,four1n1n1n1nW1W1W1W1);\r
3305    fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(2,dM1111);\r
3306    // average correlation <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))> for all events:\r
3307    fIntFlowCorrelationsPro->Fill(1.5,four1n1n1n1nW1W1W1W1,dM1111);   \r
3308    fIntFlowCorrelationsAllPro->Fill(10.5,four1n1n1n1nW1W1W1W1,dM1111);   \r
3309   } \r
3310  } // end of if(dMult>3) \r
3311  //..............................................................................................\r
3312  \r
3313 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelationsUsingParticleWeights()\r
3314 \r
3315 \r
3316 //================================================================================================================================\r
3317 \r
3318 \r
3319 void AliFlowAnalysisWithQCumulants::CalculateWeightedQProductsForIntFlow() // to be improved (completed)\r
3320 {\r
3321  // calculate averages like <<2><4>>, <<2><6>>, <<4><6>>, etc. which are needed to calculate covariances \r
3322  // Remark: here we take weighted correlations!\r
3323  \r
3324  /*\r
3325  \r
3326  // binning of fQProductsW is organized as follows:\r
3327  // \r
3328  // 1st bin: <2><4> \r
3329  // 2nd bin: <2><6>\r
3330  // 3rd bin: <2><8>\r
3331  // 4th bin: <4><6>\r
3332  // 5th bin: <4><8>\r
3333  // 6th bin: <6><8>\r
3334  \r
3335  Double_t dMult = (*fSMpk)(0,0); // multiplicity (number of particles used to determine the reaction plane)\r
3336 \r
3337  Double_t dM11 = (*fSMpk)(1,1)-(*fSMpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j\r
3338  Double_t dM1111 = (*fSMpk)(3,1)-6.*(*fSMpk)(0,2)*(*fSMpk)(1,1)  \r
3339                  + 8.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
3340                  + 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
3341 \r
3342  Double_t twoEBEW = 0.; // <2>\r
3343  Double_t fourEBEW = 0.; // <4>\r
3344  \r
3345  twoEBEW = fQCorrelationsEBE[1]->GetBinContent(1);\r
3346  fourEBEW = fQCorrelationsEBE[1]->GetBinContent(11);\r
3347  \r
3348  // <2><4>\r
3349  if(dMult>3)\r
3350  {\r
3351   fQProducts[1][0]->Fill(0.5,twoEBEW*fourEBEW,dM11*dM1111);\r
3352  }\r
3353  \r
3354  */\r
3355  \r
3356 } // end of AliFlowAnalysisWithQCumulants::CalculateWeightedQProductsForIntFlow()  \r
3357 \r
3358 \r
3359 //================================================================================================================================\r
3360 \r
3361 \r
3362 void AliFlowAnalysisWithQCumulants::InitializeArraysForIntFlow()\r
3363 {\r
3364  // Initialize all arrays used to calculate integrated flow.\r
3365  \r
3366  for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
3367  {\r
3368   fIntFlowCorrectionTermsForNUAEBE[sc] = NULL;\r
3369   fIntFlowCorrectionTermsForNUAPro[sc] = NULL;\r
3370   fIntFlowCorrectionTermsForNUAHist[sc] = NULL;\r
3371  }\r
3372    \r
3373  for(Int_t power=0;power<2;power++) // linear or quadratic \r
3374  {\r
3375   fIntFlowSumOfEventWeights[power] = NULL;    \r
3376  }\r
3377  \r
3378 } // end of void AliFlowAnalysisWithQCumulants::InitializeArraysForIntFlow()\r
3379 \r
3380 \r
3381 //================================================================================================================================\r
3382 \r
3383 \r
3384 void AliFlowAnalysisWithQCumulants::InitializeArraysForDiffFlow()\r
3385 {\r
3386  // Initialize all arrays needed to calculate differential flow.\r
3387  //  a) Initialize lists holding profiles;\r
3388  //  b) Initialize lists holding histograms;\r
3389  //  c) Initialize event-by-event quantities;\r
3390  //  d) Initialize profiles;\r
3391  //  e) Initialize histograms holding final results.\r
3392  \r
3393  // a) Initialize lists holding profiles;\r
3394  for(Int_t t=0;t<2;t++) // type (RP, POI)\r
3395  {\r
3396   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3397   {\r
3398    fDiffFlowCorrelationsProList[t][pe] = NULL;\r
3399    fDiffFlowProductOfCorrelationsProList[t][pe] = NULL;\r
3400    fDiffFlowCorrectionsProList[t][pe] = NULL;\r
3401   }\r
3402  }  \r
3403  \r
3404  // b) Initialize lists holding histograms;\r
3405  for(Int_t t=0;t<2;t++) // type (RP, POI)\r
3406  {\r
3407   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3408   {\r
3409    fDiffFlowCorrelationsHistList[t][pe] = NULL;\r
3410    for(Int_t power=0;power<2;power++)\r
3411    {\r
3412     fDiffFlowSumOfEventWeightsHistList[t][pe][power] = NULL;\r
3413    } // end of for(Int_t power=0;power<2;power++)  \r
3414    fDiffFlowSumOfProductOfEventWeightsHistList[t][pe] = NULL;\r
3415    fDiffFlowCorrectionsHistList[t][pe] = NULL;\r
3416    fDiffFlowCovariancesHistList[t][pe] = NULL;\r
3417    fDiffFlowCumulantsHistList[t][pe] = NULL;\r
3418    fDiffFlowHistList[t][pe] = NULL;\r
3419   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3420  } // enf of for(Int_t t=0;t<2;t++) // type (RP, POI) \r
3421  \r
3422  // c) Initialize event-by-event quantities:\r
3423  // 1D:\r
3424  for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)\r
3425  {\r
3426   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3427   { \r
3428    for(Int_t m=0;m<4;m++) // multiple of harmonic\r
3429    {\r
3430     for(Int_t k=0;k<9;k++) // power of weight\r
3431     {\r
3432      fReRPQ1dEBE[t][pe][m][k] = NULL;\r
3433      fImRPQ1dEBE[t][pe][m][k] = NULL;\r
3434      fs1dEBE[t][pe][k] = NULL; // to be improved (this doesn't need to be within loop over m)\r
3435     }   \r
3436    }\r
3437   }\r
3438  }\r
3439  // 1D:\r
3440  for(Int_t t=0;t<2;t++) // type (RP or POI)\r
3441  {\r
3442   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3443   { \r
3444    for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
3445    {\r
3446     for(Int_t cti=0;cti<9;cti++) // correction term index\r
3447     {\r
3448      fDiffFlowCorrectionTermsForNUAEBE[t][pe][sc][cti] = NULL;\r
3449     }   \r
3450    }\r
3451   }\r
3452  }\r
3453  // 2D:  \r
3454  for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)\r
3455  {\r
3456   for(Int_t m=0;m<4;m++) // multiple of harmonic\r
3457   {\r
3458    for(Int_t k=0;k<9;k++) // power of weight\r
3459    {\r
3460     fReRPQ2dEBE[t][m][k] = NULL;\r
3461     fImRPQ2dEBE[t][m][k] = NULL;\r
3462     fs2dEBE[t][k] = NULL; // to be improved (this doesn't need to be within loop over m)\r
3463    }   \r
3464   }\r
3465  }\r
3466  \r
3467  // d) Initialize profiles:\r
3468  for(Int_t t=0;t<2;t++) // type: RP or POI\r
3469  { \r
3470   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3471   {\r
3472    for(Int_t ci=0;ci<4;ci++) // correlation index\r
3473    {\r
3474     fDiffFlowCorrelationsPro[t][pe][ci] = NULL;\r
3475    } // end of for(Int_t ci=0;ci<4;ci++)   \r
3476    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
3477    {\r
3478     for(Int_t mci2=0;mci2<8;mci2++) // mixed correlation index\r
3479     {\r
3480      fDiffFlowProductOfCorrelationsPro[t][pe][mci1][mci2] = NULL;\r
3481     } // end of for(Int_t mci2=0;mci2<8;mci2++) // mixed correlation index\r
3482    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index  \r
3483    // correction terms for nua:\r
3484    for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
3485    {\r
3486     for(Int_t cti=0;cti<9;cti++) // correction term index\r
3487     {\r
3488      fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti] = NULL;\r
3489     }   \r
3490    }\r
3491   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3492  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
3493   \r
3494  // e) Initialize histograms holding final results.\r
3495  for(Int_t t=0;t<2;t++) // type: RP or POI\r
3496  { \r
3497   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3498   {\r
3499    for(Int_t ci=0;ci<4;ci++) // correlation index\r
3500    {\r
3501     fDiffFlowCorrelationsHist[t][pe][ci] = NULL;\r
3502     fDiffFlowCumulants[t][pe][ci] = NULL;\r
3503     fDiffFlow[t][pe][ci] = NULL;\r
3504    } // end of for(Int_t ci=0;ci<4;ci++)    \r
3505    for(Int_t covarianceIndex=0;covarianceIndex<5;covarianceIndex++) \r
3506    {\r
3507     fDiffFlowCovariances[t][pe][covarianceIndex] = NULL;     \r
3508    } // end of for(Int_t covarianceIndex=0;covarianceIndex<5;covarianceIndex++) \r
3509    // correction terms for nua:\r
3510    for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
3511    {\r
3512     for(Int_t cti=0;cti<9;cti++) // correction term index\r
3513     {\r
3514      fDiffFlowCorrectionTermsForNUAHist[t][pe][sc][cti] = NULL;\r
3515     }   \r
3516    }\r
3517   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3518  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
3519  \r
3520  // sum of event weights for reduced correlations:\r
3521  for(Int_t t=0;t<2;t++) // type = RP or POI\r
3522  {\r
3523   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3524   {\r
3525    for(Int_t p=0;p<2;p++) // power of weight is 1 or 2\r
3526    {\r
3527     for(Int_t ew=0;ew<4;ew++) // event weight index for reduced correlations\r
3528     {\r
3529      fDiffFlowSumOfEventWeights[t][pe][p][ew] = NULL;\r
3530     } \r
3531    }   \r
3532   }\r
3533  }\r
3534  // product of event weights for both types of correlations:\r
3535  for(Int_t t=0;t<2;t++) // type = RP or POI\r
3536  {\r
3537   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
3538   {\r
3539    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
3540    {\r
3541     for(Int_t mci2=0;mci2<8;mci2++) // mixed correlation index\r
3542     {\r
3543      fDiffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2] = NULL;\r
3544     } \r
3545    }   \r
3546   }\r
3547  }\r
3548 \r
3549  \r
3550  \r
3551  \r
3552  /*\r
3553  \r
3554  // nested lists in fDiffFlowProfiles:\r
3555  for(Int_t t=0;t<2;t++)\r
3556  {\r
3557   fDFPType[t] = NULL;\r
3558   for(Int_t pW=0;pW<2;pW++) // particle weights not used (0) or used (1)\r
3559   {\r
3560    fDFPParticleWeights[t][pW] = NULL;\r
3561    for(Int_t eW=0;eW<2;eW++)\r
3562    {   \r
3563     fDFPEventWeights[t][pW][eW] = NULL;\r
3564     fDiffFlowCorrelations[t][pW][eW] = NULL;\r
3565     fDiffFlowProductsOfCorrelations[t][pW][eW] = NULL;\r
3566     for(Int_t sc=0;sc<2;sc++)\r
3567     {\r
3568      fDiffFlowCorrectionTerms[t][pW][eW][sc] = NULL;\r
3569     }\r
3570    } \r
3571   }\r
3572  }  \r
3573  \r
3574  \r
3575  */\r
3576  \r
3577   \r
3578   \r
3579   /*\r
3580   for(Int_t pW=0;pW<2;pW++) // particle weights not used (0) or used (1)\r
3581   {\r
3582    for(Int_t eW=0;eW<2;eW++)\r
3583    {\r
3584     // correlations:\r
3585     for(Int_t correlationIndex=0;correlationIndex<4;correlationIndex++)\r
3586     {\r
3587      fCorrelationsPro[t][pW][eW][correlationIndex] = NULL;\r
3588     }\r
3589     // products of correlations:\r
3590     for(Int_t productOfCorrelationsIndex=0;productOfCorrelationsIndex<6;productOfCorrelationsIndex++)\r
3591     {\r
3592      fProductsOfCorrelationsPro[t][pW][eW][productOfCorrelationsIndex] = NULL;\r
3593     }\r
3594     // correction terms:\r
3595     for(Int_t sc=0;sc<2;sc++)\r
3596     {\r
3597      for(Int_t correctionsIndex=0;correctionsIndex<2;correctionsIndex++)\r
3598      {\r
3599       fCorrectionTermsPro[t][pW][eW][sc][correctionsIndex] = NULL;\r
3600      } \r
3601     } \r
3602    }\r
3603   } \r
3604   */\r
3605     \r
3606 } // end of AliFlowAnalysisWithQCumulants::InitializeArraysForDiffFlow()\r
3607 \r
3608 \r
3609 //================================================================================================================================\r
3610  /*\r
3611 \r
3612 \r
3613 void AliFlowAnalysisWithQCumulants::CalculateCorrelationsForDifferentialFlow2D(TString type)\r
3614 {\r
3615  // calculate all reduced correlations needed for differential flow for each (pt,eta) bin: \r
3616  \r
3617  if(type == "RP") // to be improved (removed)\r
3618  {\r
3619   cout<<endl;\r
3620  }\r
3621  // ... \r
3622  \r
3623  \r
3624  Int_t typeFlag = -1; \r
3625   \r
3626  // reduced correlations ares stored in fCorrelationsPro[t][pW][index] and are indexed as follows:\r
3627  // index:\r
3628  // 0: <2'>\r
3629  // 1: <4'>\r
3630 \r
3631  // multiplicity:\r
3632  Double_t dMult = (*fSMpk)(0,0);\r
3633  \r
3634  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
3635  Double_t dReQ1n = (*fReQ)(0,0);\r
3636  Double_t dReQ2n = (*fReQ)(1,0);\r
3637  //Double_t dReQ3n = (*fReQ)(2,0);\r
3638  //Double_t dReQ4n = (*fReQ)(3,0);\r
3639  Double_t dImQ1n = (*fImQ)(0,0);\r
3640  Double_t dImQ2n = (*fImQ)(1,0);\r
3641  //Double_t dImQ3n = (*fImQ)(2,0);\r
3642  //Double_t dImQ4n = (*fImQ)(3,0);\r
3643 \r
3644  // looping over all (pt,eta) bins and calculating correlations needed for differential flow: \r
3645  for(Int_t p=1;p<=fnBinsPt;p++)\r
3646  {\r
3647   for(Int_t e=1;e<=fnBinsEta;e++)\r
3648   {\r
3649    // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular (pt,eta) bin): \r
3650    Double_t p1n0kRe = 0.;\r
3651    Double_t p1n0kIm = 0.;\r
3652 \r
3653    // number of POIs in particular (pt,eta) bin:\r
3654    Double_t mp = 0.;\r
3655 \r
3656    // 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
3657    Double_t q1n0kRe = 0.;\r
3658    Double_t q1n0kIm = 0.;\r
3659    Double_t q2n0kRe = 0.;\r
3660    Double_t q2n0kIm = 0.;\r
3661 \r
3662    // number of particles which are both RPs and POIs in particular (pt,eta) bin:\r
3663    Double_t mq = 0.;\r
3664    \r
3665    // q_{m*n,0}:\r
3666    q1n0kRe = fReEBE2D[2][0][0]->GetBinContent(fReEBE2D[2][0][0]->GetBin(p,e))\r
3667            * fReEBE2D[2][0][0]->GetBinEntries(fReEBE2D[2][0][0]->GetBin(p,e));\r
3668    q1n0kIm = fImEBE2D[2][0][0]->GetBinContent(fImEBE2D[2][0][0]->GetBin(p,e))\r
3669            * fImEBE2D[2][0][0]->GetBinEntries(fImEBE2D[2][0][0]->GetBin(p,e));\r
3670    q2n0kRe = fReEBE2D[2][1][0]->GetBinContent(fReEBE2D[2][1][0]->GetBin(p,e))\r
3671            * fReEBE2D[2][1][0]->GetBinEntries(fReEBE2D[2][1][0]->GetBin(p,e));\r
3672    q2n0kIm = fImEBE2D[2][1][0]->GetBinContent(fImEBE2D[2][1][0]->GetBin(p,e))\r
3673            * fImEBE2D[2][1][0]->GetBinEntries(fImEBE2D[2][1][0]->GetBin(p,e));\r
3674            \r
3675    mq = fReEBE2D[2][0][0]->GetBinEntries(fReEBE2D[2][0][0]->GetBin(p,e)); // to be improved (cross-checked by accessing other profiles here)\r
3676    \r
3677    if(type == "POI")\r
3678    {\r
3679     // p_{m*n,0}:\r
3680     p1n0kRe = fReEBE2D[1][0][0]->GetBinContent(fReEBE2D[1][0][0]->GetBin(p,e))\r
3681             * fReEBE2D[1][0][0]->GetBinEntries(fReEBE2D[1][0][0]->GetBin(p,e));\r
3682     p1n0kIm = fImEBE2D[1][0][0]->GetBinContent(fImEBE2D[1][0][0]->GetBin(p,e))  \r
3683             * fImEBE2D[1][0][0]->GetBinEntries(fImEBE2D[1][0][0]->GetBin(p,e));\r
3684             \r
3685     mp = fReEBE2D[1][0][0]->GetBinEntries(fReEBE2D[1][0][0]->GetBin(p,e)); // to be improved (cross-checked by accessing other profiles here)\r
3686     \r
3687     typeFlag = 1;\r
3688    }\r
3689    else if(type == "RP")\r
3690    {\r
3691     // p_{m*n,0} = q_{m*n,0}:\r
3692     p1n0kRe = q1n0kRe; \r
3693     p1n0kIm = q1n0kIm; \r
3694     mp = mq; \r
3695     \r
3696     typeFlag = 0;\r
3697    }\r
3698    \r
3699    // count events with non-empty (pt,eta) bin:\r
3700    if(mp>0)\r
3701    {\r
3702     fNonEmptyBins2D[typeFlag]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,1);\r
3703    }\r
3704    \r
3705    // 2'-particle correlation for particular (pt,eta) bin:\r
3706    Double_t two1n1nPtEta = 0.;\r
3707    if(mp*dMult-mq)\r
3708    {\r
3709     two1n1nPtEta = (p1n0kRe*dReQ1n+p1n0kIm*dImQ1n-mq)\r
3710                  / (mp*dMult-mq);\r
3711    \r
3712     // fill the 2D profile to get the average correlation for each (pt,eta) bin:\r
3713     if(type == "POI")\r
3714     { \r
3715      //f2pPtEtaPOI->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nPtEta,mp*dMult-mq);\r
3716      \r
3717      fCorrelationsPro[1][0][0][0]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nPtEta,mp*dMult-mq);\r
3718     }\r
3719     else if(type == "RP")\r
3720     {\r
3721      //f2pPtEtaRP->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nPtEta,mp*dMult-mq);   \r
3722      fCorrelationsPro[0][0][0][0]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nPtEta,mp*dMult-mq);\r
3723     }\r
3724    } // end of if(mp*dMult-mq)\r
3725   \r
3726    // 4'-particle correlation:\r
3727    Double_t four1n1n1n1nPtEta = 0.;\r
3728    if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3729        + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)) // to be improved (introduce a new variable for this expression)\r
3730    {\r
3731     four1n1n1n1nPtEta = ((pow(dReQ1n,2.)+pow(dImQ1n,2.))*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)\r
3732                       - q2n0kRe*(pow(dReQ1n,2.)-pow(dImQ1n,2.))\r
3733                       - 2.*q2n0kIm*dReQ1n*dImQ1n\r
3734                       - p1n0kRe*(dReQ1n*dReQ2n+dImQ1n*dImQ2n)\r
3735                       + p1n0kIm*(dImQ1n*dReQ2n-dReQ1n*dImQ2n)\r
3736                       - 2.*dMult*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)\r
3737                       - 2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*mq                      \r
3738                       + 6.*(q1n0kRe*dReQ1n+q1n0kIm*dImQ1n)                                            \r
3739                       + 1.*(q2n0kRe*dReQ2n+q2n0kIm*dImQ2n)                      \r
3740                       + 2.*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)                       \r
3741                       + 2.*mq*dMult                      \r
3742                       - 6.*mq)        \r
3743                       / ((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3744                           + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)); \r
3745     \r
3746     // fill the 2D profile to get the average correlation for each (pt, eta) bin:\r
3747     if(type == "POI")\r
3748     {\r
3749      //f4pPtEtaPOI->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nPtEta,\r
3750      //                  (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3751      //                   + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
3752      \r
3753      fCorrelationsPro[1][0][0][1]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nPtEta,\r
3754                                      (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3755                                      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));\r
3756     }\r
3757     else if(type == "RP")\r
3758     {\r
3759      //f4pPtEtaRP->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nPtEta,\r
3760      //                 (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3761      //                  + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));   \r
3762                        \r
3763      fCorrelationsPro[0][0][0][1]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nPtEta,\r
3764                                        (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3765                                        + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));                   \r
3766     }\r
3767    } // end of if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
3768      //            +mq*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
3769    \r
3770   } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
3771  } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
3772 \r
3773  \r
3774    \r
3775     \r
3776       \r
3777 } // end of AliFlowAnalysisWithQCumulants::CalculateCorrelationsForDifferentialFlow2D()\r
3778 \r
3779 \r
3780 \r
3781  \r
3782  \r
3783 \r
3784 //================================================================================================================================\r
3785 \r
3786 \r
3787 void AliFlowAnalysisWithQCumulants::CalculateWeightedCorrelationsForDifferentialFlow2D(TString type)\r
3788 {\r
3789  // calculate all weighted correlations needed for differential flow \r
3790  \r
3791   if(type == "RP") // to be improved (removed)\r
3792  {\r
3793   cout<<endl;\r
3794  }\r
3795  // ... \r
3796  \r
3797  \r
3798  \r
3799  \r
3800  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
3801  Double_t dReQ1n1k = (*fReQ)(0,1);\r
3802  Double_t dReQ2n2k = (*fReQ)(1,2);\r
3803  Double_t dReQ1n3k = (*fReQ)(0,3);\r
3804  //Double_t dReQ4n4k = (*fReQ)(3,4);\r
3805  Double_t dImQ1n1k = (*fImQ)(0,1);\r
3806  Double_t dImQ2n2k = (*fImQ)(1,2);\r
3807  Double_t dImQ1n3k = (*fImQ)(0,3);\r
3808  //Double_t dImQ4n4k = (*fImQ)(3,4);\r
3809  \r
3810  // S^M_{p,k} (see .h file for the definition of fSMpk):\r
3811  Double_t dSM1p1k = (*fSMpk)(0,1);\r
3812  Double_t dSM1p2k = (*fSMpk)(0,2);\r
3813  Double_t dSM1p3k = (*fSMpk)(0,3);\r
3814  Double_t dSM2p1k = (*fSMpk)(1,1);\r
3815  Double_t dSM3p1k = (*fSMpk)(2,1);\r
3816  \r
3817  // looping over all (pt,eta) bins and calculating weighted correlations needed for differential flow: \r
3818  for(Int_t p=1;p<=fnBinsPt;p++)\r
3819  {\r
3820   for(Int_t e=1;e<=fnBinsEta;e++)\r
3821   {\r
3822    // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular (pt,eta) bin):  \r
3823    Double_t p1n0kRe = 0.;\r
3824    Double_t p1n0kIm = 0.;\r
3825 \r
3826    // number of POIs in particular (pt,eta) bin):\r
3827    Double_t mp = 0.;\r
3828 \r
3829    // real and imaginary parts of q_{m*n,k}: \r
3830    // (weighted Q-vector evaluated for particles which are both RPs and POIs in particular (pt,eta) bin)\r
3831    Double_t q1n2kRe = 0.;\r
3832    Double_t q1n2kIm = 0.;\r
3833    Double_t q2n1kRe = 0.;\r
3834    Double_t q2n1kIm = 0.;\r
3835 \r
3836    // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
3837    Double_t s1p1k = 0.; \r
3838    Double_t s1p2k = 0.; \r
3839    Double_t s1p3k = 0.; \r
3840    \r
3841    // M0111 from Eq. (118) in QC2c (to be improved (notation))\r
3842    Double_t dM0111 = 0.;\r
3843  \r
3844    if(type == "POI")\r
3845    {\r
3846     // p_{m*n,0}:\r
3847     p1n0kRe = fReEBE2D[1][0][0]->GetBinContent(fReEBE2D[1][0][0]->GetBin(p,e))\r
3848             * fReEBE2D[1][0][0]->GetBinEntries(fReEBE2D[1][0][0]->GetBin(p,e));\r
3849     p1n0kIm = fImEBE2D[1][0][0]->GetBinContent(fImEBE2D[1][0][0]->GetBin(p,e))\r
3850             * fImEBE2D[1][0][0]->GetBinEntries(fImEBE2D[1][0][0]->GetBin(p,e)); \r
3851             \r
3852     mp = fReEBE2D[1][0][0]->GetBinEntries(fReEBE2D[1][0][0]->GetBin(p,e));\r
3853     \r
3854     // q_{m*n,k}: \r
3855     q1n2kRe = fReEBE2D[2][0][2]->GetBinContent(fReEBE2D[2][0][2]->GetBin(p,e))\r
3856             * fReEBE2D[2][0][2]->GetBinEntries(fReEBE2D[2][0][2]->GetBin(p,e));\r
3857     q1n2kIm = fImEBE2D[2][0][2]->GetBinContent(fImEBE2D[2][0][2]->GetBin(p,e))\r
3858             * fImEBE2D[2][0][2]->GetBinEntries(fImEBE2D[2][0][2]->GetBin(p,e));\r
3859     q2n1kRe = fReEBE2D[2][1][1]->GetBinContent(fReEBE2D[2][1][1]->GetBin(p,e))\r
3860             * fReEBE2D[2][1][1]->GetBinEntries(fReEBE2D[2][1][1]->GetBin(p,e)); \r
3861     q2n1kIm = fImEBE2D[2][1][1]->GetBinContent(fImEBE2D[2][1][1]->GetBin(p,e))\r
3862             * fImEBE2D[2][1][1]->GetBinEntries(fImEBE2D[2][1][1]->GetBin(p,e));\r
3863        \r
3864     // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
3865     s1p1k = pow(fs2D[2][1]->GetBinContent(fs2D[2][1]->GetBin(p,e)),1.); \r
3866     s1p2k = pow(fs2D[2][2]->GetBinContent(fs2D[2][2]->GetBin(p,e)),1.); \r
3867     s1p3k = pow(fs2D[2][3]->GetBinContent(fs2D[2][3]->GetBin(p,e)),1.); \r
3868    \r
3869     // M0111 from Eq. (118) in QC2c (to be improved (notation)):\r
3870     dM0111 = mp*(dSM3p1k-3.*dSM1p1k*dSM1p2k+2.*dSM1p3k)\r
3871            - 3.*(s1p1k*(dSM2p1k-dSM1p2k)\r
3872            + 2.*(s1p3k-s1p2k*dSM1p1k));\r
3873    }\r
3874    else if(type == "RP")\r
3875    {\r
3876     p1n0kRe = fReEBE2D[0][0][0]->GetBinContent(fReEBE2D[0][0][0]->GetBin(p,e))\r
3877             * fReEBE2D[0][0][0]->GetBinEntries(fReEBE2D[0][0][0]->GetBin(p,e));\r
3878     p1n0kIm = fImEBE2D[0][0][0]->GetBinContent(fImEBE2D[0][0][0]->GetBin(p,e))\r
3879             * fImEBE2D[0][0][0]->GetBinEntries(fImEBE2D[0][0][0]->GetBin(p,e));\r
3880             \r
3881     mp = fReEBE2D[0][0][0]->GetBinEntries(fReEBE2D[0][0][0]->GetBin(p,e));\r
3882     \r
3883     // q_{m*n,k}: \r
3884     q1n2kRe = fReEBE2D[0][0][2]->GetBinContent(fReEBE2D[0][0][2]->GetBin(p,e))\r
3885             * fReEBE2D[0][0][2]->GetBinEntries(fReEBE2D[0][0][2]->GetBin(p,e));\r
3886     q1n2kIm = fImEBE2D[0][0][2]->GetBinContent(fImEBE2D[0][0][2]->GetBin(p,e))\r
3887             * fImEBE2D[0][0][2]->GetBinEntries(fImEBE2D[0][0][2]->GetBin(p,e));\r
3888     q2n1kRe = fReEBE2D[0][1][1]->GetBinContent(fReEBE2D[0][1][1]->GetBin(p,e))\r
3889             * fReEBE2D[0][1][1]->GetBinEntries(fReEBE2D[0][1][1]->GetBin(p,e));\r
3890     q2n1kIm = fImEBE2D[0][1][1]->GetBinContent(fImEBE2D[0][1][1]->GetBin(p,e))\r
3891             * fImEBE2D[0][1][1]->GetBinEntries(fImEBE2D[0][1][1]->GetBin(p,e));\r
3892    \r
3893     // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
3894     s1p1k = pow(fs2D[0][1]->GetBinContent(fs2D[0][1]->GetBin(p,e)),1.); \r
3895     s1p2k = pow(fs2D[0][2]->GetBinContent(fs2D[0][2]->GetBin(p,e)),1.); \r
3896     s1p3k = pow(fs2D[0][3]->GetBinContent(fs2D[0][3]->GetBin(p,e)),1.); \r
3897    \r
3898     // M0111 from Eq. (118) in QC2c (to be improved (notation)):\r
3899     dM0111 = mp*(dSM3p1k-3.*dSM1p1k*dSM1p2k+2.*dSM1p3k)\r
3900            - 3.*(s1p1k*(dSM2p1k-dSM1p2k)\r
3901            + 2.*(s1p3k-s1p2k*dSM1p1k));\r
3902     //...............................................................................................   \r
3903    }\r
3904    \r
3905    // 2'-particle correlation:\r
3906    Double_t two1n1nW0W1PtEta = 0.;\r
3907    if(mp*dSM1p1k-s1p1k)\r
3908    {\r
3909     two1n1nW0W1PtEta = (p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k-s1p1k)\r
3910                  / (mp*dSM1p1k-s1p1k);\r
3911    \r
3912     // fill the 2D profile to get the average correlation for each (pt, eta) bin:\r
3913     if(type == "POI")\r
3914     {\r
3915      //f2pPtEtaPOIW->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nW0W1PtEta,\r
3916      //                   mp*dSM1p1k-s1p1k);\r
3917      fCorrelationsPro[1][1][0][0]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nW0W1PtEta,mp*dSM1p1k-s1p1k);\r
3918     }\r
3919     else if(type == "RP")\r
3920     {\r
3921      //f2pPtEtaRPW->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nW0W1PtEta,\r
3922      //                  mp*dSM1p1k-s1p1k); \r
3923      fCorrelationsPro[0][1][0][0]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nW0W1PtEta,mp*dSM1p1k-s1p1k);  \r
3924     }\r
3925    } // end of if(mp*dMult-dmPrimePrimePtEta)\r
3926    \r
3927    // 4'-particle correlation:\r
3928    Double_t four1n1n1n1nW0W1W1W1PtEta = 0.;\r
3929    if(dM0111)\r
3930    {\r
3931     four1n1n1n1nW0W1W1W1PtEta = ((pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.))*(p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k)\r
3932                       - q2n1kRe*(pow(dReQ1n1k,2.)-pow(dImQ1n1k,2.))\r
3933                       - 2.*q2n1kIm*dReQ1n1k*dImQ1n1k\r
3934                       - p1n0kRe*(dReQ1n1k*dReQ2n2k+dImQ1n1k*dImQ2n2k)\r
3935                       + p1n0kIm*(dImQ1n1k*dReQ2n2k-dReQ1n1k*dImQ2n2k)\r
3936                       - 2.*dSM1p2k*(p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k)\r
3937                       - 2.*(pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.))*s1p1k                                            \r
3938                       + 6.*(q1n2kRe*dReQ1n1k+q1n2kIm*dImQ1n1k)                                           \r
3939                       + 1.*(q2n1kRe*dReQ2n2k+q2n1kIm*dImQ2n2k)                         \r
3940                       + 2.*(p1n0kRe*dReQ1n3k+p1n0kIm*dImQ1n3k)                      \r
3941                       + 2.*s1p1k*dSM1p2k                                      \r
3942                       - 6.*s1p3k)        \r
3943                       / dM0111; // to be imropoved (notation of dM0111)\r
3944    \r
3945     // fill the 2D profile to get the average correlation for each (pt, eta) bin:\r
3946     if(type == "POI")\r
3947     {\r
3948      //f4pPtEtaPOIW->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nW0W1W1W1PtEta,dM0111);\r
3949      fCorrelationsPro[1][1][0][1]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nW0W1W1W1PtEta,dM0111);\r
3950     }\r
3951     else if(type == "RP")\r
3952     {\r
3953      //f4pPtEtaRPW->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nW0W1W1W1PtEta,dM0111); \r
3954      fCorrelationsPro[0][1][0][1]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nW0W1W1W1PtEta,dM0111); \r
3955     }\r
3956    } // end of if(dM0111)\r
3957   \r
3958   } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
3959  } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
3960  \r
3961   \r
3962     \r
3963       \r
3964 } // end of AliFlowAnalysisWithQCumulants::CalculateWeightedCorrelationsForDifferentialFlow2D(TString type)\r
3965 \r
3966 \r
3967 //================================================================================================================================\r
3968 \r
3969  */  \r
3970 \r
3971 /*\r
3972 void AliFlowAnalysisWithQCumulants::FinalizeCorrelationsForDiffFlow(TString type, Bool_t useParticleWeights, TString eventWeights)\r
3973 {\r
3974  // 1.) Access average for 2D correlations from profiles and store them in 2D final results histograms;\r
3975  // 2.) Access spread for 2D correlations from profiles, calculate error and store it in 2D final results histograms;\r
3976  // 3.) Make projections along pt and eta axis and store results and errors in 1D final results histograms. \r
3977  \r
3978  Int_t typeFlag = -1;\r
3979  Int_t pWeightsFlag = -1;\r
3980  Int_t eWeightsFlag = -1;\r
3981 \r
3982  if(type == "RP")\r
3983  {\r
3984   typeFlag = 0;\r
3985  } else if(type == "POI")\r
3986    {\r
3987     typeFlag = 1;\r
3988    } else \r
3989      {\r
3990       cout<<"WARNING: type must be either RP or POI in AFAWQC::FCFDF() !!!!"<<endl;\r
3991       exit(0);\r
3992      }\r
3993      \r
3994  if(!useParticleWeights)\r
3995  {\r
3996   pWeightsFlag = 0;\r
3997  } else \r
3998    {\r
3999     pWeightsFlag = 1;   \r
4000    }   \r
4001    \r
4002  if(eventWeights == "exact")\r
4003  {\r
4004   eWeightsFlag = 0;\r
4005  }          \r
4006   \r
4007  // shortcuts:\r
4008  Int_t t = typeFlag;\r
4009  Int_t pW = pWeightsFlag;\r
4010  Int_t eW = eWeightsFlag;\r
4011  \r
4012  // from 2D histogram fNonEmptyBins2D make two 1D histograms fNonEmptyBins1D in pt and eta (to be improved (i.e. moved somewhere else))  \r
4013  // pt:\r
4014  for(Int_t p=1;p<fnBinsPt;p++)\r
4015  {\r
4016   Double_t contentPt = 0.;\r
4017   for(Int_t e=1;e<=fnBinsEta;e++)\r
4018   {\r
4019    contentPt += (fNonEmptyBins2D[t]->GetBinContent(fNonEmptyBins2D[t]->GetBin(p,e)));          \r
4020   }\r
4021   fNonEmptyBins1D[t][0]->SetBinContent(p,contentPt);\r
4022  }\r
4023  // eta:\r
4024  for(Int_t e=1;e<fnBinsEta;e++)\r
4025  {\r
4026   Double_t contentEta = 0.;\r
4027   for(Int_t p=1;p<=fnBinsPt;p++)\r
4028   {\r
4029    contentEta += (fNonEmptyBins2D[t]->GetBinContent(fNonEmptyBins2D[t]->GetBin(p,e)));          \r
4030   }\r
4031   fNonEmptyBins1D[t][1]->SetBinContent(e,contentEta);\r
4032  }\r
4033  \r
4034  // from 2D profile in (pt,eta) make two 1D profiles in (pt) and (eta):\r
4035  TProfile *profile[2][4]; // [0=pt,1=eta][correlation index] // to be improved (do not hardwire the correlation index)\r
4036  \r
4037  for(Int_t pe=0;pe<2;pe++) // pt or eta\r
4038  {\r
4039   for(Int_t ci=0;ci<4;ci++) // correlation index\r
4040   {\r
4041    if(pe==0) profile[pe][ci] = this->MakePtProjection(fCorrelationsPro[t][pW][eW][ci]);\r
4042    if(pe==1) profile[pe][ci] = this->MakeEtaProjection(fCorrelationsPro[t][pW][eW][ci]);\r
4043   }\r
4044  }\r
4045   \r
4046  // transfer 2D profile into 2D histogram:\r
4047  // to be improved (see in documentation if there is a method to transfer values from 2D profile into 2D histogram)    \r
4048  for(Int_t ci=0;ci<4;ci++)\r
4049  {\r
4050   for(Int_t p=1;p<=fnBinsPt;p++)\r
4051   {\r
4052    for(Int_t e=1;e<=fnBinsEta;e++)\r
4053    {\r
4054     Double_t correlation = fCorrelationsPro[t][pW][eW][ci]->GetBinContent(fCorrelationsPro[t][pW][eW][ci]->GetBin(p,e)); \r
4055     Double_t spread = fCorrelationsPro[t][pW][eW][ci]->GetBinError(fCorrelationsPro[t][pW][eW][ci]->GetBin(p,e));\r
4056     Double_t nEvts = fNonEmptyBins2D[t]->GetBinContent(fNonEmptyBins2D[t]->GetBin(p,e));\r
4057     Double_t error = 0.;\r
4058     fFinalCorrelations2D[t][pW][eW][ci]->SetBinContent(fFinalCorrelations2D[t][pW][eW][ci]->GetBin(p,e),correlation);          \r
4059     if(nEvts>0)\r
4060     {\r
4061      error = spread/pow(nEvts,0.5);\r
4062      fFinalCorrelations2D[t][pW][eW][ci]->SetBinError(fFinalCorrelations2D[t][pW][eW][ci]->GetBin(p,e),error);\r
4063     }\r
4064    } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
4065   } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
4066  } // end of for(Int_t ci=0;ci<4;ci++)\r
4067  \r
4068  // transfer 1D profile into 1D histogram (pt):\r
4069  // to be improved (see in documentation if there is a method to transfer values from 1D profile into 1D histogram)    \r
4070  for(Int_t ci=0;ci<4;ci++)\r
4071  {\r
4072   for(Int_t p=1;p<=fnBinsPt;p++)\r
4073   {\r
4074    if(profile[0][ci])\r
4075    {\r
4076     Double_t correlation = profile[0][ci]->GetBinContent(p); \r
4077     Double_t spread = profile[0][ci]->GetBinError(p);\r
4078     Double_t nEvts = fNonEmptyBins1D[t][0]->GetBinContent(p);\r
4079     Double_t error = 0.;\r
4080     fFinalCorrelations1D[t][pW][eW][0][ci]->SetBinContent(p,correlation); \r
4081     if(nEvts>0)\r
4082     {\r
4083      error = spread/pow(nEvts,0.5);\r
4084      fFinalCorrelations1D[t][pW][eW][0][ci]->SetBinError(p,error);\r
4085     }  \r
4086    }   \r
4087   } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
4088  } // end of for(Int_t ci=0;ci<4;ci++)\r
4089  \r
4090  // transfer 1D profile into 1D histogram (eta):\r
4091  // to be improved (see in documentation if there is a method to transfer values from 1D profile into 1D histogram)    \r
4092  for(Int_t ci=0;ci<4;ci++)\r
4093  {\r
4094   for(Int_t e=1;e<=fnBinsEta;e++)\r
4095   {\r
4096    if(profile[1][ci])\r
4097    {\r
4098     Double_t correlation = profile[1][ci]->GetBinContent(e); \r
4099     fFinalCorrelations1D[t][pW][eW][1][ci]->SetBinContent(e,correlation);      \r
4100    }    \r
4101   } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
4102  } // end of for(Int_t ci=0;ci<4;ci++)\r
4103         \r
4104 } // end of void AliFlowAnalysisWithQCumulants::FinalizeCorrelationsForDiffFlow(TString type, Bool_t useParticleWeights, TString eventWeights)\r
4105 */\r
4106 \r
4107 \r
4108 //================================================================================================================================\r
4109 \r
4110 \r
4111 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulants(TString type, TString ptOrEta)\r
4112 {\r
4113  // calcualate cumulants for differential flow from measured correlations\r
4114  // Remark: cumulants calculated here are NOT corrected for non-uniform acceptance. This correction is applied in the method ...\r
4115  // to be improved (description) \r
4116  \r
4117  Int_t typeFlag = -1;\r
4118  Int_t ptEtaFlag = -1;\r
4119 \r
4120  if(type == "RP")\r
4121  {\r
4122   typeFlag = 0;\r
4123  } else if(type == "POI")\r
4124    {\r
4125     typeFlag = 1;\r
4126    } \r
4127      \r
4128  if(ptOrEta == "Pt")\r
4129  {\r
4130   ptEtaFlag = 0;\r
4131  } else if(ptOrEta == "Eta")\r
4132    {\r
4133     ptEtaFlag = 1;\r
4134    } \r
4135   \r
4136  // shortcuts:\r
4137  Int_t t = typeFlag;\r
4138  Int_t pe = ptEtaFlag;\r
4139      \r
4140  // common:\r
4141  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
4142  \r
4143  // correlation <<2>>: \r
4144  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1);\r
4145  \r
4146  // 1D:\r
4147  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
4148  {\r
4149   // reduced correlations:   \r
4150   Double_t twoPrime = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b); // <<2'>>(pt)\r
4151   Double_t fourPrime = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b); // <<4'>>(pt)\r
4152   // final statistical error of reduced correlations:\r
4153   //Double_t twoPrimeError = fFinalCorrelations1D[t][pW][eW][0][0]->GetBinError(p); \r
4154   // QC{2'}:\r
4155   Double_t qc2Prime = twoPrime; // QC{2'}\r
4156   //Double_t qc2PrimeError = twoPrimeError; // final stat. error of QC{2'}\r
4157   fDiffFlowCumulants[t][pe][0]->SetBinContent(b,qc2Prime); \r
4158   //fFinalCumulantsPt[t][pW][eW][nua][0]->SetBinError(p,qc2PrimeError);   \r
4159   // QC{4'}:\r
4160   Double_t qc4Prime = fourPrime - 2.*twoPrime*two; // QC{4'} = <<4'>> - 2*<<2'>><<2>>\r
4161   fDiffFlowCumulants[t][pe][1]->SetBinContent(b,qc4Prime); \r
4162  } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
4163  \r
4164     \r
4165  /* \r
4166  // 2D (pt,eta):\r
4167  // to be improved (see documentation if I can do all this without looping)\r
4168  for(Int_t p=1;p<=fnBinsPt;p++)\r
4169  {\r
4170   for(Int_t e=1;e<=fnBinsEta;e++) \r
4171   {  \r
4172    // reduced correlations:   \r
4173    Double_t twoPrime = fFinalCorrelations2D[t][pW][eW][0]->GetBinContent(fFinalCorrelations2D[t][pW][eW][0]->GetBin(p,e)); // <<2'>>(pt,eta)\r
4174    Double_t fourPrime = fFinalCorrelations2D[t][pW][eW][1]->GetBinContent(fFinalCorrelations2D[t][pW][eW][1]->GetBin(p,e)); // <<4'>>(pt,eta)\r
4175    for(Int_t nua=0;nua<2;nua++)\r
4176    {\r
4177     // QC{2'}:\r
4178     Double_t qc2Prime = twoPrime; // QC{2'} = <<2'>>\r
4179     fFinalCumulants2D[t][pW][eW][nua][0]->SetBinContent(fFinalCumulants2D[t][pW][eW][nua][0]->GetBin(p,e),qc2Prime);    \r
4180     // QC{4'}:\r
4181     Double_t qc4Prime = fourPrime - 2.*twoPrime*two; // QC{4'} = <<4'>> - 2*<<2'>><<2>>\r
4182     fFinalCumulants2D[t][pW][eW][nua][1]->SetBinContent(fFinalCumulants2D[t][pW][eW][nua][1]->GetBin(p,e),qc4Prime);   \r
4183    } // end of for(Int_t nua=0;nua<2;nua++)   \r
4184   } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
4185  } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
4186  */\r
4187    \r
4188 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulants(TString type, Bool_t useParticleWeights, TString eventWeights); \r
4189 \r
4190 \r
4191 //================================================================================================================================\r
4192 \r
4193 \r
4194 void AliFlowAnalysisWithQCumulants::CalculateFinalResultsForRPandPOIIntegratedFlow(TString type)\r
4195 {\r
4196  // calculate final results for integrated flow of RPs and POIs \r
4197   \r
4198  Int_t typeFlag = -1;\r
4199 \r
4200  if(type == "RP")\r
4201  {\r
4202   typeFlag = 0;\r
4203  } else if(type == "POI")\r
4204    {\r
4205     typeFlag = 1;\r
4206    } else \r
4207      {\r
4208       cout<<"WARNING: type must be either RP or POI in AFAWQC::CDF() !!!!"<<endl;\r
4209       exit(0);\r
4210      }\r
4211      \r
4212  // shortcuts:\r
4213  Int_t t = typeFlag;\r
4214   \r
4215  // pt yield:    \r
4216  TH1F *yield2ndPt = NULL;\r
4217  TH1F *yield4thPt = NULL;\r
4218  TH1F *yield6thPt = NULL;\r
4219  TH1F *yield8thPt = NULL;\r
4220  \r
4221  if(type == "POI")\r
4222  {\r
4223   yield2ndPt = (TH1F*)(fCommonHists2nd->GetHistPtPOI())->Clone();\r
4224   yield4thPt = (TH1F*)(fCommonHists4th->GetHistPtPOI())->Clone();\r
4225   yield6thPt = (TH1F*)(fCommonHists6th->GetHistPtPOI())->Clone();\r
4226   yield8thPt = (TH1F*)(fCommonHists8th->GetHistPtPOI())->Clone();  \r
4227  } \r
4228  else if(type == "RP")\r
4229  {\r
4230   yield2ndPt = (TH1F*)(fCommonHists2nd->GetHistPtRP())->Clone();\r
4231   yield4thPt = (TH1F*)(fCommonHists4th->GetHistPtRP())->Clone();\r
4232   yield6thPt = (TH1F*)(fCommonHists6th->GetHistPtRP())->Clone();\r
4233   yield8thPt = (TH1F*)(fCommonHists8th->GetHistPtRP())->Clone();  \r
4234  } \r
4235  \r
4236  Int_t nBinsPt = yield2ndPt->GetNbinsX();\r
4237  \r
4238  TH1D *flow2ndPt = NULL;\r
4239  TH1D *flow4thPt = NULL;\r
4240  TH1D *flow6thPt = NULL;\r
4241  TH1D *flow8thPt = NULL;\r
4242  \r
4243  // to be improved (hardwired pt index)\r
4244  flow2ndPt = (TH1D*)fDiffFlow[t][0][0]->Clone();\r
4245  flow4thPt = (TH1D*)fDiffFlow[t][0][1]->Clone();\r
4246  flow6thPt = (TH1D*)fDiffFlow[t][0][2]->Clone();\r
4247  flow8thPt = (TH1D*)fDiffFlow[t][0][3]->Clone(); \r
4248    \r
4249  Double_t dvn2nd = 0., dvn4th = 0., dvn6th = 0., dvn8th = 0.; // differential flow\r
4250  Double_t dErrvn2nd = 0., dErrvn4th = 0., dErrvn6th = 0., dErrvn8th = 0.; // error on differential flow\r
4251  \r
4252  Double_t dVn2nd = 0., dVn4th = 0., dVn6th = 0., dVn8th = 0.; // integrated flow \r
4253  Double_t dErrVn2nd = 0., dErrVn4th = 0., dErrVn6th = 0., dErrVn8th = 0.; // error on integrated flow\r
4254 \r
4255  Double_t dYield2nd = 0., dYield4th = 0., dYield6th = 0., dYield8th = 0.; // pt yield \r
4256  Double_t dSum2nd = 0., dSum4th = 0., dSum6th = 0., dSum8th = 0.; // needed for normalizing integrated flow\r
4257  \r
4258  // looping over pt bins:\r
4259  for(Int_t p=1;p<nBinsPt+1;p++)\r
4260  {\r
4261   dvn2nd = flow2ndPt->GetBinContent(p);\r
4262   dvn4th = flow4thPt->GetBinContent(p);\r
4263   dvn6th = flow6thPt->GetBinContent(p);\r
4264   dvn8th = flow8thPt->GetBinContent(p);\r
4265   \r
4266   dErrvn2nd = flow2ndPt->GetBinError(p);\r
4267   dErrvn4th = flow4thPt->GetBinError(p);\r
4268   dErrvn6th = flow6thPt->GetBinError(p);\r
4269   dErrvn8th = flow8thPt->GetBinError(p);\r
4270 \r
4271   dYield2nd = yield2ndPt->GetBinContent(p);  \r
4272   dYield4th = yield4thPt->GetBinContent(p);\r
4273   dYield6th = yield6thPt->GetBinContent(p);\r
4274   dYield8th = yield8thPt->GetBinContent(p);\r
4275   \r
4276   dVn2nd += dvn2nd*dYield2nd;\r
4277   dVn4th += dvn4th*dYield4th;\r
4278   dVn6th += dvn6th*dYield6th;\r
4279   dVn8th += dvn8th*dYield8th;\r
4280   \r
4281   dSum2nd += dYield2nd;\r
4282   dSum4th += dYield4th;\r
4283   dSum6th += dYield6th;\r
4284   dSum8th += dYield8th;\r
4285   \r
4286   dErrVn2nd += dYield2nd*dYield2nd*dErrvn2nd*dErrvn2nd; // ro be improved (check this relation)\r
4287   dErrVn4th += dYield4th*dYield4th*dErrvn4th*dErrvn4th;\r
4288   dErrVn6th += dYield6th*dYield6th*dErrvn6th*dErrvn6th;\r
4289   dErrVn8th += dYield8th*dYield8th*dErrvn8th*dErrvn8th;\r
4290     \r
4291  } // end of for(Int_t p=1;p<nBinsPt+1;p++)\r
4292 \r
4293  // normalizing the results for integrated flow:\r
4294  if(dSum2nd) \r
4295  {\r
4296   dVn2nd /= dSum2nd;\r
4297   dErrVn2nd /= (dSum2nd*dSum2nd);\r
4298   dErrVn2nd = TMath::Sqrt(dErrVn2nd);\r
4299  } \r
4300  if(dSum4th) \r
4301  {\r
4302   dVn4th /= dSum4th;\r
4303   dErrVn4th /= (dSum4th*dSum4th);\r
4304   dErrVn4th = TMath::Sqrt(dErrVn4th);\r
4305  } \r
4306  //if(dSum6th) dVn6th/=dSum6th;\r
4307  //if(dSum8th) dVn8th/=dSum8th;\r
4308   \r
4309  // storing the results for integrated flow in common histos: (to be improved: new method for this?)\r
4310  if(type == "POI")\r
4311  {\r
4312   fCommonHistsResults2nd->FillIntegratedFlowPOI(dVn2nd,dErrVn2nd); \r
4313   fCommonHistsResults4th->FillIntegratedFlowPOI(dVn4th,dErrVn4th); \r
4314   fCommonHistsResults6th->FillIntegratedFlowPOI(dVn6th,0.); // to be improved (errors)\r
4315   fCommonHistsResults8th->FillIntegratedFlowPOI(dVn8th,0.); // to be improved (errors)\r
4316  }\r
4317  else if (type == "RP")\r
4318  {\r
4319   fCommonHistsResults2nd->FillIntegratedFlowRP(dVn2nd,dErrVn2nd); \r
4320   fCommonHistsResults4th->FillIntegratedFlowRP(dVn4th,dErrVn4th);\r
4321   fCommonHistsResults6th->FillIntegratedFlowRP(dVn6th,0.); // to be improved (errors)\r
4322   fCommonHistsResults8th->FillIntegratedFlowRP(dVn8th,0.); // to be improved (errors)\r
4323  }\r
4324  \r
4325  delete flow2ndPt;\r
4326  delete flow4thPt;\r
4327  //delete flow6thPt;\r
4328  //delete flow8thPt;\r
4329  \r
4330  delete yield2ndPt;\r
4331  delete yield4thPt;\r
4332  delete yield6thPt;\r
4333  delete yield8thPt;\r
4334            \r
4335 } // end of AliFlowAnalysisWithQCumulants::CalculateFinalResultsForRPandPOIIntegratedFlow(TString type)\r
4336 \r
4337 \r
4338 //================================================================================================================================\r
4339 \r
4340 \r
4341 void AliFlowAnalysisWithQCumulants::InitializeArraysForDistributions()\r
4342 {\r
4343  // initialize arrays used for distributions:\r
4344  \r
4345  /*\r
4346  \r
4347  for(Int_t pW=0;pW<2;pW++) // particle weights not used (0) or used (1)\r
4348  {\r
4349   for(Int_t eW=0;eW<2;eW++)\r
4350   {\r
4351    for(Int_t di=0;di<4;di++) // distribution index\r
4352    {\r
4353     fDistributions[pW][eW][di] = NULL;\r
4354    }\r
4355   } \r
4356  }\r
4357  \r
4358  */\r
4359  \r
4360 } // end of void AliFlowAnalysisWithQCumulants::InitializeArraysForDistributions()\r
4361 \r
4362 \r
4363 //================================================================================================================================\r
4364 \r
4365 \r
4366 void AliFlowAnalysisWithQCumulants::BookEverythingForDistributions()\r
4367 {\r
4368  // book all histograms for distributions\r
4369  \r
4370  /*\r
4371  //weighted <2>_{n|n} distribution\r
4372  f2pDistribution = new TH1D("f2pDistribution","<2>_{n|n} distribution",100000,-0.02,0.1);\r
4373  f2pDistribution->SetXTitle("<2>_{n|n}");\r
4374  f2pDistribution->SetYTitle("Counts");\r
4375  fHistList->Add(f2pDistribution);\r
4376 \r
4377  //weighted <4>_{n,n|n,n} distribution\r
4378  f4pDistribution = new TH1D("f4pDistribution","<4>_{n,n|n,n} distribution",100000,-0.00025,0.002);\r
4379  f4pDistribution->SetXTitle("<4>_{n,n|n,n}");\r
4380  f4pDistribution->SetYTitle("Counts");\r
4381  fHistList->Add(f4pDistribution); \r
4382  \r
4383  //weighted <6>_{n,n,n|n,n,n} distribution\r
4384  f6pDistribution = new TH1D("f6pDistribution","<6>_{n,n,n|n,n,n} distribution",100000,-0.000005,0.000025);\r
4385  f6pDistribution->SetXTitle("<6>_{n,n,n|n,n,n}");\r
4386  f6pDistribution->SetYTitle("Counts");\r
4387  fHistList->Add(f6pDistribution);\r
4388  \r
4389  //weighted <8>_{n,n,n,n|n,n,n,n} distribution\r
4390  f8pDistribution = new TH1D("f8pDistribution","<8>_{n,n,n,n|n,n,n,n} distribution",100000,-0.000000001,0.00000001);\r
4391  f8pDistribution->SetXTitle("<8>_{n,n,n,n|n,n,n,n}");\r
4392  f8pDistribution->SetYTitle("Counts");\r
4393  fHistList->Add(f8pDistribution);\r
4394  */\r
4395  \r
4396 } // end of void AliFlowAnalysisWithQCumulants::BookEverythingForDistributions()\r
4397 \r
4398 \r
4399 //================================================================================================================================\r
4400 \r
4401 \r
4402 void AliFlowAnalysisWithQCumulants::BookAndNestAllLists()\r
4403 {\r
4404  // Book and nest all lists nested in the base list fHistList.\r
4405  //  a) Book and nest lists for integrated flow;\r
4406  //  b) Book and nest lists for differential flow;\r
4407  //  c) Book and nest list for particle weights;\r
4408  //  d) Book and nest list for distributions;\r
4409  //  e) Book and nest list for nested loops;\r
4410  \r
4411  // a) Book and nest all lists for integrated flow:\r
4412  // base list for integrated flow:\r
4413  fIntFlowList = new TList();\r
4414  fIntFlowList->SetName("Integrated Flow");\r
4415  fIntFlowList->SetOwner(kTRUE);\r
4416  fHistList->Add(fIntFlowList);\r
4417  // list holding profiles: \r
4418  fIntFlowProfiles = new TList();\r
4419  fIntFlowProfiles->SetName("Profiles");\r
4420  fIntFlowProfiles->SetOwner(kTRUE);\r
4421  fIntFlowList->Add(fIntFlowProfiles);\r
4422  // list holding histograms with results:\r
4423  fIntFlowResults = new TList();\r
4424  fIntFlowResults->SetName("Results");\r
4425  fIntFlowResults->SetOwner(kTRUE);\r
4426  fIntFlowList->Add(fIntFlowResults);\r
4427  \r
4428  // b) Book and nest lists for differential flow;\r
4429  fDiffFlowList = new TList();\r
4430  fDiffFlowList->SetName("Differential Flow");\r
4431  fDiffFlowList->SetOwner(kTRUE); \r
4432  fHistList->Add(fDiffFlowList);\r
4433  // list holding profiles: \r
4434  fDiffFlowProfiles = new TList(); \r
4435  fDiffFlowProfiles->SetName("Profiles");\r
4436  fDiffFlowProfiles->SetOwner(kTRUE);\r
4437  fDiffFlowList->Add(fDiffFlowProfiles);\r
4438  // list holding histograms with results: \r
4439  fDiffFlowResults = new TList();\r
4440  fDiffFlowResults->SetName("Results");\r
4441  fDiffFlowResults->SetOwner(kTRUE);\r
4442  fDiffFlowList->Add(fDiffFlowResults);\r
4443  // flags used for naming nested lists in list fDiffFlowProfiles and fDiffFlowResults:  \r
4444  TList list;\r
4445  list.SetOwner(kTRUE);\r
4446  TString typeFlag[2] = {"RP","POI"};  \r
4447  TString ptEtaFlag[2] = {"p_{T}","#eta"}; \r
4448  TString powerFlag[2] = {"linear","quadratic"};   \r
4449  // nested lists in fDiffFlowProfiles (~/Differential Flow/Profiles):\r
4450  for(Int_t t=0;t<2;t++) // type: RP or POI\r
4451  {\r
4452   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
4453   {\r
4454    // list holding profiles with correlations:\r
4455    fDiffFlowCorrelationsProList[t][pe] = (TList*)list.Clone();\r
4456    fDiffFlowCorrelationsProList[t][pe]->SetName(Form("Profiles with correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4457    fDiffFlowProfiles->Add(fDiffFlowCorrelationsProList[t][pe]);\r
4458    // list holding profiles with products of correlations:\r
4459    fDiffFlowProductOfCorrelationsProList[t][pe] = (TList*)list.Clone();\r
4460    fDiffFlowProductOfCorrelationsProList[t][pe]->SetName(Form("Profiles with products of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4461    fDiffFlowProfiles->Add(fDiffFlowProductOfCorrelationsProList[t][pe]);\r
4462    // list holding profiles with corrections:\r
4463    fDiffFlowCorrectionsProList[t][pe] = (TList*)list.Clone();\r
4464    fDiffFlowCorrectionsProList[t][pe]->SetName(Form("Profiles with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4465    fDiffFlowProfiles->Add(fDiffFlowCorrectionsProList[t][pe]);   \r
4466   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
4467  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI   \r
4468  // nested lists in fDiffFlowResults (~/Differential Flow/Results):\r
4469  for(Int_t t=0;t<2;t++) // type: RP or POI\r
4470  {\r
4471   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
4472   {\r
4473    // list holding histograms with correlations:\r
4474    fDiffFlowCorrelationsHistList[t][pe] = (TList*)list.Clone();\r
4475    fDiffFlowCorrelationsHistList[t][pe]->SetName(Form("Correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4476    fDiffFlowResults->Add(fDiffFlowCorrelationsHistList[t][pe]);\r
4477    // list holding histograms with corrections:\r
4478    fDiffFlowCorrectionsHistList[t][pe] = (TList*)list.Clone();\r
4479    fDiffFlowCorrectionsHistList[t][pe]->SetName(Form("Histograms with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4480    fDiffFlowResults->Add(fDiffFlowCorrectionsHistList[t][pe]);   \r
4481    for(Int_t power=0;power<2;power++)\r
4482    {\r
4483     // list holding histograms with sums of event weights:\r
4484     fDiffFlowSumOfEventWeightsHistList[t][pe][power] = (TList*)list.Clone();\r
4485     fDiffFlowSumOfEventWeightsHistList[t][pe][power]->SetName(Form("Sum of %s event weights (%s, %s)",powerFlag[power].Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4486     fDiffFlowResults->Add(fDiffFlowSumOfEventWeightsHistList[t][pe][power]);    \r
4487    } // end of for(Int_t power=0;power<2;power++)\r
4488    // list holding histograms with sums of products of event weights:\r
4489    fDiffFlowSumOfProductOfEventWeightsHistList[t][pe] = (TList*)list.Clone();\r
4490    fDiffFlowSumOfProductOfEventWeightsHistList[t][pe]->SetName(Form("Sum of products of event weights (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4491    fDiffFlowResults->Add(fDiffFlowSumOfProductOfEventWeightsHistList[t][pe]);\r
4492    // list holding histograms with covariances of correlations:\r
4493    fDiffFlowCovariancesHistList[t][pe] = (TList*)list.Clone();\r
4494    fDiffFlowCovariancesHistList[t][pe]->SetName(Form("Covariances of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4495    fDiffFlowResults->Add(fDiffFlowCovariancesHistList[t][pe]);\r
4496    // list holding histograms with differential Q-cumulants:\r
4497    fDiffFlowCumulantsHistList[t][pe] = (TList*)list.Clone();\r
4498    fDiffFlowCumulantsHistList[t][pe]->SetName(Form("Differential Q-cumulants (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4499    fDiffFlowResults->Add(fDiffFlowCumulantsHistList[t][pe]);   \r
4500    // list holding histograms with differential flow estimates from Q-cumulants:\r
4501    fDiffFlowHistList[t][pe] = (TList*)list.Clone();\r
4502    fDiffFlowHistList[t][pe]->SetName(Form("Differential flow (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));\r
4503    fDiffFlowResults->Add(fDiffFlowHistList[t][pe]);      \r
4504   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
4505  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
4506   \r
4507  // c) Book and nest list for particle weights:\r
4508  fWeightsList->SetName("Weights");\r
4509  fWeightsList->SetOwner(kTRUE);   \r
4510  fHistList->Add(fWeightsList); \r
4511 \r
4512  // d) Book and nest list for distributions:\r
4513  fDistributionsList = new TList();\r
4514  fDistributionsList->SetName("Distributions");\r
4515  fDistributionsList->SetOwner(kTRUE);\r
4516  fHistList->Add(fDistributionsList);\r
4517  \r
4518  // e) Book and nest list for nested loops:\r
4519  fNestedLoopsList = new TList();\r
4520  fNestedLoopsList->SetName("Nested Loops");\r
4521  fNestedLoopsList->SetOwner(kTRUE);\r
4522  fHistList->Add(fNestedLoopsList);\r
4523  \r
4524 } // end of void AliFlowAnalysisWithQCumulants::BookAndNestAllLists()\r
4525 \r
4526 \r
4527 //================================================================================================================================\r
4528 \r
4529 \r
4530 void AliFlowAnalysisWithQCumulants::FillCommonHistResultsDiffFlow(TString type)\r
4531 {\r
4532  // fill common result histograms for differential flow\r
4533  \r
4534  Int_t typeFlag = -1;\r
4535  //Int_t ptEtaFlag = -1;\r
4536 \r
4537  if(type == "RP")\r
4538  {\r
4539   typeFlag = 0;\r
4540  } else if(type == "POI")\r
4541    {\r
4542     typeFlag = 1;\r
4543    } \r
4544   \r
4545  // shortcuts:\r
4546  Int_t t = typeFlag;\r
4547  //Int_t pe = ptEtaFlag;\r
4548 \r
4549  // to be improved (implement protection here)\r
4550      \r
4551  if(!(fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th))\r
4552  {\r
4553   cout<<"WARNING: fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th"<<endl; \r
4554   cout<<"         is NULL in AFAWQC::FCHRIF() !!!!"<<endl;\r
4555   exit(0);\r
4556  }\r
4557  \r
4558  // pt:\r
4559  for(Int_t p=1;p<=fnBinsPt;p++)\r
4560  {\r
4561   Double_t v2 = fDiffFlow[t][0][0]->GetBinContent(p);\r
4562   Double_t v4 = fDiffFlow[t][0][1]->GetBinContent(p);\r
4563   Double_t v6 = fDiffFlow[t][0][2]->GetBinContent(p);\r
4564   Double_t v8 = fDiffFlow[t][0][3]->GetBinContent(p);\r
4565   \r
4566   Double_t v2Error = fDiffFlow[t][0][0]->GetBinError(p);\r
4567   Double_t v4Error = fDiffFlow[t][0][1]->GetBinError(p);\r
4568   //Double_t v6Error = fFinalFlow1D[t][pW][nua][0][2]->GetBinError(p);\r
4569   //Double_t v8Error = fFinalFlow1D[t][pW][nua][0][3]->GetBinError(p);\r
4570  \r
4571   if(type == "RP")\r
4572   {\r
4573    fCommonHistsResults2nd->FillDifferentialFlowPtRP(p,v2,v2Error);\r
4574    fCommonHistsResults4th->FillDifferentialFlowPtRP(p,v4,v4Error);\r
4575    fCommonHistsResults6th->FillDifferentialFlowPtRP(p,v6,0.);\r
4576    fCommonHistsResults8th->FillDifferentialFlowPtRP(p,v8,0.);\r
4577   } else if(type == "POI")\r
4578     {\r
4579      fCommonHistsResults2nd->FillDifferentialFlowPtPOI(p,v2,v2Error);\r
4580      fCommonHistsResults4th->FillDifferentialFlowPtPOI(p,v4,v4Error);\r
4581      fCommonHistsResults6th->FillDifferentialFlowPtPOI(p,v6,0.);\r
4582      fCommonHistsResults8th->FillDifferentialFlowPtPOI(p,v8,0.);\r
4583     }\r
4584  } // end of for(Int_t p=1;p<=fnBinsPt;p++)   \r
4585  \r
4586  // eta:\r
4587  for(Int_t e=1;e<=fnBinsEta;e++)\r
4588  {\r
4589   Double_t v2 = fDiffFlow[t][1][0]->GetBinContent(e);\r
4590   Double_t v4 = fDiffFlow[t][1][1]->GetBinContent(e);\r
4591   Double_t v6 = fDiffFlow[t][1][2]->GetBinContent(e);\r
4592   Double_t v8 = fDiffFlow[t][1][3]->GetBinContent(e);\r
4593   \r
4594   Double_t v2Error = fDiffFlow[t][1][0]->GetBinError(e);\r
4595   Double_t v4Error = fDiffFlow[t][1][1]->GetBinError(e);\r
4596   //Double_t v6Error = fDiffFlow[t][1][2]->GetBinError(e);\r
4597   //Double_t v8Error = fDiffFlow[t][1][3]->GetBinError(e);\r
4598  \r
4599   if(type == "RP")\r
4600   {\r
4601    fCommonHistsResults2nd->FillDifferentialFlowEtaRP(e,v2,v2Error);\r
4602    fCommonHistsResults4th->FillDifferentialFlowEtaRP(e,v4,v4Error);\r
4603    fCommonHistsResults6th->FillDifferentialFlowEtaRP(e,v6,0.);\r
4604    fCommonHistsResults8th->FillDifferentialFlowEtaRP(e,v8,0.);\r
4605   } else if(type == "POI")\r
4606     {\r
4607      fCommonHistsResults2nd->FillDifferentialFlowEtaPOI(e,v2,v2Error);\r
4608      fCommonHistsResults4th->FillDifferentialFlowEtaPOI(e,v4,v4Error);\r
4609      fCommonHistsResults6th->FillDifferentialFlowEtaPOI(e,v6,0.);\r
4610      fCommonHistsResults8th->FillDifferentialFlowEtaPOI(e,v8,0.);\r
4611     }\r
4612  } // end of for(Int_t e=1;e<=fnBinsEta;e++)    \r
4613  \r
4614 } // end of void AliFlowAnalysisWithQCumulants::FillCommonHistResultsDiffFlow(TString type, Bool_t useParticleWeights, TString eventWeights, Bool_t correctedForNUA)\r
4615 \r
4616 \r
4617 //================================================================================================================================\r
4618 \r
4619 \r
4620 void AliFlowAnalysisWithQCumulants::AccessConstants()\r
4621 {\r
4622  // access needed common constants from AliFlowCommonConstants\r
4623  \r
4624  fnBinsPhi = AliFlowCommonConstants::GetMaster()->GetNbinsPhi();\r
4625  fPhiMin = AliFlowCommonConstants::GetMaster()->GetPhiMin();         \r
4626  fPhiMax = AliFlowCommonConstants::GetMaster()->GetPhiMax();\r
4627  if(fnBinsPhi) fPhiBinWidth = (fPhiMax-fPhiMin)/fnBinsPhi;  \r
4628  fnBinsPt = AliFlowCommonConstants::GetMaster()->GetNbinsPt();\r
4629  fPtMin = AliFlowCommonConstants::GetMaster()->GetPtMin();           \r
4630  fPtMax = AliFlowCommonConstants::GetMaster()->GetPtMax();\r
4631  if(fnBinsPt) fPtBinWidth = (fPtMax-fPtMin)/fnBinsPt;  \r
4632  fnBinsEta = AliFlowCommonConstants::GetMaster()->GetNbinsEta();\r
4633  fEtaMin = AliFlowCommonConstants::GetMaster()->GetEtaMin();         \r
4634  fEtaMax = AliFlowCommonConstants::GetMaster()->GetEtaMax();\r
4635  if(fnBinsEta) fEtaBinWidth = (fEtaMax-fEtaMin)/fnBinsEta;  \r
4636  \r
4637 } // end of void AliFlowAnalysisWithQCumulants::AccessConstants()\r
4638 \r
4639 \r
4640 //================================================================================================================================\r
4641 \r
4642 \r
4643 void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfEventWeights()\r
4644 {\r
4645  // Calculate sum of linear and quadratic event weights for correlations\r
4646  \r
4647  \r
4648  /*\r
4649  Double_t dMult = (*fSMpk)(0,0); // multiplicity \r
4650 \r
4651  Double_t eventWeight[4] = {0}; \r
4652  \r
4653  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
4654  {\r
4655   eventWeight[0] = dMult*(dMult-1); // event weight for <2> \r
4656   eventWeight[1] = dMult*(dMult-1)*(dMult-2)*(dMult-3); // event weight for <4> \r
4657   eventWeight[2] = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5); // event weight for <6> \r
4658   eventWeight[3] = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5)*(dMult-6)*(dMult-7); // event weight for <8> \r
4659  } else\r
4660    {\r
4661     eventWeight[0] = (*fSMpk)(1,1)-(*fSMpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j;\r
4662     eventWeight[1] = (*fSMpk)(3,1)-6.*(*fSMpk)(0,2)*(*fSMpk)(1,1)  \r
4663                    + 8.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
4664                    + 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
4665     //eventWeight[2] = ... // to be improved (calculated)               \r
4666     //eventWeight[3] = ... // to be improved (calculated)              \r
4667    }\r
4668  */\r
4669         \r
4670                       \r
4671  for(Int_t p=0;p<2;p++) // power-1\r
4672  {\r
4673   for(Int_t ci=0;ci<4;ci++) // correlation index\r
4674   { \r
4675    fIntFlowSumOfEventWeights[p]->Fill(ci+0.5,pow(fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci+1),p+1)); \r
4676   }\r
4677  }\r
4678   \r
4679 } // end of void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfEventWeights()\r
4680 \r
4681 \r
4682 //================================================================================================================================\r
4683 \r
4684 \r
4685 void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfProductOfEventWeights()\r
4686 {\r
4687  // Calculate sum of product of event weights for correlations\r
4688  \r
4689  \r
4690  /*\r
4691  Double_t dMult = (*fSMpk)(0,0); // multiplicity \r
4692 \r
4693  Double_t eventWeight[4] = {0}; \r
4694  \r
4695  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
4696  {\r
4697   eventWeight[0] = dMult*(dMult-1); // event weight for <2> \r
4698   eventWeight[1] = dMult*(dMult-1)*(dMult-2)*(dMult-3); // event weight for <4> \r
4699   eventWeight[2] = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5); // event weight for <6> \r
4700   eventWeight[3] = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5)*(dMult-6)*(dMult-7); // event weight for <8> \r
4701  } else\r
4702    {\r
4703     eventWeight[0] = (*fSMpk)(1,1)-(*fSMpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j;\r
4704     eventWeight[1] = (*fSMpk)(3,1)-6.*(*fSMpk)(0,2)*(*fSMpk)(1,1)  \r
4705                    + 8.*(*fSMpk)(0,3)*(*fSMpk)(0,1)\r
4706                    + 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
4707     //eventWeight[2] = ... // to be improved (calculated)               \r
4708     //eventWeight[3] = ... // to be improved (calculated)              \r
4709    }\r
4710 \r
4711  fIntFlowSumOfProductOfEventWeights->Fill(0.5,eventWeight[0]*eventWeight[1]); \r
4712  fIntFlowSumOfProductOfEventWeights->Fill(1.5,eventWeight[0]*eventWeight[2]); \r
4713  fIntFlowSumOfProductOfEventWeights->Fill(2.5,eventWeight[0]*eventWeight[3]); \r
4714  fIntFlowSumOfProductOfEventWeights->Fill(3.5,eventWeight[1]*eventWeight[2]); \r
4715  fIntFlowSumOfProductOfEventWeights->Fill(4.5,eventWeight[1]*eventWeight[3]); \r
4716  fIntFlowSumOfProductOfEventWeights->Fill(5.5,eventWeight[2]*eventWeight[3]); \r
4717  */\r
4718   \r
4719  \r
4720  Int_t counter = 0;\r
4721  \r
4722  for(Int_t ci1=1;ci1<4;ci1++)\r
4723  {\r
4724   for(Int_t ci2=ci1+1;ci2<=4;ci2++)\r
4725   {\r
4726    fIntFlowSumOfProductOfEventWeights->Fill(0.5+counter++,\r
4727                                             fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci1)*fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci2));\r
4728   }\r
4729  }\r
4730 \r
4731  \r
4732 \r
4733 } // end of void AliFlowAnalysisWithQCumulants::CalculateIntFlowIntFlowSumOfProductOfEventWeights()\r
4734 \r
4735 \r
4736 //================================================================================================================================\r
4737 \r
4738 \r
4739 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelations(TString type, TString ptOrEta)\r
4740 {\r
4741  // calculate reduced correlations for RPs or POIs in pt or eta bins\r
4742 \r
4743  // multiplicity:\r
4744  Double_t dMult = (*fSMpk)(0,0);\r
4745  \r
4746  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
4747  Double_t dReQ1n = (*fReQ)(0,0);\r
4748  Double_t dReQ2n = (*fReQ)(1,0);\r
4749  //Double_t dReQ3n = (*fReQ)(2,0);\r
4750  //Double_t dReQ4n = (*fReQ)(3,0);\r
4751  Double_t dImQ1n = (*fImQ)(0,0);\r
4752  Double_t dImQ2n = (*fImQ)(1,0);\r
4753  //Double_t dImQ3n = (*fImQ)(2,0);\r
4754  //Double_t dImQ4n = (*fImQ)(3,0);\r
4755 \r
4756  // reduced correlations are stored in fDiffFlowCorrelationsPro[0=RP,1=POI][0=pt,1=eta][correlation index]. Correlation index runs as follows:\r
4757  // \r
4758  // 0: <<2'>>\r
4759  // 1: <<4'>>\r
4760  // 2: <<6'>>\r
4761  // 3: <<8'>>\r
4762  \r
4763  Int_t t = -1; // type flag \r
4764  Int_t pe = -1; // ptEta flag\r
4765  \r
4766  if(type == "RP")\r
4767  {\r
4768   t = 0;\r
4769  } else if(type == "POI")\r
4770    {\r
4771     t = 1;\r
4772    }\r
4773 \r
4774  if(ptOrEta == "Pt")\r
4775  {\r
4776   pe = 0;\r
4777  } else if(ptOrEta == "Eta")\r
4778    {\r
4779     pe = 1;\r
4780    }\r
4781     \r
4782  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
4783  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
4784  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
4785  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
4786 \r
4787  // looping over all bins and calculating reduced correlations: \r
4788  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
4789  {\r
4790   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): \r
4791   Double_t p1n0kRe = 0.;\r
4792   Double_t p1n0kIm = 0.;\r
4793 \r
4794   // number of POIs in particular pt or eta bin:\r
4795   Double_t mp = 0.;\r
4796 \r
4797   // 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
4798   Double_t q1n0kRe = 0.;\r
4799   Double_t q1n0kIm = 0.;\r
4800   Double_t q2n0kRe = 0.;\r
4801   Double_t q2n0kIm = 0.;\r
4802 \r
4803   // number of particles which are both RPs and POIs in particular pt or eta bin:\r
4804   Double_t mq = 0.;\r
4805    \r
4806   if(type == "POI")\r
4807   {\r
4808    // q_{m*n,0}:\r
4809    q1n0kRe = fReRPQ1dEBE[2][pe][0][0]->GetBinContent(fReRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
4810            * fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
4811    q1n0kIm = fImRPQ1dEBE[2][pe][0][0]->GetBinContent(fImRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
4812            * fImRPQ1dEBE[2][pe][0][0]->GetBinEntries(fImRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
4813    q2n0kRe = fReRPQ1dEBE[2][pe][1][0]->GetBinContent(fReRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
4814            * fReRPQ1dEBE[2][pe][1][0]->GetBinEntries(fReRPQ1dEBE[2][pe][1][0]->GetBin(b));\r
4815    q2n0kIm = fImRPQ1dEBE[2][pe][1][0]->GetBinContent(fImRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
4816            * fImRPQ1dEBE[2][pe][1][0]->GetBinEntries(fImRPQ1dEBE[2][pe][1][0]->GetBin(b));         \r
4817                  \r
4818    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
4819   } \r
4820   else if(type == "RP")\r
4821   {\r
4822    // q_{m*n,0}:\r
4823    q1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
4824            * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
4825    q1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
4826            * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
4827    q2n0kRe = fReRPQ1dEBE[0][pe][1][0]->GetBinContent(fReRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
4828            * fReRPQ1dEBE[0][pe][1][0]->GetBinEntries(fReRPQ1dEBE[0][pe][1][0]->GetBin(b));\r
4829    q2n0kIm = fImRPQ1dEBE[0][pe][1][0]->GetBinContent(fImRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
4830            * fImRPQ1dEBE[0][pe][1][0]->GetBinEntries(fImRPQ1dEBE[0][pe][1][0]->GetBin(b));         \r
4831                  \r
4832    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
4833   }\r
4834       \r
4835    if(type == "POI")\r
4836    {\r
4837     // p_{m*n,0}:\r
4838     p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))\r
4839             * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
4840     p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  \r
4841             * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
4842             \r
4843     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
4844     \r
4845     t = 1; // typeFlag = RP or POI\r
4846    }\r
4847    else if(type == "RP")\r
4848    {\r
4849     // p_{m*n,0} = q_{m*n,0}:\r
4850     p1n0kRe = q1n0kRe; \r
4851     p1n0kIm = q1n0kIm; \r
4852             \r
4853     mp = mq; \r
4854     \r
4855     t = 0; // typeFlag = RP or POI\r
4856    }\r
4857       \r
4858    // 2'-particle correlation for particular (pt,eta) bin:\r
4859    Double_t two1n1nPtEta = 0.;\r
4860    if(mp*dMult-mq)\r
4861    {\r
4862     two1n1nPtEta = (p1n0kRe*dReQ1n+p1n0kIm*dImQ1n-mq)\r
4863                  / (mp*dMult-mq);\r
4864    \r
4865     if(type == "POI") // to be improved (I do not this if)\r
4866     { \r
4867      // fill profile to get <<2'>> for POIs\r
4868      fDiffFlowCorrelationsPro[1][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nPtEta,mp*dMult-mq);\r
4869      // histogram to store <2'> for POIs e-b-e (needed in some other methods):\r
4870      fDiffFlowCorrelationsEBE[1][pe][0]->SetBinContent(b,two1n1nPtEta);      \r
4871      fDiffFlowEventWeightsForCorrelationsEBE[1][pe][0]->SetBinContent(b,mp*dMult-mq);      \r
4872     }\r
4873     else if(type == "RP") // to be improved (I do not this if)\r
4874     {\r
4875      // profile to get <<2'>> for RPs:\r
4876      fDiffFlowCorrelationsPro[0][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nPtEta,mp*dMult-mq);\r
4877      // histogram to store <2'> for RPs e-b-e (needed in some other methods):\r
4878      fDiffFlowCorrelationsEBE[0][pe][0]->SetBinContent(b,two1n1nPtEta); \r
4879      fDiffFlowEventWeightsForCorrelationsEBE[0][pe][0]->SetBinContent(b,mp*dMult-mq); \r
4880     }\r
4881    } // end of if(mp*dMult-mq)\r
4882   \r
4883    // 4'-particle correlation:\r
4884    Double_t four1n1n1n1nPtEta = 0.;\r
4885    if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4886        + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)) // to be improved (introduce a new variable for this expression)\r
4887    {\r
4888     four1n1n1n1nPtEta = ((pow(dReQ1n,2.)+pow(dImQ1n,2.))*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)\r
4889                       - q2n0kRe*(pow(dReQ1n,2.)-pow(dImQ1n,2.))\r
4890                       - 2.*q2n0kIm*dReQ1n*dImQ1n\r
4891                       - p1n0kRe*(dReQ1n*dReQ2n+dImQ1n*dImQ2n)\r
4892                       + p1n0kIm*(dImQ1n*dReQ2n-dReQ1n*dImQ2n)\r
4893                       - 2.*dMult*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)\r
4894                       - 2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*mq                      \r
4895                       + 6.*(q1n0kRe*dReQ1n+q1n0kIm*dImQ1n)                                            \r
4896                       + 1.*(q2n0kRe*dReQ2n+q2n0kIm*dImQ2n)                      \r
4897                       + 2.*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)                       \r
4898                       + 2.*mq*dMult                      \r
4899                       - 6.*mq)        \r
4900                       / ((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4901                           + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)); \r
4902     \r
4903     if(type == "POI")\r
4904     {\r
4905      // profile to get <<4'>> for POIs:\r
4906      fDiffFlowCorrelationsPro[1][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nPtEta,\r
4907                                      (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4908                                      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)); \r
4909      // histogram to store <4'> for POIs e-b-e (needed in some other methods):\r
4910      fDiffFlowCorrelationsEBE[1][pe][1]->SetBinContent(b,four1n1n1n1nPtEta);                               \r
4911      fDiffFlowEventWeightsForCorrelationsEBE[1][pe][1]->SetBinContent(b,(mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4912                                                                         + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));                               \r
4913     }\r
4914     else if(type == "RP")\r
4915     {\r
4916      // profile to get <<4'>> for RPs:\r
4917      fDiffFlowCorrelationsPro[0][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nPtEta,\r
4918                                        (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4919                                        + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));                   \r
4920      // histogram to store <4'> for RPs e-b-e (needed in some other methods):\r
4921      fDiffFlowCorrelationsEBE[0][pe][1]->SetBinContent(b,four1n1n1n1nPtEta);                   \r
4922      fDiffFlowEventWeightsForCorrelationsEBE[0][pe][1]->SetBinContent(b,(mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4923                                                                         + mq*(dMult-1.)*(dMult-2.)*(dMult-3.));                   \r
4924     }\r
4925    } // end of if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
4926      //            +mq*(dMult-1.)*(dMult-2.)*(dMult-3.))\r
4927    \r
4928  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
4929  \r
4930    \r
4931 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelations(TString type, TString ptOrEta);\r
4932 \r
4933 \r
4934 //================================================================================================================================\r
4935 \r
4936 \r
4937 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfEventWeights(TString type, TString ptOrEta)\r
4938 {\r
4939  // Calculate sums of various event weights for reduced correlations. \r
4940  // (These quantitites are needed in expressions for unbiased estimators relevant for the statistical errors.)\r
4941 \r
4942  Int_t typeFlag = -1;\r
4943  Int_t ptEtaFlag = -1;\r
4944 \r
4945  if(type == "RP")\r
4946  {\r
4947   typeFlag = 0;\r
4948  } else if(type == "POI")\r
4949    {\r
4950     typeFlag = 1;\r
4951    } \r
4952      \r
4953  if(ptOrEta == "Pt")\r
4954  {\r
4955   ptEtaFlag = 0;\r
4956  } else if(ptOrEta == "Eta")\r
4957    {\r
4958     ptEtaFlag = 1;\r
4959    } \r
4960    \r
4961  // shortcuts:\r
4962  Int_t t = typeFlag;\r
4963  Int_t pe = ptEtaFlag;\r
4964  \r
4965  // binning:\r
4966  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
4967  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
4968  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
4969  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
4970  \r
4971  for(Int_t rpq=0;rpq<3;rpq++)\r
4972  {\r
4973   for(Int_t m=0;m<4;m++)\r
4974   {\r
4975    for(Int_t k=0;k<9;k++)\r
4976    {\r
4977     if(!fReRPQ1dEBE[rpq][pe][m][k])\r
4978     {\r
4979      cout<<"WARNING: fReRPQ1dEBE[rpq][pe][m][k] is NULL in AFAWQC::CSAPOEWFDF() !!!!"<<endl;\r
4980      cout<<"pe  = "<<pe<<endl;\r
4981      cout<<"rpq = "<<rpq<<endl;\r
4982      cout<<"m   = "<<m<<endl;\r
4983      cout<<"k   = "<<k<<endl;\r
4984      exit(0); \r
4985     }\r
4986    }\r
4987   }\r
4988  }  \r
4989 \r
4990  // multiplicities:\r
4991  Double_t dMult = (*fSMpk)(0,0); // total event multiplicity\r
4992  //Double_t mr = 0.; // number of RPs in particular pt or eta bin\r
4993  Double_t mp = 0.; // number of POIs in particular pt or eta bin \r
4994  Double_t mq = 0.; // number of particles which are both RPs and POIs in particular pt or eta bin\r
4995  \r
4996  // event weights for reduced correlations:\r
4997  Double_t dw2 = 0.; // event weight for <2'>\r
4998  Double_t dw4 = 0.; // event weight for <4'>\r
4999  //Double_t dw6 = 0.; // event weight for <6'>\r
5000  //Double_t dw8 = 0.; // event weight for <8'>\r
5001 \r
5002  // looping over bins:\r
5003  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5004  {\r
5005   if(type == "RP")\r
5006   {\r
5007    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(b);\r
5008    mp = mq; // trick to use the very same Eqs. bellow both for RP's and POI's diff. flow\r
5009   } else if(type == "POI")\r
5010     {\r
5011      mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(b);\r
5012      mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(b);    \r
5013     }\r
5014   \r
5015   // event weight for <2'>:\r
5016   dw2 = mp*dMult-mq;  \r
5017   fDiffFlowSumOfEventWeights[t][pe][0][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2);\r
5018   fDiffFlowSumOfEventWeights[t][pe][1][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw2,2.));\r
5019   \r
5020   // event weight for <4'>:\r
5021   dw4 = (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
5022      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.);  \r
5023   fDiffFlowSumOfEventWeights[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4);\r
5024   fDiffFlowSumOfEventWeights[t][pe][1][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw4,2.));\r
5025   \r
5026   // event weight for <6'>:\r
5027   //dw6 = ...;  \r
5028   //fDiffFlowSumOfEventWeights[t][pe][0][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6);\r
5029   //fDiffFlowSumOfEventWeights[t][pe][t][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw6,2.));\r
5030   \r
5031   // event weight for <8'>:\r
5032   //dw8 = ...;  \r
5033   //fDiffFlowSumOfEventWeights[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw8);\r
5034   //fDiffFlowSumOfEventWeights[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw8,2.));   \r
5035  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++) \r
5036  \r
5037 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfEventWeights()\r
5038 \r
5039 \r
5040 //================================================================================================================================\r
5041 \r
5042 \r
5043 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfProductOfEventWeights(TString type, TString ptOrEta)\r
5044 {\r
5045  // Calculate sum of products of various event weights for both types of correlations (the ones for int. and diff. flow). \r
5046  // (These quantitites are needed in expressions for unbiased estimators relevant for the statistical errors.)\r
5047  //\r
5048  // Important: To fill fDiffFlowSumOfProductOfEventWeights[][][][] use bellow table (i,j) with following constraints: \r
5049  // 1.) i<j  \r
5050  // 2.) do not store terms which DO NOT include reduced correlations;\r
5051  // Table:\r
5052  // [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
5053   \r
5054  Int_t typeFlag = -1;\r
5055  Int_t ptEtaFlag = -1;\r
5056 \r
5057  if(type == "RP")\r
5058  {\r
5059   typeFlag = 0;\r
5060  } else if(type == "POI")\r
5061    {\r
5062     typeFlag = 1;\r
5063    } \r
5064      \r
5065  if(ptOrEta == "Pt")\r
5066  {\r
5067   ptEtaFlag = 0;\r
5068  } else if(ptOrEta == "Eta")\r
5069    {\r
5070     ptEtaFlag = 1;\r
5071    } \r
5072      \r
5073  // shortcuts:\r
5074  Int_t t = typeFlag;\r
5075  Int_t pe = ptEtaFlag;\r
5076   \r
5077  // binning:\r
5078  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
5079  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
5080  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
5081  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
5082  \r
5083  // protection:\r
5084  for(Int_t rpq=0;rpq<3;rpq++)\r
5085  {\r
5086   for(Int_t m=0;m<4;m++)\r
5087   {\r
5088    for(Int_t k=0;k<9;k++)\r
5089    {\r
5090     if(!fReRPQ1dEBE[rpq][pe][m][k])\r
5091     {\r
5092      cout<<"WARNING: fReRPQ1dEBE[rpq][pe][m][k] is NULL in AFAWQC::CSAPOEWFDF() !!!!"<<endl;\r
5093      cout<<"pe  = "<<pe<<endl;\r
5094      cout<<"rpq = "<<rpq<<endl;\r
5095      cout<<"m   = "<<m<<endl;\r
5096      cout<<"k   = "<<k<<endl;\r
5097      exit(0); \r
5098     }\r
5099    }\r
5100   }\r
5101  }  \r
5102  \r
5103  // multiplicities:\r
5104  Double_t dMult = (*fSMpk)(0,0); // total event multiplicity\r
5105  //Double_t mr = 0.; // number of RPs in particular pt or eta bin\r
5106  Double_t mp = 0.; // number of POIs in particular pt or eta bin \r
5107  Double_t mq = 0.; // number of particles which are both RPs and POIs in particular pt or eta bin\r
5108  \r
5109  // event weights for correlations:\r
5110  Double_t dW2 = dMult*(dMult-1); // event weight for <2> \r
5111  Double_t dW4 = dMult*(dMult-1)*(dMult-2)*(dMult-3); // event weight for <4> \r
5112  Double_t dW6 = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5); // event weight for <6> \r
5113  Double_t dW8 = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5)*(dMult-6)*(dMult-7); // event weight for <8> \r
5114 \r
5115  // event weights for reduced correlations:\r
5116  Double_t dw2 = 0.; // event weight for <2'>\r
5117  Double_t dw4 = 0.; // event weight for <4'>\r
5118  //Double_t dw6 = 0.; // event weight for <6'>\r
5119  //Double_t dw8 = 0.; // event weight for <8'>\r
5120  \r
5121  // looping over bins:\r
5122  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5123  {\r
5124   if(type == "RP")\r
5125   {\r
5126    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(b);\r
5127    mp = mq; // trick to use the very same Eqs. bellow both for RP's and POI's diff. flow\r
5128   } else if(type == "POI")\r
5129     {\r
5130      mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(b);\r
5131      mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(b);    \r
5132     }\r
5133   \r
5134   // event weight for <2'>:\r
5135   dw2 = mp*dMult-mq;  \r
5136   fDiffFlowSumOfProductOfEventWeights[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw2); // storing product of even weights for <2> and <2'>\r
5137   fDiffFlowSumOfProductOfEventWeights[t][pe][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dW4); // storing product of even weights for <4> and <2'>\r
5138   fDiffFlowSumOfProductOfEventWeights[t][pe][1][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dW6); // storing product of even weights for <6> and <2'>\r
5139   fDiffFlowSumOfProductOfEventWeights[t][pe][1][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dW8); // storing product of even weights for <8> and <2'>\r
5140   \r
5141   // event weight for <4'>:\r
5142   dw4 = (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
5143      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.);  \r
5144   fDiffFlowSumOfProductOfEventWeights[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw4); // storing product of even weights for <2> and <4'>\r
5145   fDiffFlowSumOfProductOfEventWeights[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dw4); // storing product of even weights for <2'> and <4'>\r
5146   fDiffFlowSumOfProductOfEventWeights[t][pe][2][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW4*dw4); // storing product of even weights for <4> and <4'>\r
5147   fDiffFlowSumOfProductOfEventWeights[t][pe][3][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dW6); // storing product of even weights for <6> and <4'> \r
5148   fDiffFlowSumOfProductOfEventWeights[t][pe][3][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dW8); // storing product of even weights for <8> and <4'>\r
5149 \r
5150   // event weight for <6'>:\r
5151   //dw6 = ...;  \r
5152   //fDiffFlowSumOfProductOfEventWeights[t][pe][0][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw6); // storing product of even weights for <2> and <6'>\r
5153   //fDiffFlowSumOfProductOfEventWeights[t][pe][1][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dw6); // storing product of even weights for <2'> and <6'>\r
5154   //fDiffFlowSumOfProductOfEventWeights[t][pe][2][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW4*dw6); // storing product of even weights for <4> and <6'>\r
5155   //fDiffFlowSumOfProductOfEventWeights[t][pe][3][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dw6); // storing product of even weights for <4'> and <6'> \r
5156   //fDiffFlowSumOfProductOfEventWeights[t][pe][4][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW6*dw6); // storing product of even weights for <6> and <6'>\r
5157   //fDiffFlowSumOfProductOfEventWeights[t][pe][5][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6*dW8); // storing product of even weights for <6'> and <8>\r
5158   //fDiffFlowSumOfProductOfEventWeights[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6*dw8); // storing product of even weights for <6'> and <8'>\r
5159 \r
5160   // event weight for <8'>:\r
5161   //dw8 = ...;  \r
5162   //fDiffFlowSumOfProductOfEventWeights[t][pe][0][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw8); // storing product of even weights for <2> and <8'>\r
5163   //fDiffFlowSumOfProductOfEventWeights[t][pe][1][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dw8); // storing product of even weights for <2'> and <8'>\r
5164   //fDiffFlowSumOfProductOfEventWeights[t][pe][2][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW4*dw8); // storing product of even weights for <4> and <8'>\r
5165   //fDiffFlowSumOfProductOfEventWeights[t][pe][3][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dw8); // storing product of even weights for <4'> and <8'> \r
5166   //fDiffFlowSumOfProductOfEventWeights[t][pe][4][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW6*dw8); // storing product of even weights for <6> and <8'>\r
5167   //fDiffFlowSumOfProductOfEventWeights[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6*dw8); // storing product of even weights for <6'> and <8'>\r
5168   //fDiffFlowSumOfProductOfEventWeights[t][pe][6][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW8*dw8); // storing product of even weights for <8> and <8'>\r
5169   \r
5170   // Table:\r
5171   // [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
5172    \r
5173  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5174  \r
5175 \r
5176 \r
5177 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfProductOfEventWeights(TString type, TString ptOrEta)\r
5178 \r
5179 \r
5180 //================================================================================================================================\r
5181 \r
5182 \r
5183 void AliFlowAnalysisWithQCumulants::FinalizeReducedCorrelations(TString type, TString ptOrEta)\r
5184 {\r
5185  // Transfer profiles into histograms and calculate statistical errors correctly.\r
5186 \r
5187  Int_t typeFlag = -1;\r
5188  Int_t ptEtaFlag = -1;\r
5189 \r
5190  if(type == "RP")\r
5191  {\r
5192   typeFlag = 0;\r
5193  } else if(type == "POI")\r
5194    {\r
5195     typeFlag = 1;\r
5196    } \r
5197      \r
5198  if(ptOrEta == "Pt")\r
5199  {\r
5200   ptEtaFlag = 0;\r
5201  } else if(ptOrEta == "Eta")\r
5202    {\r
5203     ptEtaFlag = 1;\r
5204    } \r
5205   \r
5206  // shortcuts:\r
5207  Int_t t = typeFlag;\r
5208  Int_t pe = ptEtaFlag;\r
5209              \r
5210  for(Int_t rci=0;rci<4;rci++)\r
5211  {\r
5212   if(!fDiffFlowCorrelationsPro[t][pe][rci])\r
5213   {\r
5214    cout<<"WARNING: fDiffFlowCorrelationsPro[t][pe][rci] is NULL in AFAWQC::FRC() !!!!"<<endl;\r
5215    cout<<"t   = "<<t<<endl; \r
5216    cout<<"pe  = "<<pe<<endl; \r
5217    cout<<"rci = "<<rci<<endl;\r
5218    exit(0); \r
5219   }\r
5220   for(Int_t power=0;power<2;power++)\r
5221   {\r
5222    if(!fDiffFlowSumOfEventWeights[t][pe][power][rci])\r
5223    {\r
5224     cout<<"WARNING: fDiffFlowSumOfEventWeights[t][pe][power][rci] is NULL in AFAWQC::FRC() !!!!"<<endl;\r
5225     cout<<"t     = "<<t<<endl; \r
5226     cout<<"pe    = "<<pe<<endl;\r
5227     cout<<"power = "<<power<<endl; \r
5228     cout<<"rci   = "<<rci<<endl;\r
5229     exit(0); \r
5230    }   \r
5231   } // end of for(Int_t power=0;power<2;power++)\r
5232  } // end of for(Int_t rci=0;rci<4;rci++)\r
5233     \r
5234  // common:\r
5235  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
5236  \r
5237  // transfer 1D profile into 1D histogram:\r
5238  Double_t correlation = 0.;\r
5239  Double_t spread = 0.;\r
5240  Double_t sumOfWeights = 0.; // sum of weights for particular reduced correlations for particular pt or eta bin\r
5241  Double_t sumOfSquaredWeights = 0.; // sum of squared weights for particular reduced correlations for particular pt or eta bin\r
5242  Double_t error = 0.; // error = termA * spread * termB\r
5243                       // termA = (sqrt(sumOfSquaredWeights)/sumOfWeights) \r
5244                       // termB = 1/pow(1-termA^2,0.5)\r
5245  Double_t termA = 0.;                      \r
5246  Double_t termB = 0.;                      \r
5247  for(Int_t rci=0;rci<4;rci++) // index of reduced correlation\r
5248  {\r
5249   for(Int_t b=1;b<=nBinsPtEta[pe];b++) // number of pt or eta bins\r
5250   {\r
5251    correlation = fDiffFlowCorrelationsPro[t][pe][rci]->GetBinContent(b); \r
5252    spread = fDiffFlowCorrelationsPro[t][pe][rci]->GetBinError(b);\r
5253    sumOfWeights = fDiffFlowSumOfEventWeights[t][pe][0][rci]->GetBinContent(b);\r
5254    sumOfSquaredWeights = fDiffFlowSumOfEventWeights[t][pe][1][rci]->GetBinContent(b);\r
5255    if(sumOfWeights) termA = (pow(sumOfSquaredWeights,0.5)/sumOfWeights);\r
5256    if(1.-pow(termA,2.)>0.) termB = 1./pow(1.-pow(termA,2.),0.5); \r
5257    error = termA*spread*termB; // final error (unbiased estimator for standard deviation)\r
5258    fDiffFlowCorrelationsHist[t][pe][rci]->SetBinContent(b,correlation); \r
5259    fDiffFlowCorrelationsHist[t][pe][rci]->SetBinError(b,error); \r
5260   } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5261  } // end of for(Int_t rci=0;rci<4;rci++)\r
5262  \r
5263 } // end of void AliFlowAnalysisWithQCumulants::FinalizeReducedCorrelations(TString type, TString ptOrEta)\r
5264 \r
5265 \r
5266 //================================================================================================================================\r
5267 \r
5268 \r
5269 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowProductOfCorrelations(TString type, TString ptOrEta)\r
5270 {\r
5271  // store products: <2><2'>, <2><4'>, <2><6'>, <2><8'>, <2'><4>, \r
5272  //                 <2'><4'>, <2'><6>, <2'><6'>, <2'><8>, <2'><8'>,\r
5273  //                 <4><4'>, <4><6'>, <4><8'>, <4'><6>, <4'><6'>, \r
5274  //                 <4'><8>, <4'><8'>, <6><6'>, <6><8'>, <6'><8>, \r
5275  //                 <6'><8'>, <8><8'>.\r
5276   \r
5277  Int_t typeFlag = -1;\r
5278  Int_t ptEtaFlag = -1;\r
5279 \r
5280  if(type == "RP")\r
5281  {\r
5282   typeFlag = 0;\r
5283  } else if(type == "POI")\r
5284    {\r
5285     typeFlag = 1;\r
5286    } \r
5287      \r
5288  if(ptOrEta == "Pt")\r
5289  {\r
5290   ptEtaFlag = 0;\r
5291  } else if(ptOrEta == "Eta")\r
5292    {\r
5293     ptEtaFlag = 1;\r
5294    } \r
5295   \r
5296  // shortcuts:\r
5297  Int_t t = typeFlag;\r
5298  Int_t pe = ptEtaFlag;\r
5299      \r
5300  // common:\r
5301  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
5302  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
5303  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
5304    \r
5305  // protections // to be improved (add protection for all pointers in this method)\r
5306  if(!fIntFlowCorrelationsEBE)\r
5307  {\r
5308   cout<<"WARNING: fIntFlowCorrelationsEBE is NULL in AFAWQC::CDFPOC() !!!!"<<endl;\r
5309   exit(0);\r
5310  } \r
5311  \r
5312  /*    \r
5313  Double_t dMult = (*fSMpk)(0,0); // multiplicity (number of particles used to determine the reaction plane)\r
5314  //Double_t mr = 0.; // number of RPs in particular pt or eta bin\r
5315  Double_t mp = 0.; // number of POIs in particular pt or eta bin \r
5316  Double_t mq = 0.; // number of particles which are both RPs and POIs in particular pt or eta bin\r
5317  */\r
5318 \r
5319  // e-b-e correlations:\r
5320  Double_t twoEBE = fIntFlowCorrelationsEBE->GetBinContent(1); // <2>\r
5321  Double_t fourEBE = fIntFlowCorrelationsEBE->GetBinContent(2); // <4>\r
5322  Double_t sixEBE = fIntFlowCorrelationsEBE->GetBinContent(3); // <6>\r
5323  Double_t eightEBE = fIntFlowCorrelationsEBE->GetBinContent(4); // <8>\r
5324  \r
5325  // event weights for correlations:\r
5326  Double_t dW2 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1); // event weight for <2> \r
5327  Double_t dW4 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2); // event weight for <4> \r
5328  Double_t dW6 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(3); // event weight for <6> \r
5329  Double_t dW8 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(4); // event weight for <8> \r
5330   \r
5331  // e-b-e reduced correlations:\r
5332  Double_t twoReducedEBE = 0.; // <2'>\r
5333  Double_t fourReducedEBE = 0.; // <4'>\r
5334  Double_t sixReducedEBE = 0.; // <6'>\r
5335  Double_t eightReducedEBE = 0.; // <8'> \r
5336  \r
5337  // event weights for reduced correlations:\r
5338  Double_t dw2 = 0.; // event weight for <2'>\r
5339  Double_t dw4 = 0.; // event weight for <4'>\r
5340  //Double_t dw6 = 0.; // event weight for <6'>\r
5341  //Double_t dw8 = 0.; // event weight for <8'>\r
5342 \r
5343  // looping over bins:\r
5344  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5345  {\r
5346   // e-b-e reduced correlations:\r
5347   twoReducedEBE = fDiffFlowCorrelationsEBE[t][pe][0]->GetBinContent(b);\r
5348   fourReducedEBE = fDiffFlowCorrelationsEBE[t][pe][1]->GetBinContent(b);\r
5349   sixReducedEBE = fDiffFlowCorrelationsEBE[t][pe][2]->GetBinContent(b);\r
5350   eightReducedEBE = fDiffFlowCorrelationsEBE[t][pe][3]->GetBinContent(b);\r
5351   \r
5352   /*\r
5353   // to be improved (I should not do this here again)\r
5354   if(type == "RP")\r
5355   {\r
5356    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(b);\r
5357    mp = mq; // trick to use the very same Eqs. bellow both for RP's and POI's diff. flow\r
5358   } else if(type == "POI")\r
5359     {\r
5360      mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(b);\r
5361      mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(b);    \r
5362     }\r
5363   \r
5364   // event weights for reduced correlations:\r
5365   dw2 = mp*dMult-mq; // weight for <2'> \r
5366   dw4 = (mp-mq)*dMult*(dMult-1.)*(dMult-2.)\r
5367      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.); // weight for <4'>\r
5368   //dw6 = ...     \r
5369   //dw8 = ...     \r
5370   \r
5371   */\r
5372   \r
5373   dw2 = fDiffFlowEventWeightsForCorrelationsEBE[t][pe][0]->GetBinContent(b);\r
5374   dw4 = fDiffFlowEventWeightsForCorrelationsEBE[t][pe][1]->GetBinContent(b);\r
5375  \r
5376   // storing all products:\r
5377   fDiffFlowProductOfCorrelationsPro[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*twoReducedEBE,dW2*dw2); // storing <2><2'>\r
5378   fDiffFlowProductOfCorrelationsPro[t][pe][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*twoReducedEBE,dW4*dw2); // storing <4><2'>\r
5379   fDiffFlowProductOfCorrelationsPro[t][pe][1][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*twoReducedEBE,dW6*dw2); // storing <6><2'>\r
5380   fDiffFlowProductOfCorrelationsPro[t][pe][1][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],eightEBE*twoReducedEBE,dW8*dw2); // storing <8><2'>\r
5381   \r
5382   // event weight for <4'>:\r
5383   fDiffFlowProductOfCorrelationsPro[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*fourReducedEBE,dW2*dw4); // storing <2><4'>\r
5384   fDiffFlowProductOfCorrelationsPro[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoReducedEBE*fourReducedEBE,dw2*dw4); // storing <2'><4'>\r
5385   fDiffFlowProductOfCorrelationsPro[t][pe][2][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*fourReducedEBE,dW4*dw4); // storing <4><4'>\r
5386   fDiffFlowProductOfCorrelationsPro[t][pe][3][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*fourReducedEBE,dW6*dw4); // storing <6><4'> \r
5387   fDiffFlowProductOfCorrelationsPro[t][pe][3][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],eightEBE*fourReducedEBE,dW8*dw4); // storing <8><4'>\r
5388 \r
5389   // event weight for <6'>:\r
5390   //dw6 = ...;  \r
5391   //fDiffFlowProductOfCorrelationsPro[t][pe][0][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*sixReducedEBE,dW2*dw6); // storing <2><6'>\r
5392   //fDiffFlowProductOfCorrelationsPro[t][pe][1][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoReducedEBE*sixReducedEBE,dw2*dw6); // storing <2'><6'>\r
5393   //fDiffFlowProductOfCorrelationsPro[t][pe][2][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*sixReducedEBE,dW4*dw6); // storing <4><6'>\r
5394   //fDiffFlowProductOfCorrelationsPro[t][pe][3][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourReducedEBE*sixReducedEBE,dw4*dw6); // storing <4'><6'> \r
5395   //fDiffFlowProductOfCorrelationsPro[t][pe][4][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*sixReducedEBE,dW6*dw6); // storing <6><6'>\r
5396   //fDiffFlowProductOfCorrelationsPro[t][pe][5][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixReducedEBE*eightEBE,dw6*dW8); // storing <6'><8>\r
5397   //fDiffFlowProductOfCorrelationsPro[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixReducedEBE*eightReducedEBE,dw6*dw8); // storing <6'><8'>\r
5398 \r
5399   // event weight for <8'>:\r
5400   //dw8 = ...;  \r
5401   //fDiffFlowProductOfCorrelationsPro[t][pe][0][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*eightReducedEBE,dW2*dw8); // storing <2><8'>\r
5402   //fDiffFlowProductOfCorrelationsPro[t][pe][1][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoReducedEBE*eightReducedEBE,dw2*dw8); // storing <2'><8'>\r
5403   //fDiffFlowProductOfCorrelationsPro[t][pe][2][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*eightReducedEBE,dW4*dw8); // storing <4><8'>\r
5404   //fDiffFlowProductOfCorrelationsPro[t][pe][3][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourReducedEBE*eightReducedEBE,dw4*dw8); // storing <4'><8'> \r
5405   //fDiffFlowProductOfCorrelationsPro[t][pe][4][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*eightReducedEBE,dW6*dw8); // storing <6><8'>\r
5406   //fDiffFlowProductOfCorrelationsPro[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixReducedEBE*eightReducedEBE,dw6*dw8); // storing <6'><8'>\r
5407   //fDiffFlowProductOfCorrelationsPro[t][pe][6][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],eightEBE*eightReducedEBE,dW8*dw8); // storing <8><8'> \r
5408  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++       \r
5409      \r
5410 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowProductOfCorrelations(TString type, TString ptOrEta)\r
5411 \r
5412 \r
5413 //================================================================================================================================\r
5414     \r
5415     \r
5416 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCovariances(TString type, TString ptOrEta) // to be improved (reimplemented)\r
5417 {\r
5418  // a) Calculate unbiased estimators Cov(<2>,<2'>), Cov(<2>,<4'>), Cov(<4>,<2'>), Cov(<4>,<4'>) and Cov(<2'>,<4'>)\r
5419  //    for covariances V(<2>,<2'>), V(<2>,<4'>), V(<4>,<2'>), V(<4>,<4'>) and V(<2'>,<4'>).  \r
5420  // b) Store in histogram fDiffFlowCovariances[t][pe][index] for instance the following: \r
5421  //\r
5422  //             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
5423  // \r
5424  //     where N is the number of events, w_{<2>} is event weight for <2> and w_{<2'>} is event weight for <2'>.\r
5425  // c) Binning of fDiffFlowCovariances[t][pe][index] is organized as follows:\r
5426  // \r
5427  //     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
5428  //     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
5429  //     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
5430  //     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
5431  //     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
5432  //     ...\r
5433   \r
5434  Int_t typeFlag = -1;\r
5435  Int_t ptEtaFlag = -1;\r
5436 \r
5437  if(type == "RP")\r
5438  {\r
5439   typeFlag = 0;\r
5440  } else if(type == "POI")\r
5441    {\r
5442     typeFlag = 1;\r
5443    } \r
5444      \r
5445  if(ptOrEta == "Pt")\r
5446  {\r
5447   ptEtaFlag = 0;\r
5448  } else if(ptOrEta == "Eta")\r
5449    {\r
5450     ptEtaFlag = 1;\r
5451    } \r
5452   \r
5453  // shortcuts:\r
5454  Int_t t = typeFlag;\r
5455  Int_t pe = ptEtaFlag;\r
5456      \r
5457  // common:\r
5458  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
5459  //Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
5460  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
5461  //Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
5462  \r
5463  // average correlations:\r
5464  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>\r
5465  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>\r
5466  //Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>>\r
5467  //Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>\r
5468  \r
5469  // sum of weights for correlation:\r
5470  Double_t sumOfWeightsForTwo = fIntFlowSumOfEventWeights[0]->GetBinContent(1); // sum_{i=1}^{N} w_{<2>}\r
5471  Double_t sumOfWeightsForFour = fIntFlowSumOfEventWeights[0]->GetBinContent(2); // sum_{i=1}^{N} w_{<4>}\r
5472  //Double_t sumOfWeightsForSix = fIntFlowSumOfEventWeights[0]->GetBinContent(3); // sum_{i=1}^{N} w_{<6>}\r
5473  //Double_t sumOfWeightsForEight = fIntFlowSumOfEventWeights[0]->GetBinContent(4); // sum_{i=1}^{N} w_{<8>}\r
5474  \r
5475  // average reduced correlations:\r
5476  Double_t twoReduced = 0.; // <<2'>> \r
5477  Double_t fourReduced = 0.; // <<4'>>\r
5478  //Double_t sixReduced = 0.; // <<6'>>\r
5479  //Double_t eightReduced = 0.; // <<8'>>\r
5480 \r
5481  // sum of weights for reduced correlation:\r
5482  Double_t sumOfWeightsForTwoReduced = 0.; // sum_{i=1}^{N} w_{<2'>}\r
5483  Double_t sumOfWeightsForFourReduced = 0.; // sum_{i=1}^{N} w_{<4'>}\r
5484  //Double_t sumOfWeightsForSixReduced = 0.; // sum_{i=1}^{N} w_{<6'>}\r
5485  //Double_t sumOfWeightsForEightReduced = 0.; // sum_{i=1}^{N} w_{<8'>}\r
5486   \r
5487  // product of weights for reduced correlation:\r
5488  Double_t productOfWeightsForTwoTwoReduced = 0.; // sum_{i=1}^{N} w_{<2>}w_{<2'>}\r
5489  Double_t productOfWeightsForTwoFourReduced = 0.; // sum_{i=1}^{N} w_{<2>}w_{<4'>}\r
5490  Double_t productOfWeightsForFourTwoReduced = 0.; // sum_{i=1}^{N} w_{<4>}w_{<2'>}\r
5491  Double_t productOfWeightsForFourFourReduced = 0.; // sum_{i=1}^{N} w_{<4>}w_{<4'>}\r
5492  Double_t productOfWeightsForTwoReducedFourReduced = 0.; // sum_{i=1}^{N} w_{<2'>}w_{<4'>}\r
5493  // ...\r
5494  \r
5495  // products for differential flow:\r
5496  Double_t twoTwoReduced = 0; // <<2><2'>> \r
5497  Double_t twoFourReduced = 0; // <<2><4'>> \r
5498  Double_t fourTwoReduced = 0; // <<4><2'>> \r
5499  Double_t fourFourReduced = 0; // <<4><4'>> \r
5500  Double_t twoReducedFourReduced = 0; // <<2'><4'>> \r
5501 \r
5502  // denominators in the expressions for the unbiased estimators for covariances:\r
5503  // denominator = 1 - term1/(term2*term3)\r
5504  // prefactor = term1/(term2*term3)\r
5505  Double_t denominator = 0.; \r
5506  Double_t prefactor = 0.;\r
5507  Double_t term1 = 0.; \r
5508  Double_t term2 = 0.; \r
5509  Double_t term3 = 0.; \r
5510  \r
5511  // unbiased estimators for covariances for differential flow:\r
5512  Double_t covTwoTwoReduced = 0.; // Cov(<2>,<2'>)\r
5513  Double_t wCovTwoTwoReduced = 0.; // Cov(<2>,<2'>) * prefactor(w_{<2>},w_{<2'>})\r
5514  Double_t covTwoFourReduced = 0.; // Cov(<2>,<4'>)\r
5515  Double_t wCovTwoFourReduced = 0.; // Cov(<2>,<4'>) * prefactor(w_{<2>},w_{<4'>})\r
5516  Double_t covFourTwoReduced = 0.; // Cov(<4>,<2'>)\r
5517  Double_t wCovFourTwoReduced = 0.; // Cov(<4>,<2'>) * prefactor(w_{<4>},w_{<2'>})\r
5518  Double_t covFourFourReduced = 0.; // Cov(<4>,<4'>)\r
5519  Double_t wCovFourFourReduced = 0.; // Cov(<4>,<4'>) * prefactor(w_{<4>},w_{<4'>})\r
5520  Double_t covTwoReducedFourReduced = 0.; // Cov(<2'>,<4'>)\r
5521  Double_t wCovTwoReducedFourReduced = 0.; // Cov(<2'>,<4'>) * prefactor(w_{<2'>},w_{<4'>})\r
5522  \r
5523  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5524  {\r
5525   // average reduced corelations:\r
5526   twoReduced = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b);\r
5527   fourReduced = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b);\r
5528   // average products:\r
5529   twoTwoReduced = fDiffFlowProductOfCorrelationsPro[t][pe][0][1]->GetBinContent(b);\r
5530   twoFourReduced = fDiffFlowProductOfCorrelationsPro[t][pe][0][3]->GetBinContent(b);\r
5531   fourTwoReduced = fDiffFlowProductOfCorrelationsPro[t][pe][1][2]->GetBinContent(b);\r
5532   fourFourReduced = fDiffFlowProductOfCorrelationsPro[t][pe][2][3]->GetBinContent(b);\r
5533   twoReducedFourReduced = fDiffFlowProductOfCorrelationsPro[t][pe][1][3]->GetBinContent(b);  \r
5534   // sum of weights for reduced correlations:\r
5535   sumOfWeightsForTwoReduced = fDiffFlowSumOfEventWeights[t][pe][0][0]->GetBinContent(b);\r
5536   sumOfWeightsForFourReduced = fDiffFlowSumOfEventWeights[t][pe][0][1]->GetBinContent(b);\r
5537   // products of weights for correlations:\r
5538   productOfWeightsForTwoTwoReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][0][1]->GetBinContent(b); \r
5539   productOfWeightsForTwoFourReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][0][3]->GetBinContent(b);\r
5540   productOfWeightsForFourTwoReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][1][2]->GetBinContent(b);\r
5541   productOfWeightsForFourFourReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][2][3]->GetBinContent(b);\r
5542   productOfWeightsForTwoReducedFourReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][1][3]->GetBinContent(b);\r
5543   // denominator for the unbiased estimator for covariances: 1 - term1/(term2*term3) \r
5544   // prefactor (multiplies Cov's) = term1/(term2*term3)       \r
5545   // <2>,<2'>:\r
5546   term1 = productOfWeightsForTwoTwoReduced;      \r
5547   term2 = sumOfWeightsForTwo;\r
5548   term3 = sumOfWeightsForTwoReduced;        \r
5549   if(term2*term3>0.)\r
5550   {\r
5551    denominator = 1.-term1/(term2*term3);\r
5552    prefactor = term1/(term2*term3);\r
5553    if(denominator!=0)\r
5554    {\r
5555     covTwoTwoReduced = (twoTwoReduced-two*twoReduced)/denominator;            \r
5556     wCovTwoTwoReduced = covTwoTwoReduced*prefactor; \r
5557     fDiffFlowCovariances[t][pe][0]->SetBinContent(b,wCovTwoTwoReduced);\r
5558    }\r
5559   }\r
5560   // <2>,<4'>:\r
5561   term1 = productOfWeightsForTwoFourReduced;      \r
5562   term2 = sumOfWeightsForTwo;\r
5563   term3 = sumOfWeightsForFourReduced;        \r
5564   if(term2*term3>0.)\r
5565   {\r
5566    denominator = 1.-term1/(term2*term3);\r
5567    prefactor = term1/(term2*term3);\r
5568    if(denominator!=0)\r
5569    {\r
5570     covTwoFourReduced = (twoFourReduced-two*fourReduced)/denominator;            \r
5571     wCovTwoFourReduced = covTwoFourReduced*prefactor; \r
5572     fDiffFlowCovariances[t][pe][1]->SetBinContent(b,wCovTwoFourReduced);\r
5573    }\r
5574   }\r
5575   // <4>,<2'>:\r
5576   term1 = productOfWeightsForFourTwoReduced;      \r
5577   term2 = sumOfWeightsForFour;\r
5578   term3 = sumOfWeightsForTwoReduced;        \r
5579   if(term2*term3>0.)\r
5580   {\r
5581    denominator = 1.-term1/(term2*term3);\r
5582    prefactor = term1/(term2*term3);\r
5583    if(denominator!=0)\r
5584    {\r
5585     covFourTwoReduced = (fourTwoReduced-four*twoReduced)/denominator;            \r
5586     wCovFourTwoReduced = covFourTwoReduced*prefactor; \r
5587     fDiffFlowCovariances[t][pe][2]->SetBinContent(b,wCovFourTwoReduced);\r
5588    }\r
5589   }\r
5590   // <4>,<4'>:\r
5591   term1 = productOfWeightsForFourFourReduced;      \r
5592   term2 = sumOfWeightsForFour;\r
5593   term3 = sumOfWeightsForFourReduced;        \r
5594   if(term2*term3>0.)\r
5595   {\r
5596    denominator = 1.-term1/(term2*term3);\r
5597    prefactor = term1/(term2*term3);\r
5598    if(denominator!=0)\r
5599    {\r
5600     covFourFourReduced = (fourFourReduced-four*fourReduced)/denominator;            \r
5601     wCovFourFourReduced = covFourFourReduced*prefactor; \r
5602     fDiffFlowCovariances[t][pe][3]->SetBinContent(b,wCovFourFourReduced);\r
5603    }\r
5604   }\r
5605   // <2'>,<4'>:\r
5606   term1 = productOfWeightsForTwoReducedFourReduced;      \r
5607   term2 = sumOfWeightsForTwoReduced;\r
5608   term3 = sumOfWeightsForFourReduced;        \r
5609   if(term2*term3>0.)\r
5610   {\r
5611    denominator = 1.-term1/(term2*term3);\r
5612    prefactor = term1/(term2*term3);\r
5613    if(denominator!=0)\r
5614    {\r
5615     covTwoReducedFourReduced = (twoReducedFourReduced-twoReduced*fourReduced)/denominator;            \r
5616     wCovTwoReducedFourReduced = covTwoReducedFourReduced*prefactor; \r
5617     fDiffFlowCovariances[t][pe][4]->SetBinContent(b,wCovTwoReducedFourReduced);\r
5618    }\r
5619   }   \r
5620  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5621   \r
5622 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCovariances(TString type, TString ptOrEta)\r
5623 \r
5624 \r
5625 //================================================================================================================================\r
5626 \r
5627 \r
5628 void AliFlowAnalysisWithQCumulants::CalculateDiffFlow(TString type, TString ptOrEta)\r
5629 {\r
5630  // calculate differential flow from differential cumulants and previously obtained integrated flow: (to be improved: description)\r
5631  \r
5632  Int_t typeFlag = -1;\r
5633  Int_t ptEtaFlag = -1;\r
5634 \r
5635  if(type == "RP")\r
5636  {\r
5637   typeFlag = 0;\r
5638  } else if(type == "POI")\r
5639    {\r
5640     typeFlag = 1;\r
5641    } \r
5642      \r
5643  if(ptOrEta == "Pt")\r
5644  {\r
5645   ptEtaFlag = 0;\r
5646  } else if(ptOrEta == "Eta")\r
5647    {\r
5648     ptEtaFlag = 1;\r
5649    } \r
5650   \r
5651  // shortcuts:\r
5652  Int_t t = typeFlag;\r
5653  Int_t pe = ptEtaFlag;\r
5654      \r
5655  // common:\r
5656  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
5657    \r
5658  // correlations:\r
5659  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>\r
5660  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>\r
5661  \r
5662  // statistical errors of correlations:\r
5663  Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1);\r
5664  Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2);   \r
5665     \r
5666  // reduced correlations:\r
5667  Double_t twoReduced = 0.; // <<2'>>\r
5668  Double_t fourReduced = 0.; // <<4'>>\r
5669  \r
5670  // statistical errors of reduced correlations:\r
5671  Double_t twoReducedError = 0.; \r
5672  Double_t fourReducedError = 0.; \r
5673 \r
5674  // covariances:\r
5675  Double_t wCovTwoFour = fIntFlowCovariances->GetBinContent(1);// // Cov(<2>,<4>) * prefactor(<2>,<4>)\r
5676  Double_t wCovTwoTwoReduced = 0.; // Cov(<2>,<2'>) * prefactor(<2>,<2'>)\r
5677  Double_t wCovTwoFourReduced = 0.; // Cov(<2>,<4'>) * prefactor(<2>,<4'>)\r
5678  Double_t wCovFourTwoReduced = 0.; // Cov(<4>,<2'>) * prefactor(<4>,<2'>)\r
5679  Double_t wCovFourFourReduced = 0.; // Cov(<4>,<4'>) * prefactor(<4>,<4'>)\r
5680  Double_t wCovTwoReducedFourReduced = 0.; // Cov(<2'>,<4'>) * prefactor(<2'>,<4'>)\r
5681  \r
5682  // differential flow:\r
5683  Double_t v2Prime = 0.; // v'{2}                   \r
5684  Double_t v4Prime = 0.; // v'{4}\r
5685  \r
5686  // statistical error of differential flow:\r
5687  Double_t v2PrimeError = 0.;                    \r
5688  Double_t v4PrimeError = 0.; \r
5689  \r
5690  // squared statistical error of differential flow:\r
5691  Double_t v2PrimeErrorSquared = 0.;                    \r
5692  Double_t v4PrimeErrorSquared = 0.; \r
5693  \r
5694  // loop over pt or eta bins:\r
5695  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
5696  {\r
5697   // reduced correlations and statistical errors:\r
5698   twoReduced = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b);\r
5699   twoReducedError = fDiffFlowCorrelationsHist[t][pe][0]->GetBinError(b);\r
5700   fourReduced = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b);\r
5701   fourReducedError = fDiffFlowCorrelationsHist[t][pe][1]->GetBinError(b);\r
5702   // covariances:\r
5703   wCovTwoTwoReduced = fDiffFlowCovariances[t][pe][0]->GetBinContent(b);\r
5704   wCovTwoFourReduced = fDiffFlowCovariances[t][pe][1]->GetBinContent(b);\r
5705   wCovFourTwoReduced = fDiffFlowCovariances[t][pe][2]->GetBinContent(b);\r
5706   wCovFourFourReduced = fDiffFlowCovariances[t][pe][3]->GetBinContent(b);\r
5707   wCovTwoReducedFourReduced = fDiffFlowCovariances[t][pe][4]->GetBinContent(b);\r
5708   // differential flow:\r
5709   // v'{2}:\r
5710   if(two>0.) \r
5711   {\r
5712    v2Prime = twoReduced/pow(two,0.5);\r
5713    v2PrimeErrorSquared = (1./4.)*pow(two,-3.)*\r
5714                          (pow(twoReduced,2.)*pow(twoError,2.)\r
5715                           + 4.*pow(two,2.)*pow(twoReducedError,2.)\r
5716                           - 4.*two*twoReduced*wCovTwoTwoReduced);\r
5717      \r
5718                                                             \r
5719    if(v2PrimeErrorSquared>0.) v2PrimeError = pow(v2PrimeErrorSquared,0.5);\r
5720    fDiffFlow[t][pe][0]->SetBinContent(b,v2Prime); \r
5721    fDiffFlow[t][pe][0]->SetBinError(b,v2PrimeError);     \r
5722   }\r
5723   // differential flow:\r
5724   // v'{4}\r
5725   if(2.*pow(two,2.)-four > 0.) \r
5726   {\r
5727    v4Prime = (2.*two*twoReduced-fourReduced)/pow(2.*pow(two,2.)-four,3./4.);\r
5728    v4PrimeErrorSquared = pow(2.*pow(two,2.)-four,-7./2.)*\r
5729                          (pow(2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced,2.)*pow(twoError,2.)\r
5730                           + (9./16.)*pow(2.*two*twoReduced-fourReduced,2.)*pow(fourError,2.)\r
5731                           + 4.*pow(two,2.)*pow(2.*pow(two,2.)-four,2.)*pow(twoReducedError,2.)\r
5732                           + pow(2.*pow(two,2.)-four,2.)*pow(fourReducedError,2.)                          \r
5733                           - (3./2.)*(2.*two*twoReduced-fourReduced)\r
5734                           * (2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced)*wCovTwoFour\r
5735                           - 4.*two*(2.*pow(two,2.)-four)\r
5736                           * (2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced)*wCovTwoTwoReduced\r
5737                           + 2.*(2.*pow(two,2.)-four)\r
5738                           * (2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced)*wCovTwoFourReduced\r
5739                           + 3.*two*(2.*pow(two,2.)-four)*(2.*two*twoReduced-fourReduced)*wCovFourTwoReduced\r
5740                           - (3./2.)*(2.*pow(two,2.)-four)*(2.*two*twoReduced-fourReduced)*wCovFourFourReduced \r
5741                           - 4.*two*pow(2.*pow(two,2.)-four,2.)*wCovTwoReducedFourReduced);  \r
5742    if(v4PrimeErrorSquared>0.) v4PrimeError = pow(v4PrimeErrorSquared,0.5);        \r
5743    fDiffFlow[t][pe][1]->SetBinContent(b,v4Prime);\r
5744    fDiffFlow[t][pe][1]->SetBinError(b,v4PrimeError);     \r
5745   }\r
5746   \r
5747  } // end of for(Int_t b=1;b<=fnBinsPtEta[pe];b++)\r
5748  \r
5749    \r
5750  \r
5751  \r
5752  /*\r
5753  // 2D:\r
5754  for(Int_t nua=0;nua<2;nua++)\r
5755  {\r
5756   for(Int_t p=1;p<=fnBinsPt;p++)\r
5757   {\r
5758    for(Int_t e=1;e<=fnBinsEta;e++) \r
5759    { \r
5760     // differential cumulants:\r
5761     Double_t qc2Prime = fFinalCumulants2D[t][pW][eW][nua][0]->GetBinContent(fFinalCumulants2D[t][pW][eW][nua][0]->GetBin(p,e)); // QC{2'}                    \r
5762     Double_t qc4Prime = fFinalCumulants2D[t][pW][eW][nua][1]->GetBinContent(fFinalCumulants2D[t][pW][eW][nua][1]->GetBin(p,e)); // QC{4'}\r
5763     // differential flow:\r
5764     Double_t v2Prime = 0.;                    \r
5765     Double_t v4Prime = 0.; \r
5766     if(v2) \r
5767     {\r
5768      v2Prime = qc2Prime/v2;\r
5769      fFinalFlow2D[t][pW][eW][nua][0]->SetBinContent(fFinalFlow2D[t][pW][eW][nua][0]->GetBin(p,e),v2Prime);  \r
5770     }                   \r
5771     if(v4)\r
5772     {\r
5773      v4Prime = -qc4Prime/pow(v4,3.); \r
5774      fFinalFlow2D[t][pW][eW][nua][1]->SetBinContent(fFinalFlow2D[t][pW][eW][nua][1]->GetBin(p,e),v4Prime);  \r
5775     }                    \r
5776    } // end of for(Int_t e=1;e<=fnBinsEta;e++)\r
5777   } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
5778  } // end of for(Int_t nua=0;nua<2;nua++)\r
5779  */\r
5780 \r
5781 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlow(TString type, Bool_t useParticleWeights)\r
5782 \r
5783 \r
5784 //================================================================================================================================\r
5785 \r
5786 \r
5787 void AliFlowAnalysisWithQCumulants::StoreIntFlowFlags()\r
5788 {\r
5789  // a) Store all flags for integrated flow in profile fIntFlowFlags.\r
5790  \r
5791  if(!fIntFlowFlags)\r
5792  {\r
5793   cout<<"WARNING: fIntFlowFlags is NULL in AFAWQC::SFFIF() !!!!"<<endl;\r
5794   exit(0);\r
5795  } \r
5796 \r
5797  fIntFlowFlags->Fill(0.5,(Int_t)fUsePhiWeights||fUsePtWeights||fUseEtaWeights); // particle weights used or not\r
5798  //fIntFlowFlags->Fill(1.5,""); // which event weight was used? // to be improved\r
5799  fIntFlowFlags->Fill(2.5,(Int_t)fApplyCorrectionForNUA); // corrected for non-uniform acceptance or not\r
5800   \r
5801 } // end of void AliFlowAnalysisWithQCumulants::StoreIntFlowFlags()\r
5802 \r
5803 \r
5804 //================================================================================================================================\r
5805 \r
5806 \r
5807 void AliFlowAnalysisWithQCumulants::StoreDiffFlowFlags()\r
5808 {\r
5809  // Store all flags for differential flow in the profile fDiffFlowFlags.\r
5810   \r
5811  if(!fDiffFlowFlags)\r
5812  {\r
5813   cout<<"WARNING: fDiffFlowFlags is NULL in AFAWQC::SFFDF() !!!!"<<endl;\r
5814   exit(0);\r
5815  } \r
5816  \r
5817  fDiffFlowFlags->Fill(0.5,fUsePhiWeights||fUsePtWeights||fUseEtaWeights); // particle weights used or not\r
5818  //fDiffFlowFlags->Fill(1.5,""); // which event weight was used? // to be improved\r
5819  fDiffFlowFlags->Fill(2.5,fApplyCorrectionForNUA); // corrected for non-uniform acceptance or not\r
5820  fDiffFlowFlags->Fill(3.5,fCalculate2DFlow); // calculate also 2D differential flow in (pt,eta) or not\r
5821     \r
5822 } // end of void AliFlowAnalysisWithQCumulants::StoreDiffFlowFlags()\r
5823 \r
5824 \r
5825 //================================================================================================================================\r
5826 \r
5827 \r
5828 void AliFlowAnalysisWithQCumulants::GetPointersForCommonHistograms(TList *outputListHistos) \r
5829 {\r
5830  // Access all pointers to common control and common result histograms and profiles.\r
5831  \r
5832  if(outputListHistos)  \r
5833  {\r
5834   TString commonHistsName = "AliFlowCommonHistQC";\r
5835   commonHistsName += fAnalysisLabel->Data();\r
5836   AliFlowCommonHist *commonHist = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHistsName.Data()));\r
5837   if(commonHist) this->SetCommonHists(commonHist); \r
5838   TString commonHists2ndOrderName = "AliFlowCommonHist2ndOrderQC";\r
5839   commonHists2ndOrderName += fAnalysisLabel->Data();\r
5840   AliFlowCommonHist *commonHist2nd = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHists2ndOrderName.Data()));\r
5841   if(commonHist2nd) this->SetCommonHists2nd(commonHist2nd);   \r
5842   TString commonHists4thOrderName = "AliFlowCommonHist4thOrderQC";\r
5843   commonHists4thOrderName += fAnalysisLabel->Data();\r
5844   AliFlowCommonHist *commonHist4th = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHists4thOrderName.Data()));\r
5845   if(commonHist4th) this->SetCommonHists4th(commonHist4th);  \r
5846   TString commonHists6thOrderName = "AliFlowCommonHist6thOrderQC";\r
5847   commonHists6thOrderName += fAnalysisLabel->Data();\r
5848   AliFlowCommonHist *commonHist6th = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHists6thOrderName.Data()));\r
5849   if(commonHist6th) this->SetCommonHists6th(commonHist6th);  \r
5850   TString commonHists8thOrderName = "AliFlowCommonHist8thOrderQC";\r
5851   commonHists8thOrderName += fAnalysisLabel->Data();\r
5852   AliFlowCommonHist *commonHist8th = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHists8thOrderName.Data()));\r
5853   if(commonHist8th) this->SetCommonHists8th(commonHist8th);  \r
5854   TString commonHistResults2ndOrderName = "AliFlowCommonHistResults2ndOrderQC"; \r
5855   commonHistResults2ndOrderName += fAnalysisLabel->Data(); \r
5856   AliFlowCommonHistResults *commonHistRes2nd = dynamic_cast<AliFlowCommonHistResults*>\r
5857                                                (outputListHistos->FindObject(commonHistResults2ndOrderName.Data()));\r
5858   if(commonHistRes2nd) this->SetCommonHistsResults2nd(commonHistRes2nd);   \r
5859   TString commonHistResults4thOrderName = "AliFlowCommonHistResults4thOrderQC";\r
5860   commonHistResults4thOrderName += fAnalysisLabel->Data();\r
5861   AliFlowCommonHistResults *commonHistRes4th = dynamic_cast<AliFlowCommonHistResults*>\r
5862                                                (outputListHistos->FindObject(commonHistResults4thOrderName.Data()));\r
5863   if(commonHistRes4th) this->SetCommonHistsResults4th(commonHistRes4th);  \r
5864   TString commonHistResults6thOrderName = "AliFlowCommonHistResults6thOrderQC";\r
5865   commonHistResults6thOrderName += fAnalysisLabel->Data();\r
5866   AliFlowCommonHistResults *commonHistRes6th = dynamic_cast<AliFlowCommonHistResults*>\r
5867                                                (outputListHistos->FindObject(commonHistResults6thOrderName.Data()));\r
5868   if(commonHistRes6th) this->SetCommonHistsResults6th(commonHistRes6th);  \r
5869   TString commonHistResults8thOrderName = "AliFlowCommonHistResults8thOrderQC";\r
5870   commonHistResults8thOrderName += fAnalysisLabel->Data();\r
5871   AliFlowCommonHistResults *commonHistRes8th = dynamic_cast<AliFlowCommonHistResults*>\r
5872                                                (outputListHistos->FindObject(commonHistResults8thOrderName.Data()));  \r
5873   if(commonHistRes8th) this->SetCommonHistsResults8th(commonHistRes8th);\r
5874  } else\r
5875    {\r
5876     cout<<"WARNING: outputListHistos is NULL in AFAWQC::GPFCH() !!!!"<<endl;\r
5877     exit(0);\r
5878    }\r
5879         \r
5880 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForCommonHistograms(TList *outputListHistos) \r
5881 \r
5882 \r
5883 //================================================================================================================================\r
5884 \r
5885 \r
5886 void AliFlowAnalysisWithQCumulants::GetPointersForParticleWeightsHistograms(TList *outputListHistos) \r
5887 {\r
5888  // Get pointers for histograms with particle weights.\r
5889 \r
5890  if(outputListHistos)\r
5891  {\r
5892   TList *weightsList = dynamic_cast<TList*>(outputListHistos->FindObject("Weights"));\r
5893   if(weightsList) this->SetWeightsList(weightsList);\r
5894   TString fUseParticleWeightsName = "fUseParticleWeightsQC"; // to be improved (hirdwired label QC)\r
5895   fUseParticleWeightsName += fAnalysisLabel->Data();\r
5896   TProfile *useParticleWeights = dynamic_cast<TProfile*>(weightsList->FindObject(fUseParticleWeightsName.Data()));\r
5897   if(useParticleWeights)\r
5898   {\r
5899    this->SetUseParticleWeights(useParticleWeights);  \r
5900    fUsePhiWeights = (Int_t)fUseParticleWeights->GetBinContent(1); \r
5901    fUsePtWeights = (Int_t)fUseParticleWeights->GetBinContent(2); \r
5902    fUseEtaWeights = (Int_t)fUseParticleWeights->GetBinContent(3);  \r
5903   }\r
5904  } else\r
5905    {\r
5906     cout<<"WARNING: outputListHistos is NULL in AFAWQC::GPFPWH() !!!!"<<endl;\r
5907     exit(0);\r
5908    }\r
5909 \r
5910 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForParticleWeightsHistograms(TList *outputListHistos); \r
5911 \r
5912 \r
5913 //================================================================================================================================\r
5914 \r
5915 \r
5916 void AliFlowAnalysisWithQCumulants::GetPointersForIntFlowHistograms(TList *outputListHistos) \r
5917 {\r
5918  // Get pointers for histograms and profiles relevant for integrated flow:\r
5919  //  a) Get pointer to base list for integrated flow holding profile fIntFlowFlags and lists fIntFlowProfiles and fIntFlowResults.\r
5920  //  b) Get pointer to profile fIntFlowFlags holding all flags for integrated flow.\r
5921  //  c) Get pointer to list fIntFlowProfiles and pointers to all objects that she holds. \r
5922  //  d) Get pointer to list fIntFlowResults and pointers to all objects that she holds. \r
5923   \r
5924  TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data member?)\r
5925  TString powerFlag[2] = {"linear","quadratic"}; // to be improved (should I promote this to data member?)\r
5926  \r
5927  if(outputListHistos)\r
5928  {\r
5929   // a) Get pointer to base list for integrated flow holding profile fIntFlowFlags and lists fIntFlowProfiles and fIntFlowResults:\r
5930   TList *intFlowList = NULL;\r
5931   intFlowList = dynamic_cast<TList*>(outputListHistos->FindObject("Integrated Flow"));\r
5932   if(!intFlowList) \r
5933   {\r
5934    cout<<"WARNING: intFlowList is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5935    exit(0); \r
5936   }  \r
5937   \r
5938   // b) Get pointer to profile fIntFlowFlags holding all flags for integrated flow:\r
5939   TString intFlowFlagsName = "fIntFlowFlags";\r
5940   intFlowFlagsName += fAnalysisLabel->Data();\r
5941   TProfile *intFlowFlags = dynamic_cast<TProfile*>(intFlowList->FindObject(intFlowFlagsName.Data()));\r
5942   Bool_t bApplyCorrectionForNUA = kFALSE;\r
5943   if(intFlowFlags)\r
5944   {\r
5945    this->SetIntFlowFlags(intFlowFlags);  \r
5946    bApplyCorrectionForNUA = (Int_t)intFlowFlags->GetBinContent(3); \r
5947    this->SetApplyCorrectionForNUA(bApplyCorrectionForNUA);      \r
5948   } else \r
5949     {\r
5950      cout<<"WARNING: intFlowFlags is NULL in FAWQC::GPFIFH() !!!!"<<endl;\r
5951     }\r
5952   \r
5953   // c) Get pointer to list fIntFlowProfiles and pointers to all objects that she holds:\r
5954   TList *intFlowProfiles = NULL;\r
5955   intFlowProfiles = dynamic_cast<TList*>(intFlowList->FindObject("Profiles"));\r
5956   if(intFlowProfiles)  \r
5957   {\r
5958    // average multiplicities:\r
5959    TString avMultiplicityName = "fAvMultiplicity";\r
5960    avMultiplicityName += fAnalysisLabel->Data();\r
5961    TProfile *avMultiplicity = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(avMultiplicityName.Data()));\r
5962    if(avMultiplicity) \r
5963    {\r
5964     this->SetAvMultiplicity(avMultiplicity);\r
5965    } else \r
5966      {\r
5967       cout<<"WARNING: avMultiplicity is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5968      }\r
5969    // average correlations <<2>>, <<4>>, <<6>> and <<8>> (with wrong errors!):\r
5970    TString intFlowCorrelationsProName = "fIntFlowCorrelationsPro";\r
5971    intFlowCorrelationsProName += fAnalysisLabel->Data();\r
5972    TProfile *intFlowCorrelationsPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowCorrelationsProName.Data()));\r
5973    if(intFlowCorrelationsPro) \r
5974    {\r
5975     this->SetIntFlowCorrelationsPro(intFlowCorrelationsPro);\r
5976    } else \r
5977      {\r
5978       cout<<"WARNING: intFlowCorrelationsPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5979      } \r
5980    // average all correlations for integrated flow (with wrong errors!):\r
5981    TString intFlowCorrelationsAllProName = "fIntFlowCorrelationsAllPro";\r
5982    intFlowCorrelationsAllProName += fAnalysisLabel->Data();\r
5983    TProfile *intFlowCorrelationsAllPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowCorrelationsAllProName.Data()));\r
5984    if(intFlowCorrelationsAllPro) \r
5985    {\r
5986     this->SetIntFlowCorrelationsAllPro(intFlowCorrelationsAllPro);\r
5987    } else \r
5988      {\r
5989       cout<<"WARNING: intFlowCorrelationsAllPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
5990      }     \r
5991    // average extra correlations for integrated flow (which appear only when particle weights are used):\r
5992    // (to be improved: Weak point in implementation, I am assuming here that method GetPointersForParticleWeightsHistograms() was called)\r
5993    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
5994    {\r
5995     TString intFlowExtraCorrelationsProName = "fIntFlowExtraCorrelationsPro";\r
5996     intFlowExtraCorrelationsProName += fAnalysisLabel->Data();\r
5997     TProfile *intFlowExtraCorrelationsPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowExtraCorrelationsProName.Data()));\r
5998     if(intFlowExtraCorrelationsPro) \r
5999     {\r
6000      this->SetIntFlowExtraCorrelationsPro(intFlowExtraCorrelationsPro);\r
6001     } else \r
6002       {\r
6003        cout<<"WARNING: intFlowExtraCorrelationsPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6004       }\r
6005    } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)        \r
6006    // average products of correlations <2>, <4>, <6> and <8>:  \r
6007    TString intFlowProductOfCorrelationsProName = "fIntFlowProductOfCorrelationsPro";\r
6008    intFlowProductOfCorrelationsProName += fAnalysisLabel->Data();\r
6009    TProfile *intFlowProductOfCorrelationsPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowProductOfCorrelationsProName.Data()));\r
6010    if(intFlowProductOfCorrelationsPro) \r
6011    {\r
6012     this->SetIntFlowProductOfCorrelationsPro(intFlowProductOfCorrelationsPro);\r
6013    } else \r
6014      {\r
6015       cout<<"WARNING: intFlowProductOfCorrelationsPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6016      }     \r
6017    // average correction terms for non-uniform acceptance (with wrong errors!):\r
6018    for(Int_t sc=0;sc<2;sc++)\r
6019    {\r
6020     TString intFlowCorrectionTermsForNUAProName = "fIntFlowCorrectionTermsForNUAPro";\r
6021     intFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();\r
6022     TProfile *intFlowCorrectionTermsForNUAPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject((Form("%s: %s terms",intFlowCorrectionTermsForNUAProName.Data(),sinCosFlag[sc].Data()))));\r
6023     if(intFlowCorrectionTermsForNUAPro) \r
6024     {\r
6025      this->SetIntFlowCorrectionTermsForNUAPro(intFlowCorrectionTermsForNUAPro,sc);\r
6026     } else \r
6027       {\r
6028        cout<<"WARNING: intFlowCorrectionTermsForNUAPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6029        cout<<"sc = "<<sc<<endl;\r
6030       } \r
6031    } // end of for(Int_t sc=0;sc<2;sc++)           \r
6032   } else // to if(intFlowProfiles)  \r
6033     {\r
6034      cout<<"WARNING: intFlowProfiles is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6035     }\r
6036    \r
6037   //  d) Get pointer to list fIntFlowResults and pointers to all objects that she holds. \r
6038   TList *intFlowResults = NULL;\r
6039   intFlowResults = dynamic_cast<TList*>(intFlowList->FindObject("Results"));\r
6040   if(intFlowResults)\r
6041   {\r
6042    // average correlations <<2>>, <<4>>, <<6>> and <<8>> (with correct errors!):\r
6043    TString intFlowCorrelationsHistName = "fIntFlowCorrelationsHist";\r
6044    intFlowCorrelationsHistName += fAnalysisLabel->Data();\r
6045    TH1D *intFlowCorrelationsHist = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowCorrelationsHistName.Data()));\r
6046    if(intFlowCorrelationsHist) \r
6047    {\r
6048     this->SetIntFlowCorrelationsHist(intFlowCorrelationsHist);\r
6049    } else \r
6050      {\r
6051       cout<<"WARNING: intFlowCorrelationsHist is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6052      } \r
6053    // average all correlations for integrated flow (with correct errors!):\r
6054    TString intFlowCorrelationsAllHistName = "fIntFlowCorrelationsAllHist";\r
6055    intFlowCorrelationsAllHistName += fAnalysisLabel->Data();\r
6056    TH1D *intFlowCorrelationsAllHist = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowCorrelationsAllHistName.Data()));\r
6057    if(intFlowCorrelationsAllHist) \r
6058    {\r
6059     this->SetIntFlowCorrelationsAllHist(intFlowCorrelationsAllHist);\r
6060    } else \r
6061      {\r
6062       cout<<"WARNING: intFlowCorrelationsAllHist is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6063      }  \r
6064    // average correction terms for non-uniform acceptance (with correct errors!):\r
6065    TString intFlowCorrectionTermsForNUAHistName = "fIntFlowCorrectionTermsForNUAHist";\r
6066    intFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();\r
6067    for(Int_t sc=0;sc<2;sc++)\r
6068    {\r
6069     TH1D *intFlowCorrectionTermsForNUAHist = dynamic_cast<TH1D*>(intFlowResults->FindObject((Form("%s: %s terms",intFlowCorrectionTermsForNUAHistName.Data(),sinCosFlag[sc].Data()))));\r
6070     if(intFlowCorrectionTermsForNUAHist) \r
6071     {\r
6072      this->SetIntFlowCorrectionTermsForNUAHist(intFlowCorrectionTermsForNUAHist,sc);\r
6073     } else \r
6074       {\r
6075        cout<<"WARNING: intFlowCorrectionTermsForNUAHist is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6076        cout<<"sc = "<<sc<<endl;\r
6077       } \r
6078    } // end of for(Int_t sc=0;sc<2;sc++)           \r
6079    // covariances (multiplied with weight dependent prefactor):\r
6080    TString intFlowCovariancesName = "fIntFlowCovariances";\r
6081    intFlowCovariancesName += fAnalysisLabel->Data();\r
6082    TH1D *intFlowCovariances = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowCovariancesName.Data()));\r
6083    if(intFlowCovariances) \r
6084    {\r
6085     this->SetIntFlowCovariances(intFlowCovariances); \r
6086    } else \r
6087      {\r
6088       cout<<"WARNING: intFlowCovariances is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6089      } \r
6090    // sum of linear and quadratic event weights for <2>, <4>, <6> and <8>:\r
6091    TString intFlowSumOfEventWeightsName = "fIntFlowSumOfEventWeights";\r
6092    intFlowSumOfEventWeightsName += fAnalysisLabel->Data();\r
6093    for(Int_t power=0;power<2;power++)\r
6094    {\r
6095     TH1D *intFlowSumOfEventWeights = dynamic_cast<TH1D*>(intFlowResults->FindObject(Form("%s: %s",intFlowSumOfEventWeightsName.Data(),powerFlag[power].Data())));\r
6096     if(intFlowSumOfEventWeights) \r
6097     {\r
6098      this->SetIntFlowSumOfEventWeights(intFlowSumOfEventWeights,power);\r
6099     } else \r
6100       {\r
6101        cout<<"WARNING: intFlowSumOfEventWeights is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6102        cout<<"power = "<<power<<endl;\r
6103       }                                   \r
6104    } // end of for(Int_t power=0;power<2;power++)                                                                  \r
6105    // sum of products of event weights for correlations <2>, <4>, <6> and <8>:  \r
6106    TString intFlowSumOfProductOfEventWeightsName = "fIntFlowSumOfProductOfEventWeights";\r
6107    intFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();\r
6108    TH1D *intFlowSumOfProductOfEventWeights = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowSumOfProductOfEventWeightsName.Data()));\r
6109    if(intFlowSumOfProductOfEventWeights) \r
6110    {\r
6111     this->SetIntFlowSumOfProductOfEventWeights(intFlowSumOfProductOfEventWeights);\r
6112    } else \r
6113      {\r
6114       cout<<"WARNING: intFlowSumOfProductOfEventWeights is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6115      } \r
6116    // final results for integrated Q-cumulants:\r
6117    TString intFlowQcumulantsName = "fIntFlowQcumulants";\r
6118    intFlowQcumulantsName += fAnalysisLabel->Data();\r
6119    TH1D *intFlowQcumulants = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowQcumulantsName.Data()));\r
6120    if(intFlowQcumulants) \r
6121    {\r
6122     this->SetIntFlowQcumulants(intFlowQcumulants);\r
6123    } else \r
6124      {\r
6125       cout<<"WARNING: intFlowQcumulants is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6126      }  \r
6127    // final integrated flow estimates from Q-cumulants:\r
6128    TString intFlowName = "fIntFlow";\r
6129    intFlowName += fAnalysisLabel->Data();\r
6130    TH1D *intFlow = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowName.Data()));\r
6131    if(intFlow) \r
6132    {\r
6133     this->SetIntFlow(intFlow);\r
6134    } else \r
6135      {\r
6136       cout<<"WARNING: intFlow is NULL in AFAWQC::GPFIFH() !!!!"<<endl; \r
6137      }   \r
6138   } else // to if(intFlowResults)\r
6139     {\r
6140      cout<<"WARNING: intFlowResults is NULL in AFAWQC::GPFIFH() !!!!"<<endl;\r
6141     }\r
6142  } // end of if(outputListHistos)\r
6143 \r
6144 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForIntFlowHistograms(TList *outputListHistos)\r
6145 \r
6146 \r
6147 //================================================================================================================================\r
6148 \r
6149 \r
6150 void AliFlowAnalysisWithQCumulants::GetPointersForDiffFlowHistograms(TList *outputListHistos)\r
6151 {\r
6152  // Get pointer to all objects relevant for differential flow.\r
6153  //  a) Define flags locally (to be improved: should I promote flags to data members?);\r
6154  //  b) Get pointer to base list for differential flow fDiffFlowList and nested lists fDiffFlowListProfiles and fDiffFlowListResults;\r
6155  //  c) Get pointer to profile fDiffFlowFlags holding all flags for differential flow;\r
6156  //  d) Get pointers to all nested lists in fDiffFlowListProfiles and to profiles which they hold;\r
6157  //  e) Get pointers to all nested lists in fDiffFlowListResults and to histograms which they hold.\r
6158  \r
6159  // a) Define flags locally (to be improved: should I promote flags to data members?): \r
6160  TString typeFlag[2] = {"RP","POI"}; \r
6161  TString ptEtaFlag[2] = {"p_{T}","#eta"};\r
6162  TString powerFlag[2] = {"linear","quadratic"};\r
6163  TString sinCosFlag[2] = {"sin","cos"};\r
6164  TString differentialCumulantIndex[4] = {"QC{2'}","QC{4'}","QC{6'}","QC{8'}"};  \r
6165  TString differentialFlowIndex[4] = {"v'{2}","v'{4}","v'{6}","v'{8}"};  \r
6166  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"};\r
6167  TString mixedCorrelationIndex[8] = {"<2>","<2'>","<4>","<4'>","<6>","<6'>","<8>","<8'>"};\r
6168  TString covarianceName[5] = {"Cov(<2>,<2'>)","Cov(<2>,<4'>)","Cov(<4>,<2'>)","Cov(<4>,<4'>)","Cov(<2'>,<4'>)"}; \r
6169   \r
6170  // b) Get pointer to base list for differential flow fDiffFlowList and nested lists fDiffFlowListProfiles and fDiffFlowListResults:\r
6171  TList *diffFlowList = NULL;\r
6172  diffFlowList = dynamic_cast<TList*>(outputListHistos->FindObject("Differential Flow"));  \r
6173  if(!diffFlowList)\r
6174  { \r
6175   cout<<"WARNING: diffFlowList is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6176   exit(0);\r
6177  }\r
6178  // list holding nested lists containing profiles:\r
6179  TList *diffFlowListProfiles = NULL;\r
6180  diffFlowListProfiles = dynamic_cast<TList*>(diffFlowList->FindObject("Profiles"));\r
6181  if(!diffFlowListProfiles)\r
6182  { \r
6183   cout<<"WARNING: diffFlowListProfiles is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6184   exit(0);\r
6185  }\r
6186  // list holding nested lists containing 2D and 1D histograms with final results:\r
6187  TList *diffFlowListResults = NULL;\r
6188  diffFlowListResults = dynamic_cast<TList*>(diffFlowList->FindObject("Results"));\r
6189  if(!diffFlowListResults)\r
6190  { \r
6191   cout<<"WARNING: diffFlowListResults is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6192   exit(0);\r
6193  }\r
6194  \r
6195  // c) Get pointer to profile holding all flags for differential flow;\r
6196  TString diffFlowFlagsName = "fDiffFlowFlags";\r
6197  diffFlowFlagsName += fAnalysisLabel->Data();\r
6198  TProfile *diffFlowFlags = dynamic_cast<TProfile*>(diffFlowList->FindObject(diffFlowFlagsName.Data()));\r
6199  Bool_t bCalculate2DFlow = kFALSE;\r
6200  if(diffFlowFlags)\r
6201  {\r
6202   this->SetDiffFlowFlags(diffFlowFlags);  \r
6203   bCalculate2DFlow = (Int_t)diffFlowFlags->GetBinContent(4);\r
6204   this->SetCalculate2DFlow(bCalculate2DFlow); // to be improved (shoul I call this setter somewhere else?)     \r
6205  }\r
6206   \r
6207  // d) Get pointers to all nested lists in fDiffFlowListProfiles and to profiles which they hold;\r
6208  // correlations:\r
6209  TList *diffFlowCorrelationsProList[2][2] = {{NULL}};\r
6210  TString diffFlowCorrelationsProName = "fDiffFlowCorrelationsPro";\r
6211  diffFlowCorrelationsProName += fAnalysisLabel->Data();\r
6212  TProfile *diffFlowCorrelationsPro[2][2][4] = {{{NULL}}};   \r
6213  // products of correlations:\r
6214  TList *diffFlowProductOfCorrelationsProList[2][2] = {{NULL}};\r
6215  TString diffFlowProductOfCorrelationsProName = "fDiffFlowProductOfCorrelationsPro";\r
6216  diffFlowProductOfCorrelationsProName += fAnalysisLabel->Data();  \r
6217  TProfile *diffFlowProductOfCorrelationsPro[2][2][8][8] = {{{{NULL}}}};   \r
6218  // corrections:\r
6219  TList *diffFlowCorrectionsProList[2][2] = {{NULL}};\r
6220  TString diffFlowCorrectionTermsForNUAProName = "fDiffFlowCorrectionTermsForNUAPro";\r
6221  diffFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();  \r
6222  TProfile *diffFlowCorrectionTermsForNUAPro[2][2][2][10] = {{{{NULL}}}};   \r
6223  for(Int_t t=0;t<2;t++)\r
6224  {\r
6225   for(Int_t pe=0;pe<2;pe++)\r
6226   {\r
6227    diffFlowCorrelationsProList[t][pe] = dynamic_cast<TList*>(diffFlowListProfiles->FindObject(Form("Profiles with correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6228    if(!diffFlowCorrelationsProList[t][pe])\r
6229    { \r
6230     cout<<"WARNING: diffFlowCorrelationsProList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6231     cout<<"t = "<<t<<endl;\r
6232     cout<<"pe = "<<pe<<endl;\r
6233     exit(0);\r
6234    }\r
6235    for(Int_t ci=0;ci<4;ci++) // correlation index\r
6236    {\r
6237     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
6238     if(diffFlowCorrelationsPro[t][pe][ci])\r
6239     {\r
6240      this->SetDiffFlowCorrelationsPro(diffFlowCorrelationsPro[t][pe][ci],t,pe,ci);\r
6241     } else\r
6242       {\r
6243        cout<<"WARNING: diffFlowCorrelationsPro[t][pe][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6244        cout<<"t  = "<<t<<endl;\r
6245        cout<<"pe = "<<pe<<endl;   \r
6246        cout<<"ci = "<<ci<<endl;\r
6247       }     \r
6248    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index  \r
6249    // products of correlations:    \r
6250    diffFlowProductOfCorrelationsProList[t][pe] = dynamic_cast<TList*>(diffFlowListProfiles->FindObject(Form("Profiles with products of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()))); \r
6251    if(!diffFlowProductOfCorrelationsProList[t][pe])\r
6252    { \r
6253     cout<<"WARNING: ddiffFlowProductOfCorrelationsProList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6254     cout<<"t = "<<t<<endl;\r
6255     cout<<"pe = "<<pe<<endl;\r
6256     exit(0);\r
6257    }\r
6258    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
6259    {\r
6260     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6261     {\r
6262      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
6263      if(diffFlowProductOfCorrelationsPro[t][pe][mci1][mci2])\r
6264      {\r
6265       this->SetDiffFlowProductOfCorrelationsPro(diffFlowProductOfCorrelationsPro[t][pe][mci1][mci2],t,pe,mci1,mci2);\r
6266      } else\r
6267        {\r
6268         cout<<"WARNING: diffFlowCorrelationsPro[t][pe][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6269         cout<<"t    = "<<t<<endl;\r
6270         cout<<"pe   = "<<pe<<endl;   \r
6271         cout<<"mci1 = "<<mci1<<endl;\r
6272         cout<<"mci2 = "<<mci2<<endl;\r
6273        }\r
6274      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here\r
6275     } // end of for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6276    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index    \r
6277    // corrections:\r
6278    diffFlowCorrectionsProList[t][pe] = dynamic_cast<TList*>(diffFlowListProfiles->FindObject(Form("Profiles with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6279    if(!diffFlowCorrectionsProList[t][pe])\r
6280    { \r
6281     cout<<"WARNING: diffFlowCorrectionsProList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6282     cout<<"t = "<<t<<endl;\r
6283     cout<<"pe = "<<pe<<endl;\r
6284     exit(0);\r
6285    }\r
6286    // correction terms for NUA:\r
6287    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6288    {\r
6289     for(Int_t cti=0;cti<9;cti++) // correction term index\r
6290     {\r
6291      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
6292      if(diffFlowCorrectionTermsForNUAPro[t][pe][sc][cti])\r
6293      {\r
6294       this->SetDiffFlowCorrectionTermsForNUAPro(diffFlowCorrectionTermsForNUAPro[t][pe][sc][cti],t,pe,sc,cti);\r
6295      } else\r
6296        {\r
6297         cout<<"WARNING: diffFlowCorrectionTermsForNUAPro[t][pe][sc][cti] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6298         cout<<"t   = "<<t<<endl;\r
6299         cout<<"pe  = "<<pe<<endl;   \r
6300         cout<<"sc  = "<<sc<<endl;\r
6301         cout<<"cti = "<<cti<<endl;\r
6302        }    \r
6303     } // end of for(Int_t cti=0;cti<9;cti++) // correction term index\r
6304    } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6305    // ...\r
6306   } // end of for(Int_t pe=0;pe<2;pe++)\r
6307  } // end of for(Int_t t=0;t<2;t++)\r
6308   \r
6309  // e) Get pointers to all nested lists in fDiffFlowListResults and to histograms which they hold.\r
6310  // reduced correlations:\r
6311  TList *diffFlowCorrelationsHistList[2][2] = {{NULL}};\r
6312  TString diffFlowCorrelationsHistName = "fDiffFlowCorrelationsHist";\r
6313  diffFlowCorrelationsHistName += fAnalysisLabel->Data();  \r
6314  TH1D *diffFlowCorrelationsHist[2][2][4] = {{{NULL}}};\r
6315  // corrections for NUA:\r
6316  TList *diffFlowCorrectionsHistList[2][2] = {{NULL}};\r
6317  TString diffFlowCorrectionTermsForNUAHistName = "fDiffFlowCorrectionTermsForNUAHist";\r
6318  diffFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();  \r
6319  TH1D *diffFlowCorrectionTermsForNUAHist[2][2][2][10] = {{{{NULL}}}};\r
6320  // differential Q-cumulants:\r
6321  TList *diffFlowCumulantsHistList[2][2] = {{NULL}};\r
6322  TString diffFlowCumulantsName = "fDiffFlowCumulants";\r
6323  diffFlowCumulantsName += fAnalysisLabel->Data();  \r
6324  TH1D *diffFlowCumulants[2][2][4] = {{{NULL}}};\r
6325  // differential flow estimates from Q-cumulants:\r
6326  TList *diffFlowHistList[2][2] = {{NULL}};\r
6327  TString diffFlowName = "fDiffFlow";\r
6328  diffFlowName += fAnalysisLabel->Data();  \r
6329  TH1D *diffFlow[2][2][4] = {{{NULL}}};\r
6330  // differential covariances:\r
6331  TList *diffFlowCovariancesHistList[2][2] = {{NULL}};\r
6332  TString diffFlowCovariancesName = "fDiffFlowCovariances";\r
6333  diffFlowCovariancesName += fAnalysisLabel->Data();  \r
6334  TH1D *diffFlowCovariances[2][2][5] = {{{NULL}}};\r
6335  for(Int_t t=0;t<2;t++) // type: RP or POI\r
6336  { \r
6337   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6338   {\r
6339    // reduced correlations:\r
6340    diffFlowCorrelationsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6341    if(!diffFlowCorrelationsHistList[t][pe])\r
6342    { \r
6343     cout<<"WARNING: diffFlowCorrelationsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6344     cout<<"t = "<<t<<endl;\r
6345     cout<<"pe = "<<pe<<endl;\r
6346     exit(0);\r
6347    }\r
6348    for(Int_t index=0;index<4;index++) \r
6349    {\r
6350     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
6351     if(diffFlowCorrelationsHist[t][pe][index])\r
6352     {\r
6353      this->SetDiffFlowCorrelationsHist(diffFlowCorrelationsHist[t][pe][index],t,pe,index);\r
6354     } else \r
6355       {\r
6356        cout<<"WARNING: diffFlowCorrelationsHist[t][pe][index] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6357        cout<<"t     = "<<t<<endl;\r
6358        cout<<"pe    = "<<pe<<endl;\r
6359        cout<<"index = "<<index<<endl;\r
6360        exit(0);       \r
6361       } \r
6362    } // end of for(Int_t index=0;index<4;index++)\r
6363    // corrections:\r
6364    diffFlowCorrectionsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Histograms with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6365    if(!diffFlowCorrectionsHistList[t][pe])\r
6366    { \r
6367     cout<<"WARNING: diffFlowCorrectionsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6368     cout<<"t = "<<t<<endl;\r
6369     cout<<"pe = "<<pe<<endl;\r
6370     exit(0);\r
6371    }\r
6372    // correction terms for NUA:\r
6373    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6374    {\r
6375     for(Int_t cti=0;cti<9;cti++) // correction term index\r
6376     {\r
6377      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
6378      if(diffFlowCorrectionTermsForNUAHist[t][pe][sc][cti])\r
6379      {\r
6380       this->SetDiffFlowCorrectionTermsForNUAHist(diffFlowCorrectionTermsForNUAHist[t][pe][sc][cti],t,pe,sc,cti);\r
6381      } else\r
6382        {\r
6383         cout<<"WARNING: diffFlowCorrectionTermsForNUAHist[t][pe][sc][cti] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6384         cout<<"t   = "<<t<<endl;\r
6385         cout<<"pe  = "<<pe<<endl;   \r
6386         cout<<"sc  = "<<sc<<endl;\r
6387         cout<<"cti = "<<cti<<endl;\r
6388        }    \r
6389     } // end of for(Int_t cti=0;cti<9;cti++) // correction term index\r
6390    } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6391    // ...\r
6392    // differential Q-cumulants:\r
6393    diffFlowCumulantsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Differential Q-cumulants (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6394    if(!diffFlowCumulantsHistList[t][pe])\r
6395    { \r
6396     cout<<"WARNING: diffFlowCumulantsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6397     cout<<"t  = "<<t<<endl;\r
6398     cout<<"pe = "<<pe<<endl;\r
6399     exit(0);\r
6400    }\r
6401    for(Int_t index=0;index<4;index++) \r
6402    {\r
6403     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
6404     if(diffFlowCumulants[t][pe][index])\r
6405     {\r
6406      this->SetDiffFlowCumulants(diffFlowCumulants[t][pe][index],t,pe,index);\r
6407     } else \r
6408       {\r
6409        cout<<"WARNING: diffFlowCumulants[t][pe][index] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6410        cout<<"t     = "<<t<<endl;\r
6411        cout<<"pe    = "<<pe<<endl;\r
6412        cout<<"index = "<<index<<endl;\r
6413        exit(0);       \r
6414       } \r
6415    } // end of for(Int_t index=0;index<4;index++)\r
6416    // differential flow estimates from Q-cumulants:\r
6417    diffFlowHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Differential flow (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6418    if(!diffFlowHistList[t][pe])\r
6419    { \r
6420     cout<<"WARNING: diffFlowHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6421     cout<<"t  = "<<t<<endl;\r
6422     cout<<"pe = "<<pe<<endl;\r
6423     exit(0);\r
6424    }\r
6425    for(Int_t index=0;index<4;index++) \r
6426    {\r
6427     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
6428     if(diffFlow[t][pe][index])\r
6429     {\r
6430      this->SetDiffFlow(diffFlow[t][pe][index],t,pe,index);\r
6431     } else \r
6432       {\r
6433        cout<<"WARNING: diffFlow[t][pe][index] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6434        cout<<"t     = "<<t<<endl;\r
6435        cout<<"pe    = "<<pe<<endl;\r
6436        cout<<"index = "<<index<<endl;\r
6437        exit(0);       \r
6438       } \r
6439    } // end of for(Int_t index=0;index<4;index++)\r
6440    // differential covariances:\r
6441    diffFlowCovariancesHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Covariances of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6442    if(!diffFlowCovariancesHistList[t][pe])\r
6443    { \r
6444     cout<<"WARNING: diffFlowCovariancesHistList[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 covIndex=0;covIndex<5;covIndex++) \r
6450    {\r
6451     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
6452     if(diffFlowCovariances[t][pe][covIndex])\r
6453     {\r
6454      this->SetDiffFlowCovariances(diffFlowCovariances[t][pe][covIndex],t,pe,covIndex);\r
6455     } else \r
6456       {\r
6457        cout<<"WARNING: diffFlowCovariances[t][pe][covIndex] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6458        cout<<"t        = "<<t<<endl;\r
6459        cout<<"pe       = "<<pe<<endl;\r
6460        cout<<"covIndex = "<<covIndex<<endl;\r
6461        exit(0);       \r
6462       } \r
6463    } // end of for(Int_t covIndex=0;covIndex<5;covIndex++) // covariance index    \r
6464   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6465  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI \r
6466  // sum of event weights for reduced correlations:\r
6467  TList *diffFlowSumOfEventWeightsHistList[2][2][2] = {{{NULL}}};\r
6468  TString diffFlowSumOfEventWeightsName = "fDiffFlowSumOfEventWeights";\r
6469  diffFlowSumOfEventWeightsName += fAnalysisLabel->Data();  \r
6470  TH1D *diffFlowSumOfEventWeights[2][2][2][4] = {{{{NULL}}}};\r
6471  for(Int_t t=0;t<2;t++) // type is RP or POI\r
6472  { \r
6473   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6474   { \r
6475    for(Int_t p=0;p<2;p++) // power of event weights is either 1 or 2\r
6476    {\r
6477     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
6478     if(!diffFlowSumOfEventWeightsHistList[t][pe][p])\r
6479     { \r
6480      cout<<"WARNING: diffFlowSumOfEventWeightsHistList[t][pe][p] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6481      cout<<"t     = "<<t<<endl;\r
6482      cout<<"pe    = "<<pe<<endl;\r
6483      cout<<"power = "<<p<<endl;\r
6484      exit(0);\r
6485     }\r
6486     for(Int_t ew=0;ew<4;ew++) // index of reduced correlation\r
6487     {\r
6488      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
6489      if(diffFlowSumOfEventWeights[t][pe][p][ew])\r
6490      {\r
6491       this->SetDiffFlowSumOfEventWeights(diffFlowSumOfEventWeights[t][pe][p][ew],t,pe,p,ew);\r
6492      } else \r
6493        {\r
6494         cout<<"WARNING: diffFlowSumOfEventWeights[t][pe][p][ew] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6495         cout<<"t     = "<<t<<endl;\r
6496         cout<<"pe    = "<<pe<<endl;\r
6497         cout<<"power = "<<p<<endl;\r
6498         cout<<"ew    = "<<ew<<endl;\r
6499         exit(0);       \r
6500        } \r
6501     }\r
6502    } // end of for(Int_t p=0;p<2;p++) // power of event weights is either 1 or 2\r
6503   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6504  } // end of for(Int_t t=0;t<2;t++) // type is RP or POI\r
6505  //  \r
6506  TList *diffFlowSumOfProductOfEventWeightsHistList[2][2] = {{NULL}};\r
6507  TString diffFlowSumOfProductOfEventWeightsName = "fDiffFlowSumOfProductOfEventWeights";\r
6508  diffFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();  \r
6509  TH1D *diffFlowSumOfProductOfEventWeights[2][2][8][8] = {{{{NULL}}}};\r
6510  for(Int_t t=0;t<2;t++) // type is RP or POI\r
6511  { \r
6512   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6513   { \r
6514    diffFlowSumOfProductOfEventWeightsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Sum of products of event weights (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));\r
6515    if(!diffFlowSumOfProductOfEventWeightsHistList[t][pe])\r
6516    { \r
6517     cout<<"WARNING: diffFlowSumOfProductOfEventWeightsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6518     cout<<"t     = "<<t<<endl;\r
6519     cout<<"pe    = "<<pe<<endl;\r
6520     exit(0);\r
6521    }\r
6522    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
6523    {\r
6524     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6525     {\r
6526      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
6527       if(diffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2])\r
6528       {\r
6529        this->SetDiffFlowSumOfProductOfEventWeights(diffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2],t,pe,mci1,mci2);\r
6530       } else \r
6531         {\r
6532          cout<<"WARNING: diffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
6533          cout<<"t    = "<<t<<endl;\r
6534          cout<<"pe   = "<<pe<<endl;\r
6535          cout<<"mci1 = "<<mci1<<endl;\r
6536          cout<<"mci2 = "<<mci2<<endl;\r
6537          exit(0);       \r
6538         } \r
6539      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here\r
6540     } // end of for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6541    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
6542   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6543  } // end of for(Int_t t=0;t<2;t++) // type is RP or POI\r
6544 \r
6545 } // end void AliFlowAnalysisWithQCumulants::GetPointersForDiffFlowHistograms(TList *outputListHistos)\r
6546 \r
6547 \r
6548 //================================================================================================================================\r
6549 \r
6550 \r
6551 void AliFlowAnalysisWithQCumulants::BookEverythingForDifferentialFlow()\r
6552 {\r
6553  // Book all histograms and profiles needed for differential flow.\r
6554  //  a) Define flags locally (to be improved: should I promote flags to data members?);\r
6555  //  b) Book profile to hold all flags for differential flow;\r
6556  //  c) Book e-b-e quantities;\r
6557  //  d) Book profiles;\r
6558  //  e) Book histograms holding final results. \r
6559  \r
6560  // a) Define flags locally (to be improved: should I promote flags to data members?): \r
6561  TString typeFlag[2] = {"RP","POI"}; \r
6562  TString ptEtaFlag[2] = {"p_{T}","#eta"};\r
6563  TString powerFlag[2] = {"linear","quadratic"};\r
6564  TString sinCosFlag[2] = {"sin","cos"};\r
6565  TString differentialCumulantIndex[4] = {"QC{2'}","QC{4'}","QC{6'}","QC{8'}"};  \r
6566  TString differentialFlowIndex[4] = {"v'{2}","v'{4}","v'{6}","v'{8}"};  \r
6567  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"};\r
6568  TString mixedCorrelationIndex[8] = {"<2>","<2'>","<4>","<4'>","<6>","<6'>","<8>","<8'>"};\r
6569  TString covarianceName[5] = {"Cov(<2>,<2'>)","Cov(<2>,<4'>)","Cov(<4>,<2'>)","Cov(<4>,<4'>)","Cov(<2'>,<4'>)"}; \r
6570  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
6571  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
6572  Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
6573   \r
6574  // b) Book profile to hold all flags for differential flow:\r
6575  TString diffFlowFlagsName = "fDiffFlowFlags";\r
6576  diffFlowFlagsName += fAnalysisLabel->Data();\r
6577  fDiffFlowFlags = new TProfile(diffFlowFlagsName.Data(),"Flags for Differential Flow",4,0,4);\r
6578  fDiffFlowFlags->SetTickLength(-0.01,"Y");\r
6579  fDiffFlowFlags->SetMarkerStyle(25);\r
6580  fDiffFlowFlags->SetLabelSize(0.05);\r
6581  fDiffFlowFlags->SetLabelOffset(0.02,"Y");\r
6582  (fDiffFlowFlags->GetXaxis())->SetBinLabel(1,"Particle Weights");\r
6583  (fDiffFlowFlags->GetXaxis())->SetBinLabel(2,"Event Weights");\r
6584  (fDiffFlowFlags->GetXaxis())->SetBinLabel(3,"Corrected for NUA?");\r
6585  (fDiffFlowFlags->GetXaxis())->SetBinLabel(4,"Calculated 2D flow?");\r
6586  fDiffFlowList->Add(fDiffFlowFlags);\r
6587 \r
6588  // c) Book e-b-e quantities:\r
6589  // Event-by-event r_{m*n,k}(pt,eta), p_{m*n,k}(pt,eta) and q_{m*n,k}(pt,eta)\r
6590  // Explanantion of notation:\r
6591  //  1.) n is harmonic, m is multiple of harmonic;\r
6592  //  2.) k is power of particle weight;\r
6593  //  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
6594  //  4.) p_{m*n,k}(pt,eta) = Q-vector evaluated in harmonic m*n for POIs in particular (pt,eta) bin \r
6595  //                          (if i-th POI is also RP, than it is weighted with w_i^k);   \r
6596  //  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
6597  //                          (i-th RP&&POI is weighted with w_i^k)            \r
6598   \r
6599  // 1D:\r
6600  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP && POI )\r
6601  { \r
6602   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6603   {\r
6604    for(Int_t m=0;m<4;m++) // multiple of harmonic\r
6605    {\r
6606     for(Int_t k=0;k<9;k++) // power of particle weight\r
6607     {\r
6608      fReRPQ1dEBE[t][pe][m][k] = new TProfile(Form("TypeFlag%dpteta%dmultiple%dpower%dRe",t,pe,m,k),\r
6609                                              Form("TypeFlag%dpteta%dmultiple%dpower%dRe",t,pe,m,k),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6610      fImRPQ1dEBE[t][pe][m][k] = new TProfile(Form("TypeFlag%dpteta%dmultiple%dpower%dIm",t,pe,m,k),\r
6611                                              Form("TypeFlag%dpteta%dmultiple%dpower%dIm",t,pe,m,k),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6612     }\r
6613    }\r
6614   }\r
6615  } \r
6616  // to be improved (add explanation of fs1dEBE[t][pe][k]):   \r
6617  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP&&POI )\r
6618  { \r
6619   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6620   {\r
6621    for(Int_t k=0;k<9;k++) // power of particle weight\r
6622    {\r
6623     fs1dEBE[t][pe][k] = new TProfile(Form("TypeFlag%dpteta%dmultiple%d",t,pe,k),\r
6624                                      Form("TypeFlag%dpteta%dmultiple%d",t,pe,k),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6625    }\r
6626   }\r
6627  }\r
6628  // correction terms for nua:\r
6629  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)\r
6630  { \r
6631   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6632   {\r
6633    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6634    {\r
6635     for(Int_t cti=0;cti<9;cti++) // correction term index\r
6636     {\r
6637      fDiffFlowCorrectionTermsForNUAEBE[t][pe][sc][cti] = new TH1D(Form("typeFlag%d pteta%d sincos%d cti%d",t,pe,sc,cti),\r
6638                                              Form("typeFlag%d pteta%d sincos%d cti%d",t,pe,sc,cti),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); \r
6639     }\r
6640    }\r
6641   }\r
6642  } \r
6643  // 2D:\r
6644  TProfile2D styleRe("typeMultiplePowerRe","typeMultiplePowerRe",fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);\r
6645  TProfile2D styleIm("typeMultiplePowerIm","typeMultiplePowerIm",fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);\r
6646  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP&&POI )\r
6647  { \r
6648   for(Int_t m=0;m<4;m++)\r
6649   {\r
6650    for(Int_t k=0;k<9;k++)\r
6651    {\r
6652     fReRPQ2dEBE[t][m][k] = (TProfile2D*)styleRe.Clone(Form("typeFlag%dmultiple%dpower%dRe",t,m,k)); \r
6653     fImRPQ2dEBE[t][m][k] = (TProfile2D*)styleIm.Clone(Form("typeFlag%dmultiple%dpower%dIm",t,m,k));\r
6654    }\r
6655   } \r
6656  } \r
6657  TProfile2D styleS("typePower","typePower",fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);\r
6658  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP&&POI )\r
6659  { \r
6660   for(Int_t k=0;k<9;k++)\r
6661   {\r
6662    fs2dEBE[t][k] = (TProfile2D*)styleS.Clone(Form("typeFlag%dpower%d",t,k));\r
6663   }\r
6664  }\r
6665  // reduced correlations e-b-e:\r
6666  TString diffFlowCorrelationsEBEName = "fDiffFlowCorrelationsEBE";\r
6667  diffFlowCorrelationsEBEName += fAnalysisLabel->Data();\r
6668  for(Int_t t=0;t<2;t++) // type: RP or POI\r
6669  { \r
6670   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6671   {\r
6672    for(Int_t rci=0;rci<4;rci++) // reduced correlation index\r
6673    {\r
6674     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
6675    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index\r
6676   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
6677  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
6678  // event weights for reduced correlations e-b-e:\r
6679  TString diffFlowEventWeightsForCorrelationsEBEName = "fDiffFlowEventWeightsForCorrelationsEBE";\r
6680  diffFlowEventWeightsForCorrelationsEBEName += fAnalysisLabel->Data();\r
6681  for(Int_t t=0;t<2;t++) // type: RP or POI\r
6682  { \r
6683   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6684   {\r
6685    for(Int_t rci=0;rci<4;rci++) // event weight for reduced correlation index\r
6686    {\r
6687     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
6688    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index\r
6689   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
6690  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
6691       \r
6692  // d) Book profiles;\r
6693  // reduced correlations:\r
6694  TString diffFlowCorrelationsProName = "fDiffFlowCorrelationsPro";\r
6695  diffFlowCorrelationsProName += fAnalysisLabel->Data();\r
6696  // corrections terms:\r
6697  TString diffFlowCorrectionTermsForNUAProName = "fDiffFlowCorrectionTermsForNUAPro";\r
6698  diffFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();\r
6699  for(Int_t t=0;t<2;t++) // type: RP or POI\r
6700  { \r
6701   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6702   {\r
6703    for(Int_t rci=0;rci<4;rci++) // reduced correlation index\r
6704    {\r
6705     // reduced correlations:\r
6706     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
6707     fDiffFlowCorrelationsPro[t][pe][rci]->SetXTitle(ptEtaFlag[pe].Data());\r
6708     fDiffFlowCorrelationsProList[t][pe]->Add(fDiffFlowCorrelationsPro[t][pe][rci]); // to be improved (add dedicated list to hold reduced correlations)\r
6709    } // end of for(Int_t rci=0;rci<4;rci++) // correlation index\r
6710   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
6711  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
6712  // correction terms for nua:\r
6713  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)\r
6714  { \r
6715   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6716   {\r
6717    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6718    {\r
6719     for(Int_t cti=0;cti<9;cti++) // correction term index\r
6720     {\r
6721      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
6722      fDiffFlowCorrectionsProList[t][pe]->Add(fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti]);\r
6723     }\r
6724    }\r
6725   }\r
6726  } \r
6727  // e) Book histograms holding final results. \r
6728  // reduced correlations:\r
6729  TString diffFlowCorrelationsHistName = "fDiffFlowCorrelationsHist";\r
6730  diffFlowCorrelationsHistName += fAnalysisLabel->Data();\r
6731  // corrections terms:\r
6732  TString diffFlowCorrectionTermsForNUAHistName = "fDiffFlowCorrectionTermsForNUAHist";\r
6733  diffFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();\r
6734  // differential covariances:\r
6735  TString diffFlowCovariancesName = "fDiffFlowCovariances";\r
6736  diffFlowCovariancesName += fAnalysisLabel->Data();\r
6737  // differential Q-cumulants:\r
6738  TString diffFlowCumulantsName = "fDiffFlowCumulants";\r
6739  diffFlowCumulantsName += fAnalysisLabel->Data();\r
6740  // differential flow:\r
6741  TString diffFlowName = "fDiffFlow";\r
6742  diffFlowName += fAnalysisLabel->Data();\r
6743  for(Int_t t=0;t<2;t++) // type: RP or POI\r
6744  { \r
6745   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6746   {\r
6747    for(Int_t index=0;index<4;index++) \r
6748    {\r
6749     // reduced correlations:\r
6750     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
6751     fDiffFlowCorrelationsHist[t][pe][index]->SetXTitle(ptEtaFlag[pe].Data());\r
6752     fDiffFlowCorrelationsHistList[t][pe]->Add(fDiffFlowCorrelationsHist[t][pe][index]); \r
6753     // differential Q-cumulants:\r
6754     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
6755     fDiffFlowCumulants[t][pe][index]->SetXTitle(ptEtaFlag[pe].Data());\r
6756     fDiffFlowCumulantsHistList[t][pe]->Add(fDiffFlowCumulants[t][pe][index]); \r
6757     // differential flow estimates from Q-cumulants:\r
6758     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
6759     fDiffFlow[t][pe][index]->SetXTitle(ptEtaFlag[pe].Data());\r
6760     fDiffFlowHistList[t][pe]->Add(fDiffFlow[t][pe][index]); \r
6761    } // end of for(Int_t index=0;index<4;index++) \r
6762    for(Int_t covIndex=0;covIndex<5;covIndex++) // covariance index \r
6763    {\r
6764     // differential covariances:\r
6765     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
6766     fDiffFlowCovariances[t][pe][covIndex]->SetXTitle(ptEtaFlag[pe].Data());\r
6767     fDiffFlowCovariancesHistList[t][pe]->Add(fDiffFlowCovariances[t][pe][covIndex]); \r
6768    } // end of for(Int_t covIndex=0;covIndex<5;covIndex++) // covariance index\r
6769    // products of both types of correlations: \r
6770    TString diffFlowProductOfCorrelationsProName = "fDiffFlowProductOfCorrelationsPro";\r
6771    diffFlowProductOfCorrelationsProName += fAnalysisLabel->Data();  \r
6772    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
6773    {\r
6774     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6775     {\r
6776      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
6777      fDiffFlowProductOfCorrelationsPro[t][pe][mci1][mci2]->SetXTitle(ptEtaFlag[pe].Data());\r
6778      fDiffFlowProductOfCorrelationsProList[t][pe]->Add(fDiffFlowProductOfCorrelationsPro[t][pe][mci1][mci2]); \r
6779      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here\r
6780     } // end of for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6781    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index    \r
6782   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta \r
6783  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI\r
6784  // sums of event weights for reduced correlations: \r
6785  TString diffFlowSumOfEventWeightsName = "fDiffFlowSumOfEventWeights";\r
6786  diffFlowSumOfEventWeightsName += fAnalysisLabel->Data();  \r
6787  for(Int_t t=0;t<2;t++) // type is RP or POI\r
6788  { \r
6789   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6790   { \r
6791    for(Int_t p=0;p<2;p++) // power of weights is either 1 or 2\r
6792    {\r
6793     for(Int_t ew=0;ew<4;ew++) // index of reduced correlation\r
6794     {\r
6795      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
6796      fDiffFlowSumOfEventWeights[t][pe][p][ew]->SetXTitle(ptEtaFlag[pe].Data());\r
6797      fDiffFlowSumOfEventWeightsHistList[t][pe][p]->Add(fDiffFlowSumOfEventWeights[t][pe][p][ew]); // to be improved (add dedicated list to hold all this)\r
6798     }\r
6799    }\r
6800   }\r
6801  } \r
6802  // sum of products of event weights for both types of correlations: \r
6803  TString diffFlowSumOfProductOfEventWeightsName = "fDiffFlowSumOfProductOfEventWeights";\r
6804  diffFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();  \r
6805  for(Int_t t=0;t<2;t++) // type is RP or POI\r
6806  {\r
6807   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6808   { \r
6809    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index\r
6810    {\r
6811     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index\r
6812     {\r
6813      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
6814      fDiffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2]->SetXTitle(ptEtaFlag[pe].Data());\r
6815      fDiffFlowSumOfProductOfEventWeightsHistList[t][pe]->Add(fDiffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2]); \r
6816      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here\r
6817     }\r
6818    }\r
6819   }\r
6820  } \r
6821  // correction terms for nua:\r
6822  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)\r
6823  { \r
6824   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
6825   {\r
6826    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
6827    {\r
6828     for(Int_t cti=0;cti<9;cti++) // correction term index\r
6829     {\r
6830      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
6831      fDiffFlowCorrectionsHistList[t][pe]->Add(fDiffFlowCorrectionTermsForNUAHist[t][pe][sc][cti]);\r
6832     }\r
6833    }\r
6834   }\r
6835  } \r
6836           \r
6837 } // end of AliFlowAnalysisWithQCumulants::BookEverythingForDifferentialFlow()\r
6838 \r
6839 \r
6840 //================================================================================================================================\r
6841 \r
6842 /*\r
6843 void AliFlowAnalysisWithQCumulants::CalculateCorrectionsForNUAForIntQcumulants() // to be improved (do I really need this method?)\r
6844 {\r
6845  // Calculate final corrections for non-uniform acceptance for Q-cumulants.\r
6846   \r
6847  // Corrections for non-uniform acceptance are stored in histogram fCorrectionsForNUA,\r
6848  // binning of fCorrectionsForNUA is organized as follows:\r
6849  //\r
6850  // 1st bin: correction to QC{2}\r
6851  // 2nd bin: correction to QC{4}\r
6852  // 3rd bin: correction to QC{6}\r
6853  // 4th bin: correction to QC{8}\r
6854   \r
6855  // shortcuts flags:\r
6856  Int_t pW = (Int_t)(useParticleWeights);\r
6857  \r
6858  Int_t eW = -1;\r
6859  \r
6860  if(eventWeights == "exact")\r
6861  {\r
6862   eW = 0;\r
6863  }\r
6864 \r
6865  for(Int_t sc=0;sc<2;sc++) // sin or cos terms flag\r
6866  {\r
6867   if(!(fQCorrelations[pW][eW] && fQCorrections[pW][eW][sc] && fCorrections[pW][eW]))\r
6868   {\r
6869    cout<<"WARNING: fQCorrelations[pW][eW] && fQCorrections[pW][eW][sc] && fCorrections[pW][eW] is NULL in AFAWQC::CFCFNUAFIF() !!!!"<<endl;\r
6870    cout<<"pW = "<<pW<<endl;\r
6871    cout<<"eW = "<<eW<<endl;\r
6872    cout<<"sc = "<<sc<<endl;\r
6873    exit(0);\r
6874   }\r
6875  }  \r
6876 \r
6877  // measured 2-, 4-, 6- and 8-particle azimuthal correlations (biased with non-uniform acceptance!):\r
6878  Double_t two = fQCorrelations[pW][eW]->GetBinContent(1); // <<2>>\r
6879  //Double_t four = fQCorrelations[pW][eW]->GetBinContent(11); // <<4>>\r
6880  //Double_t six = fQCorrelations[pW][eW]->GetBinContent(24); // <<6>>\r
6881  //Double_t eight = fQCorrelations[pW][eW]->GetBinContent(31); // <<8>>\r
6882  \r
6883  // correction terms to QC{2}:\r
6884  // <<cos(n*phi1)>>^2\r
6885  Double_t two1stTerm = pow(fQCorrections[pW][eW][1]->GetBinContent(1),2); \r
6886  // <<sin(n*phi1)>>^2\r
6887  Double_t two2ndTerm = pow(fQCorrections[pW][eW][0]->GetBinContent(1),2); \r
6888  // final corrections for non-uniform acceptance to QC{2}:\r
6889  Double_t correctionQC2 = -1.*two1stTerm-1.*two2ndTerm;\r
6890  fCorrections[pW][eW]->SetBinContent(1,correctionQC2); \r
6891  \r
6892  // correction terms to QC{4}:\r
6893  // <<cos(n*phi1)>> <<cos(n*(phi1-phi2-phi3))>>\r
6894  Double_t four1stTerm = fQCorrections[pW][eW][1]->GetBinContent(1)*fQCorrections[pW][eW][1]->GetBinContent(3);  \r
6895  // <<sin(n*phi1)>> <<sin(n*(phi1-phi2-phi3))>>\r
6896  Double_t four2ndTerm = fQCorrections[pW][eW][0]->GetBinContent(1)*fQCorrections[pW][eW][0]->GetBinContent(3);  \r
6897  // <<cos(n*(phi1+phi2))>>^2\r
6898  Double_t four3rdTerm = pow(fQCorrections[pW][eW][1]->GetBinContent(2),2); \r
6899  // <<sin(n*(phi1+phi2))>>^2\r
6900  Double_t four4thTerm = pow(fQCorrections[pW][eW][0]->GetBinContent(2),2); \r
6901  // <<cos(n*(phi1+phi2))>> (<<cos(n*phi1)>>^2 - <<sin(n*phi1)>>^2)\r
6902  Double_t four5thTerm = fQCorrections[pW][eW][1]->GetBinContent(2)\r
6903                       * (pow(fQCorrections[pW][eW][1]->GetBinContent(1),2)-pow(fQCorrections[pW][eW][0]->GetBinContent(1),2));\r
6904  // <<sin(n*(phi1+phi2))>> <<cos(n*phi1)>> <<sin(n*phi1)>>\r
6905  Double_t four6thTerm = fQCorrections[pW][eW][0]->GetBinContent(2)\r
6906                       * fQCorrections[pW][eW][1]->GetBinContent(1)\r
6907                       * fQCorrections[pW][eW][0]->GetBinContent(1);         \r
6908  // <<cos(n*(phi1-phi2))>> (<<cos(n*phi1)>>^2 + <<sin(n*phi1)>>^2)\r
6909  Double_t four7thTerm = two*(pow(fQCorrections[pW][eW][1]->GetBinContent(1),2)+pow(fQCorrections[pW][eW][0]->GetBinContent(1),2));  \r
6910  // (<<cos(n*phi1)>>^2 + <<sin(n*phi1)>>^2)^2\r
6911  Double_t four8thTerm = pow(pow(fQCorrections[pW][eW][1]->GetBinContent(1),2)+pow(fQCorrections[pW][eW][0]->GetBinContent(1),2),2);      \r
6912  // final correction to QC{4}:\r
6913  Double_t correctionQC4 = -4.*four1stTerm+4.*four2ndTerm-four3rdTerm-four4thTerm\r
6914                         + 4.*four5thTerm+8.*four6thTerm+8.*four7thTerm-6.*four8thTerm;                            \r
6915  fCorrections[pW][eW]->SetBinContent(2,correctionQC4);   \r
6916 \r
6917  // ... to be improved (continued for 6th and 8th order)                                                    \r
6918 \r
6919 \r
6920 } // end of AliFlowAnalysisWithQCumulants::CalculateCorrectionsForNUAForIntQcumulants()\r
6921 */\r
6922 \r
6923 //================================================================================================================================\r
6924 \r
6925 \r
6926 void AliFlowAnalysisWithQCumulants::CalculateQcumulantsCorrectedForNUAIntFlow()\r
6927 {\r
6928  // Calculate generalized Q-cumulants (cumulants corrected for non-unifom acceptance).\r
6929  \r
6930  // measured 2-, 4-, 6- and 8-particle correlations (biased by non-uniform acceptance!):\r
6931  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>\r
6932  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>\r
6933  //Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>>\r
6934  //Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>\r
6935  \r
6936  // statistical error of measured 2-, 4-, 6- and 8-particle correlations:\r
6937  //Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1); // statistical error of <<2>>\r
6938  //Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2); // statistical error of <<4>>\r
6939  //Double_t sixError = fIntFlowCorrelationsHist->GetBinError(3); // statistical error of <<6>>\r
6940  //Double_t eightError = fIntFlowCorrelationsHist->GetBinError(4); // statistical error of <<8>>\r
6941 \r
6942  // QC{2}:\r
6943  // <<cos(n*phi1)>>^2\r
6944  Double_t two1stTerm = pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1),2); \r
6945  //Double_t two1stTermErrorSquared = pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinError(1),2); \r
6946  // <<sin(n*phi1)>>^2\r
6947  Double_t two2ndTerm = pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1),2); \r
6948  //Double_t two2ndTermErrorSquared = pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinError(1),2); \r
6949  // generalized QC{2}:\r
6950  Double_t gQC2 = two - two1stTerm - two2ndTerm; // to be improved (terminology, notation)\r
6951  fIntFlowQcumulants->SetBinContent(1,gQC2); \r
6952  //fIntFlowQcumulants->SetBinError(1,0.); // to be improved (propagate error) \r
6953  \r
6954  // QC{4}:\r
6955  // <<cos(n*phi1)>> <<cos(n*(phi1-phi2-phi3))>>\r
6956  Double_t four1stTerm = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1)\r
6957                       * fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(3);  \r
6958  // <<sin(n*phi1)>> <<sin(n*(phi1-phi2-phi3))>>\r
6959  Double_t four2ndTerm = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1)\r
6960                       * fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(3);  \r
6961  // <<cos(n*(phi1+phi2))>>^2\r
6962  Double_t four3rdTerm = pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(2),2); \r
6963  // <<sin(n*(phi1+phi2))>>^2\r
6964  Double_t four4thTerm = pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(2),2); \r
6965  // <<cos(n*(phi1+phi2))>> (<<cos(n*phi1)>>^2 - <<sin(n*phi1)>>^2)\r
6966  Double_t four5thTerm = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(2)\r
6967                       * (pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1),2)\r
6968                       - pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1),2));\r
6969  // <<sin(n*(phi1+phi2))>> <<cos(n*phi1)>> <<sin(n*phi1)>>\r
6970  Double_t four6thTerm = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(2)\r
6971                       * fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1)\r
6972                       * fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1);         \r
6973  // <<cos(n*(phi1-phi2))>> (<<cos(n*phi1)>>^2 + <<sin(n*phi1)>>^2)\r
6974  Double_t four7thTerm = two*(pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1),2)\r
6975                       + pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1),2));  \r
6976  // (<<cos(n*phi1)>>^2 + <<sin(n*phi1)>>^2)^2\r
6977  Double_t four8thTerm = pow(pow(fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1),2)\r
6978                       + pow(fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1),2),2);      \r
6979  // generalized QC{4}:\r
6980  Double_t gQC4 = four-2.*pow(two,2.)-4.*four1stTerm+4.*four2ndTerm-four3rdTerm\r
6981                - four4thTerm+4.*four5thTerm+8.*four6thTerm+8.*four7thTerm-6.*four8thTerm;                            \r
6982  fIntFlowQcumulants->SetBinContent(2,gQC4);   \r
6983  //fIntFlowQcumulants->SetBinError(2,0.); // to be improved (propagate error) \r
6984 \r
6985  // ... to be improved (continued for 6th and 8th order)                                                    \r
6986     \r
6987 } // end of void AliFlowAnalysisWithQCumulants::CalculateQcumulantsCorrectedForNUAIntFlow()\r
6988 \r
6989 \r
6990 //================================================================================================================================\r
6991 \r
6992 \r
6993 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectedForNUA()\r
6994 {\r
6995  // Calculate integrated flow from generalized Q-cumulants (corrected for non-uniform acceptance).\r
6996  \r
6997  // to be improved: add protection for NULL pointers, propagate statistical errors from \r
6998  // measured correlations and correction terms\r
6999  \r
7000  // generalized Q-cumulants:\r
7001  Double_t qc2 = fIntFlowQcumulants->GetBinContent(1); // QC{2}  \r
7002  Double_t qc4 = fIntFlowQcumulants->GetBinContent(2); // QC{4}  \r
7003  //Double_t qc6 = fIntFlowQcumulants->GetBinContent(3); // QC{6}  \r
7004  //Double_t qc8 = fIntFlowQcumulants->GetBinContent(4); // QC{8}\r
7005  \r
7006  // integrated flow estimates:\r
7007  Double_t v2 = 0.; // v{2,QC}  \r
7008  Double_t v4 = 0.; // v{4,QC}  \r
7009  //Double_t v6 = 0.; // v{6,QC}  \r
7010  //Double_t v8 = 0.; // v{8,QC}\r
7011 \r
7012  // calculate integrated flow estimates from generalized Q-cumulants: \r
7013  if(qc2>=0.) v2 = pow(qc2,1./2.); \r
7014  if(qc4<=0.) v4 = pow(-1.*qc4,1./4.); \r
7015  //if(qc6>=0.) v6 = pow((1./4.)*qc6,1./6.); \r
7016  //if(qc8<=0.) v8 = pow((-1./33.)*qc8,1./8.); \r
7017 \r
7018  // store integrated flow estimates from generalized Q-cumulants:\r
7019  fIntFlow->SetBinContent(1,v2);\r
7020  fIntFlow->SetBinContent(2,v4);\r
7021  //fIntFlow->SetBinContent(3,v6);\r
7022  //fIntFlow->SetBinContent(4,v8);\r
7023 \r
7024 } // end of void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectedForNUA()\r
7025 \r
7026    \r
7027 //================================================================================================================================\r
7028 \r
7029 \r
7030 void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUAIntFlow() \r
7031 {\r
7032  // From profile fIntFlowCorrectionTermsForNUAPro[2] access measured corretion terms\r
7033  // and their spread, correctly calculate the statistical errors and store the final \r
7034  // results and statistical errors for correction terms in histogram fIntFlowCorrectionTermsForNUAHist[2].\r
7035  //\r
7036  // Remark: Statistical error of correction temrs is calculated as:\r
7037  //\r
7038  //          statistical error = termA * spread * termB:\r
7039  //          termA = sqrt{sum_{i=1}^{N} w^2}/(sum_{i=1}^{N} w)\r
7040  //          termB = 1/sqrt(1-termA^2)   \r
7041  \r
7042  /* // to be improved (implement protection here)\r
7043  for(Int_t power=0;power<2;power++)\r
7044  { \r
7045   if(!(fIntFlowCorrelationsHist && fIntFlowCorrelationsPro && fIntFlowSumOfEventWeights[power])) \r
7046   {\r
7047    cout<<"WARNING: fIntFlowCorrelationsHist && fIntFlowCorrelationsPro && fIntFlowSumOfEventWeights[power] is NULL in AFAWQC::FCIF() !!!!"<<endl;\r
7048    cout<<"power = "<<power<<endl;\r
7049    exit(0);\r
7050   }\r
7051  }\r
7052  */\r
7053   \r
7054  for(Int_t sc=0;sc<2;sc++) // sin or cos correction terms \r
7055  {\r
7056   for(Int_t ci=1;ci<=10;ci++) // correction term index\r
7057   {\r
7058    Double_t correction = fIntFlowCorrectionTermsForNUAPro[sc]->GetBinContent(ci);\r
7059    //Double_t spread = fIntFlowCorrectionTermsForNUAPro[sc]->GetBinError(ci);\r
7060    //Double_t sumOfLinearEventWeights = fIntFlowSumOfEventWeights[0]->GetBinContent(ci);\r
7061    //Double_t sumOfQuadraticEventWeights = fIntFlowSumOfEventWeights[1]->GetBinContent(ci);\r
7062    //Double_t termA = 0.;\r
7063    //Double_t termB = 0.;\r
7064    //if(sumOfLinearEventWeights)\r
7065    //{\r
7066    // termA = pow(sumOfQuadraticEventWeights,0.5)/sumOfLinearEventWeights;\r
7067    //} else\r
7068    // {\r
7069    //  cout<<"WARNING: sumOfLinearEventWeights == 0 in AFAWQC::FCIF() !!!!"<<endl;\r
7070    //  cout<<"         (for "<<2*ci<<"-particle correlation)"<<endl;\r
7071    // }\r
7072    /*\r
7073    if(1.-pow(termA,2.) > 0.)\r
7074    {\r
7075     termB = 1./pow(1-pow(termA,2.),0.5);\r
7076    } else\r
7077      {\r
7078       cout<<"WARNING: 1.-pow(termA,2.) <= 0 in AFAWQC::FCIF() !!!!"<<endl;   \r
7079       cout<<"         (for "<<2*ci<<"-particle correlation)"<<endl;\r
7080      }     \r
7081    Double_t statisticalError = termA * spread * termB;\r
7082    */\r
7083    fIntFlowCorrectionTermsForNUAHist[sc]->SetBinContent(ci,correction);\r
7084    //fIntFlowCorrectionTermsForNUAHist[sc]->SetBinError(ci,statisticalError);\r
7085   } // end of for(Int_t ci=1;ci<=10;ci++) // correction term index\r
7086  } // end of for(Int sc=0;sc<2;sc++) // sin or cos correction terms \r
7087                                                                                                                                                                                                \r
7088 } // end of void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUAIntFlow()\r
7089 \r
7090 \r
7091 //================================================================================================================================\r
7092 \r
7093 \r
7094 void AliFlowAnalysisWithQCumulants::GetPointersForNestedLoopsHistograms(TList *outputListHistos)\r
7095 {\r
7096  // Get pointers to all objects relevant for calculations with nested loops.\r
7097    \r
7098  if(outputListHistos)\r
7099  {\r
7100   TList *nestedLoopsList = dynamic_cast<TList*>(outputListHistos->FindObject("Nested Loops"));\r
7101   if(nestedLoopsList) \r
7102   {\r
7103    this->SetNestedLoopsList(nestedLoopsList);\r
7104   } else\r
7105     {\r
7106      cout<<"WARNING: nestedLoopsList is NULL in AFAWQC::GPFNLH() !!!!"<<endl;\r
7107      exit(0);\r
7108     }\r
7109     \r
7110   TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data members?)\r
7111   TString typeFlag[2] = {"RP","POI"}; // to be improved (should I promote this to data members?)\r
7112   TString ptEtaFlag[2] = {"p_{T}","#eta"}; // to be improved (should I promote this to data members?)\r
7113   TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"}; // to be improved (should I promote this to data members?)\r
7114    \r
7115   TString evaluateNestedLoopsName = "fEvaluateNestedLoops";\r
7116   evaluateNestedLoopsName += fAnalysisLabel->Data();  \r
7117   TProfile *evaluateNestedLoops = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(evaluateNestedLoopsName.Data()));\r
7118   Bool_t bEvaluateIntFlowNestedLoops = kFALSE;\r
7119   Bool_t bEvaluateDiffFlowNestedLoops = kFALSE;\r
7120   if(evaluateNestedLoops)\r
7121   {\r
7122    this->SetEvaluateNestedLoops(evaluateNestedLoops);\r
7123    bEvaluateIntFlowNestedLoops = (Int_t)evaluateNestedLoops->GetBinContent(1);\r
7124    bEvaluateDiffFlowNestedLoops = (Int_t)evaluateNestedLoops->GetBinContent(2);\r
7125   }\r
7126   // nested loops relevant for integrated flow:  \r
7127   if(bEvaluateIntFlowNestedLoops)\r
7128   {\r
7129    // correlations:\r
7130    TString intFlowDirectCorrelationsName = "fIntFlowDirectCorrelations";\r
7131    intFlowDirectCorrelationsName += fAnalysisLabel->Data();\r
7132    TProfile *intFlowDirectCorrelations = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(intFlowDirectCorrelationsName.Data()));\r
7133    if(intFlowDirectCorrelations) \r
7134    { \r
7135     this->SetIntFlowDirectCorrelations(intFlowDirectCorrelations);\r
7136    } else\r
7137      {\r
7138       cout<<"WARNING: intFlowDirectCorrelations is NULL in AFAWQC::GPFNLH() !!!!"<<endl;\r
7139       exit(0);\r
7140      }\r
7141    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)  \r
7142    {\r
7143     TString intFlowExtraDirectCorrelationsName = "fIntFlowExtraDirectCorrelations";\r
7144     intFlowExtraDirectCorrelationsName += fAnalysisLabel->Data();\r
7145     TProfile *intFlowExtraDirectCorrelations = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(intFlowExtraDirectCorrelationsName.Data()));\r
7146     if(intFlowExtraDirectCorrelations) \r
7147     { \r
7148      this->SetIntFlowExtraDirectCorrelations(intFlowExtraDirectCorrelations);\r
7149     } else\r
7150       {\r
7151        cout<<"WARNING: intFlowExtraDirectCorrelations is NULL in AFAWQC::GPFNLH() !!!!"<<endl;\r
7152        exit(0);\r
7153       }       \r
7154    } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)  \r
7155    // correction terms for non-uniform acceptance:\r
7156    TString intFlowDirectCorrectionTermsForNUAName = "fIntFlowDirectCorrectionTermsForNUA";\r
7157    intFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();\r
7158    TProfile *intFlowDirectCorrectionTermsForNUA[2] = {NULL};\r
7159    for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
7160    {\r
7161     intFlowDirectCorrectionTermsForNUA[sc] = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(Form("%s: %s terms",intFlowDirectCorrectionTermsForNUAName.Data(),sinCosFlag[sc].Data())));\r
7162     if(intFlowDirectCorrectionTermsForNUA[sc]) \r
7163     { \r
7164      this->SetIntFlowDirectCorrectionTermsForNUA(intFlowDirectCorrectionTermsForNUA[sc],sc);\r
7165     } else\r
7166       {\r
7167        cout<<"WARNING: intFlowDirectCorrectionTermsForNUA[sc] is NULL in AFAWQC::GPFNLH() !!!!"<<endl;\r
7168        cout<<"sc = "<<sc<<endl;\r
7169        exit(0);\r
7170       }\r
7171    } // end of for(Int_t sc=0;sc<2;sc++) \r
7172   } // end of if(bEvaluateIntFlowNestedLoops)\r
7173     \r
7174   // nested loops relevant for differential flow:  \r
7175   if(bEvaluateDiffFlowNestedLoops)\r
7176   {\r
7177    // correlations:\r
7178    TString diffFlowDirectCorrelationsName = "fDiffFlowDirectCorrelations";\r
7179    diffFlowDirectCorrelationsName += fAnalysisLabel->Data();\r
7180    TProfile *diffFlowDirectCorrelations[2][2][4] = {{{NULL}}};\r
7181    for(Int_t t=0;t<2;t++)\r
7182    {\r
7183     for(Int_t pe=0;pe<2;pe++)\r
7184     {\r
7185      for(Int_t ci=0;ci<4;ci++) // correlation index\r
7186      {\r
7187       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
7188       if(diffFlowDirectCorrelations[t][pe][ci])\r
7189       {\r
7190        this->SetDiffFlowDirectCorrelations(diffFlowDirectCorrelations[t][pe][ci],t,pe,ci);\r
7191       } else\r
7192         {\r
7193          cout<<"WARNING: diffFlowDirectCorrelations[t][pe][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
7194          cout<<"t  = "<<t<<endl;\r
7195          cout<<"pe = "<<pe<<endl;   \r
7196          cout<<"ci = "<<ci<<endl;\r
7197         }     \r
7198      } // end of for(Int_t ci=0;ci<4;ci++) // correlation index  \r
7199     } // end of for(Int_t pe=0;pe<2;pe++)\r
7200    } // end of for(Int_t t=0;t<2;t++)   \r
7201    // correction terms for non-uniform acceptance:\r
7202    TString diffFlowDirectCorrectionTermsForNUAName = "fDiffFlowDirectCorrectionTermsForNUA";\r
7203    diffFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();  \r
7204    TProfile *diffFlowDirectCorrectionTermsForNUA[2][2][2][10] = {{{{NULL}}}};   \r
7205    for(Int_t t=0;t<2;t++)\r
7206    {\r
7207     for(Int_t pe=0;pe<2;pe++)\r
7208     {\r
7209      // correction terms for NUA:\r
7210      for(Int_t sc=0;sc<2;sc++) // sin or cos\r
7211      {\r
7212       for(Int_t cti=0;cti<9;cti++) // correction term index\r
7213       {\r
7214        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
7215        if(diffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti])\r
7216        {\r
7217         this->SetDiffFlowDirectCorrectionTermsForNUA(diffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti],t,pe,sc,cti);\r
7218        } else\r
7219          {\r
7220           cout<<"WARNING: diffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;\r
7221           cout<<"t   = "<<t<<endl;\r
7222           cout<<"pe  = "<<pe<<endl;   \r
7223           cout<<"sc  = "<<sc<<endl;\r
7224           cout<<"cti = "<<cti<<endl;\r
7225          }    \r
7226       } // end of for(Int_t cti=0;cti<9;cti++) // correction term index\r
7227      } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos\r
7228     } // end of for(Int_t pe=0;pe<2;pe++)\r
7229    } // end of for(Int_t t=0;t<2;t++)\r
7230   } // end of if(bEvaluateDiffFlowNestedLoops)\r
7231  } else // to if(outputListHistos)\r
7232    {\r
7233     cout<<"WARNING: outputListHistos is NULL in AFAWQC::GPFNLH() !!!!"<<endl;\r
7234     exit(0);\r
7235    }\r
7236 \r
7237 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForNestedLoopsHistograms(TList *outputListHistos)\r
7238 \r
7239 \r
7240 //================================================================================================================================\r
7241 \r
7242 \r
7243 void AliFlowAnalysisWithQCumulants::StoreHarmonic()\r
7244 {\r
7245  // Store flow harmonic in common control histograms.\r
7246 \r
7247  (fCommonHists->GetHarmonic())->Fill(0.5,fHarmonic);\r
7248  (fCommonHists2nd->GetHarmonic())->Fill(0.5,fHarmonic);\r
7249  (fCommonHists4th->GetHarmonic())->Fill(0.5,fHarmonic);\r
7250  (fCommonHists6th->GetHarmonic())->Fill(0.5,fHarmonic);\r
7251  (fCommonHists8th->GetHarmonic())->Fill(0.5,fHarmonic);\r
7252 \r
7253 } // end of void AliFlowAnalysisWithQCumulants::StoreHarmonic()\r
7254 \r
7255 \r
7256 //================================================================================================================================\r
7257 \r
7258 \r
7259 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelationsUsingParticleWeights(TString type, TString ptOrEta) // type = RP or POI \r
7260 {\r
7261  // Calculate all correlations needed for differential flow using particle weights.\r
7262  \r
7263  Int_t t = -1; // type flag \r
7264  Int_t pe = -1; // ptEta flag\r
7265  \r
7266  if(type == "RP")\r
7267  {\r
7268   t = 0;\r
7269  } else if(type == "POI")\r
7270    {\r
7271     t = 1;\r
7272    }\r
7273 \r
7274  if(ptOrEta == "Pt")\r
7275  {\r
7276   pe = 0;\r
7277  } else if(ptOrEta == "Eta")\r
7278    {\r
7279     pe = 1;\r
7280    }\r
7281     \r
7282  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
7283  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
7284  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
7285  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
7286 \r
7287  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
7288  Double_t dReQ1n1k = (*fReQ)(0,1);\r
7289  Double_t dReQ2n2k = (*fReQ)(1,2);\r
7290  Double_t dReQ1n3k = (*fReQ)(0,3);\r
7291  //Double_t dReQ4n4k = (*fReQ)(3,4);\r
7292  Double_t dImQ1n1k = (*fImQ)(0,1);\r
7293  Double_t dImQ2n2k = (*fImQ)(1,2);\r
7294  Double_t dImQ1n3k = (*fImQ)(0,3);\r
7295  //Double_t dImQ4n4k = (*fImQ)(3,4);\r
7296  \r
7297  // S^M_{p,k} (see .h file for the definition of fSMpk):\r
7298  Double_t dSM1p1k = (*fSMpk)(0,1);\r
7299  Double_t dSM1p2k = (*fSMpk)(0,2);\r
7300  Double_t dSM1p3k = (*fSMpk)(0,3);\r
7301  Double_t dSM2p1k = (*fSMpk)(1,1);\r
7302  Double_t dSM3p1k = (*fSMpk)(2,1);\r
7303  \r
7304  // looping over all bins and calculating reduced correlations: \r
7305  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7306  {\r
7307   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular (pt,eta) bin):  \r
7308   Double_t p1n0kRe = 0.;\r
7309   Double_t p1n0kIm = 0.;\r
7310 \r
7311   // number of POIs in particular (pt,eta) bin):\r
7312   Double_t mp = 0.;\r
7313 \r
7314   // real and imaginary parts of q_{m*n,k}: \r
7315   // (weighted Q-vector evaluated for particles which are both RPs and POIs in particular (pt,eta) bin)\r
7316   Double_t q1n2kRe = 0.;\r
7317   Double_t q1n2kIm = 0.;\r
7318   Double_t q2n1kRe = 0.;\r
7319   Double_t q2n1kIm = 0.;\r
7320 \r
7321   // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
7322   Double_t s1p1k = 0.; \r
7323   Double_t s1p2k = 0.; \r
7324   Double_t s1p3k = 0.; \r
7325    \r
7326   // M0111 from Eq. (118) in QC2c (to be improved (notation))\r
7327   Double_t dM0111 = 0.;\r
7328  \r
7329   if(type == "POI")\r
7330   {\r
7331    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))\r
7332            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7333    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  \r
7334            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7335             \r
7336    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
7337     \r
7338    t = 1; // typeFlag = RP or POI\r
7339     \r
7340    // q_{m*n,k}: (Remark: m=1 is 0, k=0 iz zero (to be improved!)) \r
7341    q1n2kRe = fReRPQ1dEBE[2][pe][0][2]->GetBinContent(fReRPQ1dEBE[2][pe][0][2]->GetBin(b))\r
7342            * fReRPQ1dEBE[2][pe][0][2]->GetBinEntries(fReRPQ1dEBE[2][pe][0][2]->GetBin(b));\r
7343    q1n2kIm = fImRPQ1dEBE[2][pe][0][2]->GetBinContent(fImRPQ1dEBE[2][pe][0][2]->GetBin(b))\r
7344            * fImRPQ1dEBE[2][pe][0][2]->GetBinEntries(fImRPQ1dEBE[2][pe][0][2]->GetBin(b));\r
7345    q2n1kRe = fReRPQ1dEBE[2][pe][1][1]->GetBinContent(fReRPQ1dEBE[2][pe][1][1]->GetBin(b))\r
7346            * fReRPQ1dEBE[2][pe][1][1]->GetBinEntries(fReRPQ1dEBE[2][pe][1][1]->GetBin(b));\r
7347    q2n1kIm = fImRPQ1dEBE[2][pe][1][1]->GetBinContent(fImRPQ1dEBE[2][pe][1][1]->GetBin(b))\r
7348            * fImRPQ1dEBE[2][pe][1][1]->GetBinEntries(fImRPQ1dEBE[2][pe][1][1]->GetBin(b));\r
7349        \r
7350    // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
7351    s1p1k = pow(fs1dEBE[2][pe][1]->GetBinContent(b)*fs1dEBE[2][pe][1]->GetBinEntries(b),1.); \r
7352    s1p2k = pow(fs1dEBE[2][pe][2]->GetBinContent(b)*fs1dEBE[2][pe][2]->GetBinEntries(b),1.); \r
7353    s1p3k = pow(fs1dEBE[2][pe][3]->GetBinContent(b)*fs1dEBE[2][pe][3]->GetBinEntries(b),1.); \r
7354      \r
7355    // M0111 from Eq. (118) in QC2c (to be improved (notation)):\r
7356    dM0111 = mp*(dSM3p1k-3.*dSM1p1k*dSM1p2k+2.*dSM1p3k)\r
7357           - 3.*(s1p1k*(dSM2p1k-dSM1p2k)\r
7358           + 2.*(s1p3k-s1p2k*dSM1p1k));\r
7359   }\r
7360    else if(type == "RP")\r
7361    {\r
7362     // q_{m*n,k}: (Remark: m=1 is 0, k=0 iz zero (to be improved!)) \r
7363     q1n2kRe = fReRPQ1dEBE[0][pe][0][2]->GetBinContent(fReRPQ1dEBE[0][pe][0][2]->GetBin(b))\r
7364             * fReRPQ1dEBE[0][pe][0][2]->GetBinEntries(fReRPQ1dEBE[0][pe][0][2]->GetBin(b));\r
7365     q1n2kIm = fImRPQ1dEBE[0][pe][0][2]->GetBinContent(fImRPQ1dEBE[0][pe][0][2]->GetBin(b))\r
7366             * fImRPQ1dEBE[0][pe][0][2]->GetBinEntries(fImRPQ1dEBE[0][pe][0][2]->GetBin(b));\r
7367     q2n1kRe = fReRPQ1dEBE[0][pe][1][1]->GetBinContent(fReRPQ1dEBE[0][pe][1][1]->GetBin(b))\r
7368             * fReRPQ1dEBE[0][pe][1][1]->GetBinEntries(fReRPQ1dEBE[0][pe][1][1]->GetBin(b));\r
7369     q2n1kIm = fImRPQ1dEBE[0][pe][1][1]->GetBinContent(fImRPQ1dEBE[0][pe][1][1]->GetBin(b))\r
7370             * fImRPQ1dEBE[0][pe][1][1]->GetBinEntries(fImRPQ1dEBE[0][pe][1][1]->GetBin(b));\r
7371 \r
7372     // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  \r
7373     s1p1k = pow(fs1dEBE[0][pe][1]->GetBinContent(b)*fs1dEBE[0][pe][1]->GetBinEntries(b),1.); \r
7374     s1p2k = pow(fs1dEBE[0][pe][2]->GetBinContent(b)*fs1dEBE[0][pe][2]->GetBinEntries(b),1.); \r
7375     s1p3k = pow(fs1dEBE[0][pe][3]->GetBinContent(b)*fs1dEBE[0][pe][3]->GetBinEntries(b),1.); \r
7376     \r
7377     // to be improved (cross-checked):\r
7378     p1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
7379             * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7380     p1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))  \r
7381             * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7382             \r
7383     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
7384      \r
7385     t = 0; // typeFlag = RP or POI\r
7386     \r
7387     // M0111 from Eq. (118) in QC2c (to be improved (notation)):\r
7388     dM0111 = mp*(dSM3p1k-3.*dSM1p1k*dSM1p2k+2.*dSM1p3k)\r
7389            - 3.*(s1p1k*(dSM2p1k-dSM1p2k)\r
7390            + 2.*(s1p3k-s1p2k*dSM1p1k));\r
7391     //...............................................................................................   \r
7392    }\r
7393    \r
7394    // 2'-particle correlation:\r
7395    Double_t two1n1nW0W1 = 0.;\r
7396    if(mp*dSM1p1k-s1p1k)\r
7397    {\r
7398     two1n1nW0W1 = (p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k-s1p1k)\r
7399                 / (mp*dSM1p1k-s1p1k);\r
7400    \r
7401     // fill profile to get <<2'>>     \r
7402     fDiffFlowCorrelationsPro[t][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nW0W1,mp*dSM1p1k-s1p1k);\r
7403     // histogram to store <2'> e-b-e (needed in some other methods):\r
7404     fDiffFlowCorrelationsEBE[t][pe][0]->SetBinContent(b,two1n1nW0W1);      \r
7405     fDiffFlowEventWeightsForCorrelationsEBE[t][pe][0]->SetBinContent(b,mp*dSM1p1k-s1p1k);      \r
7406    } // end of if(mp*dSM1p1k-s1p1k)\r
7407    \r
7408    // 4'-particle correlation:\r
7409    Double_t four1n1n1n1nW0W1W1W1 = 0.;\r
7410    if(dM0111)\r
7411    {\r
7412     four1n1n1n1nW0W1W1W1 = ((pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.))*(p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k)\r
7413                          - q2n1kRe*(pow(dReQ1n1k,2.)-pow(dImQ1n1k,2.))\r
7414                          - 2.*q2n1kIm*dReQ1n1k*dImQ1n1k\r
7415                          - p1n0kRe*(dReQ1n1k*dReQ2n2k+dImQ1n1k*dImQ2n2k)\r
7416                          + p1n0kIm*(dImQ1n1k*dReQ2n2k-dReQ1n1k*dImQ2n2k)\r
7417                          - 2.*dSM1p2k*(p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k)\r
7418                          - 2.*(pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.))*s1p1k                                            \r
7419                          + 6.*(q1n2kRe*dReQ1n1k+q1n2kIm*dImQ1n1k)                                           \r
7420                          + 1.*(q2n1kRe*dReQ2n2k+q2n1kIm*dImQ2n2k)                         \r
7421                          + 2.*(p1n0kRe*dReQ1n3k+p1n0kIm*dImQ1n3k)                      \r
7422                          + 2.*s1p1k*dSM1p2k                                      \r
7423                          - 6.*s1p3k)        \r
7424                          / dM0111; // to be improved (notation of dM0111)\r
7425    \r
7426     // fill profile to get <<4'>>     \r
7427     fDiffFlowCorrelationsPro[t][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nW0W1W1W1,dM0111);\r
7428     // histogram to store <4'> e-b-e (needed in some other methods):\r
7429     fDiffFlowCorrelationsEBE[t][pe][1]->SetBinContent(b,four1n1n1n1nW0W1W1W1);      \r
7430     fDiffFlowEventWeightsForCorrelationsEBE[t][pe][1]->SetBinContent(b,dM0111);      \r
7431    } // end of if(dM0111)\r
7432  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7433 \r
7434 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelationsUsingParticleWeights(TString type, TString ptOrEta); // type = RP or POI \r
7435 \r
7436 \r
7437 //================================================================================================================================\r
7438 \r
7439 \r
7440 void AliFlowAnalysisWithQCumulants::FillCommonControlHistograms(AliFlowEventSimple *anEvent)\r
7441 {\r
7442  // Fill common control histograms.\r
7443  \r
7444  Int_t nRP = anEvent->GetEventNSelTracksRP(); // number of RPs (i.e. number of particles used to determine the reaction plane)\r
7445  fCommonHists->FillControlHistograms(anEvent); \r
7446  if(nRP>1)\r
7447  {\r
7448   fCommonHists2nd->FillControlHistograms(anEvent);                                        \r
7449   if(nRP>3)\r
7450   {\r
7451    fCommonHists4th->FillControlHistograms(anEvent);                                        \r
7452    if(nRP>5)\r
7453    {\r
7454     fCommonHists6th->FillControlHistograms(anEvent);                                        \r
7455     if(nRP>7)\r
7456     {\r
7457      fCommonHists8th->FillControlHistograms(anEvent);                                        \r
7458     } // end of if(nRP>7)  \r
7459    } // end of if(nRP>5) \r
7460   } // end of if(nRP>3)                                                                                                                      \r
7461  } // end of if(nRP>1) \r
7462  \r
7463 } // end of void AliFlowAnalysisWithQCumulants::FillCommonControlHistograms(AliFlowEventSimple *anEvent)\r
7464 \r
7465 \r
7466 //================================================================================================================================\r
7467 \r
7468 \r
7469 void AliFlowAnalysisWithQCumulants::ResetEventByEventQuantities()\r
7470 {\r
7471  // Reset all event by event quantities.\r
7472  \r
7473  // integrated flow:\r
7474  fReQ->Zero();\r
7475  fImQ->Zero();\r
7476  fSMpk->Zero();\r
7477  fIntFlowCorrelationsEBE->Reset();\r
7478  fIntFlowEventWeightsForCorrelationsEBE->Reset();\r
7479  fIntFlowCorrelationsAllEBE->Reset();\r
7480  \r
7481  if(fApplyCorrectionForNUA)  \r
7482  {\r
7483   for(Int_t sc=0;sc<2;sc++)\r
7484   {\r
7485    fIntFlowCorrectionTermsForNUAEBE[sc]->Reset();\r
7486   } \r
7487  }\r
7488     \r
7489  // differential flow:\r
7490  // 1D:\r
7491  for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)\r
7492  {\r
7493   for(Int_t pe=0;pe<2;pe++) // 1D in pt or eta\r
7494   {\r
7495    for(Int_t m=0;m<4;m++) // multiple of harmonic\r
7496    {\r
7497     for(Int_t k=0;k<9;k++) // power of weight\r
7498     {\r
7499      if(fReRPQ1dEBE[t][pe][m][k]) fReRPQ1dEBE[t][pe][m][k]->Reset();\r
7500      if(fImRPQ1dEBE[t][pe][m][k]) fImRPQ1dEBE[t][pe][m][k]->Reset();\r
7501     }   \r
7502    }\r
7503   }\r
7504  }\r
7505   \r
7506  for(Int_t t=0;t<3;t++) // type (0 = RP, 1 = POI, 2 = RP&&POI )\r
7507  { \r
7508   for(Int_t pe=0;pe<2;pe++) // 1D in pt or eta\r
7509   {\r
7510    for(Int_t k=0;k<9;k++)\r
7511    {\r
7512     if(fs1dEBE[t][pe][k]) fs1dEBE[t][pe][k]->Reset();\r
7513    }\r
7514   }\r
7515  }\r
7516 \r
7517  // e-b-e reduced correlations:\r
7518  for(Int_t t=0;t<2;t++) // type (0 = RP, 1 = POI)\r
7519  {  \r
7520   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
7521   {\r
7522    for(Int_t rci=0;rci<4;rci++) // reduced correlation index\r
7523    {\r
7524     if(fDiffFlowCorrelationsEBE[t][pe][rci]) fDiffFlowCorrelationsEBE[t][pe][rci]->Reset();\r
7525     if(fDiffFlowEventWeightsForCorrelationsEBE[t][pe][rci]) fDiffFlowEventWeightsForCorrelationsEBE[t][pe][rci]->Reset();\r
7526    }\r
7527   }\r
7528  }\r
7529     \r
7530  // correction terms for NUA:\r
7531  for(Int_t t=0;t<2;t++) // type (0 = RP, 1 = POI)\r
7532  {  \r
7533   for(Int_t pe=0;pe<2;pe++) // pt or eta\r
7534   {\r
7535    for(Int_t sc=0;sc<2;sc++) // sin or cos\r
7536    {\r
7537     for(Int_t cti=0;cti<9;cti++) // correction term index\r
7538     {\r
7539      fDiffFlowCorrectionTermsForNUAEBE[t][pe][sc][cti]->Reset();  \r
7540     }\r
7541    }\r
7542   }      \r
7543  }\r
7544     \r
7545  // 2D (pt,eta)\r
7546  if(fCalculate2DFlow)\r
7547  {\r
7548   for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)\r
7549   {\r
7550    for(Int_t m=0;m<4;m++) // multiple of harmonic\r
7551    {\r
7552     for(Int_t k=0;k<9;k++) // power of weight\r
7553     {\r
7554      if(fReRPQ2dEBE[t][m][k]) fReRPQ2dEBE[t][m][k]->Reset();\r
7555      if(fImRPQ2dEBE[t][m][k]) fImRPQ2dEBE[t][m][k]->Reset();\r
7556     }   \r
7557    }\r
7558   }\r
7559   for(Int_t t=0;t<3;t++) // type (0 = RP, 1 = POI, 2 = RP&&POI )\r
7560   { \r
7561    for(Int_t k=0;k<9;k++)\r
7562    {\r
7563     if(fs2dEBE[t][k]) fs2dEBE[t][k]->Reset();\r
7564    }\r
7565   }  \r
7566  } // end of if(fCalculate2DFlow) \r
7567 \r
7568 } // end of void AliFlowAnalysisWithQCumulants::ResetEventByEventQuantities();\r
7569 \r
7570 \r
7571 //================================================================================================================================\r
7572 \r
7573 \r
7574 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUASinTerms(TString type, TString ptOrEta)\r
7575 {\r
7576  // Calculate correction terms for non-uniform acceptance for differential flow (sin terms).\r
7577  \r
7578  // Results are stored in fDiffFlowCorrectionTermsForNUAPro[t][pe][0][cti], where cti runs as follows:\r
7579  //  0: <<sin n(psi1)>>\r
7580  //  1: <<sin n(psi1+phi2)>>\r
7581  //  2: <<sin n(psi1+phi2-phi3)>>\r
7582  //  3: <<sin n(psi1-phi2-phi3)>>:\r
7583  //  4:\r
7584  //  5:\r
7585  //  6:\r
7586  \r
7587  // multiplicity:\r
7588  Double_t dMult = (*fSMpk)(0,0);\r
7589  \r
7590  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
7591  Double_t dReQ1n = (*fReQ)(0,0);\r
7592  Double_t dReQ2n = (*fReQ)(1,0);\r
7593  //Double_t dReQ3n = (*fReQ)(2,0);\r
7594  //Double_t dReQ4n = (*fReQ)(3,0);\r
7595  Double_t dImQ1n = (*fImQ)(0,0);\r
7596  Double_t dImQ2n = (*fImQ)(1,0);\r
7597  //Double_t dImQ3n = (*fImQ)(2,0);\r
7598  //Double_t dImQ4n = (*fImQ)(3,0);\r
7599 \r
7600  Int_t t = -1; // type flag \r
7601  Int_t pe = -1; // ptEta flag\r
7602  \r
7603  if(type == "RP")\r
7604  {\r
7605   t = 0;\r
7606  } else if(type == "POI")\r
7607    {\r
7608     t = 1;\r
7609    }\r
7610 \r
7611  if(ptOrEta == "Pt")\r
7612  {\r
7613   pe = 0;\r
7614  } else if(ptOrEta == "Eta")\r
7615    {\r
7616     pe = 1;\r
7617    }\r
7618     \r
7619  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
7620  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
7621  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
7622  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
7623 \r
7624  // looping over all bins and calculating correction terms: \r
7625  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7626  {\r
7627   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): \r
7628   Double_t p1n0kRe = 0.;\r
7629   Double_t p1n0kIm = 0.;\r
7630 \r
7631   // number of POIs in particular pt or eta bin:\r
7632   Double_t mp = 0.;\r
7633 \r
7634   // 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
7635   Double_t q1n0kRe = 0.;\r
7636   Double_t q1n0kIm = 0.;\r
7637   Double_t q2n0kRe = 0.;\r
7638   Double_t q2n0kIm = 0.;\r
7639 \r
7640   // number of particles which are both RPs and POIs in particular pt or eta bin:\r
7641   Double_t mq = 0.;\r
7642    \r
7643   if(type == "POI")\r
7644   {\r
7645    // q_{m*n,0}:\r
7646    q1n0kRe = fReRPQ1dEBE[2][pe][0][0]->GetBinContent(fReRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
7647            * fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
7648    q1n0kIm = fImRPQ1dEBE[2][pe][0][0]->GetBinContent(fImRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
7649            * fImRPQ1dEBE[2][pe][0][0]->GetBinEntries(fImRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
7650    q2n0kRe = fReRPQ1dEBE[2][pe][1][0]->GetBinContent(fReRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
7651            * fReRPQ1dEBE[2][pe][1][0]->GetBinEntries(fReRPQ1dEBE[2][pe][1][0]->GetBin(b));\r
7652    q2n0kIm = fImRPQ1dEBE[2][pe][1][0]->GetBinContent(fImRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
7653            * fImRPQ1dEBE[2][pe][1][0]->GetBinEntries(fImRPQ1dEBE[2][pe][1][0]->GetBin(b));         \r
7654                  \r
7655    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
7656   } \r
7657   else if(type == "RP")\r
7658   {\r
7659    // q_{m*n,0}:\r
7660    q1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
7661            * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7662    q1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
7663            * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7664    q2n0kRe = fReRPQ1dEBE[0][pe][1][0]->GetBinContent(fReRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
7665            * fReRPQ1dEBE[0][pe][1][0]->GetBinEntries(fReRPQ1dEBE[0][pe][1][0]->GetBin(b));\r
7666    q2n0kIm = fImRPQ1dEBE[0][pe][1][0]->GetBinContent(fImRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
7667            * fImRPQ1dEBE[0][pe][1][0]->GetBinEntries(fImRPQ1dEBE[0][pe][1][0]->GetBin(b));         \r
7668                  \r
7669    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
7670   }    \r
7671   if(type == "POI")\r
7672   {\r
7673    // p_{m*n,0}:\r
7674    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))\r
7675            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7676    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  \r
7677            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7678             \r
7679    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
7680     \r
7681    t = 1; // typeFlag = RP or POI\r
7682   }\r
7683   else if(type == "RP")\r
7684   {\r
7685    // p_{m*n,0} = q_{m*n,0}:\r
7686    p1n0kRe = q1n0kRe; \r
7687    p1n0kIm = q1n0kIm; \r
7688            \r
7689    mp = mq; \r
7690    \r
7691    t = 0; // typeFlag = RP or POI\r
7692   }\r
7693 \r
7694   // <<sin n(psi1)>>:\r
7695   Double_t sinP1nPsi = 0.;\r
7696   if(mp)\r
7697   {\r
7698    sinP1nPsi = p1n0kIm/mp;\r
7699    // fill profile for <<sin n(psi1)>>:\r
7700    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi,mp);\r
7701    // histogram to store <sin n(psi1)> e-b-e (needed in some other methods):\r
7702    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][0]->SetBinContent(b,sinP1nPsi);\r
7703   } // end of if(mp)   \r
7704   \r
7705   // <<sin n(psi1+phi2)>>:\r
7706   Double_t sinP1nPsiP1nPhi = 0.;\r
7707   if(mp*dMult-mq)\r
7708   {\r
7709    sinP1nPsiP1nPhi = (p1n0kRe*dImQ1n+p1n0kIm*dReQ1n-q2n0kIm)/(mp*dMult-mq);\r
7710    // fill profile for <<sin n(psi1+phi2)>>:\r
7711    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsiP1nPhi,mp*dMult-mq);\r
7712    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7713    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][1]->SetBinContent(b,sinP1nPsiP1nPhi);\r
7714   } // end of if(mp*dMult-mq)   \r
7715   \r
7716   // <<sin n(psi1+phi2-phi3)>>:\r
7717   Double_t sinP1nPsi1P1nPhi2MPhi3 = 0.;\r
7718   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))\r
7719   {\r
7720    sinP1nPsi1P1nPhi2MPhi3 = (p1n0kIm*(pow(dImQ1n,2.)+pow(dReQ1n,2.)-dMult)\r
7721                           - 1.*(q2n0kIm*dReQ1n-q2n0kRe*dImQ1n)  \r
7722                           - mq*dImQ1n+2.*q1n0kIm)\r
7723                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7724    // fill profile for <<sin n(psi1+phi2)>>:\r
7725    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi1P1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7726    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7727    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][2]->SetBinContent(b,sinP1nPsi1P1nPhi2MPhi3);\r
7728   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   \r
7729   \r
7730   // <<sin n(psi1-phi2-phi3)>>:\r
7731   Double_t sinP1nPsi1M1nPhi2MPhi3 = 0.;\r
7732   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))\r
7733   {\r
7734    sinP1nPsi1M1nPhi2MPhi3 = (p1n0kIm*(pow(dReQ1n,2.)-pow(dImQ1n,2.))-2.*p1n0kRe*dReQ1n*dImQ1n\r
7735                           - 1.*(p1n0kIm*dReQ2n-p1n0kRe*dImQ2n)\r
7736                           + 2.*mq*dImQ1n-2.*q1n0kIm)\r
7737                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7738    // fill profile for <<sin n(psi1+phi2)>>:\r
7739    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi1M1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7740    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7741    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][3]->SetBinContent(b,sinP1nPsi1M1nPhi2MPhi3);\r
7742   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   \r
7743  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7744  \r
7745 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUASinTerms(TString type, TString ptOrEta)\r
7746 \r
7747 \r
7748 //================================================================================================================================\r
7749 \r
7750 \r
7751 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUACosTerms(TString type, TString ptOrEta)\r
7752 {\r
7753  // Calculate correction terms for non-uniform acceptance for differential flow (cos terms).\r
7754  \r
7755  // Results are stored in fDiffFlowCorrectionTermsForNUAPro[t][pe][1][cti], where cti runs as follows:\r
7756  //  0: <<cos n(psi)>>\r
7757  //  1: <<cos n(psi1+phi2)>>\r
7758  //  2: <<cos n(psi1+phi2-phi3)>>\r
7759  //  3: <<cos n(psi1-phi2-phi3)>>\r
7760  //  4:\r
7761  //  5:\r
7762  //  6:\r
7763  \r
7764  // multiplicity:\r
7765  Double_t dMult = (*fSMpk)(0,0);\r
7766  \r
7767  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: \r
7768  Double_t dReQ1n = (*fReQ)(0,0);\r
7769  Double_t dReQ2n = (*fReQ)(1,0);\r
7770  //Double_t dReQ3n = (*fReQ)(2,0);\r
7771  //Double_t dReQ4n = (*fReQ)(3,0);\r
7772  Double_t dImQ1n = (*fImQ)(0,0);\r
7773  Double_t dImQ2n = (*fImQ)(1,0);\r
7774  //Double_t dImQ3n = (*fImQ)(2,0);\r
7775  //Double_t dImQ4n = (*fImQ)(3,0);\r
7776 \r
7777  Int_t t = -1; // type flag \r
7778  Int_t pe = -1; // ptEta flag\r
7779  \r
7780  if(type == "RP")\r
7781  {\r
7782   t = 0;\r
7783  } else if(type == "POI")\r
7784    {\r
7785     t = 1;\r
7786    }\r
7787 \r
7788  if(ptOrEta == "Pt")\r
7789  {\r
7790   pe = 0;\r
7791  } else if(ptOrEta == "Eta")\r
7792    {\r
7793     pe = 1;\r
7794    }\r
7795     \r
7796  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
7797  Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
7798  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
7799  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
7800 \r
7801  // looping over all bins and calculating correction terms: \r
7802  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7803  {\r
7804   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): \r
7805   Double_t p1n0kRe = 0.;\r
7806   Double_t p1n0kIm = 0.;\r
7807 \r
7808   // number of POIs in particular pt or eta bin:\r
7809   Double_t mp = 0.;\r
7810 \r
7811   // 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
7812   Double_t q1n0kRe = 0.;\r
7813   Double_t q1n0kIm = 0.;\r
7814   Double_t q2n0kRe = 0.;\r
7815   Double_t q2n0kIm = 0.;\r
7816 \r
7817   // number of particles which are both RPs and POIs in particular pt or eta bin:\r
7818   Double_t mq = 0.;\r
7819    \r
7820   if(type == "POI")\r
7821   {\r
7822    // q_{m*n,0}:\r
7823    q1n0kRe = fReRPQ1dEBE[2][pe][0][0]->GetBinContent(fReRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
7824            * fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
7825    q1n0kIm = fImRPQ1dEBE[2][pe][0][0]->GetBinContent(fImRPQ1dEBE[2][pe][0][0]->GetBin(b))\r
7826            * fImRPQ1dEBE[2][pe][0][0]->GetBinEntries(fImRPQ1dEBE[2][pe][0][0]->GetBin(b));\r
7827    q2n0kRe = fReRPQ1dEBE[2][pe][1][0]->GetBinContent(fReRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
7828            * fReRPQ1dEBE[2][pe][1][0]->GetBinEntries(fReRPQ1dEBE[2][pe][1][0]->GetBin(b));\r
7829    q2n0kIm = fImRPQ1dEBE[2][pe][1][0]->GetBinContent(fImRPQ1dEBE[2][pe][1][0]->GetBin(b))\r
7830            * fImRPQ1dEBE[2][pe][1][0]->GetBinEntries(fImRPQ1dEBE[2][pe][1][0]->GetBin(b));         \r
7831                  \r
7832    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
7833   } \r
7834   else if(type == "RP")\r
7835   {\r
7836    // q_{m*n,0}:\r
7837    q1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
7838            * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7839    q1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))\r
7840            * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));\r
7841    q2n0kRe = fReRPQ1dEBE[0][pe][1][0]->GetBinContent(fReRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
7842            * fReRPQ1dEBE[0][pe][1][0]->GetBinEntries(fReRPQ1dEBE[0][pe][1][0]->GetBin(b));\r
7843    q2n0kIm = fImRPQ1dEBE[0][pe][1][0]->GetBinContent(fImRPQ1dEBE[0][pe][1][0]->GetBin(b))\r
7844            * fImRPQ1dEBE[0][pe][1][0]->GetBinEntries(fImRPQ1dEBE[0][pe][1][0]->GetBin(b));         \r
7845                  \r
7846    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
7847   }    \r
7848   if(type == "POI")\r
7849   {\r
7850    // p_{m*n,0}:\r
7851    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))\r
7852            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7853    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  \r
7854            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));\r
7855             \r
7856    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
7857     \r
7858    t = 1; // typeFlag = RP or POI\r
7859   }\r
7860   else if(type == "RP")\r
7861   {\r
7862    // p_{m*n,0} = q_{m*n,0}:\r
7863    p1n0kRe = q1n0kRe; \r
7864    p1n0kIm = q1n0kIm; \r
7865            \r
7866    mp = mq; \r
7867    \r
7868    t = 0; // typeFlag = RP or POI\r
7869   }\r
7870 \r
7871   // <<cos n(psi1)>>:\r
7872   Double_t cosP1nPsi = 0.;\r
7873   if(mp)\r
7874   {\r
7875    cosP1nPsi = p1n0kRe/mp;\r
7876    \r
7877    // fill profile for <<cos n(psi1)>>:\r
7878    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi,mp);\r
7879    // histogram to store <cos n(psi1)> e-b-e (needed in some other methods):\r
7880    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][0]->SetBinContent(b,cosP1nPsi);\r
7881   } // end of if(mp)   \r
7882   \r
7883   // <<cos n(psi1+phi2)>>:\r
7884   Double_t cosP1nPsiP1nPhi = 0.;\r
7885   if(mp*dMult-mq)\r
7886   {\r
7887    cosP1nPsiP1nPhi = (p1n0kRe*dReQ1n-p1n0kIm*dImQ1n-q2n0kRe)/(mp*dMult-mq);\r
7888    // fill profile for <<sin n(psi1+phi2)>>:\r
7889    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsiP1nPhi,mp*dMult-mq);\r
7890    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7891    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][1]->SetBinContent(b,cosP1nPsiP1nPhi);\r
7892   } // end of if(mp*dMult-mq)   \r
7893   \r
7894   // <<cos n(psi1+phi2-phi3)>>:\r
7895   Double_t cosP1nPsi1P1nPhi2MPhi3 = 0.;\r
7896   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))\r
7897   {\r
7898    cosP1nPsi1P1nPhi2MPhi3 = (p1n0kRe*(pow(dImQ1n,2.)+pow(dReQ1n,2.)-dMult)\r
7899                           - 1.*(q2n0kRe*dReQ1n+q2n0kIm*dImQ1n)  \r
7900                           - mq*dReQ1n+2.*q1n0kRe)\r
7901                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7902    // fill profile for <<sin n(psi1+phi2)>>:\r
7903    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi1P1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7904    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7905    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][2]->SetBinContent(b,cosP1nPsi1P1nPhi2MPhi3);\r
7906   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   \r
7907   \r
7908   // <<cos n(psi1-phi2-phi3)>>:\r
7909   Double_t cosP1nPsi1M1nPhi2MPhi3 = 0.;\r
7910   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))\r
7911   {\r
7912    cosP1nPsi1M1nPhi2MPhi3 = (p1n0kRe*(pow(dReQ1n,2.)-pow(dImQ1n,2.))+2.*p1n0kIm*dReQ1n*dImQ1n\r
7913                           - 1.*(p1n0kRe*dReQ2n+p1n0kIm*dImQ2n)  \r
7914                           - 2.*mq*dReQ1n+2.*q1n0kRe)\r
7915                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7916    // fill profile for <<sin n(psi1+phi2)>>:\r
7917    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi1M1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));\r
7918    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):\r
7919    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][3]->SetBinContent(b,cosP1nPsi1M1nPhi2MPhi3);\r
7920   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   \r
7921  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7922  \r
7923 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUACosTerms(TString type, TString ptOrEta)\r
7924 \r
7925 \r
7926 //==================================================================================================================================\r
7927 \r
7928 \r
7929 void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUADiffFlow(TString type, TString ptOrEta)\r
7930 {\r
7931  // Transfer prolfiles into histogams and correctly propagate the error (to be improved: description)\r
7932  \r
7933  // to be improved: debugged - I do not correctly transfer all profiles into histos (bug appears only after merging) \r
7934   \r
7935  Int_t t = -1; // type flag \r
7936  Int_t pe = -1; // ptEta flag\r
7937  \r
7938  if(type == "RP")\r
7939  {\r
7940   t = 0;\r
7941  } else if(type == "POI")\r
7942    {\r
7943     t = 1;\r
7944    }\r
7945 \r
7946  if(ptOrEta == "Pt")\r
7947  {\r
7948   pe = 0;\r
7949  } else if(ptOrEta == "Eta")\r
7950    {\r
7951     pe = 1;\r
7952    }\r
7953     \r
7954  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
7955  //Double_t minPtEta[2] = {fPtMin,fEtaMin};\r
7956  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};\r
7957  //Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
7958 \r
7959  for(Int_t sc=0;sc<2;sc++) // sin or cos\r
7960  {\r
7961   for(Int_t cti=0;cti<9;cti++) // correction term index\r
7962   {\r
7963    for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7964    {\r
7965     Double_t correctionTerm = fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti]->GetBinContent(b);\r
7966     fDiffFlowCorrectionTermsForNUAHist[t][pe][sc][cti]->SetBinContent(b,correctionTerm);\r
7967     // to be improved (propagate error correctly)\r
7968     // ...\r
7969    } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
7970   } // correction term index\r
7971  } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos\r
7972 \r
7973 }// end of void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUADiffFlow(TString type, TString ptOrEta)\r
7974 \r
7975 \r
7976 //==================================================================================================================================\r
7977 \r
7978 \r
7979 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulantsCorrectedForNUA(TString type, TString ptOrEta)\r
7980\r
7981  // Calculate generalized differential flow Q-cumulants (corrected for non-uniform acceptance)\r
7982   \r
7983  Int_t typeFlag = -1;\r
7984  Int_t ptEtaFlag = -1;\r
7985 \r
7986  if(type == "RP")\r
7987  {\r
7988   typeFlag = 0;\r
7989  } else if(type == "POI")\r
7990    {\r
7991     typeFlag = 1;\r
7992    } \r
7993      \r
7994  if(ptOrEta == "Pt")\r
7995  {\r
7996   ptEtaFlag = 0;\r
7997  } else if(ptOrEta == "Eta")\r
7998    {\r
7999     ptEtaFlag = 1;\r
8000    } \r
8001   \r
8002  // shortcuts:\r
8003  Int_t t = typeFlag;\r
8004  Int_t pe = ptEtaFlag;\r
8005      \r
8006  // common:\r
8007  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
8008  \r
8009  // 2-particle correlation:\r
8010  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>\r
8011  // sin term coming from integrated flow: \r
8012  Double_t sinP1nPhi = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1); // <<sin(n*phi1)>>\r
8013  Double_t sinP1nPhi1P1nPhi2 = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(2); // <<sin(n*(phi1+phi2))>>\r
8014  Double_t sinP1nPhi1M1nPhi2M1nPhi3 = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(3); // <<sin(n*(phi1-phi2-phi3))>>\r
8015  // cos term coming from integrated flow: \r
8016  Double_t cosP1nPhi = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1); // <<cos(n*phi1)>>\r
8017  Double_t cosP1nPhi1P1nPhi2 = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(2); // <<cos(n*(phi1+phi2))>>\r
8018  Double_t cosP1nPhi1M1nPhi2M1nPhi3 = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(3); // <<cos(n*(phi1-phi2-phi3))>>\r
8019 \r
8020  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
8021  {\r
8022   Double_t twoPrime = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b); // <<2'>>\r
8023   Double_t fourPrime = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b); // <<4'>>\r
8024   Double_t sinP1nPsi = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][0]->GetBinContent(b); // <<sin n(Psi)>> \r
8025   Double_t cosP1nPsi = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][0]->GetBinContent(b); // <<cos n(Psi)>> \r
8026   Double_t sinP1nPsi1P1nPhi2 = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][1]->GetBinContent(b); // <<sin n(psi1+phi2)>> \r
8027   Double_t cosP1nPsi1P1nPhi2 = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][1]->GetBinContent(b); // <<cos n(psi1+phi2)>> \r
8028   Double_t sinP1nPsi1P1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][2]->GetBinContent(b); // <<sin n(psi1+phi2-phi3)>> \r
8029   Double_t cosP1nPsi1P1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][2]->GetBinContent(b); // <<cos n(psi1+phi2-phi3)>> \r
8030   Double_t sinP1nPsi1M1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][3]->GetBinContent(b); // <<sin n(psi1-phi2-phi3)>> \r
8031   Double_t cosP1nPsi1M1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][3]->GetBinContent(b); // <<cos n(psi1-phi2-phi3)>> \r
8032   // generalized QC{2'}:\r
8033   Double_t qc2Prime = twoPrime - sinP1nPsi*sinP1nPhi - cosP1nPsi*cosP1nPhi;\r
8034   fDiffFlowCumulants[t][pe][0]->SetBinContent(b,qc2Prime);\r
8035   // generalized QC{4'}:\r
8036   Double_t qc4Prime = fourPrime-2.*twoPrime*two\r
8037                     - cosP1nPsi*cosP1nPhi1M1nPhi2M1nPhi3\r
8038                     + sinP1nPsi*sinP1nPhi1M1nPhi2M1nPhi3\r
8039                     - cosP1nPhi*cosP1nPsi1M1nPhi2M1nPhi3\r
8040                     + sinP1nPhi*sinP1nPsi1M1nPhi2M1nPhi3\r
8041                     - 2.*cosP1nPhi*cosP1nPsi1P1nPhi2M1nPhi3\r
8042                     - 2.*sinP1nPhi*sinP1nPsi1P1nPhi2M1nPhi3\r
8043                     - cosP1nPsi1P1nPhi2*cosP1nPhi1P1nPhi2\r
8044                     - sinP1nPsi1P1nPhi2*sinP1nPhi1P1nPhi2\r
8045                     + 2.*cosP1nPhi1P1nPhi2*(cosP1nPsi*cosP1nPhi-sinP1nPsi*sinP1nPhi)\r
8046                     + 2.*sinP1nPhi1P1nPhi2*(cosP1nPsi*sinP1nPhi+sinP1nPsi*cosP1nPhi)\r
8047                     + 4.*two*(cosP1nPsi*cosP1nPhi+sinP1nPsi*sinP1nPhi)\r
8048                     + 2.*cosP1nPsi1P1nPhi2*(pow(cosP1nPhi,2.)-pow(sinP1nPhi,2.))\r
8049                     + 4.*sinP1nPsi1P1nPhi2*cosP1nPhi*sinP1nPhi\r
8050                     + 4.*twoPrime*(pow(cosP1nPhi,2.)+pow(sinP1nPhi,2.))\r
8051                     - 6.*(pow(cosP1nPhi,2.)-pow(sinP1nPhi,2.)) \r
8052                     * (cosP1nPsi*cosP1nPhi-sinP1nPsi*sinP1nPhi)\r
8053                     - 12.*cosP1nPhi*sinP1nPhi\r
8054                     * (sinP1nPsi*cosP1nPhi+cosP1nPsi*sinP1nPhi);\r
8055   fDiffFlowCumulants[t][pe][1]->SetBinContent(b,qc4Prime);   \r
8056  } // end of for(Int_t p=1;p<=fnBinsPt;p++)\r
8057  \r
8058 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulantsCorrectedForNUA(TString type, TString ptOrEta)\r
8059 \r
8060 \r
8061 //==================================================================================================================================\r
8062     \r
8063 \r
8064 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectedForNUA(TString type, TString ptOrEta)\r
8065 {\r
8066  // Calculate differential flow corrected for non-uniform acceptance.\r
8067  \r
8068  // to be improved (rewritten completely)\r
8069  \r
8070  Int_t typeFlag = -1;\r
8071  Int_t ptEtaFlag = -1;\r
8072 \r
8073  if(type == "RP")\r
8074  {\r
8075   typeFlag = 0;\r
8076  } else if(type == "POI")\r
8077    {\r
8078     typeFlag = 1;\r
8079    } \r
8080      \r
8081  if(ptOrEta == "Pt")\r
8082  {\r
8083   ptEtaFlag = 0;\r
8084  } else if(ptOrEta == "Eta")\r
8085    {\r
8086     ptEtaFlag = 1;\r
8087    } \r
8088   \r
8089  // shortcuts:\r
8090  Int_t t = typeFlag;\r
8091  Int_t pe = ptEtaFlag;\r
8092      \r
8093  // common:\r
8094  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};\r
8095    \r
8096  // to be improved: access here generalized QC{2} and QC{4} instead: \r
8097  Double_t dV2 = fIntFlow->GetBinContent(1); \r
8098  Double_t dV4 = fIntFlow->GetBinContent(2); \r
8099  \r
8100  // loop over pt or eta bins:\r
8101  for(Int_t b=1;b<=nBinsPtEta[pe];b++)\r
8102  {\r
8103   // generalized QC{2'}:\r
8104   Double_t gQC2Prime = fDiffFlowCumulants[t][pe][0]->GetBinContent(b);\r
8105   // v'{2}:\r
8106   if(dV2>0)\r
8107   { \r
8108    Double_t v2Prime = gQC2Prime/dV2;\r
8109    fDiffFlow[t][pe][0]->SetBinContent(b,v2Prime); \r
8110   }  \r
8111   // generalized QC{4'}:\r
8112   Double_t gQC4Prime = fDiffFlowCumulants[t][pe][1]->GetBinContent(b);\r
8113   // v'{4}:\r
8114   if(dV4>0)\r
8115   { \r
8116    Double_t v4Prime = -gQC4Prime/pow(dV4,3.);\r
8117    fDiffFlow[t][pe][1]->SetBinContent(b,v4Prime); \r
8118   }  \r
8119  } // end of for(Int_t b=1;b<=fnBinsPtEta[pe];b++)\r
8120   \r
8121 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectedForNUA(TString type, TString ptOrEta); \r
8122 \r
8123 \r
8124 //==================================================================================================================================\r
8125 \r
8126 \r
8127 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoops(AliFlowEventSimple* anEvent)\r
8128 {\r
8129  // Evaluate with nested loops multiparticle correlations for integrated flow (without using the particle weights). \r
8130 \r
8131  // Remark: Results are stored in profile fIntFlowDirectCorrelations whose binning is organized as follows:\r
8132  // \r
8133  //  1st bin: <2>_{1n|1n} = two1n1n = cos(n*(phi1-phi2))>\r
8134  //  2nd bin: <2>_{2n|2n} = two2n2n = cos(2n*(phi1-phi2))>\r
8135  //  3rd bin: <2>_{3n|3n} = two3n3n = cos(3n*(phi1-phi2))> \r
8136  //  4th bin: <2>_{4n|4n} = two4n4n = cos(4n*(phi1-phi2))>\r
8137  //  5th bin:           ----  EMPTY ----\r
8138  //  6th bin: <3>_{2n|1n,1n} = three2n1n1n = <cos(n*(2.*phi1-phi2-phi3))>\r
8139  //  7th bin: <3>_{3n|2n,1n} = three3n2n1n = <cos(n*(3.*phi1-2.*phi2-phi3))>\r
8140  //  8th bin: <3>_{4n|2n,2n} = three4n2n2n = <cos(n*(4.*phi1-2.*phi2-2.*phi3))>\r
8141  //  9th bin: <3>_{4n|3n,1n} = three4n3n1n = <cos(n*(4.*phi1-3.*phi2-phi3))>\r
8142  // 10th bin:           ----  EMPTY ----\r
8143  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1n = <cos(n*(phi1+phi2-phi3-phi4))>\r
8144  // 12th bin: <4>_{2n,1n|2n,1n} = four2n1n2n1n = <cos(2.*n*(phi1+phi2-phi3-phi4))>\r
8145  // 13th bin: <4>_{2n,2n|2n,2n} = four2n2n2n2n = <cos(n*(2.*phi1+phi2-2.*phi3-phi4))>\r
8146  // 14th bin: <4>_{3n|1n,1n,1n} = four3n1n1n1n = <cos(n*(3.*phi1-phi2-phi3-phi4))> \r
8147  // 15th bin: <4>_{3n,1n|3n,1n} = four3n1n3n1n = <cos(n*(4.*phi1-2.*phi2-phi3-phi4))>\r
8148  // 16th bin: <4>_{3n,1n|2n,2n} = four3n1n2n2n = <cos(n*(3.*phi1+phi2-2.*phi3-2.*phi4))>\r
8149  // 17th bin: <4>_{4n|2n,1n,1n} = four4n2n1n1n = <cos(n*(3.*phi1+phi2-3.*phi3-phi4))> \r
8150  // 18th bin:           ----  EMPTY ----\r
8151  // 19th bin: <5>_{2n|1n,1n,1n,1n} = five2n1n1n1n1n = <cos(n*(2.*phi1+phi2-phi3-phi4-phi5))>\r
8152  // 20th bin: <5>_{2n,2n|2n,1n,1n} = five2n2n2n1n1n = <cos(n*(2.*phi1+2.*phi2-2.*phi3-phi4-phi5))>\r
8153  // 21st bin: <5>_{3n,1n|2n,1n,1n} = five3n1n2n1n1n = <cos(n*(3.*phi1+phi2-2.*phi3-phi4-phi5))>\r
8154  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = five4n1n1n1n1n = <cos(n*(4.*phi1-phi2-phi3-phi4-phi5))>\r
8155  // 23rd bin:           ----  EMPTY ----\r
8156  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = six1n1n1n1n1n1n = <cos(n*(phi1+phi2+phi3-phi4-phi5-phi6))>\r
8157  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = six2n1n1n2n1n1n = <cos(n*(2.*phi1+2.*phi2-phi3-phi4-phi5-phi6))>\r
8158  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = six2n2n1n1n1n1n = <cos(n*(3.*phi1+phi2-phi3-phi4-phi5-phi6))>\r
8159  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = six3n1n1n1n1n1n = <cos(n*(2.*phi1+phi2+phi3-2.*phi4-phi5-phi6))>\r
8160  // 28th bin:           ----  EMPTY ----\r
8161  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = seven2n1n1n1n1n1n1n =  <cos(n*(2.*phi1+phi2+phi3-phi4-phi5-phi6-phi7))>\r
8162  // 30th bin:           ----  EMPTY ----\r
8163  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = eight1n1n1n1n1n1n1n1n = <cos(n*(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>\r
8164  \r
8165  Int_t nPrim = anEvent->NumberOfTracks(); \r
8166  AliFlowTrackSimple *aftsTrack = NULL; \r
8167  Double_t phi1=0., phi2=0., phi3=0., phi4=0., phi5=0., phi6=0., phi7=0., phi8=0.; \r
8168  Int_t n = fHarmonic; \r
8169  Int_t eventNo = (Int_t)fAvMultiplicity->GetBinEntries(1); // to be improved (is this casting safe in general?)\r
8170  Double_t dMult = (*fSMpk)(0,0);\r
8171  cout<<endl;\r
8172  cout<<"Multiparticle correlations: Event number: "<<eventNo<<", multiplicity is "<<dMult<<endl;\r
8173  if(dMult<2)\r
8174  {\r
8175   cout<<"... skipping this event (multiplicity too low) ..."<<endl;\r
8176  } else if (dMult>fMaxAllowedMultiplicity)\r
8177    {\r
8178     cout<<"... skipping this event (multiplicity too high) ..."<<endl;\r
8179    } else \r
8180      { \r
8181       cout<<"... evaluating nested loops (without using particle weights)..."<<endl;\r
8182      } \r
8183  \r
8184  // 2-particle correlations:       \r
8185  if(nPrim>=2 && nPrim<=fMaxAllowedMultiplicity)\r
8186  {\r
8187   for(Int_t i1=0;i1<nPrim;i1++)\r
8188   {\r
8189    aftsTrack=anEvent->GetTrack(i1);\r
8190    if(!(aftsTrack->InRPSelection())) continue;\r
8191    phi1=aftsTrack->Phi(); \r
8192    for(Int_t i2=0;i2<nPrim;i2++)\r
8193    {\r
8194     if(i2==i1)continue;\r
8195     aftsTrack=anEvent->GetTrack(i2);\r
8196     if(!(aftsTrack->InRPSelection())) continue;\r
8197     phi2=aftsTrack->Phi();\r
8198     if(nPrim==2) cout<<i1<<" "<<i2<<"\r"<<flush;\r
8199     // fill the profile with 2-p correlations: \r
8200     fIntFlowDirectCorrelations->Fill(0.5,cos(n*(phi1-phi2)),1.);    // <cos(n*(phi1-phi2))>\r
8201     fIntFlowDirectCorrelations->Fill(1.5,cos(2.*n*(phi1-phi2)),1.); // <cos(2n*(phi1-phi2))>\r
8202     fIntFlowDirectCorrelations->Fill(2.5,cos(3.*n*(phi1-phi2)),1.); // <cos(3n*(phi1-phi2))>\r
8203     fIntFlowDirectCorrelations->Fill(3.5,cos(4.*n*(phi1-phi2)),1.); // <cos(4n*(phi1-phi2))>   \r
8204    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8205   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8206  } // end of if(nPrim>=2)\r
8207  \r
8208  // 3-particle correlations:         \r
8209  if(nPrim>=3 && nPrim<=fMaxAllowedMultiplicity)\r
8210  {\r
8211   for(Int_t i1=0;i1<nPrim;i1++)\r
8212   {\r
8213    aftsTrack=anEvent->GetTrack(i1);\r
8214    if(!(aftsTrack->InRPSelection())) continue;\r
8215    phi1=aftsTrack->Phi();\r
8216    for(Int_t i2=0;i2<nPrim;i2++)\r
8217    {\r
8218     if(i2==i1)continue;\r
8219     aftsTrack=anEvent->GetTrack(i2);\r
8220     if(!(aftsTrack->InRPSelection())) continue;\r
8221     phi2=aftsTrack->Phi();\r
8222     for(Int_t i3=0;i3<nPrim;i3++)\r
8223     {\r
8224      if(i3==i1||i3==i2)continue;\r
8225      aftsTrack=anEvent->GetTrack(i3);\r
8226      if(!(aftsTrack->InRPSelection())) continue;\r
8227      phi3=aftsTrack->Phi();\r
8228      if(nPrim==3) cout<<i1<<" "<<i2<<" "<<i3<<"\r"<<flush;\r
8229      // fill the profile with 3-p correlations:   \r
8230      fIntFlowDirectCorrelations->Fill(5.,cos(2.*n*phi1-n*(phi2+phi3)),1.);       //<3>_{2n|nn,n}\r
8231      fIntFlowDirectCorrelations->Fill(6.,cos(3.*n*phi1-2.*n*phi2-n*phi3),1.);    //<3>_{3n|2n,n}\r
8232      fIntFlowDirectCorrelations->Fill(7.,cos(4.*n*phi1-2.*n*phi2-2.*n*phi3),1.); //<3>_{4n|2n,2n}\r
8233      fIntFlowDirectCorrelations->Fill(8.,cos(4.*n*phi1-3.*n*phi2-n*phi3),1.);    //<3>_{4n|3n,n}\r
8234     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8235    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8236   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8237  } // end of if(nPrim>=3)\r
8238 \r
8239  // 4-particle correlations:\r
8240  if(nPrim>=4 && nPrim<=fMaxAllowedMultiplicity)\r
8241  {       \r
8242   for(Int_t i1=0;i1<nPrim;i1++)\r
8243   { \r
8244    aftsTrack=anEvent->GetTrack(i1);\r
8245    if(!(aftsTrack->InRPSelection())) continue;\r
8246    phi1=aftsTrack->Phi();\r
8247    for(Int_t i2=0;i2<nPrim;i2++)\r
8248    {\r
8249     if(i2==i1)continue;\r
8250     aftsTrack=anEvent->GetTrack(i2);\r
8251     if(!(aftsTrack->InRPSelection())) continue;\r
8252     phi2=aftsTrack->Phi();\r
8253     for(Int_t i3=0;i3<nPrim;i3++)\r
8254     {\r
8255      if(i3==i1||i3==i2)continue;\r
8256      aftsTrack=anEvent->GetTrack(i3);\r
8257      if(!(aftsTrack->InRPSelection())) continue;\r
8258      phi3=aftsTrack->Phi();\r
8259      for(Int_t i4=0;i4<nPrim;i4++)\r
8260      {\r
8261       if(i4==i1||i4==i2||i4==i3)continue;\r
8262       aftsTrack=anEvent->GetTrack(i4);\r
8263       if(!(aftsTrack->InRPSelection())) continue;\r
8264       phi4=aftsTrack->Phi();\r
8265       if(nPrim==4) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<"\r"<<flush;\r
8266       // fill the profile with 4-p correlations:   \r
8267       fIntFlowDirectCorrelations->Fill(10.,cos(n*phi1+n*phi2-n*phi3-n*phi4),1.);            // <4>_{n,n|n,n} \r
8268       fIntFlowDirectCorrelations->Fill(11.,cos(2.*n*phi1+n*phi2-2.*n*phi3-n*phi4),1.);      // <4>_{2n,n|2n,n}\r
8269       fIntFlowDirectCorrelations->Fill(12.,cos(2.*n*phi1+2*n*phi2-2.*n*phi3-2.*n*phi4),1.); // <4>_{2n,2n|2n,2n}\r
8270       fIntFlowDirectCorrelations->Fill(13.,cos(3.*n*phi1-n*phi2-n*phi3-n*phi4),1.);         // <4>_{3n|n,n,n}\r
8271       fIntFlowDirectCorrelations->Fill(14.,cos(3.*n*phi1+n*phi2-3.*n*phi3-n*phi4),1.);      // <4>_{3n,n|3n,n}   \r
8272       fIntFlowDirectCorrelations->Fill(15.,cos(3.*n*phi1+n*phi2-2.*n*phi3-2.*n*phi4),1.);   // <4>_{3n,n|2n,2n}\r
8273       fIntFlowDirectCorrelations->Fill(16.,cos(4.*n*phi1-2.*n*phi2-n*phi3-n*phi4),1.);      // <4>_{4n|2n,n,n}     \r
8274      } // end of for(Int_t i4=0;i4<nPrim;i4++) \r
8275     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8276    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8277   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8278  } // end of if(nPrim>=)\r
8279 \r
8280  // 5-particle correlations:      \r
8281  if(nPrim>=5 && nPrim<=fMaxAllowedMultiplicity)\r
8282  {\r
8283   for(Int_t i1=0;i1<nPrim;i1++)\r
8284   {\r
8285    aftsTrack=anEvent->GetTrack(i1);\r
8286    if(!(aftsTrack->InRPSelection())) continue;  \r
8287    phi1=aftsTrack->Phi();\r
8288    for(Int_t i2=0;i2<nPrim;i2++)\r
8289    {\r
8290     if(i2==i1)continue;\r
8291     aftsTrack=anEvent->GetTrack(i2);\r
8292     if(!(aftsTrack->InRPSelection())) continue;\r
8293     phi2=aftsTrack->Phi();\r
8294     for(Int_t i3=0;i3<nPrim;i3++)\r
8295     {\r
8296      if(i3==i1||i3==i2)continue;\r
8297      aftsTrack=anEvent->GetTrack(i3);\r
8298      if(!(aftsTrack->InRPSelection())) continue;\r
8299      phi3=aftsTrack->Phi();\r
8300      for(Int_t i4=0;i4<nPrim;i4++)\r
8301      {\r
8302       if(i4==i1||i4==i2||i4==i3)continue;\r
8303       aftsTrack=anEvent->GetTrack(i4);\r
8304       if(!(aftsTrack->InRPSelection())) continue;\r
8305       phi4=aftsTrack->Phi();\r
8306       for(Int_t i5=0;i5<nPrim;i5++)\r
8307       {\r
8308        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;\r
8309        aftsTrack=anEvent->GetTrack(i5);\r
8310        if(!(aftsTrack->InRPSelection())) continue;\r
8311        phi5=aftsTrack->Phi();\r
8312        if(nPrim==5) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<"\r"<<flush;\r
8313        // fill the profile with 5-p correlations:   \r
8314        fIntFlowDirectCorrelations->Fill(18.,cos(2.*n*phi1+n*phi2-n*phi3-n*phi4-n*phi5),1.);       //<5>_{2n,n|n,n,n}\r
8315        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
8316        fIntFlowDirectCorrelations->Fill(20.,cos(3.*n*phi1+n*phi2-2.*n*phi3-n*phi4-n*phi5),1.);    //<5>_{3n,n|2n,n,n}\r
8317        fIntFlowDirectCorrelations->Fill(21.,cos(4.*n*phi1-n*phi2-n*phi3-n*phi4-n*phi5),1.);       //<5>_{4n|n,n,n,n}\r
8318       } // end of for(Int_t i5=0;i5<nPrim;i5++)\r
8319      } // end of for(Int_t i4=0;i4<nPrim;i4++)  \r
8320     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8321    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8322   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8323  } // end of if(nPrim>=5)\r
8324   \r
8325  // 6-particle correlations:\r
8326  if(nPrim>=6 && nPrim<=fMaxAllowedMultiplicity)\r
8327  {\r
8328   for(Int_t i1=0;i1<nPrim;i1++)\r
8329   {\r
8330    aftsTrack=anEvent->GetTrack(i1);\r
8331    if(!(aftsTrack->InRPSelection())) continue;\r
8332    phi1=aftsTrack->Phi();\r
8333    for(Int_t i2=0;i2<nPrim;i2++)\r
8334    {\r
8335     if(i2==i1)continue;\r
8336     aftsTrack=anEvent->GetTrack(i2);\r
8337     if(!(aftsTrack->InRPSelection())) continue;\r
8338     phi2=aftsTrack->Phi();\r
8339     for(Int_t i3=0;i3<nPrim;i3++)\r
8340     {\r
8341      if(i3==i1||i3==i2)continue;\r
8342      aftsTrack=anEvent->GetTrack(i3);\r
8343      if(!(aftsTrack->InRPSelection())) continue;\r
8344      phi3=aftsTrack->Phi();\r
8345      for(Int_t i4=0;i4<nPrim;i4++)\r
8346      {\r
8347       if(i4==i1||i4==i2||i4==i3)continue;\r
8348       aftsTrack=anEvent->GetTrack(i4);\r
8349       if(!(aftsTrack->InRPSelection())) continue;\r
8350       phi4=aftsTrack->Phi();\r
8351       for(Int_t i5=0;i5<nPrim;i5++)\r
8352       {\r
8353        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;\r
8354        aftsTrack=anEvent->GetTrack(i5);\r
8355        if(!(aftsTrack->InRPSelection())) continue;\r
8356        phi5=aftsTrack->Phi();\r
8357        for(Int_t i6=0;i6<nPrim;i6++)\r
8358        {\r
8359         if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;\r
8360         aftsTrack=anEvent->GetTrack(i6);\r
8361         if(!(aftsTrack->InRPSelection())) continue;\r
8362         phi6=aftsTrack->Phi(); \r
8363         if(nPrim==6) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<" "<<i6<<"\r"<<flush;\r
8364         // fill the profile with 6-p correlations:   \r
8365         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
8366         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
8367         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
8368         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
8369        } // end of for(Int_t i6=0;i6<nPrim;i6++)\r
8370       } // end of for(Int_t i5=0;i5<nPrim;i5++)\r
8371      } // end of for(Int_t i4=0;i4<nPrim;i4++)\r
8372     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8373    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8374   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8375  } // end of if(nPrim>=6)\r
8376   \r
8377  // 7-particle correlations:\r
8378  if(nPrim>=7 && nPrim<=fMaxAllowedMultiplicity)\r
8379  {\r
8380   for(Int_t i1=0;i1<nPrim;i1++)\r
8381   { \r
8382    aftsTrack=anEvent->GetTrack(i1);\r
8383    if(!(aftsTrack->InRPSelection())) continue;\r
8384    phi1=aftsTrack->Phi();\r
8385    for(Int_t i2=0;i2<nPrim;i2++)\r
8386    {\r
8387     if(i2==i1)continue;\r
8388     aftsTrack=anEvent->GetTrack(i2);\r
8389     if(!(aftsTrack->InRPSelection())) continue;\r
8390     phi2=aftsTrack->Phi();\r
8391     for(Int_t i3=0;i3<nPrim;i3++)\r
8392     {\r
8393      if(i3==i1||i3==i2)continue;\r
8394      aftsTrack=anEvent->GetTrack(i3);\r
8395      if(!(aftsTrack->InRPSelection())) continue;\r
8396      phi3=aftsTrack->Phi();\r
8397      for(Int_t i4=0;i4<nPrim;i4++)\r
8398      {\r
8399       if(i4==i1||i4==i2||i4==i3)continue;\r
8400       aftsTrack=anEvent->GetTrack(i4);\r
8401       if(!(aftsTrack->InRPSelection())) continue;\r
8402       phi4=aftsTrack->Phi();\r
8403       for(Int_t i5=0;i5<nPrim;i5++)\r
8404       {\r
8405        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;\r
8406        aftsTrack=anEvent->GetTrack(i5);\r
8407        if(!(aftsTrack->InRPSelection())) continue;\r
8408        phi5=aftsTrack->Phi();\r
8409        for(Int_t i6=0;i6<nPrim;i6++)\r
8410        {\r
8411         if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;\r
8412         aftsTrack=anEvent->GetTrack(i6);\r
8413         if(!(aftsTrack->InRPSelection())) continue;\r
8414         phi6=aftsTrack->Phi(); \r
8415         for(Int_t i7=0;i7<nPrim;i7++)\r
8416         {\r
8417          if(i7==i1||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6)continue;\r
8418          aftsTrack=anEvent->GetTrack(i7);\r
8419          if(!(aftsTrack->InRPSelection())) continue;\r
8420          phi7=aftsTrack->Phi(); \r
8421          if(nPrim==7) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<" "<<i6<<" "<<i7<<"\r"<<flush;\r
8422          // fill the profile with 7-p correlation:   \r
8423          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
8424         } // end of for(Int_t i7=0;i7<nPrim;i7++)\r
8425        } // end of for(Int_t i6=0;i6<nPrim;i6++) \r
8426       } // end of for(Int_t i5=0;i5<nPrim;i5++)\r
8427      } // end of for(Int_t i4=0;i4<nPrim;i4++)  \r
8428     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8429    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8430   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8431  } // end of if(nPrim>=7)\r
8432  \r
8433  // 8-particle correlations:\r
8434  if(nPrim>=8 && nPrim<=fMaxAllowedMultiplicity)\r
8435  {\r
8436   for(Int_t i1=0;i1<nPrim;i1++)\r
8437   {\r
8438    aftsTrack=anEvent->GetTrack(i1);\r
8439    if(!(aftsTrack->InRPSelection())) continue;\r
8440    phi1=aftsTrack->Phi();\r
8441    for(Int_t i2=0;i2<nPrim;i2++)\r
8442    {\r
8443     if(i2==i1)continue;\r
8444     aftsTrack=anEvent->GetTrack(i2);\r
8445     if(!(aftsTrack->InRPSelection())) continue;\r
8446     phi2=aftsTrack->Phi();\r
8447     for(Int_t i3=0;i3<nPrim;i3++)\r
8448     {\r
8449      if(i3==i1||i3==i2)continue;\r
8450      aftsTrack=anEvent->GetTrack(i3);\r
8451      if(!(aftsTrack->InRPSelection())) continue;\r
8452      phi3=aftsTrack->Phi();\r
8453      for(Int_t i4=0;i4<nPrim;i4++)\r
8454      {\r
8455       if(i4==i1||i4==i2||i4==i3)continue;\r
8456       aftsTrack=anEvent->GetTrack(i4);\r
8457       if(!(aftsTrack->InRPSelection())) continue;\r
8458       phi4=aftsTrack->Phi();\r
8459       for(Int_t i5=0;i5<nPrim;i5++)\r
8460       {\r
8461        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;\r
8462        aftsTrack=anEvent->GetTrack(i5);\r
8463        if(!(aftsTrack->InRPSelection())) continue;\r
8464        phi5=aftsTrack->Phi();\r
8465        for(Int_t i6=0;i6<nPrim;i6++)\r
8466        {\r
8467         if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;\r
8468         aftsTrack=anEvent->GetTrack(i6);\r
8469         if(!(aftsTrack->InRPSelection())) continue;\r
8470         phi6=aftsTrack->Phi();\r
8471         for(Int_t i7=0;i7<nPrim;i7++)\r
8472         {\r
8473          if(i7==i1||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6)continue;\r
8474          aftsTrack=anEvent->GetTrack(i7);\r
8475          if(!(aftsTrack->InRPSelection())) continue;\r
8476          phi7=aftsTrack->Phi();\r
8477          for(Int_t i8=0;i8<nPrim;i8++)\r
8478          {\r
8479           if(i8==i1||i8==i2||i8==i3||i8==i4||i8==i5||i8==i6||i8==i7)continue;\r
8480           aftsTrack=anEvent->GetTrack(i8);\r
8481           if(!(aftsTrack->InRPSelection())) continue;\r
8482           phi8=aftsTrack->Phi();\r
8483           cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<" "<<i6<<" "<<i7<<" "<<i8<<"\r"<<flush;\r
8484           // fill the profile with 8-p correlation:   \r
8485           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
8486          } // end of for(Int_t i8=0;i8<nPrim;i8++)\r
8487         } // end of for(Int_t i7=0;i7<nPrim;i7++) \r
8488        } // end of for(Int_t i6=0;i6<nPrim;i6++) \r
8489       } // end of for(Int_t i5=0;i5<nPrim;i5++)\r
8490      } // end of for(Int_t i4=0;i4<nPrim;i4++)  \r
8491     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8492    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8493   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8494  } // end of if(nPrim>=8)\r
8495  \r
8496  cout<<endl;\r
8497 \r
8498 } // end of AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoops(AliFlowEventSimple* anEvent)\r
8499 \r
8500 \r
8501 //==================================================================================================================================\r
8502 \r
8503 \r
8504 void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrelations()\r
8505 {\r
8506  // Cross-check results for multiparticle correlations needed for int. flow: results from Q-vectors vs results from nested loops.\r
8507 \r
8508  cout<<endl;\r
8509  cout<<endl;\r
8510  cout<<"   *****************************************"<<endl;\r
8511  cout<<"   **** cross-checking the correlations ****"<<endl;\r
8512  cout<<"   ****       for integrated flow       ****"<<endl;\r
8513  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
8514  {\r
8515   cout<<"   ****   (particle weights not used)   ****"<<endl;\r
8516  } else\r
8517    {\r
8518     cout<<"   ****     (particle weights used)     ****"<<endl;\r
8519    } \r
8520  cout<<"   *****************************************"<<endl;\r
8521  cout<<endl;\r
8522  cout<<endl;\r
8523 \r
8524  Int_t ciMax = 32; // to be improved (removed eventually when I calculate 6th and 8th order with particle weights)\r
8525  \r
8526  if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)\r
8527  {\r
8528   ciMax = 11;\r
8529  }\r
8530 \r
8531  for(Int_t ci=1;ci<=ciMax;ci++)\r
8532  {\r
8533   if(strcmp((fIntFlowCorrelationsAllPro->GetXaxis())->GetBinLabel(ci), "") == 0) continue; // to be improved (access finalized histogram here)\r
8534   cout<<(fIntFlowCorrelationsAllPro->GetXaxis())->GetBinLabel(ci)<<":"<<endl; // to be improved (access finalized histogram here)\r
8535   cout<<"from Q-vectors    = "<<fIntFlowCorrelationsAllPro->GetBinContent(ci)<<endl; // to be improved (access finalized histogram here)\r
8536   cout<<"from nested loops = "<<fIntFlowDirectCorrelations->GetBinContent(ci)<<endl;\r
8537   cout<<endl;\r
8538  }\r
8539   \r
8540 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrelations()\r
8541 \r
8542 \r
8543 //================================================================================================================================\r
8544 \r
8545 \r
8546 void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrectionTermsForNUA()\r
8547 {\r
8548  // Cross-check results for corrections terms for non-uniform acceptance needed for int. flow: results from Q-vectors vs results from nested loops.\r
8549 \r
8550  cout<<endl;\r
8551  cout<<endl;\r
8552  cout<<"   *********************************************"<<endl;\r
8553  cout<<"   **** cross-checking the correction terms ****"<<endl;\r
8554  cout<<"   **** for non-uniform acceptance relevant ****"<<endl;\r
8555  cout<<"   ****         for integrated flow         ****"<<endl;\r
8556  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights))\r
8557  {\r
8558   cout<<"   ****     (particle weights not used)     ****"<<endl;\r
8559  } else\r
8560    {\r
8561     cout<<"   ****       (particle weights used)       ****"<<endl;\r
8562    } \r
8563  cout<<"   *********************************************"<<endl;\r
8564  cout<<endl;\r
8565  cout<<endl;\r
8566 \r
8567  for(Int_t ci=1;ci<=10;ci++) // correction term index\r
8568  {\r
8569   for(Int_t sc=0;sc<2;sc++) // sin or cos term\r
8570   {\r
8571    if(strcmp((fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->GetBinLabel(ci), "") == 0) continue; // to be improved (access finalized histogram here)\r
8572    cout<<(fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->GetBinLabel(ci)<<":"<<endl; // to be improved (access finalized histogram here)\r
8573    cout<<"from Q-vectors    = "<<fIntFlowCorrectionTermsForNUAPro[sc]->GetBinContent(ci)<<endl; // to be improved (access finalized histogram here)\r
8574    cout<<"from nested loops = "<<fIntFlowDirectCorrectionTermsForNUA[sc]->GetBinContent(ci)<<endl;\r
8575    cout<<endl;\r
8576   } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos term\r
8577  } // end of for(Int_t ci=1;ci<=10;ci++) // correction term index\r
8578   \r
8579 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrectionTermsForNUA() \r
8580 \r
8581 \r
8582 //================================================================================================================================\r
8583 \r
8584 \r
8585 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent)\r
8586 {\r
8587  // Evaluate with nested loops multiparticle correlations for integrated flow (using the particle weights). \r
8588 \r
8589  // Results are stored in profile fIntFlowDirectCorrelations. \r
8590  // Remark 1: When particle weights are used the binning of fIntFlowDirectCorrelations is organized as follows:\r
8591  //\r
8592  //  1st bin: <2>_{1n|1n} = two1n1nW1W1 = <w1 w2 cos(n*(phi1-phi2))>\r
8593  //  2nd bin: <2>_{2n|2n} = two2n2nW2W2 = <w1^2 w2^2 cos(2n*(phi1-phi2))>\r
8594  //  3rd bin: <2>_{3n|3n} = two3n3nW3W3 = <w1^3 w2^3 cos(3n*(phi1-phi2))> \r
8595  //  4th bin: <2>_{4n|4n} = two4n4nW4W4 = <w1^4 w2^4 cos(4n*(phi1-phi2))>\r
8596  //  5th bin:           ----  EMPTY ----\r
8597  //  6th bin: <3>_{2n|1n,1n} = three2n1n1nW2W1W1 = <w1^2 w2 w3 cos(n*(2phi1-phi2-phi3))>\r
8598  //  7th bin: <3>_{3n|2n,1n} = ...\r
8599  //  8th bin: <3>_{4n|2n,2n} = ...\r
8600  //  9th bin: <3>_{4n|3n,1n} = ...\r
8601  // 10th bin:           ----  EMPTY ----\r
8602  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1nW1W1W1W1 = <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))>\r
8603  // 12th bin: <4>_{2n,1n|2n,1n} = ...\r
8604  // 13th bin: <4>_{2n,2n|2n,2n} = ...\r
8605  // 14th bin: <4>_{3n|1n,1n,1n} = ... \r
8606  // 15th bin: <4>_{3n,1n|3n,1n} = ...\r
8607  // 16th bin: <4>_{3n,1n|2n,2n} = ...\r
8608  // 17th bin: <4>_{4n|2n,1n,1n} = ... \r
8609  // 18th bin:           ----  EMPTY ----\r
8610  // 19th bin: <5>_{2n|1n,1n,1n,1n} = ...\r
8611  // 20th bin: <5>_{2n,2n|2n,1n,1n} = ...\r
8612  // 21st bin: <5>_{3n,1n|2n,1n,1n} = ...\r
8613  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = ...\r
8614  // 23rd bin:           ----  EMPTY ----\r
8615  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = ...\r
8616  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = ...\r
8617  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = ...\r
8618  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = ...\r
8619  // 28th bin:           ----  EMPTY ----\r
8620  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = ...\r
8621  // 30th bin:           ----  EMPTY ----\r
8622  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = ...\r
8623  \r
8624  // Remark 2: When particle weights are used there are some extra correlations. They are stored in \r
8625  // fIntFlowExtraDirectCorrelations binning of which is organized as follows:\r
8626  \r
8627  // 1st bin: two1n1nW3W1 = <w1^3 w2 cos(n*(phi1-phi2))>\r
8628  // 2nd bin: two1n1nW1W1W2 = <w1 w2 w3^2 cos(n*(phi1-phi2))>  \r
8629  // ...\r
8630  \r
8631  Int_t nPrim = anEvent->NumberOfTracks(); \r
8632  AliFlowTrackSimple *aftsTrack = NULL;\r
8633  //Double_t phi1=0., phi2=0., phi3=0., phi4=0., phi5=0., phi6=0., phi7=0., phi8=0.;\r
8634  //Double_t wPhi1=1., wPhi2=1., wPhi3=1., wPhi4=1., wPhi5=1., wPhi6=1., wPhi7=1., wPhi8=1.;\r
8635  Double_t phi1=0., phi2=0., phi3=0., phi4=0.;\r
8636  Double_t wPhi1=1., wPhi2=1., wPhi3=1., wPhi4=1.;\r
8637  Int_t n = fHarmonic; \r
8638  Int_t eventNo = (Int_t)fAvMultiplicity->GetBinEntries(1); // to be improved (is this casting safe in general?)\r
8639  Double_t dMult = (*fSMpk)(0,0);\r
8640  cout<<endl;\r
8641  cout<<"Multiparticle correlations: Event number: "<<eventNo<<", multiplicity is "<<dMult<<endl;\r
8642  if(dMult<2)\r
8643  {\r
8644   cout<<"... skipping this event (multiplicity too low) ..."<<endl;\r
8645  } else if (dMult>fMaxAllowedMultiplicity)\r
8646    {\r
8647     cout<<"... skipping this event (multiplicity too high) ..."<<endl;\r
8648    } else \r
8649      { \r
8650       cout<<"... evaluating nested loops (using particle weights) ..."<<endl;\r
8651      } \r
8652       \r
8653  // 2-particle correlations:       \r
8654  if(nPrim>=2 && nPrim<=fMaxAllowedMultiplicity)\r
8655  {\r
8656   // 2 nested loops multiparticle correlations using particle weights:       \r
8657   for(Int_t i1=0;i1<nPrim;i1++)\r
8658   {\r
8659    aftsTrack=anEvent->GetTrack(i1);\r
8660    if(!(aftsTrack->InRPSelection())) continue;\r
8661    phi1=aftsTrack->Phi();\r
8662    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));\r
8663    for(Int_t i2=0;i2<nPrim;i2++)\r
8664    {\r
8665     if(i2==i1)continue;\r
8666     aftsTrack=anEvent->GetTrack(i2);\r
8667     if(!(aftsTrack->InRPSelection())) continue;\r
8668     phi2=aftsTrack->Phi();\r
8669     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));   \r
8670     if(nPrim==2) cout<<i1<<" "<<i2<<"\r"<<flush;\r
8671     // 2-p correlations using particle weights:\r
8672     if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(0.5,cos(n*(phi1-phi2)),wPhi1*wPhi2);                  // <w1   w2   cos( n*(phi1-phi2))>\r
8673     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
8674     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
8675     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
8676     // extra correlations: \r
8677     // 2-p extra correlations (do not appear if particle weights are not used):\r
8678     if(fUsePhiWeights) fIntFlowExtraDirectCorrelations->Fill(0.5,cos(n*(phi1-phi2)),pow(wPhi1,3)*wPhi2); // <w1^3 w2 cos(n*(phi1-phi2))>\r
8679     // ...\r
8680    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8681   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8682  } // end of if(nPrim>=2)\r
8683 \r
8684  if(nPrim>=3 && nPrim<=fMaxAllowedMultiplicity)\r
8685  { \r
8686   // 3 nested loops multiparticle correlations using particle weights:       \r
8687   for(Int_t i1=0;i1<nPrim;i1++)\r
8688   {\r
8689    aftsTrack=anEvent->GetTrack(i1);\r
8690    if(!(aftsTrack->InRPSelection())) continue;\r
8691    phi1=aftsTrack->Phi();\r
8692    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));\r
8693    for(Int_t i2=0;i2<nPrim;i2++)\r
8694    {\r
8695     if(i2==i1)continue;\r
8696     aftsTrack=anEvent->GetTrack(i2);\r
8697     if(!(aftsTrack->InRPSelection())) continue;\r
8698     phi2=aftsTrack->Phi();\r
8699     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));\r
8700     for(Int_t i3=0;i3<nPrim;i3++)\r
8701     {\r
8702      if(i3==i1||i3==i2)continue;\r
8703      aftsTrack=anEvent->GetTrack(i3);\r
8704      if(!(aftsTrack->InRPSelection())) continue;\r
8705      phi3=aftsTrack->Phi();\r
8706      if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));\r
8707      if(nPrim==3) cout<<i1<<" "<<i2<<" "<<i3<<"\r"<<flush;\r
8708      // 3-p correlations using particle weights:\r
8709      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
8710      // ...\r
8711      // extra correlations: \r
8712      // 2-p extra correlations (do not appear if particle weights are not used):\r
8713       if(fUsePhiWeights) fIntFlowExtraDirectCorrelations->Fill(1.5,cos(n*(phi1-phi2)),wPhi1*wPhi2*pow(wPhi3,2)); // <w1 w2 w3^2 cos(n*(phi1-phi2))>\r
8714      // ...\r
8715      // 3-p extra correlations (do not appear if particle weights are not used):\r
8716      // ...\r
8717     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8718    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8719   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8720  } // end of if(nPrim>=3)\r
8721  \r
8722  if(nPrim>=4 && nPrim<=fMaxAllowedMultiplicity)\r
8723  {\r
8724   // 4 nested loops multiparticle correlations using particle weights:       \r
8725   for(Int_t i1=0;i1<nPrim;i1++)\r
8726   {\r
8727    aftsTrack=anEvent->GetTrack(i1);\r
8728    if(!(aftsTrack->InRPSelection())) continue;\r
8729    phi1=aftsTrack->Phi();\r
8730    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));\r
8731    for(Int_t i2=0;i2<nPrim;i2++)\r
8732    {\r
8733     if(i2==i1)continue;\r
8734     aftsTrack=anEvent->GetTrack(i2);\r
8735     if(!(aftsTrack->InRPSelection())) continue;\r
8736     phi2=aftsTrack->Phi();\r
8737     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));\r
8738     for(Int_t i3=0;i3<nPrim;i3++)\r
8739     {\r
8740      if(i3==i1||i3==i2)continue;\r
8741      aftsTrack=anEvent->GetTrack(i3);\r
8742      if(!(aftsTrack->InRPSelection())) continue;\r
8743      phi3=aftsTrack->Phi();\r
8744      if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));\r
8745      for(Int_t i4=0;i4<nPrim;i4++)\r
8746      {\r
8747       if(i4==i1||i4==i2||i4==i3)continue;\r
8748       aftsTrack=anEvent->GetTrack(i4);\r
8749       if(!(aftsTrack->InRPSelection())) continue;\r
8750       phi4=aftsTrack->Phi();\r
8751       if(fUsePhiWeights && fPhiWeights) wPhi4 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi4*fnBinsPhi/TMath::TwoPi())));\r
8752       if(nPrim>=4) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<"\r"<<flush; // to be improved (replace eventually this if statement with if(nPrim==4))\r
8753       // 4-p correlations using particle weights:\r
8754       if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(10.5,cos(n*phi1+n*phi2-n*phi3-n*phi4),wPhi1*wPhi2*wPhi3*wPhi4); \r
8755       // extra correlations: \r
8756       // 2-p extra correlations (do not appear if particle weights are not used):\r
8757       // ...\r
8758       // 3-p extra correlations (do not appear if particle weights are not used):\r
8759       // ...\r
8760       // 4-p extra correlations (do not appear if particle weights are not used):\r
8761       // ...\r
8762      } // end of for(Int_t i4=0;i4<nPrim;i4++) \r
8763     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8764    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8765   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8766  } // end of if(nPrim>=4)\r
8767 \r
8768  cout<<endl; \r
8769 \r
8770 } // end of void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent)\r
8771 \r
8772 \r
8773 //================================================================================================================================\r
8774 \r
8775 \r
8776 void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowExtraCorrelations()\r
8777 {\r
8778  // Cross-check results for extra multiparticle correlations needed for int. flow \r
8779  // which appear only when particle weights are used: results from Q-vectors vs results from nested loops.\r
8780 \r
8781  cout<<endl;\r
8782  cout<<endl;\r
8783  cout<<"   ***********************************************"<<endl;\r
8784  cout<<"   **** cross-checking the extra correlations ****"<<endl;\r
8785  cout<<"   ****          for integrated flow          ****"<<endl;\r
8786  cout<<"   ***********************************************"<<endl;\r
8787  cout<<endl;\r
8788  cout<<endl;\r
8789  \r
8790  for(Int_t eci=1;eci<=2;eci++) // to be improved (increased eciMax eventually when I calculate 6th and 8th)\r
8791  {\r
8792   if(strcmp((fIntFlowExtraCorrelationsPro->GetXaxis())->GetBinLabel(eci), "") == 0) continue;\r
8793   cout<<(fIntFlowExtraCorrelationsPro->GetXaxis())->GetBinLabel(eci)<<":"<<endl;\r
8794   cout<<"from Q-vectors    = "<<fIntFlowExtraCorrelationsPro->GetBinContent(eci)<<endl;\r
8795   cout<<"from nested loops = "<<fIntFlowExtraDirectCorrelations->GetBinContent(eci)<<endl;\r
8796   cout<<endl;\r
8797  }\r
8798 \r
8799 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowExtraCorrelations()\r
8800 \r
8801 \r
8802 //================================================================================================================================\r
8803 \r
8804 \r
8805 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrectionsForNUAWithNestedLoops(AliFlowEventSimple* anEvent)\r
8806 {\r
8807  // Evaluate with nested loops correction terms for non-uniform acceptance relevant for NONAME integrated flow (to be improved (name)).\r
8808  //\r
8809  // Remark: Both sin and cos correction terms are calculated in this method. Sin terms are stored in fIntFlowDirectCorrectionTermsForNUA[0],\r
8810  // and cos terms in fIntFlowCorrectionTermsForNUAPro[sc]fIntFlowDirectCorrectionTermsForNUA[1]. Binning of fIntFlowDirectCorrectionTermsForNUA[sc] is organized as follows \r
8811  // (sc stands for either sin or cos):\r
8812  \r
8813  //  1st bin: <<sc(n*(phi1))>> \r
8814  //  2nd bin: <<sc(n*(phi1+phi2))>> \r
8815  //  3rd bin: <<sc(n*(phi1-phi2-phi3))>>\r
8816  //  ...\r
8817  \r
8818  Int_t nPrim = anEvent->NumberOfTracks(); \r
8819  AliFlowTrackSimple *aftsTrack = NULL;\r
8820  Double_t phi1=0., phi2=0., phi3=0.;\r
8821  Int_t n = fHarmonic; \r
8822  Int_t eventNo = (Int_t)fAvMultiplicity->GetBinEntries(1); // to be improved (is this casting safe in general?)\r
8823  Double_t dMult = (*fSMpk)(0,0);\r
8824  cout<<endl;\r
8825  cout<<"Correction terms for non-uniform acceptance: Event number: "<<eventNo<<", multiplicity is "<<dMult<<endl;\r
8826  if(dMult<1)\r
8827  {\r
8828   cout<<"... skipping this event (multiplicity too low) ..."<<endl;\r
8829  } else if (dMult>fMaxAllowedMultiplicity)\r
8830    {\r
8831     cout<<"... skipping this event (multiplicity too high) ..."<<endl;\r
8832    } else \r
8833      { \r
8834       cout<<"... evaluating nested loops (without using particle weights)..."<<endl;\r
8835      }\r
8836  \r
8837  if(nPrim>=1 && nPrim<=fMaxAllowedMultiplicity)\r
8838  {\r
8839   // 1-particle correction terms for non-uniform acceptance:       \r
8840   for(Int_t i1=0;i1<nPrim;i1++)\r
8841   {\r
8842    aftsTrack=anEvent->GetTrack(i1);\r
8843    if(!(aftsTrack->InRPSelection())) continue;\r
8844    phi1=aftsTrack->Phi();\r
8845    if(nPrim==1) cout<<i1<<"\r"<<flush;\r
8846    // sin terms:\r
8847    fIntFlowDirectCorrectionTermsForNUA[0]->Fill(0.5,sin(n*phi1),1.); // <sin(n*phi1)>  \r
8848    // cos terms:\r
8849    fIntFlowDirectCorrectionTermsForNUA[1]->Fill(0.5,cos(n*phi1),1.); // <cos(n*phi1)>\r
8850   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8851  } // end of if(nPrim>=1) \r
8852   \r
8853  if(nPrim>=2 && nPrim<=fMaxAllowedMultiplicity)\r
8854  {\r
8855   // 2-particle correction terms for non-uniform acceptance:       \r
8856   for(Int_t i1=0;i1<nPrim;i1++)\r
8857   {\r
8858    aftsTrack=anEvent->GetTrack(i1);\r
8859    if(!(aftsTrack->InRPSelection())) continue;\r
8860    phi1=aftsTrack->Phi();  \r
8861    for(Int_t i2=0;i2<nPrim;i2++)\r
8862    {\r
8863     if(i2==i1)continue;\r
8864     aftsTrack=anEvent->GetTrack(i2);\r
8865     if(!(aftsTrack->InRPSelection())) continue;\r
8866     phi2=aftsTrack->Phi();\r
8867     if(nPrim==2) cout<<i1<<" "<<i2<<"\r"<<flush;\r
8868     // sin terms:\r
8869     fIntFlowDirectCorrectionTermsForNUA[0]->Fill(1.5,sin(n*(phi1+phi2)),1.); // <<sin(n*(phi1+phi2))>>\r
8870     // cos terms:\r
8871     fIntFlowDirectCorrectionTermsForNUA[1]->Fill(1.5,cos(n*(phi1+phi2)),1.); // <<cos(n*(phi1+phi2))>>\r
8872    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8873   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8874  } // end of if(nPrim>=2)\r
8875 \r
8876  if(nPrim>=3 && nPrim<=fMaxAllowedMultiplicity)\r
8877  {\r
8878   // 3-particle correction terms for non-uniform acceptance:       \r
8879   for(Int_t i1=0;i1<nPrim;i1++)\r
8880   {\r
8881    aftsTrack=anEvent->GetTrack(i1);\r
8882    if(!(aftsTrack->InRPSelection())) continue;\r
8883    phi1=aftsTrack->Phi();\r
8884    for(Int_t i2=0;i2<nPrim;i2++)\r
8885    {\r
8886     if(i2==i1)continue;\r
8887     aftsTrack=anEvent->GetTrack(i2);\r
8888     if(!(aftsTrack->InRPSelection())) continue;\r
8889     phi2=aftsTrack->Phi();\r
8890     for(Int_t i3=0;i3<nPrim;i3++)\r
8891     {\r
8892      if(i3==i1||i3==i2)continue;\r
8893      aftsTrack=anEvent->GetTrack(i3);\r
8894      if(!(aftsTrack->InRPSelection())) continue;\r
8895      phi3=aftsTrack->Phi();\r
8896      if(nPrim>=3) cout<<i1<<" "<<i2<<" "<<i3<<"\r"<<flush; // to be improved (eventually I will change this if statement)\r
8897      // sin terms:\r
8898      fIntFlowDirectCorrectionTermsForNUA[0]->Fill(2.5,sin(n*(phi1-phi2-phi3)),1.); // <<sin(n*(phi1-phi2-phi3))>>\r
8899      // cos terms:\r
8900      fIntFlowDirectCorrectionTermsForNUA[1]->Fill(2.5,cos(n*(phi1-phi2-phi3)),1.); // <<cos(n*(phi1-phi2-phi3))>>\r
8901     } // end of for(Int_t i3=0;i3<nPrim;i3++)\r
8902    } // end of for(Int_t i2=0;i2<nPrim;i2++)\r
8903   } // end of for(Int_t i1=0;i1<nPrim;i1++)\r
8904  } // end of if(nPrim>=3)\r
8905 \r
8906  cout<<endl;\r
8907 }\r
8908 //================================================================================================================================\r
8909 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoops(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)\r
8910 {\r
8911  // Evaluate reduced correlations with nested loops without using the particle weights.\r
8912  \r
8913  // Remark 1: Reduced correlations are evaluated in pt bin number fCrossCheckInPtBinNo and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.\r
8914  // Remark 2: Results are stored in 1 bin profiles fDiffFlowDirectCorrelations[t][pe][ci], where indices runs as follows:\r
8915  //           [0=RP,1=POI][0=Pt,1=Eta][0=<2'>,1=<4'>,2=<6'>,3=<8'>] \r
8916  // Remark 3: <2'> = <cos(n*(psi1-phi2))>\r
8917  //           <4'> = <cos(n*(psi1+phi2-phi3-phi4))>\r
8918  // ...\r
8919  \r
8920  Int_t typeFlag = -1;\r
8921  Int_t ptEtaFlag = -1;\r
8922  if(type == "RP")\r
8923  {\r
8924   typeFlag = 0;\r
8925  } else if(type == "POI")\r
8926    {\r
8927     typeFlag = 1;\r
8928    }      \r
8929  if(ptOrEta == "Pt")\r
8930  {\r
8931   ptEtaFlag = 0;\r
8932  } else if(ptOrEta == "Eta")\r
8933    {\r
8934     ptEtaFlag = 1;\r
8935    } \r
8936  // shortcuts:\r
8937  Int_t t = typeFlag;\r
8938  Int_t pe = ptEtaFlag;\r
8939       \r
8940  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};\r
8941  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};\r
8942  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
8943  \r
8944  Int_t nPrim = anEvent->NumberOfTracks(); \r
8945  AliFlowTrackSimple *aftsTrack = NULL;\r
8946  \r
8947  Double_t psi1=0., phi2=0., phi3=0., phi4=0.;// phi5=0., phi6=0., phi7=0., phi8=0.;\r
8948  \r
8949  Int_t n = fHarmonic; \r
8950  \r
8951  // 2'-particle correlations:\r
8952  for(Int_t i1=0;i1<nPrim;i1++)\r
8953  {\r
8954   aftsTrack=anEvent->GetTrack(i1);\r
8955   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)\r
8956   if(ptOrEta == "Pt")\r
8957   { \r
8958    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;\r
8959   } else if (ptOrEta == "Eta")\r
8960     {\r
8961      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    \r
8962     }\r
8963   psi1=aftsTrack->Phi(); \r
8964   for(Int_t i2=0;i2<nPrim;i2++)\r
8965   {\r
8966    if(i2==i1)continue;\r
8967    aftsTrack=anEvent->GetTrack(i2);\r
8968    // RP condition (!(first) particle in the correlator must be RP):\r
8969    if(!(aftsTrack->InRPSelection()))continue;\r
8970    phi2=aftsTrack->Phi();   \r
8971    // 2'-particle correlations: \r
8972    fDiffFlowDirectCorrelations[t][pe][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(1.*n*(psi1-phi2)),1.); // <cos(n*(psi1-phi2))  \r
8973   }//end of for(Int_t i2=0;i2<nPrim;i2++)\r
8974  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
8975  \r
8976  /*\r
8977  \r
8978  // 3'-particle correlations:\r
8979  for(Int_t i1=0;i1<nPrim;i1++)\r
8980  {\r
8981   aftsTrack=anEvent->GetTrack(i1);\r
8982   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)\r
8983   if(ptOrEta == "Pt")\r
8984   { \r
8985    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;\r
8986   } else if (ptOrEta == "Eta")\r
8987     {\r
8988      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    \r
8989     }\r
8990   psi1=aftsTrack->Phi();\r
8991   for(Int_t i2=0;i2<nPrim;i2++)\r
8992   {\r
8993    if(i2==i1)continue;\r
8994    aftsTrack=anEvent->GetTrack(i2);\r
8995    // RP condition (!(first) particle in the correlator must be RP):\r
8996    if(!(aftsTrack->InRPSelection())) continue;\r
8997    phi2=aftsTrack->Phi();\r
8998    for(Int_t i3=0;i3<nPrim;i3++)\r
8999    {\r
9000     if(i3==i1||i3==i2)continue;\r
9001     aftsTrack=anEvent->GetTrack(i3);\r
9002     // RP condition (!(first) particle in the correlator must be RP):\r
9003     if(!(aftsTrack->InRPSelection())) continue;\r
9004     phi3=aftsTrack->Phi();\r
9005     // 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))> \r
9006    }//end of for(Int_t i3=0;i3<nPrim;i3++)  \r
9007   }//end of for(Int_t i2=0;i2<nPrim;i2++)  \r
9008  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
9009  \r
9010  */\r
9011  \r
9012  // 4'-particle correlations:\r
9013  for(Int_t i1=0;i1<nPrim;i1++)\r
9014  {\r
9015   aftsTrack=anEvent->GetTrack(i1);\r
9016   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)\r
9017   if(ptOrEta == "Pt")\r
9018   { \r
9019    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;\r
9020   } else if (ptOrEta == "Eta")\r
9021     {\r
9022      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    \r
9023     }\r
9024   psi1=aftsTrack->Phi();\r
9025   for(Int_t i2=0;i2<nPrim;i2++)\r
9026   {\r
9027    if(i2==i1) continue;\r
9028    aftsTrack=anEvent->GetTrack(i2);\r
9029    // RP condition (!(first) particle in the correlator must be RP): \r
9030    if(!(aftsTrack->InRPSelection())) continue;\r
9031    phi2=aftsTrack->Phi();\r
9032    for(Int_t i3=0;i3<nPrim;i3++)\r
9033    { \r
9034     if(i3==i1||i3==i2) continue;\r
9035     aftsTrack=anEvent->GetTrack(i3);\r
9036     // RP condition (!(first) particle in the correlator must be RP):\r
9037     if(!(aftsTrack->InRPSelection())) continue;\r
9038     phi3=aftsTrack->Phi();\r
9039     for(Int_t i4=0;i4<nPrim;i4++)\r
9040     {\r
9041      if(i4==i1||i4==i2||i4==i3) continue;\r
9042      aftsTrack=anEvent->GetTrack(i4);\r
9043      // RP condition (!(first) particle in the correlator must be RP):\r
9044      if(!(aftsTrack->InRPSelection())) continue;  \r
9045      phi4=aftsTrack->Phi();\r
9046      // 4'-particle correlations:\r
9047      fDiffFlowDirectCorrelations[t][pe][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2-phi3-phi4)),1.); // <cos(n(psi1+phi2-phi3-phi4))>     \r
9048     }//end of for(Int_t i4=0;i4<nPrim;i4++)\r
9049    }//end of for(Int_t i3=0;i3<nPrim;i3++)\r
9050   }//end of for(Int_t i2=0;i2<nPrim;i2++) \r
9051  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
9052       \r
9053  \r
9054 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoops(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)\r
9055 \r
9056 \r
9057 //================================================================================================================================\r
9058 \r
9059 \r
9060 void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrelations(TString type, TString ptOrEta)\r
9061 {\r
9062  // Compare correlations needed for diff. flow calculated with nested loops and those calculated from Q-vectors\r
9063  \r
9064  Int_t typeFlag = -1;\r
9065  Int_t ptEtaFlag = -1;\r
9066  if(type == "RP")\r
9067  {\r
9068   typeFlag = 0;\r
9069  } else if(type == "POI")\r
9070    {\r
9071     typeFlag = 1;\r
9072    }      \r
9073  if(ptOrEta == "Pt")\r
9074  {\r
9075   ptEtaFlag = 0;\r
9076  } else if(ptOrEta == "Eta")\r
9077    {\r
9078     ptEtaFlag = 1;\r
9079    } \r
9080  // shortcuts:\r
9081  Int_t t = typeFlag;\r
9082  Int_t pe = ptEtaFlag;\r
9083       \r
9084  TString rpORpoiString[2] = {"RP ","POI"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) \r
9085  TString ptORetaString[2] = {"pt","eta"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) \r
9086  TString reducedCorrelations[4] = {"<<cos(n(psi1-phi2))>>","<<cos(n(psi1+phi2-phi3-phi4))>>","",""}; // to be improved (access this from pro or hist)\r
9087  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};\r
9088  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};\r
9089  \r
9090  Int_t crossCheckInPtEtaBinNo[2] = {fCrossCheckInPtBinNo,fCrossCheckInEtaBinNo};\r
9091  \r
9092 \r
9093  cout<<endl;\r
9094  cout<<"   *****************************************"<<endl;\r
9095  cout<<"   **** cross-checking the correlations ****"<<endl;\r
9096  cout<<"   ****      for differential flow      ****"<<endl;\r
9097  cout<<"   ****               "<<rpORpoiString[t]<<"               ****"<<endl;\r
9098  cout<<"   *****************************************"<<endl; \r
9099  cout<<endl;\r
9100  cout<<"           "<<ptORetaString[pe]<<" bin: "<<lowerPtEtaEdge[pe]<<" <= "<<ptORetaString[pe]<<" < "<<upperPtEtaEdge[pe]<<endl;\r
9101  cout<<endl;\r
9102  \r
9103  for(Int_t rci=0;rci<2;rci++) // to be improved (calculate 6th and 8th order)\r
9104  {\r
9105   cout<<"      "<<reducedCorrelations[rci].Data()<<":"<<endl;\r
9106   cout<<"      from Q-vectors    = "<<fDiffFlowCorrelationsPro[t][pe][rci]->GetBinContent(crossCheckInPtEtaBinNo[pe])<<endl;\r
9107   cout<<"      from nested loops = "<<fDiffFlowDirectCorrelations[t][pe][rci]->GetBinContent(1)<<endl;\r
9108   cout<<endl;  \r
9109  } // end of for(Int_t rci=0;rci<4;rci++)\r
9110        \r
9111 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrelations(TString type, TString ptOrEta)\r
9112 \r
9113 \r
9114 //================================================================================================================================\r
9115 \r
9116 \r
9117 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)\r
9118 {\r
9119  // Evaluate reduced correlations with nested loops without using the particle weights.\r
9120  \r
9121  // Remark 1: Reduced correlations are evaluated in pt bin number fCrossCheckInPtBinNo and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.\r
9122  // Remark 2: Results are stored in 1 bin profiles fDiffFlowDirectCorrelations[t][pe][ci], where indices runs as follows:\r
9123  //           [0=RP,1=POI][0=Pt,1=Eta][0=<2'>,1=<4'>,2=<6'>,3=<8'>] \r
9124  // Remark 3: <2'> = <w2 cos(n*(psi1-phi2))>\r
9125  //           <4'> = <w2 w3 w4 cos(n*(psi1+phi2-phi3-phi4))>\r
9126  // ...\r
9127   \r
9128  Int_t typeFlag = -1;\r
9129  Int_t ptEtaFlag = -1;\r
9130  if(type == "RP")\r
9131  {\r
9132   typeFlag = 0;\r
9133  } else if(type == "POI")\r
9134    {\r
9135     typeFlag = 1;\r
9136    }      \r
9137  if(ptOrEta == "Pt")\r
9138  {\r
9139   ptEtaFlag = 0;\r
9140  } else if(ptOrEta == "Eta")\r
9141    {\r
9142     ptEtaFlag = 1;\r
9143    } \r
9144  // shortcuts:\r
9145  Int_t t = typeFlag;\r
9146  Int_t pe = ptEtaFlag;\r
9147       \r
9148  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};\r
9149  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};\r
9150  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
9151  \r
9152  Int_t nPrim = anEvent->NumberOfTracks(); \r
9153  AliFlowTrackSimple *aftsTrack = NULL;\r
9154  \r
9155  Double_t psi1=0., phi2=0., phi3=0., phi4=0.;// phi5=0., phi6=0., phi7=0., phi8=0.;\r
9156  Double_t wPhi2=1., wPhi3=1., wPhi4=1.;// wPhi5=1., wPhi6=1., wPhi7=1., wPhi8=1.;\r
9157  \r
9158  Int_t n = fHarmonic; \r
9159  \r
9160  // 2'-particle correlations:\r
9161  for(Int_t i1=0;i1<nPrim;i1++)\r
9162  {\r
9163   aftsTrack=anEvent->GetTrack(i1);\r
9164   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)\r
9165   if(ptOrEta == "Pt")\r
9166   { \r
9167    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;\r
9168   } else if (ptOrEta == "Eta")\r
9169     {\r
9170      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;    \r
9171     }\r
9172   psi1=aftsTrack->Phi(); \r
9173   for(Int_t i2=0;i2<nPrim;i2++)\r
9174   {\r
9175    if(i2==i1) continue;\r
9176    aftsTrack=anEvent->GetTrack(i2);\r
9177    // RP condition (!(first) particle in the correlator must be RP):\r
9178    if(!(aftsTrack->InRPSelection())) continue;\r
9179    phi2=aftsTrack->Phi();   \r
9180    if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));\r
9181    // 2'-particle correlations: \r
9182    fDiffFlowDirectCorrelations[t][pe][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(1.*n*(psi1-phi2)),wPhi2); // <w2 cos(n*(psi1-phi2))  \r
9183   }//end of for(Int_t i2=0;i2<nPrim;i2++)\r
9184  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
9185  \r
9186  // 4'-particle correlations:\r
9187  for(Int_t i1=0;i1<nPrim;i1++)\r
9188  {\r
9189   aftsTrack=anEvent->GetTrack(i1);\r
9190   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)\r
9191   if(ptOrEta == "Pt")\r
9192   { \r
9193    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;\r
9194   } else if (ptOrEta == "Eta")\r
9195     {\r
9196      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;    \r
9197     }\r
9198   psi1=aftsTrack->Phi();\r
9199   for(Int_t i2=0;i2<nPrim;i2++)\r
9200   {\r
9201    if(i2==i1) continue;\r
9202    aftsTrack=anEvent->GetTrack(i2);\r
9203    // RP condition (!(first) particle in the correlator must be RP): \r
9204    if(!(aftsTrack->InRPSelection())) continue;\r
9205    phi2=aftsTrack->Phi();\r
9206    if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));\r
9207    for(Int_t i3=0;i3<nPrim;i3++)\r
9208    { \r
9209     if(i3==i1||i3==i2) continue;\r
9210     aftsTrack=anEvent->GetTrack(i3);\r
9211     // RP condition (!(first) particle in the correlator must be RP):\r
9212     if(!(aftsTrack->InRPSelection())) continue;\r
9213     phi3=aftsTrack->Phi();\r
9214     if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));\r
9215     for(Int_t i4=0;i4<nPrim;i4++)\r
9216     {\r
9217      if(i4==i1||i4==i2||i4==i3) continue;\r
9218      aftsTrack=anEvent->GetTrack(i4);\r
9219      // RP condition (!(first) particle in the correlator must be RP):\r
9220      if(!(aftsTrack->InRPSelection())) continue;  \r
9221      phi4=aftsTrack->Phi();\r
9222      if(fUsePhiWeights && fPhiWeights) wPhi4 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi4*fnBinsPhi/TMath::TwoPi())));\r
9223      // 4'-particle correlations <w2 w3 w4 cos(n(psi1+phi2-phi3-phi4))>:\r
9224      fDiffFlowDirectCorrelations[t][pe][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2-phi3-phi4)),wPhi2*wPhi3*wPhi4); \r
9225     }//end of for(Int_t i4=0;i4<nPrim;i4++)\r
9226    }//end of for(Int_t i3=0;i3<nPrim;i3++)\r
9227   }//end of for(Int_t i2=0;i2<nPrim;i2++) \r
9228  }//end of for(Int_t i1=0;i1<nPrim;i1++)      \r
9229  \r
9230 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)\r
9231 \r
9232 \r
9233 //================================================================================================================================\r
9234 \r
9235    \r
9236 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)\r
9237 {\r
9238  // Evaluate with nested loops correction terms for non-uniform acceptance (both sin and cos terms) relevant for differential flow.\r
9239  \r
9240  // Remark 1: Reduced correction terms for non-uniform acceptance are evaluated in pt bin number fCrossCheckInPtBinNo \r
9241  //           and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.\r
9242  // Remark 2: Results are stored in 1 bin profiles fDiffFlowDirectCorrections[t][pe][sc][cti], where first three indices runs as: \r
9243  //           [0=RP,1=POI][0=Pt,1=Eta][0=sin terms,1=cos terms], whilst the cti (correction term index) runs as follows: \r
9244  //  cti: \r
9245  //    0: <<sc n(psi1)>>\r
9246  //    1: <<sc n(psi1+phi2)>> \r
9247  //    2: <<sc n(psi1+phi2-phi3)>>\r
9248  //    3: <<sc n(psi1-phi2-phi3)>>\r
9249  //    4:\r
9250  //    5:\r
9251  //    6:\r
9252   \r
9253  Int_t typeFlag = -1;\r
9254  Int_t ptEtaFlag = -1;\r
9255  if(type == "RP")\r
9256  {\r
9257   typeFlag = 0;\r
9258  } else if(type == "POI")\r
9259    {\r
9260     typeFlag = 1;\r
9261    }      \r
9262  if(ptOrEta == "Pt")\r
9263  {\r
9264   ptEtaFlag = 0;\r
9265  } else if(ptOrEta == "Eta")\r
9266    {\r
9267     ptEtaFlag = 1;\r
9268    } \r
9269  // shortcuts:\r
9270  Int_t t = typeFlag;\r
9271  Int_t pe = ptEtaFlag;\r
9272       \r
9273  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};\r
9274  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};\r
9275  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};\r
9276  \r
9277  Int_t nPrim = anEvent->NumberOfTracks(); \r
9278  AliFlowTrackSimple *aftsTrack = NULL;\r
9279  \r
9280  Double_t psi1=0., phi2=0., phi3=0.;// phi4=0.;// phi5=0., phi6=0., phi7=0., phi8=0.;\r
9281  \r
9282  Int_t n = fHarmonic; \r
9283  \r
9284  // 1-particle correction terms:\r
9285  for(Int_t i1=0;i1<nPrim;i1++)\r
9286  {\r
9287   aftsTrack=anEvent->GetTrack(i1);\r
9288   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)\r
9289   if(ptOrEta == "Pt")\r
9290   { \r
9291    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;\r
9292   } else if (ptOrEta == "Eta")\r
9293     {\r
9294      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;    \r
9295     }\r
9296   psi1=aftsTrack->Phi(); \r
9297   // sin terms: \r
9298   fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*psi1),1.); // <<sin(n*(psi1))>>  \r
9299   // cos terms: \r
9300   fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*psi1),1.); // <<cos(n*(psi1))>>  \r
9301  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
9302    \r
9303  // 2-particle correction terms:\r
9304  for(Int_t i1=0;i1<nPrim;i1++)\r
9305  {\r
9306   aftsTrack=anEvent->GetTrack(i1);\r
9307   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)\r
9308   if(ptOrEta == "Pt")\r
9309   { \r
9310    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;\r
9311   } else if (ptOrEta == "Eta")\r
9312     {\r
9313      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection()))) continue;    \r
9314     }\r
9315   psi1=aftsTrack->Phi(); \r
9316   for(Int_t i2=0;i2<nPrim;i2++)\r
9317   {\r
9318    if(i2==i1) continue;\r
9319    aftsTrack=anEvent->GetTrack(i2);\r
9320    // RP condition (!(first) particle in the correlator must be RP):\r
9321    if(!(aftsTrack->InRPSelection())) continue;\r
9322    phi2=aftsTrack->Phi();   \r
9323    // sin terms: \r
9324    fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1+phi2)),1.); // <<sin(n*(psi1+phi2))>>  \r
9325    // cos terms: \r
9326    fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2)),1.); // <<cos(n*(psi1+phi2))>>  \r
9327   }//end of for(Int_t i2=0;i2<nPrim;i2++)\r
9328  }//end of for(Int_t i1=0;i1<nPrim;i1++)   \r
9329  \r
9330  // 3-particle correction terms:\r
9331  for(Int_t i1=0;i1<nPrim;i1++)\r
9332  {\r
9333   aftsTrack=anEvent->GetTrack(i1);\r
9334   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)\r
9335   if(ptOrEta == "Pt")\r
9336   { \r
9337    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;\r
9338   } else if (ptOrEta == "Eta")\r
9339     {\r
9340      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    \r
9341     }\r
9342   psi1=aftsTrack->Phi();\r
9343   for(Int_t i2=0;i2<nPrim;i2++)\r
9344   {\r
9345    if(i2==i1) continue;\r
9346    aftsTrack=anEvent->GetTrack(i2);\r
9347    // RP condition (!(first) particle in the correlator must be RP):\r
9348    if(!(aftsTrack->InRPSelection())) continue;\r
9349    phi2=aftsTrack->Phi();\r
9350    for(Int_t i3=0;i3<nPrim;i3++)\r
9351    {\r
9352     if(i3==i1||i3==i2) continue;\r
9353     aftsTrack=anEvent->GetTrack(i3);\r
9354     // RP condition (!(first) particle in the correlator must be RP):\r
9355     if(!(aftsTrack->InRPSelection())) continue;\r
9356     phi3=aftsTrack->Phi();\r
9357     // sin terms: \r
9358     fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][2]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1+phi2-phi3)),1.); // <<sin(n*(psi1+phi2-phi3))>>  \r
9359     fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][3]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1-phi2-phi3)),1.); // <<sin(n*(psi1-phi2-phi3))>>  \r
9360     // cos terms: \r
9361     fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][2]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2-phi3)),1.); // <<cos(n*(psi1+phi2-phi3))>>  \r
9362     fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][3]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1-phi2-phi3)),1.); // <<cos(n*(psi1-phi2-phi3))>>  \r
9363    }//end of for(Int_t i3=0;i3<nPrim;i3++)  \r
9364   }//end of for(Int_t i2=0;i2<nPrim;i2++)  \r
9365  }//end of for(Int_t i1=0;i1<nPrim;i1++)\r
9366    \r
9367 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)\r
9368 \r
9369 \r
9370 //================================================================================================================================\r
9371 \r
9372 \r
9373 void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrectionTermsForNUA(TString type, TString ptOrEta)\r
9374 {\r
9375  // Compare corrections temrs for non-uniform acceptance needed for diff. flow calculated with nested loops and those calculated from Q-vectors\r
9376  \r
9377  Int_t typeFlag = -1;\r
9378  Int_t ptEtaFlag = -1;\r
9379  if(type == "RP")\r
9380  {\r
9381   typeFlag = 0;\r
9382  } else if(type == "POI")\r
9383    {\r
9384     typeFlag = 1;\r
9385    }      \r
9386  if(ptOrEta == "Pt")\r
9387  {\r
9388   ptEtaFlag = 0;\r
9389  } else if(ptOrEta == "Eta")\r
9390    {\r
9391     ptEtaFlag = 1;\r
9392    } \r
9393  // shortcuts:\r
9394  Int_t t = typeFlag;\r
9395  Int_t pe = ptEtaFlag;\r
9396       \r
9397  TString rpORpoiString[2] = {"RP ","POI"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) \r
9398  TString ptORetaString[2] = {"pt","eta"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) \r
9399  //TString sinCosFlag[2] = {"sin","cos"}; // to be improved (eventually promote to data member)\r
9400  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
9401  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
9402  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};\r
9403  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};\r
9404  \r
9405  Int_t crossCheckInPtEtaBinNo[2] = {fCrossCheckInPtBinNo,fCrossCheckInEtaBinNo};\r
9406  \r
9407  cout<<endl;\r
9408  cout<<"   ******************************************"<<endl;\r
9409  cout<<"   ****  cross-checking the correction   ****"<<endl;\r
9410  cout<<"   **** terms for non-uniform acceptance ****"<<endl;\r
9411  cout<<"   ****      for differential flow       ****"<<endl;\r
9412  cout<<"   ****              "<<rpORpoiString[t]<<"                 ****"<<endl;\r
9413  cout<<"   ******************************************"<<endl; \r
9414  cout<<endl;\r
9415  cout<<"           "<<ptORetaString[pe]<<" bin: "<<lowerPtEtaEdge[pe]<<" <= "<<ptORetaString[pe]<<" < "<<upperPtEtaEdge[pe]<<endl;\r
9416  cout<<endl;\r
9417  \r
9418  for(Int_t cti=0;cti<4;cti++) // correction term index\r
9419  {\r
9420   for(Int_t sc=0;sc<2;sc++) // sin or cos terms\r
9421   {\r
9422    if(sc==0) // to be improved (this can be implemented better)\r
9423    { \r
9424     cout<<"      "<<reducedCorrectionSinTerms[cti].Data()<<":"<<endl;\r
9425    } else\r
9426      {\r
9427       cout<<"      "<<reducedCorrectionCosTerms[cti].Data()<<":"<<endl;     \r
9428      }\r
9429    cout<<"      from Q-vectors    = "<<fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti]->GetBinContent(crossCheckInPtEtaBinNo[pe])<<endl;\r
9430    cout<<"      from nested loops = "<<fDiffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti]->GetBinContent(1)<<endl;\r
9431    cout<<endl;  \r
9432   } \r
9433  } // end of for(Int_t rci=0;rci<4;rci++)\r
9434 \r
9435 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrectionTermsForNUA(TString type, TString ptOrEta)\r
9436 \r
9437 \r
9438 //================================================================================================================================\r