more for weigths
[u/mrichter/AliRoot.git] / PWG2 / FLOW / 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  *           (anteb@nikhef.nl)    *
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 #include "TFile.h"
31 #include "TList.h"
32 #include "TGraph.h"
33 #include "TParticle.h"
34 #include "TRandom3.h"
35 #include "TStyle.h"
36 #include "TProfile.h"
37 #include "TProfile2D.h" 
38 #include "TProfile3D.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 "AliQCumulantsFunctions.h"
47
48 #include "TRandom.h"
49
50 class TH1;
51 class TGraph;
52 class TPave;
53 class TLatex;
54 class TMarker;
55 class TRandom3;
56 class TObjArray;
57 class TList;
58 class TCanvas;
59 class TSystem;
60 class TROOT;
61 class AliFlowVector;
62 class TVector;
63
64 //================================================================================================================
65
66 ClassImp(AliFlowAnalysisWithQCumulants)
67
68 AliFlowAnalysisWithQCumulants::AliFlowAnalysisWithQCumulants():  
69  fTrack(NULL),
70  fHistList(NULL),
71  fAvMultIntFlowQC(NULL),
72  fQvectorComponents(NULL),
73  fIntFlowResultsQC(NULL),
74  fDiffFlowResults2ndOrderQC(NULL),
75  fDiffFlowResults4thOrderQC(NULL),
76  fCovariances(NULL),
77  fQvectorForEachEventX(NULL),//to be removed
78  fQvectorForEachEventY(NULL),//to be removed
79  fQCorrelations(NULL),
80  fQProduct(NULL),
81  fDirectCorrelations(NULL),
82  fPtReq1nRP(NULL),
83  fPtImq1nRP(NULL),
84  fPtReq2nRP(NULL),
85  fPtImq2nRP(NULL),
86  f2PerPtBin1n1nRP(NULL),
87  f2PerPtBin2n2nRP(NULL),
88  f3PerPtBin2n1n1nRP(NULL),
89  f3PerPtBin1n1n2nRP(NULL),
90  f4PerPtBin1n1n1n1nRP(NULL),
91  fEtaReq1nRP(NULL),
92  fEtaImq1nRP(NULL),
93  fEtaReq2nRP(NULL),
94  fEtaImq2nRP(NULL),
95  f2PerEtaBin1n1nRP(NULL),
96  f2PerEtaBin2n2nRP(NULL),
97  f3PerEtaBin2n1n1nRP(NULL),
98  f3PerEtaBin1n1n2nRP(NULL),
99  f4PerEtaBin1n1n1n1nRP(NULL),
100  fPtReq1nPrimePOI(NULL),
101  fPtImq1nPrimePOI(NULL),
102  fPtReq2nPrimePOI(NULL),
103  fPtImq2nPrimePOI(NULL),
104  fmPrimePerPtBin(NULL),
105  fPtReq1nPrimePrimePOI(NULL),
106  fPtImq1nPrimePrimePOI(NULL),
107  fPtReq2nPrimePrimePOI(NULL),
108  fPtImq2nPrimePrimePOI(NULL),
109  fmPrimePrimePerPtBin(NULL),
110  fEtaReq1nPrimePOI(NULL),
111  fEtaImq1nPrimePOI(NULL),
112  fEtaReq2nPrimePOI(NULL),
113  fEtaImq2nPrimePOI(NULL),
114  fmPrimePerEtaBin(NULL),
115  fEtaReq1nPrimePrimePOI(NULL),
116  fEtaImq1nPrimePrimePOI(NULL),
117  fEtaReq2nPrimePrimePOI(NULL),
118  fEtaImq2nPrimePrimePOI(NULL),
119  fmPrimePrimePerEtaBin(NULL),
120  f2PerPtBin1n1nPOI(NULL),
121  f2PerPtBin2n2nPOI(NULL),
122  f3PerPtBin2n1n1nPOI(NULL),
123  f3PerPtBin1n1n2nPOI(NULL),
124  f4PerPtBin1n1n1n1nPOI(NULL),
125  f2PerEtaBin1n1nPOI(NULL),
126  f2PerEtaBin2n2nPOI(NULL),
127  f3PerEtaBin2n1n1nPOI(NULL),
128  f3PerEtaBin1n1n2nPOI(NULL),
129  f4PerEtaBin1n1n1n1nPOI(NULL), 
130  fCommonHists2nd(NULL),
131  fCommonHists4th(NULL),
132  fCommonHists6th(NULL),
133  fCommonHists8th(NULL),
134  fCommonHistsResults2nd(NULL),
135  fCommonHistsResults4th(NULL),
136  fCommonHistsResults6th(NULL),
137  fCommonHistsResults8th(NULL),
138  f2pDistribution(NULL),
139  f4pDistribution(NULL),
140  f6pDistribution(NULL),
141  f8pDistribution(NULL),
142  fnBinsPt(0),
143  fPtMin(0),
144  fPtMax(0),
145  fnBinsEta(0),
146  fEtaMin(0),
147  fEtaMax(0),
148  fEventCounter(0),
149  fUsePhiWeights(kFALSE),
150  fUsePtWeights(kFALSE),
151  fUseEtaWeights(kFALSE),
152  fPhiWeights(),
153  fPtWeights(),
154  fEtaWeights()
155 {
156  //constructor 
157  fHistList = new TList(); 
158  
159  fnBinsPt = AliFlowCommonConstants::GetNbinsPt();
160  fPtMin   = AliFlowCommonConstants::GetPtMin();      
161  fPtMax   = AliFlowCommonConstants::GetPtMax();
162  
163  fnBinsEta = AliFlowCommonConstants::GetNbinsEta();
164  fEtaMin   = AliFlowCommonConstants::GetEtaMin();            
165  fEtaMax   = AliFlowCommonConstants::GetEtaMax();
166  
167  //to be improved
168  fPhiWeights.Reset();
169  fPtWeights.Reset();
170  fEtaWeights.Reset();
171 }
172
173 AliFlowAnalysisWithQCumulants::~AliFlowAnalysisWithQCumulants()
174 {
175  //desctructor
176  delete fHistList; 
177 }
178
179 //================================================================================================================
180
181 void AliFlowAnalysisWithQCumulants::Init()
182 {
183  //various output histograms
184  //avarage multiplicity 
185  fAvMultIntFlowQC = new TProfile("fAvMultIntFlowQC","Average Multiplicity",1,0,1,"s");
186  fAvMultIntFlowQC->SetXTitle("");
187  fAvMultIntFlowQC->SetYTitle("");
188  fAvMultIntFlowQC->SetLabelSize(0.06);
189  fAvMultIntFlowQC->SetMarkerStyle(25);
190  fAvMultIntFlowQC->SetLabelOffset(0.01);
191  (fAvMultIntFlowQC->GetXaxis())->SetBinLabel(1,"Average Multiplicity");
192  fHistList->Add(fAvMultIntFlowQC);
193  
194  //Q-vector stuff
195  fQvectorComponents = new TProfile("fQvectorComponents","Avarage of Q-vector components",44,0.,44.,"s");
196  fQvectorComponents->SetXTitle("");
197  fQvectorComponents->SetYTitle("");
198  //fHistList->Add(fQvectorComponents);
199  
200  //final results for integrated flow from Q-cumulants
201  fIntFlowResultsQC = new TH1D("fIntFlowResultsQC","Integrated Flow from Q-cumulants",4,0,4);
202  //fIntFlowResults->SetXTitle("");
203  //fIntFlowResultsQC->SetYTitle("Integrated Flow");
204  fIntFlowResultsQC->SetLabelSize(0.06);
205  //fIntFlowResultsQC->SetTickLength(1);
206  fIntFlowResultsQC->SetMarkerStyle(25);
207  (fIntFlowResultsQC->GetXaxis())->SetBinLabel(1,"v_{n}{2}");
208  (fIntFlowResultsQC->GetXaxis())->SetBinLabel(2,"v_{n}{4}");
209  (fIntFlowResultsQC->GetXaxis())->SetBinLabel(3,"v_{n}{6}");
210  (fIntFlowResultsQC->GetXaxis())->SetBinLabel(4,"v_{n}{8}");
211  fHistList->Add(fIntFlowResultsQC);
212
213  //final results for differential flow from 2nd order Q-cumulant
214  fDiffFlowResults2ndOrderQC = new TH1D("fDiffFlowResults2ndOrderQC","Differential Flow from 2nd Order Q-cumulant",fnBinsPt,fPtMin,fPtMax);
215  fDiffFlowResults2ndOrderQC->SetXTitle("p_{t} [GeV]");
216  //fDiffFlowResults2ndOrderQC->SetYTitle("Differential Flow");
217  fHistList->Add(fDiffFlowResults2ndOrderQC);
218  
219  //final results for differential flow from 4th order Q-cumulant
220  fDiffFlowResults4thOrderQC = new TH1D("fDiffFlowResults4thOrderQC","Differential Flow from 4th Order Q-cumulant",fnBinsPt,fPtMin,fPtMax);
221  fDiffFlowResults4thOrderQC->SetXTitle("p_{t} [GeV]");
222  //fDiffFlowResults4thOrderQC->SetYTitle("Differential Flow");
223  fHistList->Add(fDiffFlowResults4thOrderQC);
224  
225  //final results for covariances (1st bin: <2*4>-<2>*<4>, 2nd bin: <2*6>-<2>*<6>, ...)
226  fCovariances = new TH1D("fCovariances","Covariances",6,0,6);
227  //fCovariances->SetXTitle("");
228  //fCovariances->SetYTitle("<covariance>");
229  fCovariances->SetLabelSize(0.04);
230  fCovariances->SetTickLength(1);
231  fCovariances->SetMarkerStyle(25);
232  (fCovariances->GetXaxis())->SetBinLabel(1,"Cov(2,4)");
233  (fCovariances->GetXaxis())->SetBinLabel(2,"Cov(2,6)");
234  (fCovariances->GetXaxis())->SetBinLabel(3,"Cov(2,8)");
235  (fCovariances->GetXaxis())->SetBinLabel(4,"Cov(4,6)");
236  (fCovariances->GetXaxis())->SetBinLabel(5,"Cov(4,8)");
237  (fCovariances->GetXaxis())->SetBinLabel(6,"Cov(6,8)");
238  fHistList->Add(fCovariances);
239   
240  //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
241  //                   !!!! to be removed !!!! 
242  //profile containing the x-components of Q-vectors from all events 
243  fQvectorForEachEventX = new TProfile("fQvectorForEachEventX","x-components of Q-vectors",44000,1,44000,"s");
244  fHistList->Add(fQvectorForEachEventX);
245  
246  //profile containing the y-components of Q-vectors from all events 
247  fQvectorForEachEventY = new TProfile("fQvectorForEachEventY","y-components of Q-vectors",44000,1,44000,"s");
248  fHistList->Add(fQvectorForEachEventY);
249  //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
250     
251  //multi-particle correlations calculated from Q-vectors
252  fQCorrelations = new TProfile("fQCorrelations","multi-particle correlations from Q-vectors",32,0,32,"s");
253  //fQCorrelations->SetXTitle("correlations");
254  //fQCorrelations->SetYTitle("");
255  fQCorrelations->SetTickLength(-0.01,"Y");
256  fQCorrelations->SetMarkerStyle(25);
257  fQCorrelations->SetLabelSize(0.03);
258  fQCorrelations->SetLabelOffset(0.01,"Y");
259  
260  (fQCorrelations->GetXaxis())->SetBinLabel(1,"<<2>>_{n|n}");
261  (fQCorrelations->GetXaxis())->SetBinLabel(2,"<<2>>_{2n|2n}");
262  (fQCorrelations->GetXaxis())->SetBinLabel(3,"<<2>>_{3n|3n}");
263  (fQCorrelations->GetXaxis())->SetBinLabel(4,"<<2>>_{4n|4n}");
264  
265  (fQCorrelations->GetXaxis())->SetBinLabel(6,"<<3>>_{2n|n,n}");
266  (fQCorrelations->GetXaxis())->SetBinLabel(7,"<<3>>_{3n|2n,n}");
267  (fQCorrelations->GetXaxis())->SetBinLabel(8,"<<3>>_{4n|2n,2n}");
268  (fQCorrelations->GetXaxis())->SetBinLabel(9,"<<3>>_{4n|3n,n}");
269  
270  (fQCorrelations->GetXaxis())->SetBinLabel(11,"<<4>>_{n,n|n,n}"); 
271  (fQCorrelations->GetXaxis())->SetBinLabel(12,"<<4>>_{2n,n|2n,n}");
272  (fQCorrelations->GetXaxis())->SetBinLabel(13,"<<4>>_{2n,2n|2n,2n}");
273  (fQCorrelations->GetXaxis())->SetBinLabel(14,"<<4>>_{3n|n,n,n}");
274  (fQCorrelations->GetXaxis())->SetBinLabel(15,"<<4>>_{3n,n|3n,n}");
275  (fQCorrelations->GetXaxis())->SetBinLabel(16,"<<4>>_{3n,n|2n,2n}"); 
276  (fQCorrelations->GetXaxis())->SetBinLabel(17,"<<4>>_{4n|2n,n,n}");
277  
278  (fQCorrelations->GetXaxis())->SetBinLabel(19,"<<5>>_{2n|n,n,n,n}"); 
279  (fQCorrelations->GetXaxis())->SetBinLabel(20,"<<5>>_{2n,2n|2n,n,n}");
280  (fQCorrelations->GetXaxis())->SetBinLabel(21,"<<5>>_{3n,n|2n,n,n}");
281  (fQCorrelations->GetXaxis())->SetBinLabel(22,"<<5>>_{4n|n,n,n,n}");
282  
283  (fQCorrelations->GetXaxis())->SetBinLabel(24,"<<6>>_{n,n,n|n,n,n}");
284  (fQCorrelations->GetXaxis())->SetBinLabel(25,"<<6>>_{2n,n,n|2n,n,n}");
285  (fQCorrelations->GetXaxis())->SetBinLabel(26,"<<6>>_{2n,2n|n,n,n,n}");
286  (fQCorrelations->GetXaxis())->SetBinLabel(27,"<<6>>_{3n,n|n,n,n,n}");
287  
288  (fQCorrelations->GetXaxis())->SetBinLabel(29,"<<7>>_{2n,n,n|n,n,n,n}");
289
290  (fQCorrelations->GetXaxis())->SetBinLabel(31,"<<8>>_{n,n,n,n|n,n,n,n}");
291  
292  fHistList->Add(fQCorrelations);
293  
294  //average products
295  fQProduct = new TProfile("fQProduct","average of products",6,0,6,"s");
296  fQProduct->SetTickLength(-0.01,"Y");
297  fQProduct->SetMarkerStyle(25);
298  fQProduct->SetLabelSize(0.03);
299  fQProduct->SetLabelOffset(0.01,"Y");
300  (fQProduct->GetXaxis())->SetBinLabel(1,"<<2*4>>");
301  (fQProduct->GetXaxis())->SetBinLabel(2,"<<2*6>>");
302  (fQProduct->GetXaxis())->SetBinLabel(3,"<<2*8>>");
303  (fQProduct->GetXaxis())->SetBinLabel(4,"<<4*6>>");
304  (fQProduct->GetXaxis())->SetBinLabel(5,"<<4*8>>");
305  (fQProduct->GetXaxis())->SetBinLabel(6,"<<6*8>>");
306  fQProduct->SetXTitle("");
307  fQProduct->SetYTitle("");
308  fHistList->Add(fQProduct);
309  
310  //multi-particle correlations calculated with nested loops (0..40 integrated flow; 40..80 differential flow)
311  fDirectCorrelations = new TProfile("fDirectCorrelations","multi-particle correlations with nested loops",80,0,80,"s");
312  fDirectCorrelations->SetXTitle("");
313  fDirectCorrelations->SetYTitle("correlations");
314  fHistList->Add(fDirectCorrelations);
315  
316  //fPtReq1nRP
317  fPtReq1nRP = new TProfile("fPtReq1nRP","Re[q_n]",fnBinsPt,fPtMin,fPtMax,"s");
318  fPtReq1nRP->SetXTitle("p_{t} [GeV]");
319  fPtReq1nRP->SetYTitle("Re[q_n]");
320  //fHistList->Add(fPtReq1nRP);
321  
322  //fPtImq1nRP
323  fPtImq1nRP = new TProfile("fPtImq1nRP","Im[q_n]",fnBinsPt,fPtMin,fPtMax,"s");
324  fPtImq1nRP->SetXTitle("p_{t} [GeV]");
325  fPtImq1nRP->SetYTitle("Im[q_n]");
326  //fHistList->Add(fPtImq1nRP);
327  
328  //fPtReq2nRP
329  fPtReq2nRP = new TProfile("fPtReq2nRP","Re[q_2n]",fnBinsPt,fPtMin,fPtMax,"s");
330  fPtReq2nRP->SetXTitle("p_{t} [GeV]");
331  fPtReq2nRP->SetYTitle("Im[D]");
332  //fHistList->Add(fPtReq2nRP);
333
334  //fPtImq2nRP
335  fPtImq2nRP = new TProfile("fPtImq2nRP","Im[q_2n]",fnBinsPt,fPtMin,fPtMax,"s");
336  fPtImq2nRP->SetXTitle("p_{t} [GeV]");
337  fPtImq2nRP->SetYTitle("Im[q_2n]");
338  //fHistList->Add(fPtImq2nRP);
339  
340  //f2PerPtBin1n1nRP
341  f2PerPtBin1n1nRP = new TProfile("f2PerPtBin1n1nRP","<2'>_{n|n}",fnBinsPt,fPtMin,fPtMax,"s");
342  f2PerPtBin1n1nRP->SetXTitle("p_{t} [GeV]");
343  //f2PerPtBin1n1n->SetYTitle("<2'>_{n|n}");
344  fHistList->Add(f2PerPtBin1n1nRP);
345  
346  //f2PerPtBin2n2nRP
347  f2PerPtBin2n2nRP = new TProfile("f2PerPtBin2n2nRP","<2'>_{2n|2n}",fnBinsPt,fPtMin,fPtMax,"s");
348  f2PerPtBin2n2nRP->SetXTitle("p_{t} [GeV]");
349  //f2PerPtBin2n2nRP->SetYTitle("<2'>_{2n|2n}");}//line needed only for nested loops - end of if(nPrim>8&&nPrim<12) 
350  fHistList->Add(f2PerPtBin2n2nRP);
351  
352  //f3PerPtBin2n1n1nRP
353  f3PerPtBin2n1n1nRP = new TProfile("f3PerPtBin2n1n1nRP","<3'>_{2n|n,n}",fnBinsPt,fPtMin,fPtMax,"s");
354  f3PerPtBin2n1n1nRP->SetXTitle("p_{t} [GeV]");
355  //f3PerPtBin2n1n1nRP->SetYTitle("<3'>_{2n|n,n}");
356  fHistList->Add(f3PerPtBin2n1n1nRP);
357  
358  //f3PerPtBin1n1n2nRP
359  f3PerPtBin1n1n2nRP = new TProfile("f3PerPtBin1n1n2nRP","<3'>_{n,n|2n}",fnBinsPt,fPtMin,fPtMax,"s");
360  f3PerPtBin1n1n2nRP->SetXTitle("p_{t} [GeV]");
361  //f3PerPtBin1n1n2nRP->SetYTitle("<3'>_{n,n|2n}");
362  fHistList->Add(f3PerPtBin1n1n2nRP);
363  
364  //f4PerPtBin1n1n1n1nRP
365  f4PerPtBin1n1n1n1nRP = new TProfile("f4PerPtBin1n1n1n1nRP","<4'>_{n,n|n,n}",fnBinsPt,fPtMin,fPtMax,"s");
366  f4PerPtBin1n1n1n1nRP->SetXTitle("p_{t} [GeV]");
367  //f4PerPtBin1n1n1n1nRP->SetYTitle("<4'>_{n,n|n,n}");
368  fHistList->Add(f4PerPtBin1n1n1n1nRP);
369  
370  //fEtaReq1nRP
371  fEtaReq1nRP = new TProfile("fEtaReq1nRP","Re[q_n]",fnBinsEta,fEtaMin,fEtaMax,"s");
372  fEtaReq1nRP->SetXTitle("#eta");
373  fEtaReq1nRP->SetYTitle("Re[q_n]");
374  fHistList->Add(fEtaReq1nRP);
375  
376  //fEtaImq1nRP
377  fEtaImq1nRP = new TProfile("fEtaImq1nRP","Im[q_n]",fnBinsEta,fEtaMin,fEtaMax,"s");
378  fEtaImq1nRP->SetXTitle("#eta");
379  fEtaImq1nRP->SetYTitle("Im[q_n]");
380  //fHistList->Add(fEtaImq1nRP);
381  
382  //fEtaReq2nRP
383  fEtaReq2nRP = new TProfile("fEtaReq2nRP","Re[q_2n]",fnBinsEta,fEtaMin,fEtaMax,"s");
384  fEtaReq2nRP->SetXTitle("#eta");
385  fEtaReq2nRP->SetYTitle("Im[D]");
386  //fHistList->Add(fEtaReq2nRP);
387  
388  //fEtaImq2nRP
389  fEtaImq2nRP = new TProfile("fEtaImq2nRP","Im[q_2n]",fnBinsEta,fEtaMin,fEtaMax,"s");
390  fEtaImq2nRP->SetXTitle("#eta");
391  fEtaImq2nRP->SetYTitle("Im[q_2n]");
392  //fHistList->Add(fEtaImq2nRP);
393  
394  //f2PerEtaBin1n1nRP
395  f2PerEtaBin1n1nRP = new TProfile("f2PerEtaBin1n1nRP","<2'>_{n|n}",fnBinsEta,fEtaMin,fEtaMax,"s");
396  f2PerEtaBin1n1nRP->SetXTitle("#eta");
397
398  //f2PerEtaBin1n1nRP->SetYTitle("<2'>_{n|n}");
399  fHistList->Add(f2PerEtaBin1n1nRP);
400  
401  //f2PerEtaBin2n2nRP
402  f2PerEtaBin2n2nRP = new TProfile("f2PerEtaBin2n2nRP","<2'>_{2n|2n}",fnBinsEta,fEtaMin,fEtaMax,"s");
403  f2PerEtaBin2n2nRP->SetXTitle("#eta");
404  //f2PerEtaBin2n2nRP->SetYTitle("<2'>_{2n|2n}");
405  fHistList->Add(f2PerEtaBin2n2nRP);
406  
407  //f3PerEtaBin2n1n1nRP
408  f3PerEtaBin2n1n1nRP = new TProfile("f3PerEtaBin2n1n1nRP","<3'>_{2n|n,n}",fnBinsEta,fEtaMin,fEtaMax,"s");
409  f3PerEtaBin2n1n1nRP->SetXTitle("#eta");
410  //f3PerEtaBin2n1n1nRP->SetYTitle("<3'>_{2n|n,n}");
411  fHistList->Add(f3PerEtaBin2n1n1nRP);
412  
413  //f3PerEtaBin1n1n2nRP
414  f3PerEtaBin1n1n2nRP = new TProfile("f3PerEtaBin1n1n2RP","<3'>_{n,n|2n}",fnBinsEta,fEtaMin,fEtaMax,"s");
415  f3PerEtaBin1n1n2nRP->SetXTitle("#eta");
416  //f3PerEtaBin1n1n2n->SetYTitle("<3'>_{n,n|2n}");
417  fHistList->Add(f3PerEtaBin1n1n2nRP);
418  
419  //f4PerEtaBin1n1n1n1nRP
420  f4PerEtaBin1n1n1n1nRP = new TProfile("f4PerEtaBin1n1n1n1nRP","<4'>_{n,n|n,n}",fnBinsEta,fEtaMin,fEtaMax,"s");
421  f4PerEtaBin1n1n1n1nRP->SetXTitle("#eta");
422  //f4PerEtaBin1n1n1n1nRP->SetYTitle("<4'>_{n,n|n,n}");
423  fHistList->Add(f4PerEtaBin1n1n1n1nRP);
424  
425  //fPtReq1nPrimePOI
426  fPtReq1nPrimePOI = new TProfile("fPtReq1nPrimePOI","Re[q_{n}^{'}]",fnBinsPt,fPtMin,fPtMax,"s");
427  fPtReq1nPrimePOI->SetXTitle("p_{t} [GeV]");
428  fPtReq1nPrimePOI->SetYTitle("Re[q_{n}^{'}]");
429  //fHistList->Add(fPtReq1nPrimePOI);
430  
431  //fPtImq1nPrimePOI
432  fPtImq1nPrimePOI = new TProfile("fPtImq1nPrimePOI","Im[q_{n}^{'}]",fnBinsPt,fPtMin,fPtMax,"s");
433  fPtImq1nPrimePOI->SetXTitle("p_{t} [GeV]");
434  fPtImq1nPrimePOI->SetYTitle("Im[q_{n}^{'}]");
435  //fHistList->Add(fPtImq1nPrimePOI);
436  
437  //fPtReq2nPrimePOI
438  fPtReq2nPrimePOI = new TProfile("fPtReq2nPrimePOI","Re[q_{2n}^{'}]",fnBinsPt,fPtMin,fPtMax,"s");
439  fPtReq2nPrimePOI->SetXTitle("p_{t} [GeV]");
440  fPtReq2nPrimePOI->SetYTitle("Re[q_{2n}^{'}]");
441  //fHistList->Add(fPtReq2nPrimePOI);
442  
443  //fPtImq2nPrimePOI
444  fPtImq2nPrimePOI = new TProfile("fPtImq2nPrimePOI","Im[q_{2n}^{'}]",fnBinsPt,fPtMin,fPtMax,"s");
445  fPtImq2nPrimePOI->SetXTitle("p_{t} [GeV]");
446  fPtImq2nPrimePOI->SetYTitle("Im[q_{2n}^{'}]");
447  //fHistList->Add(fPtImq2nPrimePOI);
448  
449  //fmPrimePerPtBin
450  fmPrimePerPtBin = new TProfile("fmPrimePerPtBin","# of particles selected both as RP and POI per #p_{t} bin",fnBinsPt,fPtMin,fPtMax,"s");
451  fmPrimePerPtBin->SetXTitle("p_{t} [GeV]");
452  fmPrimePerPtBin->SetYTitle("Counts");
453  //fHistList->Add(fOverlapPerPtBin);
454  
455  //fPtReq1nPrimePrimePOI
456  fPtReq1nPrimePrimePOI = new TProfile("fPtReq1nPrimePrimePOI","Re[q_{n}^{''}]",fnBinsPt,fPtMin,fPtMax,"s");
457  fPtReq1nPrimePrimePOI->SetXTitle("p_{t} [GeV]");
458  fPtReq1nPrimePrimePOI->SetYTitle("Re[q_{n}^{''}]");
459  //fHistList->Add(fPtReq1nPrimePrimePOI);
460  
461  //fPtImq1nPrimePrimePOI
462  fPtImq1nPrimePrimePOI = new TProfile("fPtImq1nPrimePrimePOI","Im[q_{n}^{''}]",fnBinsPt,fPtMin,fPtMax,"s");
463  fPtImq1nPrimePrimePOI->SetXTitle("p_{t} [GeV]");
464  fPtImq1nPrimePrimePOI->SetYTitle("Im[q_{n}^{''}]");
465  //fHistList->Add(fPtImq1nPrimePrimePOI);
466  
467  //fPtReq2nPrimePrimePOI
468  fPtReq2nPrimePrimePOI = new TProfile("fPtReq2nPrimePrimePOI","Re[q_{2n}^{''}]",fnBinsPt,fPtMin,fPtMax,"s");
469  fPtReq2nPrimePrimePOI->SetXTitle("p_{t} [GeV]");
470  fPtReq2nPrimePrimePOI->SetYTitle("Re[q_{2n}^{''}]");
471  //fHistList->Add(fPtReq2nPrimePrimePOI);
472  
473  //fPtImq2nPrimePrimePOI
474  fPtImq2nPrimePrimePOI = new TProfile("fPtImq2nPrimePrimePOI","Im[q_{2n}^{''}]",fnBinsPt,fPtMin,fPtMax,"s");
475  fPtImq2nPrimePrimePOI->SetXTitle("p_{t} [GeV]");
476  fPtImq2nPrimePrimePOI->SetYTitle("Im[q_{2n}^{''}]");
477  //fHistList->Add(fPtImq2nPrimePrimePOI);
478  
479  //fmPrimePrimePerPtBin
480  fmPrimePrimePerPtBin = new TProfile("fmPrimePrimePerPtBin","# of particles selected as POI and NOT as RP per #p_{t} bin",fnBinsPt,fPtMin,fPtMax,"s");
481  fmPrimePrimePerPtBin->SetXTitle("p_{t} [GeV]");
482  fmPrimePrimePerPtBin->SetYTitle("Counts");
483  //fHistList->Add(fmPrimePrimePerPtBin);
484  
485  //fEtaReq1nPrimePOI
486  fEtaReq1nPrimePOI = new TProfile("fEtaReq1nPrimePOI","Re[q_{n}^{'}]",fnBinsEta,fEtaMin,fEtaMax,"s");
487  fEtaReq1nPrimePOI->SetXTitle("#eta");
488  fEtaReq1nPrimePOI->SetYTitle("Re[q_{n}^{'}]");
489  //fHistList->Add(fEtaReq1nPrimePOI);
490  
491  //fEtaImq1nPrimePOI
492  fEtaImq1nPrimePOI = new TProfile("fEtaImq1nPrimePOI","Im[q_{n}^{'}]",fnBinsEta,fEtaMin,fEtaMax,"s");
493  fEtaImq1nPrimePOI->SetXTitle("#eta");
494  fEtaImq1nPrimePOI->SetYTitle("Im[q_{n}^{'}]");
495  //fHistList->Add(fEtaImq1nPrimePOI);
496  
497  //fEtaReq2nPrimePOI
498  fEtaReq2nPrimePOI = new TProfile("fEtaReq2nPrimePOI","Re[q_{2n}^{'}]",fnBinsEta,fEtaMin,fEtaMax,"s");
499  fEtaReq2nPrimePOI->SetXTitle("#eta");
500  fEtaReq2nPrimePOI->SetYTitle("Re[q_{2n}^{'}]");
501  //fHistList->Add(fEtaReq2nPrimePOI);
502  
503  //fEtaImq2nPrimePOI
504  fEtaImq2nPrimePOI = new TProfile("fEtaImq2nPrimePOI","Im[q_{2n}^{'}]",fnBinsEta,fEtaMin,fEtaMax,"s");
505  fEtaImq2nPrimePOI->SetXTitle("#eta");
506  fEtaImq2nPrimePOI->SetYTitle("Im[q_{2n}^{'}]");
507  //fHistList->Add(fEtaImq2nPrimePOI);
508  
509  //fmPrimePerEtaBin
510  fmPrimePerEtaBin = new TProfile("fmPrimePerEtaBin","# of particles selected both as RP and POI per #p_{t} bin",fnBinsEta,fEtaMin,fEtaMax,"s");
511  fmPrimePerEtaBin->SetXTitle("#eta");
512  fmPrimePerEtaBin->SetYTitle("Counts");
513  //fHistList->Add(fOverlapPerEtaBin);
514  
515  //fEtaReq1nPrimePrimePOI
516  fEtaReq1nPrimePrimePOI = new TProfile("fEtaReq1nPrimePrimePOI","Re[q_{n}^{''}]",fnBinsEta,fEtaMin,fEtaMax,"s");
517  fEtaReq1nPrimePrimePOI->SetXTitle("#eta");
518  fEtaReq1nPrimePrimePOI->SetYTitle("Re[q_{n}^{''}]");
519  //fHistList->Add(fEtaReq1nPrimePrimePOI);
520  
521  //fEtaImq1nPrimePrimePOI
522  fEtaImq1nPrimePrimePOI = new TProfile("fEtaImq1nPrimePrimePOI","Im[q_{n}^{''}]",fnBinsEta,fEtaMin,fEtaMax,"s");
523  fEtaImq1nPrimePrimePOI->SetXTitle("#eta");
524  fEtaImq1nPrimePrimePOI->SetYTitle("Im[q_{n}^{''}]");
525  //fHistList->Add(fEtaImq1nPrimePrimePOI);
526  
527  //fEtaReq2nPrimePrimePOI
528  fEtaReq2nPrimePrimePOI = new TProfile("fEtaReq2nPrimePrimePOI","Re[q_{2n}^{''}]",fnBinsEta,fEtaMin,fEtaMax,"s");
529  fEtaReq2nPrimePrimePOI->SetXTitle("#eta");
530  fEtaReq2nPrimePrimePOI->SetYTitle("Re[q_{2n}^{''}]");
531  //fHistList->Add(fEtaReq2nPrimePrimePOI);
532  
533  //fEtaImq2nPrimePrimePOI
534  fEtaImq2nPrimePrimePOI = new TProfile("fEtaImq2nPrimePrimePOI","Im[q_{2n}^{''}]",fnBinsEta,fEtaMin,fEtaMax,"s");
535  fEtaImq2nPrimePrimePOI->SetXTitle("#eta");
536  fEtaImq2nPrimePrimePOI->SetYTitle("Im[q_{2n}^{''}]");
537  //fHistList->Add(fEtaImq2nPrimePrimePOI);
538  
539  //fmPrimePrimePerEtaBin
540  fmPrimePrimePerEtaBin = new TProfile("fmPrimePrimePerEtaBin","# of particles selected as POI and NOT as RP per #p_{t} bin",fnBinsEta,fEtaMin,fEtaMax,"s");
541  fmPrimePrimePerEtaBin->SetXTitle("#eta");
542  fmPrimePrimePerEtaBin->SetYTitle("Counts");
543  //fHistList->Add(fmPrimePrimePerEtaBin);
544
545  //f2PerPtBin1n1nPOI
546  f2PerPtBin1n1nPOI = new TProfile("f2PerPtBin1n1nPOI","<2'>_{n|n}",fnBinsPt,fPtMin,fPtMax,"s");
547  f2PerPtBin1n1nPOI->SetXTitle("#eta");
548  //f2PerPtBin1n1n->SetYTitle("<2'>_{n|n}");
549  fHistList->Add(f2PerPtBin1n1nPOI);
550  
551  //f2PerPtBin2n2nPOI
552  f2PerPtBin2n2nPOI = new TProfile("f2PerPtBin2n2nPOI","<2'>_{2n|2n}",fnBinsPt,fPtMin,fPtMax,"s");
553  f2PerPtBin2n2nPOI->SetXTitle("p_{t} [GeV]");
554  //f2PerPtBin2n2nPOI->SetYTitle("<2'>_{2n|2n}");
555  fHistList->Add(f2PerPtBin2n2nPOI);
556  
557  //f3PerPtBin2n1n1nPOI
558  f3PerPtBin2n1n1nPOI = new TProfile("f3PerPtBin2n1n1nPOI","<3'>_{2n|n,n}",fnBinsPt,fPtMin,fPtMax,"s");
559  f3PerPtBin2n1n1nPOI->SetXTitle("p_{t} [GeV]");
560  //f3PerPtBin2n1n1nPOI->SetYTitle("<3'>_{2n|n,n}");
561  fHistList->Add(f3PerPtBin2n1n1nPOI);
562  
563  //f3PerPtBin1n1n2nPOI
564  f3PerPtBin1n1n2nPOI = new TProfile("f3PerPtBin1n1n2nPOI","<3'>_{n,n|2n}",fnBinsPt,fPtMin,fPtMax,"s");
565  f3PerPtBin1n1n2nPOI->SetXTitle("p_{t} [GeV]");
566  //f3PerPtBin1n1n2nPOI->SetYTitle("<3'>_{n,n|2n}");
567  fHistList->Add(f3PerPtBin1n1n2nPOI);
568  
569  //f4PerPtBin1n1n1n1nPOI
570  f4PerPtBin1n1n1n1nPOI = new TProfile("f4PerPtBin1n1n1n1nPOI","<4'>_{n,n|n,n}",fnBinsPt,fPtMin,fPtMax,"s");
571  f4PerPtBin1n1n1n1nPOI->SetXTitle("p_{t} [GeV]");
572  //f4PerPtBin1n1n1n1nPOI->SetYTitle("<4'>_{n,n|n,n}");
573  fHistList->Add(f4PerPtBin1n1n1n1nPOI);
574  
575  //f2PerEtaBin1n1nPOI
576  f2PerEtaBin1n1nPOI = new TProfile("f2PerEtaBin1n1nPOI","<2'>_{n|n}",fnBinsEta,fEtaMin,fEtaMax,"s");
577  f2PerEtaBin1n1nPOI->SetXTitle("#eta");
578  //f2PerEtaBin1n1nPOI->SetYTitle("<2'>_{n|n}");
579  fHistList->Add(f2PerEtaBin1n1nPOI);
580  
581  //f2PerEtaBin2n2nPOI
582  f2PerEtaBin2n2nPOI = new TProfile("f2PerEtaBin2n2nPOI","<2'>_{2n|2n}",fnBinsEta,fEtaMin,fEtaMax,"s");
583  f2PerEtaBin2n2nPOI->SetXTitle("#eta");
584  //f2PerEtaBin2n2nPOI->SetYTitle("<2'>_{2n|2n}");
585  fHistList->Add(f2PerEtaBin2n2nPOI);
586  
587  //f3PerEtaBin2n1n1nPOI
588  f3PerEtaBin2n1n1nPOI = new TProfile("f3PerEtaBin2n1n1nPOI","<3'>_{2n|n,n}",fnBinsEta,fEtaMin,fEtaMax,"s");
589  f3PerEtaBin2n1n1nPOI->SetXTitle("#eta");
590  //f3PerEtaBin2n1n1nPOI->SetYTitle("<3'>_{2n|n,n}");
591  fHistList->Add(f3PerEtaBin2n1n1nPOI);
592  
593  //f3PerEtaBin1n1n2nPOI
594  f3PerEtaBin1n1n2nPOI = new TProfile("f3PerEtaBin1n1n2POI","<3'>_{n,n|2n}",fnBinsEta,fEtaMin,fEtaMax,"s");
595  f3PerEtaBin1n1n2nPOI->SetXTitle("#eta");
596  //f3PerEtaBin1n1n2n->SetYTitle("<3'>_{n,n|2n}");
597  fHistList->Add(f3PerEtaBin1n1n2nPOI);
598  
599  //f4PerEtaBin1n1n1n1nPOI
600  f4PerEtaBin1n1n1n1nPOI = new TProfile("f4PerEtaBin1n1n1n1nPOI","<4'>_{n,n|n,n}",fnBinsEta,fEtaMin,fEtaMax,"s");
601  f4PerEtaBin1n1n1n1nPOI->SetXTitle("#eta");
602  //f4PerEtaBin1n1n1n1nPOI->SetYTitle("<4'>_{n,n|n,n}");
603  fHistList->Add(f4PerEtaBin1n1n1n1nPOI);
604  
605  //common control histogram (2nd order)
606  fCommonHists2nd = new AliFlowCommonHist("AliFlowCommonHist2ndOrderQC");
607  fHistList->Add(fCommonHists2nd);  
608  
609  //common control histogram (4th order)
610  fCommonHists4th = new AliFlowCommonHist("AliFlowCommonHist4thOrderQC");
611  fHistList->Add(fCommonHists4th);  
612  
613  //common control histogram (6th order)
614  fCommonHists6th = new AliFlowCommonHist("AliFlowCommonHist6thOrderQC");
615  fHistList->Add(fCommonHists6th);  
616  
617  //common control histogram (8th order)
618  fCommonHists8th = new AliFlowCommonHist("AliFlowCommonHist8thOrderQC");
619  fHistList->Add(fCommonHists8th);  
620   
621  //common histograms for final results (2nd order)
622  fCommonHistsResults2nd = new AliFlowCommonHistResults("AliFlowCommonHistResults2ndOrderQC");
623  fHistList->Add(fCommonHistsResults2nd); 
624  
625  //common histograms for final results (4th order)
626  fCommonHistsResults4th = new AliFlowCommonHistResults("AliFlowCommonHistResults4thOrderQC");
627  fHistList->Add(fCommonHistsResults4th);
628  
629  //common histograms for final results (6th order)
630  fCommonHistsResults6th = new AliFlowCommonHistResults("AliFlowCommonHistResults6thOrderQC");
631  fHistList->Add(fCommonHistsResults6th); 
632  
633  //common histograms for final results (8th order)
634  fCommonHistsResults8th = new AliFlowCommonHistResults("AliFlowCommonHistResults8thOrderQC");
635  fHistList->Add(fCommonHistsResults8th); 
636  
637  //weighted <2>_{n|n} distribution
638  f2pDistribution = new TH1D("f2pDistribution","<2>_{n|n} distribution",100000,-0.02,0.1);
639  f2pDistribution->SetXTitle("<2>_{n|n}");
640  f2pDistribution->SetYTitle("Counts");
641  fHistList->Add(f2pDistribution);
642
643  //weighted <4>_{n,n|n,n} distribution
644  f4pDistribution = new TH1D("f4pDistribution","<4>_{n,n|n,n} distribution",100000,-0.00025,0.002);
645  f4pDistribution->SetXTitle("<4>_{n,n|n,n}");
646  f4pDistribution->SetYTitle("Counts");
647  fHistList->Add(f4pDistribution); 
648  
649  //weighted <6>_{n,n,n|n,n,n} distribution
650  f6pDistribution = new TH1D("f6pDistribution","<6>_{n,n,n|n,n,n} distribution",100000,-0.000005,0.000025);
651  f6pDistribution->SetXTitle("<6>_{n,n,n|n,n,n}");
652  f6pDistribution->SetYTitle("Counts");
653  fHistList->Add(f6pDistribution);
654  
655  //weighted <8>_{n,n,n,n|n,n,n,n} distribution
656  f8pDistribution = new TH1D("f8pDistribution","<8>_{n,n,n,n|n,n,n,n} distribution",100000,-0.000000001,0.00000001);
657  f8pDistribution->SetXTitle("<8>_{n,n,n,n|n,n,n,n}");
658  f8pDistribution->SetYTitle("Counts");
659  fHistList->Add(f8pDistribution);
660  
661  //phi weights
662  //fHistList->Add(&fPhiWeights);
663  
664  //pt weights
665  //fHistList->Add(&fPtWeights);
666  
667  //eta weights
668  //fHistList->Add(&fEtaWeights);
669 }//end of Init()
670
671 //================================================================================================================
672
673 void AliFlowAnalysisWithQCumulants::Make(AliFlowEventSimple* anEvent)
674 {
675  //running over data 
676  //set the weights:
677  if(fUsePhiWeights)
678  {
679   anEvent->SetUseWeightsPhi(fUsePhiWeights);
680   anEvent->SetPhiWeights(&fPhiWeights);
681  }
682  if(fUsePtWeights)
683  {
684   anEvent->SetUseWeightsPt(fUsePtWeights);
685   anEvent->SetPtWeights(&fPtWeights);
686  }
687  if(fUseEtaWeights)
688  {
689   anEvent->SetUseWeightsEta(fUseEtaWeights);
690   anEvent->SetEtaWeights(&fEtaWeights);
691  }
692   
693  //get the total multiplicity nPrim of event:
694  Int_t nPrim = anEvent->NumberOfTracks();//nPrim = RPs + POIs + rest  
695
696  //needed for debugging: (to be improved - add explanation here) 
697  //Bool_t bNestedLoops=kTRUE;
698  //if(!(bNestedLoops)||(nPrim>0&&nPrim<12))
699  //{
700  //if(nPrim>0&&nPrim<12)
701  //{
702  Int_t n=2;//int flow harmonic (to be improved)
703  
704  //---------------------------------------------------------------------------------------------------------
705  //Q-vectors of an event evaluated in harmonics n, 2n, 3n and 4n from RP particles:
706  AliFlowVector afvQvector1n, afvQvector2n, afvQvector3n, afvQvector4n;
707  
708  afvQvector1n.Set(0.,0.);
709  afvQvector1n.SetMult(0);
710  afvQvector1n=anEvent->GetQ(1*n); 
711
712  afvQvector2n.Set(0.,0.);
713  afvQvector2n.SetMult(0);
714  afvQvector2n=anEvent->GetQ(2*n);                          
715  
716  afvQvector3n.Set(0.,0.);
717  afvQvector3n.SetMult(0);
718  afvQvector3n=anEvent->GetQ(3*n);       
719  
720  afvQvector4n.Set(0.,0.);
721  afvQvector4n.SetMult(0);
722  afvQvector4n=anEvent->GetQ(4*n); 
723  
724             
725  //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
726  //                        !!!! to be removed !!!!
727  fQvectorForEachEventX->Fill(1.*(++fEventCounter),afvQvector1n.X());
728  fQvectorForEachEventY->Fill(1.*(fEventCounter),afvQvector1n.Y()); 
729  //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
730                        
731                                   
732                                                         
733  //---------------------------------------------------------------------------------------------------------
734  
735  //multiplicity of RP particles:
736  Double_t dMult = afvQvector1n.GetMult();
737  
738  fAvMultIntFlowQC->Fill(0.,dMult,1.);//to be removed (this info is also stored in one of control histograms)
739  
740  //---------------------------------------------------------------------------------------------------------
741  //
742  //                                          *******************
743  //                                          **** Q-vectors ****
744  //                                          *******************
745  //
746  Double_t reQ2nQ1nstarQ1nstar = pow(afvQvector1n.X(),2.)*afvQvector2n.X()+2.*afvQvector1n.X()*afvQvector1n.Y()*afvQvector2n.Y()-pow(afvQvector1n.Y(),2.)*afvQvector2n.X();//Re[Q_{2n} Q_{n}^* Q_{n}^*]
747  //Double_t imQ2nQ1nstarQ1nstar = pow(Qvector1n.X(),2.)*Qvector2n.Y()-2.*Qvector1n.X()*Qvector1n.Y()*Qvector2n.X()-pow(Qvector1n.Y(),2.)*Qvector2n.Y();//Im[Q_{2n} Q_{n}^* Q_{n}^*]
748  Double_t reQ1nQ1nQ2nstar = reQ2nQ1nstarQ1nstar;//Re[Q_{n} Q_{n} Q_{2n}^*] = Re[Q_{2n} Q_{n}^* Q_{n}^*]
749  Double_t reQ3nQ1nQ2nstarQ2nstar = (pow(afvQvector2n.X(),2.)-pow(afvQvector2n.Y(),2.))*(afvQvector3n.X()*afvQvector1n.X()-afvQvector3n.Y()*afvQvector1n.Y())+2.*afvQvector2n.X()*afvQvector2n.Y()*(afvQvector3n.X()*afvQvector1n.Y()+afvQvector3n.Y()*afvQvector1n.X());
750  //Double_t imQ3nQ1nQ2nstarQ2nstar = calculate and implement this (deleteMe) 
751  Double_t reQ2nQ2nQ3nstarQ1nstar = reQ3nQ1nQ2nstarQ2nstar;
752  Double_t reQ4nQ2nstarQ2nstar = pow(afvQvector2n.X(),2.)*afvQvector4n.X()+2.*afvQvector2n.X()*afvQvector2n.Y()*afvQvector4n.Y()-pow(afvQvector2n.Y(),2.)*afvQvector4n.X();//Re[Q_{4n} Q_{2n}^* Q_{2n}^*]
753  //Double_t imQ4nQ2nstarQ2nstar = calculate and implement this (deleteMe)
754  Double_t reQ2nQ2nQ4nstar = reQ4nQ2nstarQ2nstar;
755  Double_t reQ4nQ3nstarQ1nstar = afvQvector4n.X()*(afvQvector3n.X()*afvQvector1n.X()-afvQvector3n.Y()*afvQvector1n.Y())+afvQvector4n.Y()*(afvQvector3n.X()*afvQvector1n.Y()+afvQvector3n.Y()*afvQvector1n.X());//Re[Q_{4n} Q_{3n}^* Q_{n}^*]
756  Double_t reQ3nQ1nQ4nstar = reQ4nQ3nstarQ1nstar;//Re[Q_{3n} Q_{n} Q_{4n}^*] = Re[Q_{4n} Q_{3n}^* Q_{n}^*]
757  //Double_t imQ4nQ3nstarQ1nstar = calculate and implement this (deleteMe)
758  Double_t reQ3nQ2nstarQ1nstar = afvQvector3n.X()*afvQvector2n.X()*afvQvector1n.X()-afvQvector3n.X()*afvQvector2n.Y()*afvQvector1n.Y()+afvQvector3n.Y()*afvQvector2n.X()*afvQvector1n.Y()+afvQvector3n.Y()*afvQvector2n.Y()*afvQvector1n.X();//Re[Q_{3n} Q_{2n}^* Q_{n}^*]
759  Double_t reQ2nQ1nQ3nstar = reQ3nQ2nstarQ1nstar;//Re[Q_{2n} Q_{n} Q_{3n}^*] = Re[Q_{3n} Q_{2n}^* Q_{n}^*]
760  //Double_t imQ3nQ2nstarQ1nstar; //calculate and implement this (deleteMe)
761  Double_t reQ3nQ1nstarQ1nstarQ1nstar = afvQvector3n.X()*pow(afvQvector1n.X(),3)-3.*afvQvector1n.X()*afvQvector3n.X()*pow(afvQvector1n.Y(),2)+3.*afvQvector1n.Y()*afvQvector3n.Y()*pow(afvQvector1n.X(),2)-afvQvector3n.Y()*pow(afvQvector1n.Y(),3);//Re[Q_{3n} Q_{n}^* Q_{n}^* Q_{n}^*]
762  //Double_t imQ3nQ1nstarQ1nstarQ1nstar; //calculate and implement this (deleteMe)
763  Double_t xQ2nQ1nQ2nstarQ1nstar = pow(afvQvector2n.Mod()*afvQvector1n.Mod(),2);//|Q_{2n}|^2 |Q_{n}|^2
764  Double_t reQ4nQ2nstarQ1nstarQ1nstar = (afvQvector4n.X()*afvQvector2n.X()+afvQvector4n.Y()*afvQvector2n.Y())*(pow(afvQvector1n.X(),2)-pow(afvQvector1n.Y(),2))+2.*afvQvector1n.X()*afvQvector1n.Y()*(afvQvector4n.Y()*afvQvector2n.X()-afvQvector4n.X()*afvQvector2n.Y());//Re[Q_{4n} Q_{2n}^* Q_{n}^* Q_{n}^*] 
765  //Double_t imQ4nQ2nstarQ1nstarQ1nstar; //calculate and implement this (deleteMe)
766  Double_t reQ2nQ1nQ1nstarQ1nstarQ1nstar = (afvQvector2n.X()*afvQvector1n.X()-afvQvector2n.Y()*afvQvector1n.Y())*(pow(afvQvector1n.X(),3)-3.*afvQvector1n.X()*pow(afvQvector1n.Y(),2))+(afvQvector2n.X()*afvQvector1n.Y()+afvQvector1n.X()*afvQvector2n.Y())*(3.*afvQvector1n.Y()*pow(afvQvector1n.X(),2)-pow(afvQvector1n.Y(),3));//Re[Q_{2n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^*]
767  //Double_t imQ2nQ1nQ1nstarQ1nstarQ1nstar; //calculate and implement this (deleteMe)
768  Double_t reQ2nQ2nQ2nstarQ1nstarQ1nstar = pow(afvQvector2n.Mod(),2.)*(afvQvector2n.X()*(pow(afvQvector1n.X(),2.)-pow(afvQvector1n.Y(),2.))+2.*afvQvector2n.Y()*afvQvector1n.X()*afvQvector1n.Y());//Re[Q_{2n} Q_{2n} Q_{2n}^* Q_{n}^* Q_{n}^*]
769  //Double_t imQ2nQ2nQ2nstarQ1nstarQ1nstar = pow(Qvector2n.Mod(),2.)*(Qvector2n.Y()*(pow(Qvector1n.X(),2.)-pow(Qvector1n.Y(),2.))-2.*Qvector2n.X()*Qvector1n.X()*Qvector1n.Y());//Im[Q_{2n} Q_{2n} Q_{2n}^* Q_{n}^* Q_{n}^*]
770  Double_t reQ4nQ1nstarQ1nstarQ1nstarQ1nstar = pow(afvQvector1n.X(),4.)*afvQvector4n.X()-6.*pow(afvQvector1n.X(),2.)*afvQvector4n.X()*pow(afvQvector1n.Y(),2.)+pow(afvQvector1n.Y(),4.)*afvQvector4n.X()+4.*pow(afvQvector1n.X(),3.)*afvQvector1n.Y()*afvQvector4n.Y()-4.*pow(afvQvector1n.Y(),3.)*afvQvector1n.X()*afvQvector4n.Y();//Re[Q_{4n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]
771  //Double_t imQ4nQ1nstarQ1nstarQ1nstarQ1nstar = pow(Qvector1n.X(),4.)*Qvector4n.Y()-6.*pow(Qvector1n.X(),2.)*Qvector4n.Y()*pow(Qvector1n.Y(),2.)+pow(Qvector1n.Y(),4.)*Qvector4n.Y()+4.*pow(Qvector1n.Y(),3.)*Qvector1n.X()*Qvector4n.X()-4.*pow(Qvector1n.X(),3.)*Qvector1n.Y()*Qvector4n.X();//Im[Q_{4n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]
772  Double_t reQ3nQ1nQ2nstarQ1nstarQ1nstar = pow(afvQvector1n.Mod(),2.)*(afvQvector1n.X()*afvQvector2n.X()*afvQvector3n.X()-afvQvector3n.X()*afvQvector1n.Y()*afvQvector2n.Y()+afvQvector2n.X()*afvQvector1n.Y()*afvQvector3n.Y()+afvQvector1n.X()*afvQvector2n.Y()*afvQvector3n.Y());//Re[Q_{3n} Q_{n} Q_{2n}^* Q_{n}^* Q_{n}^*]
773  //Double_t imQ3nQ1nQ2nstarQ1nstarQ1nstar = pow(afvQvector1n.Mod(),2.)*(-afvQvector2n.X()*afvQvector3n.X()*afvQvector1n.Y()-afvQvector1n.X()*afvQvector3n.X()*afvQvector2n.Y()+afvQvector1n.X()*afvQvector2n.X()*afvQvector3n.Y()-afvQvector1n.Y()*afvQvector2n.Y()*afvQvector3n.Y());//Im[Q_{3n} Q_{n} Q_{2n}^* Q_{n}^* Q_{n}^*]
774  Double_t reQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar = (pow(afvQvector1n.X(),2.)*afvQvector2n.X()-2.*afvQvector1n.X()*afvQvector2n.X()*afvQvector1n.Y()-afvQvector2n.X()*pow(afvQvector1n.Y(),2.)+afvQvector2n.Y()*pow(afvQvector1n.X(),2.)+2.*afvQvector1n.X()*afvQvector1n.Y()*afvQvector2n.Y()-pow(afvQvector1n.Y(),2.)*afvQvector2n.Y())*(pow(afvQvector1n.X(),2.)*afvQvector2n.X()+2.*afvQvector1n.X()*afvQvector2n.X()*afvQvector1n.Y()-afvQvector2n.X()*pow(afvQvector1n.Y(),2.)-afvQvector2n.Y()*pow(afvQvector1n.X(),2.)+2.*afvQvector1n.X()*afvQvector1n.Y()*afvQvector2n.Y()+pow(afvQvector1n.Y(),2.)*afvQvector2n.Y());//Re[Q_{2n} Q_{2n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]
775  //Double_t imQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar = 2.*(pow(afvQvector1n.X(),2.)*afvQvector2n.X()-afvQvector2n.X()*pow(afvQvector1n.Y(),2.)+2.*afvQvector1n.X()*afvQvector1n.Y()*afvQvector2n.Y())*(pow(afvQvector1n.X(),2.)*afvQvector2n.Y()-2.*afvQvector1n.X()*afvQvector1n.Y()*afvQvector2n.X()-pow(afvQvector1n.Y(),2.)*afvQvector2n.Y());//Im[Q_{2n} Q_{2n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]
776  Double_t reQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = pow(afvQvector1n.Mod(),2.)*(pow(afvQvector1n.X(),3.)*afvQvector3n.X()-3.*afvQvector1n.X()*afvQvector3n.X()*pow(afvQvector1n.Y(),2.)+3.*pow(afvQvector1n.X(),2.)*afvQvector1n.Y()*afvQvector3n.Y()-pow(afvQvector1n.Y(),3.)*afvQvector3n.Y());//Re[Q_{3n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]
777  //Double_t imQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = pow(afvQvector1n.Mod(),2.)*(pow(afvQvector1n.Y(),3.)*afvQvector3n.X()-3.*afvQvector1n.Y()*afvQvector3n.X()*pow(afvQvector1n.X(),2.)-3.*pow(afvQvector1n.Y(),2.)*afvQvector1n.X()*afvQvector3n.Y()+pow(afvQvector1n.X(),3.)*afvQvector3n.Y());//Im[Q_{3n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]
778  Double_t xQ2nQ1nQ1nQ2nstarQ1nstarQ1nstar = pow(afvQvector2n.Mod(),2.)*pow(afvQvector1n.Mod(),4.);//|Q_{2n}|^2 |Q_{n}|^4
779  Double_t reQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = pow(afvQvector1n.Mod(),4.)*(pow(afvQvector1n.X(),2.)*afvQvector2n.X()-afvQvector2n.X()*pow(afvQvector1n.Y(),2.)+2.*afvQvector1n.X()*afvQvector1n.Y()*afvQvector2n.Y());//Re[Q_{2n} Q_{n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]
780  //Double_t imQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar = pow(afvQvector1n.Mod(),4.)*(pow(afvQvector1n.X(),2.)*afvQvector2n.Y()-afvQvector2n.Y()*pow(afvQvector1n.Y(),2.)-2.*afvQvector1n.X()*afvQvector2n.X()*afvQvector1n.Y());//Re[Q_{2n} Q_{n} Q_{n} Q_{n}^* Q_{n}^* Q_{n}^* Q_{n}^*]
781  //---------------------------------------------------------------------------------------------------------
782  
783  //---------------------------------------------------------------------------------------------------------
784  //
785  //                                        **************************************
786  //                                        **** multi-particle correlations: ****
787  //                                        **************************************
788  //
789  // Remark 1: multi-particle correlations calculated with Q-vectors are stored in fQCorrelations.
790  // Remark 2: binning of fQCorrelations is organized as follows: 
791  //
792  // 1st bin: <2>_{n|n} = two1n1n
793  // 2nd bin: <2>_{2n|2n} = two2n2n
794  // 3rd bin: <2>_{3n|3n} = two3n3n
795  // 4th bin: <2>_{4n|4n} = two4n4n
796  // 5th bin: --  EMPTY --
797  // 6th bin: <3>_{2n|n,n} = three2n1n1n
798  // 7th bin: <3>_{3n|2n,n} = three3n2n1n
799  // 8th bin: <3>_{4n|2n,2n} = three4n2n2n
800  // 9th bin: <3>_{4n|3n,n} = three4n3n1n
801  //10th bin: --  EMPTY --
802  //11th bin: <4>_{n,n|n,n} = four1n1n1n1n
803  //12th bin: <4>_{2n,n|2n,n} = four2n1n2n1n
804  //13th bin: <4>_{2n,2n|2n,2n} = four2n2n2n2n
805  //14th bin: <4>_{3n|n,n,n} = four3n1n1n1n
806  //15th bin: <4>_{3n,n|3n,n} = four3n1n3n1n 
807  //16th bin: <4>_{3n,n|2n,2n} = four3n1n2n2n
808  //17th bin: <4>_{4n|2n,n,n} = four4n2n1n1n
809  //18th bin: --  EMPTY --
810  //19th bin: <5>_{2n|n,n,n,n} = five2n1n1n1n1n
811  //20th bin: <5>_{2n,2n|2n,n,n} = five2n2n2n1n1n
812  //21st bin: <5>_{3n,n|2n,n,n} = five3n1n2n1n1n
813  //22nd bin: <5>_{4n|n,n,n,n} = five4n1n1n1n1n  
814  //23rd bin: --  EMPTY --
815  //24th bin: <6>_{n,n,n|n,n,n} = six1n1n1n1n1n1n
816  //25th bin: <6>_{2n,n,n|2n,n,n} = six2n1n1n2n1n1n
817  //26th bin: <6>_{2n,2n|n,n,n,n} = six2n2n1n1n1n1n
818  //27th bin: <6>_{3n,n|n,n,n,n} = six3n1n1n1n1n1n
819  //28th bin: --  EMPTY --
820  //29th bin: <7>_{2n,n,n|n,n,n,n} = seven2n1n1n1n1n1n1n
821  //30th bin: --  EMPTY --
822  //31st bin: <8>_{n,n,n,n|n,n,n,n} = eight1n1n1n1n1n1n1n1n
823
824  
825  // binning of fQProduct (all correlations are evaluated in harmonic n): 
826  // 1st bin: <2>*<4>
827  // 2nd bin: <2>*<6>
828  // 3rd bin: <2>*<8> 
829  // 4th bin: <4>*<6>
830  // 5th bin: <4>*<8>
831  // 6th bin: <6>*<8>
832          
833  //2-particle
834  Double_t two1n1n=0., two2n2n=0., two3n3n=0., two4n4n=0.; 
835  if(dMult>1)
836  {
837   //fill the common control histogram (2nd order):
838   fCommonHists2nd->FillControlHistograms(anEvent); 
839  
840   two1n1n = (pow(afvQvector1n.Mod(),2.)-dMult)/(dMult*(dMult-1.)); //<2>_{n|n}   = <cos(n*(phi1-phi2))>
841   two2n2n = (pow(afvQvector2n.Mod(),2.)-dMult)/(dMult*(dMult-1.)); //<2>_{2n|2n} = <cos(2n*(phi1-phi2))>
842   two3n3n = (pow(afvQvector3n.Mod(),2.)-dMult)/(dMult*(dMult-1.)); //<2>_{3n|3n} = <cos(3n*(phi1-phi2))>
843   two4n4n = (pow(afvQvector4n.Mod(),2.)-dMult)/(dMult*(dMult-1.)); //<2>_{4n|4n} = <cos(4n*(phi1-phi2))>
844     
845   fQCorrelations->Fill(0.,two1n1n,dMult*(dMult-1.)); 
846   fQCorrelations->Fill(1.,two2n2n,dMult*(dMult-1.)); 
847   fQCorrelations->Fill(2.,two3n3n,dMult*(dMult-1.)); 
848   fQCorrelations->Fill(3.,two4n4n,dMult*(dMult-1.)); 
849   
850   f2pDistribution->Fill(two1n1n,dMult*(dMult-1.)); 
851  }
852  
853  //3-particle
854  Double_t three2n1n1n=0., three3n2n1n=0., three4n2n2n=0., three4n3n1n=0.;
855  if(dMult>2)
856  {
857   three2n1n1n = (reQ2nQ1nstarQ1nstar-2.*pow(afvQvector1n.Mod(),2.)-pow(afvQvector2n.Mod(),2.)+2.*dMult)/(dMult*(dMult-1.)*(dMult-2.)); //Re[<3>_{2n|n,n}] = Re[<3>_{n,n|2n}] = <cos(n*(2.*phi1-phi2-phi3))>
858   three3n2n1n = (reQ3nQ2nstarQ1nstar-pow(afvQvector3n.Mod(),2.)-pow(afvQvector2n.Mod(),2.)-pow(afvQvector1n.Mod(),2.)+2.*dMult)/(dMult*(dMult-1.)*(dMult-2.)); //Re[<3>_{3n|2n,n}] = Re[<3>_{2n,n|3n}] = <cos(n*(3.*phi1-2.*phi2-phi3))>
859   three4n2n2n = (reQ4nQ2nstarQ2nstar-2.*pow(afvQvector2n.Mod(),2.)-pow(afvQvector4n.Mod(),2.)+2.*dMult)/(dMult*(dMult-1.)*(dMult-2.)); //Re[<3>_{4n|2n,2n}] = Re[<3>_{2n,2n|4n}] = <cos(n*(4.*phi1-2.*phi2-2.*phi3))>
860   three4n3n1n = (reQ4nQ3nstarQ1nstar-pow(afvQvector4n.Mod(),2.)-pow(afvQvector3n.Mod(),2.)-pow(afvQvector1n.Mod(),2.)+2.*dMult)/(dMult*(dMult-1.)*(dMult-2.)); //Re[<3>_{4n|3n,n}] = Re[<3>_{3n,n|4n}] = <cos(n*(4.*phi1-3.*phi2-phi3))>
861  
862   fQCorrelations->Fill(5.,three2n1n1n,dMult*(dMult-1.)*(dMult-2.)); 
863   fQCorrelations->Fill(6.,three3n2n1n,dMult*(dMult-1.)*(dMult-2.));
864   fQCorrelations->Fill(7.,three4n2n2n,dMult*(dMult-1.)*(dMult-2.)); 
865   fQCorrelations->Fill(8.,three4n3n1n,dMult*(dMult-1.)*(dMult-2.));    
866  }
867  
868  //4-particle
869  Double_t four1n1n1n1n=0., four2n2n2n2n=0., four2n1n2n1n=0., four3n1n1n1n=0., four4n2n1n1n=0., four3n1n2n2n=0., four3n1n3n1n=0.;  
870  if(dMult>3)
871  {
872   //fill the common control histogram (4th order):
873   fCommonHists4th->FillControlHistograms(anEvent); 
874
875   four1n1n1n1n = (2.*dMult*(dMult-3.)+pow(afvQvector1n.Mod(),4.)-4.*(dMult-2.)*pow(afvQvector1n.Mod(),2.)-2.*reQ2nQ1nstarQ1nstar+pow(afvQvector2n.Mod(),2.))/(dMult*(dMult-1)*(dMult-2.)*(dMult-3.));//<4>_{n,n|n,n}
876   four2n2n2n2n = (2.*dMult*(dMult-3.)+pow(afvQvector2n.Mod(),4.)-4.*(dMult-2.)*pow(afvQvector2n.Mod(),2.)-2.*reQ4nQ2nstarQ2nstar+pow(afvQvector4n.Mod(),2.))/(dMult*(dMult-1)*(dMult-2.)*(dMult-3.));//<4>_{2n,2n|2n,2n}
877   four2n1n2n1n = (xQ2nQ1nQ2nstarQ1nstar-2.*reQ3nQ2nstarQ1nstar-2.*reQ2nQ1nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))-((dMult-5.)*pow(afvQvector1n.Mod(),2.)+(dMult-4.)*pow(afvQvector2n.Mod(),2.)-pow(afvQvector3n.Mod(),2.))/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))+(dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.));//Re[<4>_{2n,n|2n,n}]
878   four3n1n1n1n = (reQ3nQ1nstarQ1nstarQ1nstar-3.*reQ3nQ2nstarQ1nstar-3.*reQ2nQ1nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))+(2.*pow(afvQvector3n.Mod(),2.)+3.*pow(afvQvector2n.Mod(),2.)+6.*pow(afvQvector1n.Mod(),2.)-6.*dMult)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));//Re[<4>_{3n|n,n,n}]
879   four4n2n1n1n = (reQ4nQ2nstarQ1nstarQ1nstar-2.*reQ4nQ3nstarQ1nstar-reQ4nQ2nstarQ2nstar-2.*reQ3nQ2nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))-(reQ2nQ1nstarQ1nstar-2.*pow(afvQvector4n.Mod(),2.)-2.*pow(afvQvector3n.Mod(),2.)-3.*pow(afvQvector2n.Mod(),2.)-4.*pow(afvQvector1n.Mod(),2.))/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))-(6.)/((dMult-1.)*(dMult-2.)*(dMult-3.));//Re[<4>_{4n|2n,n,n}]
880   four3n1n2n2n = (reQ3nQ1nQ2nstarQ2nstar-reQ4nQ2nstarQ2nstar-reQ3nQ1nQ4nstar-2.*reQ3nQ2nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))-(2.*reQ1nQ1nQ2nstar-pow(afvQvector4n.Mod(),2.)-2.*pow(afvQvector3n.Mod(),2.)-4.*pow(afvQvector2n.Mod(),2.)-4.*pow(afvQvector1n.Mod(),2.))/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))-(6.)/((dMult-1.)*(dMult-2.)*(dMult-3.));//Re[<4>_{3n,n|2n,2n}] 
881   four3n1n3n1n = (pow(afvQvector3n.Mod(),2.)*pow(afvQvector1n.Mod(),2.)-2.*reQ4nQ3nstarQ1nstar-2.*reQ3nQ2nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))+(pow(afvQvector4n.Mod(),2.)-(dMult-4.)*pow(afvQvector3n.Mod(),2.)+pow(afvQvector2n.Mod(),2.)-(dMult-4.)*pow(afvQvector1n.Mod(),2.))/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.))+(dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.));//<4>_{3n,n|3n,n}
882   //four_3n1n3n1n = Q3nQ1nQ3nstarQ1nstar/(M*(M-1.)*(M-2.)*(M-3.))-(2.*three_3n2n1n+2.*three_4n3n1n)/(M-3.)-(two_4n4n+M*two_3n3n+two_2n2n+M*two_1n1n)/((M-2.)*(M-3.))-M/((M-1.)*(M-2.)*(M-3.));//<4>_{3n,n|3n,n}
883   
884   fQCorrelations->Fill(10.,four1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
885   fQCorrelations->Fill(11.,four2n1n2n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
886   fQCorrelations->Fill(12.,four2n2n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
887   fQCorrelations->Fill(13.,four3n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
888   fQCorrelations->Fill(14.,four3n1n3n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
889   fQCorrelations->Fill(15.,four3n1n2n2n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));  
890   fQCorrelations->Fill(16.,four4n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)); 
891   
892   f4pDistribution->Fill(four1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
893   
894   fQProduct->Fill(0.,two1n1n*four1n1n1n1n,dMult*(dMult-1.)*dMult*(dMult-1.)*(dMult-2.)*(dMult-3.));
895  }
896
897  //5-particle
898  Double_t five2n1n1n1n1n=0., five2n2n2n1n1n=0., five3n1n2n1n1n=0., five4n1n1n1n1n=0.;
899  if(dMult>4)
900  {
901   five2n1n1n1n1n = (reQ2nQ1nQ1nstarQ1nstarQ1nstar-reQ3nQ1nstarQ1nstarQ1nstar+6.*reQ3nQ2nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))-(reQ2nQ1nQ3nstar+3.*(dMult-6.)*reQ2nQ1nstarQ1nstar+3.*reQ1nQ1nQ2nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))-(2.*pow(afvQvector3n.Mod(),2.)+3.*pow(afvQvector2n.Mod()*afvQvector1n.Mod(),2.)-3.*(dMult-4.)*pow(afvQvector2n.Mod(),2.))/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))-3.*(pow(afvQvector1n.Mod(),4.)-2.*(2*dMult-5.)*pow(afvQvector1n.Mod(),2.)+2.*dMult*(dMult-4.))/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));//Re[<5>_{2n,n|n,n,n}]
902   
903   five2n2n2n1n1n = (reQ2nQ2nQ2nstarQ1nstarQ1nstar-reQ4nQ2nstarQ1nstarQ1nstar-2.*reQ2nQ2nQ3nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))+2.*(reQ4nQ2nstarQ2nstar+4.*reQ3nQ2nstarQ1nstar+reQ3nQ1nQ4nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))+(reQ2nQ2nQ4nstar-2.*(dMult-5.)*reQ2nQ1nstarQ1nstar+2.*reQ1nQ1nQ2nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))-(2.*pow(afvQvector4n.Mod(),2.)+4.*pow(afvQvector3n.Mod(),2.)+1.*pow(afvQvector2n.Mod(),4.)-2.*(3.*dMult-10.)*pow(afvQvector2n.Mod(),2.))/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))-(4.*pow(afvQvector1n.Mod(),2.)*pow(afvQvector2n.Mod(),2.)-4.*(dMult-5.)*pow(afvQvector1n.Mod(),2.)+4.*dMult*(dMult-6.))/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));//Re[<5>_{2n,2n|2n,n,n}]  
904
905   //five_2n2n2n1n1n = reQ2nQ2nQ2nstarQ1nstarQ1nstar/(M*(M-1.)*(M-2.)*(M-3.)*(M-4.))-(4.*four_2n1n2n1n+2.*four_3n1n2n2n+1.*four_2n2n2n2n+four_4n2n1n1n)/(M-4.)-(2.*three_4n3n1n+three_4n2n2n+three_4n2n2n+2.*three_3n2n1n)/((M-3.)*(M-4.))-(4.*three_3n2n1n+(2.*M-1.)*three_2n1n1n+2.*three_2n1n1n)/((M-3.)*(M-4.))-(two_4n4n+2.*two_3n3n+4.*(M-1.)*two_2n2n+2.*(2.*M-1.)*two_1n1n)/((M-2.)*(M-3.)*(M-4.))-(2.*M-1.)/((M-1.)*(M-2.)*(M-3.)*(M-4.)); //OK! 
906    
907   five4n1n1n1n1n = (reQ4nQ1nstarQ1nstarQ1nstarQ1nstar-6.*reQ4nQ2nstarQ1nstarQ1nstar-4.*reQ3nQ1nstarQ1nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))+(8.*reQ4nQ3nstarQ1nstar+3.*reQ4nQ2nstarQ2nstar+12.*reQ3nQ2nstarQ1nstar+12.*reQ2nQ1nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))-(6.*pow(afvQvector4n.Mod(),2.)+8.*pow(afvQvector3n.Mod(),2.)+12.*pow(afvQvector2n.Mod(),2.)+24.*pow(afvQvector1n.Mod(),2.)-24.*dMult)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));//Re[<5>_{4n|n,n,n,n}] 
908   
909   //five_4n1n1n1n1n = reQ4nQ1nstarQ1nstarQ1nstarQ1nstar/(M*(M-1.)*(M-2.)*(M-3.)*(M-4.)) -  (4.*four_3n1n1n1n+6.*four_4n2n1n1n)/(M-4.)  -  (6.*three_2n1n1n  + 12.*three_3n2n1n + 4.*three_4n3n1n + 3.*three_4n2n2n)/((M-3.)*(M-4.))  -  (4.*two_1n1n + 6.*two_2n2n + 4.*two_3n3n + 1.*two_4n4n)/((M-2.)*(M-3.)*(M-4.)) - 1./((M-1.)*(M-2.)*(M-3.)*(M-4.)); //OK!
910   
911   five3n1n2n1n1n = (reQ3nQ1nQ2nstarQ1nstarQ1nstar-reQ4nQ2nstarQ1nstarQ1nstar-reQ3nQ1nstarQ1nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))-(reQ3nQ1nQ2nstarQ2nstar-3.*reQ4nQ3nstarQ1nstar-reQ4nQ2nstarQ2nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))-((2.*dMult-13.)*reQ3nQ2nstarQ1nstar-reQ3nQ1nQ4nstar-9.*reQ2nQ1nstarQ1nstar)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))-(2.*reQ1nQ1nQ2nstar+2.*pow(afvQvector4n.Mod(),2.)-2.*(dMult-5.)*pow(afvQvector3n.Mod(),2.)+2.*pow(afvQvector3n.Mod(),2.)*pow(afvQvector1n.Mod(),2.))/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))+(2.*(dMult-6.)*pow(afvQvector2n.Mod(),2.)-2.*pow(afvQvector2n.Mod(),2.)*pow(afvQvector1n.Mod(),2.)-pow(afvQvector1n.Mod(),4.)+2.*(3.*dMult-11.)*pow(afvQvector1n.Mod(),2.))/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.))-4.*(dMult-6.)/((dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));//Re[<5>_{3n,n|2n,n,n}] 
912   
913   //five3n1n2n1n1n = reQ3nQ1nQ2nstarQ1nstarQ1nstar/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)) -  (four4n2n1n1n+four1n1n1n1n+four3n1n1n1n+2.*four2n1n2n1n+2.*three3n2n1n+2.*four3n1n3n1n+four3n1n2n2n)/(dMult-4.)  -   (2.*three4n3n1n+three4n2n2n+6.*three3n2n1n+three4n3n1n+2.*three3n2n1n+3.*three2n1n1n+2.*three2n1n1n+4.*two1n1n+2.*two2n2n+2.*two3n3n)/((dMult-3.)*(dMult-4.))  -  (5.*two1n1n + 4.*two2n2n + 3.*two3n3n + 1.*two4n4n + 2.)/((dMult-2.)*(dMult-3.)*(dMult-4.))  - 1./((dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)) ;//Re[<5>_{3n,n|2n,n,n}] //OK!
914   
915   //five3n1n2n1n1n = reQ3nQ1nQ2nstarQ1nstarQ1nstar/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)) -  (four4n2n1n1n+four1n1n1n1n+four3n1n1n1n+2.*four2n1n2n1n+2.*four3n1n3n1n+four3n1n2n2n)/(dMult-4.)  -      (2.*three4n3n1n+three4n2n2n+2.*dMult*three3n2n1n+three4n3n1n+2.*three3n2n1n+3.*three2n1n1n+2.*three2n1n1n)/((dMult-3.)*(dMult-4.))  -  ((4.*dMult-3.)*two1n1n + 2.*dMult*two2n2n + (2.*dMult-1.)*two3n3n + two4n4n)/((dMult-2.)*(dMult-3.)*(dMult-4.))  - (2.*dMult-1.)/((dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)) ;//Re[<5>_{3n,n|2n,n,n}] //OK!
916    
917   fQCorrelations->Fill(18.,five2n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)); 
918   fQCorrelations->Fill(19.,five2n2n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
919   fQCorrelations->Fill(20.,five3n1n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
920   fQCorrelations->Fill(21.,five4n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.));
921  }
922
923  //6-particle
924  Double_t six1n1n1n1n1n1n=0., six2n2n1n1n1n1n=0., six3n1n1n1n1n1n=0., six2n1n1n2n1n1n=0.;
925  if(dMult>5)
926  {
927   //fill the common control histogram (6th order):
928   fCommonHists6th->FillControlHistograms(anEvent); 
929  
930   six1n1n1n1n1n1n = (pow(afvQvector1n.Mod(),6.)+9.*xQ2nQ1nQ2nstarQ1nstar-6.*reQ2nQ1nQ1nstarQ1nstarQ1nstar)/(dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5))+4.*(reQ3nQ1nstarQ1nstarQ1nstar-3.*reQ3nQ2nstarQ1nstar)/(dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5))+2.*(9.*(dMult-4.)*reQ2nQ1nstarQ1nstar+2.*pow(afvQvector3n.Mod(),2.))/(dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-4)*(dMult-5))-9.*(pow(afvQvector1n.Mod(),4.)+pow(afvQvector2n.Mod(),2.))/(dMult*(dMult-1)*(dMult-2)*(dMult-3)*(dMult-5))+(18.*pow(afvQvector1n.Mod(),2.))/(dMult*(dMult-1)*(dMult-3)*(dMult-4))-(6.)/((dMult-1)*(dMult-2)*(dMult-3));//<6>_{n,n,n|n,n,n}
931   
932   six2n1n1n2n1n1n = (xQ2nQ1nQ1nQ2nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(2.*five2n2n2n1n1n+4.*five2n1n1n1n1n+4.*five3n1n2n1n1n+4.*four2n1n2n1n+1.*four1n1n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(4.*four1n1n1n1n+4.*two1n1n+2.*three2n1n1n+2.*three2n1n1n+4.*four3n1n1n1n+8.*three2n1n1n+2.*four4n2n1n1n+4.*four2n1n2n1n+2.*two2n2n+8.*four2n1n2n1n+4.*four3n1n3n1n+8.*three3n2n1n+4.*four3n1n2n2n+4.*four1n1n1n1n+4.*four2n1n2n1n+1.*four2n2n2n2n)-dMult*(dMult-1.)*(dMult-2.)*(2.*three2n1n1n+8.*two1n1n+4.*two1n1n+2.+4.*two1n1n+4.*three2n1n1n+2.*two2n2n+4.*three2n1n1n+8.*three3n2n1n+8.*two2n2n+4.*three4n3n1n+4.*two3n3n+4.*three3n2n1n+4.*two1n1n+8.*three2n1n1n+4.*two1n1n+4.*three3n2n1n+4.*three2n1n1n+2.*two2n2n+4.*three3n2n1n+2.*three4n2n2n)-dMult*(dMult-1.)*(4.*two1n1n+4.+4.*two1n1n+2.*two2n2n+1.+4.*two1n1n+4.*two2n2n+4.*two3n3n+   1.+2.*two2n2n+1.*two4n4n)-dMult)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));//<6>_{2n,n,n|2n,n,n}
933  
934   six2n2n1n1n1n1n = (reQ2nQ2nQ1nstarQ1nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(five4n1n1n1n1n+8.*five2n1n1n1n1n+6.*five2n2n2n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(4.*four3n1n1n1n+6.*four4n2n1n1n+12.*three2n1n1n+12.*four1n1n1n1n+24.*four2n1n2n1n+4.*four3n1n2n2n+3.*four2n2n2n2n)-dMult*(dMult-1.)*(dMult-2.)*(6.*three2n1n1n+12.*three3n2n1n+4.*three4n3n1n+3.*three4n2n2n+8.*three2n1n1n+24.*two1n1n+12.*two2n2n+12.*three2n1n1n+8.*three3n2n1n+1.*three4n2n2n)-dMult*(dMult-1.)*(4.*two1n1n+6.*two2n2n+4.*two3n3n+1.*two4n4n+2.*two2n2n+8.*two1n1n+6.)-dMult)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));//<6>_{2n,2n,n|n,n,n}
935    
936   six3n1n1n1n1n1n = (reQ3nQ1nQ1nstarQ1nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(five4n1n1n1n1n+4.*five2n1n1n1n1n+6.*five3n1n2n1n1n+4.*four3n1n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(4.*four3n1n1n1n+6.*four4n2n1n1n+6.*four1n1n1n1n+12.*three2n1n1n+12.*four2n1n2n1n+6.*four3n1n1n1n+12.*three3n2n1n+4.*four3n1n3n1n+3.*four3n1n2n2n)-dMult*(dMult-1.)*(dMult-2.)*(6.*three2n1n1n+12.*three3n2n1n+4.*three4n3n1n+3.*three4n2n2n+4.*two1n1n+12.*two1n1n+6.*three2n1n1n+12.*three2n1n1n+4.*three3n2n1n+12.*two2n2n+4.*three3n2n1n+4.*two3n3n+1.*three4n3n1n+6.*three3n2n1n)-dMult*(dMult-1.)*(4.*two1n1n+6.*two2n2n+4.*two3n3n+1.*two4n4n+1.*two1n1n+4.+6.*two1n1n+4.*two2n2n+1.*two3n3n)-dMult)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));//<6>_{3n,n|n,n,n,n}
937    
938   fQCorrelations->Fill(23.,six1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); 
939   fQCorrelations->Fill(24.,six2n1n1n2n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); 
940   fQCorrelations->Fill(25.,six2n2n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
941   fQCorrelations->Fill(26.,six3n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); 
942
943   f6pDistribution->Fill(six1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)); 
944   
945   fQProduct->Fill(1.,two1n1n*six1n1n1n1n1n1n,dMult*(dMult-1.)*dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
946   fQProduct->Fill(3.,four1n1n1n1n*six1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.));
947  }
948  
949  //7-particle
950  Double_t seven2n1n1n1n1n1n1n=0.;
951  if(dMult>6)
952  {
953   seven2n1n1n1n1n1n1n = (reQ2nQ1nQ1nQ1nstarQ1nstarQ1nstarQ1nstar-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(2.*six3n1n1n1n1n1n+4.*six1n1n1n1n1n1n+1.*six2n2n1n1n1n1n+6.*six2n1n1n2n1n1n+8.*five2n1n1n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(1.*five4n1n1n1n1n +8.*five2n1n1n1n1n+8.*four3n1n1n1n+12.*five3n1n2n1n1n+4.*five2n1n1n1n1n+3.*five2n2n2n1n1n+6.*five2n2n2n1n1n+6.*four1n1n1n1n+24.*four1n1n1n1n+12.*five2n1n1n1n1n+12.*five2n1n1n1n1n+12.*three2n1n1n+24.*four2n1n2n1n+4.*five3n1n2n1n1n+4.*five2n1n1n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(4.*four3n1n1n1n+6.*four4n2n1n1n+12.*four1n1n1n1n+24.*three2n1n1n+24.*four2n1n2n1n+12.*four3n1n1n1n+24.*three3n2n1n+8.*four3n1n3n1n+6.*four3n1n2n2n+6.*three2n1n1n+12.*four1n1n1n1n+12.*four2n1n2n1n+6.*three2n1n1n+12.*four2n1n2n1n+4.*four3n1n2n2n+3.*four2n2n2n2n+4.*four1n1n1n1n+6.*three2n1n1n+24.*two1n1n+24.*four1n1n1n1n+4.*four3n1n1n1n+24.*two1n1n+24.*three2n1n1n+12.*two2n2n+24.*three2n1n1n+12.*four2n1n2n1n+8.*three3n2n1n+8.*four2n1n2n1n+1.*four4n2n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(6.*three2n1n1n+1.*three2n1n1n+8.*two1n1n+12.*three3n2n1n+24.*two1n1n+12.*three2n1n1n+4.*three2n1n1n+8.*two1n1n+4.*three4n3n1n+24.*three2n1n1n+8.*three3n2n1n+12.*two1n1n+12.*two1n1n+3.*three4n2n2n+24.*two2n2n+6.*two2n2n+12.+12.*three3n2n1n+8.*two3n3n+12.*three2n1n1n+24.*two1n1n+4.*three3n2n1n+8.*three3n2n1n+2.*three4n3n1n+12.*two1n1n+8.*three2n1n1n+4.*three2n1n1n+2.*three3n2n1n+6.*two2n2n+8.*two2n2n+1.*three4n2n2n+4.*three3n2n1n+6.*three2n1n1n)-dMult*(dMult-1.)*(4.*two1n1n+2.*two1n1n+6.*two2n2n+8.+1.*two2n2n+4.*two3n3n+12.*two1n1n+4.*two1n1n+1.*two4n4n+8.*two2n2n+6.+2.*two3n3n+4.*two1n1n+1.*two2n2n)-dMult)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.));
954         
955   fQCorrelations->Fill(28.,seven2n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.));
956  }
957  
958  //8-particle
959  Double_t eight1n1n1n1n1n1n1n1n=0.;
960  if(dMult>7)
961  {
962   //fill the common control histogram (8th order):
963   fCommonHists8th->FillControlHistograms(anEvent); 
964   
965   eight1n1n1n1n1n1n1n1n = (pow(afvQvector1n.Mod(),8)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(12.*seven2n1n1n1n1n1n1n+16.*six1n1n1n1n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(8.*six3n1n1n1n1n1n+48.*six1n1n1n1n1n1n+6.*six2n2n1n1n1n1n+96.*five2n1n1n1n1n+72.*four1n1n1n1n+36.*six2n1n1n2n1n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(2.*five4n1n1n1n1n+32.*five2n1n1n1n1n+36.*four1n1n1n1n+32.*four3n1n1n1n+48.*five2n1n1n1n1n+48.*five3n1n2n1n1n+144.*five2n1n1n1n1n+288.*four1n1n1n1n+36.*five2n2n2n1n1n+144.*three2n1n1n+96.*two1n1n+144.*four2n1n2n1n)-dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(8.*four3n1n1n1n+48.*four1n1n1n1n+12.*four4n2n1n1n+96.*four2n1n2n1n+96.*three2n1n1n+72.*three2n1n1n+144.*two1n1n+16.*four3n1n3n1n+48.*four3n1n1n1n+144.*four1n1n1n1n+72.*four1n1n1n1n+96.*three3n2n1n+24.*four3n1n2n2n+144.*four2n1n2n1n+288.*two1n1n+288.*three2n1n1n+9.*four2n2n2n2n+72.*two2n2n+24.)-dMult*(dMult-1.)*(dMult-2.)*(12.*three2n1n1n+16.*two1n1n+24.*three3n2n1n+48.*three2n1n1n+96.*two1n1n+8.*three4n3n1n+32.*three3n2n1n+96.*three2n1n1n+144.*two1n1n+6.*three4n2n2n+96.*two2n2n+36.*two2n2n+72.+48.*three3n2n1n+16.*two3n3n+72.*three2n1n1n+144.*two1n1n)-dMult*(dMult-1.)*(8.*two1n1n+12.*two2n2n+16.+8.*two3n3n+48.*two1n1n+1.*two4n4n+16.*two2n2n+18.)-dMult)/(dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));
966   
967   fQCorrelations->Fill(30.,eight1n1n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));
968  
969   f8pDistribution->Fill(eight1n1n1n1n1n1n1n1n,dMult*(dMult-1.)*(dMult-2.)*(dMult-3.)*(dMult-4.)*(dMult-5.)*(dMult-6.)*(dMult-7.));
970  } 
971  //---------------------------------------------------------------------------------------------------------
972  
973  
974  
975  
976  //--------------------------------------------------------------------------------------------------------- 
977  // DIFFERENTIAL FLOW
978  
979  Double_t dQ1nx = afvQvector1n.X();
980  Double_t dQ1ny = afvQvector1n.Y();
981  Double_t dQ2nx = afvQvector2n.X();
982  Double_t dQ2ny = afvQvector2n.Y();
983  
984  Double_t dBinWidthPt=0.,dBinWidthEta=0.;
985  if(fnBinsPt)
986  { 
987   dBinWidthPt=1.*(fPtMax-fPtMin)/fnBinsPt;
988  } 
989  if(fnBinsEta)
990  {
991   dBinWidthEta=1.*(fEtaMax-fEtaMin)/fnBinsEta;
992  }
993  
994  //RP:
995  Double_t qxPtRP=0.,qyPtRP=0.,q2xPtRP=0.,q2yPtRP=0.,mPtRP=0.;//add comments for these variables (deleteMe)
996  Double_t qxEtaRP=0.,qyEtaRP=0.,q2xEtaRP=0.,q2yEtaRP=0.,mEtaRP=0.;//add comments for these variables (deleteMe)
997   
998  for(Int_t i=0;i<nPrim;i++)//loop over all particles
999  { 
1000   fTrack=anEvent->GetTrack(i);
1001   if(fTrack && fTrack->UseForIntegratedFlow())//checking RP condition 
1002   {
1003    //Pt:
1004    fPtReq1nRP->Fill(fTrack->Pt(),cos(n*(fTrack->Phi())),1.);
1005    fPtImq1nRP->Fill(fTrack->Pt(),sin(n*(fTrack->Phi())),1.);
1006    fPtReq2nRP->Fill(fTrack->Pt(),cos(2.*n*(fTrack->Phi())),1.);
1007    fPtImq2nRP->Fill(fTrack->Pt(),sin(2.*n*(fTrack->Phi())),1.);
1008    //Eta:
1009    fEtaReq1nRP->Fill(fTrack->Eta(),cos(n*(fTrack->Phi())),1.);
1010    fEtaImq1nRP->Fill(fTrack->Eta(),sin(n*(fTrack->Phi())),1.);
1011    fEtaReq2nRP->Fill(fTrack->Eta(),cos(2.*n*(fTrack->Phi())),1.);
1012    fEtaImq2nRP->Fill(fTrack->Eta(),sin(2.*n*(fTrack->Phi())),1.);
1013   }
1014  } 
1015   
1016  //Pt:
1017  Double_t twoDiffPt1n1nRP=0.,twoDiffPt2n2nRP=0.,threeDiffPt2n1n1nRP=0.,threeDiffPt1n1n2nRP=0.,fourDiffPt1n1n1n1nRP=0.;
1018  
1019  for(Int_t bin=1;bin<(fnBinsPt+1);bin++)//loop over pt-bins 
1020  { 
1021   qxPtRP = (fPtReq1nRP->GetBinContent(bin))*(fPtReq1nRP->GetBinEntries(bin));
1022   qyPtRP = (fPtImq1nRP->GetBinContent(bin))*(fPtImq1nRP->GetBinEntries(bin)); 
1023   q2xPtRP = (fPtReq2nRP->GetBinContent(bin))*(fPtReq2nRP->GetBinEntries(bin));  
1024   q2yPtRP = (fPtImq2nRP->GetBinContent(bin))*(fPtImq2nRP->GetBinEntries(bin)); 
1025   mPtRP = fPtReq1nRP->GetBinEntries(bin);          
1026  
1027   if(mPtRP>0&&dMult>1)
1028   {
1029    twoDiffPt1n1nRP = (qxPtRP*dQ1nx+qyPtRP*dQ1ny-mPtRP)/(mPtRP*(dMult-1.));
1030    f2PerPtBin1n1nRP->Fill(fPtMin+(bin-1)*dBinWidthPt,twoDiffPt1n1nRP,mPtRP*(dMult-1.));//<2'>_{n|n}
1031    
1032    twoDiffPt2n2nRP = (q2xPtRP*dQ2nx+q2yPtRP*dQ2ny-mPtRP)/(mPtRP*(dMult-1.));
1033    f2PerPtBin2n2nRP->Fill(fPtMin+(bin-1)*dBinWidthPt,twoDiffPt2n2nRP,mPtRP*(dMult-1.));//<2'>_{2n|2n} 
1034   }
1035   
1036   if(mPtRP>0&&dMult>2)
1037   {
1038    threeDiffPt2n1n1nRP = (q2xPtRP*(dQ1nx*dQ1nx-dQ1ny*dQ1ny)+2.*q2yPtRP*dQ1nx*dQ1ny-2.*(qxPtRP*dQ1nx+qyPtRP*dQ1ny)-(q2xPtRP*dQ2nx+q2yPtRP*dQ2ny)+2.*mPtRP)/(mPtRP*(dMult-1.)*(dMult-2.));
1039    f3PerPtBin2n1n1nRP->Fill(fPtMin+(bin-1)*dBinWidthPt,threeDiffPt2n1n1nRP,mPtRP*(dMult-1.)*(dMult-2.));//Re[<3'>_{2n|n,n}]
1040    
1041    threeDiffPt1n1n2nRP = (dQ2nx*(qxPtRP*dQ1nx-qyPtRP*dQ1ny)+dQ2ny*(qxPtRP*dQ1ny+qyPtRP*dQ1nx)-2.*(qxPtRP*dQ1nx+qyPtRP*dQ1ny)-(q2xPtRP*dQ2nx+q2yPtRP*dQ2ny)+2.*mPtRP)/(mPtRP*(dMult-1.)*(dMult-2.));
1042    f3PerPtBin1n1n2nRP->Fill(fPtMin+(bin-1)*dBinWidthPt,threeDiffPt1n1n2nRP,mPtRP*(dMult-1.)*(dMult-2.));//Re[<3'>_{n,n|2n}]
1043   }
1044   
1045   if(mPtRP>0&&dMult>3)
1046   {
1047    fourDiffPt1n1n1n1nRP = ((dQ1nx*dQ1nx+dQ1ny*dQ1ny)*(qxPtRP*dQ1nx+qyPtRP*dQ1ny)-(q2xPtRP*(dQ1nx*dQ1nx-dQ1ny*dQ1ny)+2.*q2yPtRP*dQ1nx*dQ1ny)-(dQ2nx*(qxPtRP*dQ1nx-qyPtRP*dQ1ny)+dQ2ny*(qxPtRP*dQ1ny+qyPtRP*dQ1nx))+(q2xPtRP*dQ2nx+q2yPtRP*dQ2ny)-2.*(dMult-3.)*(qxPtRP*dQ1nx+qyPtRP*dQ1ny)-2.*mPtRP*(dQ1nx*dQ1nx+dQ1ny*dQ1ny)+2.*(dQ1nx*qxPtRP+dQ1ny*qyPtRP)+2.*mPtRP*(dMult-3.))/(mPtRP*(dMult-1.)*(dMult-2.)*(dMult-3.));
1048    f4PerPtBin1n1n1n1nRP->Fill(fPtMin+(bin-1)*dBinWidthPt,fourDiffPt1n1n1n1nRP,mPtRP*(dMult-1.)*(dMult-2.)*(dMult-3.));//Re[<4'>_{n,n|n,n}]
1049   } 
1050  }//end of for(Int_t bin=1;bin<(fnBinsPt+1);bin++)//loop over pt-bins  
1051   
1052  fPtReq1nRP->Reset();
1053  fPtImq1nRP->Reset();
1054  fPtReq2nRP->Reset();
1055  fPtImq2nRP->Reset();
1056  
1057  //Eta:
1058  Double_t twoDiffEta1n1nRP=0.,twoDiffEta2n2nRP=0.,threeDiffEta2n1n1nRP=0.,threeDiffEta1n1n2nRP=0.,fourDiffEta1n1n1n1nRP=0.;
1059  
1060  for(Int_t bin=1;bin<(fnBinsEta+1);bin++)//loop over eta-bins 
1061  { 
1062   qxEtaRP = (fEtaReq1nRP->GetBinContent(bin))*(fEtaReq1nRP->GetBinEntries(bin));
1063   qyEtaRP = (fEtaImq1nRP->GetBinContent(bin))*(fEtaImq1nRP->GetBinEntries(bin)); 
1064   q2xEtaRP = (fEtaReq2nRP->GetBinContent(bin))*(fEtaReq2nRP->GetBinEntries(bin));  
1065   q2yEtaRP = (fEtaImq2nRP->GetBinContent(bin))*(fEtaImq2nRP->GetBinEntries(bin)); 
1066   mEtaRP = fEtaReq1nRP->GetBinEntries(bin); 
1067   
1068   if(mEtaRP>0&&dMult>1)
1069   {
1070    twoDiffEta1n1nRP = (qxEtaRP*dQ1nx+qyEtaRP*dQ1ny-mEtaRP)/(mEtaRP*(dMult-1.));
1071    f2PerEtaBin1n1nRP->Fill(fEtaMin+(bin-1)*dBinWidthEta,twoDiffEta1n1nRP,mEtaRP*(dMult-1.));//<2'>_{n|n}
1072    
1073    twoDiffEta2n2nRP = (q2xEtaRP*dQ2nx+q2yEtaRP*dQ2ny-mEtaRP)/(mEtaRP*(dMult-1.));
1074    f2PerEtaBin2n2nRP->Fill(fEtaMin+(bin-1)*dBinWidthEta,twoDiffEta2n2nRP,mEtaRP*(dMult-1.));//<2'>_{2n|2n} 
1075   }
1076   
1077   if(mEtaRP>0&&dMult>2)
1078   {
1079    threeDiffEta2n1n1nRP = (q2xEtaRP*(dQ1nx*dQ1nx-dQ1ny*dQ1ny)+2.*q2yEtaRP*dQ1nx*dQ1ny-2.*(qxEtaRP*dQ1nx+qyEtaRP*dQ1ny)-(q2xEtaRP*dQ2nx+q2yEtaRP*dQ2ny)+2.*mEtaRP)/(mEtaRP*(dMult-1.)*(dMult-2.));
1080    f3PerEtaBin2n1n1nRP->Fill(fEtaMin+(bin-1)*dBinWidthEta,threeDiffEta2n1n1nRP,mEtaRP*(dMult-1.)*(dMult-2.));//Re[<3'>_{2n|n,n}]
1081    
1082    threeDiffEta1n1n2nRP = (dQ2nx*(qxEtaRP*dQ1nx-qyEtaRP*dQ1ny)+dQ2ny*(qxEtaRP*dQ1ny+qyEtaRP*dQ1nx)-2.*(qxEtaRP*dQ1nx+qyEtaRP*dQ1ny)-(q2xEtaRP*dQ2nx+q2yEtaRP*dQ2ny)+2.*mEtaRP)/(mEtaRP*(dMult-1.)*(dMult-2.));
1083    f3PerEtaBin1n1n2nRP->Fill(fEtaMin+(bin-1)*dBinWidthEta,threeDiffEta1n1n2nRP,mEtaRP*(dMult-1.)*(dMult-2.));//Re[<3'>_{n,n|2n}]
1084   }
1085   
1086   if(mEtaRP>0&&dMult>3)
1087   {
1088    fourDiffEta1n1n1n1nRP = ((dQ1nx*dQ1nx+dQ1ny*dQ1ny)*(qxEtaRP*dQ1nx+qyEtaRP*dQ1ny)-(q2xEtaRP*(dQ1nx*dQ1nx-dQ1ny*dQ1ny)+2.*q2yEtaRP*dQ1nx*dQ1ny)-(dQ2nx*(qxEtaRP*dQ1nx-qyEtaRP*dQ1ny)+dQ2ny*(qxEtaRP*dQ1ny+qyEtaRP*dQ1nx))+(q2xEtaRP*dQ2nx+q2yEtaRP*dQ2ny)-2.*(dMult-3.)*(qxEtaRP*dQ1nx+qyEtaRP*dQ1ny)-2.*mEtaRP*(dQ1nx*dQ1nx+dQ1ny*dQ1ny)+2.*(dQ1nx*qxEtaRP+dQ1ny*qyEtaRP)+2.*mEtaRP*(dMult-3.))/(mEtaRP*(dMult-1.)*(dMult-2.)*(dMult-3.));
1089    f4PerEtaBin1n1n1n1nRP->Fill(fEtaMin+(bin-1)*dBinWidthEta,fourDiffEta1n1n1n1nRP,mEtaRP*(dMult-1.)*(dMult-2.)*(dMult-3.));//Re[<4'>_{n,n|n,n}]
1090   }  
1091  }//end of for(Int_t bin=1;bin<(fnBinsEta+1);bin++)//loop over eta-bins 
1092   
1093  fEtaReq1nRP->Reset();
1094  fEtaImq1nRP->Reset();
1095  fEtaReq2nRP->Reset();
1096  fEtaImq2nRP->Reset();
1097  
1098  //POI:
1099  Double_t qxPrimePtPOI=0.,qyPrimePtPOI=0.,q2xPrimePtPOI=0.,q2yPrimePtPOI=0.,mPrimePtPOI=0.;//add comments for these variables (deleteMe)
1100  Double_t qxPrimePrimePtPOI=0.,qyPrimePrimePtPOI=0.,q2xPrimePrimePtPOI=0.,q2yPrimePrimePtPOI=0.,mPrimePrimePtPOI=0.;//add comments for these variables (deleteMe)
1101  Double_t qxPrimeEtaPOI=0.,qyPrimeEtaPOI=0.,q2xPrimeEtaPOI=0.,q2yPrimeEtaPOI=0.,mPrimeEtaPOI=0.;//add comments for these variables (deleteMe)
1102  Double_t qxPrimePrimeEtaPOI=0.,qyPrimePrimeEtaPOI=0.,q2xPrimePrimeEtaPOI=0.,q2yPrimePrimeEtaPOI=0.,mPrimePrimeEtaPOI=0.;//add comments for the
1103
1104  for(Int_t i=0;i<nPrim;i++)//loop over all particles (to be improved: do the calculations for RPs and POIs in the same loop) 
1105  { 
1106   fTrack=anEvent->GetTrack(i);
1107   if(fTrack)
1108   {
1109    if(fTrack->UseForDifferentialFlow())//checking if particle is POI 
1110    {
1111     if(fTrack->UseForIntegratedFlow())//checking if particle is both POI and RP 
1112     {
1113      //Pt:
1114      fPtReq1nPrimePrimePOI->Fill(fTrack->Pt(),cos(n*(fTrack->Phi())),1.); 
1115      fPtImq1nPrimePrimePOI->Fill(fTrack->Pt(),sin(n*(fTrack->Phi())),1.);
1116      fPtReq2nPrimePrimePOI->Fill(fTrack->Pt(),cos(2.*n*(fTrack->Phi())),1.);
1117      fPtImq2nPrimePrimePOI->Fill(fTrack->Pt(),sin(2.*n*(fTrack->Phi())),1.);
1118      //Eta:
1119      fEtaReq1nPrimePrimePOI->Fill(fTrack->Eta(),cos(n*(fTrack->Phi())),1.); 
1120      fEtaImq1nPrimePrimePOI->Fill(fTrack->Eta(),sin(n*(fTrack->Phi())),1.);
1121      fEtaReq2nPrimePrimePOI->Fill(fTrack->Eta(),cos(2.*n*(fTrack->Phi())),1.);
1122      fEtaImq2nPrimePrimePOI->Fill(fTrack->Eta(),sin(2.*n*(fTrack->Phi())),1.);
1123     }else if(!(fTrack->UseForIntegratedFlow()))//checking if particles is POI and not RP  
1124      {
1125       //Pt:
1126       fPtReq1nPrimePOI->Fill(fTrack->Pt(),cos(n*(fTrack->Phi())),1.); 
1127       fPtImq1nPrimePOI->Fill(fTrack->Pt(),sin(n*(fTrack->Phi())),1.);
1128       fPtReq2nPrimePOI->Fill(fTrack->Pt(),cos(2.*n*(fTrack->Phi())),1.);
1129       fPtImq2nPrimePOI->Fill(fTrack->Pt(),sin(2.*n*(fTrack->Phi())),1.);
1130       //Eta:
1131       fEtaReq1nPrimePOI->Fill(fTrack->Eta(),cos(n*(fTrack->Phi())),1.); 
1132       fEtaImq1nPrimePOI->Fill(fTrack->Eta(),sin(n*(fTrack->Phi())),1.);
1133       fEtaReq2nPrimePOI->Fill(fTrack->Eta(),cos(2.*n*(fTrack->Phi())),1.);
1134       fEtaImq2nPrimePOI->Fill(fTrack->Eta(),sin(2.*n*(fTrack->Phi())),1.);
1135      }//end of else if(!(fTrack->UseForIntegratedFlow()))//checking if particles is POI and not RP 
1136    }//end of if(fTrack->UseForDifferentialFlow())//checking if particle is POI
1137   }//end of if(fTrack}      
1138  }//end of for(Int_t i=0;i<nPrim;i++)        
1139          
1140  //Pt:
1141  //Double_t twoDiffPt1n1nPOI=0.,twoDiffPt2n2nPOI=0.,threeDiffPt2n1n1nPOI=0.,threeDiffPt1n1n2nPOI=0.,fourDiffPt1n1n1n1nPOI=0.;
1142  Double_t twoDiffPt1n1nPOI=0.,twoDiffPt2n2nPOI=0.,fourDiffPt1n1n1n1nPOI=0.;
1143  
1144  for(Int_t bin=1;bin<(fnBinsPt+1);bin++)//loop over pt-bins 
1145  { 
1146   //q'      
1147   qxPrimePtPOI = (fPtReq1nPrimePOI->GetBinContent(bin))*(fPtReq1nPrimePOI->GetBinEntries(bin));
1148   qyPrimePtPOI = (fPtImq1nPrimePOI->GetBinContent(bin))*(fPtImq1nPrimePOI->GetBinEntries(bin)); 
1149   q2xPrimePtPOI = (fPtReq2nPrimePOI->GetBinContent(bin))*(fPtReq2nPrimePOI->GetBinEntries(bin));  
1150   q2yPrimePtPOI = (fPtImq2nPrimePOI->GetBinContent(bin))*(fPtImq2nPrimePOI->GetBinEntries(bin)); 
1151   mPrimePtPOI = fPtReq1nPrimePOI->GetBinEntries(bin);      
1152   //q''                    
1153   qxPrimePrimePtPOI = (fPtReq1nPrimePrimePOI->GetBinContent(bin))*(fPtReq1nPrimePrimePOI->GetBinEntries(bin));
1154   qyPrimePrimePtPOI = (fPtImq1nPrimePrimePOI->GetBinContent(bin))*(fPtImq1nPrimePrimePOI->GetBinEntries(bin)); 
1155   q2xPrimePrimePtPOI = (fPtReq2nPrimePrimePOI->GetBinContent(bin))*(fPtReq2nPrimePrimePOI->GetBinEntries(bin));  
1156   q2yPrimePrimePtPOI = (fPtImq2nPrimePrimePOI->GetBinContent(bin))*(fPtImq2nPrimePrimePOI->GetBinEntries(bin)); 
1157   mPrimePrimePtPOI = fPtReq1nPrimePrimePOI->GetBinEntries(bin);         
1158                    
1159   if((mPrimePtPOI+mPrimePrimePtPOI>0)&&dMult>0&&!(mPrimePrimePtPOI==1&&mPrimePtPOI==0&&dMult==1))//to be improved 
1160   {   
1161    twoDiffPt1n1nPOI = (qxPrimePrimePtPOI*dQ1nx+qyPrimePrimePtPOI*dQ1ny-mPrimePrimePtPOI+qxPrimePtPOI*dQ1nx+qyPrimePtPOI*dQ1ny)/(mPrimePrimePtPOI*(dMult-1)+mPrimePtPOI*dMult);   
1162    f2PerPtBin1n1nPOI->Fill(fPtMin+(bin-1)*dBinWidthPt,twoDiffPt1n1nPOI,mPrimePrimePtPOI*(dMult-1)+mPrimePtPOI*dMult);//<2'>_{n|n}
1163   
1164    twoDiffPt2n2nPOI = (q2xPrimePrimePtPOI*dQ2nx+q2yPrimePrimePtPOI*dQ2ny-mPrimePrimePtPOI+q2xPrimePtPOI*dQ2nx+q2yPrimePtPOI*dQ2ny)/(mPrimePrimePtPOI*(dMult-1)+mPrimePtPOI*dMult);   
1165    f2PerPtBin2n2nPOI->Fill(fPtMin+(bin-1)*dBinWidthPt,twoDiffPt2n2nPOI,mPrimePrimePtPOI*(dMult-1)+mPrimePtPOI*dMult);//<2'>_{2n|2n} 
1166   }//end of if((mPrimePtPOI+mPrimePrimePtPOI>0)&&dMult>0)
1167   
1168   /*
1169   to be improved: correct Eqs. needed here)
1170   if(mPtPOI>0&&dMult>3)
1171   {
1172    threeDiffPt2n1n1nPOI = (q2xPtPOI*(dQ1nx*dQ1nx-dQ1ny*dQ1ny)+2.*q2yPtPOI*dQ1nx*dQ1ny-2.*(qxPtPOI*dQ1nx+qyPtPOI*dQ1ny)-(q2xPtPOI*dQ2nx+q2yPtPOI*dQ2ny)+2.*mPtPOI)/(mPtPOI*(dMult-1.)*(dMult-2.));//to be improved (correct formula needed)
1173    //f3PePOItBin2n1n1nPOI->Fill(fPtMin+(bin-1)*dBinWidthPt,threeDiffPt2n1n1nPOI,mPtPOI*(dMult-1.)*(dMult-2.));//Re[<3'>_{2n|n,n}]
1174    
1175    threeDiffPt1n1n2nPOI = (dQ2nx*(qxPtPOI*dQ1nx-qyPtPOI*dQ1ny)+dQ2ny*(qxPtPOI*dQ1ny+qyPtPOI*dQ1nx)-2.*(qxPtPOI*dQ1nx+qyPtPOI*dQ1ny)-(q2xPtPOI*dQ2nx+q2yPtPOI*dQ2ny)+2.*mPtPOI)/(mPtPOI*(dMult-1.)*(dMult-2.));//to be improved (correct formula needed)
1176    //f3PePOItBin1n1n2nPOI->Fill(fPtMin+(bin-1)*dBinWidthPt,threeDiffPt1n1n2nPOI,mPtPOI*(dMult-1.)*(dMult-2.));//Re[<3'>_{n,n|2n}]
1177   }
1178   */
1179   
1180   //if((mPrimePtPOI+mPrimePrimePtPOI>0)&&dMult>2)//to be improved (dMult>2 or dMult>3)
1181   if(!(mPrimePtPOI==0&&mPrimePrimePtPOI==0)&&!(mPrimePtPOI==0&&(dMult==1||dMult==2||dMult==3))&&!(mPrimePrimePtPOI==0&&(dMult==0||dMult==1||dMult==2)))//to be improved 
1182   {  
1183    fourDiffPt1n1n1n1nPOI=((dQ1nx*dQ1nx+dQ1ny*dQ1ny)*(qxPrimePtPOI*dQ1nx+qyPrimePtPOI*dQ1ny)-2.*(dMult-1)*(qxPrimePtPOI*dQ1nx+qyPrimePtPOI*dQ1ny)-(dQ2nx*(qxPrimePtPOI*dQ1nx-qyPrimePtPOI*dQ1ny)+dQ2ny*(qxPrimePtPOI*dQ1ny+qyPrimePtPOI*dQ1nx))+(dQ1nx*dQ1nx+dQ1ny*dQ1ny)*(qxPrimePrimePtPOI*dQ1nx+qyPrimePrimePtPOI*dQ1ny)-(q2xPrimePrimePtPOI*(dQ1nx*dQ1nx-dQ1ny*dQ1ny)+2.*q2yPrimePrimePtPOI*dQ1nx*dQ1ny)-(dQ2nx*(qxPrimePrimePtPOI*dQ1nx-qyPrimePrimePtPOI*dQ1ny)+dQ2ny*(qxPrimePrimePtPOI*dQ1ny+qyPrimePrimePtPOI*dQ1nx))+(q2xPrimePrimePtPOI*dQ2nx+q2yPrimePrimePtPOI*dQ2ny)-2.*(dMult-3.)*(qxPrimePrimePtPOI*dQ1nx+qyPrimePrimePtPOI*dQ1ny)-2.*mPrimePrimePtPOI*(dQ1nx*dQ1nx+dQ1ny*dQ1ny)+2.*(dQ1nx*qxPrimePrimePtPOI+dQ1ny*qyPrimePrimePtPOI)+2.*mPrimePrimePtPOI*(dMult-3.))/(mPrimePtPOI*dMult*(dMult-1)*(dMult-2)+mPrimePrimePtPOI*(dMult-1)*(dMult-2)*(dMult-3));
1184            
1185    f4PerPtBin1n1n1n1nPOI->Fill(fPtMin+(bin-1)*dBinWidthPt,fourDiffPt1n1n1n1nPOI,mPrimePtPOI*dMult*(dMult-1)*(dMult-2)+mPrimePrimePtPOI*(dMult-1)*(dMult-2)*(dMult-3));//Re[<4'>_{n,n|n,n}]
1186   }//end of if((mPrimePtPOI+mPrimePrimePtPOI>0)&&dMult>2)   
1187  }//end of for(Int_t bin=1;bin<(fnBinsPt+1);bin++)//loop over pt-bins  
1188    
1189  fPtReq1nPrimePOI->Reset();
1190  fPtImq1nPrimePOI->Reset();
1191  fPtReq2nPrimePOI->Reset();
1192  fPtImq2nPrimePOI->Reset();
1193  
1194  fPtReq1nPrimePrimePOI->Reset();
1195  fPtImq1nPrimePrimePOI->Reset();
1196  fPtReq2nPrimePrimePOI->Reset();
1197  fPtImq2nPrimePrimePOI->Reset();
1198
1199  //Eta:
1200  //Double_t twoDiffEta1n1nPOI=0.,twoDiffEta2n2nPOI=0.,threeDiffEta2n1n1nPOI=0.,threeDiffEta1n1n2nPOI=0.,fourDiffEta1n1n1n1nPOI=0.;
1201  Double_t twoDiffEta1n1nPOI=0.,twoDiffEta2n2nPOI=0.,fourDiffEta1n1n1n1nPOI=0.;
1202  
1203  for(Int_t bin=1;bin<(fnBinsEta+1);bin++)//loop over eta-bins 
1204  { 
1205   //q'      
1206   qxPrimeEtaPOI = (fEtaReq1nPrimePOI->GetBinContent(bin))*(fEtaReq1nPrimePOI->GetBinEntries(bin));
1207   qyPrimeEtaPOI = (fEtaImq1nPrimePOI->GetBinContent(bin))*(fEtaImq1nPrimePOI->GetBinEntries(bin)); 
1208   q2xPrimeEtaPOI = (fEtaReq2nPrimePOI->GetBinContent(bin))*(fEtaReq2nPrimePOI->GetBinEntries(bin));  
1209   q2yPrimeEtaPOI = (fEtaImq2nPrimePOI->GetBinContent(bin))*(fEtaImq2nPrimePOI->GetBinEntries(bin)); 
1210   mPrimeEtaPOI = fEtaReq1nPrimePOI->GetBinEntries(bin);      
1211   //q''                    
1212   qxPrimePrimeEtaPOI = (fEtaReq1nPrimePrimePOI->GetBinContent(bin))*(fEtaReq1nPrimePrimePOI->GetBinEntries(bin));
1213   qyPrimePrimeEtaPOI = (fEtaImq1nPrimePrimePOI->GetBinContent(bin))*(fEtaImq1nPrimePrimePOI->GetBinEntries(bin)); 
1214   q2xPrimePrimeEtaPOI = (fEtaReq2nPrimePrimePOI->GetBinContent(bin))*(fEtaReq2nPrimePrimePOI->GetBinEntries(bin));  
1215   q2yPrimePrimeEtaPOI = (fEtaImq2nPrimePrimePOI->GetBinContent(bin))*(fEtaImq2nPrimePrimePOI->GetBinEntries(bin)); 
1216   mPrimePrimeEtaPOI = fEtaReq1nPrimePrimePOI->GetBinEntries(bin);         
1217                    
1218   if((mPrimeEtaPOI+mPrimePrimeEtaPOI>0)&&dMult>0&&!(mPrimePrimeEtaPOI==1&&mPrimeEtaPOI==0&&dMult==1))//to be improved (dMult>1 or dMult>0)
1219   {   
1220    twoDiffEta1n1nPOI = (qxPrimePrimeEtaPOI*dQ1nx+qyPrimePrimeEtaPOI*dQ1ny-mPrimePrimeEtaPOI+qxPrimeEtaPOI*dQ1nx+qyPrimeEtaPOI*dQ1ny)/(mPrimePrimeEtaPOI*(dMult-1)+mPrimeEtaPOI*dMult);   
1221    f2PerEtaBin1n1nPOI->Fill(fEtaMin+(bin-1)*dBinWidthEta,twoDiffEta1n1nPOI,mPrimePrimeEtaPOI*(dMult-1)+mPrimeEtaPOI*dMult);//<2'>_{n|n}
1222   
1223    twoDiffEta2n2nPOI = (q2xPrimePrimeEtaPOI*dQ2nx+q2yPrimePrimeEtaPOI*dQ2ny-mPrimePrimeEtaPOI+q2xPrimeEtaPOI*dQ2nx+q2yPrimeEtaPOI*dQ2ny)/(mPrimePrimeEtaPOI*(dMult-1)+mPrimeEtaPOI*dMult);   
1224    f2PerEtaBin2n2nPOI->Fill(fEtaMin+(bin-1)*dBinWidthEta,twoDiffEta2n2nPOI,mPrimePrimeEtaPOI*(dMult-1)+mPrimeEtaPOI*dMult);//<2'>_{2n|2n} 
1225   }//end of if((mPrimeEtaPOI+mPrimePrimeEtaPOI>0)&&dMult>0)
1226   
1227   /*
1228   to be improved: correct Eqs. needed here)
1229   if(mEtaPOI>0&&dMult>3)
1230   {
1231    threeDiffEta2n1n1nPOI = (q2xEtaPOI*(dQ1nx*dQ1nx-dQ1ny*dQ1ny)+2.*q2yEtaPOI*dQ1nx*dQ1ny-2.*(qxEtaPOI*dQ1nx+qyEtaPOI*dQ1ny)-(q2xEtaPOI*dQ2nx+q2yEtaPOI*dQ2ny)+2.*mEtaPOI)/(mEtaPOI*(dMult-1.)*(dMult-2.));//to be improved (correct formula)
1232    //f3PePOItBin2n1n1nPOI->Fill(fEtaMin+(bin-1)*dBinWidthEta,threeDiffEta2n1n1nPOI,mEtaPOI*(dMult-1.)*(dMult-2.));//Re[<3'>_{2n|n,n}]
1233    
1234    threeDiffEta1n1n2nPOI = (dQ2nx*(qxEtaPOI*dQ1nx-qyEtaPOI*dQ1ny)+dQ2ny*(qxEtaPOI*dQ1ny+qyEtaPOI*dQ1nx)-2.*(qxEtaPOI*dQ1nx+qyEtaPOI*dQ1ny)-(q2xEtaPOI*dQ2nx+q2yEtaPOI*dQ2ny)+2.*mEtaPOI)/(mEtaPOI*(dMult-1.)*(dMult-2.));//to be improved (correct formula)
1235    //f3PePOItBin1n1n2nPOI->Fill(fEtaMin+(bin-1)*dBinWidthEta,threeDiffEta1n1n2nPOI,mEtaPOI*(dMult-1.)*(dMult-2.));//Re[<3'>_{n,n|2n}]
1236   }
1237   */
1238   
1239   //if((mPrimeEtaPOI+mPrimePrimeEtaPOI>0)&&dMult>2)//to be improved (dMult>2 or dMult>3)
1240   if(!(mPrimeEtaPOI==0&&mPrimePrimeEtaPOI==0)&&!(mPrimeEtaPOI==0&&(dMult==1||dMult==2||dMult==3))&&!(mPrimePrimeEtaPOI==0&&(dMult==0||dMult==1||dMult==2)))
1241   {  
1242    fourDiffEta1n1n1n1nPOI=((dQ1nx*dQ1nx+dQ1ny*dQ1ny)*(qxPrimeEtaPOI*dQ1nx+qyPrimeEtaPOI*dQ1ny)-2.*(dMult-1)*(qxPrimeEtaPOI*dQ1nx+qyPrimeEtaPOI*dQ1ny)-(dQ2nx*(qxPrimeEtaPOI*dQ1nx-qyPrimeEtaPOI*dQ1ny)+dQ2ny*(qxPrimeEtaPOI*dQ1ny+qyPrimeEtaPOI*dQ1nx))+(dQ1nx*dQ1nx+dQ1ny*dQ1ny)*(qxPrimePrimeEtaPOI*dQ1nx+qyPrimePrimeEtaPOI*dQ1ny)-(q2xPrimePrimeEtaPOI*(dQ1nx*dQ1nx-dQ1ny*dQ1ny)+2.*q2yPrimePrimeEtaPOI*dQ1nx*dQ1ny)-(dQ2nx*(qxPrimePrimeEtaPOI*dQ1nx-qyPrimePrimeEtaPOI*dQ1ny)+dQ2ny*(qxPrimePrimeEtaPOI*dQ1ny+qyPrimePrimeEtaPOI*dQ1nx))+(q2xPrimePrimeEtaPOI*dQ2nx+q2yPrimePrimeEtaPOI*dQ2ny)-2.*(dMult-3.)*(qxPrimePrimeEtaPOI*dQ1nx+qyPrimePrimeEtaPOI*dQ1ny)-2.*mPrimePrimeEtaPOI*(dQ1nx*dQ1nx+dQ1ny*dQ1ny)+2.*(dQ1nx*qxPrimePrimeEtaPOI+dQ1ny*qyPrimePrimeEtaPOI)+2.*mPrimePrimeEtaPOI*(dMult-3.))/(mPrimeEtaPOI*dMult*(dMult-1)*(dMult-2)+mPrimePrimeEtaPOI*(dMult-1)*(dMult-2)*(dMult-3));
1243            
1244    f4PerEtaBin1n1n1n1nPOI->Fill(fEtaMin+(bin-1)*dBinWidthEta,fourDiffEta1n1n1n1nPOI,mPrimeEtaPOI*dMult*(dMult-1)*(dMult-2)+mPrimePrimeEtaPOI*(dMult-1)*(dMult-2)*(dMult-3));//Re[<4'>_{n,n|n,n}]
1245   }//end of if((mPrimeEtaPOI+mPrimePrimeEtaPOI>0)&&dMult>2)   
1246  }//end of for(Int_t bin=1;bin<(fnBinsEta+1);bin++)//loop over eta-bins  
1247    
1248  fEtaReq1nPrimePOI->Reset();
1249  fEtaImq1nPrimePOI->Reset();
1250  fEtaReq2nPrimePOI->Reset();
1251  fEtaImq2nPrimePOI->Reset();
1252  
1253  fEtaReq1nPrimePrimePOI->Reset();
1254  fEtaImq1nPrimePrimePOI->Reset();
1255  fEtaReq2nPrimePrimePOI->Reset();
1256  fEtaImq2nPrimePrimePOI->Reset();
1257
1258 //---------------------------------------------------------------------------------------------------------
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270 /*
1271  //Eta:
1272  Double_t twoDiffEta1n1nPOI=0.,twoDiffEta2n2nPOI=0.,threeDiffEta2n1n1nPOI=0.,threeDiffEta1n1n2nPOI=0.,fourDiffEta1n1n1n1nPOI=0.;
1273  
1274  for(Int_t bin=1;bin<(fnBinsEta+1);bin++)//loop over eta-bins 
1275  { 
1276   qxEtaPOI = (fEtaReq1nPOI->GetBinContent(bin))*(fEtaReq1nPOI->GetBinEntries(bin));
1277   qyEtaPOI = (fEtaImq1nPOI->GetBinContent(bin))*(fEtaImq1nPOI->GetBinEntries(bin)); 
1278   q2xEtaPOI = (fEtaReq2nPOI->GetBinContent(bin))*(fEtaReq2nPOI->GetBinEntries(bin));  
1279   q2yEtaPOI = (fEtaImq2nPOI->GetBinContent(bin))*(fEtaImq2nPOI->GetBinEntries(bin)); 
1280   mEtaPOI = fEtaReq1nPOI->GetBinEntries(bin); 
1281   
1282   if(mEtaPOI>0&&dMult>1)
1283   {
1284    twoDiffEta1n1nPOI = (qxEtaPOI*dQ1nx+qyEtaPOI*dQ1ny-dOverlapEta)/((mEtaPOI-dOverlapEta)*dMult+dOverlapEta*(dMult-1.));
1285    f2PerEtaBin1n1nPOI->Fill(fEtaMin+(bin-1)*dBinWidthEta,twoDiffEta1n1nPOI,(mEtaPOI-dOverlapEta)*dMult+dOverlapEta*(dMult-1.));//<2'>_{n|n}
1286    
1287    twoDiffEta2n2nPOI = (q2xEtaPOI*dQ2nx+q2yEtaPOI*dQ2ny-dOverlapEta)/((mEtaPOI-dOverlapEta)*dMult+dOverlapEta*(dMult-1.));
1288    f2PerEtaBin2n2nPOI->Fill(fEtaMin+(bin-1)*dBinWidthEta,twoDiffEta2n2nPOI,(mEtaPOI-dOverlapEta)*dMult+dOverlapEta*(dMult-1.));//<2'>_{2n|2n} 
1289   }
1290   
1291   if(mEtaPOI>0&&dMult>2)
1292   {
1293    threeDiffEta2n1n1nPOI = (q2xEtaPOI*(dQ1nx*dQ1nx-dQ1ny*dQ1ny)+2.*q2yEtaPOI*dQ1nx*dQ1ny-2.*(qxEtaPOI*dQ1nx+qyEtaPOI*dQ1ny)-(q2xEtaPOI*dQ2nx+q2yEtaPOI*dQ2ny)+2.*mEtaPOI)/(mEtaPOI*(dMult-1.)*(dMult-2.));//to be improved (correct formula)
1294    //f3PerEtaBin2n1n1nPOI->Fill(fEtaMin+(bin-1)*dBinWidthEta,threeDiffEta2n1n1nPOI,mEtaPOI*(dMult-1.)*(dMult-2.));//Re[<3'>_{2n|n,n}]
1295    
1296    threeDiffEta1n1n2nPOI = (dQ2nx*(qxEtaPOI*dQ1nx-qyEtaPOI*dQ1ny)+dQ2ny*(qxEtaPOI*dQ1ny+qyEtaPOI*dQ1nx)-2.*(qxEtaPOI*dQ1nx+qyEtaPOI*dQ1ny)-(q2xEtaPOI*dQ2nx+q2yEtaPOI*dQ2ny)+2.*mEtaPOI)/(mEtaPOI*(dMult-1.)*(dMult-2.));//to be improved (correct formula)
1297    //f3PerEtaBin1n1n2nPOI->Fill(fEtaMin+(bin-1)*dBinWidthEta,threeDiffEta1n1n2nPOI,mEtaPOI*(dMult-1.)*(dMult-2.));//Re[<3'>_{n,n|2n}]
1298   }
1299   
1300   if(mEtaPOI>0&&dMult>3)
1301   {
1302    fourDiffEta1n1n1n1nPOI = ((dQ1nx*dQ1nx+dQ1ny*dQ1ny)*(qxEtaPOI*dQ1nx+qyEtaPOI*dQ1ny)-(q2xEtaPOI*(dQ1nx*dQ1nx-dQ1ny*dQ1ny)+2.*q2yEtaPOI*dQ1nx*dQ1ny)-(dQ2nx*(qxEtaPOI*dQ1nx-qyEtaPOI*dQ1ny)+dQ2ny*(qxEtaPOI*dQ1ny+qyEtaPOI*dQ1nx))+(q2xEtaPOI*dQ2nx+q2yEtaPOI*dQ2ny)-2.*(dMult-3.)*(qxEtaPOI*dQ1nx+qyEtaPOI*dQ1ny)-2.*mEtaPOI*(dQ1nx*dQ1nx+dQ1ny*dQ1ny)+2.*(dQ1nx*qxEtaPOI+dQ1ny*qyEtaPOI)+2.*mEtaPOI*(dMult-3.))/(mEtaPOI*(dMult-1.)*(dMult-2.)*(dMult-3.));//to be improved (correct formula)
1303    //f4PerEtaBin1n1n1n1nPOI->Fill(fEtaMin+(bin-1)*dBinWidthEta,fourDiffEta1n1n1n1nPOI,mEtaPOI*(dMult-1.)*(dMult-2.)*(dMult-3.));//Re[<4'>_{n,n|n,n}]
1304   }
1305    
1306  } 
1307   
1308  fEtaReq1nPOI->Reset();
1309  fEtaImq1nPOI->Reset();
1310  fEtaReq2nPOI->Reset();
1311  fEtaImq2nPOI->Reset();
1312 */
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338  /*
1339
1340
1341
1342
1343  //if(bNestedLoops)to be improved
1344  //{ to be improved               
1345  //-------------------------------------------------------------------------------------------------------------------------------- 
1346  //
1347  //                                          **********************
1348  //                                          **** NESTED LOOPS ****
1349  //                                          ********************** 
1350  //
1351  // Remark 1: multi-particle correlations calculated with nested loops are stored in fDirectCorrelations.
1352  // Remark 2: binning of fDirectCorrelations: bins 0..40 - correlations needed for integrated flow; bins 40..80 - correlations needed for differential flow (taking as an example bin 0.5 < pt < 0.6)
1353  //
1354  // binning details of fDirectCorrelations (integrated flow):
1355  //
1356  // 1st bin: <2>_{n|n} = two1n1n
1357  // 2nd bin: <2>_{2n|2n} = two2n2n
1358  // 3rd bin: <2>_{3n|3n} = two3n3n
1359  // 4th bin: <2>_{4n|4n} = two4n4n
1360  // 5th bin: --  EMPTY --
1361  // 6th bin: <3>_{2n|n,n} = three2n1n1n
1362  // 7th bin: <3>_{3n|2n,n} = three3n2n1n
1363  // 8th bin: <3>_{4n|2n,2n} = three4n2n2n
1364  // 9th bin: <3>_{4n|3n,n} = three4n3n1n
1365  //10th bin: --  EMPTY --
1366  //11th bin: <4>_{n,n|n,n} = four1n1n1n1n
1367  //12th bin: <4>_{2n,n|2n,n} = four2n1n2n1n
1368  //13th bin: <4>_{2n,2n|2n,2n} = four2n2n2n2n
1369  //14th bin: <4>_{3n|n,n,n} = four3n1n1n1n
1370  //15th bin: <4>_{3n,n|3n,n} = four3n1n3n1n 
1371  //16th bin: <4>_{3n,n|2n,2n} = four3n1n2n2n
1372  //17th bin: <4>_{4n|2n,n,n} = four4n2n1n1n
1373  //18th bin: --  EMPTY --
1374  //19th bin: <5>_{2n|n,n,n,n} = five2n1n1n1n1n
1375  //20th bin: <5>_{2n,2n|2n,n,n} = five2n2n2n1n1n
1376  //21st bin: <5>_{3n,n|2n,n,n} = five3n1n2n1n1n
1377  //22nd bin: <5>_{4n|n,n,n,n} = five4n1n1n1n1n  
1378  //23rd bin: --  EMPTY --
1379  //24th bin: <6>_{n,n,n|n,n,n} = six1n1n1n1n1n1n
1380  //25th bin: <6>_{2n,n,n|2n,n,n} = six2n1n1n2n1n1n
1381  //26th bin: <6>_{2n,2n|n,n,n,n} = six2n2n1n1n1n1n
1382  //27th bin: <6>_{3n,n|n,n,n,n} = six3n1n1n1n1n1n
1383  //28th bin: --  EMPTY --
1384  //29th bin: <7>_{2n,n,n|n,n,n,n} = seven2n1n1n1n1n1n1n
1385  //30th bin: --  EMPTY --
1386  //31st bin: <8>_{n,n,n,n|n,n,n,n} = eight1n1n1n1n1n1n1n1n
1387  
1388  Double_t phi1=0., phi2=0., phi3=0., phi4=0., phi5=0., phi6=0., phi7=0., phi8=0.;
1389
1390  //<2>_{k*n|k*n} (k=1,2,3 and 4)
1391  for(Int_t i1=0;i1<dMult;i1++)
1392  {
1393   fTrack=anEvent->GetTrack(i1);
1394   phi1=fTrack->Phi();
1395   for(Int_t i2=0;i2<dMult;i2++)
1396   {
1397    if(i2==i1)continue;
1398    fTrack=anEvent->GetTrack(i2);
1399    phi2=fTrack->Phi();
1400    fDirectCorrelations->Fill(0.,cos(n*(phi1-phi2)),1);    //<2>_{n|n}
1401    fDirectCorrelations->Fill(1.,cos(2.*n*(phi1-phi2)),1); //<2>_{2n|2n}
1402    fDirectCorrelations->Fill(2.,cos(3.*n*(phi1-phi2)),1); //<2>_{3n|3n}
1403    fDirectCorrelations->Fill(3.,cos(4.*n*(phi1-phi2)),1); //<2>_{4n|4n} 
1404   }
1405  }  
1406      
1407  //<3>_{2n|n,n}, <3>_{3n|2n,n}, <3>_{4n|2n,2n} and <3>_{4n|3n,n}
1408  for(Int_t i1=0;i1<dMult;i1++)
1409  {
1410   fTrack=anEvent->GetTrack(i1);
1411   phi1=fTrack->Phi();
1412   for(Int_t i2=0;i2<dMult;i2++)
1413   {
1414    if(i2==i1)continue;
1415    fTrack=anEvent->GetTrack(i2);
1416    phi2=fTrack->Phi();
1417    for(Int_t i3=0;i3<dMult;i3++)
1418    {
1419     if(i3==i1||i3==i2)continue;
1420     fTrack=anEvent->GetTrack(i3);
1421     phi3=fTrack->Phi();
1422     fDirectCorrelations->Fill(5.,cos(2*n*phi1-n*(phi2+phi3)),1);        //<3>_{2n|n,n}
1423     fDirectCorrelations->Fill(6.,cos(3.*n*phi1-2.*n*phi2-n*phi3),1);    //<3>_{3n|2n,n}
1424     fDirectCorrelations->Fill(7.,cos(4.*n*phi1-2.*n*phi2-2.*n*phi3),1); //<3>_{4n|2n,2n}
1425     fDirectCorrelations->Fill(8.,cos(4.*n*phi1-3.*n*phi2-n*phi3),1);    //<3>_{4n|3n,n}
1426    }
1427   }
1428  }
1429   
1430  //<4>_{n,n|n,n}, <4>_{2n,n|2n,n}, <4>_{2n,2n|2n,2n}, <4>_{3n|n,n,n}, <4>_{3n,n|3n,n}, <4>_{3n,n|2n,2n} and <4>_{4n|2n,n,n} 
1431  for(Int_t i1=0;i1<dMult;i1++)
1432  {
1433   fTrack=anEvent->GetTrack(i1);
1434   phi1=fTrack->Phi();
1435   for(Int_t i2=0;i2<dMult;i2++)
1436   {
1437    if(i2==i1)continue;
1438    fTrack=anEvent->GetTrack(i2);
1439    phi2=fTrack->Phi();
1440    for(Int_t i3=0;i3<dMult;i3++)
1441    {
1442     if(i3==i1||i3==i2)continue;
1443     fTrack=anEvent->GetTrack(i3);
1444     phi3=fTrack->Phi();
1445     for(Int_t i4=0;i4<dMult;i4++)
1446     {
1447      if(i4==i1||i4==i2||i4==i3)continue;
1448      fTrack=anEvent->GetTrack(i4);
1449      phi4=fTrack->Phi();
1450      fDirectCorrelations->Fill(10.,cos(n*phi1+n*phi2-n*phi3-n*phi4),1);            //<4>_{n,n|n,n}
1451      fDirectCorrelations->Fill(11.,cos(2.*n*phi1+n*phi2-2.*n*phi3-n*phi4),1);      //<4>_{2n,n|2n,n}
1452      fDirectCorrelations->Fill(12.,cos(2.*n*phi1+2*n*phi2-2.*n*phi3-2.*n*phi4),1); //<4>_{2n,2n|2n,2n}
1453      fDirectCorrelations->Fill(13.,cos(3.*n*phi1-n*phi2-n*phi3-n*phi4),1);         //<4>_{3n|n,n,n}
1454      fDirectCorrelations->Fill(14.,cos(3.*n*phi1+n*phi2-3.*n*phi3-n*phi4),1);      //<4>_{3n,n|3n,n}   
1455      fDirectCorrelations->Fill(15.,cos(3.*n*phi1+n*phi2-2.*n*phi3-2.*n*phi4),1);   //<4>_{3n,n|2n,2n}
1456      fDirectCorrelations->Fill(16.,cos(4.*n*phi1-2.*n*phi2-n*phi3-n*phi4),1);      //<4>_{4n|2n,n,n}
1457     }  
1458    }
1459   }
1460  }
1461  
1462  //<5>_{2n,n,n,n,n}, //<5>_{2n,2n|2n,n,n}, <5>_{3n,n|2n,n,n} and <5>_{4n|n,n,n,n}
1463  for(Int_t i1=0;i1<dMult;i1++)
1464  {
1465   //cout<<"i1 = "<<i1<<endl;
1466   fTrack=anEvent->GetTrack(i1);
1467   phi1=fTrack->Phi();
1468   for(Int_t i2=0;i2<dMult;i2++)
1469   {
1470    if(i2==i1)continue;
1471    fTrack=anEvent->GetTrack(i2);
1472    phi2=fTrack->Phi();
1473    for(Int_t i3=0;i3<dMult;i3++)
1474    {
1475     if(i3==i1||i3==i2)continue;
1476     fTrack=anEvent->GetTrack(i3);
1477     phi3=fTrack->Phi();
1478     for(Int_t i4=0;i4<dMult;i4++)
1479     {
1480      if(i4==i1||i4==i2||i4==i3)continue;
1481      fTrack=anEvent->GetTrack(i4);
1482      phi4=fTrack->Phi();
1483      for(Int_t i5=0;i5<dMult;i5++)
1484      {
1485       if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
1486       fTrack=anEvent->GetTrack(i5);
1487       phi5=fTrack->Phi();
1488       fDirectCorrelations->Fill(18.,cos(2.*n*phi1+n*phi2-n*phi3-n*phi4-n*phi5),1);       //<5>_{2n,n|n,n,n}
1489       fDirectCorrelations->Fill(19.,cos(2.*n*phi1+2.*n*phi2-2.*n*phi3-n*phi4-n*phi5),1); //<5>_{2n,2n|2n,n,n}
1490       fDirectCorrelations->Fill(20.,cos(3.*n*phi1+n*phi2-2.*n*phi3-n*phi4-n*phi5),1);    //<5>_{3n,n|2n,n,n}
1491       fDirectCorrelations->Fill(21.,cos(4.*n*phi1-n*phi2-n*phi3-n*phi4-n*phi5),1);       //<5>_{4n|n,n,n,n}
1492      }
1493     }  
1494    }
1495   }
1496  }
1497  
1498  //<6>_{n,n,n,n,n,n}, <6>_{2n,n,n|2n,n,n}, <6>_{2n,2n|n,n,n,n} and <6>_{3n,n|n,n,n,n}
1499  for(Int_t i1=0;i1<dMult;i1++)
1500  {
1501   //cout<<"i1 = "<<i1<<endl;
1502   fTrack=anEvent->GetTrack(i1);
1503   phi1=fTrack->Phi();
1504   for(Int_t i2=0;i2<dMult;i2++)
1505   {
1506    if(i2==i1)continue;
1507    fTrack=anEvent->GetTrack(i2);
1508    phi2=fTrack->Phi();
1509    for(Int_t i3=0;i3<dMult;i3++)
1510    {
1511     if(i3==i1||i3==i2)continue;
1512     fTrack=anEvent->GetTrack(i3);
1513     phi3=fTrack->Phi();
1514     for(Int_t i4=0;i4<dMult;i4++)
1515     {
1516      if(i4==i1||i4==i2||i4==i3)continue;
1517      fTrack=anEvent->GetTrack(i4);
1518      phi4=fTrack->Phi();
1519      for(Int_t i5=0;i5<dMult;i5++)
1520      {
1521       if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
1522       fTrack=anEvent->GetTrack(i5);
1523       phi5=fTrack->Phi();
1524       for(Int_t i6=0;i6<dMult;i6++)
1525       {
1526        if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;
1527        fTrack=anEvent->GetTrack(i6);
1528        phi6=fTrack->Phi(); 
1529        fDirectCorrelations->Fill(23.,cos(n*phi1+n*phi2+n*phi3-n*phi4-n*phi5-n*phi6),1);       //<6>_{n,n,n|n,n,n}
1530        fDirectCorrelations->Fill(24.,cos(2.*n*phi1+n*phi2+n*phi3-2.*n*phi4-n*phi5-n*phi6),1); //<6>_{2n,n,n|2n,n,n}
1531        fDirectCorrelations->Fill(25.,cos(2.*n*phi1+2.*n*phi2-n*phi3-n*phi4-n*phi5-n*phi6),1); //<6>_{2n,2n|n,n,n,n}
1532        fDirectCorrelations->Fill(26.,cos(3.*n*phi1+n*phi2-n*phi3-n*phi4-n*phi5-n*phi6),1);    //<6>_{3n,n|n,n,n,n}     
1533       } 
1534      }
1535     }  
1536    }
1537   }
1538  }
1539
1540  //<7>_{2n,n,n|n,n,n,n}
1541  for(Int_t i1=0;i1<dMult;i1++)
1542  {
1543   //cout<<"i1 = "<<i1<<endl;
1544   fTrack=anEvent->GetTrack(i1);
1545   phi1=fTrack->Phi();
1546   for(Int_t i2=0;i2<dMult;i2++)
1547   {
1548    if(i2==i1)continue;
1549    fTrack=anEvent->GetTrack(i2);
1550    phi2=fTrack->Phi();
1551    for(Int_t i3=0;i3<dMult;i3++)
1552    {
1553     if(i3==i1||i3==i2)continue;
1554     fTrack=anEvent->GetTrack(i3);
1555     phi3=fTrack->Phi();
1556     for(Int_t i4=0;i4<dMult;i4++)
1557     {
1558      if(i4==i1||i4==i2||i4==i3)continue;
1559      fTrack=anEvent->GetTrack(i4);
1560      phi4=fTrack->Phi();
1561      for(Int_t i5=0;i5<dMult;i5++)
1562      {
1563       if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
1564       fTrack=anEvent->GetTrack(i5);
1565       phi5=fTrack->Phi();
1566       for(Int_t i6=0;i6<dMult;i6++)
1567       {
1568        if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;
1569        fTrack=anEvent->GetTrack(i6);
1570        phi6=fTrack->Phi(); 
1571        for(Int_t i7=0;i7<dMult;i7++)
1572        {
1573         if(i7==i1||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6)continue;
1574         fTrack=anEvent->GetTrack(i7);
1575         phi7=fTrack->Phi(); 
1576         fDirectCorrelations->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}
1577        } 
1578       } 
1579      }
1580     }  
1581    }
1582   }
1583  }
1584  
1585  //<8>_{n,n,n,n|n,n,n,n}
1586  for(Int_t i1=0;i1<dMult;i1++)
1587  {
1588   cout<<"i1 = "<<i1<<endl;
1589   fTrack=anEvent->GetTrack(i1);
1590   phi1=fTrack->Phi();
1591   for(Int_t i2=0;i2<dMult;i2++)
1592   {
1593    if(i2==i1)continue;
1594    fTrack=anEvent->GetTrack(i2);
1595    phi2=fTrack->Phi();
1596    for(Int_t i3=0;i3<dMult;i3++)
1597    {
1598     if(i3==i1||i3==i2)continue;
1599     fTrack=anEvent->GetTrack(i3);
1600     phi3=fTrack->Phi();
1601     for(Int_t i4=0;i4<dMult;i4++)
1602     {
1603      if(i4==i1||i4==i2||i4==i3)continue;
1604      fTrack=anEvent->GetTrack(i4);
1605      phi4=fTrack->Phi();
1606      for(Int_t i5=0;i5<dMult;i5++)
1607      {
1608       if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
1609       fTrack=anEvent->GetTrack(i5);
1610       phi5=fTrack->Phi();
1611       for(Int_t i6=0;i6<dMult;i6++)
1612       {
1613        if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;
1614        fTrack=anEvent->GetTrack(i6);
1615        phi6=fTrack->Phi(); 
1616        for(Int_t i7=0;i7<dMult;i7++)
1617        {
1618         if(i7==i1||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6)continue;
1619         fTrack=anEvent->GetTrack(i7);
1620         phi7=fTrack->Phi(); 
1621         for(Int_t i8=0;i8<dMult;i8++)
1622         {
1623          if(i8==i1||i8==i2||i8==i3||i8==i4||i8==i5||i8==i6||i8==i7)continue;
1624          fTrack=anEvent->GetTrack(i8);
1625          phi8=fTrack->Phi();  
1626          fDirectCorrelations->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}
1627         } 
1628        } 
1629       } 
1630      }
1631     }  
1632    }
1633   }
1634  }
1635  
1636  // binning details of fDirectCorrelations (differential flow):
1637  //
1638  //41st bin: <2'>_{n|n}
1639  //42nd bin: <2'>_{2n|2n}
1640  //43rd bin: <2'>_{3n|3n}
1641  //44th bin: <2'>_{4n|4n}
1642  //46th bin: <3'>_{2n|n,n}
1643  //47th bin: <3'>_{n,n|2n}
1644  //51st bin: <4'>_{n,n|n,n}
1645  //56th bin: <5'>_{2n,n|n,n,n}
1646  //61st bin: <6'>_{n,n,n|n,n,n}
1647  //66th bin: <7'>_{2n,n,n|n,n,n,n}
1648  //71st bin: <8'>_{n,n,n,n|n,n,n,n}
1649  
1650  
1651  //<2'>_{n|n}
1652  for(Int_t i1=0;i1<nPrim;i1++)
1653  {
1654   fTrack=anEvent->GetTrack(i1);
1655   if(!((fTrack->Pt()>=0.5&&fTrack->Pt()<0.6)&&(fTrack->UseForDifferentialFlow())))continue;//POI condition
1656   phi1=fTrack->Phi();
1657   for(Int_t i2=0;i2<nPrim;i2++)
1658   {
1659    if(i2==i1)continue;
1660    fTrack=anEvent->GetTrack(i2);
1661    if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition
1662    phi2=fTrack->Phi();
1663     //cout<<"1st = "<<i1<<"     "<< (anEvent->GetTrack(i1))->Eta() << " " << (anEvent->GetTrack(i1))->Pt()<<endl;
1664     //cout<<"2nd = "<<i2<<"     "<< (anEvent->GetTrack(i2))->Eta() << " " << (anEvent->GetTrack(i2))->Pt()<<endl; 
1665    //fill the fDirectCorrelations:    
1666    fDirectCorrelations->Fill(40.,cos(1.*n*(phi1-phi2)),1);//<2'>_{n,n}
1667    fDirectCorrelations->Fill(41.,cos(2.*n*(phi1-phi2)),1);//<2'>_{2n,2n}
1668    fDirectCorrelations->Fill(42.,cos(3.*n*(phi1-phi2)),1);//<2'>_{3n,3n}
1669    fDirectCorrelations->Fill(43.,cos(4.*n*(phi1-phi2)),1);//<2'>_{4n,4n}     
1670   }//end of for(Int_t i2=0;i2<nPrim;i2++)
1671  }//end of for(Int_t i1=0;i1<nPrim;i1++)
1672  
1673  //<3'>_{2n|n,n}
1674  for(Int_t i1=0;i1<nPrim;i1++)
1675  {
1676   fTrack=anEvent->GetTrack(i1);
1677   if(!((fTrack->Pt()>=0.5&&fTrack->Pt()<0.6)&&(fTrack->UseForDifferentialFlow())))continue;//POI condition
1678   phi1=fTrack->Phi();
1679   for(Int_t i2=0;i2<nPrim;i2++)
1680   {
1681    if(i2==i1)continue;
1682    fTrack=anEvent->GetTrack(i2);
1683    if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition
1684    phi2=fTrack->Phi();
1685    for(Int_t i3=0;i3<nPrim;i3++)
1686    {
1687     if(i3==i1||i3==i2)continue;
1688     fTrack=anEvent->GetTrack(i3);
1689     if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition
1690     phi3=fTrack->Phi();
1691     //fill the fDirectCorrelations:           
1692     fDirectCorrelations->Fill(45.,cos(n*(2.*phi1-phi2-phi3)),1);//<3'>_{2n|n,n}
1693     fDirectCorrelations->Fill(46.,cos(n*(phi1+phi2-2.*phi3)),1);//<3'>_{n,n|2n}    
1694    }//end of for(Int_t i3=0;i3<nPrim;i3++)  
1695   }//end of for(Int_t i2=0;i2<nPrim;i2++)  
1696  }//end of for(Int_t i1=0;i1<nPrim;i1++) 
1697   
1698  //<4'>_{n,n|n,n}
1699  for(Int_t i1=0;i1<nPrim;i1++)
1700  {
1701   fTrack=anEvent->GetTrack(i1);
1702   if(!((fTrack->Pt()>=0.5&&fTrack->Pt()<0.6)&&(fTrack->UseForDifferentialFlow())))continue;//POI condition
1703   phi1=fTrack->Phi();
1704   for(Int_t i2=0;i2<nPrim;i2++)
1705   {
1706    if(i2==i1)continue;
1707    fTrack=anEvent->GetTrack(i2);
1708    if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition   
1709    phi2=fTrack->Phi();
1710    for(Int_t i3=0;i3<nPrim;i3++)
1711    { 
1712     if(i3==i1||i3==i2)continue;
1713     fTrack=anEvent->GetTrack(i3);
1714     if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition   
1715     phi3=fTrack->Phi();
1716     for(Int_t i4=0;i4<nPrim;i4++)
1717     {
1718      if(i4==i1||i4==i2||i4==i3)continue;
1719      fTrack=anEvent->GetTrack(i4);
1720      if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1721      phi4=fTrack->Phi();
1722      //fill the fDirectCorrelations:
1723      fDirectCorrelations->Fill(50.,cos(n*(phi1+phi2-phi3-phi4)),1);//<4'>_{n,n|n,n} 
1724     }//end of for(Int_t i4=0;i4<nPrim;i4++)
1725    }//end of for(Int_t i3=0;i3<nPrim;i3++)
1726   }//end of for(Int_t i2=0;i2<nPrim;i2++) 
1727  }//end of for(Int_t i1=0;i1<nPrim;i1++)
1728  
1729  //<5'>_{2n,n|n,n,n}
1730  for(Int_t i1=0;i1<nPrim;i1++)
1731  {
1732   fTrack=anEvent->GetTrack(i1);
1733   if(!((fTrack->Pt()>=0.5&&fTrack->Pt()<0.6)&&(fTrack->UseForDifferentialFlow())))continue;//POI condition
1734   phi1=fTrack->Phi();
1735   for(Int_t i2=0;i2<nPrim;i2++)
1736   {
1737    if(i2==i1)continue;
1738    fTrack=anEvent->GetTrack(i2);
1739    if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition   
1740    phi2=fTrack->Phi();
1741    for(Int_t i3=0;i3<nPrim;i3++)
1742    { 
1743     if(i3==i1||i3==i2)continue;
1744     fTrack=anEvent->GetTrack(i3);
1745     if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition   
1746     phi3=fTrack->Phi();
1747     for(Int_t i4=0;i4<nPrim;i4++)
1748     {
1749      if(i4==i1||i4==i2||i4==i3)continue;
1750      fTrack=anEvent->GetTrack(i4);
1751      if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1752      phi4=fTrack->Phi();
1753      for(Int_t i5=0;i5<nPrim;i5++)
1754      {
1755       if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
1756       fTrack=anEvent->GetTrack(i5);
1757       if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1758       phi5=fTrack->Phi();    
1759       //fill the fDirectCorrelations:if(bNestedLoops)
1760       fDirectCorrelations->Fill(55.,cos(2.*n*phi1+n*phi2-n*phi3-n*phi4-n*phi5),1);//<5'>_{2n,n|n,n,n}
1761      }//end of for(Int_t i5=0;i5<nPrim;i5++)  
1762     }//end of for(Int_t i4=0;i4<nPrim;i4++)
1763    }//end of for(Int_t i3=0;i3<nPrim;i3++)
1764   }//end of for(Int_t i2=0;i2<nPrim;i2++) 
1765  }//end of for(Int_t i1=0;i1<nPrim;i1++)
1766  
1767  //<6'>_{n,n,n|n,n,n}
1768  for(Int_t i1=0;i1<nPrim;i1++)
1769  {
1770   fTrack=anEvent->GetTrack(i1);
1771   if(!((fTrack->Pt()>=0.5&&fTrack->Pt()<0.6)&&(fTrack->UseForDifferentialFlow())))continue;//POI condition
1772   phi1=fTrack->Phi();
1773   for(Int_t i2=0;i2<nPrim;i2++)
1774   {
1775    if(i2==i1)continue;
1776    fTrack=anEvent->GetTrack(i2);
1777    if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition   
1778    phi2=fTrack->Phi();
1779    for(Int_t i3=0;i3<nPrim;i3++)
1780    { 
1781     if(i3==i1||i3==i2)continue;
1782     fTrack=anEvent->GetTrack(i3);
1783     if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition   
1784     phi3=fTrack->Phi();
1785     for(Int_t i4=0;i4<nPrim;i4++)
1786     {
1787      if(i4==i1||i4==i2||i4==i3)continue;
1788      fTrack=anEvent->GetTrack(i4);
1789      if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1790      phi4=fTrack->Phi();
1791      for(Int_t i5=0;i5<nPrim;i5++)
1792      {
1793       if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
1794       fTrack=anEvent->GetTrack(i5);
1795       if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1796       phi5=fTrack->Phi();    
1797       for(Int_t i6=0;i6<nPrim;i6++)
1798       {
1799        if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;
1800        fTrack=anEvent->GetTrack(i6);
1801        if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1802        phi6=fTrack->Phi();  
1803        //fill the fDirectCorrelations:
1804        fDirectCorrelations->Fill(60.,cos(n*(phi1+phi2+phi3-phi4-phi5-phi6)),1);//<6'>_{n,n,n|n,n,n}
1805       }//end of for(Int_t i6=0;i6<nPrim;i6++)   
1806      }//end of for(Int_t i5=0;i5<nPrim;i5++)  
1807     }//end of for(Int_t i4=0;i4<nPrim;i4++)
1808    }//end of for(Int_t i3=0;i3<nPrim;i3++)
1809   }//end of for(Int_t i2=0;i2<nPrim;i2++) 
1810  }//end of for(Int_t i1=0;i1<nPrim;i1++)
1811  
1812  //<7'>_{2n,n,n|n,n,n,n}
1813  for(Int_t i1=0;i1<nPrim;i1++)
1814  {
1815   fTrack=anEvent->GetTrack(i1);
1816   if(!((fTrack->Pt()>=0.5&&fTrack->Pt()<0.6)&&(fTrack->UseForDifferentialFlow())))continue;//POI condition
1817   phi1=fTrack->Phi();
1818   for(Int_t i2=0;i2<nPrim;i2++)
1819   {
1820    if(i2==i1)continue;
1821    fTrack=anEvent->GetTrack(i2);
1822    if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition   
1823    phi2=fTrack->Phi();
1824    for(Int_t i3=0;i3<nPrim;i3++)
1825    { 
1826     if(i3==i1||i3==i2)continue;
1827     fTrack=anEvent->GetTrack(i3);
1828     if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition   
1829     phi3=fTrack->Phi();
1830     for(Int_t i4=0;i4<nPrim;i4++)
1831     {
1832      if(i4==i1||i4==i2||i4==i3)continue;
1833      fTrack=anEvent->GetTrack(i4);
1834      if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1835      phi4=fTrack->Phi();
1836      for(Int_t i5=0;i5<nPrim;i5++)
1837      {
1838       if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
1839       fTrack=anEvent->GetTrack(i5);
1840       if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1841       phi5=fTrack->Phi();    
1842       for(Int_t i6=0;i6<nPrim;i6++)
1843       {
1844        if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;
1845        fTrack=anEvent->GetTrack(i6);
1846        if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1847        phi6=fTrack->Phi();
1848        for(Int_t i7=0;i7<nPrim;i7++)
1849        {
1850         if(i7==i1||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6)continue;
1851         fTrack=anEvent->GetTrack(i7);
1852         if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1853         phi7=fTrack->Phi();   
1854         //fill the fDirectCorrelations:
1855         fDirectCorrelations->Fill(65.,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}
1856        }//end of for(Int_t i7=0;i7<nPrim;i7++)  
1857       }//end of for(Int_t i6=0;i6<nPrim;i6++)   
1858      }//end of for(Int_t i5=0;i5<nPrim;i5++)  
1859     }//end of for(Int_t i4=0;i4<nPrim;i4++)
1860    }//end of for(Int_t i3=0;i3<nPrim;i3++)
1861   }//end of for(Int_t i2=0;i2<nPrim;i2++) 
1862  }//end of for(Int_t i1=0;i1<nPrim;i1++)
1863  
1864  //<8'>_{n,n,n,n|n,n,n,n}
1865  for(Int_t i1=0;i1<nPrim;i1++)
1866  {
1867   fTrack=anEvent->GetTrack(i1);
1868   if(!((fTrack->Pt()>=0.5&&fTrack->Pt()<0.6)&&(fTrack->UseForDifferentialFlow())))continue;//POI condition
1869   phi1=fTrack->Phi();
1870   for(Int_t i2=0;i2<nPrim;i2++)
1871   {
1872    if(i2==i1)continue;
1873    fTrack=anEvent->GetTrack(i2);
1874    if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition   
1875    phi2=fTrack->Phi();
1876    for(Int_t i3=0;i3<nPrim;i3++)
1877    { 
1878     if(i3==i1||i3==i2)continue;
1879     fTrack=anEvent->GetTrack(i3);
1880     if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition   
1881     phi3=fTrack->Phi();
1882     for(Int_t i4=0;i4<nPrim;i4++)
1883     {
1884      if(i4==i1||i4==i2||i4==i3)continue;
1885      fTrack=anEvent->GetTrack(i4);
1886      if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1887      phi4=fTrack->Phi();
1888      for(Int_t i5=0;i5<nPrim;i5++)
1889      {
1890       if(i5==i1||i5==i2||i5==i3||i5==i4)continue;
1891       fTrack=anEvent->GetTrack(i5);
1892       if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1893       phi5=fTrack->Phi();    
1894       for(Int_t i6=0;i6<nPrim;i6++)
1895       {
1896        if(i6==i1||i6==i2||i6==i3||i6==i4||i6==i5)continue;
1897        fTrack=anEvent->GetTrack(i6);
1898        if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1899        phi6=fTrack->Phi();
1900        for(Int_t i7=0;i7<nPrim;i7++)
1901        {
1902         if(i7==i1||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6)continue;
1903         fTrack=anEvent->GetTrack(i7);
1904         if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1905         phi7=fTrack->Phi();
1906         for(Int_t i8=0;i8<nPrim;i8++)
1907         {
1908          if(i8==i1||i8==i2||i8==i3||i8==i4||i8==i5||i8==i6||i8==i7)continue;
1909          fTrack=anEvent->GetTrack(i8);
1910          if(!(fTrack->UseForIntegratedFlow()))continue;//RP condition  
1911          phi8=fTrack->Phi();           
1912          //fill the fDirectCorrelations:
1913          fDirectCorrelations->Fill(70.,cos(n*(phi1+phi2+phi3+phi4-phi5-phi6-phi7-phi8)),1);//<8'>_{n,n,n,n|n,n,n,n}
1914         }//end of for(Int_t i8=0;i8<nPrim;i8++) 
1915        }//end of for(Int_t i7=0;i7<nPrim;i7++)  
1916       }//end of for(Int_t i6=0;i6<nPrim;i6++)   
1917      }//end of for(Int_t i5=0;i5<nPrim;i5++)  
1918     }//end of for(Int_t i4=0;i4<nPrim;i4++)
1919    }//end of for(Int_t i3=0;i3<nPrim;i3++)
1920   }//end of for(Int_t i2=0;i2<nPrim;i2++) 
1921  }//end of for(Int_t i1=0;i1<nPrim;i1++)
1922  
1923  
1924  
1925  */
1926  
1927  
1928 //--------------------------------------------------------------------------------------------------------------------------------  
1929
1930  //}//end of if(nPrim>0&&nPrim<12)
1931 }//end of Make()
1932
1933 //================================================================================================================
1934
1935 void AliFlowAnalysisWithQCumulants::Finish()
1936 {
1937  //calculate the final results
1938  AliQCumulantsFunctions finalResults(fIntFlowResultsQC,fDiffFlowResults2ndOrderQC,fDiffFlowResults4thOrderQC,fCovariances,fAvMultIntFlowQC,fQvectorComponents,fQCorrelations, fQProduct,fDirectCorrelations,f2PerPtBin1n1nRP,f2PerPtBin2n2nRP,f3PerPtBin2n1n1nRP,f3PerPtBin1n1n2nRP,f4PerPtBin1n1n1n1nRP, f2PerEtaBin1n1nRP,f2PerEtaBin2n2nRP,f3PerEtaBin2n1n1nRP,f3PerEtaBin1n1n2nRP,f4PerEtaBin1n1n1n1nRP,f2PerPtBin1n1nPOI,f2PerPtBin2n2nPOI,f3PerPtBin2n1n1nPOI,f3PerPtBin1n1n2nPOI,f4PerPtBin1n1n1n1nPOI, f2PerEtaBin1n1nPOI,f2PerEtaBin2n2nPOI,f3PerEtaBin2n1n1nPOI,f3PerEtaBin1n1n2nPOI,f4PerEtaBin1n1n1n1nPOI,fCommonHists2nd,fCommonHists4th, fCommonHists6th, fCommonHists8th,fCommonHistsResults2nd, fCommonHistsResults4th,fCommonHistsResults6th,fCommonHistsResults8th);
1939
1940  finalResults.Calculate(); 
1941  
1942  
1943  /*
1944    
1945     
1946  //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1947  //                   !!!! to be removed !!!!  
1948  
1949  TCanvas* qvectorPlot = new TCanvas("qvectorPlot","Q-vector Plot",1000,1000);
1950  
1951  qvectorPlot->cd(1);
1952  
1953  TH1D* style = new TH1D("style","Q-vectors",100,-244,244); 
1954  (style->GetYaxis())->SetRangeUser(-244,244);
1955  
1956  style->Draw();
1957   
1958  Int_t nBins=fQvectorForEachEventX->GetNbinsX();
1959  Double_t qxxx=0.,qyyy=0.;
1960  //cout<<"nBins = "<<nBins<<endl;   
1961  //cout<<fQvectorForEachEventX->GetBinEntries(4)<<endl;    
1962  //cout<<fQvectorForEachEventY->GetBinEntries(4)<<endl;     
1963  
1964  for(Int_t b=1;b<nBins+1;b++)
1965  {
1966   if(fQvectorForEachEventX->GetBinEntries(b)==1 && fQvectorForEachEventY->GetBinEntries(b)==1)
1967   {
1968    qxxx=fQvectorForEachEventX->GetBinContent(b);
1969    qyyy=fQvectorForEachEventY->GetBinContent(b);
1970    //cout<<qxxx<<" "<<qyyy<<endl;
1971    TArrow *qvector = new TArrow(0.0,0.0,qxxx,qyyy,0.0144,"|>");
1972    qvector->SetAngle(40);
1973    qvector->SetLineWidth(2);
1974    qvector->Draw("");
1975   }
1976  }  
1977  
1978  //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx       
1979
1980  */        
1981                            
1982 }
1983
1984 //================================================================================================================
1985
1986 void AliFlowAnalysisWithQCumulants::WriteHistograms(TString outputFileName)
1987 {
1988  //store the final results in output .root file
1989  TFile *output = new TFile(outputFileName.Data(),"RECREATE");
1990  output->WriteObject(fHistList, "cobjQC","SingleKey");
1991  delete output;
1992 }
1993
1994 //================================================================================================================
1995
1996
1997