]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/FLOW/Base/AliFlowAnalysisWithQCumulants.cxx
32330db11b5ea087b1916f3b07ce78bea3c0f84f
[u/mrichter/AliRoot.git] / PWG / FLOW / Base / AliFlowAnalysisWithQCumulants.cxx
1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  * 
14 **************************************************************************/
15
16 /********************************** 
17  * flow analysis with Q-cumulants * 
18  *                                * 
19  * author: Ante Bilandzic         * 
20  *        (abilandzic@gmail.com)  *
21  *********************************/ 
22
23 #define AliFlowAnalysisWithQCumulants_cxx
24
25 #include "Riostream.h"
26 #include "AliFlowCommonConstants.h"
27 #include "AliFlowCommonHist.h"
28 #include "AliFlowCommonHistResults.h"
29 #include "TChain.h"
30
31 #include "TFile.h"
32 #include "TList.h"
33 #include "TGraph.h"
34 #include "TParticle.h"
35 #include "TRandom3.h"
36 #include "TStyle.h"
37 #include "TProfile.h"
38 #include "TProfile2D.h" 
39 #include "TMath.h"
40 #include "TArrow.h"
41 #include "TPaveLabel.h"
42 #include "TCanvas.h"
43 #include "AliFlowEventSimple.h"
44 #include "AliFlowTrackSimple.h"
45 #include "AliFlowAnalysisWithQCumulants.h"
46 #include "TArrayD.h"
47 #include "TRandom.h"
48 #include "TF1.h"
49
50 class TH1;
51 class TH2;
52 class TGraph;
53 class TPave;
54 class TLatex;
55 class TMarker;
56 class TRandom3;
57 class TObjArray;
58 class TList;
59 class TCanvas;
60 class TSystem;
61 class TROOT;
62 class AliFlowVector;
63 class TVector;
64
65 //================================================================================================================
66
67 using std::endl;
68 using std::cout;
69 using std::flush;
70 ClassImp(AliFlowAnalysisWithQCumulants)
71
72 AliFlowAnalysisWithQCumulants::AliFlowAnalysisWithQCumulants(): 
73  // 0.) base:
74  fHistList(NULL),
75  // 1.) common:
76  fBookOnlyBasicCCH(kTRUE),
77  fCommonHists(NULL),
78  fCommonHists2nd(NULL), 
79  fCommonHists4th(NULL),
80  fCommonHists6th(NULL),
81  fCommonHists8th(NULL),
82  fCommonHistsResults2nd(NULL),
83  fCommonHistsResults4th(NULL),
84  fCommonHistsResults6th(NULL),
85  fCommonHistsResults8th(NULL),
86  fnBinsPhi(0),
87  fPhiMin(0),
88  fPhiMax(0),
89  fPhiBinWidth(0),
90  fnBinsPt(0),
91  fPtMin(0),
92  fPtMax(0),
93  fPtBinWidth(0),
94  fnBinsEta(0),
95  fEtaMin(0),
96  fEtaMax(0),
97  fEtaBinWidth(0),
98  fCommonConstants(NULL),
99  fFillMultipleControlHistograms(kFALSE),
100  fHarmonic(2),
101  fAnalysisLabel(NULL),
102  // 2a.) particle weights:
103  fWeightsList(NULL),
104  fUsePhiWeights(kFALSE),
105  fUsePtWeights(kFALSE),
106  fUseEtaWeights(kFALSE),
107  fUseTrackWeights(kFALSE),
108  fUseParticleWeights(NULL),
109  fPhiWeights(NULL),
110  fPtWeights(NULL),
111  fEtaWeights(NULL),
112  // 2b.) event weights:
113  fMultiplicityWeight(NULL),
114  // 3.) integrated flow:
115  fIntFlowList(NULL), 
116  fIntFlowProfiles(NULL),
117  fIntFlowResults(NULL),
118  fIntFlowAllCorrelationsVsM(NULL),
119  fIntFlowFlags(NULL),
120  fApplyCorrectionForNUA(kFALSE),  
121  fApplyCorrectionForNUAVsM(kFALSE),
122  fnBinsMult(10000),
123  fMinMult(0.),  
124  fMaxMult(10000.), 
125  fPropagateErrorAlsoFromNIT(kFALSE), 
126  fCalculateCumulantsVsM(kFALSE),
127  fCalculateAllCorrelationsVsM(kFALSE), 
128  fMinimumBiasReferenceFlow(kTRUE), 
129  fForgetAboutCovariances(kFALSE), 
130  fStorePhiDistributionForOneEvent(kFALSE),
131  fReQ(NULL),
132  fImQ(NULL),
133  fSpk(NULL),
134  fIntFlowCorrelationsEBE(NULL),
135  fIntFlowEventWeightsForCorrelationsEBE(NULL),
136  fIntFlowCorrelationsAllEBE(NULL),
137  fReferenceMultiplicityEBE(0.),  
138  fAvMultiplicity(NULL),
139  fIntFlowCorrelationsPro(NULL),
140  fIntFlowSquaredCorrelationsPro(NULL),
141  fIntFlowCorrelationsAllPro(NULL),
142  fIntFlowExtraCorrelationsPro(NULL),
143  fIntFlowProductOfCorrelationsPro(NULL),
144  fIntFlowProductOfCorrectionTermsForNUAPro(NULL),
145  fIntFlowCorrelationsHist(NULL),
146  fIntFlowCorrelationsAllHist(NULL),
147  fIntFlowCovariances(NULL),
148  fIntFlowSumOfProductOfEventWeights(NULL),
149  fIntFlowCovariancesNUA(NULL),
150  fIntFlowSumOfProductOfEventWeightsNUA(NULL),
151  fIntFlowQcumulants(NULL),
152  fIntFlowQcumulantsRebinnedInM(NULL), 
153  fIntFlowQcumulantsErrorSquaredRatio(NULL), 
154  fIntFlow(NULL),
155  fIntFlowRebinnedInM(NULL),
156  fIntFlowDetectorBias(NULL),
157  // 4.) differential flow:
158  fDiffFlowList(NULL),
159  fDiffFlowProfiles(NULL),
160  fDiffFlowResults(NULL),
161  fDiffFlow2D(NULL),
162  fDiffFlowFlags(NULL),
163  fCalculateDiffFlow(kTRUE),
164  fCalculate2DDiffFlow(kFALSE),
165  fCalculateDiffFlowVsEta(kTRUE),
166  // 5.) other differential correlators:
167  fOtherDiffCorrelatorsList(NULL),
168  // 6.) distributions:
169  fDistributionsList(NULL),
170  fDistributionsFlags(NULL),
171  fStoreDistributions(kFALSE),
172  // 7.) various:
173  fVariousList(NULL),
174  fPhiDistributionForOneEvent(NULL),
175  // x.) debugging and cross-checking:
176  fNestedLoopsList(NULL),
177  fEvaluateIntFlowNestedLoops(kFALSE),
178  fEvaluateDiffFlowNestedLoops(kFALSE),
179  fMaxAllowedMultiplicity(10),
180  fEvaluateNestedLoops(NULL),
181  fIntFlowDirectCorrelations(NULL),
182  fIntFlowExtraDirectCorrelations(NULL),
183  fCrossCheckInPtBinNo(10),
184  fCrossCheckInEtaBinNo(20),
185  fNoOfParticlesInBin(NULL)
186  {
187   // constructor  
188   
189   // base list to hold all output objects:
190   fHistList = new TList();
191   fHistList->SetName("cobjQC");
192   fHistList->SetOwner(kTRUE);
193   
194   // list to hold histograms with phi, pt and eta weights:      
195   fWeightsList = new TList();
196   
197   // multiplicity weight:
198   fMultiplicityWeight = new TString("combinations");
199     
200   // analysis label;
201   fAnalysisLabel = new TString();
202       
203   // initialize all arrays:  
204   this->InitializeArraysForIntFlow();
205   this->InitializeArraysForDiffFlow();
206   this->InitializeArraysForDistributions();
207   this->InitializeArraysForVarious();
208   this->InitializeArraysForNestedLoops();
209   
210  } // end of constructor
211  
212 //================================================================================================================  
213
214 AliFlowAnalysisWithQCumulants::~AliFlowAnalysisWithQCumulants()
215 {
216  // destructor
217  
218  delete fHistList;
219
220 } // end of AliFlowAnalysisWithQCumulants::~AliFlowAnalysisWithQCumulants()
221
222 //================================================================================================================
223
224 void AliFlowAnalysisWithQCumulants::Init()
225 {
226  // a) Cross check if the settings make sense before starting the QC adventure;
227  // b) Access all common constants;
228  // c) Book all objects;
229  // d) Store flags for integrated and differential flow;
230  // e) Store flags for distributions of corelations;
231  // f) Store harmonic which will be estimated.
232   
233  //save old value and prevent histograms from being added to directory
234  //to avoid name clashes in case multiple analaysis objects are used
235  //in an analysis
236  Bool_t oldHistAddStatus = TH1::AddDirectoryStatus();
237  TH1::AddDirectory(kFALSE);
238  
239  // a) Cross check if the settings make sense before starting the QC adventure; 
240  this->CrossCheckSettings();
241  // b) Access all common constants and book a profile to hold them:
242  this->CommonConstants("Init");
243  // c) Book all objects:
244  this->BookAndFillWeightsHistograms(); 
245  this->BookAndNestAllLists();
246  this->BookCommonHistograms();
247  this->BookEverythingForIntegratedFlow(); 
248  this->BookEverythingForDifferentialFlow(); 
249  this->BookEverythingFor2DDifferentialFlow(); 
250  this->BookEverythingForDistributions();
251  this->BookEverythingForVarious();
252  this->BookEverythingForNestedLoops();
253  // d) Store flags for integrated and differential flow:
254  this->StoreIntFlowFlags();
255  this->StoreDiffFlowFlags();
256  // e) Store flags for distributions of corelations:
257  this->StoreFlagsForDistributions();
258  // f) Store harmonic which will be estimated:
259  this->StoreHarmonic();
260  
261  TH1::AddDirectory(oldHistAddStatus);
262 } // end of void AliFlowAnalysisWithQCumulants::Init()
263
264 //================================================================================================================
265
266 void AliFlowAnalysisWithQCumulants::Make(AliFlowEventSimple* anEvent)
267 {
268  // Running over data only in this method.
269  
270  // a) Check all pointers used in this method;
271  // b) Define local variables;
272  // c) Fill the common control histograms and call the method to fill fAvMultiplicity;
273  // d) Loop over data and calculate e-b-e quantities Q_{n,k}, S_{p,k} and s_{p,k};
274  // e) Calculate the final expressions for S_{p,k} and s_{p,k} (important !!!!); 
275  // f) Call the methods which calculate correlations for reference flow;
276  // g) Call the methods which calculate correlations for differential flow;
277  // h) Call the methods which calculate correlations for 2D differential flow;
278  // i) Call the methods which calculate other differential correlators;
279  // j) Distributions of correlations;
280  // k) Store phi distribution for one event to illustrate flow;
281  // l) Cross-check with nested loops correlators for reference flow;
282  // m) Cross-check with nested loops correlators for differential flow;
283  // n) Reset all event-by-event quantities (very important !!!!). 
284  
285  // a) Check all pointers used in this method:
286  this->CheckPointersUsedInMake();
287  
288  // b) Define local variables:
289  Double_t dPhi = 0.; // azimuthal angle in the laboratory frame
290  Double_t dPt  = 0.; // transverse momentum
291  Double_t dEta = 0.; // pseudorapidity
292  Double_t wPhi = 1.; // phi weight
293  Double_t wPt  = 1.; // pt weight
294  Double_t wEta = 1.; // eta weight
295  Double_t wTrack = 1.; // track weight
296  Int_t nRP = anEvent->GetEventNSelTracksRP(); // number of RPs (i.e. number of reference particles)
297  fReferenceMultiplicityEBE = anEvent->GetReferenceMultiplicity(); // reference multiplicity for current event
298  Double_t ptEta[2] = {0.,0.}; // 0 = dPt, 1 = dEta
299   
300  // c) Fill the common control histograms and call the method to fill fAvMultiplicity:
301  this->FillCommonControlHistograms(anEvent);                                                               
302  this->FillAverageMultiplicities(nRP);                                                                  
303                                                                                                                                                                                                                                                                                         
304  // d) Loop over data and calculate e-b-e quantities Q_{n,k}, S_{p,k} and s_{p,k}:
305  Int_t nPrim = anEvent->NumberOfTracks();  // nPrim = total number of primary tracks, i.e. nPrim = nRP + nPOI where:
306                                            //  nRP   = # of reference particles;
307                                            //  nPOI  = # of particles of interest.
308  AliFlowTrackSimple *aftsTrack = NULL;
309  Int_t n = fHarmonic; // shortcut for the harmonic 
310  for(Int_t i=0;i<nPrim;i++) 
311  { 
312   aftsTrack=anEvent->GetTrack(i);
313   if(aftsTrack)
314   {
315    if(!(aftsTrack->InRPSelection() || aftsTrack->InPOISelection())){continue;} // safety measure: consider only tracks which are RPs or POIs
316    if(aftsTrack->InRPSelection()) // RP condition:
317    {    
318     dPhi = aftsTrack->Phi();
319     dPt  = aftsTrack->Pt();
320     dEta = aftsTrack->Eta();
321     if(fUsePhiWeights && fPhiWeights && fnBinsPhi) // determine phi weight for this particle:
322     {
323      wPhi = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*fnBinsPhi/TMath::TwoPi())));
324     }
325     if(fUsePtWeights && fPtWeights && fnBinsPt) // determine pt weight for this particle:
326     {
327      wPt = fPtWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-fPtMin)/fPtBinWidth))); 
328     }              
329     if(fUseEtaWeights && fEtaWeights && fEtaBinWidth) // determine eta weight for this particle: 
330     {
331      wEta = fEtaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-fEtaMin)/fEtaBinWidth))); 
332     }      
333     // Access track weight:
334     if(fUseTrackWeights)
335     {
336      wTrack = aftsTrack->Weight(); 
337     }
338     // Calculate Re[Q_{m*n,k}] and Im[Q_{m*n,k}] for this event (m = 1,2,...,6, k = 0,1,...,8):
339     for(Int_t m=0;m<6;m++) // to be improved - hardwired 6 
340     {
341      for(Int_t k=0;k<9;k++) // to be improved - hardwired 9
342      {
343       (*fReQ)(m,k)+=pow(wPhi*wPt*wEta*wTrack,k)*TMath::Cos((m+1)*n*dPhi); 
344       (*fImQ)(m,k)+=pow(wPhi*wPt*wEta*wTrack,k)*TMath::Sin((m+1)*n*dPhi); 
345      } 
346     }
347     // Calculate S_{p,k} for this event (Remark: final calculation of S_{p,k} follows after the loop over data bellow):
348     for(Int_t p=0;p<8;p++)
349     {
350      for(Int_t k=0;k<9;k++)
351      {     
352       (*fSpk)(p,k)+=pow(wPhi*wPt*wEta*wTrack,k);
353      }
354     } 
355     // Differential flow:
356     if(fCalculateDiffFlow || fCalculate2DDiffFlow)
357     {
358      ptEta[0] = dPt; 
359      ptEta[1] = dEta; 
360      // Calculate r_{m*n,k} and s_{p,k} (r_{m,k} is 'p-vector' for RPs): 
361      for(Int_t k=0;k<9;k++) // to be improved - hardwired 9
362      {
363       for(Int_t m=0;m<4;m++) // to be improved - hardwired 4
364       {
365        if(fCalculateDiffFlow)
366        {
367         for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
368         {
369          fReRPQ1dEBE[0][pe][m][k]->Fill(ptEta[pe],pow(wPhi*wPt*wEta*wTrack,k)*TMath::Cos((m+1.)*n*dPhi),1.);
370          fImRPQ1dEBE[0][pe][m][k]->Fill(ptEta[pe],pow(wPhi*wPt*wEta*wTrack,k)*TMath::Sin((m+1.)*n*dPhi),1.);          
371          if(m==0) // s_{p,k} does not depend on index m
372          {
373           fs1dEBE[0][pe][k]->Fill(ptEta[pe],pow(wPhi*wPt*wEta*wTrack,k),1.);
374          } // end of if(m==0) // s_{p,k} does not depend on index m
375         } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
376        } // end of if(fCalculateDiffFlow) 
377        if(fCalculate2DDiffFlow)
378        {
379         fReRPQ2dEBE[0][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta*wTrack,k)*TMath::Cos((m+1.)*n*dPhi),1.);
380         fImRPQ2dEBE[0][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta*wTrack,k)*TMath::Sin((m+1.)*n*dPhi),1.);      
381         if(m==0) // s_{p,k} does not depend on index m
382         {
383          fs2dEBE[0][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta*wTrack,k),1.);
384         } // end of if(m==0) // s_{p,k} does not depend on index m
385        } // end of if(fCalculate2DDiffFlow)
386       } // end of for(Int_t m=0;m<4;m++) // to be improved - hardwired 4
387      } // end of for(Int_t k=0;k<9;k++) // to be improved - hardwired 9
388      // Checking if RP particle is also POI particle:      
389      if(aftsTrack->InPOISelection())
390      {
391       // Calculate q_{m*n,k} and s_{p,k} ('q-vector' and 's' for RPs && POIs): 
392       for(Int_t k=0;k<9;k++) // to be improved - hardwired 9
393       {
394        for(Int_t m=0;m<4;m++) // to be improved - hardwired 4
395        {
396         if(fCalculateDiffFlow)
397         {
398          for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
399          {
400           fReRPQ1dEBE[2][pe][m][k]->Fill(ptEta[pe],pow(wPhi*wPt*wEta*wTrack,k)*TMath::Cos((m+1.)*n*dPhi),1.);
401           fImRPQ1dEBE[2][pe][m][k]->Fill(ptEta[pe],pow(wPhi*wPt*wEta*wTrack,k)*TMath::Sin((m+1.)*n*dPhi),1.);          
402           if(m==0) // s_{p,k} does not depend on index m
403           {
404            fs1dEBE[2][pe][k]->Fill(ptEta[pe],pow(wPhi*wPt*wEta*wTrack,k),1.);
405           } // end of if(m==0) // s_{p,k} does not depend on index m
406          } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
407         } // end of if(fCalculateDiffFlow) 
408         if(fCalculate2DDiffFlow)
409         {
410          fReRPQ2dEBE[2][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta*wTrack,k)*TMath::Cos((m+1.)*n*dPhi),1.);
411          fImRPQ2dEBE[2][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta*wTrack,k)*TMath::Sin((m+1.)*n*dPhi),1.);      
412          if(m==0) // s_{p,k} does not depend on index m
413          {
414           fs2dEBE[2][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta*wTrack,k),1.);
415          } // end of if(m==0) // s_{p,k} does not depend on index m
416         } // end of if(fCalculate2DDiffFlow)
417        } // end of for(Int_t m=0;m<4;m++) // to be improved - hardwired 4
418       } // end of for(Int_t k=0;k<9;k++) // to be improved - hardwired 9    
419      } // end of if(aftsTrack->InPOISelection())  
420     } // end of if(fCalculateDiffFlow || fCalculate2DDiffFlow)         
421    } // end of if(pTrack->InRPSelection())
422    if(aftsTrack->InPOISelection())
423    {
424     dPhi = aftsTrack->Phi();
425     dPt  = aftsTrack->Pt();
426     dEta = aftsTrack->Eta();
427     wPhi = 1.;
428     wPt  = 1.;
429     wEta = 1.;
430     wTrack = 1.;
431     if(fUsePhiWeights && fPhiWeights && fnBinsPhi && aftsTrack->InRPSelection()) // determine phi weight for POI && RP particle:
432     {
433      wPhi = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*fnBinsPhi/TMath::TwoPi())));
434     }
435     if(fUsePtWeights && fPtWeights && fnBinsPt && aftsTrack->InRPSelection()) // determine pt weight for POI && RP particle:
436     {
437      wPt = fPtWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-fPtMin)/fPtBinWidth))); 
438     }              
439     if(fUseEtaWeights && fEtaWeights && fEtaBinWidth && aftsTrack->InRPSelection()) // determine eta weight for POI && RP particle: 
440     {
441      wEta = fEtaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-fEtaMin)/fEtaBinWidth))); 
442     }      
443     // Access track weight for POI && RP particle:
444     if(aftsTrack->InRPSelection() && fUseTrackWeights)
445     {
446      wTrack = aftsTrack->Weight(); 
447     }
448     ptEta[0] = dPt;
449     ptEta[1] = dEta;
450     // Calculate p_{m*n,k} ('p-vector' for POIs): 
451     for(Int_t k=0;k<9;k++) // to be improved - hardwired 9
452     {
453      for(Int_t m=0;m<4;m++) // to be improved - hardwired 4
454      {
455       if(fCalculateDiffFlow)
456       {
457        for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
458        {
459         fReRPQ1dEBE[1][pe][m][k]->Fill(ptEta[pe],pow(wPhi*wPt*wEta*wTrack,k)*TMath::Cos((m+1.)*n*dPhi),1.);
460         fImRPQ1dEBE[1][pe][m][k]->Fill(ptEta[pe],pow(wPhi*wPt*wEta*wTrack,k)*TMath::Sin((m+1.)*n*dPhi),1.);          
461        } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
462       } // end of if(fCalculateDiffFlow) 
463       if(fCalculate2DDiffFlow)
464       {
465        fReRPQ2dEBE[1][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta*wTrack,k)*TMath::Cos((m+1.)*n*dPhi),1.);
466        fImRPQ2dEBE[1][m][k]->Fill(dPt,dEta,pow(wPhi*wPt*wEta*wTrack,k)*TMath::Sin((m+1.)*n*dPhi),1.);      
467       } // end of if(fCalculate2DDiffFlow)
468      } // end of for(Int_t m=0;m<4;m++) // to be improved - hardwired 4
469     } // end of for(Int_t k=0;k<9;k++) // to be improved - hardwired 9    
470    } // end of if(pTrack->InPOISelection())    
471   } else // to if(aftsTrack)
472     {
473      printf("\n WARNING (QC): No particle (i.e. aftsTrack is a NULL pointer in AFAWQC::Make())!!!!\n\n");
474     }
475  } // end of for(Int_t i=0;i<nPrim;i++) 
476
477  // e) Calculate the final expressions for S_{p,k} and s_{p,k} (important !!!!):
478  for(Int_t p=0;p<8;p++)
479  {
480   for(Int_t k=0;k<9;k++)
481   {
482    (*fSpk)(p,k)=pow((*fSpk)(p,k),p+1);
483    // ... for the time being s_{p,k} dosn't need higher powers, so no need to finalize it here ...
484   } // end of for(Int_t k=0;k<9;k++)  
485  } // end of for(Int_t p=0;p<8;p++)
486  
487  // f) Call the methods which calculate correlations for reference flow:
488  if(!fEvaluateIntFlowNestedLoops)
489  {
490   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
491   {
492    if(nRP>1){this->CalculateIntFlowCorrelations();} // without using particle weights
493   } else // to if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
494     {
495      if(nRP>1){this->CalculateIntFlowCorrelationsUsingParticleWeights();} // with using particle weights   
496     }        
497   // Whether or not using particle weights the following is calculated in the same way:  
498   if(nRP>3){this->CalculateIntFlowProductOfCorrelations();}
499   if(nRP>1){this->CalculateIntFlowSumOfEventWeights();}
500   if(nRP>1){this->CalculateIntFlowSumOfProductOfEventWeights();}  
501   // Non-isotropic terms:
502   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
503   {
504    if(nRP>0){this->CalculateIntFlowCorrectionsForNUASinTerms();}
505    if(nRP>0){this->CalculateIntFlowCorrectionsForNUACosTerms();}
506   } else // to if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
507     {
508      if(nRP>0){this->CalculateIntFlowCorrectionsForNUASinTermsUsingParticleWeights();}
509      if(nRP>0){this->CalculateIntFlowCorrectionsForNUACosTermsUsingParticleWeights();}     
510     }      
511   // Whether or not using particle weights the following is calculated in the same way:  
512   if(nRP>0){this->CalculateIntFlowProductOfCorrectionTermsForNUA();}     
513   if(nRP>0){this->CalculateIntFlowSumOfEventWeightsNUA();}     
514   if(nRP>0){this->CalculateIntFlowSumOfProductOfEventWeightsNUA();}      
515  } // end of if(!fEvaluateIntFlowNestedLoops)
516
517  // g) Call the methods which calculate correlations for differential flow:
518  if(!fEvaluateDiffFlowNestedLoops && fCalculateDiffFlow)
519  {
520   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
521   {
522    // Without using particle weights:
523    this->CalculateDiffFlowCorrelations("RP","Pt"); 
524    if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrelations("RP","Eta");}
525    this->CalculateDiffFlowCorrelations("POI","Pt");
526    if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrelations("POI","Eta");}
527    // Non-isotropic terms:
528    this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Pt");
529    if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Eta");}
530    this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Pt");
531    if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Eta");}
532    this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Pt");
533    if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Eta");}
534    this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Pt");
535    if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Eta");}   
536   } else // to if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
537     {
538      // With using particle weights:   
539      this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Pt"); 
540      if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Eta");} 
541      this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Pt"); 
542      if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Eta");} 
543      // Non-isotropic terms:
544      this->CalculateDiffFlowCorrectionsForNUASinTermsUsingParticleWeights("RP","Pt");
545      if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrectionsForNUASinTermsUsingParticleWeights("RP","Eta");}
546      this->CalculateDiffFlowCorrectionsForNUASinTermsUsingParticleWeights("POI","Pt");
547      if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrectionsForNUASinTermsUsingParticleWeights("POI","Eta");}
548      this->CalculateDiffFlowCorrectionsForNUACosTermsUsingParticleWeights("RP","Pt");
549      if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrectionsForNUACosTermsUsingParticleWeights("RP","Eta");}
550      this->CalculateDiffFlowCorrectionsForNUACosTermsUsingParticleWeights("POI","Pt");
551      if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrectionsForNUACosTermsUsingParticleWeights("POI","Eta");}   
552     }     
553   // Whether or not using particle weights the following is calculated in the same way:  
554   this->CalculateDiffFlowProductOfCorrelations("RP","Pt");
555   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowProductOfCorrelations("RP","Eta");}
556   this->CalculateDiffFlowProductOfCorrelations("POI","Pt");
557   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowProductOfCorrelations("POI","Eta");}
558   this->CalculateDiffFlowSumOfEventWeights("RP","Pt");
559   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowSumOfEventWeights("RP","Eta");}
560   this->CalculateDiffFlowSumOfEventWeights("POI","Pt");
561   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowSumOfEventWeights("POI","Eta");}
562   this->CalculateDiffFlowSumOfProductOfEventWeights("RP","Pt");
563   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowSumOfProductOfEventWeights("RP","Eta");}
564   this->CalculateDiffFlowSumOfProductOfEventWeights("POI","Pt");
565   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowSumOfProductOfEventWeights("POI","Eta");}   
566  } // end of if(!fEvaluateDiffFlowNestedLoops && fCalculateDiffFlow)
567
568  // h) Call the methods which calculate correlations for 2D differential flow:
569  if(!fEvaluateDiffFlowNestedLoops && fCalculate2DDiffFlow)
570  {
571   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
572   {
573    // Without using particle weights:
574    this->Calculate2DDiffFlowCorrelations("RP"); 
575    this->Calculate2DDiffFlowCorrelations("POI");
576    // Non-isotropic terms:
577    // ... to be ctd ...
578   } else // to if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
579     {
580      // With using particle weights:   
581      // ... to be ctd ...  
582      // Non-isotropic terms:
583      // ... to be ctd ...
584     }     
585   // Whether or not using particle weights the following is calculated in the same way:  
586   // ... to be ctd ...   
587  } // end of if(!fEvaluateDiffFlowNestedLoops && fCalculate2DDiffFlow)
588  
589  // i) Call the methods which calculate other differential correlators:
590  if(!fEvaluateDiffFlowNestedLoops && fCalculateDiffFlow)
591  {
592   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
593   {
594    // Without using particle weights:
595    this->CalculateOtherDiffCorrelators("RP","Pt"); 
596    if(fCalculateDiffFlowVsEta){this->CalculateOtherDiffCorrelators("RP","Eta");}
597    this->CalculateOtherDiffCorrelators("POI","Pt"); 
598    if(fCalculateDiffFlowVsEta){this->CalculateOtherDiffCorrelators("POI","Eta");}     
599   } else // to if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
600     {
601      // With using particle weights:   
602      // ... to be ctd ...  
603     }     
604   // Whether or not using particle weights the following is calculated in the same way:  
605   // ... to be ctd ...   
606  } // end of if(!fEvaluateDiffFlowNestedLoops)
607  
608  // j) Distributions of correlations:
609  if(fStoreDistributions){this->StoreDistributionsOfCorrelations();}
610  
611  // k) Store phi distribution for one event to illustrate flow: 
612  if(fStorePhiDistributionForOneEvent){this->StorePhiDistributionForOneEvent(anEvent);}
613    
614  // l) Cross-check with nested loops correlators for reference flow:
615  if(fEvaluateIntFlowNestedLoops){this->EvaluateIntFlowNestedLoops(anEvent);} 
616
617  // m) Cross-check with nested loops correlators for differential flow:
618  if(fEvaluateDiffFlowNestedLoops){this->EvaluateDiffFlowNestedLoops(anEvent);} 
619  
620  // n) Reset all event-by-event quantities (very important !!!!):
621  this->ResetEventByEventQuantities();
622  
623 } // end of AliFlowAnalysisWithQCumulants::Make(AliFlowEventSimple* anEvent)
624
625 //================================================================================================================================
626
627 void AliFlowAnalysisWithQCumulants::Finish()
628 {
629  // Calculate the final results.
630  
631  // a) Check all pointers used in this method;
632  // b) Acces the constants;
633  // c) Access the flags;
634  // d) Calculate reference cumulants (not corrected for detector effects);
635  // e) Correct reference cumulants for detector effects;
636  // f) Calculate reference flow;
637  // g) Store results for reference flow in AliFlowCommonHistResults and print them on the screen;
638  // h) Calculate the final results for differential flow (without/with weights);
639  // i) Correct the results for differential flow (without/with weights) for effects of non-uniform acceptance (NUA);
640  // j) Calculate the final results for integrated flow (RP/POI) and store in AliFlowCommonHistResults;
641  // k) Store results for differential flow in AliFlowCommonHistResults;
642  // l) Print the final results for integrated flow (RP/POI) on the screen; 
643  // m) Cross-checking: Results from Q-vectors vs results from nested loops.
644  
645  // a) Check all pointers used in this method:
646  this->CheckPointersUsedInFinish();
647   
648  // b) Acces the constants:
649  this->CommonConstants("Finish");          
650  
651  if(fCommonHists && fCommonHists->GetHarmonic()) // to be improved (moved somewhere else)
652  {
653   fHarmonic = (Int_t)(fCommonHists->GetHarmonic())->GetBinContent(1);
654  } 
655  
656  // c) Access the flags: // to be improved (implement a method for this? should I store again the flags becose they can get modified with redoFinish?)
657  fUsePhiWeights = (Bool_t)fUseParticleWeights->GetBinContent(1); 
658  fUsePtWeights = (Bool_t)fUseParticleWeights->GetBinContent(2); 
659  fUseEtaWeights = (Bool_t)fUseParticleWeights->GetBinContent(3);  
660  fUseTrackWeights = (Bool_t)fUseParticleWeights->GetBinContent(4);  
661  fApplyCorrectionForNUA = (Bool_t)fIntFlowFlags->GetBinContent(3); 
662  fPrintFinalResults[0] = (Bool_t)fIntFlowFlags->GetBinContent(4);
663  fPrintFinalResults[1] = (Bool_t)fIntFlowFlags->GetBinContent(5);
664  fPrintFinalResults[2] = (Bool_t)fIntFlowFlags->GetBinContent(6);
665  fPrintFinalResults[3] = (Bool_t)fIntFlowFlags->GetBinContent(7);
666  fApplyCorrectionForNUAVsM = (Bool_t)fIntFlowFlags->GetBinContent(8);  
667  fPropagateErrorAlsoFromNIT = (Bool_t)fIntFlowFlags->GetBinContent(9);  
668  fCalculateCumulantsVsM = (Bool_t)fIntFlowFlags->GetBinContent(10); 
669  fMinimumBiasReferenceFlow = (Bool_t)fIntFlowFlags->GetBinContent(11); 
670  fForgetAboutCovariances = (Bool_t)fIntFlowFlags->GetBinContent(12);
671  fStorePhiDistributionForOneEvent = (Bool_t)fIntFlowFlags->GetBinContent(13);
672  fFillMultipleControlHistograms = (Bool_t)fIntFlowFlags->GetBinContent(14); 
673  fCalculateAllCorrelationsVsM = (Bool_t)fIntFlowFlags->GetBinContent(15);
674  fEvaluateIntFlowNestedLoops = (Bool_t)fEvaluateNestedLoops->GetBinContent(1);
675  fEvaluateDiffFlowNestedLoops = (Bool_t)fEvaluateNestedLoops->GetBinContent(2); 
676  fCrossCheckInPtBinNo = (Int_t)fEvaluateNestedLoops->GetBinContent(3);
677  fCrossCheckInEtaBinNo = (Int_t)fEvaluateNestedLoops->GetBinContent(4); 
678           
679  // d) Calculate reference cumulants (not corrected for detector effects):
680  this->FinalizeCorrelationsIntFlow();
681  this->CalculateCovariancesIntFlow();
682  this->CalculateCumulantsIntFlow();
683
684  // e) Correct reference cumulants for detector effects:
685  this->FinalizeCorrectionTermsForNUAIntFlow();
686  this->CalculateCovariancesNUAIntFlow(); 
687  this->CalculateQcumulantsCorrectedForNUAIntFlow();  
688
689  // f) Calculate reference flow:
690  this->CalculateReferenceFlow(); 
691   
692  // g) Store results for reference flow in AliFlowCommonHistResults and print them on the screen:
693  this->FillCommonHistResultsIntFlow();  
694  if(fPrintFinalResults[0]){this->PrintFinalResultsForIntegratedFlow("RF");}
695  if(fPrintFinalResults[3] && fCalculateCumulantsVsM){this->PrintFinalResultsForIntegratedFlow("RF, rebinned in M");}
696  
697  // h) Calculate the final results for differential flow (without/with weights):
698  if(fCalculateDiffFlow)
699  {
700   this->FinalizeReducedCorrelations("RP","Pt"); 
701   if(fCalculateDiffFlowVsEta){this->FinalizeReducedCorrelations("RP","Eta");} 
702   this->FinalizeReducedCorrelations("POI","Pt"); 
703   if(fCalculateDiffFlowVsEta){this->FinalizeReducedCorrelations("POI","Eta");}
704   this->CalculateDiffFlowCovariances("RP","Pt");
705   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCovariances("RP","Eta");}
706   this->CalculateDiffFlowCovariances("POI","Pt");
707   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCovariances("POI","Eta");}
708   this->CalculateDiffFlowCumulants("RP","Pt");
709   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCumulants("RP","Eta");}
710   this->CalculateDiffFlowCumulants("POI","Pt");
711   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCumulants("POI","Eta");}
712   this->CalculateDiffFlow("RP","Pt");
713   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlow("RP","Eta");}
714   this->CalculateDiffFlow("POI","Pt");
715   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlow("POI","Eta");}
716  } // if(fCalculateDiffFlow)
717  
718  // i) Correct the results for differential flow (without/with weights) for effects of non-uniform acceptance (NUA):
719  if(fCalculateDiffFlow)
720  {
721   this->FinalizeCorrectionTermsForNUADiffFlow("RP","Pt");
722   if(fCalculateDiffFlowVsEta){this->FinalizeCorrectionTermsForNUADiffFlow("RP","Eta");}
723   this->FinalizeCorrectionTermsForNUADiffFlow("POI","Pt");
724   if(fCalculateDiffFlowVsEta){this->FinalizeCorrectionTermsForNUADiffFlow("POI","Eta");}      
725   this->CalculateDiffFlowCumulantsCorrectedForNUA("RP","Pt");   
726   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCumulantsCorrectedForNUA("RP","Eta");}   
727   this->CalculateDiffFlowCumulantsCorrectedForNUA("POI","Pt");   
728   if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCumulantsCorrectedForNUA("POI","Eta");}  
729   if(fApplyCorrectionForNUA)
730   {
731    this->CalculateDiffFlowCorrectedForNUA("RP","Pt"); 
732    if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrectedForNUA("RP","Eta");} 
733    this->CalculateDiffFlowCorrectedForNUA("POI","Pt"); 
734    if(fCalculateDiffFlowVsEta){this->CalculateDiffFlowCorrectedForNUA("POI","Eta");} 
735   }
736  } // end of if(fCalculateDiffFlow && fApplyCorrectionForNUA)
737  
738  // i) Calcualate final results for 2D differential flow: 
739  if(fCalculate2DDiffFlow)
740  {
741   this->Calculate2DDiffFlowCumulants("RP");
742   this->Calculate2DDiffFlowCumulants("POI");
743   this->Calculate2DDiffFlow("RP");  
744   this->Calculate2DDiffFlow("POI");  
745  } // end of if(fCalculate2DDiffFlow)
746     
747  // j) Calculate the final results for integrated flow (RP/POI) and store in AliFlowCommonHistResults:
748  if(fCalculateDiffFlow)
749  {
750   this->CalculateFinalResultsForRPandPOIIntegratedFlow("RP");
751   this->CalculateFinalResultsForRPandPOIIntegratedFlow("POI");
752  }
753  
754  // k) Store results for differential flow in AliFlowCommonHistResults:
755  if(fCalculateDiffFlow)
756  {
757   this->FillCommonHistResultsDiffFlow("RP");
758   this->FillCommonHistResultsDiffFlow("POI");
759  }
760  
761  // l) Print the final results for integrated flow (RP/POI) on the screen:
762  if(fPrintFinalResults[1] && fCalculateDiffFlow){this->PrintFinalResultsForIntegratedFlow("RP");} 
763  if(fPrintFinalResults[2] && fCalculateDiffFlow){this->PrintFinalResultsForIntegratedFlow("POI");}
764     
765  // m) Cross-checking: Results from Q-vectors vs results from nested loops:
766  //  m1) Reference flow:
767  if(fEvaluateIntFlowNestedLoops)
768  {
769   this->CrossCheckIntFlowCorrelations();
770   this->CrossCheckIntFlowCorrectionTermsForNUA(); 
771   if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights){this->CrossCheckIntFlowExtraCorrelations();}     
772  } // end of if(fEvaluateIntFlowNestedLoops)  
773  //  m2) Differential flow: 
774  if(fEvaluateDiffFlowNestedLoops && fCalculateDiffFlow) 
775  {
776   // Correlations:
777   this->PrintNumberOfParticlesInSelectedBin();
778   this->CrossCheckDiffFlowCorrelations("RP","Pt");  
779   if(fCalculateDiffFlowVsEta){this->CrossCheckDiffFlowCorrelations("RP","Eta");} 
780   this->CrossCheckDiffFlowCorrelations("POI","Pt");  
781   if(fCalculateDiffFlowVsEta){this->CrossCheckDiffFlowCorrelations("POI","Eta");}
782   // Correction terms for non-uniform acceptance:
783   this->CrossCheckDiffFlowCorrectionTermsForNUA("RP","Pt");      
784   if(fCalculateDiffFlowVsEta){this->CrossCheckDiffFlowCorrectionTermsForNUA("RP","Eta");}       
785   this->CrossCheckDiffFlowCorrectionTermsForNUA("POI","Pt");      
786   if(fCalculateDiffFlowVsEta){this->CrossCheckDiffFlowCorrectionTermsForNUA("POI","Eta");}
787   // Other differential correlators:       
788   this->CrossCheckOtherDiffCorrelators("RP","Pt");  
789   if(fCalculateDiffFlowVsEta){this->CrossCheckOtherDiffCorrelators("RP","Eta");} 
790   this->CrossCheckOtherDiffCorrelators("POI","Pt");  
791   if(fCalculateDiffFlowVsEta){this->CrossCheckOtherDiffCorrelators("POI","Eta");}
792  } // end of if(fEvaluateDiffFlowNestedLoops)
793                                                                                                                                                                                                                                                                                                                                    
794 } // end of AliFlowAnalysisWithQCumulants::Finish()
795
796 //================================================================================================================================
797
798 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowNestedLoops(AliFlowEventSimple* anEvent)
799 {
800  // Evalauted all correlators for reference flow with nested loops.
801  
802  Int_t nPrim = anEvent->NumberOfTracks(); // nPrim = nRP + nPOI 
803  if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity) // by default fMaxAllowedMultiplicity = 10 
804  {
805   // Without using particle weights:
806   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
807   {
808    // Correlations:
809    this->CalculateIntFlowCorrelations(); // from Q-vectors
810    this->EvaluateIntFlowCorrelationsWithNestedLoops(anEvent); // from nested loops (to be improved: do I have to pass here anEvent or not?)
811    // Correction for non-uniform acceptance:
812    this->CalculateIntFlowCorrectionsForNUASinTerms(); // from Q-vectors (sin terms)
813    this->CalculateIntFlowCorrectionsForNUACosTerms(); // from Q-vectors (cos terms)
814    this->EvaluateIntFlowCorrectionsForNUAWithNestedLoops(anEvent); // from nested loops (both sin and cos terms)
815   }
816   // Using particle weights:
817   if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)
818   {
819    // Correlations
820    this->CalculateIntFlowCorrelationsUsingParticleWeights(); // from Q-vectors
821    this->EvaluateIntFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent); // from nested loops (to be improved: do I have to pass here anEvent or not?)
822    // Correction for non-uniform acceptance:
823    this->CalculateIntFlowCorrectionsForNUASinTermsUsingParticleWeights(); // from Q-vectors (sin terms)
824    this->CalculateIntFlowCorrectionsForNUACosTermsUsingParticleWeights(); // from Q-vectors (cos terms)
825    this->EvaluateIntFlowCorrectionsForNUAWithNestedLoopsUsingParticleWeights(anEvent); // from nested loops (both sin and cos terms)   
826   }
827  } else if(nPrim>fMaxAllowedMultiplicity) // to if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity)
828    {
829     cout<<endl;
830     cout<<"Skipping the event because multiplicity is "<<nPrim<<". Too high to evaluate nested loops!"<<endl;
831    } else
832      {
833       cout<<endl;
834       cout<<"Skipping the event because multiplicity is "<<nPrim<<"."<<endl;      
835      } 
836
837 } // end of void AliFlowAnalysisWithQCumulants::EvaluateIntFlowNestedLoops(AliFlowEventSimple* anEvent)
838
839 //================================================================================================================================
840
841 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowNestedLoops(AliFlowEventSimple* anEvent)
842 {
843  // Evalauted all correlators for differential flow with nested loops.
844
845  if(!fCalculateDiffFlow){return;}
846
847  Int_t nPrim = anEvent->NumberOfTracks(); // nPrim = nRP + nPOI 
848  if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity) // by default fMaxAllowedMultiplicity = 10
849  {
850   // Without using particle weights:
851   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
852   {
853    // 1.) Reduced correlations:
854    //  Q-vectors:
855    this->CalculateDiffFlowCorrelations("RP","Pt");
856    this->CalculateDiffFlowCorrelations("RP","Eta");
857    this->CalculateDiffFlowCorrelations("POI","Pt");
858    this->CalculateDiffFlowCorrelations("POI","Eta");
859    //  Nested loops:
860    this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"RP","Pt"); 
861    this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"RP","Eta"); 
862    this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"POI","Pt"); 
863    this->EvaluateDiffFlowCorrelationsWithNestedLoops(anEvent,"POI","Eta"); 
864    // 2.) Reduced corrections for non-uniform acceptance:
865    //  Q-vectors:
866    this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Pt");
867    this->CalculateDiffFlowCorrectionsForNUASinTerms("RP","Eta");
868    this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Pt");
869    this->CalculateDiffFlowCorrectionsForNUASinTerms("POI","Eta");
870    this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Pt");
871    this->CalculateDiffFlowCorrectionsForNUACosTerms("RP","Eta");
872    this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Pt");
873    this->CalculateDiffFlowCorrectionsForNUACosTerms("POI","Eta");
874    //  Nested loops:
875    this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"RP","Pt");
876    this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"RP","Eta");
877    this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"POI","Pt"); 
878    this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(anEvent,"POI","Eta"); 
879    // 3.) Other differential correlators:
880    //  Q-vectors:
881    this->CalculateOtherDiffCorrelators("RP","Pt");
882    this->CalculateOtherDiffCorrelators("RP","Eta");
883    this->CalculateOtherDiffCorrelators("POI","Pt");
884    this->CalculateOtherDiffCorrelators("POI","Eta");   
885    //  Nested loops:
886    this->EvaluateOtherDiffCorrelatorsWithNestedLoops(anEvent,"RP","Pt");
887    this->EvaluateOtherDiffCorrelatorsWithNestedLoops(anEvent,"RP","Eta");
888    this->EvaluateOtherDiffCorrelatorsWithNestedLoops(anEvent,"POI","Pt");
889    this->EvaluateOtherDiffCorrelatorsWithNestedLoops(anEvent,"POI","Eta");   
890   } // end of if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
891   // Using particle weights:
892   if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)
893   {
894    this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Pt"); 
895    this->CalculateDiffFlowCorrelationsUsingParticleWeights("RP","Eta"); 
896    this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Pt"); 
897    this->CalculateDiffFlowCorrelationsUsingParticleWeights("POI","Eta"); 
898    this->CalculateDiffFlowCorrectionsForNUASinTermsUsingParticleWeights("RP","Pt");
899    this->CalculateDiffFlowCorrectionsForNUASinTermsUsingParticleWeights("RP","Eta");
900    this->CalculateDiffFlowCorrectionsForNUASinTermsUsingParticleWeights("POI","Pt");
901    this->CalculateDiffFlowCorrectionsForNUASinTermsUsingParticleWeights("POI","Eta");
902    this->CalculateDiffFlowCorrectionsForNUACosTermsUsingParticleWeights("RP","Pt");
903    this->CalculateDiffFlowCorrectionsForNUACosTermsUsingParticleWeights("RP","Eta");
904    this->CalculateDiffFlowCorrectionsForNUACosTermsUsingParticleWeights("POI","Pt");
905    this->CalculateDiffFlowCorrectionsForNUACosTermsUsingParticleWeights("POI","Eta");
906    this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"RP","Pt"); 
907    this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"RP","Eta");
908    this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"POI","Pt"); 
909    this->EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(anEvent,"POI","Eta");   
910    this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoopsUsingParticleWeights(anEvent,"RP","Pt"); 
911    this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoopsUsingParticleWeights(anEvent,"RP","Eta"); 
912    this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoopsUsingParticleWeights(anEvent,"POI","Pt"); 
913    this->EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoopsUsingParticleWeights(anEvent,"POI","Eta"); 
914   } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)
915  } // end of if(nPrim>0 && nPrim<=fMaxAllowedMultiplicity) // by default fMaxAllowedMultiplicity = 10
916
917 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowNestedLoops(AliFlowEventSimple* anEvent)
918
919 //================================================================================================================================
920
921 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUACosTerms()
922 {
923  // Calculate correction terms for non-uniform acceptance of the detector for reference flow (cos terms).
924  
925  // multiplicity:
926  Double_t dMult = (*fSpk)(0,0);
927  
928  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
929  Double_t dReQ1n = (*fReQ)(0,0);
930  Double_t dReQ2n = (*fReQ)(1,0);
931  //Double_t dReQ3n = (*fReQ)(2,0);
932  //Double_t dReQ4n = (*fReQ)(3,0);
933  Double_t dImQ1n = (*fImQ)(0,0);
934  Double_t dImQ2n = (*fImQ)(1,0);
935  //Double_t dImQ3n = (*fImQ)(2,0);
936  //Double_t dImQ4n = (*fImQ)(3,0);
937         
938  //                                  *************************************************************
939  //                                  **** corrections for non-uniform acceptance (cos terms): ****
940  //                                  *************************************************************
941  //
942  // Remark 1: corrections for non-uniform acceptance (cos terms) calculated with non-weighted Q-vectors 
943  //           are stored in 1D profile fQCorrectionsCos.
944  // Remark 2: binning of fIntFlowCorrectionTermsForNUAPro[1] is organized as follows:
945  // --------------------------------------------------------------------------------------------------------------------
946  // 1st bin: <<cos(n*(phi1))>> = cosP1n
947  // 2nd bin: <<cos(n*(phi1+phi2))>> = cosP1nP1n
948  // 3rd bin: <<cos(n*(phi1-phi2-phi3))>> = cosP1nM1nM1n
949  // 4th bin: <<cos(n*(2phi1-phi2))>> = cosP2nM1n
950  // --------------------------------------------------------------------------------------------------------------------
951   
952  // 1-particle:
953  Double_t cosP1n = 0.; // <<cos(n*(phi1))>>
954    
955  if(dMult>0)
956  {
957   cosP1n = dReQ1n/dMult; 
958   
959   // average non-weighted 1-particle correction (cos terms) for non-uniform acceptance for single event:
960   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(1,cosP1n);
961   // event weights for NUA terms:
962   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->SetBinContent(1,dMult);
963   
964   // final average non-weighted 1-particle correction (cos terms) for non-uniform acceptance for all events:
965   fIntFlowCorrectionTermsForNUAPro[1]->Fill(0.5,cosP1n,dMult);  
966   if(fCalculateCumulantsVsM){fIntFlowCorrectionTermsForNUAVsMPro[1][0]->Fill(dMult+0.5,cosP1n,dMult);}    
967  } 
968  
969  // 2-particle:
970  Double_t cosP1nP1n = 0.; // <<cos(n*(phi1+phi2))>>
971  Double_t cosP2nM1n = 0.; // <<cos(n*(2phi1-phi2))>>
972  
973  if(dMult>1)
974  {
975   cosP1nP1n = (pow(dReQ1n,2)-pow(dImQ1n,2)-dReQ2n)/(dMult*(dMult-1)); 
976   cosP2nM1n = (dReQ2n*dReQ1n+dImQ2n*dImQ1n-dReQ1n)/(dMult*(dMult-1)); 
977   
978   // average non-weighted 2-particle correction (cos terms) for non-uniform acceptance for single event:
979   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(2,cosP1nP1n);
980   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(4,cosP2nM1n);
981   // event weights for NUA terms:
982   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->SetBinContent(2,dMult*(dMult-1));
983   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->SetBinContent(4,dMult*(dMult-1));
984       
985   // final average non-weighted 2-particle correction (cos terms) for non-uniform acceptance for all events:
986   fIntFlowCorrectionTermsForNUAPro[1]->Fill(1.5,cosP1nP1n,dMult*(dMult-1));  
987   fIntFlowCorrectionTermsForNUAPro[1]->Fill(3.5,cosP2nM1n,dMult*(dMult-1));
988   if(fCalculateCumulantsVsM)
989   {
990    fIntFlowCorrectionTermsForNUAVsMPro[1][1]->Fill(dMult+0.5,cosP1nP1n,dMult*(dMult-1));  
991    fIntFlowCorrectionTermsForNUAVsMPro[1][3]->Fill(dMult+0.5,cosP2nM1n,dMult*(dMult-1));
992   }
993  } 
994  
995  // 3-particle:
996  Double_t cosP1nM1nM1n = 0.; // <<cos(n*(phi1-phi2-phi3))>>
997  
998  if(dMult>2)
999  {
1000   cosP1nM1nM1n = (dReQ1n*(pow(dReQ1n,2)+pow(dImQ1n,2))-dReQ1n*dReQ2n-dImQ1n*dImQ2n-2.*(dMult-1)*dReQ1n)
1001                / (dMult*(dMult-1)*(dMult-2)); 
1002   
1003   // average non-weighted 3-particle correction (cos terms) for non-uniform acceptance for single event:
1004   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(3,cosP1nM1nM1n);
1005   // event weights for NUA terms:
1006   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->SetBinContent(3,dMult*(dMult-1)*(dMult-2));
1007   
1008   // final average non-weighted 3-particle correction (cos terms) for non-uniform acceptance for all events:
1009   fIntFlowCorrectionTermsForNUAPro[1]->Fill(2.5,cosP1nM1nM1n,dMult*(dMult-1)*(dMult-2));
1010   if(fCalculateCumulantsVsM){fIntFlowCorrectionTermsForNUAVsMPro[1][2]->Fill(dMult+0.5,cosP1nM1nM1n,dMult*(dMult-1)*(dMult-2));}  
1011  } 
1012  
1013 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUACosTerms()
1014
1015
1016 //================================================================================================================================
1017
1018
1019 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUASinTerms()
1020 {
1021  // calculate corrections for non-uniform acceptance of the detector for no-name integrated flow (sin terms)
1022  
1023  // multiplicity:
1024  Double_t dMult = (*fSpk)(0,0);
1025  
1026  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
1027  Double_t dReQ1n = (*fReQ)(0,0);
1028  Double_t dReQ2n = (*fReQ)(1,0);
1029  //Double_t dReQ3n = (*fReQ)(2,0);
1030  //Double_t dReQ4n = (*fReQ)(3,0);
1031  Double_t dImQ1n = (*fImQ)(0,0);
1032  Double_t dImQ2n = (*fImQ)(1,0);
1033  //Double_t dImQ3n = (*fImQ)(2,0);
1034  //Double_t dImQ4n = (*fImQ)(3,0);
1035         
1036  //                                  *************************************************************
1037  //                                  **** corrections for non-uniform acceptance (sin terms): ****
1038  //                                  *************************************************************
1039  //
1040  // Remark 1: corrections for non-uniform acceptance (sin terms) calculated with non-weighted Q-vectors 
1041  //           are stored in 1D profile fQCorrectionsSin.
1042  // Remark 2: binning of fIntFlowCorrectionTermsForNUAPro[0] is organized as follows:
1043  // --------------------------------------------------------------------------------------------------------------------
1044  // 1st bin: <<sin(n*(phi1))>> = sinP1n
1045  // 2nd bin: <<sin(n*(phi1+phi2))>> = sinP1nP1n
1046  // 3rd bin: <<sin(n*(phi1-phi2-phi3))>> = sinP1nM1nM1n
1047  // 4th bin: <<sin(n*(2phi1-phi2))>> = sinP2nM1n
1048  // --------------------------------------------------------------------------------------------------------------------
1049  
1050  // 1-particle:
1051  Double_t sinP1n = 0.; // <sin(n*(phi1))>
1052  
1053  if(dMult>0)
1054  {
1055   sinP1n = dImQ1n/dMult; 
1056      
1057   // average non-weighted 1-particle correction (sin terms) for non-uniform acceptance for single event:
1058   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(1,sinP1n);  
1059   // event weights for NUA terms:
1060   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->SetBinContent(1,dMult);
1061   
1062   // final average non-weighted 1-particle correction (sin terms) for non-uniform acceptance for all events:   
1063   fIntFlowCorrectionTermsForNUAPro[0]->Fill(0.5,sinP1n,dMult);  
1064   if(fCalculateCumulantsVsM){fIntFlowCorrectionTermsForNUAVsMPro[0][0]->Fill(dMult+0.5,sinP1n,dMult);} 
1065  } 
1066  
1067  // 2-particle:
1068  Double_t sinP1nP1n = 0.; // <<sin(n*(phi1+phi2))>>
1069  Double_t sinP2nM1n = 0.; // <<sin(n*(2phi1-phi2))>>
1070  if(dMult>1)
1071  {
1072   sinP1nP1n = (2.*dReQ1n*dImQ1n-dImQ2n)/(dMult*(dMult-1)); 
1073   sinP2nM1n = (dImQ2n*dReQ1n-dReQ2n*dImQ1n-dImQ1n)/(dMult*(dMult-1)); 
1074      
1075   // average non-weighted 2-particle correction (sin terms) for non-uniform acceptance for single event:
1076   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(2,sinP1nP1n);
1077   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(4,sinP2nM1n);
1078   // event weights for NUA terms:
1079   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->SetBinContent(2,dMult*(dMult-1));
1080   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->SetBinContent(4,dMult*(dMult-1));
1081   
1082   // final average non-weighted 1-particle correction (sin terms) for non-uniform acceptance for all events:      
1083   fIntFlowCorrectionTermsForNUAPro[0]->Fill(1.5,sinP1nP1n,dMult*(dMult-1));  
1084   fIntFlowCorrectionTermsForNUAPro[0]->Fill(3.5,sinP2nM1n,dMult*(dMult-1));  
1085   if(fCalculateCumulantsVsM)
1086   {
1087    fIntFlowCorrectionTermsForNUAVsMPro[0][1]->Fill(dMult+0.5,sinP1nP1n,dMult*(dMult-1));  
1088    fIntFlowCorrectionTermsForNUAVsMPro[0][3]->Fill(dMult+0.5,sinP2nM1n,dMult*(dMult-1));    
1089   }
1090  } 
1091  
1092  // 3-particle:
1093  Double_t sinP1nM1nM1n = 0.; // <<sin(n*(phi1-phi2-phi3))>>
1094  
1095  if(dMult>2)
1096  {
1097   sinP1nM1nM1n = (-dImQ1n*(pow(dReQ1n,2)+pow(dImQ1n,2))+dReQ1n*dImQ2n-dImQ1n*dReQ2n+2.*(dMult-1)*dImQ1n)
1098                / (dMult*(dMult-1)*(dMult-2)); 
1099   
1100   // average non-weighted 3-particle correction (sin terms) for non-uniform acceptance for single event:
1101   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(3,sinP1nM1nM1n);
1102   // event weights for NUA terms:
1103   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->SetBinContent(3,dMult*(dMult-1)*(dMult-2));
1104   
1105   // final average non-weighted 3-particle correction (sin terms) for non-uniform acceptance for all events:  
1106   fIntFlowCorrectionTermsForNUAPro[0]->Fill(2.5,sinP1nM1nM1n,dMult*(dMult-1)*(dMult-2));
1107   if(fCalculateCumulantsVsM){fIntFlowCorrectionTermsForNUAVsMPro[0][2]->Fill(dMult+0.5,sinP1nM1nM1n,dMult*(dMult-1)*(dMult-2));}  
1108  } 
1109  
1110 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUASinTerms()
1111
1112 //================================================================================================================================
1113
1114 void AliFlowAnalysisWithQCumulants::GetOutputHistograms(TList *outputListHistos)
1115 {
1116  // a) Get pointers for common control and common result histograms;
1117  // b) Get pointers for histograms holding particle weights;
1118  // c) Get pointers for reference flow histograms;
1119  // d) Get pointers for differential flow histograms;
1120  // e) Get pointers for 2D differential flow histograms;
1121  // f) Get pointers for other differential correlators;
1122  // g) Get pointers for nested loops' histograms.
1123  
1124  if(outputListHistos)
1125  {      
1126   this->SetHistList(outputListHistos);
1127   if(!fHistList)
1128   {
1129    printf("\n WARNING (QC): fHistList is NULL in AFAWQC::GOH() !!!!\n\n");
1130    exit(0);
1131   }
1132   this->GetPointersForCommonHistograms(); 
1133   this->GetPointersForParticleWeightsHistograms(); 
1134   this->GetPointersForIntFlowHistograms();
1135   this->GetPointersForDiffFlowHistograms(); 
1136   this->GetPointersFor2DDiffFlowHistograms(); 
1137   this->GetPointersForOtherDiffCorrelators();  
1138   this->GetPointersForNestedLoopsHistograms(); 
1139  } else 
1140    {
1141     printf("\n WARNING (QC): outputListHistos is NULL in AFAWQC::GOH() !!!!\n\n");
1142     exit(0);
1143    }
1144    
1145 } // end of void AliFlowAnalysisWithQCumulants::GetOutputHistograms(TList *outputListHistos)
1146
1147 //================================================================================================================================
1148
1149 TProfile* AliFlowAnalysisWithQCumulants::MakePtProjection(TProfile2D *profilePtEta) const
1150 {
1151  // project 2D profile onto pt axis to get 1D profile
1152  
1153  Int_t nBinsPt   = profilePtEta->GetNbinsX();
1154  Double_t dPtMin = (profilePtEta->GetXaxis())->GetXmin();
1155  Double_t dPtMax = (profilePtEta->GetXaxis())->GetXmax();
1156  
1157  Int_t nBinsEta   = profilePtEta->GetNbinsY();
1158  
1159  TProfile *profilePt = new TProfile("","",nBinsPt,dPtMin,dPtMax); 
1160  
1161  for(Int_t p=1;p<=nBinsPt;p++)
1162  {
1163   Double_t contentPt = 0.;
1164   Double_t entryPt = 0.;
1165   Double_t spreadPt = 0.;
1166   Double_t sum1 = 0.;
1167   Double_t sum2 = 0.;
1168   Double_t sum3 = 0.;
1169   for(Int_t e=1;e<=nBinsEta;e++)
1170   {
1171    contentPt += (profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)))
1172               * (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));
1173    entryPt   += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));
1174    
1175    sum1 += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)))
1176          * (pow(profilePtEta->GetBinError(profilePtEta->GetBin(p,e)),2.)
1177             + pow(profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)),2.)); 
1178    sum2 += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));
1179    sum3 += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)))
1180          * (profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)));            
1181   }
1182   if(sum2>0. && sum1/sum2-pow(sum3/sum2,2.) > 0.)
1183   {
1184    spreadPt = pow(sum1/sum2-pow(sum3/sum2,2.),0.5);
1185   }
1186   profilePt->SetBinContent(p,contentPt);
1187   profilePt->SetBinEntries(p,entryPt);
1188   {
1189    profilePt->SetBinError(p,spreadPt);
1190   }
1191   
1192  }
1193  
1194  return profilePt;
1195  
1196 } // end of TProfile* AliFlowAnalysisWithQCumulants::MakePtProjection(TProfile2D *profilePtEta)
1197
1198
1199 //================================================================================================================================
1200
1201
1202 TProfile* AliFlowAnalysisWithQCumulants::MakeEtaProjection(TProfile2D *profilePtEta) const
1203 {
1204  // project 2D profile onto eta axis to get 1D profile
1205  
1206  Int_t nBinsEta   = profilePtEta->GetNbinsY();
1207  Double_t dEtaMin = (profilePtEta->GetYaxis())->GetXmin();
1208  Double_t dEtaMax = (profilePtEta->GetYaxis())->GetXmax();
1209  
1210  Int_t nBinsPt = profilePtEta->GetNbinsX();
1211  
1212  TProfile *profileEta = new TProfile("","",nBinsEta,dEtaMin,dEtaMax); 
1213  
1214  for(Int_t e=1;e<=nBinsEta;e++)
1215  {
1216   Double_t contentEta = 0.;
1217   Double_t entryEta = 0.;
1218   for(Int_t p=1;p<=nBinsPt;p++)
1219   {
1220    contentEta += (profilePtEta->GetBinContent(profilePtEta->GetBin(p,e)))
1221               * (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));
1222    entryEta   += (profilePtEta->GetBinEntries(profilePtEta->GetBin(p,e)));
1223   }
1224   profileEta->SetBinContent(e,contentEta);
1225   profileEta->SetBinEntries(e,entryEta);
1226  }
1227  
1228  return profileEta;
1229  
1230 } // end of TProfile* AliFlowAnalysisWithQCumulants::MakeEtaProjection(TProfile2D *profilePtEta)
1231
1232 //================================================================================================================================
1233
1234 void AliFlowAnalysisWithQCumulants::PrintFinalResultsForIntegratedFlow(TString type)
1235 {
1236  // Printing on the screen the final results for integrated flow (RF, POI and RP). 
1237  
1238  Int_t n = fHarmonic; 
1239  
1240  Double_t dVn[4] = {0.}; // array to hold Vn{2}, Vn{4}, Vn{6} and Vn{8}   
1241  Double_t dVnErr[4] = {0.}; // array to hold errors of Vn{2}, Vn{4}, Vn{6} and Vn{8}   
1242  
1243  if(type == "RF")
1244  {
1245   for(Int_t b=0;b<4;b++)
1246   {
1247    dVn[0] = (fCommonHistsResults2nd->GetHistIntFlow())->GetBinContent(1); 
1248    dVnErr[0] = (fCommonHistsResults2nd->GetHistIntFlow())->GetBinError(1); 
1249    dVn[1] = (fCommonHistsResults4th->GetHistIntFlow())->GetBinContent(1); 
1250    dVnErr[1] = (fCommonHistsResults4th->GetHistIntFlow())->GetBinError(1); 
1251    dVn[2] = (fCommonHistsResults6th->GetHistIntFlow())->GetBinContent(1); 
1252    dVnErr[2] = (fCommonHistsResults6th->GetHistIntFlow())->GetBinError(1); 
1253    dVn[3] = (fCommonHistsResults8th->GetHistIntFlow())->GetBinContent(1); 
1254    dVnErr[3] = (fCommonHistsResults8th->GetHistIntFlow())->GetBinError(1);    
1255   }  
1256  } else if(type == "RP")
1257    {
1258     dVn[0] = (fCommonHistsResults2nd->GetHistIntFlowRP())->GetBinContent(1); 
1259     dVnErr[0] = (fCommonHistsResults2nd->GetHistIntFlowRP())->GetBinError(1); 
1260     dVn[1] = (fCommonHistsResults4th->GetHistIntFlowRP())->GetBinContent(1); 
1261     dVnErr[1] = (fCommonHistsResults4th->GetHistIntFlowRP())->GetBinError(1); 
1262     dVn[2] = (fCommonHistsResults6th->GetHistIntFlowRP())->GetBinContent(1); 
1263     dVnErr[2] = (fCommonHistsResults6th->GetHistIntFlowRP())->GetBinError(1); 
1264     dVn[3] = (fCommonHistsResults8th->GetHistIntFlowRP())->GetBinContent(1); 
1265     dVnErr[3] = (fCommonHistsResults8th->GetHistIntFlowRP())->GetBinError(1); 
1266    } else if(type == "POI")
1267      {
1268       dVn[0] = (fCommonHistsResults2nd->GetHistIntFlowPOI())->GetBinContent(1); 
1269       dVnErr[0] = (fCommonHistsResults2nd->GetHistIntFlowPOI())->GetBinError(1); 
1270       dVn[1] = (fCommonHistsResults4th->GetHistIntFlowPOI())->GetBinContent(1); 
1271       dVnErr[1] = (fCommonHistsResults4th->GetHistIntFlowPOI())->GetBinError(1); 
1272       dVn[2] = (fCommonHistsResults6th->GetHistIntFlowPOI())->GetBinContent(1); 
1273       dVnErr[2] = (fCommonHistsResults6th->GetHistIntFlowPOI())->GetBinError(1); 
1274       dVn[3] = (fCommonHistsResults8th->GetHistIntFlowPOI())->GetBinContent(1); 
1275       dVnErr[3] = (fCommonHistsResults8th->GetHistIntFlowPOI())->GetBinError(1); 
1276      } else if(type == "RF, rebinned in M" && fCalculateCumulantsVsM)
1277        {
1278         for(Int_t b=0;b<4;b++)
1279         {
1280          dVn[b] = fIntFlowRebinnedInM->GetBinContent(b+1); 
1281          dVnErr[b] = fIntFlowRebinnedInM->GetBinError(b+1);
1282         }  
1283        }
1284  
1285  TString title = " flow estimates from Q-cumulants"; 
1286  TString subtitle = "    ("; 
1287  TString subtitle2 = "       (rebinned in M)"; 
1288  
1289  if(type != "RF, rebinned in M")
1290  {
1291   if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
1292   {
1293    subtitle.Append(type);
1294    subtitle.Append(", without weights)");
1295   } else  
1296     {
1297      subtitle.Append(type);
1298      subtitle.Append(", with weights)");
1299     }
1300  } else
1301    {
1302     if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
1303     {
1304      subtitle.Append("RF");
1305      subtitle.Append(", without weights)");
1306     } else  
1307       {
1308        subtitle.Append("RF");
1309        subtitle.Append(", with weights)");      
1310       }
1311    } 
1312    
1313  cout<<endl;
1314  cout<<"*************************************"<<endl;
1315  cout<<"*************************************"<<endl;
1316  cout<<title.Data()<<endl; 
1317  cout<<subtitle.Data()<<endl; 
1318  if(type == "RF, rebinned in M"){cout<<subtitle2.Data()<<endl;}
1319  cout<<endl;
1320   
1321  for(Int_t i=0;i<4;i++)
1322  {
1323   cout<<"  v_"<<n<<"{"<<2*(i+1)<<"} = "<<dVn[i]<<" +/- "<<dVnErr[i]<<endl;
1324  }
1325  
1326  cout<<endl;
1327  if(type == "RF")
1328  {
1329   if(fApplyCorrectionForNUA)
1330   {
1331    cout<<" detector bias (corrected for): "<<endl;
1332   } else
1333     {
1334      cout<<" detector bias (not corrected for):"<<endl;  
1335     }
1336   cout<<"  to QC{2}: "<<fIntFlowDetectorBias->GetBinContent(1)<<" +/- "<<fIntFlowDetectorBias->GetBinError(1)<<endl;
1337   cout<<"  to QC{4}: "<<fIntFlowDetectorBias->GetBinContent(2)<<" +/- "<<fIntFlowDetectorBias->GetBinError(2)<<endl;
1338   cout<<endl;
1339  }
1340  if(type == "RF" || type == "RF, rebinned in M")
1341  {
1342   cout<<"     nEvts = "<<(Int_t)fCommonHists->GetHistMultRP()->GetEntries()<<", <M> = "<<(Double_t)fCommonHists->GetHistMultRP()->GetMean()<<endl; 
1343  }
1344  else if (type == "RP")
1345  {
1346   cout<<"     nEvts = "<<(Int_t)fCommonHists->GetHistMultRP()->GetEntries()<<", <M> = "<<(Double_t)fCommonHists->GetHistMultRP()->GetMean()<<endl;  
1347  } 
1348  else if (type == "POI")
1349  {
1350   cout<<"     nEvts = "<<(Int_t)fCommonHists->GetHistMultPOI()->GetEntries()<<", <M> = "<<(Double_t)fCommonHists->GetHistMultPOI()->GetMean()<<endl;
1351  }  
1352  
1353  cout<<"*************************************"<<endl;
1354  cout<<"*************************************"<<endl;
1355  cout<<endl; 
1356   
1357 }// end of AliFlowAnalysisWithQCumulants::PrintFinalResultsForIntegratedFlow(TString type="RF");
1358
1359 //================================================================================================================================
1360
1361 void AliFlowAnalysisWithQCumulants::WriteHistograms(TString outputFileName)
1362 {
1363  //store the final results in output .root file
1364  TFile *output = new TFile(outputFileName.Data(),"RECREATE");
1365  //output->WriteObject(fHistList, "cobjQC","SingleKey");
1366  fHistList->Write(fHistList->GetName(), TObject::kSingleKey);
1367  delete output;
1368 }
1369
1370
1371 //================================================================================================================================
1372
1373
1374 void AliFlowAnalysisWithQCumulants::WriteHistograms(TDirectoryFile *outputFileName)
1375 {
1376  //store the final results in output .root file
1377  fHistList->SetName("cobjQC");
1378  fHistList->SetOwner(kTRUE);
1379  outputFileName->Add(fHistList);
1380  outputFileName->Write(outputFileName->GetName(), TObject::kSingleKey);
1381 }
1382
1383 //================================================================================================================================
1384
1385 void AliFlowAnalysisWithQCumulants::BookCommonHistograms()
1386 {
1387  // Book common control histograms and common histograms for final results.
1388  //  a) Book common control histograms;
1389  //  b) Book common result histograms.
1390  
1391  // a) Book common control histograms: 
1392  //  Common control histograms (all events):
1393  TString commonHistsName = "AliFlowCommonHistQC";
1394  commonHistsName += fAnalysisLabel->Data();
1395  fCommonHists = new AliFlowCommonHist(commonHistsName.Data(),commonHistsName.Data(),fBookOnlyBasicCCH);
1396  fHistList->Add(fCommonHists);  
1397  //  Common control histograms (selected events):
1398  if(fFillMultipleControlHistograms)
1399  {
1400   // Common control histogram filled for events with 2 and more reference particles:
1401   TString commonHists2ndOrderName = "AliFlowCommonHist2ndOrderQC";
1402   commonHists2ndOrderName += fAnalysisLabel->Data();
1403   fCommonHists2nd = new AliFlowCommonHist(commonHists2ndOrderName.Data(),commonHists2ndOrderName.Data(),fBookOnlyBasicCCH);
1404   fHistList->Add(fCommonHists2nd);  
1405   // Common control histogram filled for events with 2 and more reference particles:
1406   TString commonHists4thOrderName = "AliFlowCommonHist4thOrderQC";
1407   commonHists4thOrderName += fAnalysisLabel->Data();
1408   fCommonHists4th = new AliFlowCommonHist(commonHists4thOrderName.Data(),commonHists4thOrderName.Data(),fBookOnlyBasicCCH);
1409   fHistList->Add(fCommonHists4th);  
1410   // Common control histogram filled for events with 6 and more reference particles:
1411   TString commonHists6thOrderName = "AliFlowCommonHist6thOrderQC";
1412   commonHists6thOrderName += fAnalysisLabel->Data();
1413   fCommonHists6th = new AliFlowCommonHist(commonHists6thOrderName.Data(),commonHists6thOrderName.Data(),fBookOnlyBasicCCH);
1414   fHistList->Add(fCommonHists6th);  
1415   // Common control histogram filled for events with 8 and more reference particles:
1416   TString commonHists8thOrderName = "AliFlowCommonHist8thOrderQC";
1417   commonHists8thOrderName += fAnalysisLabel->Data();
1418   fCommonHists8th = new AliFlowCommonHist(commonHists8thOrderName.Data(),commonHists8thOrderName.Data(),fBookOnlyBasicCCH);
1419   fHistList->Add(fCommonHists8th);    
1420  } // end of if(fFillMultipleControlHistograms)
1421  
1422  // b) Book common result histograms: 
1423  //  Common result histograms for QC{2}:
1424  TString commonHistResults2ndOrderName = "AliFlowCommonHistResults2ndOrderQC";
1425  commonHistResults2ndOrderName += fAnalysisLabel->Data();
1426  fCommonHistsResults2nd = new AliFlowCommonHistResults(commonHistResults2ndOrderName.Data(),"",fHarmonic);
1427  fHistList->Add(fCommonHistsResults2nd);  
1428  //  Common result histograms for QC{4}:
1429  TString commonHistResults4thOrderName = "AliFlowCommonHistResults4thOrderQC";
1430  commonHistResults4thOrderName += fAnalysisLabel->Data();
1431  fCommonHistsResults4th = new AliFlowCommonHistResults(commonHistResults4thOrderName.Data(),"",fHarmonic);
1432  fHistList->Add(fCommonHistsResults4th); 
1433  //  Common result histograms for QC{6}:
1434  TString commonHistResults6thOrderName = "AliFlowCommonHistResults6thOrderQC";
1435  commonHistResults6thOrderName += fAnalysisLabel->Data();
1436  fCommonHistsResults6th = new AliFlowCommonHistResults(commonHistResults6thOrderName.Data(),"",fHarmonic);
1437  fHistList->Add(fCommonHistsResults6th);  
1438  //  Common result histograms for QC{8}:
1439  TString commonHistResults8thOrderName = "AliFlowCommonHistResults8thOrderQC";
1440  commonHistResults8thOrderName += fAnalysisLabel->Data();
1441  fCommonHistsResults8th = new AliFlowCommonHistResults(commonHistResults8thOrderName.Data(),"",fHarmonic);
1442  fHistList->Add(fCommonHistsResults8th); 
1443  
1444 } // end of void AliFlowAnalysisWithQCumulants::BookCommonHistograms()
1445
1446 //================================================================================================================================
1447
1448 void AliFlowAnalysisWithQCumulants::BookAndFillWeightsHistograms()
1449 {
1450  // Book and fill histograms which hold phi, pt and eta weights.
1451
1452  if(!fWeightsList)
1453  {
1454   printf("\n WARNING (QC): fWeightsList is NULL in AFAWQC::BAFWH() !!!! \n\n");
1455   exit(0);  
1456  }
1457     
1458  TString fUseParticleWeightsName = "fUseParticleWeightsQC";
1459  fUseParticleWeightsName += fAnalysisLabel->Data();
1460  fUseParticleWeights = new TProfile(fUseParticleWeightsName.Data(),"0 = particle weight not used, 1 = particle weight used ",4,0,4);
1461  fUseParticleWeights->SetLabelSize(0.06);
1462  (fUseParticleWeights->GetXaxis())->SetBinLabel(1,"w_{#phi}");
1463  (fUseParticleWeights->GetXaxis())->SetBinLabel(2,"w_{p_{T}}");
1464  (fUseParticleWeights->GetXaxis())->SetBinLabel(3,"w_{#eta}");
1465  (fUseParticleWeights->GetXaxis())->SetBinLabel(4,"w_{track}");
1466  fUseParticleWeights->Fill(0.5,(Int_t)fUsePhiWeights);
1467  fUseParticleWeights->Fill(1.5,(Int_t)fUsePtWeights);
1468  fUseParticleWeights->Fill(2.5,(Int_t)fUseEtaWeights);
1469  fUseParticleWeights->Fill(3.5,(Int_t)fUseTrackWeights);
1470  fWeightsList->Add(fUseParticleWeights); 
1471   
1472  if(fUsePhiWeights)
1473  {
1474   if(fWeightsList->FindObject("phi_weights"))
1475   {
1476    fPhiWeights = dynamic_cast<TH1F*>(fWeightsList->FindObject("phi_weights"));
1477    if(!fPhiWeights)
1478    {
1479     printf("\n WARNING (QC): fPhiWeights is NULL in AFAWQC::BAFWH() !!!!\n\n");
1480     exit(0);
1481    }
1482    if(TMath::Abs(fPhiWeights->GetBinWidth(1)-fPhiBinWidth)>pow(10.,-6.))
1483    {
1484     cout<<endl;
1485     cout<<"WARNING (QC): Inconsistent binning in histograms for phi-weights throughout the code."<<endl;
1486     cout<<endl;
1487     //exit(0);
1488    }
1489   } else 
1490     {
1491      cout<<"WARNING: fWeightsList->FindObject(\"phi_weights\") is NULL in AFAWQC::BAFWH() !!!!"<<endl;
1492      exit(0);
1493     }
1494  } // end of if(fUsePhiWeights)
1495  
1496  if(fUsePtWeights) 
1497  {
1498   if(fWeightsList->FindObject("pt_weights"))
1499   {
1500    fPtWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("pt_weights"));
1501    if(!fPtWeights)
1502    {
1503     printf("\n WARNING (QC): fPtWeights is NULL in AFAWQC::BAFWH() !!!!\n\n");
1504     exit(0);
1505    }
1506    if(TMath::Abs(fPtWeights->GetBinWidth(1)-fPtBinWidth)>pow(10.,-6.))
1507    {
1508     cout<<endl;
1509     cout<<"WARNING (QC): Inconsistent binning in histograms for pt-weights throughout the code."<<endl;
1510     cout<<endl;
1511     //exit(0);
1512    }
1513   } else 
1514     {
1515      cout<<"WARNING: fWeightsList->FindObject(\"pt_weights\") is NULL in AFAWQC::BAFWH() !!!!"<<endl;
1516      exit(0);
1517     }
1518  } // end of if(fUsePtWeights)    
1519
1520  if(fUseEtaWeights) 
1521  {
1522   if(fWeightsList->FindObject("eta_weights"))
1523   {
1524    fEtaWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("eta_weights"));
1525    if(!fEtaWeights)
1526    {
1527     printf("\n WARNING (QC): fEtaWeights is NULL in AFAWQC::BAFWH() !!!!\n\n");
1528     exit(0);
1529    }
1530    if(TMath::Abs(fEtaWeights->GetBinWidth(1)-fEtaBinWidth)>pow(10.,-6.))
1531    {
1532     cout<<endl;
1533     cout<<"WARNING (QC): Inconsistent binning in histograms for eta-weights throughout the code."<<endl;
1534     cout<<endl;
1535     //exit(0);
1536    }
1537   } else 
1538     {
1539      cout<<"WARNING: fUseEtaWeights && fWeightsList->FindObject(\"eta_weights\") is NULL in AFAWQC::BAFWH() !!!!"<<endl;
1540      exit(0);
1541     }
1542  } // end of if(fUseEtaWeights)
1543  
1544 } // end of AliFlowAnalysisWithQCumulants::BookAndFillWeightsHistograms()
1545
1546 //================================================================================================================================
1547
1548 void AliFlowAnalysisWithQCumulants::BookEverythingForIntegratedFlow()
1549 {
1550  // Book all objects for integrated flow:
1551  //  a) Book profile to hold all flags for integrated flow;
1552  //  b) Book event-by-event quantities;
1553  //  c) Book profiles; // to be improved (comment)
1554  //  d) Book histograms holding the final results.
1555  
1556  TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data members?)
1557  TString powerFlag[2] = {"linear","quadratic"}; // to be improved (should I promote this to data members?)
1558  
1559  // a) Book profile to hold all flags for integrated flow:
1560  TString intFlowFlagsName = "fIntFlowFlags";
1561  intFlowFlagsName += fAnalysisLabel->Data();
1562  fIntFlowFlags = new TProfile(intFlowFlagsName.Data(),"Flags for Integrated Flow",15,0,15);
1563  fIntFlowFlags->SetTickLength(-0.01,"Y");
1564  fIntFlowFlags->SetMarkerStyle(25);
1565  fIntFlowFlags->SetLabelSize(0.04);
1566  fIntFlowFlags->SetLabelOffset(0.02,"Y");
1567  fIntFlowFlags->GetXaxis()->SetBinLabel(1,"Particle Weights");
1568  fIntFlowFlags->GetXaxis()->SetBinLabel(2,"Event Weights");
1569  fIntFlowFlags->GetXaxis()->SetBinLabel(3,"Corrected for NUA?");
1570  fIntFlowFlags->GetXaxis()->SetBinLabel(4,"Print RF results");
1571  fIntFlowFlags->GetXaxis()->SetBinLabel(5,"Print RP results");
1572  fIntFlowFlags->GetXaxis()->SetBinLabel(6,"Print POI results");
1573  fIntFlowFlags->GetXaxis()->SetBinLabel(7,"Print RF (rebinned in M) results");
1574  fIntFlowFlags->GetXaxis()->SetBinLabel(8,"Corrected for NUA vs M?");
1575  fIntFlowFlags->GetXaxis()->SetBinLabel(9,"Propagate errors to v_{n} from correlations?");
1576  fIntFlowFlags->GetXaxis()->SetBinLabel(10,"Calculate cumulants vs M");
1577  fIntFlowFlags->GetXaxis()->SetBinLabel(11,"fMinimumBiasReferenceFlow");
1578  fIntFlowFlags->GetXaxis()->SetBinLabel(12,"fForgetAboutCovariances");
1579  fIntFlowFlags->GetXaxis()->SetBinLabel(13,"fStorePhiDistributionForOneEvent");
1580  fIntFlowFlags->GetXaxis()->SetBinLabel(14,"fFillMultipleControlHistograms");
1581  fIntFlowFlags->GetXaxis()->SetBinLabel(15,"Calculate all correlations vs M");
1582  fIntFlowList->Add(fIntFlowFlags);
1583
1584  // b) Book event-by-event quantities:
1585  // Re[Q_{m*n,k}], Im[Q_{m*n,k}] and S_{p,k}^M: 
1586  fReQ  = new TMatrixD(6,9);
1587  fImQ  = new TMatrixD(6,9);
1588  fSpk = new TMatrixD(8,9);
1589  // average correlations <2>, <4>, <6> and <8> for single event (bining is the same as in fIntFlowCorrelationsPro and fIntFlowCorrelationsHist):
1590  TString intFlowCorrelationsEBEName = "fIntFlowCorrelationsEBE";
1591  intFlowCorrelationsEBEName += fAnalysisLabel->Data();
1592  fIntFlowCorrelationsEBE = new TH1D(intFlowCorrelationsEBEName.Data(),intFlowCorrelationsEBEName.Data(),4,0,4);
1593  // weights for average correlations <2>, <4>, <6> and <8> for single event:
1594  TString intFlowEventWeightsForCorrelationsEBEName = "fIntFlowEventWeightsForCorrelationsEBE";
1595  intFlowEventWeightsForCorrelationsEBEName += fAnalysisLabel->Data();
1596  fIntFlowEventWeightsForCorrelationsEBE = new TH1D(intFlowEventWeightsForCorrelationsEBEName.Data(),intFlowEventWeightsForCorrelationsEBEName.Data(),4,0,4);
1597  // average all correlations for single event (bining is the same as in fIntFlowCorrelationsAllPro and fIntFlowCorrelationsAllHist):
1598  TString intFlowCorrelationsAllEBEName = "fIntFlowCorrelationsAllEBE";
1599  intFlowCorrelationsAllEBEName += fAnalysisLabel->Data();
1600  fIntFlowCorrelationsAllEBE = new TH1D(intFlowCorrelationsAllEBEName.Data(),intFlowCorrelationsAllEBEName.Data(),64,0,64);
1601  // average correction terms for non-uniform acceptance for single event 
1602  // (binning is the same as in fIntFlowCorrectionTermsForNUAPro[2] and fIntFlowCorrectionTermsForNUAHist[2]):
1603  TString fIntFlowCorrectionTermsForNUAEBEName = "fIntFlowCorrectionTermsForNUAEBE";
1604  fIntFlowCorrectionTermsForNUAEBEName += fAnalysisLabel->Data();
1605  for(Int_t sc=0;sc<2;sc++) // sin or cos terms
1606  {
1607   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()),4,0,4);  
1608  }
1609  // event weights for terms for non-uniform acceptance: 
1610  TString fIntFlowEventWeightForCorrectionTermsForNUAEBEName = "fIntFlowEventWeightForCorrectionTermsForNUAEBE";
1611  fIntFlowEventWeightForCorrectionTermsForNUAEBEName += fAnalysisLabel->Data();
1612  for(Int_t sc=0;sc<2;sc++) // sin or cos terms
1613  {
1614   fIntFlowEventWeightForCorrectionTermsForNUAEBE[sc] = new TH1D(Form("%s: %s terms",fIntFlowEventWeightForCorrectionTermsForNUAEBEName.Data(),sinCosFlag[sc].Data()),Form("Event weights for terms for non-uniform acceptance (%s terms)",sinCosFlag[sc].Data()),4,0,4); // to be improved - 4  
1615  }
1616  // c) Book profiles: // to be improved (comment)
1617  // profile to hold average multiplicities and number of events for events with nRP>=0, nRP>=1, ... , and nRP>=8:
1618  TString avMultiplicityName = "fAvMultiplicity";
1619  avMultiplicityName += fAnalysisLabel->Data();
1620  fAvMultiplicity = new TProfile(avMultiplicityName.Data(),"Average multiplicities of reference particles (RPs)",9,0,9);
1621  fAvMultiplicity->SetTickLength(-0.01,"Y");
1622  fAvMultiplicity->SetMarkerStyle(25);
1623  fAvMultiplicity->SetLabelSize(0.05);
1624  fAvMultiplicity->SetLabelOffset(0.02,"Y");
1625  fAvMultiplicity->SetYTitle("Average multiplicity");
1626  (fAvMultiplicity->GetXaxis())->SetBinLabel(1,"all evts");
1627  (fAvMultiplicity->GetXaxis())->SetBinLabel(2,"n_{RP} #geq 1");
1628  (fAvMultiplicity->GetXaxis())->SetBinLabel(3,"n_{RP} #geq 2");
1629  (fAvMultiplicity->GetXaxis())->SetBinLabel(4,"n_{RP} #geq 3");
1630  (fAvMultiplicity->GetXaxis())->SetBinLabel(5,"n_{RP} #geq 4");
1631  (fAvMultiplicity->GetXaxis())->SetBinLabel(6,"n_{RP} #geq 5");
1632  (fAvMultiplicity->GetXaxis())->SetBinLabel(7,"n_{RP} #geq 6");
1633  (fAvMultiplicity->GetXaxis())->SetBinLabel(8,"n_{RP} #geq 7");
1634  (fAvMultiplicity->GetXaxis())->SetBinLabel(9,"n_{RP} #geq 8");
1635  fIntFlowProfiles->Add(fAvMultiplicity);
1636  // Average correlations <<2>>, <<4>>, <<6>> and <<8>> for all events (with wrong errors!):
1637  TString correlationFlag[4] = {"#LT#LT2#GT#GT","#LT#LT4#GT#GT","#LT#LT6#GT#GT","#LT#LT8#GT#GT"};
1638  TString intFlowCorrelationsProName = "fIntFlowCorrelationsPro";
1639  intFlowCorrelationsProName += fAnalysisLabel->Data();
1640  fIntFlowCorrelationsPro = new TProfile(intFlowCorrelationsProName.Data(),"Average correlations for all events",4,0,4,"s");
1641  fIntFlowCorrelationsPro->Sumw2();
1642  fIntFlowCorrelationsPro->SetTickLength(-0.01,"Y");
1643  fIntFlowCorrelationsPro->SetMarkerStyle(25);
1644  fIntFlowCorrelationsPro->SetLabelSize(0.06);
1645  fIntFlowCorrelationsPro->SetLabelOffset(0.01,"Y");
1646  for(Int_t b=0;b<4;b++)
1647  {
1648   (fIntFlowCorrelationsPro->GetXaxis())->SetBinLabel(b+1,correlationFlag[b].Data());
1649  }
1650  fIntFlowProfiles->Add(fIntFlowCorrelationsPro);
1651  // Average correlations squared <<2>^2>, <<4>^2>, <<6>^2> and <<8>^2> for all events:
1652  TString squaredCorrelationFlag[4] = {"#LT#LT2#GT^{2}#GT","#LT#LT4#GT^{2}#GT","#LT#LT6#GT^{2}#GT","#LT#LT8#GT^{2}#GT"};
1653  TString intFlowSquaredCorrelationsProName = "fIntFlowSquaredCorrelationsPro";
1654  intFlowSquaredCorrelationsProName += fAnalysisLabel->Data();
1655  fIntFlowSquaredCorrelationsPro = new TProfile(intFlowSquaredCorrelationsProName.Data(),"Average squared correlations for all events",4,0,4,"s");
1656  fIntFlowSquaredCorrelationsPro->Sumw2();
1657  fIntFlowSquaredCorrelationsPro->SetTickLength(-0.01,"Y");
1658  fIntFlowSquaredCorrelationsPro->SetMarkerStyle(25);
1659  fIntFlowSquaredCorrelationsPro->SetLabelSize(0.06);
1660  fIntFlowSquaredCorrelationsPro->SetLabelOffset(0.01,"Y");
1661  for(Int_t b=0;b<4;b++)
1662  {
1663   (fIntFlowSquaredCorrelationsPro->GetXaxis())->SetBinLabel(b+1,squaredCorrelationFlag[b].Data());
1664  }
1665  fIntFlowProfiles->Add(fIntFlowSquaredCorrelationsPro);
1666  if(fCalculateCumulantsVsM)
1667  {
1668   for(Int_t ci=0;ci<4;ci++) // correlation index
1669   {
1670    // average correlations <<2>>, <<4>>, <<6>> and <<8>> versus multiplicity for all events (with wrong errors):
1671    TString intFlowCorrelationsVsMProName = "fIntFlowCorrelationsVsMPro";
1672    intFlowCorrelationsVsMProName += fAnalysisLabel->Data();
1673    fIntFlowCorrelationsVsMPro[ci] = new TProfile(Form("%s, %s",intFlowCorrelationsVsMProName.Data(),correlationFlag[ci].Data()),
1674                                                  Form("%s vs multiplicity",correlationFlag[ci].Data()),
1675                                                  fnBinsMult,fMinMult,fMaxMult,"s");   
1676    fIntFlowCorrelationsVsMPro[ci]->Sumw2();                                                                                       
1677    fIntFlowCorrelationsVsMPro[ci]->GetYaxis()->SetTitle(correlationFlag[ci].Data());
1678    fIntFlowCorrelationsVsMPro[ci]->GetXaxis()->SetTitle("M");
1679    fIntFlowProfiles->Add(fIntFlowCorrelationsVsMPro[ci]);
1680    // average squared correlations <<2>^2>, <<4>^2>, <<6>^2> and <<8>^2> versus multiplicity for all events:  
1681    TString intFlowSquaredCorrelationsVsMProName = "fIntFlowSquaredCorrelationsVsMPro";
1682    intFlowSquaredCorrelationsVsMProName += fAnalysisLabel->Data();
1683    fIntFlowSquaredCorrelationsVsMPro[ci] = new TProfile(Form("%s, %s",intFlowSquaredCorrelationsVsMProName.Data(),squaredCorrelationFlag[ci].Data()),
1684                                                         Form("%s vs multiplicity",squaredCorrelationFlag[ci].Data()),
1685                                                         fnBinsMult,fMinMult,fMaxMult,"s");   
1686    fIntFlowSquaredCorrelationsVsMPro[ci]->Sumw2();                                                                                              
1687    fIntFlowSquaredCorrelationsVsMPro[ci]->GetYaxis()->SetTitle(squaredCorrelationFlag[ci].Data());
1688    fIntFlowSquaredCorrelationsVsMPro[ci]->GetXaxis()->SetTitle("M");
1689    fIntFlowProfiles->Add(fIntFlowSquaredCorrelationsVsMPro[ci]);
1690   } // end of for(Int_t ci=0;ci<4;ci++) // correlation index  
1691  } // end of if(fCalculateCumulantsVsM)
1692  // averaged all correlations for all events (with wrong errors!):
1693  TString intFlowCorrelationsAllProName = "fIntFlowCorrelationsAllPro";
1694  intFlowCorrelationsAllProName += fAnalysisLabel->Data();
1695  fIntFlowCorrelationsAllPro = new TProfile(intFlowCorrelationsAllProName.Data(),"Average all correlations for all events",64,0,64);
1696  fIntFlowCorrelationsAllPro->Sumw2();
1697  fIntFlowCorrelationsAllPro->SetTickLength(-0.01,"Y");
1698  fIntFlowCorrelationsAllPro->SetMarkerStyle(25);
1699  fIntFlowCorrelationsAllPro->SetLabelSize(0.03);
1700  fIntFlowCorrelationsAllPro->SetLabelOffset(0.01,"Y");
1701  // 2-p correlations:
1702  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(1,"#LT#LT2#GT#GT_{n|n}");
1703  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(2,"#LT#LT2#GT#GT_{2n|2n}");
1704  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(3,"#LT#LT2#GT#GT_{3n|3n}");
1705  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(4,"#LT#LT2#GT#GT_{4n|4n}");
1706  // 3-p correlations:
1707  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(6,"#LT#LT3#GT#GT_{2n|n,n}");
1708  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(7,"#LT#LT3#GT#GT_{3n|2n,n}");
1709  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(8,"#LT#LT3#GT#GT_{4n|2n,2n}");
1710  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(9,"#LT#LT3#GT#GT_{4n|3n,n}");
1711  // 4-p correlations:
1712  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(11,"#LT#LT4#GT#GT_{n,n|n,n}"); 
1713  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(12,"#LT#LT4#GT#GT_{2n,n|2n,n}");
1714  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(13,"#LT#LT4#GT#GT_{2n,2n|2n,2n}");
1715  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(14,"#LT#LT4#GT#GT_{3n|n,n,n}");
1716  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(15,"#LT#LT4#GT#GT_{3n,n|3n,n}");
1717  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(16,"#LT#LT4#GT#GT_{3n,n|2n,2n}"); 
1718  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(17,"#LT#LT4#GT#GT_{4n|2n,n,n}");
1719  // 5-p correlations:
1720  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(19,"#LT#LT5#GT#GT_{2n,n|n,n,n}"); 
1721  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(20,"#LT#LT5#GT#GT_{2n,2n|2n,n,n}");
1722  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(21,"#LT#LT5#GT#GT_{3n,n|2n,n,n}");
1723  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(22,"#LT#LT5#GT#GT_{4n|n,n,n,n}");
1724  // 6-p correlations:
1725  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(24,"#LT#LT6#GT#GT_{n,n,n|n,n,n}");
1726  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(25,"#LT#LT6#GT#GT_{2n,n,n|2n,n,n}");
1727  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(26,"#LT#LT6#GT#GT_{2n,2n|n,n,n,n}");
1728  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(27,"#LT#LT6#GT#GT_{3n,n|n,n,n,n}");
1729  // 7-p correlations:  
1730  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(29,"#LT#LT7#GT#GT_{2n,n,n|n,n,n,n}");
1731  // 8-p correlations:
1732  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(31,"#LT#LT8#GT#GT_{n,n,n,n|n,n,n,n}");
1733  //  EXTRA correlations for v3{5} study:
1734  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(33,"#LT#LT4#GT#GT_{4n,2n|3n,3n}");
1735  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(34,"#LT#LT5#GT#GT_{3n,3n|2n,2n,2n}");
1736  //  EXTRA correlations for Teaney-Yan study:
1737  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(35,"#LT#LT2#GT#GT_{5n|5n}");
1738  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(36,"#LT#LT2#GT#GT_{6n|6n}");
1739  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(37,"#LT#LT3#GT#GT_{5n|3n,2n}");
1740  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(38,"#LT#LT3#GT#GT_{5n|4n,1n}");
1741  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(39,"#LT#LT3#GT#GT_{6n|3n,3n}");
1742  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(40,"#LT#LT3#GT#GT_{6n|4n,2n}");
1743  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(41,"#LT#LT3#GT#GT_{6n|5n,1n}");
1744  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(42,"#LT#LT4#GT#GT_{6n|3n,2n,1n}");
1745  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(43,"#LT#LT4#GT#GT_{3n,2n|3n,2n}");
1746  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(44,"#LT#LT4#GT#GT_{4n,1n|3n,2n}");
1747  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(45,"#LT#LT4#GT#GT_{3n,3n|3n,3n}");
1748  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(46,"#LT#LT4#GT#GT_{4n,2n|3n,3n}");
1749  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(47,"#LT#LT4#GT#GT_{5n,1n|3n,3n}");
1750  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(48,"#LT#LT4#GT#GT_{4n,2n|4n,2n}");
1751  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(49,"#LT#LT4#GT#GT_{5n,1n|4n,2n}");
1752  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(50,"#LT#LT4#GT#GT_{5n|3n,1n,1n}");
1753  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(51,"#LT#LT4#GT#GT_{5n|2n,2n,1n}");
1754  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(52,"#LT#LT4#GT#GT_{5n,1n|5n,1n}");
1755  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(53,"#LT#LT5#GT#GT_{3n,3n|3n,2n,1n}");
1756  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(54,"#LT#LT5#GT#GT_{4n,2n|3n,2n,1n}");
1757  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(55,"#LT#LT5#GT#GT_{3n,2n|3n,1n,1n}");
1758  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(56,"#LT#LT5#GT#GT_{3n,2n|2n,2n,1n}");
1759  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(57,"#LT#LT5#GT#GT_{5n,1n|3n,2n,1n}");
1760  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(58,"#LT#LT6#GT#GT_{3n,2n,1n|3n,2n,1n}");
1761  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(59,"#LT#LT4#GT#GT_{6n|4n,1n,1n}");
1762  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(60,"#LT#LT4#GT#GT_{6n|2n,2n,2n}");
1763  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(61,"#LT#LT5#GT#GT_{6n|2n,2n,1n,1n}");
1764  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(62,"#LT#LT5#GT#GT_{4n,1n,1n|3n,3n}");
1765  (fIntFlowCorrelationsAllPro->GetXaxis())->SetBinLabel(63,"#LT#LT6#GT#GT_{3n,3n|2n,2n,1n,1n}");
1766  fIntFlowProfiles->Add(fIntFlowCorrelationsAllPro);
1767  // average all correlations versus multiplicity (errors via Sumw2 - to be improved):
1768  if(fCalculateAllCorrelationsVsM)
1769  {
1770   // 2-p correlations vs M:  
1771   fIntFlowCorrelationsAllVsMPro[0] = new TProfile("two1n1n","#LT#LT2#GT#GT_{n|n}",fnBinsMult,fMinMult,fMaxMult);
1772   fIntFlowCorrelationsAllVsMPro[0]->Sumw2();
1773   fIntFlowCorrelationsAllVsMPro[0]->GetXaxis()->SetTitle("M");  
1774   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[0]);  
1775   fIntFlowCorrelationsAllVsMPro[1] = new TProfile("two2n2n","#LT#LT2#GT#GT_{2n|2n}",fnBinsMult,fMinMult,fMaxMult);
1776   fIntFlowCorrelationsAllVsMPro[1]->Sumw2();
1777   fIntFlowCorrelationsAllVsMPro[1]->GetXaxis()->SetTitle("M");  
1778   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[1]);
1779   fIntFlowCorrelationsAllVsMPro[2] = new TProfile("two3n3n","#LT#LT2#GT#GT_{3n|3n}",fnBinsMult,fMinMult,fMaxMult);
1780   fIntFlowCorrelationsAllVsMPro[2]->Sumw2();
1781   fIntFlowCorrelationsAllVsMPro[2]->GetXaxis()->SetTitle("M");  
1782   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[2]);
1783   fIntFlowCorrelationsAllVsMPro[3] = new TProfile("two4n4n","#LT#LT2#GT#GT_{4n|4n}",fnBinsMult,fMinMult,fMaxMult);
1784   fIntFlowCorrelationsAllVsMPro[3]->Sumw2();
1785   fIntFlowCorrelationsAllVsMPro[3]->GetXaxis()->SetTitle("M");  
1786   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[3]);
1787   // 3-p correlations vs M:
1788   fIntFlowCorrelationsAllVsMPro[5] = new TProfile("three2n1n1n","#LT#LT3#GT#GT_{2n|n,n}",fnBinsMult,fMinMult,fMaxMult);
1789   fIntFlowCorrelationsAllVsMPro[5]->Sumw2();
1790   fIntFlowCorrelationsAllVsMPro[5]->GetXaxis()->SetTitle("M");  
1791   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[5]);
1792   fIntFlowCorrelationsAllVsMPro[6] = new TProfile("three3n2n1n","#LT#LT3#GT#GT_{3n|2n,n}",fnBinsMult,fMinMult,fMaxMult);
1793   fIntFlowCorrelationsAllVsMPro[6]->Sumw2();
1794   fIntFlowCorrelationsAllVsMPro[6]->GetXaxis()->SetTitle("M");  
1795   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[6]);
1796   fIntFlowCorrelationsAllVsMPro[7] = new TProfile("three4n2n2n","#LT#LT3#GT#GT_{4n|2n,2n}",fnBinsMult,fMinMult,fMaxMult);
1797   fIntFlowCorrelationsAllVsMPro[7]->Sumw2();
1798   fIntFlowCorrelationsAllVsMPro[7]->GetXaxis()->SetTitle("M");  
1799   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[7]);
1800   fIntFlowCorrelationsAllVsMPro[8] = new TProfile("three4n3n1n","#LT#LT3#GT#GT_{4n|3n,n}",fnBinsMult,fMinMult,fMaxMult);
1801   fIntFlowCorrelationsAllVsMPro[8]->Sumw2();
1802   fIntFlowCorrelationsAllVsMPro[8]->GetXaxis()->SetTitle("M");  
1803   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[8]);
1804   // 4-p correlations vs M:
1805   fIntFlowCorrelationsAllVsMPro[10] = new TProfile("four1n1n1n1n","#LT#LT4#GT#GT_{n,n|n,n}",fnBinsMult,fMinMult,fMaxMult);
1806   fIntFlowCorrelationsAllVsMPro[10]->Sumw2();
1807   fIntFlowCorrelationsAllVsMPro[10]->GetXaxis()->SetTitle("M");  
1808   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[10]);
1809   fIntFlowCorrelationsAllVsMPro[11] = new TProfile("four2n1n2n1n","#LT#LT4#GT#GT_{2n,n|2n,n}",fnBinsMult,fMinMult,fMaxMult);
1810   fIntFlowCorrelationsAllVsMPro[11]->Sumw2();
1811   fIntFlowCorrelationsAllVsMPro[11]->GetXaxis()->SetTitle("M");  
1812   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[11]);
1813   fIntFlowCorrelationsAllVsMPro[12] = new TProfile("four2n2n2n2n","#LT#LT4#GT#GT_{2n,2n|2n,2n}",fnBinsMult,fMinMult,fMaxMult);
1814   fIntFlowCorrelationsAllVsMPro[12]->Sumw2();
1815   fIntFlowCorrelationsAllVsMPro[12]->GetXaxis()->SetTitle("M");  
1816   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[12]);
1817   fIntFlowCorrelationsAllVsMPro[13] = new TProfile("four3n1n1n1n","#LT#LT4#GT#GT_{3n|n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1818   fIntFlowCorrelationsAllVsMPro[13]->Sumw2();
1819   fIntFlowCorrelationsAllVsMPro[13]->GetXaxis()->SetTitle("M");  
1820   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[13]);
1821   fIntFlowCorrelationsAllVsMPro[14] = new TProfile("four3n1n3n1n","#LT#LT4#GT#GT_{3n,n|3n,n}",fnBinsMult,fMinMult,fMaxMult);
1822   fIntFlowCorrelationsAllVsMPro[14]->Sumw2();
1823   fIntFlowCorrelationsAllVsMPro[14]->GetXaxis()->SetTitle("M");  
1824   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[14]);
1825   fIntFlowCorrelationsAllVsMPro[15] = new TProfile("four3n1n2n2n","#LT#LT4#GT#GT_{3n,n|2n,2n}",fnBinsMult,fMinMult,fMaxMult);
1826   fIntFlowCorrelationsAllVsMPro[15]->Sumw2();
1827   fIntFlowCorrelationsAllVsMPro[15]->GetXaxis()->SetTitle("M");  
1828   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[15]);
1829   fIntFlowCorrelationsAllVsMPro[16] = new TProfile("four4n2n1n1n","#LT#LT4#GT#GT_{4n|2n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1830   fIntFlowCorrelationsAllVsMPro[16]->Sumw2();
1831   fIntFlowCorrelationsAllVsMPro[16]->GetXaxis()->SetTitle("M");  
1832   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[16]);
1833   // 5-p correlations vs M:
1834   fIntFlowCorrelationsAllVsMPro[18] = new TProfile("five2n1n1n1n1n","#LT#LT5#GT#GT_{2n,n|n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1835   fIntFlowCorrelationsAllVsMPro[18]->Sumw2();
1836   fIntFlowCorrelationsAllVsMPro[18]->GetXaxis()->SetTitle("M");  
1837   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[18]);
1838   fIntFlowCorrelationsAllVsMPro[19] = new TProfile("five2n2n2n1n1n","#LT#LT5#GT#GT_{2n,2n|2n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1839   fIntFlowCorrelationsAllVsMPro[19]->Sumw2();
1840   fIntFlowCorrelationsAllVsMPro[19]->GetXaxis()->SetTitle("M");  
1841   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[19]);
1842   fIntFlowCorrelationsAllVsMPro[20] = new TProfile("five3n1n2n1n1n","#LT#LT5#GT#GT_{3n,n|2n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1843   fIntFlowCorrelationsAllVsMPro[20]->Sumw2();
1844   fIntFlowCorrelationsAllVsMPro[20]->GetXaxis()->SetTitle("M");  
1845   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[20]);
1846   fIntFlowCorrelationsAllVsMPro[21] = new TProfile("five4n1n1n1n1n","#LT#LT5#GT#GT_{4n|n,n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1847   fIntFlowCorrelationsAllVsMPro[21]->Sumw2();
1848   fIntFlowCorrelationsAllVsMPro[21]->GetXaxis()->SetTitle("M");  
1849   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[21]);
1850   // 6-p correlations vs M:
1851   fIntFlowCorrelationsAllVsMPro[23] = new TProfile("six1n1n1n1n1n1n","#LT#LT6#GT#GT_{n,n,n|n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1852   fIntFlowCorrelationsAllVsMPro[23]->Sumw2();
1853   fIntFlowCorrelationsAllVsMPro[23]->GetXaxis()->SetTitle("M");  
1854   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[23]);
1855   fIntFlowCorrelationsAllVsMPro[24] = new TProfile("six2n1n1n2n1n1n","#LT#LT6#GT#GT_{2n,n,n|2n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1856   fIntFlowCorrelationsAllVsMPro[24]->Sumw2();
1857   fIntFlowCorrelationsAllVsMPro[24]->GetXaxis()->SetTitle("M");  
1858   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[24]);
1859   fIntFlowCorrelationsAllVsMPro[25] = new TProfile("six2n2n1n1n1n1n","#LT#LT6#GT#GT_{2n,2n|n,n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1860   fIntFlowCorrelationsAllVsMPro[25]->Sumw2();
1861   fIntFlowCorrelationsAllVsMPro[25]->GetXaxis()->SetTitle("M");  
1862   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[25]);
1863   fIntFlowCorrelationsAllVsMPro[26] = new TProfile("six3n1n1n1n1n1n","#LT#LT6#GT#GT_{3n,n|n,n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1864   fIntFlowCorrelationsAllVsMPro[26]->Sumw2();
1865   fIntFlowCorrelationsAllVsMPro[26]->GetXaxis()->SetTitle("M");  
1866   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[26]);
1867   // 7-p correlations vs M:
1868   fIntFlowCorrelationsAllVsMPro[28] = new TProfile("seven2n1n1n1n1n1n1n","#LT#LT7#GT#GT_{2n,n,n|n,n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1869   fIntFlowCorrelationsAllVsMPro[28]->Sumw2();
1870   fIntFlowCorrelationsAllVsMPro[28]->GetXaxis()->SetTitle("M");  
1871   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[28]);
1872   // 8-p correlations vs M:
1873   fIntFlowCorrelationsAllVsMPro[30] = new TProfile("eight1n1n1n1n1n1n1n1n","#LT#LT8#GT#GT_{n,n,n,n|n,n,n,n}",fnBinsMult,fMinMult,fMaxMult);
1874   fIntFlowCorrelationsAllVsMPro[30]->Sumw2();
1875   fIntFlowCorrelationsAllVsMPro[30]->GetXaxis()->SetTitle("M");  
1876   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[30]);
1877   // EXTRA correlations vs M for v3{5} study (to be improved - put them in a right order somewhere):
1878   fIntFlowCorrelationsAllVsMPro[32] = new TProfile("four4n2n3n3n","#LT#LT4#GT#GT_{4n,2n|3n,3n}",fnBinsMult,fMinMult,fMaxMult);
1879   fIntFlowCorrelationsAllVsMPro[32]->Sumw2();
1880   fIntFlowCorrelationsAllVsMPro[32]->GetXaxis()->SetTitle("M");  
1881   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[32]);
1882   fIntFlowCorrelationsAllVsMPro[33] = new TProfile("five3n3n2n2n2n","#LT#LT5#GT#GT_{3n,3n|2n,2n,2n}",fnBinsMult,fMinMult,fMaxMult);
1883   fIntFlowCorrelationsAllVsMPro[33]->Sumw2();
1884   fIntFlowCorrelationsAllVsMPro[33]->GetXaxis()->SetTitle("M");  
1885   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[33]);
1886   // EXTRA correlations vs M for Teaney-Yan study (to be improved - put them in a right order somewhere):
1887   fIntFlowCorrelationsAllVsMPro[34] = new TProfile("two5n5n","#LT#LT2#GT#GT_{5n|5n}",fnBinsMult,fMinMult,fMaxMult);
1888   fIntFlowCorrelationsAllVsMPro[34]->Sumw2();
1889   fIntFlowCorrelationsAllVsMPro[34]->GetXaxis()->SetTitle("M");  
1890   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[34]);  
1891   fIntFlowCorrelationsAllVsMPro[35] = new TProfile("two6n6n","#LT#LT2#GT#GT_{6n|6n}",fnBinsMult,fMinMult,fMaxMult);
1892   fIntFlowCorrelationsAllVsMPro[35]->Sumw2();
1893   fIntFlowCorrelationsAllVsMPro[35]->GetXaxis()->SetTitle("M");  
1894   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[35]);  
1895   fIntFlowCorrelationsAllVsMPro[36] = new TProfile("three5n3n2n","#LT#LT3#GT#GT_{5n|3n,2n}",fnBinsMult,fMinMult,fMaxMult);
1896   fIntFlowCorrelationsAllVsMPro[36]->Sumw2();
1897   fIntFlowCorrelationsAllVsMPro[36]->GetXaxis()->SetTitle("M");  
1898   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[36]); 
1899   fIntFlowCorrelationsAllVsMPro[37] = new TProfile("three5n4n1n","#LT#LT3#GT#GT_{5n|4n,1n}",fnBinsMult,fMinMult,fMaxMult);
1900   fIntFlowCorrelationsAllVsMPro[37]->Sumw2();
1901   fIntFlowCorrelationsAllVsMPro[37]->GetXaxis()->SetTitle("M");  
1902   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[37]);
1903   fIntFlowCorrelationsAllVsMPro[38] = new TProfile("three6n3n3n","#LT#LT3#GT#GT_{6n|3n,3n}",fnBinsMult,fMinMult,fMaxMult);
1904   fIntFlowCorrelationsAllVsMPro[38]->Sumw2();
1905   fIntFlowCorrelationsAllVsMPro[38]->GetXaxis()->SetTitle("M");  
1906   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[38]);  
1907   fIntFlowCorrelationsAllVsMPro[39] = new TProfile("three6n4n2n","#LT#LT3#GT#GT_{6n|4n,2n}",fnBinsMult,fMinMult,fMaxMult);
1908   fIntFlowCorrelationsAllVsMPro[39]->Sumw2();
1909   fIntFlowCorrelationsAllVsMPro[39]->GetXaxis()->SetTitle("M");  
1910   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[39]);
1911   fIntFlowCorrelationsAllVsMPro[40] = new TProfile("three6n5n1n","#LT#LT3#GT#GT_{6n|5n,1n}",fnBinsMult,fMinMult,fMaxMult);
1912   fIntFlowCorrelationsAllVsMPro[40]->Sumw2();
1913   fIntFlowCorrelationsAllVsMPro[40]->GetXaxis()->SetTitle("M");  
1914   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[40]);
1915   fIntFlowCorrelationsAllVsMPro[41] = new TProfile("four6n3n2n1n","#LT#LT4#GT#GT_{6n|3n,2n,1n}",fnBinsMult,fMinMult,fMaxMult);
1916   fIntFlowCorrelationsAllVsMPro[41]->Sumw2();
1917   fIntFlowCorrelationsAllVsMPro[41]->GetXaxis()->SetTitle("M");  
1918   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[41]);
1919   fIntFlowCorrelationsAllVsMPro[42] = new TProfile("four3n2n3n2n","#LT#LT4#GT#GT_{3n,2n|3n,2n}",fnBinsMult,fMinMult,fMaxMult);
1920   fIntFlowCorrelationsAllVsMPro[42]->Sumw2();
1921   fIntFlowCorrelationsAllVsMPro[42]->GetXaxis()->SetTitle("M");  
1922   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[42]);
1923   fIntFlowCorrelationsAllVsMPro[43] = new TProfile("four4n1n3n2n","#LT#LT4#GT#GT_{4n,1n|3n,2n}",fnBinsMult,fMinMult,fMaxMult);
1924   fIntFlowCorrelationsAllVsMPro[43]->Sumw2();
1925   fIntFlowCorrelationsAllVsMPro[43]->GetXaxis()->SetTitle("M");  
1926   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[43]);
1927   fIntFlowCorrelationsAllVsMPro[44] = new TProfile("four3n3n3n3n","#LT#LT4#GT#GT_{3n,3n|3n,3n}",fnBinsMult,fMinMult,fMaxMult);
1928   fIntFlowCorrelationsAllVsMPro[44]->Sumw2();
1929   fIntFlowCorrelationsAllVsMPro[44]->GetXaxis()->SetTitle("M");  
1930   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[44]);
1931   fIntFlowCorrelationsAllVsMPro[45] = new TProfile("four4n2n3n3n","#LT#LT4#GT#GT_{4n,2n|3n,3n}",fnBinsMult,fMinMult,fMaxMult);
1932   fIntFlowCorrelationsAllVsMPro[45]->Sumw2();
1933   fIntFlowCorrelationsAllVsMPro[45]->GetXaxis()->SetTitle("M");  
1934   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[45]);
1935   fIntFlowCorrelationsAllVsMPro[46] = new TProfile("four5n1n3n3n","#LT#LT4#GT#GT_{5n,1n|3n,3n}",fnBinsMult,fMinMult,fMaxMult);
1936   fIntFlowCorrelationsAllVsMPro[46]->Sumw2();
1937   fIntFlowCorrelationsAllVsMPro[46]->GetXaxis()->SetTitle("M");  
1938   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[46]);
1939   fIntFlowCorrelationsAllVsMPro[47] = new TProfile("four4n2n4n2n","#LT#LT4#GT#GT_{4n,2n|4n,2n}",fnBinsMult,fMinMult,fMaxMult);
1940   fIntFlowCorrelationsAllVsMPro[47]->Sumw2();
1941   fIntFlowCorrelationsAllVsMPro[47]->GetXaxis()->SetTitle("M");  
1942   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[47]);
1943   fIntFlowCorrelationsAllVsMPro[48] = new TProfile("four5n1n4n2n","#LT#LT4#GT#GT_{5n,1n|4n,2n}",fnBinsMult,fMinMult,fMaxMult);
1944   fIntFlowCorrelationsAllVsMPro[48]->Sumw2();
1945   fIntFlowCorrelationsAllVsMPro[48]->GetXaxis()->SetTitle("M");  
1946   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[48]);
1947   fIntFlowCorrelationsAllVsMPro[49] = new TProfile("four5n3n1n1n","#LT#LT4#GT#GT_{5n|3n,1n,1n}",fnBinsMult,fMinMult,fMaxMult);
1948   fIntFlowCorrelationsAllVsMPro[49]->Sumw2();
1949   fIntFlowCorrelationsAllVsMPro[49]->GetXaxis()->SetTitle("M");  
1950   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[49]);
1951   fIntFlowCorrelationsAllVsMPro[50] = new TProfile("four5n2n2n1n","#LT#LT4#GT#GT_{5n|2n,2n,1n}",fnBinsMult,fMinMult,fMaxMult);
1952   fIntFlowCorrelationsAllVsMPro[50]->Sumw2();
1953   fIntFlowCorrelationsAllVsMPro[50]->GetXaxis()->SetTitle("M");  
1954   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[50]);
1955   fIntFlowCorrelationsAllVsMPro[51] = new TProfile("four5n1n5n1n","#LT#LT4#GT#GT_{5n,1n|5n,1n}",fnBinsMult,fMinMult,fMaxMult);
1956   fIntFlowCorrelationsAllVsMPro[51]->Sumw2();
1957   fIntFlowCorrelationsAllVsMPro[51]->GetXaxis()->SetTitle("M");  
1958   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[51]);
1959   fIntFlowCorrelationsAllVsMPro[52] = new TProfile("five3n3n3n2n1n","#LT#LT5#GT#GT_{3n,3n|3n,2n,1n}",fnBinsMult,fMinMult,fMaxMult);
1960   fIntFlowCorrelationsAllVsMPro[52]->Sumw2();
1961   fIntFlowCorrelationsAllVsMPro[52]->GetXaxis()->SetTitle("M");  
1962   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[52]);
1963   fIntFlowCorrelationsAllVsMPro[53] = new TProfile("five4n2n3n2n1n","#LT#LT5#GT#GT_{4n,2n|3n,2n,1n}",fnBinsMult,fMinMult,fMaxMult);
1964   fIntFlowCorrelationsAllVsMPro[53]->Sumw2();
1965   fIntFlowCorrelationsAllVsMPro[53]->GetXaxis()->SetTitle("M");  
1966   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[53]);
1967   fIntFlowCorrelationsAllVsMPro[54] = new TProfile("five3n2n3n1n1n","#LT#LT5#GT#GT_{3n,2n|3n,1n,1n}",fnBinsMult,fMinMult,fMaxMult);
1968   fIntFlowCorrelationsAllVsMPro[54]->Sumw2();
1969   fIntFlowCorrelationsAllVsMPro[54]->GetXaxis()->SetTitle("M");  
1970   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[54]);
1971   fIntFlowCorrelationsAllVsMPro[55] = new TProfile("five3n2n2n2n1n","#LT#LT5#GT#GT_{3n,2n|2n,2n,1n}",fnBinsMult,fMinMult,fMaxMult);
1972   fIntFlowCorrelationsAllVsMPro[55]->Sumw2();
1973   fIntFlowCorrelationsAllVsMPro[55]->GetXaxis()->SetTitle("M");  
1974   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[55]);
1975   fIntFlowCorrelationsAllVsMPro[56] = new TProfile("five5n1n3n2n1n","#LT#LT5#GT#GT_{5n,1n|3n,2n,1n}",fnBinsMult,fMinMult,fMaxMult);
1976   fIntFlowCorrelationsAllVsMPro[56]->Sumw2();
1977   fIntFlowCorrelationsAllVsMPro[56]->GetXaxis()->SetTitle("M");  
1978   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[56]);
1979   fIntFlowCorrelationsAllVsMPro[57] = new TProfile("six3n2n1n3n2n1n","#LT#LT6#GT#GT_{3n,2n,1n|3n,2n,1n}",fnBinsMult,fMinMult,fMaxMult);
1980   fIntFlowCorrelationsAllVsMPro[57]->Sumw2();
1981   fIntFlowCorrelationsAllVsMPro[57]->GetXaxis()->SetTitle("M");  
1982   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[57]);  
1983   fIntFlowCorrelationsAllVsMPro[58] = new TProfile("four6n4n1n1n","#LT#LT4#GT#GT_{6n|4n,1n,1n}",fnBinsMult,fMinMult,fMaxMult);
1984   fIntFlowCorrelationsAllVsMPro[58]->Sumw2();
1985   fIntFlowCorrelationsAllVsMPro[58]->GetXaxis()->SetTitle("M");  
1986   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[58]);
1987   fIntFlowCorrelationsAllVsMPro[59] = new TProfile("four6n2n2n2n","#LT#LT4#GT#GT_{6n|2n,2n,2n}",fnBinsMult,fMinMult,fMaxMult);
1988   fIntFlowCorrelationsAllVsMPro[59]->Sumw2();
1989   fIntFlowCorrelationsAllVsMPro[59]->GetXaxis()->SetTitle("M");  
1990   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[59]);
1991   fIntFlowCorrelationsAllVsMPro[60] = new TProfile("five6n2n2n1n1n","#LT#LT5#GT#GT_{6n|2n,2n,1n,1n}",fnBinsMult,fMinMult,fMaxMult);
1992   fIntFlowCorrelationsAllVsMPro[60]->Sumw2();
1993   fIntFlowCorrelationsAllVsMPro[60]->GetXaxis()->SetTitle("M");  
1994   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[60]);
1995   fIntFlowCorrelationsAllVsMPro[61] = new TProfile("five4n1n1n3n3n","#LT#LT5#GT#GT_{4n,1n,1n|3n,3n}",fnBinsMult,fMinMult,fMaxMult);
1996   fIntFlowCorrelationsAllVsMPro[61]->Sumw2();
1997   fIntFlowCorrelationsAllVsMPro[61]->GetXaxis()->SetTitle("M");  
1998   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[61]);
1999   fIntFlowCorrelationsAllVsMPro[62] = new TProfile("six3n3n2n2n1n1n","#LT#LT6#GT#GT_{3n,3n|2n,2n,1n,1n}",fnBinsMult,fMinMult,fMaxMult);
2000   fIntFlowCorrelationsAllVsMPro[62]->Sumw2();
2001   fIntFlowCorrelationsAllVsMPro[62]->GetXaxis()->SetTitle("M");  
2002   fIntFlowAllCorrelationsVsM->Add(fIntFlowCorrelationsAllVsMPro[62]);
2003  } // end of if(fCalculateAllCorrelationsVsM)
2004  // when particle weights are used some extra correlations appear:
2005  if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights) 
2006  {
2007   TString intFlowExtraCorrelationsProName = "fIntFlowExtraCorrelationsPro";
2008   intFlowExtraCorrelationsProName += fAnalysisLabel->Data();
2009   fIntFlowExtraCorrelationsPro = new TProfile(intFlowExtraCorrelationsProName.Data(),"Average extra correlations for all events",100,0,100,"s");
2010   fIntFlowExtraCorrelationsPro->SetTickLength(-0.01,"Y");
2011   fIntFlowExtraCorrelationsPro->SetMarkerStyle(25);
2012   fIntFlowExtraCorrelationsPro->SetLabelSize(0.03);
2013   fIntFlowExtraCorrelationsPro->SetLabelOffset(0.01,"Y");
2014   // extra 2-p correlations:
2015   (fIntFlowExtraCorrelationsPro->GetXaxis())->SetBinLabel(1,"<<w1^3 w2 cos(n*(phi1-phi2))>>");
2016   (fIntFlowExtraCorrelationsPro->GetXaxis())->SetBinLabel(2,"<<w1 w2 w3^2 cos(n*(phi1-phi2))>>");
2017   fIntFlowProfiles->Add(fIntFlowExtraCorrelationsPro);
2018  } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)
2019  // average product of correlations <2>, <4>, <6> and <8>:  
2020  TString productFlag[6] = {"#LT#LT2#GT#LT4#GT#GT","#LT#LT2#GT#LT6#GT#GT","#LT#LT2#GT#LT8#GT#GT",
2021                            "#LT#LT4#GT#LT6#GT#GT","#LT#LT4#GT#LT8#GT#GT","#LT#LT6#GT#LT8#GT#GT"};
2022  TString intFlowProductOfCorrelationsProName = "fIntFlowProductOfCorrelationsPro";
2023  intFlowProductOfCorrelationsProName += fAnalysisLabel->Data();
2024  fIntFlowProductOfCorrelationsPro = new TProfile(intFlowProductOfCorrelationsProName.Data(),"Average products of correlations",6,0,6);
2025  fIntFlowProductOfCorrelationsPro->SetTickLength(-0.01,"Y");
2026  fIntFlowProductOfCorrelationsPro->SetMarkerStyle(25); 
2027  fIntFlowProductOfCorrelationsPro->SetLabelSize(0.05);
2028  fIntFlowProductOfCorrelationsPro->SetLabelOffset(0.01,"Y");
2029  for(Int_t b=0;b<6;b++)
2030  {
2031   (fIntFlowProductOfCorrelationsPro->GetXaxis())->SetBinLabel(b+1,productFlag[b].Data());
2032  }
2033  fIntFlowProfiles->Add(fIntFlowProductOfCorrelationsPro); 
2034  // average product of correlations <2>, <4>, <6> and <8> versus multiplicity
2035  // [0=<<2><4>>,1=<<2><6>>,2=<<2><8>>,3=<<4><6>>,4=<<4><8>>,5=<<6><8>>]  
2036  if(fCalculateCumulantsVsM)
2037  {
2038   TString intFlowProductOfCorrelationsVsMProName = "fIntFlowProductOfCorrelationsVsMPro";
2039   intFlowProductOfCorrelationsVsMProName += fAnalysisLabel->Data();
2040   for(Int_t pi=0;pi<6;pi++)
2041   { 
2042    fIntFlowProductOfCorrelationsVsMPro[pi] = new TProfile(Form("%s, %s",intFlowProductOfCorrelationsVsMProName.Data(),productFlag[pi].Data()),
2043                                                           Form("%s versus multiplicity",productFlag[pi].Data()),
2044                                                           fnBinsMult,fMinMult,fMaxMult);             
2045    fIntFlowProductOfCorrelationsVsMPro[pi]->GetXaxis()->SetTitle("M");
2046    fIntFlowProfiles->Add(fIntFlowProductOfCorrelationsVsMPro[pi]);
2047   } // end of for(Int_t pi=0;pi<6;pi++)
2048  } // end of if(fCalculateCumulantsVsM) 
2049  // average product of correction terms for NUA:  
2050  TString intFlowProductOfCorrectionTermsForNUAProName = "fIntFlowProductOfCorrectionTermsForNUAPro";
2051  intFlowProductOfCorrectionTermsForNUAProName += fAnalysisLabel->Data();
2052  fIntFlowProductOfCorrectionTermsForNUAPro = new TProfile(intFlowProductOfCorrectionTermsForNUAProName.Data(),"Average products of correction terms for NUA",27,0,27);
2053  fIntFlowProductOfCorrectionTermsForNUAPro->SetTickLength(-0.01,"Y");
2054  fIntFlowProductOfCorrectionTermsForNUAPro->SetMarkerStyle(25); 
2055  fIntFlowProductOfCorrectionTermsForNUAPro->SetLabelSize(0.03);
2056  fIntFlowProductOfCorrectionTermsForNUAPro->SetLabelOffset(0.01,"Y");
2057  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(1,"<<2><cos(#phi)>>");
2058  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(2,"<<2><sin(#phi)>>");
2059  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(3,"<<cos(#phi)><sin(#phi)>>");
2060  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(4,"Cov(<2>,<cos(#phi_{1}+#phi_{2})>)");
2061  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(5,"Cov(<2>,<sin(#phi_{1}+#phi_{2})>)");
2062  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(6,"Cov(<2>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)");
2063  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(7,"Cov(<2>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)");
2064  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(8,"Cov(<4>,<cos(#phi)>)");
2065  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(9,"Cov(<4>,<sin(#phi)>)");
2066  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(10,"Cov(<4>,<cos(#phi_{1}+#phi_{2})>)");
2067  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(11,"Cov(<4>,<sin(#phi_{1}+#phi_{2})>)");
2068  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(12,"Cov(<4>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>>)");
2069  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(13,"Cov(<4>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>>)");
2070  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(14,"Cov(<cos(#phi)>,<cos(#phi_{1}+#phi_{2})>)"); 
2071  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(15,"Cov(<cos(#phi)>,<sin(#phi_{1}+#phi_{2})>)");
2072  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(16,"Cov(<cos(#phi)>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)");
2073  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(17,"Cov(<cos(#phi)>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)");
2074  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(18,"Cov(<sin(#phi)>,<cos(#phi_{1}+#phi_{2})>)");
2075  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(19,"Cov(<sin(#phi)>,<sin(#phi_{1}+#phi_{2})>)");
2076  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(20,"Cov(<sin(#phi)>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)");
2077  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(21,"Cov(<sin(#phi)>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)");
2078  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(22,"Cov(<cos(#phi_{1}+#phi_{2})>,<sin(#phi_{1}+#phi_{2})>)");
2079  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(23,"Cov(<cos(#phi_{1}+#phi_{2})>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)");
2080  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(24,"Cov(<cos(#phi_{1}+#phi_{2})>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)");
2081  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(25,"Cov(<sin(#phi_{1}+#phi_{2})>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)");
2082  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(26,"Cov(<sin(#phi_{1}+#phi_{2})>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)");
2083  (fIntFlowProductOfCorrectionTermsForNUAPro->GetXaxis())->SetBinLabel(27,"Cov(<cos(#phi_{1}-#phi_{2}-#phi_{3}>,<sin(#phi_{1}-#phi_{2}-#phi_{3}>)");
2084  fIntFlowProfiles->Add(fIntFlowProductOfCorrectionTermsForNUAPro);
2085  // average correction terms for non-uniform acceptance (with wrong errors!):
2086  for(Int_t sc=0;sc<2;sc++) // sin or cos terms
2087  {
2088   TString intFlowCorrectionTermsForNUAProName = "fIntFlowCorrectionTermsForNUAPro";
2089   intFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();
2090   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()),4,0,4,"s");
2091   fIntFlowCorrectionTermsForNUAPro[sc]->SetTickLength(-0.01,"Y");
2092   fIntFlowCorrectionTermsForNUAPro[sc]->SetMarkerStyle(25);
2093   fIntFlowCorrectionTermsForNUAPro[sc]->SetLabelSize(0.05);
2094   fIntFlowCorrectionTermsForNUAPro[sc]->SetLabelOffset(0.01,"Y");
2095   (fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->SetBinLabel(1,Form("#LT#LT%s(n(#phi_{1}))#GT#GT",sinCosFlag[sc].Data()));
2096   (fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->SetBinLabel(2,Form("#LT#LT%s(n(#phi_{1}+#phi_{2}))#GT#GT",sinCosFlag[sc].Data()));  
2097   (fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->SetBinLabel(3,Form("#LT#LT%s(n(#phi_{1}-#phi_{2}-#phi_{3}))#GT#GT",sinCosFlag[sc].Data()));  
2098   (fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->SetBinLabel(4,Form("#LT#LT%s(n(2#phi_{1}-#phi_{2}))#GT#GT",sinCosFlag[sc].Data()));  
2099   fIntFlowProfiles->Add(fIntFlowCorrectionTermsForNUAPro[sc]);
2100   // versus multiplicity:
2101   if(fCalculateCumulantsVsM)
2102   {
2103    TString correctionTermFlag[4] = {"(n(phi1))","(n(phi1+phi2))","(n(phi1-phi2-phi3))","(n(2phi1-phi2))"}; // to be improved - hardwired 4
2104    for(Int_t ci=0;ci<4;ci++) // correction term index (to be improved - hardwired 4)
2105    {
2106     TString intFlowCorrectionTermsForNUAVsMProName = "fIntFlowCorrectionTermsForNUAVsMPro";
2107     intFlowCorrectionTermsForNUAVsMProName += fAnalysisLabel->Data();
2108     fIntFlowCorrectionTermsForNUAVsMPro[sc][ci] = new TProfile(Form("%s: #LT#LT%s%s#GT#GT",intFlowCorrectionTermsForNUAVsMProName.Data(),sinCosFlag[sc].Data(),correctionTermFlag[ci].Data()),Form("#LT#LT%s%s#GT#GT vs M",sinCosFlag[sc].Data(),correctionTermFlag[ci].Data()),fnBinsMult,fMinMult,fMaxMult,"s");
2109     fIntFlowProfiles->Add(fIntFlowCorrectionTermsForNUAVsMPro[sc][ci]);
2110    }
2111   } // end of if(fCalculateCumulantsVsM)
2112  } // end of for(Int_t sc=0;sc<2;sc++) 
2113  
2114  // d) Book histograms holding the final results:
2115  // average correlations <<2>>, <<4>>, <<6>> and <<8>> for all events (with correct errors!):
2116  TString intFlowCorrelationsHistName = "fIntFlowCorrelationsHist";
2117  intFlowCorrelationsHistName += fAnalysisLabel->Data();
2118  fIntFlowCorrelationsHist = new TH1D(intFlowCorrelationsHistName.Data(),"Average correlations for all events",4,0,4);
2119  fIntFlowCorrelationsHist->SetTickLength(-0.01,"Y");
2120  fIntFlowCorrelationsHist->SetMarkerStyle(25);
2121  fIntFlowCorrelationsHist->SetLabelSize(0.06);
2122  fIntFlowCorrelationsHist->SetLabelOffset(0.01,"Y");
2123  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(1,"#LT#LT2#GT#GT");
2124  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(2,"#LT#LT4#GT#GT");
2125  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(3,"#LT#LT6#GT#GT");
2126  (fIntFlowCorrelationsHist->GetXaxis())->SetBinLabel(4,"#LT#LT8#GT#GT");
2127  fIntFlowResults->Add(fIntFlowCorrelationsHist);
2128  // average correlations <<2>>, <<4>>, <<6>> and <<8>> for all events (with correct errors!) vs M:
2129  if(fCalculateCumulantsVsM)
2130  {
2131   for(Int_t ci=0;ci<4;ci++) // correlation index
2132   {
2133    TString intFlowCorrelationsVsMHistName = "fIntFlowCorrelationsVsMHist";
2134    intFlowCorrelationsVsMHistName += fAnalysisLabel->Data();
2135    fIntFlowCorrelationsVsMHist[ci] = new TH1D(Form("%s, %s",intFlowCorrelationsVsMHistName.Data(),correlationFlag[ci].Data()),
2136                                               Form("%s vs multiplicity",correlationFlag[ci].Data()),
2137                                               fnBinsMult,fMinMult,fMaxMult);                                            
2138    fIntFlowCorrelationsVsMHist[ci]->GetYaxis()->SetTitle(correlationFlag[ci].Data());
2139    fIntFlowCorrelationsVsMHist[ci]->GetXaxis()->SetTitle("M");
2140    fIntFlowResults->Add(fIntFlowCorrelationsVsMHist[ci]);
2141   } // end of for(Int_t ci=0;ci<4;ci++) // correlation index   
2142  } // end of if(fCalculateCumulantsVsM) 
2143  // average all correlations for all events (with correct errors!):
2144  TString intFlowCorrelationsAllHistName = "fIntFlowCorrelationsAllHist";
2145  intFlowCorrelationsAllHistName += fAnalysisLabel->Data();
2146  fIntFlowCorrelationsAllHist = new TH1D(intFlowCorrelationsAllHistName.Data(),"Average correlations for all events",34,0,34);
2147  fIntFlowCorrelationsAllHist->SetTickLength(-0.01,"Y");
2148  fIntFlowCorrelationsAllHist->SetMarkerStyle(25);
2149  fIntFlowCorrelationsAllHist->SetLabelSize(0.03);
2150  fIntFlowCorrelationsAllHist->SetLabelOffset(0.01,"Y");
2151  // 2-p correlations:
2152  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(1,"<<2>>_{n|n}");
2153  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(2,"<<2>>_{2n|2n}");
2154  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(3,"<<2>>_{3n|3n}");
2155  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(4,"<<2>>_{4n|4n}");
2156  // 3-p correlations:
2157  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(6,"<<3>>_{2n|n,n}");
2158  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(7,"<<3>>_{3n|2n,n}");
2159  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(8,"<<3>>_{4n|2n,2n}");
2160  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(9,"<<3>>_{4n|3n,n}");
2161  // 4-p correlations:
2162  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(11,"<<4>>_{n,n|n,n}"); 
2163  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(12,"<<4>>_{2n,n|2n,n}");
2164  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(13,"<<4>>_{2n,2n|2n,2n}");
2165  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(14,"<<4>>_{3n|n,n,n}");
2166  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(15,"<<4>>_{3n,n|3n,n}");
2167  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(16,"<<4>>_{3n,n|2n,2n}"); 
2168  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(17,"<<4>>_{4n|2n,n,n}");
2169  // 5-p correlations:
2170  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(19,"<<5>>_{2n|n,n,n,n}"); 
2171  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(20,"<<5>>_{2n,2n|2n,n,n}");
2172  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(21,"<<5>>_{3n,n|2n,n,n}");
2173  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(22,"<<5>>_{4n|n,n,n,n}");
2174  // 6-p correlations:
2175  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(24,"<<6>>_{n,n,n|n,n,n}");
2176  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(25,"<<6>>_{2n,n,n|2n,n,n}");
2177  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(26,"<<6>>_{2n,2n|n,n,n,n}");
2178  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(27,"<<6>>_{3n,n|n,n,n,n}");
2179  // 7-p correlations:  
2180  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(29,"<<7>>_{2n,n,n|n,n,n,n}");
2181  // 8-p correlations:
2182  (fIntFlowCorrelationsAllHist->GetXaxis())->SetBinLabel(31,"<<8>>_{n,n,n,n|n,n,n,n}");
2183  fIntFlowResults->Add(fIntFlowCorrelationsAllHist);
2184  // average correction terms for non-uniform acceptance (with correct errors!):
2185  for(Int_t sc=0;sc<2;sc++) // sin or cos terms
2186  {
2187   TString intFlowCorrectionTermsForNUAHistName = "fIntFlowCorrectionTermsForNUAHist";
2188   intFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();
2189   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()),4,0,4);
2190   fIntFlowCorrectionTermsForNUAHist[sc]->SetTickLength(-0.01,"Y");
2191   fIntFlowCorrectionTermsForNUAHist[sc]->SetMarkerStyle(25);
2192   fIntFlowCorrectionTermsForNUAHist[sc]->SetLabelSize(0.05);
2193   fIntFlowCorrectionTermsForNUAHist[sc]->SetLabelOffset(0.01,"Y");
2194   (fIntFlowCorrectionTermsForNUAHist[sc]->GetXaxis())->SetBinLabel(1,Form("#LT#LT%s(n(#phi_{1}))#GT#GT",sinCosFlag[sc].Data()));
2195   (fIntFlowCorrectionTermsForNUAHist[sc]->GetXaxis())->SetBinLabel(2,Form("#LT#LT%s(n(#phi_{1}+#phi_{2}))#GT#GT",sinCosFlag[sc].Data()));  
2196   (fIntFlowCorrectionTermsForNUAHist[sc]->GetXaxis())->SetBinLabel(3,Form("#LT#LT%s(n(#phi_{1}-#phi_{2}-#phi_{3}))#GT#GT",sinCosFlag[sc].Data()));  
2197   (fIntFlowCorrectionTermsForNUAHist[sc]->GetXaxis())->SetBinLabel(4,Form("#LT#LT%s(n(2#phi_{1}-#phi_{2}))#GT#GT",sinCosFlag[sc].Data()));   
2198   fIntFlowResults->Add(fIntFlowCorrectionTermsForNUAHist[sc]);
2199  } // end of for(Int_t sc=0;sc<2;sc++) 
2200  // covariances (multiplied with weight dependent prefactor):
2201  TString intFlowCovariancesName = "fIntFlowCovariances";
2202  intFlowCovariancesName += fAnalysisLabel->Data();
2203  fIntFlowCovariances = new TH1D(intFlowCovariancesName.Data(),"Covariances (multiplied with weight dependent prefactor)",6,0,6);
2204  fIntFlowCovariances->SetLabelSize(0.04);
2205  fIntFlowCovariances->SetMarkerStyle(25);
2206  (fIntFlowCovariances->GetXaxis())->SetBinLabel(1,"Cov(#LT2#GT,#LT4#GT)");
2207  (fIntFlowCovariances->GetXaxis())->SetBinLabel(2,"Cov(#LT2#GT,#LT6#GT)");
2208  (fIntFlowCovariances->GetXaxis())->SetBinLabel(3,"Cov(#LT2#GT,#LT8#GT)");
2209  (fIntFlowCovariances->GetXaxis())->SetBinLabel(4,"Cov(#LT4#GT,#LT6#GT)");
2210  (fIntFlowCovariances->GetXaxis())->SetBinLabel(5,"Cov(#LT4#GT,#LT8#GT)");
2211  (fIntFlowCovariances->GetXaxis())->SetBinLabel(6,"Cov(#LT6#GT,#LT8#GT)");  
2212  fIntFlowResults->Add(fIntFlowCovariances);
2213  // sum of linear and quadratic event weights for <2>, <4>, <6> and <8>:
2214  TString intFlowSumOfEventWeightsName = "fIntFlowSumOfEventWeights";
2215  intFlowSumOfEventWeightsName += fAnalysisLabel->Data();
2216  for(Int_t power=0;power<2;power++)
2217  {
2218   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);
2219   fIntFlowSumOfEventWeights[power]->SetLabelSize(0.04);
2220   fIntFlowSumOfEventWeights[power]->SetMarkerStyle(25);
2221   if(power == 0)
2222   {
2223    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(1,"#sum_{i=1}^{N} w_{#LT2#GT}");
2224    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(2,"#sum_{i=1}^{N} w_{#LT4#GT}");
2225    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(3,"#sum_{i=1}^{N} w_{#LT6#GT}");
2226    (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(4,"#sum_{i=1}^{N} w_{#LT8#GT}");
2227   } else if (power == 1) 
2228     {
2229      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(1,"#sum_{i=1}^{N} w_{#LT2#GT}^{2}");
2230      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(2,"#sum_{i=1}^{N} w_{#LT4#GT}^{2}");
2231      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(3,"#sum_{i=1}^{N} w_{#LT6#GT}^{2}");
2232      (fIntFlowSumOfEventWeights[power]->GetXaxis())->SetBinLabel(4,"#sum_{i=1}^{N} w_{#LT8#GT}^{2}");
2233     }
2234   fIntFlowResults->Add(fIntFlowSumOfEventWeights[power]);
2235  } 
2236  // sum of products of event weights for correlations <2>, <4>, <6> and <8>:  
2237  TString intFlowSumOfProductOfEventWeightsName = "fIntFlowSumOfProductOfEventWeights";
2238  intFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();
2239  fIntFlowSumOfProductOfEventWeights = new TH1D(intFlowSumOfProductOfEventWeightsName.Data(),"Sum of product of event weights for correlations",6,0,6);
2240  fIntFlowSumOfProductOfEventWeights->SetLabelSize(0.04);
2241  fIntFlowSumOfProductOfEventWeights->SetMarkerStyle(25);
2242  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(1,"#sum_{i=1}^{N} w_{#LT2#GT} w_{#LT4#GT}");
2243  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(2,"#sum_{i=1}^{N} w_{#LT2#GT} w_{#LT6#GT}");
2244  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(3,"#sum_{i=1}^{N} w_{#LT2#GT} w_{#LT8#GT}");
2245  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(4,"#sum_{i=1}^{N} w_{#LT4#GT} w_{#LT6#GT}");
2246  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(5,"#sum_{i=1}^{N} w_{#LT4#GT} w_{#LT8#GT}");
2247  (fIntFlowSumOfProductOfEventWeights->GetXaxis())->SetBinLabel(6,"#sum_{i=1}^{N} w_{#LT6#GT} w_{#LT8#GT}");
2248  fIntFlowResults->Add(fIntFlowSumOfProductOfEventWeights);
2249  // final result for covariances of correlations (multiplied with weight dependent prefactor) versus M
2250  // [0=Cov(2,4),1=Cov(2,6),2=Cov(2,8),3=Cov(4,6),4=Cov(4,8),5=Cov(6,8)]:
2251  if(fCalculateCumulantsVsM)
2252  {
2253   TString intFlowCovariancesVsMName = "fIntFlowCovariancesVsM";
2254   intFlowCovariancesVsMName += fAnalysisLabel->Data();
2255   TString covarianceFlag[6] = {"Cov(<2>,<4>)","Cov(<2>,<6>)","Cov(<2>,<8>)","Cov(<4>,<6>)","Cov(<4>,<8>)","Cov(<6>,<8>)"};
2256   for(Int_t ci=0;ci<6;ci++)
2257   {
2258    fIntFlowCovariancesVsM[ci] = new TH1D(Form("%s, %s",intFlowCovariancesVsMName.Data(),covarianceFlag[ci].Data()),
2259                                          Form("%s vs multiplicity",covarianceFlag[ci].Data()),
2260                                          fnBinsMult,fMinMult,fMaxMult);
2261    fIntFlowCovariancesVsM[ci]->GetYaxis()->SetTitle(covarianceFlag[ci].Data());
2262    fIntFlowCovariancesVsM[ci]->GetXaxis()->SetTitle("M");
2263    fIntFlowResults->Add(fIntFlowCovariancesVsM[ci]);
2264   }
2265  } // end of if(fCalculateCumulantsVsM) 
2266  // sum of linear and quadratic event weights for <2>, <4>, <6> and <8> versus multiplicity
2267  // [0=sum{w_{<2>}},1=sum{w_{<4>}},2=sum{w_{<6>}},3=sum{w_{<8>}}][0=linear 1,1=quadratic]:
2268  if(fCalculateCumulantsVsM)
2269  {
2270   TString intFlowSumOfEventWeightsVsMName = "fIntFlowSumOfEventWeightsVsM";
2271   intFlowSumOfEventWeightsVsMName += fAnalysisLabel->Data();
2272   TString sumFlag[2][4] = {{"#sum_{i=1}^{N} w_{<2>}","#sum_{i=1}^{N} w_{<4>}","#sum_{i=1}^{N} w_{<6>}","#sum_{i=1}^{N} w_{<8>}"},
2273                            {"#sum_{i=1}^{N} w_{<2>}^{2}","#sum_{i=1}^{N} w_{<4>}^{2}","#sum_{i=1}^{N} w_{<6>}^{2}","#sum_{i=1}^{N} w_{<8>}^{2}"}};
2274   for(Int_t si=0;si<4;si++)
2275   {
2276    for(Int_t power=0;power<2;power++)
2277    {
2278     fIntFlowSumOfEventWeightsVsM[si][power] = new TH1D(Form("%s, %s",intFlowSumOfEventWeightsVsMName.Data(),sumFlag[power][si].Data()),
2279                                                        Form("%s vs multiplicity",sumFlag[power][si].Data()),
2280                                                        fnBinsMult,fMinMult,fMaxMult);    
2281     fIntFlowSumOfEventWeightsVsM[si][power]->GetYaxis()->SetTitle(sumFlag[power][si].Data());  
2282     fIntFlowSumOfEventWeightsVsM[si][power]->GetXaxis()->SetTitle("M");  
2283     fIntFlowResults->Add(fIntFlowSumOfEventWeightsVsM[si][power]);
2284    } // end of for(Int_t power=0;power<2;power++)
2285   } // end of for(Int_t si=0;si<4;si++)   
2286  } // end of if(fCalculateCumulantsVsM)
2287  // sum of products of event weights for correlations <2>, <4>, <6> and <8> vs M
2288  // [0=sum{w_{<2>}w_{<4>}},1=sum{w_{<2>}w_{<6>}},2=sum{w_{<2>}w_{<8>}},
2289  //  3=sum{w_{<4>}w_{<6>}},4=sum{w_{<4>}w_{<8>}},5=sum{w_{<6>}w_{<8>}}]:  
2290  if(fCalculateCumulantsVsM)
2291  {
2292   TString intFlowSumOfProductOfEventWeightsVsMName = "fIntFlowSumOfProductOfEventWeightsVsM";
2293   intFlowSumOfProductOfEventWeightsVsMName += fAnalysisLabel->Data();
2294   TString sopowFlag[6] = {"#sum_{i=1}^{N} w_{<2>} w_{<4>}","#sum_{i=1}^{N} w_{<2>} w_{<6>}","#sum_{i=1}^{N} w_{<2>} w_{<8>}",
2295                           "#sum_{i=1}^{N} w_{<4>} w_{<6>}","#sum_{i=1}^{N} w_{<4>} w_{<8>}","#sum_{i=1}^{N} w_{<6>} w_{<8>}"}; 
2296   for(Int_t pi=0;pi<6;pi++)
2297   {
2298    fIntFlowSumOfProductOfEventWeightsVsM[pi] = new TH1D(Form("%s, %s",intFlowSumOfProductOfEventWeightsVsMName.Data(),sopowFlag[pi].Data()),
2299                                                         Form("%s versus multiplicity",sopowFlag[pi].Data()),
2300                                                         fnBinsMult,fMinMult,fMaxMult); 
2301    fIntFlowSumOfProductOfEventWeightsVsM[pi]->GetXaxis()->SetTitle("M");
2302    fIntFlowSumOfProductOfEventWeightsVsM[pi]->GetYaxis()->SetTitle(sopowFlag[pi].Data()); 
2303    fIntFlowResults->Add(fIntFlowSumOfProductOfEventWeightsVsM[pi]);
2304   } // end of for(Int_t pi=0;pi<6;pi++) 
2305  } // end of if(fCalculateCumulantsVsM)
2306  // covariances of NUA terms (multiplied with weight dependent prefactor):
2307  TString intFlowCovariancesNUAName = "fIntFlowCovariancesNUA";
2308  intFlowCovariancesNUAName += fAnalysisLabel->Data();
2309  fIntFlowCovariancesNUA = new TH1D(intFlowCovariancesNUAName.Data(),"Covariances for NUA (multiplied with weight dependent prefactor)",27,0,27);
2310  fIntFlowCovariancesNUA->SetLabelSize(0.04);
2311  fIntFlowCovariancesNUA->SetMarkerStyle(25);
2312  fIntFlowCovariancesNUA->GetXaxis()->SetLabelSize(0.02);
2313  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(1,"Cov(<2>,<cos(#phi)>");
2314  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(2,"Cov(<2>,<sin(#phi)>)");
2315  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(3,"Cov(<cos(#phi)>,<sin(#phi)>)");
2316  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(4,"Cov(<2>,<cos(#phi_{1}+#phi_{2})>)");
2317  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(5,"Cov(<2>,<sin(#phi_{1}+#phi_{2})>)");
2318  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(6,"Cov(<2>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)");
2319  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(7,"Cov(<2>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)");
2320  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(8,"Cov(<4>,<cos(#phi)>)");
2321  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(9,"Cov(<4>,<sin(#phi)>)");
2322  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(10,"Cov(<4>,<cos(#phi_{1}+#phi_{2})>)");
2323  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(11,"Cov(<4>,<sin(#phi_{1}+#phi_{2})>)");
2324  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(12,"Cov(<4>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>>)");
2325  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(13,"Cov(<4>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>>)");
2326  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(14,"Cov(<cos(#phi)>,<cos(#phi_{1}+#phi_{2})>)"); 
2327  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(15,"Cov(<cos(#phi)>,<sin(#phi_{1}+#phi_{2})>)");
2328  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(16,"Cov(<cos(#phi)>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)");
2329  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(17,"Cov(<cos(#phi)>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)");
2330  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(18,"Cov(<sin(#phi)>,<cos(#phi_{1}+#phi_{2})>)");
2331  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(19,"Cov(<sin(#phi)>,<sin(#phi_{1}+#phi_{2})>)");
2332  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(20,"Cov(<sin(#phi)>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)");
2333  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(21,"Cov(<sin(#phi)>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)");
2334  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(22,"Cov(<cos(#phi_{1}+#phi_{2})>,<sin(#phi_{1}+#phi_{2})>)");
2335  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(23,"Cov(<cos(#phi_{1}+#phi_{2})>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)");
2336  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(24,"Cov(<cos(#phi_{1}+#phi_{2})>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)");
2337  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(25,"Cov(<sin(#phi_{1}+#phi_{2})>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)");
2338  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(26,"Cov(<sin(#phi_{1}+#phi_{2})>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)");
2339  (fIntFlowCovariancesNUA->GetXaxis())->SetBinLabel(27,"Cov(<cos(#phi_{1}-#phi_{2}-#phi_{3}>,<sin(#phi_{1}-#phi_{2}-#phi_{3}>)");
2340  fIntFlowResults->Add(fIntFlowCovariancesNUA);
2341  // sum of linear and quadratic event weights for NUA terms:
2342  TString intFlowSumOfEventWeightsNUAName = "fIntFlowSumOfEventWeightsNUA";
2343  intFlowSumOfEventWeightsNUAName += fAnalysisLabel->Data();
2344  for(Int_t sc=0;sc<2;sc++)
2345  {
2346   for(Int_t power=0;power<2;power++)
2347   {
2348    fIntFlowSumOfEventWeightsNUA[sc][power] = new TH1D(Form("%s: %s, %s",intFlowSumOfEventWeightsNUAName.Data(),powerFlag[power].Data(),sinCosFlag[sc].Data()),Form("Sum of %s event weights for NUA %s terms",powerFlag[power].Data(),sinCosFlag[sc].Data()),4,0,4); // to be improved - 4
2349    fIntFlowSumOfEventWeightsNUA[sc][power]->SetLabelSize(0.05);
2350    fIntFlowSumOfEventWeightsNUA[sc][power]->SetMarkerStyle(25);
2351    if(power == 0)
2352    {
2353     (fIntFlowSumOfEventWeightsNUA[sc][power]->GetXaxis())->SetBinLabel(1,Form("#sum_{i=1}^{N} w_{<%s(#phi)>}",sinCosFlag[sc].Data()));
2354     (fIntFlowSumOfEventWeightsNUA[sc][power]->GetXaxis())->SetBinLabel(2,Form("#sum_{i=1}^{N} w_{<%s(#phi_{1}+#phi_{2})>}",sinCosFlag[sc].Data()));
2355     (fIntFlowSumOfEventWeightsNUA[sc][power]->GetXaxis())->SetBinLabel(3,Form("#sum_{i=1}^{N} w_{<%s(#phi_{1}-#phi_{2}-#phi_{3})>}",sinCosFlag[sc].Data()));   
2356     (fIntFlowSumOfEventWeightsNUA[sc][power]->GetXaxis())->SetBinLabel(4,Form("#sum_{i=1}^{N} w_{<%s(2#phi_{1}-#phi_{2})>}",sinCosFlag[sc].Data()));
2357    } else if(power == 1) 
2358      {
2359       (fIntFlowSumOfEventWeightsNUA[sc][power]->GetXaxis())->SetBinLabel(1,Form("#sum_{i=1}^{N} w_{<%s(#phi)>}^{2}",sinCosFlag[sc].Data()));
2360       (fIntFlowSumOfEventWeightsNUA[sc][power]->GetXaxis())->SetBinLabel(2,Form("#sum_{i=1}^{N} w_{<%s(#phi_{1}+#phi_{2})>}^{2}",sinCosFlag[sc].Data()));
2361       (fIntFlowSumOfEventWeightsNUA[sc][power]->GetXaxis())->SetBinLabel(3,Form("#sum_{i=1}^{N} w_{<%s(#phi_{1}-#phi_{2}-#phi_{3})>}^{2}",sinCosFlag[sc].Data()));
2362       (fIntFlowSumOfEventWeightsNUA[sc][power]->GetXaxis())->SetBinLabel(4,Form("#sum_{i=1}^{N} w_{<%s(2#phi_{1}-#phi_{2})>}^{2}",sinCosFlag[sc].Data()));
2363      }
2364    fIntFlowResults->Add(fIntFlowSumOfEventWeightsNUA[sc][power]);
2365   }
2366  }  
2367  // sum of products of event weights for NUA terms:  
2368  TString intFlowSumOfProductOfEventWeightsNUAName = "fIntFlowSumOfProductOfEventWeightsNUA";
2369  intFlowSumOfProductOfEventWeightsNUAName += fAnalysisLabel->Data();
2370  fIntFlowSumOfProductOfEventWeightsNUA = new TH1D(intFlowSumOfProductOfEventWeightsNUAName.Data(),"Sum of product of event weights for NUA terms",27,0,27);
2371  fIntFlowSumOfProductOfEventWeightsNUA->SetLabelSize(0.02);
2372  fIntFlowSumOfProductOfEventWeightsNUA->SetMarkerStyle(25);
2373  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(1,"#sum_{i=1}^{N} w_{#LT2#GT} w_{#LTcos(#phi)#GT}");
2374  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(2,"#sum_{i=1}^{N} w_{#LT2#GT} w_{#LTsin(#phi)#GT}");
2375  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(3,"#sum_{i=1}^{N} w_{#LTcos(#phi)#GT} w_{#LTsin(#phi)#GT}");
2376  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(4,"#sum_{i=1}^{N} w_{#LT2#GT} w_{#LTcos(#phi_{1}+#phi_{2})#GT}");
2377  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(5,"#sum_{i=1}^{N} w_{#LT2#GT} w_{#LTsin(#phi_{1}+#phi_{2})#GT}");
2378  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(6,"#sum_{i=1}^{N} w_{#LT2#GT} w_{#LTcos(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2379  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(7,"#sum_{i=1}^{N} w_{#LT2#GT} w_{#LTsin(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2380  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(8,"#sum_{i=1}^{N} w_{#LT4#GT} w_{#LTcos(#phi)#GT}");
2381  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(9,"#sum_{i=1}^{N} w_{#LT4#GT} w_{#LTsin(#phi)#GT}");
2382  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(10,"#sum_{i=1}^{N} w_{#LT4#GT} w_{#LTcos(#phi_{1}+#phi_{2})#GT}");
2383  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(11,"#sum_{i=1}^{N} w_{#LT4#GT} w_{#LTsin(#phi_{1}+#phi_{2})#GT}");
2384  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(12,"#sum_{i=1}^{N} w_{#LT4#GT} w_{#LTcos(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2385  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(13,"#sum_{i=1}^{N} w_{#LT4#GT} w_{#LTsin(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2386  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(14,"#sum_{i=1}^{N} w_{#LTcos(#phi)#GT} w_{#LTcos(#phi_{1}+#phi_{2})#GT}");
2387  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(15,"#sum_{i=1}^{N} w_{#LTcos(#phi)#GT} w_{#LTsin(#phi_{1}+#phi_{2})#GT}");
2388  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(16,"#sum_{i=1}^{N} w_{#LTcos(#phi)#GT} w_{#LTcos(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2389  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(17,"#sum_{i=1}^{N} w_{#LTcos(#phi)#GT} w_{#LTsin(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2390  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(18,"#sum_{i=1}^{N} w_{#LTsin(#phi)#GT} w_{#LTcos(#phi_{1}+#phi_{2})#GT}");
2391  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(19,"#sum_{i=1}^{N} w_{#LTsin(#phi)#GT} w_{#LTsin(#phi_{1}+#phi_{2})#GT}");
2392  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(20,"#sum_{i=1}^{N} w_{#LTsin(#phi)#GT} w_{#LTcos(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2393  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(21,"#sum_{i=1}^{N} w_{#LTsin(#phi)#GT} w_{#LTsin(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2394  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(22,"#sum_{i=1}^{N} w_{#LTcos(#phi_{1}+#phi_{2})#GT} w_{#LTsin(#phi_{1}+#phi_{2})#GT}");
2395  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(23,"#sum_{i=1}^{N} w_{#LTcos(#phi_{1}+#phi_{2})#GT} w_{#LTcos(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2396  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(24,"#sum_{i=1}^{N} w_{#LTcos(#phi_{1}+#phi_{2})#GT} w_{#LTsin(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2397  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(25,"#sum_{i=1}^{N} w_{#LTsin(#phi_{1}+#phi_{2})#GT} w_{#LTcos(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2398  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(26,"#sum_{i=1}^{N} w_{#LTsin(#phi_{1}+#phi_{2})#GT} w_{#LTsin(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2399  (fIntFlowSumOfProductOfEventWeightsNUA->GetXaxis())->SetBinLabel(27,"#sum_{i=1}^{N} w_{#LTcos(#phi_{1}-#phi_{2}-#phi_{3})#GT} w_{#LTsin(#phi_{1}-#phi_{2}-#phi_{3})#GT}");
2400  fIntFlowResults->Add(fIntFlowSumOfProductOfEventWeightsNUA);
2401  // Final results for reference Q-cumulants:
2402  TString cumulantFlag[4] = {"QC{2}","QC{4}","QC{6}","QC{8}"};
2403  TString intFlowQcumulantsName = "fIntFlowQcumulants";
2404  intFlowQcumulantsName += fAnalysisLabel->Data();
2405  fIntFlowQcumulants = new TH1D(intFlowQcumulantsName.Data(),"Reference Q-cumulants",4,0,4);
2406  if(fPropagateErrorAlsoFromNIT)
2407  {
2408   fIntFlowQcumulants->SetTitle("Reference Q-cumulants (error from non-isotropic terms also propagated)");
2409  }
2410  fIntFlowQcumulants->SetLabelSize(0.05);
2411  fIntFlowQcumulants->SetMarkerStyle(25);
2412  for(Int_t b=0;b<4;b++)
2413  {
2414   (fIntFlowQcumulants->GetXaxis())->SetBinLabel(b+1,cumulantFlag[b].Data());
2415  } 
2416  fIntFlowResults->Add(fIntFlowQcumulants);
2417  // Final results for reference Q-cumulants rebinned in M: 
2418  if(fCalculateCumulantsVsM)
2419  {
2420   TString intFlowQcumulantsRebinnedInMName = "fIntFlowQcumulantsRebinnedInM";
2421   intFlowQcumulantsRebinnedInMName += fAnalysisLabel->Data();
2422   fIntFlowQcumulantsRebinnedInM = new TH1D(intFlowQcumulantsRebinnedInMName.Data(),"Reference Q-cumulants rebinned in M",4,0,4);
2423   fIntFlowQcumulantsRebinnedInM->SetLabelSize(0.05);
2424   fIntFlowQcumulantsRebinnedInM->SetMarkerStyle(25);
2425   for(Int_t b=0;b<4;b++)
2426   {
2427    (fIntFlowQcumulantsRebinnedInM->GetXaxis())->SetBinLabel(b+1,cumulantFlag[b].Data());
2428   } 
2429   fIntFlowResults->Add(fIntFlowQcumulantsRebinnedInM);
2430  } // end of if(fCalculateCumulantsVsM) 
2431  // Ratio between error squared: with/without non-isotropic terms:
2432  TString intFlowQcumulantsErrorSquaredRatioName = "fIntFlowQcumulantsErrorSquaredRatio";
2433  intFlowQcumulantsErrorSquaredRatioName += fAnalysisLabel->Data();
2434  fIntFlowQcumulantsErrorSquaredRatio = new TH1D(intFlowQcumulantsErrorSquaredRatioName.Data(),"Error squared of reference Q-cumulants: #frac{with NUA terms}{without NUA terms}",4,0,4);
2435  fIntFlowQcumulantsErrorSquaredRatio->SetLabelSize(0.05);
2436  fIntFlowQcumulantsErrorSquaredRatio->SetMarkerStyle(25);
2437  for(Int_t b=0;b<4;b++)
2438  {
2439   (fIntFlowQcumulantsErrorSquaredRatio->GetXaxis())->SetBinLabel(b+1,cumulantFlag[b].Data());
2440  } 
2441  fIntFlowResults->Add(fIntFlowQcumulantsErrorSquaredRatio);
2442  // final results for integrated Q-cumulants versus multiplicity:
2443  if(fCalculateCumulantsVsM)
2444  {
2445   TString intFlowQcumulantsVsMName = "fIntFlowQcumulantsVsM";
2446   intFlowQcumulantsVsMName += fAnalysisLabel->Data();
2447   for(Int_t co=0;co<4;co++) // cumulant order
2448   {
2449    fIntFlowQcumulantsVsM[co] = new TH1D(Form("%s, %s",intFlowQcumulantsVsMName.Data(),cumulantFlag[co].Data()),
2450                                         Form("%s vs multipicity",cumulantFlag[co].Data()),
2451                                         fnBinsMult,fMinMult,fMaxMult);
2452    fIntFlowQcumulantsVsM[co]->GetXaxis()->SetTitle("M");                                     
2453    fIntFlowQcumulantsVsM[co]->GetYaxis()->SetTitle(cumulantFlag[co].Data());  
2454    fIntFlowResults->Add(fIntFlowQcumulantsVsM[co]);                                    
2455   } // end of for(Int_t co=0;co<4;co++) // cumulant order
2456  } // end of if(fCalculateCumulantsVsM)
2457  // final integrated flow estimates from Q-cumulants:
2458  TString flowFlag[4] = {Form("v_{%d}{2,QC}",fHarmonic),Form("v_{%d}{4,QC}",fHarmonic),Form("v_{%d}{6,QC}",fHarmonic),Form("v_{%d}{8,QC}",fHarmonic)};
2459  TString intFlowName = "fIntFlow";
2460  intFlowName += fAnalysisLabel->Data();  
2461  // integrated flow from Q-cumulants:
2462  fIntFlow = new TH1D(intFlowName.Data(),"Reference flow estimates from Q-cumulants",4,0,4);
2463  fIntFlow->SetLabelSize(0.05);
2464  fIntFlow->SetMarkerStyle(25);
2465  for(Int_t b=0;b<4;b++)
2466  {
2467   (fIntFlow->GetXaxis())->SetBinLabel(b+1,flowFlag[b].Data()); 
2468  }
2469  fIntFlowResults->Add(fIntFlow); 
2470  // Reference flow vs M rebinned in one huge bin:
2471  if(fCalculateCumulantsVsM)
2472  { 
2473   TString intFlowRebinnedInMName = "fIntFlowRebinnedInM";
2474   intFlowRebinnedInMName += fAnalysisLabel->Data();  
2475   fIntFlowRebinnedInM = new TH1D(intFlowRebinnedInMName.Data(),"Reference flow estimates from Q-cumulants (rebinned in M)",4,0,4);
2476   fIntFlowRebinnedInM->SetLabelSize(0.05);
2477   fIntFlowRebinnedInM->SetMarkerStyle(25);
2478   for(Int_t b=0;b<4;b++)
2479   {
2480    (fIntFlowRebinnedInM->GetXaxis())->SetBinLabel(b+1,flowFlag[b].Data()); 
2481   }
2482   fIntFlowResults->Add(fIntFlowRebinnedInM); 
2483  } 
2484  // integrated flow from Q-cumulants: versus multiplicity:
2485  if(fCalculateCumulantsVsM)
2486  {
2487   TString intFlowVsMName = "fIntFlowVsM";
2488   intFlowVsMName += fAnalysisLabel->Data();
2489   for(Int_t co=0;co<4;co++) // cumulant order
2490   {
2491    fIntFlowVsM[co] = new TH1D(Form("%s, %s",intFlowVsMName.Data(),flowFlag[co].Data()),
2492                               Form("%s vs multipicity",flowFlag[co].Data()),
2493                               fnBinsMult,fMinMult,fMaxMult);
2494    fIntFlowVsM[co]->GetXaxis()->SetTitle("M");                                     
2495    fIntFlowVsM[co]->GetYaxis()->SetTitle(flowFlag[co].Data());  
2496    fIntFlowResults->Add(fIntFlowVsM[co]);                                    
2497   } // end of for(Int_t co=0;co<4;co++) // cumulant order
2498  } // end of if(fCalculateCumulantsVsM)
2499  // quantifying detector effects effects to correlations:
2500  TString intFlowDetectorBiasName = "fIntFlowDetectorBias";
2501  intFlowDetectorBiasName += fAnalysisLabel->Data();  
2502  fIntFlowDetectorBias = new TH1D(intFlowDetectorBiasName.Data(),"Quantifying detector bias",4,0,4);
2503  fIntFlowDetectorBias->SetLabelSize(0.05);
2504  fIntFlowDetectorBias->SetMarkerStyle(25);
2505  for(Int_t ci=0;ci<4;ci++)
2506  {  
2507   (fIntFlowDetectorBias->GetXaxis())->SetBinLabel(ci+1,Form("#frac{corrected}{measured} %s",cumulantFlag[ci].Data()));
2508  }
2509  fIntFlowResults->Add(fIntFlowDetectorBias); 
2510  // quantifying detector effects to correlations versus multiplicity:
2511  if(fCalculateCumulantsVsM)
2512  {
2513   TString intFlowDetectorBiasVsMName = "fIntFlowDetectorBiasVsM";
2514   intFlowDetectorBiasVsMName += fAnalysisLabel->Data();
2515   for(Int_t ci=0;ci<4;ci++) // correlation index
2516   {
2517    fIntFlowDetectorBiasVsM[ci] = new TH1D(Form("%s for %s",intFlowDetectorBiasVsMName.Data(),cumulantFlag[ci].Data()),
2518                                           Form("Quantifying detector bias for %s vs multipicity",cumulantFlag[ci].Data()),
2519                                           fnBinsMult,fMinMult,fMaxMult);
2520    fIntFlowDetectorBiasVsM[ci]->GetXaxis()->SetTitle("M");                                     
2521    fIntFlowDetectorBiasVsM[ci]->GetYaxis()->SetTitle("#frac{corrected}{measured}");  
2522    fIntFlowResults->Add(fIntFlowDetectorBiasVsM[ci]);                                    
2523   } // end of for(Int_t co=0;co<4;co++) // cumulant order
2524  } // end of if(fCalculateCumulantsVsM)
2525    
2526 } // end of AliFlowAnalysisWithQCumulants::BookEverythingForIntegratedFlow()
2527
2528 //================================================================================================================================
2529
2530 void AliFlowAnalysisWithQCumulants::InitializeArraysForNestedLoops()
2531 {
2532  // Initialize arrays of all objects relevant for calculations with nested loops.
2533  
2534  // integrated flow:
2535  for(Int_t sc=0;sc<2;sc++) // sin or cos terms
2536  {
2537   fIntFlowDirectCorrectionTermsForNUA[sc] = NULL;
2538  } 
2539
2540  // differential flow:  
2541  // correlations:
2542  for(Int_t t=0;t<2;t++) // type: RP or POI
2543  { 
2544   for(Int_t pe=0;pe<2;pe++) // pt or eta
2545   {
2546    for(Int_t ci=0;ci<4;ci++) // correlation index
2547    {
2548     fDiffFlowDirectCorrelations[t][pe][ci] = NULL;
2549    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index  
2550   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
2551  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
2552  // correction terms for non-uniform acceptance:
2553  for(Int_t t=0;t<2;t++) // type: RP or POI
2554  { 
2555   for(Int_t pe=0;pe<2;pe++) // pt or eta
2556   {
2557    for(Int_t sc=0;sc<2;sc++) // sin or cos terms
2558    {
2559     for(Int_t cti=0;cti<9;cti++) // correction term index
2560     {
2561      fDiffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti] = NULL;
2562     }   
2563    }
2564   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
2565  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
2566
2567  // other differential correlators: 
2568  for(Int_t t=0;t<2;t++) // type: RP or POI
2569  { 
2570   for(Int_t pe=0;pe<2;pe++) // pt or eta
2571   {
2572    for(Int_t sc=0;sc<2;sc++) // sin or cos terms
2573    {
2574     for(Int_t ci=0;ci<1;ci++) // correlator index
2575     {
2576      fOtherDirectDiffCorrelators[t][pe][sc][ci] = NULL;
2577     }   
2578    }
2579   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
2580  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
2581
2582 } // end of void AliFlowAnalysisWithQCumulants::InitializeArraysForNestedLoops()
2583
2584 //================================================================================================================================
2585
2586 void AliFlowAnalysisWithQCumulants::BookEverythingForNestedLoops()
2587 {
2588  // Book all objects relevant for calculations with nested loops.
2589  
2590  TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data members?)
2591  TString typeFlag[2] = {"RP","POI"}; // to be improved (should I promote this to data members?)
2592  TString ptEtaFlag[2] = {"p_{T}","#eta"}; // to be improved (should I promote this to data members?)
2593  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"}; // to be improved (should I promote this to data members?)
2594  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
2595  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
2596
2597  TString evaluateNestedLoopsName = "fEvaluateNestedLoops";
2598  evaluateNestedLoopsName += fAnalysisLabel->Data();
2599  fEvaluateNestedLoops = new TProfile(evaluateNestedLoopsName.Data(),"Flags for nested loops",4,0,4);
2600  fEvaluateNestedLoops->SetLabelSize(0.03);
2601  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(1,"fEvaluateIntFlowNestedLoops");
2602  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(2,"fEvaluateDiffFlowNestedLoops");
2603  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(3,"fCrossCheckInPtBinNo");
2604  (fEvaluateNestedLoops->GetXaxis())->SetBinLabel(4,"fCrossCheckInEtaBinNo");
2605  fEvaluateNestedLoops->Fill(0.5,(Int_t)fEvaluateIntFlowNestedLoops);
2606  fEvaluateNestedLoops->Fill(1.5,(Int_t)fEvaluateDiffFlowNestedLoops);
2607  fEvaluateNestedLoops->Fill(2.5,fCrossCheckInPtBinNo);
2608  fEvaluateNestedLoops->Fill(3.5,fCrossCheckInEtaBinNo);
2609  fNestedLoopsList->Add(fEvaluateNestedLoops);
2610  // nested loops for integrated flow:
2611  if(fEvaluateIntFlowNestedLoops)
2612  {
2613   // correlations:
2614   TString intFlowDirectCorrelationsName = "fIntFlowDirectCorrelations";
2615   intFlowDirectCorrelationsName += fAnalysisLabel->Data();
2616   fIntFlowDirectCorrelations = new TProfile(intFlowDirectCorrelationsName.Data(),"Multiparticle correlations calculated with nested loops (for int. flow)",64,0,64,"s");
2617   fNestedLoopsList->Add(fIntFlowDirectCorrelations);
2618   if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)
2619   {
2620    TString intFlowExtraDirectCorrelationsName = "fIntFlowExtraDirectCorrelations";
2621    intFlowExtraDirectCorrelationsName += fAnalysisLabel->Data();
2622    fIntFlowExtraDirectCorrelations = new TProfile(intFlowExtraDirectCorrelationsName.Data(),"Extra multiparticle correlations calculated with nested loops (for int. flow)",100,0,100,"s");
2623    fNestedLoopsList->Add(fIntFlowExtraDirectCorrelations);  
2624   } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)
2625   // correction terms for non-uniform acceptance:
2626   for(Int_t sc=0;sc<2;sc++) // sin or cos terms
2627   {
2628    TString intFlowDirectCorrectionTermsForNUAName = "fIntFlowDirectCorrectionTermsForNUA";
2629    intFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();
2630    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");
2631    fNestedLoopsList->Add(fIntFlowDirectCorrectionTermsForNUA[sc]);
2632   } // end of for(Int_t sc=0;sc<2;sc++) 
2633  } // end of if(fEvaluateIntFlowNestedLoops)
2634  
2635  // nested loops for differential flow: 
2636  if(fEvaluateDiffFlowNestedLoops)
2637  {
2638   // reduced correlations:
2639   TString diffFlowDirectCorrelationsName = "fDiffFlowDirectCorrelations";
2640   diffFlowDirectCorrelationsName += fAnalysisLabel->Data();
2641   for(Int_t t=0;t<2;t++) // type: RP or POI
2642   { 
2643    for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
2644    {
2645     for(Int_t rci=0;rci<4;rci++) // reduced correlation index
2646     {
2647      // reduced correlations:
2648      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");
2649      fDiffFlowDirectCorrelations[t][pe][rci]->SetXTitle(ptEtaFlag[pe].Data());
2650      fNestedLoopsList->Add(fDiffFlowDirectCorrelations[t][pe][rci]); // to be improved (add dedicated list to hold reduced correlations)
2651     } // end of for(Int_t rci=0;rci<4;rci++) // correlation index
2652    } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta 
2653   } // end of for(Int_t t=0;t<2;t++) // type: RP or POI 
2654   
2655   
2656   // correction terms for non-uniform acceptance:
2657   TString diffFlowDirectCorrectionTermsForNUAName = "fDiffFlowDirectCorrectionTermsForNUA";
2658   diffFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();
2659   for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)
2660   { 
2661    for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
2662    {
2663     for(Int_t sc=0;sc<2;sc++) // sin or cos
2664     {
2665      for(Int_t cti=0;cti<9;cti++) // correction term index
2666      {
2667       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"); 
2668       fNestedLoopsList->Add(fDiffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti]);
2669      }
2670     }
2671    }
2672   }
2673   // other differential correlators: 
2674   TString otherDirectDiffCorrelatorsName = "fOtherDirectDiffCorrelators";
2675   otherDirectDiffCorrelatorsName += fAnalysisLabel->Data();
2676   for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)
2677   { 
2678    for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
2679    {
2680     for(Int_t sc=0;sc<2;sc++) // sin or cos
2681     {
2682      for(Int_t ci=0;ci<1;ci++) // correlator index
2683      {
2684       fOtherDirectDiffCorrelators[t][pe][sc][ci] = new TProfile(Form("%s, %s, %s, %s, ci = %d",otherDirectDiffCorrelatorsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),ci+1),Form("%s, %s, %s, %s, ci = %d",otherDirectDiffCorrelatorsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),ci+1),1,lowerPtEtaEdge[pe],upperPtEtaEdge[pe]); 
2685       fNestedLoopsList->Add(fOtherDirectDiffCorrelators[t][pe][sc][ci]);
2686      }
2687     }
2688    }
2689   }
2690   // number of RPs and POIs in selected pt and eta bins for cross-checkings:
2691   TString noOfParticlesInBinName = "fNoOfParticlesInBin";
2692   fNoOfParticlesInBin = new TH1D(noOfParticlesInBinName.Data(),"Number of RPs and POIs in selected p_{T} and #eta bin",4,0,4);
2693   fNoOfParticlesInBin->GetXaxis()->SetBinLabel(1,"# of RPs in p_{T} bin");
2694   fNoOfParticlesInBin->GetXaxis()->SetBinLabel(2,"# of RPs in #eta bin");
2695   fNoOfParticlesInBin->GetXaxis()->SetBinLabel(3,"# of POIs in p_{T} bin");
2696   fNoOfParticlesInBin->GetXaxis()->SetBinLabel(4,"# of POIs in #eta bin");
2697   fNestedLoopsList->Add(fNoOfParticlesInBin);
2698  } // end of if(fEvaluateDiffFlowNestedLoops)
2699
2700 } // end of AliFlowAnalysisWithQCumulants::BookEverythingForNestedLoops()
2701
2702 //================================================================================================================================
2703
2704 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelations()
2705 {
2706  // Calculate in this method all multiparticle azimuthal correlations.
2707  //
2708  // Remark 1: All multiparticle correlations are stored in TProfile fIntFlowCorrelationsAllPro;
2709  // Remark 2: There is a special TProfile fIntFlowCorrelationsPro holding results 
2710  //           only for same harmonic's correlations <<2>>, <<4>>, <<6>> and <<8>>;  
2711  // Remark 3: Binning of fIntFlowCorrelationsAllPro is organized as follows:
2712  // --------------------------------------------------------------------------------------------------------------------
2713  //  1st bin: <2>_{1n|1n} = two1n1n = cos(1n(phi1-phi2))>
2714  //  2nd bin: <2>_{2n|2n} = two2n2n = cos(2n(phi1-phi2))>
2715  //  3rd bin: <2>_{3n|3n} = two3n3n = cos(3n(phi1-phi2))> 
2716  //  4th bin: <2>_{4n|4n} = two4n4n = cos(4n(phi1-phi2))>
2717  //  5th bin:           ----  EMPTY ----
2718  //  6th bin: <3>_{2n|1n,1n} = three2n1n1n = <cos(n(2*phi1-phi2-phi3))>
2719  //  7th bin: <3>_{3n|2n,1n} = three3n2n1n = <cos(n(3*phi1-2*phi2-phi3))>
2720  //  8th bin: <3>_{4n|2n,2n} = three4n2n2n = <cos(n(4*phi1-2*phi2-2*phi3))>
2721  //  9th bin: <3>_{4n|3n,1n} = three4n3n1n = <cos(n(4*phi1-3*phi2-phi3))>
2722  // 10th bin:           ----  EMPTY ----
2723  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1n = <cos(n(phi1+phi2-phi3-phi4))>
2724  // 12th bin: <4>_{2n,1n|2n,1n} = four2n1n2n1n = <cos(n(2*phi1+phi2-2*phi3-phi4))>
2725  // 13th bin: <4>_{2n,2n|2n,2n} = four2n2n2n2n = <cos(2n(phi1+phi2-phi3-phi4))>
2726  // 14th bin: <4>_{3n|1n,1n,1n} = four3n1n1n1n = <cos(n(3*phi1-phi2-phi3-phi4))> 
2727  // 15th bin: <4>_{3n,1n|3n,1n} = four3n1n3n1n = <cos(n(3*phi1+phi2-3*phi3-phi4))>
2728  // 16th bin: <4>_{3n,1n|2n,2n} = four3n1n2n2n = <cos(n(3*phi1+phi2-2*phi3-2*phi4))>
2729  // 17th bin: <4>_{4n|2n,1n,1n} = four4n2n1n1n = <cos(n(4*phi1-2*phi2-phi3-phi4))>
2730  // 18th bin:           ----  EMPTY ----
2731  // 19th bin: <5>_{2n,1n|1n,1n,1n} = five2n1n1n1n1n = <cos(n(2*phi1+phi2-phi3-phi4-phi5))>
2732  // 20th bin: <5>_{2n,2n|2n,1n,1n} = five2n2n2n1n1n = <cos(n(2*phi1+2*phi2-2*phi3-phi4-phi5))>
2733  // 21st bin: <5>_{3n,1n|2n,1n,1n} = five3n1n2n1n1n = <cos(n(3*phi1+phi2-2*phi3-phi4-phi5))>
2734  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = five4n1n1n1n1n = <cos(n(4*phi1-phi2-phi3-phi4-phi5))>
2735  // 23rd bin:           ----  EMPTY ----
2736  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = six1n1n1n1n1n1n = <cos(n(phi1+phi2+phi3-phi4-phi5-phi6))>
2737  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = six2n1n1n2n1n1n = <cos(n(2*phi1+phi2+phi3-2*phi4-phi5-phi6))>
2738  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = six2n2n1n1n1n1n = <cos(n(2*phi1+2*phi2-phi3-phi4-phi5-phi6))>
2739  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = six3n1n1n1n1n1n = <cos(n(3*phi1+phi2-phi3-phi4-phi5-phi6))> 
2740  // 28th bin:           ----  EMPTY ----
2741  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = seven2n1n1n1n1n1n1n =  <cos(n(2*phi1+phi2+phi3-phi4-phi5-phi6-phi7))>
2742  // 30th bin:           ----  EMPTY ----
2743  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = eight1n1n1n1n1n1n1n1n = <cos(n(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>
2744  // 32nd bin:           ----  EMPTY ----
2745  //  Extra correlations for v3{5} study: 
2746  // 33rd bin: <4>_{4n,2n|3n,3n} = four4n2n3n3n = <cos(n(4*phi1+2*phi2-3*phi3-3*phi4))>
2747  // 34th bin: <5>_{3n,3n|2n,2n,2n} = five3n3n2n2n2n = <cos(n(3*phi1+3*phi2-2*phi3-2*phi4-2*phi5))> 
2748  //  Extra correlations for Teaney-Yan study: 
2749  // 35th bin: <2>_{5n|5n} = two5n5n = <cos(5n(phi1-phi2)> 
2750  // 36th bin: <2>_{6n|6n} = two6n6n = <cos(6n(phi1-phi2)> 
2751  // 37th bin: <3>_{5n|3n,2n} = three5n3n2n = <cos(n(5*phi1-3*phi2-2*phi3)> 
2752  // 38th bin: <3>_{5n|4n,1n} = three5n4n1n = <cos(n(5*phi1-4*phi2-1*phi3)> 
2753  // 39th bin: <3>_{6n|3n,3n} = three6n3n3n = <cos(n(6*phi1-3*phi2-3*phi3)> 
2754  // 40th bin: <3>_{6n|4n,2n} = three6n4n2n = <cos(n(6*phi1-4*phi2-2*phi3)> 
2755  // 41st bin: <3>_{6n|5n,1n} = three6n5n1n = <cos(n(6*phi1-5*phi2-1*phi3)>
2756  // 42nd bin: <4>_{6n|3n,2n,1n} = four6n3n2n1n = <cos(n(6*phi1-3*phi2-2*phi3-1*phi4)>
2757  // 43rd bin: <4>_{3n,2n|3n,2n} = four3n2n3n2n = <cos(n(3*phi1+2*phi2-3*phi3-2*phi4)>
2758  // 44th bin: <4>_{4n,1n|3n,2n} = four4n1n3n2n = <cos(n(4*phi1+1*phi2-3*phi3-2*phi4)>
2759  // 45th bin: <4>_{3n,3n|3n,3n} = four3n3n3n3n = <cos(3n*(phi1+phi2-phi3-phi4))> 
2760  // 46th bin: <4>_{4n,2n|3n,3n} = four4n2n3n3n = <cos(n(4*phi1+2*phi2-3*phi3-3*phi4)>
2761  // 47th bin: <4>_{5n,1n|3n,3n} = four5n1n3n3n = <cos(n(5*phi1+1*phi2-3*phi3-3*phi4)>
2762  // 48th bin: <4>_{4n,2n|4n,2n} = four4n2n4n2n = <cos(n(4*phi1+2*phi2-4*phi3-2*phi4)> 
2763  // 49th bin: <4>_{5n,1n|4n,2n} = four5n1n4n2n = <cos(n(5*phi1+1*phi2-4*phi3-2*phi4)>
2764  // 50th bin: <4>_{5n|3n,1n,1n} = four5n3n1n1n = <cos(n(5*phi1-3*phi2-1*phi3-1*phi4)>
2765  // 51st bin: <4>_{5n|2n,2n,1n} = four5n2n2n1n = <cos(n(5*phi1-2*phi2-2*phi3-1*phi4)>
2766  // 52nd bin: <4>_{5n,1n|5n,1n} = four5n1n5n1n = <cos(n(5*phi1+1*phi2-5*phi3-1*phi4)>
2767  // 53rd bin: <5>_{3n,3n|3n,2n,1n} = five3n3n3n2n1n = <cos(n(3*phi1+3*phi2-3*phi3-2*phi4-1*phi5)>
2768  // 54th bin: <5>_{4n,2n|3n,2n,1n} = five4n2n3n2n1n = <cos(n(4*phi1+2*phi2-3*phi3-2*phi4-1*phi5)>
2769  // 55th bin: <5>_{3n,2n|3n,1n,1n} = five3n2n3n1n1n = <cos(n(3*phi1+2*phi2-3*phi3-1*phi4-1*phi5)>
2770  // 56th bin: <5>_{3n,2n|2n,2n,1n} = five3n2n2n2n1n = <cos(n(3*phi1+2*phi2-2*phi3-2*phi4-1*phi5)>
2771  // 57th bin: <5>_{5n,1n|3n,2n,1n} = five5n1n3n2n1n = <cos(n(5*phi1+1*phi2-3*phi3-2*phi4-1*phi5)>
2772  // 58th bin: <6>_{3n,2n,1n|3n,2n,1n} = six3n2n1n3n2n1n = <cos(n(3*phi1+2*phi2+1*phi3-3*phi4-2*phi5-1*phi6)>
2773  //  Extra correlations for Teaney-Yan study (B): 
2774  // 59th bin: <4>_{6n|4n,1n,1n} = four6n4n1n1n = <cos(n(6*phi1-4*phi2-1*phi3-1*phi4)>
2775  // 60th bin: <4>_{6n|2n,2n,2n} = four6n2n2n2n = <cos(n(6*phi1-2*phi2-2*phi3-2*phi4)>
2776  // 61st bin: <5>_{6n|2n,2n,1n,1n} = five6n2n2n1n1n = <cos(n(6*phi1-2*phi2-2*phi3-1*phi4-1*phi5)>
2777  // 62nd bin: <5>_{4n,1n,1n|3n,3n} = five4n1n1n3n3n = <cos(n(4*phi1+1*phi2+1*phi3-3*phi4-3*phi5)>
2778  // 63rd bin: <6>_{3n,3n|2n,2n,1n,1n} = six3n3n2n2n1n1n = <cos(n(3*phi1+3*phi2-2*phi3-2*phi4-1*phi5-1*phi6)>
2779  // --------------------------------------------------------------------------------------------------------------------
2780
2781  // Multiplicity of an event: 
2782  Double_t dMult = (*fSpk)(0,0);
2783  // Real parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n, 4n, 5n and 6n: 
2784  Double_t dReQ1n = (*fReQ)(0,0);
2785  Double_t dReQ2n = (*fReQ)(1,0);
2786  Double_t dReQ3n = (*fReQ)(2,0);
2787  Double_t dReQ4n = (*fReQ)(3,0);
2788  Double_t dReQ5n = (*fReQ)(4,0); 
2789  Double_t dReQ6n = (*fReQ)(5,0);
2790  // Imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n, 4n, 5n and 6n:
2791  Double_t dImQ1n = (*fImQ)(0,0);
2792  Double_t dImQ2n = (*fImQ)(1,0);
2793  Double_t dImQ3n = (*fImQ)(2,0);
2794  Double_t dImQ4n = (*fImQ)(3,0);
2795  Double_t dImQ5n = (*fImQ)(4,0); 
2796  Double_t dImQ6n = (*fImQ)(5,0);
2797   
2798  // Real parts of expressions involving various combinations of Q-vectors which appears
2799  // simultaneously in several equations for multiparticle correlations bellow: 
2800  // Re[Q_{2n}Q_{n}^*Q_{n}^*]
2801  Double_t reQ2nQ1nstarQ1nstar = pow(dReQ1n,2.)*dReQ2n+2.*dReQ1n*dImQ1n*dImQ2n-pow(dImQ1n,2.)*dReQ2n; 
2802  // Re[Q_{6n}Q_{3n}^*Q_{3n}^*]
2803  Double_t reQ6nQ3nstarQ3nstar = pow(dReQ3n,2.)*dReQ6n+2.*dReQ3n*dImQ3n*dImQ6n-pow(dImQ3n,2.)*dReQ6n;  
2804  // Re[Q_{4n}Q_{2n}^*Q_{2n}^*]
2805  Double_t reQ4nQ2nstarQ2nstar = pow(dReQ2n,2.)*dReQ4n+2.*dReQ2n*dImQ2n*dImQ4n-pow(dImQ2n,2.)*dReQ4n;
2806  // Re[Q_{4n}Q_{3n}^*Q_{n}^*]
2807  Double_t reQ4nQ3nstarQ1nstar = dReQ4n*(dReQ3n*dReQ1n-dImQ3n*dImQ1n)+dImQ4n*(dReQ3n*dImQ1n+dImQ3n*dReQ1n);
2808  // Re[Q_{3n}Q_{2n}^*Q_{n}^*]
2809  Double_t reQ3nQ2nstarQ1nstar = dReQ3n*dReQ2n*dReQ1n-dReQ3n*dImQ2n*dImQ1n+dImQ3n*dReQ2n*dImQ1n
2810                               + dImQ3n*dImQ2n*dReQ1n; 
2811  // Re[Q_{5n}Q_{3n}^*Q_{2n}^*]
2812  Double_t reQ5nQ3nstarQ2nstar = dReQ5n*dReQ2n*dReQ3n-dReQ5n*dImQ2n*dImQ3n+dImQ5n*dReQ2n*dImQ3n
2813                               + dImQ5n*dImQ2n*dReQ3n;                             
2814  // Re[Q_{5n}Q_{4n}^*Q_{1n}^*]
2815  Double_t reQ5nQ4nstarQ1nstar = dReQ5n*dReQ4n*dReQ1n-dReQ5n*dImQ4n*dImQ1n+dImQ5n*dReQ4n*dImQ1n
2816                               + dImQ5n*dImQ4n*dReQ1n;                              
2817  // Re[Q_{6n}Q_{5n}^*Q_{1n}^*]                              
2818  Double_t reQ6nQ5nstarQ1nstar = dReQ6n*dReQ5n*dReQ1n-dReQ6n*dImQ5n*dImQ1n+dImQ6n*dReQ5n*dImQ1n
2819                               + dImQ6n*dImQ5n*dReQ1n;
2820  // Re[Q_{6n}Q_{4n}^*Q_{2n}^*]                              
2821  Double_t reQ6nQ4nstarQ2nstar = dReQ6n*dReQ4n*dReQ2n-dReQ6n*dImQ4n*dImQ2n+dImQ6n*dReQ4n*dImQ2n
2822                               + dImQ6n*dImQ4n*dReQ2n;
2823  // Re[Q_{3n}Q_{n}Q_{2n}^*Q_{2n}^*]
2824  Double_t reQ3nQ1nQ2nstarQ2nstar = (pow(dReQ2n,2.)-pow(dImQ2n,2.))*(dReQ3n*dReQ1n-dImQ3n*dImQ1n) 
2825                                  + 2.*dReQ2n*dImQ2n*(dReQ3n*dImQ1n+dImQ3n*dReQ1n);                                
2826  // Re[Q_{3n}Q_{n}^*Q_{n}^*Q_{n}^*]
2827  Double_t reQ3nQ1nstarQ1nstarQ1nstar = dReQ3n*pow(dReQ1n,3)-3.*dReQ1n*dReQ3n*pow(dImQ1n,2)
2828                                      + 3.*dImQ1n*dImQ3n*pow(dReQ1n,2)-dImQ3n*pow(dImQ1n,3);
2829  // Re[Q_{6n}Q_{2n}^*Q_{2n}^*Q_{2n}^*]
2830  Double_t reQ6nQ2nstarQ2nstarQ2nstar = dReQ6n*pow(dReQ2n,3)-3.*dReQ2n*dReQ6n*pow(dImQ2n,2)
2831                                      + 3.*dImQ2n*dImQ6n*pow(dReQ2n,2)-dImQ6n*pow(dImQ2n,3);
2832  // Re[Q_{4n}Q_{2n}^*Q_{n}^*Q_{n}^*]
2833  Double_t reQ4nQ2nstarQ1nstarQ1nstar = (dReQ4n*dReQ2n+dImQ4n*dImQ2n)*(pow(dReQ1n,2)-pow(dImQ1n,2)) 
2834                                      + 2.*dReQ1n*dImQ1n*(dImQ4n*dReQ2n-dReQ4n*dImQ2n);  
2835  // Re[Q_{4n}Q_{2n}^*Q_{3n}^*Q_{3n}^*]
2836  Double_t reQ4nQ2nQ3nstarQ3nstar = (dReQ4n*dReQ2n-dImQ4n*dImQ2n)*(dReQ3n*dReQ3n-dImQ3n*dImQ3n)
2837                                  + 2.*(dReQ4n*dImQ2n+dImQ4n*dReQ2n)*dReQ3n*dImQ3n;                    
2838  // Re[Q_{4n}Q_{n}Q_{3n}^*Q_{2n}^*]
2839  Double_t reQ4nQ1nQ3nstarQ2nstar = dImQ1n*dImQ2n*dImQ3n*dImQ4n+dImQ3n*dImQ4n*dReQ1n*dReQ2n 
2840                                  + dImQ2n*dImQ4n*dReQ1n*dReQ3n-dImQ1n*dImQ4n*dReQ2n*dReQ3n
2841                                  - dImQ2n*dImQ3n*dReQ1n*dReQ4n+dImQ1n*dImQ3n*dReQ2n*dReQ4n 
2842                                  + dImQ1n*dImQ2n*dReQ3n*dReQ4n+dReQ1n*dReQ2n*dReQ3n*dReQ4n;
2843  // Re[Q_{5n}Q_{n}Q_{4n}^*Q_{2n}^*]
2844  Double_t reQ5nQ1nQ4nstarQ2nstar = dImQ1n*dImQ2n*dImQ4n*dImQ5n+dImQ4n*dImQ5n*dReQ1n*dReQ2n 
2845                                  + dImQ2n*dImQ5n*dReQ1n*dReQ4n-dImQ1n*dImQ5n*dReQ2n*dReQ4n
2846                                  - dImQ2n*dImQ4n*dReQ1n*dReQ5n+dImQ1n*dImQ4n*dReQ2n*dReQ5n 
2847                                  + dImQ1n*dImQ2n*dReQ4n*dReQ5n+dReQ1n*dReQ2n*dReQ4n*dReQ5n;                                  
2848  // Re[Q_{5n}Q_{n}Q_{3n}^*Q_{3n}^*]                                  
2849  Double_t reQ5nQ1nQ3nstarQ3nstar = dImQ1n*pow(dImQ3n,2.)*dImQ5n+2.*dImQ3n*dImQ5n*dReQ1n*dReQ3n
2850                                  - dImQ1n*dImQ5n*pow(dReQ3n,2.)-pow(dImQ3n,2.)*dReQ1n*dReQ5n 
2851                                  + 2.*dImQ1n*dImQ3n*dReQ3n*dReQ5n+dReQ1n*pow(dReQ3n,2.)*dReQ5n;
2852  // Re[Q_{5n}Q_{3n}^*Q_{n}^*Q_{n}^*]                                  
2853  Double_t reQ5nQ3nstarQ1nstarQ1nstar = -pow(dImQ1n,2.)*dImQ3n*dImQ5n+dImQ3n*dImQ5n*pow(dReQ1n,2.)
2854                                      + 2.*dImQ1n*dImQ5n*dReQ1n*dReQ3n-2.*dImQ1n*dImQ3n*dReQ1n*dReQ5n 
2855                                      - pow(dImQ1n,2.)*dReQ3n*dReQ5n+pow(dReQ1n,2.)*dReQ3n*dReQ5n;                     
2856  // Re[Q_{5n}Q_{2n}^*Q_{2n}^*Q_{n}^*]                                  
2857  Double_t reQ5nQ2nstarQ2nstarQ1nstar = -pow(dImQ2n,2.)*dImQ1n*dImQ5n+dImQ1n*dImQ5n*pow(dReQ2n,2.)
2858                                      + 2.*dImQ2n*dImQ5n*dReQ2n*dReQ1n-2.*dImQ2n*dImQ1n*dReQ2n*dReQ5n 
2859                                      - pow(dImQ2n,2.)*dReQ1n*dReQ5n+pow(dReQ2n,2.)*dReQ1n*dReQ5n;                                     
2860  // Re[Q_{6n}Q_{4n}^*Q_{n}^*Q_{n}^*]                                  
2861  Double_t reQ6nQ4nstarQ1nstarQ1nstar = -pow(dImQ1n,2.)*dImQ4n*dImQ6n+dImQ4n*dImQ6n*pow(dReQ1n,2.) 
2862                                      +  2.*dImQ1n*dImQ6n*dReQ1n*dReQ4n-2.*dImQ1n*dImQ4n*dReQ1n*dReQ6n 
2863                                      -  pow(dImQ1n,2.)*dReQ4n*dReQ6n+pow(dReQ1n,2.)*dReQ4n*dReQ6n;
2864  // |Q_{2n}|^2 |Q_{n}|^2
2865  Double_t dQ2nQ1nQ2nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.));
2866  // |Q_{4n}|^2 |Q_{2n}|^2
2867  Double_t dQ4nQ2nQ4nstarQ2nstar = (pow(dReQ4n,2.)+pow(dImQ4n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.));
2868  // |Q_{3n}|^2 |Q_{2n}|^2
2869  Double_t dQ3nQ2nQ3nstarQ2nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ3n,2.)+pow(dImQ3n,2.));
2870  // |Q_{5n}|^2 |Q_{n}|^2
2871  Double_t dQ5nQ1nQ5nstarQ1nstar = (pow(dReQ5n,2.)+pow(dImQ5n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.));
2872  // |Q_{3n}|^2 |Q_{n}|^2
2873  Double_t dQ3nQ1nQ3nstarQ1nstar = (pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.));
2874  // Re[Q_{2n}Q_{n}Q_{n}^*Q_{n}^*Q_{n}^*]
2875  Double_t reQ2nQ1nQ1nstarQ1nstarQ1nstar = (dReQ2n*dReQ1n-dImQ2n*dImQ1n)*(pow(dReQ1n,3)-3.*dReQ1n*pow(dImQ1n,2))
2876                                         + (dReQ2n*dImQ1n+dReQ1n*dImQ2n)*(3.*dImQ1n*pow(dReQ1n,2)-pow(dImQ1n,3)); 
2877  // Re[Q_{2n}Q_{2n}Q_{2n}^*Q_{n}^*Q_{n}^*]
2878  Double_t reQ2nQ2nQ2nstarQ1nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))
2879                                         * (dReQ2n*(pow(dReQ1n,2.)-pow(dImQ1n,2.)) + 2.*dImQ2n*dReQ1n*dImQ1n);
2880  // Re[Q_{4n}Q_{n}^*Q_{n}^*Q_{n}^*Q_{n}^*]
2881  Double_t reQ4nQ1nstarQ1nstarQ1nstarQ1nstar = pow(dReQ1n,4.)*dReQ4n-6.*pow(dReQ1n,2.)*dReQ4n*pow(dImQ1n,2.)
2882                                             + pow(dImQ1n,4.)*dReQ4n+4.*pow(dReQ1n,3.)*dImQ1n*dImQ4n
2883                                             - 4.*pow(dImQ1n,3.)*dReQ1n*dImQ4n;
2884  // Re[Q_{3n}Q_{n}Q_{2n}^*Q_{n}^*Q_{n}^*]
2885  Double_t reQ3nQ1nQ2nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)+pow(dImQ1n,2.))
2886                                         * (dReQ1n*dReQ2n*dReQ3n-dReQ3n*dImQ1n*dImQ2n
2887                                         + dReQ2n*dImQ1n*dImQ3n+dReQ1n*dImQ2n*dImQ3n);
2888  // Re[Q_{6n}Q_{n}Q_{3n}^*Q_{2n}^*Q_{n}^*]
2889  Double_t reQ6nQ3nstarQ2nstarQ1nstar = dReQ1n*dReQ2n*dReQ3n*dReQ6n-dReQ3n*dReQ6n*dImQ1n*dImQ2n
2890                                      - dReQ2n*dReQ6n*dImQ1n*dImQ3n-dReQ1n*dReQ6n*dImQ2n*dImQ3n
2891                                      + dReQ2n*dReQ3n*dImQ1n*dImQ6n+dReQ1n*dReQ3n*dImQ2n*dImQ6n 
2892                                      + dReQ1n*dReQ2n*dImQ3n*dImQ6n-dImQ1n*dImQ2n*dImQ3n*dImQ6n;
2893  // Re[Q_{3n}Q_{3n}Q_{3n}^*Q_{2n}^*Q_{n}^*]
2894  Double_t reQ3nQ3nQ3nstarQ2nstarQ1nstar = (pow(dImQ3n,2.)+pow(dReQ3n,2.))
2895                                         * (dImQ2n*dImQ3n*dReQ1n+dImQ1n*dImQ3n*dReQ2n
2896                                         - dImQ1n*dImQ2n*dReQ3n+dReQ1n*dReQ2n*dReQ3n);   
2897  // Re[Q_{3n}Q_{3n}Q_{2n}^*Q_{2n}^*Q_{2n}^*]
2898  Double_t reQ3nQ3nQ2nstarQ2nstarQ2nstar = pow(dReQ2n,3.)*pow(dReQ3n,2.) 
2899                                         - 3.*dReQ2n*pow(dReQ3n,2.)*pow(dImQ2n,2.)
2900                                         + 6.*pow(dReQ2n,2.)*dReQ3n*dImQ2n*dImQ3n 
2901                                         - 2.*dReQ3n*pow(dImQ2n,3.)*dImQ3n-pow(dReQ2n,3.)*pow(dImQ3n,2.) 
2902                                         + 3.*dReQ2n*pow(dImQ2n,2.)*pow(dImQ3n,2.);
2903  // Re[Q_{4n}Q_{2n}Q_{3n}^*Q_{2n}^*Q_{n}^*]
2904  Double_t reQ4nQ2nQ3nstarQ2nstarQ1nstar = (pow(dImQ2n,2.)+pow(dReQ2n,2.))
2905                                         * (dImQ3n*dImQ4n*dReQ1n+dImQ1n*dImQ4n*dReQ3n 
2906                                         - dImQ1n*dImQ3n*dReQ4n+dReQ1n*dReQ3n*dReQ4n);
2907  // Re[Q_{3n}Q_{2n}Q_{3n}^*Q_{n}^*Q_{n}^*]
2908  Double_t reQ3nQ2nQ3nstarQ1nstarQ1nstar = -(pow(dImQ3n,2.)+pow(dReQ3n,2.))
2909                                         * (-2.*dImQ1n*dImQ2n*dReQ1n+pow(dImQ1n,2.)*dReQ2n-pow(dReQ1n,2.)*dReQ2n);                              
2910  // Re[Q_{3n}Q_{2n}Q_{2n}^*Q_{2n}^*Q_{n}^*]
2911  Double_t reQ3nQ2nQ2nstarQ2nstarQ1nstar = (pow(dImQ2n,2.)+pow(dReQ2n,2.))
2912                                         * (dImQ2n*dImQ3n*dReQ1n+dImQ1n*dImQ3n*dReQ2n 
2913                                         - dImQ1n*dImQ2n*dReQ3n+dReQ1n*dReQ2n*dReQ3n);
2914  // Re[Q_{5n}Q_{n}Q_{3n}^*Q_{2n}^*Q_{n}^*]
2915  Double_t reQ5nQ1nQ3nstarQ2nstarQ1nstar = (pow(dImQ1n,2.)+pow(dReQ1n,2.))
2916                                         * (dImQ3n*dImQ5n*dReQ2n+dImQ2n*dImQ5n*dReQ3n 
2917                                         - dImQ2n*dImQ3n*dReQ5n+dReQ2n*dReQ3n*dReQ5n);   
2918  // Re[Q_{2n}Q_{2n}Q_{n}^*Q_{n}^*Q_{n}^*Q_{n}^*]
2919  Double_t reQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)*dReQ2n-2.*dReQ1n*dReQ2n*dImQ1n-dReQ2n*pow(dImQ1n,2.)
2920                                                + dImQ2n*pow(dReQ1n,2.)+2.*dReQ1n*dImQ1n*dImQ2n-pow(dImQ1n,2.)*dImQ2n)
2921                                                * (pow(dReQ1n,2.)*dReQ2n+2.*dReQ1n*dReQ2n*dImQ1n-dReQ2n*pow(dImQ1n,2.)
2922                                                - dImQ2n*pow(dReQ1n,2.)+2.*dReQ1n*dImQ1n*dImQ2n+pow(dImQ1n,2.)*dImQ2n); 
2923  // Re[Q_{3n}Q_{n}Q_{n}^*Q_{n}^*Q_{n}^*Q_{n}^*]
2924  Double_t reQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = (pow(dReQ1n,2.)+pow(dImQ1n,2.))
2925                                                * (pow(dReQ1n,3.)*dReQ3n-3.*dReQ1n*dReQ3n*pow(dImQ1n,2.)
2926                                                + 3.*pow(dReQ1n,2.)*dImQ1n*dImQ3n-pow(dImQ1n,3.)*dImQ3n);
2927  // |Q_{2n}|^2 |Q_{n}|^4
2928  Double_t dQ2nQ1nQ1nQ2nstarQ1nstarQ1nstar = (pow(dReQ2n,2.)+pow(dImQ2n,2.))*pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.); 
2929  // |Q_{3n}|^2 |Q_{2n}|^2 |Q_{n}|^2
2930  Double_t dQ3nQ2nQ1nQ3nstarQ2nstarQ1nstar = (pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
2931                                           * (pow(dReQ1n,2.)+pow(dImQ1n,2.));
2932  // Re[Q_{2n}Q_{n}Q_{n}Q_{n}^*Q_{n}^*Q_{n}^*Q_{n}^*]
2933  Double_t reQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)
2934                                                   * (pow(dReQ1n,2.)*dReQ2n-dReQ2n*pow(dImQ1n,2.)
2935                                                   + 2.*dReQ1n*dImQ1n*dImQ2n);                                                  
2936  // Re[Q_{6n}Q_{2n}^*Q_{2n}^*Q_{n}^*Q_{n}^*]
2937  Double_t reQ6nQ2nstarQ2nstarQ1nstarQ1nstar = pow(dReQ1n*dReQ2n,2.)*dReQ6n-pow(dReQ2n*dImQ1n,2.)*dReQ6n
2938                                             - 4.*dReQ1n*dReQ2n*dReQ6n*dImQ1n*dImQ2n 
2939                                             - pow(dReQ1n*dImQ2n,2.)*dReQ6n+pow(dImQ1n*dImQ2n,2.)*dReQ6n
2940                                             + 2.*dReQ1n*pow(dReQ2n,2.)*dImQ1n*dImQ6n
2941                                             + 2.*pow(dReQ1n,2.)*dReQ2n*dImQ2n*dImQ6n 
2942                                             - 2.*dReQ2n*pow(dImQ1n,2.)*dImQ2n*dImQ6n 
2943                                             - 2.*dReQ1n*dImQ1n*pow(dImQ2n,2.)*dImQ6n;       
2944  // Re[Q_{4n}Q_{1n}Q_{1n}Q_{3n}^*Q_{3n}^*]
2945  Double_t reQ4nQ1nQ1nQ3nstarQ3nstar = pow(dReQ1n*dReQ3n,2.)*dReQ4n-pow(dReQ3n*dImQ1n,2.)*dReQ4n  
2946                                     + 4.*dReQ1n*dReQ3n*dReQ4n*dImQ1n*dImQ3n 
2947                                     - pow(dReQ1n*dImQ3n,2.)*dReQ4n+pow(dImQ1n*dImQ3n,2.)*dReQ4n  
2948                                     - 2.*dReQ1n*pow(dReQ3n,2.)*dImQ1n*dImQ4n 
2949                                     + 2.*pow(dReQ1n,2.)*dReQ3n*dImQ3n*dImQ4n 
2950                                     - 2.*dReQ3n*pow(dImQ1n,2.)*dImQ3n*dImQ4n 
2951                                     + 2.*dReQ1n*dImQ1n*pow(dImQ3n,2.)*dImQ4n;
2952  // Re[Q_{3n}Q_{3n}Q_{2n}^*Q_{2n}^*Q_{1n}^*Q_{1n}^*]
2953  Double_t reQ3nQ3nQ2nstarQ2nstarQ1nstarQ1nstar = (dReQ1n*dReQ2n*dReQ3n-dReQ2n*dReQ3n*dImQ1n-dReQ1n*dReQ3n*dImQ2n 
2954                                                - dReQ3n*dImQ1n*dImQ2n+dReQ1n*dReQ2n*dImQ3n+dReQ2n*dImQ1n*dImQ3n 
2955                                                + dReQ1n*dImQ2n*dImQ3n-dImQ1n*dImQ2n*dImQ3n)*(dReQ1n*dReQ2n*dReQ3n 
2956                                                + dReQ2n*dReQ3n*dImQ1n+dReQ1n*dReQ3n*dImQ2n-dReQ3n*dImQ1n*dImQ2n 
2957                                                - dReQ1n*dReQ2n*dImQ3n+dReQ2n*dImQ1n*dImQ3n+dReQ1n*dImQ2n*dImQ3n 
2958                                                + dImQ1n*dImQ2n*dImQ3n);
2959     
2960  // Results for multiparticle azimuthal correlations:
2961  // 2-particle:
2962  Double_t two1n1n = 0.; // <cos(n(phi1-phi2))>
2963  Double_t two2n2n = 0.; // <cos(2n(phi1-phi2))>
2964  Double_t two3n3n = 0.; // <cos(3n(phi1-phi2))>
2965  Double_t two4n4n = 0.; // <cos(4n(phi1-phi2))>
2966  if(dMult>1)
2967  {
2968   two1n1n = (pow(dReQ1n,2.)+pow(dImQ1n,2.)-dMult)/(dMult*(dMult-1.)); 
2969   two2n2n = (pow(dReQ2n,2.)+pow(dImQ2n,2.)-dMult)/(dMult*(dMult-1.)); 
2970   two3n3n = (pow(dReQ3n,2.)+pow(dImQ3n,2.)-dMult)/(dMult*(dMult-1.)); 
2971   two4n4n = (pow(dReQ4n,2.)+pow(dImQ4n,2.)-dMult)/(dMult*(dMult-1.)); 
2972   // Average 2-particle correlations for single event: 
2973   fIntFlowCorrelationsAllEBE->SetBinContent(1,two1n1n);
2974   fIntFlowCorrelationsAllEBE->SetBinContent(2,two2n2n);
2975   fIntFlowCorrelationsAllEBE->SetBinContent(3,two3n3n);
2976   fIntFlowCorrelationsAllEBE->SetBinContent(4,two4n4n);         
2977   // Average 2-particle correlations for all events:      
2978   fIntFlowCorrelationsAllPro->Fill(0.5,two1n1n,dMult*(dMult-1.));
2979   fIntFlowCorrelationsAllPro->Fill(1.5,two2n2n,dMult*(dMult-1.)); 
2980   fIntFlowCorrelationsAllPro->Fill(2.5,two3n3n,dMult*(dMult-1.)); 
2981   fIntFlowCorrelationsAllPro->Fill(3.5,two4n4n,dMult*(dMult-1.)); 
2982   // Store separetately <2>:
2983   fIntFlowCorrelationsEBE->SetBinContent(1,two1n1n); // <2>  
2984   // Testing other multiplicity weights:
2985   Double_t mWeight2p = 0.;
2986   if(!strcmp(fMultiplicityWeight->Data(),"combinations"))
2987   {
2988    mWeight2p = dMult*(dMult-1.);
2989   } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))
2990     {
2991      mWeight2p = 1.;    
2992     } else if(!strcmp(fMultiplicityWeight->Data(),"multiplicity"))
2993       {
2994        mWeight2p = dMult;           
2995       }          
2996   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(1,mWeight2p); // eW_<2>
2997   fIntFlowCorrelationsPro->Fill(0.5,two1n1n,mWeight2p);
2998   fIntFlowSquaredCorrelationsPro->Fill(0.5,two1n1n*two1n1n,mWeight2p);
2999   if(fCalculateCumulantsVsM)
3000   {
3001    fIntFlowCorrelationsVsMPro[0]->Fill(dMult+0.5,two1n1n,mWeight2p);
3002    fIntFlowSquaredCorrelationsVsMPro[0]->Fill(dMult+0.5,two1n1n*two1n1n,mWeight2p);
3003   } 
3004   if(fCalculateAllCorrelationsVsM)
3005   {
3006    fIntFlowCorrelationsAllVsMPro[0]->Fill(dMult+0.5,two1n1n,mWeight2p);
3007    fIntFlowCorrelationsAllVsMPro[1]->Fill(dMult+0.5,two2n2n,mWeight2p);
3008    fIntFlowCorrelationsAllVsMPro[2]->Fill(dMult+0.5,two3n3n,mWeight2p);
3009    fIntFlowCorrelationsAllVsMPro[3]->Fill(dMult+0.5,two4n4n,mWeight2p);
3010   }  
3011  } // end of if(dMult>1)
3012  
3013  // 3-particle:
3014  Double_t three2n1n1n = 0.; // <cos(n(2*phi1-phi2-phi3))>
3015  Double_t three3n2n1n = 0.; // <cos(n(3*phi1-2*phi2-phi3))>
3016  Double_t three4n2n2n = 0.; // <cos(n(4*phi1-2*phi2-2*phi3))>
3017  Double_t three4n3n1n = 0.; // <cos(n(4*phi1-3*phi2-phi3))> 
3018  if(dMult>2)
3019  {
3020   three2n1n1n = (reQ2nQ1nstarQ1nstar-2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3021               - (pow(dReQ2n,2.)+pow(dImQ2n,2.))+2.*dMult)
3022               / (dMult*(dMult-1.)*(dMult-2.));                     
3023   three3n2n1n = (reQ3nQ2nstarQ1nstar-(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3024               - (pow(dReQ2n,2.)+pow(dImQ2n,2.))
3025               - (pow(dReQ1n,2.)+pow(dImQ1n,2.))+2.*dMult)
3026               / (dMult*(dMult-1.)*(dMult-2.));
3027   three4n2n2n = (reQ4nQ2nstarQ2nstar-2.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3028               - (pow(dReQ4n,2.)+pow(dImQ4n,2.))+2.*dMult)
3029               / (dMult*(dMult-1.)*(dMult-2.)); 
3030   three4n3n1n = (reQ4nQ3nstarQ1nstar-(pow(dReQ4n,2.)+pow(dImQ4n,2.))
3031               - (pow(dReQ3n,2.)+pow(dImQ3n,2.))
3032               - (pow(dReQ1n,2.)+pow(dImQ1n,2.))+2.*dMult)
3033               / (dMult*(dMult-1.)*(dMult-2.));              
3034   // Average 3-particle correlations for single event: 
3035   fIntFlowCorrelationsAllEBE->SetBinContent(6,three2n1n1n);
3036   fIntFlowCorrelationsAllEBE->SetBinContent(7,three3n2n1n);
3037   fIntFlowCorrelationsAllEBE->SetBinContent(8,three4n2n2n);
3038   fIntFlowCorrelationsAllEBE->SetBinContent(9,three4n3n1n);
3039   // Average 3-particle correlations for all events:                
3040   fIntFlowCorrelationsAllPro->Fill(5.5,three2n1n1n,dMult*(dMult-1.)*(dMult-2.)); 
3041   fIntFlowCorrelationsAllPro->Fill(6.5,three3n2n1n,dMult*(dMult-1.)*(dMult-2.));
3042   fIntFlowCorrelationsAllPro->Fill(7.5,three4n2n2n,dMult*(dMult-1.)*(dMult-2.)); 
3043   fIntFlowCorrelationsAllPro->Fill(8.5,three4n3n1n,dMult*(dMult-1.)*(dMult-2.));  
3044   // Average 3-particle correlations vs M for all events:                
3045   if(fCalculateAllCorrelationsVsM)
3046   {
3047    fIntFlowCorrelationsAllVsMPro[5]->Fill(dMult+0.5,three2n1n1n,dMult*(dMult-1.)*(dMult-2.));
3048    fIntFlowCorrelationsAllVsMPro[6]->Fill(dMult+0.5,three3n2n1n,dMult*(dMult-1.)*(dMult-2.));
3049    fIntFlowCorrelationsAllVsMPro[7]->Fill(dMult+0.5,three4n2n2n,dMult*(dMult-1.)*(dMult-2.));
3050    fIntFlowCorrelationsAllVsMPro[8]->Fill(dMult+0.5,three4n3n1n,dMult*(dMult-1.)*(dMult-2.));
3051   }    
3052  } // end of if(dMult>2)
3053  
3054  // 4-particle:
3055  Double_t four1n1n1n1n = 0.; // <cos(n(phi1+phi2-phi3-phi4))>
3056  Double_t four2n2n2n2n = 0.; // <cos(2n(phi1+phi2-phi3-phi4))>
3057  Double_t four2n1n2n1n = 0.; // <cos(n(2*phi1+phi2-2*phi3-phi4))> 
3058  Double_t four3n1n1n1n = 0.; // <cos(n(3*phi1-phi2-phi3-phi4))> 
3059  Double_t four4n2n1n1n = 0.; // <cos(n(4*phi1-2*phi2-phi3-phi4))> 
3060  Double_t four3n1n2n2n = 0.; // <cos(n(3*phi1+phi2-2*phi3-2*phi4))> 
3061  Double_t four3n1n3n1n = 0.; // <cos(n(3*phi1+phi2-3*phi3-phi4))>    
3062  if(dMult>3)
3063  {
3064   four1n1n1n1n = (2.*dMult*(dMult-3.)+pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)-4.*(dMult-2.)*(pow(dReQ1n,2.)
3065                + pow(dImQ1n,2.))-2.*reQ2nQ1nstarQ1nstar+(pow(dReQ2n,2.)+pow(dImQ2n,2.)))
3066                / (dMult*(dMult-1)*(dMult-2.)*(dMult-3.));     
3067   four2n2n2n2n = (2.*dMult*(dMult-3.)+pow((pow(dReQ2n,2.)+pow(dImQ2n,2.)),2.)-4.*(dMult-2.)*(pow(dReQ2n,2.)
3068                + pow(dImQ2n,2.))-2.*reQ4nQ2nstarQ2nstar+(pow(dReQ4n,2.)+pow(dImQ4n,2.)))
3069                / (dMult*(dMult-1)*(dMult-2.)*(dMult-3.));
3070   four2n1n2n1n = (dQ2nQ1nQ2nstarQ1nstar-2.*reQ3nQ2nstarQ1nstar-2.*reQ2nQ1nstarQ1nstar)
3071                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))
3072                - ((dMult-5.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3073                + (dMult-4.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-(pow(dReQ3n,2.)+pow(dImQ3n,2.)))
3074                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))
3075                + (dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.));
3076   four3n1n1n1n = (reQ3nQ1nstarQ1nstarQ1nstar-3.*reQ3nQ2nstarQ1nstar-3.*reQ2nQ1nstarQ1nstar
3077                + 2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+3.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3078                + 6.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-6.*dMult)
3079                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3080   four4n2n1n1n = (reQ4nQ2nstarQ1nstarQ1nstar-2.*reQ4nQ3nstarQ1nstar-reQ4nQ2nstarQ2nstar-2.*reQ3nQ2nstarQ1nstar)
3081                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))
3082                - (reQ2nQ1nstarQ1nstar-2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))-2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3083                - 3.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))
3084                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))
3085                - 6./((dMult-1.)*(dMult-2.)*(dMult-3.));
3086   four3n1n2n2n = (reQ3nQ1nQ2nstarQ2nstar-reQ4nQ2nstarQ2nstar-reQ4nQ3nstarQ1nstar-2.*reQ3nQ2nstarQ1nstar)
3087                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))
3088                - (2.*reQ2nQ1nstarQ1nstar-(pow(dReQ4n,2.)+pow(dImQ4n,2.))-2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3089                - 4.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.)))
3090                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))
3091                - 6./((dMult-1.)*(dMult-2.)*(dMult-3.)); 
3092   four3n1n3n1n = ((pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3093                - 2.*reQ4nQ3nstarQ1nstar-2.*reQ3nQ2nstarQ1nstar
3094                + pow(dReQ4n,2.)+pow(dImQ4n,2.)-(dMult-4.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3095                + pow(dReQ2n,2.)+pow(dImQ2n,2.)-(dMult-4.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3096                + dMult*(dMult-6.))
3097                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));           
3098   // Average 4-particle correlations for single event: 
3099   fIntFlowCorrelationsAllEBE->SetBinContent(11,four1n1n1n1n);
3100   fIntFlowCorrelationsAllEBE->SetBinContent(12,four2n1n2n1n);
3101   fIntFlowCorrelationsAllEBE->SetBinContent(13,four2n2n2n2n);
3102   fIntFlowCorrelationsAllEBE->SetBinContent(14,four3n1n1n1n);
3103   fIntFlowCorrelationsAllEBE->SetBinContent(15,four3n1n3n1n);
3104   fIntFlowCorrelationsAllEBE->SetBinContent(16,four3n1n2n2n);
3105   fIntFlowCorrelationsAllEBE->SetBinContent(17,four4n2n1n1n);       
3106   // Average 4-particle correlations for all events:                
3107   fIntFlowCorrelationsAllPro->Fill(10.5,four1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3108   fIntFlowCorrelationsAllPro->Fill(11.5,four2n1n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3109   fIntFlowCorrelationsAllPro->Fill(12.5,four2n2n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3110   fIntFlowCorrelationsAllPro->Fill(13.5,four3n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3111   fIntFlowCorrelationsAllPro->Fill(14.5,four3n1n3n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3112   fIntFlowCorrelationsAllPro->Fill(15.5,four3n1n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));  
3113   fIntFlowCorrelationsAllPro->Fill(16.5,four4n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));  
3114   // Average 4-particle correlations vs M for all events:                
3115   if(fCalculateAllCorrelationsVsM)
3116   {
3117    fIntFlowCorrelationsAllVsMPro[10]->Fill(dMult+0.5,four1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3118    fIntFlowCorrelationsAllVsMPro[11]->Fill(dMult+0.5,four2n1n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3119    fIntFlowCorrelationsAllVsMPro[12]->Fill(dMult+0.5,four2n2n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3120    fIntFlowCorrelationsAllVsMPro[13]->Fill(dMult+0.5,four3n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3121    fIntFlowCorrelationsAllVsMPro[14]->Fill(dMult+0.5,four3n1n3n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3122    fIntFlowCorrelationsAllVsMPro[15]->Fill(dMult+0.5,four3n1n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3123    fIntFlowCorrelationsAllVsMPro[16]->Fill(dMult+0.5,four4n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3124   }       
3125   // Store separetately <4>:
3126   fIntFlowCorrelationsEBE->SetBinContent(2,four1n1n1n1n); // <4>
3127   // Testing other multiplicity weights:
3128   Double_t mWeight4p = 0.;
3129   if(!strcmp(fMultiplicityWeight->Data(),"combinations"))
3130   {
3131    mWeight4p = dMult*(dMult-1.)*(dMult-2.)*(dMult-3.);
3132   } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))
3133     {
3134      mWeight4p = 1.;    
3135     } else if(!strcmp(fMultiplicityWeight->Data(),"multiplicity"))
3136       {
3137        mWeight4p = dMult;           
3138       }      
3139   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(2,mWeight4p); // eW_<4>
3140   fIntFlowCorrelationsPro->Fill(1.5,four1n1n1n1n,mWeight4p);
3141   fIntFlowSquaredCorrelationsPro->Fill(1.5,four1n1n1n1n*four1n1n1n1n,mWeight4p);
3142   if(fCalculateCumulantsVsM)
3143   {
3144    fIntFlowCorrelationsVsMPro[1]->Fill(dMult+0.5,four1n1n1n1n,mWeight4p);
3145    fIntFlowSquaredCorrelationsVsMPro[1]->Fill(dMult+0.5,four1n1n1n1n*four1n1n1n1n,mWeight4p);
3146   }   
3147  } // end of if(dMult>3)
3148
3149  // 5-particle:
3150  Double_t five2n1n1n1n1n = 0.; // <cos(n(2*phi1+phi2-phi3-phi4-phi5))>
3151  Double_t five2n2n2n1n1n = 0.; // <cos(n(2*phi1+2*phi2-2*phi3-phi4-phi5))>
3152  Double_t five3n1n2n1n1n = 0.; // <cos(n(3*phi1+phi2-2*phi3-phi4-phi5))>
3153  Double_t five4n1n1n1n1n = 0.; // <cos(n(4*phi1-phi2-phi3-phi4-phi5))>
3154  if(dMult>4)
3155  {            
3156   five2n1n1n1n1n = (reQ2nQ1nQ1nstarQ1nstarQ1nstar-reQ3nQ1nstarQ1nstarQ1nstar+5.*reQ3nQ2nstarQ1nstar
3157                  - 3.*(dMult-5.)*reQ2nQ1nstarQ1nstar-2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3158                  - 3.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))     
3159                  + 3.*(dMult-4.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3160                  - 3.*pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)
3161                  + 6.*(2.*dMult-5.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-6.*dMult*(dMult-4.))
3162                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3163   five2n2n2n1n1n = (reQ2nQ2nQ2nstarQ1nstarQ1nstar-reQ4nQ2nstarQ1nstarQ1nstar-2.*reQ3nQ1nQ2nstarQ2nstar
3164                  + 3.*reQ4nQ2nstarQ2nstar+8.*reQ3nQ2nstarQ1nstar+2.*reQ4nQ3nstarQ1nstar
3165                  - 2.*(dMult-6.)*reQ2nQ1nstarQ1nstar
3166                  - 2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))-4.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3167                  - pow((pow(dReQ2n,2.)+pow(dImQ2n,2.)),2.)
3168                  + 2.*(3.*dMult-10.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3169                  - 4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3170                  + 4.*(dMult-5.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-4.*dMult*(dMult-6.))
3171                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3172   five4n1n1n1n1n = (reQ4nQ1nstarQ1nstarQ1nstarQ1nstar-6.*reQ4nQ2nstarQ1nstarQ1nstar-4.*reQ3nQ1nstarQ1nstarQ1nstar
3173                  + 8.*reQ4nQ3nstarQ1nstar+3.*reQ4nQ2nstarQ2nstar+12.*reQ3nQ2nstarQ1nstar+12.*reQ2nQ1nstarQ1nstar
3174                  - 6.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))-8.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3175                  - 12.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-24.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))+24.*dMult)
3176                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3177   five3n1n2n1n1n = (reQ3nQ1nQ2nstarQ1nstarQ1nstar-reQ4nQ2nstarQ1nstarQ1nstar-reQ3nQ1nstarQ1nstarQ1nstar
3178                  - reQ3nQ1nQ2nstarQ2nstar+4.*reQ4nQ3nstarQ1nstar+reQ4nQ2nstarQ2nstar
3179                  - (2.*dMult-13.)*reQ3nQ2nstarQ1nstar+7.*reQ2nQ1nstarQ1nstar
3180                  - 2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))
3181                  + 2.*(dMult-5.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3182                  - 2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3183                  + 2.*(dMult-6.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3184                  - 2.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3185                  - pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)
3186                  + 2.*(3.*dMult-11.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-4.*dMult*(dMult-6.))
3187                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));                 
3188   // Average 5-particle correlations for single event: 
3189   fIntFlowCorrelationsAllEBE->SetBinContent(19,five2n1n1n1n1n);
3190   fIntFlowCorrelationsAllEBE->SetBinContent(20,five2n2n2n1n1n);
3191   fIntFlowCorrelationsAllEBE->SetBinContent(21,five3n1n2n1n1n);
3192   fIntFlowCorrelationsAllEBE->SetBinContent(22,five4n1n1n1n1n);        
3193   // Average 5-particle correlations for all events:                         
3194   fIntFlowCorrelationsAllPro->Fill(18.5,five2n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)); 
3195   fIntFlowCorrelationsAllPro->Fill(19.5,five2n2n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3196   fIntFlowCorrelationsAllPro->Fill(20.5,five3n1n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3197   fIntFlowCorrelationsAllPro->Fill(21.5,five4n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)); 
3198   // Average 5-particle correlations vs M for all events:                
3199   if(fCalculateAllCorrelationsVsM)
3200   {
3201    fIntFlowCorrelationsAllVsMPro[18]->Fill(dMult+0.5,five2n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3202    fIntFlowCorrelationsAllVsMPro[19]->Fill(dMult+0.5,five2n2n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3203    fIntFlowCorrelationsAllVsMPro[20]->Fill(dMult+0.5,five3n1n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3204    fIntFlowCorrelationsAllVsMPro[21]->Fill(dMult+0.5,five4n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3205   }    
3206  } // end of if(dMult>4)
3207     
3208  // 6-particle:
3209  Double_t six1n1n1n1n1n1n = 0.; // <cos(n(phi1+phi2+phi3-phi4-phi5-phi6))>
3210  Double_t six2n2n1n1n1n1n = 0.; // <cos(n(2*phi1+2*phi2-phi3-phi4-phi5-phi6))>
3211  Double_t six3n1n1n1n1n1n = 0.; // <cos(n(3*phi1+phi2-phi3-phi4-phi5-phi6))>
3212  Double_t six2n1n1n2n1n1n = 0.; // <cos(n(2*phi1+phi2+phi3-2*phi4-phi5-phi6))>
3213  if(dMult>5)
3214  {
3215   six1n1n1n1n1n1n = (pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),3.)-6.*reQ2nQ1nQ1nstarQ1nstarQ1nstar
3216                   + 4.*reQ3nQ1nstarQ1nstarQ1nstar-12.*reQ3nQ2nstarQ1nstar+18.*(dMult-4.)*reQ2nQ1nstarQ1nstar
3217                   + 9.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3218                   + 4.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))-9.*(dMult-4.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3219                   - 9.*(dMult-4.)*pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.) 
3220                   + 18.*(dMult*dMult-7.*dMult+10.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3221                   - 6.*dMult*(dMult*dMult-9.*dMult+20.))
3222                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3223   six2n1n1n2n1n1n = (dQ2nQ1nQ1nQ2nstarQ1nstarQ1nstar-4.*reQ3nQ1nQ2nstarQ1nstarQ1nstar
3224                   - 4.*reQ2nQ1nQ1nstarQ1nstarQ1nstar-2.*reQ2nQ2nQ2nstarQ1nstarQ1nstar
3225                   + 4.*reQ4nQ2nstarQ1nstarQ1nstar+4.*reQ3nQ1nQ2nstarQ2nstar+4.*reQ3nQ1nstarQ1nstarQ1nstar
3226                   - 8.*reQ4nQ3nstarQ1nstar-4.*reQ4nQ2nstarQ2nstar+4.*(2.*dMult-13.)*reQ3nQ2nstarQ1nstar
3227                   + 2.*(7.*dMult-34.)*reQ2nQ1nstarQ1nstar+4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3228                   - 4.*(dMult-7.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3229                   + 4.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))-4.*(dMult-6.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3230                   + pow((pow(dReQ2n,2.)+pow(dImQ2n,2.)),2.)+(2.*dMult*dMult-27.*dMult+76.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3231                   - (dMult-12.)*pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)
3232                   + 4.*(dMult*dMult-15.*dMult+34.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3233                   - 2.*dMult*(dMult*dMult-17.*dMult+60.))
3234                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3235   six2n2n1n1n1n1n = (reQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar-6.*reQ2nQ2nQ2nstarQ1nstarQ1nstar-reQ4nQ1nstarQ1nstarQ1nstarQ1nstar
3236                   - 8.*reQ2nQ1nQ1nstarQ1nstarQ1nstar+8.*reQ3nQ1nstarQ1nstarQ1nstar+6.*reQ4nQ2nstarQ1nstarQ1nstar
3237                   + 8.*reQ3nQ1nQ2nstarQ2nstar-40.*reQ3nQ2nstarQ1nstar-8.*reQ4nQ3nstarQ1nstar-9.*reQ4nQ2nstarQ2nstar
3238                   + 24.*(dMult-4.)*reQ2nQ1nstarQ1nstar+24.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3239                   + 6.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+16.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3240                   + 3.*pow((pow(dReQ2n,2.)+pow(dImQ2n,2.)),2.)-12.*(2.*dMult-7.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3241                   + 12.*pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)-48.*(dMult-3.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3242                   + 24.*dMult*(dMult-5.))
3243                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); 
3244   six3n1n1n1n1n1n = (reQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar-6.*reQ3nQ1nQ2nstarQ1nstarQ1nstar+6.*reQ4nQ2nstarQ1nstarQ1nstar
3245                   - reQ4nQ1nstarQ1nstarQ1nstarQ1nstar-4.*reQ2nQ1nQ1nstarQ1nstarQ1nstar+3.*reQ3nQ1nQ2nstarQ2nstar
3246                   - 4.*(dMult-5.)*reQ3nQ1nstarQ1nstarQ1nstar-14.*reQ4nQ3nstarQ1nstar
3247                   - 3.*reQ4nQ2nstarQ2nstar+4.*(3.*dMult-17.)*reQ3nQ2nstarQ1nstar+12.*(dMult-6.)*reQ2nQ1nstarQ1nstar
3248                   + 12.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))  
3249                   + 8.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ3n,2.)+pow(dImQ3n,2.))  
3250                   + 6.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))-8.*(dMult-5.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.)) 
3251                   - 12.*(dMult-5.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-48.*(dMult-3.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3252                   + 12.*pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)+24.*dMult*(dMult-5.))
3253                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3254   // Average 6-particle correlations for single event: 
3255   fIntFlowCorrelationsAllEBE->SetBinContent(24,six1n1n1n1n1n1n);
3256   fIntFlowCorrelationsAllEBE->SetBinContent(25,six2n1n1n2n1n1n);
3257   fIntFlowCorrelationsAllEBE->SetBinContent(26,six2n2n1n1n1n1n);
3258   fIntFlowCorrelationsAllEBE->SetBinContent(27,six3n1n1n1n1n1n);
3259   // Average 6-particle correlations for all events:         
3260   fIntFlowCorrelationsAllPro->Fill(23.5,six1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); 
3261   fIntFlowCorrelationsAllPro->Fill(24.5,six2n1n1n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); 
3262   fIntFlowCorrelationsAllPro->Fill(25.5,six2n2n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3263   fIntFlowCorrelationsAllPro->Fill(26.5,six3n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); 
3264   // Average 6-particle correlations vs M for all events:                
3265   if(fCalculateAllCorrelationsVsM)
3266   {
3267    fIntFlowCorrelationsAllVsMPro[23]->Fill(dMult+0.5,six1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3268    fIntFlowCorrelationsAllVsMPro[24]->Fill(dMult+0.5,six2n1n1n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3269    fIntFlowCorrelationsAllVsMPro[25]->Fill(dMult+0.5,six2n2n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3270    fIntFlowCorrelationsAllVsMPro[26]->Fill(dMult+0.5,six3n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3271   }    
3272   // Store separetately <6>:
3273   fIntFlowCorrelationsEBE->SetBinContent(3,six1n1n1n1n1n1n); // <6>
3274   // Testing other multiplicity weights:
3275   Double_t mWeight6p = 0.;
3276   if(!strcmp(fMultiplicityWeight->Data(),"combinations"))
3277   {
3278    mWeight6p = dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.);
3279   } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))
3280     {
3281      mWeight6p = 1.;    
3282     } else if(!strcmp(fMultiplicityWeight->Data(),"multiplicity"))
3283       {
3284        mWeight6p = dMult;           
3285       }
3286   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(3,mWeight6p); // eW_<6>
3287   fIntFlowCorrelationsPro->Fill(2.5,six1n1n1n1n1n1n,mWeight6p);
3288   fIntFlowSquaredCorrelationsPro->Fill(2.5,six1n1n1n1n1n1n*six1n1n1n1n1n1n,mWeight6p);
3289   if(fCalculateCumulantsVsM)
3290   {
3291    fIntFlowCorrelationsVsMPro[2]->Fill(dMult+0.5,six1n1n1n1n1n1n,mWeight6p);
3292    fIntFlowSquaredCorrelationsVsMPro[2]->Fill(dMult+0.5,six1n1n1n1n1n1n*six1n1n1n1n1n1n,mWeight6p);
3293   }    
3294  } // end of if(dMult>5)
3295  
3296  // 7-particle:
3297  Double_t seven2n1n1n1n1n1n1n = 0.; // <cos(n(2*phi1+phi2+phi3-phi4-phi5-phi6-phi7))>
3298  if(dMult>6)
3299  {
3300   seven2n1n1n1n1n1n1n = (reQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar-4.*pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),3.)
3301                       - reQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar-2.*reQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar
3302                       + 9.*reQ2nQ2nQ2nstarQ1nstarQ1nstar+20.*reQ3nQ1nQ2nstarQ1nstarQ1nstar 
3303                       + 2.*reQ4nQ1nstarQ1nstarQ1nstarQ1nstar-8.*(dMult-8.)*reQ2nQ1nQ1nstarQ1nstarQ1nstar
3304                       - 18.*reQ4nQ2nstarQ1nstarQ1nstar-14.*reQ3nQ1nQ2nstarQ2nstar
3305                       + 8.*(dMult-7.)*reQ3nQ1nstarQ1nstarQ1nstar+28.*reQ4nQ3nstarQ1nstar
3306                       + 12.*reQ4nQ2nstarQ2nstar-8.*(5.*dMult-31.)*reQ3nQ2nstarQ1nstar      
3307                       + 12.*(dMult*dMult-15.*dMult+46.)*reQ2nQ1nstarQ1nstar
3308                       - 16.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3309                       - 6.*pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),2.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3310                       - 3.*pow(pow(dReQ2n,2.)+pow(dImQ2n,2.),2.)
3311                       + 12.*(2.*dMult-13.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3312                       - 12.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+16.*(dMult-6.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3313                       - 12.*(dMult-8.)*(dMult-4.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3314                       + 12.*(3.*dMult-14.)*pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),2.)
3315                       - 24.*(3.*dMult-7.)*(dMult-6.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3316                       + 24.*dMult*(dMult-5.)*(dMult-6.))
3317                       / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.));   
3318   // Average 7-particle correlations for single event: 
3319   fIntFlowCorrelationsAllEBE->SetBinContent(29,seven2n1n1n1n1n1n1n);       
3320   // Average 7-particle correlations for all events:                      
3321   fIntFlowCorrelationsAllPro->Fill(28.5,seven2n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)
3322                                                                  *(dMult-4.)*(dMult-5.)*(dMult-6.));
3323   // Average 7-particle correlations vs M for all events:                
3324   if(fCalculateAllCorrelationsVsM)
3325   {
3326    fIntFlowCorrelationsAllVsMPro[28]->Fill(dMult+0.5,seven2n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)
3327                                                                               *(dMult-4.)*(dMult-5.)*(dMult-6.));
3328   }    
3329  } // end of if(dMult>6)
3330  
3331  // 8-particle:
3332  Double_t eight1n1n1n1n1n1n1n1n = 0.; // <cos(n(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>
3333  if(dMult>7)
3334  {  
3335   eight1n1n1n1n1n1n1n1n = (pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),4.)-12.*reQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar
3336                         + 16.*reQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar+6.*reQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar
3337                         - 12.*reQ4nQ1nstarQ1nstarQ1nstarQ1nstar-36.*reQ2nQ2nQ2nstarQ1nstarQ1nstar
3338                         - 96.*reQ3nQ1nQ2nstarQ1nstarQ1nstar
3339                         + 72.*reQ4nQ2nstarQ1nstarQ1nstar+48.*reQ3nQ1nQ2nstarQ2nstar
3340                         - 64.*(dMult-6.)*reQ3nQ1nstarQ1nstarQ1nstar
3341                         + 96.*(dMult-6.)*reQ2nQ1nQ1nstarQ1nstarQ1nstar
3342                         - 96.*reQ4nQ3nstarQ1nstar-36.*reQ4nQ2nstarQ2nstar
3343                         + 192.*(dMult-6.)*reQ3nQ2nstarQ1nstar
3344                         - 144.*(dMult-7.)*(dMult-4.)*reQ2nQ1nstarQ1nstar
3345                         + 64.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3346                         - 144.*(dMult-6.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3347                         + 72.*(dMult-7.)*(dMult-4.)*(pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),2.)+pow(dReQ2n,2.)+pow(dImQ2n,2.))
3348                         - 96.*(dMult-7.)*(dMult-6.)*(dMult-2.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3349                         + 36.*pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),2.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3350                         + 9.*pow(pow(dReQ2n,2.)+pow(dImQ2n,2.),2.)
3351                         - 64.*(dMult-6.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3352                         + 36.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))
3353                         - 16.*(dMult-6.)*pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),3.)
3354                         + 24.*dMult*(dMult-7.)*(dMult-6.)*(dMult-5.))
3355                         / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));   
3356   // Average 8-particle correlations for single event: 
3357   fIntFlowCorrelationsAllEBE->SetBinContent(31,eight1n1n1n1n1n1n1n1n);      
3358   // Average 8-particle correlations for all events:                       
3359   fIntFlowCorrelationsAllPro->Fill(30.5,eight1n1n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)
3360                                                                    *(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));
3361   // Average 8-particle correlations vs M for all events:                
3362   if(fCalculateAllCorrelationsVsM)
3363   {
3364    fIntFlowCorrelationsAllVsMPro[30]->Fill(dMult+0.5,eight1n1n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)
3365                                                                                 *(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));
3366   }     
3367   // Store separetately <8>:
3368   fIntFlowCorrelationsEBE->SetBinContent(4,eight1n1n1n1n1n1n1n1n); // <8>
3369   // Testing other multiplicity weights:
3370   Double_t mWeight8p = 0.;
3371   if(!strcmp(fMultiplicityWeight->Data(),"combinations"))
3372   {
3373    mWeight8p = dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.);
3374   } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))
3375     {
3376      mWeight8p = 1.;    
3377     } else if(!strcmp(fMultiplicityWeight->Data(),"multiplicity"))
3378       {
3379        mWeight8p = dMult;           
3380       }        
3381   fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(4,mWeight8p); // eW_<8>
3382   fIntFlowCorrelationsPro->Fill(3.5,eight1n1n1n1n1n1n1n1n,mWeight8p);
3383   fIntFlowSquaredCorrelationsPro->Fill(3.5,eight1n1n1n1n1n1n1n1n*eight1n1n1n1n1n1n1n1n,mWeight8p);  
3384   if(fCalculateCumulantsVsM)
3385   {
3386    fIntFlowCorrelationsVsMPro[3]->Fill(dMult+0.5,eight1n1n1n1n1n1n1n1n,mWeight8p);
3387    fIntFlowSquaredCorrelationsVsMPro[3]->Fill(dMult+0.5,eight1n1n1n1n1n1n1n1n*eight1n1n1n1n1n1n1n1n,mWeight8p);
3388   }    
3389  } // end of if(dMult>7) 
3390  
3391  // EXTRA correlations for v3{5} study:
3392  // 4-particle:
3393  Double_t four4n2n3n3n = 0.; // <cos(n(4*phi1+2*phi2-3*phi3-3*phi4))>
3394  if(dMult>3.)
3395  {
3396   four4n2n3n3n = (reQ4nQ2nQ3nstarQ3nstar-reQ6nQ4nstarQ2nstar-reQ6nQ3nstarQ3nstar
3397                - 2.*reQ4nQ3nstarQ1nstar-2.*reQ3nQ2nstarQ1nstar
3398                + (pow(dReQ6n,2.)+pow(dImQ6n,2.))+2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))
3399                + 2.*(2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3400                + (pow(dReQ1n,2.)+pow(dImQ1n,2.))-3.*dMult))
3401                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));               
3402   fIntFlowCorrelationsAllPro->Fill(32.5,four4n2n3n3n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3403   // Average 4-particle correlations vs M for all events:                
3404   if(fCalculateAllCorrelationsVsM)
3405   {
3406    fIntFlowCorrelationsAllVsMPro[32]->Fill(dMult+0.5,four4n2n3n3n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3407   }    
3408  } // end of if(dMult>3.)
3409  
3410  // 5-particle:
3411  Double_t five3n3n2n2n2n = 0.; // <cos(n(3*phi1+3*phi2-2*phi3-2*phi4-2*phi5))>                                    
3412  if(dMult>4.)
3413  {
3414   five3n3n2n2n2n = (reQ3nQ3nQ2nstarQ2nstarQ2nstar-reQ6nQ2nstarQ2nstarQ2nstar-3.*reQ4nQ2nQ3nstarQ3nstar 
3415                  - 6.*reQ3nQ1nQ2nstarQ2nstar+2.*reQ6nQ3nstarQ3nstar+3.*reQ6nQ4nstarQ2nstar
3416                  + 6.*reQ4nQ3nstarQ1nstar+6.*reQ4nQ2nstarQ2nstar
3417                  + 12.*reQ3nQ2nstarQ1nstar+6.*reQ2nQ1nstarQ1nstar
3418                  - 2.*((pow(dReQ6n,2.)+pow(dImQ6n,2.)) 
3419                  + 3.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))
3420                  + 6.*(pow(dReQ3n,2.)+pow(dImQ3n,2.)) 
3421                  + 9.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3422                  + 6.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-12.*dMult))
3423                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3424   fIntFlowCorrelationsAllPro->Fill(33.5,five3n3n2n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3425   if(fCalculateAllCorrelationsVsM)
3426   {
3427    fIntFlowCorrelationsAllVsMPro[33]->Fill(dMult+0.5,five3n3n2n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3428   }     
3429  } // end of if(dMult>4.)
3430  
3431  // EXTRA correlations for Teaney-Yan study: 
3432  // 2-particle:
3433  Double_t two5n5n = 0.; // <cos(5n(phi1-phi2))>
3434  Double_t two6n6n = 0.; // <cos(6n(phi1-phi2))> 
3435  if(dMult>1)
3436  {
3437   two5n5n = (pow(dReQ5n,2.)+pow(dImQ5n,2.)-dMult)/(dMult*(dMult-1.)); 
3438   two6n6n = (pow(dReQ6n,2.)+pow(dImQ6n,2.)-dMult)/(dMult*(dMult-1.));        
3439   // Average 2-particle correlations for all events:      
3440   fIntFlowCorrelationsAllPro->Fill(34.5,two5n5n,dMult*(dMult-1.));
3441   fIntFlowCorrelationsAllPro->Fill(35.5,two6n6n,dMult*(dMult-1.)); 
3442   if(fCalculateAllCorrelationsVsM)
3443   {
3444    fIntFlowCorrelationsAllVsMPro[34]->Fill(dMult+0.5,two5n5n,dMult*(dMult-1.));
3445    fIntFlowCorrelationsAllVsMPro[35]->Fill(dMult+0.5,two6n6n,dMult*(dMult-1.));
3446   }       
3447  } // end of if(dMult>1)
3448  
3449  // 3-particle:
3450  Double_t three5n3n2n = 0.; // <cos(n(5*phi1-3*phi2-2*phi3)> 
3451  Double_t three5n4n1n = 0.; // <cos(n(5*phi1-4*phi2-1*phi3)> 
3452  Double_t three6n3n3n = 0.; // <cos(n(6*phi1-3*phi2-3*phi3)> 
3453  Double_t three6n4n2n = 0.; // <cos(n(6*phi1-4*phi2-2*phi3)> 
3454  Double_t three6n5n1n = 0.; // <cos(n(6*phi1-5*phi2-1*phi3)> 
3455  if(dMult>2)
3456  {
3457   three5n3n2n = (reQ5nQ3nstarQ2nstar-(pow(dReQ5n,2.)+pow(dImQ5n,2.))
3458               - (pow(dReQ3n,2.)+pow(dImQ3n,2.))
3459               - (pow(dReQ2n,2.)+pow(dImQ2n,2.))+2.*dMult)
3460               / (dMult*(dMult-1.)*(dMult-2.));           
3461   three5n4n1n = (reQ5nQ4nstarQ1nstar-(pow(dReQ5n,2.)+pow(dImQ5n,2.))
3462               - (pow(dReQ4n,2.)+pow(dImQ4n,2.))
3463               - (pow(dReQ1n,2.)+pow(dImQ1n,2.))+2.*dMult)
3464               / (dMult*(dMult-1.)*(dMult-2.));                          
3465   three6n3n3n = (reQ6nQ3nstarQ3nstar-2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3466               - (pow(dReQ6n,2.)+pow(dImQ6n,2.))+2.*dMult)
3467               / (dMult*(dMult-1.)*(dMult-2.)); 
3468   three6n4n2n = (reQ6nQ4nstarQ2nstar-(pow(dReQ6n,2.)+pow(dImQ6n,2.))
3469               - (pow(dReQ4n,2.)+pow(dImQ4n,2.))
3470               - (pow(dReQ2n,2.)+pow(dImQ2n,2.))+2.*dMult)
3471               / (dMult*(dMult-1.)*(dMult-2.));
3472   three6n5n1n = (reQ6nQ5nstarQ1nstar-(pow(dReQ6n,2.)+pow(dImQ6n,2.))
3473               - (pow(dReQ5n,2.)+pow(dImQ5n,2.))
3474               - (pow(dReQ1n,2.)+pow(dImQ1n,2.))+2.*dMult)
3475               / (dMult*(dMult-1.)*(dMult-2.));            
3476   // Average 3-particle correlations for all events:      
3477   fIntFlowCorrelationsAllPro->Fill(36.5,three5n3n2n,dMult*(dMult-1.)*(dMult-2.)); // <<cos(n(5*phi1-3*phi2-2*phi3)>> 
3478   fIntFlowCorrelationsAllPro->Fill(37.5,three5n4n1n,dMult*(dMult-1.)*(dMult-2.)); // <<cos(n(5*phi1-4*phi2-1*phi3)>> 
3479   fIntFlowCorrelationsAllPro->Fill(38.5,three6n3n3n,dMult*(dMult-1.)*(dMult-2.)); // <<cos(n(6*phi1-3*phi2-3*phi3)>> 
3480   fIntFlowCorrelationsAllPro->Fill(39.5,three6n4n2n,dMult*(dMult-1.)*(dMult-2.)); // <<cos(n(6*phi1-4*phi2-2*phi3)>>
3481   fIntFlowCorrelationsAllPro->Fill(40.5,three6n5n1n,dMult*(dMult-1.)*(dMult-2.)); // <<cos(n(6*phi1-5*phi2-1*phi3)>>
3482   if(fCalculateAllCorrelationsVsM)
3483   {
3484    fIntFlowCorrelationsAllVsMPro[36]->Fill(dMult+0.5,three5n3n2n,dMult*(dMult-1.)*(dMult-2.));
3485    fIntFlowCorrelationsAllVsMPro[37]->Fill(dMult+0.5,three5n4n1n,dMult*(dMult-1.)*(dMult-2.));
3486    fIntFlowCorrelationsAllVsMPro[38]->Fill(dMult+0.5,three6n3n3n,dMult*(dMult-1.)*(dMult-2.));
3487    fIntFlowCorrelationsAllVsMPro[39]->Fill(dMult+0.5,three6n4n2n,dMult*(dMult-1.)*(dMult-2.));
3488    fIntFlowCorrelationsAllVsMPro[40]->Fill(dMult+0.5,three6n5n1n,dMult*(dMult-1.)*(dMult-2.));
3489   }       
3490  } // end of if(dMult>2)
3491  
3492  // 4-particle:
3493  Double_t four6n3n2n1n = 0.; // <cos(n(6*phi1-3*phi2-2*phi3-1*phi4)>
3494  Double_t four3n2n3n2n = 0.; // <cos(n(3*phi1+2*phi2-3*phi3-2*phi4)>
3495  Double_t four4n1n3n2n = 0.; // <cos(n(4*phi1+1*phi2-3*phi3-2*phi4)> 
3496  Double_t four3n3n3n3n = 0.; // <cos(3n(phi1+phi2-phi3-phi4))> 
3497  //Double_t four4n2n3n3n = 0.; // <cos(n(4*phi1+2*phi2-3*phi3-3*phi4)> // I already have this one above
3498  Double_t four5n1n3n3n = 0.; // <cos(n(5*phi1+1*phi2-3*phi3-3*phi4)>
3499  Double_t four4n2n4n2n = 0.; // <cos(n(4*phi1+2*phi2-4*phi3-2*phi4)> 
3500  Double_t four5n1n4n2n = 0.; // <cos(n(5*phi1+1*phi2-4*phi3-2*phi4)> 
3501  Double_t four5n3n1n1n = 0.; // <cos(n(5*phi1-3*phi2-1*phi3-1*phi4)> 
3502  Double_t four5n2n2n1n = 0.; // <cos(n(5*phi1-2*phi2-2*phi3-1*phi4)>
3503  Double_t four5n1n5n1n = 0.; // <cos(n(5*phi1+1*phi2-5*phi3-1*phi4)>
3504  Double_t four6n4n1n1n = 0.; // <cos(n(6*phi1-4*phi2-1*phi3-1*phi4)>
3505  Double_t four6n2n2n2n = 0.; // <cos(n(6*phi1-2*phi2-2*phi3-2*phi4)>
3506  if(dMult>3)
3507  {
3508   four6n3n2n1n = (reQ6nQ3nstarQ2nstarQ1nstar-reQ6nQ4nstarQ2nstar-reQ6nQ3nstarQ3nstar-reQ6nQ5nstarQ1nstar
3509                - reQ5nQ3nstarQ2nstar-reQ4nQ3nstarQ1nstar-reQ3nQ2nstarQ1nstar
3510                + 2.*(pow(dReQ6n,2.)+pow(dImQ6n,2.))+pow(dReQ5n,2.)+pow(dImQ5n,2.)
3511                + pow(dReQ4n,2.)+pow(dImQ4n,2.)+3.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3512                + 2.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))+2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-6.*dMult)
3513                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3514   four3n2n3n2n = (dQ3nQ2nQ3nstarQ2nstar-2.*reQ5nQ3nstarQ2nstar-2.*reQ3nQ2nstarQ1nstar
3515                + pow(dReQ5n,2.)+pow(dImQ5n,2.)+pow(dReQ1n,2.)+pow(dImQ1n,2.)               
3516                -(dMult-4.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.)+pow(dReQ2n,2.)+pow(dImQ2n,2.))
3517                + dMult*(dMult-6.))
3518                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));     
3519   four4n1n3n2n = (reQ4nQ1nQ3nstarQ2nstar-reQ5nQ3nstarQ2nstar-reQ5nQ4nstarQ1nstar-reQ4nQ3nstarQ1nstar
3520                - reQ4nQ2nstarQ2nstar-reQ3nQ2nstarQ1nstar-reQ2nQ1nstarQ1nstar
3521                + pow(dReQ5n,2.)+pow(dImQ5n,2.)+2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))
3522                + 2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+3.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3523                + 3.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-6.*dMult) 
3524                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));                             
3525   four3n3n3n3n = (2.*dMult*(dMult-3.)+pow((pow(dReQ3n,2.)+pow(dImQ3n,2.)),2.)-4.*(dMult-2.)*(pow(dReQ3n,2.)
3526                + pow(dImQ3n,2.))-2.*reQ6nQ3nstarQ3nstar+(pow(dReQ6n,2.)+pow(dImQ6n,2.)))
3527                / (dMult*(dMult-1)*(dMult-2.)*(dMult-3.));   
3528   //four4n2n3n3n = ; // I already have this one above
3529   four5n1n3n3n = (reQ5nQ1nQ3nstarQ3nstar-reQ6nQ5nstarQ1nstar-reQ6nQ3nstarQ3nstar-2.*reQ5nQ3nstarQ2nstar
3530                - 2.*reQ3nQ2nstarQ1nstar+pow(dReQ6n,2.)+pow(dImQ6n,2.)+2.*(pow(dReQ5n,2.)+pow(dImQ5n,2.))
3531                + 4.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+2.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3532                + 2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-6.*dMult)                                  
3533                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));   
3534   four4n2n4n2n = (dQ4nQ2nQ4nstarQ2nstar-2.*reQ6nQ4nstarQ2nstar-2.*reQ4nQ2nstarQ2nstar)
3535                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))
3536                - ((dMult-5.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3537                + (dMult-4.)*(pow(dReQ4n,2.)+pow(dImQ4n,2.))-(pow(dReQ6n,2.)+pow(dImQ6n,2.)))
3538                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))
3539                + (dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.)); 
3540   four5n1n4n2n = (reQ5nQ1nQ4nstarQ2nstar-reQ6nQ5nstarQ1nstar-reQ6nQ4nstarQ2nstar-reQ5nQ4nstarQ1nstar
3541                - reQ5nQ3nstarQ2nstar-reQ4nQ3nstarQ1nstar-reQ2nQ1nstarQ1nstar+pow(dReQ6n,2.)+pow(dImQ6n,2.)
3542                + 2.*(pow(dReQ5n,2.)+pow(dImQ5n,2.))+2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))
3543                + pow(dReQ3n,2.)+pow(dImQ3n,2.)+2.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3544                + 3.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-6.*dMult)
3545                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));     
3546   four5n3n1n1n = (reQ5nQ3nstarQ1nstarQ1nstar-2.*reQ5nQ4nstarQ1nstar-reQ5nQ3nstarQ2nstar-2.*reQ4nQ3nstarQ1nstar
3547                - reQ2nQ1nstarQ1nstar+2.*(pow(dReQ5n,2.)+pow(dImQ5n,2.))+2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))
3548                + 2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+pow(dReQ2n,2.)+pow(dImQ2n,2.)
3549                + 4.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-6.*dMult) 
3550                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));                    
3551   four5n2n2n1n = (reQ5nQ2nstarQ2nstarQ1nstar-reQ5nQ4nstarQ1nstar-2.*reQ5nQ3nstarQ2nstar-reQ4nQ2nstarQ2nstar
3552                - 2.*reQ3nQ2nstarQ1nstar+2.*(pow(dReQ5n,2.)+pow(dImQ5n,2.))+pow(dReQ4n,2.)+pow(dImQ4n,2.)
3553                + 2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+4.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3554                + 2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-6.*dMult)
3555                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));   
3556   four5n1n5n1n = (dQ5nQ1nQ5nstarQ1nstar-2.*reQ6nQ5nstarQ1nstar-2.*reQ5nQ4nstarQ1nstar
3557                + pow(dReQ6n,2.)+pow(dImQ6n,2.)-(dMult-4.)*(pow(dReQ5n,2.)+pow(dImQ5n,2.))
3558                + pow(dReQ4n,2.)+pow(dImQ4n,2.)-(dMult-4.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))+dMult*(dMult-6.))  
3559                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));    
3560                               
3561   // TBI: Recursive formula needed:
3562   four6n4n1n1n = (reQ6nQ4nstarQ1nstarQ1nstar
3563                - dMult*(dMult-1.)*(dMult-2.)*(three2n1n1n+2.*three5n4n1n+2.*three6n5n1n+three6n4n2n)
3564                - dMult*(dMult-1.)*(2.*two1n1n+1.*two4n4n+1.*two6n6n+1.*two2n2n+2.*two5n5n)
3565                - 1.*dMult)
3566                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3567   
3568   four6n2n2n2n = (reQ6nQ2nstarQ2nstarQ2nstar-3.*reQ6nQ4nstarQ2nstar-3.*reQ4nQ2nstarQ2nstar
3569                + 2.*(pow(dReQ6n,2.)+pow(dImQ6n,2.))+3.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))
3570                + 6.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))-6.*dMult)
3571                / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3572   // Average 4-particle correlations for all events:      
3573   fIntFlowCorrelationsAllPro->Fill(41.5,four6n3n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3574   fIntFlowCorrelationsAllPro->Fill(42.5,four3n2n3n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3575   fIntFlowCorrelationsAllPro->Fill(43.5,four4n1n3n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3576   fIntFlowCorrelationsAllPro->Fill(44.5,four3n3n3n3n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3577   //fIntFlowCorrelationsAllPro->Fill(45.5,four4n2n3n3n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)); // I already have this one above
3578   fIntFlowCorrelationsAllPro->Fill(46.5,four5n1n3n3n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3579   fIntFlowCorrelationsAllPro->Fill(47.5,four4n2n4n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3580   fIntFlowCorrelationsAllPro->Fill(48.5,four5n1n4n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3581   fIntFlowCorrelationsAllPro->Fill(49.5,four5n3n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3582   fIntFlowCorrelationsAllPro->Fill(50.5,four5n2n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3583   fIntFlowCorrelationsAllPro->Fill(51.5,four5n1n5n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3584   fIntFlowCorrelationsAllPro->Fill(58.5,four6n4n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3585   fIntFlowCorrelationsAllPro->Fill(59.5,four6n2n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3586   if(fCalculateAllCorrelationsVsM)
3587   {
3588    fIntFlowCorrelationsAllVsMPro[41]->Fill(dMult+0.5,four6n3n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3589    fIntFlowCorrelationsAllVsMPro[42]->Fill(dMult+0.5,four3n2n3n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3590    fIntFlowCorrelationsAllVsMPro[43]->Fill(dMult+0.5,four4n1n3n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3591    fIntFlowCorrelationsAllVsMPro[44]->Fill(dMult+0.5,four3n3n3n3n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3592    //fIntFlowCorrelationsAllVsMPro[45]->Fill(dMult+0.5,four4n2n3n3n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3593    fIntFlowCorrelationsAllVsMPro[46]->Fill(dMult+0.5,four5n1n3n3n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3594    fIntFlowCorrelationsAllVsMPro[47]->Fill(dMult+0.5,four4n2n4n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3595    fIntFlowCorrelationsAllVsMPro[48]->Fill(dMult+0.5,four5n1n4n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3596    fIntFlowCorrelationsAllVsMPro[49]->Fill(dMult+0.5,four5n3n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3597    fIntFlowCorrelationsAllVsMPro[50]->Fill(dMult+0.5,four5n2n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3598    fIntFlowCorrelationsAllVsMPro[51]->Fill(dMult+0.5,four5n1n5n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3599    fIntFlowCorrelationsAllVsMPro[58]->Fill(dMult+0.5,four6n4n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3600    fIntFlowCorrelationsAllVsMPro[59]->Fill(dMult+0.5,four6n2n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
3601   }       
3602  } // end of if(dMult>3)
3603
3604  // 5-particle:
3605  Double_t five3n3n3n2n1n = 0.; // <cos(n(3*phi1+3*phi2-3*phi3-2*phi4-1*phi5)>
3606  Double_t five4n2n3n2n1n = 0.; // <cos(n(4*phi1+2*phi2-3*phi3-2*phi4-1*phi5)>
3607  Double_t five3n2n3n1n1n = 0.; // <cos(n(3*phi1+2*phi2-3*phi3-1*phi4-1*phi5)>
3608  Double_t five3n2n2n2n1n = 0.; // <cos(n(3*phi1+2*phi2-2*phi3-2*phi4-1*phi5)>
3609  Double_t five5n1n3n2n1n = 0.; // <cos(n(5*phi1+1*phi2-3*phi3-2*phi4-1*phi5)>
3610  Double_t five6n2n2n1n1n = 0.; // <cos(n(6*phi1-2*phi2-2*phi3-1*phi4-1*phi5)>
3611  Double_t five4n1n1n3n3n = 0.; // <cos(n(4*phi1+1*phi2+1*phi3-3*phi4-3*phi5)>
3612  if(dMult>4)
3613  { 
3614   five3n3n3n2n1n = (reQ3nQ3nQ3nstarQ2nstarQ1nstar-reQ6nQ3nstarQ2nstarQ1nstar-reQ5nQ1nQ3nstarQ3nstar-reQ4nQ2nQ3nstarQ3nstar
3615                  + reQ6nQ5nstarQ1nstar+reQ6nQ4nstarQ2nstar+3.*reQ6nQ3nstarQ3nstar+4.*reQ5nQ3nstarQ2nstar+4.*reQ4nQ3nstarQ1nstar
3616                  - 2.*(dMult-6.)*reQ3nQ2nstarQ1nstar-2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.)) 
3617                  - 2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3618                  - 2.*(pow(dReQ6n,2.)+pow(dImQ6n,2.))-2.*(pow(dReQ5n,2.)+pow(dImQ5n,2.))
3619                  - 2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+2.*(3.*dMult-10.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3620                  - pow((pow(dReQ3n,2.)+pow(dImQ3n,2.)),2.)+2.*(dMult-5.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3621                  + 2.*(dMult-5.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-4.*dMult*(dMult-6.))
3622                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));                                  
3623   five4n2n3n2n1n = (reQ4nQ2nQ3nstarQ2nstarQ1nstar-reQ6nQ3nstarQ2nstarQ1nstar-reQ5nQ1nQ4nstarQ2nstar
3624                  - reQ4nQ2nQ3nstarQ3nstar-reQ4nQ1nQ3nstarQ2nstar-reQ4nQ2nstarQ1nstarQ1nstar
3625                  - reQ3nQ1nQ2nstarQ2nstar-(pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3626                  + 3.*reQ6nQ4nstarQ2nstar+reQ6nQ5nstarQ1nstar+reQ6nQ3nstarQ3nstar+reQ5nQ4nstarQ1nstar
3627                  + 3.*reQ5nQ3nstarQ2nstar-(dMult-7.)*reQ4nQ3nstarQ1nstar+3.*reQ4nQ2nstarQ2nstar+7.*reQ3nQ2nstarQ1nstar
3628                  + 4.*reQ2nQ1nstarQ1nstar-(pow(dReQ4n,2.)+pow(dImQ4n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3629                  - (pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3630                  - 2.*(pow(dReQ6n,2.)+pow(dImQ6n,2.))-2.*(pow(dReQ5n,2.)+pow(dImQ5n,2.))
3631                  + (dMult-8.)*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+(dMult-10.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3632                  + 2.*(dMult-7.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))+(dMult-12.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3633                  - 2.*dMult*(dMult-12.))
3634                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));   
3635   five3n2n3n1n1n = (reQ3nQ2nQ3nstarQ1nstarQ1nstar-reQ5nQ3nstarQ1nstarQ1nstar-2.*reQ4nQ1nQ3nstarQ2nstar-reQ3nQ1nstarQ1nstarQ1nstar
3636                  - 2.*reQ3nQ1nQ2nstarQ2nstar+2.*reQ5nQ4nstarQ1nstar+3.*reQ5nQ3nstarQ2nstar+6.*reQ4nQ3nstarQ1nstar
3637                  + 2.*reQ4nQ2nstarQ2nstar+9.*reQ3nQ2nstarQ1nstar-(dMult-8.)*reQ2nQ1nstarQ1nstar
3638                  - (pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.)) 
3639                  - 2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.)) 
3640                  - 2.*(pow(dReQ5n,2.)+pow(dImQ5n,2.))-4.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))
3641                  + 2.*(dMult-6.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))+(dMult-12.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3642                  + 2.*(dMult-9.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-2.*dMult*(dMult-12.))
3643                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3644   five3n2n2n2n1n = (reQ3nQ2nQ2nstarQ2nstarQ1nstar-reQ5nQ2nstarQ2nstarQ1nstar-reQ4nQ1nQ3nstarQ2nstar-reQ3nQ1nQ2nstarQ2nstar
3645                  - 2.*(pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))+reQ5nQ4nstarQ1nstar
3646                  + 4.*reQ5nQ3nstarQ2nstar+reQ4nQ3nstarQ1nstar+3.*reQ4nQ2nstarQ2nstar-2.*(dMult-6.)*reQ3nQ2nstarQ1nstar
3647                  + 4.*reQ2nQ1nstarQ1nstar-2.*(pow(dReQ5n,2.)+pow(dImQ5n,2.))
3648                  - 2.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+2.*(dMult-5.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3649                  - 2.*(pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3650                  - pow((pow(dReQ2n,2.)+pow(dImQ2n,2.)),2.)+2.*(3.*dMult-10.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3651                  + 2.*(dMult-6.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))-4.*dMult*(dMult-6.))
3652                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)); 
3653   five5n1n3n2n1n = (reQ5nQ1nQ3nstarQ2nstarQ1nstar-reQ6nQ3nstarQ2nstarQ1nstar-reQ5nQ1nQ4nstarQ2nstar-reQ5nQ1nQ3nstarQ3nstar
3654                  - reQ4nQ1nQ3nstarQ2nstar-reQ5nQ3nstarQ1nstarQ1nstar-reQ5nQ2nstarQ2nstarQ1nstar 
3655                  + 3.*reQ6nQ5nstarQ1nstar+reQ6nQ4nstarQ2nstar+reQ6nQ3nstarQ3nstar+4.*reQ5nQ4nstarQ1nstar
3656                  - (dMult-7.)*reQ5nQ3nstarQ2nstar+4.*reQ4nQ3nstarQ1nstar+reQ4nQ2nstarQ2nstar+6.*reQ3nQ2nstarQ1nstar
3657                  + 3.*reQ2nQ1nstarQ1nstar-(pow(dReQ5n,2.)+pow(dImQ5n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3658                  - (pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3659                  - (pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3660                  - 2.*(pow(dReQ6n,2.)+pow(dImQ6n,2.))+(dMult-8.)*(pow(dReQ5n,2.)+pow(dImQ5n,2.))  
3661                  - 4.*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+(dMult-10.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3662                  + (dMult-10.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))+2.*(dMult-7.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3663                  - 2.*dMult*(dMult-12.))
3664                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));      
3665  
3666   // Peter Jochumzsen:
3667   five6n2n2n1n1n = (reQ6nQ2nstarQ2nstarQ1nstarQ1nstar
3668                  - 12.*pow(dReQ1n,2.)-12.*pow(dImQ1n,2.)
3669                  - 14.*pow(dReQ2n,2.)-14.*pow(dImQ2n,2.)
3670                  - 8.*pow(dReQ3n,2.)-8.*pow(dImQ3n,2.)
3671                  - 6.*pow(dReQ4n,2.)-6.*pow(dImQ4n,2.)
3672                  - 4.*pow(dReQ5n,2.)-4.*pow(dImQ5n,2.)
3673                  - 6.*pow(dReQ6n,2.)-6.*pow(dImQ6n,2.)
3674                  + 2.*reQ2nQ1nstarQ1nstar + 8.*reQ3nQ2nstarQ1nstar
3675                  + 5.*reQ6nQ4nstarQ2nstar - reQ6nQ4nstarQ1nstarQ1nstar
3676                  + 2.*reQ6nQ3nstarQ3nstar - reQ6nQ2nstarQ2nstarQ2nstar 
3677                  + 4.*reQ4nQ2nstarQ2nstar - 2.*reQ4nQ2nstarQ1nstarQ1nstar 
3678                  + 2.*reQ5nQ4nstarQ1nstar - 2.*reQ5nQ2nstarQ2nstarQ1nstar 
3679                  + 4.*reQ4nQ3nstarQ1nstar + 4.*reQ5nQ3nstarQ2nstar
3680                  + 4.*reQ6nQ5nstarQ1nstar - 4.*reQ6nQ3nstarQ2nstarQ1nstar + 24.*dMult)
3681                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3682   
3683   // Peter Jochumzsen:
3684   /*
3685   five4n1n1n3n3n = (reQ6nQ2nstarQ2nstarQ1nstarQ1nstar
3686                  - 12.*pow(dReQ1n,2.)-12.*pow(dImQ1n,2.)
3687                  - 14.*pow(dReQ2n,2.)-14.*pow(dImQ2n,2.)
3688                  - 8.*pow(dReQ3n,2.)-8.*pow(dImQ3n,2.)
3689                  - 6.*pow(dReQ4n,2.)-6.*pow(dImQ4n,2.)
3690                  - 4.*pow(dReQ5n,2.)-4.*pow(dImQ5n,2.)
3691                  - 6.*pow(dReQ6n,2.)-6.*pow(dImQ6n,2.)
3692                  + 2.*reQ2nQ1nstarQ1nstar + 8.*reQ3nQ2nstarQ1nstar
3693                  + 5.*reQ6nQ4nstarQ2nstar - reQ6nQ4nstarQ1nstarQ1nstar
3694                  + 2.*reQ6nQ3nstarQ3nstar - reQ6nQ2nstarQ2nstarQ2nstar
3695                  + 4.*reQ4nQ2nstarQ2nstar - 2.*reQ4nQ2nstarQ1nstarQ1nstar
3696                  + 2.*reQ5nQ4nstarQ1nstar - 2.*reQ5nQ2nstarQ2nstarQ1nstar
3697                  + 4.*reQ4nQ3nstarQ1nstar + 4.*reQ5nQ3nstarQ2nstar
3698                  + 4.*reQ6nQ5nstarQ1nstar - 4.*reQ6nQ3nstarQ2nstarQ1nstar + 24.*dMult)
3699                  / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3700   */
3701   
3702   // Average 5-particle correlations for all events:      
3703   fIntFlowCorrelationsAllPro->Fill(52.5,five3n3n3n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3704   fIntFlowCorrelationsAllPro->Fill(53.5,five4n2n3n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3705   fIntFlowCorrelationsAllPro->Fill(54.5,five3n2n3n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3706   fIntFlowCorrelationsAllPro->Fill(55.5,five3n2n2n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3707   fIntFlowCorrelationsAllPro->Fill(56.5,five5n1n3n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3708   fIntFlowCorrelationsAllPro->Fill(60.5,five6n2n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3709   fIntFlowCorrelationsAllPro->Fill(61.5,five4n1n1n3n3n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3710   if(fCalculateAllCorrelationsVsM)
3711   {
3712    fIntFlowCorrelationsAllVsMPro[52]->Fill(dMult+0.5,five3n3n3n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3713    fIntFlowCorrelationsAllVsMPro[53]->Fill(dMult+0.5,five4n2n3n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3714    fIntFlowCorrelationsAllVsMPro[54]->Fill(dMult+0.5,five3n2n3n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3715    fIntFlowCorrelationsAllVsMPro[55]->Fill(dMult+0.5,five3n2n2n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3716    fIntFlowCorrelationsAllVsMPro[56]->Fill(dMult+0.5,five5n1n3n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3717    fIntFlowCorrelationsAllVsMPro[60]->Fill(dMult+0.5,five6n2n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3718    fIntFlowCorrelationsAllVsMPro[61]->Fill(dMult+0.5,five4n1n1n3n3n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
3719   }         
3720  } // end of if(dMult>4)
3721
3722  // 6-particle:
3723  Double_t six3n2n1n3n2n1n = 0.; // <cos(n(3*phi1+2*phi2+1*phi3-3*phi4-2*phi5-1*phi6)>
3724  Double_t six3n3n2n2n1n1n = 0.; // <cos(n(3*phi1+3*phi2-2*phi3-2*phi4-1*phi5-1*phi6)>   
3725  if(dMult>5.)
3726  { 
3727   six3n2n1n3n2n1n = (dQ3nQ2nQ1nQ3nstarQ2nstarQ1nstar-2.*reQ3nQ3nQ3nstarQ2nstarQ1nstar
3728                   - 2.*reQ3nQ2nQ2nstarQ2nstarQ1nstar-2.*reQ3nQ1nQ2nstarQ1nstarQ1nstar
3729                   - 2.*reQ3nQ2nQ3nstarQ1nstarQ1nstar-2.*reQ4nQ2nQ3nstarQ2nstarQ1nstar
3730                   - 2.*reQ5nQ1nQ3nstarQ2nstarQ1nstar+4.*reQ6nQ3nstarQ2nstarQ1nstar
3731                   + 2.*reQ5nQ1nQ4nstarQ2nstar+2.*reQ5nQ1nQ3nstarQ3nstar
3732                   + 2.*reQ4nQ2nQ3nstarQ3nstar+6.*reQ4nQ1nQ3nstarQ2nstar
3733                   + 2.*reQ5nQ3nstarQ1nstarQ1nstar+2.*reQ5nQ2nstarQ2nstarQ1nstar
3734                   + 6.*reQ3nQ1nQ2nstarQ2nstar+2.*reQ4nQ2nstarQ1nstarQ1nstar
3735                   - 4.*reQ6nQ5nstarQ1nstar-4.*reQ6nQ4nstarQ2nstar-6.*reQ5nQ4nstarQ1nstar
3736                   - 4.*reQ6nQ3nstarQ3nstar+2.*(dMult-11.)*reQ5nQ3nstarQ2nstar
3737                   + 2.*(dMult-13.)*reQ4nQ3nstarQ1nstar-8.*reQ4nQ2nstarQ2nstar
3738                   + 2.*(5.*dMult-32.)*reQ3nQ2nstarQ1nstar+2.*reQ3nQ1nstarQ1nstarQ1nstar
3739                   + 2.*(dMult-13.)*reQ2nQ1nstarQ1nstar
3740                   - (dMult-10.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3741                   + (pow(dReQ5n,2.)+pow(dImQ5n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3742                   + (pow(dReQ4n,2.)+pow(dImQ4n,2.))*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3743                   - (dMult-11.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3744                   - (dMult-10.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3745                   + 4.*(pow(dReQ6n,2.)+pow(dImQ6n,2.))-(dMult-12.)*(pow(dReQ5n,2.)+pow(dImQ5n,2.))
3746                   - (dMult-16.)*(pow(dReQ4n,2.)+pow(dImQ4n,2.))+pow((pow(dReQ3n,2.)+pow(dImQ3n,2.)),2.)
3747                   + (dMult*dMult-19.*dMult+68.)*(pow(dReQ3n,2.)+pow(dImQ3n,2.))
3748                   + (dMult*dMult-19.*dMult+72.)*(pow(dReQ2n,2.)+pow(dImQ2n,2.))
3749                   + pow((pow(dReQ2n,2.)+pow(dImQ2n,2.)),2.)+pow((pow(dReQ1n,2.)+pow(dImQ1n,2.)),2.)
3750                   + (dMult*dMult-20.*dMult+80.)*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
3751                   - dMult*(dMult-12.)*(dMult-10.))
3752                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));   
3753   
3754   // Peter Jochumzsen:
3755   six3n3n2n2n1n1n = (reQ3nQ3nQ2nstarQ2nstarQ1nstarQ1nstar
3756                   + (80.-16.*dMult)*pow(dReQ1n,2.)+(80.-16.*dMult)*pow(dImQ1n,2.)
3757                   + (78.-16.*dMult)*pow(dReQ2n,2.)+(78.-16.*dMult)*pow(dImQ2n,2.)
3758                   + (72.-16.*dMult)*pow(dReQ3n,2.)+(72.-16.*dMult)*pow(dImQ3n,2.)
3759                   + 14.*pow(dReQ4n,2.)+14.*pow(dImQ4n,2.)
3760                   + 8.*pow(dReQ5n,2.)+8.*pow(dImQ5n,2.)
3761                   + 6.*pow(dReQ6n,2.)+6.*pow(dImQ6n,2.)
3762                   + 1.*reQ6nQ2nstarQ2nstarQ2nstar - 1.*reQ6nQ2nstarQ2nstarQ1nstarQ1nstar
3763                   - 76.*reQ3nQ2nstarQ1nstar + 4.*reQ3nQ1nstarQ1nstarQ1nstar
3764                   - 8.*reQ3nQ2nstarQ1nstar + 8.*dQ2nQ1nQ2nstarQ1nstar
3765                   + 4.*reQ5nQ2nstarQ2nstarQ1nstar - 2.*reQ6nQ3nstarQ3nstar
3766                   + 4.*reQ6nQ3nstarQ2nstarQ1nstar - 4.*reQ5nQ4nstarQ1nstar
3767                   + 16.*dMult*reQ3nQ2nstarQ1nstar - 2.*reQ4nQ2nstarQ2nstar
3768                   - 4.*reQ3nQ3nQ3nstarQ2nstarQ1nstar -8.*reQ4nQ3nstarQ1nstar
3769                   - 10.*reQ4nQ2nstarQ2nstar + 4.*reQ4nQ2nstarQ1nstarQ1nstar
3770                   - 12.*reQ4nQ3nstarQ1nstar + 8.*dQ3nQ1nQ3nstarQ1nstar
3771                   + 8.*reQ3nQ1nQ2nstarQ2nstar - 4.*reQ3nQ1nQ2nstarQ1nstarQ1nstar
3772                   + 5.*reQ4nQ2nQ3nstarQ3nstar+2.*pow(pow(dReQ2n,2.)+pow(dImQ2n,2.),2.)
3773                   + 4.*reQ5nQ1nQ3nstarQ3nstar+2.*pow(pow(dReQ3n,2.)+pow(dImQ3n,2.),2.)
3774                   - 6.*reQ6nQ3nstarQ3nstar - 14.*reQ2nQ1nstarQ1nstar
3775                   - 1.*reQ3nQ3nQ2nstarQ2nstarQ2nstar-4.*reQ3nQ2nQ2nstarQ2nstarQ1nstar
3776                   - 1.*reQ4nQ1nQ1nQ3nstarQ3nstar-8.*reQ5nQ3nstarQ2nstar
3777                   + 2.*pow(pow(dReQ1n,2.)+pow(dImQ1n,2.),2.) - 10.*reQ2nQ1nstarQ1nstar
3778                   - 4.*reQ6nQ5nstarQ1nstar-5.*reQ6nQ4nstarQ2nstar
3779                   + 1.*reQ6nQ4nstarQ1nstarQ1nstar-8.*reQ5nQ3nstarQ2nstar
3780                   + 4.*reQ4nQ1nQ3nstarQ2nstar+8.*dQ3nQ2nQ3nstarQ2nstar
3781                   - 120.*dMult + 16.*dMult*dMult)
3782                   / (dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3783
3784   // Average 6-particle correlations for all events:      
3785   fIntFlowCorrelationsAllPro->Fill(57.5,six3n2n1n3n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3786   fIntFlowCorrelationsAllPro->Fill(62.5,six3n3n2n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3787   if(fCalculateAllCorrelationsVsM)
3788   {
3789    fIntFlowCorrelationsAllVsMPro[57]->Fill(dMult+0.5,six3n2n1n3n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3790    fIntFlowCorrelationsAllVsMPro[62]->Fill(dMult+0.5,six3n3n2n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
3791   }          
3792  } // end of if(dMult>5.)
3793  
3794 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelations()
3795
3796 //================================================================================================================================
3797
3798 void AliFlowAnalysisWithQCumulants::StorePhiDistributionForOneEvent(AliFlowEventSimple *anEvent)
3799 {
3800  // Store phi distribution for one event to illustrate flow.
3801  
3802  if(fPhiDistributionForOneEvent->GetEntries()>0){return;} // store only phi distribution for one event
3803  
3804  Double_t vMin = fPhiDistributionForOneEventSettings[0]; 
3805  Double_t vMax = fPhiDistributionForOneEventSettings[1]; 
3806  Double_t refMultMin = fPhiDistributionForOneEventSettings[2]; 
3807  Double_t refMultMax = fPhiDistributionForOneEventSettings[3]; 
3808  
3809  Double_t vEBE = 0.;
3810  Double_t cumulant4thEBE = fIntFlowCorrelationsEBE->GetBinContent(2)-2.*pow(fIntFlowCorrelationsEBE->GetBinContent(1),2.);
3811  if(cumulant4thEBE<0.)
3812  {
3813   vEBE = pow(-1.*cumulant4thEBE,0.25);
3814   if((vEBE>vMin && vEBE<vMax) && (fReferenceMultiplicityEBE>refMultMin && fReferenceMultiplicityEBE<refMultMax))
3815   {
3816    fPhiDistributionForOneEvent->SetTitle(Form("v_{%i} = %f",fHarmonic,vEBE));
3817    for(Int_t p=0;p<anEvent->NumberOfTracks();p++)
3818    {
3819     if(anEvent->GetTrack(p)->InRPSelection())
3820     {
3821      fPhiDistributionForOneEvent->Fill(anEvent->GetTrack(p)->Phi());
3822     }
3823    } // end of for(Int_t p=0;p<anEvent->NumberOfTracks();p++)
3824   } else
3825     {
3826      fPhiDistributionForOneEvent->SetTitle(Form("v_{%i} = %f, out of specified boundaries",fHarmonic,vEBE));  
3827     } 
3828    
3829  } // end of if(cumulant4thEBE<0.)
3830  
3831 } // end of void AliFlowAnalysisWithQCumulants::StorePhiDistributionForOneEvent(AliFlowEventSimple *anEvent)
3832
3833 //================================================================================================================================
3834
3835 void AliFlowAnalysisWithQCumulants::CalculateIntFlowProductOfCorrelations()
3836 {
3837  // Calculate averages of products of correlations for integrated flow.
3838  
3839  // multiplicity:
3840  Double_t dMult = (*fSpk)(0,0);
3841  
3842  Int_t counter = 0;
3843  
3844  for(Int_t ci1=1;ci1<4;ci1++)
3845  {
3846   for(Int_t ci2=ci1+1;ci2<=4;ci2++)
3847   {
3848    fIntFlowProductOfCorrelationsPro->Fill(0.5+counter,
3849                                           fIntFlowCorrelationsEBE->GetBinContent(ci1)*
3850                                           fIntFlowCorrelationsEBE->GetBinContent(ci2),
3851                                           fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci1)*
3852                                           fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci2));
3853    // products versus multiplicity:  // [0=<<2><4>>,1=<<2><6>>,2=<<2><8>>,3=<<4><6>>,4=<<4><8>>,5=<<6><8>>]
3854    if(fCalculateCumulantsVsM)
3855    {
3856     fIntFlowProductOfCorrelationsVsMPro[counter]->Fill(dMult+0.5, // to be improved: dMult => sum of weights ?
3857                                                        fIntFlowCorrelationsEBE->GetBinContent(ci1)*
3858                                                        fIntFlowCorrelationsEBE->GetBinContent(ci2),
3859                                                        fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci1)*
3860                                                        fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci2));
3861    } // end of if(fCalculateCumulantsVsM)
3862    counter++;                                                                                                                        
3863   }
3864  }
3865  
3866 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowProductOfCorrelations()
3867
3868
3869 //================================================================================================================================
3870
3871
3872 void AliFlowAnalysisWithQCumulants::CalculateIntFlowProductOfCorrectionTermsForNUA()
3873 {
3874  // Calculate averages of products of correction terms for NUA.
3875  
3876  // a) Binning of fIntFlowProductOfCorrectionTermsForNUAPro is organized as follows:
3877  //     1st bin: <<2><cos(phi)>> 
3878  //     2nd bin: <<2><sin(phi)>>
3879  //     3rd bin: <<cos(phi)><sin(phi)>>
3880  //     4th bin: <<2><cos(phi1+phi2)>> 
3881  //     5th bin: <<2><sin(phi1+phi2)>>
3882  //     6th bin: <<2><cos(phi1-phi2-phi3)>> 
3883  //     7th bin: <<2><sin(phi1-phi2-phi3)>>
3884  //     8th bin: <<4><cos(phi1)>>
3885  //     9th bin: <<4><sin(phi1)>>
3886  //    10th bin: <<4><cos(phi1+phi2)>>
3887  //    11th bin: <<4><sin(phi1+phi2)>>
3888  //    12th bin: <<4><cos(phi1-phi2-phi3)>>
3889  //    13th bin: <<4><sin(phi1-phi2-phi3)>>
3890  //    14th bin: <<cos(phi1)><cos(phi1+phi2)>>
3891  //    15th bin: <<cos(phi1)><sin(phi1+phi2)>> 
3892  //    16th bin: <<cos(phi1)><cos(phi1-phi2-phi3)>>
3893  //    17th bin: <<cos(phi1)><sin(phi1-phi2-phi3)>> 
3894  //    18th bin: <<sin(phi1)><cos(phi1+phi2)>>
3895  //    19th bin: <<sin(phi1)><sin(phi1+phi2)>> 
3896  //    20th bin: <<sin(phi1)><cos(phi1-phi2-phi3)>>
3897  //    21st bin: <<sin(phi1)><sin(phi1-phi2-phi3)>>
3898  //    22nd bin: <<cos(phi1+phi2)><sin(phi1+phi2)>>
3899  //    23rd bin: <<cos(phi1+phi2)><cos(phi1-phi2-phi3)>>
3900  //    24th bin: <<cos(phi1+phi2)><sin(phi1-phi2-phi3)>>
3901  //    25th bin: <<sin(phi1+phi2)><cos(phi1-phi2-phi3)>>
3902  //    26th bin: <<sin(phi1+phi2)><sin(phi1-phi2-phi3)>>
3903  //    27th bin: <<cos(phi1-phi2-phi3)><sin(phi1-phi2-phi3)>>
3904  
3905  // <<2><cos(phi)>>:
3906  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(0.5,
3907                                                  fIntFlowCorrelationsEBE->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(1),
3908                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)
3909                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1));
3910  // <<2><sin(phi)>>:
3911  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(1.5,
3912                                                  fIntFlowCorrelationsEBE->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(1),
3913                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)
3914                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1));
3915  // <<cos(phi)><sin(phi)>>:
3916  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(2.5,
3917                                                  fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(1),
3918                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1)
3919                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1));
3920  // <<2><cos(phi1+phi2)>>:
3921  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(3.5,
3922                                                  fIntFlowCorrelationsEBE->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(2),
3923                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)
3924                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)); 
3925  // <<2><sin(phi1+phi2)>>:
3926  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(4.5,
3927                                                  fIntFlowCorrelationsEBE->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(2),
3928                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)
3929                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2)); 
3930  // <<2><cos(phi1-phi2-phi3)>>:
3931  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(5.5,
3932                                                  fIntFlowCorrelationsEBE->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(3),
3933                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)
3934                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3)); 
3935  // <<2><sin(phi1-phi2-phi3)>>:
3936  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(6.5,
3937                                                  fIntFlowCorrelationsEBE->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(3),
3938                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)
3939                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3)); 
3940  // <<4><cos(phi1)>>:
3941  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(7.5,
3942                                                  fIntFlowCorrelationsEBE->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(1),
3943                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)
3944                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1));
3945  // <<4><sin(phi1)>>:
3946  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(8.5,
3947                                                  fIntFlowCorrelationsEBE->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(1),
3948                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)
3949                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1));
3950  // <<4><cos(phi1+phi2)>>:
3951  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(9.5,
3952                                                  fIntFlowCorrelationsEBE->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(2),
3953                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)
3954                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)); 
3955  // <<4><sin(phi1+phi2)>>:
3956  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(10.5,
3957                                                  fIntFlowCorrelationsEBE->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(2),
3958                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)
3959                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2));
3960  // <<4><cos(phi1-phi2-phi3)>>:
3961  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(11.5,
3962                                                  fIntFlowCorrelationsEBE->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(3),
3963                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)
3964                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3)); 
3965  // <<4><sin(phi1-phi2-phi3)>>:
3966  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(12.5,
3967                                                  fIntFlowCorrelationsEBE->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(3),
3968                                                  fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)
3969                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3));   
3970  // <<cos(phi1)><cos(phi1+phi2)>>:
3971  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(13.5,
3972                                                  fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(2),
3973                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1)
3974                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)); 
3975  // <<cos(phi1)><sin(phi1+phi2)>>: 
3976  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(14.5,
3977                                                  fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(2),
3978                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1)
3979                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2)); 
3980  // <<cos(phi1)><cos(phi1-phi2-phi3)>>:
3981  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(15.5,
3982                                                  fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(3),
3983                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1)
3984                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3)); 
3985  // <<cos(phi1)><sin(phi1-phi2-phi3)>>: 
3986  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(16.5,
3987                                                  fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(3),
3988                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1)
3989                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3));  
3990  // <<sin(phi1)><cos(phi1+phi2)>>:
3991  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(17.5,
3992                                                  fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(2),
3993                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1)
3994                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2));  
3995  // <<sin(phi1)><sin(phi1+phi2)>>: 
3996  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(18.5,
3997                                                  fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(2),
3998                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1)
3999                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2));  
4000  // <<sin(phi1)><cos(phi1-phi2-phi3)>>:
4001  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(19.5,
4002                                                  fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(3),
4003                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1)
4004                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3)); 
4005  // <<sin(phi1)><sin(phi1-phi2-phi3)>>:
4006  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(20.5,
4007                                                  fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(1)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(3),
4008                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1)
4009                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3)); 
4010  // <<cos(phi1+phi2)><sin(phi1+phi2)>>:
4011  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(21.5,
4012                                                  fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(2),
4013                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)
4014                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2)); 
4015  // <<cos(phi1+phi2)><cos(phi1-phi2-phi3)>>:
4016  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(22.5,
4017                                                  fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(3),
4018                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)
4019                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3));   
4020  // <<cos(phi1+phi2)><sin(phi1-phi2-phi3)>>:
4021  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(23.5,
4022                                                  fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(3),
4023                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)
4024                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3));    
4025  // <<sin(phi1+phi2)><cos(phi1-phi2-phi3)>>:
4026  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(24.5,
4027                                                  fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(3),
4028                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2)
4029                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3));    
4030  // <<sin(phi1+phi2)><sin(phi1-phi2-phi3)>>:
4031  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(25.5,
4032                                                  fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(2)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(3),
4033                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2)
4034                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3));    
4035  // <<cos(phi1-phi2-phi3)><sin(phi1-phi2-phi3)>>:
4036  fIntFlowProductOfCorrectionTermsForNUAPro->Fill(26.5,
4037                                                  fIntFlowCorrectionTermsForNUAEBE[1]->GetBinContent(3)*fIntFlowCorrectionTermsForNUAEBE[0]->GetBinContent(3),
4038                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3)
4039                                                  *fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3));    
4040
4041 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowProductOfCorrectionTermsForNUA()
4042
4043 //================================================================================================================================
4044
4045 void AliFlowAnalysisWithQCumulants::CalculateCovariancesIntFlow()
4046 {
4047  // a) Calculate unbiased estimators Cov(<2>,<4>), Cov(<2>,<6>), Cov(<2>,<8>), Cov(<4>,<6>), Cov(<4>,<8>) and Cov(<6>,<8>)
4048  //    for covariances V_(<2>,<4>), V_(<2>,<6>), V_(<2>,<8>), V_(<4>,<6>), V_(<4>,<8>) and V_(<6>,<8>).
4049  // b) Store in histogram fIntFlowCovariances for instance the following: 
4050  //
4051  //             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)]
4052  // 
4053  //    where N is the number of events, w_{<2>} is event weight for <2> and w_{<4>} is event weight for <4>.
4054  // c) Binning of fIntFlowCovariances is organized as follows:
4055  // 
4056  //     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)] 
4057  //     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)]
4058  //     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)]
4059  //     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)]
4060  //     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)]
4061  //     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)]
4062  //
4063     
4064  // Average 2-, 4-, 6- and 8-particle correlations for all events:
4065  Double_t correlation[4] = {0.};
4066  for(Int_t ci=0;ci<4;ci++)
4067  {
4068   correlation[ci] = fIntFlowCorrelationsPro->GetBinContent(ci+1);
4069  } 
4070  // Average products of 2-, 4-, 6- and 8-particle correlations: 
4071  Double_t productOfCorrelations[4][4] = {{0.}};
4072  Int_t productOfCorrelationsLabel = 1;
4073  // Denominators in the expressions for the unbiased estimator for covariance:
4074  Double_t denominator[4][4] = {{0.}};
4075  Int_t sumOfProductOfEventWeightsLabel1 = 1;
4076  // Weight dependent prefactor which multiply unbiased estimators for covariances:
4077  Double_t wPrefactor[4][4] = {{0.}}; 
4078  Int_t sumOfProductOfEventWeightsLabel2 = 1;
4079  for(Int_t c1=0;c1<4;c1++)
4080  {
4081   for(Int_t c2=c1+1;c2<4;c2++)
4082   {
4083    productOfCorrelations[c1][c2] = fIntFlowProductOfCorrelationsPro->GetBinContent(productOfCorrelationsLabel);
4084    if(TMath::Abs(fIntFlowSumOfEventWeights[0]->GetBinContent(c1+1)) > 1.e-44 && TMath::Abs(fIntFlowSumOfEventWeights[0]->GetBinContent(c2+1)) > 1.e-44)
4085    {
4086     denominator[c1][c2] = 1.-(fIntFlowSumOfProductOfEventWeights->GetBinContent(sumOfProductOfEventWeightsLabel1))
4087                         / (fIntFlowSumOfEventWeights[0]->GetBinContent(c1+1) 
4088                         * fIntFlowSumOfEventWeights[0]->GetBinContent(c2+1));                              
4089     wPrefactor[c1][c2] = fIntFlowSumOfProductOfEventWeights->GetBinContent(sumOfProductOfEventWeightsLabel2)
4090                        / (fIntFlowSumOfEventWeights[0]->GetBinContent(c1+1)
4091                        * fIntFlowSumOfEventWeights[0]->GetBinContent(c2+1));                                                       
4092    }
4093    productOfCorrelationsLabel++; // to be improved - do I need here all 3 counters?
4094    sumOfProductOfEventWeightsLabel1++;
4095    sumOfProductOfEventWeightsLabel2++;  
4096   } // end of for(Int_t c2=c1+1;c2<4;c2++)
4097  } // end of for(Int_t c1=0;c1<4;c1++)
4098  
4099  Int_t covarianceLabel = 1;
4100  for(Int_t c1=0;c1<4;c1++)
4101  {
4102   for(Int_t c2=c1+1;c2<4;c2++)
4103   {
4104    if(TMath::Abs(denominator[c1][c2]) > 1.e-44)
4105    {
4106     // Covariances:
4107     Double_t cov = (productOfCorrelations[c1][c2]-correlation[c1]*correlation[c2])/denominator[c1][c2]; 
4108     // Covariances multiplied with weight dependent prefactor:
4109     Double_t wCov = cov * wPrefactor[c1][c2];
4110     fIntFlowCovariances->SetBinContent(covarianceLabel,wCov);
4111    }
4112    covarianceLabel++;
4113   } // end of for(Int_t c2=c1+1;c2<4;c2++) 
4114  } // end of for(Int_t c1=0;c1<4;c1++)
4115  
4116  // Versus multiplicity: 
4117  if(!fCalculateCumulantsVsM){return;}
4118  Int_t nBins = fIntFlowCorrelationsVsMPro[0]->GetNbinsX(); // to be improved (hardwired 0) 
4119  for(Int_t b=1;b<=nBins;b++)
4120  {
4121   // Average 2-, 4-, 6- and 8-particle correlations for all events:
4122   Double_t correlationVsM[4] = {0.};
4123   for(Int_t ci=0;ci<4;ci++)
4124   {
4125    correlationVsM[ci] = fIntFlowCorrelationsVsMPro[ci]->GetBinContent(b);
4126   } // end of for(Int_t ci=0;ci<4;ci++)
4127   // Average products of 2-, 4-, 6- and 8-particle correlations: 
4128   Double_t productOfCorrelationsVsM[4][4] = {{0.}};
4129   Int_t productOfCorrelationsLabelVsM = 1;
4130   // Denominators in the expressions for the unbiased estimator for covariance:
4131   Double_t denominatorVsM[4][4] = {{0.}};
4132   Int_t sumOfProductOfEventWeightsLabel1VsM = 1;
4133   // Weight dependent prefactor which multiply unbiased estimators for covariances:
4134   Double_t wPrefactorVsM[4][4] = {{0.}}; 
4135   Int_t sumOfProductOfEventWeightsLabel2VsM = 1;
4136   for(Int_t c1=0;c1<4;c1++)
4137   {
4138    for(Int_t c2=c1+1;c2<4;c2++)
4139    {
4140     productOfCorrelationsVsM[c1][c2] = fIntFlowProductOfCorrelationsVsMPro[productOfCorrelationsLabelVsM-1]->GetBinContent(b);
4141     if(TMath::Abs(fIntFlowSumOfEventWeightsVsM[c1][0]->GetBinContent(b)) > 1.e-44 && TMath::Abs(fIntFlowSumOfEventWeightsVsM[c2][0]->GetBinContent(b)) > 1.e-44)
4142     {
4143      denominatorVsM[c1][c2] = 1.-(fIntFlowSumOfProductOfEventWeightsVsM[sumOfProductOfEventWeightsLabel1VsM-1]->GetBinContent(b))
4144                             / (fIntFlowSumOfEventWeightsVsM[c1][0]->GetBinContent(b) 
4145                             * fIntFlowSumOfEventWeightsVsM[c2][0]->GetBinContent(b));                              
4146      wPrefactorVsM[c1][c2] = fIntFlowSumOfProductOfEventWeightsVsM[sumOfProductOfEventWeightsLabel2VsM-1]->GetBinContent(b)
4147                            / (fIntFlowSumOfEventWeightsVsM[c1][0]->GetBinContent(b)
4148                            * fIntFlowSumOfEventWeightsVsM[c2][0]->GetBinContent(b));                                                       
4149     }
4150     productOfCorrelationsLabelVsM++;
4151     sumOfProductOfEventWeightsLabel1VsM++;
4152     sumOfProductOfEventWeightsLabel2VsM++;  
4153    } // end of for(Int_t c1=0;c1<4;c1++) 
4154   } // end of for(Int_t c2=c1+1;c2<4;c2++)
4155  
4156   Int_t covarianceLabelVsM = 1;
4157   for(Int_t c1=0;c1<4;c1++)
4158   {
4159    for(Int_t c2=c1+1;c2<4;c2++)
4160    {
4161     if(TMath::Abs(denominatorVsM[c1][c2]) > 1.e-44)
4162     {
4163      // Covariances:
4164      Double_t covVsM = (productOfCorrelationsVsM[c1][c2]-correlationVsM[c1]*correlationVsM[c2])/denominatorVsM[c1][c2]; 
4165      // Covariances multiplied with weight dependent prefactor:
4166      Double_t wCovVsM = covVsM * wPrefactorVsM[c1][c2];
4167      fIntFlowCovariancesVsM[covarianceLabelVsM-1]->SetBinContent(b,wCovVsM);
4168     }
4169     covarianceLabelVsM++;
4170    } // end of for(Int_t c2=c1+1;c2<4;c2++)
4171   } // end of for(Int_t c1=0;c1<4;c1++)
4172  } // end of for(Int_t b=1;b<=nBins;b++)
4173   
4174 } // end of AliFlowAnalysisWithQCumulants::CalculateCovariancesIntFlow()
4175
4176 //================================================================================================================================
4177
4178 void AliFlowAnalysisWithQCumulants::CalculateCovariancesNUAIntFlow()
4179 {
4180  // a) Calculate unbiased estimators Cov(*,*) for true covariances V_(*,*) for NUA terms.
4181  // b) Store in histogram fIntFlowCovariancesNUA for instance the following: 
4182  //
4183  //             Cov(<2>,<cos(phi)>) * (sum_{i=1}^{N} w_{<2>}_i w_{<cos(phi)>}_i )/[(sum_{i=1}^{N} w_{<2>}_i) * (sum_{j=1}^{N} w_{<cos(phi)>}_j)]
4184  // 
4185  //    where N is the number of events, w_{<2>} is event weight for <2> and w_{<cos(phi)>} is event weight for <cos(phi)>.
4186  // c) Binning of fIntFlowCovariancesNUA is organized as follows:
4187  // 
4188  //     1st bin: Cov(<2>,<cos(phi)>) * (sum_{i=1}^{N} w_{<2>}_i w_{<cos(phi)>}_i )/[(sum_{i=1}^{N} w_{<2>}_i) * (sum_{j=1}^{N} w_{<cos(phi)>}_j)] 
4189  //     2nd bin: Cov(<2>,<sin(phi)>) * (sum_{i=1}^{N} w_{<2>}_i w_{<sin(phi)>}_i )/[(sum_{i=1}^{N} w_{<2>}_i) * (sum_{j=1}^{N} w_{<sin(phi)>}_j)]
4190  //     3rd bin: Cov(<cos(phi)>,<sin(phi)>) * (sum_{i=1}^{N} w_{<cos(phi)>}_i w_{<sin(phi)>}_i )/[(sum_{i=1}^{N} w_{<cos(phi)>}_i) * (sum_{j=1}^{N} w_{<sin(phi)>}_j)]
4191  // ...
4192       
4193  // Cov(<2>,<cos(phi)>):
4194  Double_t product1 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(1); // <<2><cos(phi)>> 
4195  Double_t term1st1 = fIntFlowCorrelationsPro->GetBinContent(1); // <<2>>
4196  Double_t term2nd1 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(1); // <<cos(phi)>>
4197  Double_t sumOfW1st1 = fIntFlowSumOfEventWeights[0]->GetBinContent(1); // W_{<2>}
4198  Double_t sumOfW2nd1 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(1); // W_{<cos(phi)>}
4199  Double_t sumOfWW1 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(1); // W_{<2>} * W_{<cos(phi)>}
4200  // numerator in the expression for the the unbiased estimator for covariance:
4201  Double_t numerator1 = product1 - term1st1*term2nd1; 
4202  // denominator in the expression for the the unbiased estimator for covariance:
4203  Double_t denominator1 = 0.;
4204  if(TMath::Abs(sumOfW1st1*sumOfW2nd1)>0.)
4205  {
4206   denominator1 = 1.-sumOfWW1/(sumOfW1st1*sumOfW2nd1);
4207   if(TMath::Abs(denominator1)>0.)
4208   {
4209    // covariance:
4210    Double_t covariance1 = numerator1/denominator1;
4211    // weight dependent prefactor for covariance:
4212    Double_t wPrefactor1 = sumOfWW1/(sumOfW1st1*sumOfW2nd1);
4213    // finally, store "weighted" covariance:
4214    fIntFlowCovariancesNUA->SetBinContent(1,wPrefactor1*covariance1);
4215   } // end of if(TMath::Abs(denominator)>0.)
4216  } // end of if(TMath::Abs(sumOfW1st1*sumOfW2nd1)>0.)
4217  
4218  // Cov(<2>,<sin(phi)>):
4219  Double_t product2 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(2); // <<2><sin(phi)>> 
4220  Double_t term1st2 = fIntFlowCorrelationsPro->GetBinContent(1); // <<2>>
4221  Double_t term2nd2 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(1); // <<sin(phi)>>
4222  Double_t sumOfW1st2 = fIntFlowSumOfEventWeights[0]->GetBinContent(1); // W_{<2>}
4223  Double_t sumOfW2nd2 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(1); // W_{<sin(phi)>}
4224  Double_t sumOfWW2 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(2); // W_{<2>} * W_{<sin(phi)>}
4225  // numerator in the expression for the the unbiased estimator for covariance:
4226  Double_t numerator2 = product2 - term1st2*term2nd2;
4227  // denominator in the expression for the the unbiased estimator for covariance:
4228  Double_t denominator2 = 0.;
4229  if(TMath::Abs(sumOfW1st2*sumOfW2nd2)>0.)
4230  {  
4231   denominator2 = 1.-sumOfWW2/(sumOfW1st2*sumOfW2nd2);
4232   if(TMath::Abs(denominator2)>0.)
4233   {
4234    // covariance:
4235    Double_t covariance2 = numerator2/denominator2;
4236    // weight dependent prefactor for covariance:
4237    Double_t wPrefactor2 = sumOfWW2/(sumOfW1st2*sumOfW2nd2);
4238    // finally, store "weighted" covariance:
4239    fIntFlowCovariancesNUA->SetBinContent(2,wPrefactor2*covariance2);
4240   } // end of if(TMath::Abs(denominator2)>0.)
4241  } // end of if(TMath::Abs(sumOfW1st2*sumOfW2nd2)>0.)
4242  
4243  // Cov(<cos(phi)>,<sin(phi)>):
4244  Double_t product3 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(3); // <<cos(phi)><sin(phi)>> 
4245  Double_t term1st3 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(1); // <<cos(phi)>>
4246  Double_t term2nd3 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(1); // <<sin(phi)>>
4247  Double_t sumOfW1st3 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(1); // W_{<cos(phi)>}
4248  Double_t sumOfW2nd3 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(1); // W_{<sin(phi)>}
4249  Double_t sumOfWW3 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(3); // W_{<cos(phi)>} * W_{<sin(phi)>}
4250  // numerator in the expression for the the unbiased estimator for covariance:
4251  Double_t numerator3 = product3 - term1st3*term2nd3; 
4252  // denominator in the expression for the the unbiased estimator for covariance:
4253  Double_t denominator3 = 0;
4254  if(TMath::Abs(sumOfW1st3*sumOfW2nd3)>0.)
4255  { 
4256   denominator3 = 1.-sumOfWW3/(sumOfW1st3*sumOfW2nd3);
4257   if(TMath::Abs(denominator3)>0.)
4258   {
4259    // covariance:
4260    Double_t covariance3 = numerator3/denominator3;
4261    // weight dependent prefactor for covariance:
4262    Double_t wPrefactor3 = sumOfWW3/(sumOfW1st3*sumOfW2nd3);
4263    // finally, store "weighted" covariance:
4264    fIntFlowCovariancesNUA->SetBinContent(3,wPrefactor3*covariance3);
4265   } // end of if(TMath::Abs(denominator3)>0.)
4266  } // end of if(TMath::Abs(sumOfW1st3*sumOfW2nd3)>0.)
4267  
4268  // Cov(<2>,<cos(phi1+phi2)>):
4269  Double_t product4 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(4); // <<2><cos(phi1+phi2)>> 
4270  Double_t term1st4 = fIntFlowCorrelationsPro->GetBinContent(1); // <<2>>
4271  Double_t term2nd4 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(2); // <<cos(phi1+phi2)>>
4272  Double_t sumOfW1st4 = fIntFlowSumOfEventWeights[0]->GetBinContent(1); // W_{<2>}
4273  Double_t sumOfW2nd4 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(2); // W_{<cos(phi1+phi2)>}
4274  Double_t sumOfWW4 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(4); // W_{<2>} * W_{<cos(phi1+phi2)>}
4275  // numerator in the expression for the the unbiased estimator for covariance:
4276  Double_t numerator4 = product4 - term1st4*term2nd4; 
4277  // denominator in the expression for the the unbiased estimator for covariance:
4278  Double_t denominator4 = 0.;
4279  if(TMath::Abs(sumOfW1st4*sumOfW2nd4)>0.)
4280  { 
4281   denominator4 = 1.-sumOfWW4/(sumOfW1st4*sumOfW2nd4);
4282   if(TMath::Abs(denominator4)>0.)
4283   {  
4284    // covariance:
4285    Double_t covariance4 = numerator4/denominator4;
4286    // weight dependent prefactor for covariance:
4287    Double_t wPrefactor4 = sumOfWW4/(sumOfW1st4*sumOfW2nd4);
4288    // finally, store "weighted" covariance:
4289    fIntFlowCovariancesNUA->SetBinContent(4,wPrefactor4*covariance4);
4290   } // end of if(TMath::Abs(denominator4)>0.)
4291  } // end of if(TMath::Abs(sumOfW1st4*sumOfW2nd4)>0.)
4292  
4293  // Cov(<2>,<sin(phi1+phi2)>):
4294  Double_t product5 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(5); // <<2><sin(phi1+phi2)>> 
4295  Double_t term1st5 = fIntFlowCorrelationsPro->GetBinContent(1); // <<2>>
4296  Double_t term2nd5 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(2); // <<sin(phi1+phi2)>>
4297  Double_t sumOfW1st5 = fIntFlowSumOfEventWeights[0]->GetBinContent(1); // W_{<2>}
4298  Double_t sumOfW2nd5 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(2); // W_{<sin(phi1+phi2)>}
4299  Double_t sumOfWW5 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(5); // W_{<2>} * W_{<sin(phi1+phi2)>}
4300  // numerator in the expression for the the unbiased estimator for covariance:
4301  Double_t numerator5 = product5 - term1st5*term2nd5; 
4302  // denominator in the expression for the the unbiased estimator for covariance:
4303  Double_t denominator5 = 0.;
4304  if(TMath::Abs(sumOfW1st5*sumOfW2nd5)>0.)
4305  {  
4306   denominator5 = 1.-sumOfWW5/(sumOfW1st5*sumOfW2nd5);
4307   if(TMath::Abs(denominator5)>0.)
4308   {  
4309    // covariance:
4310    Double_t covariance5 = numerator5/denominator5;
4311    // weight dependent prefactor for covariance:
4312    Double_t wPrefactor5 = sumOfWW5/(sumOfW1st5*sumOfW2nd5);
4313    // finally, store "weighted" covariance:
4314    fIntFlowCovariancesNUA->SetBinContent(5,wPrefactor5*covariance5);
4315   } // end of if(TMath::Abs(denominator5)>0.)
4316  } // end of if(TMath::Abs(sumOfW1st5*sumOfW2nd5)>0.)
4317  
4318  // Cov(<2>,<cos(phi1-phi2-phi3)>):
4319  Double_t product6 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(6); // <<2><cos(phi1-phi2-phi3)>> 
4320  Double_t term1st6 = fIntFlowCorrelationsPro->GetBinContent(1); // <<2>>
4321  Double_t term2nd6 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(3); // <<cos(phi1-phi2-phi3)>>
4322  Double_t sumOfW1st6 = fIntFlowSumOfEventWeights[0]->GetBinContent(1); // W_{<2>}
4323  Double_t sumOfW2nd6 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(3); // W_{<cos(phi1-phi2-phi3)>}
4324  Double_t sumOfWW6 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(6); // W_{<2>} * W_{<cos(phi1-phi2-phi3)>}
4325  // numerator in the expression for the the unbiased estimator for covariance:
4326  Double_t numerator6 = product6 - term1st6*term2nd6; 
4327  // denominator in the expression for the the unbiased estimator for covariance:
4328  Double_t denominator6 = 0.;
4329  if(TMath::Abs(sumOfW1st6*sumOfW2nd6)>0.)
4330  {  
4331   denominator6 = 1.-sumOfWW6/(sumOfW1st6*sumOfW2nd6);
4332   if(TMath::Abs(denominator6)>0.)
4333   {  
4334    // covariance:
4335    Double_t covariance6 = numerator6/denominator6;
4336    // weight dependent prefactor for covariance:
4337    Double_t wPrefactor6 = sumOfWW6/(sumOfW1st6*sumOfW2nd6);
4338    // finally, store "weighted" covariance:
4339    fIntFlowCovariancesNUA->SetBinContent(6,wPrefactor6*covariance6);
4340   } // end of if(TMath::Abs(denominator6)>0.)
4341  } // end of if(TMath::Abs(sumOfW1st6*sumOfW2nd6)>0.)
4342  
4343  // Cov(<2>,<sin(phi1-phi2-phi3)>):
4344  Double_t product7 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(7); // <<2><sin(phi1-phi2-phi3)>> 
4345  Double_t term1st7 = fIntFlowCorrelationsPro->GetBinContent(1); // <<2>>
4346  Double_t term2nd7 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(3); // <<sin(phi1-phi2-phi3)>>
4347  Double_t sumOfW1st7 = fIntFlowSumOfEventWeights[0]->GetBinContent(1); // W_{<2>}
4348  Double_t sumOfW2nd7 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(3); // W_{<sin(phi1-phi2-phi3)>}
4349  Double_t sumOfWW7 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(7); // W_{<2>} * W_{<sin(phi1-phi2-phi3)>}
4350  // numerator in the expression for the the unbiased estimator for covariance:
4351  Double_t numerator7 = product7 - term1st7*term2nd7; 
4352  // denominator in the expression for the the unbiased estimator for covariance:
4353  Double_t denominator7 = 0.;
4354  if(TMath::Abs(sumOfW1st7*sumOfW2nd7)>0.)
4355  {  
4356   denominator7 = 1.-sumOfWW7/(sumOfW1st7*sumOfW2nd7);
4357   if(TMath::Abs(denominator7)>0.)
4358   {   
4359    // covariance:
4360    Double_t covariance7 = numerator7/denominator7;
4361    // weight dependent prefactor for covariance:
4362    Double_t wPrefactor7 = sumOfWW7/(sumOfW1st7*sumOfW2nd7);
4363    // finally, store "weighted" covariance:
4364    fIntFlowCovariancesNUA->SetBinContent(7,wPrefactor7*covariance7);
4365   } // end of if(TMath::Abs(denominator7)>0.)
4366  } // end of if(TMath::Abs(sumOfW1st7*sumOfW2nd7)>0.)
4367  
4368  // Cov(<4>,<cos(phi1>):
4369  Double_t product8 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(8); // <<4><cos(phi1)>> 
4370  Double_t term1st8 = fIntFlowCorrelationsPro->GetBinContent(2); // <<4>>
4371  Double_t term2nd8 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(1); // <<cos(phi1)>>
4372  Double_t sumOfW1st8 = fIntFlowSumOfEventWeights[0]->GetBinContent(2); // W_{<4>}
4373  Double_t sumOfW2nd8 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(1); // W_{<cos(phi1)>}
4374  Double_t sumOfWW8 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(8); // W_{<4>} * W_{<cos(phi1)>}
4375  // numerator in the expression for the the unbiased estimator for covariance:
4376  Double_t numerator8 = product8 - term1st8*term2nd8; 
4377  // denominator in the expression for the the unbiased estimator for covariance:
4378  Double_t denominator8 = 0.;
4379  if(TMath::Abs(sumOfW1st8*sumOfW2nd8)>0.)
4380  { 
4381   denominator8 = 1.-sumOfWW8/(sumOfW1st8*sumOfW2nd8);
4382   if(TMath::Abs(denominator8)>0.)
4383   {     
4384    // covariance:
4385    Double_t covariance8 = numerator8/denominator8;
4386    // weight dependent prefactor for covariance:
4387    Double_t wPrefactor8 = sumOfWW8/(sumOfW1st8*sumOfW2nd8);
4388    // finally, store "weighted" covariance:
4389    fIntFlowCovariancesNUA->SetBinContent(8,wPrefactor8*covariance8);
4390   } // end of if(TMath::Abs(denominator8)>0.)
4391  } // end of if(TMath::Abs(sumOfW1st8*sumOfW2nd8)>0.)
4392  
4393  // Cov(<4>,<sin(phi1)>):
4394  Double_t product9 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(9); // <<4><sin(phi1)>> 
4395  Double_t term1st9 = fIntFlowCorrelationsPro->GetBinContent(2); // <<4>>
4396  Double_t term2nd9 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(1); // <<sin(phi1)>>
4397  Double_t sumOfW1st9 = fIntFlowSumOfEventWeights[0]->GetBinContent(2); // W_{<4>}
4398  Double_t sumOfW2nd9 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(1); // W_{<sin(phi1)>}
4399  Double_t sumOfWW9 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(9); // W_{<4>} * W_{<sin(phi1)>}
4400  // numerator in the expression for the the unbiased estimator for covariance:
4401  Double_t numerator9 = product9 - term1st9*term2nd9; 
4402  // denominator in the expression for the the unbiased estimator for covariance:
4403  Double_t denominator9 = 0.;
4404  if(TMath::Abs(sumOfW1st9*sumOfW2nd9)>0.) 
4405  {
4406   denominator9 = 1.-sumOfWW9/(sumOfW1st9*sumOfW2nd9);
4407   if(TMath::Abs(denominator9)>0.)
4408   {     
4409    // covariance:
4410    Double_t covariance9 = numerator9/denominator9;
4411    // weight dependent prefactor for covariance:
4412    Double_t wPrefactor9 = sumOfWW9/(sumOfW1st9*sumOfW2nd9);
4413    // finally, store "weighted" covariance:
4414    fIntFlowCovariancesNUA->SetBinContent(9,wPrefactor9*covariance9); 
4415   }
4416  } // end of if(TMath::Abs(sumOfW1st9*sumOfW2nd9)>0.) 
4417  
4418  // Cov(<4>,<cos(phi1+phi2)>):
4419  Double_t product10 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(10); // <<4><cos(phi1+phi2)>> 
4420  Double_t term1st10 = fIntFlowCorrelationsPro->GetBinContent(2); // <<4>>
4421  Double_t term2nd10 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(2); // <<cos(phi1+phi2)>>
4422  Double_t sumOfW1st10 = fIntFlowSumOfEventWeights[0]->GetBinContent(2); // W_{<4>}
4423  Double_t sumOfW2nd10 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(2); // W_{<cos(phi1+phi2)>}
4424  Double_t sumOfWW10 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(10); // W_{<4>} * W_{<cos(phi1+phi2)>}
4425  // numerator in the expression for the the unbiased estimator for covariance:
4426  Double_t numerator10 = product10 - term1st10*term2nd10; 
4427  // denominator in the expression for the the unbiased estimator for covariance:
4428  Double_t denominator10 = 0.;
4429  if(TMath::Abs(sumOfW1st10*sumOfW2nd10)>0.) 
4430  { 
4431   denominator10 = 1.-sumOfWW10/(sumOfW1st10*sumOfW2nd10);
4432   if(TMath::Abs(denominator10)>0.) 
4433   { 
4434    // covariance:
4435    Double_t covariance10 = numerator10/denominator10;
4436    // weight dependent prefactor for covariance:
4437    Double_t wPrefactor10 = sumOfWW10/(sumOfW1st10*sumOfW2nd10);
4438    // finally, store "weighted" covariance:
4439    fIntFlowCovariancesNUA->SetBinContent(10,wPrefactor10*covariance10);
4440   } // end of if(TMath::Abs(denominator10)>0.) 
4441  } // end of if(TMath::Abs(sumOfW1st10*sumOfW2nd10)>0.) 
4442  
4443  // Cov(<4>,<sin(phi1+phi2)>):
4444  Double_t product11 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(11); // <<4><sin(phi1+phi2)>> 
4445  Double_t term1st11 = fIntFlowCorrelationsPro->GetBinContent(2); // <<4>>
4446  Double_t term2nd11 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(2); // <<sin(phi1+phi2)>>
4447  Double_t sumOfW1st11 = fIntFlowSumOfEventWeights[0]->GetBinContent(2); // W_{<4>}
4448  Double_t sumOfW2nd11 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(2); // W_{<sin(phi1+phi2)>}
4449  Double_t sumOfWW11 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(11); // W_{<4>} * W_{<sin(phi1+phi2)>}
4450  // numerator in the expression for the the unbiased estimator for covariance:
4451  Double_t numerator11 = product11 - term1st11*term2nd11; 
4452  // denominator in the expression for the the unbiased estimator for covariance:
4453  Double_t denominator11 = 0.;
4454  if(TMath::Abs(sumOfW1st11*sumOfW2nd11)>0.) 
4455  {  
4456   denominator11 = 1.-sumOfWW11/(sumOfW1st11*sumOfW2nd11);
4457   if(TMath::Abs(denominator11)>0.) 
4458   { 
4459    // covariance:
4460    Double_t covariance11 = numerator11/denominator11;
4461    // weight dependent prefactor for covariance:
4462    Double_t wPrefactor11 = sumOfWW11/(sumOfW1st11*sumOfW2nd11);
4463    // finally, store "weighted" covariance:
4464    fIntFlowCovariancesNUA->SetBinContent(11,wPrefactor11*covariance11);
4465   } // end of if(TMath::Abs(denominator11)>0.) 
4466  } // end of if(TMath::Abs(sumOfW1st11*sumOfW2nd11)>0.) 
4467
4468  // Cov(<4>,<cos(phi1-phi2-phi3)>):
4469  Double_t product12 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(12); // <<4><cos(phi1-phi2-phi3)>> 
4470  Double_t term1st12 = fIntFlowCorrelationsPro->GetBinContent(2); // <<4>>
4471  Double_t term2nd12 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(3); // <<cos(phi1-phi2-phi3)>>
4472  Double_t sumOfW1st12 = fIntFlowSumOfEventWeights[0]->GetBinContent(2); // W_{<4>}
4473  Double_t sumOfW2nd12 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(3); // W_{<cos(phi1-phi2-phi3)>}
4474  Double_t sumOfWW12 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(12); // W_{<4>} * W_{<cos(phi1-phi2-phi3)>}
4475  // numerator in the expression for the the unbiased estimator for covariance:
4476  Double_t numerator12 = product12 - term1st12*term2nd12; 
4477  // denominator in the expression for the the unbiased estimator for covariance:
4478  Double_t denominator12 = 0.;
4479  if(TMath::Abs(sumOfW1st12*sumOfW2nd12)>0.) 
4480  {   
4481   denominator12 = 1.-sumOfWW12/(sumOfW1st12*sumOfW2nd12);
4482   if(TMath::Abs(denominator12)>0.) 
4483   { 
4484    // covariance:
4485    Double_t covariance12 = numerator12/denominator12;
4486    // weight dependent prefactor for covariance:
4487    Double_t wPrefactor12 = sumOfWW12/(sumOfW1st12*sumOfW2nd12);
4488    // finally, store "weighted" covariance:
4489    fIntFlowCovariancesNUA->SetBinContent(12,wPrefactor12*covariance12);
4490   } // end of if(TMath::Abs(denominator12)>0.)
4491  } // end of if(TMath::Abs(sumOfW1st12*sumOfW2nd12)>0.)  
4492
4493  // Cov(<4>,<sin(phi1-phi2-phi3)>):
4494  Double_t product13 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(13); // <<4><sin(phi1-phi2-phi3)>> 
4495  Double_t term1st13 = fIntFlowCorrelationsPro->GetBinContent(2); // <<4>>
4496  Double_t term2nd13 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(3); // <<sin(phi1-phi2-phi3)>>
4497  Double_t sumOfW1st13 = fIntFlowSumOfEventWeights[0]->GetBinContent(2); // W_{<4>}
4498  Double_t sumOfW2nd13 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(3); // W_{<sin(phi1-phi2-phi3)>}
4499  Double_t sumOfWW13 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(13); // W_{<4>} * W_{<sin(phi1-phi2-phi3)>}
4500  // numerator in the expression for the the unbiased estimator for covariance:
4501  Double_t numerator13 = product13 - term1st13*term2nd13; 
4502  // denominator in the expression for the the unbiased estimator for covariance:
4503  Double_t denominator13 = 0.;
4504  if(TMath::Abs(sumOfW1st13*sumOfW2nd13)>0.) 
4505  {   
4506   denominator13 = 1.-sumOfWW13/(sumOfW1st13*sumOfW2nd13);
4507   if(TMath::Abs(denominator13)>0.) 
4508   { 
4509    // covariance:
4510    Double_t covariance13 = numerator13/denominator13;
4511    // weight dependent prefactor for covariance:
4512    Double_t wPrefactor13 = sumOfWW13/(sumOfW1st13*sumOfW2nd13);
4513    // finally, store "weighted" covariance:
4514    fIntFlowCovariancesNUA->SetBinContent(13,wPrefactor13*covariance13);
4515   } // end of if(TMath::Abs(denominator13)>0.) 
4516  } // end of if(TMath::Abs(sumOfW1st13*sumOfW2nd13)>0.) 
4517
4518  // Cov(<cos(phi1)>,<cos(phi1+phi2)>):
4519  Double_t product14 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(14); // <<cos(phi1)><cos(phi1+phi2)>> 
4520  Double_t term1st14 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(1); // <<cos(phi1)>>
4521  Double_t term2nd14 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(2); // <<cos(phi1+phi2)>>
4522  Double_t sumOfW1st14 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(1); // W_{<cos(phi1)>}
4523  Double_t sumOfW2nd14 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(2); // W_{<cos(phi1+phi2)>}
4524  Double_t sumOfWW14 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(14); // W_{<cos(phi1)>} * W_{<cos(phi1+phi2)>}
4525  // numerator in the expression for the the unbiased estimator for covariance:
4526  Double_t numerator14 = product14 - term1st14*term2nd14; 
4527  // denominator in the expression for the the unbiased estimator for covariance:
4528  Double_t denominator14 = 0.;
4529  if(TMath::Abs(sumOfW1st14*sumOfW2nd14)>0.) 
4530  {  
4531   denominator14 = 1.-sumOfWW14/(sumOfW1st14*sumOfW2nd14);
4532   if(TMath::Abs(denominator14)>0.) 
4533   { 
4534    // covariance:
4535    Double_t covariance14 = numerator14/denominator14;
4536    // weight dependent prefactor for covariance:
4537    Double_t wPrefactor14 = sumOfWW14/(sumOfW1st14*sumOfW2nd14);
4538    // finally, store "weighted" covariance:
4539    fIntFlowCovariancesNUA->SetBinContent(14,wPrefactor14*covariance14);
4540   } // end of if(TMath::Abs(denominator14)>0.) 
4541  } // end of if(TMath::Abs(sumOfW1st14*sumOfW2nd14)>0.) 
4542
4543  // Cov(<cos(phi1)>,<sin(phi1+phi2)>):
4544  Double_t product15 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(15); // <<cos(phi1)><sin(phi1+phi2)>> 
4545  Double_t term1st15 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(1); // <<cos(phi1)>>
4546  Double_t term2nd15 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(2); // <<sin(phi1+phi2)>>
4547  Double_t sumOfW1st15 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(1); // W_{<cos(phi1)>}
4548  Double_t sumOfW2nd15 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(2); // W_{<sin(phi1+phi2)>}
4549  Double_t sumOfWW15 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(15); // W_{<cos(phi1)>} * W_{<sin(phi1+phi2)>}
4550  // numerator in the expression for the the unbiased estimator for covariance:
4551  Double_t numerator15 = product15 - term1st15*term2nd15; 
4552  // denominator in the expression for the the unbiased estimator for covariance:
4553  Double_t denominator15 = 0.;
4554  if(TMath::Abs(sumOfW1st15*sumOfW2nd15)>0.) 
4555  {  
4556   denominator15 = 1.-sumOfWW15/(sumOfW1st15*sumOfW2nd15);
4557   if(TMath::Abs(denominator15)>0.) 
4558   { 
4559    // covariance:
4560    Double_t covariance15 = numerator15/denominator15;
4561    // weight dependent prefactor for covariance:
4562    Double_t wPrefactor15 = sumOfWW15/(sumOfW1st15*sumOfW2nd15);
4563    // finally, store "weighted" covariance:
4564    fIntFlowCovariancesNUA->SetBinContent(15,wPrefactor15*covariance15);
4565   } // end of if(TMath::Abs(denominator15)>0.)  
4566  } // end of if(TMath::Abs(sumOfW1st15*sumOfW2nd15)>0.)  
4567  
4568  // Cov(<cos(phi1)>,<cos(phi1-phi2-phi3)>):
4569  Double_t product16 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(16); // <<cos(phi1)><cos(phi1-phi2-phi3)>> 
4570  Double_t term1st16 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(1); // <<cos(phi1)>>
4571  Double_t term2nd16 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(3); // <<cos(phi1-phi2-phi3)>>
4572  Double_t sumOfW1st16 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(1); // W_{<cos(phi1)>}
4573  Double_t sumOfW2nd16 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(3); // W_{<cos(phi1-phi2-phi3)>}
4574  Double_t sumOfWW16 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(16); // W_{<cos(phi1)>} * W_{<cos(phi1-phi2-phi3)>}
4575  // numerator in the expression for the the unbiased estimator for covariance:
4576  Double_t numerator16 = product16 - term1st16*term2nd16; 
4577  // denominator in the expression for the the unbiased estimator for covariance:
4578  Double_t denominator16 = 0.;
4579  if(TMath::Abs(sumOfW1st16*sumOfW2nd16)>0.) 
4580  {   
4581   denominator16 = 1.-sumOfWW16/(sumOfW1st16*sumOfW2nd16);
4582   if(TMath::Abs(denominator16)>0.) 
4583   {   
4584    // covariance:
4585    Double_t covariance16 = numerator16/denominator16;
4586    // weight dependent prefactor for covariance:
4587    Double_t wPrefactor16 = sumOfWW16/(sumOfW1st16*sumOfW2nd16);
4588    // finally, store "weighted" covariance:
4589    fIntFlowCovariancesNUA->SetBinContent(16,wPrefactor16*covariance16);
4590   } // end of if(TMath::Abs(denominator16)>0.)
4591  } // end ofif(TMath::Abs(sumOfW1st16*sumOfW2nd16)>0.)  
4592  
4593  // Cov(<cos(phi1)>,<sin(phi1-phi2-phi3)>):
4594  Double_t product17 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(17); // <<cos(phi1)><sin(phi1-phi2-phi3)>> 
4595  Double_t term1st17 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(1); // <<cos(phi1)>>
4596  Double_t term2nd17 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(3); // <<sin(phi1-phi2-phi3)>>
4597  Double_t sumOfW1st17 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(1); // W_{<cos(phi1)>}
4598  Double_t sumOfW2nd17 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(3); // W_{<sin(phi1-phi2-phi3)>}
4599  Double_t sumOfWW17 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(17); // W_{<cos(phi1)>} * W_{<sin(phi1-phi2-phi3)>}
4600  // numerator in the expression for the the unbiased estimator for covariance:
4601  Double_t numerator17 = product17 - term1st17*term2nd17; 
4602  // denominator in the expression for the the unbiased estimator for covariance:
4603  Double_t denominator17 = 0.;
4604  if(TMath::Abs(sumOfW1st17*sumOfW2nd17)>0.) 
4605  {
4606   denominator17 = 1.-sumOfWW17/(sumOfW1st17*sumOfW2nd17);
4607   if(TMath::Abs(denominator17)>0.) 
4608   {   
4609    // covariance:
4610    Double_t covariance17 = numerator17/denominator17;
4611    // weight dependent prefactor for covariance:
4612    Double_t wPrefactor17 = sumOfWW17/(sumOfW1st17*sumOfW2nd17);
4613     // finally, store "weighted" covariance:
4614    fIntFlowCovariancesNUA->SetBinContent(17,wPrefactor17*covariance17);
4615   } // end of if(TMath::Abs(denominator17)>0.) 
4616  } // end of if(TMath::Abs(sumOfW1st17*sumOfW2nd17)>0.) 
4617
4618  // Cov(<sin(phi1)>,<cos(phi1+phi2)>):
4619  Double_t product18 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(18); // <<sin(phi1)><cos(phi1+phi2)>> 
4620  Double_t term1st18 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(1); // <<sin(phi1)>>
4621  Double_t term2nd18 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(2); // <<cos(phi1+phi2)>>
4622  Double_t sumOfW1st18 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(1); // W_{<sin(phi1)>}
4623  Double_t sumOfW2nd18 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(2); // W_{<cos(phi1+phi2)>}
4624  Double_t sumOfWW18 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(18); // W_{<sin(phi1)>} * W_{<cos(phi1+phi2)>}
4625  // numerator in the expression for the the unbiased estimator for covariance:
4626  Double_t numerator18 = product18 - term1st18*term2nd18; 
4627  // denominator in the expression for the the unbiased estimator for covariance:
4628  Double_t denominator18 = 0.;
4629  if(TMath::Abs(sumOfW1st18*sumOfW2nd18)>0.) 
4630  { 
4631   denominator18 = 1.-sumOfWW18/(sumOfW1st18*sumOfW2nd18);
4632   if(TMath::Abs(denominator18)>0.) 
4633   {   
4634    // covariance:
4635    Double_t covariance18 = numerator18/denominator18;
4636    // weight dependent prefactor for covariance:
4637    Double_t wPrefactor18 = sumOfWW18/(sumOfW1st18*sumOfW2nd18);
4638    // finally, store "weighted" covariance:
4639    fIntFlowCovariancesNUA->SetBinContent(18,wPrefactor18*covariance18); 
4640   } // end of if(TMath::Abs(denominator18)>0.) 
4641  } // end of if(TMath::Abs(sumOfW1st18*sumOfW2nd18)>0.) 
4642
4643  // Cov(<sin(phi1)>,<sin(phi1+phi2)>):
4644  Double_t product19 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(19); // <<sin(phi1)><sin(phi1+phi2)>> 
4645  Double_t term1st19 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(1); // <<sin(phi1)>>
4646  Double_t term2nd19 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(2); // <<sin(phi1+phi2)>>
4647  Double_t sumOfW1st19 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(1); // W_{<sin(phi1)>}
4648  Double_t sumOfW2nd19 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(2); // W_{<sin(phi1+phi2)>}
4649  Double_t sumOfWW19 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(19); // W_{<sin(phi1)>} * W_{<sin(phi1+phi2)>}
4650  // numerator in the expression for the the unbiased estimator for covariance:
4651  Double_t numerator19 = product19 - term1st19*term2nd19; 
4652  // denominator in the expression for the the unbiased estimator for covariance:
4653  Double_t denominator19 = 0.;
4654  if(TMath::Abs(sumOfW1st19*sumOfW2nd19)>0.) 
4655  { 
4656   denominator19 = 1.-sumOfWW19/(sumOfW1st19*sumOfW2nd19);
4657   if(TMath::Abs(denominator19)>0.) 
4658   {   
4659    // covariance:
4660    Double_t covariance19 = numerator19/denominator19;
4661    // weight dependent prefactor for covariance:
4662    Double_t wPrefactor19 = sumOfWW19/(sumOfW1st19*sumOfW2nd19);
4663    // finally, store "weighted" covariance:
4664    fIntFlowCovariancesNUA->SetBinContent(19,wPrefactor19*covariance19);
4665   } // end of if(TMath::Abs(denominator19)>0.)
4666  } // end of if(TMath::Abs(sumOfW1st19*sumOfW2nd19)>0.)
4667  
4668  // Cov(<sin(phi1)>,<cos(phi1-phi2-phi3)>):
4669  Double_t product20 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(20); // <<sin(phi1)><cos(phi1-phi2-phi3)>> 
4670  Double_t term1st20 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(1); // <<sin(phi1)>>
4671  Double_t term2nd20 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(3); // <<cos(phi1-phi2-phi3)>>
4672  Double_t sumOfW1st20 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(1); // W_{<sin(phi1)>}
4673  Double_t sumOfW2nd20 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(3); // W_{<cos(phi1-phi2-phi3)>}
4674  Double_t sumOfWW20 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(20); // W_{<sin(phi1)>} * W_{<cos(phi1-phi2-phi3)>}
4675  // numerator in the expression for the the unbiased estimator for covariance:
4676  Double_t numerator20 = product20 - term1st20*term2nd20; 
4677  // denominator in the expression for the the unbiased estimator for covariance:
4678  Double_t denominator20 = 0.;
4679  if(TMath::Abs(sumOfW1st20*sumOfW2nd20)>0.)
4680  { 
4681   denominator20 = 1.-sumOfWW20/(sumOfW1st20*sumOfW2nd20);
4682   if(TMath::Abs(denominator20)>0.) 
4683   { 
4684    // covariance:
4685    Double_t covariance20 = numerator20/denominator20;
4686    // weight dependent prefactor for covariance:
4687    Double_t wPrefactor20 = sumOfWW20/(sumOfW1st20*sumOfW2nd20);
4688    // finally, store "weighted" covariance:
4689    fIntFlowCovariancesNUA->SetBinContent(20,wPrefactor20*covariance20);
4690   } // end of if(TMath::Abs(denominator20)>0.) 
4691  } // end of if(TMath::Abs(sumOfW1st20*sumOfW2nd20)>0.)
4692
4693  // Cov(<sin(phi1)>,<sin(phi1-phi2-phi3)>):
4694  Double_t product21 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(21); // <<sin(phi1)><sin(phi1-phi2-phi3)>> 
4695  Double_t term1st21 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(1); // <<sin(phi1)>>
4696  Double_t term2nd21 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(3); // <<sin(phi1-phi2-phi3)>>
4697  Double_t sumOfW1st21 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(1); // W_{<sin(phi1)>}
4698  Double_t sumOfW2nd21 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(3); // W_{<sin(phi1-phi2-phi3)>}
4699  Double_t sumOfWW21 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(21); // W_{<sin(phi1)>} * W_{<sin(phi1-phi2-phi3)>}
4700  // numerator in the expression for the the unbiased estimator for covariance:
4701  Double_t numerator21 = product21 - term1st21*term2nd21; 
4702  // denominator in the expression for the the unbiased estimator for covariance:
4703  Double_t denominator21 = 0.;
4704  if(TMath::Abs(sumOfW1st21*sumOfW2nd21)>0.)
4705  { 
4706   denominator21 = 1.-sumOfWW21/(sumOfW1st21*sumOfW2nd21);
4707   if(TMath::Abs(denominator21)>0.) 
4708   {   
4709    // covariance:
4710    Double_t covariance21 = numerator21/denominator21;
4711    // weight dependent prefactor for covariance:
4712    Double_t wPrefactor21 = sumOfWW21/(sumOfW1st21*sumOfW2nd21);
4713    // finally, store "weighted" covariance:
4714    fIntFlowCovariancesNUA->SetBinContent(21,wPrefactor21*covariance21);
4715   } // end of if(TMath::Abs(denominator21)>0.)
4716  } // end of if(TMath::Abs(sumOfW1st21*sumOfW2nd21)>0.)
4717
4718  // Cov(<cos(phi1+phi2)>,<sin(phi1+phi2)>):
4719  Double_t product22 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(22); // <<cos(phi1+phi2)><sin(phi1+phi2)>> 
4720  Double_t term1st22 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(2); // <<cos(phi1+phi2)>>
4721  Double_t term2nd22 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(2); // <<sin(phi1+phi2)>>
4722  Double_t sumOfW1st22 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(2); // W_{<cos(phi1+phi2)>}
4723  Double_t sumOfW2nd22 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(2); // W_{<sin(phi1+phi2)>}
4724  Double_t sumOfWW22 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(22); // W_{<cos(phi1+phi2)>} * W_{<sin(phi1+phi2)>}
4725  // numerator in the expression for the the unbiased estimator for covariance:
4726  Double_t numerator22 = product22 - term1st22*term2nd22; 
4727  // denominator in the expression for the the unbiased estimator for covariance:
4728  Double_t denominator22 = 0.;
4729  if(TMath::Abs(sumOfW1st22*sumOfW2nd22)>0.)
4730  { 
4731   denominator22 = 1.-sumOfWW22/(sumOfW1st22*sumOfW2nd22);
4732   if(TMath::Abs(denominator22)>0.) 
4733   {   
4734    // covariance:
4735    Double_t covariance22 = numerator22/denominator22;
4736    // weight dependent prefactor for covariance:
4737    Double_t wPrefactor22 = sumOfWW22/(sumOfW1st22*sumOfW2nd22);
4738    // finally, store "weighted" covariance:
4739    fIntFlowCovariancesNUA->SetBinContent(22,wPrefactor22*covariance22);
4740   } // end of if(TMath::Abs(denominator22)>0.) 
4741  } // end of if(TMath::Abs(sumOfW1st22*sumOfW2nd22)>0.) 
4742
4743  // Cov(<cos(phi1+phi2)>,<cos(phi1-phi2-phi3)>):
4744  Double_t product23 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(23); // <<cos(phi1+phi2)><cos(phi1-phi2-phi3)>> 
4745  Double_t term1st23 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(2); // <<cos(phi1+phi2)>>
4746  Double_t term2nd23 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(3); // <<cos(phi1-phi2-phi3)>>
4747  Double_t sumOfW1st23 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(2); // W_{<cos(phi1+phi2)>}
4748  Double_t sumOfW2nd23 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(3); // W_{<cos(phi1-phi2-phi3)>}
4749  Double_t sumOfWW23 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(23); // W_{<cos(phi1+phi2)>} * W_{<cos(phi1-phi2-phi3)>}
4750  // numerator in the expression for the the unbiased estimator for covariance:
4751  Double_t numerator23 = product23 - term1st23*term2nd23; 
4752  // denominator in the expression for the the unbiased estimator for covariance:
4753  Double_t denominator23 = 0.;
4754  if(TMath::Abs(sumOfW1st23*sumOfW2nd23)>0.)
4755  {  
4756   denominator23 = 1.-sumOfWW23/(sumOfW1st23*sumOfW2nd23);
4757   if(TMath::Abs(denominator23)>0.) 
4758   {   
4759    // covariance:
4760    Double_t covariance23 = numerator23/denominator23;
4761    // weight dependent prefactor for covariance:
4762    Double_t wPrefactor23 = sumOfWW23/(sumOfW1st23*sumOfW2nd23);
4763    // finally, store "weighted" covariance:
4764    fIntFlowCovariancesNUA->SetBinContent(23,wPrefactor23*covariance23);
4765   } // end of if(TMath::Abs(denominator23)>0.) 
4766  } // end of if(TMath::Abs(sumOfW1st23*sumOfW2nd23)>0.)
4767  
4768  // Cov(<cos(phi1+phi2)>,<sin(phi1-phi2-phi3)>):
4769  Double_t product24 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(24); // <<cos(phi1+phi2)><sin(phi1-phi2-phi3)>> 
4770  Double_t term1st24 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(2); // <<cos(phi1+phi2)>>
4771  Double_t term2nd24 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(3); // <<sin(phi1-phi2-phi3)>>
4772  Double_t sumOfW1st24 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(2); // W_{<cos(phi1+phi2)>}
4773  Double_t sumOfW2nd24 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(3); // W_{<sin(phi1-phi2-phi3)>}
4774  Double_t sumOfWW24 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(24); // W_{<cos(phi1+phi2)>} * W_{<sin(phi1-phi2-phi3)>}
4775  // numerator in the expression for the the unbiased estimator for covariance:
4776  Double_t numerator24 = product24 - term1st24*term2nd24; 
4777  // denominator in the expression for the the unbiased estimator for covariance:
4778  Double_t denominator24 = 0.;
4779  if(TMath::Abs(sumOfW1st24*sumOfW2nd24)>0.)
4780  {   
4781   denominator24 = 1.-sumOfWW24/(sumOfW1st24*sumOfW2nd24);
4782   if(TMath::Abs(denominator24)>0.) 
4783   {   
4784    // covariance:
4785    Double_t covariance24 = numerator24/denominator24;
4786    // weight dependent prefactor for covariance:
4787    Double_t wPrefactor24 = sumOfWW24/(sumOfW1st24*sumOfW2nd24);
4788    // finally, store "weighted" covariance:
4789    fIntFlowCovariancesNUA->SetBinContent(24,wPrefactor24*covariance24);
4790   } // end of if(TMath::Abs(denominator24)>0.)  
4791  } // end of if(TMath::Abs(sumOfW1st24*sumOfW2nd24)>0.)
4792
4793  // Cov(<sin(phi1+phi2)>,<cos(phi1-phi2-phi3)>):
4794  Double_t product25 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(25); // <<sin(phi1+phi2)><cos(phi1-phi2-phi3)>> 
4795  Double_t term1st25 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(2); // <<sin(phi1+phi2)>>
4796  Double_t term2nd25 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(3); // <<cos(phi1-phi2-phi3)>>
4797  Double_t sumOfW1st25 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(2); // W_{<sin(phi1+phi2)>}
4798  Double_t sumOfW2nd25 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(3); // W_{<cos(phi1-phi2-phi3)>}
4799  Double_t sumOfWW25 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(25); // W_{<sin(phi1+phi2)>} * W_{<cos(phi1-phi2-phi3)>}
4800  // numerator in the expression for the the unbiased estimator for covariance:
4801  Double_t numerator25 = product25 - term1st25*term2nd25; 
4802  // denominator in the expression for the the unbiased estimator for covariance:
4803  Double_t denominator25 = 0.;
4804  if(TMath::Abs(sumOfW1st25*sumOfW2nd25)>0.)
4805  { 
4806   denominator25 = 1.-sumOfWW25/(sumOfW1st25*sumOfW2nd25);
4807   if(TMath::Abs(denominator25)>0.) 
4808   { 
4809    // covariance:
4810    Double_t covariance25 = numerator25/denominator25;
4811    // weight dependent prefactor for covariance:
4812    Double_t wPrefactor25 = sumOfWW25/(sumOfW1st25*sumOfW2nd25);
4813    // finally, store "weighted" covariance:
4814    fIntFlowCovariancesNUA->SetBinContent(25,wPrefactor25*covariance25);
4815   } // end of if(TMath::Abs(denominator25)>0.)
4816  } // end of if(TMath::Abs(sumOfW1st25*sumOfW2nd25)>0.)
4817  
4818  // Cov(<sin(phi1+phi2)>,<sin(phi1-phi2-phi3)>):
4819  Double_t product26 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(26); // <<sin(phi1+phi2)><sin(phi1-phi2-phi3)>> 
4820  Double_t term1st26 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(2); // <<sin(phi1+phi2)>>
4821  Double_t term2nd26 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(3); // <<sin(phi1-phi2-phi3)>>
4822  Double_t sumOfW1st26 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(2); // W_{<sin(phi1+phi2)>}
4823  Double_t sumOfW2nd26 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(3); // W_{<sin(phi1-phi2-phi3)>}
4824  Double_t sumOfWW26 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(26); // W_{<sin(phi1+phi2)>} * W_{<sin(phi1-phi2-phi3)>}
4825  // numerator in the expression for the the unbiased estimator for covariance:
4826  Double_t numerator26 = product26 - term1st26*term2nd26; 
4827  // denominator in the expression for the the unbiased estimator for covariance:
4828  Double_t denominator26 = 0.;
4829  if(TMath::Abs(sumOfW1st26*sumOfW2nd26)>0.)
4830  { 
4831   denominator26 = 1.-sumOfWW26/(sumOfW1st26*sumOfW2nd26);
4832   if(TMath::Abs(denominator26)>0.) 
4833   { 
4834    // covariance:
4835    Double_t covariance26 = numerator26/denominator26;
4836    // weight dependent prefactor for covariance:
4837    Double_t wPrefactor26 = sumOfWW26/(sumOfW1st26*sumOfW2nd26);
4838    // finally, store "weighted" covariance:
4839    fIntFlowCovariancesNUA->SetBinContent(26,wPrefactor26*covariance26);
4840   } // end of if(TMath::Abs(denominator26)>0.) 
4841  } // end of if(TMath::Abs(sumOfW1st26*sumOfW2nd26)>0.)
4842  
4843  // Cov(<cos(phi1-phi2-phi3)>,<sin(phi1-phi2-phi3)>):
4844  Double_t product27 = fIntFlowProductOfCorrectionTermsForNUAPro->GetBinContent(27); // <<cos(phi1-phi2-phi3)><sin(phi1-phi2-phi3)>> 
4845  Double_t term1st27 = fIntFlowCorrectionTermsForNUAPro[1]->GetBinContent(3); // <<cos(phi1-phi2-phi3)>>
4846  Double_t term2nd27 = fIntFlowCorrectionTermsForNUAPro[0]->GetBinContent(3); // <<sin(phi1-phi2-phi3)>>
4847  Double_t sumOfW1st27 = fIntFlowSumOfEventWeightsNUA[1][0]->GetBinContent(3); // W_{<cos(phi1-phi2-phi3)>}
4848  Double_t sumOfW2nd27 = fIntFlowSumOfEventWeightsNUA[0][0]->GetBinContent(3); // W_{<sin(phi1-phi2-phi3)>}
4849  Double_t sumOfWW27 = fIntFlowSumOfProductOfEventWeightsNUA->GetBinContent(27); // W_{<cos(phi1-phi2-phi3)>} * W_{<sin(phi1-phi2-phi3)>}
4850  // numerator in the expression for the the unbiased estimator for covariance:
4851  Double_t numerator27 = product27 - term1st27*term2nd27; 
4852  // denominator in the expression for the the unbiased estimator for covariance:
4853  Double_t denominator27 = 0.;
4854  if(TMath::Abs(sumOfW1st27*sumOfW2nd27)>0.)
4855  { 
4856   denominator27 = 1.-sumOfWW27/(sumOfW1st27*sumOfW2nd27);
4857   if(TMath::Abs(denominator27)>0.) 
4858   { 
4859    // covariance:
4860    Double_t covariance27 = numerator27/denominator27;
4861    // weight dependent prefactor for covariance:
4862    Double_t wPrefactor27 = sumOfWW27/(sumOfW1st27*sumOfW2nd27);
4863    // finally, store "weighted" covariance:
4864    fIntFlowCovariancesNUA->SetBinContent(27,wPrefactor27*covariance27);
4865   } // end of if(TMath::Abs(denominator27)>0.) 
4866  } // end of if(TMath::Abs(sumOfW1st27*sumOfW2nd27)>0.)
4867  
4868 } // end of AliFlowAnalysisWithQCumulants::CalculateCovariancesNUAIntFlow()
4869
4870 //================================================================================================================================
4871
4872 void AliFlowAnalysisWithQCumulants::FinalizeCorrelationsIntFlow() 
4873 {
4874  // From profile fIntFlowCorrelationsPro access measured correlations and spread, 
4875  // correctly calculate the statistical errors and store the final results and 
4876  // statistical errors for correlations in histogram fIntFlowCorrelationsHist.
4877  //
4878  // Remark: Statistical error of correlation is calculated as:
4879  //
4880  //          statistical error = termA * spread * termB:
4881  //          termA = sqrt{sum_{i=1}^{N} w^2}/(sum_{i=1}^{N} w)
4882  //          termB = 1/sqrt(1-termA^2)   
4883  //
4884    
4885  for(Int_t ci=1;ci<=4;ci++) // correlation index
4886  {
4887   if(fIntFlowCorrelationsPro->GetBinEffectiveEntries(ci) < 2 || fIntFlowSquaredCorrelationsPro->GetBinEffectiveEntries(ci) < 2)
4888   {
4889    fIntFlowCorrelationsPro->SetBinError(ci,0.);
4890    fIntFlowSquaredCorrelationsPro->SetBinError(ci,0.);
4891    continue;
4892   } 
4893   Double_t correlation = fIntFlowCorrelationsPro->GetBinContent(ci);
4894   Double_t squaredCorrelation = fIntFlowSquaredCorrelationsPro->GetBinContent(ci);
4895   Double_t spread = 0.;
4896   if(squaredCorrelation-correlation*correlation >= 0.)
4897   {
4898    spread = pow(squaredCorrelation-correlation*correlation,0.5);
4899   } else
4900     {
4901      cout<<endl;
4902      cout<<Form(" WARNING: Imaginary 'spread' for %d-particle correlation!!!! ",2*ci)<<endl;
4903      cout<<endl;
4904     }
4905   Double_t sumOfLinearEventWeights = fIntFlowSumOfEventWeights[0]->GetBinContent(ci);
4906   Double_t sumOfQuadraticEventWeights = fIntFlowSumOfEventWeights[1]->GetBinContent(ci);
4907   Double_t termA = 0.;
4908   Double_t termB = 0.;
4909   if(TMath::Abs(sumOfLinearEventWeights) > 0.) // to be improved - shall I omitt here Abs() ?
4910   {
4911    termA = pow(sumOfQuadraticEventWeights,0.5)/sumOfLinearEventWeights;
4912   } else
4913     {
4914      cout<<endl;
4915      cout<<" WARNING (QC): sumOfLinearEventWeights == 0 in method FinalizeCorrelationsIntFlow() !!!!"<<endl;
4916      cout<<"               (for "<<2*ci<<"-particle correlation)"<<endl;
4917      cout<<endl;
4918     }
4919   if(1.-pow(termA,2.) > 0.)
4920   {
4921    termB = 1./pow(1-pow(termA,2.),0.5);
4922   } else
4923     {
4924      cout<<endl;
4925      cout<<" WARNING (QC): 1.-pow(termA,2.) <= 0 in method FinalizeCorrelationsIntFlow() !!!!"<<endl;   
4926      cout<<"               (for "<<2*ci<<"-particle correlation)"<<endl;
4927      cout<<endl;
4928     }     
4929   Double_t statisticalError = termA * spread * termB;
4930   fIntFlowCorrelationsHist->SetBinContent(ci,correlation);
4931   fIntFlowCorrelationsHist->SetBinError(ci,statisticalError);
4932  } // end of for(Int_t ci=1;ci<=4;ci++) // correlation index     
4933  
4934  // Versus multiplicity: 
4935  if(!fCalculateCumulantsVsM){return;}
4936  for(Int_t ci=0;ci<=3;ci++) // correlation index
4937  {
4938   Int_t nBins = fIntFlowCorrelationsVsMPro[ci]->GetNbinsX(); 
4939   for(Int_t b=1;b<=nBins;b++) // looping over multiplicity bins
4940   {
4941    if(fIntFlowCorrelationsVsMPro[ci]->GetBinEffectiveEntries(b) < 2 || fIntFlowSquaredCorrelationsVsMPro[ci]->GetBinEffectiveEntries(b) < 2)
4942    {
4943     fIntFlowCorrelationsVsMPro[ci]->SetBinError(b,0.);
4944     fIntFlowSquaredCorrelationsVsMPro[ci]->SetBinError(b,0.);
4945     continue;
4946    } 
4947    Double_t correlationVsM = fIntFlowCorrelationsVsMPro[ci]->GetBinContent(b);
4948    Double_t squaredCorrelationVsM = fIntFlowSquaredCorrelationsVsMPro[ci]->GetBinContent(b);
4949    Double_t spreadVsM = 0.;
4950    if(squaredCorrelationVsM-correlationVsM*correlationVsM >= 0.)
4951    {
4952     spreadVsM = pow(squaredCorrelationVsM-correlationVsM*correlationVsM,0.5);
4953    } else
4954      {
4955       cout<<endl;
4956       cout<<Form(" WARNING (QC): Imaginary 'spreadVsM' for ci = %d, bin = %d, entries = %f !!!!",
4957                  ci,b,fIntFlowCorrelationsVsMPro[ci]->GetBinEffectiveEntries(b))<<endl; 
4958       cout<<endl;
4959      }     
4960    Double_t sumOfLinearEventWeightsVsM = fIntFlowSumOfEventWeightsVsM[ci][0]->GetBinContent(b);
4961    Double_t sumOfQuadraticEventWeightsVsM = fIntFlowSumOfEventWeightsVsM[ci][1]->GetBinContent(b);
4962    Double_t termAVsM = 0.;
4963    Double_t termBVsM = 0.;
4964    if(sumOfLinearEventWeightsVsM > 0.) 
4965    {
4966     termAVsM = pow(sumOfQuadraticEventWeightsVsM,0.5)/sumOfLinearEventWeightsVsM;
4967    }
4968    if(1.-pow(termAVsM,2.) > 0.)
4969    {
4970     termBVsM = 1./pow(1-pow(termAVsM,2.),0.5);
4971    }     
4972    Double_t statisticalErrorVsM = termAVsM * spreadVsM * termBVsM;
4973    fIntFlowCorrelationsVsMHist[ci]->SetBinContent(b,correlationVsM);
4974    fIntFlowCorrelationsVsMHist[ci]->SetBinError(b,statisticalErrorVsM);  
4975   } // end of for(Int_t b=1;b<=nBins;b++)
4976  } // end of for(Int_t ci=1;ci<=4;ci++) // correlation index                                                        
4977                                                                                                                            
4978 } // end of AliFlowAnalysisWithQCumulants::FinalizeCorrelationsIntFlow()
4979
4980 //================================================================================================================================
4981
4982 void AliFlowAnalysisWithQCumulants::FillAverageMultiplicities(Int_t nRP)
4983 {
4984  // Fill profile fAverageMultiplicity to hold average multiplicities and 
4985  // number of events for events with nRP>=0, nRP>=1, ... , and nRP>=8
4986  
4987  // Binning of fAverageMultiplicity is organized as follows:
4988  //  1st bin: all events (including the empty ones)
4989  //  2nd bin: event with # of RPs greater or equal to 1
4990  //  3rd bin: event with # of RPs greater or equal to 2
4991  //  4th bin: event with # of RPs greater or equal to 3
4992  //  5th bin: event with # of RPs greater or equal to 4
4993  //  6th bin: event with # of RPs greater or equal to 5
4994  //  7th bin: event with # of RPs greater or equal to 6
4995  //  8th bin: event with # of RPs greater or equal to 7
4996  //  9th bin: event with # of RPs greater or equal to 8
4997  
4998  if(nRP<0)
4999  {
5000   cout<<endl;
5001   cout<<" WARNING (QC): nRP<0 in in AFAWQC::FAM() !!!!"<<endl;
5002   cout<<endl;
5003   exit(0);
5004  }
5005  
5006  for(Int_t i=0;i<9;i++)
5007  {
5008   if(nRP>=i){fAvMultiplicity->Fill(i+0.5,nRP,1);}
5009  }
5010  
5011 } // end of AliFlowAnalysisWithQCumulants::FillAverageMultiplicities(nRP)
5012
5013 //================================================================================================================================
5014
5015 void AliFlowAnalysisWithQCumulants::CalculateCumulantsIntFlow()
5016
5017  // a) Calculate Q-cumulants from the measured multiparticle correlations;
5018  // b) Propagate the statistical errors from measured multiparticle correlations to statistical errors of Q-cumulants;  
5019  // c) Remark: Q-cumulants calculated in this method are biased by non-uniform acceptance of detector !!!! 
5020  //            Method CalculateQcumulantsCorrectedForNUAIntFlow() is called afterwards to correct for this bias;
5021  // d) Store the results and statistical error of Q-cumulants in histogram fIntFlowQcumulants.
5022  //    Binning of fIntFlowQcumulants is organized as follows:
5023  //
5024  //            1st bin: QC{2}
5025  //            2nd bin: QC{4}
5026  //            3rd bin: QC{6}
5027  //            4th bin: QC{8}
5028  //
5029  
5030  // Correlations:
5031  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>> 
5032  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>  
5033  Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>> 
5034  Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>  
5035  // Statistical errors of average 2-, 4-, 6- and 8-particle azimuthal correlations:
5036  Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1); // statistical error of <2>  
5037  Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2); // statistical error of <4>   
5038  Double_t sixError = fIntFlowCorrelationsHist->GetBinError(3); // statistical error of <6> 
5039  Double_t eightError = fIntFlowCorrelationsHist->GetBinError(4); // statistical error of <8> 
5040  // Covariances (multiplied by prefactor depending on weights - see comments in CalculateCovariancesIntFlow()):
5041  Double_t wCov24 = 0.; // Cov(<2>,<4>) * prefactor(w_<2>,w_<4>)
5042  Double_t wCov26 = 0.; // Cov(<2>,<6>) * prefactor(w_<2>,w_<6>)
5043  Double_t wCov28 = 0.; // Cov(<2>,<8>) * prefactor(w_<2>,w_<8>)
5044  Double_t wCov46 = 0.; // Cov(<4>,<6>) * prefactor(w_<4>,w_<6>)
5045  Double_t wCov48 = 0.; // Cov(<4>,<8>) * prefactor(w_<4>,w_<8>)
5046  Double_t wCov68 = 0.; // Cov(<6>,<8>) * prefactor(w_<6>,w_<8>)  
5047  if(!fForgetAboutCovariances)
5048  {
5049   wCov24 = fIntFlowCovariances->GetBinContent(1); // Cov(<2>,<4>) * prefactor(w_<2>,w_<4>)
5050   wCov26 = fIntFlowCovariances->GetBinContent(2); // Cov(<2>,<6>) * prefactor(w_<2>,w_<6>)
5051   wCov28 = fIntFlowCovariances->GetBinContent(3); // Cov(<2>,<8>) * prefactor(w_<2>,w_<8>)
5052   wCov46 = fIntFlowCovariances->GetBinContent(4); // Cov(<4>,<6>) * prefactor(w_<4>,w_<6>)
5053   wCov48 = fIntFlowCovariances->GetBinContent(5); // Cov(<4>,<8>) * prefactor(w_<4>,w_<8>)
5054   wCov68 = fIntFlowCovariances->GetBinContent(6); // Cov(<6>,<8>) * prefactor(w_<6>,w_<8>) 
5055  }
5056  // Q-cumulants: 
5057  Double_t qc2 = 0.; // QC{2}
5058  Double_t qc4 = 0.; // QC{4}
5059  Double_t qc6 = 0.; // QC{6}
5060  Double_t qc8 = 0.; // QC{8}
5061  if(TMath::Abs(two) > 0.){qc2 = two;} 
5062  if(TMath::Abs(four) > 0.){qc4 = four-2.*pow(two,2.);} 
5063  if(TMath::Abs(six) > 0.){qc6 = six-9.*two*four+12.*pow(two,3.);} 
5064  if(TMath::Abs(eight) > 0.){qc8 = eight-16.*two*six-18.*pow(four,2.)+144.*pow(two,2.)*four-144.*pow(two,4.);} 
5065  // Statistical errors of Q-cumulants:       
5066  Double_t qc2Error = 0.;
5067  Double_t qc4Error = 0.;
5068  Double_t qc6Error = 0.;
5069  Double_t qc8Error = 0.; 
5070  // Squared statistical errors of Q-cumulants:       
5071  //Double_t qc2ErrorSquared = 0.;
5072  Double_t qc4ErrorSquared = 0.;
5073  Double_t qc6ErrorSquared = 0.;
5074  Double_t qc8ErrorSquared = 0.;        
5075  // Statistical error of QC{2}:              
5076  qc2Error = twoError;                                                 
5077  // Statistical error of QC{4}:              
5078  qc4ErrorSquared = 16.*pow(two,2.)*pow(twoError,2)+pow(fourError,2.)
5079                  - 8.*two*wCov24;                     
5080  if(qc4ErrorSquared>0.)
5081  {
5082   qc4Error = pow(qc4ErrorSquared,0.5);
5083  } else 
5084    {
5085     cout<<" WARNING (QC): Statistical error of QC{4} is imaginary !!!!"<<endl;
5086    }                                           
5087  // Statistical error of QC{6}:              
5088  qc6ErrorSquared = 81.*pow(4.*pow(two,2.)-four,2.)*pow(twoError,2.)
5089                  + 81.*pow(two,2.)*pow(fourError,2.)
5090                  + pow(sixError,2.)
5091                  - 162.*two*(4.*pow(two,2.)-four)*wCov24
5092                  + 18.*(4.*pow(two,2.)-four)*wCov26
5093                  - 18.*two*wCov46;                     
5094  if(qc6ErrorSquared>0.)
5095  {
5096   qc6Error = pow(qc6ErrorSquared,0.5);
5097  } else 
5098    {
5099     cout<<" WARNING (QC): Statistical error of QC{6} is imaginary !!!!"<<endl;
5100    }                       
5101  // Statistical error of QC{8}:              
5102  qc8ErrorSquared = 256.*pow(36.*pow(two,3.)-18.*four*two+six,2.)*pow(twoError,2.)
5103                  + 1296.*pow(4.*pow(two,2.)-four,2.)*pow(fourError,2.)
5104                  + 256.*pow(two,2.)*pow(sixError,2.)
5105                  + pow(eightError,2.)
5106                  - 1152.*(36.*pow(two,3.)-18.*four*two+six)*(4.*pow(two,2.)-four)*wCov24
5107                  + 512.*two*(36.*pow(two,3.)-18.*four*two+six)*wCov26
5108                  - 32.*(36.*pow(two,3.)-18.*four*two+six)*wCov28
5109                  - 1152.*two*(4.*pow(two,2.)-four)*wCov46
5110                  + 72.*(4.*pow(two,2.)-four)*wCov48
5111                  - 32.*two*wCov68;      
5112  if(qc8ErrorSquared>0.)
5113  {
5114   qc8Error = pow(qc8ErrorSquared,0.5);
5115  } else 
5116    {
5117     cout<<"WARNING (QC): Statistical error of QC{8} is imaginary !!!!"<<endl;
5118    }
5119  // Store the results and statistical errors for Q-cumulants:
5120  if(TMath::Abs(qc2)>0.)
5121  {
5122   fIntFlowQcumulants->SetBinContent(1,qc2);
5123   fIntFlowQcumulants->SetBinError(1,qc2Error);
5124  }
5125  if(TMath::Abs(qc4)>0.)
5126  {
5127   fIntFlowQcumulants->SetBinContent(2,qc4);
5128   fIntFlowQcumulants->SetBinError(2,qc4Error);
5129  }
5130  if(TMath::Abs(qc6)>0.)
5131  {
5132   fIntFlowQcumulants->SetBinContent(3,qc6);
5133   fIntFlowQcumulants->SetBinError(3,qc6Error);
5134  }
5135  if(TMath::Abs(qc8)>0.)
5136  {
5137   fIntFlowQcumulants->SetBinContent(4,qc8); 
5138   fIntFlowQcumulants->SetBinError(4,qc8Error);
5139  } 
5140  
5141  // Versus multiplicity: 
5142  if(!fCalculateCumulantsVsM){return;}
5143  Int_t nBins = fIntFlowCorrelationsVsMPro[0]->GetNbinsX(); // to be improved (hardwired 0) 
5144  Double_t value[4] = {0.}; // QCs vs M
5145  Double_t error[4] = {0.}; // error of QCs vs M
5146  Double_t dSum1[4] = {0.}; // sum value_i/(error_i)^2
5147  Double_t dSum2[4] = {0.}; // sum 1/(error_i)^2
5148  for(Int_t b=1;b<=nBins;b++)
5149  {
5150   // Correlations:
5151   two = fIntFlowCorrelationsVsMHist[0]->GetBinContent(b); // <<2>> 
5152   four = fIntFlowCorrelationsVsMHist[1]->GetBinContent(b); // <<4>>  
5153   six = fIntFlowCorrelationsVsMHist[2]->GetBinContent(b); // <<6>> 
5154   eight = fIntFlowCorrelationsVsMHist[3]->GetBinContent(b); // <<8>>  
5155   // Statistical errors of average 2-, 4-, 6- and 8-particle azimuthal correlations:
5156   twoError = fIntFlowCorrelationsVsMHist[0]->GetBinError(b); // statistical error of <2>  
5157   fourError = fIntFlowCorrelationsVsMHist[1]->GetBinError(b); // statistical error of <4>   
5158   sixError = fIntFlowCorrelationsVsMHist[2]->GetBinError(b); // statistical error of <6> 
5159   eightError = fIntFlowCorrelationsVsMHist[3]->GetBinError(b); // statistical error of <8> 
5160   // Covariances (multiplied by prefactor depending on weights - see comments in CalculateCovariancesIntFlow()):
5161   if(!fForgetAboutCovariances)
5162   {
5163    wCov24 = fIntFlowCovariancesVsM[0]->GetBinContent(b); // Cov(<2>,<4>) * prefactor(w_<2>,w_<4>)
5164    wCov26 = fIntFlowCovariancesVsM[1]->GetBinContent(b); // Cov(<2>,<6>) * prefactor(w_<2>,w_<6>)
5165    wCov28 = fIntFlowCovariancesVsM[2]->GetBinContent(b); // Cov(<2>,<8>) * prefactor(w_<2>,w_<8>)
5166    wCov46 = fIntFlowCovariancesVsM[3]->GetBinContent(b); // Cov(<4>,<6>) * prefactor(w_<4>,w_<6>)
5167    wCov48 = fIntFlowCovariancesVsM[4]->GetBinContent(b); // Cov(<4>,<8>) * prefactor(w_<4>,w_<8>)
5168    wCov68 = fIntFlowCovariancesVsM[5]->GetBinContent(b); // Cov(<6>,<8>) * prefactor(w_<6>,w_<8>) 
5169   }
5170   // Q-cumulants: 
5171   qc2 = 0.; // QC{2}
5172   qc4 = 0.; // QC{4}
5173   qc6 = 0.; // QC{6}
5174   qc8 = 0.; // QC{8}
5175   if(TMath::Abs(two) > 0.){qc2 = two;} 
5176   if(TMath::Abs(four) > 0.){qc4 = four-2.*pow(two,2.);} 
5177   if(TMath::Abs(six) > 0.){qc6 = six-9.*two*four+12.*pow(two,3.);} 
5178   if(TMath::Abs(eight) > 0.){qc8 = eight-16.*two*six-18.*pow(four,2.)+144.*pow(two,2.)*four-144.*pow(two,4.);}  
5179   // Statistical errors of Q-cumulants:       
5180   qc2Error = 0.;
5181   qc4Error = 0.;
5182   qc6Error = 0.;
5183   qc8Error = 0.; 
5184   // Squared statistical errors of Q-cumulants:       
5185   //Double_t qc2ErrorSquared = 0.;
5186   qc4ErrorSquared = 0.;
5187   qc6ErrorSquared = 0.;
5188   qc8ErrorSquared = 0.;    
5189   // Statistical error of QC{2}:              
5190   qc2Error = twoError;                                             
5191   // Statistical error of QC{4}:              
5192   qc4ErrorSquared = 16.*pow(two,2.)*pow(twoError,2)+pow(fourError,2.)
5193                   - 8.*two*wCov24;                     
5194   if(qc4ErrorSquared>0.)
5195   {
5196    qc4Error = pow(qc4ErrorSquared,0.5);
5197   } else 
5198     {
5199      // cout<<"WARNING: Statistical error of QC{4} is imaginary in multiplicity bin "<<b<<" !!!!"<<endl;
5200     }                                       
5201   // Statistical error of QC{6}:              
5202   qc6ErrorSquared = 81.*pow(4.*pow(two,2.)-four,2.)*pow(twoError,2.)
5203                   + 81.*pow(two,2.)*pow(fourError,2.)
5204                   + pow(sixError,2.)
5205                   - 162.*two*(4.*pow(two,2.)-four)*wCov24
5206                   + 18.*(4.*pow(two,2.)-four)*wCov26
5207                   - 18.*two*wCov46;                     
5208   if(qc6ErrorSquared>0.)
5209   {
5210    qc6Error = pow(qc6ErrorSquared,0.5);
5211   } else 
5212     {
5213      // cout<<"WARNING: Statistical error of QC{6} is imaginary in multiplicity bin "<<b<<" !!!!"<<endl;
5214     }                            
5215   // Statistical error of QC{8}:              
5216   qc8ErrorSquared = 256.*pow(36.*pow(two,3.)-18.*four*two+six,2.)*pow(twoError,2.)
5217                   + 1296.*pow(4.*pow(two,2.)-four,2.)*pow(fourError,2.)
5218                   + 256.*pow(two,2.)*pow(sixError,2.)
5219                   + pow(eightError,2.)
5220                   - 1152.*(36.*pow(two,3.)-18.*four*two+six)*(4.*pow(two,2.)-four)*wCov24
5221                   + 512.*two*(36.*pow(two,3.)-18.*four*two+six)*wCov26
5222                   - 32.*(36.*pow(two,3.)-18.*four*two+six)*wCov28
5223                   - 1152.*two*(4.*pow(two,2.)-four)*wCov46
5224                   + 72.*(4.*pow(two,2.)-four)*wCov48
5225                   - 32.*two*wCov68;      
5226   if(qc8ErrorSquared>0.)
5227   {
5228    qc8Error = pow(qc8ErrorSquared,0.5);
5229   } else 
5230     {
5231      // cout<<"WARNING: Statistical error of QC{8} is imaginary in multiplicity bin "<<b<<" !!!!"<<endl;
5232     }
5233   // Store the results and statistical errors for Q-cumulants:
5234   if(TMath::Abs(qc2)>0.)
5235   {
5236    fIntFlowQcumulantsVsM[0]->SetBinContent(b,qc2);
5237    fIntFlowQcumulantsVsM[0]->SetBinError(b,qc2Error);  
5238   }
5239   if(TMath::Abs(qc4)>0.)
5240   {
5241    fIntFlowQcumulantsVsM[1]->SetBinContent(b,qc4);  
5242    fIntFlowQcumulantsVsM[1]->SetBinError(b,qc4Error);
5243   }
5244   if(TMath::Abs(qc6)>0.)
5245   {
5246    fIntFlowQcumulantsVsM[2]->SetBinContent(b,qc6); 
5247    fIntFlowQcumulantsVsM[2]->SetBinError(b,qc6Error);
5248   }
5249   if(TMath::Abs(qc8)>0.)
5250   {  
5251    fIntFlowQcumulantsVsM[3]->SetBinContent(b,qc8);
5252    fIntFlowQcumulantsVsM[3]->SetBinError(b,qc8Error);
5253   } 
5254   // Rebin in M:
5255   for(Int_t co=0;co<4;co++)
5256   {
5257    if(fIntFlowCorrelationsVsMPro[co]->GetBinEffectiveEntries(b)<2){continue;}
5258    value[co] = fIntFlowQcumulantsVsM[co]->GetBinContent(b);
5259    error[co] = fIntFlowQcumulantsVsM[co]->GetBinError(b);
5260    if(error[co]>0.)
5261    {
5262     dSum1[co]+=value[co]/(error[co]*error[co]);
5263     dSum2[co]+=1./(error[co]*error[co]);
5264    }
5265   } // end of for(Int_t co=0;co<4;co++) 
5266  } // end of for(Int_t b=1;b<=nBins;b++)
5267  // Store rebinned Q-cumulants:
5268  for(Int_t co=0;co<4;co++)
5269  {
5270   if(dSum2[co]>0.)
5271   {
5272    fIntFlowQcumulantsRebinnedInM->SetBinContent(co+1,dSum1[co]/dSum2[co]);
5273    fIntFlowQcumulantsRebinnedInM->SetBinError(co+1,pow(1./dSum2[co],0.5));
5274   }
5275  } // end of for(Int_t co=0;co<4;co++)
5276  
5277 } // end of AliFlowAnalysisWithQCumulants::CalculateCumulantsIntFlow()
5278
5279 //================================================================================================================================ 
5280
5281 void AliFlowAnalysisWithQCumulants::CalculateReferenceFlow()
5282 {
5283  // a) Calculate the final results for reference flow estimates from Q-cumulants;
5284  // b) Propagate the statistical errors to reference flow estimates from statistical error of Q-cumulants; 
5285  // c) Store the results and statistical errors of reference flow estimates in histogram fIntFlow.
5286  //    Binning of fIntFlow is organized as follows:
5287  //
5288  //            1st bin: v{2,QC}
5289  //            2nd bin: v{4,QC}
5290  //            3rd bin: v{6,QC}
5291  //            4th bin: v{8,QC}
5292  //
5293  
5294  // Reference flow estimates:
5295  Double_t v2 = 0.; // v{2,QC}  
5296  Double_t v4 = 0.; // v{4,QC}  
5297  Double_t v6 = 0.; // v{6,QC}  
5298  Double_t v8 = 0.; // v{8,QC}
5299  // Reference flow's statistical errors:
5300  Double_t v2Error = 0.; // v{2,QC} stat. error 
5301  Double_t v4Error = 0.; // v{4,QC} stat. error
5302  Double_t v6Error = 0.; // v{6,QC} stat. error
5303  Double_t v8Error = 0.; // v{8,QC} stat. error
5304   
5305  // Q-cumulants:
5306  Double_t qc2 = fIntFlowQcumulants->GetBinContent(1); // QC{2}  
5307  Double_t qc4 = fIntFlowQcumulants->GetBinContent(2); // QC{4}  
5308  Double_t qc6 = fIntFlowQcumulants->GetBinContent(3); // QC{6}  
5309  Double_t qc8 = fIntFlowQcumulants->GetBinContent(4); // QC{8}
5310  // Q-cumulants's statistical errors: 
5311  Double_t qc2Error = fIntFlowQcumulants->GetBinError(1); // QC{2} stat. error  
5312  Double_t qc4Error = fIntFlowQcumulants->GetBinError(2); // QC{4} stat. error  
5313  Double_t qc6Error = fIntFlowQcumulants->GetBinError(3); // QC{6} stat. error  
5314  Double_t qc8Error = fIntFlowQcumulants->GetBinError(4); // QC{8} stat. error
5315  // Calculate reference flow estimates from Q-cumulants: 
5316  if(qc2>=0.){v2 = pow(qc2,0.5);} 
5317  if(qc4<=0.){v4 = pow(-1.*qc4,1./4.);} 
5318  if(qc6>=0.){v6 = pow((1./4.)*qc6,1./6.);}
5319  if(qc8<=0.){v8 = pow((-1./33.)*qc8,1./8.);}  
5320  // Calculate stat. error for reference flow estimates from stat. error of Q-cumulants:  
5321  if(qc2>0.){v2Error = (1./2.)*pow(qc2,-0.5)*qc2Error;} 
5322  if(qc4<0.){v4Error = (1./4.)*pow(-qc4,-3./4.)*qc4Error;} 
5323  if(qc6>0.){v6Error = (1./6.)*pow(2.,-1./3.)*pow(qc6,-5./6.)*qc6Error;}   
5324  if(qc8<0.){v8Error = (1./8.)*pow(33.,-1./8.)*pow(-qc8,-7./8.)*qc8Error;}   
5325  // Print warnings for the 'wrong sign' cumulants: 
5326  if(TMath::Abs(v2) < 1.e-44)
5327  {
5328   cout<<" WARNING: Wrong sign QC{2}, couldn't calculate v{2,QC} !!!!"<<endl;
5329  }
5330  if(TMath::Abs(v4) < 1.e-44)
5331  {
5332   cout<<" WARNING: Wrong sign QC{4}, couldn't calculate v{4,QC} !!!!"<<endl;
5333  } 
5334  if(TMath::Abs(v6) < 1.e-44)
5335  {
5336   cout<<" WARNING: Wrong sign QC{6}, couldn't calculate v{6,QC} !!!!"<<endl; 
5337  }
5338  if(TMath::Abs(v8) < 1.e-44)
5339  {
5340   cout<<" WARNING: Wrong sign QC{8}, couldn't calculate v{8,QC} !!!!"<<endl;
5341  }                       
5342  // Store the results and statistical errors of integrated flow estimates:
5343  fIntFlow->SetBinContent(1,v2);
5344  fIntFlow->SetBinError(1,v2Error);
5345  fIntFlow->SetBinContent(2,v4);
5346  fIntFlow->SetBinError(2,v4Error);
5347  fIntFlow->SetBinContent(3,v6);
5348  fIntFlow->SetBinError(3,v6Error);
5349  fIntFlow->SetBinContent(4,v8);
5350  fIntFlow->SetBinError(4,v8Error);  
5351   
5352  // Versus multiplicity: 
5353  if(!fCalculateCumulantsVsM){return;} 
5354  Int_t nBins = fIntFlowCorrelationsVsMPro[0]->GetNbinsX(); // to be improved (hardwired 0) 
5355  for(Int_t b=1;b<=nBins;b++)
5356  {
5357   // Q-cumulants:
5358   Double_t qc2VsM = fIntFlowQcumulantsVsM[0]->GetBinContent(b); // QC{2}  
5359   Double_t qc4VsM = fIntFlowQcumulantsVsM[1]->GetBinContent(b); // QC{4}  
5360   Double_t qc6VsM = fIntFlowQcumulantsVsM[2]->GetBinContent(b); // QC{6}  
5361   Double_t qc8VsM = fIntFlowQcumulantsVsM[3]->GetBinContent(b); // QC{8}
5362   // Q-cumulants's statistical errors: 
5363   Double_t qc2ErrorVsM = fIntFlowQcumulantsVsM[0]->GetBinError(b); // QC{2} stat. error  
5364   Double_t qc4ErrorVsM = fIntFlowQcumulantsVsM[1]->GetBinError(b); // QC{4} stat. error  
5365   Double_t qc6ErrorVsM = fIntFlowQcumulantsVsM[2]->GetBinError(b); // QC{6} stat. error  
5366   Double_t qc8ErrorVsM = fIntFlowQcumulantsVsM[3]->GetBinError(b); // QC{8} stat. error
5367   // Reference flow estimates:
5368   Double_t v2VsM = 0.; // v{2,QC}  
5369   Double_t v4VsM = 0.; // v{4,QC}  
5370   Double_t v6VsM = 0.; // v{6,QC}  
5371   Double_t v8VsM = 0.; // v{8,QC}
5372   // Reference flow estimates errors:
5373   Double_t v2ErrorVsM = 0.; // v{2,QC} stat. error  
5374   Double_t v4ErrorVsM = 0.; // v{4,QC} stat. error
5375   Double_t v6ErrorVsM = 0.; // v{6,QC} stat. error  
5376   Double_t v8ErrorVsM = 0.; // v{8,QC} stat. error
5377   // Calculate reference flow estimates from Q-cumulants: 
5378   if(qc2VsM>=0.){v2VsM = pow(qc2VsM,0.5);} 
5379   if(qc4VsM<=0.){v4VsM = pow(-1.*qc4VsM,1./4.);} 
5380   if(qc6VsM>=0.){v6VsM = pow((1./4.)*qc6VsM,1./6.);}
5381   if(qc8VsM<=0.){v8VsM = pow((-1./33.)*qc8VsM,1./8.);}  
5382   // Calculate stat. error for reference flow estimates from stat. error of Q-cumulants: 
5383   if(qc2VsM>0.){v2ErrorVsM = (1./2.)*pow(qc2VsM,-0.5)*qc2ErrorVsM;} 
5384   if(qc4VsM<0.){v4ErrorVsM = (1./4.)*pow(-qc4VsM,-3./4.)*qc4ErrorVsM;} 
5385   if(qc6VsM>0.){v6ErrorVsM = (1./6.)*pow(2.,-1./3.)*pow(qc6VsM,-5./6.)*qc6ErrorVsM;}   
5386   if(qc8VsM<0.){v8ErrorVsM = (1./8.)*pow(33.,-1./8.)*pow(-qc8VsM,-7./8.)*qc8ErrorVsM;}                       
5387   // Store the results and statistical errors of integrated flow estimates:
5388   fIntFlowVsM[0]->SetBinContent(b,v2VsM);
5389   fIntFlowVsM[0]->SetBinError(b,v2ErrorVsM);
5390   fIntFlowVsM[1]->SetBinContent(b,v4VsM);
5391   fIntFlowVsM[1]->SetBinError(b,v4ErrorVsM);
5392   fIntFlowVsM[2]->SetBinContent(b,v6VsM);
5393   fIntFlowVsM[2]->SetBinError(b,v6ErrorVsM);
5394   fIntFlowVsM[3]->SetBinContent(b,v8VsM);
5395   fIntFlowVsM[3]->SetBinError(b,v8ErrorVsM);
5396  } // end of for(Int_t b=1;b<=nBins;b++)
5397  
5398  // 'Rebinned in M' calculation: // to be improved - this can be implemented better:   
5399  // Reference flow estimates:
5400  Double_t v2RebinnedInM = 0.; // v{2,QC}  
5401  Double_t v4RebinnedInM = 0.; // v{4,QC}  
5402  Double_t v6RebinnedInM = 0.; // v{6,QC}  
5403  Double_t v8RebinnedInM = 0.; // v{8,QC}
5404  // Reference flow's statistical errors:
5405  Double_t v2ErrorRebinnedInM = 0.; // v{2,QC} stat. error 
5406  Double_t v4ErrorRebinnedInM = 0.; // v{4,QC} stat. error
5407  Double_t v6ErrorRebinnedInM = 0.; // v{6,QC} stat. error
5408  Double_t v8ErrorRebinnedInM = 0.; // v{8,QC} stat. error
5409  // Q-cumulants:
5410  Double_t qc2RebinnedInM = fIntFlowQcumulantsRebinnedInM->GetBinContent(1); // QC{2}  
5411  Double_t qc4RebinnedInM = fIntFlowQcumulantsRebinnedInM->GetBinContent(2); // QC{4}  
5412  Double_t qc6RebinnedInM = fIntFlowQcumulantsRebinnedInM->GetBinContent(3); // QC{6}  
5413  Double_t qc8RebinnedInM = fIntFlowQcumulantsRebinnedInM->GetBinContent(4); // QC{8}
5414  // Q-cumulants's statistical errors: 
5415  Double_t qc2ErrorRebinnedInM = fIntFlowQcumulantsRebinnedInM->GetBinError(1); // QC{2} stat. error  
5416  Double_t qc4ErrorRebinnedInM = fIntFlowQcumulantsRebinnedInM->GetBinError(2); // QC{4} stat. error  
5417  Double_t qc6ErrorRebinnedInM = fIntFlowQcumulantsRebinnedInM->GetBinError(3); // QC{6} stat. error  
5418  Double_t qc8ErrorRebinnedInM = fIntFlowQcumulantsRebinnedInM->GetBinError(4); // QC{8} stat. error
5419  // Calculate reference flow estimates from Q-cumulants: 
5420  if(qc2RebinnedInM>=0.){v2RebinnedInM = pow(qc2RebinnedInM,0.5);} 
5421  if(qc4RebinnedInM<=0.){v4RebinnedInM = pow(-1.*qc4RebinnedInM,1./4.);} 
5422  if(qc6RebinnedInM>=0.){v6RebinnedInM = pow((1./4.)*qc6RebinnedInM,1./6.);}
5423  if(qc8RebinnedInM<=0.){v8RebinnedInM = pow((-1./33.)*qc8RebinnedInM,1./8.);}  
5424  // Calculate stat. error for reference flow estimates from stat. error of Q-cumulants: 
5425  if(qc2RebinnedInM>0.){v2ErrorRebinnedInM = (1./2.)*pow(qc2RebinnedInM,-0.5)*qc2ErrorRebinnedInM;} 
5426  if(qc4RebinnedInM<0.){v4ErrorRebinnedInM = (1./4.)*pow(-qc4RebinnedInM,-3./4.)*qc4ErrorRebinnedInM;} 
5427  if(qc6RebinnedInM>0.){v6ErrorRebinnedInM = (1./6.)*pow(2.,-1./3.)*pow(qc6RebinnedInM,-5./6.)*qc6ErrorRebinnedInM;}   
5428  if(qc8RebinnedInM<0.){v8ErrorRebinnedInM = (1./8.)*pow(33.,-1./8.)*pow(-qc8RebinnedInM,-7./8.)*qc8ErrorRebinnedInM;}   
5429  // Print warnings for the 'wrong sign' cumulants: 
5430  if(TMath::Abs(v2RebinnedInM) < 1.e-44)
5431  {
5432   cout<<" WARNING: Wrong sign QC{2} rebinned in M, couldn't calculate v{2,QC} !!!!"<<endl;
5433  }
5434  if(TMath::Abs(v4RebinnedInM) < 1.e-44)
5435  {
5436   cout<<" WARNING: Wrong sign QC{4} rebinned in M, couldn't calculate v{4,QC} !!!!"<<endl;
5437  }
5438  if(TMath::Abs(v6RebinnedInM) < 1.e-44)
5439  {
5440   cout<<" WARNING: Wrong sign QC{6} rebinned in M, couldn't calculate v{6,QC} !!!!"<<endl;
5441  }
5442  if(TMath::Abs(v8RebinnedInM) < 1.e-44)
5443  {
5444   cout<<" WARNING: Wrong sign QC{8} rebinned in M, couldn't calculate v{8,QC} !!!!"<<endl;
5445  }                       
5446  // Store the results and statistical errors of integrated flow estimates:
5447  fIntFlowRebinnedInM->SetBinContent(1,v2RebinnedInM);
5448  fIntFlowRebinnedInM->SetBinError(1,v2ErrorRebinnedInM);
5449  fIntFlowRebinnedInM->SetBinContent(2,v4RebinnedInM);
5450  fIntFlowRebinnedInM->SetBinError(2,v4ErrorRebinnedInM);
5451  fIntFlowRebinnedInM->SetBinContent(3,v6RebinnedInM);
5452  fIntFlowRebinnedInM->SetBinError(3,v6ErrorRebinnedInM);
5453  fIntFlowRebinnedInM->SetBinContent(4,v8RebinnedInM);
5454  fIntFlowRebinnedInM->SetBinError(4,v8ErrorRebinnedInM);    
5455   
5456 } // end of AliFlowAnalysisWithQCumulants::CalculateReferenceFlow()
5457
5458 //================================================================================================================================ 
5459
5460 void AliFlowAnalysisWithQCumulants::FillCommonHistResultsIntFlow()
5461 {
5462  // Fill in AliFlowCommonHistResults histograms relevant for reference flow.
5463  
5464  // There are two possibilities here:
5465  // a) Store minimum bias reference flow - use SetMinimumBiasReferenceFlow(kTRUE). This result is 
5466  //    biased by the interplay between nonflow correlations and multiplicity fluctuations and is 
5467  //    also stored in local histogram fIntFlow; 
5468  // b) Store reference flow obtained from flow analysis performed at fixed multiplicity and 
5469  //    rebinned only at the end of the day - use SetMinimumBiasReferenceFlow(kFALSE). This result
5470  //    is also stored in local histogram fIntFlowRebinnedInM.
5471  
5472  // Reference flow estimates:
5473  Double_t v[4] = {0.};
5474  // Statistical errors of reference flow estimates:
5475  Double_t vError[4] = {0.};
5476   
5477  for(Int_t b=0;b<4;b++)
5478  {
5479   if(fMinimumBiasReferenceFlow)
5480   { 
5481    v[b] = fIntFlow->GetBinContent(b+1);
5482    vError[b] = fIntFlow->GetBinError(b+1);
5483   } else
5484     {
5485      v[b] = fIntFlowRebinnedInM->GetBinContent(b+1);
5486      vError[b] = fIntFlowRebinnedInM->GetBinError(b+1);
5487     }
5488  } // end of for(Int_t b=0;b<4;b++)
5489   
5490  // Fill AliFlowCommonHistResults histogram:
5491  fCommonHistsResults2nd->FillIntegratedFlow(v[0],vError[0]); // to be improved (hardwired 2nd in the name)  
5492  fCommonHistsResults4th->FillIntegratedFlow(v[1],vError[1]); // to be improved (hardwired 4th in the name)
5493  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)) // to be improved (calculate also 6th and 8th order)
5494  {
5495   fCommonHistsResults6th->FillIntegratedFlow(v[2],vError[2]); // to be improved (hardwired 6th in the name)
5496   fCommonHistsResults8th->FillIntegratedFlow(v[3],vError[3]); // to be improved (hardwired 8th in the name) 
5497  }
5498  
5499 } // end of AliFlowAnalysisWithQCumulants::FillCommonHistResultsIntFlow()
5500
5501 //================================================================================================================================ 
5502
5503 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelationsUsingParticleWeights()
5504 {
5505  // Calculate all correlations needed for integrated flow using particle weights.
5506   
5507  // Remark 1: When particle weights are used the binning of fIntFlowCorrelationAllPro is organized as follows:
5508  //
5509  //  1st bin: <2>_{1n|1n} = two1n1nW1W1 = <w1 w2 cos(n*(phi1-phi2))>
5510  //  2nd bin: <2>_{2n|2n} = two2n2nW2W2 = <w1^2 w2^2 cos(2n*(phi1-phi2))>
5511  //  3rd bin: <2>_{3n|3n} = two3n3nW3W3 = <w1^3 w2^3 cos(3n*(phi1-phi2))> 
5512  //  4th bin: <2>_{4n|4n} = two4n4nW4W4 = <w1^4 w2^4 cos(4n*(phi1-phi2))>
5513  //  5th bin:           ----  EMPTY ----
5514  //  6th bin: <3>_{2n|1n,1n} = three2n1n1nW2W1W1 = <w1^2 w2 w3 cos(n*(2phi1-phi2-phi3))>
5515  //  7th bin: <3>_{3n|2n,1n} = ...
5516  //  8th bin: <3>_{4n|2n,2n} = ...
5517  //  9th bin: <3>_{4n|3n,1n} = ...
5518  // 10th bin:           ----  EMPTY ----
5519  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1nW1W1W1W1 = <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))>
5520  // 12th bin: <4>_{2n,1n|2n,1n} = ...
5521  // 13th bin: <4>_{2n,2n|2n,2n} = ...
5522  // 14th bin: <4>_{3n|1n,1n,1n} = ... 
5523  // 15th bin: <4>_{3n,1n|3n,1n} = ...
5524  // 16th bin: <4>_{3n,1n|2n,2n} = ...
5525  // 17th bin: <4>_{4n|2n,1n,1n} = ... 
5526  // 18th bin:           ----  EMPTY ----
5527  // 19th bin: <5>_{2n|1n,1n,1n,1n} = ...
5528  // 20th bin: <5>_{2n,2n|2n,1n,1n} = ...
5529  // 21st bin: <5>_{3n,1n|2n,1n,1n} = ...
5530  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = ...
5531  // 23rd bin:           ----  EMPTY ----
5532  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = ...
5533  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = ...
5534  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = ...
5535  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = ...
5536  // 28th bin:           ----  EMPTY ----
5537  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = ...
5538  // 30th bin:           ----  EMPTY ----
5539  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = ...
5540  
5541  // Remark 2: When particle weights are used there are some extra correlations. They are stored in 
5542  // fIntFlowExtraCorrelationsPro binning of which is organized as follows:
5543  
5544  // 1st bin: two1n1nW3W1 = <w1^3 w2 cos(n*(phi1-phi2))>
5545  // 2nd bin: two1n1nW1W1W2 = <w1 w2 w3^2 cos(n*(phi1-phi2))>  
5546  
5547  // multiplicity (number of particles used to determine the reaction plane)
5548  Double_t dMult = (*fSpk)(0,0);
5549  
5550  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
5551  Double_t dReQ1n1k = (*fReQ)(0,1);
5552  Double_t dReQ2n2k = (*fReQ)(1,2);
5553  Double_t dReQ3n3k = (*fReQ)(2,3);
5554  Double_t dReQ4n4k = (*fReQ)(3,4);
5555  Double_t dReQ1n3k = (*fReQ)(0,3);
5556  Double_t dImQ1n1k = (*fImQ)(0,1);
5557  Double_t dImQ2n2k = (*fImQ)(1,2);
5558  Double_t dImQ3n3k = (*fImQ)(2,3);
5559  Double_t dImQ4n4k = (*fImQ)(3,4);
5560  Double_t dImQ1n3k = (*fImQ)(0,3);
5561
5562  // dMs are variables introduced in order to simplify some Eqs. bellow:
5563  //..............................................................................................
5564  Double_t dM11 = (*fSpk)(1,1)-(*fSpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j
5565  Double_t dM22 = (*fSpk)(1,2)-(*fSpk)(0,4); // dM22 = sum_{i,j=1,i!=j}^M w_i^2 w_j^2
5566  Double_t dM33 = (*fSpk)(1,3)-(*fSpk)(0,6); // dM33 = sum_{i,j=1,i!=j}^M w_i^3 w_j^3
5567  Double_t dM44 = (*fSpk)(1,4)-(*fSpk)(0,8); // dM44 = sum_{i,j=1,i!=j}^M w_i^4 w_j^4
5568  Double_t dM31 = (*fSpk)(0,3)*(*fSpk)(0,1)-(*fSpk)(0,4); // dM31 = sum_{i,j=1,i!=j}^M w_i^3 w_j
5569  Double_t dM211 = (*fSpk)(0,2)*(*fSpk)(1,1)-2.*(*fSpk)(0,3)*(*fSpk)(0,1)
5570                 - (*fSpk)(1,2)+2.*(*fSpk)(0,4); // dM211 = sum_{i,j,k=1,i!=j!=k}^M w_i^2 w_j w_k
5571  Double_t dM1111 = (*fSpk)(3,1)-6.*(*fSpk)(0,2)*(*fSpk)(1,1)  
5572                  + 8.*(*fSpk)(0,3)*(*fSpk)(0,1)
5573                  + 3.*(*fSpk)(1,2)-6.*(*fSpk)(0,4); // dM1111 = sum_{i,j,k,l=1,i!=j!=k!=l}^M w_i w_j w_k w_l
5574  //..............................................................................................
5575
5576  // 2-particle correlations:
5577  Double_t two1n1nW1W1 = 0.; // <w1 w2 cos(n*(phi1-phi2))>
5578  Double_t two2n2nW2W2 = 0.; // <w1^2 w2^2 cos(2n*(phi1-phi2))>
5579  Double_t two3n3nW3W3 = 0.; // <w1^3 w2^3 cos(3n*(phi1-phi2))>
5580  Double_t two4n4nW4W4 = 0.; // <w1^4 w2^4 cos(4n*(phi1-phi2))>
5581  if(dMult>1) 
5582  { 
5583   if(dM11)
5584   {
5585    two1n1nW1W1 = (pow(dReQ1n1k,2)+pow(dImQ1n1k,2)-(*fSpk)(0,2))/dM11;    
5586    // average correlation <w1 w2 cos(n*(phi1-phi2))> for single event: 
5587    fIntFlowCorrelationsEBE->SetBinContent(1,two1n1nW1W1);
5588    fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(1,dM11);
5589    // average correlation <w1 w2 cos(n*(phi1-phi2))> for all events:
5590    fIntFlowCorrelationsPro->Fill(0.5,two1n1nW1W1,dM11);  
5591    // average squared correlation <w1 w2 cos(n*(phi1-phi2))> for all events:
5592    fIntFlowSquaredCorrelationsPro->Fill(0.5,two1n1nW1W1*two1n1nW1W1,dM11); 
5593    fIntFlowCorrelationsAllPro->Fill(0.5,two1n1nW1W1,dM11);   
5594   }
5595   if(dM22)
5596   {
5597    two2n2nW2W2 = (pow(dReQ2n2k,2)+pow(dImQ2n2k,2)-(*fSpk)(0,4))/dM22; 
5598    // ...
5599    // average correlation <w1^2 w2^2 cos(2n*(phi1-phi2))> for all events:
5600    fIntFlowCorrelationsAllPro->Fill(1.5,two2n2nW2W2,dM22);   
5601   }
5602   if(dM33)
5603   {
5604    two3n3nW3W3 = (pow(dReQ3n3k,2)+pow(dImQ3n3k,2)-(*fSpk)(0,6))/dM33;
5605    // ...
5606    // average correlation <w1^3 w2^3 cos(3n*(phi1-phi2))> for all events:
5607    fIntFlowCorrelationsAllPro->Fill(2.5,two3n3nW3W3,dM33);   
5608   }
5609   if(dM44)
5610   {
5611    two4n4nW4W4 = (pow(dReQ4n4k,2)+pow(dImQ4n4k,2)-(*fSpk)(0,8))/dM44; 
5612    // ...
5613    // average correlation <w1^4 w2^4 cos(4n*(phi1-phi2))> for all events:
5614    fIntFlowCorrelationsAllPro->Fill(3.5,two4n4nW4W4,dM44);      
5615   }
5616  } // end of if(dMult>1) 
5617
5618  // extra 2-particle correlations:
5619  Double_t two1n1nW3W1 = 0.; // <w1^3 w2 cos(n*(phi1-phi2))>
5620  Double_t two1n1nW1W1W2 = 0.; // <w1 w2 w3^2 cos(n*(phi1-phi2))> 
5621  if(dMult>1) 
5622  {    
5623   if(dM31)
5624   {
5625    two1n1nW3W1 = (dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k-(*fSpk)(0,4))/dM31; 
5626    fIntFlowExtraCorrelationsPro->Fill(0.5,two1n1nW3W1,dM31);  
5627   } 
5628   if(dM211)
5629   {
5630    two1n1nW1W1W2 = ((*fSpk)(0,2)*(pow(dReQ1n1k,2)+pow(dImQ1n1k,2)-(*fSpk)(0,2))
5631                  - 2.*(dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k
5632                  - (*fSpk)(0,4)))/dM211;
5633    fIntFlowExtraCorrelationsPro->Fill(1.5,two1n1nW1W1W2,dM211);  
5634   }  
5635  } // end of if(dMult>1)
5636  //..............................................................................................
5637  
5638  //..............................................................................................
5639  // 3-particle correlations:
5640  Double_t three2n1n1nW2W1W1 = 0.; // <w1^2 w2 w3 cos(n*(2phi1-phi2-phi3))>
5641  
5642  if(dMult>2) 
5643  { 
5644   if(dM211)
5645   {                                                       
5646    three2n1n1nW2W1W1 = (pow(dReQ1n1k,2.)*dReQ2n2k+2.*dReQ1n1k*dImQ1n1k*dImQ2n2k-pow(dImQ1n1k,2.)*dReQ2n2k
5647                      - 2.*(dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k)
5648                      - pow(dReQ2n2k,2)-pow(dImQ2n2k,2)
5649                      + 2.*(*fSpk)(0,4))/dM211;                                                                               
5650    fIntFlowCorrelationsAllPro->Fill(5.5,three2n1n1nW2W1W1,dM211);
5651   } 
5652  } // end of if(dMult>2) 
5653  //..............................................................................................
5654  
5655  //..............................................................................................
5656  // 4-particle correlations:
5657  Double_t four1n1n1n1nW1W1W1W1 = 0.; // <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))>
5658  if(dMult>3) 
5659  { 
5660   if(dM1111)
5661   {      
5662    four1n1n1n1nW1W1W1W1 = (pow(pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.),2)
5663                         - 2.*(pow(dReQ1n1k,2.)*dReQ2n2k+2.*dReQ1n1k*dImQ1n1k*dImQ2n2k-pow(dImQ1n1k,2.)*dReQ2n2k)
5664                         + 8.*(dReQ1n3k*dReQ1n1k+dImQ1n3k*dImQ1n1k)
5665                         + (pow(dReQ2n2k,2)+pow(dImQ2n2k,2))
5666                         - 4.*(*fSpk)(0,2)*(pow(dReQ1n1k,2)+pow(dImQ1n1k,2))
5667                         - 6.*(*fSpk)(0,4)+2.*(*fSpk)(1,2))/dM1111;  
5668                           
5669    // average correlation <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))> for single event: 
5670    fIntFlowCorrelationsEBE->SetBinContent(2,four1n1n1n1nW1W1W1W1);
5671    fIntFlowEventWeightsForCorrelationsEBE->SetBinContent(2,dM1111);
5672    // average correlation <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))> for all events:
5673    fIntFlowCorrelationsPro->Fill(1.5,four1n1n1n1nW1W1W1W1,dM1111);   
5674    // average squared correlation <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))> for all events:
5675    fIntFlowSquaredCorrelationsPro->Fill(1.5,four1n1n1n1nW1W1W1W1*four1n1n1n1nW1W1W1W1,dM1111);      
5676    fIntFlowCorrelationsAllPro->Fill(10.5,four1n1n1n1nW1W1W1W1,dM1111);   
5677   } 
5678  } // end of if(dMult>3) 
5679  //..............................................................................................
5680  
5681 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrelationsUsingParticleWeights()
5682
5683 //================================================================================================================================
5684
5685 void AliFlowAnalysisWithQCumulants::InitializeArraysForIntFlow()
5686 {
5687  // Initialize all arrays used to calculate integrated flow.
5688  
5689  for(Int_t sc=0;sc<2;sc++) // sin or cos terms
5690  {
5691   fIntFlowCorrectionTermsForNUAEBE[sc] = NULL;
5692   fIntFlowEventWeightForCorrectionTermsForNUAEBE[sc] = NULL;
5693   fIntFlowCorrectionTermsForNUAPro[sc] = NULL;
5694   fIntFlowCorrectionTermsForNUAHist[sc] = NULL;
5695   for(Int_t ci=0;ci<4;ci++) // correction term index (to be improved - hardwired 4)
5696   {
5697    fIntFlowCorrectionTermsForNUAVsMPro[sc][ci] = NULL;
5698   }
5699   for(Int_t power=0;power<2;power++) // linear or quadratic 
5700   {
5701    fIntFlowSumOfEventWeightsNUA[sc][power] = NULL;
5702   }
5703  }
5704  for(Int_t power=0;power<2;power++) // linear or quadratic 
5705  {
5706   fIntFlowSumOfEventWeights[power] = NULL;    
5707  }
5708  for(Int_t i=0;i<4;i++) // print on the screen the final results (0=RF, 1=RP, 2=POI, 3=RF (rebbined in M))
5709  {
5710   fPrintFinalResults[i] = kTRUE;
5711  }
5712  for(Int_t ci=0;ci<4;ci++) // correlation index or cumulant order
5713  {
5714   fIntFlowCorrelationsVsMPro[ci] = NULL;
5715   fIntFlowSquaredCorrelationsVsMPro[ci] = NULL;
5716   fIntFlowCorrelationsVsMHist[ci] = NULL;
5717   fIntFlowQcumulantsVsM[ci] = NULL;
5718   fIntFlowVsM[ci] = NULL;
5719   fIntFlowDetectorBiasVsM[ci] = NULL;
5720   for(Int_t lc=0;lc<2;lc++)
5721   {
5722    fIntFlowSumOfEventWeightsVsM[ci][lc] = NULL;
5723   }
5724  } 
5725  for(Int_t pi=0;pi<6;pi++) // product or covariance index
5726  {
5727   fIntFlowProductOfCorrelationsVsMPro[pi] = NULL;
5728   fIntFlowCovariancesVsM[pi] = NULL;
5729   fIntFlowSumOfProductOfEventWeightsVsM[pi] = NULL;
5730  } 
5731  for(Int_t ci=0;ci<64;ci++) // correlation index for all correlations vs M profiles (to be improved - hardwired 64)
5732  {
5733   fIntFlowCorrelationsAllVsMPro[ci] = NULL;
5734  } 
5735
5736 } // end of void AliFlowAnalysisWithQCumulants::InitializeArraysForIntFlow()
5737
5738 //================================================================================================================================
5739
5740 void AliFlowAnalysisWithQCumulants::InitializeArraysForDiffFlow()
5741 {
5742  // Initialize all arrays needed to calculate differential flow.
5743  //  a) Initialize lists holding profiles;
5744  //  b) Initialize lists holding histograms;
5745  //  c) Initialize event-by-event quantities;
5746  //  d) Initialize profiles;
5747  //  e) Initialize histograms holding final results.
5748  
5749  // a) Initialize lists holding profiles;
5750  for(Int_t t=0;t<2;t++) // type (RP, POI)
5751  {
5752   for(Int_t pe=0;pe<2;pe++) // pt or eta
5753   {
5754    fDiffFlowCorrelationsProList[t][pe] = NULL;
5755    fDiffFlowProductOfCorrelationsProList[t][pe] = NULL;
5756    fDiffFlowCorrectionsProList[t][pe] = NULL;
5757   }
5758   // 2D:
5759   f2DDiffFlowCorrelationsProList[t] = NULL;
5760  }  
5761  
5762  // b) Initialize lists holding histograms;
5763  for(Int_t t=0;t<2;t++) // type (RP, POI)
5764  {
5765   for(Int_t pe=0;pe<2;pe++) // pt or eta
5766   {
5767    fDiffFlowCorrelationsHistList[t][pe] = NULL;
5768    for(Int_t power=0;power<2;power++)
5769    {
5770     fDiffFlowSumOfEventWeightsHistList[t][pe][power] = NULL;
5771    } // end of for(Int_t power=0;power<2;power++)  
5772    fDiffFlowSumOfProductOfEventWeightsHistList[t][pe] = NULL;
5773    fDiffFlowCorrectionsHistList[t][pe] = NULL;
5774    fDiffFlowCovariancesHistList[t][pe] = NULL;
5775    fDiffFlowCumulantsHistList[t][pe] = NULL;
5776    fDiffFlowDetectorBiasHistList[t][pe] = NULL;
5777    fDiffFlowHistList[t][pe] = NULL;
5778   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
5779  } // enf of for(Int_t t=0;t<2;t++) // type (RP, POI) 
5780  
5781  // c) Initialize event-by-event quantities:
5782  // 1D:
5783  for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)
5784  {
5785   for(Int_t pe=0;pe<2;pe++) // pt or eta
5786   { 
5787    for(Int_t m=0;m<4;m++) // multiple of harmonic
5788    {
5789     for(Int_t k=0;k<9;k++) // power of weight
5790     {
5791      fReRPQ1dEBE[t][pe][m][k] = NULL;
5792      fImRPQ1dEBE[t][pe][m][k] = NULL;
5793      fs1dEBE[t][pe][k] = NULL; // to be improved (this doesn't need to be within loop over m)
5794     }   
5795    }
5796   }
5797  }
5798  // 1D:
5799  for(Int_t t=0;t<2;t++) // type (RP or POI)
5800  {
5801   for(Int_t pe=0;pe<2;pe++) // pt or eta
5802   { 
5803    for(Int_t sc=0;sc<2;sc++) // sin or cos terms
5804    {
5805     for(Int_t cti=0;cti<9;cti++) // correction term index
5806     {
5807      fDiffFlowCorrectionTermsForNUAEBE[t][pe][sc][cti] = NULL;
5808     }   
5809    }
5810   }
5811  }
5812  // 2D:  
5813  for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)
5814  {
5815   for(Int_t m=0;m<4;m++) // multiple of harmonic
5816   {
5817    for(Int_t k=0;k<9;k++) // power of weight
5818    {
5819     fReRPQ2dEBE[t][m][k] = NULL;
5820     fImRPQ2dEBE[t][m][k] = NULL;
5821     fs2dEBE[t][k] = NULL; // to be improved (this doesn't need to be within loop over m)
5822    }   
5823   }
5824  }
5825  
5826  // d) Initialize profiles:
5827  for(Int_t t=0;t<2;t++) // type: RP or POI
5828  { 
5829   for(Int_t pe=0;pe<2;pe++) // pt or eta
5830   {
5831    for(Int_t ci=0;ci<4;ci++) // correlation index
5832    {
5833     fDiffFlowCorrelationsPro[t][pe][ci] = NULL;
5834     fDiffFlowSquaredCorrelationsPro[t][pe][ci] = NULL;
5835    } // end of for(Int_t ci=0;ci<4;ci++)   
5836    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index
5837    {
5838     for(Int_t mci2=0;mci2<8;mci2++) // mixed correlation index
5839     {
5840      fDiffFlowProductOfCorrelationsPro[t][pe][mci1][mci2] = NULL;
5841     } // end of for(Int_t mci2=0;mci2<8;mci2++) // mixed correlation index
5842    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index  
5843    // correction terms for nua:
5844    for(Int_t sc=0;sc<2;sc++) // sin or cos terms
5845    {
5846     for(Int_t cti=0;cti<9;cti++) // correction term index
5847     {
5848      fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti] = NULL;
5849     }   
5850    }
5851    // other differential correlators:
5852    for(Int_t sc=0;sc<2;sc++) // sin or cos terms
5853    {
5854     for(Int_t ci=0;ci<1;ci++) // correction term index
5855     {
5856      fOtherDiffCorrelators[t][pe][sc][ci] = NULL;
5857     }   
5858    }
5859   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
5860   for(Int_t ci=0;ci<4;ci++) // correlation index
5861   {
5862    f2DDiffFlowCorrelationsPro[t][ci] = NULL;
5863   }
5864  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
5865   
5866  // e) Initialize histograms holding final results.
5867  for(Int_t t=0;t<2;t++) // type: RP or POI
5868  { 
5869   for(Int_t pe=0;pe<2;pe++) // pt or eta
5870   {
5871    for(Int_t ci=0;ci<4;ci++) // correlation index
5872    {
5873     fDiffFlowCorrelationsHist[t][pe][ci] = NULL;
5874     fDiffFlowCumulants[t][pe][ci] = NULL;
5875     fDiffFlowDetectorBias[t][pe][ci] = NULL;
5876     fDiffFlow[t][pe][ci] = NULL;
5877    } // end of for(Int_t ci=0;ci<4;ci++)    
5878    for(Int_t covarianceIndex=0;covarianceIndex<5;covarianceIndex++) 
5879    {
5880     fDiffFlowCovariances[t][pe][covarianceIndex] = NULL;     
5881    } // end of for(Int_t covarianceIndex=0;covarianceIndex<5;covarianceIndex++) 
5882    // correction terms for nua:
5883    for(Int_t sc=0;sc<2;sc++) // sin or cos terms
5884    {
5885     for(Int_t cti=0;cti<9;cti++) // correction term index
5886     {
5887      fDiffFlowCorrectionTermsForNUAHist[t][pe][sc][cti] = NULL;
5888     }   
5889    }
5890   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
5891   for(Int_t ci=0;ci<4;ci++) // correlation index
5892   {
5893    f2DDiffFlowCumulants[t][ci] = NULL;
5894    f2DDiffFlow[t][ci] = NULL;
5895   }
5896  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
5897  
5898  // sum of event weights for reduced correlations:
5899  for(Int_t t=0;t<2;t++) // type = RP or POI
5900  {
5901   for(Int_t pe=0;pe<2;pe++) // pt or eta
5902   {
5903    for(Int_t p=0;p<2;p++) // power of weight is 1 or 2
5904    {
5905     for(Int_t ew=0;ew<4;ew++) // event weight index for reduced correlations
5906     {
5907      fDiffFlowSumOfEventWeights[t][pe][p][ew] = NULL;
5908     } 
5909    }   
5910   }
5911  }
5912  // product of event weights for both types of correlations:
5913  for(Int_t t=0;t<2;t++) // type = RP or POI
5914  {
5915   for(Int_t pe=0;pe<2;pe++) // pt or eta
5916   {
5917    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index
5918    {
5919     for(Int_t mci2=0;mci2<8;mci2++) // mixed correlation index
5920     {
5921      fDiffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2] = NULL;
5922     } 
5923    }   
5924   }
5925  }
5926     
5927 } // end of AliFlowAnalysisWithQCumulants::InitializeArraysForDiffFlow()
5928
5929 //================================================================================================================================
5930
5931 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulants(TString type, TString ptOrEta)
5932 {
5933  // Calculate differential flow cumulants from measured multiparticle correlations.
5934  
5935  // REMARK: Cumulants calculated in this method are NOT corrected for non-uniform acceptance. 
5936  // This correction, if enabled via setter SetApplyCorrectionForNUA(Bool_t), is applied 
5937  // in the method CalculateDiffFlowCumulantsCorrectedForNUA(TString type, TString ptOrEta)
5938  
5939  Int_t t = 0;
5940  Int_t pe = 0;
5941
5942  if(type == "RP")
5943  {
5944   t = 0;
5945  } else if(type == "POI")
5946    {
5947     t = 1;
5948    } 
5949      
5950  if(ptOrEta == "Pt")
5951  {
5952   pe = 0;
5953  } else if(ptOrEta == "Eta")
5954    {
5955     pe = 1;
5956    } 
5957      
5958  // Common:
5959  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
5960  
5961  // Correlation <<2>>: 
5962  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1);
5963  Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1);
5964  
5965  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
5966  {
5967   // Reduced correlations:   
5968   Double_t twoPrime = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b); // <<2'>>
5969   Double_t twoPrimeError = fDiffFlowCorrelationsHist[t][pe][0]->GetBinError(b); // stat. error of <<2'>>
5970   Double_t fourPrime = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b); // <<4'>>
5971   Double_t fourPrimeError = fDiffFlowCorrelationsHist[t][pe][1]->GetBinError(b); // stat. error of <<4'>>
5972   // Covariances:
5973   Double_t wCovTwoTwoReduced = fDiffFlowCovariances[t][pe][0]->GetBinContent(b); // Cov(<2>,<2'>) * prefactor(<2>,<2'>)
5974   Double_t wCovTwoFourReduced = fDiffFlowCovariances[t][pe][1]->GetBinContent(b); // Cov(<2>,<4'>) * prefactor(<2>,<4'>)
5975   Double_t wCovTwoReducedFourReduced = fDiffFlowCovariances[t][pe][4]->GetBinContent(b); // Cov(<2'>,<4'>) * prefactor(<2'>,<4'>)
5976   // QC{2'}:
5977   Double_t qc2Prime = twoPrime; // QC{2'}
5978   Double_t qc2PrimeError = twoPrimeError; // stat. error of QC{2'}
5979   fDiffFlowCumulants[t][pe][0]->SetBinContent(b,qc2Prime); 
5980   fDiffFlowCumulants[t][pe][0]->SetBinError(b,qc2PrimeError); 
5981   // QC{4'}:
5982   Double_t qc4Prime = fourPrime - 2.*twoPrime*two; // QC{4'} = <<4'>> - 2*<<2'>><<2>>
5983   Double_t qc4PrimeError = 0.; // stat. error of QC{4'}
5984   Double_t qc4PrimeErrorSquared = 4.*pow(twoPrime,2.)*pow(twoError,2.)
5985                                 + 4.*pow(two,2.)*pow(twoPrimeError,2.)
5986                                 + pow(fourPrimeError,2.)
5987                                 + 8.*two*twoPrime*wCovTwoTwoReduced
5988                                 - 4.*twoPrime*wCovTwoFourReduced
5989                                 - 4.*two*wCovTwoReducedFourReduced;
5990   if(qc4PrimeErrorSquared>0.)
5991   {
5992    qc4PrimeError = pow(qc4PrimeErrorSquared,0.5);
5993   } 
5994   fDiffFlowCumulants[t][pe][1]->SetBinContent(b,qc4Prime); 
5995   fDiffFlowCumulants[t][pe][1]->SetBinError(b,qc4PrimeError); 
5996  } // end of for(Int_t p=1;p<=fnBinsPt;p++)
5997     
5998 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulants(TString type, Bool_t useParticleWeights, TString eventWeights); 
5999
6000 //================================================================================================================================
6001
6002 void AliFlowAnalysisWithQCumulants::Calculate2DDiffFlowCumulants(TString type)
6003 {
6004  // Calculate 2D differential cumulants.
6005  
6006  // Remark: correction for detector effects and error propagation not implemented yet for 2D differential cumulants.
6007  
6008  Int_t t = 0;
6009
6010  if(type == "RP")
6011  {
6012   t = 0;
6013  } else if(type == "POI")
6014    {
6015     t = 1;
6016    }
6017        
6018  // Reference correlation <<2>>: 
6019  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1);
6020  
6021  // Looping over all (pt,eta) bins and calculating differential flow cumulants: 
6022  for(Int_t p=1;p<=fnBinsPt;p++)
6023  {
6024   for(Int_t e=1;e<=fnBinsEta;e++)
6025   {
6026    // Reduced correlations:   
6027    Double_t twoPrime = f2DDiffFlowCorrelationsPro[t][0]->GetBinContent(f2DDiffFlowCorrelationsPro[t][0]->GetBin(p,e)); // <<2'>>(pt,eta)
6028    Double_t fourPrime = f2DDiffFlowCorrelationsPro[t][1]->GetBinContent(f2DDiffFlowCorrelationsPro[t][1]->GetBin(p,e)); // <<4'>>(pt,eta)
6029    // Cumulants:
6030    Double_t qc2Prime = twoPrime; // QC{2'} = <<2'>>   
6031    f2DDiffFlowCumulants[t][0]->SetBinContent(f2DDiffFlowCumulants[t][0]->GetBin(p,e),qc2Prime); 
6032    Double_t qc4Prime = fourPrime - 2.*twoPrime*two; // QC{4'} = <<4'>> - 2*<<2'>><<2>>
6033    f2DDiffFlowCumulants[t][1]->SetBinContent(f2DDiffFlowCumulants[t][1]->GetBin(p,e),qc4Prime); 
6034   } // end of for(Int_t e=1;e<=fnBinsEta;e++)
6035  } // end of for(Int_t p=1;p<=fnBinsPt;p++)
6036  
6037 } // end of void AliFlowAnalysisWithQCumulants::Calculate2DDiffFlowCumulants(TString type)
6038
6039 //================================================================================================================================
6040
6041 void AliFlowAnalysisWithQCumulants::CalculateFinalResultsForRPandPOIIntegratedFlow(TString type)
6042 {
6043  // Calculate final results for integrated flow of RPs and POIs. 
6044   
6045  // to be improved - check if the integrated flow calculation here is actually correct 
6046   
6047  Int_t t = 0; // RP = 0, POI = 1
6048
6049  if(type == "RP")
6050  {
6051   t = 0;
6052  } else if(type == "POI")
6053    {
6054     t = 1;
6055    }
6056      
6057  // pt yield:    
6058  TH1F *yield2ndPt = NULL;
6059  TH1F *yield4thPt = NULL;
6060  TH1F *yield6thPt = NULL;
6061  TH1F *yield8thPt = NULL;
6062  
6063  if(type == "POI")
6064  {
6065   if(fFillMultipleControlHistograms)
6066   {
6067    yield2ndPt = (TH1F*)(fCommonHists2nd->GetHistPtPOI())->Clone();
6068    yield4thPt = (TH1F*)(fCommonHists4th->GetHistPtPOI())->Clone();
6069    yield6thPt = (TH1F*)(fCommonHists6th->GetHistPtPOI())->Clone();
6070    yield8thPt = (TH1F*)(fCommonHists8th->GetHistPtPOI())->Clone();  
6071   } else
6072     {
6073      yield2ndPt = (TH1F*)(fCommonHists->GetHistPtPOI())->Clone();
6074      yield4thPt = (TH1F*)(fCommonHists->GetHistPtPOI())->Clone();
6075      yield6thPt = (TH1F*)(fCommonHists->GetHistPtPOI())->Clone();
6076      yield8thPt = (TH1F*)(fCommonHists->GetHistPtPOI())->Clone();     
6077     }
6078  } 
6079  else if(type == "RP")
6080  {
6081   if(fFillMultipleControlHistograms)
6082   {
6083    yield2ndPt = (TH1F*)(fCommonHists2nd->GetHistPtRP())->Clone();
6084    yield4thPt = (TH1F*)(fCommonHists4th->GetHistPtRP())->Clone();
6085    yield6thPt = (TH1F*)(fCommonHists6th->GetHistPtRP())->Clone();
6086    yield8thPt = (TH1F*)(fCommonHists8th->GetHistPtRP())->Clone();  
6087   } else
6088     {
6089      yield2ndPt = (TH1F*)(fCommonHists->GetHistPtRP())->Clone();
6090      yield4thPt = (TH1F*)(fCommonHists->GetHistPtRP())->Clone();
6091      yield6thPt = (TH1F*)(fCommonHists->GetHistPtRP())->Clone();
6092      yield8thPt = (TH1F*)(fCommonHists->GetHistPtRP())->Clone();    
6093     } 
6094  } 
6095  
6096  if(!yield2ndPt){return;}
6097  if(!yield4thPt){return;}
6098  if(!yield6thPt){return;}
6099  if(!yield8thPt){return;} 
6100
6101  Int_t nBinsPt = yield2ndPt->GetNbinsX();
6102  
6103  TH1D *flow2ndPt = NULL;
6104  TH1D *flow4thPt = NULL;
6105  TH1D *flow6thPt = NULL;
6106  TH1D *flow8thPt = NULL;
6107  
6108  // to be improved (hardwired pt index)
6109  flow2ndPt = (TH1D*)fDiffFlow[t][0][0]->Clone();
6110  flow4thPt = (TH1D*)fDiffFlow[t][0][1]->Clone();
6111  flow6thPt = (TH1D*)fDiffFlow[t][0][2]->Clone();
6112  flow8thPt = (TH1D*)fDiffFlow[t][0][3]->Clone(); 
6113
6114  if(!flow2ndPt){return;}
6115  if(!flow4thPt){return;}
6116  if(!flow6thPt){return;}
6117  if(!flow8thPt){return;} 
6118    
6119  Double_t dvn2nd = 0., dvn4th = 0., dvn6th = 0., dvn8th = 0.; // differential flow
6120  Double_t dErrvn2nd = 0., dErrvn4th = 0., dErrvn6th = 0., dErrvn8th = 0.; // error on differential flow
6121  
6122  Double_t dVn2nd = 0., dVn4th = 0., dVn6th = 0., dVn8th = 0.; // integrated flow 
6123  Double_t dErrVn2nd = 0., dErrVn4th = 0., dErrVn6th = 0., dErrVn8th = 0.; // error on integrated flow
6124
6125  Double_t dYield2nd = 0., dYield4th = 0., dYield6th = 0., dYield8th = 0.; // pt yield 
6126  Double_t dSum2nd = 0., dSum4th = 0., dSum6th = 0., dSum8th = 0.; // needed for normalizing integrated flow
6127  
6128  // looping over pt bins:
6129  for(Int_t p=1;p<nBinsPt+1;p++)
6130  {
6131   dvn2nd = flow2ndPt->GetBinContent(p);
6132   dvn4th = flow4thPt->GetBinContent(p);
6133   dvn6th = flow6thPt->GetBinContent(p);
6134   dvn8th = flow8thPt->GetBinContent(p);
6135   
6136   dErrvn2nd = flow2ndPt->GetBinError(p);
6137   dErrvn4th = flow4thPt->GetBinError(p);
6138   dErrvn6th = flow6thPt->GetBinError(p);
6139   dErrvn8th = flow8thPt->GetBinError(p);
6140
6141   dYield2nd = yield2ndPt->GetBinContent(p);  
6142   dYield4th = yield4thPt->GetBinContent(p);
6143   dYield6th = yield6thPt->GetBinContent(p);
6144   dYield8th = yield8thPt->GetBinContent(p);
6145   
6146   dVn2nd += dvn2nd*dYield2nd;
6147   dVn4th += dvn4th*dYield4th;
6148   dVn6th += dvn6th*dYield6th;
6149   dVn8th += dvn8th*dYield8th;
6150   
6151   dSum2nd += dYield2nd;
6152   dSum4th += dYield4th;
6153   dSum6th += dYield6th;
6154   dSum8th += dYield8th;
6155   
6156   dErrVn2nd += dYield2nd*dYield2nd*dErrvn2nd*dErrvn2nd; // ro be improved (check this relation)
6157   dErrVn4th += dYield4th*dYield4th*dErrvn4th*dErrvn4th;
6158   dErrVn6th += dYield6th*dYield6th*dErrvn6th*dErrvn6th;
6159   dErrVn8th += dYield8th*dYield8th*dErrvn8th*dErrvn8th;
6160     
6161  } // end of for(Int_t p=1;p<nBinsPt+1;p++)
6162
6163  // normalizing the results for integrated flow:
6164  if(dSum2nd) 
6165  {
6166   dVn2nd /= dSum2nd;
6167   dErrVn2nd /= (dSum2nd*dSum2nd);
6168   dErrVn2nd = TMath::Sqrt(dErrVn2nd);
6169  } 
6170  if(dSum4th) 
6171  {
6172   dVn4th /= dSum4th;
6173   dErrVn4th /= (dSum4th*dSum4th);
6174   dErrVn4th = TMath::Sqrt(dErrVn4th);
6175  } 
6176  //if(dSum6th) dVn6th/=dSum6th;
6177  //if(dSum8th) dVn8th/=dSum8th;
6178   
6179  // storing the results for integrated flow in common histos: (to be improved: new method for this?)
6180  if(type == "POI")
6181  {
6182   fCommonHistsResults2nd->FillIntegratedFlowPOI(dVn2nd,dErrVn2nd); 
6183   fCommonHistsResults4th->FillIntegratedFlowPOI(dVn4th,dErrVn4th); 
6184   fCommonHistsResults6th->FillIntegratedFlowPOI(dVn6th,0.); // to be improved (errors)
6185   fCommonHistsResults8th->FillIntegratedFlowPOI(dVn8th,0.); // to be improved (errors)
6186  }
6187  else if (type == "RP")
6188  {
6189   fCommonHistsResults2nd->FillIntegratedFlowRP(dVn2nd,dErrVn2nd); 
6190   fCommonHistsResults4th->FillIntegratedFlowRP(dVn4th,dErrVn4th);
6191   fCommonHistsResults6th->FillIntegratedFlowRP(dVn6th,0.); // to be improved (errors)
6192   fCommonHistsResults8th->FillIntegratedFlowRP(dVn8th,0.); // to be improved (errors)
6193  }
6194  
6195  delete flow2ndPt;
6196  delete flow4thPt;
6197  //delete flow6thPt;
6198  //delete flow8thPt;
6199  
6200  delete yield2ndPt;
6201  delete yield4thPt;
6202  delete yield6thPt;
6203  delete yield8thPt;
6204            
6205 } // end of AliFlowAnalysisWithQCumulants::CalculateFinalResultsForRPandPOIIntegratedFlow(TString type)
6206
6207 //================================================================================================================================
6208
6209 void AliFlowAnalysisWithQCumulants::InitializeArraysForDistributions()
6210 {
6211  // Initialize all arrays used for distributions.
6212  
6213  // a) Initialize arrays of histograms used to hold distributions of correlations; 
6214  // b) Initialize array to hold min and max values of correlations.
6215  
6216  // a) Initialize arrays of histograms used to hold distributions of correlations:
6217  for(Int_t di=0;di<4;di++) // distribution index
6218  {
6219   fDistributions[di] = NULL;
6220  }
6221  
6222  // b) Initialize default min and max values of correlations:
6223  //    (Remark: The default values bellow were chosen for v2=5% and M=500)
6224  fMinValueOfCorrelation[0] = -0.01; // <2>_min 
6225  fMaxValueOfCorrelation[0] = 0.04; // <2>_max 
6226  fMinValueOfCorrelation[1] = -0.00002; // <4>_min 
6227  fMaxValueOfCorrelation[1] = 0.00015; // <4>_max  
6228  fMinValueOfCorrelation[2] = -0.0000003; // <6>_min 
6229  fMaxValueOfCorrelation[2] = 0.0000006; // <6>_max  
6230  fMinValueOfCorrelation[3] = -0.000000006; // <8>_min 
6231  fMaxValueOfCorrelation[3] = 0.000000003; // <8>_max 
6232  
6233 } // end of void AliFlowAnalysisWithQCumulants::InitializeArraysForDistributions()
6234
6235 //================================================================================================================================
6236
6237 void AliFlowAnalysisWithQCumulants::InitializeArraysForVarious()
6238 {
6239  // Initialize all arrays used for various unclassified objects.
6240  
6241  for(Int_t p=0;p<4;p++) // [v_min,v_max,refMult_min,refMult_max]
6242  {
6243   fPhiDistributionForOneEventSettings[p] = 0.;
6244  } 
6245    
6246 } //  end of void AliFlowAnalysisWithQCumulants::InitializeArraysForVarious()
6247
6248 //================================================================================================================================
6249
6250 void AliFlowAnalysisWithQCumulants::BookEverythingForDistributions()
6251 {
6252  // a) Book profile to hold all flags for distributions of correlations;
6253  // b) Book all histograms to hold distributions of correlations.
6254  
6255  TString correlationIndex[4] = {"<2>","<4>","<6>","<8>"}; // to be improved (should I promote this to data members?)
6256   
6257  // a) Book profile to hold all flags for distributions of correlations:
6258  TString distributionsFlagsName = "fDistributionsFlags";
6259  distributionsFlagsName += fAnalysisLabel->Data();
6260  fDistributionsFlags = new TProfile(distributionsFlagsName.Data(),"Flags for Distributions of Correlations",9,0,9);
6261  fDistributionsFlags->SetTickLength(-0.01,"Y");
6262  fDistributionsFlags->SetMarkerStyle(25);
6263  fDistributionsFlags->SetLabelSize(0.05);
6264  fDistributionsFlags->SetLabelOffset(0.02,"Y");
6265  fDistributionsFlags->GetXaxis()->SetBinLabel(1,"Store or not?");
6266  fDistributionsFlags->GetXaxis()->SetBinLabel(2,"<2>_{min}");
6267  fDistributionsFlags->GetXaxis()->SetBinLabel(3,"<2>_{max}");
6268  fDistributionsFlags->GetXaxis()->SetBinLabel(4,"<4>_{min}");
6269  fDistributionsFlags->GetXaxis()->SetBinLabel(5,"<4>_{max}");
6270  fDistributionsFlags->GetXaxis()->SetBinLabel(6,"<6>_{min}");
6271  fDistributionsFlags->GetXaxis()->SetBinLabel(7,"<6>_{max}");
6272  fDistributionsFlags->GetXaxis()->SetBinLabel(8,"<8>_{min}");
6273  fDistributionsFlags->GetXaxis()->SetBinLabel(9,"<8>_{max}");
6274  fDistributionsList->Add(fDistributionsFlags);
6275  
6276  // b) Book all histograms to hold distributions of correlations.
6277  if(fStoreDistributions)
6278  { 
6279   TString distributionsName = "fDistributions";
6280   distributionsName += fAnalysisLabel->Data();
6281   for(Int_t di=0;di<4;di++) // distribution index
6282   {
6283    fDistributions[di] = new TH1D(Form("Distribution of %s",correlationIndex[di].Data()),Form("Distribution of %s",correlationIndex[di].Data()),10000,fMinValueOfCorrelation[di],fMaxValueOfCorrelation[di]); 
6284    fDistributions[di]->SetXTitle(correlationIndex[di].Data());
6285    fDistributionsList->Add(fDistributions[di]);
6286   } // end of for(Int_t di=0;di<4;di++) // distribution index
6287  } // end of if(fStoreDistributions)
6288  
6289 } // end of void AliFlowAnalysisWithQCumulants::BookEverythingForDistributions()
6290
6291 //================================================================================================================================
6292
6293 void AliFlowAnalysisWithQCumulants::BookEverythingForVarious()
6294 {
6295  // Book all objects for various unclassified quantities.
6296  
6297  if(!fStorePhiDistributionForOneEvent){return;}
6298  
6299  // a) Book histogram holding phi distribution for single event to illustrate flow.
6300  
6301  // a) Book histogram holding phi distribution for single event to illustrate flow:
6302  fPhiDistributionForOneEvent = new TH1D("fPhiDistributionForOneEvent","",360,0.,TMath::TwoPi());
6303  fPhiDistributionForOneEvent->GetXaxis()->SetTitle("#phi");
6304  fVariousList->Add(fPhiDistributionForOneEvent);
6305  
6306 } // end of void AliFlowAnalysisWithQCumulants::BookEverythingForVarious()
6307
6308 //================================================================================================================================
6309
6310 void AliFlowAnalysisWithQCumulants::StoreFlagsForDistributions()
6311 {
6312  // Store all flags for distributiuons of correlations in profile fDistributionsFlags.
6313  
6314  if(!fDistributionsFlags)
6315  {
6316   cout<<"WARNING: fDistributionsFlags is NULL in AFAWQC::SDF() !!!!"<<endl;
6317   exit(0);
6318  } 
6319
6320  fDistributionsFlags->Fill(0.5,(Int_t)fStoreDistributions); // histos with distributions of correlations stored or not in the output file
6321  // store min and max values of correlations:
6322  for(Int_t di=0;di<4;di++) // distribution index
6323  {
6324   fDistributionsFlags->Fill(1.5+2.*(Double_t)di,fMinValueOfCorrelation[di]);
6325   fDistributionsFlags->Fill(2.5+2.*(Double_t)di,fMaxValueOfCorrelation[di]);
6326  }
6327      
6328 } // end of void AliFlowAnalysisWithQCumulants::StoreFlagsForDistributions()
6329
6330 //================================================================================================================================
6331
6332 void AliFlowAnalysisWithQCumulants::StoreDistributionsOfCorrelations()
6333 {
6334  // Store distributions of correlations.
6335  
6336  if(!(fIntFlowCorrelationsEBE && fIntFlowEventWeightsForCorrelationsEBE))
6337  {
6338   cout<<"WARNING: fIntFlowCorrelationsEBE && fIntFlowEventWeightsForCorrelationsEBE"<<endl; 
6339   cout<<"         is NULL in AFAWQC::SDOC() !!!!"<<endl;
6340   exit(0);
6341  }
6342
6343  for(Int_t di=0;di<4;di++) // distribution index
6344  {
6345   if(!fDistributions[di])
6346   { 
6347    cout<<"WARNING: fDistributions[di] is NULL in AFAWQC::SDOC() !!!!"<<endl;
6348    cout<<"di = "<<di<<endl;
6349    exit(0);
6350   } else 
6351     {
6352      fDistributions[di]->Fill(fIntFlowCorrelationsEBE->GetBinContent(di+1),fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(di+1)); 
6353     } 
6354  } // end of for(Int_t di=0;di<4;di++) // distribution index
6355
6356 } // end of void AliFlowAnalysisWithQCumulants::StoreDistributionsOfCorrelations()
6357
6358 //================================================================================================================================
6359
6360 void AliFlowAnalysisWithQCumulants::BookAndNestAllLists()
6361 {
6362  // Book and nest all lists nested in the base list fHistList.
6363  //  a) Book and nest lists for integrated flow;
6364  //  b) Book and nest lists for differential flow;
6365  //  c) Book and nest list for particle weights;
6366  //  d) Book and nest list for distributions;
6367  //  e) Book and nest list for various unclassified objects; 
6368  //  f) Book and nest list for nested loops.
6369  
6370  // a) Book and nest all lists for integrated flow:
6371  //  Base list for integrated flow:
6372  fIntFlowList = new TList();
6373  fIntFlowList->SetName("Integrated Flow");
6374  fIntFlowList->SetOwner(kTRUE);
6375  fHistList->Add(fIntFlowList);
6376  //  List holding profiles: 
6377  fIntFlowProfiles = new TList();
6378  fIntFlowProfiles->SetName("Profiles");
6379  fIntFlowProfiles->SetOwner(kTRUE);
6380  fIntFlowList->Add(fIntFlowProfiles);
6381  //  List holding all profiles with results for correlations vs M:
6382  if(fCalculateAllCorrelationsVsM)
6383  {
6384   fIntFlowAllCorrelationsVsM = new TList();
6385   fIntFlowAllCorrelationsVsM->SetName("Correlations vs M");
6386   fIntFlowAllCorrelationsVsM->SetOwner(kTRUE); 
6387   fIntFlowProfiles->Add(fIntFlowAllCorrelationsVsM);
6388  } // end of if(fCalculateAllCorrelationsVsM)
6389  //  List holding histograms with results:
6390  fIntFlowResults = new TList();
6391  fIntFlowResults->SetName("Results");
6392  fIntFlowResults->SetOwner(kTRUE);
6393  fIntFlowList->Add(fIntFlowResults);
6394  
6395  // b) Book and nest lists for differential flow:
6396  this->BookAndNestListsForDifferentialFlow();
6397  
6398  // c) Book and nest list for particle weights:
6399  fWeightsList->SetName("Weights");
6400  fWeightsList->SetOwner(kTRUE);   
6401  fHistList->Add(fWeightsList); 
6402
6403  // d) Book and nest list for distributions:
6404  fDistributionsList = new TList();
6405  fDistributionsList->SetName("Distributions");
6406  fDistributionsList->SetOwner(kTRUE);
6407  fHistList->Add(fDistributionsList);
6408  
6409  // e) Book and nest list for various unclassified objects:
6410  if(fStorePhiDistributionForOneEvent)
6411  {
6412   fVariousList = new TList();
6413   fVariousList->SetName("Various");
6414   fVariousList->SetOwner(kTRUE);
6415   fHistList->Add(fVariousList);
6416  }
6417   
6418  // f) Book and nest list for other differential correlators:
6419  fOtherDiffCorrelatorsList = new TList();
6420  fOtherDiffCorrelatorsList->SetName("Other differential correlators");
6421  fOtherDiffCorrelatorsList->SetOwner(kTRUE);
6422  if(fCalculateDiffFlow){fHistList->Add(fOtherDiffCorrelatorsList);} // TBI: Use another flag here instead of fCalculateDiffFlow 
6423   
6424  // g) Book and nest list for nested loops:
6425  fNestedLoopsList = new TList();
6426  fNestedLoopsList->SetName("Nested Loops");
6427  fNestedLoopsList->SetOwner(kTRUE);
6428  fHistList->Add(fNestedLoopsList);
6429  
6430 } // end of void AliFlowAnalysisWithQCumulants::BookAndNestAllLists()
6431
6432 //================================================================================================================================
6433
6434 void AliFlowAnalysisWithQCumulants::BookAndNestListsForDifferentialFlow()
6435 {
6436  // Book and nest lists for differential flow.
6437
6438  // Base list for differential flow objects:
6439  fDiffFlowList = new TList();
6440  fDiffFlowList->SetName("Differential Flow");
6441  fDiffFlowList->SetOwner(kTRUE); 
6442  fHistList->Add(fDiffFlowList);
6443  
6444  // Local flags: 
6445  TString typeFlag[2] = {"RP","POI"};  
6446  TString ptEtaFlag[2] = {"p_{T}","#eta"}; 
6447  TString powerFlag[2] = {"linear","quadratic"};   
6448
6449  // 2D:
6450  if(fCalculate2DDiffFlow)
6451  {
6452   fDiffFlow2D = new TList(); 
6453   fDiffFlow2D->SetName("2D");
6454   fDiffFlow2D->SetOwner(kTRUE);
6455   fDiffFlowList->Add(fDiffFlow2D); 
6456   for(Int_t t=0;t<2;t++)
6457   {
6458    f2DDiffFlowCorrelationsProList[t] = new TList();
6459    f2DDiffFlowCorrelationsProList[t]->SetOwner(kTRUE);
6460    f2DDiffFlowCorrelationsProList[t]->SetName(Form("Profiles with 2D correlations (%s)",typeFlag[t].Data()));
6461    fDiffFlow2D->Add(f2DDiffFlowCorrelationsProList[t]);
6462   } // end of for(Int_t t=0;t<2;t++)
6463  } // end of if(fCalculate2DDiffFlow)
6464
6465  // What follows bellow in this method is relevant only for 1D differential flow:
6466  if(!fCalculateDiffFlow){return;}
6467  
6468  // List holding profiles: 
6469  fDiffFlowProfiles = new TList(); 
6470  fDiffFlowProfiles->SetName("Profiles");
6471  fDiffFlowProfiles->SetOwner(kTRUE);
6472  fDiffFlowList->Add(fDiffFlowProfiles);
6473  // List holding histograms with results: 
6474  fDiffFlowResults = new TList();
6475  fDiffFlowResults->SetName("Results");
6476  fDiffFlowResults->SetOwner(kTRUE);
6477  fDiffFlowList->Add(fDiffFlowResults);
6478  // Flags used for naming nested lists in list fDiffFlowProfiles and fDiffFlowResults:  
6479  TList list;
6480  list.SetOwner(kTRUE);
6481  // Nested lists in fDiffFlowProfiles (~/Differential Flow/Profiles):
6482  for(Int_t t=0;t<2;t++) // type: RP or POI
6483  {
6484   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
6485   {
6486    // list holding profiles with correlations:
6487    fDiffFlowCorrelationsProList[t][pe] = (TList*)list.Clone();
6488    fDiffFlowCorrelationsProList[t][pe]->SetName(Form("Profiles with correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6489    fDiffFlowProfiles->Add(fDiffFlowCorrelationsProList[t][pe]);
6490    // list holding profiles with products of correlations:
6491    fDiffFlowProductOfCorrelationsProList[t][pe] = (TList*)list.Clone();
6492    fDiffFlowProductOfCorrelationsProList[t][pe]->SetName(Form("Profiles with products of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6493    fDiffFlowProfiles->Add(fDiffFlowProductOfCorrelationsProList[t][pe]);
6494    // list holding profiles with corrections:
6495    fDiffFlowCorrectionsProList[t][pe] = (TList*)list.Clone();
6496    fDiffFlowCorrectionsProList[t][pe]->SetName(Form("Profiles with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6497    fDiffFlowProfiles->Add(fDiffFlowCorrectionsProList[t][pe]);   
6498   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta 
6499  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI   
6500  // nested lists in fDiffFlowResults (~/Differential Flow/Results):
6501  for(Int_t t=0;t<2;t++) // type: RP or POI
6502  {
6503   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
6504   {
6505    // list holding histograms with correlations:
6506    fDiffFlowCorrelationsHistList[t][pe] = (TList*)list.Clone();
6507    fDiffFlowCorrelationsHistList[t][pe]->SetName(Form("Correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6508    fDiffFlowResults->Add(fDiffFlowCorrelationsHistList[t][pe]);
6509    // list holding histograms with corrections:
6510    fDiffFlowCorrectionsHistList[t][pe] = (TList*)list.Clone();
6511    fDiffFlowCorrectionsHistList[t][pe]->SetName(Form("Histograms with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6512    fDiffFlowResults->Add(fDiffFlowCorrectionsHistList[t][pe]);   
6513    for(Int_t power=0;power<2;power++)
6514    {
6515     // list holding histograms with sums of event weights:
6516     fDiffFlowSumOfEventWeightsHistList[t][pe][power] = (TList*)list.Clone();
6517     fDiffFlowSumOfEventWeightsHistList[t][pe][power]->SetName(Form("Sum of %s event weights (%s, %s)",powerFlag[power].Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6518     fDiffFlowResults->Add(fDiffFlowSumOfEventWeightsHistList[t][pe][power]);    
6519    } // end of for(Int_t power=0;power<2;power++)
6520    // list holding histograms with sums of products of event weights:
6521    fDiffFlowSumOfProductOfEventWeightsHistList[t][pe] = (TList*)list.Clone();
6522    fDiffFlowSumOfProductOfEventWeightsHistList[t][pe]->SetName(Form("Sum of products of event weights (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6523    fDiffFlowResults->Add(fDiffFlowSumOfProductOfEventWeightsHistList[t][pe]);
6524    // list holding histograms with covariances of correlations:
6525    fDiffFlowCovariancesHistList[t][pe] = (TList*)list.Clone();
6526    fDiffFlowCovariancesHistList[t][pe]->SetName(Form("Covariances of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6527    fDiffFlowResults->Add(fDiffFlowCovariancesHistList[t][pe]);
6528    // list holding histograms with differential Q-cumulants:
6529    fDiffFlowCumulantsHistList[t][pe] = (TList*)list.Clone();
6530    fDiffFlowCumulantsHistList[t][pe]->SetName(Form("Differential Q-cumulants (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6531    fDiffFlowResults->Add(fDiffFlowCumulantsHistList[t][pe]);   
6532    // list holding histograms which quantify detector bias to differential Q-cumulants:
6533    fDiffFlowDetectorBiasHistList[t][pe] = (TList*)list.Clone();
6534    fDiffFlowDetectorBiasHistList[t][pe]->SetName(Form("Detector bias (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6535    fDiffFlowResults->Add(fDiffFlowDetectorBiasHistList[t][pe]);   
6536    // list holding histograms with differential flow estimates from Q-cumulants:
6537    fDiffFlowHistList[t][pe] = (TList*)list.Clone();
6538    fDiffFlowHistList[t][pe]->SetName(Form("Differential flow (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()));
6539    fDiffFlowResults->Add(fDiffFlowHistList[t][pe]);      
6540   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
6541  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
6542   
6543 } // end of void AliFlowAnalysisWithQCumulants::BookAndNestListsForDifferentialFlow()
6544
6545 //================================================================================================================================
6546
6547 void AliFlowAnalysisWithQCumulants::FillCommonHistResultsDiffFlow(TString type)
6548 {
6549  // Fill common result histograms for differential flow.
6550  
6551  Int_t t = 0; 
6552
6553  if(type == "RP")
6554  {
6555   t = 0;
6556  } else if(type == "POI")
6557    {
6558     t = 1;
6559    } 
6560   
6561  // to be improved - check all pointers used in this method
6562      
6563  if(!(fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th))
6564  {
6565   cout<<"WARNING: fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th"<<endl; 
6566   cout<<"         is NULL in AFAWQC::FCHRIF() !!!!"<<endl;
6567   exit(0);
6568  }
6569  
6570  // pt:
6571  for(Int_t p=1;p<=fnBinsPt;p++)
6572  {
6573   Double_t v2 = fDiffFlow[t][0][0]->GetBinContent(p);
6574   Double_t v4 = fDiffFlow[t][0][1]->GetBinContent(p);
6575   Double_t v6 = fDiffFlow[t][0][2]->GetBinContent(p);
6576   Double_t v8 = fDiffFlow[t][0][3]->GetBinContent(p);
6577   
6578   Double_t v2Error = fDiffFlow[t][0][0]->GetBinError(p);
6579   Double_t v4Error = fDiffFlow[t][0][1]->GetBinError(p);
6580   //Double_t v6Error = fFinalFlow1D[t][pW][nua][0][2]->GetBinError(p);
6581   //Double_t v8Error = fFinalFlow1D[t][pW][nua][0][3]->GetBinError(p);
6582  
6583   if(type == "RP")
6584   {
6585    fCommonHistsResults2nd->FillDifferentialFlowPtRP(p,v2,v2Error);
6586    fCommonHistsResults4th->FillDifferentialFlowPtRP(p,v4,v4Error);
6587    fCommonHistsResults6th->FillDifferentialFlowPtRP(p,v6,0.);
6588    fCommonHistsResults8th->FillDifferentialFlowPtRP(p,v8,0.);
6589   } else if(type == "POI")
6590     {
6591      fCommonHistsResults2nd->FillDifferentialFlowPtPOI(p,v2,v2Error);
6592      fCommonHistsResults4th->FillDifferentialFlowPtPOI(p,v4,v4Error);
6593      fCommonHistsResults6th->FillDifferentialFlowPtPOI(p,v6,0.);
6594      fCommonHistsResults8th->FillDifferentialFlowPtPOI(p,v8,0.);
6595     }
6596  } // end of for(Int_t p=1;p<=fnBinsPt;p++)   
6597  
6598  // eta:
6599  if(!fCalculateDiffFlowVsEta){return;}
6600  for(Int_t e=1;e<=fnBinsEta;e++)
6601  {
6602   Double_t v2 = fDiffFlow[t][1][0]->GetBinContent(e);
6603   Double_t v4 = fDiffFlow[t][1][1]->GetBinContent(e);
6604   Double_t v6 = fDiffFlow[t][1][2]->GetBinContent(e);
6605   Double_t v8 = fDiffFlow[t][1][3]->GetBinContent(e);
6606   
6607   Double_t v2Error = fDiffFlow[t][1][0]->GetBinError(e);
6608   Double_t v4Error = fDiffFlow[t][1][1]->GetBinError(e);
6609   //Double_t v6Error = fDiffFlow[t][1][2]->GetBinError(e);
6610   //Double_t v8Error = fDiffFlow[t][1][3]->GetBinError(e);
6611  
6612   if(type == "RP")
6613   {
6614    fCommonHistsResults2nd->FillDifferentialFlowEtaRP(e,v2,v2Error);
6615    fCommonHistsResults4th->FillDifferentialFlowEtaRP(e,v4,v4Error);
6616    fCommonHistsResults6th->FillDifferentialFlowEtaRP(e,v6,0.);
6617    fCommonHistsResults8th->FillDifferentialFlowEtaRP(e,v8,0.);
6618   } else if(type == "POI")
6619     {
6620      fCommonHistsResults2nd->FillDifferentialFlowEtaPOI(e,v2,v2Error);
6621      fCommonHistsResults4th->FillDifferentialFlowEtaPOI(e,v4,v4Error);
6622      fCommonHistsResults6th->FillDifferentialFlowEtaPOI(e,v6,0.);
6623      fCommonHistsResults8th->FillDifferentialFlowEtaPOI(e,v8,0.);
6624     }
6625  } // end of for(Int_t e=1;e<=fnBinsEta;e++)    
6626  
6627 } // end of void AliFlowAnalysisWithQCumulants::FillCommonHistResultsDiffFlow(TString type, Bool_t useParticleWeights, TString eventWeights, Bool_t correctedForNUA)
6628
6629 //================================================================================================================================
6630
6631 void AliFlowAnalysisWithQCumulants::CommonConstants(TString method)
6632 {
6633  // Access and store common constants.
6634  
6635  // a) If this method was called in Init() access common constants from AliFlowCommonConstants;
6636  // b) If this method was called in Init() book and fill TProfile to hold constants accessed in a);
6637  // c) If this method was called in Finish() access common constants from TProfile booked and filled in b).
6638
6639  if(method == "Init")
6640  {
6641   // a) If this method was called in Init() access common constants from AliFlowCommonConstants:
6642   fnBinsPhi = AliFlowCommonConstants::GetMaster()->GetNbinsPhi();
6643   fPhiMin = AliFlowCommonConstants::GetMaster()->GetPhiMin();        
6644   fPhiMax = AliFlowCommonConstants::GetMaster()->GetPhiMax();
6645   if(fnBinsPhi){fPhiBinWidth = (fPhiMax-fPhiMin)/fnBinsPhi;}  
6646   fnBinsPt = AliFlowCommonConstants::GetMaster()->GetNbinsPt();
6647   fPtMin = AliFlowCommonConstants::GetMaster()->GetPtMin();          
6648   fPtMax = AliFlowCommonConstants::GetMaster()->GetPtMax();
6649   if(fnBinsPt){fPtBinWidth = (fPtMax-fPtMin)/fnBinsPt;}  
6650   fnBinsEta = AliFlowCommonConstants::GetMaster()->GetNbinsEta();
6651   fEtaMin = AliFlowCommonConstants::GetMaster()->GetEtaMin();        
6652   fEtaMax = AliFlowCommonConstants::GetMaster()->GetEtaMax();
6653   if(fnBinsEta){fEtaBinWidth = (fEtaMax-fEtaMin)/fnBinsEta;}  
6654   
6655   // b) If this method was called in Init() book and fill TProfile to hold constants accessed in a):
6656   TString fCommonConstantsName = "fCommonConstants";
6657   fCommonConstantsName += fAnalysisLabel->Data();
6658   fCommonConstants = new TProfile(fCommonConstantsName.Data(),"Common constants",9,0.,9.);
6659   fCommonConstants->SetLabelSize(0.05);
6660   fCommonConstants->GetXaxis()->SetBinLabel(1,"nBins (#phi)");
6661   fCommonConstants->Fill(0.5,fnBinsPhi);
6662   fCommonConstants->GetXaxis()->SetBinLabel(2,"#phi_{min}");
6663   fCommonConstants->Fill(1.5,fPhiMin);
6664   fCommonConstants->GetXaxis()->SetBinLabel(3,"#phi_{max}");
6665   fCommonConstants->Fill(2.5,fPhiMax);
6666   fCommonConstants->GetXaxis()->SetBinLabel(4,"nBins (p_{t})");
6667   fCommonConstants->Fill(3.5,fnBinsPt);
6668   fCommonConstants->GetXaxis()->SetBinLabel(5,"(p_{t})_{min}");
6669   fCommonConstants->Fill(4.5,fPtMin);
6670   fCommonConstants->GetXaxis()->SetBinLabel(6,"(p_{t})_{max}");
6671   fCommonConstants->Fill(5.5,fPtMax);
6672   fCommonConstants->GetXaxis()->SetBinLabel(7,"nBins (#eta)");
6673   fCommonConstants->Fill(6.5,fnBinsEta);
6674   fCommonConstants->GetXaxis()->SetBinLabel(8,"#eta_{min}");
6675   fCommonConstants->Fill(7.5,fEtaMin);
6676   fCommonConstants->GetXaxis()->SetBinLabel(9,"#eta_{max}");
6677   fCommonConstants->Fill(8.5,fEtaMax);
6678   fHistList->Add(fCommonConstants); 
6679  } // end of if(method == "Init")
6680  else if(method == "Finish")
6681  {
6682   // c) If this method was called in Finish() access common constants from TProfile booked and filled in b):
6683   if(!fCommonConstants)
6684   {
6685    printf("\n WARNING (QC): fCommonConstants is NULL in AFAWQC::AC(\"%s\") !!!!\n\n",method.Data());
6686    exit(0);
6687   } 
6688   fnBinsPhi = (Int_t)fCommonConstants->GetBinContent(1);
6689   fPhiMin = fCommonConstants->GetBinContent(2);      
6690   fPhiMax = fCommonConstants->GetBinContent(3);
6691   if(fnBinsPhi){fPhiBinWidth = (fPhiMax-fPhiMin)/fnBinsPhi;}  
6692   fnBinsPt = (Int_t)fCommonConstants->GetBinContent(4);
6693   fPtMin = fCommonConstants->GetBinContent(5);       
6694   fPtMax = fCommonConstants->GetBinContent(6);
6695   if(fnBinsPt){fPtBinWidth = (fPtMax-fPtMin)/fnBinsPt;}  
6696   fnBinsEta = (Int_t)fCommonConstants->GetBinContent(7);
6697   fEtaMin = fCommonConstants->GetBinContent(8);      
6698   fEtaMax = fCommonConstants->GetBinContent(9);
6699   if(fnBinsEta){fEtaBinWidth = (fEtaMax-fEtaMin)/fnBinsEta;}  
6700  } // end of else if(method == "Finish")
6701
6702 } // end of void AliFlowAnalysisWithQCumulants::CommonConstants(TString method)
6703
6704 //================================================================================================================================
6705
6706 void AliFlowAnalysisWithQCumulants::CrossCheckSettings()
6707 {
6708  // a) Cross check if the choice for multiplicity weights make sense.
6709  
6710  // a) Cross check if the choice for multiplicity weights make sense:
6711  if(strcmp(fMultiplicityWeight->Data(),"combinations") && 
6712     strcmp(fMultiplicityWeight->Data(),"unit") &&
6713     strcmp(fMultiplicityWeight->Data(),"multiplicity"))
6714  {
6715   cout<<"WARNING (QC): Multiplicity weight can be either \"combinations\", \"unit\""<<endl;
6716   cout<<"              or \"multiplicity\". Certainly not \""<<fMultiplicityWeight->Data()<<"\"."<<endl;
6717   exit(0);
6718  }   
6719  
6720 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckSettings()
6721
6722 //================================================================================================================================
6723
6724 void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfEventWeights()
6725 {
6726  // Calculate sum of linear and quadratic event weights for correlations.
6727  
6728  // multiplicity:
6729  Double_t dMult = (*fSpk)(0,0);
6730                         
6731  for(Int_t p=0;p<2;p++) // power-1
6732  {
6733   for(Int_t ci=0;ci<4;ci++) // correlation index
6734   { 
6735    fIntFlowSumOfEventWeights[p]->Fill(ci+0.5,pow(fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci+1),p+1)); 
6736    if(fCalculateCumulantsVsM)
6737    {
6738     fIntFlowSumOfEventWeightsVsM[ci][p]->Fill(dMult+0.5,pow(fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci+1),p+1)); // to be improved: dMult => sum of weights?
6739    }
6740   }
6741  }
6742   
6743 } // end of void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfEventWeights()
6744
6745 //================================================================================================================================
6746
6747 void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfEventWeightsNUA()
6748 {
6749  // Calculate sum of linear and quadratic event weights for NUA terms.
6750                        
6751  for(Int_t sc=0;sc<2;sc++) // sin or cos terms
6752  {
6753   for(Int_t p=0;p<2;p++) // power-1
6754   {
6755    for(Int_t ci=0;ci<4;ci++) // nua term index
6756    { 
6757     fIntFlowSumOfEventWeightsNUA[sc][p]->Fill(ci+0.5,pow(fIntFlowEventWeightForCorrectionTermsForNUAEBE[sc]->GetBinContent(ci+1),p+1)); 
6758    }
6759   }
6760  }
6761   
6762 } // end of void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfEventWeightsNUA()
6763
6764 //================================================================================================================================
6765
6766 void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfProductOfEventWeights()
6767 {
6768  // Calculate sum of product of event weights for correlations.
6769   
6770  // multiplicity:
6771  Double_t dMult = (*fSpk)(0,0);
6772   
6773  Int_t counter = 0;
6774  
6775  for(Int_t ci1=1;ci1<4;ci1++)
6776  {
6777   for(Int_t ci2=ci1+1;ci2<=4;ci2++)
6778   {
6779    fIntFlowSumOfProductOfEventWeights->Fill(0.5+counter,
6780                                             fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci1)*
6781                                             fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci2));
6782    if(fCalculateCumulantsVsM)
6783    {                                                                                    
6784     fIntFlowSumOfProductOfEventWeightsVsM[counter]->Fill(dMult+0.5, // to be improved: dMult => sum of weights?
6785                                                          fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci1)*
6786                                                          fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(ci2));
6787    } // end of if(fCalculateCumulantsVsM)
6788    counter++;                                         
6789   }
6790  }
6791
6792 } // end of void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfProductOfEventWeights()
6793
6794 //================================================================================================================================
6795
6796 void AliFlowAnalysisWithQCumulants::CalculateIntFlowSumOfProductOfEventWeightsNUA()
6797 {
6798  // Calculate sum of product of event weights for NUA terms.
6799   
6800  // w_{<2>} * w_{<cos(#phi)>}:
6801  fIntFlowSumOfProductOfEventWeightsNUA->Fill(0.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)*
6802                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1));
6803  // w_{<2>} * w_{<sin(#phi)>}:
6804  fIntFlowSumOfProductOfEventWeightsNUA->Fill(1.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)*
6805                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1));
6806  // w_{<cos(#phi)> * w_{<sin(#phi)>}:
6807  fIntFlowSumOfProductOfEventWeightsNUA->Fill(2.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1)*
6808                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1));
6809  // w_{<2>} * w{<cos(phi1+phi2)>}
6810  fIntFlowSumOfProductOfEventWeightsNUA->Fill(3.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)*
6811                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)); 
6812  // w_{<2>} * w{<sin(phi1+phi2)>}
6813  fIntFlowSumOfProductOfEventWeightsNUA->Fill(4.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)*
6814                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2));
6815  // w_{<2>} * w{<cos(phi1-phi2-phi3)>}
6816  fIntFlowSumOfProductOfEventWeightsNUA->Fill(5.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)*
6817                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3));
6818  // w_{<2>} * w{<sin(phi1-phi2-phi3)>}
6819  fIntFlowSumOfProductOfEventWeightsNUA->Fill(6.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1)*
6820                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3));  
6821  // w_{<4>} * w{<cos(phi1)>}
6822  fIntFlowSumOfProductOfEventWeightsNUA->Fill(7.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)*
6823                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1));
6824  // w_{<4>} * w{<sin(phi1)>}
6825  fIntFlowSumOfProductOfEventWeightsNUA->Fill(8.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)*
6826                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1));
6827  // w_{<4>} * w{<cos(phi1+phi2)>}
6828  fIntFlowSumOfProductOfEventWeightsNUA->Fill(9.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)*
6829                                                  fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)); 
6830  // w_{<4>} * w{<sin(phi1+phi2)>}
6831  fIntFlowSumOfProductOfEventWeightsNUA->Fill(10.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)*
6832                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2));
6833  // w_{<4>} * w{<cos(phi1-phi2-phi3)>}
6834  fIntFlowSumOfProductOfEventWeightsNUA->Fill(11.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)*
6835                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3));
6836  // w_{<4>} * w{<sin(phi1-phi2-phi3)>}
6837  fIntFlowSumOfProductOfEventWeightsNUA->Fill(12.5,fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2)*
6838                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3));
6839  // w_{<cos(phi1)>} * w{<cos(phi1+phi2)>}
6840  fIntFlowSumOfProductOfEventWeightsNUA->Fill(13.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1)*
6841                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2));
6842  // w_{<cos(phi1)>} * w{<sin(phi1+phi2)>}
6843  fIntFlowSumOfProductOfEventWeightsNUA->Fill(14.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1)*
6844                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2)); 
6845  // w_{<cos(phi1)>} * w{<cos(phi1-phi2-phi3)>}
6846  fIntFlowSumOfProductOfEventWeightsNUA->Fill(15.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1)*
6847                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3));
6848  // w_{<cos(phi1)>} * w{<sin(phi1-phi2-phi3)>}
6849  fIntFlowSumOfProductOfEventWeightsNUA->Fill(16.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(1)*
6850                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3));
6851  // w_{<sin(phi1)>} * w{<cos(phi1+phi2)>}
6852  fIntFlowSumOfProductOfEventWeightsNUA->Fill(17.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1)*
6853                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2));
6854  // w_{<sin(phi1)>} * w{<sin(phi1+phi2)>}
6855  fIntFlowSumOfProductOfEventWeightsNUA->Fill(18.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1)*
6856                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2));
6857  // w_{<sin(phi1)>} * w{<cos(phi1-phi2-phi3)>}
6858  fIntFlowSumOfProductOfEventWeightsNUA->Fill(19.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1)*
6859                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3));
6860  // w_{<sin(phi1)>} * w{<sin(phi1-phi2-phi3)>}
6861  fIntFlowSumOfProductOfEventWeightsNUA->Fill(20.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(1)*
6862                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3)); 
6863  // w_{<cos(phi1+phi2)>} * w{<sin(phi1+phi2))>}
6864  fIntFlowSumOfProductOfEventWeightsNUA->Fill(21.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)*
6865                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2)); 
6866  // w_{<cos(phi1+phi2)>} * w{<cos(phi1-phi2-phi3)>}
6867  fIntFlowSumOfProductOfEventWeightsNUA->Fill(22.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)*
6868                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3)); 
6869  // w_{<cos(phi1+phi2)>} * w{<sin(phi1-phi2-phi3)>}
6870  fIntFlowSumOfProductOfEventWeightsNUA->Fill(23.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(2)*
6871                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3)); 
6872  // w_{<sin(phi1+phi2)>} * w{<cos(phi1-phi2-phi3)>}
6873  fIntFlowSumOfProductOfEventWeightsNUA->Fill(24.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2)*
6874                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3)); 
6875  // w_{<sin(phi1+phi2)>} * w{<sin(phi1-phi2-phi3)>}
6876  fIntFlowSumOfProductOfEventWeightsNUA->Fill(25.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(2)*
6877                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3)); 
6878  // w_{<cos(phi1-phi2-phi3)>} * w{<sin(phi1-phi2-phi3)>}
6879  fIntFlowSumOfProductOfEventWeightsNUA->Fill(26.5,fIntFlowEventWeightForCorrectionTermsForNUAEBE[1]->GetBinContent(3)*
6880                                                   fIntFlowEventWeightForCorrectionTermsForNUAEBE[0]->GetBinContent(3));
6881
6882 } // end of void AliFlowAnalysisWithQCumulants::CalculateIntFlowIntFlowSumOfProductOfEventWeightsNUA()
6883
6884 //================================================================================================================================
6885
6886 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelations(TString type, TString ptOrEta)
6887 {
6888  // Calculate reduced correlations for RPs or POIs for all pt and eta bins.
6889
6890  // Multiplicity:
6891  Double_t dMult = (*fSpk)(0,0);
6892  
6893  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
6894  Double_t dReQ1n = (*fReQ)(0,0);
6895  Double_t dReQ2n = (*fReQ)(1,0);
6896  //Double_t dReQ3n = (*fReQ)(2,0);
6897  //Double_t dReQ4n = (*fReQ)(3,0);
6898  Double_t dImQ1n = (*fImQ)(0,0);
6899  Double_t dImQ2n = (*fImQ)(1,0);
6900  //Double_t dImQ3n = (*fImQ)(2,0);
6901  //Double_t dImQ4n = (*fImQ)(3,0);
6902
6903  // reduced correlations are stored in fDiffFlowCorrelationsPro[0=RP,1=POI][0=pt,1=eta][correlation index]. Correlation index runs as follows:
6904  // 
6905  // 0: <<2'>>
6906  // 1: <<4'>>
6907  // 2: <<6'>>
6908  // 3: <<8'>>
6909  
6910  //Int_t t = 0; // type flag 
6911  Int_t pe = 0; // ptEta flag
6912  
6913  if(type == "RP")
6914  {
6915   //t = 0;
6916  } else if(type == "POI")
6917    {
6918     //t = 1;
6919    }
6920
6921  if(ptOrEta == "Pt")
6922  {
6923   pe = 0;
6924  } else if(ptOrEta == "Eta")
6925    {
6926     pe = 1;
6927    }
6928     
6929  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
6930  Double_t minPtEta[2] = {fPtMin,fEtaMin};
6931  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
6932  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
6933
6934  // looping over all bins and calculating reduced correlations: 
6935  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
6936  {
6937   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): 
6938   Double_t p1n0kRe = 0.;
6939   Double_t p1n0kIm = 0.;
6940
6941   // number of POIs in particular pt or eta bin:
6942   Double_t mp = 0.;
6943
6944   // 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):
6945   Double_t q1n0kRe = 0.;
6946   Double_t q1n0kIm = 0.;
6947   Double_t q2n0kRe = 0.;
6948   Double_t q2n0kIm = 0.;
6949
6950   // number of particles which are both RPs and POIs in particular pt or eta bin:
6951   Double_t mq = 0.;
6952    
6953   if(type == "POI")
6954   {
6955    // q_{m*n,0}:
6956    q1n0kRe = fReRPQ1dEBE[2][pe][0][0]->GetBinContent(fReRPQ1dEBE[2][pe][0][0]->GetBin(b))
6957            * fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b));
6958    q1n0kIm = fImRPQ1dEBE[2][pe][0][0]->GetBinContent(fImRPQ1dEBE[2][pe][0][0]->GetBin(b))
6959            * fImRPQ1dEBE[2][pe][0][0]->GetBinEntries(fImRPQ1dEBE[2][pe][0][0]->GetBin(b));
6960    q2n0kRe = fReRPQ1dEBE[2][pe][1][0]->GetBinContent(fReRPQ1dEBE[2][pe][1][0]->GetBin(b))
6961            * fReRPQ1dEBE[2][pe][1][0]->GetBinEntries(fReRPQ1dEBE[2][pe][1][0]->GetBin(b));
6962    q2n0kIm = fImRPQ1dEBE[2][pe][1][0]->GetBinContent(fImRPQ1dEBE[2][pe][1][0]->GetBin(b))
6963            * fImRPQ1dEBE[2][pe][1][0]->GetBinEntries(fImRPQ1dEBE[2][pe][1][0]->GetBin(b));         
6964                  
6965    mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
6966   } 
6967   else if(type == "RP")
6968   {
6969    // q_{m*n,0}:
6970    q1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))
6971            * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));
6972    q1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))
6973            * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));
6974    q2n0kRe = fReRPQ1dEBE[0][pe][1][0]->GetBinContent(fReRPQ1dEBE[0][pe][1][0]->GetBin(b))
6975            * fReRPQ1dEBE[0][pe][1][0]->GetBinEntries(fReRPQ1dEBE[0][pe][1][0]->GetBin(b));
6976    q2n0kIm = fImRPQ1dEBE[0][pe][1][0]->GetBinContent(fImRPQ1dEBE[0][pe][1][0]->GetBin(b))
6977            * fImRPQ1dEBE[0][pe][1][0]->GetBinEntries(fImRPQ1dEBE[0][pe][1][0]->GetBin(b));         
6978                  
6979    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)  
6980   }
6981       
6982    if(type == "POI")
6983    {
6984     // p_{m*n,0}:
6985     p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))
6986             * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));
6987     p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  
6988             * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));
6989             
6990     mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
6991     
6992     //t = 1; // typeFlag = RP or POI
6993    }
6994    else if(type == "RP")
6995    {
6996     // p_{m*n,0} = q_{m*n,0}:
6997     p1n0kRe = q1n0kRe; 
6998     p1n0kIm = q1n0kIm; 
6999             
7000     mp = mq; 
7001     
7002     //t = 0; // typeFlag = RP or POI
7003    }
7004       
7005    // 2'-particle correlation for particular pt or eta bin:
7006    Double_t two1n1nPtEta = 0.;
7007    Double_t mWeight2pPrime = 0.; // multiplicity weight for <2'>
7008    if(mp*dMult-mq)
7009    {
7010     two1n1nPtEta = (p1n0kRe*dReQ1n+p1n0kIm*dImQ1n-mq)
7011                  / (mp*dMult-mq);
7012     // determine multiplicity weight:
7013     if(!strcmp(fMultiplicityWeight->Data(),"combinations"))
7014     {
7015      mWeight2pPrime = mp*dMult-mq;
7016     } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))
7017       {
7018        mWeight2pPrime = 1.;    
7019       } 
7020     if(type == "POI") // to be improved (I do not this if)
7021     { 
7022      // fill profile to get <<2'>> for POIs
7023      fDiffFlowCorrelationsPro[1][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nPtEta,mWeight2pPrime);
7024      // fill profile to get <<2'>^2> for POIs
7025      fDiffFlowSquaredCorrelationsPro[1][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nPtEta*two1n1nPtEta,mWeight2pPrime);   
7026      // histogram to store <2'> for POIs e-b-e (needed in some other methods):
7027      fDiffFlowCorrelationsEBE[1][pe][0]->SetBinContent(b,two1n1nPtEta);      
7028      fDiffFlowEventWeightsForCorrelationsEBE[1][pe][0]->SetBinContent(b,mWeight2pPrime);      
7029     }
7030     else if(type == "RP") // to be improved (I do not this if)
7031     {
7032      // profile to get <<2'>> for RPs:
7033      fDiffFlowCorrelationsPro[0][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nPtEta,mWeight2pPrime);     
7034      // profile to get <<2'>^2> for RPs:
7035      fDiffFlowSquaredCorrelationsPro[0][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nPtEta*two1n1nPtEta,mWeight2pPrime);          
7036      // histogram to store <2'> for RPs e-b-e (needed in some other methods):
7037      fDiffFlowCorrelationsEBE[0][pe][0]->SetBinContent(b,two1n1nPtEta); 
7038      fDiffFlowEventWeightsForCorrelationsEBE[0][pe][0]->SetBinContent(b,mWeight2pPrime); 
7039     }
7040    } // end of if(mp*dMult-mq)
7041   
7042    // 4'-particle correlation:
7043    Double_t four1n1n1n1nPtEta = 0.;
7044    Double_t mWeight4pPrime = 0.; // multiplicity weight for <4'>
7045    if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)
7046        + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)) // to be improved (introduce a new variable for this expression)
7047    {
7048     four1n1n1n1nPtEta = ((pow(dReQ1n,2.)+pow(dImQ1n,2.))*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)
7049                       - q2n0kRe*(pow(dReQ1n,2.)-pow(dImQ1n,2.))
7050                       - 2.*q2n0kIm*dReQ1n*dImQ1n
7051                       - p1n0kRe*(dReQ1n*dReQ2n+dImQ1n*dImQ2n)
7052                       + p1n0kIm*(dImQ1n*dReQ2n-dReQ1n*dImQ2n)
7053                       - 2.*dMult*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)
7054                       - 2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*mq                      
7055                       + 6.*(q1n0kRe*dReQ1n+q1n0kIm*dImQ1n)                                            
7056                       + 1.*(q2n0kRe*dReQ2n+q2n0kIm*dImQ2n)                      
7057                       + 2.*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)                       
7058                       + 2.*mq*dMult                      
7059                       - 6.*mq)        
7060                       / ((mp-mq)*dMult*(dMult-1.)*(dMult-2.)
7061                           + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)); 
7062     // determine multiplicity weight:
7063     if(!strcmp(fMultiplicityWeight->Data(),"combinations"))
7064     {
7065      mWeight4pPrime = (mp-mq)*dMult*(dMult-1.)*(dMult-2.) + mq*(dMult-1.)*(dMult-2.)*(dMult-3.);
7066     } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))
7067       {
7068        mWeight4pPrime = 1.;    
7069       }     
7070     if(type == "POI")
7071     {
7072      // profile to get <<4'>> for POIs:
7073      fDiffFlowCorrelationsPro[1][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nPtEta,mWeight4pPrime);      
7074      // profile to get <<4'>^2> for POIs:
7075      fDiffFlowSquaredCorrelationsPro[1][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nPtEta*four1n1n1n1nPtEta,mWeight4pPrime); 
7076      // histogram to store <4'> for POIs e-b-e (needed in some other methods):
7077      fDiffFlowCorrelationsEBE[1][pe][1]->SetBinContent(b,four1n1n1n1nPtEta);                               
7078      fDiffFlowEventWeightsForCorrelationsEBE[1][pe][1]->SetBinContent(b,mWeight4pPrime);                               
7079     }
7080     else if(type == "RP")
7081     {
7082      // profile to get <<4'>> for RPs:
7083      fDiffFlowCorrelationsPro[0][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nPtEta,mWeight4pPrime);    
7084      // profile to get <<4'>^2> for RPs:
7085      fDiffFlowSquaredCorrelationsPro[0][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nPtEta*four1n1n1n1nPtEta,mWeight4pPrime);    
7086      // histogram to store <4'> for RPs e-b-e (needed in some other methods):
7087      fDiffFlowCorrelationsEBE[0][pe][1]->SetBinContent(b,four1n1n1n1nPtEta);                   
7088      fDiffFlowEventWeightsForCorrelationsEBE[0][pe][1]->SetBinContent(b,mWeight4pPrime);                   
7089     }
7090    } // end of if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)
7091      //            +mq*(dMult-1.)*(dMult-2.)*(dMult-3.))
7092    
7093  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
7094  
7095    
7096 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelations(TString type, TString ptOrEta);
7097
7098 //================================================================================================================================
7099
7100 void AliFlowAnalysisWithQCumulants::CalculateOtherDiffCorrelators(TString type, TString ptOrEta)
7101 {
7102  // Calculate other differential correlators for RPs or POIs for all pt and eta bins.
7103  
7104  // Multiplicity:
7105  Double_t dMult = (*fSpk)(0,0);
7106  
7107  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
7108  Double_t dReQ1n = (*fReQ)(0,0);
7109  Double_t dReQ2n = (*fReQ)(1,0);
7110  Double_t dReQ3n = (*fReQ)(2,0);
7111  //Double_t dReQ4n = (*fReQ)(3,0);
7112  Double_t dImQ1n = (*fImQ)(0,0);
7113  Double_t dImQ2n = (*fImQ)(1,0);
7114  Double_t dImQ3n = (*fImQ)(2,0);
7115  //Double_t dImQ4n = (*fImQ)(3,0);
7116
7117  // Other correlations are stored in fOtherDiffCorrelators[2][2][2][1], [0=RP,1=POI][0=pt,1=eta][0=sin terms,1=cos terms][correlator index]
7118  // Correlation index runs as follows:
7119  // 
7120  //  0: <exp[in(psi1-3phi2+2phi3)]>
7121  
7122  Int_t t = 0; // type flag 
7123  Int_t pe = 0; // ptEta flag
7124  
7125  if(type == "RP")
7126  {
7127   t = 0;
7128  } else if(type == "POI")
7129    {
7130     t = 1;
7131    }
7132
7133  if(ptOrEta == "Pt")
7134  {
7135   pe = 0;
7136  } else if(ptOrEta == "Eta")
7137    {
7138     pe = 1;
7139    }
7140     
7141  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
7142  Double_t minPtEta[2] = {fPtMin,fEtaMin};
7143  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
7144  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
7145
7146  // looping over all bins and calculating reduced correlations: 
7147  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
7148  {
7149   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): 
7150   Double_t p1n0kRe = 0.;
7151   Double_t p1n0kIm = 0.;
7152
7153   // number of POIs in particular pt or eta bin:
7154   Double_t mp = 0.;
7155
7156   // 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):
7157   Double_t q1n0kRe = 0.;
7158   Double_t q1n0kIm = 0.;
7159   Double_t q2n0kRe = 0.;
7160   Double_t q2n0kIm = 0.;
7161   Double_t q3n0kRe = 0.;
7162   Double_t q3n0kIm = 0.;
7163
7164   // number of particles which are both RPs and POIs in particular pt or eta bin:
7165   Double_t mq = 0.;
7166    
7167   if(type == "POI")
7168   {
7169    // q_{m*n,0}:
7170    q1n0kRe = fReRPQ1dEBE[2][pe][0][0]->GetBinContent(fReRPQ1dEBE[2][pe][0][0]->GetBin(b))
7171            * fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b));
7172    q1n0kIm = fImRPQ1dEBE[2][pe][0][0]->GetBinContent(fImRPQ1dEBE[2][pe][0][0]->GetBin(b))
7173            * fImRPQ1dEBE[2][pe][0][0]->GetBinEntries(fImRPQ1dEBE[2][pe][0][0]->GetBin(b));
7174    q2n0kRe = fReRPQ1dEBE[2][pe][1][0]->GetBinContent(fReRPQ1dEBE[2][pe][1][0]->GetBin(b))
7175            * fReRPQ1dEBE[2][pe][1][0]->GetBinEntries(fReRPQ1dEBE[2][pe][1][0]->GetBin(b));
7176    q2n0kIm = fImRPQ1dEBE[2][pe][1][0]->GetBinContent(fImRPQ1dEBE[2][pe][1][0]->GetBin(b))
7177            * fImRPQ1dEBE[2][pe][1][0]->GetBinEntries(fImRPQ1dEBE[2][pe][1][0]->GetBin(b));                         
7178    q3n0kRe = fReRPQ1dEBE[2][pe][2][0]->GetBinContent(fReRPQ1dEBE[2][pe][2][0]->GetBin(b))
7179            * fReRPQ1dEBE[2][pe][2][0]->GetBinEntries(fReRPQ1dEBE[2][pe][2][0]->GetBin(b));
7180    q3n0kIm = fImRPQ1dEBE[2][pe][2][0]->GetBinContent(fImRPQ1dEBE[2][pe][2][0]->GetBin(b))
7181            * fImRPQ1dEBE[2][pe][2][0]->GetBinEntries(fImRPQ1dEBE[2][pe][2][0]->GetBin(b));         
7182
7183    mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
7184   } 
7185   else if(type == "RP")
7186   {
7187    // q_{m*n,0}:
7188    q1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))
7189            * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));
7190    q1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))
7191            * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));
7192    q2n0kRe = fReRPQ1dEBE[0][pe][1][0]->GetBinContent(fReRPQ1dEBE[0][pe][1][0]->GetBin(b))
7193            * fReRPQ1dEBE[0][pe][1][0]->GetBinEntries(fReRPQ1dEBE[0][pe][1][0]->GetBin(b));
7194    q2n0kIm = fImRPQ1dEBE[0][pe][1][0]->GetBinContent(fImRPQ1dEBE[0][pe][1][0]->GetBin(b))
7195            * fImRPQ1dEBE[0][pe][1][0]->GetBinEntries(fImRPQ1dEBE[0][pe][1][0]->GetBin(b));         
7196    q3n0kRe = fReRPQ1dEBE[0][pe][2][0]->GetBinContent(fReRPQ1dEBE[0][pe][2][0]->GetBin(b))
7197            * fReRPQ1dEBE[0][pe][2][0]->GetBinEntries(fReRPQ1dEBE[0][pe][2][0]->GetBin(b));
7198    q3n0kIm = fImRPQ1dEBE[0][pe][2][0]->GetBinContent(fImRPQ1dEBE[0][pe][2][0]->GetBin(b))
7199            * fImRPQ1dEBE[0][pe][2][0]->GetBinEntries(fImRPQ1dEBE[0][pe][2][0]->GetBin(b));         
7200                  
7201    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)  
7202   }
7203       
7204    if(type == "POI")
7205    {
7206     // p_{m*n,0}:
7207     p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))
7208             * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));
7209     p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  
7210             * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));
7211             
7212     mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
7213     
7214     t = 1; // typeFlag = RP or POI
7215    }
7216    else if(type == "RP")
7217    {
7218     // p_{m*n,0} = q_{m*n,0}:
7219     p1n0kRe = q1n0kRe; 
7220     p1n0kIm = q1n0kIm; 
7221             
7222     mp = mq; 
7223     
7224     t = 0; // typeFlag = RP or POI
7225    }
7226       
7227    // 3'-particle correlators:
7228    //  Taeney-Yan correlator:
7229    Double_t dTaeneyYan = 0.;
7230    Double_t mWeightTaeneyYan = 0.; // multiplicity weight for Taeney-Yan correlator
7231    if((mp*dMult-2.*mq)*(dMult-1.) > 0.) // to be improved - is this condition fully justified?
7232    {
7233     dTaeneyYan = (dReQ3n*(p1n0kRe*dReQ2n-p1n0kIm*dImQ2n)+dImQ3n*(p1n0kIm*dReQ2n+p1n0kRe*dImQ2n)
7234                - p1n0kRe*dReQ1n - p1n0kIm*dImQ1n
7235                - q2n0kRe*dReQ2n - q2n0kIm*dImQ2n              
7236                - q3n0kRe*dReQ3n - q3n0kIm*dImQ3n
7237                + 2.*mq)
7238                / ((mp*dMult-2.*mq)*(dMult-1.));
7239     // determine multiplicity weight:
7240     if(!strcmp(fMultiplicityWeight->Data(),"combinations"))
7241     {
7242      mWeightTaeneyYan = (mp*dMult-2.*mq)*(dMult-1.);
7243     } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))
7244       {
7245        mWeightTaeneyYan = 1.;    
7246       } 
7247     // Fill profiles:
7248     fOtherDiffCorrelators[t][pe][1][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dTaeneyYan,mWeightTaeneyYan);
7249    } // end of if((mp*dMult-2.*mq)*(dMult-1.) > 0.)  
7250    
7251  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
7252  
7253 } // end of void AliFlowAnalysisWithQCumulants::CalculateOtherDiffCorrelators(TString type, TString ptOrEta)
7254
7255 //================================================================================================================================
7256
7257 void AliFlowAnalysisWithQCumulants::Calculate2DDiffFlowCorrelations(TString type)
7258 {
7259  // Calculate all reduced correlations needed for 2D differential flow for each (pt,eta) bin. 
7260  
7261  // Multiplicity:
7262  Double_t dMult = (*fSpk)(0,0);
7263  // Real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
7264  Double_t dReQ1n = (*fReQ)(0,0);
7265  Double_t dReQ2n = (*fReQ)(1,0);
7266  //Double_t dReQ3n = (*fReQ)(2,0);
7267  //Double_t dReQ4n = (*fReQ)(3,0);
7268  Double_t dImQ1n = (*fImQ)(0,0);
7269  Double_t dImQ2n = (*fImQ)(1,0);
7270  //Double_t dImQ3n = (*fImQ)(2,0);
7271  //Double_t dImQ4n = (*fImQ)(3,0);
7272
7273  // 2D reduced correlations are stored in TProfile2D f2DDiffFlowCorrelationsPro[0=RP,1=POI][correlation index]. 
7274  // Correlation index runs as follows:
7275  //  0: <<2'>> 
7276  //  1: <<4'>>
7277  //  2: <<6'>>
7278  //  3: <<8'>>
7279  
7280  Int_t t = 0; // type flag  
7281  if(type == "RP")
7282  {
7283   t = 0;
7284  } else if(type == "POI")
7285    {
7286     t = 1;
7287    }
7288
7289  // Looping over all (pt,eta) bins and calculating correlations needed for differential flow: 
7290  for(Int_t p=1;p<=fnBinsPt;p++)
7291  {
7292   for(Int_t e=1;e<=fnBinsEta;e++)
7293   {
7294    // Real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular (pt,eta) bin): 
7295    Double_t p1n0kRe = 0.;
7296    Double_t p1n0kIm = 0.;
7297    // Number of POIs in particular pt or eta bin:
7298    Double_t mp = 0.;
7299    // Real and imaginary parts of q_{m*n,0} (non-weighted Q-vector evaluated for 'RP && POI particles' in particular pt or eta bin):
7300    Double_t q1n0kRe = 0.;
7301    Double_t q1n0kIm = 0.;
7302    Double_t q2n0kRe = 0.;
7303    Double_t q2n0kIm = 0.; 
7304    // Number of 'RP && POI particles' in particular pt or eta bin:
7305    Double_t mq = 0.;
7306    if(type == "POI")
7307    {
7308     // q_{m*n,0}:
7309     q1n0kRe = fReRPQ2dEBE[2][0][0]->GetBinContent(fReRPQ2dEBE[2][0][0]->GetBin(p,e))
7310             * fReRPQ2dEBE[2][0][0]->GetBinEntries(fReRPQ2dEBE[2][0][0]->GetBin(p,e));
7311     q1n0kIm = fImRPQ2dEBE[2][0][0]->GetBinContent(fImRPQ2dEBE[2][0][0]->GetBin(p,e))
7312             * fImRPQ2dEBE[2][0][0]->GetBinEntries(fImRPQ2dEBE[2][0][0]->GetBin(p,e));
7313     q2n0kRe = fReRPQ2dEBE[2][1][0]->GetBinContent(fReRPQ2dEBE[2][1][0]->GetBin(p,e))
7314             * fReRPQ2dEBE[2][1][0]->GetBinEntries(fReRPQ2dEBE[2][1][0]->GetBin(p,e));
7315     q2n0kIm = fImRPQ2dEBE[2][1][0]->GetBinContent(fImRPQ2dEBE[2][1][0]->GetBin(p,e))
7316             * fImRPQ2dEBE[2][1][0]->GetBinEntries(fImRPQ2dEBE[2][1][0]->GetBin(p,e));         
7317     // m_{q}:             
7318     mq = fReRPQ2dEBE[2][0][0]->GetBinEntries(fReRPQ2dEBE[2][0][0]->GetBin(p,e)); // to be improved (cross-checked by accessing other profiles here)
7319    } // end of if(type == "POI")
7320    else if(type == "RP")
7321    {
7322     // q_{m*n,0}:
7323     q1n0kRe = fReRPQ2dEBE[0][0][0]->GetBinContent(fReRPQ2dEBE[0][0][0]->GetBin(p,e))
7324             * fReRPQ2dEBE[0][0][0]->GetBinEntries(fReRPQ2dEBE[0][0][0]->GetBin(p,e));
7325     q1n0kIm = fImRPQ2dEBE[0][0][0]->GetBinContent(fImRPQ2dEBE[0][0][0]->GetBin(p,e))
7326             * fImRPQ2dEBE[0][0][0]->GetBinEntries(fImRPQ2dEBE[0][0][0]->GetBin(p,e));
7327     q2n0kRe = fReRPQ2dEBE[0][1][0]->GetBinContent(fReRPQ2dEBE[0][1][0]->GetBin(p,e))
7328             * fReRPQ2dEBE[0][1][0]->GetBinEntries(fReRPQ2dEBE[0][1][0]->GetBin(p,e));
7329     q2n0kIm = fImRPQ2dEBE[0][1][0]->GetBinContent(fImRPQ2dEBE[0][1][0]->GetBin(p,e))
7330             * fImRPQ2dEBE[0][1][0]->GetBinEntries(fImRPQ2dEBE[0][1][0]->GetBin(p,e));         
7331     // m_{q}:             
7332     mq = fReRPQ2dEBE[0][0][0]->GetBinEntries(fReRPQ2dEBE[0][0][0]->GetBin(p,e)); // to be improved (cross-checked by accessing other profiles here)  
7333    } // end of else if(type == "RP")
7334    if(type == "POI")
7335    {
7336     // p_{m*n,0}:
7337     p1n0kRe = fReRPQ2dEBE[1][0][0]->GetBinContent(fReRPQ2dEBE[1][0][0]->GetBin(p,e))
7338             * fReRPQ2dEBE[1][0][0]->GetBinEntries(fReRPQ2dEBE[1][0][0]->GetBin(p,e));
7339     p1n0kIm = fImRPQ2dEBE[1][0][0]->GetBinContent(fImRPQ2dEBE[1][0][0]->GetBin(p,e))  
7340             * fImRPQ2dEBE[1][0][0]->GetBinEntries(fImRPQ2dEBE[1][0][0]->GetBin(p,e));
7341     // m_{p}        
7342     mp = fReRPQ2dEBE[1][0][0]->GetBinEntries(fReRPQ2dEBE[1][0][0]->GetBin(p,e)); // to be improved (cross-checked by accessing other profiles here)
7343     
7344     t = 1; // typeFlag = RP or POI
7345    } // end of if(type == "POI")
7346    else if(type == "RP")
7347    {
7348     // p_{m*n,0} = q_{m*n,0}:
7349     p1n0kRe = q1n0kRe; 
7350     p1n0kIm = q1n0kIm; 
7351     // m_{p} = m_{q}:        
7352     mp = mq; 
7353
7354     t = 0; // typeFlag = RP or POI
7355    } // end of if(type == "RP")
7356
7357    // 2'-particle correlation for particular (pt,eta) bin:
7358    Double_t two1n1nPtEta = 0.;
7359    Double_t mWeight2pPrime = 0.; // multiplicity weight for <2'>
7360    if(mp*dMult-mq)
7361    {
7362     two1n1nPtEta = (p1n0kRe*dReQ1n+p1n0kIm*dImQ1n-mq)
7363                  / (mp*dMult-mq);
7364     // Determine multiplicity weight:
7365     if(!strcmp(fMultiplicityWeight->Data(),"combinations"))
7366     {
7367      mWeight2pPrime = mp*dMult-mq;
7368     } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))
7369       {
7370        mWeight2pPrime = 1.;    
7371       } 
7372     // Fill 2D profile holding <<2'>>:     
7373     f2DDiffFlowCorrelationsPro[t][0]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,two1n1nPtEta,mWeight2pPrime);
7374    } // end of if(mp*dMult-mq)
7375    
7376    // 4'-particle correlation:
7377    Double_t four1n1n1n1nPtEta = 0.;
7378    Double_t mWeight4pPrime = 0.; // multiplicity weight for <4'>
7379    if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)
7380        + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)) // to be improved (introduce a new variable for this expression)
7381    {
7382     four1n1n1n1nPtEta = ((pow(dReQ1n,2.)+pow(dImQ1n,2.))*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)
7383                       - q2n0kRe*(pow(dReQ1n,2.)-pow(dImQ1n,2.))
7384                       - 2.*q2n0kIm*dReQ1n*dImQ1n
7385                       - p1n0kRe*(dReQ1n*dReQ2n+dImQ1n*dImQ2n)
7386                       + p1n0kIm*(dImQ1n*dReQ2n-dReQ1n*dImQ2n)
7387                       - 2.*dMult*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)
7388                       - 2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))*mq                      
7389                       + 6.*(q1n0kRe*dReQ1n+q1n0kIm*dImQ1n)                                            
7390                       + 1.*(q2n0kRe*dReQ2n+q2n0kIm*dImQ2n)                      
7391                       + 2.*(p1n0kRe*dReQ1n+p1n0kIm*dImQ1n)                       
7392                       + 2.*mq*dMult                      
7393                       - 6.*mq)        
7394                       / ((mp-mq)*dMult*(dMult-1.)*(dMult-2.)
7395                           + mq*(dMult-1.)*(dMult-2.)*(dMult-3.)); 
7396     // Determine multiplicity weight:
7397     if(!strcmp(fMultiplicityWeight->Data(),"combinations"))
7398     {
7399      mWeight4pPrime = (mp-mq)*dMult*(dMult-1.)*(dMult-2.) + mq*(dMult-1.)*(dMult-2.)*(dMult-3.);
7400     } else if(!strcmp(fMultiplicityWeight->Data(),"unit"))
7401       {
7402        mWeight4pPrime = 1.;    
7403       }     
7404     // Fill 2D profile holding <<4'>>:
7405     f2DDiffFlowCorrelationsPro[t][1]->Fill(fPtMin+(p-1)*fPtBinWidth,fEtaMin+(e-1)*fEtaBinWidth,four1n1n1n1nPtEta,mWeight4pPrime);      
7406    } // end of if((mp-mq)*dMult*(dMult-1.)*(dMult-2.)
7407      //            +mq*(dMult-1.)*(dMult-2.)*(dMult-3.))
7408   } // end of for(Int_t e=1;e<=fnBinsEta;e++)
7409  } // end of for(Int_t p=1;p<=fnBinsPt;p++)   
7410       
7411 } // end of AliFlowAnalysisWithQCumulants::Calculate2DDiffFlowCorrelations(TString type)
7412
7413 //================================================================================================================================
7414
7415 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfEventWeights(TString type, TString ptOrEta)
7416 {
7417  // Calculate sums of various event weights for reduced correlations. 
7418  // (These quantitites are needed in expressions for unbiased estimators relevant for the statistical errors.)
7419
7420  Int_t typeFlag = 0;
7421  Int_t ptEtaFlag = 0;
7422
7423  if(type == "RP")
7424  {
7425   typeFlag = 0;
7426  } else if(type == "POI")
7427    {
7428     typeFlag = 1;
7429    } 
7430      
7431  if(ptOrEta == "Pt")
7432  {
7433   ptEtaFlag = 0;
7434  } else if(ptOrEta == "Eta")
7435    {
7436     ptEtaFlag = 1;
7437    } 
7438    
7439  // shortcuts:
7440  Int_t t = typeFlag;
7441  Int_t pe = ptEtaFlag;
7442  
7443  // binning:
7444  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
7445  Double_t minPtEta[2] = {fPtMin,fEtaMin};
7446  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
7447  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
7448  
7449  for(Int_t rpq=0;rpq<3;rpq++)
7450  {
7451   for(Int_t m=0;m<4;m++)
7452   {
7453    for(Int_t k=0;k<9;k++)
7454    {
7455     if(!fReRPQ1dEBE[rpq][pe][m][k])
7456     {
7457      cout<<"WARNING: fReRPQ1dEBE[rpq][pe][m][k] is NULL in AFAWQC::CSAPOEWFDF() !!!!"<<endl;
7458      cout<<"pe  = "<<pe<<endl;
7459      cout<<"rpq = "<<rpq<<endl;
7460      cout<<"m   = "<<m<<endl;
7461      cout<<"k   = "<<k<<endl;
7462      exit(0); 
7463     }
7464    }
7465   }
7466  }  
7467
7468  // multiplicities:
7469  Double_t dMult = (*fSpk)(0,0); // total event multiplicity
7470  //Double_t mr = 0.; // number of RPs in particular pt or eta bin
7471  Double_t mp = 0.; // number of POIs in particular pt or eta bin 
7472  Double_t mq = 0.; // number of particles which are both RPs and POIs in particular pt or eta bin
7473  
7474  // event weights for reduced correlations:
7475  Double_t dw2 = 0.; // event weight for <2'>
7476  Double_t dw4 = 0.; // event weight for <4'>
7477  //Double_t dw6 = 0.; // event weight for <6'>
7478  //Double_t dw8 = 0.; // event weight for <8'>
7479
7480  // looping over bins:
7481  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
7482  {
7483   if(type == "RP")
7484   {
7485    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(b);
7486    mp = mq; // trick to use the very same Eqs. bellow both for RP's and POI's diff. flow
7487   } else if(type == "POI")
7488     {
7489      mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(b);
7490      mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(b);    
7491     }
7492   
7493   // event weight for <2'>:
7494   dw2 = mp*dMult-mq;  
7495   fDiffFlowSumOfEventWeights[t][pe][0][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2);
7496   fDiffFlowSumOfEventWeights[t][pe][1][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw2,2.));
7497   
7498   // event weight for <4'>:
7499   dw4 = (mp-mq)*dMult*(dMult-1.)*(dMult-2.)
7500      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.);  
7501   fDiffFlowSumOfEventWeights[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4);
7502   fDiffFlowSumOfEventWeights[t][pe][1][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw4,2.));
7503   
7504   // event weight for <6'>:
7505   //dw6 = ...;  
7506   //fDiffFlowSumOfEventWeights[t][pe][0][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6);
7507   //fDiffFlowSumOfEventWeights[t][pe][t][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw6,2.));
7508   
7509   // event weight for <8'>:
7510   //dw8 = ...;  
7511   //fDiffFlowSumOfEventWeights[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw8);
7512   //fDiffFlowSumOfEventWeights[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],pow(dw8,2.));   
7513  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++) 
7514  
7515 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfEventWeights()
7516
7517
7518 //================================================================================================================================
7519
7520
7521 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfProductOfEventWeights(TString type, TString ptOrEta)
7522 {
7523  // Calculate sum of products of various event weights for both types of correlations (the ones for int. and diff. flow). 
7524  // (These quantitites are needed in expressions for unbiased estimators relevant for the statistical errors.)
7525  //
7526  // Important: To fill fDiffFlowSumOfProductOfEventWeights[][][][] use bellow table (i,j) with following constraints: 
7527  // 1.) i<j  
7528  // 2.) do not store terms which DO NOT include reduced correlations;
7529  // Table:
7530  // [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'>]
7531   
7532  Int_t typeFlag = 0;
7533  Int_t ptEtaFlag = 0;
7534
7535  if(type == "RP")
7536  {
7537   typeFlag = 0;
7538  } else if(type == "POI")
7539    {
7540     typeFlag = 1;
7541    } 
7542      
7543  if(ptOrEta == "Pt")
7544  {
7545   ptEtaFlag = 0;
7546  } else if(ptOrEta == "Eta")
7547    {
7548     ptEtaFlag = 1;
7549    } 
7550      
7551  // shortcuts:
7552  Int_t t = typeFlag;
7553  Int_t pe = ptEtaFlag;
7554   
7555  // binning:
7556  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
7557  Double_t minPtEta[2] = {fPtMin,fEtaMin};
7558  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
7559  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
7560  
7561  // protection:
7562  for(Int_t rpq=0;rpq<3;rpq++)
7563  {
7564   for(Int_t m=0;m<4;m++)
7565   {
7566    for(Int_t k=0;k<9;k++)
7567    {
7568     if(!fReRPQ1dEBE[rpq][pe][m][k])
7569     {
7570      cout<<"WARNING: fReRPQ1dEBE[rpq][pe][m][k] is NULL in AFAWQC::CSAPOEWFDF() !!!!"<<endl;
7571      cout<<"pe  = "<<pe<<endl;
7572      cout<<"rpq = "<<rpq<<endl;
7573      cout<<"m   = "<<m<<endl;
7574      cout<<"k   = "<<k<<endl;
7575      exit(0); 
7576     }
7577    }
7578   }
7579  }  
7580  
7581  // multiplicities:
7582  Double_t dMult = (*fSpk)(0,0); // total event multiplicity
7583  //Double_t mr = 0.; // number of RPs in particular pt or eta bin
7584  Double_t mp = 0.; // number of POIs in particular pt or eta bin 
7585  Double_t mq = 0.; // number of particles which are both RPs and POIs in particular pt or eta bin
7586  
7587  // event weights for correlations:
7588  Double_t dW2 = dMult*(dMult-1); // event weight for <2> 
7589  Double_t dW4 = dMult*(dMult-1)*(dMult-2)*(dMult-3); // event weight for <4> 
7590  Double_t dW6 = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5); // event weight for <6> 
7591  Double_t dW8 = dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5)*(dMult-6)*(dMult-7); // event weight for <8> 
7592
7593  // event weights for reduced correlations:
7594  Double_t dw2 = 0.; // event weight for <2'>
7595  Double_t dw4 = 0.; // event weight for <4'>
7596  //Double_t dw6 = 0.; // event weight for <6'>
7597  //Double_t dw8 = 0.; // event weight for <8'>
7598  
7599  // looping over bins:
7600  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
7601  {
7602   if(type == "RP")
7603   {
7604    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(b);
7605    mp = mq; // trick to use the very same Eqs. bellow both for RP's and POI's diff. flow
7606   } else if(type == "POI")
7607     {
7608      mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(b);
7609      mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(b);    
7610     }
7611   
7612   // event weight for <2'>:
7613   dw2 = mp*dMult-mq;  
7614   fDiffFlowSumOfProductOfEventWeights[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw2); // storing product of even weights for <2> and <2'>
7615   fDiffFlowSumOfProductOfEventWeights[t][pe][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dW4); // storing product of even weights for <4> and <2'>
7616   fDiffFlowSumOfProductOfEventWeights[t][pe][1][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dW6); // storing product of even weights for <6> and <2'>
7617   fDiffFlowSumOfProductOfEventWeights[t][pe][1][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dW8); // storing product of even weights for <8> and <2'>
7618   
7619   // event weight for <4'>:
7620   dw4 = (mp-mq)*dMult*(dMult-1.)*(dMult-2.)
7621      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.);  
7622   fDiffFlowSumOfProductOfEventWeights[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw4); // storing product of even weights for <2> and <4'>
7623   fDiffFlowSumOfProductOfEventWeights[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dw4); // storing product of even weights for <2'> and <4'>
7624   fDiffFlowSumOfProductOfEventWeights[t][pe][2][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW4*dw4); // storing product of even weights for <4> and <4'>
7625   fDiffFlowSumOfProductOfEventWeights[t][pe][3][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dW6); // storing product of even weights for <6> and <4'> 
7626   fDiffFlowSumOfProductOfEventWeights[t][pe][3][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dW8); // storing product of even weights for <8> and <4'>
7627
7628   // event weight for <6'>:
7629   //dw6 = ...;  
7630   //fDiffFlowSumOfProductOfEventWeights[t][pe][0][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw6); // storing product of even weights for <2> and <6'>
7631   //fDiffFlowSumOfProductOfEventWeights[t][pe][1][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dw6); // storing product of even weights for <2'> and <6'>
7632   //fDiffFlowSumOfProductOfEventWeights[t][pe][2][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW4*dw6); // storing product of even weights for <4> and <6'>
7633   //fDiffFlowSumOfProductOfEventWeights[t][pe][3][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dw6); // storing product of even weights for <4'> and <6'> 
7634   //fDiffFlowSumOfProductOfEventWeights[t][pe][4][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW6*dw6); // storing product of even weights for <6> and <6'>
7635   //fDiffFlowSumOfProductOfEventWeights[t][pe][5][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6*dW8); // storing product of even weights for <6'> and <8>
7636   //fDiffFlowSumOfProductOfEventWeights[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6*dw8); // storing product of even weights for <6'> and <8'>
7637
7638   // event weight for <8'>:
7639   //dw8 = ...;  
7640   //fDiffFlowSumOfProductOfEventWeights[t][pe][0][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW2*dw8); // storing product of even weights for <2> and <8'>
7641   //fDiffFlowSumOfProductOfEventWeights[t][pe][1][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw2*dw8); // storing product of even weights for <2'> and <8'>
7642   //fDiffFlowSumOfProductOfEventWeights[t][pe][2][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW4*dw8); // storing product of even weights for <4> and <8'>
7643   //fDiffFlowSumOfProductOfEventWeights[t][pe][3][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw4*dw8); // storing product of even weights for <4'> and <8'> 
7644   //fDiffFlowSumOfProductOfEventWeights[t][pe][4][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW6*dw8); // storing product of even weights for <6> and <8'>
7645   //fDiffFlowSumOfProductOfEventWeights[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dw6*dw8); // storing product of even weights for <6'> and <8'>
7646   //fDiffFlowSumOfProductOfEventWeights[t][pe][6][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],dW8*dw8); // storing product of even weights for <8> and <8'>
7647   
7648   // Table:
7649   // [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'>]
7650    
7651  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
7652  
7653
7654
7655 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowSumOfProductOfEventWeights(TString type, TString ptOrEta)
7656
7657 //================================================================================================================================
7658
7659 void AliFlowAnalysisWithQCumulants::FinalizeReducedCorrelations(TString type, TString ptOrEta)
7660 {
7661  // Transfer profiles into histograms and calculate statistical errors correctly.
7662
7663  Int_t t = 0; // RP or POI
7664  Int_t pe = 0; // pt or eta
7665
7666  if(type == "RP")
7667  {
7668   t = 0;
7669  } else if(type == "POI")
7670    {
7671     t = 1;
7672    } 
7673      
7674  if(ptOrEta == "Pt")
7675  {
7676   pe = 0;
7677  } else if(ptOrEta == "Eta")
7678    {
7679     pe = 1;
7680    } 
7681                
7682  for(Int_t rci=0;rci<4;rci++) // to be improved - moved into the method CheckPointersUsedInFinish()
7683  {
7684   if(!fDiffFlowCorrelationsPro[t][pe][rci])
7685   {
7686    cout<<"WARNING: fDiffFlowCorrelationsPro[t][pe][rci] is NULL in AFAWQC::FRC() !!!!"<<endl;
7687    cout<<"t   = "<<t<<endl; 
7688    cout<<"pe  = "<<pe<<endl; 
7689    cout<<"rci = "<<rci<<endl;
7690    exit(0); 
7691   }
7692   if(!fDiffFlowSquaredCorrelationsPro[t][pe][rci])
7693   {
7694    cout<<"WARNING: fDiffFlowSquaredCorrelationsPro[t][pe][rci] is NULL in AFAWQC::FRC() !!!!"<<endl;
7695    cout<<"t   = "<<t<<endl; 
7696    cout<<"pe  = "<<pe<<endl; 
7697    cout<<"rci = "<<rci<<endl;
7698    exit(0); 
7699   }
7700   for(Int_t power=0;power<2;power++)
7701   {
7702    if(!fDiffFlowSumOfEventWeights[t][pe][power][rci])
7703    {
7704     cout<<"WARNING: fDiffFlowSumOfEventWeights[t][pe][power][rci] is NULL in AFAWQC::FRC() !!!!"<<endl;
7705     cout<<"t     = "<<t<<endl; 
7706     cout<<"pe    = "<<pe<<endl;
7707     cout<<"power = "<<power<<endl; 
7708     cout<<"rci   = "<<rci<<endl;
7709     exit(0); 
7710    }   
7711   } // end of for(Int_t power=0;power<2;power++)
7712  } // end of for(Int_t rci=0;rci<4;rci++)
7713     
7714  // common:
7715  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta}; 
7716  // transfer 1D profile into 1D histogram:
7717  Double_t correlation = 0.;
7718  Double_t squaredCorrelation = 0.;
7719  Double_t spread = 0.;
7720  Double_t sumOfWeights = 0.; // sum of weights for particular reduced correlations for particular pt or eta bin
7721  Double_t sumOfSquaredWeights = 0.; // sum of squared weights for particular reduced correlations for particular pt or eta bin
7722  Double_t error = 0.; // error = termA * spread * termB
7723                       // termA = (sqrt(sumOfSquaredWeights)/sumOfWeights) 
7724                       // termB = 1/pow(1-termA^2,0.5)
7725  Double_t termA = 0.;                      
7726  Double_t termB = 0.;                      
7727  for(Int_t rci=0;rci<4;rci++) // index of reduced correlation
7728  {
7729   for(Int_t b=1;b<=nBinsPtEta[pe];b++) // number of pt or eta bins
7730   {
7731    if(fDiffFlowCorrelationsPro[t][pe][rci]->GetBinEffectiveEntries(b) < 2 || 
7732       fDiffFlowSquaredCorrelationsPro[t][pe][rci]->GetBinEffectiveEntries(b) < 2)
7733    {
7734     fDiffFlowCorrelationsPro[t][pe][rci]->SetBinError(b,0.);
7735     fDiffFlowSquaredCorrelationsPro[t][pe][rci]->SetBinError(b,0.);
7736     continue; // to be improved - should I ignore results in pt bins with one entry for reduced correlations or not?
7737    }  
7738    correlation = fDiffFlowCorrelationsPro[t][pe][rci]->GetBinContent(b); 
7739    squaredCorrelation = fDiffFlowSquaredCorrelationsPro[t][pe][rci]->GetBinContent(b); 
7740    if(squaredCorrelation-correlation*correlation >= 0.)
7741    {
7742     spread = pow(squaredCorrelation-correlation*correlation,0.5);
7743    } else
7744      {
7745       cout<<endl;
7746       cout<<Form(" WARNING: Imaginary 'spread' for rci = %d, pe = %d, bin = %d !!!!",rci,pe,b)<<endl;
7747       cout<<endl;
7748      }
7749    sumOfWeights = fDiffFlowSumOfEventWeights[t][pe][0][rci]->GetBinContent(b);
7750    sumOfSquaredWeights = fDiffFlowSumOfEventWeights[t][pe][1][rci]->GetBinContent(b);
7751    if(TMath::Abs(sumOfWeights)>0.){termA = (pow(sumOfSquaredWeights,0.5)/sumOfWeights);}
7752    if(1.-pow(termA,2.)>0.){termB = 1./pow(1.-pow(termA,2.),0.5);} 
7753    error = termA*spread*termB; // final error (unbiased estimator for standard deviation)
7754    fDiffFlowCorrelationsHist[t][pe][rci]->SetBinContent(b,correlation); 
7755    fDiffFlowCorrelationsHist[t][pe][rci]->SetBinError(b,error); 
7756   } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
7757  } // end of for(Int_t rci=0;rci<4;rci++)
7758  
7759 } // end of void AliFlowAnalysisWithQCumulants::FinalizeReducedCorrelations(TString type, TString ptOrEta)
7760
7761 //================================================================================================================================
7762
7763 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowProductOfCorrelations(TString type, TString ptOrEta)
7764 {
7765  // store products: <2><2'>, <2><4'>, <2><6'>, <2><8'>, <2'><4>, 
7766  //                 <2'><4'>, <2'><6>, <2'><6'>, <2'><8>, <2'><8'>,
7767  //                 <4><4'>, <4><6'>, <4><8'>, <4'><6>, <4'><6'>, 
7768  //                 <4'><8>, <4'><8'>, <6><6'>, <6><8'>, <6'><8>, 
7769  //                 <6'><8'>, <8><8'>.
7770   
7771  Int_t typeFlag = 0;
7772  Int_t ptEtaFlag = 0;
7773
7774  if(type == "RP")
7775  {
7776   typeFlag = 0;
7777  } else if(type == "POI")
7778    {
7779     typeFlag = 1;
7780    } 
7781      
7782  if(ptOrEta == "Pt")
7783  {
7784   ptEtaFlag = 0;
7785  } else if(ptOrEta == "Eta")
7786    {
7787     ptEtaFlag = 1;
7788    } 
7789   
7790  // shortcuts:
7791  Int_t t = typeFlag;
7792  Int_t pe = ptEtaFlag;
7793      
7794  // common:
7795  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
7796  Double_t minPtEta[2] = {fPtMin,fEtaMin};
7797  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
7798    
7799  // protections // to be improved (add protection for all pointers in this method)
7800  if(!fIntFlowCorrelationsEBE)
7801  {
7802   cout<<"WARNING: fIntFlowCorrelationsEBE is NULL in AFAWQC::CDFPOC() !!!!"<<endl;
7803   exit(0);
7804  } 
7805  
7806  /*    
7807  Double_t dMult = (*fSpk)(0,0); // multiplicity (number of particles used to determine the reaction plane)
7808  //Double_t mr = 0.; // number of RPs in particular pt or eta bin
7809  Double_t mp = 0.; // number of POIs in particular pt or eta bin 
7810  Double_t mq = 0.; // number of particles which are both RPs and POIs in particular pt or eta bin
7811  */
7812
7813  // e-b-e correlations:
7814  Double_t twoEBE = fIntFlowCorrelationsEBE->GetBinContent(1); // <2>
7815  Double_t fourEBE = fIntFlowCorrelationsEBE->GetBinContent(2); // <4>
7816  Double_t sixEBE = fIntFlowCorrelationsEBE->GetBinContent(3); // <6>
7817  Double_t eightEBE = fIntFlowCorrelationsEBE->GetBinContent(4); // <8>
7818  
7819  // event weights for correlations:
7820  Double_t dW2 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(1); // event weight for <2> 
7821  Double_t dW4 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(2); // event weight for <4> 
7822  Double_t dW6 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(3); // event weight for <6> 
7823  Double_t dW8 = fIntFlowEventWeightsForCorrelationsEBE->GetBinContent(4); // event weight for <8> 
7824   
7825  // e-b-e reduced correlations:
7826  Double_t twoReducedEBE = 0.; // <2'>
7827  Double_t fourReducedEBE = 0.; // <4'>
7828  //Double_t sixReducedEBE = 0.; // <6'>
7829  //Double_t eightReducedEBE = 0.; // <8'> 
7830  
7831  // event weights for reduced correlations:
7832  Double_t dw2 = 0.; // event weight for <2'>
7833  Double_t dw4 = 0.; // event weight for <4'>
7834  //Double_t dw6 = 0.; // event weight for <6'>
7835  //Double_t dw8 = 0.; // event weight for <8'>
7836
7837  // looping over bins:
7838  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
7839  {
7840   // e-b-e reduced correlations:
7841   twoReducedEBE = fDiffFlowCorrelationsEBE[t][pe][0]->GetBinContent(b);
7842   fourReducedEBE = fDiffFlowCorrelationsEBE[t][pe][1]->GetBinContent(b);
7843   //sixReducedEBE = fDiffFlowCorrelationsEBE[t][pe][2]->GetBinContent(b);
7844   //eightReducedEBE = fDiffFlowCorrelationsEBE[t][pe][3]->GetBinContent(b);
7845   
7846   /*
7847   // to be improved (I should not do this here again)
7848   if(type == "RP")
7849   {
7850    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(b);
7851    mp = mq; // trick to use the very same Eqs. bellow both for RP's and POI's diff. flow
7852   } else if(type == "POI")
7853     {
7854      mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(b);
7855      mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(b);    
7856     }
7857   
7858   // event weights for reduced correlations:
7859   dw2 = mp*dMult-mq; // weight for <2'> 
7860   dw4 = (mp-mq)*dMult*(dMult-1.)*(dMult-2.)
7861      + mq*(dMult-1.)*(dMult-2.)*(dMult-3.); // weight for <4'>
7862   //dw6 = ...     
7863   //dw8 = ...     
7864   
7865   */
7866   
7867   dw2 = fDiffFlowEventWeightsForCorrelationsEBE[t][pe][0]->GetBinContent(b);
7868   dw4 = fDiffFlowEventWeightsForCorrelationsEBE[t][pe][1]->GetBinContent(b);
7869  
7870   // storing all products:
7871   fDiffFlowProductOfCorrelationsPro[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*twoReducedEBE,dW2*dw2); // storing <2><2'>
7872   fDiffFlowProductOfCorrelationsPro[t][pe][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*twoReducedEBE,dW4*dw2); // storing <4><2'>
7873   fDiffFlowProductOfCorrelationsPro[t][pe][1][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*twoReducedEBE,dW6*dw2); // storing <6><2'>
7874   fDiffFlowProductOfCorrelationsPro[t][pe][1][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],eightEBE*twoReducedEBE,dW8*dw2); // storing <8><2'>
7875   
7876   // event weight for <4'>:
7877   fDiffFlowProductOfCorrelationsPro[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*fourReducedEBE,dW2*dw4); // storing <2><4'>
7878   fDiffFlowProductOfCorrelationsPro[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoReducedEBE*fourReducedEBE,dw2*dw4); // storing <2'><4'>
7879   fDiffFlowProductOfCorrelationsPro[t][pe][2][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*fourReducedEBE,dW4*dw4); // storing <4><4'>
7880   fDiffFlowProductOfCorrelationsPro[t][pe][3][4]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*fourReducedEBE,dW6*dw4); // storing <6><4'> 
7881   fDiffFlowProductOfCorrelationsPro[t][pe][3][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],eightEBE*fourReducedEBE,dW8*dw4); // storing <8><4'>
7882
7883   // event weight for <6'>:
7884   //dw6 = ...;  
7885   //fDiffFlowProductOfCorrelationsPro[t][pe][0][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*sixReducedEBE,dW2*dw6); // storing <2><6'>
7886   //fDiffFlowProductOfCorrelationsPro[t][pe][1][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoReducedEBE*sixReducedEBE,dw2*dw6); // storing <2'><6'>
7887   //fDiffFlowProductOfCorrelationsPro[t][pe][2][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*sixReducedEBE,dW4*dw6); // storing <4><6'>
7888   //fDiffFlowProductOfCorrelationsPro[t][pe][3][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourReducedEBE*sixReducedEBE,dw4*dw6); // storing <4'><6'> 
7889   //fDiffFlowProductOfCorrelationsPro[t][pe][4][5]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*sixReducedEBE,dW6*dw6); // storing <6><6'>
7890   //fDiffFlowProductOfCorrelationsPro[t][pe][5][6]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixReducedEBE*eightEBE,dw6*dW8); // storing <6'><8>
7891   //fDiffFlowProductOfCorrelationsPro[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixReducedEBE*eightReducedEBE,dw6*dw8); // storing <6'><8'>
7892
7893   // event weight for <8'>:
7894   //dw8 = ...;  
7895   //fDiffFlowProductOfCorrelationsPro[t][pe][0][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoEBE*eightReducedEBE,dW2*dw8); // storing <2><8'>
7896   //fDiffFlowProductOfCorrelationsPro[t][pe][1][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],twoReducedEBE*eightReducedEBE,dw2*dw8); // storing <2'><8'>
7897   //fDiffFlowProductOfCorrelationsPro[t][pe][2][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourEBE*eightReducedEBE,dW4*dw8); // storing <4><8'>
7898   //fDiffFlowProductOfCorrelationsPro[t][pe][3][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],fourReducedEBE*eightReducedEBE,dw4*dw8); // storing <4'><8'> 
7899   //fDiffFlowProductOfCorrelationsPro[t][pe][4][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixEBE*eightReducedEBE,dW6*dw8); // storing <6><8'>
7900   //fDiffFlowProductOfCorrelationsPro[t][pe][5][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sixReducedEBE*eightReducedEBE,dw6*dw8); // storing <6'><8'>
7901   //fDiffFlowProductOfCorrelationsPro[t][pe][6][7]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],eightEBE*eightReducedEBE,dW8*dw8); // storing <8><8'> 
7902  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++       
7903      
7904 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowProductOfCorrelations(TString type, TString ptOrEta)
7905
7906 //================================================================================================================================
7907     
7908 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCovariances(TString type, TString ptOrEta) // to be improved (reimplemented)
7909 {
7910  // a) Calculate unbiased estimators Cov(<2>,<2'>), Cov(<2>,<4'>), Cov(<4>,<2'>), Cov(<4>,<4'>) and Cov(<2'>,<4'>)
7911  //    for covariances V(<2>,<2'>), V(<2>,<4'>), V(<4>,<2'>), V(<4>,<4'>) and V(<2'>,<4'>).  
7912  // b) Store in histogram fDiffFlowCovariances[t][pe][index] for instance the following: 
7913  //
7914  //             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)]
7915  // 
7916  //     where N is the number of events, w_{<2>} is event weight for <2> and w_{<2'>} is event weight for <2'>.
7917  // c) Binning of fDiffFlowCovariances[t][pe][index] is organized as follows:
7918  // 
7919  //     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)] 
7920  //     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)] 
7921  //     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)] 
7922  //     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)] 
7923  //     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)] 
7924  //     ...
7925   
7926  Int_t typeFlag = 0;
7927  Int_t ptEtaFlag = 0;
7928
7929  if(type == "RP")
7930  {
7931   typeFlag = 0;
7932  } else if(type == "POI")
7933    {
7934     typeFlag = 1;
7935    } 
7936      
7937  if(ptOrEta == "Pt")
7938  {
7939   ptEtaFlag = 0;
7940  } else if(ptOrEta == "Eta")
7941    {
7942     ptEtaFlag = 1;
7943    } 
7944   
7945  // shortcuts:
7946  Int_t t = typeFlag;
7947  Int_t pe = ptEtaFlag;
7948      
7949  // common:
7950  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
7951  //Double_t minPtEta[2] = {fPtMin,fEtaMin};
7952  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
7953  //Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
7954  
7955  // average correlations:
7956  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>
7957  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>
7958  //Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>>
7959  //Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>
7960  
7961  // sum of weights for correlation:
7962  Double_t sumOfWeightsForTwo = fIntFlowSumOfEventWeights[0]->GetBinContent(1); // sum_{i=1}^{N} w_{<2>}
7963  Double_t sumOfWeightsForFour = fIntFlowSumOfEventWeights[0]->GetBinContent(2); // sum_{i=1}^{N} w_{<4>}
7964  //Double_t sumOfWeightsForSix = fIntFlowSumOfEventWeights[0]->GetBinContent(3); // sum_{i=1}^{N} w_{<6>}
7965  //Double_t sumOfWeightsForEight = fIntFlowSumOfEventWeights[0]->GetBinContent(4); // sum_{i=1}^{N} w_{<8>}
7966  
7967  // average reduced correlations:
7968  Double_t twoReduced = 0.; // <<2'>> 
7969  Double_t fourReduced = 0.; // <<4'>>
7970  //Double_t sixReduced = 0.; // <<6'>>
7971  //Double_t eightReduced = 0.; // <<8'>>
7972
7973  // sum of weights for reduced correlation:
7974  Double_t sumOfWeightsForTwoReduced = 0.; // sum_{i=1}^{N} w_{<2'>}
7975  Double_t sumOfWeightsForFourReduced = 0.; // sum_{i=1}^{N} w_{<4'>}
7976  //Double_t sumOfWeightsForSixReduced = 0.; // sum_{i=1}^{N} w_{<6'>}
7977  //Double_t sumOfWeightsForEightReduced = 0.; // sum_{i=1}^{N} w_{<8'>}
7978   
7979  // product of weights for reduced correlation:
7980  Double_t productOfWeightsForTwoTwoReduced = 0.; // sum_{i=1}^{N} w_{<2>}w_{<2'>}
7981  Double_t productOfWeightsForTwoFourReduced = 0.; // sum_{i=1}^{N} w_{<2>}w_{<4'>}
7982  Double_t productOfWeightsForFourTwoReduced = 0.; // sum_{i=1}^{N} w_{<4>}w_{<2'>}
7983  Double_t productOfWeightsForFourFourReduced = 0.; // sum_{i=1}^{N} w_{<4>}w_{<4'>}
7984  Double_t productOfWeightsForTwoReducedFourReduced = 0.; // sum_{i=1}^{N} w_{<2'>}w_{<4'>}
7985  // ...
7986  
7987  // products for differential flow:
7988  Double_t twoTwoReduced = 0; // <<2><2'>> 
7989  Double_t twoFourReduced = 0; // <<2><4'>> 
7990  Double_t fourTwoReduced = 0; // <<4><2'>> 
7991  Double_t fourFourReduced = 0; // <<4><4'>> 
7992  Double_t twoReducedFourReduced = 0; // <<2'><4'>> 
7993
7994  // denominators in the expressions for the unbiased estimators for covariances:
7995  // denominator = 1 - term1/(term2*term3)
7996  // prefactor = term1/(term2*term3)
7997  Double_t denominator = 0.; 
7998  Double_t prefactor = 0.;
7999  Double_t term1 = 0.; 
8000  Double_t term2 = 0.; 
8001  Double_t term3 = 0.; 
8002  
8003  // unbiased estimators for covariances for differential flow:
8004  Double_t covTwoTwoReduced = 0.; // Cov(<2>,<2'>)
8005  Double_t wCovTwoTwoReduced = 0.; // Cov(<2>,<2'>) * prefactor(w_{<2>},w_{<2'>})
8006  Double_t covTwoFourReduced = 0.; // Cov(<2>,<4'>)
8007  Double_t wCovTwoFourReduced = 0.; // Cov(<2>,<4'>) * prefactor(w_{<2>},w_{<4'>})
8008  Double_t covFourTwoReduced = 0.; // Cov(<4>,<2'>)
8009  Double_t wCovFourTwoReduced = 0.; // Cov(<4>,<2'>) * prefactor(w_{<4>},w_{<2'>})
8010  Double_t covFourFourReduced = 0.; // Cov(<4>,<4'>)
8011  Double_t wCovFourFourReduced = 0.; // Cov(<4>,<4'>) * prefactor(w_{<4>},w_{<4'>})
8012  Double_t covTwoReducedFourReduced = 0.; // Cov(<2'>,<4'>)
8013  Double_t wCovTwoReducedFourReduced = 0.; // Cov(<2'>,<4'>) * prefactor(w_{<2'>},w_{<4'>})
8014  
8015  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
8016  {
8017   // average reduced corelations:
8018   twoReduced = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b);
8019   fourReduced = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b);
8020   // average products:
8021   twoTwoReduced = fDiffFlowProductOfCorrelationsPro[t][pe][0][1]->GetBinContent(b);
8022   twoFourReduced = fDiffFlowProductOfCorrelationsPro[t][pe][0][3]->GetBinContent(b);
8023   fourTwoReduced = fDiffFlowProductOfCorrelationsPro[t][pe][1][2]->GetBinContent(b);
8024   fourFourReduced = fDiffFlowProductOfCorrelationsPro[t][pe][2][3]->GetBinContent(b);
8025   twoReducedFourReduced = fDiffFlowProductOfCorrelationsPro[t][pe][1][3]->GetBinContent(b);  
8026   // sum of weights for reduced correlations:
8027   sumOfWeightsForTwoReduced = fDiffFlowSumOfEventWeights[t][pe][0][0]->GetBinContent(b);
8028   sumOfWeightsForFourReduced = fDiffFlowSumOfEventWeights[t][pe][0][1]->GetBinContent(b);
8029   // products of weights for correlations:
8030   productOfWeightsForTwoTwoReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][0][1]->GetBinContent(b); 
8031   productOfWeightsForTwoFourReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][0][3]->GetBinContent(b);
8032   productOfWeightsForFourTwoReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][1][2]->GetBinContent(b);
8033   productOfWeightsForFourFourReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][2][3]->GetBinContent(b);
8034   productOfWeightsForTwoReducedFourReduced = fDiffFlowSumOfProductOfEventWeights[t][pe][1][3]->GetBinContent(b);
8035   // denominator for the unbiased estimator for covariances: 1 - term1/(term2*term3) 
8036   // prefactor (multiplies Cov's) = term1/(term2*term3)       
8037   // <2>,<2'>:
8038   term1 = productOfWeightsForTwoTwoReduced;      
8039   term2 = sumOfWeightsForTwo;
8040   term3 = sumOfWeightsForTwoReduced;        
8041   if(term2*term3>0.)
8042   {
8043    denominator = 1.-term1/(term2*term3);
8044    prefactor = term1/(term2*term3);
8045    if(TMath::Abs(denominator)>1.e-6)
8046    {
8047     covTwoTwoReduced = (twoTwoReduced-two*twoReduced)/denominator;            
8048     wCovTwoTwoReduced = covTwoTwoReduced*prefactor; 
8049     fDiffFlowCovariances[t][pe][0]->SetBinContent(b,wCovTwoTwoReduced);
8050    }
8051   }
8052   // <2>,<4'>:
8053   term1 = productOfWeightsForTwoFourReduced;      
8054   term2 = sumOfWeightsForTwo;
8055   term3 = sumOfWeightsForFourReduced;        
8056   if(term2*term3>0.)
8057   {
8058    denominator = 1.-term1/(term2*term3);
8059    prefactor = term1/(term2*term3);
8060    if(TMath::Abs(denominator)>1.e-6)
8061    {
8062     covTwoFourReduced = (twoFourReduced-two*fourReduced)/denominator;            
8063     wCovTwoFourReduced = covTwoFourReduced*prefactor; 
8064     fDiffFlowCovariances[t][pe][1]->SetBinContent(b,wCovTwoFourReduced);
8065    }
8066   }
8067   // <4>,<2'>:
8068   term1 = productOfWeightsForFourTwoReduced;      
8069   term2 = sumOfWeightsForFour;
8070   term3 = sumOfWeightsForTwoReduced;        
8071   if(term2*term3>0.)
8072   {
8073    denominator = 1.-term1/(term2*term3);
8074    prefactor = term1/(term2*term3);
8075    if(TMath::Abs(denominator)>1.e-6)
8076    {
8077     covFourTwoReduced = (fourTwoReduced-four*twoReduced)/denominator;            
8078     wCovFourTwoReduced = covFourTwoReduced*prefactor; 
8079     fDiffFlowCovariances[t][pe][2]->SetBinContent(b,wCovFourTwoReduced);
8080    }
8081   }
8082   // <4>,<4'>:
8083   term1 = productOfWeightsForFourFourReduced;      
8084   term2 = sumOfWeightsForFour;
8085   term3 = sumOfWeightsForFourReduced;        
8086   if(term2*term3>0.)
8087   {
8088    denominator = 1.-term1/(term2*term3);
8089    prefactor = term1/(term2*term3);
8090    if(TMath::Abs(denominator)>1.e-6)
8091    {
8092     covFourFourReduced = (fourFourReduced-four*fourReduced)/denominator;            
8093     wCovFourFourReduced = covFourFourReduced*prefactor; 
8094     fDiffFlowCovariances[t][pe][3]->SetBinContent(b,wCovFourFourReduced);
8095    }
8096   }
8097   // <2'>,<4'>:
8098   term1 = productOfWeightsForTwoReducedFourReduced;      
8099   term2 = sumOfWeightsForTwoReduced;
8100   term3 = sumOfWeightsForFourReduced;        
8101   if(term2*term3>0.)
8102   {
8103    denominator = 1.-term1/(term2*term3);
8104    prefactor = term1/(term2*term3);
8105    if(TMath::Abs(denominator)>1.e-6)
8106    {
8107     covTwoReducedFourReduced = (twoReducedFourReduced-twoReduced*fourReduced)/denominator;            
8108     wCovTwoReducedFourReduced = covTwoReducedFourReduced*prefactor; 
8109     fDiffFlowCovariances[t][pe][4]->SetBinContent(b,wCovTwoReducedFourReduced);
8110    }
8111   }   
8112  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
8113   
8114 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCovariances(TString type, TString ptOrEta)
8115
8116 //================================================================================================================================
8117
8118 void AliFlowAnalysisWithQCumulants::CalculateDiffFlow(TString type, TString ptOrEta)
8119 {
8120  // Calculate final results for differential flow.
8121  
8122  // REMARK: Differential flow calculated in this method is NOT corrected for non-uniform acceptance. 
8123  // This correction, if enabled via setter SetApplyCorrectionForNUA(Bool_t), is applied in the method 
8124  // CalculateDiffFlowCorrectedForNUA(TString type, TString ptOrEta)
8125   
8126  Int_t t = 0; // RP or POI
8127  Int_t pe = 0; // pt or eta
8128
8129  if(type == "RP")
8130  {
8131   t = 0;
8132  } else if(type == "POI")
8133    {
8134     t = 1;
8135    } 
8136      
8137  if(ptOrEta == "Pt")
8138  {
8139   pe = 0;
8140  } else if(ptOrEta == "Eta")
8141    {
8142     pe = 1;
8143    } 
8144        
8145  // Common:
8146  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
8147  // Correlations:
8148  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>
8149  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>> 
8150  // Statistical errors of correlations:
8151  Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1);
8152  Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2);   
8153  // Reduced correlations:
8154  Double_t twoReduced = 0.; // <<2'>>
8155  Double_t fourReduced = 0.; // <<4'>>
8156  // Statistical errors of reduced correlations:
8157  Double_t twoReducedError = 0.; 
8158  Double_t fourReducedError = 0.; 
8159  // Covariances:
8160  Double_t wCovTwoFour = 0.; // Cov(<2>,<4>) * prefactor(<2>,<4>)
8161  if(!fForgetAboutCovariances)
8162  {
8163   wCovTwoFour = fIntFlowCovariances->GetBinContent(1); // Cov(<2>,<4>) * prefactor(<2>,<4>)
8164  }
8165  Double_t wCovTwoTwoReduced = 0.; // Cov(<2>,<2'>) * prefactor(<2>,<2'>)
8166  Double_t wCovTwoFourReduced = 0.; // Cov(<2>,<4'>) * prefactor(<2>,<4'>)
8167  Double_t wCovFourTwoReduced = 0.; // Cov(<4>,<2'>) * prefactor(<4>,<2'>)
8168  Double_t wCovFourFourReduced = 0.; // Cov(<4>,<4'>) * prefactor(<4>,<4'>)
8169  Double_t wCovTwoReducedFourReduced = 0.; // Cov(<2'>,<4'>) * prefactor(<2'>,<4'>)
8170  // Differential flow:
8171  Double_t v2Prime = 0.; // v'{2}                   
8172  Double_t v4Prime = 0.; // v'{4}
8173  // Statistical error of differential flow:
8174  Double_t v2PrimeError = 0.;                    
8175  Double_t v4PrimeError = 0.; 
8176  // Squared statistical error of differential flow:
8177  Double_t v2PrimeErrorSquared = 0.;                    
8178  Double_t v4PrimeErrorSquared = 0.; 
8179  // Loop over pt or eta bins:
8180  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
8181  {
8182   // Reduced correlations and statistical errors:
8183   twoReduced = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b);
8184   twoReducedError = fDiffFlowCorrelationsHist[t][pe][0]->GetBinError(b);
8185   fourReduced = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b);
8186   fourReducedError = fDiffFlowCorrelationsHist[t][pe][1]->GetBinError(b);
8187   // Covariances:
8188   if(!fForgetAboutCovariances)
8189   {
8190    wCovTwoTwoReduced = fDiffFlowCovariances[t][pe][0]->GetBinContent(b);
8191    wCovTwoFourReduced = fDiffFlowCovariances[t][pe][1]->GetBinContent(b);
8192    wCovFourTwoReduced = fDiffFlowCovariances[t][pe][2]->GetBinContent(b);
8193    wCovFourFourReduced = fDiffFlowCovariances[t][pe][3]->GetBinContent(b);
8194    wCovTwoReducedFourReduced = fDiffFlowCovariances[t][pe][4]->GetBinContent(b);
8195   }
8196   // Differential flow:
8197   // v'{2}:
8198   if(two>0.) 
8199   {
8200    v2Prime = twoReduced/pow(two,0.5);
8201    v2PrimeErrorSquared = (1./4.)*pow(two,-3.)*(pow(twoReduced,2.)*pow(twoError,2.)
8202                        + 4.*pow(two,2.)*pow(twoReducedError,2.)
8203                        - 4.*two*twoReduced*wCovTwoTwoReduced);
8204    if(v2PrimeErrorSquared>0.){v2PrimeError = pow(v2PrimeErrorSquared,0.5);}
8205    if(TMath::Abs(v2Prime)>0.)
8206    {
8207     fDiffFlow[t][pe][0]->SetBinContent(b,v2Prime); 
8208     fDiffFlow[t][pe][0]->SetBinError(b,v2PrimeError);    
8209    }  
8210   } // end of if(two>0.) 
8211   // differential flow:
8212   // v'{4}
8213   if(2.*pow(two,2.)-four > 0.) 
8214   {
8215    v4Prime = (2.*two*twoReduced-fourReduced)/pow(2.*pow(two,2.)-four,3./4.);
8216    v4PrimeErrorSquared = pow(2.*pow(two,2.)-four,-7./2.)
8217                        * (pow(2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced,2.)*pow(twoError,2.)
8218                        + (9./16.)*pow(2.*two*twoReduced-fourReduced,2.)*pow(fourError,2.)
8219                        + 4.*pow(two,2.)*pow(2.*pow(two,2.)-four,2.)*pow(twoReducedError,2.)
8220                        + pow(2.*pow(two,2.)-four,2.)*pow(fourReducedError,2.)                          
8221                        - (3./2.)*(2.*two*twoReduced-fourReduced)
8222                        * (2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced)*wCovTwoFour
8223                        - 4.*two*(2.*pow(two,2.)-four)
8224                        * (2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced)*wCovTwoTwoReduced
8225                        + 2.*(2.*pow(two,2.)-four)
8226                        * (2.*pow(two,2.)*twoReduced-3.*two*fourReduced+2.*four*twoReduced)*wCovTwoFourReduced
8227                        + 3.*two*(2.*pow(two,2.)-four)*(2.*two*twoReduced-fourReduced)*wCovFourTwoReduced
8228                        - (3./2.)*(2.*pow(two,2.)-four)*(2.*two*twoReduced-fourReduced)*wCovFourFourReduced 
8229                        - 4.*two*pow(2.*pow(two,2.)-four,2.)*wCovTwoReducedFourReduced);  
8230    if(v4PrimeErrorSquared>0.){v4PrimeError = pow(v4PrimeErrorSquared,0.5);}        
8231    if(TMath::Abs(v4Prime)>0.)
8232    {
8233     fDiffFlow[t][pe][1]->SetBinContent(b,v4Prime);
8234     fDiffFlow[t][pe][1]->SetBinError(b,v4PrimeError);     
8235    }
8236   } // end of if(2.*pow(two,2.)-four > 0.)  
8237  } // end of for(Int_t b=1;b<=fnBinsPtEta[pe];b++)
8238
8239 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlow(TString type, Bool_t useParticleWeights)
8240
8241 //================================================================================================================================
8242
8243 void AliFlowAnalysisWithQCumulants::Calculate2DDiffFlow(TString type)
8244 {
8245  // Calculate final results for 2D diferential flow.
8246
8247  // to be improved - check pointers used in this method
8248
8249  Int_t t = 0; // RP or POI
8250
8251  if(type == "RP")
8252  {
8253   t = 0;
8254  } else if(type == "POI")
8255    {
8256     t = 1;
8257    } 
8258  
8259  // Differential flow:
8260  Double_t v2Prime = 0.; // v'{2}                   
8261  Double_t v4Prime = 0.; // v'{4}
8262  // Differential cumulants:
8263  Double_t qc2Prime = 0.; // QC{2'}                   
8264  Double_t qc4Prime = 0.; // QC{4'}
8265  // Looping over all (pt,eta) bins and calculating differential flow: 
8266  for(Int_t p=1;p<=fnBinsPt;p++)
8267  {
8268   for(Int_t e=1;e<=fnBinsEta;e++)
8269   {
8270    // QC{2'}:
8271    qc2Prime = f2DDiffFlowCumulants[t][0]->GetBinContent(f2DDiffFlowCumulants[t][0]->GetBin(p,e));
8272    if(qc2Prime>=0.)
8273    {
8274     v2Prime = pow(qc2Prime,0.5);
8275     f2DDiffFlow[t][0]->SetBinContent(f2DDiffFlow[t][0]->GetBin(p,e),v2Prime); 
8276    } 
8277    // QC{4'}:
8278    qc4Prime = f2DDiffFlowCumulants[t][1]->GetBinContent(f2DDiffFlowCumulants[t][1]->GetBin(p,e));
8279    if(qc4Prime<=0.)
8280    {
8281     v4Prime = pow(-1.*qc4Prime,1./4.);
8282     f2DDiffFlow[t][1]->SetBinContent(f2DDiffFlow[t][1]->GetBin(p,e),v4Prime); 
8283    }   
8284   } // end of for(Int_t e=1;e<=fnBinsEta;e++)
8285  } // end of for(Int_t p=1;p<=fnBinsPt;p++)
8286  
8287 } // end of void AliFlowAnalysisWithQCumulants::Calculate2DDiffFlow(TString type)  
8288
8289 //================================================================================================================================
8290
8291 void AliFlowAnalysisWithQCumulants::StoreIntFlowFlags()
8292 {
8293  // a) Store all flags for integrated flow in profile fIntFlowFlags.
8294  
8295  if(!fIntFlowFlags)
8296  {
8297   cout<<"WARNING: fIntFlowFlags is NULL in AFAWQC::SFFIF() !!!!"<<endl;
8298   exit(0);
8299  } 
8300
8301  // particle weights used or not:
8302  fIntFlowFlags->Fill(0.5,(Int_t)fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights);
8303  // which event weights were used:
8304  if(strcmp(fMultiplicityWeight->Data(),"combinations"))
8305  {
8306   fIntFlowFlags->Fill(1.5,0); // 0 = "combinations" (default)
8307  } else if(strcmp(fMultiplicityWeight->Data(),"unit"))
8308    {
8309     fIntFlowFlags->Fill(1.5,1); // 1 = "unit"   
8310    } else if(strcmp(fMultiplicityWeight->Data(),"multiplicity"))
8311      {
8312       fIntFlowFlags->Fill(1.5,2); // 2 = "multiplicity"        
8313      } 
8314  fIntFlowFlags->Fill(2.5,(Int_t)fApplyCorrectionForNUA);
8315  fIntFlowFlags->Fill(3.5,(Int_t)fPrintFinalResults[0]);
8316  fIntFlowFlags->Fill(4.5,(Int_t)fPrintFinalResults[1]);
8317  fIntFlowFlags->Fill(5.5,(Int_t)fPrintFinalResults[2]);
8318  fIntFlowFlags->Fill(6.5,(Int_t)fPrintFinalResults[3]);
8319  fIntFlowFlags->Fill(7.5,(Int_t)fApplyCorrectionForNUAVsM);
8320  fIntFlowFlags->Fill(8.5,(Int_t)fPropagateErrorAlsoFromNIT);
8321  fIntFlowFlags->Fill(9.5,(Int_t)fCalculateCumulantsVsM);
8322  fIntFlowFlags->Fill(10.5,(Int_t)fMinimumBiasReferenceFlow);
8323  fIntFlowFlags->Fill(11.5,(Int_t)fForgetAboutCovariances);
8324  fIntFlowFlags->Fill(12.5,(Int_t)fStorePhiDistributionForOneEvent); 
8325  fIntFlowFlags->Fill(13.5,(Int_t)fFillMultipleControlHistograms);  
8326  fIntFlowFlags->Fill(14.5,(Int_t)fCalculateAllCorrelationsVsM);  
8327 } // end of void AliFlowAnalysisWithQCumulants::StoreIntFlowFlags()
8328
8329 //================================================================================================================================
8330
8331 void AliFlowAnalysisWithQCumulants::StoreDiffFlowFlags()
8332 {
8333  // Store all flags for differential flow in the profile fDiffFlowFlags.
8334   
8335  if(!fDiffFlowFlags)
8336  {
8337   printf("\n WARNING (QC): fDiffFlowFlags is NULL in AFAWQC::SDFF() !!!!\n\n");
8338   exit(0);
8339  } 
8340  
8341  fDiffFlowFlags->Fill(0.5,fCalculateDiffFlow); // calculate differential flow
8342  fDiffFlowFlags->Fill(1.5,fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights); // particle weights used or not?
8343  //fDiffFlowFlags->Fill(2.5,""); // which event weight was used? ("combinations", "unit" or "multiplicity") to be improved - finalized
8344  fDiffFlowFlags->Fill(3.5,fApplyCorrectionForNUA); // corrected for non-uniform acceptance or not
8345  fDiffFlowFlags->Fill(4.5,fCalculate2DDiffFlow); // calculate also 2D differential flow vs (pt,eta) 
8346  fDiffFlowFlags->Fill(5.5,fCalculateDiffFlowVsEta); // if you set kFALSE only differential flow vs pt is calculated
8347      
8348 } // end of void AliFlowAnalysisWithQCumulants::StoreDiffFlowFlags()
8349
8350 //================================================================================================================================
8351
8352 void AliFlowAnalysisWithQCumulants::GetPointersForCommonHistograms() 
8353 {
8354  // Access all pointers to common control and common result histograms and profiles.
8355  
8356  TString sCommonConstantsName = "fCommonConstants";
8357  sCommonConstantsName += fAnalysisLabel->Data();
8358  fCommonConstants = dynamic_cast<TProfile*>(fHistList->FindObject(sCommonConstantsName.Data()));
8359  if(!fCommonConstants)
8360  {
8361   printf("\n WARNING (QC): fCommonConstants is NULL in AFAWQC::GPFCH() !!!!\n\n");
8362   exit(0);
8363  }
8364  
8365  // to be improved - lines bellow can be implemented better.
8366  
8367  TString commonHistsName = "AliFlowCommonHistQC";
8368  commonHistsName += fAnalysisLabel->Data();
8369  AliFlowCommonHist *commonHist = dynamic_cast<AliFlowCommonHist*>(fHistList->FindObject(commonHistsName.Data()));
8370  if(commonHist) 
8371  {
8372   this->SetCommonHists(commonHist); 
8373   if(fCommonHists->GetHarmonic())
8374   {
8375    fHarmonic = (Int_t)(fCommonHists->GetHarmonic())->GetBinContent(1);
8376   } 
8377  } // end of if(commonHist) 
8378  TString commonHists2ndOrderName = "AliFlowCommonHist2ndOrderQC";
8379  commonHists2ndOrderName += fAnalysisLabel->Data();
8380  AliFlowCommonHist *commonHist2nd = dynamic_cast<AliFlowCommonHist*>(fHistList->FindObject(commonHists2ndOrderName.Data()));
8381  if(commonHist2nd) this->SetCommonHists2nd(commonHist2nd);   
8382  TString commonHists4thOrderName = "AliFlowCommonHist4thOrderQC";
8383  commonHists4thOrderName += fAnalysisLabel->Data();
8384  AliFlowCommonHist *commonHist4th = dynamic_cast<AliFlowCommonHist*>(fHistList->FindObject(commonHists4thOrderName.Data()));
8385  if(commonHist4th) this->SetCommonHists4th(commonHist4th);  
8386  TString commonHists6thOrderName = "AliFlowCommonHist6thOrderQC";
8387  commonHists6thOrderName += fAnalysisLabel->Data();
8388  AliFlowCommonHist *commonHist6th = dynamic_cast<AliFlowCommonHist*>(fHistList->FindObject(commonHists6thOrderName.Data()));
8389  if(commonHist6th) this->SetCommonHists6th(commonHist6th);  
8390  TString commonHists8thOrderName = "AliFlowCommonHist8thOrderQC";
8391  commonHists8thOrderName += fAnalysisLabel->Data();
8392  AliFlowCommonHist *commonHist8th = dynamic_cast<AliFlowCommonHist*>(fHistList->FindObject(commonHists8thOrderName.Data()));
8393  if(commonHist8th) this->SetCommonHists8th(commonHist8th); 
8394   
8395  TString commonHistResults2ndOrderName = "AliFlowCommonHistResults2ndOrderQC"; 
8396  commonHistResults2ndOrderName += fAnalysisLabel->Data(); 
8397  AliFlowCommonHistResults *commonHistRes2nd = dynamic_cast<AliFlowCommonHistResults*>
8398                                               (fHistList->FindObject(commonHistResults2ndOrderName.Data()));
8399  if(commonHistRes2nd) this->SetCommonHistsResults2nd(commonHistRes2nd);   
8400  TString commonHistResults4thOrderName = "AliFlowCommonHistResults4thOrderQC";
8401  commonHistResults4thOrderName += fAnalysisLabel->Data();
8402  AliFlowCommonHistResults *commonHistRes4th = dynamic_cast<AliFlowCommonHistResults*>
8403                                               (fHistList->FindObject(commonHistResults4thOrderName.Data()));
8404  if(commonHistRes4th) this->SetCommonHistsResults4th(commonHistRes4th);  
8405  TString commonHistResults6thOrderName = "AliFlowCommonHistResults6thOrderQC";
8406  commonHistResults6thOrderName += fAnalysisLabel->Data();
8407  AliFlowCommonHistResults *commonHistRes6th = dynamic_cast<AliFlowCommonHistResults*>
8408                                               (fHistList->FindObject(commonHistResults6thOrderName.Data()));
8409  if(commonHistRes6th) this->SetCommonHistsResults6th(commonHistRes6th);  
8410  TString commonHistResults8thOrderName = "AliFlowCommonHistResults8thOrderQC";
8411  commonHistResults8thOrderName += fAnalysisLabel->Data();
8412  AliFlowCommonHistResults *commonHistRes8th = dynamic_cast<AliFlowCommonHistResults*>
8413                                               (fHistList->FindObject(commonHistResults8thOrderName.Data()));  
8414  if(commonHistRes8th) this->SetCommonHistsResults8th(commonHistRes8th);
8415        
8416 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForCommonHistograms() 
8417
8418 //================================================================================================================================
8419
8420 void AliFlowAnalysisWithQCumulants::GetPointersForParticleWeightsHistograms() 
8421 {
8422  // Get pointers for histograms with particle weights.
8423
8424  TList *weightsList = dynamic_cast<TList*>(fHistList->FindObject("Weights"));
8425  if(!weightsList){printf("\n WARNING (QC): weightsList is NULL in AFAWQC::GPFPWH() !!!!\n");exit(0);}
8426  this->SetWeightsList(weightsList);
8427  TString fUseParticleWeightsName = "fUseParticleWeightsQC"; // to be improved (hirdwired label QC)
8428  fUseParticleWeightsName += fAnalysisLabel->Data();
8429  TProfile *useParticleWeights = dynamic_cast<TProfile*>(weightsList->FindObject(fUseParticleWeightsName.Data()));
8430  if(useParticleWeights)
8431  {
8432   this->SetUseParticleWeights(useParticleWeights);  
8433   fUsePhiWeights = (Int_t)fUseParticleWeights->GetBinContent(1); 
8434   fUsePtWeights = (Int_t)fUseParticleWeights->GetBinContent(2); 
8435   fUseEtaWeights = (Int_t)fUseParticleWeights->GetBinContent(3);  
8436   fUseTrackWeights = (Int_t)fUseParticleWeights->GetBinContent(4);  
8437  }
8438 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForParticleWeightsHistograms(); 
8439
8440 //================================================================================================================================
8441
8442 void AliFlowAnalysisWithQCumulants::GetPointersForIntFlowHistograms() 
8443 {
8444  // Get pointers for histograms and profiles relevant for integrated flow:
8445  //  a) Get pointer to base list for integrated flow holding profile fIntFlowFlags and lists fIntFlowProfiles and fIntFlowResults.
8446  //  b) Get pointer to profile fIntFlowFlags holding all flags for integrated flow.
8447  //  c) Get pointer to list fIntFlowProfiles and pointers to all objects that she holds. 
8448  //  d) Get pointer to list fIntFlowResults and pointers to all objects that she holds. 
8449   
8450  TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data member?)
8451  TString powerFlag[2] = {"linear","quadratic"}; // to be improved (should I promote this to data member?)
8452  TString correlationFlag[4] = {"#LT#LT2#GT#GT","#LT#LT4#GT#GT","#LT#LT6#GT#GT","#LT#LT8#GT#GT"}; // to be improved (should I promote this to data member?)
8453  TString squaredCorrelationFlag[4] = {"#LT#LT2#GT^{2}#GT","#LT#LT4#GT^{2}#GT","#LT#LT6#GT^{2}#GT","#LT#LT8#GT^{2}#GT"}; // to be improved (should I promote this to data member?)
8454  
8455  // a) Get pointer to base list for integrated flow holding profile fIntFlowFlags and lists fIntFlowProfiles and fIntFlowResults:
8456  TList *intFlowList = NULL;
8457  intFlowList = dynamic_cast<TList*>(fHistList->FindObject("Integrated Flow"));
8458  if(!intFlowList) 
8459  {
8460   cout<<"WARNING: intFlowList is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8461   exit(0); 
8462  }  
8463   
8464  // b) Get pointer to profile fIntFlowFlags holding all flags for integrated flow:
8465  TString intFlowFlagsName = "fIntFlowFlags";
8466  intFlowFlagsName += fAnalysisLabel->Data();
8467  TProfile *intFlowFlags = dynamic_cast<TProfile*>(intFlowList->FindObject(intFlowFlagsName.Data()));
8468  if(intFlowFlags)
8469  {
8470   this->SetIntFlowFlags(intFlowFlags);  
8471   fApplyCorrectionForNUA = (Bool_t)intFlowFlags->GetBinContent(3); 
8472   fApplyCorrectionForNUAVsM = (Bool_t)intFlowFlags->GetBinContent(8); 
8473   fCalculateCumulantsVsM = (Bool_t)intFlowFlags->GetBinContent(10);  
8474  } else 
8475    {
8476     cout<<"WARNING: intFlowFlags is NULL in FAWQC::GPFIFH() !!!!"<<endl;
8477    }
8478   
8479   // c) Get pointer to list fIntFlowProfiles and pointers to all objects that she holds:
8480   TList *intFlowProfiles = NULL;
8481   intFlowProfiles = dynamic_cast<TList*>(intFlowList->FindObject("Profiles"));
8482   if(intFlowProfiles)  
8483   {
8484    // average multiplicities:
8485    TString avMultiplicityName = "fAvMultiplicity";
8486    avMultiplicityName += fAnalysisLabel->Data();
8487    TProfile *avMultiplicity = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(avMultiplicityName.Data()));
8488    if(avMultiplicity) 
8489    {
8490     this->SetAvMultiplicity(avMultiplicity);
8491    } else 
8492      {
8493       cout<<"WARNING: avMultiplicity is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8494      }
8495    // average correlations <<2>>, <<4>>, <<6>> and <<8>> (with wrong errors!):
8496    TString intFlowCorrelationsProName = "fIntFlowCorrelationsPro";
8497    intFlowCorrelationsProName += fAnalysisLabel->Data();
8498    TProfile *intFlowCorrelationsPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowCorrelationsProName.Data()));
8499    if(intFlowCorrelationsPro) 
8500    {
8501     this->SetIntFlowCorrelationsPro(intFlowCorrelationsPro);
8502    } else 
8503      {
8504       cout<<"WARNING: intFlowCorrelationsPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8505      }      
8506    // average squared correlations <<2>^2>, <<4>^2>, <<6>^2> and <<8^2>>:
8507    TString intFlowSquaredCorrelationsProName = "fIntFlowSquaredCorrelationsPro";
8508    intFlowSquaredCorrelationsProName += fAnalysisLabel->Data();
8509    TProfile *intFlowSquaredCorrelationsPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowSquaredCorrelationsProName.Data()));
8510    if(intFlowSquaredCorrelationsPro) 
8511    {
8512     this->SetIntFlowSquaredCorrelationsPro(intFlowSquaredCorrelationsPro);
8513    } else 
8514      {
8515       cout<<"WARNING: intFlowSquaredCorrelationsPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8516      }             
8517    if(fCalculateCumulantsVsM)
8518    {
8519     // Average correlations <<2>>, <<4>>, <<6>> and <<8>> versus multiplicity for all events (error is wrong here):   
8520     TString intFlowCorrelationsVsMProName = "fIntFlowCorrelationsVsMPro";
8521     intFlowCorrelationsVsMProName += fAnalysisLabel->Data();
8522     for(Int_t ci=0;ci<4;ci++) // correlation index
8523     {
8524      TProfile *intFlowCorrelationsVsMPro = dynamic_cast<TProfile*>
8525                                         (intFlowProfiles->FindObject(Form("%s, %s",intFlowCorrelationsVsMProName.Data(),correlationFlag[ci].Data())));
8526      if(intFlowCorrelationsVsMPro)
8527      {
8528       this->SetIntFlowCorrelationsVsMPro(intFlowCorrelationsVsMPro,ci);
8529      } else
8530        {
8531         cout<<"WARNING: "<<Form("intFlowCorrelationsVsMPro[%d]",ci)<<" is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8532        }   
8533     } // end of for(Int_t ci=0;ci<4;ci++) // correlation index 
8534     // Average squared correlations <<2>^2>, <<4>^2>, <<6>^2> and <<8>^2> versus multiplicity for all events:   
8535     TString intFlowSquaredCorrelationsVsMProName = "fIntFlowSquaredCorrelationsVsMPro";
8536     intFlowSquaredCorrelationsVsMProName += fAnalysisLabel->Data();
8537     for(Int_t ci=0;ci<4;ci++) // correlation index
8538     {
8539      TProfile *intFlowSquaredCorrelationsVsMPro = dynamic_cast<TProfile*>
8540                       (intFlowProfiles->FindObject(Form("%s, %s",intFlowSquaredCorrelationsVsMProName.Data(),squaredCorrelationFlag[ci].Data())));
8541      if(intFlowSquaredCorrelationsVsMPro)
8542      {
8543       this->SetIntFlowSquaredCorrelationsVsMPro(intFlowSquaredCorrelationsVsMPro,ci);
8544      } else
8545        {
8546         cout<<"WARNING: "<<Form("intFlowSquaredCorrelationsVsMPro[%d]",ci)<<" is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8547        }   
8548     } // end of for(Int_t ci=0;ci<4;ci++) // correlation index 
8549    } // end of if(fCalculateCumulantsVsM)
8550    // average all correlations for integrated flow (with wrong errors!):
8551    TString intFlowCorrelationsAllProName = "fIntFlowCorrelationsAllPro";
8552    intFlowCorrelationsAllProName += fAnalysisLabel->Data();
8553    TProfile *intFlowCorrelationsAllPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowCorrelationsAllProName.Data()));
8554    if(intFlowCorrelationsAllPro) 
8555    {
8556     this->SetIntFlowCorrelationsAllPro(intFlowCorrelationsAllPro);
8557    } else 
8558      {
8559       cout<<"WARNING: intFlowCorrelationsAllPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8560      }     
8561    // average extra correlations for integrated flow (which appear only when particle weights are used):
8562    // (to be improved: Weak point in implementation, I am assuming here that method GetPointersForParticleWeightsHistograms() was called)
8563    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)
8564    {
8565     TString intFlowExtraCorrelationsProName = "fIntFlowExtraCorrelationsPro";
8566     intFlowExtraCorrelationsProName += fAnalysisLabel->Data();
8567     TProfile *intFlowExtraCorrelationsPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowExtraCorrelationsProName.Data()));
8568     if(intFlowExtraCorrelationsPro) 
8569     {
8570      this->SetIntFlowExtraCorrelationsPro(intFlowExtraCorrelationsPro);
8571     } else 
8572       {
8573        cout<<"WARNING: intFlowExtraCorrelationsPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8574       }
8575    } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)        
8576    // average products of correlations <2>, <4>, <6> and <8>:  
8577    TString intFlowProductOfCorrelationsProName = "fIntFlowProductOfCorrelationsPro";
8578    intFlowProductOfCorrelationsProName += fAnalysisLabel->Data();
8579    TProfile *intFlowProductOfCorrelationsPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowProductOfCorrelationsProName.Data()));
8580    if(intFlowProductOfCorrelationsPro) 
8581    {
8582     this->SetIntFlowProductOfCorrelationsPro(intFlowProductOfCorrelationsPro);
8583    } else 
8584      {
8585       cout<<"WARNING: intFlowProductOfCorrelationsPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8586      }               
8587    // average product of correlations <2>, <4>, <6> and <8> versus multiplicity  
8588    // [0=<<2><4>>,1=<<2><6>>,2=<<2><8>>,3=<<4><6>>,4=<<4><8>>,5=<<6><8>>]  
8589    if(fCalculateCumulantsVsM)
8590    {
8591     TString intFlowProductOfCorrelationsVsMProName = "fIntFlowProductOfCorrelationsVsMPro";
8592     intFlowProductOfCorrelationsVsMProName += fAnalysisLabel->Data();
8593     TString productFlag[6] = {"#LT#LT2#GT#LT4#GT#GT","#LT#LT2#GT#LT6#GT#GT","#LT#LT2#GT#LT8#GT#GT",
8594                               "#LT#LT4#GT#LT6#GT#GT","#LT#LT4#GT#LT8#GT#GT","#LT#LT6#GT#LT8#GT#GT"};
8595     for(Int_t pi=0;pi<6;pi++)
8596     { 
8597      TProfile *intFlowProductOfCorrelationsVsMPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(Form("%s, %s",intFlowProductOfCorrelationsVsMProName.Data(),productFlag[pi].Data())));
8598      if(intFlowProductOfCorrelationsVsMPro)
8599      {
8600       this->SetIntFlowProductOfCorrelationsVsMPro(intFlowProductOfCorrelationsVsMPro,pi);
8601      } else
8602        {
8603         cout<<"WARNING: "<<Form("intFlowProductOfCorrelationsVsMPro[%d]",pi)<<" is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8604        }
8605     } // end of for(Int_t pi=0;pi<6;pi++)
8606    } // end of if(fCalculateCumulantsVsM)
8607    // average correction terms for non-uniform acceptance (with wrong errors!):
8608    for(Int_t sc=0;sc<2;sc++)
8609    {
8610     TString intFlowCorrectionTermsForNUAProName = "fIntFlowCorrectionTermsForNUAPro";
8611     intFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();
8612     TProfile *intFlowCorrectionTermsForNUAPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject((Form("%s: %s terms",intFlowCorrectionTermsForNUAProName.Data(),sinCosFlag[sc].Data()))));
8613     if(intFlowCorrectionTermsForNUAPro) 
8614     {
8615      this->SetIntFlowCorrectionTermsForNUAPro(intFlowCorrectionTermsForNUAPro,sc);
8616     } else 
8617       {
8618        cout<<"WARNING: intFlowCorrectionTermsForNUAPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8619        cout<<"sc = "<<sc<<endl;
8620       } 
8621     // versus multiplicity:
8622     if(fCalculateCumulantsVsM)
8623     {
8624      TString correctionTermFlag[4] = {"(n(phi1))","(n(phi1+phi2))","(n(phi1-phi2-phi3))","(n(2phi1-phi2))"}; // to be improved - hardwired 4
8625      TString intFlowCorrectionTermsForNUAVsMProName = "fIntFlowCorrectionTermsForNUAVsMPro";
8626      intFlowCorrectionTermsForNUAVsMProName += fAnalysisLabel->Data();
8627      for(Int_t ci=0;ci<4;ci++) // correction term index (to be improved - hardwired 4)
8628      {
8629       TProfile *intFlowCorrectionTermsForNUAVsMPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(Form("%s: #LT#LT%s%s#GT#GT",intFlowCorrectionTermsForNUAVsMProName.Data(),sinCosFlag[sc].Data(),correctionTermFlag[ci].Data())));
8630       if(intFlowCorrectionTermsForNUAVsMPro) 
8631       {
8632        this->SetIntFlowCorrectionTermsForNUAVsMPro(intFlowCorrectionTermsForNUAVsMPro,sc,ci);
8633       } else 
8634         {
8635          cout<<"WARNING: intFlowCorrectionTermsForNUAVsMPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8636          cout<<"sc = "<<sc<<endl;
8637          cout<<"ci = "<<ci<<endl;
8638         }       
8639      } // end of for(Int_t ci=0;ci<4;ci++) // correction term index (to be improved - hardwired 4)
8640     } // end of if(fCalculateCumulantsVsM)
8641    } // end of for(Int_t sc=0;sc<2;sc++)           
8642    // average products of correction terms for NUA:  
8643    TString intFlowProductOfCorrectionTermsForNUAProName = "fIntFlowProductOfCorrectionTermsForNUAPro";
8644    intFlowProductOfCorrectionTermsForNUAProName += fAnalysisLabel->Data();
8645    TProfile *intFlowProductOfCorrectionTermsForNUAPro = dynamic_cast<TProfile*>(intFlowProfiles->FindObject(intFlowProductOfCorrectionTermsForNUAProName.Data()));
8646    if(intFlowProductOfCorrectionTermsForNUAPro) 
8647    {
8648     this->SetIntFlowProductOfCorrectionTermsForNUAPro(intFlowProductOfCorrectionTermsForNUAPro);
8649    } else 
8650      {
8651       cout<<"WARNING: intFlowProductOfCorrectionTermsForNUAPro is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8652      }     
8653   } else // to if(intFlowProfiles)  
8654     {
8655      cout<<"WARNING: intFlowProfiles is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8656     }
8657    
8658   //  d) Get pointer to list fIntFlowResults and pointers to all objects that she holds. 
8659   TList *intFlowResults = NULL;
8660   intFlowResults = dynamic_cast<TList*>(intFlowList->FindObject("Results"));
8661   if(intFlowResults)
8662   {
8663    // average correlations <<2>>, <<4>>, <<6>> and <<8>> (with correct errors!):
8664    TString intFlowCorrelationsHistName = "fIntFlowCorrelationsHist";
8665    intFlowCorrelationsHistName += fAnalysisLabel->Data();
8666    TH1D *intFlowCorrelationsHist = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowCorrelationsHistName.Data()));
8667    if(intFlowCorrelationsHist) 
8668    {
8669     this->SetIntFlowCorrelationsHist(intFlowCorrelationsHist);
8670    } else 
8671      {
8672       cout<<"WARNING: intFlowCorrelationsHist is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8673      } 
8674    // average correlations <<2>>, <<4>>, <<6>> and <<8>> (with correct errors!) vs M:    
8675    if(fCalculateCumulantsVsM)
8676    {
8677     TString intFlowCorrelationsVsMHistName = "fIntFlowCorrelationsVsMHist";
8678     intFlowCorrelationsVsMHistName += fAnalysisLabel->Data();
8679     for(Int_t ci=0;ci<4;ci++) // correlation index
8680     {
8681      TH1D *intFlowCorrelationsVsMHist = dynamic_cast<TH1D*>
8682                                         (intFlowResults->FindObject(Form("%s, %s",intFlowCorrelationsVsMHistName.Data(),correlationFlag[ci].Data())));
8683      if(intFlowCorrelationsVsMHist)
8684      {
8685       this->SetIntFlowCorrelationsVsMHist(intFlowCorrelationsVsMHist,ci);
8686      } else
8687        {
8688         cout<<"WARNING: "<<Form("intFlowCorrelationsVsMHist[%d]",ci)<<" is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8689        }   
8690     } // end of for(Int_t ci=0;ci<4;ci++) // correlation index   
8691    } // end of if(fCalculateCumulantsVsM)
8692    // average all correlations for integrated flow (with correct errors!):
8693    TString intFlowCorrelationsAllHistName = "fIntFlowCorrelationsAllHist";
8694    intFlowCorrelationsAllHistName += fAnalysisLabel->Data();
8695    TH1D *intFlowCorrelationsAllHist = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowCorrelationsAllHistName.Data()));
8696    if(intFlowCorrelationsAllHist) 
8697    {
8698     this->SetIntFlowCorrelationsAllHist(intFlowCorrelationsAllHist);
8699    } else 
8700      {
8701       cout<<"WARNING: intFlowCorrelationsAllHist is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8702      }  
8703    // average correction terms for non-uniform acceptance (with correct errors!):
8704    TString intFlowCorrectionTermsForNUAHistName = "fIntFlowCorrectionTermsForNUAHist";
8705    intFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();
8706    for(Int_t sc=0;sc<2;sc++)
8707    {
8708     TH1D *intFlowCorrectionTermsForNUAHist = dynamic_cast<TH1D*>(intFlowResults->FindObject((Form("%s: %s terms",intFlowCorrectionTermsForNUAHistName.Data(),sinCosFlag[sc].Data()))));
8709     if(intFlowCorrectionTermsForNUAHist) 
8710     {
8711      this->SetIntFlowCorrectionTermsForNUAHist(intFlowCorrectionTermsForNUAHist,sc);
8712     } else 
8713       {
8714        cout<<"WARNING: intFlowCorrectionTermsForNUAHist is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8715        cout<<"sc = "<<sc<<endl;
8716       } 
8717    } // end of for(Int_t sc=0;sc<2;sc++)           
8718    // covariances (multiplied with weight dependent prefactor):
8719    TString intFlowCovariancesName = "fIntFlowCovariances";
8720    intFlowCovariancesName += fAnalysisLabel->Data();
8721    TH1D *intFlowCovariances = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowCovariancesName.Data()));
8722    if(intFlowCovariances) 
8723    {
8724     this->SetIntFlowCovariances(intFlowCovariances); 
8725    } else 
8726      {
8727       cout<<"WARNING: intFlowCovariances is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8728      } 
8729    // sum of linear and quadratic event weights for <2>, <4>, <6> and <8>:
8730    TString intFlowSumOfEventWeightsName = "fIntFlowSumOfEventWeights";
8731    intFlowSumOfEventWeightsName += fAnalysisLabel->Data();
8732    for(Int_t power=0;power<2;power++)
8733    {
8734     TH1D *intFlowSumOfEventWeights = dynamic_cast<TH1D*>(intFlowResults->FindObject(Form("%s: %s",intFlowSumOfEventWeightsName.Data(),powerFlag[power].Data())));
8735     if(intFlowSumOfEventWeights) 
8736     {
8737      this->SetIntFlowSumOfEventWeights(intFlowSumOfEventWeights,power);
8738     } else 
8739       {
8740        cout<<"WARNING: intFlowSumOfEventWeights is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8741        cout<<"power = "<<power<<endl;
8742       }                                   
8743    } // end of for(Int_t power=0;power<2;power++)                                                                  
8744    // sum of products of event weights for correlations <2>, <4>, <6> and <8>:  
8745    TString intFlowSumOfProductOfEventWeightsName = "fIntFlowSumOfProductOfEventWeights";
8746    intFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();
8747    TH1D *intFlowSumOfProductOfEventWeights = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowSumOfProductOfEventWeightsName.Data()));
8748    if(intFlowSumOfProductOfEventWeights) 
8749    {
8750     this->SetIntFlowSumOfProductOfEventWeights(intFlowSumOfProductOfEventWeights);
8751    } else 
8752      {
8753       cout<<"WARNING: intFlowSumOfProductOfEventWeights is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8754      } 
8755    // final result for covariances of correlations (multiplied with weight dependent prefactor) versus M
8756    // [0=Cov(2,4),1=Cov(2,6),2=Cov(2,8),3=Cov(4,6),4=Cov(4,8),5=Cov(6,8)]:
8757    if(fCalculateCumulantsVsM)
8758    {
8759     TString intFlowCovariancesVsMName = "fIntFlowCovariancesVsM";
8760     intFlowCovariancesVsMName += fAnalysisLabel->Data();
8761     TString covarianceFlag[6] = {"Cov(<2>,<4>)","Cov(<2>,<6>)","Cov(<2>,<8>)","Cov(<4>,<6>)","Cov(<4>,<8>)","Cov(<6>,<8>)"};
8762     for(Int_t ci=0;ci<6;ci++)
8763     { 
8764      TH1D *intFlowCovariancesVsM = dynamic_cast<TH1D*>(intFlowResults->FindObject(Form("%s, %s",intFlowCovariancesVsMName.Data(),covarianceFlag[ci].Data())));
8765      if(intFlowCovariancesVsM)
8766      {
8767       this->SetIntFlowCovariancesVsM(intFlowCovariancesVsM,ci);
8768      } else
8769        {
8770         cout<<"WARNING: "<<Form("intFlowCovariancesVsM[%d]",ci)<<" is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8771        }    
8772     } // end of for(Int_t ci=0;ci<6;ci++)
8773    } // end of if(fCalculateCumulantsVsM)
8774    // sum of linear and quadratic event weights for <2>, <4>, <6> and <8> versus multiplicity
8775    // [0=sum{w_{<2>}},1=sum{w_{<4>}},2=sum{w_{<6>}},3=sum{w_{<8>}}][0=linear 1,1=quadratic]:
8776    if(fCalculateCumulantsVsM)
8777    {
8778     TString intFlowSumOfEventWeightsVsMName = "fIntFlowSumOfEventWeightsVsM";
8779     intFlowSumOfEventWeightsVsMName += fAnalysisLabel->Data();
8780     TString sumFlag[2][4] = {{"#sum_{i=1}^{N} w_{<2>}","#sum_{i=1}^{N} w_{<4>}","#sum_{i=1}^{N} w_{<6>}","#sum_{i=1}^{N} w_{<8>}"},
8781                              {"#sum_{i=1}^{N} w_{<2>}^{2}","#sum_{i=1}^{N} w_{<4>}^{2}","#sum_{i=1}^{N} w_{<6>}^{2}","#sum_{i=1}^{N} w_{<8>}^{2}"}};
8782     for(Int_t si=0;si<4;si++)
8783     {
8784      for(Int_t power=0;power<2;power++)
8785      {
8786       TH1D *intFlowSumOfEventWeightsVsM = dynamic_cast<TH1D*>(intFlowResults->FindObject(Form("%s, %s",intFlowSumOfEventWeightsVsMName.Data(),sumFlag[power][si].Data())));
8787       if(intFlowSumOfEventWeightsVsM)
8788       {
8789        this->SetIntFlowSumOfEventWeightsVsM(intFlowSumOfEventWeightsVsM,si,power);
8790       } else
8791         {
8792          cout<<"WARNING: "<<Form("intFlowSumOfEventWeightsVsM[%d][%d]",si,power)<<" is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8793         }    
8794      } // end of for(Int_t power=0;power<2;power++)
8795     } // end of for(Int_t si=0;si<4;si++)   
8796    } // end of if(fCalculateCumulantsVsM)
8797    // sum of products of event weights for correlations <2>, <4>, <6> and <8> vs M
8798    // [0=sum{w_{<2>}w_{<4>}},1=sum{w_{<2>}w_{<6>}},2=sum{w_{<2>}w_{<8>}},
8799    //  3=sum{w_{<4>}w_{<6>}},4=sum{w_{<4>}w_{<8>}},5=sum{w_{<6>}w_{<8>}}]:  
8800    if(fCalculateCumulantsVsM)
8801    {
8802     TString intFlowSumOfProductOfEventWeightsVsMName = "fIntFlowSumOfProductOfEventWeightsVsM";
8803     intFlowSumOfProductOfEventWeightsVsMName += fAnalysisLabel->Data();
8804     TString sopowFlag[6] = {"#sum_{i=1}^{N} w_{<2>} w_{<4>}","#sum_{i=1}^{N} w_{<2>} w_{<6>}","#sum_{i=1}^{N} w_{<2>} w_{<8>}",
8805                             "#sum_{i=1}^{N} w_{<4>} w_{<6>}","#sum_{i=1}^{N} w_{<4>} w_{<8>}","#sum_{i=1}^{N} w_{<6>} w_{<8>}"}; 
8806     for(Int_t pi=0;pi<6;pi++)
8807     {
8808      TH1D *intFlowSumOfProductOfEventWeightsVsM = dynamic_cast<TH1D*>(intFlowResults->FindObject(Form("%s, %s",intFlowSumOfProductOfEventWeightsVsMName.Data(),sopowFlag[pi].Data())));
8809      if(intFlowSumOfProductOfEventWeightsVsM)
8810      {
8811       this->SetIntFlowSumOfProductOfEventWeightsVsM(intFlowSumOfProductOfEventWeightsVsM,pi);
8812      } else
8813        {
8814         cout<<"WARNING: "<<Form("intFlowSumOfProductOfEventWeightsVsM[%d]",pi)<<" is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8815        }
8816     } // end of for(Int_t pi=0;pi<6;pi++)        
8817    } // end of if(fCalculateCumulantsVsM)
8818    // covariances for NUA (multiplied with weight dependent prefactor):
8819    TString intFlowCovariancesNUAName = "fIntFlowCovariancesNUA";
8820    intFlowCovariancesNUAName += fAnalysisLabel->Data();
8821    TH1D *intFlowCovariancesNUA = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowCovariancesNUAName.Data()));
8822    if(intFlowCovariancesNUA) 
8823    {
8824     this->SetIntFlowCovariancesNUA(intFlowCovariancesNUA); 
8825    } else 
8826      {
8827       cout<<"WARNING: intFlowCovariancesNUA is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8828      } 
8829    // sum of linear and quadratic event weights NUA terms:
8830    TString intFlowSumOfEventWeightsNUAName = "fIntFlowSumOfEventWeightsNUA";
8831    intFlowSumOfEventWeightsNUAName += fAnalysisLabel->Data();
8832    for(Int_t sc=0;sc<2;sc++)
8833    {
8834     for(Int_t power=0;power<2;power++)
8835     {
8836      TH1D *intFlowSumOfEventWeightsNUA = dynamic_cast<TH1D*>(intFlowResults->FindObject(Form("%s: %s, %s",intFlowSumOfEventWeightsNUAName.Data(),powerFlag[power].Data(),sinCosFlag[sc].Data())));
8837      if(intFlowSumOfEventWeightsNUA) 
8838      {
8839       this->SetIntFlowSumOfEventWeightsNUA(intFlowSumOfEventWeightsNUA,sc,power);
8840      } else 
8841        {
8842         cout<<"WARNING: intFlowSumOfEventWeightsNUA is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8843         cout<<"sc    = "<<sc<<endl;
8844         cout<<"power = "<<power<<endl;
8845        }                                   
8846     } // end of for(Int_t power=0;power<2;power++)                                                                  
8847    } // end of for(Int_t sc=0;sc<2;sc++)     
8848    // sum of products of event weights for NUA terms:  
8849    TString intFlowSumOfProductOfEventWeightsNUAName = "fIntFlowSumOfProductOfEventWeightsNUA";
8850    intFlowSumOfProductOfEventWeightsNUAName += fAnalysisLabel->Data();
8851    TH1D *intFlowSumOfProductOfEventWeightsNUA = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowSumOfProductOfEventWeightsNUAName.Data()));
8852    if(intFlowSumOfProductOfEventWeightsNUA) 
8853    {
8854     this->SetIntFlowSumOfProductOfEventWeightsNUA(intFlowSumOfProductOfEventWeightsNUA);
8855    } else 
8856      {
8857       cout<<"WARNING: intFlowSumOfProductOfEventWeightsNUA is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8858      } 
8859    // Final results for reference Q-cumulants:
8860    TString intFlowQcumulantsName = "fIntFlowQcumulants";
8861    intFlowQcumulantsName += fAnalysisLabel->Data();
8862    TH1D *intFlowQcumulants = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowQcumulantsName.Data()));
8863    if(intFlowQcumulants) 
8864    {
8865     this->SetIntFlowQcumulants(intFlowQcumulants);
8866    } else 
8867      {
8868       cout<<"WARNING: intFlowQcumulants is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8869      }  
8870    // Final results for reference Q-cumulants rebinned in M:
8871    if(fCalculateCumulantsVsM)
8872    {
8873     TString intFlowQcumulantsRebinnedInMName = "fIntFlowQcumulantsRebinnedInM";
8874     intFlowQcumulantsRebinnedInMName += fAnalysisLabel->Data();
8875     TH1D *intFlowQcumulantsRebinnedInM = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowQcumulantsRebinnedInMName.Data()));
8876     if(intFlowQcumulantsRebinnedInM) 
8877     {
8878      this->SetIntFlowQcumulantsRebinnedInM(intFlowQcumulantsRebinnedInM);
8879     } else 
8880       {
8881        cout<<"WARNING: intFlowQcumulantsRebinnedInM is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8882       }  
8883    } // end of if(fCalculateCumulantsVsM)
8884    // Ratio between error squared: with/without non-isotropic terms:
8885    TString intFlowQcumulantsErrorSquaredRatioName = "fIntFlowQcumulantsErrorSquaredRatio";
8886    intFlowQcumulantsErrorSquaredRatioName += fAnalysisLabel->Data();
8887    TH1D *intFlowQcumulantsErrorSquaredRatio = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowQcumulantsErrorSquaredRatioName.Data()));
8888    if(intFlowQcumulantsErrorSquaredRatio) 
8889    {
8890     this->SetIntFlowQcumulantsErrorSquaredRatio(intFlowQcumulantsErrorSquaredRatio);
8891    } else 
8892      {
8893       cout<<" WARNING: intntFlowQcumulantsErrorSquaredRatio is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8894      }  
8895    // final results for integrated Q-cumulants versus multiplicity:
8896    TString cumulantFlag[4] = {"QC{2}","QC{4}","QC{6}","QC{8}"};
8897    if(fCalculateCumulantsVsM)
8898    {
8899     TString intFlowQcumulantsVsMName = "fIntFlowQcumulantsVsM";
8900     intFlowQcumulantsVsMName += fAnalysisLabel->Data();
8901     for(Int_t co=0;co<4;co++) // cumulant order
8902     {
8903      TH1D *intFlowQcumulantsVsM = dynamic_cast<TH1D*>
8904                                   (intFlowResults->FindObject(Form("%s, %s",intFlowQcumulantsVsMName.Data(),cumulantFlag[co].Data())));
8905      if(intFlowQcumulantsVsM)
8906      {
8907       this->SetIntFlowQcumulantsVsM(intFlowQcumulantsVsM,co);
8908      } else
8909        {
8910         cout<<"WARNING: "<<Form("intFlowQcumulantsVsM[%d]",co)<<" is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8911        }
8912     } // end of for(Int_t co=0;co<4;co++) // cumulant order
8913    } // end of if(fCalculateCumulantsVsM)
8914    // Final reference flow estimates from Q-cumulants:
8915    TString intFlowName = "fIntFlow";
8916    intFlowName += fAnalysisLabel->Data();
8917    TH1D *intFlow = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowName.Data()));
8918    if(intFlow) 
8919    {
8920     this->SetIntFlow(intFlow);
8921    } else 
8922      {
8923       cout<<"WARNING: intFlow is NULL in AFAWQC::GPFIFH() !!!!"<<endl; 
8924      } 
8925    // Final reference flow estimates from Q-cumulants vs M rebinned in M:
8926    if(fCalculateCumulantsVsM)
8927    {
8928     TString intFlowRebinnedInMName = "fIntFlowRebinnedInM";
8929     intFlowRebinnedInMName += fAnalysisLabel->Data();
8930     TH1D *intFlowRebinnedInM = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowRebinnedInMName.Data()));
8931     if(intFlowRebinnedInM) 
8932     {
8933      this->SetIntFlowRebinnedInM(intFlowRebinnedInM);
8934     } else 
8935       {
8936        cout<<"WARNING: intFlowRebinnedInM is NULL in AFAWQC::GPFIFH() !!!!"<<endl; 
8937       } 
8938    } // end of if(fCalculateCumulantsVsM)
8939    // integrated flow from Q-cumulants versus multiplicity:
8940    if(fCalculateCumulantsVsM)
8941    {
8942     TString intFlowVsMName = "fIntFlowVsM";
8943     intFlowVsMName += fAnalysisLabel->Data();
8944     TString flowFlag[4] = {Form("v_{%d}{2,QC}",fHarmonic),Form("v_{%d}{4,QC}",fHarmonic),Form("v_{%d}{6,QC}",fHarmonic),Form("v_{%d}{8,QC}",fHarmonic)};
8945     for(Int_t co=0;co<4;co++) // cumulant order
8946     {
8947      TH1D *intFlowVsM = dynamic_cast<TH1D*>
8948                         (intFlowResults->FindObject(Form("%s, %s",intFlowVsMName.Data(),flowFlag[co].Data())));            
8949      if(intFlowVsM)
8950      {
8951       this->SetIntFlowVsM(intFlowVsM,co);
8952      } else
8953        {
8954         cout<<"WARNING: "<<Form("intFlowVsM[%d]",co)<<" is NULL in AFAWQC::GPFIFH() !!!!"<<endl;      
8955        }
8956     } // end of for(Int_t co=0;co<4;co++) // cumulant order
8957    } // end of if(fCalculateCumulantsVsM)
8958    // quantifying detector effects effects to correlations:
8959    TString intFlowDetectorBiasName = "fIntFlowDetectorBias";
8960    intFlowDetectorBiasName += fAnalysisLabel->Data();
8961    TH1D *intFlowDetectorBias = dynamic_cast<TH1D*>(intFlowResults->FindObject(intFlowDetectorBiasName.Data()));
8962    if(intFlowDetectorBias) 
8963    {
8964     this->SetIntFlowDetectorBias(intFlowDetectorBias);
8965    } else 
8966      {
8967       cout<<"WARNING: intFlowDetectorBias is NULL in AFAWQC::GPFIFH() !!!!"<<endl; 
8968      } 
8969    // quantifying detector effects effects to correlations vs multiplicity:
8970    if(fCalculateCumulantsVsM)
8971    {
8972     TString intFlowDetectorBiasVsMName = "fIntFlowDetectorBiasVsM";
8973     intFlowDetectorBiasVsMName += fAnalysisLabel->Data();
8974     for(Int_t ci=0;ci<4;ci++) // correlation index
8975     {
8976      TH1D *intFlowDetectorBiasVsM = dynamic_cast<TH1D*>
8977                                     (intFlowResults->FindObject(Form("%s for %s",intFlowDetectorBiasVsMName.Data(),cumulantFlag[ci].Data())));
8978      if(intFlowDetectorBiasVsM)
8979      {
8980       this->SetIntFlowDetectorBiasVsM(intFlowDetectorBiasVsM,ci);
8981      } else
8982        {
8983         cout<<"WARNING: "<<Form("intFlowDetectorBiasVsM[%d]",ci)<<" is NULL in AFAWQC::GPFIFH() !!!!"<<endl;      
8984        }
8985     } // end of for(Int_t ci=0;ci<4;ci++) // correlation index   
8986    } // end of if(fCalculateCumulantsVsM)
8987   } else // to if(intFlowResults)
8988     {
8989      cout<<"WARNING: intFlowResults is NULL in AFAWQC::GPFIFH() !!!!"<<endl;
8990     }
8991     
8992 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForIntFlowHistograms()
8993
8994 //================================================================================================================================
8995
8996 void AliFlowAnalysisWithQCumulants::GetPointersFor2DDiffFlowHistograms()
8997 {
8998  // Get pointers for 2D differential flow histograms.
8999  //  a) Check pointers used in this method;
9000  //  b) Get pointers to 2D differential flow lists;
9001  //  c) Get pointers to 2D differential flow profiles;
9002  //  d) Get pointers to 2D differential flow histograms. 
9003
9004  // a) Check pointers used in this method:
9005  if(!fDiffFlowList)
9006  { 
9007   printf("\n WARNING (QC): fDiffFlowList is NULL in AFAWQC::GPF2DDFH() !!!!\n");
9008   printf("               Call method GetPointersForDiffFlowHistograms() first.\n\n");
9009   exit(0);
9010  }
9011  if(!fDiffFlowFlags)
9012  { 
9013   printf("\n WARNING (QC): fDiffFlowFlags is NULL in AFAWQC::GPF2DDFH() !!!!\n\n");
9014   printf("               Call method GetPointersForDiffFlowHistograms() first.\n\n");
9015   exit(0);
9016  }
9017  
9018  // b) Get pointers to 2D differential flow lists:
9019  this->SetCalculate2DDiffFlow((Bool_t)fDiffFlowFlags->GetBinContent(5)); // to be improved - hardwired 5
9020  if(!fCalculate2DDiffFlow){return;}
9021  TString typeFlag[2] = {"RP","POI"}; 
9022  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"};
9023  TString differentialCumulantIndex[4] = {"QC{2'}","QC{4'}","QC{6'}","QC{8'}"};  
9024  TString differentialFlowIndex[4] = {"v'{2}","v'{4}","v'{6}","v'{8}"};  
9025  // Base list: 
9026  TString diffFlow2DListName = "2D"; 
9027  diffFlow2DListName += fAnalysisLabel->Data();
9028  fDiffFlow2D = dynamic_cast<TList*>(fDiffFlowList->FindObject(diffFlow2DListName.Data()));
9029  if(!fDiffFlow2D)
9030  { 
9031   printf("\n WARNING (QC): fDiffFlow2D is NULL in AFAWQC::GPFDFH() !!!!\n\n");
9032   exit(0);
9033  }
9034  // Lists holding profiles with 2D correlations: 
9035  TString s2DDiffFlowCorrelationsProListName = "Profiles with 2D correlations"; 
9036  s2DDiffFlowCorrelationsProListName += fAnalysisLabel->Data(); // to be improved
9037  for(Int_t t=0;t<2;t++)
9038  {
9039   f2DDiffFlowCorrelationsProList[t] = dynamic_cast<TList*>(fDiffFlow2D->FindObject(Form("Profiles with 2D correlations (%s)",typeFlag[t].Data())));
9040   if(!f2DDiffFlowCorrelationsProList[t])
9041   { 
9042    printf("\n WARNING (QC): f2DDiffFlowCorrelationsProList[%i] is NULL in AFAWQC::GPF2DFH() !!!!\n\n",t);
9043    exit(0);
9044   }
9045  } // end of for(Int_t t=0;t<2;t++) 
9046  
9047  // c) Get pointers to 2D differential flow profiles:
9048  TString s2DDiffFlowCorrelationsProName = "f2DDiffFlowCorrelationsPro";
9049  s2DDiffFlowCorrelationsProName += fAnalysisLabel->Data();
9050  for(Int_t t=0;t<2;t++) // type: RP or POI
9051  { 
9052   for(Int_t rci=0;rci<4;rci++) // reduced correlation index
9053   {
9054    f2DDiffFlowCorrelationsPro[t][rci] = dynamic_cast<TProfile2D*>(f2DDiffFlowCorrelationsProList[t]->FindObject(Form("%s, %s, %s",s2DDiffFlowCorrelationsProName.Data(),typeFlag[t].Data(),reducedCorrelationIndex[rci].Data())));
9055    if(!f2DDiffFlowCorrelationsPro[t][rci])
9056    {
9057     printf("\n WARNING (QC): f2DDiffFlowCorrelationsPro[%i][%i] is NULL in AFAWQC::GPF2DFH() !!!!\n\n",t,rci);
9058     exit(0);   
9059    } else
9060      {
9061       this->Set2DDiffFlowCorrelationsPro(f2DDiffFlowCorrelationsPro[t][rci],t,rci);
9062      } 
9063   } // end of for(Int_t rci=0;rci<4;rci++) // reduced correlation index
9064  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI 
9065
9066  // d) Get pointers to 2D differential flow histograms: 
9067  TString s2DDiffFlowCumulantsName = "f2DDiffFlowCumulants";
9068  s2DDiffFlowCumulantsName += fAnalysisLabel->Data();
9069  TString s2DDiffFlowName = "f2DDiffFlow";
9070  s2DDiffFlowName += fAnalysisLabel->Data();
9071  for(Int_t t=0;t<2;t++) // type: RP or POI
9072  { 
9073   for(Int_t rci=0;rci<4;rci++) // reduced correlation index
9074   {
9075    // 2D differential cumulants:
9076    f2DDiffFlowCumulants[t][rci] = dynamic_cast<TH2D*>(f2DDiffFlowCorrelationsProList[t]->FindObject(Form("%s, %s, %s",s2DDiffFlowCumulantsName.Data(),typeFlag[t].Data(),differentialCumulantIndex[rci].Data())));
9077    if(!f2DDiffFlowCumulants[t][rci])
9078    {
9079     printf("\n WARNING (QC): f2DDiffFlowCumulants[%i][%i] is NULL in AFAWQC::GPF2DFH() !!!!\n\n",t,rci);
9080     exit(0);   
9081    } else
9082      {
9083       this->Set2DDiffFlowCumulants(f2DDiffFlowCumulants[t][rci],t,rci);
9084      } 
9085    // 2D differential flow:
9086    f2DDiffFlow[t][rci] = dynamic_cast<TH2D*>(f2DDiffFlowCorrelationsProList[t]->FindObject(Form("%s, %s, %s",s2DDiffFlowName.Data(),typeFlag[t].Data(),differentialFlowIndex[rci].Data())));
9087    if(!f2DDiffFlow[t][rci])
9088    {
9089     printf("\n WARNING (QC): f2DDiffFlow[%i][%i] is NULL in AFAWQC::GPF2DFH() !!!!\n\n",t,rci);
9090     exit(0);   
9091    } else
9092      {
9093       this->Set2DDiffFlow(f2DDiffFlow[t][rci],t,rci);
9094      } 
9095   } // end of for(Int_t rci=0;rci<4;rci++) // reduced correlation index
9096  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI 
9097   
9098 } // end of void AliFlowAnalysisWithQCumulants::GetPointersFor2DDiffFlowHistograms()
9099
9100 //================================================================================================================================
9101
9102 void AliFlowAnalysisWithQCumulants::GetPointersForOtherDiffCorrelators()
9103 {
9104  // Get pointers for other differential correlators.
9105  //  a) Get pointer to list with other differential correlators;
9106  //  b) Declare local flags;
9107  //  c) Get pointers to other differential profiles.
9108
9109  if(!fCalculateDiffFlow){return;} // TBI: This must eventually be moved somewhere else 
9110
9111  // a) Get pointer to list with other differential correlators:
9112  fOtherDiffCorrelatorsList = dynamic_cast<TList*>(fHistList->FindObject("Other differential correlators"));  
9113  if(!fOtherDiffCorrelatorsList)
9114  { 
9115   printf("\n WARNING (QC): fOtherDiffCorrelatorsList is NULL in AFAWQC::GPFDFH() !!!!\n\n");
9116   exit(0);
9117  }
9118  
9119  // b) Declare local flags: // (to be improved - promoted to data members)
9120  TString typeFlag[2] = {"RP","POI"}; 
9121  TString ptEtaFlag[2] = {"p_{T}","#eta"};
9122  TString sinCosFlag[2] = {"sin","cos"}; 
9123   
9124  // c) Get pointers to other differential profiles:
9125  TString otherDiffCorrelatorsName = "fOtherDiffCorrelators";
9126  otherDiffCorrelatorsName += fAnalysisLabel->Data();
9127  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)
9128  { 
9129   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9130   {
9131    for(Int_t sc=0;sc<2;sc++) // sin or cos
9132    {
9133     for(Int_t ci=0;ci<1;ci++) // correlator index
9134     {
9135      fOtherDiffCorrelators[t][pe][sc][ci] = dynamic_cast<TProfile*>(fOtherDiffCorrelatorsList->FindObject(Form("%s, %s, %s, %s, ci = %d",otherDiffCorrelatorsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),ci+1))); 
9136      if(!fOtherDiffCorrelators[t][pe][sc][ci])
9137      {
9138       printf("\n WARNING (QC): fOtherDiffCorrelators[%i][%i][%i][%i] is NULL in AFAWQC::GPFODC() !!!!\n\n",t,pe,sc,ci);
9139       exit(0);       
9140      } else
9141        {
9142         this->SetOtherDiffCorrelators(fOtherDiffCorrelators[t][pe][sc][ci],t,pe,sc,ci);     
9143        } 
9144     } // end of for(Int_t ci=0;ci<1;ci++) // correlator index
9145    } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos
9146   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
9147  } // end of for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)
9148   
9149 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForOtherDiffCorrelators()
9150
9151 //================================================================================================================================
9152
9153 void AliFlowAnalysisWithQCumulants::GetPointersForDiffFlowHistograms()
9154 {
9155  // Get pointer to all objects relevant for differential flow.
9156  //  a) Get pointer to base list for differential flow fDiffFlowList;
9157  //  b) Get pointer to profile fDiffFlowFlags holding all flags for differential flow. Access and set some flags;
9158  //  c) Get pointers to nested lists fDiffFlowListProfiles and fDiffFlowListResults;
9159  //  d) Define flags locally (to be improved: should I promote these flags to data members?);
9160  //  e) Get pointers to all nested lists in fDiffFlowListProfiles and to profiles which they hold;
9161  //  f) Get pointers to all nested lists in fDiffFlowListResults and to histograms which they hold.
9162  
9163  // a) Get pointer to base list for differential flow fDiffFlowList:
9164  fDiffFlowList = dynamic_cast<TList*>(fHistList->FindObject("Differential Flow"));  
9165  if(!fDiffFlowList)
9166  { 
9167   printf("\n WARNING (QC): fDiffFlowList is NULL in AFAWQC::GPFDFH() !!!!\n\n");
9168   exit(0);
9169  }
9170  
9171  // b) Get pointer to profile fDiffFlowFlags holding all flags for differential flow. Access and set some flags:
9172  TString diffFlowFlagsName = "fDiffFlowFlags";
9173  diffFlowFlagsName += fAnalysisLabel->Data();
9174  fDiffFlowFlags = dynamic_cast<TProfile*>(fDiffFlowList->FindObject(diffFlowFlagsName.Data()));
9175  if(fDiffFlowFlags)
9176  {
9177   this->SetCalculateDiffFlow((Bool_t)fDiffFlowFlags->GetBinContent(1)); // to be improved - hardwired 1
9178   this->SetCalculateDiffFlowVsEta((Bool_t)fDiffFlowFlags->GetBinContent(6)); // to be improved - hardwired 6
9179  } else
9180    {
9181     printf("\n WARNING (QC): fDiffFlowFlags is NULL in AFAWQC::GPFDFH() !!!!\n\n");
9182     printf("\n             Flags in method Finish() are wrong.\n\n");
9183     exit(0);
9184    } 
9185    
9186  if(!fCalculateDiffFlow){return;} // IMPORTANT: do not move this anywhere above in this method (to be improved)   
9187   
9188  // c) Get pointers to nested lists fDiffFlowListProfiles and fDiffFlowListResults:
9189  //  List holding nested lists holding profiles:
9190  TList *diffFlowListProfiles = NULL;
9191  diffFlowListProfiles = dynamic_cast<TList*>(fDiffFlowList->FindObject("Profiles"));
9192  if(!diffFlowListProfiles)
9193  { 
9194   printf("\n WARNING (QC): diffFlowListProfiles is NULL in AFAWQC::GPFDFH() !!!!\n\n");
9195   exit(0);
9196  }
9197  //  List holding nested lists holding histograms with final results:
9198  TList *diffFlowListResults = NULL;
9199  diffFlowListResults = dynamic_cast<TList*>(fDiffFlowList->FindObject("Results"));
9200  if(!diffFlowListResults)
9201  { 
9202   printf("\n WARNING (QC): diffFlowListResults is NULL in AFAWQC::GPFDFH() !!!!\n\n");
9203   exit(0);
9204  }
9205  
9206  // d) Define flags locally (to be improved: should I promote these flags to data members?):
9207  TString typeFlag[2] = {"RP","POI"}; 
9208  TString ptEtaFlag[2] = {"p_{T}","#eta"};
9209  TString powerFlag[2] = {"linear","quadratic"};
9210  TString sinCosFlag[2] = {"sin","cos"};
9211  TString differentialCumulantIndex[4] = {"QC{2'}","QC{4'}","QC{6'}","QC{8'}"};  
9212  TString differentialFlowIndex[4] = {"v'{2}","v'{4}","v'{6}","v'{8}"};  
9213  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"};
9214  TString reducedSquaredCorrelationIndex[4] = {"<2'>^{2}","<4'>^{2}","<6'>^{2}","<8'>^{2}"}; 
9215  TString mixedCorrelationIndex[8] = {"<2>","<2'>","<4>","<4'>","<6>","<6'>","<8>","<8'>"};
9216  TString covarianceName[5] = {"Cov(<2>,<2'>)","Cov(<2>,<4'>)","Cov(<4>,<2'>)","Cov(<4>,<4'>)","Cov(<2'>,<4'>)"}; 
9217   
9218  // e) Get pointers to all nested lists in fDiffFlowListProfiles and to profiles which they hold:
9219  // correlations:
9220  TList *diffFlowCorrelationsProList[2][2] = {{NULL}};
9221  TString diffFlowCorrelationsProName = "fDiffFlowCorrelationsPro";
9222  diffFlowCorrelationsProName += fAnalysisLabel->Data();
9223  TProfile *diffFlowCorrelationsPro[2][2][4] = {{{NULL}}}; 
9224  // squared correlations:  
9225  TString diffFlowSquaredCorrelationsProName = "fDiffFlowSquaredCorrelationsPro";
9226  diffFlowSquaredCorrelationsProName += fAnalysisLabel->Data(); 
9227  TProfile *diffFlowSquaredCorrelationsPro[2][2][4] = {{{NULL}}};  
9228  // products of correlations:
9229  TList *diffFlowProductOfCorrelationsProList[2][2] = {{NULL}};
9230  TString diffFlowProductOfCorrelationsProName = "fDiffFlowProductOfCorrelationsPro";
9231  diffFlowProductOfCorrelationsProName += fAnalysisLabel->Data();  
9232  TProfile *diffFlowProductOfCorrelationsPro[2][2][8][8] = {{{{NULL}}}};   
9233  // corrections:
9234  TList *diffFlowCorrectionsProList[2][2] = {{NULL}};
9235  TString diffFlowCorrectionTermsForNUAProName = "fDiffFlowCorrectionTermsForNUAPro";
9236  diffFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();  
9237  TProfile *diffFlowCorrectionTermsForNUAPro[2][2][2][10] = {{{{NULL}}}};   
9238  for(Int_t t=0;t<2;t++)
9239  {
9240   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++)
9241   {
9242    diffFlowCorrelationsProList[t][pe] = dynamic_cast<TList*>(diffFlowListProfiles->FindObject(Form("Profiles with correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));
9243    if(!diffFlowCorrelationsProList[t][pe])
9244    { 
9245     cout<<"WARNING: diffFlowCorrelationsProList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9246     cout<<"t = "<<t<<endl;
9247     cout<<"pe = "<<pe<<endl;
9248     exit(0);
9249    }
9250    for(Int_t ci=0;ci<4;ci++) // correlation index
9251    {
9252     // reduced correlations:
9253     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())));
9254     if(diffFlowCorrelationsPro[t][pe][ci])
9255     {
9256      this->SetDiffFlowCorrelationsPro(diffFlowCorrelationsPro[t][pe][ci],t,pe,ci);
9257     } else
9258       {
9259        cout<<"WARNING: diffFlowCorrelationsPro[t][pe][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9260        cout<<"t  = "<<t<<endl;
9261        cout<<"pe = "<<pe<<endl;   
9262        cout<<"ci = "<<ci<<endl;
9263       }     
9264     // reduced squared correlations:
9265     diffFlowSquaredCorrelationsPro[t][pe][ci] = dynamic_cast<TProfile*>(diffFlowCorrelationsProList[t][pe]->FindObject(Form("%s, %s, %s, %s",diffFlowSquaredCorrelationsProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedSquaredCorrelationIndex[ci].Data())));
9266     if(diffFlowSquaredCorrelationsPro[t][pe][ci])
9267     {
9268      this->SetDiffFlowSquaredCorrelationsPro(diffFlowSquaredCorrelationsPro[t][pe][ci],t,pe,ci);
9269     } else
9270       {
9271        cout<<"WARNING: diffFlowSquaredCorrelationsPro[t][pe][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9272        cout<<"t  = "<<t<<endl;
9273        cout<<"pe = "<<pe<<endl;   
9274        cout<<"ci = "<<ci<<endl;
9275       }       
9276    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index  
9277    // products of correlations:    
9278    diffFlowProductOfCorrelationsProList[t][pe] = dynamic_cast<TList*>(diffFlowListProfiles->FindObject(Form("Profiles with products of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data()))); 
9279    if(!diffFlowProductOfCorrelationsProList[t][pe])
9280    { 
9281     cout<<"WARNING: ddiffFlowProductOfCorrelationsProList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9282     cout<<"t = "<<t<<endl;
9283     cout<<"pe = "<<pe<<endl;
9284     exit(0);
9285    }
9286    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index
9287    {
9288     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index
9289     {
9290      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())));
9291      if(diffFlowProductOfCorrelationsPro[t][pe][mci1][mci2])
9292      {
9293       this->SetDiffFlowProductOfCorrelationsPro(diffFlowProductOfCorrelationsPro[t][pe][mci1][mci2],t,pe,mci1,mci2);
9294      } else
9295        {
9296         cout<<"WARNING: diffFlowProductOfCorrelationsPro[t][pe][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9297         cout<<"t    = "<<t<<endl;
9298         cout<<"pe   = "<<pe<<endl;   
9299         cout<<"mci1 = "<<mci1<<endl;
9300         cout<<"mci2 = "<<mci2<<endl;
9301        }
9302      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here
9303     } // end of for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index
9304    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index    
9305    // corrections:
9306    diffFlowCorrectionsProList[t][pe] = dynamic_cast<TList*>(diffFlowListProfiles->FindObject(Form("Profiles with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));
9307    if(!diffFlowCorrectionsProList[t][pe])
9308    { 
9309     cout<<"WARNING: diffFlowCorrectionsProList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9310     cout<<"t = "<<t<<endl;
9311     cout<<"pe = "<<pe<<endl;
9312     exit(0);
9313    }
9314    // correction terms for NUA:
9315    for(Int_t sc=0;sc<2;sc++) // sin or cos
9316    {
9317     for(Int_t cti=0;cti<9;cti++) // correction term index
9318     {
9319      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)));
9320      if(diffFlowCorrectionTermsForNUAPro[t][pe][sc][cti])
9321      {
9322       this->SetDiffFlowCorrectionTermsForNUAPro(diffFlowCorrectionTermsForNUAPro[t][pe][sc][cti],t,pe,sc,cti);
9323      } else
9324        {
9325         cout<<"WARNING: diffFlowCorrectionTermsForNUAPro[t][pe][sc][cti] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9326         cout<<"t   = "<<t<<endl;
9327         cout<<"pe  = "<<pe<<endl;   
9328         cout<<"sc  = "<<sc<<endl;
9329         cout<<"cti = "<<cti<<endl;
9330        }    
9331     } // end of for(Int_t cti=0;cti<9;cti++) // correction term index
9332    } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos
9333    // ...
9334   } // end of for(Int_t pe=0;pe<2;pe++)
9335  } // end of for(Int_t t=0;t<2;t++)
9336   
9337  // f) Get pointers to all nested lists in fDiffFlowListResults and to histograms which they hold:
9338  // reduced correlations:
9339  TList *diffFlowCorrelationsHistList[2][2] = {{NULL}};
9340  TString diffFlowCorrelationsHistName = "fDiffFlowCorrelationsHist";
9341  diffFlowCorrelationsHistName += fAnalysisLabel->Data();  
9342  TH1D *diffFlowCorrelationsHist[2][2][4] = {{{NULL}}};
9343  // corrections for NUA:
9344  TList *diffFlowCorrectionsHistList[2][2] = {{NULL}};
9345  TString diffFlowCorrectionTermsForNUAHistName = "fDiffFlowCorrectionTermsForNUAHist";
9346  diffFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();  
9347  TH1D *diffFlowCorrectionTermsForNUAHist[2][2][2][10] = {{{{NULL}}}};
9348  // differential Q-cumulants:
9349  TList *diffFlowCumulantsHistList[2][2] = {{NULL}};
9350  TString diffFlowCumulantsName = "fDiffFlowCumulants";
9351  diffFlowCumulantsName += fAnalysisLabel->Data();  
9352  TH1D *diffFlowCumulants[2][2][4] = {{{NULL}}};
9353  // detector bias to differential Q-cumulants:
9354  TList *diffFlowDetectorBiasHistList[2][2] = {{NULL}};
9355  TString diffFlowDetectorBiasName = "fDiffFlowDetectorBias";
9356  diffFlowDetectorBiasName += fAnalysisLabel->Data();  
9357  TH1D *diffFlowDetectorBias[2][2][4] = {{{NULL}}}; 
9358  // differential flow estimates from Q-cumulants:
9359  TList *diffFlowHistList[2][2] = {{NULL}};
9360  TString diffFlowName = "fDiffFlow";
9361  diffFlowName += fAnalysisLabel->Data();  
9362  TH1D *diffFlow[2][2][4] = {{{NULL}}};
9363  // differential covariances:
9364  TList *diffFlowCovariancesHistList[2][2] = {{NULL}};
9365  TString diffFlowCovariancesName = "fDiffFlowCovariances";
9366  diffFlowCovariancesName += fAnalysisLabel->Data();  
9367  TH1D *diffFlowCovariances[2][2][5] = {{{NULL}}};
9368  for(Int_t t=0;t<2;t++) // type: RP or POI
9369  { 
9370   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9371   {
9372    // reduced correlations:
9373    diffFlowCorrelationsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));
9374    if(!diffFlowCorrelationsHistList[t][pe])
9375    { 
9376     cout<<"WARNING: diffFlowCorrelationsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9377     cout<<"t = "<<t<<endl;
9378     cout<<"pe = "<<pe<<endl;
9379     exit(0);
9380    }
9381    for(Int_t index=0;index<4;index++) 
9382    {
9383     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())));
9384     if(diffFlowCorrelationsHist[t][pe][index])
9385     {
9386      this->SetDiffFlowCorrelationsHist(diffFlowCorrelationsHist[t][pe][index],t,pe,index);
9387     } else 
9388       {
9389        cout<<"WARNING: diffFlowCorrelationsHist[t][pe][index] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9390        cout<<"t     = "<<t<<endl;
9391        cout<<"pe    = "<<pe<<endl;
9392        cout<<"index = "<<index<<endl;
9393        exit(0);       
9394       } 
9395    } // end of for(Int_t index=0;index<4;index++)
9396    // corrections:
9397    diffFlowCorrectionsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Histograms with correction terms for NUA (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));
9398    if(!diffFlowCorrectionsHistList[t][pe])
9399    { 
9400     cout<<"WARNING: diffFlowCorrectionsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9401     cout<<"t = "<<t<<endl;
9402     cout<<"pe = "<<pe<<endl;
9403     exit(0);
9404    }
9405    // correction terms for NUA:
9406    for(Int_t sc=0;sc<2;sc++) // sin or cos
9407    {
9408     for(Int_t cti=0;cti<9;cti++) // correction term index
9409     {
9410      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)));
9411      if(diffFlowCorrectionTermsForNUAHist[t][pe][sc][cti])
9412      {
9413       this->SetDiffFlowCorrectionTermsForNUAHist(diffFlowCorrectionTermsForNUAHist[t][pe][sc][cti],t,pe,sc,cti);
9414      } else
9415        {
9416         cout<<"WARNING: diffFlowCorrectionTermsForNUAHist[t][pe][sc][cti] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9417         cout<<"t   = "<<t<<endl;
9418         cout<<"pe  = "<<pe<<endl;   
9419         cout<<"sc  = "<<sc<<endl;
9420         cout<<"cti = "<<cti<<endl;
9421        }    
9422     } // end of for(Int_t cti=0;cti<9;cti++) // correction term index
9423    } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos
9424    // ...
9425    // differential Q-cumulants:
9426    diffFlowCumulantsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Differential Q-cumulants (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));
9427    if(!diffFlowCumulantsHistList[t][pe])
9428    { 
9429     cout<<"WARNING: diffFlowCumulantsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9430     cout<<"t  = "<<t<<endl;
9431     cout<<"pe = "<<pe<<endl;
9432     exit(0);
9433    }
9434    for(Int_t index=0;index<4;index++) 
9435    {
9436     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())));
9437     if(diffFlowCumulants[t][pe][index])
9438     {
9439      this->SetDiffFlowCumulants(diffFlowCumulants[t][pe][index],t,pe,index);
9440     } else 
9441       {
9442        cout<<"WARNING: diffFlowCumulants[t][pe][index] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9443        cout<<"t     = "<<t<<endl;
9444        cout<<"pe    = "<<pe<<endl;
9445        cout<<"index = "<<index<<endl;
9446        exit(0);       
9447       } 
9448    } // end of for(Int_t index=0;index<4;index++)
9449    // Detector bias to differential Q-cumulants:
9450    diffFlowDetectorBiasHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Detector bias (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));
9451    if(!diffFlowDetectorBiasHistList[t][pe])
9452    { 
9453     cout<<"WARNING: diffFlowDetectorBiasHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9454     cout<<"t  = "<<t<<endl;
9455     cout<<"pe = "<<pe<<endl;
9456     exit(0);
9457    }
9458    for(Int_t index=0;index<4;index++) 
9459    {
9460     diffFlowDetectorBias[t][pe][index] = dynamic_cast<TH1D*>(diffFlowDetectorBiasHistList[t][pe]->FindObject(Form("%s, %s, %s, %s",diffFlowDetectorBiasName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),differentialCumulantIndex[index].Data())));
9461     if(diffFlowDetectorBias[t][pe][index])
9462     {
9463      this->SetDiffFlowDetectorBias(diffFlowDetectorBias[t][pe][index],t,pe,index);
9464     } else 
9465       {
9466        cout<<"WARNING: diffFlowDetectorBias[t][pe][index] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9467        cout<<"t     = "<<t<<endl;
9468        cout<<"pe    = "<<pe<<endl;
9469        cout<<"index = "<<index<<endl;
9470        exit(0);       
9471       } 
9472    } // end of for(Int_t index=0;index<4;index++)
9473    // differential flow estimates from Q-cumulants:
9474    diffFlowHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Differential flow (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));
9475    if(!diffFlowHistList[t][pe])
9476    { 
9477     cout<<"WARNING: diffFlowHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9478     cout<<"t  = "<<t<<endl;
9479     cout<<"pe = "<<pe<<endl;
9480     exit(0);
9481    }
9482    for(Int_t index=0;index<4;index++) 
9483    {
9484     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())));
9485     if(diffFlow[t][pe][index])
9486     {
9487      this->SetDiffFlow(diffFlow[t][pe][index],t,pe,index);
9488     } else 
9489       {
9490        cout<<"WARNING: diffFlow[t][pe][index] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9491        cout<<"t     = "<<t<<endl;
9492        cout<<"pe    = "<<pe<<endl;
9493        cout<<"index = "<<index<<endl;
9494        exit(0);       
9495       } 
9496    } // end of for(Int_t index=0;index<4;index++)
9497    // differential covariances:
9498    diffFlowCovariancesHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Covariances of correlations (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));
9499    if(!diffFlowCovariancesHistList[t][pe])
9500    { 
9501     cout<<"WARNING: diffFlowCovariancesHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9502     cout<<"t  = "<<t<<endl;
9503     cout<<"pe = "<<pe<<endl;
9504     exit(0);
9505    }
9506    for(Int_t covIndex=0;covIndex<5;covIndex++) 
9507    {
9508     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())));
9509     if(diffFlowCovariances[t][pe][covIndex])
9510     {
9511      this->SetDiffFlowCovariances(diffFlowCovariances[t][pe][covIndex],t,pe,covIndex);
9512     } else 
9513       {
9514        cout<<"WARNING: diffFlowCovariances[t][pe][covIndex] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9515        cout<<"t        = "<<t<<endl;
9516        cout<<"pe       = "<<pe<<endl;
9517        cout<<"covIndex = "<<covIndex<<endl;
9518        exit(0);       
9519       } 
9520    } // end of for(Int_t covIndex=0;covIndex<5;covIndex++) // covariance index    
9521   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
9522  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI 
9523  // sum of event weights for reduced correlations:
9524  TList *diffFlowSumOfEventWeightsHistList[2][2][2] = {{{NULL}}};
9525  TString diffFlowSumOfEventWeightsName = "fDiffFlowSumOfEventWeights";
9526  diffFlowSumOfEventWeightsName += fAnalysisLabel->Data();  
9527  TH1D *diffFlowSumOfEventWeights[2][2][2][4] = {{{{NULL}}}};
9528  for(Int_t t=0;t<2;t++) // type is RP or POI
9529  { 
9530   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9531   { 
9532    for(Int_t p=0;p<2;p++) // power of event weights is either 1 or 2
9533    {
9534     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())));
9535     if(!diffFlowSumOfEventWeightsHistList[t][pe][p])
9536     { 
9537      cout<<"WARNING: diffFlowSumOfEventWeightsHistList[t][pe][p] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9538      cout<<"t     = "<<t<<endl;
9539      cout<<"pe    = "<<pe<<endl;
9540      cout<<"power = "<<p<<endl;
9541      exit(0);
9542     }
9543     for(Int_t ew=0;ew<4;ew++) // index of reduced correlation
9544     {
9545      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())));    
9546      if(diffFlowSumOfEventWeights[t][pe][p][ew])
9547      {
9548       this->SetDiffFlowSumOfEventWeights(diffFlowSumOfEventWeights[t][pe][p][ew],t,pe,p,ew);
9549      } else 
9550        {
9551         cout<<"WARNING: diffFlowSumOfEventWeights[t][pe][p][ew] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9552         cout<<"t     = "<<t<<endl;
9553         cout<<"pe    = "<<pe<<endl;
9554         cout<<"power = "<<p<<endl;
9555         cout<<"ew    = "<<ew<<endl;
9556         exit(0);       
9557        } 
9558     }
9559    } // end of for(Int_t p=0;p<2;p++) // power of event weights is either 1 or 2
9560   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
9561  } // end of for(Int_t t=0;t<2;t++) // type is RP or POI
9562  //  
9563  TList *diffFlowSumOfProductOfEventWeightsHistList[2][2] = {{NULL}};
9564  TString diffFlowSumOfProductOfEventWeightsName = "fDiffFlowSumOfProductOfEventWeights";
9565  diffFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();  
9566  TH1D *diffFlowSumOfProductOfEventWeights[2][2][8][8] = {{{{NULL}}}};
9567  for(Int_t t=0;t<2;t++) // type is RP or POI
9568  { 
9569   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9570   { 
9571    diffFlowSumOfProductOfEventWeightsHistList[t][pe] = dynamic_cast<TList*>(diffFlowListResults->FindObject(Form("Sum of products of event weights (%s, %s)",typeFlag[t].Data(),ptEtaFlag[pe].Data())));
9572    if(!diffFlowSumOfProductOfEventWeightsHistList[t][pe])
9573    { 
9574     cout<<"WARNING: diffFlowSumOfProductOfEventWeightsHistList[t][pe] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9575     cout<<"t     = "<<t<<endl;
9576     cout<<"pe    = "<<pe<<endl;
9577     exit(0);
9578    }
9579    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index
9580    {
9581     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index
9582     {
9583      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())));    
9584       if(diffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2])
9585       {
9586        this->SetDiffFlowSumOfProductOfEventWeights(diffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2],t,pe,mci1,mci2);
9587       } else 
9588         {
9589          cout<<"WARNING: diffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
9590          cout<<"t    = "<<t<<endl;
9591          cout<<"pe   = "<<pe<<endl;
9592          cout<<"mci1 = "<<mci1<<endl;
9593          cout<<"mci2 = "<<mci2<<endl;
9594          exit(0);       
9595         } 
9596      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here
9597     } // end of for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index
9598    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index
9599   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta
9600  } // end of for(Int_t t=0;t<2;t++) // type is RP or POI
9601
9602 } // end void AliFlowAnalysisWithQCumulants::GetPointersForDiffFlowHistograms()
9603
9604 //================================================================================================================================
9605
9606 void AliFlowAnalysisWithQCumulants::BookEverythingFor2DDifferentialFlow()
9607 {
9608  // Book all objects needed for 2D differential flow.
9609  //  a) Define flags locally (to be improved: should I promote flags to data members?);
9610  //  b) Book e-b-e quantities;
9611  //  c) Book 2D profiles;
9612  //  d) Book 2D histograms.
9613  
9614  if(!fCalculate2DDiffFlow){return;}
9615
9616  // a) Define flags locally (to be improved: should I promote flags to data members?):
9617  TString typeFlag[2] = {"RP","POI"}; 
9618  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"};
9619  TString differentialCumulantIndex[4] = {"QC{2'}","QC{4'}","QC{6'}","QC{8'}"};  
9620  TString differentialFlowIndex[4] = {"v'{2}","v'{4}","v'{6}","v'{8}"};  
9621   
9622  // b) Book e-b-e quantities: 
9623  TProfile2D styleRe("typeMultiplePowerRe","typeMultiplePowerRe",fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);
9624  TProfile2D styleIm("typeMultiplePowerIm","typeMultiplePowerIm",fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);
9625  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP&&POI )
9626  { 
9627   for(Int_t m=0;m<4;m++)
9628   {
9629    for(Int_t k=0;k<9;k++)
9630    {
9631     fReRPQ2dEBE[t][m][k] = (TProfile2D*)styleRe.Clone(Form("typeFlag%dmultiple%dpower%dRe",t,m,k)); 
9632     fImRPQ2dEBE[t][m][k] = (TProfile2D*)styleIm.Clone(Form("typeFlag%dmultiple%dpower%dIm",t,m,k));
9633    }
9634   } 
9635  } 
9636  TProfile2D styleS("typePower","typePower",fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);
9637  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP&&POI )
9638  { 
9639   for(Int_t k=0;k<9;k++)
9640   {
9641    fs2dEBE[t][k] = (TProfile2D*)styleS.Clone(Form("typeFlag%dpower%d",t,k));
9642   }
9643  }
9644
9645  // c) Book 2D profiles:
9646  TString s2DDiffFlowCorrelationsProName = "f2DDiffFlowCorrelationsPro";
9647  s2DDiffFlowCorrelationsProName += fAnalysisLabel->Data();
9648  for(Int_t t=0;t<2;t++) // type: RP or POI
9649  { 
9650   for(Int_t rci=0;rci<4;rci++) // reduced correlation index
9651   {
9652    f2DDiffFlowCorrelationsPro[t][rci] = new TProfile2D(Form("%s, %s, %s",s2DDiffFlowCorrelationsProName.Data(),typeFlag[t].Data(),reducedCorrelationIndex[rci].Data()),Form("%s, %s, %s",s2DDiffFlowCorrelationsProName.Data(),typeFlag[t].Data(),reducedCorrelationIndex[rci].Data()),fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax,"");
9653    f2DDiffFlowCorrelationsPro[t][rci]->Sumw2();
9654    f2DDiffFlowCorrelationsPro[t][rci]->SetXTitle("p_{t}");
9655    f2DDiffFlowCorrelationsPro[t][rci]->SetYTitle("#eta");
9656    f2DDiffFlowCorrelationsProList[t]->Add(f2DDiffFlowCorrelationsPro[t][rci]); 
9657   } // end of for(Int_t rci=0;rci<4;rci++) // correlation index
9658  } // end of for(Int_t t=0;t<2;t++) // type: RP or POIs
9659
9660  // d) Book 2D histograms:
9661  TString s2DDiffFlowCumulantsName = "f2DDiffFlowCumulants";
9662  s2DDiffFlowCumulantsName += fAnalysisLabel->Data();
9663  TString s2DDiffFlowName = "f2DDiffFlow";
9664  s2DDiffFlowName += fAnalysisLabel->Data();
9665  for(Int_t t=0;t<2;t++) // type: RP or POI
9666  { 
9667   for(Int_t rci=0;rci<4;rci++) // reduced correlation index
9668   {
9669    // 2D diferential cumulants:
9670    f2DDiffFlowCumulants[t][rci] = new TH2D(Form("%s, %s, %s",s2DDiffFlowCumulantsName.Data(),typeFlag[t].Data(),differentialCumulantIndex[rci].Data()),Form("%s, %s, %s",s2DDiffFlowCumulantsName.Data(),typeFlag[t].Data(),differentialCumulantIndex[rci].Data()),fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);
9671    f2DDiffFlowCumulants[t][rci]->SetXTitle("p_{t}");
9672    f2DDiffFlowCumulants[t][rci]->SetYTitle("#eta");
9673    f2DDiffFlowCorrelationsProList[t]->Add(f2DDiffFlowCumulants[t][rci]); //  to be improved - moved to another list 
9674    // 2D differential flow:
9675    f2DDiffFlow[t][rci] = new TH2D(Form("%s, %s, %s",s2DDiffFlowName.Data(),typeFlag[t].Data(),differentialFlowIndex[rci].Data()),Form("%s, %s, %s",s2DDiffFlowName.Data(),typeFlag[t].Data(),differentialFlowIndex[rci].Data()),fnBinsPt,fPtMin,fPtMax,fnBinsEta,fEtaMin,fEtaMax);
9676    f2DDiffFlow[t][rci]->SetXTitle("p_{t}");
9677    f2DDiffFlow[t][rci]->SetYTitle("#eta");
9678    f2DDiffFlowCorrelationsProList[t]->Add(f2DDiffFlow[t][rci]); //  to be improved - moved to another list 
9679   } // end of for(Int_t rci=0;rci<4;rci++) // correlation index
9680  } // end of for(Int_t t=0;t<2;t++) // type: RP or POIs
9681
9682 } // void AliFlowAnalysisWithQCumulants::BookEverythingFor2DDifferentialFlow()
9683
9684 //================================================================================================================================
9685
9686 void AliFlowAnalysisWithQCumulants::BookEverythingForDifferentialFlow()
9687 {
9688  // Book all histograms and profiles needed for differential flow.
9689  //  a) Book profile to hold all flags for differential flow;
9690  //  b) Define flags locally (to be improved: should I promote flags to data members?);
9691  //  c) Book e-b-e quantities;
9692  //  d) Book profiles;
9693  //  e) Book histograms holding final results. 
9694  
9695  // a) Book profile to hold all flags for differential flow:
9696  TString diffFlowFlagsName = "fDiffFlowFlags";
9697  diffFlowFlagsName += fAnalysisLabel->Data();
9698  fDiffFlowFlags = new TProfile(diffFlowFlagsName.Data(),"Flags for differential flow",6,0,6);
9699  fDiffFlowFlags->SetTickLength(-0.01,"Y");
9700  fDiffFlowFlags->SetMarkerStyle(25);
9701  fDiffFlowFlags->SetLabelSize(0.04,"X");
9702  fDiffFlowFlags->SetLabelOffset(0.02,"Y");
9703  fDiffFlowFlags->GetXaxis()->SetBinLabel(1,"Calculate diff. flow"); 
9704  fDiffFlowFlags->GetXaxis()->SetBinLabel(2,"Particle weights");
9705  fDiffFlowFlags->GetXaxis()->SetBinLabel(3,"Event weights");
9706  fDiffFlowFlags->GetXaxis()->SetBinLabel(4,"Correct for NUA");
9707  fDiffFlowFlags->GetXaxis()->SetBinLabel(5,"Calculate 2D diff. flow");
9708  fDiffFlowFlags->GetXaxis()->SetBinLabel(6,"Calculate diff. flow vs eta");
9709  fDiffFlowList->Add(fDiffFlowFlags);
9710
9711  if(!fCalculateDiffFlow){return;}
9712   
9713  // b) Define flags locally (to be improved: should I promote flags to data members?): 
9714  TString typeFlag[2] = {"RP","POI"}; 
9715  TString ptEtaFlag[2] = {"p_{T}","#eta"};
9716  TString powerFlag[2] = {"linear","quadratic"};
9717  TString sinCosFlag[2] = {"sin","cos"};
9718  TString differentialCumulantIndex[4] = {"QC{2'}","QC{4'}","QC{6'}","QC{8'}"};  
9719  TString differentialFlowIndex[4] = {"v'{2}","v'{4}","v'{6}","v'{8}"};  
9720  TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"};
9721  TString reducedSquaredCorrelationIndex[4] = {"<2'>^{2}","<4'>^{2}","<6'>^{2}","<8'>^{2}"};
9722  TString mixedCorrelationIndex[8] = {"<2>","<2'>","<4>","<4'>","<6>","<6'>","<8>","<8'>"};
9723  TString covarianceName[5] = {"Cov(<2>,<2'>)","Cov(<2>,<4'>)","Cov(<4>,<2'>)","Cov(<4>,<4'>)","Cov(<2'>,<4'>)"}; 
9724  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
9725  Double_t minPtEta[2] = {fPtMin,fEtaMin};
9726  Double_t maxPtEta[2] = {fPtMax,fEtaMax};
9727    
9728  // c) Book e-b-e quantities:
9729  // Event-by-event r_{m*n,k}(pt,eta), p_{m*n,k}(pt,eta) and q_{m*n,k}(pt,eta)
9730  // Explanantion of notation:
9731  //  1.) n is harmonic, m is multiple of harmonic;
9732  //  2.) k is power of particle weight;
9733  //  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);   
9734  //  4.) p_{m*n,k}(pt,eta) = Q-vector evaluated in harmonic m*n for POIs in particular (pt,eta) bin 
9735  //                          (if i-th POI is also RP, than it is weighted with w_i^k);   
9736  //  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 
9737  //                          (i-th RP&&POI is weighted with w_i^k)            
9738   
9739  // 1D:
9740  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP && POI )
9741  { 
9742   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9743   {
9744    for(Int_t m=0;m<4;m++) // multiple of harmonic
9745    {
9746     for(Int_t k=0;k<9;k++) // power of particle weight
9747     {
9748      fReRPQ1dEBE[t][pe][m][k] = new TProfile(Form("TypeFlag%dpteta%dmultiple%dpower%dRe",t,pe,m,k),
9749                                              Form("TypeFlag%dpteta%dmultiple%dpower%dRe",t,pe,m,k),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); 
9750      fImRPQ1dEBE[t][pe][m][k] = new TProfile(Form("TypeFlag%dpteta%dmultiple%dpower%dIm",t,pe,m,k),
9751                                              Form("TypeFlag%dpteta%dmultiple%dpower%dIm",t,pe,m,k),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); 
9752     }
9753    }
9754   }
9755  } 
9756  // to be improved (add explanation of fs1dEBE[t][pe][k]):   
9757  for(Int_t t=0;t<3;t++) // typeFlag (0 = RP, 1 = POI, 2 = RP&&POI )
9758  { 
9759   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9760   {
9761    for(Int_t k=0;k<9;k++) // power of particle weight
9762    {
9763     fs1dEBE[t][pe][k] = new TProfile(Form("TypeFlag%dpteta%dmultiple%d",t,pe,k),
9764                                      Form("TypeFlag%dpteta%dmultiple%d",t,pe,k),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); 
9765    }
9766   }
9767  }
9768  // correction terms for nua:
9769  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)
9770  { 
9771   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9772   {
9773    for(Int_t sc=0;sc<2;sc++) // sin or cos
9774    {
9775     for(Int_t cti=0;cti<9;cti++) // correction term index
9776     {
9777      fDiffFlowCorrectionTermsForNUAEBE[t][pe][sc][cti] = new TH1D(Form("typeFlag%d pteta%d sincos%d cti%d",t,pe,sc,cti),
9778                                              Form("typeFlag%d pteta%d sincos%d cti%d",t,pe,sc,cti),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); 
9779     }
9780    }
9781   }
9782  } 
9783  // reduced correlations e-b-e:
9784  TString diffFlowCorrelationsEBEName = "fDiffFlowCorrelationsEBE";
9785  diffFlowCorrelationsEBEName += fAnalysisLabel->Data();
9786  for(Int_t t=0;t<2;t++) // type: RP or POI
9787  { 
9788   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9789   {
9790    for(Int_t rci=0;rci<4;rci++) // reduced correlation index
9791    {
9792     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]);
9793    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index
9794   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta 
9795  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
9796  // event weights for reduced correlations e-b-e:
9797  TString diffFlowEventWeightsForCorrelationsEBEName = "fDiffFlowEventWeightsForCorrelationsEBE";
9798  diffFlowEventWeightsForCorrelationsEBEName += fAnalysisLabel->Data();
9799  for(Int_t t=0;t<2;t++) // type: RP or POI
9800  { 
9801   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9802   {
9803    for(Int_t rci=0;rci<4;rci++) // event weight for reduced correlation index
9804    {
9805     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]);
9806    } // end of for(Int_t ci=0;ci<4;ci++) // correlation index
9807   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta 
9808  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
9809       
9810  // d) Book profiles;
9811  // reduced correlations:
9812  TString diffFlowCorrelationsProName = "fDiffFlowCorrelationsPro";
9813  diffFlowCorrelationsProName += fAnalysisLabel->Data();
9814  // reduced squared correlations:
9815  TString diffFlowSquaredCorrelationsProName = "fDiffFlowSquaredCorrelationsPro";
9816  diffFlowSquaredCorrelationsProName += fAnalysisLabel->Data();
9817  // corrections terms:
9818  TString diffFlowCorrectionTermsForNUAProName = "fDiffFlowCorrectionTermsForNUAPro";
9819  diffFlowCorrectionTermsForNUAProName += fAnalysisLabel->Data();
9820  // reduced correlations:
9821  for(Int_t t=0;t<2;t++) // type: RP or POI
9822  { 
9823   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9824   {
9825    for(Int_t rci=0;rci<4;rci++) // reduced correlation index
9826    {
9827     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");
9828     fDiffFlowCorrelationsPro[t][pe][rci]->Sumw2();
9829     fDiffFlowCorrelationsPro[t][pe][rci]->SetXTitle(ptEtaFlag[pe].Data());
9830     fDiffFlowCorrelationsProList[t][pe]->Add(fDiffFlowCorrelationsPro[t][pe][rci]); // to be improved (add dedicated list to hold reduced correlations)
9831    } // end of for(Int_t rci=0;rci<4;rci++) // correlation index
9832   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta 
9833  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
9834  // reduced squared correlations:
9835  for(Int_t t=0;t<2;t++) // type: RP or POI
9836  { 
9837   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9838   {
9839    for(Int_t rci=0;rci<4;rci++) // reduced correlation index
9840    {
9841     fDiffFlowSquaredCorrelationsPro[t][pe][rci] = new TProfile(Form("%s, %s, %s, %s",diffFlowSquaredCorrelationsProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedSquaredCorrelationIndex[rci].Data()),Form("%s, %s, %s, %s",diffFlowSquaredCorrelationsProName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),reducedSquaredCorrelationIndex[rci].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe],"s");
9842     fDiffFlowSquaredCorrelationsPro[t][pe][rci]->Sumw2();
9843     fDiffFlowSquaredCorrelationsPro[t][pe][rci]->SetXTitle(ptEtaFlag[pe].Data());
9844     fDiffFlowCorrelationsProList[t][pe]->Add(fDiffFlowSquaredCorrelationsPro[t][pe][rci]); // to be improved (add dedicated list to hold reduced correlations)
9845    } // end of for(Int_t rci=0;rci<4;rci++) // correlation index
9846   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta 
9847  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
9848  // correction terms for nua:
9849  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)
9850  { 
9851   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9852   {
9853    for(Int_t sc=0;sc<2;sc++) // sin or cos
9854    {
9855     for(Int_t cti=0;cti<9;cti++) // correction term index
9856     {
9857      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]); 
9858      fDiffFlowCorrectionsProList[t][pe]->Add(fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti]);
9859     }
9860    }
9861   }
9862  } 
9863  // Other differential correlators:
9864  TString otherDiffCorrelatorsName = "fOtherDiffCorrelators";
9865  otherDiffCorrelatorsName += fAnalysisLabel->Data();
9866  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)
9867  { 
9868   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9869   {
9870    for(Int_t sc=0;sc<2;sc++) // sin or cos
9871    {
9872     for(Int_t ci=0;ci<1;ci++) // correlator index
9873     {
9874      fOtherDiffCorrelators[t][pe][sc][ci] = new TProfile(Form("%s, %s, %s, %s, ci = %d",otherDiffCorrelatorsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),ci+1),Form("%s, %s, %s, %s, ci = %d",otherDiffCorrelatorsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),ci+1),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]); 
9875      fOtherDiffCorrelators[t][pe][sc][ci]->Sumw2();
9876      fOtherDiffCorrelatorsList->Add(fOtherDiffCorrelators[t][pe][sc][ci]);
9877     }
9878    }
9879   }
9880  }  
9881  // e) Book histograms holding final results. 
9882  // reduced correlations:
9883  TString diffFlowCorrelationsHistName = "fDiffFlowCorrelationsHist";
9884  diffFlowCorrelationsHistName += fAnalysisLabel->Data();
9885  // corrections terms:
9886  TString diffFlowCorrectionTermsForNUAHistName = "fDiffFlowCorrectionTermsForNUAHist";
9887  diffFlowCorrectionTermsForNUAHistName += fAnalysisLabel->Data();
9888  // differential covariances:
9889  TString diffFlowCovariancesName = "fDiffFlowCovariances";
9890  diffFlowCovariancesName += fAnalysisLabel->Data();
9891  // differential Q-cumulants:
9892  TString diffFlowCumulantsName = "fDiffFlowCumulants";
9893  diffFlowCumulantsName += fAnalysisLabel->Data();
9894  // Detector bias to differential Q-cumulants:
9895  TString diffFlowDetectorBiasName = "fDiffFlowDetectorBias";
9896  diffFlowDetectorBiasName += fAnalysisLabel->Data();
9897  // differential flow:
9898  TString diffFlowName = "fDiffFlow";
9899  diffFlowName += fAnalysisLabel->Data();
9900  for(Int_t t=0;t<2;t++) // type: RP or POI
9901  { 
9902   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9903   {
9904    for(Int_t index=0;index<4;index++) 
9905    {
9906     // reduced correlations:
9907     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]);
9908     fDiffFlowCorrelationsHist[t][pe][index]->SetXTitle(ptEtaFlag[pe].Data());
9909     fDiffFlowCorrelationsHistList[t][pe]->Add(fDiffFlowCorrelationsHist[t][pe][index]); 
9910     // differential Q-cumulants:
9911     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]);
9912     fDiffFlowCumulants[t][pe][index]->SetXTitle(ptEtaFlag[pe].Data());
9913     fDiffFlowCumulantsHistList[t][pe]->Add(fDiffFlowCumulants[t][pe][index]); 
9914     // Detector bias to differential Q-cumulants:
9915     fDiffFlowDetectorBias[t][pe][index] = new TH1D(Form("%s, %s, %s, %s",diffFlowDetectorBiasName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),differentialCumulantIndex[index].Data()),Form("%s, %s, %s, %s",diffFlowDetectorBiasName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),differentialCumulantIndex[index].Data()),nBinsPtEta[pe],minPtEta[pe],maxPtEta[pe]);
9916     fDiffFlowDetectorBias[t][pe][index]->SetXTitle(ptEtaFlag[pe].Data());
9917     fDiffFlowDetectorBias[t][pe][index]->SetTitle(Form("#frac{corrected}{measured} %s",differentialCumulantIndex[index].Data()));
9918     fDiffFlowDetectorBiasHistList[t][pe]->Add(fDiffFlowDetectorBias[t][pe][index]); 
9919     // differential flow estimates from Q-cumulants:
9920     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]);
9921     fDiffFlow[t][pe][index]->SetXTitle(ptEtaFlag[pe].Data());
9922     fDiffFlowHistList[t][pe]->Add(fDiffFlow[t][pe][index]); 
9923    } // end of for(Int_t index=0;index<4;index++) 
9924    for(Int_t covIndex=0;covIndex<5;covIndex++) // covariance index 
9925    {
9926     // differential covariances:
9927     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]);
9928     fDiffFlowCovariances[t][pe][covIndex]->SetXTitle(ptEtaFlag[pe].Data());
9929     fDiffFlowCovariancesHistList[t][pe]->Add(fDiffFlowCovariances[t][pe][covIndex]); 
9930    } // end of for(Int_t covIndex=0;covIndex<5;covIndex++) // covariance index
9931    // products of both types of correlations: 
9932    TString diffFlowProductOfCorrelationsProName = "fDiffFlowProductOfCorrelationsPro";
9933    diffFlowProductOfCorrelationsProName += fAnalysisLabel->Data();  
9934    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index
9935    {
9936     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index
9937     {
9938      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]); 
9939      fDiffFlowProductOfCorrelationsPro[t][pe][mci1][mci2]->SetXTitle(ptEtaFlag[pe].Data());
9940      fDiffFlowProductOfCorrelationsProList[t][pe]->Add(fDiffFlowProductOfCorrelationsPro[t][pe][mci1][mci2]); 
9941      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here
9942     } // end of for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index
9943    } // end of for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index    
9944   } // end of for(Int_t pe=0;pe<2;pe++) // pt or eta 
9945  } // end of for(Int_t t=0;t<2;t++) // type: RP or POI
9946  // sums of event weights for reduced correlations: 
9947  TString diffFlowSumOfEventWeightsName = "fDiffFlowSumOfEventWeights";
9948  diffFlowSumOfEventWeightsName += fAnalysisLabel->Data();  
9949  for(Int_t t=0;t<2;t++) // type is RP or POI
9950  { 
9951   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9952   { 
9953    for(Int_t p=0;p<2;p++) // power of weights is either 1 or 2
9954    {
9955     for(Int_t ew=0;ew<4;ew++) // index of reduced correlation
9956     {
9957      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]); 
9958      fDiffFlowSumOfEventWeights[t][pe][p][ew]->SetXTitle(ptEtaFlag[pe].Data());
9959      fDiffFlowSumOfEventWeightsHistList[t][pe][p]->Add(fDiffFlowSumOfEventWeights[t][pe][p][ew]); // to be improved (add dedicated list to hold all this)
9960     }
9961    }
9962   }
9963  } 
9964  // sum of products of event weights for both types of correlations: 
9965  TString diffFlowSumOfProductOfEventWeightsName = "fDiffFlowSumOfProductOfEventWeights";
9966  diffFlowSumOfProductOfEventWeightsName += fAnalysisLabel->Data();  
9967  for(Int_t t=0;t<2;t++) // type is RP or POI
9968  {
9969   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9970   { 
9971    for(Int_t mci1=0;mci1<8;mci1++) // mixed correlation index
9972    {
9973     for(Int_t mci2=mci1+1;mci2<8;mci2++) // mixed correlation index
9974     {
9975      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]); 
9976      fDiffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2]->SetXTitle(ptEtaFlag[pe].Data());
9977      fDiffFlowSumOfProductOfEventWeightsHistList[t][pe]->Add(fDiffFlowSumOfProductOfEventWeights[t][pe][mci1][mci2]); 
9978      if(mci1%2 == 0) mci2++; // products which DO NOT include reduced correlations are not stored here
9979     }
9980    }
9981   }
9982  } 
9983  // correction terms for nua:
9984  for(Int_t t=0;t<2;t++) // typeFlag (0 = RP, 1 = POI)
9985  { 
9986   for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
9987   {
9988    for(Int_t sc=0;sc<2;sc++) // sin or cos
9989    {
9990     for(Int_t cti=0;cti<9;cti++) // correction term index
9991     {
9992      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]); 
9993      fDiffFlowCorrectionsHistList[t][pe]->Add(fDiffFlowCorrectionTermsForNUAHist[t][pe][sc][cti]);
9994     }
9995    }
9996   }
9997  } 
9998           
9999 } // end of AliFlowAnalysisWithQCumulants::BookEverythingForDifferentialFlow()
10000
10001 //================================================================================================================================
10002
10003 void AliFlowAnalysisWithQCumulants::CalculateQcumulantsCorrectedForNUAIntFlow()
10004 {
10005  // Calculate generalized Q-cumulants (cumulants corrected for non-unifom acceptance).
10006  
10007  // Isotropic cumulants:
10008  Double_t QC2 = fIntFlowQcumulants->GetBinContent(1);
10009  Double_t QC2Error = fIntFlowQcumulants->GetBinError(1);
10010  Double_t QC4 = fIntFlowQcumulants->GetBinContent(2);
10011  Double_t QC4Error = fIntFlowQcumulants->GetBinError(2);
10012  //Double_t QC6 = fIntFlowQcumulants->GetBinContent(3);
10013  //Double_t QC6Error = fIntFlowQcumulants->GetBinError(3);
10014  //Double_t QC8 = fIntFlowQcumulants->GetBinContent(4);
10015  //Double_t QC8Error = fIntFlowQcumulants->GetBinError(4);
10016  
10017  // Measured 2-, 4-, 6- and 8-particle correlations:
10018  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>
10019  Double_t twoError = fIntFlowCorrelationsHist->GetBinError(1); // statistical error of <<2>>
10020  Double_t four = fIntFlowCorrelationsHist->GetBinContent(2); // <<4>>
10021  Double_t fourError = fIntFlowCorrelationsHist->GetBinError(2); // statistical error of <<4>>
10022  //Double_t six = fIntFlowCorrelationsHist->GetBinContent(3); // <<6>>
10023  //Double_t sixError = fIntFlowCorrelationsHist->GetBinError(3); // statistical error of <<6>>
10024  //Double_t eight = fIntFlowCorrelationsHist->GetBinContent(4); // <<8>>
10025  //Double_t eightError = fIntFlowCorrelationsHist->GetBinError(4); // statistical error of <<8>>
10026   
10027  // Non-isotropic terms:
10028  Double_t c1 = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1); // <<cos(n*phi1)>>
10029  Double_t c1Error = fIntFlowCorrectionTermsForNUAHist[1]->GetBinError(1); // statistical error of <<cos(n*phi1)>>
10030  Double_t c2 = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(2); // <<cos(n*(phi1+phi2))>>
10031  Double_t c2Error = fIntFlowCorrectionTermsForNUAHist[1]->GetBinError(2); // statistical error of <<cos(n*(phi1+phi2))>>
10032  Double_t c3 = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(3); // <<cos(n*(phi1-phi2-phi3))>>
10033  Double_t c3Error = fIntFlowCorrectionTermsForNUAHist[1]->GetBinError(3); // statistical error of <<cos(n*(phi1-phi2-phi3))>>
10034  Double_t s1 = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1); // <<sin(n*phi1)>>
10035  Double_t s1Error = fIntFlowCorrectionTermsForNUAHist[0]->GetBinError(1); // statistical error of <<sin(n*phi1)>>
10036  Double_t s2 = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(2); // <<sin(n*(phi1+phi2))>>
10037  Double_t s2Error = fIntFlowCorrectionTermsForNUAHist[0]->GetBinError(2); // statistical error of <<sin(n*(phi1+phi2))>>
10038  Double_t s3 = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(3); // <<sin(n*(phi1-phi2-phi3))>>
10039  Double_t s3Error = fIntFlowCorrectionTermsForNUAHist[0]->GetBinError(3); // statistical error of <<sin(n*(phi1-phi2-phi3))>>
10040  
10041  // Shortcuts:
10042  Double_t a1 = 2.*pow(c1,2.)+2.*pow(s1,2.)-two;
10043  Double_t a2 = 6.*pow(c1,3.)-2.*c1*c2+c3+6.*c1*pow(s1,2.)-2.*s1*s2-4.*c1*two;
10044  Double_t a3 = 2.*pow(s1,2.)-2.*pow(c1,2.)+c2;
10045  Double_t a4 = 6.*pow(s1,3.)+6.*pow(c1,2.)*s1+2.*c2*s1-2.*c1*s2-s3-4.*s1*two;
10046  Double_t a5 = 4.*c1*s1-s2;
10047  
10048  // Covariances (including weight dependent prefactor):
10049  Double_t wCov1 = 0.; // w*Cov(<2>,<cos(phi)) 
10050  Double_t wCov2 = 0.; // w*Cov(<2>,<sin(phi))
10051  Double_t wCov3 = 0.; // w*Cov(<cos(phi),<sin(phi))
10052  Double_t wCov4 = 0.; // w*Cov(<2>,<4>) 
10053  Double_t wCov5 = 0.; // w*Cov(<2>,<cos(#phi_{1}+#phi_{2})>)
10054  Double_t wCov6 = 0.; // w*Cov(<2>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10055  Double_t wCov7 = 0.; // w*Cov(<2>,<sin(#phi_{1}+#phi_{2})>)
10056  Double_t wCov8 = 0.; // w*Cov(<2>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10057  Double_t wCov9 = 0.; // w*Cov(<4>,<cos(#phi)>
10058  Double_t wCov10 = 0.; // w*Cov(<4>,<cos(#phi_{1}+#phi_{2})>)
10059  Double_t wCov11 = 0.; // w*Cov(<4>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10060  Double_t wCov12 = 0.; // w*Cov(<4>,<sin(#phi)>
10061  Double_t wCov13 = 0.; // w*Cov(<4>,<sin(#phi_{1}+#phi_{2})>)
10062  Double_t wCov14 = 0.; // w*Cov(<4>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10063  Double_t wCov15 = 0.; // w*Cov(<cos(#phi)>,<cos(#phi_{1}+#phi_{2})>)
10064  Double_t wCov16 = 0.; // w*Cov(<cos(#phi)>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10065  Double_t wCov17 = 0.; // w*Cov(<cos(#phi)>,<sin(#phi_{1}+#phi_{2})>)
10066  Double_t wCov18 = 0.; // w*Cov(<cos(#phi)>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10067  Double_t wCov19 = 0.; // w*Cov(<cos(#phi_{1}+#phi_{2})>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10068  Double_t wCov20 = 0.; // w*Cov(<sin(#phi)>,<cos(#phi_{1}+#phi_{2})>)
10069  Double_t wCov21 = 0.; // w*Cov(<cos(#phi_{1}+#phi_{2})>,<sin(#phi_{1}+#phi_{2})>)
10070  Double_t wCov22 = 0.; // w*Cov(<cos(#phi_{1}+#phi_{2})>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10071  Double_t wCov23 = 0.; // w*Cov(<sin(#phi)>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10072  Double_t wCov24 = 0.; // w*Cov(<sin(#phi_{1}+#phi_{2})>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10073  Double_t wCov25 = 0.; // w*Cov(<cos(#phi_{1}-#phi_{2}-#phi_{3}>,<sin(#phi_{1}-#phi_{2}-#phi_{3}>)
10074  Double_t wCov26 = 0.; // w*Cov(<sin(#phi)>,<sin(#phi_{1}+#phi_{2})>)
10075  Double_t wCov27 = 0.; // w*Cov(<sin(#phi)>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10076  Double_t wCov28 = 0.; // w*Cov(<sin(#phi_{1}+#phi_{2})>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10077  if(!fForgetAboutCovariances)
10078  {
10079   wCov1 = fIntFlowCovariancesNUA->GetBinContent(1); // w*Cov(<2>,<cos(phi)) 
10080   wCov2 = fIntFlowCovariancesNUA->GetBinContent(2); // w*Cov(<2>,<sin(phi))
10081   wCov3 = fIntFlowCovariancesNUA->GetBinContent(3); // w*Cov(<cos(phi),<sin(phi))
10082   wCov4 = fIntFlowCovariances->GetBinContent(1); // w*Cov(<2>,<4>) 
10083   wCov5 = fIntFlowCovariancesNUA->GetBinContent(4); // w*Cov(<2>,<cos(#phi_{1}+#phi_{2})>)
10084   wCov6 = fIntFlowCovariancesNUA->GetBinContent(6); // w*Cov(<2>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10085   wCov7 = fIntFlowCovariancesNUA->GetBinContent(5); // w*Cov(<2>,<sin(#phi_{1}+#phi_{2})>)
10086   wCov8 = fIntFlowCovariancesNUA->GetBinContent(7); // w*Cov(<2>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10087   wCov9 = fIntFlowCovariancesNUA->GetBinContent(8); // w*Cov(<4>,<cos(#phi)>
10088   wCov10 = fIntFlowCovariancesNUA->GetBinContent(10); // w*Cov(<4>,<cos(#phi_{1}+#phi_{2})>)
10089   wCov11 = fIntFlowCovariancesNUA->GetBinContent(12); // w*Cov(<4>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10090   wCov12 = fIntFlowCovariancesNUA->GetBinContent(9); // w*Cov(<4>,<sin(#phi)>
10091   wCov13 = fIntFlowCovariancesNUA->GetBinContent(11); // w*Cov(<4>,<sin(#phi_{1}+#phi_{2})>)
10092   wCov14 = fIntFlowCovariancesNUA->GetBinContent(13); // w*Cov(<4>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10093   wCov15 = fIntFlowCovariancesNUA->GetBinContent(14); // w*Cov(<cos(#phi)>,<cos(#phi_{1}+#phi_{2})>)
10094   wCov16 = fIntFlowCovariancesNUA->GetBinContent(16); // w*Cov(<cos(#phi)>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10095   wCov17 = fIntFlowCovariancesNUA->GetBinContent(15); // w*Cov(<cos(#phi)>,<sin(#phi_{1}+#phi_{2})>)
10096   wCov18 = fIntFlowCovariancesNUA->GetBinContent(17); // w*Cov(<cos(#phi)>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10097   wCov19 = fIntFlowCovariancesNUA->GetBinContent(23); // w*Cov(<cos(#phi_{1}+#phi_{2})>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10098   wCov20 = fIntFlowCovariancesNUA->GetBinContent(18); // w*Cov(<sin(#phi)>,<cos(#phi_{1}+#phi_{2})>)
10099   wCov21 = fIntFlowCovariancesNUA->GetBinContent(22); // w*Cov(<cos(#phi_{1}+#phi_{2})>,<sin(#phi_{1}+#phi_{2})>)
10100   wCov22 = fIntFlowCovariancesNUA->GetBinContent(24); // w*Cov(<cos(#phi_{1}+#phi_{2})>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10101   wCov23 = fIntFlowCovariancesNUA->GetBinContent(20); // w*Cov(<sin(#phi)>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10102   wCov24 = fIntFlowCovariancesNUA->GetBinContent(25); // w*Cov(<sin(#phi_{1}+#phi_{2})>,<cos(#phi_{1}-#phi_{2}-#phi_{3})>)
10103   wCov25 = fIntFlowCovariancesNUA->GetBinContent(27); // w*Cov(<cos(#phi_{1}-#phi_{2}-#phi_{3}>,<sin(#phi_{1}-#phi_{2}-#phi_{3}>)
10104   wCov26 = fIntFlowCovariancesNUA->GetBinContent(19); // w*Cov(<sin(#phi)>,<sin(#phi_{1}+#phi_{2})>)
10105   wCov27 = fIntFlowCovariancesNUA->GetBinContent(21); // w*Cov(<sin(#phi)>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10106   wCov28 = fIntFlowCovariancesNUA->GetBinContent(26); // w*Cov(<sin(#phi_{1}+#phi_{2})>,<sin(#phi_{1}-#phi_{2}-#phi_{3})>)
10107  } // end of if(!fForgetAboutCovariances)
10108  
10109  // Calculating generalized QC{2}:
10110  //  Generalized QC{2}:
10111  Double_t gQC2 = two - pow(c1,2.) - pow(s1,2.);
10112  if(fApplyCorrectionForNUA){fIntFlowQcumulants->SetBinContent(1,gQC2);} 
10113  //  Statistical error of generalized QC{2}:
10114  Double_t gQC2ErrorSquared = pow(twoError,2.)+4.*pow(c1,2.)*pow(c1Error,2.)
10115                            + 4.*pow(s1,2.)*pow(s1Error,2.)
10116                            - 4*c1*wCov1-4*s1*wCov2 
10117                            + 8.*c1*s1*wCov3;
10118  //  Store ratio of error squared - with/without NUA terms:
10119  Double_t ratioErrorSquaredQC2 = 0.;
10120  if(fIntFlowQcumulants->GetBinError(1)>0.)
10121  { 
10122   ratioErrorSquaredQC2 = (gQC2ErrorSquared/pow(fIntFlowQcumulants->GetBinError(1),2.));
10123   fIntFlowQcumulantsErrorSquaredRatio->SetBinContent(1,ratioErrorSquaredQC2);
10124  }
10125  //  If enabled, store error by including non-isotropic terms:                         
10126  if(fApplyCorrectionForNUA && fPropagateErrorAlsoFromNIT)
10127  {
10128   if(gQC2ErrorSquared>=0.)
10129   {
10130    fIntFlowQcumulants->SetBinError(1,pow(gQC2ErrorSquared,0.5));
10131   } else
10132     {
10133      fIntFlowQcumulants->SetBinError(1,0.);
10134      cout<<endl;
10135      cout<<" WARNING (QC): Statistical error of generalized QC{2} is imaginary !!!!"<<endl;
10136      cout<<endl;
10137     }   
10138  } // end of if(fApplyCorrectionForNUA && fPropagateErrorAlsoFromNIT)
10139  // Quantify detector bias to QC{2}:
10140  if(TMath::Abs(QC2)>0.)
10141  {
10142   fIntFlowDetectorBias->SetBinContent(1,gQC2/QC2); 
10143   if(QC2Error>0.)
10144   {
10145    Double_t errorSquared = gQC2ErrorSquared/pow(QC2,2.)+pow(gQC2,2.)*pow(QC2Error,2.)/pow(QC2,4.);
10146    if(errorSquared>0.)
10147    {
10148     fIntFlowDetectorBias->SetBinError(1,pow(errorSquared,0.5));  
10149    }
10150   }
10151  } // end of if(TMath::Abs(QC2)>0.)
10152
10153  // Calculating generalized QC{4}:
10154  //  Generalized QC{4}:
10155  Double_t gQC4 = four-2.*pow(two,2.)
10156                - 4.*c1*c3+4.*s1*s3-pow(c2,2.)-pow(s2,2.)
10157                + 4.*c2*(pow(c1,2.)-pow(s1,2.))+8.*s2*s1*c1
10158                + 8.*two*(pow(c1,2.)+pow(s1,2.))-6.*pow((pow(c1,2.)+pow(s1,2.)),2.);
10159  if(fApplyCorrectionForNUA){fIntFlowQcumulants->SetBinContent(2,gQC4);}   
10160  //  Statistical error of generalized QC{4}:
10161  Double_t gQC4ErrorSquared = 16.*pow(a1,2.)*pow(twoError,2.)+pow(fourError,2.)+16.*pow(a2,2.)*pow(c1Error,2.)
10162                            + 4.*pow(a3,2.)*pow(c2Error,2.)+16.*pow(c1,2.)*pow(c3Error,2.)
10163                            + 16.*pow(a4,2.)*pow(s1Error,2.)+4.*pow(a5,2.)*pow(s2Error,2.)
10164                            + 16.*pow(s1,2.)*pow(s3Error,2.)+8.*a1*wCov4-32.*a1*a2*wCov1
10165                            - 16.*a3*a1*wCov5-32.*c1*a1*wCov6-32.*a1*a4*wCov2+16.*a5*a1*wCov7
10166                            + 32.*s1*a1*wCov8-8.*a2*wCov9-4.*a3*wCov10-8.*c1*wCov11-8.*a4*wCov12
10167                            + 4.*a5*wCov13+8.*s1*wCov14+16.*a3*a2*wCov15+32.*c1*a2*wCov16+32.*a2*a4*wCov3
10168                            - 16.*a5*a2*wCov17-32.*s1*a2*wCov18+16.*c1*a3*wCov19+16.*a3*a4*wCov20
10169                            - 8.*a3*a5*wCov21-16.*s1*a3*wCov22+32.*c1*a4*wCov23-16.*c1*a5*wCov24
10170                            - 32.*c1*s1*wCov25-16.*a5*a4*wCov26-32.*s1*a4*wCov27+16.*s1*a5*wCov28;
10171  //  Store ratio of error squared - with/without NUA terms:
10172  Double_t ratioErrorSquaredQC4 = 0.;
10173  if(fIntFlowQcumulants->GetBinError(2)>0.)
10174  { 
10175   ratioErrorSquaredQC4 = (gQC4ErrorSquared/pow(fIntFlowQcumulants->GetBinError(2),2.));
10176   fIntFlowQcumulantsErrorSquaredRatio->SetBinContent(2,ratioErrorSquaredQC4);
10177  }                          
10178  if(fApplyCorrectionForNUA && fPropagateErrorAlsoFromNIT)
10179  {
10180   if(gQC4ErrorSquared>=0.)
10181   {
10182    fIntFlowQcumulants->SetBinError(2,pow(gQC4ErrorSquared,0.5));
10183   } else
10184     {
10185      fIntFlowQcumulants->SetBinError(2,0.);
10186      cout<<endl;
10187      cout<<" WARNING (QC): Statistical error of generalized QC{4} is imaginary !!!!"<<endl;
10188      cout<<endl;
10189     }   
10190  } // end of if(fApplyCorrectionForNUA && fPropagateErrorAlsoFromNIT)
10191  // Quantify detector bias to QC{4}:
10192  if(TMath::Abs(QC4)>0.)
10193  {
10194   fIntFlowDetectorBias->SetBinContent(2,gQC4/QC4); 
10195   if(QC4Error>0.)
10196   {
10197    Double_t errorSquared = gQC4ErrorSquared/pow(QC4,2.)+pow(gQC4,2.)*pow(QC4Error,2.)/pow(QC4,4.);
10198    if(errorSquared>0.)
10199    {
10200     fIntFlowDetectorBias->SetBinError(2,pow(errorSquared,0.5));  
10201    }
10202   }
10203  } // end of if(TMath::Abs(QC4)>0.)
10204
10205
10206  // .... to be improved (continued for 6th and 8th order) ....            
10207  
10208      
10209  // versus multiplicity:
10210  if(fCalculateCumulantsVsM) // to be improved - propagate error for nua terms vs M
10211  { 
10212   Int_t nBins = fIntFlowCorrelationsVsMPro[0]->GetNbinsX(); // to be improved (hardwired 0) 
10213   Double_t value[4] = {0.}; // QCs vs M
10214   Double_t error[4] = {0.}; // error of QCs vs M
10215   Double_t dSum1[4] = {0.}; // sum value_i/(error_i)^2
10216   Double_t dSum2[4] = {0.}; // sum 1/(error_i)^2
10217   for(Int_t b=1;b<=nBins;b++)
10218   {
10219    // Measured correlations:
10220    two = fIntFlowCorrelationsVsMHist[0]->GetBinContent(b); // <<2>> vs M
10221    four = fIntFlowCorrelationsVsMHist[1]->GetBinContent(b); // <<4>> vs M
10222    // Isotropic cumulants:
10223    QC2 = two;
10224    QC4 = four-2.*pow(two,2.);
10225    // Non-isotropic terms:
10226    c1 = fIntFlowCorrectionTermsForNUAVsMPro[1][0]->GetBinContent(b); // <<cos(n*phi1)>>
10227    c2 = fIntFlowCorrectionTermsForNUAVsMPro[1][1]->GetBinContent(b); // <<cos(n*(phi1+phi2))>>
10228    c3 = fIntFlowCorrectionTermsForNUAVsMPro[1][2]->GetBinContent(b); // <<cos(n*(phi1-phi2-phi3))>>
10229    s1 = fIntFlowCorrectionTermsForNUAVsMPro[0][0]->GetBinContent(b); // <<sin(n*phi1)>>
10230    s2 = fIntFlowCorrectionTermsForNUAVsMPro[0][1]->GetBinContent(b); // <<sin(n*(phi1+phi2))>>
10231    s3 = fIntFlowCorrectionTermsForNUAVsMPro[0][2]->GetBinContent(b); // <<sin(n*(phi1-phi2-phi3))>>
10232    // Generalized QC{2} vs M:
10233    gQC2 = two - pow(c1,2.) - pow(s1,2.); 
10234    if(fApplyCorrectionForNUAVsM){fIntFlowQcumulantsVsM[0]->SetBinContent(b,gQC2);}   
10235    // Generalized QC{4} vs M:  
10236    gQC4 = four-2.*pow(two,2.)
10237                  - 4.*c1*c3+4.*s1*s3-pow(c2,2.)-pow(s2,2.)
10238                  + 4.*c2*(pow(c1,2.)-pow(s1,2.))+8.*s2*s1*c1
10239                  + 8.*two*(pow(c1,2.)+pow(s1,2.))-6.*pow((pow(c1,2.)+pow(s1,2.)),2.);
10240    if(fApplyCorrectionForNUAVsM){fIntFlowQcumulantsVsM[1]->SetBinContent(b,gQC4);}   
10241    // Detector bias vs M:
10242    if(TMath::Abs(QC2)>0.)
10243    {
10244     fIntFlowDetectorBiasVsM[0]->SetBinContent(b,gQC2/QC2); 
10245    } // end of if(TMath::Abs(QC2)>0.)
10246    if(TMath::Abs(QC4)>0.)
10247    {
10248     fIntFlowDetectorBiasVsM[1]->SetBinContent(b,gQC4/QC4); 
10249    } // end of if(TMath::Abs(QC4)>0.)  
10250    // Rebin in M:
10251    for(Int_t co=0;co<4;co++)
10252    {
10253     value[co] = fIntFlowQcumulantsVsM[co]->GetBinContent(b);
10254     error[co] = fIntFlowQcumulantsVsM[co]->GetBinError(b);
10255     if(error[co]>0.)
10256     {
10257      dSum1[co]+=value[co]/(error[co]*error[co]);
10258      dSum2[co]+=1./(error[co]*error[co]);
10259     }
10260    } // end of for(Int_t co=0;co<4;co++) 
10261   } // end of for(Int_t b=1;b<=nBins;b++)
10262   // Store rebinned Q-cumulants:
10263   if(fApplyCorrectionForNUAVsM)
10264   {
10265    for(Int_t co=0;co<4;co++)
10266    {
10267     if(dSum2[co]>0.)
10268     {
10269      fIntFlowQcumulantsRebinnedInM->SetBinContent(co+1,dSum1[co]/dSum2[co]);
10270      fIntFlowQcumulantsRebinnedInM->SetBinError(co+1,pow(1./dSum2[co],0.5));
10271     }
10272    } // end of for(Int_t co=0;co<4;co++)
10273   } // end of if(fApplyCorrectionForNUAVsM)
10274  } // end of if(fCalculateCumulantsVsM) 
10275      
10276 } // end of void AliFlowAnalysisWithQCumulants::CalculateQcumulantsCorrectedForNUAIntFlow()
10277  
10278 //================================================================================================================================
10279
10280 void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUAIntFlow() 
10281 {
10282  // From profile fIntFlowCorrectionTermsForNUAPro[sc] access measured correction terms for NUA
10283  // and their spread, correctly calculate the statistical errors and store the final 
10284  // results and statistical errors for correction terms for NUA in histogram fIntFlowCorrectionTermsForNUAHist[sc].
10285  //
10286  // Remark: Statistical error of correction temrs is calculated as:
10287  //
10288  //          statistical error = termA * spread * termB:
10289  //          termA = sqrt{sum_{i=1}^{N} w^2}/(sum_{i=1}^{N} w)
10290  //          termB = 1/sqrt(1-termA^2)   
10291  
10292  TString sinCosFlag[2] = {"sin","cos"}; // to be improved - promore this to data member?
10293  TString nonisotropicTermFlag[4] = {"(n(phi1))","(n(phi1+phi2))","(n(phi1-phi2-phi3))","(n(2phi1-phi2))"}; // to be improved - hardwired 4
10294     
10295  for(Int_t sc=0;sc<2;sc++) // sin or cos correction terms 
10296  {
10297   for(Int_t ci=1;ci<=4;ci++) // correction term index (to be improved - hardwired 4)
10298   {
10299    Double_t correction = fIntFlowCorrectionTermsForNUAPro[sc]->GetBinContent(ci);
10300    Double_t spread = fIntFlowCorrectionTermsForNUAPro[sc]->GetBinError(ci);
10301    Double_t sumOfLinearEventWeights = fIntFlowSumOfEventWeightsNUA[sc][0]->GetBinContent(ci);
10302    Double_t sumOfQuadraticEventWeights = fIntFlowSumOfEventWeightsNUA[sc][1]->GetBinContent(ci);
10303    Double_t termA = 0.;
10304    Double_t termB = 0.;
10305    if(TMath::Abs(sumOfLinearEventWeights)>1.e-44)
10306    {
10307     termA = pow(sumOfQuadraticEventWeights,0.5)/sumOfLinearEventWeights;
10308    } else
10309      {
10310       cout<<" WARNING (QC): sumOfLinearEventWeights == 0 in AFAWQC::FCTFNIF() !!!!"<<endl;
10311       cout<<Form("               (for <<%s[%s]>> non-isotropic term)",sinCosFlag[sc].Data(),nonisotropicTermFlag[ci-1].Data())<<endl;
10312      }
10313    if(1.-pow(termA,2.) > 0.)
10314    {
10315     termB = 1./pow(1-pow(termA,2.),0.5);
10316    } else
10317      {
10318       cout<<" WARNING (QC): 1.-pow(termA,2.) <= 0 in AFAWQC::FCTFNIF() !!!!"<<endl;   
10319       cout<<Form("               (for <<%s[%s]>> non-isotropic term)",sinCosFlag[sc].Data(),nonisotropicTermFlag[ci-1].Data())<<endl;
10320      }     
10321    Double_t statisticalError = termA * spread * termB;
10322    fIntFlowCorrectionTermsForNUAHist[sc]->SetBinContent(ci,correction);
10323    fIntFlowCorrectionTermsForNUAHist[sc]->SetBinError(ci,statisticalError);
10324   } // end of for(Int_t ci=1;ci<=4;ci++) // correction term index
10325  } // end of for(Int sc=0;sc<2;sc++) // sin or cos correction terms 
10326                                                                                                                                                                                                
10327 } // end of void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUAIntFlow()
10328
10329 //================================================================================================================================
10330
10331 void AliFlowAnalysisWithQCumulants::GetPointersForNestedLoopsHistograms()
10332 {
10333  // Get pointers to all objects relevant for calculations with nested loops.
10334    
10335  TList *nestedLoopsList = dynamic_cast<TList*>(fHistList->FindObject("Nested Loops"));
10336  if(nestedLoopsList) 
10337  {
10338   this->SetNestedLoopsList(nestedLoopsList);
10339  } else
10340    {
10341     cout<<"WARNING: nestedLoopsList is NULL in AFAWQC::GPFNLH() !!!!"<<endl;
10342     exit(0);
10343    }
10344     
10345   TString sinCosFlag[2] = {"sin","cos"}; // to be improved (should I promote this to data members?)
10346   TString typeFlag[2] = {"RP","POI"}; // to be improved (should I promote this to data members?)
10347   TString ptEtaFlag[2] = {"p_{T}","#eta"}; // to be improved (should I promote this to data members?)
10348   TString reducedCorrelationIndex[4] = {"<2'>","<4'>","<6'>","<8'>"}; // to be improved (should I promote this to data members?)
10349    
10350   TString evaluateNestedLoopsName = "fEvaluateNestedLoops";
10351   evaluateNestedLoopsName += fAnalysisLabel->Data();  
10352   TProfile *evaluateNestedLoops = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(evaluateNestedLoopsName.Data()));
10353   Bool_t bEvaluateIntFlowNestedLoops = kFALSE;
10354   Bool_t bEvaluateDiffFlowNestedLoops = kFALSE;
10355   if(evaluateNestedLoops)
10356   {
10357    this->SetEvaluateNestedLoops(evaluateNestedLoops);
10358    bEvaluateIntFlowNestedLoops = (Int_t)evaluateNestedLoops->GetBinContent(1);
10359    bEvaluateDiffFlowNestedLoops = (Int_t)evaluateNestedLoops->GetBinContent(2);
10360   }
10361   // nested loops relevant for integrated flow:  
10362   if(bEvaluateIntFlowNestedLoops)
10363   {
10364    // correlations:
10365    TString intFlowDirectCorrelationsName = "fIntFlowDirectCorrelations";
10366    intFlowDirectCorrelationsName += fAnalysisLabel->Data();
10367    TProfile *intFlowDirectCorrelations = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(intFlowDirectCorrelationsName.Data()));
10368    if(intFlowDirectCorrelations) 
10369    { 
10370     this->SetIntFlowDirectCorrelations(intFlowDirectCorrelations);
10371    } else
10372      {
10373       cout<<"WARNING: intFlowDirectCorrelations is NULL in AFAWQC::GPFNLH() !!!!"<<endl;
10374       exit(0);
10375      }
10376    if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)  
10377    {
10378     TString intFlowExtraDirectCorrelationsName = "fIntFlowExtraDirectCorrelations";
10379     intFlowExtraDirectCorrelationsName += fAnalysisLabel->Data();
10380     TProfile *intFlowExtraDirectCorrelations = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(intFlowExtraDirectCorrelationsName.Data()));
10381     if(intFlowExtraDirectCorrelations) 
10382     { 
10383      this->SetIntFlowExtraDirectCorrelations(intFlowExtraDirectCorrelations);
10384     } else
10385       {
10386        cout<<"WARNING: intFlowExtraDirectCorrelations is NULL in AFAWQC::GPFNLH() !!!!"<<endl;
10387        exit(0);
10388       }       
10389    } // end of if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)  
10390    // correction terms for non-uniform acceptance:
10391    TString intFlowDirectCorrectionTermsForNUAName = "fIntFlowDirectCorrectionTermsForNUA";
10392    intFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();
10393    TProfile *intFlowDirectCorrectionTermsForNUA[2] = {NULL};
10394    for(Int_t sc=0;sc<2;sc++) // sin or cos terms
10395    {
10396     intFlowDirectCorrectionTermsForNUA[sc] = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(Form("%s: %s terms",intFlowDirectCorrectionTermsForNUAName.Data(),sinCosFlag[sc].Data())));
10397     if(intFlowDirectCorrectionTermsForNUA[sc]) 
10398     { 
10399      this->SetIntFlowDirectCorrectionTermsForNUA(intFlowDirectCorrectionTermsForNUA[sc],sc);
10400     } else
10401       {
10402        cout<<"WARNING: intFlowDirectCorrectionTermsForNUA[sc] is NULL in AFAWQC::GPFNLH() !!!!"<<endl;
10403        cout<<"sc = "<<sc<<endl;
10404        exit(0);
10405       }
10406    } // end of for(Int_t sc=0;sc<2;sc++) 
10407   } // end of if(bEvaluateIntFlowNestedLoops)
10408     
10409   // nested loops relevant for differential flow:  
10410   if(bEvaluateDiffFlowNestedLoops)
10411   {
10412    // correlations:
10413    TString diffFlowDirectCorrelationsName = "fDiffFlowDirectCorrelations";
10414    diffFlowDirectCorrelationsName += fAnalysisLabel->Data();
10415    TProfile *diffFlowDirectCorrelations[2][2][4] = {{{NULL}}};
10416    for(Int_t t=0;t<2;t++)
10417    {
10418     for(Int_t pe=0;pe<2;pe++)
10419     {
10420      for(Int_t ci=0;ci<4;ci++) // correlation index
10421      {
10422       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())));
10423       if(diffFlowDirectCorrelations[t][pe][ci])
10424       {
10425        this->SetDiffFlowDirectCorrelations(diffFlowDirectCorrelations[t][pe][ci],t,pe,ci);
10426       } else
10427         {
10428          cout<<"WARNING: diffFlowDirectCorrelations[t][pe][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
10429          cout<<"t  = "<<t<<endl;
10430          cout<<"pe = "<<pe<<endl;   
10431          cout<<"ci = "<<ci<<endl;
10432         }     
10433      } // end of for(Int_t ci=0;ci<4;ci++) // correlation index  
10434     } // end of for(Int_t pe=0;pe<2;pe++)
10435    } // end of for(Int_t t=0;t<2;t++)   
10436    // correction terms for non-uniform acceptance:
10437    TString diffFlowDirectCorrectionTermsForNUAName = "fDiffFlowDirectCorrectionTermsForNUA";
10438    diffFlowDirectCorrectionTermsForNUAName += fAnalysisLabel->Data();  
10439    TProfile *diffFlowDirectCorrectionTermsForNUA[2][2][2][10] = {{{{NULL}}}};   
10440    for(Int_t t=0;t<2;t++)
10441    {
10442     for(Int_t pe=0;pe<2;pe++)
10443     {
10444      // correction terms for NUA:
10445      for(Int_t sc=0;sc<2;sc++) // sin or cos
10446      {
10447       for(Int_t cti=0;cti<9;cti++) // correction term index
10448       {
10449        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)));
10450        if(diffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti])
10451        {
10452         this->SetDiffFlowDirectCorrectionTermsForNUA(diffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti],t,pe,sc,cti);
10453        } else
10454          {
10455           cout<<"WARNING: diffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
10456           cout<<"t   = "<<t<<endl;
10457           cout<<"pe  = "<<pe<<endl;   
10458           cout<<"sc  = "<<sc<<endl;
10459           cout<<"cti = "<<cti<<endl;
10460          }    
10461       } // end of for(Int_t cti=0;cti<9;cti++) // correction term index
10462      } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos
10463     } // end of for(Int_t pe=0;pe<2;pe++)
10464    } // end of for(Int_t t=0;t<2;t++)
10465    // other differential correlators:
10466    TString otherDirectDiffCorrelatorsName = "fOtherDirectDiffCorrelators";
10467    otherDirectDiffCorrelatorsName += fAnalysisLabel->Data();  
10468    TProfile *otherDirectDiffCorrelators[2][2][2][1] = {{{{NULL}}}};   
10469    for(Int_t t=0;t<2;t++)
10470    {
10471     for(Int_t pe=0;pe<2;pe++)
10472     {
10473      // correction terms for NUA:
10474      for(Int_t sc=0;sc<2;sc++) // sin or cos
10475      {
10476       for(Int_t ci=0;ci<1;ci++) // correlator index
10477       {
10478        otherDirectDiffCorrelators[t][pe][sc][ci] = dynamic_cast<TProfile*>(nestedLoopsList->FindObject(Form("%s, %s, %s, %s, ci = %d",otherDirectDiffCorrelatorsName.Data(),typeFlag[t].Data(),ptEtaFlag[pe].Data(),sinCosFlag[sc].Data(),ci+1)));
10479        if(otherDirectDiffCorrelators[t][pe][sc][ci])
10480        {
10481         this->SetOtherDirectDiffCorrelators(otherDirectDiffCorrelators[t][pe][sc][ci],t,pe,sc,ci);
10482        } else
10483          {
10484           cout<<"WARNING: otherDirectDiffCorrelators[t][pe][sc][ci] is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
10485           cout<<"t   = "<<t<<endl;
10486           cout<<"pe  = "<<pe<<endl;   
10487           cout<<"sc  = "<<sc<<endl;
10488           cout<<"ci = "<<ci<<endl;
10489          }    
10490       } // end of for(Int_t ci=0;ci<9;ci++) // correction term index
10491      } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos
10492     } // end of for(Int_t pe=0;pe<2;pe++)
10493    } // end of for(Int_t t=0;t<2;t++)
10494    // number of RPs and POIs in selected pt and eta bins for cross-checkings:
10495    TString noOfParticlesInBinName = "fNoOfParticlesInBin";
10496    TH1D *noOfParticlesInBin = NULL;
10497    noOfParticlesInBin = dynamic_cast<TH1D*>(nestedLoopsList->FindObject(noOfParticlesInBinName.Data()));
10498    if(noOfParticlesInBin)
10499    {
10500     this->SetNoOfParticlesInBin(noOfParticlesInBin);
10501    } else
10502      {
10503       cout<<endl;
10504       cout<<" WARNING (QC): noOfParticlesInBin is NULL in AFAWQC::GPFDFH() !!!!"<<endl;
10505       cout<<endl;
10506      }
10507   } // end of if(bEvaluateDiffFlowNestedLoops)
10508
10509 } // end of void AliFlowAnalysisWithQCumulants::GetPointersForNestedLoopsHistograms()
10510
10511 //================================================================================================================================
10512
10513 void AliFlowAnalysisWithQCumulants::StoreHarmonic()
10514 {
10515  // Store flow harmonic in common control histograms.
10516
10517  (fCommonHists->GetHarmonic())->Fill(0.5,fHarmonic);
10518  if(fFillMultipleControlHistograms)
10519  {
10520   (fCommonHists2nd->GetHarmonic())->Fill(0.5,fHarmonic);
10521   (fCommonHists4th->GetHarmonic())->Fill(0.5,fHarmonic);
10522   (fCommonHists6th->GetHarmonic())->Fill(0.5,fHarmonic);
10523   (fCommonHists8th->GetHarmonic())->Fill(0.5,fHarmonic);
10524  }
10525  
10526 } // end of void AliFlowAnalysisWithQCumulants::StoreHarmonic()
10527
10528 //================================================================================================================================
10529
10530 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelationsUsingParticleWeights(TString type, TString ptOrEta) // type = RP or POI 
10531 {
10532  // Calculate all correlations needed for differential flow using particle weights.
10533  
10534  Int_t t = 0; // type flag 
10535  Int_t pe = 0; // ptEta flag
10536  
10537  if(type == "RP")
10538  {
10539   t = 0;
10540  } else if(type == "POI")
10541    {
10542     t = 1;
10543    }
10544
10545  if(ptOrEta == "Pt")
10546  {
10547   pe = 0;
10548  } else if(ptOrEta == "Eta")
10549    {
10550     pe = 1;
10551    }
10552     
10553  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
10554  Double_t minPtEta[2] = {fPtMin,fEtaMin};
10555  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
10556  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
10557
10558  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
10559  Double_t dReQ1n1k = (*fReQ)(0,1);
10560  Double_t dReQ2n2k = (*fReQ)(1,2);
10561  Double_t dReQ1n3k = (*fReQ)(0,3);
10562  //Double_t dReQ4n4k = (*fReQ)(3,4);
10563  Double_t dImQ1n1k = (*fImQ)(0,1);
10564  Double_t dImQ2n2k = (*fImQ)(1,2);
10565  Double_t dImQ1n3k = (*fImQ)(0,3);
10566  //Double_t dImQ4n4k = (*fImQ)(3,4);
10567  
10568  // S^M_{p,k} (see .h file for the definition of fSpk):
10569  Double_t dSM1p1k = (*fSpk)(0,1);
10570  Double_t dSM1p2k = (*fSpk)(0,2);
10571  Double_t dSM1p3k = (*fSpk)(0,3);
10572  Double_t dSM2p1k = (*fSpk)(1,1);
10573  Double_t dSM3p1k = (*fSpk)(2,1);
10574  
10575  // looping over all bins and calculating reduced correlations: 
10576  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
10577  {
10578   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular (pt,eta) bin):  
10579   Double_t p1n0kRe = 0.;
10580   Double_t p1n0kIm = 0.;
10581
10582   // number of POIs in particular (pt,eta) bin):
10583   Double_t mp = 0.;
10584
10585   // real and imaginary parts of q_{m*n,k}: 
10586   // (weighted Q-vector evaluated for particles which are both RPs and POIs in particular (pt,eta) bin)
10587   Double_t q1n2kRe = 0.;
10588   Double_t q1n2kIm = 0.;
10589   Double_t q2n1kRe = 0.;
10590   Double_t q2n1kIm = 0.;
10591
10592   // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  
10593   Double_t s1p1k = 0.; 
10594   Double_t s1p2k = 0.; 
10595   Double_t s1p3k = 0.; 
10596    
10597   // M0111 from Eq. (118) in QC2c (to be improved (notation))
10598   Double_t dM0111 = 0.;
10599  
10600   if(type == "POI")
10601   {
10602    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))
10603            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));
10604    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  
10605            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));
10606             
10607    mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
10608     
10609    t = 1; // typeFlag = RP or POI
10610     
10611    // q_{m*n,k}: (Remark: m=1 is 0, k=0 iz zero (to be improved!)) 
10612    q1n2kRe = fReRPQ1dEBE[2][pe][0][2]->GetBinContent(fReRPQ1dEBE[2][pe][0][2]->GetBin(b))
10613            * fReRPQ1dEBE[2][pe][0][2]->GetBinEntries(fReRPQ1dEBE[2][pe][0][2]->GetBin(b));
10614    q1n2kIm = fImRPQ1dEBE[2][pe][0][2]->GetBinContent(fImRPQ1dEBE[2][pe][0][2]->GetBin(b))
10615            * fImRPQ1dEBE[2][pe][0][2]->GetBinEntries(fImRPQ1dEBE[2][pe][0][2]->GetBin(b));
10616    q2n1kRe = fReRPQ1dEBE[2][pe][1][1]->GetBinContent(fReRPQ1dEBE[2][pe][1][1]->GetBin(b))
10617            * fReRPQ1dEBE[2][pe][1][1]->GetBinEntries(fReRPQ1dEBE[2][pe][1][1]->GetBin(b));
10618    q2n1kIm = fImRPQ1dEBE[2][pe][1][1]->GetBinContent(fImRPQ1dEBE[2][pe][1][1]->GetBin(b))
10619            * fImRPQ1dEBE[2][pe][1][1]->GetBinEntries(fImRPQ1dEBE[2][pe][1][1]->GetBin(b));
10620        
10621    // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  
10622    s1p1k = pow(fs1dEBE[2][pe][1]->GetBinContent(b)*fs1dEBE[2][pe][1]->GetBinEntries(b),1.); 
10623    s1p2k = pow(fs1dEBE[2][pe][2]->GetBinContent(b)*fs1dEBE[2][pe][2]->GetBinEntries(b),1.); 
10624    s1p3k = pow(fs1dEBE[2][pe][3]->GetBinContent(b)*fs1dEBE[2][pe][3]->GetBinEntries(b),1.); 
10625      
10626    // M0111 from Eq. (118) in QC2c (to be improved (notation)):
10627    dM0111 = mp*(dSM3p1k-3.*dSM1p1k*dSM1p2k+2.*dSM1p3k)
10628           - 3.*(s1p1k*(dSM2p1k-dSM1p2k)
10629           + 2.*(s1p3k-s1p2k*dSM1p1k));
10630   }
10631    else if(type == "RP")
10632    {
10633     // q_{m*n,k}: (Remark: m=1 is 0, k=0 iz zero (to be improved!)) 
10634     q1n2kRe = fReRPQ1dEBE[0][pe][0][2]->GetBinContent(fReRPQ1dEBE[0][pe][0][2]->GetBin(b))
10635             * fReRPQ1dEBE[0][pe][0][2]->GetBinEntries(fReRPQ1dEBE[0][pe][0][2]->GetBin(b));
10636     q1n2kIm = fImRPQ1dEBE[0][pe][0][2]->GetBinContent(fImRPQ1dEBE[0][pe][0][2]->GetBin(b))
10637             * fImRPQ1dEBE[0][pe][0][2]->GetBinEntries(fImRPQ1dEBE[0][pe][0][2]->GetBin(b));
10638     q2n1kRe = fReRPQ1dEBE[0][pe][1][1]->GetBinContent(fReRPQ1dEBE[0][pe][1][1]->GetBin(b))
10639             * fReRPQ1dEBE[0][pe][1][1]->GetBinEntries(fReRPQ1dEBE[0][pe][1][1]->GetBin(b));
10640     q2n1kIm = fImRPQ1dEBE[0][pe][1][1]->GetBinContent(fImRPQ1dEBE[0][pe][1][1]->GetBin(b))
10641             * fImRPQ1dEBE[0][pe][1][1]->GetBinEntries(fImRPQ1dEBE[0][pe][1][1]->GetBin(b));
10642
10643     // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  
10644     s1p1k = pow(fs1dEBE[0][pe][1]->GetBinContent(b)*fs1dEBE[0][pe][1]->GetBinEntries(b),1.); 
10645     s1p2k = pow(fs1dEBE[0][pe][2]->GetBinContent(b)*fs1dEBE[0][pe][2]->GetBinEntries(b),1.); 
10646     s1p3k = pow(fs1dEBE[0][pe][3]->GetBinContent(b)*fs1dEBE[0][pe][3]->GetBinEntries(b),1.); 
10647     
10648     // to be improved (cross-checked):
10649     p1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))
10650             * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));
10651     p1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))  
10652             * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));
10653             
10654     mp = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
10655      
10656     t = 0; // typeFlag = RP or POI
10657     
10658     // M0111 from Eq. (118) in QC2c (to be improved (notation)):
10659     dM0111 = mp*(dSM3p1k-3.*dSM1p1k*dSM1p2k+2.*dSM1p3k)
10660            - 3.*(s1p1k*(dSM2p1k-dSM1p2k)
10661            + 2.*(s1p3k-s1p2k*dSM1p1k));
10662     //...............................................................................................   
10663    }
10664    
10665    // 2'-particle correlation:
10666    Double_t two1n1nW0W1 = 0.;
10667    if(mp*dSM1p1k-s1p1k)
10668    {
10669     two1n1nW0W1 = (p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k-s1p1k)
10670                 / (mp*dSM1p1k-s1p1k);
10671    
10672     // fill profile to get <<2'>>     
10673     fDiffFlowCorrelationsPro[t][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nW0W1,mp*dSM1p1k-s1p1k);    
10674     // fill profile to get <<2'>^2>     
10675     fDiffFlowSquaredCorrelationsPro[t][pe][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],two1n1nW0W1*two1n1nW0W1,mp*dSM1p1k-s1p1k);        
10676     // histogram to store <2'> e-b-e (needed in some other methods):
10677     fDiffFlowCorrelationsEBE[t][pe][0]->SetBinContent(b,two1n1nW0W1);      
10678     fDiffFlowEventWeightsForCorrelationsEBE[t][pe][0]->SetBinContent(b,mp*dSM1p1k-s1p1k);      
10679    } // end of if(mp*dSM1p1k-s1p1k)
10680    
10681    // 4'-particle correlation:
10682    Double_t four1n1n1n1nW0W1W1W1 = 0.;
10683    if(dM0111)
10684    {
10685     four1n1n1n1nW0W1W1W1 = ((pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.))*(p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k)
10686                          - q2n1kRe*(pow(dReQ1n1k,2.)-pow(dImQ1n1k,2.))
10687                          - 2.*q2n1kIm*dReQ1n1k*dImQ1n1k
10688                          - p1n0kRe*(dReQ1n1k*dReQ2n2k+dImQ1n1k*dImQ2n2k)
10689                          + p1n0kIm*(dImQ1n1k*dReQ2n2k-dReQ1n1k*dImQ2n2k)
10690                          - 2.*dSM1p2k*(p1n0kRe*dReQ1n1k+p1n0kIm*dImQ1n1k)
10691                          - 2.*(pow(dReQ1n1k,2.)+pow(dImQ1n1k,2.))*s1p1k                                            
10692                          + 6.*(q1n2kRe*dReQ1n1k+q1n2kIm*dImQ1n1k)                                           
10693                          + 1.*(q2n1kRe*dReQ2n2k+q2n1kIm*dImQ2n2k)                         
10694                          + 2.*(p1n0kRe*dReQ1n3k+p1n0kIm*dImQ1n3k)                      
10695                          + 2.*s1p1k*dSM1p2k                                      
10696                          - 6.*s1p3k)        
10697                          / dM0111; // to be improved (notation of dM0111)
10698    
10699     // fill profile to get <<4'>>     
10700     fDiffFlowCorrelationsPro[t][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nW0W1W1W1,dM0111);    
10701     // fill profile to get <<4'>^2>     
10702     fDiffFlowSquaredCorrelationsPro[t][pe][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],four1n1n1n1nW0W1W1W1*four1n1n1n1nW0W1W1W1,dM0111);        
10703     // histogram to store <4'> e-b-e (needed in some other methods):
10704     fDiffFlowCorrelationsEBE[t][pe][1]->SetBinContent(b,four1n1n1n1nW0W1W1W1);      
10705     fDiffFlowEventWeightsForCorrelationsEBE[t][pe][1]->SetBinContent(b,dM0111);      
10706    } // end of if(dM0111)
10707  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
10708
10709 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrelationsUsingParticleWeights(TString type, TString ptOrEta); // type = RP or POI 
10710
10711 //================================================================================================================================
10712
10713 void AliFlowAnalysisWithQCumulants::FillCommonControlHistograms(AliFlowEventSimple *anEvent)
10714 {
10715  // Fill common control histograms.
10716  
10717  Int_t nRP = anEvent->GetEventNSelTracksRP(); // number of RPs (i.e. number of particles used to determine the reaction plane)
10718  fCommonHists->FillControlHistograms(anEvent); 
10719  if(fFillMultipleControlHistograms)
10720  {
10721   if(nRP>1)
10722   {
10723    fCommonHists2nd->FillControlHistograms(anEvent);                                        
10724    if(nRP>3)
10725    {
10726     fCommonHists4th->FillControlHistograms(anEvent);                                        
10727     if(nRP>5)
10728     {
10729      fCommonHists6th->FillControlHistograms(anEvent);                                        
10730      if(nRP>7)
10731      {
10732       fCommonHists8th->FillControlHistograms(anEvent);                                        
10733      } // end of if(nRP>7)  
10734     } // end of if(nRP>5) 
10735    } // end of if(nRP>3)                                                                                                                      
10736   } // end of if(nRP>1) 
10737  } // end of if(fFillMultipleControlHistograms)
10738  
10739 } // end of void AliFlowAnalysisWithQCumulants::FillCommonControlHistograms(AliFlowEventSimple *anEvent)
10740
10741 //================================================================================================================================
10742
10743 void AliFlowAnalysisWithQCumulants::ResetEventByEventQuantities()
10744 {
10745  // Reset all event by event quantities.
10746  
10747  // Reference flow:
10748  fReQ->Zero();
10749  fImQ->Zero();
10750  fSpk->Zero();
10751  fIntFlowCorrelationsEBE->Reset();
10752  fIntFlowEventWeightsForCorrelationsEBE->Reset();
10753  fIntFlowCorrelationsAllEBE->Reset();
10754  
10755  for(Int_t sc=0;sc<2;sc++)
10756  {
10757   fIntFlowCorrectionTermsForNUAEBE[sc]->Reset();
10758   fIntFlowEventWeightForCorrectionTermsForNUAEBE[sc]->Reset(); 
10759  }
10760     
10761  // Differential flow:
10762  if(fCalculateDiffFlow)
10763  {
10764   for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)
10765   {
10766    for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // 1D in pt or eta
10767    {
10768     for(Int_t m=0;m<4;m++) // multiple of harmonic
10769     {
10770      for(Int_t k=0;k<9;k++) // power of weight
10771      {
10772       if(fReRPQ1dEBE[t][pe][m][k]) fReRPQ1dEBE[t][pe][m][k]->Reset();
10773       if(fImRPQ1dEBE[t][pe][m][k]) fImRPQ1dEBE[t][pe][m][k]->Reset();
10774      }   
10775     } 
10776    }
10777   } 
10778   for(Int_t t=0;t<3;t++) // type (0 = RP, 1 = POI, 2 = RP&&POI )
10779   { 
10780    for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // 1D in pt or eta
10781    {
10782     for(Int_t k=0;k<9;k++)
10783     {
10784      if(fs1dEBE[t][pe][k]) fs1dEBE[t][pe][k]->Reset();
10785     }
10786    }
10787   }
10788   // e-b-e reduced correlations:
10789   for(Int_t t=0;t<2;t++) // type (0 = RP, 1 = POI)
10790   {  
10791    for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
10792    {
10793     for(Int_t rci=0;rci<4;rci++) // reduced correlation index
10794     {
10795      if(fDiffFlowCorrelationsEBE[t][pe][rci]) fDiffFlowCorrelationsEBE[t][pe][rci]->Reset();
10796      if(fDiffFlowEventWeightsForCorrelationsEBE[t][pe][rci]) fDiffFlowEventWeightsForCorrelationsEBE[t][pe][rci]->Reset();
10797     }
10798    }
10799   }  
10800   // correction terms for NUA:
10801   for(Int_t t=0;t<2;t++) // type (0 = RP, 1 = POI)
10802   {  
10803    for(Int_t pe=0;pe<1+(Int_t)fCalculateDiffFlowVsEta;pe++) // pt or eta
10804    {
10805     for(Int_t sc=0;sc<2;sc++) // sin or cos
10806     {
10807      for(Int_t cti=0;cti<9;cti++) // correction term index
10808      {
10809      fDiffFlowCorrectionTermsForNUAEBE[t][pe][sc][cti]->Reset();  
10810      }
10811     }
10812    }      
10813   }
10814  } // end of if(fCalculateDiffFlow)   
10815
10816  // 2D (pt,eta)
10817  if(fCalculate2DDiffFlow)
10818  {
10819   for(Int_t t=0;t<3;t++) // type (RP, POI, POI&&RP)
10820   {
10821    for(Int_t m=0;m<4;m++) // multiple of harmonic
10822    {
10823     for(Int_t k=0;k<9;k++) // power of weight
10824     {
10825      if(fReRPQ2dEBE[t][m][k]){fReRPQ2dEBE[t][m][k]->Reset();}
10826      if(fImRPQ2dEBE[t][m][k]){fImRPQ2dEBE[t][m][k]->Reset();}
10827     }   
10828    }
10829   }
10830   for(Int_t t=0;t<3;t++) // type (0 = RP, 1 = POI, 2 = RP&&POI )
10831   { 
10832    for(Int_t k=0;k<9;k++)
10833    {
10834     if(fs2dEBE[t][k]){fs2dEBE[t][k]->Reset();}
10835    }
10836   }  
10837  } // end of if(fCalculate2DDiffFlow) 
10838
10839 } // end of void AliFlowAnalysisWithQCumulants::ResetEventByEventQuantities();
10840
10841 //================================================================================================================================
10842
10843 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUASinTerms(TString type, TString ptOrEta)
10844 {
10845  // Calculate correction terms for non-uniform acceptance for differential flow (sin terms).
10846  
10847  // Results are stored in fDiffFlowCorrectionTermsForNUAPro[t][pe][0][cti], where cti runs as follows:
10848  //  0: <<sin n(psi1)>>
10849  //  1: <<sin n(psi1+phi2)>>
10850  //  2: <<sin n(psi1+phi2-phi3)>>
10851  //  3: <<sin n(psi1-phi2-phi3)>>:
10852  //  4:
10853  //  5:
10854  //  6:
10855  
10856  // multiplicity:
10857  Double_t dMult = (*fSpk)(0,0);
10858  
10859  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
10860  Double_t dReQ1n = (*fReQ)(0,0);
10861  Double_t dReQ2n = (*fReQ)(1,0);
10862  //Double_t dReQ3n = (*fReQ)(2,0);
10863  //Double_t dReQ4n = (*fReQ)(3,0);
10864  Double_t dImQ1n = (*fImQ)(0,0);
10865  Double_t dImQ2n = (*fImQ)(1,0);
10866  //Double_t dImQ3n = (*fImQ)(2,0);
10867  //Double_t dImQ4n = (*fImQ)(3,0);
10868
10869  Int_t t = 0; // type flag 
10870  Int_t pe = 0; // ptEta flag
10871  
10872  if(type == "RP")
10873  {
10874   t = 0;
10875  } else if(type == "POI")
10876    {
10877     t = 1;
10878    }
10879
10880  if(ptOrEta == "Pt")
10881  {
10882   pe = 0;
10883  } else if(ptOrEta == "Eta")
10884    {
10885     pe = 1;
10886    }
10887     
10888  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
10889  Double_t minPtEta[2] = {fPtMin,fEtaMin};
10890  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
10891  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
10892
10893  // looping over all bins and calculating correction terms: 
10894  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
10895  {
10896   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): 
10897   Double_t p1n0kRe = 0.;
10898   Double_t p1n0kIm = 0.;
10899
10900   // number of POIs in particular pt or eta bin:
10901   Double_t mp = 0.;
10902
10903   // 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):
10904   Double_t q1n0kRe = 0.;
10905   Double_t q1n0kIm = 0.;
10906   Double_t q2n0kRe = 0.;
10907   Double_t q2n0kIm = 0.;
10908
10909   // number of particles which are both RPs and POIs in particular pt or eta bin:
10910   Double_t mq = 0.;
10911    
10912   if(type == "POI")
10913   {
10914    // q_{m*n,0}:
10915    q1n0kRe = fReRPQ1dEBE[2][pe][0][0]->GetBinContent(fReRPQ1dEBE[2][pe][0][0]->GetBin(b))
10916            * fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b));
10917    q1n0kIm = fImRPQ1dEBE[2][pe][0][0]->GetBinContent(fImRPQ1dEBE[2][pe][0][0]->GetBin(b))
10918            * fImRPQ1dEBE[2][pe][0][0]->GetBinEntries(fImRPQ1dEBE[2][pe][0][0]->GetBin(b));
10919    q2n0kRe = fReRPQ1dEBE[2][pe][1][0]->GetBinContent(fReRPQ1dEBE[2][pe][1][0]->GetBin(b))
10920            * fReRPQ1dEBE[2][pe][1][0]->GetBinEntries(fReRPQ1dEBE[2][pe][1][0]->GetBin(b));
10921    q2n0kIm = fImRPQ1dEBE[2][pe][1][0]->GetBinContent(fImRPQ1dEBE[2][pe][1][0]->GetBin(b))
10922            * fImRPQ1dEBE[2][pe][1][0]->GetBinEntries(fImRPQ1dEBE[2][pe][1][0]->GetBin(b));         
10923                  
10924    mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
10925   } 
10926   else if(type == "RP")
10927   {
10928    // q_{m*n,0}:
10929    q1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))
10930            * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));
10931    q1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))
10932            * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));
10933    q2n0kRe = fReRPQ1dEBE[0][pe][1][0]->GetBinContent(fReRPQ1dEBE[0][pe][1][0]->GetBin(b))
10934            * fReRPQ1dEBE[0][pe][1][0]->GetBinEntries(fReRPQ1dEBE[0][pe][1][0]->GetBin(b));
10935    q2n0kIm = fImRPQ1dEBE[0][pe][1][0]->GetBinContent(fImRPQ1dEBE[0][pe][1][0]->GetBin(b))
10936            * fImRPQ1dEBE[0][pe][1][0]->GetBinEntries(fImRPQ1dEBE[0][pe][1][0]->GetBin(b));         
10937                  
10938    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)  
10939   }    
10940   if(type == "POI")
10941   {
10942    // p_{m*n,0}:
10943    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))
10944            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));
10945    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  
10946            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));
10947             
10948    mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
10949     
10950    t = 1; // typeFlag = RP or POI
10951   }
10952   else if(type == "RP")
10953   {
10954    // p_{m*n,0} = q_{m*n,0}:
10955    p1n0kRe = q1n0kRe; 
10956    p1n0kIm = q1n0kIm; 
10957            
10958    mp = mq; 
10959    
10960    t = 0; // typeFlag = RP or POI
10961   }
10962
10963   // <<sin n(psi1)>>:
10964   Double_t sinP1nPsi = 0.;
10965   if(mp)
10966   {
10967    sinP1nPsi = p1n0kIm/mp;
10968    // fill profile for <<sin n(psi1)>>:
10969    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi,mp);
10970    // histogram to store <sin n(psi1)> e-b-e (needed in some other methods):
10971    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][0]->SetBinContent(b,sinP1nPsi);
10972   } // end of if(mp)   
10973   
10974   // <<sin n(psi1+phi2)>>:
10975   Double_t sinP1nPsiP1nPhi = 0.;
10976   if(mp*dMult-mq)
10977   {
10978    sinP1nPsiP1nPhi = (p1n0kRe*dImQ1n+p1n0kIm*dReQ1n-q2n0kIm)/(mp*dMult-mq);
10979    // fill profile for <<sin n(psi1+phi2)>>:
10980    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsiP1nPhi,mp*dMult-mq);
10981    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):
10982    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][1]->SetBinContent(b,sinP1nPsiP1nPhi);
10983   } // end of if(mp*dMult-mq)   
10984   
10985   // <<sin n(psi1+phi2-phi3)>>:
10986   Double_t sinP1nPsi1P1nPhi2MPhi3 = 0.;
10987   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))
10988   {
10989    sinP1nPsi1P1nPhi2MPhi3 = (p1n0kIm*(pow(dImQ1n,2.)+pow(dReQ1n,2.)-dMult)
10990                           - 1.*(q2n0kIm*dReQ1n-q2n0kRe*dImQ1n)  
10991                           - mq*dImQ1n+2.*q1n0kIm)
10992                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));
10993    // fill profile for <<sin n(psi1+phi2)>>:
10994    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi1P1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));
10995    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):
10996    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][2]->SetBinContent(b,sinP1nPsi1P1nPhi2MPhi3);
10997   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   
10998   
10999   // <<sin n(psi1-phi2-phi3)>>:
11000   Double_t sinP1nPsi1M1nPhi2MPhi3 = 0.;
11001   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))
11002   {
11003    sinP1nPsi1M1nPhi2MPhi3 = (p1n0kIm*(pow(dReQ1n,2.)-pow(dImQ1n,2.))-2.*p1n0kRe*dReQ1n*dImQ1n
11004                           - 1.*(p1n0kIm*dReQ2n-p1n0kRe*dImQ2n)
11005                           + 2.*mq*dImQ1n-2.*q1n0kIm)
11006                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));
11007    // fill profile for <<sin n(psi1+phi2)>>:
11008    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi1M1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));
11009    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):
11010    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][3]->SetBinContent(b,sinP1nPsi1M1nPhi2MPhi3);
11011   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   
11012  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
11013  
11014 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUASinTerms(TString type, TString ptOrEta)
11015
11016
11017 //================================================================================================================================
11018
11019
11020 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUACosTerms(TString type, TString ptOrEta)
11021 {
11022  // Calculate correction terms for non-uniform acceptance for differential flow (cos terms).
11023  
11024  // Results are stored in fDiffFlowCorrectionTermsForNUAPro[t][pe][1][cti], where cti runs as follows:
11025  //  0: <<cos n(psi)>>
11026  //  1: <<cos n(psi1+phi2)>>
11027  //  2: <<cos n(psi1+phi2-phi3)>>
11028  //  3: <<cos n(psi1-phi2-phi3)>>
11029  //  4:
11030  //  5:
11031  //  6:
11032  
11033  // multiplicity:
11034  Double_t dMult = (*fSpk)(0,0);
11035  
11036  // real and imaginary parts of non-weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
11037  Double_t dReQ1n = (*fReQ)(0,0);
11038  Double_t dReQ2n = (*fReQ)(1,0);
11039  //Double_t dReQ3n = (*fReQ)(2,0);
11040  //Double_t dReQ4n = (*fReQ)(3,0);
11041  Double_t dImQ1n = (*fImQ)(0,0);
11042  Double_t dImQ2n = (*fImQ)(1,0);
11043  //Double_t dImQ3n = (*fImQ)(2,0);
11044  //Double_t dImQ4n = (*fImQ)(3,0);
11045
11046  Int_t t = 0; // type flag 
11047  Int_t pe = 0; // ptEta flag
11048  
11049  if(type == "RP")
11050  {
11051   t = 0;
11052  } else if(type == "POI")
11053    {
11054     t = 1;
11055    }
11056
11057  if(ptOrEta == "Pt")
11058  {
11059   pe = 0;
11060  } else if(ptOrEta == "Eta")
11061    {
11062     pe = 1;
11063    }
11064     
11065  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
11066  Double_t minPtEta[2] = {fPtMin,fEtaMin};
11067  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
11068  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
11069
11070  // looping over all bins and calculating correction terms: 
11071  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
11072  {
11073   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): 
11074   Double_t p1n0kRe = 0.;
11075   Double_t p1n0kIm = 0.;
11076
11077   // number of POIs in particular pt or eta bin:
11078   Double_t mp = 0.;
11079
11080   // 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):
11081   Double_t q1n0kRe = 0.;
11082   Double_t q1n0kIm = 0.;
11083   Double_t q2n0kRe = 0.;
11084   Double_t q2n0kIm = 0.;
11085
11086   // number of particles which are both RPs and POIs in particular pt or eta bin:
11087   Double_t mq = 0.;
11088    
11089   if(type == "POI")
11090   {
11091    // q_{m*n,0}:
11092    q1n0kRe = fReRPQ1dEBE[2][pe][0][0]->GetBinContent(fReRPQ1dEBE[2][pe][0][0]->GetBin(b))
11093            * fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b));
11094    q1n0kIm = fImRPQ1dEBE[2][pe][0][0]->GetBinContent(fImRPQ1dEBE[2][pe][0][0]->GetBin(b))
11095            * fImRPQ1dEBE[2][pe][0][0]->GetBinEntries(fImRPQ1dEBE[2][pe][0][0]->GetBin(b));
11096    q2n0kRe = fReRPQ1dEBE[2][pe][1][0]->GetBinContent(fReRPQ1dEBE[2][pe][1][0]->GetBin(b))
11097            * fReRPQ1dEBE[2][pe][1][0]->GetBinEntries(fReRPQ1dEBE[2][pe][1][0]->GetBin(b));
11098    q2n0kIm = fImRPQ1dEBE[2][pe][1][0]->GetBinContent(fImRPQ1dEBE[2][pe][1][0]->GetBin(b))
11099            * fImRPQ1dEBE[2][pe][1][0]->GetBinEntries(fImRPQ1dEBE[2][pe][1][0]->GetBin(b));         
11100                  
11101    mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
11102   } 
11103   else if(type == "RP")
11104   {
11105    // q_{m*n,0}:
11106    q1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))
11107            * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));
11108    q1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))
11109            * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));
11110    q2n0kRe = fReRPQ1dEBE[0][pe][1][0]->GetBinContent(fReRPQ1dEBE[0][pe][1][0]->GetBin(b))
11111            * fReRPQ1dEBE[0][pe][1][0]->GetBinEntries(fReRPQ1dEBE[0][pe][1][0]->GetBin(b));
11112    q2n0kIm = fImRPQ1dEBE[0][pe][1][0]->GetBinContent(fImRPQ1dEBE[0][pe][1][0]->GetBin(b))
11113            * fImRPQ1dEBE[0][pe][1][0]->GetBinEntries(fImRPQ1dEBE[0][pe][1][0]->GetBin(b));         
11114                  
11115    mq = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)  
11116   }    
11117   if(type == "POI")
11118   {
11119    // p_{m*n,0}:
11120    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))
11121            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));
11122    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  
11123            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));
11124             
11125    mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
11126     
11127    t = 1; // typeFlag = RP or POI
11128   }
11129   else if(type == "RP")
11130   {
11131    // p_{m*n,0} = q_{m*n,0}:
11132    p1n0kRe = q1n0kRe; 
11133    p1n0kIm = q1n0kIm; 
11134            
11135    mp = mq; 
11136    
11137    t = 0; // typeFlag = RP or POI
11138   }
11139
11140   // <<cos n(psi1)>>:
11141   Double_t cosP1nPsi = 0.;
11142   if(mp)
11143   {
11144    cosP1nPsi = p1n0kRe/mp;
11145    
11146    // fill profile for <<cos n(psi1)>>:
11147    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi,mp);
11148    // histogram to store <cos n(psi1)> e-b-e (needed in some other methods):
11149    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][0]->SetBinContent(b,cosP1nPsi);
11150   } // end of if(mp)   
11151   
11152   // <<cos n(psi1+phi2)>>:
11153   Double_t cosP1nPsiP1nPhi = 0.;
11154   if(mp*dMult-mq)
11155   {
11156    cosP1nPsiP1nPhi = (p1n0kRe*dReQ1n-p1n0kIm*dImQ1n-q2n0kRe)/(mp*dMult-mq);
11157    // fill profile for <<sin n(psi1+phi2)>>:
11158    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsiP1nPhi,mp*dMult-mq);
11159    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):
11160    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][1]->SetBinContent(b,cosP1nPsiP1nPhi);
11161   } // end of if(mp*dMult-mq)   
11162   
11163   // <<cos n(psi1+phi2-phi3)>>:
11164   Double_t cosP1nPsi1P1nPhi2MPhi3 = 0.;
11165   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))
11166   {
11167    cosP1nPsi1P1nPhi2MPhi3 = (p1n0kRe*(pow(dImQ1n,2.)+pow(dReQ1n,2.)-dMult)
11168                           - 1.*(q2n0kRe*dReQ1n+q2n0kIm*dImQ1n)  
11169                           - mq*dReQ1n+2.*q1n0kRe)
11170                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));
11171    // fill profile for <<sin n(psi1+phi2)>>:
11172    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi1P1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));
11173    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):
11174    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][2]->SetBinContent(b,cosP1nPsi1P1nPhi2MPhi3);
11175   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   
11176   
11177   // <<cos n(psi1-phi2-phi3)>>:
11178   Double_t cosP1nPsi1M1nPhi2MPhi3 = 0.;
11179   if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))
11180   {
11181    cosP1nPsi1M1nPhi2MPhi3 = (p1n0kRe*(pow(dReQ1n,2.)-pow(dImQ1n,2.))+2.*p1n0kIm*dReQ1n*dImQ1n
11182                           - 1.*(p1n0kRe*dReQ2n+p1n0kIm*dImQ2n)  
11183                           - 2.*mq*dReQ1n+2.*q1n0kRe)
11184                           / (mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));
11185    // fill profile for <<sin n(psi1+phi2)>>:
11186    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi1M1nPhi2MPhi3,mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.));
11187    // histogram to store <sin n(psi1+phi2)> e-b-e (needed in some other methods):
11188    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][3]->SetBinContent(b,cosP1nPsi1M1nPhi2MPhi3);
11189   } // end of if(mq*(dMult-1.)*(dMult-2.)+(mp-mq)*dMult*(dMult-1.))   
11190  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
11191  
11192 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUACosTerms(TString type, TString ptOrEta)
11193
11194 //==================================================================================================================================
11195
11196 void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUADiffFlow(TString type, TString ptOrEta)
11197 {
11198  // Transfer profiles into histogams and correctly propagate the error.
11199  
11200  Int_t t = 0; // type flag 
11201  Int_t pe = 0; // ptEta flag
11202  
11203  if(type == "RP")
11204  {
11205   t = 0;
11206  } else if(type == "POI")
11207    {
11208     t = 1;
11209    }
11210
11211  if(ptOrEta == "Pt")
11212  {
11213   pe = 0;
11214  } else if(ptOrEta == "Eta")
11215    {
11216     pe = 1;
11217    }
11218     
11219  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
11220  //Double_t minPtEta[2] = {fPtMin,fEtaMin};
11221  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
11222  //Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
11223
11224  for(Int_t sc=0;sc<2;sc++) // sin or cos
11225  {
11226   for(Int_t cti=0;cti<9;cti++) // correction term index
11227   {
11228    for(Int_t b=1;b<=nBinsPtEta[pe];b++)
11229    {
11230     Double_t correctionTerm = fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti]->GetBinContent(b);
11231     fDiffFlowCorrectionTermsForNUAHist[t][pe][sc][cti]->SetBinContent(b,correctionTerm);
11232     // to be improved (propagate error correctly)
11233     // ...
11234    } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
11235   } // correction term index
11236  } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos
11237
11238 }// end of void AliFlowAnalysisWithQCumulants::FinalizeCorrectionTermsForNUADiffFlow(TString type, TString ptOrEta)
11239
11240 //==================================================================================================================================
11241
11242 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulantsCorrectedForNUA(TString type, TString ptOrEta)
11243
11244  // Calculate generalized differential flow cumulants (corrected for non-uniform acceptance).
11245  
11246  // to be improved - propagate error also from non-isotropic terms
11247   
11248  Int_t t = 0; // RP = 0, POI = 1
11249  Int_t pe = 0; // pt = 0, eta = 1
11250
11251  if(type == "RP")
11252  {
11253   t = 0;
11254  } else if(type == "POI")
11255    {
11256     t = 1;
11257    } 
11258      
11259  if(ptOrEta == "Pt")
11260  {
11261   pe = 0;
11262  } else if(ptOrEta == "Eta")
11263    {
11264     pe = 1;
11265    } 
11266        
11267  // Common:
11268  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
11269  // 2-particle correlation:
11270  Double_t two = fIntFlowCorrelationsHist->GetBinContent(1); // <<2>>
11271  // sinus terms coming from reference flow: 
11272  Double_t sinP1nPhi = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(1); // <<sin(n*phi1)>>
11273  Double_t sinP1nPhi1P1nPhi2 = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(2); // <<sin(n*(phi1+phi2))>>
11274  Double_t sinP1nPhi1M1nPhi2M1nPhi3 = fIntFlowCorrectionTermsForNUAHist[0]->GetBinContent(3); // <<sin(n*(phi1-phi2-phi3))>>
11275  // cosinus terms coming from reference flow: 
11276  Double_t cosP1nPhi = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(1); // <<cos(n*phi1)>>
11277  Double_t cosP1nPhi1P1nPhi2 = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(2); // <<cos(n*(phi1+phi2))>>
11278  Double_t cosP1nPhi1M1nPhi2M1nPhi3 = fIntFlowCorrectionTermsForNUAHist[1]->GetBinContent(3); // <<cos(n*(phi1-phi2-phi3))>>
11279
11280  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
11281  {
11282   Double_t twoPrime = fDiffFlowCorrelationsHist[t][pe][0]->GetBinContent(b); // <<2'>>
11283   Double_t fourPrime = fDiffFlowCorrelationsHist[t][pe][1]->GetBinContent(b); // <<4'>>
11284   Double_t sinP1nPsi = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][0]->GetBinContent(b); // <<sin n(Psi)>> 
11285   Double_t cosP1nPsi = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][0]->GetBinContent(b); // <<cos n(Psi)>> 
11286   Double_t sinP1nPsi1P1nPhi2 = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][1]->GetBinContent(b); // <<sin n(psi1+phi2)>> 
11287   Double_t cosP1nPsi1P1nPhi2 = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][1]->GetBinContent(b); // <<cos n(psi1+phi2)>> 
11288   Double_t sinP1nPsi1P1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][2]->GetBinContent(b); // <<sin n(psi1+phi2-phi3)>> 
11289   Double_t cosP1nPsi1P1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][2]->GetBinContent(b); // <<cos n(psi1+phi2-phi3)>> 
11290   Double_t sinP1nPsi1M1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][0][3]->GetBinContent(b); // <<sin n(psi1-phi2-phi3)>> 
11291   Double_t cosP1nPsi1M1nPhi2M1nPhi3 = fDiffFlowCorrectionTermsForNUAHist[t][pe][1][3]->GetBinContent(b); // <<cos n(psi1-phi2-phi3)>> 
11292   // Generalized QC{2'}:
11293   Double_t qc2Prime = twoPrime - sinP1nPsi*sinP1nPhi - cosP1nPsi*cosP1nPhi;
11294   if(fApplyCorrectionForNUA)
11295   {
11296    fDiffFlowCumulants[t][pe][0]->SetBinContent(b,qc2Prime);
11297   }
11298   if(TMath::Abs(twoPrime)>0.)
11299   {
11300    fDiffFlowDetectorBias[t][pe][0]->SetBinContent(b,qc2Prime/twoPrime); // detector bias = generalized/isotropic cumulant.   
11301   }
11302   // Generalized QC{4'}:
11303   Double_t qc4Prime = fourPrime-2.*twoPrime*two
11304                     - cosP1nPsi*cosP1nPhi1M1nPhi2M1nPhi3
11305                     + sinP1nPsi*sinP1nPhi1M1nPhi2M1nPhi3
11306                     - cosP1nPhi*cosP1nPsi1M1nPhi2M1nPhi3
11307                     + sinP1nPhi*sinP1nPsi1M1nPhi2M1nPhi3
11308                     - 2.*cosP1nPhi*cosP1nPsi1P1nPhi2M1nPhi3
11309                     - 2.*sinP1nPhi*sinP1nPsi1P1nPhi2M1nPhi3
11310                     - cosP1nPsi1P1nPhi2*cosP1nPhi1P1nPhi2
11311                     - sinP1nPsi1P1nPhi2*sinP1nPhi1P1nPhi2
11312                     + 2.*cosP1nPhi1P1nPhi2*(cosP1nPsi*cosP1nPhi-sinP1nPsi*sinP1nPhi)
11313                     + 2.*sinP1nPhi1P1nPhi2*(cosP1nPsi*sinP1nPhi+sinP1nPsi*cosP1nPhi)
11314                     + 4.*two*(cosP1nPsi*cosP1nPhi+sinP1nPsi*sinP1nPhi)
11315                     + 2.*cosP1nPsi1P1nPhi2*(pow(cosP1nPhi,2.)-pow(sinP1nPhi,2.))
11316                     + 4.*sinP1nPsi1P1nPhi2*cosP1nPhi*sinP1nPhi
11317                     + 4.*twoPrime*(pow(cosP1nPhi,2.)+pow(sinP1nPhi,2.))
11318                     - 6.*(pow(cosP1nPhi,2.)-pow(sinP1nPhi,2.)) 
11319                     * (cosP1nPsi*cosP1nPhi-sinP1nPsi*sinP1nPhi)
11320                     - 12.*cosP1nPhi*sinP1nPhi
11321                     * (sinP1nPsi*cosP1nPhi+cosP1nPsi*sinP1nPhi);
11322   if(fApplyCorrectionForNUA)
11323   {
11324    fDiffFlowCumulants[t][pe][1]->SetBinContent(b,qc4Prime);   
11325   }
11326   if(TMath::Abs(fourPrime-2.*twoPrime*two)>0.)
11327   {
11328    fDiffFlowDetectorBias[t][pe][1]->SetBinContent(b,qc4Prime/(fourPrime-2.*twoPrime*two)); // detector bias = generalized/isotropic cumulant.   
11329   }
11330  } // end of for(Int_t p=1;p<=fnBinsPt;p++)
11331  
11332 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCumulantsCorrectedForNUA(TString type, TString ptOrEta)
11333
11334 //==================================================================================================================================    
11335
11336 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectedForNUA(TString type, TString ptOrEta)
11337 {
11338  // Calculate differential flow corrected for non-uniform acceptance.
11339  
11340  // to be improved: eventually I will have to access here masured correlations and NUA terms
11341  //                 instead of cumulants in order to propagate statistical error correctly also 
11342  //                 to NUA terms (propagating errors directly from cumulants is WRONG for 
11343  //                 differential flow becuase that doesn't account at all cross-covariance terms) 
11344  
11345  // REMARK: When NUA correction is apllied error for differential flow DOES NOT get corrected,
11346  //         i.e. only value is being corrected, error is still the one relevant for isotropic
11347  //         case. This eventually will be resolved. 
11348   
11349  
11350  Int_t t = 0; // RP or POI
11351  Int_t pe = 0; // pt or eta
11352
11353  if(type == "RP")
11354  {
11355   t = 0;
11356  } else if(type == "POI")
11357    {
11358     t = 1;
11359    }     
11360  if(ptOrEta == "Pt")
11361  {
11362   pe = 0;
11363  } else if(ptOrEta == "Eta")
11364    {
11365     pe = 1;
11366    } 
11367   
11368  // Common:
11369  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
11370  // Reference Q-cumulants
11371  Double_t qc2 = fIntFlowQcumulants->GetBinContent(1); // QC{2} 
11372  Double_t qc4 = fIntFlowQcumulants->GetBinContent(2); // QC{4}
11373  // Loop over pt or eta bins:
11374  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
11375  {
11376   // Differential Q-cumulants:
11377   Double_t qc2Prime = fDiffFlowCumulants[t][pe][0]->GetBinContent(b); // QC{2'}
11378   Double_t qc4Prime = fDiffFlowCumulants[t][pe][1]->GetBinContent(b); // QC{4'}
11379   // v'{2}:
11380   if(qc2>0.)
11381   { 
11382    Double_t v2Prime = qc2Prime/pow(qc2,0.5);
11383    if(TMath::Abs(v2Prime)>0.){fDiffFlow[t][pe][0]->SetBinContent(b,v2Prime);} 
11384   }  
11385   // v'{4}:
11386   if(qc4<0.)
11387   { 
11388    Double_t v4Prime = -qc4Prime/pow(-qc4,3./4.);
11389    if(TMath::Abs(v4Prime)>0.){fDiffFlow[t][pe][1]->SetBinContent(b,v4Prime);} 
11390   }  
11391  } // end of for(Int_t b=1;b<=fnBinsPtEta[pe];b++)
11392   
11393 } // end of void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectedForNUA(TString type, TString ptOrEta); 
11394
11395 //==================================================================================================================================
11396
11397 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoops(AliFlowEventSimple * const anEvent)
11398 {
11399  // Evaluate with nested loops multiparticle correlations for integrated flow (without using the particle weights). 
11400
11401  // Remark: Results are stored in profile fIntFlowDirectCorrelations whose binning is organized as follows:
11402  // 
11403  //  1st bin: <2>_{1n|1n} = two1n1n = cos(n*(phi1-phi2))>
11404  //  2nd bin: <2>_{2n|2n} = two2n2n = cos(2n*(phi1-phi2))>
11405  //  3rd bin: <2>_{3n|3n} = two3n3n = cos(3n*(phi1-phi2))> 
11406  //  4th bin: <2>_{4n|4n} = two4n4n = cos(4n*(phi1-phi2))>
11407  //  5th bin:           ----  EMPTY ----
11408  //  6th bin: <3>_{2n|1n,1n} = three2n1n1n = <cos(n*(2.*phi1-phi2-phi3))>
11409  //  7th bin: <3>_{3n|2n,1n} = three3n2n1n = <cos(n*(3.*phi1-2.*phi2-phi3))>
11410  //  8th bin: <3>_{4n|2n,2n} = three4n2n2n = <cos(n*(4.*phi1-2.*phi2-2.*phi3))>
11411  //  9th bin: <3>_{4n|3n,1n} = three4n3n1n = <cos(n*(4.*phi1-3.*phi2-phi3))>
11412  // 10th bin:           ----  EMPTY ----
11413  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1n = <cos(n*(phi1+phi2-phi3-phi4))>
11414  // 12th bin: <4>_{2n,1n|2n,1n} = four2n1n2n1n = <cos(2.*n*(phi1+phi2-phi3-phi4))>
11415  // 13th bin: <4>_{2n,2n|2n,2n} = four2n2n2n2n = <cos(n*(2.*phi1+phi2-2.*phi3-phi4))>
11416  // 14th bin: <4>_{3n|1n,1n,1n} = four3n1n1n1n = <cos(n*(3.*phi1-phi2-phi3-phi4))> 
11417  // 15th bin: <4>_{3n,1n|3n,1n} = four3n1n3n1n = <cos(n*(4.*phi1-2.*phi2-phi3-phi4))>
11418  // 16th bin: <4>_{3n,1n|2n,2n} = four3n1n2n2n = <cos(n*(3.*phi1+phi2-2.*phi3-2.*phi4))>
11419  // 17th bin: <4>_{4n|2n,1n,1n} = four4n2n1n1n = <cos(n*(3.*phi1+phi2-3.*phi3-phi4))> 
11420  // 18th bin:           ----  EMPTY ----
11421  // 19th bin: <5>_{2n|1n,1n,1n,1n} = five2n1n1n1n1n = <cos(n*(2.*phi1+phi2-phi3-phi4-phi5))>
11422  // 20th bin: <5>_{2n,2n|2n,1n,1n} = five2n2n2n1n1n = <cos(n*(2.*phi1+2.*phi2-2.*phi3-phi4-phi5))>
11423  // 21st bin: <5>_{3n,1n|2n,1n,1n} = five3n1n2n1n1n = <cos(n*(3.*phi1+phi2-2.*phi3-phi4-phi5))>
11424  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = five4n1n1n1n1n = <cos(n*(4.*phi1-phi2-phi3-phi4-phi5))>
11425  // 23rd bin:           ----  EMPTY ----
11426  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = six1n1n1n1n1n1n = <cos(n*(phi1+phi2+phi3-phi4-phi5-phi6))>
11427  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = six2n1n1n2n1n1n = <cos(n*(2.*phi1+2.*phi2-phi3-phi4-phi5-phi6))>
11428  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = six2n2n1n1n1n1n = <cos(n*(3.*phi1+phi2-phi3-phi4-phi5-phi6))>
11429  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = six3n1n1n1n1n1n = <cos(n*(2.*phi1+phi2+phi3-2.*phi4-phi5-phi6))>
11430  // 28th bin:           ----  EMPTY ----
11431  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = seven2n1n1n1n1n1n1n =  <cos(n*(2.*phi1+phi2+phi3-phi4-phi5-phi6-phi7))>
11432  // 30th bin:           ----  EMPTY ----
11433  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = eight1n1n1n1n1n1n1n1n = <cos(n*(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8))>
11434  // 32nd bin:           ----  EMPTY ----
11435   //  Extra correlations for 3p TY study: 
11436  // 33rd bin: <4>_{4n,2n|3n,3n}= four4n2n3n3n = <cos(n*(4.*phi1+2.*phi2-3.*phi3-3.*phi4))>
11437  // 34th bin: <5>_{3n,3n|2n,2n,2n} = five3n3n2n2n2n = <cos(n(3*phi1+3*phi2-2*phi3-2*phi4-2*phi5))> 
11438   //  Extra correlations for 6p TY study: 
11439  // 35th bin: <2>_{5n|5n} = two5n5n = <cos(5n*(phi1-phi2)> T
11440  // 36th bin: <2>_{6n|6n} = two6n6n = <cos(6n*(phi1-phi2)> T
11441  // 37th bin: <3>_{5n|3n,2n} = three5n3n2n = <cos(n*(5*phi1-3*phi2-2*phi3)> 
11442  // 38th bin: <3>_{5n|4n,1n} = three5n4n1n = <cos(n*(5*phi1-4*phi2-1*phi3)> 
11443  // 39th bin: <3>_{6n|3n,3n} = three6n3n3n = <cos(n*(6*phi1-3*phi2-3*phi3)> T 
11444  // 40th bin: <3>_{6n|4n,2n} = three6n4n2n = <cos(n*(6*phi1-4*phi2-2*phi3)> T
11445  // 41st bin: <3>_{6n|5n,1n} = three6n5n1n = <cos(n*(6*phi1-5*phi2-1*phi3)>
11446  // 42nd bin: <4>_{6n|3n,2n,1n} = four6n3n2n1n = <cos(n*(6*phi1-3*phi2-2*phi3-1*phi4)>
11447  // 43rd bin: <4>_{3n,2n|3n,2n} = four3n2n3n2n = <cos(n*(3*phi1+2*phi2-3*phi3-2*phi4)>
11448  // 44th bin: <4>_{4n,1n|3n,2n} = four4n1n3n2n = <cos(n*(4*phi1+1*phi2-3*phi3-2*phi4)>
11449  // 45th bin: <4>_{3n,3n|3n,3n} = four3n3n3n3n = <cos(3.*n*(phi1+phi2-phi3-phi4))> T
11450  // 46th bin: <4>_{4n,2n|3n,3n} = four4n2n3n3n = <cos(n*(4*phi1+2*phi2-3*phi3-3*phi4)>
11451  // 47th bin: <4>_{5n,1n|3n,3n} = four5n1n3n3n = <cos(n*(5*phi1+1*phi2-3*phi3-3*phi4)>
11452  // 48th bin: <4>_{4n,2n|4n,2n} = four4n2n4n2n = <cos(n*(4*phi1+2*phi2-4*phi3-2*phi4)> T
11453  // 49th bin: <4>_{5n,1n|4n,2n} = four5n1n4n2n = <cos(n*(5*phi1+1*phi2-4*phi3-2*phi4)>
11454  // 50th bin: <4>_{5n|3n,1n,1n} = four5n3n1n1n = <cos(n*(5*phi1-3*phi2-1*phi3-1*phi4)>
11455  // 51st bin: <4>_{5n|2n,2n,1n} = four5n2n2n1n = <cos(n*(5*phi1-2*phi2-2*phi3-1*phi4)>
11456  // 52nd bin: <4>_{5n,1n|5n,1n} = four5n1n5n1n = <cos(n*(5*phi1+1*phi2-5*phi3-1*phi4)>
11457  // 53rd bin: <5>_{3n,3n|3n,2n,1n} = four3n3n3n2n1n = <cos(n*(3*phi1+3*phi2-3*phi3-2*phi4-1*phi5)>
11458  // 54th bin: <5>_{4n,2n|3n,2n,1n} = four4n2n3n2n1n = <cos(n*(4*phi1+2*phi2-3*phi3-2*phi4-1*phi5)>
11459  // 55th bin: <5>_{3n,2n|3n,1n,1n} = four3n2n3n1n1n = <cos(n*(3*phi1+2*phi2-3*phi3-1*phi4-1*phi5)>
11460  // 56th bin: <5>_{3n,2n|2n,2n,1n} = four3n2n2n2n1n = <cos(n*(3*phi1+2*phi2-2*phi3-2*phi4-1*phi5)>
11461  // 57th bin: <5>_{5n,1n|3n,2n,1n} = four5n1n3n2n1n = <cos(n*(5*phi1+1*phi2-3*phi3-2*phi4-1*phi5)>
11462  // 58th bin: <6>_{3n,2n,1n|3n,2n,1n} = six3n2n1n3n2n1n = <cos(n*(3*phi1+2*phi2+1*phi3-3*phi4-2*phi5-1*phi6)>
11463   
11464  Int_t nPrim = anEvent->NumberOfTracks(); 
11465  AliFlowTrackSimple *aftsTrack = NULL; 
11466  Double_t phi1=0., phi2=0., phi3=0., phi4=0., phi5=0., phi6=0., phi7=0., phi8=0.; 
11467  Int_t n = fHarmonic; 
11468  Int_t eventNo = (Int_t)fAvMultiplicity->GetBinEntries(1); // to be improved (is this casting safe in general?)
11469  Double_t dMult = (*fSpk)(0,0);
11470  cout<<endl;
11471  cout<<"Multiparticle correlations: Event number: "<<eventNo<<", multiplicity is "<<dMult<<endl;
11472  if(dMult<2)
11473  {
11474   cout<<"... skipping this event (multiplicity too low) ..."<<endl;
11475  } else if (dMult>fMaxAllowedMultiplicity)
11476    {
11477     cout<<"... skipping this event (multiplicity too high) ..."<<endl;
11478    } else 
11479      { 
11480       cout<<"... evaluating nested loops (without using particle weights)..."<<endl;
11481      } 
11482  
11483  // 2-particle correlations:       
11484  if(nPrim>=2 && nPrim<=fMaxAllowedMultiplicity)
11485  {
11486   for(Int_t i1=0;i1<nPrim;i1++)
11487   {
11488    aftsTrack=anEvent->GetTrack(i1);
11489    if(!(aftsTrack->InRPSelection())) continue;
11490    phi1=aftsTrack->Phi(); 
11491    for(Int_t i2=0;i2<nPrim;i2++)
11492    {
11493     if(i2==i1)continue;
11494     aftsTrack=anEvent->GetTrack(i2);
11495     if(!(aftsTrack->InRPSelection())) continue;
11496     phi2=aftsTrack->Phi();
11497     if(nPrim==2) cout<<i1<<" "<<i2<<"\r"<<flush;
11498     // fill the profile with 2-p correlations: 
11499     fIntFlowDirectCorrelations->Fill(0.5,cos(n*(phi1-phi2)),1.);     // <cos(n*(phi1-phi2))>
11500     fIntFlowDirectCorrelations->Fill(1.5,cos(2.*n*(phi1-phi2)),1.);  // <cos(2n*(phi1-phi2))>
11501     fIntFlowDirectCorrelations->Fill(2.5,cos(3.*n*(phi1-phi2)),1.);  // <cos(3n*(phi1-phi2))>
11502     fIntFlowDirectCorrelations->Fill(3.5,cos(4.*n*(phi1-phi2)),1.);  // <cos(4n*(phi1-phi2))>   
11503     fIntFlowDirectCorrelations->Fill(34.5,cos(5.*n*(phi1-phi2)),1.); // <cos(5n*(phi1-phi2))>
11504     fIntFlowDirectCorrelations->Fill(35.5,cos(6.*n*(phi1-phi2)),1.); // <cos(6n*(phi1-phi2))>   
11505    } // end of for(Int_t i2=0;i2<nPrim;i2++)
11506   } // end of for(Int_t i1=0;i1<nPrim;i1++)
11507  } // end of if(nPrim>=2)
11508  
11509  // 3-particle correlations:         
11510  if(nPrim>=3 && nPrim<=fMaxAllowedMultiplicity)
11511  {
11512   for(Int_t i1=0;i1<nPrim;i1++)
11513   {
11514    aftsTrack=anEvent->GetTrack(i1);
11515    if(!(aftsTrack->InRPSelection())) continue;
11516    phi1=aftsTrack->Phi();
11517    for(Int_t i2=0;i2<nPrim;i2++)
11518    {
11519     if(i2==i1)continue;
11520     aftsTrack=anEvent->GetTrack(i2);
11521     if(!(aftsTrack->InRPSelection())) continue;
11522     phi2=aftsTrack->Phi();
11523     for(Int_t i3=0;i3<nPrim;i3++)
11524     {
11525      if(i3==i1||i3==i2)continue;
11526      aftsTrack=anEvent->GetTrack(i3);
11527      if(!(aftsTrack->InRPSelection())) continue;
11528      phi3=aftsTrack->Phi();
11529      if(nPrim==3) cout<<i1<<" "<<i2<<" "<<i3<<"\r"<<flush;
11530      // fill the profile with 3-p correlations:   
11531      fIntFlowDirectCorrelations->Fill(5.,cos(2.*n*phi1-n*(phi2+phi3)),1.);         //<3>_{2n|nn,n}
11532      fIntFlowDirectCorrelations->Fill(6.,cos(3.*n*phi1-2.*n*phi2-n*phi3),1.);      //<3>_{3n|2n,n}
11533      fIntFlowDirectCorrelations->Fill(7.,cos(4.*n*phi1-2.*n*phi2-2.*n*phi3),1.);   //<3>_{4n|2n,2n}
11534      fIntFlowDirectCorrelations->Fill(8.,cos(4.*n*phi1-3.*n*phi2-n*phi3),1.);      //<3>_{4n|3n,n}
11535      fIntFlowDirectCorrelations->Fill(36.5,cos(5.*n*phi1-3.*n*phi2-2.*n*phi3),1.); //<3>_{5n|3n,2n}
11536      fIntFlowDirectCorrelations->Fill(37.5,cos(5.*n*phi1-4.*n*phi2-1.*n*phi3),1.); //<3>_{5n|4n,1n}
11537      fIntFlowDirectCorrelations->Fill(38.5,cos(6.*n*phi1-3.*n*phi2-3.*n*phi3),1.); //<3>_{6n|3n,3n}
11538      fIntFlowDirectCorrelations->Fill(39.5,cos(6.*n*phi1-4.*n*phi2-2.*n*phi3),1.); //<3>_{6n|4n,2n}     
11539      fIntFlowDirectCorrelations->Fill(40.5,cos(6.*n*phi1-5.*n*phi2-1.*n*phi3),1.); //<3>_{6n|5n,1n}
11540     } // end of for(Int_t i3=0;i3<nPrim;i3++)
11541    } // end of for(Int_t i2=0;i2<nPrim;i2++)
11542   } // end of for(Int_t i1=0;i1<nPrim;i1++)
11543  } // end of if(nPrim>=3)
11544
11545  // 4-particle correlations:
11546  if(nPrim>=4 && nPrim<=fMaxAllowedMultiplicity)
11547  {       
11548   for(Int_t i1=0;i1<nPrim;i1++)
11549   { 
11550    aftsTrack=anEvent->GetTrack(i1);
11551    if(!(aftsTrack->InRPSelection())) continue;
11552    phi1=aftsTrack->Phi();
11553    for(Int_t i2=0;i2<nPrim;i2++)
11554    {
11555     if(i2==i1)continue;
11556     aftsTrack=anEvent->GetTrack(i2);
11557     if(!(aftsTrack->InRPSelection())) continue;
11558     phi2=aftsTrack->Phi();
11559     for(Int_t i3=0;i3<nPrim;i3++)
11560     {
11561      if(i3==i1||i3==i2)continue;
11562      aftsTrack=anEvent->GetTrack(i3);
11563      if(!(aftsTrack->InRPSelection())) continue;
11564      phi3=aftsTrack->Phi();
11565      for(Int_t i4=0;i4<nPrim;i4++)
11566      {
11567       if(i4==i1||i4==i2||i4==i3)continue;
11568       aftsTrack=anEvent->GetTrack(i4);
11569       if(!(aftsTrack->InRPSelection())) continue;
11570       phi4=aftsTrack->Phi();
11571       if(nPrim==4) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<"\r"<<flush;
11572       // fill the profile with 4-p correlations:   
11573       fIntFlowDirectCorrelations->Fill(10.,cos(n*phi1+n*phi2-n*phi3-n*phi4),1.);            // <4>_{n,n|n,n} 
11574       fIntFlowDirectCorrelations->Fill(11.,cos(2.*n*phi1+n*phi2-2.*n*phi3-n*phi4),1.);      // <4>_{2n,n|2n,n}
11575       fIntFlowDirectCorrelations->Fill(12.,cos(2.*n*phi1+2*n*phi2-2.*n*phi3-2.*n*phi4),1.); // <4>_{2n,2n|2n,2n}
11576       fIntFlowDirectCorrelations->Fill(13.,cos(3.*n*phi1-n*phi2-n*phi3-n*phi4),1.);         // <4>_{3n|n,n,n}
11577       fIntFlowDirectCorrelations->Fill(14.,cos(3.*n*phi1+n*phi2-3.*n*phi3-n*phi4),1.);      // <4>_{3n,n|3n,n}   
11578       fIntFlowDirectCorrelations->Fill(15.,cos(3.*n*phi1+n*phi2-2.*n*phi3-2.*n*phi4),1.);   // <4>_{3n,n|2n,2n}
11579       fIntFlowDirectCorrelations->Fill(16.,cos(4.*n*phi1-2.*n*phi2-n*phi3-n*phi4),1.);      // <4>_{4n|2n,n,n}     
11580       fIntFlowDirectCorrelations->Fill(32.,cos(n*(4.*phi1+2.*phi2-3.*phi3-3.*phi4)),1.);    // <4>_{4n,2n|3n,3n}        
11581       fIntFlowDirectCorrelations->Fill(41.5,cos(n*(6.*phi1-3.*phi2-2.*phi3-1.*phi4)),1.);    // <4>_{6n|3n,2n,1n}  
11582       fIntFlowDirectCorrelations->Fill(42.5,cos(n*(3.*phi1+2.*phi2-3.*phi3-2.*phi4)),1.);    // <4>_{3n,2n|3n,2n}  
11583       fIntFlowDirectCorrelations->Fill(43.5,cos(n*(4.*phi1+1.*phi2-3.*phi3-2.*phi4)),1.);    // <4>_{4n,1n|3n,2n}  
11584       fIntFlowDirectCorrelations->Fill(44.5,cos(n*(3.*phi1+3.*phi2-3.*phi3-3.*phi4)),1.);    // <4>_{3n,3n|3n,3n}  
11585       fIntFlowDirectCorrelations->Fill(45.5,cos(n*(4.*phi1+2.*phi2-3.*phi3-3.*phi4)),1.);    // <4>_{4n,2n|3n,3n}  
11586       fIntFlowDirectCorrelations->Fill(46.5,cos(n*(5.*phi1+1.*phi2-3.*phi3-3.*phi4)),1.);    // <4>_{5n,1n|3n,3n}  
11587       fIntFlowDirectCorrelations->Fill(47.5,cos(n*(4.*phi1+2.*phi2-4.*phi3-2.*phi4)),1.);    // <4>_{4n,2n|4n,2n}     
11588       fIntFlowDirectCorrelations->Fill(48.5,cos(n*(5.*phi1+1.*phi2-4.*phi3-2.*phi4)),1.);    // <4>_{5n,1n|4n,2n}  
11589       fIntFlowDirectCorrelations->Fill(49.5,cos(n*(5.*phi1-3.*phi2-1.*phi3-1.*phi4)),1.);    // <4>_{5n|3n,1n,1n}  
11590       fIntFlowDirectCorrelations->Fill(50.5,cos(n*(5.*phi1-2.*phi2-2.*phi3-1.*phi4)),1.);    // <4>_{5n|2n,2n,1n}  
11591       fIntFlowDirectCorrelations->Fill(51.5,cos(n*(5.*phi1+1.*phi2-5.*phi3-1.*phi4)),1.);    // <4>_{5n,1n|5n,1n}        
11592       fIntFlowDirectCorrelations->Fill(58.5,cos(n*(6.*phi1-4.*phi2-1.*phi3-1.*phi4)),1.);    // <4>_{6n|4n,1n,1n}  
11593       fIntFlowDirectCorrelations->Fill(59.5,cos(n*(6.*phi1-2.*phi2-2.*phi3-2.*phi4)),1.);    // <4>_{6n|2n,2n,2n}  
11594      } // end of for(Int_t i4=0;i4<nPrim;i4++) 
11595     } // end of for(Int_t i3=0;i3<nPrim;i3++)
11596    } // end of for(Int_t i2=0;i2<nPrim;i2++)
11597   } // end of for(Int_t i1=0;i1<nPrim;i1++)
11598  } // end of if(nPrim>=)
11599
11600  // 5-particle correlations:      
11601  if(nPrim>=5 && nPrim<=fMaxAllowedMultiplicity)
11602  {
11603   for(Int_t i1=0;i1<nPrim;i1++)
11604   {
11605    aftsTrack=anEvent->GetTrack(i1);
11606    if(!(aftsTrack->InRPSelection())) continue;  
11607    phi1=aftsTrack->Phi();
11608    for(Int_t i2=0;i2<nPrim;i2++)
11609    {
11610     if(i2==i1)continue;
11611     aftsTrack=anEvent->GetTrack(i2);
11612     if(!(aftsTrack->InRPSelection())) continue;
11613     phi2=aftsTrack->Phi();
11614     for(Int_t i3=0;i3<nPrim;i3++)
11615     {
11616      if(i3==i1||i3==i2)continue;
11617      aftsTrack=anEvent->GetTrack(i3);
11618      if(!(aftsTrack->InRPSelection())) continue;
11619      phi3=aftsTrack->Phi();
11620      for(Int_t i4=0;i4<nPrim;i4++)
11621      {
11622       if(i4==i1||i4==i2||i4==i3)continue;
11623       aftsTrack=anEvent->GetTrack(i4);
11624       if(!(aftsTrack->InRPSelection())) continue;
11625       phi4=aftsTrack->Phi();
11626       for(Int_t i5=0;i5<nPrim;i5++)
11627       {
11628        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
11629        aftsTrack=anEvent->GetTrack(i5);
11630        if(!(aftsTrack->InRPSelection())) continue;
11631        phi5=aftsTrack->Phi();
11632        if(nPrim==5) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<"\r"<<flush;
11633        // fill the profile with 5-p correlations:   
11634        fIntFlowDirectCorrelations->Fill(18.,cos(2.*n*phi1+n*phi2-n*phi3-n*phi4-n*phi5),1.);              // <5>_{2n,n|n,n,n}
11635        fIntFlowDirectCorrelations->Fill(19.,cos(2.*n*phi1+2.*n*phi2-2.*n*phi3-n*phi4-n*phi5),1.);        // <5>_{2n,2n|2n,n,n}
11636        fIntFlowDirectCorrelations->Fill(20.,cos(3.*n*phi1+n*phi2-2.*n*phi3-n*phi4-n*phi5),1.);           // <5>_{3n,n|2n,n,n}
11637        fIntFlowDirectCorrelations->Fill(21.,cos(4.*n*phi1-n*phi2-n*phi3-n*phi4-n*phi5),1.);              // <5>_{4n|n,n,n,n}
11638        fIntFlowDirectCorrelations->Fill(33.,cos(3.*n*phi1+3.*n*phi2-2.*n*phi3-2.*n*phi4-2.*n*phi5),1.);  // <5>_{3n,3n|2n,2n,2n}       
11639        fIntFlowDirectCorrelations->Fill(52.5,cos(3.*n*phi1+3.*n*phi2-3.*n*phi3-2.*n*phi4-1.*n*phi5),1.); // <5>_{3n,3n|3n,2n,1n}      
11640        fIntFlowDirectCorrelations->Fill(53.5,cos(4.*n*phi1+2.*n*phi2-3.*n*phi3-2.*n*phi4-1.*n*phi5),1.); // <5>_{4n,2n|3n,2n,1n}       
11641        fIntFlowDirectCorrelations->Fill(54.5,cos(3.*n*phi1+2.*n*phi2-3.*n*phi3-1.*n*phi4-1.*n*phi5),1.); // <5>_{3n,2n|3n,1n,1n}
11642        fIntFlowDirectCorrelations->Fill(55.5,cos(3.*n*phi1+2.*n*phi2-2.*n*phi3-2.*n*phi4-1.*n*phi5),1.); // <5>_{3n,2n|2n,2n,1n}
11643        fIntFlowDirectCorrelations->Fill(56.5,cos(5.*n*phi1+1.*n*phi2-3.*n*phi3-2.*n*phi4-1.*n*phi5),1.); // <5>_{5n,1n|3n,2n,1n}              
11644        fIntFlowDirectCorrelations->Fill(60.5,cos(6.*n*phi1-2.*n*phi2-2.*n*phi3-1.*n*phi4-1.*n*phi5),1.); // <5>_{6n|2n,2n,1n,1n}
11645        fIntFlowDirectCorrelations->Fill(61.5,cos(4.*n*phi1+1.*n*phi2+1.*n*phi3-3.*n*phi4-3.*n*phi5),1.); // <5>_{4n,1n,1n|3n,3n}              
11646       } // end of for(Int_t i5=0;i5<nPrim;i5++)
11647      } // end of for(Int_t i4=0;i4<nPrim;i4++)  
11648     } // end of for(Int_t i3=0;i3<nPrim;i3++)
11649    } // end of for(Int_t i2=0;i2<nPrim;i2++)
11650   } // end of for(Int_t i1=0;i1<nPrim;i1++)
11651  } // end of if(nPrim>=5)
11652   
11653  // 6-particle correlations:
11654  if(nPrim>=6 && nPrim<=fMaxAllowedMultiplicity)
11655  {
11656   for(Int_t i1=0;i1<nPrim;i1++)
11657   {
11658    aftsTrack=anEvent->GetTrack(i1);
11659    if(!(aftsTrack->InRPSelection())) continue;
11660    phi1=aftsTrack->Phi();
11661    for(Int_t i2=0;i2<nPrim;i2++)
11662    {
11663     if(i2==i1)continue;
11664     aftsTrack=anEvent->GetTrack(i2);
11665     if(!(aftsTrack->InRPSelection())) continue;
11666     phi2=aftsTrack->Phi();
11667     for(Int_t i3=0;i3<nPrim;i3++)
11668     {
11669      if(i3==i1||i3==i2)continue;
11670      aftsTrack=anEvent->GetTrack(i3);
11671      if(!(aftsTrack->InRPSelection())) continue;
11672      phi3=aftsTrack->Phi();
11673      for(Int_t i4=0;i4<nPrim;i4++)
11674      {
11675       if(i4==i1||i4==i2||i4==i3)continue;
11676       aftsTrack=anEvent->GetTrack(i4);
11677       if(!(aftsTrack->InRPSelection())) continue;
11678       phi4=aftsTrack->Phi();
11679       for(Int_t i5=0;i5<nPrim;i5++)
11680       {
11681        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
11682        aftsTrack=anEvent->GetTrack(i5);
11683        if(!(aftsTrack->InRPSelection())) continue;
11684        phi5=aftsTrack->Phi();
11685        for(Int_t i6=0;i6<nPrim;i6++)
11686        {
11687         if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;
11688         aftsTrack=anEvent->GetTrack(i6);
11689         if(!(aftsTrack->InRPSelection())) continue;
11690         phi6=aftsTrack->Phi(); 
11691         if(nPrim==6) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<" "<<i6<<"\r"<<flush;
11692         // fill the profile with 6-p correlations:   
11693         fIntFlowDirectCorrelations->Fill(23.,cos(n*phi1+n*phi2+n*phi3-n*phi4-n*phi5-n*phi6),1.);                    // <6>_{1n,1n,1n|1n,1n,1n}
11694         fIntFlowDirectCorrelations->Fill(24.,cos(2.*n*phi1+n*phi2+n*phi3-2.*n*phi4-n*phi5-n*phi6),1.);              // <6>_{2n,1n,1n|2n,1n,1n}
11695         fIntFlowDirectCorrelations->Fill(25.,cos(2.*n*phi1+2.*n*phi2-n*phi3-n*phi4-n*phi5-n*phi6),1.);              // <6>_{2n,2n|1n,1n,1n,1n}
11696         fIntFlowDirectCorrelations->Fill(26.,cos(3.*n*phi1+n*phi2-n*phi3-n*phi4-n*phi5-n*phi6),1.);                 // <6>_{3n,1n|1n,1n,1n,1n}  
11697         fIntFlowDirectCorrelations->Fill(57.5,cos(3.*n*phi1+2.*n*phi2+1.*n*phi3-3.*n*phi4-2.*n*phi5-1.*n*phi6),1.); // <6>_{3n,2n,1n|3n,2n,1n}  
11698         fIntFlowDirectCorrelations->Fill(62.5,cos(3.*n*phi1+3.*n*phi2-2.*n*phi3-2.*n*phi4-1.*n*phi5-1.*n*phi6),1.); // <6>_{3n,3n|2n,2n,1n,1n}  
11699        } // end of for(Int_t i6=0;i6<nPrim;i6++)
11700       } // end of for(Int_t i5=0;i5<nPrim;i5++)
11701      } // end of for(Int_t i4=0;i4<nPrim;i4++)
11702     } // end of for(Int_t i3=0;i3<nPrim;i3++)
11703    } // end of for(Int_t i2=0;i2<nPrim;i2++)
11704   } // end of for(Int_t i1=0;i1<nPrim;i1++)
11705  } // end of if(nPrim>=6)
11706   
11707  // 7-particle correlations:
11708  if(nPrim>=7 && nPrim<=fMaxAllowedMultiplicity)
11709  {
11710   for(Int_t i1=0;i1<nPrim;i1++)
11711   { 
11712    aftsTrack=anEvent->GetTrack(i1);
11713    if(!(aftsTrack->InRPSelection())) continue;
11714    phi1=aftsTrack->Phi();
11715    for(Int_t i2=0;i2<nPrim;i2++)
11716    {
11717     if(i2==i1)continue;
11718     aftsTrack=anEvent->GetTrack(i2);
11719     if(!(aftsTrack->InRPSelection())) continue;
11720     phi2=aftsTrack->Phi();
11721     for(Int_t i3=0;i3<nPrim;i3++)
11722     {
11723      if(i3==i1||i3==i2)continue;
11724      aftsTrack=anEvent->GetTrack(i3);
11725      if(!(aftsTrack->InRPSelection())) continue;
11726      phi3=aftsTrack->Phi();
11727      for(Int_t i4=0;i4<nPrim;i4++)
11728      {
11729       if(i4==i1||i4==i2||i4==i3)continue;
11730       aftsTrack=anEvent->GetTrack(i4);
11731       if(!(aftsTrack->InRPSelection())) continue;
11732       phi4=aftsTrack->Phi();
11733       for(Int_t i5=0;i5<nPrim;i5++)
11734       {
11735        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
11736        aftsTrack=anEvent->GetTrack(i5);
11737        if(!(aftsTrack->InRPSelection())) continue;
11738        phi5=aftsTrack->Phi();
11739        for(Int_t i6=0;i6<nPrim;i6++)
11740        {
11741         if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;
11742         aftsTrack=anEvent->GetTrack(i6);
11743         if(!(aftsTrack->InRPSelection())) continue;
11744         phi6=aftsTrack->Phi(); 
11745         for(Int_t i7=0;i7<nPrim;i7++)
11746         {
11747          if(i7==i1||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6)continue;
11748          aftsTrack=anEvent->GetTrack(i7);
11749          if(!(aftsTrack->InRPSelection())) continue;
11750          phi7=aftsTrack->Phi(); 
11751          if(nPrim==7) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<" "<<i6<<" "<<i7<<"\r"<<flush;
11752          // fill the profile with 7-p correlation:   
11753          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}
11754         } // end of for(Int_t i7=0;i7<nPrim;i7++)
11755        } // end of for(Int_t i6=0;i6<nPrim;i6++) 
11756       } // end of for(Int_t i5=0;i5<nPrim;i5++)
11757      } // end of for(Int_t i4=0;i4<nPrim;i4++)  
11758     } // end of for(Int_t i3=0;i3<nPrim;i3++)
11759    } // end of for(Int_t i2=0;i2<nPrim;i2++)
11760   } // end of for(Int_t i1=0;i1<nPrim;i1++)
11761  } // end of if(nPrim>=7)
11762  
11763  // 8-particle correlations:
11764  if(nPrim>=8 && nPrim<=fMaxAllowedMultiplicity)
11765  {
11766   for(Int_t i1=0;i1<nPrim;i1++)
11767   {
11768    aftsTrack=anEvent->GetTrack(i1);
11769    if(!(aftsTrack->InRPSelection())) continue;
11770    phi1=aftsTrack->Phi();
11771    for(Int_t i2=0;i2<nPrim;i2++)
11772    {
11773     if(i2==i1)continue;
11774     aftsTrack=anEvent->GetTrack(i2);
11775     if(!(aftsTrack->InRPSelection())) continue;
11776     phi2=aftsTrack->Phi();
11777     for(Int_t i3=0;i3<nPrim;i3++)
11778     {
11779      if(i3==i1||i3==i2)continue;
11780      aftsTrack=anEvent->GetTrack(i3);
11781      if(!(aftsTrack->InRPSelection())) continue;
11782      phi3=aftsTrack->Phi();
11783      for(Int_t i4=0;i4<nPrim;i4++)
11784      {
11785       if(i4==i1||i4==i2||i4==i3)continue;
11786       aftsTrack=anEvent->GetTrack(i4);
11787       if(!(aftsTrack->InRPSelection())) continue;
11788       phi4=aftsTrack->Phi();
11789       for(Int_t i5=0;i5<nPrim;i5++)
11790       {
11791        if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
11792        aftsTrack=anEvent->GetTrack(i5);
11793        if(!(aftsTrack->InRPSelection())) continue;
11794        phi5=aftsTrack->Phi();
11795        for(Int_t i6=0;i6<nPrim;i6++)
11796        {
11797         if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;
11798         aftsTrack=anEvent->GetTrack(i6);
11799         if(!(aftsTrack->InRPSelection())) continue;
11800         phi6=aftsTrack->Phi();
11801         for(Int_t i7=0;i7<nPrim;i7++)
11802         {
11803          if(i7==i1||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6)continue;
11804          aftsTrack=anEvent->GetTrack(i7);
11805          if(!(aftsTrack->InRPSelection())) continue;
11806          phi7=aftsTrack->Phi();
11807          for(Int_t i8=0;i8<nPrim;i8++)
11808          {
11809           if(i8==i1||i8==i2||i8==i3||i8==i4||i8==i5||i8==i6||i8==i7)continue;
11810           aftsTrack=anEvent->GetTrack(i8);
11811           if(!(aftsTrack->InRPSelection())) continue;
11812           phi8=aftsTrack->Phi();
11813           cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<" "<<i6<<" "<<i7<<" "<<i8<<"\r"<<flush;
11814           // fill the profile with 8-p correlation:   
11815           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}
11816          } // end of for(Int_t i8=0;i8<nPrim;i8++)
11817         } // end of for(Int_t i7=0;i7<nPrim;i7++) 
11818        } // end of for(Int_t i6=0;i6<nPrim;i6++) 
11819       } // end of for(Int_t i5=0;i5<nPrim;i5++)
11820      } // end of for(Int_t i4=0;i4<nPrim;i4++)  
11821     } // end of for(Int_t i3=0;i3<nPrim;i3++)
11822    } // end of for(Int_t i2=0;i2<nPrim;i2++)
11823   } // end of for(Int_t i1=0;i1<nPrim;i1++)
11824  } // end of if(nPrim>=8)
11825  
11826  cout<<endl;
11827
11828 } // end of AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoops(AliFlowEventSimple* anEvent)
11829
11830
11831 //==================================================================================================================================
11832
11833
11834 void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrelations()
11835 {
11836  // Cross-check results for multiparticle correlations needed for int. flow: results from Q-vectors vs results from nested loops.
11837
11838  cout<<endl;
11839  cout<<endl;
11840  cout<<"   *****************************************"<<endl;
11841  cout<<"   **** cross-checking the correlations ****"<<endl;
11842  cout<<"   ****       for integrated flow       ****"<<endl;
11843  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
11844  {
11845   cout<<"   ****   (particle weights not used)   ****"<<endl;
11846  } else
11847    {
11848     cout<<"   ****     (particle weights used)     ****"<<endl;
11849    } 
11850  cout<<"   *****************************************"<<endl;
11851  cout<<endl;
11852  cout<<endl;
11853
11854  Int_t ciMax = 64; // to be improved (removed eventually when I calculate 6th and 8th order with particle weights)
11855  
11856  if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights)
11857  {
11858   ciMax = 11;
11859  }
11860
11861  for(Int_t ci=1;ci<=ciMax;ci++)
11862  {
11863   if(strcmp((fIntFlowCorrelationsAllPro->GetXaxis())->GetBinLabel(ci), "") == 0) continue; // to be improved (access finalized histogram here)
11864   cout<<(fIntFlowCorrelationsAllPro->GetXaxis())->GetBinLabel(ci)<<":"<<endl; // to be improved (access finalized histogram here)
11865   cout<<"from Q-vectors    = "<<fIntFlowCorrelationsAllPro->GetBinContent(ci)<<endl; // to be improved (access finalized histogram here)
11866   cout<<"from nested loops = "<<fIntFlowDirectCorrelations->GetBinContent(ci)<<endl;
11867   cout<<endl;
11868  }
11869   
11870 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrelations()
11871
11872 //================================================================================================================================
11873
11874 void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrectionTermsForNUA()
11875 {
11876  // Cross-check results for corrections terms for non-uniform acceptance needed for int. flow: results from Q-vectors vs results from nested loops.
11877
11878  cout<<endl;
11879  cout<<endl;
11880  cout<<"   *********************************************"<<endl;
11881  cout<<"   **** cross-checking the correction terms ****"<<endl;
11882  cout<<"   **** for non-uniform acceptance relevant ****"<<endl;
11883  cout<<"   ****         for integrated flow         ****"<<endl;
11884  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
11885  {
11886   cout<<"   ****     (particle weights not used)     ****"<<endl;
11887  } else
11888    {
11889     cout<<"   ****       (particle weights used)       ****"<<endl;
11890    } 
11891  cout<<"   *********************************************"<<endl;
11892  cout<<endl;
11893  cout<<endl;
11894
11895  for(Int_t ci=1;ci<=4;ci++) // correction term index (to be improved - hardwired 4)
11896  {
11897   for(Int_t sc=0;sc<2;sc++) // sin or cos term
11898   {
11899    if(strcmp((fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->GetBinLabel(ci), "") == 0) continue; // to be improved (access finalized histogram here)
11900    cout<<(fIntFlowCorrectionTermsForNUAPro[sc]->GetXaxis())->GetBinLabel(ci)<<":"<<endl; // to be improved (access finalized histogram here)
11901    cout<<"from Q-vectors    = "<<fIntFlowCorrectionTermsForNUAPro[sc]->GetBinContent(ci)<<endl; // to be improved (access finalized histogram here)
11902    cout<<"from nested loops = "<<fIntFlowDirectCorrectionTermsForNUA[sc]->GetBinContent(ci)<<endl;
11903    cout<<endl;
11904   } // end of for(Int_t sc=0;sc<2;sc++) // sin or cos term
11905  } // end of for(Int_t ci=1;ci<=10;ci++) // correction term index
11906   
11907 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowCorrectionTermsForNUA() 
11908
11909 //================================================================================================================================
11910
11911 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple * const anEvent)
11912 {
11913  // Evaluate with nested loops multiparticle correlations for integrated flow (using the particle weights). 
11914
11915  // Results are stored in profile fIntFlowDirectCorrelations. 
11916  // Remark 1: When particle weights are used the binning of fIntFlowDirectCorrelations is organized as follows:
11917  //
11918  //  1st bin: <2>_{1n|1n} = two1n1nW1W1 = <w1 w2 cos(n*(phi1-phi2))>
11919  //  2nd bin: <2>_{2n|2n} = two2n2nW2W2 = <w1^2 w2^2 cos(2n*(phi1-phi2))>
11920  //  3rd bin: <2>_{3n|3n} = two3n3nW3W3 = <w1^3 w2^3 cos(3n*(phi1-phi2))> 
11921  //  4th bin: <2>_{4n|4n} = two4n4nW4W4 = <w1^4 w2^4 cos(4n*(phi1-phi2))>
11922  //  5th bin:           ----  EMPTY ----
11923  //  6th bin: <3>_{2n|1n,1n} = three2n1n1nW2W1W1 = <w1^2 w2 w3 cos(n*(2phi1-phi2-phi3))>
11924  //  7th bin: <3>_{3n|2n,1n} = ...
11925  //  8th bin: <3>_{4n|2n,2n} = ...
11926  //  9th bin: <3>_{4n|3n,1n} = ...
11927  // 10th bin:           ----  EMPTY ----
11928  // 11th bin: <4>_{1n,1n|1n,1n} = four1n1n1n1nW1W1W1W1 = <w1 w2 w3 w4 cos(n*(phi1+phi2-phi3-phi4))>
11929  // 12th bin: <4>_{2n,1n|2n,1n} = ...
11930  // 13th bin: <4>_{2n,2n|2n,2n} = ...
11931  // 14th bin: <4>_{3n|1n,1n,1n} = ... 
11932  // 15th bin: <4>_{3n,1n|3n,1n} = ...
11933  // 16th bin: <4>_{3n,1n|2n,2n} = ...
11934  // 17th bin: <4>_{4n|2n,1n,1n} = ... 
11935  // 18th bin:           ----  EMPTY ----
11936  // 19th bin: <5>_{2n|1n,1n,1n,1n} = ...
11937  // 20th bin: <5>_{2n,2n|2n,1n,1n} = ...
11938  // 21st bin: <5>_{3n,1n|2n,1n,1n} = ...
11939  // 22nd bin: <5>_{4n|1n,1n,1n,1n} = ...
11940  // 23rd bin:           ----  EMPTY ----
11941  // 24th bin: <6>_{1n,1n,1n|1n,1n,1n} = ...
11942  // 25th bin: <6>_{2n,1n,1n|2n,1n,1n} = ...
11943  // 26th bin: <6>_{2n,2n|1n,1n,1n,1n} = ...
11944  // 27th bin: <6>_{3n,1n|1n,1n,1n,1n} = ...
11945  // 28th bin:           ----  EMPTY ----
11946  // 29th bin: <7>_{2n,1n,1n|1n,1n,1n,1n} = ...
11947  // 30th bin:           ----  EMPTY ----
11948  // 31st bin: <8>_{1n,1n,1n,1n|1n,1n,1n,1n} = ...
11949  
11950  // Remark 2: When particle weights are used there are some extra correlations. They are stored in 
11951  // fIntFlowExtraDirectCorrelations binning of which is organized as follows:
11952  
11953  // 1st bin: two1n1nW3W1 = <w1^3 w2 cos(n*(phi1-phi2))>
11954  // 2nd bin: two1n1nW1W1W2 = <w1 w2 w3^2 cos(n*(phi1-phi2))>  
11955  // ...
11956  
11957  Int_t nPrim = anEvent->NumberOfTracks(); 
11958  AliFlowTrackSimple *aftsTrack = NULL;
11959  //Double_t phi1=0., phi2=0., phi3=0., phi4=0., phi5=0., phi6=0., phi7=0., phi8=0.;
11960  //Double_t wPhi1=1., wPhi2=1., wPhi3=1., wPhi4=1., wPhi5=1., wPhi6=1., wPhi7=1., wPhi8=1.;
11961  Double_t phi1=0., phi2=0., phi3=0., phi4=0.;
11962  Double_t wPhi1=1., wPhi2=1., wPhi3=1., wPhi4=1.;
11963  Int_t n = fHarmonic; 
11964  Int_t eventNo = (Int_t)fAvMultiplicity->GetBinEntries(1); // to be improved (is this casting safe in general?)
11965  Double_t dMult = (*fSpk)(0,0);
11966  cout<<endl;
11967  cout<<"Multiparticle correlations: Event number: "<<eventNo<<", multiplicity is "<<dMult<<endl;
11968  if(dMult<2)
11969  {
11970   cout<<"... skipping this event (multiplicity too low) ..."<<endl;
11971  } else if (dMult>fMaxAllowedMultiplicity)
11972    {
11973     cout<<"... skipping this event (multiplicity too high) ..."<<endl;
11974    } else 
11975      { 
11976       cout<<"... evaluating nested loops (using particle weights) ..."<<endl;
11977      } 
11978       
11979  // 2-particle correlations:       
11980  if(nPrim>=2 && nPrim<=fMaxAllowedMultiplicity)
11981  {
11982   // 2 nested loops multiparticle correlations using particle weights:       
11983   for(Int_t i1=0;i1<nPrim;i1++)
11984   {
11985    aftsTrack=anEvent->GetTrack(i1);
11986    if(!(aftsTrack->InRPSelection())) continue;
11987    phi1=aftsTrack->Phi();
11988    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));
11989    for(Int_t i2=0;i2<nPrim;i2++)
11990    {
11991     if(i2==i1)continue;
11992     aftsTrack=anEvent->GetTrack(i2);
11993     if(!(aftsTrack->InRPSelection())) continue;
11994     phi2=aftsTrack->Phi();
11995     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));   
11996     if(nPrim==2) cout<<i1<<" "<<i2<<"\r"<<flush;
11997     // 2-p correlations using particle weights:
11998     if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(0.5,cos(n*(phi1-phi2)),wPhi1*wPhi2);                  // <w1   w2   cos( n*(phi1-phi2))>
11999     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))>
12000     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))>
12001     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))> 
12002     // extra correlations: 
12003     // 2-p extra correlations (do not appear if particle weights are not used):
12004     if(fUsePhiWeights) fIntFlowExtraDirectCorrelations->Fill(0.5,cos(n*(phi1-phi2)),pow(wPhi1,3)*wPhi2); // <w1^3 w2 cos(n*(phi1-phi2))>
12005     // ...
12006    } // end of for(Int_t i2=0;i2<nPrim;i2++)
12007   } // end of for(Int_t i1=0;i1<nPrim;i1++)
12008  } // end of if(nPrim>=2)
12009
12010  if(nPrim>=3 && nPrim<=fMaxAllowedMultiplicity)
12011  { 
12012   // 3 nested loops multiparticle correlations using particle weights:       
12013   for(Int_t i1=0;i1<nPrim;i1++)
12014   {
12015    aftsTrack=anEvent->GetTrack(i1);
12016    if(!(aftsTrack->InRPSelection())) continue;
12017    phi1=aftsTrack->Phi();
12018    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));
12019    for(Int_t i2=0;i2<nPrim;i2++)
12020    {
12021     if(i2==i1)continue;
12022     aftsTrack=anEvent->GetTrack(i2);
12023     if(!(aftsTrack->InRPSelection())) continue;
12024     phi2=aftsTrack->Phi();
12025     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));
12026     for(Int_t i3=0;i3<nPrim;i3++)
12027     {
12028      if(i3==i1||i3==i2)continue;
12029      aftsTrack=anEvent->GetTrack(i3);
12030      if(!(aftsTrack->InRPSelection())) continue;
12031      phi3=aftsTrack->Phi();
12032      if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));
12033      if(nPrim==3) cout<<i1<<" "<<i2<<" "<<i3<<"\r"<<flush;
12034      // 3-p correlations using particle weights:
12035      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))>
12036      // ...
12037      // extra correlations: 
12038      // 2-p extra correlations (do not appear if particle weights are not used):
12039       if(fUsePhiWeights) fIntFlowExtraDirectCorrelations->Fill(1.5,cos(n*(phi1-phi2)),wPhi1*wPhi2*pow(wPhi3,2)); // <w1 w2 w3^2 cos(n*(phi1-phi2))>
12040      // ...
12041      // 3-p extra correlations (do not appear if particle weights are not used):
12042      // ...
12043     } // end of for(Int_t i3=0;i3<nPrim;i3++)
12044    } // end of for(Int_t i2=0;i2<nPrim;i2++)
12045   } // end of for(Int_t i1=0;i1<nPrim;i1++)
12046  } // end of if(nPrim>=3)
12047  
12048  if(nPrim>=4 && nPrim<=fMaxAllowedMultiplicity)
12049  {
12050   // 4 nested loops multiparticle correlations using particle weights:       
12051   for(Int_t i1=0;i1<nPrim;i1++)
12052   {
12053    aftsTrack=anEvent->GetTrack(i1);
12054    if(!(aftsTrack->InRPSelection())) continue;
12055    phi1=aftsTrack->Phi();
12056    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));
12057    for(Int_t i2=0;i2<nPrim;i2++)
12058    {
12059     if(i2==i1)continue;
12060     aftsTrack=anEvent->GetTrack(i2);
12061     if(!(aftsTrack->InRPSelection())) continue;
12062     phi2=aftsTrack->Phi();
12063     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));
12064     for(Int_t i3=0;i3<nPrim;i3++)
12065     {
12066      if(i3==i1||i3==i2)continue;
12067      aftsTrack=anEvent->GetTrack(i3);
12068      if(!(aftsTrack->InRPSelection())) continue;
12069      phi3=aftsTrack->Phi();
12070      if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));
12071      for(Int_t i4=0;i4<nPrim;i4++)
12072      {
12073       if(i4==i1||i4==i2||i4==i3)continue;
12074       aftsTrack=anEvent->GetTrack(i4);
12075       if(!(aftsTrack->InRPSelection())) continue;
12076       phi4=aftsTrack->Phi();
12077       if(fUsePhiWeights && fPhiWeights) wPhi4 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi4*fnBinsPhi/TMath::TwoPi())));
12078       if(nPrim>=4) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<"\r"<<flush; // to be improved (replace eventually this if statement with if(nPrim==4))
12079       // 4-p correlations using particle weights:
12080       if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(10.5,cos(n*phi1+n*phi2-n*phi3-n*phi4),wPhi1*wPhi2*wPhi3*wPhi4); 
12081       // extra correlations: 
12082       // 2-p extra correlations (do not appear if particle weights are not used):
12083       // ...
12084       // 3-p extra correlations (do not appear if particle weights are not used):
12085       // ...
12086       // 4-p extra correlations (do not appear if particle weights are not used):
12087       // ...
12088      } // end of for(Int_t i4=0;i4<nPrim;i4++) 
12089     } // end of for(Int_t i3=0;i3<nPrim;i3++)
12090    } // end of for(Int_t i2=0;i2<nPrim;i2++)
12091   } // end of for(Int_t i1=0;i1<nPrim;i1++)
12092  } // end of if(nPrim>=4)
12093
12094  cout<<endl; 
12095
12096 } // end of void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent)
12097
12098 //================================================================================================================================
12099
12100 void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowExtraCorrelations()
12101 {
12102  // Cross-check results for extra multiparticle correlations needed for int. flow 
12103  // which appear only when particle weights are used: results from Q-vectors vs results from nested loops.
12104
12105  cout<<endl;
12106  cout<<endl;
12107  cout<<"   ***********************************************"<<endl;
12108  cout<<"   **** cross-checking the extra correlations ****"<<endl;
12109  cout<<"   ****          for integrated flow          ****"<<endl;
12110  cout<<"   ***********************************************"<<endl;
12111  cout<<endl;
12112  cout<<endl;
12113  
12114  for(Int_t eci=1;eci<=2;eci++) // to be improved (increased eciMax eventually when I calculate 6th and 8th)
12115  {
12116   if(strcmp((fIntFlowExtraCorrelationsPro->GetXaxis())->GetBinLabel(eci), "") == 0) continue;
12117   cout<<(fIntFlowExtraCorrelationsPro->GetXaxis())->GetBinLabel(eci)<<":"<<endl;
12118   cout<<"from Q-vectors    = "<<fIntFlowExtraCorrelationsPro->GetBinContent(eci)<<endl;
12119   cout<<"from nested loops = "<<fIntFlowExtraDirectCorrelations->GetBinContent(eci)<<endl;
12120   cout<<endl;
12121  }
12122
12123 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckIntFlowExtraCorrelations()
12124
12125 //================================================================================================================================
12126
12127 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrectionsForNUAWithNestedLoops(AliFlowEventSimple * const anEvent)
12128 {
12129  // Evaluate with nested loops correction terms for non-uniform acceptance relevant for NONAME integrated flow (to be improved (name)).
12130  //
12131  // Remark: Both sin and cos correction terms are calculated in this method. Sin terms are stored in fIntFlowDirectCorrectionTermsForNUA[0],
12132  // and cos terms in fIntFlowDirectCorrectionTermsForNUA[1]. Binning of fIntFlowDirectCorrectionTermsForNUA[sc] is organized as follows 
12133  // (sc stands for either sin or cos):
12134  
12135  //  1st bin: <<sc(n*(phi1))>> 
12136  //  2nd bin: <<sc(n*(phi1+phi2))>> 
12137  //  3rd bin: <<sc(n*(phi1-phi2-phi3))>>
12138  //  4th bin: <<sc(n*(2phi1-phi2))>>
12139  
12140  Int_t nPrim = anEvent->NumberOfTracks(); 
12141  AliFlowTrackSimple *aftsTrack = NULL;
12142  Double_t phi1=0., phi2=0., phi3=0.;
12143  Int_t n = fHarmonic; 
12144  Int_t eventNo = (Int_t)fAvMultiplicity->GetBinEntries(1); // to be improved (is this casting safe in general?)
12145  Double_t dMult = (*fSpk)(0,0);
12146  cout<<endl;
12147  cout<<"Correction terms for non-uniform acceptance: Event number: "<<eventNo<<", multiplicity is "<<dMult<<endl;
12148  if(dMult<1)
12149  {
12150   cout<<"... skipping this event (multiplicity too low) ..."<<endl;
12151  } else if (dMult>fMaxAllowedMultiplicity)
12152    {
12153     cout<<"... skipping this event (multiplicity too high) ..."<<endl;
12154    } else 
12155      { 
12156       cout<<"... evaluating nested loops (without using particle weights)..."<<endl;
12157      }
12158  
12159  if(nPrim>=1 && nPrim<=fMaxAllowedMultiplicity)
12160  {
12161   // 1-particle correction terms for non-uniform acceptance:       
12162   for(Int_t i1=0;i1<nPrim;i1++)
12163   {
12164    aftsTrack=anEvent->GetTrack(i1);
12165    if(!(aftsTrack->InRPSelection())) continue;
12166    phi1=aftsTrack->Phi();
12167    if(nPrim==1) cout<<i1<<"\r"<<flush;
12168    // sin terms:
12169    fIntFlowDirectCorrectionTermsForNUA[0]->Fill(0.5,sin(n*phi1),1.); // <sin(n*phi1)>  
12170    // cos terms:
12171    fIntFlowDirectCorrectionTermsForNUA[1]->Fill(0.5,cos(n*phi1),1.); // <cos(n*phi1)>
12172   } // end of for(Int_t i1=0;i1<nPrim;i1++)
12173  } // end of if(nPrim>=1) 
12174   
12175  if(nPrim>=2 && nPrim<=fMaxAllowedMultiplicity)
12176  {
12177   // 2-particle correction terms for non-uniform acceptance:       
12178   for(Int_t i1=0;i1<nPrim;i1++)
12179   {
12180    aftsTrack=anEvent->GetTrack(i1);
12181    if(!(aftsTrack->InRPSelection())) continue;
12182    phi1=aftsTrack->Phi();  
12183    for(Int_t i2=0;i2<nPrim;i2++)
12184    {
12185     if(i2==i1)continue;
12186     aftsTrack=anEvent->GetTrack(i2);
12187     if(!(aftsTrack->InRPSelection())) continue;
12188     phi2=aftsTrack->Phi();
12189     if(nPrim==2) cout<<i1<<" "<<i2<<"\r"<<flush;
12190     // sin terms:
12191     fIntFlowDirectCorrectionTermsForNUA[0]->Fill(1.5,sin(n*(phi1+phi2)),1.); // <<sin(n*(phi1+phi2))>>
12192     fIntFlowDirectCorrectionTermsForNUA[0]->Fill(3.5,sin(n*(2*phi1-phi2)),1.); // <<sin(n*(2*phi1-phi2))>>
12193     // cos terms:
12194     fIntFlowDirectCorrectionTermsForNUA[1]->Fill(1.5,cos(n*(phi1+phi2)),1.); // <<cos(n*(phi1+phi2))>>
12195     fIntFlowDirectCorrectionTermsForNUA[1]->Fill(3.5,cos(n*(2*phi1-phi2)),1.); // <<cos(n*(2*phi1-phi2))>>
12196    } // end of for(Int_t i2=0;i2<nPrim;i2++)
12197   } // end of for(Int_t i1=0;i1<nPrim;i1++)
12198  } // end of if(nPrim>=2)
12199
12200  if(nPrim>=3 && nPrim<=fMaxAllowedMultiplicity)
12201  {
12202   // 3-particle correction terms for non-uniform acceptance:       
12203   for(Int_t i1=0;i1<nPrim;i1++)
12204   {
12205    aftsTrack=anEvent->GetTrack(i1);
12206    if(!(aftsTrack->InRPSelection())) continue;
12207    phi1=aftsTrack->Phi();
12208    for(Int_t i2=0;i2<nPrim;i2++)
12209    {
12210     if(i2==i1)continue;
12211     aftsTrack=anEvent->GetTrack(i2);
12212     if(!(aftsTrack->InRPSelection())) continue;
12213     phi2=aftsTrack->Phi();
12214     for(Int_t i3=0;i3<nPrim;i3++)
12215     {
12216      if(i3==i1||i3==i2)continue;
12217      aftsTrack=anEvent->GetTrack(i3);
12218      if(!(aftsTrack->InRPSelection())) continue;
12219      phi3=aftsTrack->Phi();
12220      if(nPrim>=3) cout<<i1<<" "<<i2<<" "<<i3<<"\r"<<flush; // to be improved (eventually I will change this if statement)
12221      // sin terms:
12222      fIntFlowDirectCorrectionTermsForNUA[0]->Fill(2.5,sin(n*(phi1-phi2-phi3)),1.); // <<sin(n*(phi1-phi2-phi3))>>
12223      // cos terms:
12224      fIntFlowDirectCorrectionTermsForNUA[1]->Fill(2.5,cos(n*(phi1-phi2-phi3)),1.); // <<cos(n*(phi1-phi2-phi3))>>
12225     } // end of for(Int_t i3=0;i3<nPrim;i3++)
12226    } // end of for(Int_t i2=0;i2<nPrim;i2++)
12227   } // end of for(Int_t i1=0;i1<nPrim;i1++)
12228  } // end of if(nPrim>=3)
12229
12230  cout<<endl;
12231 }
12232
12233 //================================================================================================================================
12234
12235 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoops(AliFlowEventSimple * const anEvent, TString type, TString ptOrEta)
12236 {
12237  // Evaluate reduced correlations with nested loops without using the particle weights.
12238  
12239  // Remark 1: Reduced correlations are evaluated in pt bin number fCrossCheckInPtBinNo and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.
12240  // Remark 2: Results are stored in 1 bin profiles fDiffFlowDirectCorrelations[t][pe][ci], where indices runs as follows:
12241  //           [0=RP,1=POI][0=Pt,1=Eta][0=<2'>,1=<4'>,2=<6'>,3=<8'>] 
12242  // Remark 3: <2'> = <cos(n*(psi1-phi2))>
12243  //           <4'> = <cos(n*(psi1+phi2-phi3-phi4))>
12244  // ...
12245  
12246  Int_t typeFlag = 0;
12247  Int_t ptEtaFlag = 0;
12248  if(type == "RP")
12249  {
12250   typeFlag = 0;
12251  } else if(type == "POI")
12252    {
12253     typeFlag = 1;
12254    }      
12255  if(ptOrEta == "Pt")
12256  {
12257   ptEtaFlag = 0;
12258  } else if(ptOrEta == "Eta")
12259    {
12260     ptEtaFlag = 1;
12261    } 
12262  // shortcuts:
12263  Int_t t = typeFlag;
12264  Int_t pe = ptEtaFlag;
12265       
12266  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
12267  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
12268  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
12269  
12270  Int_t nPrim = anEvent->NumberOfTracks(); 
12271  AliFlowTrackSimple *aftsTrack = NULL;
12272  
12273  Double_t psi1=0., phi2=0., phi3=0., phi4=0.;// phi5=0., phi6=0., phi7=0., phi8=0.;
12274  
12275  Int_t n = fHarmonic; 
12276   
12277  // 2'-particle correlations:
12278  for(Int_t i1=0;i1<nPrim;i1++)
12279  {
12280   aftsTrack=anEvent->GetTrack(i1);
12281   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12282   if(typeFlag==1) // this is diff flow of POIs 
12283   {
12284    if(ptOrEta == "Pt")
12285    { 
12286     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12287    } else if (ptOrEta == "Eta")
12288      {
12289       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12290      }
12291   } else // this is diff flow of RPs 
12292     {
12293      if(ptOrEta == "Pt")
12294      { 
12295       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
12296      } else if (ptOrEta == "Eta")
12297        {
12298         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
12299        }
12300     }
12301        
12302   psi1=aftsTrack->Phi(); 
12303   for(Int_t i2=0;i2<nPrim;i2++)
12304   {
12305    if(i2==i1)continue;
12306    aftsTrack=anEvent->GetTrack(i2);
12307    // RP condition (!(first) particle in the correlator must be RP):
12308    if(!(aftsTrack->InRPSelection()))continue;
12309    phi2=aftsTrack->Phi();   
12310    // 2'-particle correlations: 
12311    fDiffFlowDirectCorrelations[t][pe][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(1.*n*(psi1-phi2)),1.); // <cos(n*(psi1-phi2))  
12312   }//end of for(Int_t i2=0;i2<nPrim;i2++)
12313  }//end of for(Int_t i1=0;i1<nPrim;i1++)
12314  
12315  /*
12316  
12317  // 3'-particle correlations:
12318  for(Int_t i1=0;i1<nPrim;i1++)
12319  {
12320   aftsTrack=anEvent->GetTrack(i1);
12321   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12322   if(ptOrEta == "Pt")
12323   { 
12324    if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12325   } else if (ptOrEta == "Eta")
12326     {
12327      if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12328     }
12329   psi1=aftsTrack->Phi();
12330   for(Int_t i2=0;i2<nPrim;i2++)
12331   {
12332    if(i2==i1)continue;
12333    aftsTrack=anEvent->GetTrack(i2);
12334    // RP condition (!(first) particle in the correlator must be RP):
12335    if(!(aftsTrack->InRPSelection())) continue;
12336    phi2=aftsTrack->Phi();
12337    for(Int_t i3=0;i3<nPrim;i3++)
12338    {
12339     if(i3==i1||i3==i2)continue;
12340     aftsTrack=anEvent->GetTrack(i3);
12341     // RP condition (!(first) particle in the correlator must be RP):
12342     if(!(aftsTrack->InRPSelection())) continue;
12343     phi3=aftsTrack->Phi();
12344     // 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))> 
12345    }//end of for(Int_t i3=0;i3<nPrim;i3++)  
12346   }//end of for(Int_t i2=0;i2<nPrim;i2++)  
12347  }//end of for(Int_t i1=0;i1<nPrim;i1++)
12348  
12349  */
12350  
12351  // 4'-particle correlations:
12352  for(Int_t i1=0;i1<nPrim;i1++)
12353  {
12354   aftsTrack=anEvent->GetTrack(i1);
12355   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12356   if(typeFlag==1) // this is diff flow of POIs 
12357   {
12358    if(ptOrEta == "Pt")
12359    { 
12360     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12361    } else if (ptOrEta == "Eta")
12362      {
12363       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12364      }
12365   } else // this is diff flow of RPs 
12366     {
12367      if(ptOrEta == "Pt")
12368      { 
12369       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
12370      } else if (ptOrEta == "Eta")
12371        {
12372         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
12373        }
12374     }
12375     
12376   psi1=aftsTrack->Phi();
12377   for(Int_t i2=0;i2<nPrim;i2++)
12378   {
12379    if(i2==i1) continue;
12380    aftsTrack=anEvent->GetTrack(i2);
12381    // RP condition (!(first) particle in the correlator must be RP): 
12382    if(!(aftsTrack->InRPSelection())) continue;
12383    phi2=aftsTrack->Phi();
12384    for(Int_t i3=0;i3<nPrim;i3++)
12385    { 
12386     if(i3==i1||i3==i2) continue;
12387     aftsTrack=anEvent->GetTrack(i3);
12388     // RP condition (!(first) particle in the correlator must be RP):
12389     if(!(aftsTrack->InRPSelection())) continue;
12390     phi3=aftsTrack->Phi();
12391     for(Int_t i4=0;i4<nPrim;i4++)
12392     {
12393      if(i4==i1||i4==i2||i4==i3) continue;
12394      aftsTrack=anEvent->GetTrack(i4);
12395      // RP condition (!(first) particle in the correlator must be RP):
12396      if(!(aftsTrack->InRPSelection())) continue;  
12397      phi4=aftsTrack->Phi();
12398      // 4'-particle correlations:
12399      fDiffFlowDirectCorrelations[t][pe][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2-phi3-phi4)),1.); // <cos(n(psi1+phi2-phi3-phi4))>     
12400     }//end of for(Int_t i4=0;i4<nPrim;i4++)
12401    }//end of for(Int_t i3=0;i3<nPrim;i3++)
12402   }//end of for(Int_t i2=0;i2<nPrim;i2++) 
12403  }//end of for(Int_t i1=0;i1<nPrim;i1++)
12404       
12405  // count # of RPs and POIs in selected pt and eta bins for cross-checkings:
12406  for(Int_t i=0;i<nPrim;i++)
12407  {
12408   aftsTrack=anEvent->GetTrack(i); 
12409   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12410   if(typeFlag==1) // this is diff flow of POIs 
12411   {
12412    if(ptOrEta == "Pt")
12413    { 
12414     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12415    } else if (ptOrEta == "Eta")
12416      {
12417       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12418      }
12419   } else // this is diff flow of RPs 
12420     {
12421      if(ptOrEta == "Pt")
12422      { 
12423       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
12424      } else if (ptOrEta == "Eta")
12425        {
12426         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
12427        }
12428     }
12429   if(t==1)t++; 
12430   fNoOfParticlesInBin->Fill(t+pe+0.5);  
12431  }
12432
12433 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoops(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)
12434
12435 //================================================================================================================================
12436
12437 void AliFlowAnalysisWithQCumulants::EvaluateOtherDiffCorrelatorsWithNestedLoops(AliFlowEventSimple * const anEvent, TString type, TString ptOrEta)
12438 {
12439  // Evaluate other differential correlators with nested loops without using the particle weights.
12440
12441  // Remark 1: Other differential correlators are evaluated in pt bin number fCrossCheckInPtBinNo 
12442  //           and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.
12443  // Remark 2: Results are stored in 1 bin profiles fOtherDirectDiffCorrelators[t][pe][sc][ci], where indices runs as follows:
12444  //           [0=RP,1=POI][0=Pt,1=Eta][0=sin terms,1=cos terms][ci = correlator index] 
12445  // Remark 3: Correlator index 'ci' runs as follows:
12446  //            0: <exp(n*(psi1-3phi2+2phi3))> (Teaney-Yan correlator)
12447   
12448  Int_t typeFlag = 0;
12449  Int_t ptEtaFlag = 0;
12450  if(type == "RP")
12451  {
12452   typeFlag = 0;
12453  } else if(type == "POI")
12454    {
12455     typeFlag = 1;
12456    }      
12457  if(ptOrEta == "Pt")
12458  {
12459   ptEtaFlag = 0;
12460  } else if(ptOrEta == "Eta")
12461    {
12462     ptEtaFlag = 1;
12463    } 
12464  // shortcuts:
12465  Int_t t = typeFlag;
12466  Int_t pe = ptEtaFlag;
12467       
12468  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
12469  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
12470  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
12471  
12472  Int_t nPrim = anEvent->NumberOfTracks(); 
12473  AliFlowTrackSimple *aftsTrack = NULL;
12474  
12475  Double_t psi1=0., phi2=0., phi3=0.;
12476  
12477  Int_t n = fHarmonic; 
12478
12479  // 3-p correlators:
12480  for(Int_t i1=0;i1<nPrim;i1++)
12481  {
12482   aftsTrack=anEvent->GetTrack(i1);
12483   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12484   if(typeFlag==1) // this is diff flow of POIs 
12485   {
12486    if(ptOrEta == "Pt")
12487    { 
12488     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12489    } else if (ptOrEta == "Eta")
12490      {
12491       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12492      }
12493   } else // this is diff flow of RPs 
12494     {
12495      if(ptOrEta == "Pt")
12496      { 
12497       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
12498      } else if (ptOrEta == "Eta")
12499        {
12500         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
12501        }
12502     }
12503   psi1=aftsTrack->Phi();
12504   for(Int_t i2=0;i2<nPrim;i2++)
12505   {
12506    if(i2==i1) continue;
12507    aftsTrack=anEvent->GetTrack(i2);
12508    // RP condition (!(first) particle in the correlator must be RP): 
12509    if(!(aftsTrack->InRPSelection())) continue;
12510    phi2=aftsTrack->Phi();
12511    for(Int_t i3=0;i3<nPrim;i3++)
12512    { 
12513     if(i3==i1||i3==i2) continue;
12514     aftsTrack=anEvent->GetTrack(i3);
12515     // RP condition (!(first) particle in the correlator must be RP):
12516     if(!(aftsTrack->InRPSelection())) continue;
12517     phi3=aftsTrack->Phi();
12518     // Fill 3-p correlators:
12519     fOtherDirectDiffCorrelators[t][pe][1][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1-3.*phi2+2.*phi3)),1.); // <cos(n(psi1-3.*phi2+2.*phi3))>     
12520    }//end of for(Int_t i3=0;i3<nPrim;i3++)
12521   }//end of for(Int_t i2=0;i2<nPrim;i2++) 
12522  }//end of for(Int_t i1=0;i1<nPrim;i1++)   
12523 } // end of void AliFlowAnalysisWithQCumulants::EvaluateOtherDiffCorrelatorsWithNestedLoops(AliFlowEventSimple * const anEvent, TString type, TString ptOrEta)
12524
12525 //================================================================================================================================
12526
12527 void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrelations(TString type, TString ptOrEta)
12528 {
12529  // Compare correlations needed for diff. flow calculated with nested loops and those calculated from Q-vectors
12530  
12531  Int_t typeFlag = 0;
12532  Int_t ptEtaFlag = 0;
12533  if(type == "RP")
12534  {
12535   typeFlag = 0;
12536  } else if(type == "POI")
12537    {
12538     typeFlag = 1;
12539    }      
12540  if(ptOrEta == "Pt")
12541  {
12542   ptEtaFlag = 0;
12543  } else if(ptOrEta == "Eta")
12544    {
12545     ptEtaFlag = 1;
12546    } 
12547  // shortcuts:
12548  Int_t t = typeFlag;
12549  Int_t pe = ptEtaFlag;
12550       
12551  TString rpORpoiString[2] = {"RP ","POI"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) 
12552  TString ptORetaString[2] = {"pt","eta"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) 
12553  TString reducedCorrelations[4] = {"<<cos(n(psi1-phi2))>>","<<cos(n(psi1+phi2-phi3-phi4))>>","",""}; // to be improved (access this from pro or hist)
12554  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
12555  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
12556  
12557  Int_t crossCheckInPtEtaBinNo[2] = {fCrossCheckInPtBinNo,fCrossCheckInEtaBinNo};
12558  
12559
12560  cout<<endl;
12561  cout<<"   *****************************************"<<endl;
12562  cout<<"   **** cross-checking the correlations ****"<<endl;
12563  cout<<"   ****   for differential flow ("<<rpORpoiString[t]<<")   ****"<<endl;
12564  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
12565  {
12566   cout<<"   ****   (particle weights not used)   ****"<<endl;
12567  } else
12568    {
12569     cout<<"   ****    (particle weights used)      ****"<<endl;
12570    } 
12571  cout<<"   *****************************************"<<endl; 
12572  cout<<endl;
12573  cout<<"           "<<ptORetaString[pe]<<" bin: "<<lowerPtEtaEdge[pe]<<" <= "<<ptORetaString[pe]<<" < "<<upperPtEtaEdge[pe]<<endl;
12574  cout<<endl;
12575  
12576  for(Int_t rci=0;rci<2;rci++) // to be improved (calculate 6th and 8th order)
12577  {
12578   cout<<"      "<<reducedCorrelations[rci].Data()<<":"<<endl;
12579   cout<<"      from Q-vectors    = "<<fDiffFlowCorrelationsPro[t][pe][rci]->GetBinContent(crossCheckInPtEtaBinNo[pe])<<endl;
12580   cout<<"      from nested loops = "<<fDiffFlowDirectCorrelations[t][pe][rci]->GetBinContent(1)<<endl;
12581   cout<<endl;  
12582  } // end of for(Int_t rci=0;rci<4;rci++)
12583         
12584 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrelations(TString type, TString ptOrEta)
12585
12586 //================================================================================================================================
12587
12588 void AliFlowAnalysisWithQCumulants::CrossCheckOtherDiffCorrelators(TString type, TString ptOrEta)
12589 {
12590  // Compare correlations needed for diff. flow calculated with nested loops and those calculated from Q-vectors
12591  
12592  Int_t typeFlag = 0;
12593  Int_t ptEtaFlag = 0;
12594  if(type == "RP")
12595  {
12596   typeFlag = 0;
12597  } else if(type == "POI")
12598    {
12599     typeFlag = 1;
12600    }      
12601  if(ptOrEta == "Pt")
12602  {
12603   ptEtaFlag = 0;
12604  } else if(ptOrEta == "Eta")
12605    {
12606     ptEtaFlag = 1;
12607    } 
12608  // shortcuts:
12609  Int_t t = typeFlag;
12610  Int_t pe = ptEtaFlag;
12611       
12612  TString rpORpoiString[2] = {"RP ","POI"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) 
12613  TString ptORetaString[2] = {"pt","eta"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) 
12614  TString otherCorrelators[1] = {"<<cos(n(psi1-3phi2+2phi3))>>"}; // to be improved (access this from pro or hist)
12615  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
12616  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
12617  
12618  Int_t crossCheckInPtEtaBinNo[2] = {fCrossCheckInPtBinNo,fCrossCheckInEtaBinNo};
12619
12620  cout<<endl;
12621  cout<<"   *****************************************"<<endl;
12622  cout<<"   ****   cross-checking the other      ****"<<endl;
12623  cout<<"   ****   diff. correlators ("<<rpORpoiString[t]<<")       ****"<<endl;
12624  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
12625  {
12626   cout<<"   ****   (particle weights not used)   ****"<<endl;
12627  } else
12628    {
12629     cout<<"   ****    (particle weights used)      ****"<<endl;
12630    } 
12631  cout<<"   *****************************************"<<endl; 
12632  cout<<endl;
12633  cout<<"           "<<ptORetaString[pe]<<" bin: "<<lowerPtEtaEdge[pe]<<" <= "<<ptORetaString[pe]<<" < "<<upperPtEtaEdge[pe]<<endl;
12634  cout<<endl;
12635  
12636  for(Int_t ci=0;ci<1;ci++) 
12637  {
12638   cout<<"      "<<otherCorrelators[ci].Data()<<":"<<endl;
12639   cout<<"      from Q-vectors    = "<<fOtherDiffCorrelators[t][pe][1][ci]->GetBinContent(crossCheckInPtEtaBinNo[pe])<<endl;
12640   cout<<"      from nested loops = "<<fOtherDirectDiffCorrelators[t][pe][1][ci]->GetBinContent(1)<<endl;
12641   cout<<endl;  
12642  } // end of for(Int_t ci=0;ci<1;ci++)
12643         
12644 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckOtherDiffCorrelators(TString type, TString ptOrEta)
12645
12646 //================================================================================================================================
12647
12648 void AliFlowAnalysisWithQCumulants::PrintNumberOfParticlesInSelectedBin()
12649 {
12650  // Print on the screen number of RPs and POIs in selected pt and eta bin for cross checkings.
12651  
12652  cout<<endl;
12653  cout<<"Number of RPs in selected pt bin   = "<<fNoOfParticlesInBin->GetBinContent(1)<<endl;
12654  cout<<"Number of RPs in selected eta bin  = "<<fNoOfParticlesInBin->GetBinContent(2)<<endl;
12655  cout<<"Number of POIs in selected pt bin  = "<<fNoOfParticlesInBin->GetBinContent(3)<<endl;
12656  cout<<"Number of POIs in selected eta bin = "<<fNoOfParticlesInBin->GetBinContent(4)<<endl;
12657  
12658 } // end of void AliFlowAnalysisWithQCumulants::PrintNumberOfParticlesInSelectedBin()
12659
12660 //================================================================================================================================
12661
12662 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple * const anEvent, TString type, TString ptOrEta)
12663 {
12664  // Evaluate reduced correlations with nested loops without using the particle weights.
12665  
12666  // Remark 1: Reduced correlations are evaluated in pt bin number fCrossCheckInPtBinNo and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.
12667  // Remark 2: Results are stored in 1 bin profiles fDiffFlowDirectCorrelations[t][pe][ci], where indices runs as follows:
12668  //           [0=RP,1=POI][0=Pt,1=Eta][0=<2'>,1=<4'>,2=<6'>,3=<8'>] 
12669  // Remark 3: <2'> = <w2 cos(n*(psi1-phi2))>
12670  //           <4'> = <w2 w3 w4 cos(n*(psi1+phi2-phi3-phi4))>
12671  // ...
12672   
12673  Int_t typeFlag = 0;
12674  Int_t ptEtaFlag = 0;
12675  if(type == "RP")
12676  {
12677   typeFlag = 0;
12678  } else if(type == "POI")
12679    {
12680     typeFlag = 1;
12681    }      
12682  if(ptOrEta == "Pt")
12683  {
12684   ptEtaFlag = 0;
12685  } else if(ptOrEta == "Eta")
12686    {
12687     ptEtaFlag = 1;
12688    } 
12689  // shortcuts:
12690  Int_t t = typeFlag;
12691  Int_t pe = ptEtaFlag;
12692       
12693  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
12694  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
12695  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
12696  
12697  Int_t nPrim = anEvent->NumberOfTracks(); 
12698  AliFlowTrackSimple *aftsTrack = NULL;
12699  
12700  Double_t psi1=0., phi2=0., phi3=0., phi4=0.;// phi5=0., phi6=0., phi7=0., phi8=0.;
12701  Double_t wPhi2=1., wPhi3=1., wPhi4=1.;// wPhi5=1., wPhi6=1., wPhi7=1., wPhi8=1.;
12702  
12703  Int_t n = fHarmonic; 
12704  
12705  // 2'-particle correlations:
12706  for(Int_t i1=0;i1<nPrim;i1++)
12707  {
12708   aftsTrack=anEvent->GetTrack(i1);
12709   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12710   if(typeFlag==1) // this is diff flow of POIs 
12711   {
12712    if(ptOrEta == "Pt")
12713    { 
12714     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12715    } else if (ptOrEta == "Eta")
12716      {
12717       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12718      }
12719   } else // this is diff flow of RPs 
12720     {
12721      if(ptOrEta == "Pt")
12722      { 
12723       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
12724      } else if (ptOrEta == "Eta")
12725        {
12726         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
12727        }
12728     }
12729   psi1=aftsTrack->Phi(); 
12730   for(Int_t i2=0;i2<nPrim;i2++)
12731   {
12732    if(i2==i1) continue;
12733    aftsTrack=anEvent->GetTrack(i2);
12734    // RP condition (!(first) particle in the correlator must be RP):
12735    if(!(aftsTrack->InRPSelection())) continue;
12736    phi2=aftsTrack->Phi();   
12737    if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));
12738    // 2'-particle correlations: 
12739    fDiffFlowDirectCorrelations[t][pe][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(1.*n*(psi1-phi2)),wPhi2); // <w2 cos(n*(psi1-phi2))  
12740   }//end of for(Int_t i2=0;i2<nPrim;i2++)
12741  }//end of for(Int_t i1=0;i1<nPrim;i1++)
12742  
12743  // 4'-particle correlations:
12744  for(Int_t i1=0;i1<nPrim;i1++)
12745  {
12746   aftsTrack=anEvent->GetTrack(i1);
12747   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12748   if(typeFlag==1) // this is diff flow of POIs 
12749   {
12750    if(ptOrEta == "Pt")
12751    { 
12752     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12753    } else if (ptOrEta == "Eta")
12754      {
12755       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12756      }
12757   } else // this is diff flow of RPs 
12758     {
12759      if(ptOrEta == "Pt")
12760      { 
12761       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
12762      } else if (ptOrEta == "Eta")
12763        {
12764         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
12765        }
12766     }
12767   psi1=aftsTrack->Phi();
12768   for(Int_t i2=0;i2<nPrim;i2++)
12769   {
12770    if(i2==i1) continue;
12771    aftsTrack=anEvent->GetTrack(i2);
12772    // RP condition (!(first) particle in the correlator must be RP): 
12773    if(!(aftsTrack->InRPSelection())) continue;
12774    phi2=aftsTrack->Phi();
12775    if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));
12776    for(Int_t i3=0;i3<nPrim;i3++)
12777    { 
12778     if(i3==i1||i3==i2) continue;
12779     aftsTrack=anEvent->GetTrack(i3);
12780     // RP condition (!(first) particle in the correlator must be RP):
12781     if(!(aftsTrack->InRPSelection())) continue;
12782     phi3=aftsTrack->Phi();
12783     if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));
12784     for(Int_t i4=0;i4<nPrim;i4++)
12785     {
12786      if(i4==i1||i4==i2||i4==i3) continue;
12787      aftsTrack=anEvent->GetTrack(i4);
12788      // RP condition (!(first) particle in the correlator must be RP):
12789      if(!(aftsTrack->InRPSelection())) continue;  
12790      phi4=aftsTrack->Phi();
12791      if(fUsePhiWeights && fPhiWeights) wPhi4 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi4*fnBinsPhi/TMath::TwoPi())));
12792      // 4'-particle correlations <w2 w3 w4 cos(n(psi1+phi2-phi3-phi4))>:
12793      fDiffFlowDirectCorrelations[t][pe][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2-phi3-phi4)),wPhi2*wPhi3*wPhi4); 
12794     }//end of for(Int_t i4=0;i4<nPrim;i4++)
12795    }//end of for(Int_t i3=0;i3<nPrim;i3++)
12796   }//end of for(Int_t i2=0;i2<nPrim;i2++) 
12797  }//end of for(Int_t i1=0;i1<nPrim;i1++)      
12798  
12799  // count # of RPs and POIs in selected pt and eta bins for cross-checkings: (to be improved - moved to dedicated method)
12800  for(Int_t i=0;i<nPrim;i++)
12801  {
12802   aftsTrack=anEvent->GetTrack(i); 
12803   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12804   if(typeFlag==1) // this is diff flow of POIs 
12805   {
12806    if(ptOrEta == "Pt")
12807    { 
12808     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12809    } else if (ptOrEta == "Eta")
12810      {
12811       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12812      }
12813   } else // this is diff flow of RPs 
12814     {
12815      if(ptOrEta == "Pt")
12816      { 
12817       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
12818      } else if (ptOrEta == "Eta")
12819        {
12820         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
12821        }
12822     }
12823   if(t==1)t++; 
12824   fNoOfParticlesInBin->Fill(t+pe+0.5);  
12825  }
12826  
12827 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrelationsWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)
12828
12829 //================================================================================================================================
12830
12831 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(AliFlowEventSimple * const anEvent, TString type, TString ptOrEta)
12832 {
12833  // Evaluate with nested loops correction terms for non-uniform acceptance (both sin and cos terms) relevant for differential flow.
12834  
12835  // Remark 1: Reduced correction terms for non-uniform acceptance are evaluated in pt bin number fCrossCheckInPtBinNo 
12836  //           and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.
12837  // Remark 2: Results are stored in 1 bin profiles fDiffFlowDirectCorrections[t][pe][sc][cti], where first three indices runs as: 
12838  //           [0=RP,1=POI][0=Pt,1=Eta][0=sin terms,1=cos terms], whilst the cti (correction term index) runs as follows: 
12839  //  cti: 
12840  //    0: <<sc n(psi1)>>
12841  //    1: <<sc n(psi1+phi2)>> 
12842  //    2: <<sc n(psi1+phi2-phi3)>>
12843  //    3: <<sc n(psi1-phi2-phi3)>>
12844  //    4:
12845  //    5:
12846  //    6:
12847   
12848  Int_t typeFlag = 0;
12849  Int_t ptEtaFlag = 0;
12850  if(type == "RP")
12851  {
12852   typeFlag = 0;
12853  } else if(type == "POI")
12854    {
12855     typeFlag = 1;
12856    }      
12857  if(ptOrEta == "Pt")
12858  {
12859   ptEtaFlag = 0;
12860  } else if(ptOrEta == "Eta")
12861    {
12862     ptEtaFlag = 1;
12863    } 
12864  // shortcuts:
12865  Int_t t = typeFlag;
12866  Int_t pe = ptEtaFlag;
12867       
12868  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
12869  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
12870  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
12871  
12872  Int_t nPrim = anEvent->NumberOfTracks(); 
12873  AliFlowTrackSimple *aftsTrack = NULL;
12874  
12875  Double_t psi1=0., phi2=0., phi3=0.;// phi4=0.;// phi5=0., phi6=0., phi7=0., phi8=0.;
12876  
12877  Int_t n = fHarmonic; 
12878  
12879  // 1-particle correction terms:
12880  for(Int_t i1=0;i1<nPrim;i1++)
12881  {
12882   aftsTrack=anEvent->GetTrack(i1);
12883   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12884   if(typeFlag==1) // this is diff flow of POIs 
12885   {
12886    if(ptOrEta == "Pt")
12887    { 
12888     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12889    } else if (ptOrEta == "Eta")
12890      {
12891       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12892      }
12893   } else // this is diff flow of RPs 
12894     {
12895      if(ptOrEta == "Pt")
12896      { 
12897       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
12898      } else if (ptOrEta == "Eta")
12899        {
12900         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
12901        }
12902     }
12903   psi1=aftsTrack->Phi(); 
12904   // sin terms: 
12905   fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*psi1),1.); // <<sin(n*(psi1))>>  
12906   // cos terms: 
12907   fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*psi1),1.); // <<cos(n*(psi1))>>  
12908  }//end of for(Int_t i1=0;i1<nPrim;i1++)
12909    
12910  // 2-particle correction terms:
12911  for(Int_t i1=0;i1<nPrim;i1++)
12912  {
12913   aftsTrack=anEvent->GetTrack(i1);
12914    // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12915   if(typeFlag==1) // this is diff flow of POIs 
12916   {
12917    if(ptOrEta == "Pt")
12918    { 
12919     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12920    } else if (ptOrEta == "Eta")
12921      {
12922       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12923      }
12924   } else // this is diff flow of RPs 
12925     {
12926      if(ptOrEta == "Pt")
12927      { 
12928       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
12929      } else if (ptOrEta == "Eta")
12930        {
12931         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
12932        }
12933     }
12934   psi1=aftsTrack->Phi(); 
12935   for(Int_t i2=0;i2<nPrim;i2++)
12936   {
12937    if(i2==i1) continue;
12938    aftsTrack=anEvent->GetTrack(i2);
12939    // RP condition (!(first) particle in the correlator must be RP):
12940    if(!(aftsTrack->InRPSelection())) continue;
12941    phi2=aftsTrack->Phi();   
12942    // sin terms: 
12943    fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1+phi2)),1.); // <<sin(n*(psi1+phi2))>>  
12944    // cos terms: 
12945    fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2)),1.); // <<cos(n*(psi1+phi2))>>  
12946   }//end of for(Int_t i2=0;i2<nPrim;i2++)
12947  }//end of for(Int_t i1=0;i1<nPrim;i1++)   
12948  
12949  // 3-particle correction terms:
12950  for(Int_t i1=0;i1<nPrim;i1++)
12951  {
12952   aftsTrack=anEvent->GetTrack(i1);
12953    // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
12954   if(typeFlag==1) // this is diff flow of POIs 
12955   {
12956    if(ptOrEta == "Pt")
12957    { 
12958     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
12959    } else if (ptOrEta == "Eta")
12960      {
12961       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
12962      }
12963   } else // this is diff flow of RPs 
12964     {
12965      if(ptOrEta == "Pt")
12966      { 
12967       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
12968      } else if (ptOrEta == "Eta")
12969        {
12970         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
12971        }
12972     }
12973   psi1=aftsTrack->Phi();
12974   for(Int_t i2=0;i2<nPrim;i2++)
12975   {
12976    if(i2==i1) continue;
12977    aftsTrack=anEvent->GetTrack(i2);
12978    // RP condition (!(first) particle in the correlator must be RP):
12979    if(!(aftsTrack->InRPSelection())) continue;
12980    phi2=aftsTrack->Phi();
12981    for(Int_t i3=0;i3<nPrim;i3++)
12982    {
12983     if(i3==i1||i3==i2) continue;
12984     aftsTrack=anEvent->GetTrack(i3);
12985     // RP condition (!(first) particle in the correlator must be RP):
12986     if(!(aftsTrack->InRPSelection())) continue;
12987     phi3=aftsTrack->Phi();
12988     // sin terms: 
12989     fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][2]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1+phi2-phi3)),1.); // <<sin(n*(psi1+phi2-phi3))>>  
12990     fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][3]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1-phi2-phi3)),1.); // <<sin(n*(psi1-phi2-phi3))>>  
12991     // cos terms: 
12992     fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][2]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2-phi3)),1.); // <<cos(n*(psi1+phi2-phi3))>>  
12993     fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][3]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1-phi2-phi3)),1.); // <<cos(n*(psi1-phi2-phi3))>>  
12994    }//end of for(Int_t i3=0;i3<nPrim;i3++)  
12995   }//end of for(Int_t i2=0;i2<nPrim;i2++)  
12996  }//end of for(Int_t i1=0;i1<nPrim;i1++)
12997    
12998 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoops(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)
12999
13000
13001 //================================================================================================================================
13002
13003
13004 void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrectionTermsForNUA(TString type, TString ptOrEta)
13005 {
13006  // Compare corrections temrs for non-uniform acceptance needed for diff. flow calculated with nested loops and those calculated from Q-vectors
13007  
13008  Int_t typeFlag = 0;
13009  Int_t ptEtaFlag = 0;
13010  if(type == "RP")
13011  {
13012   typeFlag = 0;
13013  } else if(type == "POI")
13014    {
13015     typeFlag = 1;
13016    }      
13017  if(ptOrEta == "Pt")
13018  {
13019   ptEtaFlag = 0;
13020  } else if(ptOrEta == "Eta")
13021    {
13022     ptEtaFlag = 1;
13023    } 
13024  // shortcuts:
13025  Int_t t = typeFlag;
13026  Int_t pe = ptEtaFlag;
13027       
13028  TString rpORpoiString[2] = {"RP ","POI"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) 
13029  TString ptORetaString[2] = {"pt","eta"}; // to be improved (name in the same way as in the other methods, eventually promote to data member) 
13030  //TString sinCosFlag[2] = {"sin","cos"}; // to be improved (eventually promote to data member)
13031  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)
13032  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)
13033  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
13034  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
13035  
13036  Int_t crossCheckInPtEtaBinNo[2] = {fCrossCheckInPtBinNo,fCrossCheckInEtaBinNo};
13037  
13038  cout<<endl;
13039  cout<<"   ******************************************"<<endl;
13040  cout<<"   ****  cross-checking the correction   ****"<<endl;
13041  cout<<"   **** terms for non-uniform acceptance ****"<<endl; 
13042  cout<<"   ****    for differential flow ("<<rpORpoiString[t]<<")   ****"<<endl;
13043  if(!(fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights))
13044  {
13045   cout<<"   ****    (particle weights not used)   ****"<<endl;
13046  } else
13047    {
13048     cout<<"   ****     (particle weights used)      ****"<<endl;
13049    } 
13050  cout<<"   ******************************************"<<endl; 
13051  cout<<endl;
13052  cout<<"           "<<ptORetaString[pe]<<" bin: "<<lowerPtEtaEdge[pe]<<" <= "<<ptORetaString[pe]<<" < "<<upperPtEtaEdge[pe]<<endl;
13053  cout<<endl;
13054  
13055  for(Int_t cti=0;cti<4;cti++) // correction term index
13056  {
13057   for(Int_t sc=0;sc<2;sc++) // sin or cos terms
13058   {
13059    if(sc==0) // to be improved (this can be implemented better)
13060    { 
13061     cout<<"      "<<reducedCorrectionSinTerms[cti].Data()<<":"<<endl;
13062    } else
13063      {
13064       cout<<"      "<<reducedCorrectionCosTerms[cti].Data()<<":"<<endl;     
13065      }
13066    cout<<"      from Q-vectors    = "<<fDiffFlowCorrectionTermsForNUAPro[t][pe][sc][cti]->GetBinContent(crossCheckInPtEtaBinNo[pe])<<endl;
13067    cout<<"      from nested loops = "<<fDiffFlowDirectCorrectionTermsForNUA[t][pe][sc][cti]->GetBinContent(1)<<endl;
13068    cout<<endl;  
13069   } 
13070  } // end of for(Int_t rci=0;rci<4;rci++)
13071
13072 } // end of void AliFlowAnalysisWithQCumulants::CrossCheckDiffFlowCorrectionTermsForNUA(TString type, TString ptOrEta)
13073
13074 //================================================================================================================================
13075
13076 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUACosTermsUsingParticleWeights()
13077 {
13078  // Calculate corrections using particle weights for non-uniform acceptance of the detector for no-name integrated flow (cos terms).
13079  
13080  //                                  **********************************************************************
13081  //                                  **** weighted corrections for non-uniform acceptance (cos terms): ****
13082  //                                  **********************************************************************
13083  
13084  // Remark 1: When particle weights are used the binning of fIntFlowCorrectionTermsForNUAPro[1] is organized as follows:
13085  //
13086  // 1st bin: <<w1 cos(n*(phi1))>> = cosP1nW1
13087  // 2nd bin: <<w1 w2 cos(n*(phi1+phi2))>> = cosP1nP1nW1W1
13088  // 3rd bin: <<w1 w2 w3 cos(n*(phi1-phi2-phi3))>> = cosP1nM1nM1nW1W1W1 
13089  // ...
13090
13091  // multiplicity (number of particles used to determine the reaction plane)
13092  Double_t dMult = (*fSpk)(0,0);
13093  
13094  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
13095  Double_t dReQ1n1k = (*fReQ)(0,1);
13096  Double_t dReQ2n2k = (*fReQ)(1,2);
13097  //Double_t dReQ3n3k = (*fReQ)(2,3);
13098  //Double_t dReQ4n4k = (*fReQ)(3,4);
13099  Double_t dReQ1n3k = (*fReQ)(0,3);
13100  Double_t dImQ1n1k = (*fImQ)(0,1);
13101  Double_t dImQ2n2k = (*fImQ)(1,2);
13102  //Double_t dImQ3n3k = (*fImQ)(2,3);
13103  //Double_t dImQ4n4k = (*fImQ)(3,4);
13104  //Double_t dImQ1n3k = (*fImQ)(0,3);
13105
13106  // dMs are variables introduced in order to simplify some Eqs. bellow:
13107  //..............................................................................................
13108  Double_t dM11 = (*fSpk)(1,1)-(*fSpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j
13109  Double_t dM111 = (*fSpk)(2,1)-3.*(*fSpk)(0,2)*(*fSpk)(0,1)
13110                 + 2.*(*fSpk)(0,3); // dM111 = sum_{i,j,k=1,i!=j!=k}^M w_i w_j w_k
13111  //..............................................................................................
13112          // 1-particle:
13113  Double_t cosP1nW1 = 0.; // <<w1 cos(n*(phi1))>>
13114    
13115  if(dMult>0 && TMath::Abs((*fSpk)(0,1))>1.e-6)
13116  {
13117   cosP1nW1 = dReQ1n1k/(*fSpk)(0,1); 
13118   
13119   // average weighted 1-particle correction (cos terms) for non-uniform acceptance for single event:
13120   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(1,cosP1nW1);
13121   
13122   // final average weighted 1-particle correction (cos terms) for non-uniform acceptance for all events:
13123   fIntFlowCorrectionTermsForNUAPro[1]->Fill(0.5,cosP1nW1,(*fSpk)(0,1));  
13124  } 
13125  
13126  // 2-particle:
13127  Double_t cosP1nP1nW1W1 = 0.; // <<w1 w2 cos(n*(phi1+phi2))>>
13128  
13129  if(dMult>1 && TMath::Abs(dM11)>1.e-6)
13130  {
13131   cosP1nP1nW1W1 = (pow(dReQ1n1k,2)-pow(dImQ1n1k,2)-dReQ2n2k)/dM11; 
13132   
13133   // average weighted 2-particle correction (cos terms) for non-uniform acceptance for single event:
13134   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(2,cosP1nP1nW1W1);
13135   
13136   // final average weighted 2-particle correction (cos terms) for non-uniform acceptance for all events:
13137   fIntFlowCorrectionTermsForNUAPro[1]->Fill(1.5,cosP1nP1nW1W1,dM11);  
13138  } 
13139  
13140  // 3-particle:
13141  Double_t cosP1nM1nM1nW1W1W1 = 0.; // <<w1 w2 w3 cos(n*(phi1-phi2-phi3))>>
13142  
13143  if(dMult>2 && TMath::Abs(dM111)>1.e-6)
13144  {
13145   cosP1nM1nM1nW1W1W1 = (dReQ1n1k*(pow(dReQ1n1k,2)+pow(dImQ1n1k,2))
13146                      - dReQ1n1k*dReQ2n2k-dImQ1n1k*dImQ2n2k
13147                      - 2.*((*fSpk)(0,2))*dReQ1n1k
13148                      + 2.*dReQ1n3k) 
13149                      / dM111; 
13150   
13151   // average non-weighted 3-particle correction (cos terms) for non-uniform acceptance for single event:
13152   fIntFlowCorrectionTermsForNUAEBE[1]->SetBinContent(3,cosP1nM1nM1nW1W1W1);
13153   
13154   // final average non-weighted 3-particle correction (cos terms) for non-uniform acceptance for all events:
13155   fIntFlowCorrectionTermsForNUAPro[1]->Fill(2.5,cosP1nM1nM1nW1W1W1,dM111);  
13156  } 
13157  
13158 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUACosTermsUsingParticleWeights()
13159
13160
13161 //================================================================================================================================
13162
13163
13164 void AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUASinTermsUsingParticleWeights()
13165 {
13166  // calculate corrections using particle weights for non-uniform acceptance of the detector for no-name integrated flow (sin terms)
13167  
13168  //                                  **********************************************************************
13169  //                                  **** weighted corrections for non-uniform acceptance (sin terms): ****
13170  //                                  **********************************************************************
13171  
13172  // Remark 1: When particle weights are used the binning of fIntFlowCorrectionTermsForNUAPro[0] is organized as follows:
13173  //
13174  // 1st bin: <<w1 sin(n*(phi1))>> = sinP1nW1
13175  // 2nd bin: <<w1 w2 sin(n*(phi1+phi2))>> = sinP1nP1nW1W1
13176  // 3rd bin: <<w1 w2 w3 sin(n*(phi1-phi2-phi3))>> = sinP1nM1nM1nW1W1W1 
13177  // ...
13178
13179  // multiplicity (number of particles used to determine the reaction plane)
13180  Double_t dMult = (*fSpk)(0,0);
13181  
13182  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
13183  Double_t dReQ1n1k = (*fReQ)(0,1);
13184  Double_t dReQ2n2k = (*fReQ)(1,2);
13185  //Double_t dReQ3n3k = (*fReQ)(2,3);
13186  //Double_t dReQ4n4k = (*fReQ)(3,4);
13187  //Double_t dReQ1n3k = (*fReQ)(0,3);
13188  Double_t dImQ1n1k = (*fImQ)(0,1);
13189  Double_t dImQ2n2k = (*fImQ)(1,2);
13190  //Double_t dImQ3n3k = (*fImQ)(2,3);
13191  //Double_t dImQ4n4k = (*fImQ)(3,4);
13192  Double_t dImQ1n3k = (*fImQ)(0,3);
13193
13194  // dMs are variables introduced in order to simplify some Eqs. bellow:
13195  //..............................................................................................
13196  Double_t dM11 = (*fSpk)(1,1)-(*fSpk)(0,2); // dM11 = sum_{i,j=1,i!=j}^M w_i w_j
13197  Double_t dM111 = (*fSpk)(2,1)-3.*(*fSpk)(0,2)*(*fSpk)(0,1)
13198                 + 2.*(*fSpk)(0,3); // dM111 = sum_{i,j,k=1,i!=j!=k}^M w_i w_j w_k
13199  //..............................................................................................
13200  
13201  // 1-particle:
13202  Double_t sinP1nW1 = 0.; // <<w1 sin(n*(phi1))>>
13203  
13204  if(dMult>0 && TMath::Abs((*fSpk)(0,1))>1.e-6)
13205  {
13206   sinP1nW1 = dImQ1n1k/((*fSpk)(0,1)); 
13207      
13208   // average weighted 1-particle correction (sin terms) for non-uniform acceptance for single event:
13209   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(1,sinP1nW1);
13210   
13211   // final average weighted 1-particle correction (sin terms) for non-uniform acceptance for all events:   
13212   fIntFlowCorrectionTermsForNUAPro[0]->Fill(0.5,sinP1nW1,(*fSpk)(0,1));  
13213  } 
13214  
13215  // 2-particle:
13216  Double_t sinP1nP1nW1W1 = 0.; // <<w1 w2 sin(n*(phi1+phi2))>>
13217  
13218  if(dMult>1 && TMath::Abs(dM11)>1.e-6)
13219  {
13220   sinP1nP1nW1W1 = (2.*dReQ1n1k*dImQ1n1k-dImQ2n2k)/dM11; 
13221      
13222   // average weighted 2-particle correction (sin terms) for non-uniform acceptance for single event:
13223   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(2,sinP1nP1nW1W1);
13224   
13225   // final average weighted 1-particle correction (sin terms) for non-uniform acceptance for all events:      
13226   fIntFlowCorrectionTermsForNUAPro[0]->Fill(1.5,sinP1nP1nW1W1,dM11);  
13227  } 
13228  
13229  // 3-particle:
13230  Double_t sinP1nM1nM1nW1W1W1 = 0.; // <<w1 w2 w3 sin(n*(phi1-phi2-phi3))>>
13231  
13232  if(dMult>2 && TMath::Abs(dM111)>1.e-6)
13233  {
13234   sinP1nM1nM1nW1W1W1 = (-dImQ1n1k*(pow(dReQ1n1k,2)+pow(dImQ1n1k,2))
13235                      + dReQ1n1k*dImQ2n2k-dImQ1n1k*dReQ2n2k
13236                      + 2.*((*fSpk)(0,2))*dImQ1n1k
13237                      - 2.*dImQ1n3k)
13238                      / dM111; 
13239   
13240   // average weighted 3-particle correction (sin terms) for non-uniform acceptance for single event:
13241   fIntFlowCorrectionTermsForNUAEBE[0]->SetBinContent(3,sinP1nM1nM1nW1W1W1);
13242   
13243   // final average weighted 3-particle correction (sin terms) for non-uniform acceptance for all events:  
13244   fIntFlowCorrectionTermsForNUAPro[0]->Fill(2.5,sinP1nM1nM1nW1W1W1,dM111);  
13245  } 
13246  
13247 } // end of AliFlowAnalysisWithQCumulants::CalculateIntFlowCorrectionsForNUASinTermsUsingParticleWeights()
13248
13249 //================================================================================================================================
13250
13251 void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrectionsForNUAWithNestedLoopsUsingParticleWeights(AliFlowEventSimple * const anEvent)
13252 {
13253  // Evaluate with nested loops correction terms for non-uniform acceptance for integrated flow (using the particle weights). 
13254
13255  // Results are stored in profiles fIntFlowDirectCorrectionTermsForNUA[0] (sin terms) and
13256  // fIntFlowDirectCorrectionTermsForNUA[1] (cos terms). 
13257  
13258  // Remark 1: When particle weights are used the binning of fIntFlowDirectCorrectionTermsForNUA[sc] is 
13259  // organized as follows (sc stands for either sin or cos):
13260  //
13261  // 1st bin: <<w1 sc(n*(phi1))>> = scP1nW1
13262  // 2nd bin: <<w1 w2 sc(n*(phi1+phi2))>> = scP1nP1nW1W1
13263  // 3rd bin: <<w1 w2 w3 sc(n*(phi1-phi2-phi3))>> = scP1nM1nM1nW1W1W1 
13264  // ...
13265   
13266  Int_t nPrim = anEvent->NumberOfTracks(); 
13267  AliFlowTrackSimple *aftsTrack = NULL;
13268  //Double_t phi1=0., phi2=0., phi3=0., phi4=0., phi5=0., phi6=0., phi7=0., phi8=0.;
13269  //Double_t wPhi1=1., wPhi2=1., wPhi3=1., wPhi4=1., wPhi5=1., wPhi6=1., wPhi7=1., wPhi8=1.;
13270  Double_t phi1=0., phi2=0., phi3=0.;
13271  Double_t wPhi1=1., wPhi2=1., wPhi3=1.;
13272  Int_t n = fHarmonic; 
13273  Int_t eventNo = (Int_t)fAvMultiplicity->GetBinEntries(1); // to be improved (is this casting safe in general?)
13274  Double_t dMult = (*fSpk)(0,0);
13275  cout<<endl;
13276  cout<<"Correction terms for non-uniform acceptance: Event number: "<<eventNo<<", multiplicity is "<<dMult<<endl;
13277  if(dMult<1)
13278  {
13279   cout<<"... skipping this event (multiplicity too low) ..."<<endl;
13280  } else if (dMult>fMaxAllowedMultiplicity)
13281    {
13282     cout<<"... skipping this event (multiplicity too high) ..."<<endl;
13283    } else 
13284      { 
13285       cout<<"... evaluating nested loops (using particle weights) ..."<<endl;
13286      } 
13287       
13288  // 1-particle correction terms using particle weights:       
13289  if(nPrim>=1 && nPrim<=fMaxAllowedMultiplicity)
13290  {
13291   for(Int_t i1=0;i1<nPrim;i1++)
13292   {
13293    aftsTrack=anEvent->GetTrack(i1);
13294    if(!(aftsTrack->InRPSelection())) continue;
13295    phi1=aftsTrack->Phi();
13296    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));
13297    // 1-particle correction terms using particle weights:
13298    if(fUsePhiWeights) fIntFlowDirectCorrectionTermsForNUA[0]->Fill(0.5,sin(n*phi1),wPhi1); // <w1 sin(n*phi1)>
13299    if(fUsePhiWeights) fIntFlowDirectCorrectionTermsForNUA[1]->Fill(0.5,cos(n*phi1),wPhi1); // <w1 cos(n*phi1)>
13300   } // end of for(Int_t i1=0;i1<nPrim;i1++)
13301  } // end of if(nPrim>=1 && nPrim<=fMaxAllowedMultiplicity) 
13302  
13303  // 2-particle correction terms using particle weights:       
13304  if(nPrim>=2 && nPrim<=fMaxAllowedMultiplicity)
13305  {
13306   for(Int_t i1=0;i1<nPrim;i1++)
13307   {
13308    aftsTrack=anEvent->GetTrack(i1);
13309    if(!(aftsTrack->InRPSelection())) continue;
13310    phi1=aftsTrack->Phi();
13311    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));
13312    for(Int_t i2=0;i2<nPrim;i2++)
13313    {
13314     if(i2==i1)continue;
13315     aftsTrack=anEvent->GetTrack(i2);
13316     if(!(aftsTrack->InRPSelection())) continue;
13317     phi2=aftsTrack->Phi();
13318     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));   
13319     if(nPrim==2) cout<<i1<<" "<<i2<<"\r"<<flush;
13320     // 2-p correction terms using particle weights:    
13321     if(fUsePhiWeights) fIntFlowDirectCorrectionTermsForNUA[0]->Fill(1.5,sin(n*(phi1+phi2)),wPhi1*wPhi2); // <w1 w2 sin(n*(phi1+phi2))>
13322     if(fUsePhiWeights) fIntFlowDirectCorrectionTermsForNUA[1]->Fill(1.5,cos(n*(phi1+phi2)),wPhi1*wPhi2); // <w1 w2 cos(n*(phi1+phi2))>
13323    } // end of for(Int_t i2=0;i2<nPrim;i2++)
13324   } // end of for(Int_t i1=0;i1<nPrim;i1++)
13325  } // end of if(nPrim>=2)
13326
13327  // 3-particle correction terms using particle weights:       
13328  if(nPrim>=3 && nPrim<=fMaxAllowedMultiplicity)
13329  { 
13330   for(Int_t i1=0;i1<nPrim;i1++)
13331   {
13332    aftsTrack=anEvent->GetTrack(i1);
13333    if(!(aftsTrack->InRPSelection())) continue;
13334    phi1=aftsTrack->Phi();
13335    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));
13336    for(Int_t i2=0;i2<nPrim;i2++)
13337    {
13338     if(i2==i1)continue;
13339     aftsTrack=anEvent->GetTrack(i2);
13340     if(!(aftsTrack->InRPSelection())) continue;
13341     phi2=aftsTrack->Phi();
13342     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));
13343     for(Int_t i3=0;i3<nPrim;i3++)
13344     {
13345      if(i3==i1||i3==i2)continue;
13346      aftsTrack=anEvent->GetTrack(i3);
13347      if(!(aftsTrack->InRPSelection())) continue;
13348      phi3=aftsTrack->Phi();
13349      if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));
13350      if(nPrim==3) cout<<i1<<" "<<i2<<" "<<i3<<"\r"<<flush;
13351      // 3-p correction terms using particle weights:    
13352      if(fUsePhiWeights) fIntFlowDirectCorrectionTermsForNUA[0]->Fill(2.5,sin(n*(phi1-phi2-phi3)),wPhi1*wPhi2*wPhi3); // <w1 w2 w3 sin(n*(phi1-phi2-phi3))>
13353      if(fUsePhiWeights) fIntFlowDirectCorrectionTermsForNUA[1]->Fill(2.5,cos(n*(phi1-phi2-phi3)),wPhi1*wPhi2*wPhi3); // <w1 w2 w3 cos(n*(phi1-phi2-phi3))>
13354     } // end of for(Int_t i3=0;i3<nPrim;i3++)
13355    } // end of for(Int_t i2=0;i2<nPrim;i2++)
13356   } // end of for(Int_t i1=0;i1<nPrim;i1++)
13357  } // end of if(nPrim>=3)
13358  
13359  /*
13360  
13361  if(nPrim>=4 && nPrim<=fMaxAllowedMultiplicity)
13362  {
13363   // 4 nested loops multiparticle correlations using particle weights:       
13364   for(Int_t i1=0;i1<nPrim;i1++)
13365   {
13366    aftsTrack=anEvent->GetTrack(i1);
13367    if(!(aftsTrack->InRPSelection())) continue;
13368    phi1=aftsTrack->Phi();
13369    if(fUsePhiWeights && fPhiWeights) wPhi1 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi1*fnBinsPhi/TMath::TwoPi())));
13370    for(Int_t i2=0;i2<nPrim;i2++)
13371    {
13372     if(i2==i1)continue;
13373     aftsTrack=anEvent->GetTrack(i2);
13374     if(!(aftsTrack->InRPSelection())) continue;
13375     phi2=aftsTrack->Phi();
13376     if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));
13377     for(Int_t i3=0;i3<nPrim;i3++)
13378     {
13379      if(i3==i1||i3==i2)continue;
13380      aftsTrack=anEvent->GetTrack(i3);
13381      if(!(aftsTrack->InRPSelection())) continue;
13382      phi3=aftsTrack->Phi();
13383      if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));
13384      for(Int_t i4=0;i4<nPrim;i4++)
13385      {
13386       if(i4==i1||i4==i2||i4==i3)continue;
13387       aftsTrack=anEvent->GetTrack(i4);
13388       if(!(aftsTrack->InRPSelection())) continue;
13389       phi4=aftsTrack->Phi();
13390       if(fUsePhiWeights && fPhiWeights) wPhi4 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi4*fnBinsPhi/TMath::TwoPi())));
13391       if(nPrim>=4) cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<"\r"<<flush; // to be improved (replace eventually this if statement with if(nPrim==4))
13392       // 4-p correlations using particle weights:
13393       if(fUsePhiWeights) fIntFlowDirectCorrelations->Fill(10.5,cos(n*phi1+n*phi2-n*phi3-n*phi4),wPhi1*wPhi2*wPhi3*wPhi4); 
13394       // extra correlations: 
13395       // 2-p extra correlations (do not appear if particle weights are not used):
13396       // ...
13397       // 3-p extra correlations (do not appear if particle weights are not used):
13398       // ...
13399       // 4-p extra correlations (do not appear if particle weights are not used):
13400       // ...
13401      } // end of for(Int_t i4=0;i4<nPrim;i4++) 
13402     } // end of for(Int_t i3=0;i3<nPrim;i3++)
13403    } // end of for(Int_t i2=0;i2<nPrim;i2++)
13404   } // end of for(Int_t i1=0;i1<nPrim;i1++)
13405  } // end of if(nPrim>=4)
13406
13407  */
13408
13409  cout<<endl; 
13410
13411 } // end of void AliFlowAnalysisWithQCumulants::EvaluateIntFlowCorrectionsForNUAWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent)
13412
13413 //================================================================================================================================
13414
13415 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUACosTermsUsingParticleWeights(TString type, TString ptOrEta)
13416 {
13417  // Calculate correction terms for non-uniform acceptance for differential flow (cos terms) using particle weights.
13418  
13419  // Results are stored in fDiffFlowCorrectionTermsForNUAPro[t][pe][1][cti], where cti runs as follows:
13420  //
13421  //  0: <<cos n(psi)>>
13422  //  1: <<w2 cos n(psi1+phi2)>>
13423  //  2: <<w2 w3 cos n(psi1+phi2-phi3)>>
13424  //  3: <<w2 w3 cos n(psi1-phi2-phi3)>>
13425  //  4:
13426  //  5:
13427  //  6:
13428  
13429  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
13430  Double_t dReQ1n1k = (*fReQ)(0,1);
13431  Double_t dReQ2n2k = (*fReQ)(1,2);
13432  //Double_t dReQ1n3k = (*fReQ)(0,3);
13433  //Double_t dReQ4n4k = (*fReQ)(3,4);
13434  Double_t dImQ1n1k = (*fImQ)(0,1);
13435  Double_t dImQ2n2k = (*fImQ)(1,2);
13436  //Double_t dImQ1n3k = (*fImQ)(0,3);
13437  //Double_t dImQ4n4k = (*fImQ)(3,4);
13438  
13439  // S^M_{p,k} (see .h file for the definition of fSpk):
13440  Double_t dSM1p1k = (*fSpk)(0,1);
13441  Double_t dSM1p2k = (*fSpk)(0,2);
13442  Double_t dSM2p1k = (*fSpk)(1,1);
13443
13444  Int_t t = 0; // type flag 
13445  Int_t pe = 0; // ptEta flag
13446  
13447  if(type == "RP")
13448  {
13449   t = 0;
13450  } else if(type == "POI")
13451    {
13452     t = 1;
13453    }
13454
13455  if(ptOrEta == "Pt")
13456  {
13457   pe = 0;
13458  } else if(ptOrEta == "Eta")
13459    {
13460     pe = 1;
13461    }
13462     
13463  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
13464  Double_t minPtEta[2] = {fPtMin,fEtaMin};
13465  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
13466  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
13467  
13468  // looping over all bins and calculating correction terms: 
13469  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
13470  {
13471   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): 
13472   Double_t p1n0kRe = 0.;
13473   Double_t p1n0kIm = 0.;
13474
13475   // number of POIs in particular pt or eta bin:
13476   Double_t mp = 0.;
13477
13478   // real and imaginary parts of q_{m*n,0} (weighted Q-vector evaluated for particles which are both RPs and POIs in particular pt or eta bin):
13479   Double_t q1n2kRe = 0.;
13480   //Double_t q1n2kIm = 0.;
13481   Double_t q2n1kRe = 0.;
13482   Double_t q2n1kIm = 0.;
13483     
13484   // s_{1,1}, s_{1,2} // to be improved (add explanation)  
13485   Double_t s1p1k = 0.; 
13486   Double_t s1p2k = 0.; 
13487   
13488   // number of particles which are both RPs and POIs in particular pt or eta bin:
13489   //Double_t mq = 0.;
13490   
13491   // M0111 from Eq. (118) in QC2c (to be improved (notation))
13492   Double_t dM01 = 0.;
13493   Double_t dM011 = 0.;
13494   
13495   if(type == "POI")
13496   {           
13497    // q_{m*n,k}:
13498    q1n2kRe = fReRPQ1dEBE[2][pe][0][2]->GetBinContent(fReRPQ1dEBE[2][pe][0][2]->GetBin(b))
13499            * fReRPQ1dEBE[2][pe][0][2]->GetBinEntries(fReRPQ1dEBE[2][pe][0][2]->GetBin(b));
13500    //q1n2kIm = fImRPQ1dEBE[2][pe][0][2]->GetBinContent(fImRPQ1dEBE[2][pe][0][2]->GetBin(b))
13501    //        * fImRPQ1dEBE[2][pe][0][2]->GetBinEntries(fImRPQ1dEBE[2][pe][0][2]->GetBin(b));         
13502    q2n1kRe = fReRPQ1dEBE[2][pe][1][1]->GetBinContent(fReRPQ1dEBE[2][pe][1][1]->GetBin(b))
13503            * fReRPQ1dEBE[2][pe][1][1]->GetBinEntries(fReRPQ1dEBE[2][pe][1][1]->GetBin(b));
13504    q2n1kIm = fImRPQ1dEBE[2][pe][1][1]->GetBinContent(fImRPQ1dEBE[2][pe][1][1]->GetBin(b))
13505            * fImRPQ1dEBE[2][pe][1][1]->GetBinEntries(fImRPQ1dEBE[2][pe][1][1]->GetBin(b));         
13506    //mq = fReRPQ1dEBE[2][pe][1][1]->GetBinEntries(fReRPQ1dEBE[2][pe][1][1]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
13507    
13508    s1p1k = pow(fs1dEBE[2][pe][1]->GetBinContent(b)*fs1dEBE[2][pe][1]->GetBinEntries(b),1.); 
13509    s1p2k = pow(fs1dEBE[2][pe][2]->GetBinContent(b)*fs1dEBE[2][pe][2]->GetBinEntries(b),1.); 
13510   }else if(type == "RP")
13511    {
13512     // q_{m*n,k}: (Remark: m=1 is 0, k=0 iz zero (to be improved!)) 
13513     q1n2kRe = fReRPQ1dEBE[0][pe][0][2]->GetBinContent(fReRPQ1dEBE[0][pe][0][2]->GetBin(b))
13514             * fReRPQ1dEBE[0][pe][0][2]->GetBinEntries(fReRPQ1dEBE[0][pe][0][2]->GetBin(b));
13515     //q1n2kIm = fImRPQ1dEBE[0][pe][0][2]->GetBinContent(fImRPQ1dEBE[0][pe][0][2]->GetBin(b))
13516     //        * fImRPQ1dEBE[0][pe][0][2]->GetBinEntries(fImRPQ1dEBE[0][pe][0][2]->GetBin(b));
13517     q2n1kRe = fReRPQ1dEBE[0][pe][1][1]->GetBinContent(fReRPQ1dEBE[0][pe][1][1]->GetBin(b))
13518             * fReRPQ1dEBE[0][pe][1][1]->GetBinEntries(fReRPQ1dEBE[0][pe][1][1]->GetBin(b));
13519     q2n1kIm = fImRPQ1dEBE[0][pe][1][1]->GetBinContent(fImRPQ1dEBE[0][pe][1][1]->GetBin(b))
13520             * fImRPQ1dEBE[0][pe][1][1]->GetBinEntries(fImRPQ1dEBE[0][pe][1][1]->GetBin(b));
13521     // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  
13522     s1p1k = pow(fs1dEBE[0][pe][1]->GetBinContent(b)*fs1dEBE[0][pe][1]->GetBinEntries(b),1.); 
13523     s1p2k = pow(fs1dEBE[0][pe][2]->GetBinContent(b)*fs1dEBE[0][pe][2]->GetBinEntries(b),1.); 
13524     //s1p3k = pow(fs1dEBE[0][pe][3]->GetBinContent(b)*fs1dEBE[0][pe][3]->GetBinEntries(b),1.);  
13525     
13526     //mq = fReRPQ1dEBE[0][pe][1][1]->GetBinEntries(fReRPQ1dEBE[0][pe][1][1]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here) 
13527   }    
13528   
13529   if(type == "POI")
13530   {
13531    // p_{m*n,k}:   
13532    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))
13533            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));
13534    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  
13535            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));
13536    mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here) 
13537    // M01 from Eq. (118) in QC2c (to be improved (notation)):
13538    dM01 = mp*dSM1p1k-s1p1k;
13539    dM011 = mp*(dSM2p1k-dSM1p2k)
13540          - 2.*(s1p1k*dSM1p1k-s1p2k);
13541        
13542    // typeFlag = RP (0) or POI (1):   
13543    t = 1; 
13544   } else if(type == "RP")
13545     {  
13546      // to be improved (cross-checked):
13547      p1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))
13548              * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));
13549      p1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))  
13550              * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));
13551      mp = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
13552      // M01 from Eq. (118) in QC2c (to be improved (notation)):
13553      dM01 = mp*dSM1p1k-s1p1k;
13554      dM011 = mp*(dSM2p1k-dSM1p2k)
13555            - 2.*(s1p1k*dSM1p1k-s1p2k); 
13556      // typeFlag = RP (0) or POI (1): 
13557      t = 0;
13558     }
13559   
13560   // <<cos n(psi1)>>:
13561   Double_t cosP1nPsi = 0.;
13562   if(mp)
13563   {
13564    cosP1nPsi = p1n0kRe/mp;
13565    
13566    // fill profile for <<cos n(psi1)>>:
13567    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi,mp);
13568    // histogram to store <cos n(psi1)> e-b-e (needed in some other methods):
13569    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][0]->SetBinContent(b,cosP1nPsi);
13570   } // end of if(mp)   
13571   
13572   // <<w2 cos n(psi1+phi2)>>:
13573   Double_t cosP1nPsiP1nPhiW2 = 0.;
13574   if(dM01)
13575   {
13576    cosP1nPsiP1nPhiW2 = (p1n0kRe*dReQ1n1k-p1n0kIm*dImQ1n1k-q2n1kRe)/(dM01);
13577    // fill profile for <<w2 cos n(psi1+phi2)>>:
13578    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsiP1nPhiW2,dM01);
13579    // histogram to store <w2 cos n(psi1+phi2)> e-b-e (needed in some other methods):
13580    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][1]->SetBinContent(b,cosP1nPsiP1nPhiW2);
13581   } // end of if(dM01)   
13582   
13583   // <<w2 w3 cos n(psi1+phi2-phi3)>>:
13584   Double_t cosP1nPsi1P1nPhi2MPhi3W2W3 = 0.;
13585   if(dM011)
13586   {
13587    cosP1nPsi1P1nPhi2MPhi3W2W3 = (p1n0kRe*(pow(dImQ1n1k,2.)+pow(dReQ1n1k,2.))
13588                               - p1n0kRe*dSM1p2k
13589                               - q2n1kRe*dReQ1n1k-q2n1kIm*dImQ1n1k
13590                               - s1p1k*dReQ1n1k
13591                               + 2.*q1n2kRe)
13592                               / dM011;  
13593    // fill profile for <<w1 w2 w3 cos n(psi1+phi2)>>:
13594    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi1P1nPhi2MPhi3W2W3,dM011);
13595    // histogram to store <w1 w2 w3 cos n(psi1+phi2)> e-b-e (needed in some other methods):
13596    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][2]->SetBinContent(b,cosP1nPsi1P1nPhi2MPhi3W2W3);
13597   } // end of if(dM011)   
13598   
13599   // <<w2 w3 cos n(psi1-phi2-phi3)>>:
13600   Double_t cosP1nPsi1M1nPhi2MPhi3W2W3 = 0.;
13601   if(dM011)
13602   {
13603    cosP1nPsi1M1nPhi2MPhi3W2W3 = (p1n0kRe*(pow(dReQ1n1k,2.)-pow(dImQ1n1k,2.))+2.*p1n0kIm*dReQ1n1k*dImQ1n1k
13604                               - 1.*(p1n0kRe*dReQ2n2k+p1n0kIm*dImQ2n2k)  
13605                               - 2.*s1p1k*dReQ1n1k
13606                               + 2.*q1n2kRe)
13607                               / dM011;
13608    // fill profile for <<w1 w2 w3 cos n(psi1+phi2)>>:
13609    fDiffFlowCorrectionTermsForNUAPro[t][pe][1][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],cosP1nPsi1M1nPhi2MPhi3W2W3,dM011);
13610    // histogram to store <w1 w2 w3 cos n(psi1+phi2)> e-b-e (needed in some other methods):
13611    fDiffFlowCorrectionTermsForNUAEBE[t][pe][1][3]->SetBinContent(b,cosP1nPsi1M1nPhi2MPhi3W2W3);
13612   } // end of if(dM011)   
13613  
13614  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
13615    
13616 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUACosTermsUsingParticleWeights(TString type, TString ptOrEta)
13617
13618
13619 //================================================================================================================================
13620
13621
13622 void AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUASinTermsUsingParticleWeights(TString type, TString ptOrEta)
13623 {
13624  // Calculate correction terms for non-uniform acceptance for differential flow (sin terms).
13625   
13626  // Results are stored in fDiffFlowCorrectionTermsForNUAPro[t][pe][0][cti], where cti runs as follows:
13627  //  0: <<sin n(psi1)>>
13628  //  1: <<w2 sin n(psi1+phi2)>>
13629  //  2: <<w2 w3 sin n(psi1+phi2-phi3)>>
13630  //  3: <<w2 w3 sin n(psi1-phi2-phi3)>>:
13631  //  4:
13632  //  5:
13633  //  6:
13634  
13635  // real and imaginary parts of weighted Q-vectors evaluated in harmonics n, 2n, 3n and 4n: 
13636  Double_t dReQ1n1k = (*fReQ)(0,1);
13637  Double_t dReQ2n2k = (*fReQ)(1,2);
13638  //Double_t dReQ1n3k = (*fReQ)(0,3);
13639  //Double_t dReQ4n4k = (*fReQ)(3,4);
13640  Double_t dImQ1n1k = (*fImQ)(0,1);
13641  Double_t dImQ2n2k = (*fImQ)(1,2);
13642  //Double_t dImQ1n3k = (*fImQ)(0,3);
13643  //Double_t dImQ4n4k = (*fImQ)(3,4);
13644  
13645  // S^M_{p,k} (see .h file for the definition of fSpk):
13646  Double_t dSM1p1k = (*fSpk)(0,1);
13647  Double_t dSM1p2k = (*fSpk)(0,2);
13648  Double_t dSM2p1k = (*fSpk)(1,1);
13649
13650  Int_t t = 0; // type flag 
13651  Int_t pe = 0; // ptEta flag
13652  
13653  if(type == "RP")
13654  {
13655   t = 0;
13656  } else if(type == "POI")
13657    {
13658     t = 1;
13659    }
13660
13661  if(ptOrEta == "Pt")
13662  {
13663   pe = 0;
13664  } else if(ptOrEta == "Eta")
13665    {
13666     pe = 1;
13667    }
13668     
13669  Int_t nBinsPtEta[2] = {fnBinsPt,fnBinsEta};
13670  Double_t minPtEta[2] = {fPtMin,fEtaMin};
13671  //Double_t maxPtEta[2] = {fPtMax,fEtaMax};
13672  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
13673
13674  // looping over all bins and calculating correction terms: 
13675  for(Int_t b=1;b<=nBinsPtEta[pe];b++)
13676  {
13677   // real and imaginary parts of p_{m*n,0} (non-weighted Q-vector evaluated for POIs in particular pt or eta bin): 
13678   Double_t p1n0kRe = 0.;
13679   Double_t p1n0kIm = 0.;
13680
13681   // number of POIs in particular pt or eta bin:
13682   Double_t mp = 0.;
13683
13684   // real and imaginary parts of q_{m*n,0} (weighted Q-vector evaluated for particles which are both RPs and POIs in particular pt or eta bin):
13685   //Double_t q1n2kRe = 0.;
13686   Double_t q1n2kIm = 0.;
13687   Double_t q2n1kRe = 0.;
13688   Double_t q2n1kIm = 0.;
13689     
13690   // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  
13691   Double_t s1p1k = 0.; 
13692   Double_t s1p2k = 0.; 
13693   
13694   // number of particles which are both RPs and POIs in particular pt or eta bin:
13695   //Double_t mq = 0.;
13696   
13697   // M0111 from Eq. (118) in QC2c (to be improved (notation))
13698   Double_t dM01 = 0.;
13699   Double_t dM011 = 0.;
13700
13701   if(type == "POI")
13702   {    
13703    // q_{m*n,k}:
13704    //q1n2kRe = fReRPQ1dEBE[2][pe][0][2]->GetBinContent(fReRPQ1dEBE[2][pe][0][2]->GetBin(b))
13705    //        * fReRPQ1dEBE[2][pe][0][2]->GetBinEntries(fReRPQ1dEBE[2][pe][0][2]->GetBin(b));
13706    q1n2kIm = fImRPQ1dEBE[2][pe][0][2]->GetBinContent(fImRPQ1dEBE[2][pe][0][2]->GetBin(b))
13707            * fImRPQ1dEBE[2][pe][0][2]->GetBinEntries(fImRPQ1dEBE[2][pe][0][2]->GetBin(b));         
13708    q2n1kRe = fReRPQ1dEBE[2][pe][1][1]->GetBinContent(fReRPQ1dEBE[2][pe][1][1]->GetBin(b))
13709            * fReRPQ1dEBE[2][pe][1][1]->GetBinEntries(fReRPQ1dEBE[2][pe][1][1]->GetBin(b));
13710    q2n1kIm = fImRPQ1dEBE[2][pe][1][1]->GetBinContent(fImRPQ1dEBE[2][pe][1][1]->GetBin(b))
13711            * fImRPQ1dEBE[2][pe][1][1]->GetBinEntries(fImRPQ1dEBE[2][pe][1][1]->GetBin(b));         
13712    //mq = fReRPQ1dEBE[2][pe][0][0]->GetBinEntries(fReRPQ1dEBE[2][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)
13713    
13714    s1p1k = pow(fs1dEBE[2][pe][1]->GetBinContent(b)*fs1dEBE[2][pe][1]->GetBinEntries(b),1.); 
13715    s1p2k = pow(fs1dEBE[2][pe][2]->GetBinContent(b)*fs1dEBE[2][pe][2]->GetBinEntries(b),1.); 
13716   }else if(type == "RP")
13717    {
13718     // q_{m*n,k}: (Remark: m=1 is 0, k=0 iz zero (to be improved!)) 
13719     //q1n2kRe = fReRPQ1dEBE[0][pe][0][2]->GetBinContent(fReRPQ1dEBE[0][pe][0][2]->GetBin(b))
13720     //        * fReRPQ1dEBE[0][pe][0][2]->GetBinEntries(fReRPQ1dEBE[0][pe][0][2]->GetBin(b));
13721     q1n2kIm = fImRPQ1dEBE[0][pe][0][2]->GetBinContent(fImRPQ1dEBE[0][pe][0][2]->GetBin(b))
13722             * fImRPQ1dEBE[0][pe][0][2]->GetBinEntries(fImRPQ1dEBE[0][pe][0][2]->GetBin(b));
13723     q2n1kRe = fReRPQ1dEBE[0][pe][1][1]->GetBinContent(fReRPQ1dEBE[0][pe][1][1]->GetBin(b))
13724             * fReRPQ1dEBE[0][pe][1][1]->GetBinEntries(fReRPQ1dEBE[0][pe][1][1]->GetBin(b));
13725     q2n1kIm = fImRPQ1dEBE[0][pe][1][1]->GetBinContent(fImRPQ1dEBE[0][pe][1][1]->GetBin(b))
13726             * fImRPQ1dEBE[0][pe][1][1]->GetBinEntries(fImRPQ1dEBE[0][pe][1][1]->GetBin(b));
13727     // s_{1,1}, s_{1,2} and s_{1,3} // to be improved (add explanation)  
13728     s1p1k = pow(fs1dEBE[0][pe][1]->GetBinContent(b)*fs1dEBE[0][pe][1]->GetBinEntries(b),1.); 
13729     s1p2k = pow(fs1dEBE[0][pe][2]->GetBinContent(b)*fs1dEBE[0][pe][2]->GetBinEntries(b),1.); 
13730     //s1p3k = pow(fs1dEBE[0][pe][3]->GetBinContent(b)*fs1dEBE[0][pe][3]->GetBinEntries(b),1.); 
13731   }    
13732   
13733   if(type == "POI")
13734   {
13735    // p_{m*n,k}:   
13736    p1n0kRe = fReRPQ1dEBE[1][pe][0][0]->GetBinContent(fReRPQ1dEBE[1][pe][0][0]->GetBin(b))
13737            * fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b));
13738    p1n0kIm = fImRPQ1dEBE[1][pe][0][0]->GetBinContent(fImRPQ1dEBE[1][pe][0][0]->GetBin(b))  
13739            * fImRPQ1dEBE[1][pe][0][0]->GetBinEntries(fImRPQ1dEBE[1][pe][0][0]->GetBin(b));
13740    mp = fReRPQ1dEBE[1][pe][0][0]->GetBinEntries(fReRPQ1dEBE[1][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here) 
13741    // M01 from Eq. (118) in QC2c (to be improved (notation)):
13742    dM01 = mp*dSM1p1k-s1p1k;
13743    dM011 = mp*(dSM2p1k-dSM1p2k)
13744          - 2.*(s1p1k*dSM1p1k-s1p2k);  
13745    // typeFlag = RP (0) or POI (1):   
13746    t = 1;           
13747   } else if(type == "RP")
13748     { 
13749      // to be improved (cross-checked):
13750      p1n0kRe = fReRPQ1dEBE[0][pe][0][0]->GetBinContent(fReRPQ1dEBE[0][pe][0][0]->GetBin(b))
13751              * fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b));
13752      p1n0kIm = fImRPQ1dEBE[0][pe][0][0]->GetBinContent(fImRPQ1dEBE[0][pe][0][0]->GetBin(b))  
13753              * fImRPQ1dEBE[0][pe][0][0]->GetBinEntries(fImRPQ1dEBE[0][pe][0][0]->GetBin(b));
13754      mp = fReRPQ1dEBE[0][pe][0][0]->GetBinEntries(fReRPQ1dEBE[0][pe][0][0]->GetBin(b)); // to be improved (cross-checked by accessing other profiles here)    
13755      // M01 from Eq. (118) in QC2c (to be improved (notation)):
13756      dM01 = mp*dSM1p1k-s1p1k;
13757      dM011 = mp*(dSM2p1k-dSM1p2k)
13758            - 2.*(s1p1k*dSM1p1k-s1p2k); 
13759      // typeFlag = RP (0) or POI (1): 
13760      t = 0;
13761     }
13762   
13763   // <<sin n(psi1)>>:
13764   Double_t sinP1nPsi = 0.;
13765   if(mp)
13766   {
13767    sinP1nPsi = p1n0kIm/mp;
13768    
13769    // fill profile for <<sin n(psi1)>>:
13770    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][0]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi,mp);
13771    // histogram to store <sin n(psi1)> e-b-e (needed in some other methods):
13772    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][0]->SetBinContent(b,sinP1nPsi);
13773   } // end of if(mp)   
13774   
13775   // <<w2 sin n(psi1+phi2)>>:
13776   Double_t sinP1nPsiP1nPhiW2 = 0.;
13777   if(dM01)
13778   {
13779    sinP1nPsiP1nPhiW2 = (p1n0kRe*dImQ1n1k+p1n0kIm*dReQ1n1k-q2n1kIm)/(dM01);
13780    // fill profile for <<w2 sin n(psi1+phi2)>>:
13781    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][1]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsiP1nPhiW2,dM01);
13782    // histogram to store <w2 sin n(psi1+phi2)> e-b-e (needed in some other methods):
13783    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][1]->SetBinContent(b,sinP1nPsiP1nPhiW2);
13784   } // end of if(mp*dMult-mq)   
13785   
13786   // <<w2 w3 sin n(psi1+phi2-phi3)>>:
13787   Double_t sinP1nPsi1P1nPhi2MPhi3W2W3 = 0.;
13788   if(dM011)
13789   {
13790    sinP1nPsi1P1nPhi2MPhi3W2W3 = (p1n0kIm*(pow(dImQ1n1k,2.)+pow(dReQ1n1k,2.))
13791                               - p1n0kIm*dSM1p2k
13792                               + q2n1kRe*dImQ1n1k-q2n1kIm*dReQ1n1k
13793                               - s1p1k*dImQ1n1k
13794                               + 2.*q1n2kIm)
13795                               / dM011;  
13796    // fill profile for <<w2 w3 sin n(psi1+phi2-phi3)>>:
13797    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][2]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi1P1nPhi2MPhi3W2W3,dM011);
13798    // histogram to store <w2 w3 sin n(psi1+phi2-phi3)> e-b-e (needed in some other methods):
13799    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][2]->SetBinContent(b,sinP1nPsi1P1nPhi2MPhi3W2W3);
13800   } // end of if(dM011)   
13801   
13802   // <<w2 w3 sin n(psi1-phi2-phi3)>>:
13803   Double_t sinP1nPsi1M1nPhi2MPhi3W2W3 = 0.;
13804   if(dM011)
13805   {
13806    sinP1nPsi1M1nPhi2MPhi3W2W3 = (p1n0kIm*(pow(dReQ1n1k,2.)-pow(dImQ1n1k,2.))-2.*p1n0kRe*dReQ1n1k*dImQ1n1k
13807                               + 1.*(p1n0kRe*dImQ2n2k-p1n0kIm*dReQ2n2k)  
13808                               + 2.*s1p1k*dImQ1n1k
13809                               - 2.*q1n2kIm)
13810                               / dM011;
13811    // fill profile for <<w2 w3 sin n(psi1-phi2-phi3)>>:
13812    fDiffFlowCorrectionTermsForNUAPro[t][pe][0][3]->Fill(minPtEta[pe]+(b-1)*binWidthPtEta[pe],sinP1nPsi1M1nPhi2MPhi3W2W3,dM011);
13813    // histogram to store <w2 w3 sin n(psi1-phi2-phi3)> e-b-e (needed in some other methods):
13814    fDiffFlowCorrectionTermsForNUAEBE[t][pe][0][3]->SetBinContent(b,sinP1nPsi1M1nPhi2MPhi3W2W3);
13815   } // end of if(dM011)   
13816   
13817  } // end of for(Int_t b=1;b<=nBinsPtEta[pe];b++)
13818
13819 } // end of AliFlowAnalysisWithQCumulants::CalculateDiffFlowCorrectionsForNUASinTermsUsingParticleWeights(TString type, TString ptOrEta)
13820
13821 //================================================================================================================================
13822    
13823 void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoopsUsingParticleWeights(AliFlowEventSimple * const anEvent, TString type, TString ptOrEta)
13824 {
13825  // Evaluate with nested loops correction terms for non-uniform acceptance 
13826  // with using particle weights (both sin and cos terms) relevant for differential flow.
13827  
13828  // Remark 1: "w1" in expressions bellow is a particle weight used only for particles which were 
13829  //           flagged both as POI and RP.
13830  // Remark 2: Reduced correction terms for non-uniform acceptance are evaluated in pt bin number fCrossCheckInPtBinNo 
13831  //           and eta bin number fCrossCheckInEtaBinNo both for RPs and POIs.
13832  // Remark 3: Results are stored in 1 bin profiles fDiffFlowDirectCorrections[t][pe][sc][cti], where first three indices runs as: 
13833  //           [0=RP,1=POI][0=Pt,1=Eta][0=sin terms,1=cos terms], whilst the cti (correction term index) runs as follows: 
13834  //  cti: 
13835  //    0: <<sc n(psi1)>>
13836  //    1: <<w2 sc n(psi1+phi2)>> 
13837  //    2: <<w2 w3 sc n(psi1+phi2-phi3)>>
13838  //    3: <<w2 w3 sc n(psi1-phi2-phi3)>>
13839  //    4:
13840  //    5:
13841  //    6:
13842      
13843  Int_t typeFlag = 0;
13844  Int_t ptEtaFlag = 0;
13845  if(type == "RP")
13846  {
13847   typeFlag = 0;
13848  } else if(type == "POI")
13849    {
13850     typeFlag = 1;
13851    }      
13852  if(ptOrEta == "Pt")
13853  {
13854   ptEtaFlag = 0;
13855  } else if(ptOrEta == "Eta")
13856    {
13857     ptEtaFlag = 1;
13858    } 
13859  // shortcuts:
13860  Int_t t = typeFlag;
13861  Int_t pe = ptEtaFlag;
13862       
13863  Double_t lowerPtEtaEdge[2] = {fPtMin+(fCrossCheckInPtBinNo-1)*fPtBinWidth,fEtaMin+(fCrossCheckInEtaBinNo-1)*fEtaBinWidth};
13864  Double_t upperPtEtaEdge[2] = {fPtMin+fCrossCheckInPtBinNo*fPtBinWidth,fEtaMin+fCrossCheckInEtaBinNo*fEtaBinWidth};
13865  Double_t binWidthPtEta[2] = {fPtBinWidth,fEtaBinWidth};
13866  
13867  Int_t nPrim = anEvent->NumberOfTracks(); 
13868  AliFlowTrackSimple *aftsTrack = NULL;
13869  
13870  Double_t psi1=0., phi2=0., phi3=0.;// phi4=0.;// phi5=0., phi6=0., phi7=0., phi8=0.;
13871  Double_t wPhi2=1., wPhi3=1.;
13872  
13873  Int_t n = fHarmonic; 
13874  
13875  // 1'-particle correction terms:
13876  for(Int_t i1=0;i1<nPrim;i1++)
13877  {
13878   aftsTrack=anEvent->GetTrack(i1);
13879   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
13880   if(typeFlag==1) // this is diff flow of POIs 
13881   {
13882    if(ptOrEta == "Pt")
13883    { 
13884     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
13885    } else if (ptOrEta == "Eta")
13886      {
13887       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
13888      }
13889   } else // this is diff flow of RPs 
13890     {
13891      if(ptOrEta == "Pt")
13892      { 
13893       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
13894      } else if (ptOrEta == "Eta")
13895        {
13896         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
13897        }
13898     }
13899   psi1=aftsTrack->Phi(); 
13900   // sin terms: 
13901   fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*psi1),1.); // <<sin(n*(psi1))>>  
13902   // cos terms: 
13903   fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][0]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*psi1),1.); // <<cos(n*(psi1))>>  
13904  }//end of for(Int_t i1=0;i1<nPrim;i1++)
13905    
13906  // 2'-particle correction terms:
13907  for(Int_t i1=0;i1<nPrim;i1++)
13908  {
13909   aftsTrack=anEvent->GetTrack(i1);
13910   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
13911   if(typeFlag==1) // this is diff flow of POIs 
13912   {
13913    if(ptOrEta == "Pt")
13914    { 
13915     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
13916    } else if (ptOrEta == "Eta")
13917      {
13918       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
13919      }
13920   } else // this is diff flow of RPs 
13921     {
13922      if(ptOrEta == "Pt")
13923      { 
13924       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
13925      } else if (ptOrEta == "Eta")
13926        {
13927         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
13928        }
13929     }
13930   psi1=aftsTrack->Phi(); 
13931   for(Int_t i2=0;i2<nPrim;i2++)
13932   {
13933    if(i2==i1) continue;
13934    aftsTrack=anEvent->GetTrack(i2);
13935    // RP condition (!(first) particle in the correlator must be RP):
13936    if(!(aftsTrack->InRPSelection())) continue;
13937    phi2=aftsTrack->Phi();
13938    if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));   
13939    // sin terms: 
13940    fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1+phi2)),wPhi2); // <<w2 sin(n*(psi1+phi2))>>  
13941    // cos terms: 
13942    fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][1]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2)),wPhi2); // <<w2 cos(n*(psi1+phi2))>>  
13943   }//end of for(Int_t i2=0;i2<nPrim;i2++)
13944  }//end of for(Int_t i1=0;i1<nPrim;i1++)   
13945  
13946  // 3'-particle correction terms:
13947  for(Int_t i1=0;i1<nPrim;i1++)
13948  {
13949   aftsTrack=anEvent->GetTrack(i1);
13950   // POI condition (first particle in the correlator must be POI): // to be improved (this can be implemented much better)
13951   if(typeFlag==1) // this is diff flow of POIs 
13952   {
13953    if(ptOrEta == "Pt")
13954    { 
13955     if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;
13956    } else if (ptOrEta == "Eta")
13957      {
13958       if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InPOISelection())))continue;    
13959      }
13960   } else // this is diff flow of RPs 
13961     {
13962      if(ptOrEta == "Pt")
13963      { 
13964       if(!((aftsTrack->Pt()>=lowerPtEtaEdge[pe] && aftsTrack->Pt()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;
13965      } else if (ptOrEta == "Eta")
13966        {
13967         if(!((aftsTrack->Eta()>=lowerPtEtaEdge[pe] && aftsTrack->Eta()<upperPtEtaEdge[pe]) && (aftsTrack->InRPSelection())))continue;    
13968        }
13969     }
13970   psi1=aftsTrack->Phi();
13971   for(Int_t i2=0;i2<nPrim;i2++)
13972   {
13973    if(i2==i1) continue;
13974    aftsTrack=anEvent->GetTrack(i2);
13975    // RP condition (!(first) particle in the correlator must be RP):
13976    if(!(aftsTrack->InRPSelection())) continue;
13977    phi2=aftsTrack->Phi();
13978    if(fUsePhiWeights && fPhiWeights) wPhi2 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi2*fnBinsPhi/TMath::TwoPi())));   
13979    for(Int_t i3=0;i3<nPrim;i3++)
13980    {
13981     if(i3==i1||i3==i2) continue;
13982     aftsTrack=anEvent->GetTrack(i3);
13983     // RP condition (!(first) particle in the correlator must be RP):
13984     if(!(aftsTrack->InRPSelection())) continue;
13985     phi3=aftsTrack->Phi();
13986     if(fUsePhiWeights && fPhiWeights) wPhi3 = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(phi3*fnBinsPhi/TMath::TwoPi())));   
13987     // sin terms: 
13988     fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][2]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1+phi2-phi3)),wPhi2*wPhi3); // <<wPhi2*wPhi3 sin(n*(psi1+phi2-phi3))>>  
13989     fDiffFlowDirectCorrectionTermsForNUA[t][pe][0][3]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,sin(n*(psi1-phi2-phi3)),wPhi2*wPhi3); // <<wPhi2*wPhi3 sin(n*(psi1-phi2-phi3))>>  
13990     // cos terms: 
13991     fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][2]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1+phi2-phi3)),wPhi2*wPhi3); // <<wPhi2*wPhi3 cos(n*(psi1+phi2-phi3))>>  
13992     fDiffFlowDirectCorrectionTermsForNUA[t][pe][1][3]->Fill(lowerPtEtaEdge[pe]+binWidthPtEta[pe]/2.,cos(n*(psi1-phi2-phi3)),wPhi2*wPhi3); // <<wPhi2*wPhi3 cos(n*(psi1-phi2-phi3))>>  
13993    }//end of for(Int_t i3=0;i3<nPrim;i3++)  
13994   }//end of for(Int_t i2=0;i2<nPrim;i2++)  
13995  }//end of for(Int_t i1=0;i1<nPrim;i1++)
13996                
13997 } // end of void AliFlowAnalysisWithQCumulants::EvaluateDiffFlowCorrectionTermsForNUAWithNestedLoopsUsingParticleWeights(AliFlowEventSimple* anEvent, TString type, TString ptOrEta)
13998
13999 //================================================================================================================================
14000
14001 void AliFlowAnalysisWithQCumulants::CheckPointersUsedInFinish()
14002 {
14003  // Check all pointers used in method Finish().
14004  
14005  if(!fAvMultiplicity)
14006  {
14007   cout<<endl;
14008   cout<<" WARNING (QC): fAvMultiplicity is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14009   cout<<endl;
14010   exit(0);
14011  }
14012  if(!fIntFlowCorrelationsPro)
14013  {
14014   cout<<endl;
14015   cout<<" WARNING (QC): fIntFlowCorrelationsPro is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14016   cout<<endl;
14017   exit(0); 
14018  }
14019  if(!fIntFlowSquaredCorrelationsPro)
14020  {
14021   cout<<endl;
14022   cout<<" WARNING (QC): fIntFlowSquaredCorrelationsPro is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14023   cout<<endl;
14024   exit(0); 
14025  } 
14026  if(!fIntFlowCorrelationsHist)
14027  {
14028   cout<<endl;
14029   cout<<" WARNING (QC): fIntFlowCorrelationsHist is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14030   cout<<endl;
14031   exit(0); 
14032  }
14033  if((fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights) && !fIntFlowExtraCorrelationsPro) 
14034  {
14035   cout<<endl;
14036   cout<<" WARNING (QC): fIntFlowExtraCorrelationsPro is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14037   cout<<endl;
14038   exit(0); 
14039  } 
14040  for(Int_t power=0;power<2;power++)
14041  { 
14042   if(!fIntFlowSumOfEventWeights[power]) 
14043   {
14044    cout<<endl;
14045    cout<<Form(" WARNING (QC): fIntFlowSumOfEventWeights[%d] is NULL in CheckPointersUsedInFinish() !!!!",power)<<endl;
14046    cout<<endl;
14047    exit(0);
14048   }
14049  } // end of for(Int_t power=0;power<2;power++)
14050  if(!fIntFlowProductOfCorrelationsPro)
14051  {
14052   cout<<endl;
14053   cout<<" WARNING (QC): fIntFlowProductOfCorrelationsPro is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14054   cout<<endl;
14055   exit(0); 
14056  } 
14057  if(!fIntFlowSumOfProductOfEventWeights)
14058  {
14059   cout<<endl;
14060   cout<<" WARNING (QC): fIntFlowSumOfProductOfEventWeights is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14061   cout<<endl;
14062   exit(0); 
14063  }
14064  if(!fIntFlowCovariances)
14065  {
14066   cout<<endl;
14067   cout<<" WARNING (QC): fIntFlowCovariances is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14068   cout<<endl;
14069   exit(0); 
14070  }  
14071  if(!fIntFlowQcumulants)
14072  {
14073   cout<<endl;
14074   cout<<" WARNING (QC): fIntFlowQcumulants is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14075   cout<<endl;
14076   exit(0); 
14077  }  
14078  if(!fIntFlow)
14079  {
14080   cout<<endl;
14081   cout<<" WARNING (QC): fIntFlow is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14082   cout<<endl;
14083   exit(0); 
14084  }
14085  if(!fCommonHists)
14086  {
14087   cout<<endl;
14088   cout<<" WARNING (QC): fCommonHists is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14089   cout<<endl;
14090   exit(0); 
14091  }
14092  if(!(fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th && fCommonHistsResults8th))
14093  {
14094   cout<<endl;
14095   cout<<" WARNING (QC): fCommonHistsResults2nd && fCommonHistsResults4th && fCommonHistsResults6th"<<endl; 
14096   cout<<"               && fCommonHistsResults8th is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14097   cout<<endl;
14098   exit(0);
14099  } 
14100  
14101  // NUA stuff:
14102  for(Int_t sc=0;sc<2;sc++) // sin/cos
14103  { 
14104   if(!fIntFlowCorrectionTermsForNUAPro[sc]) 
14105   {
14106    cout<<endl;
14107    cout<<Form(" WARNING (QC): fIntFlowCorrectionTermsForNUAPro[%d] is NULL in CheckPointersUsedInFinish() !!!!",sc)<<endl;
14108    cout<<endl;
14109    exit(0);
14110   }
14111   if(!fIntFlowCorrectionTermsForNUAHist[sc]) 
14112   {
14113    cout<<endl;
14114    cout<<Form(" WARNING (QC): fIntFlowCorrectionTermsForNUAHist[%d] is NULL in CheckPointersUsedInFinish() !!!!",sc)<<endl;
14115    cout<<endl;
14116    exit(0);
14117   }
14118   for(Int_t lq=0;lq<2;lq++) // linear/quadratic
14119   {
14120    if(!fIntFlowSumOfEventWeightsNUA[sc][lq]) 
14121    {
14122     cout<<endl;
14123     cout<<Form(" WARNING (QC): fIntFlowSumOfEventWeightsNUA[%d][%d] is NULL in CheckPointersUsedInFinish() !!!!",sc,lq)<<endl;
14124     cout<<endl;
14125     exit(0);
14126    }
14127   } // end of for(Int_t lq=0;lq<2;lq++) // linear/quadratic
14128  } // end of for(Int_t power=0;power<2;power++) 
14129  if(!fIntFlowProductOfCorrectionTermsForNUAPro)
14130  {
14131   cout<<endl;
14132   cout<<" WARNING (QC): fIntFlowProductOfCorrectionTermsForNUAPro is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14133   cout<<endl;
14134   exit(0); 
14135  } 
14136  if(!fIntFlowSumOfProductOfEventWeightsNUA)
14137  {
14138   cout<<endl;
14139   cout<<" WARNING (QC): fIntFlowSumOfProductOfEventWeightsNUA is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14140   cout<<endl;
14141   exit(0); 
14142  } 
14143  if(!fIntFlowCovariancesNUA)
14144  {
14145   cout<<endl;
14146   cout<<" WARNING (QC): fIntFlowCovariancesNUA is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14147   cout<<endl;
14148   exit(0); 
14149  } 
14150  if(!fIntFlowQcumulantsErrorSquaredRatio)
14151  {
14152   cout<<endl;
14153   cout<<" WARNING (QC): fIntFlowQcumulantsErrorSquaredRatio is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14154   cout<<endl;
14155   exit(0); 
14156  } 
14157  if(!fIntFlowDetectorBias)
14158  {
14159   cout<<endl;
14160   cout<<" WARNING (QC): fIntFlowDetectorBias is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14161   cout<<endl;
14162   exit(0); 
14163  }
14164  
14165  // Versus multiplicity:
14166  if(!fCalculateCumulantsVsM){return;}
14167  for(Int_t co=0;co<=3;co++) // cumulant order
14168  {
14169   if(!fIntFlowQcumulantsVsM[co])
14170   {
14171    cout<<endl;
14172    cout<<Form(" WARNING (QC): fIntFlowQcumulantsVsM[%d] is NULL in CheckPointersUsedInFinish() !!!!",co)<<endl;
14173    cout<<endl;
14174    exit(0); 
14175   }
14176   if(!fIntFlowVsM[co])
14177   {
14178    cout<<endl;
14179    cout<<Form(" WARNING (QC): fIntFlowVsM[%d] is NULL in CheckPointersUsedInFinish() !!!!",co)<<endl;
14180    cout<<endl;
14181    exit(0); 
14182   }
14183   if(!fIntFlowDetectorBiasVsM[co])
14184   {
14185    cout<<endl;
14186    cout<<Form(" WARNING (QC): fIntFlowDetectorBiasVsM[%d] is NULL in CheckPointersUsedInFinish() !!!!",co)<<endl;
14187    cout<<endl;
14188    exit(0); 
14189   }
14190  } // end of for(Int_t c0=0;c0<=3;c0++) // cumulant order
14191  for(Int_t ci=0;ci<=3;ci++) // correlation index
14192  {
14193   if(!fIntFlowCorrelationsVsMPro[ci])
14194   {
14195    cout<<endl;
14196    cout<<Form(" WARNING (QC): fIntFlowCorrelationsVsMPro[%d] is NULL in CheckPointersUsedInFinish() !!!!",ci)<<endl;
14197    cout<<endl;
14198    exit(0); 
14199   }
14200   if(!fIntFlowSquaredCorrelationsVsMPro[ci])
14201   {
14202    cout<<endl;
14203    cout<<Form(" WARNING (QC): fIntFlowSquaredCorrelationsVsMPro[%d] is NULL in CheckPointersUsedInFinish() !!!!",ci)<<endl;
14204    cout<<endl;
14205    exit(0); 
14206   }  
14207   if(!fIntFlowCorrelationsVsMHist[ci])
14208   {
14209    cout<<endl;
14210    cout<<Form(" WARNING (QC): fIntFlowCorrelationsVsMHist[%d] is NULL in CheckPointersUsedInFinish() !!!!",ci)<<endl;
14211    cout<<endl;
14212    exit(0); 
14213   }
14214   for(Int_t power=0;power<2;power++) 
14215   {
14216    if(!fIntFlowSumOfEventWeightsVsM[ci][power])
14217    {
14218     cout<<endl;
14219     cout<<Form(" WARNING (QC): fIntFlowSumOfEventWeightsVsM[%d][%d] is NULL in CheckPointersUsedInFinish() !!!!",ci,power)<<endl;
14220     cout<<endl;
14221     exit(0);   
14222    }
14223   } // end of for(Int_t power=0;power<2;power++) 
14224  } // end of for(Int_t ci=0;ci<=3;ci++) // correlation index
14225  for(Int_t i=0;i<6;i++)
14226  {
14227   if(!fIntFlowProductOfCorrelationsVsMPro[i])
14228   {
14229    cout<<endl;
14230    cout<<Form(" WARNING (QC): fIntFlowProductOfCorrelationsVsMPro[%d] is NULL in CheckPointersUsedInFinish() !!!!",i)<<endl;
14231    cout<<endl;
14232    exit(0); 
14233   }
14234   if(!fIntFlowSumOfProductOfEventWeightsVsM[i])
14235   {
14236    cout<<endl;
14237    cout<<Form(" WARNING (QC): fIntFlowSumOfProductOfEventWeightsVsM[%d] is NULL in CheckPointersUsedInFinish() !!!!",i)<<endl;
14238    cout<<endl;
14239    exit(0); 
14240   }
14241   if(!fIntFlowCovariancesVsM[i])
14242   {
14243    cout<<endl;
14244    cout<<Form(" WARNING (QC): fIntFlowCovariancesVsM[%d] is NULL in CheckPointersUsedInFinish() !!!!",i)<<endl;
14245    cout<<endl;
14246    exit(0); 
14247   }
14248  } // end of for(Int_t i=0;i<6;i++) 
14249  if(!fIntFlowRebinnedInM)
14250  {
14251   cout<<endl;
14252   cout<<" WARNING (QC): fIntFlowRebinnedInM is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14253   cout<<endl;
14254   exit(0); 
14255  }
14256  if(!fIntFlowQcumulantsRebinnedInM)
14257  {
14258   cout<<endl;
14259   cout<<" WARNING (QC): fIntFlowQcumulantsRebinnedInM is NULL in CheckPointersUsedInFinish() !!!!"<<endl;
14260   cout<<endl;
14261   exit(0); 
14262  }  
14263  
14264 } // end of void AliFlowAnalysisWithQCumulants::CheckPointersUsedInFinish()
14265
14266 //================================================================================================================================
14267
14268 void AliFlowAnalysisWithQCumulants::CheckPointersUsedInMake()
14269 {
14270  // Check all pointers used in method Make(). // to be improved - check other pointers as well
14271  
14272  if(!fAvMultiplicity)
14273  {
14274   printf("\n WARNING (QC): fAvMultiplicity is NULL in CheckPointersUsedInMake() !!!!\n\n");
14275   exit(0);
14276  }
14277  if((fUsePhiWeights||fUsePtWeights||fUseEtaWeights||fUseTrackWeights) && !fIntFlowExtraCorrelationsPro) 
14278  {
14279   printf("\n WARNING (QC): fIntFlowExtraCorrelationsPro is NULL in CheckPointersUsedInMake() !!!!\n\n");
14280   exit(0); 
14281  } 
14282  // 2D:
14283  if(fCalculate2DDiffFlow)
14284  {
14285   for(Int_t t=0;t<2;t++) // type = RP or POI
14286   { 
14287    for(Int_t rci=0;rci<4;rci++) // reduced correlation index
14288    {
14289     if(!f2DDiffFlowCorrelationsPro[t][rci])
14290     {
14291      printf("\n WARNING (QC): f2DDiffFlowCorrelationsPro[%i][%i] is NULL in CheckPointersUsedInMake() !!!!\n\n",t,rci);
14292      exit(0);     
14293     } // end of if(!f2DDiffFlowCorrelationsPro[t][rci])  
14294    } // end of for(Int_t rci=0;rci<4;rci++) // reduced correlation index
14295   } // end of for(Int_t t=0;t<2;t++)
14296  } // end of if(fCalculate2DDiffFlow)  
14297
14298 } // end of void AliFlowAnalysisWithQCumulants::CheckPointersUsedInMake()
14299  
14300