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