]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowCommon/AliFlowEventSimple.cxx
rulechecker fixes from Mikolaj
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowEventSimple.cxx
CommitLineData
f1d945a1 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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
929098e4 16/*****************************************************************
17 AliFlowEventSimple: A simple event
18 for flow analysis
19
20 origin: Naomi van der Kolk (kolk@nikhef.nl)
21 Ante Bilandzic (anteb@nikhef.nl)
22 Raimond Snellings (Raimond.Snellings@nikhef.nl)
23 mods: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch)
24*****************************************************************/
25
f1d945a1 26#include "Riostream.h"
27#include "TObjArray.h"
26c4cbb9 28#include "TFile.h"
03a02aca 29#include "TList.h"
929098e4 30#include "TTree.h"
31#include "TParticle.h"
f1d945a1 32#include "TMath.h"
26c4cbb9 33#include "TH1F.h"
34#include "TH1D.h"
bc231a12 35#include "TF1.h"
26c4cbb9 36#include "TProfile.h"
929098e4 37#include "TParameter.h"
c076fda8 38#include "TBrowser.h"
f1d945a1 39#include "AliFlowVector.h"
40#include "AliFlowTrackSimple.h"
929098e4 41#include "AliFlowTrackSimpleCuts.h"
701f71c1 42#include "AliFlowEventSimple.h"
7382279b 43#include "TRandom.h"
f1d945a1 44
f1d945a1 45ClassImp(AliFlowEventSimple)
46
47//-----------------------------------------------------------------------
46bec39c 48AliFlowEventSimple::AliFlowEventSimple():
49 fTrackCollection(NULL),
85d2ee8d 50 fReferenceMultiplicity(0),
46bec39c 51 fNumberOfTracks(0),
bc231a12 52 fNumberOfRPs(0),
7183fe85 53 fMCReactionPlaneAngle(0.),
929098e4 54 fMCReactionPlaneAngleIsSet(kFALSE),
bc231a12 55 fAfterBurnerPrecision(0.001),
9fa64edc 56 fUserModified(kFALSE),
c076fda8 57 fNumberOfTracksWrap(NULL),
bc231a12 58 fNumberOfRPsWrap(NULL),
a12990bb 59 fMCReactionPlaneAngleWrap(NULL)
46bec39c 60{
61 cout << "AliFlowEventSimple: Default constructor to be used only by root for io" << endl;
62}
63
64//-----------------------------------------------------------------------
9fa64edc 65AliFlowEventSimple::AliFlowEventSimple( Int_t n,
66 ConstructionMethod method,
bc231a12 67 TF1* ptDist,
68 Double_t phiMin,
69 Double_t phiMax,
70 Double_t etaMin,
71 Double_t etaMax):
9fa64edc 72 fTrackCollection(new TObjArray(n)),
a1c43d26 73 fReferenceMultiplicity(0),
bc231a12 74 fNumberOfTracks(0),
75 fNumberOfRPs(0),
76 fMCReactionPlaneAngle(0.),
77 fMCReactionPlaneAngleIsSet(kFALSE),
78 fAfterBurnerPrecision(0.001),
9fa64edc 79 fUserModified(kFALSE),
bc231a12 80 fNumberOfTracksWrap(NULL),
81 fNumberOfRPsWrap(NULL),
82 fMCReactionPlaneAngleWrap(NULL)
83{
9fa64edc 84 //ctor
85 // if second argument is set to AliFlowEventSimple::kGenerate
86 // it generates n random tracks with given Pt distribution
87 // (a sane default is provided), phi and eta are uniform
88
89 if (method==kGenerate)
90 Generate(n,ptDist,phiMin,phiMax,etaMin,etaMax);
f1d945a1 91}
92
93//-----------------------------------------------------------------------
e35ddff0 94AliFlowEventSimple::AliFlowEventSimple(const AliFlowEventSimple& anEvent):
bc231a12 95 TObject(anEvent),
96 fTrackCollection((TObjArray*)(anEvent.fTrackCollection)->Clone()),
85d2ee8d 97 fReferenceMultiplicity(anEvent.fReferenceMultiplicity),
e35ddff0 98 fNumberOfTracks(anEvent.fNumberOfTracks),
bc231a12 99 fNumberOfRPs(anEvent.fNumberOfRPs),
a12990bb 100 fMCReactionPlaneAngle(anEvent.fMCReactionPlaneAngle),
929098e4 101 fMCReactionPlaneAngleIsSet(anEvent.fMCReactionPlaneAngleIsSet),
bc231a12 102 fAfterBurnerPrecision(anEvent.fAfterBurnerPrecision),
9fa64edc 103 fUserModified(anEvent.fUserModified),
c076fda8 104 fNumberOfTracksWrap(anEvent.fNumberOfTracksWrap),
bc231a12 105 fNumberOfRPsWrap(anEvent.fNumberOfRPsWrap),
a12990bb 106 fMCReactionPlaneAngleWrap(anEvent.fMCReactionPlaneAngleWrap)
f1d945a1 107{
929098e4 108 //copy constructor
f1d945a1 109}
110
111//-----------------------------------------------------------------------
e35ddff0 112AliFlowEventSimple& AliFlowEventSimple::operator=(const AliFlowEventSimple& anEvent)
f1d945a1 113{
124fb262 114 //assignment operator
701f71c1 115 if (fTrackCollection) fTrackCollection->Delete();
124fb262 116 delete fTrackCollection;
bc231a12 117 fTrackCollection = (TObjArray*)(anEvent.fTrackCollection)->Clone(); //deep copy
85d2ee8d 118 fReferenceMultiplicity = anEvent.fReferenceMultiplicity;
e35ddff0 119 fNumberOfTracks = anEvent.fNumberOfTracks;
bc231a12 120 fNumberOfRPs = anEvent.fNumberOfRPs;
a12990bb 121 fMCReactionPlaneAngle = anEvent.fMCReactionPlaneAngle;
929098e4 122 fMCReactionPlaneAngleIsSet = anEvent.fMCReactionPlaneAngleIsSet;
bc231a12 123 fAfterBurnerPrecision = anEvent.fAfterBurnerPrecision;
9fa64edc 124 fUserModified=anEvent.fUserModified;
929098e4 125 fNumberOfTracksWrap = anEvent.fNumberOfTracksWrap;
bc231a12 126 fNumberOfRPsWrap = anEvent.fNumberOfRPsWrap;
a12990bb 127 fMCReactionPlaneAngleWrap=anEvent.fMCReactionPlaneAngleWrap;
f1d945a1 128 return *this;
f1d945a1 129}
130
929098e4 131//-----------------------------------------------------------------------
f1d945a1 132AliFlowEventSimple::~AliFlowEventSimple()
133{
134 //destructor
929098e4 135 if (fTrackCollection) fTrackCollection->Delete();
136 delete fTrackCollection;
7d27a354 137 delete fNumberOfTracksWrap;
138 delete fNumberOfRPsWrap;
139 delete fMCReactionPlaneAngleWrap;
f1d945a1 140}
141
bc231a12 142//-----------------------------------------------------------------------
143void AliFlowEventSimple::Generate(Int_t nParticles,
6e027e29 144 TF1* ptDist,
145 Double_t phiMin,
146 Double_t phiMax,
147 Double_t etaMin,
148 Double_t etaMax)
bc231a12 149{
150 //generate nParticles random tracks uniform in phi and eta
151 //according to the specified pt distribution
6e027e29 152 if (!ptDist)
153 {
154 static TF1 ptdistribution("ptSpectra","x*TMath::Exp(-pow(0.13957*0.13957+x*x,0.5)/0.4)",0.1,10.);
155 ptDist=&ptdistribution;
156 }
9fa64edc 157
bc231a12 158 for (Int_t i=0; i<nParticles; i++)
159 {
701f71c1 160 AliFlowTrackSimple* track = new AliFlowTrackSimple();
161 track->SetPhi( gRandom->Uniform(phiMin,phiMax) );
162 track->SetEta( gRandom->Uniform(etaMin,etaMax) );
163 track->SetPt( ptDist->GetRandom() );
164 track->SetCharge( (gRandom->Uniform()-0.5<0)?-1:1 );
165 AddTrack(track);
bc231a12 166 }
6e027e29 167 fMCReactionPlaneAngle=gRandom->Uniform(0.0,TMath::TwoPi());
9fa64edc 168 fMCReactionPlaneAngleIsSet=kTRUE;
169 SetUserModified();
bc231a12 170}
171
929098e4 172//-----------------------------------------------------------------------
f1d945a1 173AliFlowTrackSimple* AliFlowEventSimple::GetTrack(Int_t i)
174{
175 //get track i from collection
7382279b 176 if (i>=fNumberOfTracks) return NULL;
124fb262 177 AliFlowTrackSimple* pTrack = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i)) ;
e35ddff0 178 return pTrack;
f1d945a1 179}
180
7382279b 181//-----------------------------------------------------------------------
182void AliFlowEventSimple::AddTrack( AliFlowTrackSimple* track )
183{
7d27a354 184 //add a track, delete the old one if necessary
185 if (fNumberOfTracks < fTrackCollection->GetEntriesFast())
186 {
187 TObject* o = fTrackCollection->At(fNumberOfTracks);
188 if (o) delete o;
189 }
190 fTrackCollection->AddAtAndExpand(track,fNumberOfTracks);
7382279b 191 fNumberOfTracks++;
192}
193
929098e4 194//-----------------------------------------------------------------------
195AliFlowVector AliFlowEventSimple::GetQ(Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
f1d945a1 196{
929098e4 197 // calculate Q-vector in harmonic n without weights (default harmonic n=2)
e35ddff0 198 Double_t dQX = 0.;
199 Double_t dQY = 0.;
200 AliFlowVector vQ;
201 vQ.Set(0.,0.);
929098e4 202
9825d4a9 203 Int_t iOrder = n;
8eca5d19 204 Double_t sumOfWeights = 0.;
44e060e0 205 Double_t dPhi = 0.;
206 Double_t dPt = 0.;
207 Double_t dEta = 0.;
208 Double_t dWeight = 1.;
929098e4 209
26c4cbb9 210 AliFlowTrackSimple* pTrack = NULL;
929098e4 211
44e060e0 212 Int_t nBinsPhi = 0;
213 Double_t dBinWidthPt = 0.;
214 Double_t dPtMin = 0.;
215 Double_t dBinWidthEta = 0.;
216 Double_t dEtaMin = 0.;
929098e4 217
44e060e0 218 Double_t wPhi = 1.; // weight Phi
219 Double_t wPt = 1.; // weight Pt
220 Double_t wEta = 1.; // weight Eta
929098e4 221
03a02aca 222 TH1F *phiWeights = NULL;
ae733b3b 223 TH1D *ptWeights = NULL;
03a02aca 224 TH1D *etaWeights = NULL;
929098e4 225
03a02aca 226 if(weightsList)
26c4cbb9 227 {
929098e4 228 if(usePhiWeights)
229 {
230 phiWeights = dynamic_cast<TH1F *>(weightsList->FindObject("phi_weights"));
231 if(phiWeights) nBinsPhi = phiWeights->GetNbinsX();
232 }
233 if(usePtWeights)
03a02aca 234 {
929098e4 235 ptWeights = dynamic_cast<TH1D *>(weightsList->FindObject("pt_weights"));
236 if(ptWeights)
237 {
238 dBinWidthPt = ptWeights->GetBinWidth(1); // assuming that all bins have the same width
239 dPtMin = (ptWeights->GetXaxis())->GetXmin();
240 }
241 }
242 if(useEtaWeights)
03a02aca 243 {
929098e4 244 etaWeights = dynamic_cast<TH1D *>(weightsList->FindObject("eta_weights"));
245 if(etaWeights)
246 {
247 dBinWidthEta = etaWeights->GetBinWidth(1); // assuming that all bins have the same width
248 dEtaMin = (etaWeights->GetXaxis())->GetXmin();
249 }
250 }
03a02aca 251 } // end of if(weightsList)
929098e4 252
253 // loop over tracks
254 for(Int_t i=0; i<fNumberOfTracks; i++)
26c4cbb9 255 {
124fb262 256 pTrack = (AliFlowTrackSimple*)fTrackCollection->At(i);
929098e4 257 if(pTrack)
f1d945a1 258 {
929098e4 259 if(pTrack->InRPSelection())
260 {
261 dPhi = pTrack->Phi();
262 dPt = pTrack->Pt();
263 dEta = pTrack->Eta();
701f71c1 264 dWeight = pTrack->Weight();
929098e4 265
266 // determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
267 if(phiWeights && nBinsPhi)
268 {
269 wPhi = phiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*nBinsPhi/TMath::TwoPi())));
270 }
271 // determine v'(pt) weight:
272 if(ptWeights && dBinWidthPt)
273 {
274 wPt=ptWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-dPtMin)/dBinWidthPt)));
275 }
276 // determine v'(eta) weight:
277 if(etaWeights && dBinWidthEta)
278 {
279 wEta=etaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-dEtaMin)/dBinWidthEta)));
280 }
281
282 // building up the weighted Q-vector:
44e060e0 283 dQX += dWeight*wPhi*wPt*wEta*TMath::Cos(iOrder*dPhi);
284 dQY += dWeight*wPhi*wPt*wEta*TMath::Sin(iOrder*dPhi);
929098e4 285
286 // weighted multiplicity:
8eca5d19 287 sumOfWeights += dWeight*wPhi*wPt*wEta;
929098e4 288
289 } // end of if (pTrack->InRPSelection())
290 } // end of if (pTrack)
291 else
292 {
293 cerr << "no particle!!!"<<endl;
294 }
ae733b3b 295 } // loop over particles
929098e4 296
e35ddff0 297 vQ.Set(dQX,dQY);
8eca5d19 298 vQ.SetMult(sumOfWeights);
929098e4 299
e35ddff0 300 return vQ;
929098e4 301
5fef318d 302}
303
929098e4 304//-----------------------------------------------------------------------
305void AliFlowEventSimple::Get2Qsub(AliFlowVector* Qarray, Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
395fadba 306{
929098e4 307
308 // calculate Q-vector in harmonic n without weights (default harmonic n=2)
395fadba 309 Double_t dQX = 0.;
310 Double_t dQY = 0.;
929098e4 311
395fadba 312 Int_t iOrder = n;
8eca5d19 313 Double_t sumOfWeights = 0.;
395fadba 314 Double_t dPhi = 0.;
315 Double_t dPt = 0.;
316 Double_t dEta = 0.;
44e060e0 317 Double_t dWeight = 1.;
929098e4 318
395fadba 319 AliFlowTrackSimple* pTrack = NULL;
929098e4 320
44e060e0 321 Int_t iNbinsPhiSub0 = 0;
322 Int_t iNbinsPhiSub1 = 0;
395fadba 323 Double_t dBinWidthPt = 0.;
324 Double_t dPtMin = 0.;
325 Double_t dBinWidthEta= 0.;
326 Double_t dEtaMin = 0.;
929098e4 327
328 Double_t dWphi = 1.; // weight Phi
329 Double_t dWpt = 1.; // weight Pt
330 Double_t dWeta = 1.; // weight Eta
331
44e060e0 332 TH1F* phiWeightsSub0 = NULL;
333 TH1F* phiWeightsSub1 = NULL;
29195b69 334 TH1D* ptWeights = NULL;
335 TH1D* etaWeights = NULL;
929098e4 336
337 if(weightsList)
338 {
339 if(usePhiWeights)
340 {
44e060e0 341 phiWeightsSub0 = dynamic_cast<TH1F *>(weightsList->FindObject("phi_weights_sub0"));
44e060e0 342 if(phiWeightsSub0) {
13ff9ccd 343 iNbinsPhiSub0 = phiWeightsSub0->GetNbinsX();
44e060e0 344 }
13ff9ccd 345 phiWeightsSub1 = dynamic_cast<TH1F *>(weightsList->FindObject("phi_weights_sub1"));
44e060e0 346 if(phiWeightsSub1) {
13ff9ccd 347 iNbinsPhiSub1 = phiWeightsSub1->GetNbinsX();
29195b69 348 }
929098e4 349 }
350 if(usePtWeights)
351 {
29195b69 352 ptWeights = dynamic_cast<TH1D *>(weightsList->FindObject("pt_weights"));
929098e4 353 if(ptWeights)
354 {
355 dBinWidthPt = ptWeights->GetBinWidth(1); // assuming that all bins have the same width
356 dPtMin = (ptWeights->GetXaxis())->GetXmin();
357 }
358 }
359 if(useEtaWeights)
360 {
361 etaWeights = dynamic_cast<TH1D *>(weightsList->FindObject("eta_weights"));
362 if(etaWeights)
363 {
364 dBinWidthEta = etaWeights->GetBinWidth(1); // assuming that all bins have the same width
365 dEtaMin = (etaWeights->GetXaxis())->GetXmin();
366 }
367 }
395fadba 368 } // end of if(weightsList)
929098e4 369
b125a454 370 //loop over the two subevents
929098e4 371 for (Int_t s=0; s<2; s++)
372 {
373 // loop over tracks
374 for(Int_t i=0; i<fNumberOfTracks; i++)
375 {
124fb262 376 pTrack = (AliFlowTrackSimple*)fTrackCollection->At(i);
929098e4 377 if(pTrack)
378 {
379 if(pTrack->InRPSelection())
380 {
381 if (pTrack->InSubevent(s))
382 {
44e060e0 383 dPhi = pTrack->Phi();
384 dPt = pTrack->Pt();
385 dEta = pTrack->Eta();
386 dWeight = pTrack->Weight();
929098e4 387
388 // determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
13ff9ccd 389 //subevent 0
390 if(s == 0) {
391 if(phiWeightsSub0 && iNbinsPhiSub0) {
392 Int_t phiBin = 1+(Int_t)(TMath::Floor(dPhi*iNbinsPhiSub0/TMath::TwoPi()));
393 //use the phi value at the center of the bin
394 dPhi = phiWeightsSub0->GetBinCenter(phiBin);
395 dWphi = phiWeightsSub0->GetBinContent(phiBin);
396 }
397 }
398 //subevent 1
399 else if (s == 1) {
400 if(phiWeightsSub1 && iNbinsPhiSub1) {
401 Int_t phiBin = 1+(Int_t)(TMath::Floor(dPhi*iNbinsPhiSub1/TMath::TwoPi()));
402 //use the phi value at the center of the bin
403 dPhi = phiWeightsSub1->GetBinCenter(phiBin);
404 dWphi = phiWeightsSub1->GetBinContent(phiBin);
44e060e0 405 }
406 }
13ff9ccd 407
929098e4 408 // determine v'(pt) weight:
409 if(ptWeights && dBinWidthPt)
410 {
411 dWpt=ptWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-dPtMin)/dBinWidthPt)));
412 }
44e060e0 413
929098e4 414 // determine v'(eta) weight:
415 if(etaWeights && dBinWidthEta)
416 {
417 dWeta=etaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-dEtaMin)/dBinWidthEta)));
418 }
419
420 // building up the weighted Q-vector:
44e060e0 421 dQX += dWeight*dWphi*dWpt*dWeta*TMath::Cos(iOrder*dPhi);
422 dQY += dWeight*dWphi*dWpt*dWeta*TMath::Sin(iOrder*dPhi);
929098e4 423
424 // weighted multiplicity:
8eca5d19 425 sumOfWeights+=dWeight*dWphi*dWpt*dWeta;
929098e4 426
427 } // end of subevent
428 } // end of if (pTrack->InRPSelection())
29195b69 429 } // end of if (pTrack)
929098e4 430 else
431 {
432 cerr << "no particle!!!"<<endl;
433 }
29195b69 434 } // loop over particles
435 Qarray[s].Set(dQX,dQY);
8eca5d19 436 Qarray[s].SetMult(sumOfWeights);
29195b69 437 //reset
8eca5d19 438 sumOfWeights = 0.;
29195b69 439 dQX = 0.;
440 dQY = 0.;
441 }
929098e4 442
395fadba 443}
444
445
929098e4 446//-----------------------------------------------------------------------
c076fda8 447void AliFlowEventSimple::Print(Option_t *option) const
448{
449 // -*-*-*-*-*Print some global quantities for this histogram collection class *-*-*-*-*-*-*-*
450 // ===============================================
451 // printf( "TH1.Print Name = %s, Entries= %d, Total sum= %g\n",GetName(),Int_t(fEntries),GetSumOfWeights());
f873707d 452 printf( "Class.Print Name = %s, #tracks= %d, Number of RPs= %d, MC EventPlaneAngle= %f\n",
bc231a12 453 GetName(),fNumberOfTracks, fNumberOfRPs, fMCReactionPlaneAngle );
c076fda8 454
b4dba88d 455 TString optionstr(option);
456 if (!optionstr.Contains("all")) return;
929098e4 457 if (fTrackCollection)
458 {
c076fda8 459 fTrackCollection->Print(option);
460 }
929098e4 461 else
462 {
c076fda8 463 printf( "Empty track collection \n");
464 }
465}
466
929098e4 467//-----------------------------------------------------------------------
468void AliFlowEventSimple::Browse(TBrowser *b)
c076fda8 469{
cc0afcfc 470 //browse in TBrowser
c076fda8 471 if (!b) return;
929098e4 472 if (!fNumberOfTracksWrap)
473 {
c076fda8 474 fNumberOfTracksWrap = new TParameter<int>("fNumberOfTracks", fNumberOfTracks);
475 b->Add(fNumberOfTracksWrap);
476 }
bc231a12 477 if (!fNumberOfRPsWrap)
929098e4 478 {
bc231a12 479 fNumberOfRPsWrap = new TParameter<int>("fNumberOfRPs", fNumberOfRPs);
480 b->Add(fNumberOfRPsWrap);
c076fda8 481 }
929098e4 482 if (!fMCReactionPlaneAngleWrap)
483 {
7183fe85 484 fMCReactionPlaneAngleWrap = new TParameter<double>(" fMCReactionPlaneAngle", fMCReactionPlaneAngle);
a12990bb 485 b->Add( fMCReactionPlaneAngleWrap);
486 }
c076fda8 487 if (fTrackCollection) b->Add(fTrackCollection,"AliFlowTracksSimple");
488}
489
929098e4 490//-----------------------------------------------------------------------
491AliFlowEventSimple::AliFlowEventSimple( TTree* inputTree,
492 const AliFlowTrackSimpleCuts* rpCuts,
493 const AliFlowTrackSimpleCuts* poiCuts):
494 fTrackCollection(NULL),
85d2ee8d 495 fReferenceMultiplicity(0),
929098e4 496 fNumberOfTracks(0),
bc231a12 497 fNumberOfRPs(0),
929098e4 498 fMCReactionPlaneAngle(0.),
499 fMCReactionPlaneAngleIsSet(kFALSE),
bc231a12 500 fAfterBurnerPrecision(0.001),
9fa64edc 501 fUserModified(kFALSE),
929098e4 502 fNumberOfTracksWrap(NULL),
bc231a12 503 fNumberOfRPsWrap(NULL),
929098e4 504 fMCReactionPlaneAngleWrap(NULL)
505{
506 //constructor, fills the event from a TTree of kinematic.root files
507 //applies RP and POI cuts, tags the tracks
508
509 Int_t numberOfInputTracks = inputTree->GetEntries() ;
510 fTrackCollection = new TObjArray(numberOfInputTracks/2);
511
512 TParticle* pParticle = new TParticle();
513 inputTree->SetBranchAddress("Particles",&pParticle);
514
515 Int_t iSelParticlesPOI = 0;
516
517 for (Int_t i=0; i<numberOfInputTracks; i++)
518 {
519 inputTree->GetEntry(i); //get input particle
520
521 if (!pParticle) continue; //no particle
522 if (!pParticle->IsPrimary()) continue;
523
7382279b 524 Bool_t rpOK = rpCuts->PassesCuts(pParticle);
525 Bool_t poiOK = poiCuts->PassesCuts(pParticle);
929098e4 526
7382279b 527 if (rpOK || poiOK)
929098e4 528 {
529 AliFlowTrackSimple* pTrack = new AliFlowTrackSimple(pParticle);
530
531 //marking the particles used for int. flow:
7382279b 532 if(rpOK)
929098e4 533 {
534 pTrack->SetForRPSelection(kTRUE);
bc231a12 535 fNumberOfRPs++;
929098e4 536 }
537 //marking the particles used for diff. flow:
7382279b 538 if(poiOK)
929098e4 539 {
540 pTrack->SetForPOISelection(kTRUE);
541 iSelParticlesPOI++;
542 }
543 //adding a particles which were used either for int. or diff. flow to the list
124fb262 544 AddTrack(pTrack);
929098e4 545 }
546 }//for i
547 delete pParticle;
548}
549
550//_____________________________________________________________________________
551void AliFlowEventSimple::CloneTracks(Int_t n)
552{
553 //clone every track n times to add non-flow
34b15925 554 if (n<=0) return; //no use to clone stuff zero or less times
bc231a12 555 Int_t ntracks = fNumberOfTracks;
556 fTrackCollection->Expand((n+1)*fNumberOfTracks);
557 for (Int_t i=0; i<n; i++)
929098e4 558 {
bc231a12 559 for (Int_t itrack=0; itrack<ntracks; itrack++)
929098e4 560 {
561 AliFlowTrackSimple* track = dynamic_cast<AliFlowTrackSimple*>(fTrackCollection->At(itrack));
562 if (!track) continue;
bc231a12 563 AddTrack(static_cast<AliFlowTrackSimple*>(track->Clone()));
929098e4 564 }
565 }
9fa64edc 566 SetUserModified();
929098e4 567}
7382279b 568
569//_____________________________________________________________________________
570void AliFlowEventSimple::ResolutionPt(Double_t res)
571{
572 //smear pt of all tracks by gaussian with sigma=res
573 for (Int_t i=0; i<fNumberOfTracks; i++)
574 {
575 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
124fb262 576 if (track) track->ResolutionPt(res);
7382279b 577 }
9fa64edc 578 SetUserModified();
7382279b 579}
124fb262 580
581//_____________________________________________________________________________
34b15925 582void AliFlowEventSimple::TagSubeventsInEta( Double_t etaMinA,
583 Double_t etaMaxA,
584 Double_t etaMinB,
585 Double_t etaMaxB )
124fb262 586{
587 //Flag two subevents in given eta ranges
588 for (Int_t i=0; i<fNumberOfTracks; i++)
589 {
590 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
3ca4688a 591 if (!track) continue;
592 track->ResetSubEventTags();
124fb262 593 Double_t eta=track->Eta();
594 if (eta >= etaMinA && eta <= etaMaxA) track->SetForSubevent(0);
595 if (eta >= etaMinB && eta <= etaMaxB) track->SetForSubevent(1);
596 }
597}
598
076df7bf 599//_____________________________________________________________________________
600void AliFlowEventSimple::TagSubeventsByCharge()
601{
602 //Flag two subevents in given eta ranges
603 for (Int_t i=0; i<fNumberOfTracks; i++)
604 {
605 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
3ca4688a 606 if (!track) continue;
607 track->ResetSubEventTags();
076df7bf 608 Int_t charge=track->Charge();
609 if (charge<0) track->SetForSubevent(0);
610 if (charge>0) track->SetForSubevent(1);
611 }
612}
613
bc231a12 614//_____________________________________________________________________________
34b15925 615void AliFlowEventSimple::AddV1( Double_t v1 )
bc231a12 616{
617 //add v2 to all tracks wrt the reaction plane angle
618 for (Int_t i=0; i<fNumberOfTracks; i++)
619 {
620 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
621 if (track) track->AddV1(v1, fMCReactionPlaneAngle, fAfterBurnerPrecision);
622 }
9fa64edc 623 SetUserModified();
bc231a12 624}
625
124fb262 626//_____________________________________________________________________________
34b15925 627void AliFlowEventSimple::AddV2( Double_t v2 )
124fb262 628{
244c607a 629 //add v2 to all tracks wrt the reaction plane angle
124fb262 630 for (Int_t i=0; i<fNumberOfTracks; i++)
631 {
632 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
bc231a12 633 if (track) track->AddV2(v2, fMCReactionPlaneAngle, fAfterBurnerPrecision);
634 }
9fa64edc 635 SetUserModified();
bc231a12 636}
637
638//_____________________________________________________________________________
54089829 639void AliFlowEventSimple::AddV3( Double_t v3 )
640{
641 //add v3 to all tracks wrt the reaction plane angle
642 for (Int_t i=0; i<fNumberOfTracks; i++)
643 {
644 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
645 if (track) track->AddV3(v3, fMCReactionPlaneAngle, fAfterBurnerPrecision);
646 }
647 SetUserModified();
648}
649
650//_____________________________________________________________________________
34b15925 651void AliFlowEventSimple::AddV4( Double_t v4 )
bc231a12 652{
653 //add v4 to all tracks wrt the reaction plane angle
654 for (Int_t i=0; i<fNumberOfTracks; i++)
655 {
656 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
657 if (track) track->AddV4(v4, fMCReactionPlaneAngle, fAfterBurnerPrecision);
658 }
9fa64edc 659 SetUserModified();
bc231a12 660}
661
662//_____________________________________________________________________________
1a80f9f6 663void AliFlowEventSimple::AddV5( Double_t v5 )
664{
665 //add v4 to all tracks wrt the reaction plane angle
666 for (Int_t i=0; i<fNumberOfTracks; i++)
667 {
668 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
669 if (track) track->AddV5(v5, fMCReactionPlaneAngle, fAfterBurnerPrecision);
670 }
671 SetUserModified();
672}
673
674//_____________________________________________________________________________
675void AliFlowEventSimple::AddFlow( Double_t v1, Double_t v2, Double_t v3, Double_t v4, Double_t v5,
676 Double_t rp1, Double_t rp2, Double_t rp3, Double_t rp4, Double_t rp5 )
677{
678 //add flow to all tracks wrt the reaction plane angle, for all harmonic separate angle
679 for (Int_t i=0; i<fNumberOfTracks; i++)
680 {
681 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
682 if (track) track->AddFlow(v1,v2,v3,v4,v5,rp1,rp2,rp3,rp4,rp5,fAfterBurnerPrecision);
683 }
684 SetUserModified();
685}
686
687//_____________________________________________________________________________
688void AliFlowEventSimple::AddFlow( Double_t v1, Double_t v2, Double_t v3, Double_t v4, Double_t v5 )
bc231a12 689{
690 //add flow to all tracks wrt the reaction plane angle
691 for (Int_t i=0; i<fNumberOfTracks; i++)
692 {
693 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
1a80f9f6 694 if (track) track->AddFlow(v1,v2,v3,v4,v5,fMCReactionPlaneAngle, fAfterBurnerPrecision);
124fb262 695 }
9fa64edc 696 SetUserModified();
124fb262 697}
698
99ff691b 699//_____________________________________________________________________________
700void AliFlowEventSimple::AddV2( TF1* ptDepV2 )
701{
702 //add v2 to all tracks wrt the reaction plane angle
703 for (Int_t i=0; i<fNumberOfTracks; i++)
704 {
705 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
2a745a5f 706 if (!track) continue;
99ff691b 707 Double_t v2 = ptDepV2->Eval(track->Pt());
2a745a5f 708 track->AddV2(v2, fMCReactionPlaneAngle, fAfterBurnerPrecision);
99ff691b 709 }
710 SetUserModified();
711}
712
dd91b595 713//_____________________________________________________________________________
cc0afcfc 714void AliFlowEventSimple::TagRP( const AliFlowTrackSimpleCuts* cuts )
dd91b595 715{
716 //tag tracks as reference particles (RPs)
717 for (Int_t i=0; i<fNumberOfTracks; i++)
718 {
719 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
720 if (!track) continue;
701f71c1 721 Bool_t pass=cuts->PassesCuts(track);
e0da66a2 722 Bool_t rpTrack=track->InRPSelection();
701f71c1 723 if (pass)
e0da66a2 724 {
725 if (!rpTrack) fNumberOfRPs++; //only increase if not already tagged
726 }
701f71c1 727 else
e0da66a2 728 {
729 if (rpTrack) fNumberOfRPs--; //only decrease if detagging
730 }
731 track->SetForRPSelection(pass);
dd91b595 732 }
733}
734
735//_____________________________________________________________________________
cc0afcfc 736void AliFlowEventSimple::TagPOI( const AliFlowTrackSimpleCuts* cuts )
dd91b595 737{
738 //tag tracks as particles of interest (POIs)
739 for (Int_t i=0; i<fNumberOfTracks; i++)
740 {
741 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
742 if (!track) continue;
701f71c1 743 Bool_t pass=cuts->PassesCuts(track);
744 track->SetForPOISelection(pass);
dd91b595 745 }
746}
747
34b15925 748//_____________________________________________________________________________
749void AliFlowEventSimple::DefineDeadZone( Double_t etaMin,
750 Double_t etaMax,
751 Double_t phiMin,
752 Double_t phiMax )
753{
754 //mark tracks in given eta-phi region as dead
755 //by resetting the flow bits
756 for (Int_t i=0; i<fNumberOfTracks; i++)
757 {
758 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
759 Double_t eta = track->Eta();
760 Double_t phi = track->Phi();
761 if (eta>etaMin && eta<etaMax && phi>phiMin && phi<phiMax)
1a43aca9 762 {
763 if (track->InRPSelection()) fNumberOfRPs--;
34b15925 764 track->ResetFlowTags();
1a43aca9 765 }
34b15925 766 }
767}
768
769//_____________________________________________________________________________
770Int_t AliFlowEventSimple::CleanUpDeadTracks()
771{
772 //remove tracks that have no flow tags set and cleanup the container
65ef7d1a 773 //returns number of cleaned tracks
774 Int_t ncleaned=0;
34b15925 775 for (Int_t i=0; i<fNumberOfTracks; i++)
776 {
777 AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
cd62a2a8 778 if (!track) continue;
7d27a354 779 if (track->IsDead()) {delete track;track=NULL;ncleaned++;}
34b15925 780 }
781 fTrackCollection->Compress(); //clean up empty slots
7d27a354 782 fNumberOfTracks-=ncleaned; //update number of tracks
65ef7d1a 783 return ncleaned;
34b15925 784}
99ff691b 785
786//_____________________________________________________________________________
787TF1* AliFlowEventSimple::SimplePtDepV2()
788{
789 //return a standard pt dependent v2 formula, user has to clean up!
790 return new TF1("StandardPtDepV2","((x<1.0)*(0.05/1.0)*x+(x>=1.0)*0.05)");
791}
792
793//_____________________________________________________________________________
794TF1* AliFlowEventSimple::SimplePtSpectrum()
795{
796 //return a standard pt spectrum, user has to clean up!
797 return new TF1("StandardPtSpectrum","x*TMath::Exp(-pow(0.13957*0.13957+x*x,0.5)/0.4)",0.1,10.);
798}
7d27a354 799
800//_____________________________________________________________________________
801void AliFlowEventSimple::ClearFast()
802{
803 //clear the counter without deleting allocated objects so they can be reused
804 fReferenceMultiplicity = 0;
805 fNumberOfTracks = 0;
806 fNumberOfRPs = 0;
807 fMCReactionPlaneAngle = 0.0;
808 fMCReactionPlaneAngleIsSet = kFALSE;
809 fAfterBurnerPrecision = 0.001;
810 fUserModified = kFALSE;
811}