]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowCommon/AliFlowEventSimple.cxx
start of moving various methods into the flowevent
[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"
35#include "TProfile.h"
929098e4 36#include "TParameter.h"
c076fda8 37#include "TBrowser.h"
f1d945a1 38#include "AliFlowVector.h"
39#include "AliFlowTrackSimple.h"
40#include "AliFlowEventSimple.h"
929098e4 41#include "AliFlowTrackSimpleCuts.h"
f1d945a1 42
f1d945a1 43ClassImp(AliFlowEventSimple)
44
45//-----------------------------------------------------------------------
46
46bec39c 47AliFlowEventSimple::AliFlowEventSimple():
48 fTrackCollection(NULL),
49 fNumberOfTracks(0),
1918addd 50 fEventNSelTracksRP(0),
7183fe85 51 fMCReactionPlaneAngle(0.),
929098e4 52 fMCReactionPlaneAngleIsSet(kFALSE),
c076fda8 53 fNumberOfTracksWrap(NULL),
1918addd 54 fEventNSelTracksRPWrap(NULL),
a12990bb 55 fMCReactionPlaneAngleWrap(NULL)
46bec39c 56{
57 cout << "AliFlowEventSimple: Default constructor to be used only by root for io" << endl;
58}
59
60//-----------------------------------------------------------------------
61
62AliFlowEventSimple::AliFlowEventSimple(Int_t aLenght):
63 fTrackCollection(NULL),
64 fNumberOfTracks(0),
1918addd 65 fEventNSelTracksRP(0),
7183fe85 66 fMCReactionPlaneAngle(0.),
929098e4 67 fMCReactionPlaneAngleIsSet(kFALSE),
c076fda8 68 fNumberOfTracksWrap(NULL),
1918addd 69 fEventNSelTracksRPWrap(NULL),
a12990bb 70 fMCReactionPlaneAngleWrap(NULL)
f1d945a1 71{
929098e4 72 //constructor
73 fTrackCollection = new TObjArray(aLenght);
f1d945a1 74}
75
76//-----------------------------------------------------------------------
77
e35ddff0 78AliFlowEventSimple::AliFlowEventSimple(const AliFlowEventSimple& anEvent):
bc6b015e 79 TObject(),
e35ddff0 80 fTrackCollection(anEvent.fTrackCollection),
81 fNumberOfTracks(anEvent.fNumberOfTracks),
1918addd 82 fEventNSelTracksRP(anEvent.fEventNSelTracksRP),
a12990bb 83 fMCReactionPlaneAngle(anEvent.fMCReactionPlaneAngle),
929098e4 84 fMCReactionPlaneAngleIsSet(anEvent.fMCReactionPlaneAngleIsSet),
c076fda8 85 fNumberOfTracksWrap(anEvent.fNumberOfTracksWrap),
1918addd 86 fEventNSelTracksRPWrap(anEvent.fEventNSelTracksRPWrap),
a12990bb 87 fMCReactionPlaneAngleWrap(anEvent.fMCReactionPlaneAngleWrap)
f1d945a1 88{
929098e4 89 //copy constructor
f1d945a1 90}
91
92//-----------------------------------------------------------------------
93
e35ddff0 94AliFlowEventSimple& AliFlowEventSimple::operator=(const AliFlowEventSimple& anEvent)
f1d945a1 95{
26c4cbb9 96 *fTrackCollection = *anEvent.fTrackCollection ;
e35ddff0 97 fNumberOfTracks = anEvent.fNumberOfTracks;
1918addd 98 fEventNSelTracksRP = anEvent.fEventNSelTracksRP;
a12990bb 99 fMCReactionPlaneAngle = anEvent.fMCReactionPlaneAngle;
929098e4 100 fMCReactionPlaneAngleIsSet = anEvent.fMCReactionPlaneAngleIsSet;
101 fNumberOfTracksWrap = anEvent.fNumberOfTracksWrap;
1918addd 102 fEventNSelTracksRPWrap = anEvent.fEventNSelTracksRPWrap;
a12990bb 103 fMCReactionPlaneAngleWrap=anEvent.fMCReactionPlaneAngleWrap;
c076fda8 104
f1d945a1 105 return *this;
f1d945a1 106}
107
929098e4 108//-----------------------------------------------------------------------
f1d945a1 109
110AliFlowEventSimple::~AliFlowEventSimple()
111{
112 //destructor
929098e4 113 if (fTrackCollection) fTrackCollection->Delete();
114 delete fTrackCollection;
c076fda8 115 if (fNumberOfTracksWrap) delete fNumberOfTracksWrap;
1918addd 116 if (fEventNSelTracksRPWrap) delete fEventNSelTracksRPWrap;
a12990bb 117 if (fMCReactionPlaneAngleWrap) delete fMCReactionPlaneAngleWrap;
f1d945a1 118}
119
929098e4 120//-----------------------------------------------------------------------
f1d945a1 121
122AliFlowTrackSimple* AliFlowEventSimple::GetTrack(Int_t i)
123{
124 //get track i from collection
e35ddff0 125 AliFlowTrackSimple* pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i) ;
126 return pTrack;
f1d945a1 127}
128
929098e4 129//-----------------------------------------------------------------------
130AliFlowVector AliFlowEventSimple::GetQ(Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
f1d945a1 131{
929098e4 132 // calculate Q-vector in harmonic n without weights (default harmonic n=2)
e35ddff0 133 Double_t dQX = 0.;
134 Double_t dQY = 0.;
135 AliFlowVector vQ;
136 vQ.Set(0.,0.);
929098e4 137
9825d4a9 138 Int_t iOrder = n;
ae733b3b 139 Double_t iUsedTracks = 0;
26c4cbb9 140 Double_t dPhi=0.;
ae733b3b 141 Double_t dPt=0.;
142 Double_t dEta=0.;
929098e4 143
26c4cbb9 144 AliFlowTrackSimple* pTrack = NULL;
929098e4 145
146 Int_t nBinsPhi=0;
26c4cbb9 147 Double_t dBinWidthPt=0.;
ae733b3b 148 Double_t dPtMin=0.;
26c4cbb9 149 Double_t dBinWidthEta=0.;
ae733b3b 150 Double_t dEtaMin=0.;
929098e4 151
152 Double_t wPhi=1.; // weight Phi
153 Double_t wPt=1.; // weight Pt
154 Double_t wEta=1.; // weight Eta
155
03a02aca 156 TH1F *phiWeights = NULL;
ae733b3b 157 TH1D *ptWeights = NULL;
03a02aca 158 TH1D *etaWeights = NULL;
929098e4 159
03a02aca 160 if(weightsList)
26c4cbb9 161 {
929098e4 162 if(usePhiWeights)
163 {
164 phiWeights = dynamic_cast<TH1F *>(weightsList->FindObject("phi_weights"));
165 if(phiWeights) nBinsPhi = phiWeights->GetNbinsX();
166 }
167 if(usePtWeights)
03a02aca 168 {
929098e4 169 ptWeights = dynamic_cast<TH1D *>(weightsList->FindObject("pt_weights"));
170 if(ptWeights)
171 {
172 dBinWidthPt = ptWeights->GetBinWidth(1); // assuming that all bins have the same width
173 dPtMin = (ptWeights->GetXaxis())->GetXmin();
174 }
175 }
176 if(useEtaWeights)
03a02aca 177 {
929098e4 178 etaWeights = dynamic_cast<TH1D *>(weightsList->FindObject("eta_weights"));
179 if(etaWeights)
180 {
181 dBinWidthEta = etaWeights->GetBinWidth(1); // assuming that all bins have the same width
182 dEtaMin = (etaWeights->GetXaxis())->GetXmin();
183 }
184 }
03a02aca 185 } // end of if(weightsList)
929098e4 186
187 // loop over tracks
188 for(Int_t i=0; i<fNumberOfTracks; i++)
26c4cbb9 189 {
929098e4 190 pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i);
191 if(pTrack)
f1d945a1 192 {
929098e4 193 if(pTrack->InRPSelection())
194 {
195 dPhi = pTrack->Phi();
196 dPt = pTrack->Pt();
197 dEta = pTrack->Eta();
198
199 // determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
200 if(phiWeights && nBinsPhi)
201 {
202 wPhi = phiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*nBinsPhi/TMath::TwoPi())));
203 }
204 // determine v'(pt) weight:
205 if(ptWeights && dBinWidthPt)
206 {
207 wPt=ptWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-dPtMin)/dBinWidthPt)));
208 }
209 // determine v'(eta) weight:
210 if(etaWeights && dBinWidthEta)
211 {
212 wEta=etaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-dEtaMin)/dBinWidthEta)));
213 }
214
215 // building up the weighted Q-vector:
216 dQX += wPhi*wPt*wEta*TMath::Cos(iOrder*dPhi);
217 dQY += wPhi*wPt*wEta*TMath::Sin(iOrder*dPhi);
218
219 // weighted multiplicity:
220 iUsedTracks+=wPhi*wPt*wEta;
221
222 } // end of if (pTrack->InRPSelection())
223 } // end of if (pTrack)
224 else
225 {
226 cerr << "no particle!!!"<<endl;
227 }
ae733b3b 228 } // loop over particles
929098e4 229
e35ddff0 230 vQ.Set(dQX,dQY);
231 vQ.SetMult(iUsedTracks);
929098e4 232
e35ddff0 233 return vQ;
929098e4 234
5fef318d 235}
236
929098e4 237//-----------------------------------------------------------------------
238void AliFlowEventSimple::Get2Qsub(AliFlowVector* Qarray, Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
395fadba 239{
929098e4 240
241 // calculate Q-vector in harmonic n without weights (default harmonic n=2)
395fadba 242 Double_t dQX = 0.;
243 Double_t dQY = 0.;
929098e4 244
395fadba 245 Int_t iOrder = n;
246 Double_t iUsedTracks = 0;
247 Double_t dPhi = 0.;
248 Double_t dPt = 0.;
249 Double_t dEta = 0.;
929098e4 250
395fadba 251 AliFlowTrackSimple* pTrack = NULL;
929098e4 252
253 Int_t iNbinsPhi = 0;
395fadba 254 Double_t dBinWidthPt = 0.;
255 Double_t dPtMin = 0.;
256 Double_t dBinWidthEta= 0.;
257 Double_t dEtaMin = 0.;
929098e4 258
259 Double_t dWphi = 1.; // weight Phi
260 Double_t dWpt = 1.; // weight Pt
261 Double_t dWeta = 1.; // weight Eta
262
29195b69 263 TH1F* phiWeights = NULL;
264 TH1D* ptWeights = NULL;
265 TH1D* etaWeights = NULL;
929098e4 266
267 if(weightsList)
268 {
269 if(usePhiWeights)
270 {
29195b69 271 phiWeights = dynamic_cast<TH1F *>(weightsList->FindObject("phi_weights"));
929098e4 272 if(phiWeights)
273 {
274 iNbinsPhi = phiWeights->GetNbinsX();
29195b69 275 }
929098e4 276 }
277 if(usePtWeights)
278 {
29195b69 279 ptWeights = dynamic_cast<TH1D *>(weightsList->FindObject("pt_weights"));
929098e4 280 if(ptWeights)
281 {
282 dBinWidthPt = ptWeights->GetBinWidth(1); // assuming that all bins have the same width
283 dPtMin = (ptWeights->GetXaxis())->GetXmin();
284 }
285 }
286 if(useEtaWeights)
287 {
288 etaWeights = dynamic_cast<TH1D *>(weightsList->FindObject("eta_weights"));
289 if(etaWeights)
290 {
291 dBinWidthEta = etaWeights->GetBinWidth(1); // assuming that all bins have the same width
292 dEtaMin = (etaWeights->GetXaxis())->GetXmin();
293 }
294 }
395fadba 295 } // end of if(weightsList)
929098e4 296
b125a454 297 //loop over the two subevents
929098e4 298 for (Int_t s=0; s<2; s++)
299 {
300 // loop over tracks
301 for(Int_t i=0; i<fNumberOfTracks; i++)
302 {
303 pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i);
304 if(pTrack)
305 {
306 if(pTrack->InRPSelection())
307 {
308 if (pTrack->InSubevent(s))
309 {
310 dPhi = pTrack->Phi();
311 dPt = pTrack->Pt();
312 dEta = pTrack->Eta();
313
314 // determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
315 if(phiWeights && iNbinsPhi)
316 {
317 dWphi = phiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*iNbinsPhi/TMath::TwoPi())));
318 }
319 // determine v'(pt) weight:
320 if(ptWeights && dBinWidthPt)
321 {
322 dWpt=ptWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-dPtMin)/dBinWidthPt)));
323 }
324 // determine v'(eta) weight:
325 if(etaWeights && dBinWidthEta)
326 {
327 dWeta=etaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-dEtaMin)/dBinWidthEta)));
328 }
329
330 // building up the weighted Q-vector:
331 dQX += dWphi*dWpt*dWeta*TMath::Cos(iOrder*dPhi);
332 dQY += dWphi*dWpt*dWeta*TMath::Sin(iOrder*dPhi);
333
334 // weighted multiplicity:
335 iUsedTracks+=dWphi*dWpt*dWeta;
336
337 } // end of subevent
338 } // end of if (pTrack->InRPSelection())
29195b69 339 } // end of if (pTrack)
929098e4 340 else
341 {
342 cerr << "no particle!!!"<<endl;
343 }
29195b69 344 } // loop over particles
345 Qarray[s].Set(dQX,dQY);
346 Qarray[s].SetMult(iUsedTracks);
347 //reset
348 iUsedTracks = 0;
349 dQX = 0.;
350 dQY = 0.;
351 }
929098e4 352
395fadba 353}
354
355
929098e4 356//-----------------------------------------------------------------------
c076fda8 357void AliFlowEventSimple::Print(Option_t *option) const
358{
359 // -*-*-*-*-*Print some global quantities for this histogram collection class *-*-*-*-*-*-*-*
360 // ===============================================
361 // printf( "TH1.Print Name = %s, Entries= %d, Total sum= %g\n",GetName(),Int_t(fEntries),GetSumOfWeights());
7183fe85 362 printf( "Class.Print Name = %s, Total number of tracks= %d, Number of selected tracks= %d, MC EventPlaneAngle= %f",
929098e4 363 GetName(),fNumberOfTracks, fEventNSelTracksRP, fMCReactionPlaneAngle );
c076fda8 364
929098e4 365 if (fTrackCollection)
366 {
c076fda8 367 fTrackCollection->Print(option);
368 }
929098e4 369 else
370 {
c076fda8 371 printf( "Empty track collection \n");
372 }
373}
374
929098e4 375//-----------------------------------------------------------------------
376void AliFlowEventSimple::Browse(TBrowser *b)
c076fda8 377{
378 if (!b) return;
929098e4 379 if (!fNumberOfTracksWrap)
380 {
c076fda8 381 fNumberOfTracksWrap = new TParameter<int>("fNumberOfTracks", fNumberOfTracks);
382 b->Add(fNumberOfTracksWrap);
383 }
929098e4 384 if (!fEventNSelTracksRPWrap)
385 {
1918addd 386 fEventNSelTracksRPWrap = new TParameter<int>("fEventNSelTracksRP", fEventNSelTracksRP);
387 b->Add(fEventNSelTracksRPWrap);
c076fda8 388 }
929098e4 389 if (!fMCReactionPlaneAngleWrap)
390 {
7183fe85 391 fMCReactionPlaneAngleWrap = new TParameter<double>(" fMCReactionPlaneAngle", fMCReactionPlaneAngle);
a12990bb 392 b->Add( fMCReactionPlaneAngleWrap);
393 }
c076fda8 394 if (fTrackCollection) b->Add(fTrackCollection,"AliFlowTracksSimple");
395}
396
929098e4 397//-----------------------------------------------------------------------
398AliFlowEventSimple::AliFlowEventSimple( TTree* inputTree,
399 const AliFlowTrackSimpleCuts* rpCuts,
400 const AliFlowTrackSimpleCuts* poiCuts):
401 fTrackCollection(NULL),
402 fNumberOfTracks(0),
403 fEventNSelTracksRP(0),
404 fMCReactionPlaneAngle(0.),
405 fMCReactionPlaneAngleIsSet(kFALSE),
406 fNumberOfTracksWrap(NULL),
407 fEventNSelTracksRPWrap(NULL),
408 fMCReactionPlaneAngleWrap(NULL)
409{
410 //constructor, fills the event from a TTree of kinematic.root files
411 //applies RP and POI cuts, tags the tracks
412
413 Int_t numberOfInputTracks = inputTree->GetEntries() ;
414 fTrackCollection = new TObjArray(numberOfInputTracks/2);
415
416 TParticle* pParticle = new TParticle();
417 inputTree->SetBranchAddress("Particles",&pParticle);
418
419 Int_t iSelParticlesPOI = 0;
420
421 for (Int_t i=0; i<numberOfInputTracks; i++)
422 {
423 inputTree->GetEntry(i); //get input particle
424
425 if (!pParticle) continue; //no particle
426 if (!pParticle->IsPrimary()) continue;
427
428 Bool_t bPassedRPFlowCuts = rpCuts->PassesCuts(pParticle);
429 Bool_t bPassedPOIFlowCuts = poiCuts->PassesCuts(pParticle);
430
431 if (bPassedRPFlowCuts || bPassedPOIFlowCuts)
432 {
433 AliFlowTrackSimple* pTrack = new AliFlowTrackSimple(pParticle);
434
435 //marking the particles used for int. flow:
436 if(bPassedRPFlowCuts)
437 {
438 pTrack->SetForRPSelection(kTRUE);
439 fEventNSelTracksRP++;
440 }
441 //marking the particles used for diff. flow:
442 if(bPassedPOIFlowCuts)
443 {
444 pTrack->SetForPOISelection(kTRUE);
445 iSelParticlesPOI++;
446 }
447 //adding a particles which were used either for int. or diff. flow to the list
448 fTrackCollection->Add(pTrack);
449 fNumberOfTracks++;
450 }
451 }//for i
452 delete pParticle;
453}
454
455//_____________________________________________________________________________
456void AliFlowEventSimple::CloneTracks(Int_t n)
457{
458 //clone every track n times to add non-flow
459 for (Int_t i=1; i<n; i++)
460 {
461 for (Int_t itrack=0; itrack<fNumberOfTracks; itrack++)
462 {
463 AliFlowTrackSimple* track = dynamic_cast<AliFlowTrackSimple*>(fTrackCollection->At(itrack));
464 if (!track) continue;
465 fTrackCollection->Add(new AliFlowTrackSimple(*track));
466 fNumberOfTracks++;
467
468 }
469 }
470}