]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowCommon/AliFlowEventSimple.cxx
added += and + for AliFlowVector
[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
f1d945a1 16#include "Riostream.h"
17#include "TObjArray.h"
26c4cbb9 18#include "TFile.h"
03a02aca 19#include "TList.h"
f1d945a1 20#include "TMath.h"
26c4cbb9 21#include "TH1F.h"
22#include "TH1D.h"
23#include "TProfile.h"
c076fda8 24#include "TBrowser.h"
f1d945a1 25#include "AliFlowVector.h"
26#include "AliFlowTrackSimple.h"
27#include "AliFlowEventSimple.h"
28
26c4cbb9 29/**************************************
30 * AliFlowEventSimple: A simple event *
31 * for flow analysis *
32 * *
33 * authors: Naomi van der Kolk *
34 * (kolk@nikhef.nl) *
35 * Ante Bilandzic *
36 * (anteb@nikhef.nl) *
37 * ***********************************/
38
f1d945a1 39ClassImp(AliFlowEventSimple)
40
41//-----------------------------------------------------------------------
42
46bec39c 43AliFlowEventSimple::AliFlowEventSimple():
44 fTrackCollection(NULL),
45 fNumberOfTracks(0),
1918addd 46 fEventNSelTracksRP(0),
7183fe85 47 fMCReactionPlaneAngle(0.),
c076fda8 48 fNumberOfTracksWrap(NULL),
1918addd 49 fEventNSelTracksRPWrap(NULL),
a12990bb 50 fMCReactionPlaneAngleWrap(NULL)
46bec39c 51{
52 cout << "AliFlowEventSimple: Default constructor to be used only by root for io" << endl;
53}
54
55//-----------------------------------------------------------------------
56
57AliFlowEventSimple::AliFlowEventSimple(Int_t aLenght):
58 fTrackCollection(NULL),
59 fNumberOfTracks(0),
1918addd 60 fEventNSelTracksRP(0),
7183fe85 61 fMCReactionPlaneAngle(0.),
c076fda8 62 fNumberOfTracksWrap(NULL),
1918addd 63 fEventNSelTracksRPWrap(NULL),
a12990bb 64 fMCReactionPlaneAngleWrap(NULL)
f1d945a1 65{
66 //constructor
e35ddff0 67 fTrackCollection = new TObjArray(aLenght) ;
f1d945a1 68}
69
70//-----------------------------------------------------------------------
71
e35ddff0 72AliFlowEventSimple::AliFlowEventSimple(const AliFlowEventSimple& anEvent):
bc6b015e 73 TObject(),
e35ddff0 74 fTrackCollection(anEvent.fTrackCollection),
75 fNumberOfTracks(anEvent.fNumberOfTracks),
1918addd 76 fEventNSelTracksRP(anEvent.fEventNSelTracksRP),
a12990bb 77 fMCReactionPlaneAngle(anEvent.fMCReactionPlaneAngle),
c076fda8 78 fNumberOfTracksWrap(anEvent.fNumberOfTracksWrap),
1918addd 79 fEventNSelTracksRPWrap(anEvent.fEventNSelTracksRPWrap),
a12990bb 80 fMCReactionPlaneAngleWrap(anEvent.fMCReactionPlaneAngleWrap)
f1d945a1 81{
82 //copy constructor
f1d945a1 83}
84
85//-----------------------------------------------------------------------
86
e35ddff0 87AliFlowEventSimple& AliFlowEventSimple::operator=(const AliFlowEventSimple& anEvent)
f1d945a1 88{
26c4cbb9 89 *fTrackCollection = *anEvent.fTrackCollection ;
e35ddff0 90 fNumberOfTracks = anEvent.fNumberOfTracks;
1918addd 91 fEventNSelTracksRP = anEvent.fEventNSelTracksRP;
a12990bb 92 fMCReactionPlaneAngle = anEvent.fMCReactionPlaneAngle;
c076fda8 93 fNumberOfTracksWrap = anEvent.fNumberOfTracksWrap;
1918addd 94 fEventNSelTracksRPWrap = anEvent.fEventNSelTracksRPWrap;
a12990bb 95 fMCReactionPlaneAngleWrap=anEvent.fMCReactionPlaneAngleWrap;
c076fda8 96
f1d945a1 97 return *this;
f1d945a1 98}
99
f1d945a1 100//-----------------------------------------------------------------------
101
102AliFlowEventSimple::~AliFlowEventSimple()
103{
104 //destructor
c076fda8 105 if (fTrackCollection) fTrackCollection->Delete(); delete fTrackCollection;
106 if (fNumberOfTracksWrap) delete fNumberOfTracksWrap;
1918addd 107 if (fEventNSelTracksRPWrap) delete fEventNSelTracksRPWrap;
a12990bb 108 if (fMCReactionPlaneAngleWrap) delete fMCReactionPlaneAngleWrap;
f1d945a1 109}
110
111//-----------------------------------------------------------------------
112
113AliFlowTrackSimple* AliFlowEventSimple::GetTrack(Int_t i)
114{
115 //get track i from collection
e35ddff0 116 AliFlowTrackSimple* pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i) ;
117 return pTrack;
f1d945a1 118}
119
120//-----------------------------------------------------------------------
03a02aca 121AliFlowVector AliFlowEventSimple::GetQ(Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
f1d945a1 122{
ae733b3b 123 // calculate Q-vector in harmonic n without weights (default harmonic n=2)
e35ddff0 124 Double_t dQX = 0.;
125 Double_t dQY = 0.;
126 AliFlowVector vQ;
127 vQ.Set(0.,0.);
9825d4a9 128
129 Int_t iOrder = n;
ae733b3b 130 Double_t iUsedTracks = 0;
26c4cbb9 131 Double_t dPhi=0.;
ae733b3b 132 Double_t dPt=0.;
133 Double_t dEta=0.;
26c4cbb9 134
135 AliFlowTrackSimple* pTrack = NULL;
136
137 Int_t nBinsPhi=0;
138 Double_t dBinWidthPt=0.;
ae733b3b 139 Double_t dPtMin=0.;
26c4cbb9 140 Double_t dBinWidthEta=0.;
ae733b3b 141 Double_t dEtaMin=0.;
26c4cbb9 142
ae733b3b 143 Double_t wPhi=1.; // weight Phi
144 Double_t wPt=1.; // weight Pt
145 Double_t wEta=1.; // weight Eta
26c4cbb9 146
03a02aca 147 TH1F *phiWeights = NULL;
ae733b3b 148 TH1D *ptWeights = NULL;
03a02aca 149 TH1D *etaWeights = NULL;
cbbaf54a 150
03a02aca 151 if(weightsList)
26c4cbb9 152 {
03a02aca 153 if(usePhiWeights)
26c4cbb9 154 {
03a02aca 155 phiWeights = dynamic_cast<TH1F *>(weightsList->FindObject("phi_weights"));
156 if(phiWeights) nBinsPhi = phiWeights->GetNbinsX();
157 }
158 if(usePtWeights)
26c4cbb9 159 {
03a02aca 160 ptWeights = dynamic_cast<TH1D *>(weightsList->FindObject("pt_weights"));
161 if(ptWeights)
162 {
163 dBinWidthPt = ptWeights->GetBinWidth(1); // assuming that all bins have the same width
ae733b3b 164 dPtMin = (ptWeights->GetXaxis())->GetXmin();
03a02aca 165 }
166 }
167 if(useEtaWeights)
26c4cbb9 168 {
03a02aca 169 etaWeights = dynamic_cast<TH1D *>(weightsList->FindObject("eta_weights"));
170 if(etaWeights)
171 {
172 dBinWidthEta = etaWeights->GetBinWidth(1); // assuming that all bins have the same width
ae733b3b 173 dEtaMin = (etaWeights->GetXaxis())->GetXmin();
03a02aca 174 }
175 }
176 } // end of if(weightsList)
26c4cbb9 177
03a02aca 178 // loop over tracks
26c4cbb9 179 for(Int_t i=0;i<fNumberOfTracks;i++)
180 {
181 pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i);
182 if(pTrack)
183 {
1918addd 184 if(pTrack->InRPSelection())
f1d945a1 185 {
26c4cbb9 186 dPhi = pTrack->Phi();
187 dPt = pTrack->Pt();
188 dEta = pTrack->Eta();
ae733b3b 189
190 // determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
191 if(phiWeights && nBinsPhi)
26c4cbb9 192 {
ae733b3b 193 wPhi = phiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*nBinsPhi/TMath::TwoPi())));
26c4cbb9 194 }
ae733b3b 195 // determine v'(pt) weight:
196 if(ptWeights && dBinWidthPt)
26c4cbb9 197 {
ae733b3b 198 wPt=ptWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-dPtMin)/dBinWidthPt)));
26c4cbb9 199 }
ae733b3b 200 // determine v'(eta) weight:
201 if(etaWeights && dBinWidthEta)
26c4cbb9 202 {
ae733b3b 203 wEta=etaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-dEtaMin)/dBinWidthEta)));
03a02aca 204 }
ae733b3b 205
206 // building up the weighted Q-vector:
26c4cbb9 207 dQX += wPhi*wPt*wEta*TMath::Cos(iOrder*dPhi);
208 dQY += wPhi*wPt*wEta*TMath::Sin(iOrder*dPhi);
ae733b3b 209
210 // weighted multiplicity:
211 iUsedTracks+=wPhi*wPt*wEta;
cbbaf54a 212
1918addd 213 } // end of if (pTrack->InRPSelection())
ae733b3b 214 } // end of if (pTrack)
26c4cbb9 215 else {cerr << "no particle!!!"<<endl;}
ae733b3b 216 } // loop over particles
26c4cbb9 217
e35ddff0 218 vQ.Set(dQX,dQY);
219 vQ.SetMult(iUsedTracks);
cbbaf54a 220
e35ddff0 221 return vQ;
f1d945a1 222
5fef318d 223}
224
395fadba 225//-----------------------------------------------------------------------
226AliFlowVector AliFlowEventSimple::GetQsub(Double_t etaMin, Double_t etaMax, Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
227{
228 //for eta subevents
229
230 // calculate Q-vector in harmonic n without weights (default harmonic n=2)
231 Double_t dQX = 0.;
232 Double_t dQY = 0.;
233 AliFlowVector vQ;
234 vQ.Set(0.,0.);
235
236 Int_t iOrder = n;
237 Double_t iUsedTracks = 0;
238 Double_t dPhi = 0.;
239 Double_t dPt = 0.;
240 Double_t dEta = 0.;
241
242 AliFlowTrackSimple* pTrack = NULL;
243
244 Int_t nBinsPhi = 0;
245 Double_t dBinWidthPt = 0.;
246 Double_t dPtMin = 0.;
247 Double_t dBinWidthEta= 0.;
248 Double_t dEtaMin = 0.;
249
250 Double_t wPhi = 1.; // weight Phi
251 Double_t wPt = 1.; // weight Pt
252 Double_t wEta = 1.; // weight Eta
253
254 TH1F *phiWeights = NULL;
255 TH1D *ptWeights = NULL;
256 TH1D *etaWeights = NULL;
cbbaf54a 257
395fadba 258 if(weightsList)
259 {
260 if(usePhiWeights)
261 {
262 phiWeights = dynamic_cast<TH1F *>(weightsList->FindObject("phi_weights"));
263 if(phiWeights) nBinsPhi = phiWeights->GetNbinsX();
264 }
265 if(usePtWeights)
266 {
267 ptWeights = dynamic_cast<TH1D *>(weightsList->FindObject("pt_weights"));
268 if(ptWeights)
269 {
270 dBinWidthPt = ptWeights->GetBinWidth(1); // assuming that all bins have the same width
271 dPtMin = (ptWeights->GetXaxis())->GetXmin();
272 }
273 }
274 if(useEtaWeights)
275 {
276 etaWeights = dynamic_cast<TH1D *>(weightsList->FindObject("eta_weights"));
277 if(etaWeights)
278 {
279 dBinWidthEta = etaWeights->GetBinWidth(1); // assuming that all bins have the same width
280 dEtaMin = (etaWeights->GetXaxis())->GetXmin();
281 }
282 }
283 } // end of if(weightsList)
284
285 // loop over tracks
286 for(Int_t i=0;i<fNumberOfTracks;i++)
287 {
288 pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i);
289 if(pTrack)
290 {
1918addd 291 if(pTrack->InRPSelection())
395fadba 292 {
293 dPhi = pTrack->Phi();
294 dPt = pTrack->Pt();
295 dEta = pTrack->Eta();
296 if (dEta>etaMin && dEta<etaMax) {
297 // determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
298 if(phiWeights && nBinsPhi)
299 {
300 wPhi = phiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*nBinsPhi/TMath::TwoPi())));
301 }
302 // determine v'(pt) weight:
303 if(ptWeights && dBinWidthPt)
304 {
305 wPt=ptWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-dPtMin)/dBinWidthPt)));
306 }
307 // determine v'(eta) weight:
308 if(etaWeights && dBinWidthEta)
309 {
310 wEta=etaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-dEtaMin)/dBinWidthEta)));
311 }
312
313 // building up the weighted Q-vector:
314 dQX += wPhi*wPt*wEta*TMath::Cos(iOrder*dPhi);
315 dQY += wPhi*wPt*wEta*TMath::Sin(iOrder*dPhi);
316
317 // weighted multiplicity:
318 iUsedTracks+=wPhi*wPt*wEta;
cbbaf54a 319
395fadba 320 } // end of if dEta in eta range
1918addd 321 } // end of if (pTrack->InRPSelection())
395fadba 322 } // end of if (pTrack)
323 else {cerr << "no particle!!!"<<endl;}
324 } // loop over particles
325
326 vQ.Set(dQX,dQY);
327 vQ.SetMult(iUsedTracks);
cbbaf54a 328
395fadba 329 return vQ;
330
331}
332
333
c076fda8 334//-----------------------------------------------------------------------
335void AliFlowEventSimple::Print(Option_t *option) const
336{
337 // -*-*-*-*-*Print some global quantities for this histogram collection class *-*-*-*-*-*-*-*
338 // ===============================================
339 // printf( "TH1.Print Name = %s, Entries= %d, Total sum= %g\n",GetName(),Int_t(fEntries),GetSumOfWeights());
7183fe85 340 printf( "Class.Print Name = %s, Total number of tracks= %d, Number of selected tracks= %d, MC EventPlaneAngle= %f",
1918addd 341 GetName(),fNumberOfTracks, fEventNSelTracksRP, fMCReactionPlaneAngle );
c076fda8 342
343 if (fTrackCollection) {
344 fTrackCollection->Print(option);
345 }
346 else {
347 printf( "Empty track collection \n");
348 }
349}
350
351//-----------------------------------------------------------------------
352 void AliFlowEventSimple::Browse(TBrowser *b)
353{
354 if (!b) return;
355 if (!fNumberOfTracksWrap) {
356 fNumberOfTracksWrap = new TParameter<int>("fNumberOfTracks", fNumberOfTracks);
357 b->Add(fNumberOfTracksWrap);
358 }
1918addd 359 if (!fEventNSelTracksRPWrap) {
360 fEventNSelTracksRPWrap = new TParameter<int>("fEventNSelTracksRP", fEventNSelTracksRP);
361 b->Add(fEventNSelTracksRPWrap);
c076fda8 362 }
a12990bb 363 if (!fMCReactionPlaneAngleWrap) {
7183fe85 364 fMCReactionPlaneAngleWrap = new TParameter<double>(" fMCReactionPlaneAngle", fMCReactionPlaneAngle);
a12990bb 365 b->Add( fMCReactionPlaneAngleWrap);
366 }
c076fda8 367 if (fTrackCollection) b->Add(fTrackCollection,"AliFlowTracksSimple");
368}
369
395fadba 370