]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowCommon/AliFlowEventSimple.cxx
fixing coding violations from FC
[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//-----------------------------------------------------------------------
29195b69 226void AliFlowEventSimple::Get2Qsub(AliFlowVector* Qarray, Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
395fadba 227{
395fadba 228
229 // calculate Q-vector in harmonic n without weights (default harmonic n=2)
230 Double_t dQX = 0.;
231 Double_t dQY = 0.;
b125a454 232
395fadba 233 Int_t iOrder = n;
234 Double_t iUsedTracks = 0;
235 Double_t dPhi = 0.;
236 Double_t dPt = 0.;
237 Double_t dEta = 0.;
238
239 AliFlowTrackSimple* pTrack = NULL;
240
29195b69 241 Int_t iNbinsPhi = 0;
395fadba 242 Double_t dBinWidthPt = 0.;
243 Double_t dPtMin = 0.;
244 Double_t dBinWidthEta= 0.;
245 Double_t dEtaMin = 0.;
246
29195b69 247 Double_t dWphi = 1.; // weight Phi
248 Double_t dWpt = 1.; // weight Pt
249 Double_t dWeta = 1.; // weight Eta
395fadba 250
29195b69 251 TH1F* phiWeights = NULL;
252 TH1D* ptWeights = NULL;
253 TH1D* etaWeights = NULL;
cbbaf54a 254
29195b69 255 if(weightsList) {
256 if(usePhiWeights) {
257 phiWeights = dynamic_cast<TH1F *>(weightsList->FindObject("phi_weights"));
258 if(phiWeights) {
259 iNbinsPhi = phiWeights->GetNbinsX();
260 }
261 }
262 if(usePtWeights) {
263 ptWeights = dynamic_cast<TH1D *>(weightsList->FindObject("pt_weights"));
264 if(ptWeights) {
265 dBinWidthPt = ptWeights->GetBinWidth(1); // assuming that all bins have the same width
266 dPtMin = (ptWeights->GetXaxis())->GetXmin();
267 }
268 }
269 if(useEtaWeights) {
270 etaWeights = dynamic_cast<TH1D *>(weightsList->FindObject("eta_weights"));
271 if(etaWeights) {
272 dBinWidthEta = etaWeights->GetBinWidth(1); // assuming that all bins have the same width
273 dEtaMin = (etaWeights->GetXaxis())->GetXmin();
274 }
395fadba 275 }
276 } // end of if(weightsList)
277
b125a454 278 //loop over the two subevents
29195b69 279 for (Int_t s=0;s<2;s++) {
280 // loop over tracks
281 for(Int_t i=0;i<fNumberOfTracks;i++) {
282 pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i);
283 if(pTrack) {
284 if(pTrack->InRPSelection()) {
285 if (pTrack->InSubevent(s)) {
286 dPhi = pTrack->Phi();
287 dPt = pTrack->Pt();
288 dEta = pTrack->Eta();
b125a454 289
29195b69 290 // determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
291 if(phiWeights && iNbinsPhi) {
292 dWphi = phiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*iNbinsPhi/TMath::TwoPi())));
293 }
294 // determine v'(pt) weight:
295 if(ptWeights && dBinWidthPt) {
296 dWpt=ptWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-dPtMin)/dBinWidthPt)));
297 }
298 // determine v'(eta) weight:
299 if(etaWeights && dBinWidthEta) {
300 dWeta=etaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-dEtaMin)/dBinWidthEta)));
301 }
b125a454 302
29195b69 303 // building up the weighted Q-vector:
304 dQX += dWphi*dWpt*dWeta*TMath::Cos(iOrder*dPhi);
305 dQY += dWphi*dWpt*dWeta*TMath::Sin(iOrder*dPhi);
b125a454 306
29195b69 307 // weighted multiplicity:
308 iUsedTracks+=dWphi*dWpt*dWeta;
b125a454 309
29195b69 310 } // end of subevent
311 } // end of if (pTrack->InRPSelection())
312 } // end of if (pTrack)
313 else {cerr << "no particle!!!"<<endl;}
314 } // loop over particles
315 Qarray[s].Set(dQX,dQY);
316 Qarray[s].SetMult(iUsedTracks);
317 //reset
318 iUsedTracks = 0;
319 dQX = 0.;
320 dQY = 0.;
321 }
322
395fadba 323}
324
325
c076fda8 326//-----------------------------------------------------------------------
327void AliFlowEventSimple::Print(Option_t *option) const
328{
329 // -*-*-*-*-*Print some global quantities for this histogram collection class *-*-*-*-*-*-*-*
330 // ===============================================
331 // printf( "TH1.Print Name = %s, Entries= %d, Total sum= %g\n",GetName(),Int_t(fEntries),GetSumOfWeights());
7183fe85 332 printf( "Class.Print Name = %s, Total number of tracks= %d, Number of selected tracks= %d, MC EventPlaneAngle= %f",
1918addd 333 GetName(),fNumberOfTracks, fEventNSelTracksRP, fMCReactionPlaneAngle );
c076fda8 334
335 if (fTrackCollection) {
336 fTrackCollection->Print(option);
337 }
338 else {
339 printf( "Empty track collection \n");
340 }
341}
342
343//-----------------------------------------------------------------------
344 void AliFlowEventSimple::Browse(TBrowser *b)
345{
346 if (!b) return;
347 if (!fNumberOfTracksWrap) {
348 fNumberOfTracksWrap = new TParameter<int>("fNumberOfTracks", fNumberOfTracks);
349 b->Add(fNumberOfTracksWrap);
350 }
1918addd 351 if (!fEventNSelTracksRPWrap) {
352 fEventNSelTracksRPWrap = new TParameter<int>("fEventNSelTracksRP", fEventNSelTracksRP);
353 b->Add(fEventNSelTracksRPWrap);
c076fda8 354 }
a12990bb 355 if (!fMCReactionPlaneAngleWrap) {
7183fe85 356 fMCReactionPlaneAngleWrap = new TParameter<double>(" fMCReactionPlaneAngle", fMCReactionPlaneAngle);
a12990bb 357 b->Add( fMCReactionPlaneAngleWrap);
358 }
c076fda8 359 if (fTrackCollection) b->Add(fTrackCollection,"AliFlowTracksSimple");
360}
361
395fadba 362