]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowCommon/AliFlowAnalysisWithNestedLoops.cxx
another codechecker warning fixed
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowAnalysisWithNestedLoops.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  * Only in this class nested loops are used for flow analysis. *
20  * Nested loops are used to evaluate:                          *
21  *                                                             *  
22  *  a) Distribution of relative angle difference (phi1-phi2);  *
23  *  b) Cross-check the results for mixed harmonics.            *
24  *                                                             *
25  *       Author: Ante Bilandzic (abilandzic@gmail.com)         *
26  ***************************************************************/ 
27
28 #define AliFlowAnalysisWithNestedLoops_cxx
29
30 #include "Riostream.h"
31 #include "AliFlowCommonConstants.h"
32 #include "AliFlowCommonHist.h"
33 #include "AliFlowCommonHistResults.h"
34
35 #include "TMath.h"
36 #include "TFile.h"
37 #include "TList.h"
38 #include "TProfile.h"
39
40 #include "AliFlowEventSimple.h"
41 #include "AliFlowTrackSimple.h"
42 #include "AliFlowAnalysisWithNestedLoops.h"
43
44 class TH1;
45 class TList;
46 ClassImp(AliFlowAnalysisWithNestedLoops)
47
48 //================================================================================================================
49
50 AliFlowAnalysisWithNestedLoops::AliFlowAnalysisWithNestedLoops(): 
51 fHistList(NULL),
52 fHistListName(NULL),
53 fHarmonic(0),
54 fAnalysisLabel(NULL),
55 fAnalysisSettings(NULL),
56 fOppositeChargesPOI(kFALSE),
57 fEvaluateDifferential3pCorrelator(kFALSE), 
58 fPrintOnTheScreen(kTRUE),
59 fCommonHists(NULL),
60 fnBinsPhi(0),
61 fPhiMin(0),
62 fPhiMax(0),
63 fPhiBinWidth(0),
64 fnBinsPt(0),
65 fPtMin(0),
66 fPtMax(0),
67 fPtBinWidth(0),
68 fnBinsEta(0),
69 fEtaMin(0),
70 fEtaMax(0),
71 fEtaBinWidth(0),
72 fWeightsList(NULL),
73 fUsePhiWeights(kFALSE),
74 fUsePtWeights(kFALSE),
75 fUseEtaWeights(kFALSE),
76 fUseParticleWeights(NULL),
77 fPhiWeights(NULL),
78 fPtWeights(NULL),
79 fEtaWeights(NULL),
80 fListRAD(NULL),
81 fEvaluateNestedLoopsForRAD(kTRUE),
82 fRelativeAngleDistribution(NULL),
83 fCharge(NULL),
84 fListQC(NULL),
85 fEvaluateNestedLoopsForQC(kFALSE),
86 fListMH(NULL),
87 fEvaluateNestedLoopsForMH(kFALSE),
88 f3pCorrelatorPro(NULL) 
89 {
90  // Constructor. 
91  
92  // Base list to hold all output objects:
93  fHistList = new TList();
94  fHistListName = new TString("cobjNL");
95  fHistList->SetName(fHistListName->Data());
96  fHistList->SetOwner(kTRUE);
97  
98  // List to hold histograms with phi, pt and eta weights:      
99  fWeightsList = new TList();
100  
101  // List to hold objects relevant for relative angle distributions:      
102  fListRAD = new TList();
103  
104  // List holding objects relevant for debugging and cross-checking of Q-cumulants class: 
105  fListQC = new TList();
106
107  // List holding objects relevant for debugging and cross-checking of MH class: 
108  fListMH = new TList();
109  
110  // Initialize all arrays: 
111  this->InitializeArraysForMH();
112  
113 } // AliFlowAnalysisWithNestedLoops::AliFlowAnalysisWithNestedLoops()
114  
115 //================================================================================================================  
116
117 AliFlowAnalysisWithNestedLoops::~AliFlowAnalysisWithNestedLoops()
118 {
119  // Destructor.
120  
121  delete fHistList;
122
123 } // end of AliFlowAnalysisWithNestedLoops::~AliFlowAnalysisWithNestedLoops()
124
125 //================================================================================================================
126
127 void AliFlowAnalysisWithNestedLoops::Init()
128 {
129  // Initialize and book all objects. 
130  
131  // a) Cross check if the user settings make sense before starting; 
132  // b) Access all common constants;
133  // c) Book and nest all lists in the base list fHistList;
134  // d) Book profile holding seetings for analysis with nested loops;
135  // e) Book common control histograms;
136  // f) Book all objects relevant for distributions;
137  // g) Book and fill histograms to hold phi, pt and eta weights;
138  // h) Store harmonic n.
139
140
141  //save old value and prevent histograms from being added to directory
142  //to avoid name clashes in case multiple analaysis objects are used
143  //in an analysis
144  Bool_t oldHistAddStatus = TH1::AddDirectoryStatus();
145  TH1::AddDirectory(kFALSE);
146  
147  TH1::SetDefaultSumw2();
148   
149  this->CrossCheckSettings();
150  this->AccessConstants();
151  this->BookAndNestAllLists();
152  this->BookAndFillProfileHoldingSettings();
153  this->BookCommonHistograms();
154  this->BookEverythingForRAD();
155  this->BookEverythingForMH();
156  this->BookAndFillWeightsHistograms();
157  this->StoreHarmonic(); 
158
159  //restore old status
160  TH1::AddDirectory(oldHistAddStatus);
161 } // end of void AliFlowAnalysisWithNestedLoops::Init()
162
163 //================================================================================================================
164
165 void AliFlowAnalysisWithNestedLoops::Make(AliFlowEventSimple* anEvent)
166 {
167  // Running over data only in this method.
168  
169  // a) Check all pointers used in this method;
170  // b) Fill common control histograms;
171  // c) Evaluate nested loops for relative angle distribution;
172  // d) Evaluate nested loops for mixed harmonics.
173  
174  this->CheckPointersUsedInMake();
175  fCommonHists->FillControlHistograms(anEvent);  
176  if(fEvaluateNestedLoopsForRAD) this->EvaluateNestedLoopsForRAD(anEvent);
177  if(fEvaluateNestedLoopsForMH) this->EvaluateNestedLoopsForMH(anEvent);
178   
179 } // end of AliFlowAnalysisWithNestedLoops::Make(AliFlowEventSimple* anEvent)
180
181 //================================================================================================================
182
183 void AliFlowAnalysisWithNestedLoops::Finish()
184 {
185  // Calculate the final results.
186  
187  // a) Access settings for analysis with mixed harmonics;
188  // b) Check all pointers used in this method;
189  // c) Print on the screen.
190  
191  this->AccessSettings();
192  this->CheckPointersUsedInFinish();
193  if(fPrintOnTheScreen) this->PrintOnTheScreen();
194                                                                                                                                                                                                                                                                                                                
195 } // end of AliFlowAnalysisWithNestedLoops::Finish()
196
197 //================================================================================================================
198
199 void AliFlowAnalysisWithNestedLoops::GetOutputHistograms(TList *outputListHistos)
200 {
201  // Get pointers to all objects saved in the output file.
202  
203  // a) Get pointers for common control histograms. 
204  if(outputListHistos)
205  {      
206   this->SetHistList(outputListHistos);
207   if(!fHistList)
208   {
209    cout<<endl;
210    cout<<" WARNING (NL): fHistList is NULL in AFAWNL::GOH() !!!!"<<endl;
211    cout<<endl;
212    exit(0);
213   }
214   this->GetPointersForBaseHistograms();
215   this->GetPointersForCommonHistograms();
216   this->AccessSettings();
217   if(fEvaluateNestedLoopsForRAD) this->GetPointersForRAD();
218   if(fEvaluateNestedLoopsForMH) this->GetPointersForMH();
219  } else 
220    {
221     cout<<endl;
222     cout<<" WARNING (NL): outputListHistos is NULL in AFAWNL::GOH() !!!!"<<endl;
223     cout<<endl;
224     exit(0);
225    }
226    
227 } // end of void AliFlowAnalysisWithNestedLoops::GetOutputHistograms(TList *outputListHistos)
228
229 //================================================================================================================
230
231 void AliFlowAnalysisWithNestedLoops::GetPointersForBaseHistograms() 
232 {
233  // Get pointers to base histograms.
234  
235  TString analysisSettingsName = "fAnalysisSettings";
236  TProfile *analysisSettings = dynamic_cast<TProfile*>(fHistList->FindObject(analysisSettingsName.Data()));
237  if(analysisSettings) 
238  {
239   this->SetAnalysisSettings(analysisSettings); 
240  } else
241    {
242     cout<<endl;
243     cout<<" WARNING (NL): analysisSettings is NULL in AFAWNL::GPFBH() !!!!"<<endl;
244     cout<<endl;
245     exit(0);  
246    }
247  
248 } // end of void AliFlowAnalysisWithNestedLoops::GetPointersForBaseHistograms()
249
250 //================================================================================================================
251
252 void AliFlowAnalysisWithNestedLoops::GetPointersForCommonHistograms() 
253 {
254  // Get pointers to common control histograms.
255  
256  TString commonHistsName = "AliFlowCommonHistNL";
257  AliFlowCommonHist *commonHist = dynamic_cast<AliFlowCommonHist*>(fHistList->FindObject(commonHistsName.Data()));
258  if(commonHist) 
259  {
260   this->SetCommonHists(commonHist); 
261  } else
262    {
263     cout<<endl;
264     cout<<" WARNING (NL): commonHist is NULL in AFAWNL::GPFCH() !!!!"<<endl;
265     cout<<endl;
266     exit(0);  
267    }
268  
269 } // end of void AliFlowAnalysisWithNestedLoops::GetPointersForCommonHistograms()
270
271 //================================================================================================================
272
273 void AliFlowAnalysisWithNestedLoops::GetPointersForRAD() 
274 {
275  // Get pointers to objects relevant for relative angle distributions.
276  
277  TList *listRAD = NULL;
278  listRAD = dynamic_cast<TList*>(fHistList->FindObject("Relative Angle Distribution"));
279  if(!listRAD) 
280  {
281   cout<<"WARNING: listRAD is NULL in AFAWNL::GPFRAD() !!!!"<<endl;
282   exit(0); 
283  }  
284
285  TString relativeAngleDistributionName = "fRelativeAngleDistribution";
286  TH1D *relativeAngleDistribution = dynamic_cast<TH1D*>(listRAD->FindObject(relativeAngleDistributionName.Data()));
287  if(relativeAngleDistribution)
288  {
289   this->SetRelativeAngleDistribution(relativeAngleDistribution);  
290  }
291   
292  TString chargeName = "fCharge";
293  TH1D *charge = dynamic_cast<TH1D*>(listRAD->FindObject(chargeName.Data()));
294  if(charge)
295  {
296   this->SetCharge(charge);  
297  }
298
299 } // end of void AliFlowAnalysisWithNestedLoops::GetPointersForRAD()
300
301 //================================================================================================================
302
303 void AliFlowAnalysisWithNestedLoops::GetPointersForMH() 
304 {
305  // Get pointers to objects evaluated with nested loops.
306  
307  TList *listMH = NULL;
308  listMH = dynamic_cast<TList*>(fHistList->FindObject("Mixed Harmonics"));
309  if(!listMH) 
310  {
311   cout<<"WARNING: listMH is NULL in AFAWNL::GPFMH() !!!!"<<endl;
312   exit(0); 
313  }  
314   
315  TString s3pCorrelatorProName = "f3pCorrelatorPro";
316  TProfile *p3pCorrelatorPro = dynamic_cast<TProfile*>(listMH->FindObject(s3pCorrelatorProName.Data()));
317  if(p3pCorrelatorPro)
318  {
319   this->Set3pCorrelatorPro(p3pCorrelatorPro);  
320  } 
321  if(!fEvaluateDifferential3pCorrelator){return;} 
322  TString psdFlag[2] = {"PtSum","PtDiff"};
323  for(Int_t sd=0;sd<2;sd++)
324  {
325   TProfile *p3pCorrelatorVsPtSumDiffDirectPro = dynamic_cast<TProfile*>(listMH->FindObject(Form("f3pCorrelatorDirectVs%s",psdFlag[sd].Data())));
326   if(p3pCorrelatorVsPtSumDiffDirectPro)
327   {
328    this->Set3pCorrelatorVsPtSumDiffDirectPro(p3pCorrelatorVsPtSumDiffDirectPro,sd);  
329   }  
330  } // end of for(Int_t sd=0;sd<2;sd++)
331  
332 } // end of void AliFlowAnalysisWithNestedLoops::GetPointersForMH() 
333
334 //================================================================================================================
335
336 void AliFlowAnalysisWithNestedLoops::WriteHistograms(TString outputFileName)
337 {
338  // Store the final results in output .root file.
339  TFile *output = new TFile(outputFileName.Data(),"RECREATE");
340  fHistList->Write(fHistList->GetName(),TObject::kSingleKey);
341  delete output;
342 }
343
344 //================================================================================================================
345
346 void AliFlowAnalysisWithNestedLoops::WriteHistograms(TDirectoryFile *outputFileName)
347 {
348  // Store the final results in output .root file.
349  fHistList->SetName("cobjNL");
350  fHistList->SetOwner(kTRUE);
351  outputFileName->Add(fHistList);
352  outputFileName->Write(outputFileName->GetName(),TObject::kSingleKey);
353 }
354
355 //================================================================================================================
356
357 void AliFlowAnalysisWithNestedLoops::StoreHarmonic()
358 {
359  // Store harmonic n used in cos[n*(phi1+phi2-2phi3)] and cos[n*(psi1+psi2-2phi3)].
360
361  (fCommonHists->GetHarmonic())->Fill(0.5,fHarmonic);
362
363 } // end of void AliFlowAnalysisWithNestedLoops::StoreHarmonic()
364
365 //================================================================================================================
366
367 void AliFlowAnalysisWithNestedLoops::BookAndNestAllLists()
368 {
369  // Book and nest all list in base list fHistList.
370
371  // Weights:
372  fWeightsList->SetName("Weights");
373  fWeightsList->SetOwner(kTRUE);   
374  fHistList->Add(fWeightsList); 
375  // List for Relative Angle Distribution:
376  fListRAD->SetName("Relative Angle Distribution");
377  fListRAD->SetOwner(kTRUE);   
378  if(fEvaluateNestedLoopsForRAD) fHistList->Add(fListRAD); 
379  // List for Q-cumulants:
380  fListQC->SetName("Q-cumulants");
381  fListQC->SetOwner(kTRUE);   
382  if(fEvaluateNestedLoopsForQC) fHistList->Add(fListQC); 
383  // List for Mixed Harmonics:
384  fListMH->SetName("Mixed Harmonics");
385  fListMH->SetOwner(kTRUE);   
386  if(fEvaluateNestedLoopsForMH) fHistList->Add(fListMH); 
387
388 } // end of void AliFlowAnalysisWithNestedLoops::BookAndNestAllLists()
389
390 //================================================================================================================
391
392 void AliFlowAnalysisWithNestedLoops::BookAndFillProfileHoldingSettings()
393 {
394  // Book profile to hold all analysis settings.
395
396  TString analysisSettingsName = "fAnalysisSettings";
397  fAnalysisSettings = new TProfile(analysisSettingsName.Data(),"Settings for analysis with nested loops",7,0,7);
398  fAnalysisSettings->GetXaxis()->SetLabelSize(0.035);
399  fAnalysisSettings->GetXaxis()->SetBinLabel(1,"Nested loops for RAD?");
400  fAnalysisSettings->Fill(0.5,(Int_t)fEvaluateNestedLoopsForRAD);
401  fAnalysisSettings->GetXaxis()->SetBinLabel(2,"Nested loops for QC?");
402  fAnalysisSettings->Fill(1.5,(Int_t)fEvaluateNestedLoopsForQC);
403  fAnalysisSettings->GetXaxis()->SetBinLabel(3,"Nested loops for MH?");
404  fAnalysisSettings->Fill(2.5,(Int_t)fEvaluateNestedLoopsForMH);
405  fAnalysisSettings->GetXaxis()->SetBinLabel(4,"fHarmonic");
406  fAnalysisSettings->Fill(3.5,(Int_t)fHarmonic);
407  fAnalysisSettings->GetXaxis()->SetBinLabel(5,"Print on the screen?");
408  fAnalysisSettings->Fill(4.5,(Int_t)fPrintOnTheScreen); 
409  fAnalysisSettings->GetXaxis()->SetBinLabel(6,"fOppositeChargesPOI");
410  fAnalysisSettings->Fill(5.5,fOppositeChargesPOI);  
411  fAnalysisSettings->GetXaxis()->SetBinLabel(7,"fEvaluateDifferential3pCorrelator");
412  fAnalysisSettings->Fill(6.5,fEvaluateDifferential3pCorrelator);  
413  fHistList->Add(fAnalysisSettings);
414  
415 } // end of void AliFlowAnalysisWithNestedLoops::BookAndFillProfileHoldingSettings()
416
417 //================================================================================================================
418
419 void AliFlowAnalysisWithNestedLoops::BookCommonHistograms()
420 {
421  // Book common control histograms and common histograms for final results.
422  
423  TString commonHistsName = "AliFlowCommonHistNL";
424  fCommonHists = new AliFlowCommonHist(commonHistsName.Data());
425  fHistList->Add(fCommonHists);  
426  
427 } // end of void AliFlowAnalysisWithNestedLoops::BookCommonHistograms()
428
429 //================================================================================================================
430
431 void AliFlowAnalysisWithNestedLoops::BookEverythingForRAD()
432 {
433  // Book all objects relevant calculation of relative angle distribution.
434  
435  TString relativeAngleDistributionName = "fRelativeAngleDistribution";
436  fRelativeAngleDistribution = new TH1D(relativeAngleDistributionName.Data(),"Relative angle distribution",720,-TMath::TwoPi(),TMath::TwoPi());
437  fRelativeAngleDistribution->GetYaxis()->SetTitle("#frac{dN}{#Delta #phi}"); 
438  fRelativeAngleDistribution->GetXaxis()->SetTitle("#Delta #phi");
439  fListRAD->Add(fRelativeAngleDistribution);
440
441  TString chargeName = "fCharge";
442  fCharge = new TH1D(chargeName.Data(),"Charges",3,0,3);
443  
444  fCharge->GetXaxis()->SetBinLabel(1,"+"); 
445  fCharge->GetXaxis()->SetBinLabel(2,"-"); 
446  fCharge->GetXaxis()->SetBinLabel(3,"rest"); 
447  fListRAD->Add(fCharge);
448
449 } // end fo void AliFlowAnalysisWithNestedLoops::BookEverythingForRAD()
450
451 //================================================================================================================
452
453 void AliFlowAnalysisWithNestedLoops::AccessConstants()
454 {
455  // Access needed common constants from AliFlowCommonConstants.
456  
457  fnBinsPhi = AliFlowCommonConstants::GetMaster()->GetNbinsPhi();
458  fPhiMin = AliFlowCommonConstants::GetMaster()->GetPhiMin();         
459  fPhiMax = AliFlowCommonConstants::GetMaster()->GetPhiMax();
460  if(fnBinsPhi) fPhiBinWidth = (fPhiMax-fPhiMin)/fnBinsPhi;  
461  fnBinsPt = AliFlowCommonConstants::GetMaster()->GetNbinsPt();
462  fPtMin = AliFlowCommonConstants::GetMaster()->GetPtMin();           
463  fPtMax = AliFlowCommonConstants::GetMaster()->GetPtMax();
464  if(fnBinsPt) fPtBinWidth = (fPtMax-fPtMin)/fnBinsPt;  
465  fnBinsEta = AliFlowCommonConstants::GetMaster()->GetNbinsEta();
466  fEtaMin = AliFlowCommonConstants::GetMaster()->GetEtaMin();         
467  fEtaMax = AliFlowCommonConstants::GetMaster()->GetEtaMax();
468  if(fnBinsEta) fEtaBinWidth = (fEtaMax-fEtaMin)/fnBinsEta;  
469  
470 } // end of void AliFlowAnalysisWithNestedLoops::AccessConstants()
471
472 //================================================================================================================
473
474 void AliFlowAnalysisWithNestedLoops::CrossCheckSettings()
475 {
476  // Cross-check if the user settings make sense. 
477  
478  // ...
479  
480 } // end of void AliFlowAnalysisWithNestedLoops::CrossCheckSettings()
481
482 //================================================================================================================
483
484 void AliFlowAnalysisWithNestedLoops::BookAndFillWeightsHistograms()
485 {
486  // Book and fill (by accessing file "weights.root") histograms which hold phi, pt and eta weights.
487
488  if(!fWeightsList)
489  {
490   cout<<"WARNING: fWeightsList is NULL in AFAWNL::BAFWH() !!!!"<<endl;
491   exit(0);  
492  }
493  // Profile to hold flags for weights:   
494  TString fUseParticleWeightsName = "fUseParticleWeightsNL";
495  fUseParticleWeights = new TProfile(fUseParticleWeightsName.Data(),"0 = particle weight not used, 1 = particle weight used ",3,0,3);
496  fUseParticleWeights->SetLabelSize(0.06);
497  (fUseParticleWeights->GetXaxis())->SetBinLabel(1,"w_{#phi}");
498  (fUseParticleWeights->GetXaxis())->SetBinLabel(2,"w_{p_{T}}");
499  (fUseParticleWeights->GetXaxis())->SetBinLabel(3,"w_{#eta}");
500  fUseParticleWeights->Fill(0.5,(Int_t)fUsePhiWeights);
501  fUseParticleWeights->Fill(1.5,(Int_t)fUsePtWeights);
502  fUseParticleWeights->Fill(2.5,(Int_t)fUseEtaWeights);
503  fWeightsList->Add(fUseParticleWeights); 
504  // Phi-weights: 
505  if(fUsePhiWeights)
506  {
507   if(fWeightsList->FindObject("phi_weights"))
508   {
509    fPhiWeights = dynamic_cast<TH1F*>(fWeightsList->FindObject("phi_weights"));
510    if(TMath::Abs(fPhiWeights->GetBinWidth(1)-fPhiBinWidth)>pow(10.,-6.))
511    {
512     cout<<endl;
513     cout<<"WARNING (NL): Inconsistent binning in histograms for phi-weights throughout the code."<<endl;
514     cout<<endl;
515     exit(0);
516    }
517   } else 
518     {
519      cout<<"WARNING (NL): fWeightsList->FindObject(\"phi_weights\") is NULL in AFAWNL::BAFWH() !!!!"<<endl;
520      exit(0);
521     }
522  } // end of if(fUsePhiWeights)
523  // Pt-weights:
524  if(fUsePtWeights) 
525  {
526   if(fWeightsList->FindObject("pt_weights"))
527   {
528    fPtWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("pt_weights"));
529    if(TMath::Abs(fPtWeights->GetBinWidth(1)-fPtBinWidth)>pow(10.,-6.))
530    {
531     cout<<endl;
532     cout<<"WARNING (NL): Inconsistent binning in histograms for pt-weights throughout the code."<<endl;
533     cout<<endl;
534     exit(0);
535    }
536   } else 
537     {
538      cout<<"WARNING (NL): fWeightsList->FindObject(\"pt_weights\") is NULL in AFAWNL::BAFWH() !!!!"<<endl;
539      exit(0);
540     }
541  } // end of if(fUsePtWeights)    
542  // Eta-weights:
543  if(fUseEtaWeights) 
544  {
545   if(fWeightsList->FindObject("eta_weights"))
546   {
547    fEtaWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("eta_weights"));
548    if(TMath::Abs(fEtaWeights->GetBinWidth(1)-fEtaBinWidth)>pow(10.,-6.))
549    {
550     cout<<endl;
551     cout<<"WARNING (NL): Inconsistent binning in histograms for eta-weights throughout the code."<<endl;
552     cout<<endl;
553     exit(0);
554    }
555   } else 
556     {
557      cout<<"WARNING: fUseEtaWeights && fWeightsList->FindObject(\"eta_weights\") is NULL in AFAWNL::BAFWH() !!!!"<<endl;
558      exit(0);
559     }
560  } // end of if(fUseEtaWeights)
561  
562 } // end of AliFlowAnalysisWithNestedLoops::BookAndFillWeightsHistograms()
563
564 //================================================================================================================
565
566 void AliFlowAnalysisWithNestedLoops::CheckPointersUsedInMake()
567 {
568  // Check pointers used in method Make().
569                         
570  if(fEvaluateNestedLoopsForRAD) CheckPointersForRAD("Make");
571  if(fEvaluateNestedLoopsForMH) CheckPointersForMH("Make"); 
572                                                                                                                                                                                                                                                                                                                                    
573 } // end of AliFlowAnalysisWithNestedLoops::CheckPointersUsedInMake()
574
575 //================================================================================================================
576
577 void AliFlowAnalysisWithNestedLoops::CheckPointersUsedInFinish()
578 {
579  // Check pointers used in method Finish().
580  
581  if(fEvaluateNestedLoopsForRAD) CheckPointersForRAD("Finish");
582  if(fEvaluateNestedLoopsForMH) CheckPointersForMH("Finish"); 
583                                                                                                                                                                                                                                                                                                                                    
584 } // end of AliFlowAnalysisWithNestedLoops::CheckPointersUsedInFinish()
585
586 //================================================================================================================
587
588 void AliFlowAnalysisWithNestedLoops::CheckPointersForRAD(TString where)
589 {
590  // Check pointers relevant for calculation of relative angle distribution.
591  
592  if(!fRelativeAngleDistribution)
593  {
594   cout<<endl;
595   cout<<" WARNING (NL): fRelativeAngleDistribution is NULL in "<<where.Data()<<"() !!!!"<<endl;
596   cout<<endl;
597   exit(0); 
598  }
599  
600  if(strcmp(where.Data(),"Make") == 0)
601  {
602   // Check pointers used only in method Make():
603   // ...
604  }
605  else if(strcmp(where.Data(),"Finish") == 0)
606  {
607   // Check pointers used only in method Finish():
608   // ...
609  }
610
611 } // end of void AliFlowAnalysisWithNestedLoops::CheckPointersForRAD(TString where)
612
613 //================================================================================================================
614
615 void AliFlowAnalysisWithNestedLoops::CheckPointersForMH(TString where)
616 {
617  // Check pointers relevant for calculation of mixed harmonics.
618  
619  if(strcmp(where.Data(),"Make") == 0)
620  {
621   // Check pointers used only in method Make():
622   if(!f3pCorrelatorPro)
623   {
624    cout<<endl;
625    cout<<" WARNING (NL): f3pCorrelatorPro is NULL in Make() !!!!"<<endl;
626    cout<<endl;
627    exit(0); 
628   }
629   if(!fEvaluateDifferential3pCorrelator){return;}
630   for(Int_t sd=0;sd<2;sd++)
631   {
632    if(!(f3pCorrelatorVsPtSumDiffDirectPro[sd]))
633    {
634     cout<<endl;
635     cout<<" WARNING (NL): "<<Form("f3pCorrelatorVsPtSumDiffDirectPro[%d]",sd)<<" is NULL in Make() !!!!"<<endl;
636     cout<<endl;
637     exit(0);   
638    } 
639   } // end of for(Int_t sd=0;sd<2;sd++)
640  } // if(strcmp(where.Data(),"Make") == 0)
641  else if(strcmp(where.Data(),"Finish") == 0)
642  {
643   // Check pointers used only in method Finish():
644   if(!f3pCorrelatorPro)
645   {
646    cout<<endl;
647    cout<<" WARNING (NL): f3pCorrelatorPro is NULL in Finish() !!!!"<<endl;
648    cout<<endl;
649    exit(0); 
650   }
651  } // else if(strcmp(where.Data(),"Finish") == 0)
652
653 } // end of void AliFlowAnalysisWithNestedLoops::CheckPointersForMH(TString where)
654
655 //================================================================================================================
656
657 void AliFlowAnalysisWithNestedLoops::AccessSettings()
658 {
659  // Access the settings for analysis.
660   
661  fEvaluateNestedLoopsForRAD = (Bool_t)fAnalysisSettings->GetBinContent(1);
662  fEvaluateNestedLoopsForQC = (Bool_t)fAnalysisSettings->GetBinContent(2);
663  fEvaluateNestedLoopsForMH = (Bool_t)fAnalysisSettings->GetBinContent(3);
664  fHarmonic = (Int_t)fAnalysisSettings->GetBinContent(4);
665  fPrintOnTheScreen = (Bool_t)fAnalysisSettings->GetBinContent(5);
666  fOppositeChargesPOI = (Bool_t)fAnalysisSettings->GetBinContent(6);
667  fEvaluateDifferential3pCorrelator = (Bool_t)fAnalysisSettings->GetBinContent(7);
668                                                                                                                                                                                                                                                                                                                                    
669 } // end of AliFlowAnalysisWithNestedLoops::AccessSettings()
670
671 //================================================================================================================
672
673 void AliFlowAnalysisWithNestedLoops::InitializeArraysForMH()
674 {
675  // Initialize arrays mixed harmonics calculations.
676  
677  for(Int_t sd=0;sd<2;sd++) // sum or difference
678  {
679   f3pCorrelatorVsPtSumDiffDirectPro[sd] = NULL;
680  }
681   
682 } // end of AliFlowAnalysisWithNestedLoops::InitializeArraysForMH()
683
684 //================================================================================================================  
685
686 void AliFlowAnalysisWithNestedLoops::BookEverythingForMH()
687 {
688  // Book all objects relevant for mixed harmonics.
689  
690  if(fEvaluateNestedLoopsForMH)
691  {  
692   TString s3pCorrelatorProName = "f3pCorrelatorPro";
693   f3pCorrelatorPro = new TProfile(s3pCorrelatorProName.Data(),"",1,0,1);
694   f3pCorrelatorPro->SetStats(kFALSE);
695   f3pCorrelatorPro->GetXaxis()->SetLabelOffset(0.01);
696   f3pCorrelatorPro->GetXaxis()->SetLabelSize(0.05);
697   if(fHarmonic == 1)
698   {
699    f3pCorrelatorPro->GetXaxis()->SetBinLabel(1,"#LT#LTcos(#phi_{1}+#phi_{2}-2#phi_{3})#GT#GT");
700   } else
701     {
702      f3pCorrelatorPro->GetXaxis()->SetBinLabel(1,Form("#LT#LTcos[%i(#phi_{1}+#phi_{2}-2#phi_{3})]#GT#GT",fHarmonic));
703     }
704   fListMH->Add(f3pCorrelatorPro);  
705   
706   if(fEvaluateDifferential3pCorrelator)
707   {
708    TString psdFlag[2] = {"PtSum","PtDiff"};
709    TString psdTitleFlag[2] = {"(p_{t,1}+p_{t,2})/2","#left|p_{t,1}-p_{t,2}#right|"};
710    //TString s3pCorrelatorVsPtSumDiffDirectProName = "f3pCorrelatorVsPtSumDiffDirectPro";
711    for(Int_t sd=0;sd<2;sd++)
712    {
713     // to be improved: hardwired ,fnBinsPt,0.,fPtMax):
714     f3pCorrelatorVsPtSumDiffDirectPro[sd] = new TProfile(Form("f3pCorrelatorDirectVs%s",psdFlag[sd].Data()),"",fnBinsPt,0.,fPtMax);
715     //f3pCorrelatorVsPtSumDiffDirectPro[sd]->SetLabelSize(0.05);
716     //f3pCorrelatorVsPtSumDiffDirectPro[sd]->SetMarkerStyle(25);
717     f3pCorrelatorVsPtSumDiffDirectPro[sd]->GetXaxis()->SetTitle(psdTitleFlag[sd].Data());
718     fListMH->Add(f3pCorrelatorVsPtSumDiffDirectPro[sd]);
719    }
720   } // end of if(fEvaluateDifferential3pCorrelator)
721  } // end of if(fEvaluateNestedLoopsForMH)
722
723 } // end of AliFlowAnalysisWithNestedLoops::BookEverythingForMH()
724
725 //================================================================================================================
726
727 void AliFlowAnalysisWithNestedLoops::EvaluateNestedLoopsForRAD(AliFlowEventSimple *anEvent)
728 {
729  // Evaluate nested loops needed for calculation of relative angle distribution.
730  
731  Double_t dPhi1=0., dPhi2=0.; // azimuthal angles in the laboratory frame
732  AliFlowTrackSimple *aftsTrack = NULL; // simple track
733   
734  // Loop over data and store for each distinct pair phi1-phi2 in fRelativeAngleDistribution:
735  Int_t nPrim = anEvent->NumberOfTracks();  // nPrim = total number of primary tracks, i.e. nPrim = nRP + nPOI + rest, where:
736                                            // nRP   = # of particles used to determine the reaction plane ("Reference Particles");
737                                            // nPOI  = # of particles of interest for a detailed flow analysis ("Particles of Interest");
738                                            // rest  = # of particles which are not niether RPs nor POIs.  
739  // Start nested loops over data:
740  for(Int_t i=0;i<nPrim;i++) 
741  { 
742   aftsTrack=anEvent->GetTrack(i);
743   if(aftsTrack)
744   {
745    if(!aftsTrack->InRPSelection()) continue; // consider only tracks which are RPs 
746    dPhi1 = aftsTrack->Phi();
747    for(Int_t j=0;j<nPrim;j++) 
748    { 
749     if(j==i) continue; // eliminating trivial contribution from autocorrelation
750     aftsTrack=anEvent->GetTrack(j);
751     if(aftsTrack)
752     {
753      if(!aftsTrack->InRPSelection()) continue; // consider only tracks which are RPs 
754      dPhi2 = aftsTrack->Phi();
755      // Fill the histogram:
756      fRelativeAngleDistribution->Fill(dPhi1-dPhi2);
757     }
758    } // end of for(Int_t j=0;j<nPrim;j++)
759   } else // to if(aftsTrack)
760     {
761      cout<<endl;
762      cout<<" WARNING (NL): No particle! (i.e. aftsTrack is a NULL pointer in AFAWNL::Make().)"<<endl;
763      cout<<endl;       
764     }
765  } // end of for(Int_t i=0;i<nPrim;i++) 
766  
767 } // end of void AliFlowAnalysisWithNestedLoops::EvaluateNestedLoopsForRAD(AliFlowEventSimple *anEvent)
768
769 //================================================================================================================
770
771 void AliFlowAnalysisWithNestedLoops::EvaluateNestedLoopsForMH(AliFlowEventSimple *anEvent)
772 {
773  // Evaluate nested loops needed for mixed harmonics.
774  // Remark: phi labels the azimuthal angle of RP particle and psi labels azimuthal angle of POI particle.
775   
776  Int_t nPrim = anEvent->NumberOfTracks(); 
777  Int_t nRP = anEvent->GetEventNSelTracksRP(); 
778  AliFlowTrackSimple *aftsTrack = NULL;
779  Double_t phi1=0.,phi2=0.,phi3=0.; // azimuthal angles of RPs
780  Double_t psi1=0.,psi2=0.; // azimuthal angles of POIs
781  Int_t charge1=0,charge2=0; // charge of POIs
782  Double_t pt1=0.,pt2=0.; // transverse momenta of POIs
783  Int_t n = fHarmonic; 
784  
785  // Evaluting correlator cos[n(phi1+phi2-2*phi3)] with three nested loops:
786  if(nRP>=3)
787  {
788   for(Int_t i1=0;i1<nPrim;i1++)
789   {
790    aftsTrack=anEvent->GetTrack(i1);
791    if(!(aftsTrack->InRPSelection())) continue;
792    phi1 = aftsTrack->Phi();  
793    for(Int_t i2=0;i2<nPrim;i2++)
794    {
795     if(i2==i1) continue;
796     aftsTrack = anEvent->GetTrack(i2);
797     if(!(aftsTrack->InRPSelection())) continue;
798     phi2 = aftsTrack->Phi();
799     for(Int_t i3=0;i3<nPrim;i3++)
800     {
801      if(i3==i1||i3==i2) continue;
802      aftsTrack=anEvent->GetTrack(i3);
803      if(!(aftsTrack->InRPSelection())) continue;
804      phi3 = aftsTrack->Phi();
805      f3pCorrelatorPro->Fill(0.5,cos(n*(phi1+phi2-2.*phi3)),1.);
806     } // end of for(Int_t i3=0;i3<nPrim;i3++)  
807    } // end of for(Int_t i2=0;i2<nPrim;i2++)  
808   } // end of for(Int_t i1=0;i1<nPrim;i1++)
809  }
810
811  // Evaluting correlator cos[n(psi1+psi2-2*phi3)] with three nested loops:
812  if(!fEvaluateDifferential3pCorrelator){return;}
813  for(Int_t i1=0;i1<nPrim;i1++)
814  {
815   aftsTrack=anEvent->GetTrack(i1);
816   if(!(aftsTrack->InPOISelection())){continue;}
817   psi1 = aftsTrack->Phi();  
818   pt1 = aftsTrack->Pt();     
819   charge1 = aftsTrack->Charge();     
820   for(Int_t i2=0;i2<nPrim;i2++)
821   {
822    if(i2==i1){continue;}
823    aftsTrack = anEvent->GetTrack(i2);
824    if(!(aftsTrack->InPOISelection())){continue;}
825    psi2 = aftsTrack->Phi();
826    pt2 = aftsTrack->Pt();
827    charge2 = aftsTrack->Charge();     
828    if(fOppositeChargesPOI && charge1 == charge2){continue;}
829    for(Int_t i3=0;i3<nPrim;i3++)
830    {
831     if(i3==i1||i3==i2){continue;}
832     aftsTrack=anEvent->GetTrack(i3);
833     if(!(aftsTrack->InRPSelection())){continue;}
834     phi3 = aftsTrack->Phi();
835     // Evaluate and store differential correlator cos[n(psi1+psi2-2*phi3)]:
836     Double_t ptSum = (pt1+pt2)/2.;
837     Double_t ptDiff = TMath::Abs(pt1-pt2);
838     Double_t diff3pCorrelator = TMath::Cos(n*(psi1+psi2-2.*phi3));
839     f3pCorrelatorVsPtSumDiffDirectPro[0]->Fill(ptSum,diff3pCorrelator,1.);
840     f3pCorrelatorVsPtSumDiffDirectPro[1]->Fill(ptDiff,diff3pCorrelator,1.);
841    } // end of for(Int_t i3=0;i3<nPrim;i3++)  
842   } // end of for(Int_t i2=0;i2<nPrim;i2++)  
843  } // end of for(Int_t i1=0;i1<nPrim;i1++)
844
845 } // end of void AliFlowAnalysisWithNestedLoops::EvaluateNestedLoopsForMH(AliFlowEventSimple *anEvent)
846
847 //================================================================================================================
848
849 void AliFlowAnalysisWithNestedLoops::PrintOnTheScreen()
850 {
851  // Print on the screen.
852  
853  cout<<endl;
854  cout<<"****************************************************"<<endl;
855  cout<<"****************************************************"<<endl;
856  cout<<"                  Nested Loops                 "<<endl; 
857  cout<<endl;
858  
859  if(fEvaluateNestedLoopsForRAD) 
860  {
861   cout<<"  Evaluated for relative angle distribution."<<endl;
862  }
863  
864  if(fEvaluateNestedLoopsForMH) 
865  {
866   cout<<"  Evaluated for mixed harmonics:"<<endl;
867   if(fHarmonic != 1)
868   {
869    cout<<"   cos["<<fHarmonic<<"(phi1+phi2-2phi3)] = "<<f3pCorrelatorPro->GetBinContent(1)<<" +/- " <<f3pCorrelatorPro->GetBinError(1)<<endl;
870   } else
871     {
872      cout<<"   cos(phi1+phi2-2phi3) = "<<f3pCorrelatorPro->GetBinContent(1)<<" +/- " <<f3pCorrelatorPro->GetBinError(1)<<endl;
873     }  
874   if(fEvaluateDifferential3pCorrelator)
875   {
876    cout<<"  Evaluated also for differential 3p correlator "<<endl;
877    if(fHarmonic != 1)
878    {
879     cout<<"   cos["<<fHarmonic<<"(psi1+psi2-2phi3)]. "<<endl;
880    } else
881      {  
882       cout<<"   cos(psi1+psi2-2phi3). "<<endl; 
883      }  
884   } // end of if(fEvaluateDifferential3pCorrelator)
885  } // end of if(fEvaluateNestedLoopsForMH) 
886  
887  if(!fEvaluateNestedLoopsForRAD && !fEvaluateNestedLoopsForMH)
888  {
889   cout<<"  Not evaluated."<<endl;
890  }
891  cout<<endl;
892  cout<<"****************************************************"<<endl;
893  cout<<"****************************************************"<<endl;
894  cout<<endl;
895  
896 } // end of void AliFlowAnalysisWithNestedLoops::PrintOnTheScreen()
897
898