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