]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowCommon/AliFlowAnalysisWithMixedHarmonics.cxx
correction for detector effects for three particle correlations used to calculate...
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowAnalysisWithMixedHarmonics.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 /* $Id$ */
17
18 /********************************************************** 
19  * In this class azimuthal correlators in mixed harmonics *
20  * are implemented in terms of Q-vectors. This approach   *
21  * doesn't require evaluation of nested loops. This class *
22  * can be used to:                                        *
23  *                                                        *  
24  *  a) Extract subdominant harmonics (like v1 and v4);    *
25  *  b) Study flow of two-particle resonances;             *
26  *  c) Study strong parity violation.                     * 
27  *                                                        * 
28  * Author: Ante Bilandzic (abilandzic@gmail.com)          *
29  *********************************************************/ 
30
31 #define AliFlowAnalysisWithMixedHarmonics_cxx
32
33 #include "Riostream.h"
34 #include "AliFlowCommonConstants.h"
35 #include "AliFlowCommonHist.h"
36 #include "AliFlowCommonHistResults.h"
37
38 #include "TMath.h"
39 #include "TFile.h"
40 #include "TList.h"
41 #include "TProfile.h"
42 #include "TProfile2D.h"
43
44 #include "AliFlowEventSimple.h"
45 #include "AliFlowTrackSimple.h"
46 #include "AliFlowAnalysisWithMixedHarmonics.h"
47
48 class TH1;
49 class TList;
50 ClassImp(AliFlowAnalysisWithMixedHarmonics)
51
52 //================================================================================================================
53
54 AliFlowAnalysisWithMixedHarmonics::AliFlowAnalysisWithMixedHarmonics(): 
55 fHistList(NULL),
56 fHistListName(NULL),
57 fAnalysisLabel(NULL),
58 fAnalysisSettings(NULL),
59 fCorrelatorInteger(1),
60 fNoOfMultipicityBins(10),
61 fMultipicityBinWidth(2),
62 fMinMultiplicity(1),
63 fCorrectForDetectorEffects(kTRUE),
64 fPrintOnTheScreen(kTRUE),
65 fCommonHists(NULL),
66 fnBinsPhi(0),
67 fPhiMin(0),
68 fPhiMax(0),
69 fPhiBinWidth(0),
70 fnBinsPt(0),
71 fPtMin(0),
72 fPtMax(0),
73 fPtBinWidth(0),
74 fnBinsEta(0),
75 fEtaMin(0),
76 fEtaMax(0),
77 fEtaBinWidth(0),
78 fWeightsList(NULL),
79 fUsePhiWeights(kFALSE),
80 fUsePtWeights(kFALSE),
81 fUseEtaWeights(kFALSE),
82 fUseParticleWeights(NULL),
83 fPhiWeights(NULL),
84 fPtWeights(NULL),
85 fEtaWeights(NULL),
86 fReQnk(NULL),
87 fImQnk(NULL),
88 fSpk(NULL),
89 fProfileList(NULL),
90 f3pCorrelatorPro(NULL),
91 fNonIsotropicTermsPro(NULL),
92 f3pCorrelatorVsMPro(NULL),
93 fNonIsotropicTermsVsMPro(NULL),
94 fResultsList(NULL),
95 f3pCorrelatorHist(NULL),
96 fDetectorBiasHist(NULL),
97 f3pCorrelatorVsMHist(NULL),
98 fDetectorBiasVsMHist(NULL)
99 {
100  // Constructor. 
101  
102  // Base list to hold all output objects:
103  fHistList = new TList();
104  fHistListName = new TString("cobjMH");
105  fHistList->SetName(fHistListName->Data());
106  fHistList->SetOwner(kTRUE);
107  
108  // List to hold histograms with phi, pt and eta weights:      
109  fWeightsList = new TList();
110  
111  // List to hold all all-event profiles:      
112  fProfileList = new TList();
113  
114  // List to hold objects with final results:      
115  fResultsList = new TList();
116
117  // Initialize all arrays:  
118  this->InitializeArrays();
119  
120 } // AliFlowAnalysisWithMixedHarmonics::AliFlowAnalysisWithMixedHarmonics()
121  
122 //================================================================================================================  
123
124 AliFlowAnalysisWithMixedHarmonics::~AliFlowAnalysisWithMixedHarmonics()
125 {
126  // Destructor.
127  
128  delete fHistList;
129
130 } // end of AliFlowAnalysisWithMixedHarmonics::~AliFlowAnalysisWithMixedHarmonics()
131
132 //================================================================================================================
133
134 void AliFlowAnalysisWithMixedHarmonics::Init()
135 {
136  // Initialize and book all objects. 
137  
138  // a) Cross check if the user settings make sense before starting; 
139  // b) Access all common constants;
140  // c) Book and nest all lists in the base list fHistList;
141  // d) Book common control histograms;
142  // e) Book all event-by-event quantities;
143  // f) Book all all-event quantities;
144  // g) Book and fill histograms to hold phi, pt and eta weights;
145   
146  //save old value and prevent histograms from being added to directory
147  //to avoid name clashes in case multiple analaysis objects are used
148  //in an analysis
149  Bool_t oldHistAddStatus = TH1::AddDirectoryStatus();
150  TH1::AddDirectory(kFALSE);
151  
152  TH1::SetDefaultSumw2();
153  
154  this->CrossCheckSettings();
155  this->AccessConstants();
156  this->BookAndNestAllLists();
157  this->BookProfileHoldingSettings();
158  this->BookCommonHistograms();
159  this->BookAllEventByEventQuantities();
160  this->BookAllAllEventQuantities();
161  this->BookAndFillWeightsHistograms();
162
163  TH1::AddDirectory(oldHistAddStatus);
164  
165 } // end of void AliFlowAnalysisWithMixedHarmonics::Init()
166
167 //================================================================================================================
168
169 void AliFlowAnalysisWithMixedHarmonics::Make(AliFlowEventSimple* anEvent)
170 {
171  // Running over data only in this method.
172  
173  // a) Check all pointers used in this method;
174  // b) Define local variables;
175  // c) Fill common control histograms;
176  // d) Loop over data and calculate e-b-e quantities Q_{n,k} and S_{p,k};
177  // e) Calculate 3-p azimuthal correlator and non-isotropic terms in terms of Q_{n,k} and S_{p,k};
178  // f) Calculate differential 3-p azimuthal correlator cos(2phi1-psi2-psi3) in terms of Q_{2n} and p_{n}:
179  // g) Reset all event-by-event quantities.
180  
181  // a) Check all pointers used in this method:
182  this->CheckPointersUsedInMake();
183  
184  // b) Define local variables:
185  Double_t dPhi = 0.; // azimuthal angle in the laboratory frame
186  Double_t dPt  = 0.; // transverse momentum
187  Double_t dEta = 0.; // pseudorapidity
188  Double_t wPhi = 1.; // phi weight
189  Double_t wPt  = 1.; // pt weight
190  Double_t wEta = 1.; // eta weight
191  AliFlowTrackSimple *aftsTrack = NULL; // simple track
192  
193  // c) Fill common control histograms:
194  fCommonHists->FillControlHistograms(anEvent);  
195  
196  // d) Loop over data and calculate e-b-e quantities:
197  Int_t nPrim = anEvent->NumberOfTracks();  // nPrim = total number of primary tracks, i.e. nPrim = nRP + nPOI + rest, where:
198                                            // nRP   = # of particles used to determine the reaction plane ("Reference Particles");
199                                            // nPOI  = # of particles of interest for a detailed flow analysis ("Particles of Interest");
200                                            // rest  = # of particles which are not niether RPs nor POIs.  
201  // Start loop over data:
202  for(Int_t i=0;i<nPrim;i++) 
203  { 
204   aftsTrack=anEvent->GetTrack(i);
205   if(aftsTrack)
206   {
207    if(!(aftsTrack->InRPSelection() || aftsTrack->InPOISelection())) continue; // consider only tracks which are either RPs or POIs
208    Int_t n = fCorrelatorInteger; // integer n in the correlator cos[n(2phi1-phi2-phi3)]
209    if(aftsTrack->InRPSelection()) // checking RP condition:
210    {    
211     dPhi = aftsTrack->Phi();
212     dPt  = aftsTrack->Pt();
213     dEta = aftsTrack->Eta();
214     if(fUsePhiWeights && fPhiWeights && fnBinsPhi) // determine phi-weight for this particle:
215     {
216      wPhi = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*fnBinsPhi/TMath::TwoPi())));
217     }
218     if(fUsePtWeights && fPtWeights && fnBinsPt) // determine pt-weight for this particle:
219     {
220      wPt = fPtWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-fPtMin)/fPtBinWidth))); 
221     }              
222     if(fUseEtaWeights && fEtaWeights && fEtaBinWidth) // determine eta-weight for this particle: 
223     {
224      wEta = fEtaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-fEtaMin)/fEtaBinWidth))); 
225     } 
226     // Calculate Re[Q_{m*n,k}] and Im[Q_{m*n,k}], (m = 1,2 and k = 0,1,2,3) for this event:
227     for(Int_t m=0;m<2;m++)
228     {
229      for(Int_t k=0;k<4;k++) // to be improved (what is maximum k that I need?)
230      {
231       (*fReQnk)(m,k)+=pow(wPhi*wPt*wEta,k)*TMath::Cos((m+1)*n*dPhi); 
232       (*fImQnk)(m,k)+=pow(wPhi*wPt*wEta,k)*TMath::Sin((m+1)*n*dPhi); 
233      } 
234     }
235     // Calculate partially S_{p,k} for this event (final calculation of S_{p,k} follows after the loop over data bellow):
236     for(Int_t p=0;p<4;p++) // to be improved (what is maximum p that I need?)
237     {
238      for(Int_t k=0;k<4;k++) // to be improved (what is maximum k that I need?)
239      {     
240       (*fSpk)(p,k)+=pow(wPhi*wPt*wEta,k);
241      }
242     }    
243    } // end of if(aftsTrack->InRPSelection())
244    // POIs:
245    if(aftsTrack->InPOISelection()) // 1st POI
246    {
247     Double_t dPsi1 = aftsTrack->Phi();
248     Double_t dPt1  = aftsTrack->Pt();
249     for(Int_t j=i+1;j<nPrim;j++)
250     {
251      aftsTrack=anEvent->GetTrack(j);
252      if(aftsTrack->InPOISelection()) // 2nd POI
253      {
254       Double_t dPsi2 = aftsTrack->Phi();
255       Double_t dPt2  = aftsTrack->Pt(); 
256       // Fill:
257       fRePEBE[0]->Fill((dPt1+dPt2)/2.,TMath::Cos(n*(dPsi1+dPsi2)),1.);
258       fImPEBE[0]->Fill((dPt1+dPt2)/2.,TMath::Sin(n*(dPsi1+dPsi2)),1.);
259       fRePEBE[1]->Fill(TMath::Abs(dPt1-dPt2),TMath::Cos(n*(dPsi1+dPsi2)),1.);
260       fImPEBE[1]->Fill(TMath::Abs(dPt1-dPt2),TMath::Sin(n*(dPsi1+dPsi2)),1.);
261      }
262     }
263    }  
264   } else // to if(aftsTrack)
265     {
266      cout<<endl;
267      cout<<" WARNING (MH): No particle! (i.e. aftsTrack is a NULL pointer in AFAWMH::Make().)"<<endl;
268      cout<<endl;       
269     }
270  } // end of for(Int_t i=0;i<nPrim;i++) 
271
272  // Calculate the final expressions for S_{p,k}:
273  for(Int_t p=0;p<4;p++) // to be improved (what is maximum p that I need?)
274  {
275   for(Int_t k=0;k<4;k++) // to be improved (what is maximum  that I need?)
276   {
277    (*fSpk)(p,k)=pow((*fSpk)(p,k),p+1);
278   }  
279  } 
280  
281  // e) Calculate 3-p azimuthal correlator in terms of Q_{n,k} and S_{p,k}:
282  if(anEvent->GetEventNSelTracksRP() >= 3) 
283  {
284   this->Calculate3pCorrelator();
285  }             
286  if(anEvent->GetEventNSelTracksRP() >= 0) // to be improved (is this correct if statement?)  
287  {
288   this->CalculateNonIsotropicTerms();                          
289  }
290                  
291  // f) Calculate differential 3-p azimuthal correlator cos(2phi1-psi2-psi3) in terms of Q_{2n} and p_{n}:
292  this->CalculateDifferential3pCorrelator(); // to be improved - add relevant if statements for the min No of RPs and POIs
293  
294  // g) Reset all event-by-event quantities: 
295  this->ResetEventByEventQuantities();
296    
297 } // end of AliFlowAnalysisWithMixedHarmonics::Make(AliFlowEventSimple* anEvent)
298
299 //================================================================================================================
300
301 void AliFlowAnalysisWithMixedHarmonics::Finish()
302 {
303  // Calculate the final results.
304  
305  // a) Check all pointers used in this method;
306  // b) Access settings for analysis with mixed harmonics;
307  // c) Correct for detector effects;
308  // d) Print on the screen the final results.
309  
310  this->CheckPointersUsedInFinish();
311  this->AccessSettings();
312  if(fCorrectForDetectorEffects) 
313  {
314   this->CorrectForDetectorEffects();
315   this->CorrectForDetectorEffectsVsM();
316  }
317  if(fPrintOnTheScreen) this->PrintOnTheScreen();
318                                                                                                                                                                                                                                                                                                                
319 } // end of AliFlowAnalysisWithMixedHarmonics::Finish()
320
321 //================================================================================================================
322
323 void AliFlowAnalysisWithMixedHarmonics::GetOutputHistograms(TList *outputListHistos)
324 {
325  // Get pointers to all objects saved in the output file.
326  
327  // a) Get pointers for common control histograms. 
328  if(outputListHistos)
329  {      
330   this->SetHistList(outputListHistos);
331   if(!fHistList)
332   {
333    cout<<endl;
334    cout<<" WARNING (MH): fHistList is NULL in AFAWMH::GOH() !!!!"<<endl;
335    cout<<endl;
336    exit(0);
337   }
338   this->GetPointersForBaseHistograms();
339   this->GetPointersForCommonHistograms();
340   this->GetPointersForAllEventProfiles();
341   this->GetPointersForResultsHistograms();
342  } else 
343    {
344     cout<<endl;
345     cout<<" WARNING (MH): outputListHistos is NULL in AFAWMH::GOH() !!!!"<<endl;
346     cout<<endl;
347     exit(0);
348    }
349    
350 } // end of void AliFlowAnalysisWithMixedHarmonics::GetOutputHistograms(TList *outputListHistos)
351
352 //================================================================================================================
353
354 void AliFlowAnalysisWithMixedHarmonics::GetPointersForBaseHistograms() 
355 {
356  // Get pointers to base histograms.
357  
358  TString analysisSettingsName = "fAnalysisSettings";
359  TProfile *analysisSettings = dynamic_cast<TProfile*>(fHistList->FindObject(analysisSettingsName.Data()));
360  if(analysisSettings) 
361  {
362   this->SetAnalysisSettings(analysisSettings); 
363  } else
364    {
365     cout<<endl;
366     cout<<" WARNING (MH): analysisSettings is NULL in AFAWMH::GPFBH() !!!!"<<endl;
367     cout<<endl;
368     exit(0);  
369    }
370  
371 } // end of void AliFlowAnalysisWithMixedHarmonics::GetPointersForBaseHistograms()
372
373 //================================================================================================================
374
375 void AliFlowAnalysisWithMixedHarmonics::GetPointersForCommonHistograms() 
376 {
377  // Get pointers to common control histograms.
378  
379  TString commonHistsName = "AliFlowCommonHistMH";
380  AliFlowCommonHist *commonHist = dynamic_cast<AliFlowCommonHist*>(fHistList->FindObject(commonHistsName.Data()));
381  if(commonHist) 
382  {
383   this->SetCommonHists(commonHist); 
384  } else
385    {
386     cout<<endl;
387     cout<<" WARNING (MH): commonHist is NULL in AFAWMH::GPFCH() !!!!"<<endl;
388     cout<<endl;
389     exit(0);  
390    }
391  
392 } // end of void AliFlowAnalysisWithMixedHarmonics::GetPointersForCommonHistograms()
393
394 //================================================================================================================
395
396 void AliFlowAnalysisWithMixedHarmonics::GetPointersForAllEventProfiles() 
397 {
398  // Get pointers to profiles holding final results.
399  
400  TList *profileList = NULL;
401  profileList = dynamic_cast<TList*>(fHistList->FindObject("Profiles"));
402  if(!profileList) 
403  {
404   cout<<"WARNING: profileList is NULL in AFAWMH::GPFAEP() !!!!"<<endl;
405   exit(0); 
406  }  
407  
408  TString s3pCorrelatorProName = "f3pCorrelatorPro";
409  TProfile *p3pCorrelatorPro = dynamic_cast<TProfile*>(profileList->FindObject(s3pCorrelatorProName.Data()));
410  if(p3pCorrelatorPro)
411  {
412   this->Set3pCorrelatorPro(p3pCorrelatorPro);  
413  }
414  TString s3pCorrelatorVsMProName = "f3pCorrelatorVsMPro";
415  TProfile *p3pCorrelatorVsMPro = dynamic_cast<TProfile*>(profileList->FindObject(s3pCorrelatorVsMProName.Data()));
416  if(p3pCorrelatorVsMPro)
417  {
418   this->Set3pCorrelatorVsMPro(p3pCorrelatorVsMPro);  
419  }
420  TString nonIsotropicTermsProName = "fNonIsotropicTermsPro";
421  TProfile *nonIsotropicTermsPro = dynamic_cast<TProfile*>(profileList->FindObject(nonIsotropicTermsProName.Data()));
422  if(nonIsotropicTermsPro)
423  {
424   this->SetNonIsotropicTermsPro(nonIsotropicTermsPro);  
425  }
426  TString nonIsotropicTermsVsMProName = "fNonIsotropicTermsVsMPro";
427  TProfile2D *nonIsotropicTermsVsMPro = dynamic_cast<TProfile2D*>(profileList->FindObject(nonIsotropicTermsVsMProName.Data()));
428  if(nonIsotropicTermsVsMPro)
429  {
430   this->SetNonIsotropicTermsVsMPro(nonIsotropicTermsVsMPro);  
431  } 
432  TString psdFlag[2] = {"PtSum","PtDiff"}; 
433  for(Int_t sd=0;sd<2;sd++)
434  {
435   TProfile *p3pCorrelatorVsPtSumDiffPro = dynamic_cast<TProfile*>(profileList->FindObject(Form("f3pCorrelatorVs%sPro",psdFlag[sd].Data())));
436   if(p3pCorrelatorVsPtSumDiffPro)
437   {
438    this->Set3pCorrelatorVsPtSumDiffPro(p3pCorrelatorVsPtSumDiffPro,sd);  
439   }
440  }  
441   
442 } // end of void AliFlowAnalysisWithMixedHarmonics::GetPointersForAllEventProfiles()
443
444 //================================================================================================================
445
446 void AliFlowAnalysisWithMixedHarmonics::GetPointersForResultsHistograms() 
447 {
448  // Get pointers to histograms holding final results.
449  
450  TList *resultsList = NULL;
451  resultsList = dynamic_cast<TList*>(fHistList->FindObject("Results"));
452  if(!resultsList) 
453  {
454   cout<<"WARNING: resultsList is NULL in AFAWMH::GPFRH() !!!!"<<endl;
455   exit(0); 
456  }  
457  TString s3pCorrelatorHistName = "f3pCorrelatorHist";
458  TH1D *h3pCorrelatorHist = dynamic_cast<TH1D*>(resultsList->FindObject(s3pCorrelatorHistName.Data()));
459  if(h3pCorrelatorHist)
460  {
461   this->Set3pCorrelatorHist(h3pCorrelatorHist);  
462  }
463  TString s3pCorrelatorVsMHistName = "f3pCorrelatorVsMHist";
464  TH1D *h3pCorrelatorVsMHist = dynamic_cast<TH1D*>(resultsList->FindObject(s3pCorrelatorVsMHistName.Data()));
465  if(h3pCorrelatorVsMHist)
466  {
467   this->Set3pCorrelatorVsMHist(h3pCorrelatorVsMHist);  
468  }
469  TString detectorBiasHistName = "fDetectorBiasHist";
470  TH1D *detectorBiasHist = dynamic_cast<TH1D*>(resultsList->FindObject(detectorBiasHistName.Data()));
471  if(detectorBiasHist)
472  {
473   this->SetDetectorBiasHist(detectorBiasHist);  
474  }
475  TString detectorBiasVsMHistName = "fDetectorBiasVsMHist";
476  TH1D *detectorBiasVsMHist = dynamic_cast<TH1D*>(resultsList->FindObject(detectorBiasVsMHistName.Data()));
477  if(detectorBiasVsMHist)
478  {
479   this->SetDetectorBiasVsMHist(detectorBiasVsMHist);  
480  }
481
482 } // end of void AliFlowAnalysisWithMixedHarmonics::GetPointersForResultsHistograms()
483
484 //================================================================================================================
485
486 void AliFlowAnalysisWithMixedHarmonics::WriteHistograms(TString outputFileName)
487 {
488  // Store the final results in output .root file.
489  TFile *output = new TFile(outputFileName.Data(),"RECREATE");
490  fHistList->Write(fHistList->GetName(),TObject::kSingleKey);
491  delete output;
492 }
493
494 //================================================================================================================
495
496 void AliFlowAnalysisWithMixedHarmonics::WriteHistograms(TDirectoryFile *outputFileName)
497 {
498  // Store the final results in output .root file.
499  fHistList->SetName("cobjMH");
500  fHistList->SetOwner(kTRUE);
501  outputFileName->Add(fHistList);
502  outputFileName->Write(outputFileName->GetName(),TObject::kSingleKey);
503 }
504
505 //================================================================================================================
506
507 void AliFlowAnalysisWithMixedHarmonics::InitializeArrays()
508 {
509  // Initialize arrays.
510  
511  for(Int_t sd=0;sd<2;sd++)
512  {
513   fRePEBE[sd] = NULL;
514   fImPEBE[sd] = NULL;
515   f3pCorrelatorVsPtSumDiffPro[sd] = NULL;
516  }
517   
518 } // end of AliFlowAnalysisWithMixedHarmonics::InitializeArrays()
519
520 //================================================================================================================  
521
522 void AliFlowAnalysisWithMixedHarmonics::BookAndNestAllLists()
523 {
524  // Book and nest all list in base list fHistList.
525
526  // Weights:
527  fWeightsList->SetName("Weights");
528  fWeightsList->SetOwner(kTRUE);   
529  fHistList->Add(fWeightsList); 
530  // Profiles:
531  fProfileList->SetName("Profiles");
532  fProfileList->SetOwner(kTRUE);   
533  fHistList->Add(fProfileList); 
534  // Results:
535  fResultsList->SetName("Results");
536  fResultsList->SetOwner(kTRUE);   
537  fHistList->Add(fResultsList); 
538
539 } // end of void AliFlowAnalysisWithMixedHarmonics::BookAndNestAllLists()
540
541 //================================================================================================================
542
543 void AliFlowAnalysisWithMixedHarmonics::BookProfileHoldingSettings()
544 {
545  // Book profile to hold all analysis settings.
546
547  TString analysisSettingsName = "fAnalysisSettings";
548  fAnalysisSettings = new TProfile(analysisSettingsName.Data(),"Settings for analysis with mixed harmonics",6,0,6);
549  fAnalysisSettings->GetXaxis()->SetLabelSize(0.025);
550  fAnalysisSettings->GetXaxis()->SetBinLabel(1,"Integer n in cos(n(2#phi_{1}-#phi_{2}-#phi_{3}))");
551  fAnalysisSettings->Fill(0.5,fCorrelatorInteger);
552  fAnalysisSettings->GetXaxis()->SetBinLabel(2,"Corrected for detector effects?");
553  fAnalysisSettings->Fill(1.5,(Int_t)fCorrectForDetectorEffects); 
554  fAnalysisSettings->GetXaxis()->SetBinLabel(3,"# of multiplicity bins");
555  fAnalysisSettings->Fill(2.5,fNoOfMultipicityBins); 
556  fAnalysisSettings->GetXaxis()->SetBinLabel(4,"Width of multiplicity bins");
557  fAnalysisSettings->Fill(3.5,fMultipicityBinWidth);  
558  fAnalysisSettings->GetXaxis()->SetBinLabel(5,"Minimal multiplicity");
559  fAnalysisSettings->Fill(4.5,fMinMultiplicity);
560  fAnalysisSettings->GetXaxis()->SetBinLabel(6,"Print on the screen?");
561  fAnalysisSettings->Fill(5.5,(Int_t)fPrintOnTheScreen);
562  fHistList->Add(fAnalysisSettings);
563  
564 } // end of void AliFlowAnalysisWithMixedHarmonics::BookProfileHoldingSettings()
565
566 //================================================================================================================
567
568 void AliFlowAnalysisWithMixedHarmonics::BookCommonHistograms()
569 {
570  // Book common control histograms and common histograms for final results.
571  
572  TString commonHistsName = "AliFlowCommonHistMH";
573  fCommonHists = new AliFlowCommonHist(commonHistsName.Data());
574  fHistList->Add(fCommonHists);  
575  
576 } // end of void AliFlowAnalysisWithMixedHarmonics::BookCommonHistograms()
577
578 //================================================================================================================
579
580 void AliFlowAnalysisWithMixedHarmonics::BookAllEventByEventQuantities()
581 {
582  // Book all event-by-event quantitites.
583  
584  // Q_{n,k} and S{p,k}:
585  fReQnk = new TMatrixD(2,4); // to be improved(bound on k)
586  fImQnk = new TMatrixD(2,4); // to be improved(bound on k)
587  fSpk = new TMatrixD(4,4); // to be improved(bound on p and k)
588  
589  // p_n vs [(p1+p2)/2,|p1-p2|]
590  TString psdFlag[2] = {"PtSum","PtDiff"};
591  for(Int_t sd=0;sd<2;sd++)
592  {
593   // to be improved: hardwired ,fnBinsPt,0.,fPtMax):
594   fRePEBE[sd] = new TProfile(Form("fRePEBE%s",psdFlag[sd].Data()),"",fnBinsPt,0.,fPtMax);
595   fImPEBE[sd] = new TProfile(Form("fImPEBE%s",psdFlag[sd].Data()),"",fnBinsPt,0.,fPtMax);
596  }  
597  
598 } // end fo void AliFlowAnalysisWithMixedHarmonics::BookAllEventByEventQuantities()
599
600 //================================================================================================================
601
602 void AliFlowAnalysisWithMixedHarmonics::BookAllAllEventQuantities()
603 {
604  // Book all all-event quantitites.
605  
606  // a) Book quantites without multiplicity binning;
607  // b) Book quantites with multiplicity binning;
608  // c) Book quantities with binning in (p1+p2)/2, |p1-p2|, (eta1+eta2)/2 or |eta1-eta2|.
609   
610  // a) Book quantites without multiplicity binning:
611  // 3-p correlator <<cos[n(2phi1-phi2-phi3)]>> for all events:
612  TString s3pCorrelatorProName = "f3pCorrelatorPro";
613  f3pCorrelatorPro = new TProfile(s3pCorrelatorProName.Data(),"",1,0,1);
614  f3pCorrelatorPro->GetXaxis()->SetLabelOffset(0.01);
615  f3pCorrelatorPro->GetXaxis()->SetLabelSize(0.05);
616  if(fCorrelatorInteger == 1)
617  {
618   f3pCorrelatorPro->GetXaxis()->SetBinLabel(1,"cos(2#phi_{1}-#phi_{2}-#phi_{3})");
619  } else
620    {
621     f3pCorrelatorPro->GetXaxis()->SetBinLabel(1,Form("cos[%d(2#phi_{1}-#phi_{2}-#phi_{3})]",fCorrelatorInteger)); 
622    }
623  fProfileList->Add(f3pCorrelatorPro);
624  // Non-isotropic terms in the decomposition of <cos[n(2phi1-phi2-phi3)]:
625  TString nonIsotropicTermsProName = "fNonIsotropicTermsPro";
626  fNonIsotropicTermsPro = new TProfile(nonIsotropicTermsProName.Data(),"",10,0,10);
627  if(fCorrelatorInteger == 1)
628  {
629   fNonIsotropicTermsPro->SetTitle("Non-isotropic terms in decomposition of cos(2#phi_{1}-#phi_{2}-#phi_{3})");
630   fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(1,"cos(#phi_{1})");
631   fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(2,"sin(#phi_{1})");
632   fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(3,"cos(2#phi_{1})");
633   fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(4,"sin(2#phi_{1})");
634   fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(5,"cos(#phi_{1}+#phi_{2})");
635   fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(6,"sin(#phi_{1}+#phi_{2})");
636   fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(7,"cos(2#phi_{1}-#phi_{2})");
637   fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(8,"sin(2#phi_{1}-#phi_{2})");
638   fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(9,"cos(#phi_{1}-#phi_{2}-#phi_{3})");
639   fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(10,"sin(#phi_{1}-#phi_{2}-#phi_{3})");  
640  } else
641    {
642     fNonIsotropicTermsPro->SetTitle(Form("Non-isotropic terms in decomposition of cos[%d(2#phi_{1}-#phi_{2}-#phi_{3})]",fCorrelatorInteger));
643     fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(1,Form("cos(%d#phi_{1})",fCorrelatorInteger));
644     fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(2,Form("sin(%d#phi_{1})",fCorrelatorInteger));
645     fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(3,Form("cos(%d#phi_{1})",2*fCorrelatorInteger));
646     fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(4,Form("sin(%d#phi_{1})",2*fCorrelatorInteger));
647     fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(5,Form("cos(%d(#phi_{1}+#phi_{2}))",fCorrelatorInteger));
648     fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(6,Form("sin(%d(#phi_{1}+#phi_{2}))",fCorrelatorInteger));
649     fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(7,Form("cos(%d(2#phi_{1}-#phi_{2}))",fCorrelatorInteger));
650     fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(8,Form("sin(%d(2#phi_{1}-#phi_{2}))",fCorrelatorInteger));
651     fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(9,Form("cos(%d(#phi_{1}-#phi_{2}-#phi_{3}))",fCorrelatorInteger));
652     fNonIsotropicTermsPro->GetXaxis()->SetBinLabel(10,Form("sin(%d(#phi_{1}-#phi_{2}-#phi_{3}))",fCorrelatorInteger));  
653    } 
654  fProfileList->Add(fNonIsotropicTermsPro);
655  // 3-p correlator <<cos[n(2phi1-phi2-phi3)]>> corrected for detector effects:
656  TString s3pCorrelatorHistName = "f3pCorrelatorHist";
657  f3pCorrelatorHist = new TH1D(s3pCorrelatorHistName.Data(),"",1,0,1);
658  f3pCorrelatorHist->GetXaxis()->SetLabelOffset(0.01);
659  f3pCorrelatorHist->GetXaxis()->SetLabelSize(0.05);
660  if(fCorrelatorInteger == 1)
661  {
662   f3pCorrelatorHist->GetXaxis()->SetBinLabel(1,"cos(2#phi_{1}-#phi_{2}-#phi_{3})");
663  } else
664    {
665     f3pCorrelatorHist->GetXaxis()->SetBinLabel(1,Form("cos[%d(2#phi_{1}-#phi_{2}-#phi_{3})]",fCorrelatorInteger)); 
666    }
667  fResultsList->Add(f3pCorrelatorHist);
668  // Quantified bias comming from detector inefficiencies to 3-p correlator <<cos[n(2phi1-phi2-phi3)]>>:
669  TString detectorBiasHistName = "fDetectorBiasHist";
670  fDetectorBiasHist = new TH1D(detectorBiasHistName.Data(),"Bias coming from detector inefficiences",1,0,1);
671  fDetectorBiasHist->GetXaxis()->SetBinLabel(1,"#frac{corrected}{measured}");
672  fResultsList->Add(fDetectorBiasHist);
673  
674  // b) Book quantites with multiplicity binning.
675  // 3-p correlator <<cos[n(2phi1-phi2-phi3)]>> versus multiplicity:
676  TString s3pCorrelatorVsMProName = "f3pCorrelatorVsMPro";
677  f3pCorrelatorVsMPro = new TProfile(s3pCorrelatorVsMProName.Data(),"",fNoOfMultipicityBins+2,0,fNoOfMultipicityBins+2);
678  if(fCorrelatorInteger == 1)
679  {
680   f3pCorrelatorVsMPro->SetTitle("cos(2#phi_{1}-#phi_{2}-#phi_{3}) #font[72]{vs} M");
681  } else
682    {
683     f3pCorrelatorVsMPro->SetTitle(Form("cos[%d(2#phi_{1}-#phi_{2}-#phi_{3})] #font[72]{vs} M",fCorrelatorInteger)); 
684    }
685  f3pCorrelatorVsMPro->GetXaxis()->SetBinLabel(1,Form("M < %d",(Int_t)fMinMultiplicity));
686  for(Int_t b=2;b<=fNoOfMultipicityBins+1;b++)
687  {
688   f3pCorrelatorVsMPro->GetXaxis()->SetBinLabel(b,Form("%d #leq M < %d",(Int_t)(fMinMultiplicity+(b-2)*fMultipicityBinWidth),(Int_t)(fMinMultiplicity+(b-1)*fMultipicityBinWidth)));
689  }
690  f3pCorrelatorVsMPro->GetXaxis()->SetBinLabel(fNoOfMultipicityBins+2,Form(" M #geq %d",(Int_t)(fMinMultiplicity+fNoOfMultipicityBins*fMultipicityBinWidth)));
691  fProfileList->Add(f3pCorrelatorVsMPro); 
692  // 3-p correlator <<cos[n(2phi1-phi2-phi3)]>> versus multiplicity corrected for detector effects:
693  TString s3pCorrelatorVsMHistName = "f3pCorrelatorVsMHist";
694  f3pCorrelatorVsMHist = new TH1D(s3pCorrelatorVsMHistName.Data(),"",fNoOfMultipicityBins+2,0,fNoOfMultipicityBins+2);
695  if(fCorrelatorInteger == 1)
696  {
697   f3pCorrelatorVsMHist->SetTitle("cos(2#phi_{1}-#phi_{2}-#phi_{3}) #font[72]{vs} M");
698  } else
699    {
700     f3pCorrelatorVsMHist->SetTitle(Form("cos[%d(2#phi_{1}-#phi_{2}-#phi_{3})] #font[72]{vs} M",fCorrelatorInteger)); 
701    }
702  f3pCorrelatorVsMHist->GetXaxis()->SetBinLabel(1,Form("M < %d",(Int_t)fMinMultiplicity));
703  for(Int_t b=2;b<=fNoOfMultipicityBins+1;b++)
704  {
705   f3pCorrelatorVsMHist->GetXaxis()->SetBinLabel(b,Form("%d #leq M < %d",(Int_t)(fMinMultiplicity+(b-2)*fMultipicityBinWidth),(Int_t)(fMinMultiplicity+(b-1)*fMultipicityBinWidth)));
706  }
707  f3pCorrelatorVsMHist->GetXaxis()->SetBinLabel(fNoOfMultipicityBins+2,Form(" M #geq %d",(Int_t)(fMinMultiplicity+fNoOfMultipicityBins*fMultipicityBinWidth)));
708  fResultsList->Add(f3pCorrelatorVsMHist);
709  // Non-isotropic terms in the decomposition of <cos[n(2phi1-phi2-phi3)] vs multiplicity:
710  TString nonIsotropicTermsVsMProName = "fNonIsotropicTermsVsMPro";
711  fNonIsotropicTermsVsMPro = new TProfile2D(nonIsotropicTermsVsMProName.Data(),"Non-isotropic terms in the decomposition of cos[n(2phi1-phi2-phi3)] #font[72]{vs} M",10,0,10,fNoOfMultipicityBins+2,0,fNoOfMultipicityBins+2);
712  if(fCorrelatorInteger == 1)
713  {
714   fNonIsotropicTermsVsMPro->SetTitle("Non-isotropic terms in decomposition of cos(2#phi_{1}-#phi_{2}-#phi_{3}) #font[72]{vs} M");
715   fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(1,"cos(#phi_{1})");
716   fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(2,"sin(#phi_{1})");
717   fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(3,"cos(2#phi_{1})");
718   fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(4,"sin(2#phi_{1})");
719   fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(5,"cos(#phi_{1}+#phi_{2})");
720   fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(6,"sin(#phi_{1}+#phi_{2})");
721   fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(7,"cos(2#phi_{1}-#phi_{2})");
722   fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(8,"sin(2#phi_{1}-#phi_{2})");
723   fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(9,"cos(#phi_{1}-#phi_{2}-#phi_{3})");
724   fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(10,"sin(#phi_{1}-#phi_{2}-#phi_{3})");  
725  } else
726    {
727     fNonIsotropicTermsVsMPro->SetTitle(Form("Non-isotropic terms in decomposition of cos[%d(2#phi_{1}-#phi_{2}-#phi_{3})]",fCorrelatorInteger));
728     fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(1,Form("cos(%d#phi_{1})",fCorrelatorInteger));
729     fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(2,Form("sin(%d#phi_{1})",fCorrelatorInteger));
730     fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(3,Form("cos(%d#phi_{1})",2*fCorrelatorInteger));
731     fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(4,Form("sin(%d#phi_{1})",2*fCorrelatorInteger));
732     fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(5,Form("cos(%d(#phi_{1}+#phi_{2}))",fCorrelatorInteger));
733     fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(6,Form("sin(%d(#phi_{1}+#phi_{2}))",fCorrelatorInteger));
734     fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(7,Form("cos(%d(2#phi_{1}-#phi_{2}))",fCorrelatorInteger));
735     fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(8,Form("sin(%d(2#phi_{1}-#phi_{2}))",fCorrelatorInteger));
736     fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(9,Form("cos(%d(#phi_{1}-#phi_{2}-#phi_{3}))",fCorrelatorInteger));
737     fNonIsotropicTermsVsMPro->GetXaxis()->SetBinLabel(10,Form("sin(%d(#phi_{1}-#phi_{2}-#phi_{3}))",fCorrelatorInteger));  
738    } 
739  fNonIsotropicTermsVsMPro->GetYaxis()->SetBinLabel(1,Form("M < %d",(Int_t)fMinMultiplicity));
740  for(Int_t b=2;b<=fNoOfMultipicityBins+1;b++)
741  {
742   fNonIsotropicTermsVsMPro->GetYaxis()->SetBinLabel(b,Form("%d #leq M < %d",(Int_t)(fMinMultiplicity+(b-2)*fMultipicityBinWidth),(Int_t)(fMinMultiplicity+(b-1)*fMultipicityBinWidth)));
743  }
744  fNonIsotropicTermsVsMPro->GetYaxis()->SetBinLabel(fNoOfMultipicityBins+2,Form(" M #geq %d",(Int_t)(fMinMultiplicity+fNoOfMultipicityBins*fMultipicityBinWidth)));
745  fProfileList->Add(fNonIsotropicTermsVsMPro); 
746  // Quantified bias comming from detector inefficiencies to 3-p correlator <<cos[n(2phi1-phi2-phi3)]>> vs multiplicity
747  TString detectorBiasVsMHistName = "fDetectorBiasVsMHist";
748  fDetectorBiasVsMHist = new TH1D(detectorBiasVsMHistName.Data(),"",fNoOfMultipicityBins+2,0,fNoOfMultipicityBins+2);
749  if(fCorrelatorInteger == 1)
750  {
751   fDetectorBiasVsMHist->SetTitle("#frac{corrected}{measured} cos(2#phi_{1}-#phi_{2}-#phi_{3}) #font[72]{vs} M"); // to be improved (title)
752  } else
753    {
754     fDetectorBiasVsMHist->SetTitle(Form("#frac{corrected}{measured} cos[%d(2#phi_{1}-#phi_{2}-#phi_{3})] #font[72]{vs} M",fCorrelatorInteger)); // to be improved (title)
755    }
756  fDetectorBiasVsMHist->GetXaxis()->SetBinLabel(1,Form("M < %d",(Int_t)fMinMultiplicity));
757  for(Int_t b=2;b<=fNoOfMultipicityBins+1;b++)
758  {
759   fDetectorBiasVsMHist->GetXaxis()->SetBinLabel(b,Form("%d #leq M < %d",(Int_t)(fMinMultiplicity+(b-2)*fMultipicityBinWidth),(Int_t)(fMinMultiplicity+(b-1)*fMultipicityBinWidth)));
760  }
761  fDetectorBiasVsMHist->GetXaxis()->SetBinLabel(fNoOfMultipicityBins+2,Form(" M #geq %d",(Int_t)(fMinMultiplicity+fNoOfMultipicityBins*fMultipicityBinWidth)));
762  fResultsList->Add(fDetectorBiasVsMHist);
763  
764  // c) Book quantities with binning in (p1+p2)/2, |p1-p2|, (eta1+eta2)/2 or |eta1-eta2|: 
765  TString psdFlag[2] = {"PtSum","PtDiff"};
766  TString psdTitleFlag[2] = {"(p_{t,1}+p_{t,2})/2","#left|p_{t,1}-p_{t,2}#right|"};
767  //TString s3pCorrelatorVsPtSumDiffProName = "f3pCorrelatorVsPtSumDiffPro";
768  for(Int_t sd=0;sd<2;sd++)
769  {
770   // to be improved: hardwired ,fnBinsPt,0.,fPtMax):
771   f3pCorrelatorVsPtSumDiffPro[sd] = new TProfile(Form("f3pCorrelatorVs%sPro",psdFlag[sd].Data()),"",fnBinsPt,0.,fPtMax);
772   //f3pCorrelatorVsPtSumDiffPro[sd]->SetLabelSize(0.05);
773   //f3pCorrelatorVsPtSumDiffPro[sd]->SetMarkerStyle(25);
774   f3pCorrelatorVsPtSumDiffPro[sd]->GetXaxis()->SetTitle(psdTitleFlag[sd].Data());
775   fProfileList->Add(f3pCorrelatorVsPtSumDiffPro[sd]);
776  }  
777   
778 } // end of void AliFlowAnalysisWithMixedHarmonics::BookAllAllEventQuantities()
779
780 //================================================================================================================
781
782 void AliFlowAnalysisWithMixedHarmonics::AccessConstants()
783 {
784  // Access needed common constants from AliFlowCommonConstants.
785  
786  fnBinsPhi = AliFlowCommonConstants::GetMaster()->GetNbinsPhi();
787  fPhiMin = AliFlowCommonConstants::GetMaster()->GetPhiMin();         
788  fPhiMax = AliFlowCommonConstants::GetMaster()->GetPhiMax();
789  if(fnBinsPhi) fPhiBinWidth = (fPhiMax-fPhiMin)/fnBinsPhi;  
790  fnBinsPt = AliFlowCommonConstants::GetMaster()->GetNbinsPt();
791  fPtMin = AliFlowCommonConstants::GetMaster()->GetPtMin();           
792  fPtMax = AliFlowCommonConstants::GetMaster()->GetPtMax();
793  if(fnBinsPt) fPtBinWidth = (fPtMax-fPtMin)/fnBinsPt;  
794  fnBinsEta = AliFlowCommonConstants::GetMaster()->GetNbinsEta();
795  fEtaMin = AliFlowCommonConstants::GetMaster()->GetEtaMin();         
796  fEtaMax = AliFlowCommonConstants::GetMaster()->GetEtaMax();
797  if(fnBinsEta) fEtaBinWidth = (fEtaMax-fEtaMin)/fnBinsEta;  
798  
799 } // end of void AliFlowAnalysisWithMixedHarmonics::AccessConstants()
800
801 //================================================================================================================
802
803 void AliFlowAnalysisWithMixedHarmonics::CrossCheckSettings()
804 {
805  // Cross-check if the user settings make sense. 
806  
807 } // end of void AliFlowAnalysisWithMixedHarmonics::CrossCheckSettings()
808
809 //================================================================================================================
810
811 void AliFlowAnalysisWithMixedHarmonics::BookAndFillWeightsHistograms()
812 {
813  // Book and fill (by accessing file "weights.root") histograms which hold phi, pt and eta weights.
814
815  if(!fWeightsList)
816  {
817   cout<<"WARNING: fWeightsList is NULL in AFAWMH::BAFWH() !!!!"<<endl;
818   exit(0);  
819  }
820  // Profile to hold flags for weights:   
821  TString fUseParticleWeightsName = "fUseParticleWeightsMH";
822  fUseParticleWeights = new TProfile(fUseParticleWeightsName.Data(),"0 = particle weight not used, 1 = particle weight used ",3,0,3);
823  fUseParticleWeights->SetLabelSize(0.06);
824  (fUseParticleWeights->GetXaxis())->SetBinLabel(1,"w_{#phi}");
825  (fUseParticleWeights->GetXaxis())->SetBinLabel(2,"w_{p_{T}}");
826  (fUseParticleWeights->GetXaxis())->SetBinLabel(3,"w_{#eta}");
827  fUseParticleWeights->Fill(0.5,(Int_t)fUsePhiWeights);
828  fUseParticleWeights->Fill(1.5,(Int_t)fUsePtWeights);
829  fUseParticleWeights->Fill(2.5,(Int_t)fUseEtaWeights);
830  fWeightsList->Add(fUseParticleWeights); 
831  // Phi-weights: 
832  if(fUsePhiWeights)
833  {
834   if(fWeightsList->FindObject("phi_weights"))
835   {
836    fPhiWeights = dynamic_cast<TH1F*>(fWeightsList->FindObject("phi_weights"));
837    if(TMath::Abs(fPhiWeights->GetBinWidth(1)-fPhiBinWidth)>pow(10.,-6.))
838    {
839     cout<<endl;
840     cout<<"WARNING (MH): Inconsistent binning in histograms for phi-weights throughout the code."<<endl;
841     cout<<endl;
842     exit(0);
843    }
844   } else 
845     {
846      cout<<"WARNING (MH): fWeightsList->FindObject(\"phi_weights\") is NULL in AFAWMH::BAFWH() !!!!"<<endl;
847      exit(0);
848     }
849  } // end of if(fUsePhiWeights)
850  // Pt-weights:
851  if(fUsePtWeights) 
852  {
853   if(fWeightsList->FindObject("pt_weights"))
854   {
855    fPtWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("pt_weights"));
856    if(TMath::Abs(fPtWeights->GetBinWidth(1)-fPtBinWidth)>pow(10.,-6.))
857    {
858     cout<<endl;
859     cout<<"WARNING (MH): Inconsistent binning in histograms for pt-weights throughout the code."<<endl;
860     cout<<endl;
861     exit(0);
862    }
863   } else 
864     {
865      cout<<"WARNING (MH): fWeightsList->FindObject(\"pt_weights\") is NULL in AFAWMH::BAFWH() !!!!"<<endl;
866      exit(0);
867     }
868  } // end of if(fUsePtWeights)    
869  // Eta-weights:
870  if(fUseEtaWeights) 
871  {
872   if(fWeightsList->FindObject("eta_weights"))
873   {
874    fEtaWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("eta_weights"));
875    if(TMath::Abs(fEtaWeights->GetBinWidth(1)-fEtaBinWidth)>pow(10.,-6.))
876    {
877     cout<<endl;
878     cout<<"WARNING (MH): Inconsistent binning in histograms for eta-weights throughout the code."<<endl;
879     cout<<endl;
880     exit(0);
881    }
882   } else 
883     {
884      cout<<"WARNING: fUseEtaWeights && fWeightsList->FindObject(\"eta_weights\") is NULL in AFAWMH::BAFWH() !!!!"<<endl;
885      exit(0);
886     }
887  } // end of if(fUseEtaWeights)
888  
889 } // end of AliFlowAnalysisWithMixedHarmonics::BookAndFillWeightsHistograms()
890
891 //================================================================================================================
892
893 void AliFlowAnalysisWithMixedHarmonics::CheckPointersUsedInMake()
894 {
895  // Check pointers used in method Make().
896                         
897  if(!fReQnk || !fImQnk || !fSpk )
898  {                        
899   cout<<endl;
900   cout<<" WARNING (MH::Make()): (!fReQnk || !fImQnk || !fSpk) is NULL !!!!"<<endl;
901   cout<<endl;
902   exit(0);
903  }
904  if(!f3pCorrelatorPro)
905  {
906   cout<<endl;
907   cout<<" WARNING (MH::Make()): (!f3pCorrelatorPro) is NULL !!!!"<<endl;
908   cout<<endl;
909   exit(0); 
910  }
911  if(!fNonIsotropicTermsPro)
912  {                        
913   cout<<endl;
914   cout<<" WARNING (MH::Make()): !fNonIsotropicTermsPro is NULL !!!!"<<endl;
915   cout<<endl;
916   exit(0);
917  } 
918  if(!f3pCorrelatorVsMPro)
919  {                        
920   cout<<endl;
921   cout<<" WARNING (MH::Make()): !f3pCorrelatorVsMPro is NULL !!!!"<<endl;
922   cout<<endl;
923   exit(0);
924  }
925  if(!fNonIsotropicTermsVsMPro)
926  {                        
927   cout<<endl;
928   cout<<" WARNING (MH::Make()): !fNonIsotropicTermsVsMPro is NULL !!!!"<<endl;
929   cout<<endl;
930   exit(0);
931  }
932  for(Int_t sd=0;sd<2;sd++)
933  {
934   if(!(f3pCorrelatorVsPtSumDiffPro[sd]))
935   {
936    cout<<endl;
937    cout<<" WARNING (MH::Make()): !"<<Form("f3pCorrelatorVsPtSumDiffPro[%d]",sd)<<" is NULL !!!!"<<endl;
938    cout<<endl;
939    exit(0);   
940   } 
941  }
942                                                                                                                                                                                                                                                                                                                                    
943 } // end of AliFlowAnalysisWithMixedHarmonics::CheckPointersUsedInMake()
944
945 //================================================================================================================
946
947 void AliFlowAnalysisWithMixedHarmonics::CheckPointersUsedInFinish()
948 {
949  // Check pointers used in method Finish().
950  
951  if(!fAnalysisSettings)
952  {                        
953   cout<<endl;
954   cout<<" WARNING (MH::Finish()): !fAnalysisSettings is NULL !!!!"<<endl;
955   cout<<endl;
956   exit(0);
957  }
958  if(!f3pCorrelatorPro)
959  {                        
960   cout<<endl;
961   cout<<" WARNING (MH::Finish()): !f3pCorrelatorPro is NULL !!!!"<<endl;
962   cout<<endl;
963   exit(0);
964  }
965  if(!fNonIsotropicTermsPro)
966  {                        
967   cout<<endl;
968   cout<<" WARNING (MH::Finish()): !fNonIsotropicTermsPro is NULL !!!!"<<endl;
969   cout<<endl;
970   exit(0);
971  } 
972  if(!f3pCorrelatorVsMPro)
973  {                        
974   cout<<endl;
975   cout<<" WARNING (MH::Finish()): !f3pCorrelatorVsMPro is NULL !!!!"<<endl;
976   cout<<endl;
977   exit(0);
978  }
979  if(!f3pCorrelatorVsMHist)
980  {                        
981   cout<<endl;
982   cout<<" WARNING (MH::Finish()): !f3pCorrelatorVsMHist is NULL !!!!"<<endl;
983   cout<<endl;
984   exit(0);
985  }
986  if(!fNonIsotropicTermsVsMPro)
987  {                        
988   cout<<endl;
989   cout<<" WARNING (MH::Finish()): !fNonIsotropicTermsVsMPro is NULL !!!!"<<endl;
990   cout<<endl;
991   exit(0);
992  }
993  if(!f3pCorrelatorHist)
994  {                        
995   cout<<endl;
996   cout<<" WARNING (MH::Finish()): !f3pCorrelatorHist is NULL !!!!"<<endl;
997   cout<<endl;
998   exit(0);
999  }   
1000  if(!fDetectorBiasHist)
1001  {                        
1002   cout<<endl;
1003   cout<<" WARNING (MH::Finish()): !fDetectorBiasHist is NULL !!!!"<<endl;
1004   cout<<endl;
1005   exit(0);
1006  }   
1007  /* to be improved - enabled eventually
1008  if(!fDetectorBiasVsMHist)
1009  {                        
1010   cout<<endl;
1011   cout<<" WARNING (MH::Finish()): !fDetectorBiasVsMHist is NULL !!!!"<<endl;
1012   cout<<endl;
1013   exit(0);
1014  } 
1015  */  
1016  for(Int_t sd=0;sd<2;sd++)
1017  {
1018   if(!(f3pCorrelatorVsPtSumDiffPro[sd]))
1019   {
1020    cout<<endl;
1021    cout<<" WARNING (MH::Finish()): !"<<Form("f3pCorrelatorVsPtSumDiffPro[%d]",sd)<<" is NULL !!!!"<<endl;
1022    cout<<endl;
1023    exit(0);   
1024   } 
1025  }
1026
1027 } // end of AliFlowAnalysisWithMixedHarmonics::CheckPointersUsedInFinish()
1028
1029 //================================================================================================================
1030
1031 void AliFlowAnalysisWithMixedHarmonics::PrintOnTheScreen()
1032 {
1033  // Print the final results on the screen.
1034  
1035  cout<<endl;
1036  cout<<"*******************************************************"<<endl;
1037  cout<<"*******************************************************"<<endl;
1038  cout<<"                    Mixed Harmonics                      "<<endl; 
1039  cout<<endl;
1040  if(fCorrelatorInteger!=1)
1041  {
1042   cout<<"  cos["<<fCorrelatorInteger<<"(2phi1-phi2-phi3)] = "<<f3pCorrelatorHist->GetBinContent(1)<<
1043   " +/- "<<f3pCorrelatorHist->GetBinError(1)<<endl;
1044  } else
1045    {
1046     cout<<"  cos(2phi1-phi2-phi3) = "<<f3pCorrelatorHist->GetBinContent(1)<<" +/- "<<f3pCorrelatorHist->GetBinError(1)<<endl;
1047    }
1048  cout<<"  Detector Bias = "<<fDetectorBiasHist->GetBinContent(1)<<endl;
1049  cout<<endl;
1050  cout<<"*******************************************************"<<endl;
1051  cout<<"*******************************************************"<<endl;
1052
1053 } // end of void AliFlowAnalysisWithMixedHarmonics::PrintOnTheScreen()
1054
1055 //================================================================================================================
1056
1057 void AliFlowAnalysisWithMixedHarmonics::AccessSettings()
1058 {
1059  // Access the settings for analysis with mixed harmonics.
1060  
1061  fCorrelatorInteger = (Int_t)fAnalysisSettings->GetBinContent(1);
1062  fCorrectForDetectorEffects = (Bool_t)fAnalysisSettings->GetBinContent(2);
1063  fNoOfMultipicityBins = (Int_t)fAnalysisSettings->GetBinContent(3);
1064  fMultipicityBinWidth = (Double_t)fAnalysisSettings->GetBinContent(4);
1065  fMinMultiplicity = (Double_t)fAnalysisSettings->GetBinContent(5);
1066  fPrintOnTheScreen = (Bool_t)fAnalysisSettings->GetBinContent(6);
1067                                                                                                                                                                                                                                                                                                                                    
1068 } // end of AliFlowAnalysisWithMixedHarmonics::AccessSettings()
1069
1070 //================================================================================================================
1071
1072 void AliFlowAnalysisWithMixedHarmonics::CorrectForDetectorEffects()
1073 {
1074  // Correct measured 3-p correlator cos[n(2phi1-phi2-phi3)] for detector effects.
1075   
1076  Double_t measured3pCorrelator = f3pCorrelatorPro->GetBinContent(1); // biased by detector effects
1077  Double_t corrected3pCorrelator = 0.; // corrected for detector effects
1078  Double_t nonIsotropicTerms[10] = {0.}; // there are 10 distinct non-isotropic terms
1079  for(Int_t nit=0;nit<10;nit++)
1080  {
1081   nonIsotropicTerms[nit] = fNonIsotropicTermsPro->GetBinContent(nit+1);
1082  }                    
1083  // Calculate corrected 3-p correlator:                     
1084  corrected3pCorrelator = measured3pCorrelator
1085                        - nonIsotropicTerms[2]*nonIsotropicTerms[4]                                                                                
1086                        - nonIsotropicTerms[3]*nonIsotropicTerms[5]                                                              
1087                        - 2.*nonIsotropicTerms[0]*nonIsotropicTerms[6]                                       
1088                        - 2.*nonIsotropicTerms[1]*nonIsotropicTerms[7]                                       
1089                        + 2.*nonIsotropicTerms[2]*(pow(nonIsotropicTerms[0],2.)-pow(nonIsotropicTerms[1],2.))                                       
1090                        + 4.*nonIsotropicTerms[3]*nonIsotropicTerms[0]*nonIsotropicTerms[1]; 
1091  // Store corrected correlator:
1092  f3pCorrelatorHist->SetBinContent(1,corrected3pCorrelator);
1093  f3pCorrelatorHist->SetBinError(1,f3pCorrelatorPro->GetBinError(1)); // to be improved (propagate error for non-isotropic terms)
1094  // Quantify bias from detector inefficiences to 3-p correlator. Remark: Bias is quantified as a 
1095  // ratio between corrected and measured 3-p correlator:
1096  //              bias = corrected/measured
1097  // This bias is stored in histogram fDetectorBias.
1098  Double_t bias = 0.;
1099  if(measured3pCorrelator)
1100  {
1101   bias = corrected3pCorrelator/measured3pCorrelator;
1102   fDetectorBiasHist->SetBinContent(1,bias);                                                          
1103  }   
1104                                                                                                                                                                                                                                                                                                                                    
1105 } // end of AliFlowAnalysisWithMixedHarmonics::CorrectForDetectorEffects()
1106
1107 //================================================================================================================
1108
1109 void AliFlowAnalysisWithMixedHarmonics::CorrectForDetectorEffectsVsM()
1110 {
1111  // Correct measured 3-p correlator cos[n(2phi1-phi2-phi3)] vs M for detector effects.
1112   
1113  for(Int_t b=1;b<=fNoOfMultipicityBins+2;b++) 
1114  {  
1115   Double_t measured3pCorrelator = f3pCorrelatorVsMPro->GetBinContent(b); // biased by detector effects
1116   Double_t corrected3pCorrelator = 0.; // corrected for detector effects
1117   Double_t nonIsotropicTerms[10] = {0.}; // there are 10 distinct non-isotropic terms
1118   for(Int_t nit=0;nit<10;nit++)
1119   {
1120    nonIsotropicTerms[nit] = fNonIsotropicTermsVsMPro->GetBinContent(fNonIsotropicTermsVsMPro->GetBin(nit+1,b));
1121   }                    
1122   // Calculate corrected 3-p correlator:                     
1123   corrected3pCorrelator = measured3pCorrelator
1124                         - nonIsotropicTerms[2]*nonIsotropicTerms[4]                                                                                
1125                         - nonIsotropicTerms[3]*nonIsotropicTerms[5]                                                              
1126                         - 2.*nonIsotropicTerms[0]*nonIsotropicTerms[6]                                       
1127                         - 2.*nonIsotropicTerms[1]*nonIsotropicTerms[7]                                       
1128                         + 2.*nonIsotropicTerms[2]*(pow(nonIsotropicTerms[0],2.)-pow(nonIsotropicTerms[1],2.))                                       
1129                         + 4.*nonIsotropicTerms[3]*nonIsotropicTerms[0]*nonIsotropicTerms[1]; 
1130   // Store corrected correlator:
1131   f3pCorrelatorVsMHist->SetBinContent(b,corrected3pCorrelator);
1132   f3pCorrelatorVsMHist->SetBinError(b,f3pCorrelatorVsMPro->GetBinError(b)); // to be improved (propagate error for non-isotropic terms)
1133   // Quantify bias from detector inefficiences to 3-p correlator. Remark: Bias is quantified as a 
1134   // ratio between corrected and measured 3-p correlator:
1135   //              bias = corrected/measured
1136   // This bias is stored in histogram fDetectorBias.
1137   Double_t bias = 0.;
1138   if(measured3pCorrelator)
1139   {
1140    bias = corrected3pCorrelator/measured3pCorrelator;
1141    fDetectorBiasVsMHist->SetBinContent(b,bias);                                                          
1142   }   
1143  } // end of for(Int_t b=1;b<=fNoOfMultipicityBins;b++) 
1144                                                                                                                                                                                                                                                                                                                                    
1145 } // end of AliFlowAnalysisWithMixedHarmonics::CorrectForDetectorEffectsVsM()
1146
1147 //================================================================================================================
1148
1149 void AliFlowAnalysisWithMixedHarmonics::ResetEventByEventQuantities()
1150 {
1151  // Reset all event by event quantities.
1152  
1153  fReQnk->Zero();
1154  fImQnk->Zero();
1155  fSpk->Zero();
1156   
1157  for(Int_t sd=0;sd<2;sd++)
1158  {
1159   fRePEBE[sd]->Reset();
1160   fImPEBE[sd]->Reset();
1161  }
1162  
1163 } // end of void AliFlowAnalysisWithMixedHarmonics::ResetEventByEventQuantities()
1164
1165 //================================================================================================================
1166
1167 void AliFlowAnalysisWithMixedHarmonics::Calculate3pCorrelator()
1168 {
1169  // Calculate 3-p azimuthal correlator cos[n(2phi1-phi2-phi3)] in terms of Q_{n,k} and S_{p,k}.
1170  
1171  // a) Calculate 3-p correlator without using particle weights;
1172  // b) Calculate 3-p correlator with using particle weights.
1173
1174  // a) Calculate 3-p correlator without using particle weights: 
1175  if(!(fUsePhiWeights || fUsePtWeights || fUseEtaWeights))
1176  {
1177   // Multiplicity (number of RPs):
1178   Double_t dMult = (*fSpk)(0,0);
1179   // Real and imaginary parts of non-weighted Q-vectors (Q_{n,0}) evaluated in harmonics n and 2n: 
1180   Double_t dReQ1n = (*fReQnk)(0,0);
1181   Double_t dReQ2n = (*fReQnk)(1,0);
1182   Double_t dImQ1n = (*fImQnk)(0,0);
1183   Double_t dImQ2n = (*fImQnk)(1,0);
1184   // 3-particle azimuthal correlator <cos(n*(2.*phi1-phi2-phi3))>:
1185   Double_t three2n1n1n = (pow(dReQ1n,2.)*dReQ2n + 2.*dReQ1n*dImQ1n*dImQ2n - pow(dImQ1n,2.)*dReQ2n
1186                        - 2.*(pow(dReQ1n,2.)+pow(dImQ1n,2.))
1187                        - (pow(dReQ2n,2.)+pow(dImQ2n,2.))+2.*dMult)
1188                        / (dMult*(dMult-1.)*(dMult-2.));                 
1189   // Fill all-events profile:                     
1190   f3pCorrelatorPro->Fill(0.5,three2n1n1n,dMult*(dMult-1.)*(dMult-2.));
1191   
1192   // 3-particle azimuthal correlator <cos(n*(2.*phi1-phi2-phi3))> vs multiplicity:
1193   if(dMult<fMinMultiplicity) 
1194   {
1195    f3pCorrelatorVsMPro->Fill(0.5,three2n1n1n,dMult*(dMult-1.)*(dMult-2.));
1196   } else if(dMult>=fMinMultiplicity+fNoOfMultipicityBins*fMultipicityBinWidth)
1197     {
1198      f3pCorrelatorVsMPro->Fill(0.5+fNoOfMultipicityBins+1,three2n1n1n,dMult*(dMult-1.)*(dMult-2.));  
1199     } else
1200       {
1201        f3pCorrelatorVsMPro->Fill(1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),three2n1n1n,dMult*(dMult-1.)*(dMult-2.));
1202       }
1203       
1204  } // end of if(!(fUsePhiWeights || fUsePtWeights || fUseEtaWeights)) 
1205
1206  // b) Calculate 3-p correlator without using particle weights: 
1207  if(fUsePhiWeights || fUsePtWeights || fUseEtaWeights)
1208  {
1209  
1210  } // end of if(fUsePhiWeights || fUsePtWeights || fUseEtaWeights)
1211  
1212 } // end of void AliFlowAnalysisWithMixedHarmonics::Calculate3pCorrelator() 
1213
1214 //================================================================================================================
1215
1216 void AliFlowAnalysisWithMixedHarmonics::CalculateNonIsotropicTerms()
1217 {
1218  // Calculate non-isotropic terms which appear in the decomposition of 3-p correlator <cos[n(2phi1-phi2-phi3)]>.
1219  
1220  // For detector with uniform acceptance all these terms vanish. These non-isotropic terms are stored in fNonIsotropicTermsPro.
1221  // Binning of fNonIsotropicTermsPro is organized as follows:
1222  //  1st bin: <<cos(n*phi1)>>
1223  //  2nd bin: <<sin(n*phi1)>>
1224  //  3rd bin: <<cos(2n*phi1)>>
1225  //  4th bin: <<sin(2n*phi1)>>
1226  //  5th bin: <<cos(n*(phi1+phi2)>>
1227  //  6th bin: <<sin(n*(phi1+phi2)>>
1228  //  7th bin: <<cos(n*(2phi1-phi2)>>
1229  //  8th bin: <<sin(n*(2phi1-phi2)>>
1230  //  9th bin: <<cos(n*(phi1-phi2-phi3)>>
1231  // 10th bin: <<sin(n*(phi1-phi2-phi3)>> 
1232  
1233  // a) Calculate using particle weights; 
1234  // b) Calculate without using particle weights. 
1235  
1236  // a) Calculate using particle weights: 
1237  if(!(fUsePhiWeights || fUsePtWeights || fUseEtaWeights))
1238  {
1239   // Multiplicity (number of RPs):
1240   Double_t dMult = (*fSpk)(0,0);
1241   // Real and imaginary parts of non-weighted Q-vectors (Q_{n,0}) evaluated in harmonics n and 2n: 
1242   Double_t dReQ1n = (*fReQnk)(0,0);
1243   Double_t dReQ2n = (*fReQnk)(1,0);
1244   Double_t dImQ1n = (*fImQnk)(0,0);
1245   Double_t dImQ2n = (*fImQnk)(1,0);
1246   // 1-particle terms:
1247   Double_t cosP1n = 0.; // <cos(n*(phi1))>  
1248   Double_t sinP1n = 0.; // <sin(n*(phi1))>
1249   Double_t cosP2n = 0.; // <cos(2n*(phi1))>  
1250   Double_t sinP2n = 0.; // <sin(2n*(phi1))>
1251   if(dMult>0)
1252   { 
1253    cosP1n = dReQ1n/dMult; 
1254    sinP1n = dImQ1n/dMult;
1255    cosP2n = dReQ2n/dMult; 
1256    sinP2n = dImQ2n/dMult;   
1257    // All-events avarages:
1258    fNonIsotropicTermsPro->Fill(0.5,cosP1n,dMult); // <<cos(n*(phi1))>> 
1259    fNonIsotropicTermsPro->Fill(1.5,sinP1n,dMult); // <<sin(n*(phi1))>>   
1260    fNonIsotropicTermsPro->Fill(2.5,cosP2n,dMult); // <<cos(2n*(phi1))>> 
1261    fNonIsotropicTermsPro->Fill(3.5,sinP2n,dMult); // <<sin(2n*(phi1))>>   
1262    // All-events avarages vs M:
1263    if(dMult<fMinMultiplicity) 
1264    {
1265     fNonIsotropicTermsVsMPro->Fill(0.5,0.5,cosP1n,dMult); // <<cos(n*(phi1))>> 
1266     fNonIsotropicTermsVsMPro->Fill(1.5,0.5,sinP1n,dMult); // <<sin(n*(phi1))>>   
1267     fNonIsotropicTermsVsMPro->Fill(2.5,0.5,cosP2n,dMult); // <<cos(2n*(phi1))>> 
1268     fNonIsotropicTermsVsMPro->Fill(3.5,0.5,sinP2n,dMult); // <<sin(2n*(phi1))>>   
1269    } else if(dMult>=fMinMultiplicity+fNoOfMultipicityBins*fMultipicityBinWidth)
1270      {
1271       fNonIsotropicTermsVsMPro->Fill(0.5,0.5+fNoOfMultipicityBins+1,cosP1n,dMult); // <<cos(n*(phi1))>> 
1272       fNonIsotropicTermsVsMPro->Fill(1.5,0.5+fNoOfMultipicityBins+1,sinP1n,dMult); // <<sin(n*(phi1))>>   
1273       fNonIsotropicTermsVsMPro->Fill(2.5,0.5+fNoOfMultipicityBins+1,cosP2n,dMult); // <<cos(2n*(phi1))>> 
1274       fNonIsotropicTermsVsMPro->Fill(3.5,0.5+fNoOfMultipicityBins+1,sinP2n,dMult); // <<sin(2n*(phi1))>>       
1275      } else
1276        {
1277         fNonIsotropicTermsVsMPro->Fill(0.5,1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),cosP1n,dMult); // <<cos(n*(phi1))>> 
1278         fNonIsotropicTermsVsMPro->Fill(1.5,1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),sinP1n,dMult); // <<sin(n*(phi1))>>   
1279         fNonIsotropicTermsVsMPro->Fill(2.5,1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),cosP2n,dMult); // <<cos(2n*(phi1))>> 
1280         fNonIsotropicTermsVsMPro->Fill(3.5,1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),sinP2n,dMult); // <<sin(2n*(phi1))>>              
1281        }    
1282   } // end of if(dMult>0) 
1283   // 2-particle terms:
1284   Double_t cosP1nP1n = 0.; // <cos(n*(phi1+phi2))>
1285   Double_t sinP1nP1n = 0.; // <sin(n*(phi1+phi2))>
1286   Double_t cosP2nM1n = 0.; // <cos(n*(2phi1-phi2))>
1287   Double_t sinP2nM1n = 0.; // <sin(n*(2phi1-phi2))>
1288   if(dMult>1)
1289   {
1290    cosP1nP1n = (pow(dReQ1n,2)-pow(dImQ1n,2)-dReQ2n)/(dMult*(dMult-1)); 
1291    sinP1nP1n = (2.*dReQ1n*dImQ1n-dImQ2n)/(dMult*(dMult-1)); 
1292    cosP2nM1n = (dReQ2n*dReQ1n+dImQ2n*dImQ1n-dReQ1n)/(dMult*(dMult-1)); 
1293    sinP2nM1n = (dImQ2n*dReQ1n-dReQ2n*dImQ1n-dImQ1n)/(dMult*(dMult-1)); 
1294    // All-events avarages:
1295    fNonIsotropicTermsPro->Fill(4.5,cosP1nP1n,dMult*(dMult-1.)); // <<cos(n*(phi1+phi2))>> 
1296    fNonIsotropicTermsPro->Fill(5.5,sinP1nP1n,dMult*(dMult-1.)); // <<sin(n*(phi1+phi2))>>   
1297    fNonIsotropicTermsPro->Fill(6.5,cosP2nM1n,dMult*(dMult-1.)); // <<cos(n*(2phi1-phi2))>> 
1298    fNonIsotropicTermsPro->Fill(7.5,sinP2nM1n,dMult*(dMult-1.)); // <<sin(n*(2phi1-phi2))>>   
1299    // All-events avarages vs M:  
1300    if(dMult<fMinMultiplicity) 
1301    {
1302     fNonIsotropicTermsVsMPro->Fill(4.5,0.5,cosP1nP1n,dMult*(dMult-1.)); // <<cos(n*(phi1+phi2))>> 
1303     fNonIsotropicTermsVsMPro->Fill(5.5,0.5,sinP1nP1n,dMult*(dMult-1.)); // <<sin(n*(phi1+phi2))>>   
1304     fNonIsotropicTermsVsMPro->Fill(6.5,0.5,cosP2nM1n,dMult*(dMult-1.)); // <<cos(n*(2phi1-phi2))>> 
1305     fNonIsotropicTermsVsMPro->Fill(7.5,0.5,sinP2nM1n,dMult*(dMult-1.)); // <<sin(n*(2phi1-phi2))>>   
1306    } else if(dMult>=fMinMultiplicity+fNoOfMultipicityBins*fMultipicityBinWidth)
1307      {
1308       fNonIsotropicTermsVsMPro->Fill(4.5,0.5+fNoOfMultipicityBins+1,cosP1nP1n,dMult*(dMult-1.)); // <<cos(n*(phi1+phi2))>> 
1309       fNonIsotropicTermsVsMPro->Fill(5.5,0.5+fNoOfMultipicityBins+1,sinP1nP1n,dMult*(dMult-1.)); // <<sin(n*(phi1+phi2))>>   
1310       fNonIsotropicTermsVsMPro->Fill(6.5,0.5+fNoOfMultipicityBins+1,cosP2nM1n,dMult*(dMult-1.)); // <<cos(n*(2phi1-phi2))>> 
1311       fNonIsotropicTermsVsMPro->Fill(7.5,0.5+fNoOfMultipicityBins+1,sinP2nM1n,dMult*(dMult-1.)); // <<sin(n*(2phi1-phi2))>>    
1312      } else
1313        {
1314         fNonIsotropicTermsVsMPro->Fill(4.5,1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),cosP1nP1n,dMult*(dMult-1.)); // <<cos(n*(phi1+phi2))>> 
1315         fNonIsotropicTermsVsMPro->Fill(5.5,1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),sinP1nP1n,dMult*(dMult-1.)); // <<sin(n*(phi1+phi2))>>   
1316         fNonIsotropicTermsVsMPro->Fill(6.5,1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),cosP2nM1n,dMult*(dMult-1.)); // <<cos(n*(2phi1-phi2))>> 
1317         fNonIsotropicTermsVsMPro->Fill(7.5,1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),sinP2nM1n,dMult*(dMult-1.)); // <<sin(n*(2phi1-phi2))>>    
1318        }  
1319   } // end of if(dMult>1) 
1320   // 3-particle:
1321   Double_t cosP1nM1nM1n = 0.; // <cos(n*(phi1-phi2-phi3))>
1322   Double_t sinP1nM1nM1n = 0.; // <sin(n*(phi1-phi2-phi3))>
1323   if(dMult>2)
1324   {
1325    cosP1nM1nM1n = (dReQ1n*(pow(dReQ1n,2)+pow(dImQ1n,2))-dReQ1n*dReQ2n-dImQ1n*dImQ2n-2.*(dMult-1)*dReQ1n)
1326                 / (dMult*(dMult-1)*(dMult-2)); 
1327    sinP1nM1nM1n = (-dImQ1n*(pow(dReQ1n,2)+pow(dImQ1n,2))+dReQ1n*dImQ2n-dImQ1n*dReQ2n+2.*(dMult-1)*dImQ1n)
1328                 / (dMult*(dMult-1)*(dMult-2));              
1329    // All-events avarages:
1330    fNonIsotropicTermsPro->Fill(8.5,cosP1nM1nM1n,dMult*(dMult-1.)*(dMult-2.)); // <<cos(n*(phi1-phi2-phi3))>> 
1331    fNonIsotropicTermsPro->Fill(9.5,sinP1nM1nM1n,dMult*(dMult-1.)*(dMult-2.)); // <<sin(n*(phi1-phi2-phi3))>>    
1332    // All-events avarages vs M:  
1333    if(dMult<fMinMultiplicity) 
1334    {
1335     fNonIsotropicTermsVsMPro->Fill(8.5,0.5,cosP1nM1nM1n,dMult*(dMult-1.)*(dMult-2.)); // <<cos(n*(phi1-phi2-phi3))>> 
1336     fNonIsotropicTermsVsMPro->Fill(9.5,0.5,sinP1nM1nM1n,dMult*(dMult-1.)*(dMult-2.)); // <<sin(n*(phi1-phi2-phi3))>>    
1337    } else if(dMult>=fMinMultiplicity+fNoOfMultipicityBins*fMultipicityBinWidth)
1338      {
1339       fNonIsotropicTermsVsMPro->Fill(8.5,0.5+fNoOfMultipicityBins+1,cosP1nM1nM1n,dMult*(dMult-1.)*(dMult-2.)); // <<cos(n*(phi1-phi2-phi3))>> 
1340       fNonIsotropicTermsVsMPro->Fill(9.5,0.5+fNoOfMultipicityBins+1,sinP1nM1nM1n,dMult*(dMult-1.)*(dMult-2.)); // <<sin(n*(phi1-phi2-phi3))>>    
1341      } else
1342        {
1343         fNonIsotropicTermsVsMPro->Fill(8.5,1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),
1344                                        cosP1nM1nM1n,dMult*(dMult-1.)*(dMult-2.)); // <<cos(n*(phi1-phi2-phi3))>> 
1345         fNonIsotropicTermsVsMPro->Fill(9.5,1.5+(Int_t)((dMult-fMinMultiplicity)/fMultipicityBinWidth),
1346                                        sinP1nM1nM1n,dMult*(dMult-1.)*(dMult-2.)); // <<sin(n*(phi1-phi2-phi3))>>           
1347        }  
1348   } // end of if(dMult>2)
1349  } // end of if(!(fUsePhiWeights || fUsePtWeights || fUseEtaWeights))
1350  
1351  // b) Calculate without using particle weights:
1352  if(fUsePhiWeights || fUsePtWeights || fUseEtaWeights)
1353  {
1354  
1355  } // end of if(fUsePhiWeights || fUsePtWeights || fUseEtaWeights)
1356  
1357 } // end of void AliFlowAnalysisWithMixedHarmonics::CalculateNonIsotropicTerms()
1358
1359 //================================================================================================================
1360
1361 void AliFlowAnalysisWithMixedHarmonics::CalculateDifferential3pCorrelator()
1362 {
1363  // Calculate differential 3-p azimuthal correlator cos[n(2phi1-psi2-psi3)] in terms of Q_{2n} and p_{n}.
1364  
1365  // a) Calculate differential 3-p correlator without using particle weights;
1366  // b) Calculate differential 3-p correlator with using particle weights.
1367
1368  // a) Calculate differential 3-p correlator without using particle weights: 
1369  if(!(fUsePhiWeights || fUsePtWeights || fUseEtaWeights))
1370  {
1371   // Multiplicity (number of RPs):
1372   Double_t dMult = (*fSpk)(0,0);
1373   // Real and imaginary parts of non-weighted Q-vectors (Q_{n,0}) evaluated in harmonic 2n: 
1374   Double_t dReQ2n = (*fReQnk)(1,0);
1375   Double_t dImQ2n = (*fImQnk)(1,0);
1376   for(Int_t sd=0;sd<2;sd++) // [(p1+p2)/2,|p1-p2|]
1377   {
1378    // looping over all bins and calculating reduced correlations: 
1379    for(Int_t b=1;b<=fnBinsPt;b++)
1380    {
1381     // real and imaginary parts of p_{n}: 
1382     Double_t p1nRe = fRePEBE[sd]->GetBinContent(b)*fRePEBE[sd]->GetBinEntries(b);
1383     Double_t p1nIm = fImPEBE[sd]->GetBinContent(b)*fImPEBE[sd]->GetBinEntries(b);
1384     // number of pairs of POIs in particular (p1+p2)/2 or |p1-p2| bin:
1385     Double_t mp = fRePEBE[sd]->GetBinEntries(b);
1386     Double_t cosP2nphi1M1npsi2M1npsi2 = 0; // cos[n(2phi1-psi2-psi3)]
1387     if(mp*dMult>0.)
1388     {
1389      cosP2nphi1M1npsi2M1npsi2 = (p1nRe*dReQ2n+p1nIm*dImQ2n)/(mp*dMult);
1390     }
1391     f3pCorrelatorVsPtSumDiffPro[sd]->Fill(fPtMin+(b-1)*fPtBinWidth,cosP2nphi1M1npsi2M1npsi2,mp*dMult);
1392    } // end of for(Int_t b=1;b<=fnBinsPt;b++)
1393   } // end of for(Int_t sd=0;sd<2;sd++)      
1394  } // end of if(!(fUsePhiWeights || fUsePtWeights || fUseEtaWeights)) 
1395
1396  // b) Calculate differential 3-p correlator by using particle weights: 
1397  if(fUsePhiWeights || fUsePtWeights || fUseEtaWeights)
1398  {
1399  
1400  } // end of if(fUsePhiWeights || fUsePtWeights || fUseEtaWeights)
1401  
1402 } // end of void AliFlowAnalysisWithMixedHarmonics::CalculateDifferential3pCorrelator() 
1403
1404 //================================================================================================================
1405