Coding rules and bug fix in AliMUONTriggerGUI (select the right digit store from...
[u/mrichter/AliRoot.git] / PWG2 / FLOW / 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"
f1d945a1 19#include "TMath.h"
26c4cbb9 20#include "TH1F.h"
21#include "TH1D.h"
22#include "TProfile.h"
f1d945a1 23#include "AliFlowVector.h"
24#include "AliFlowTrackSimple.h"
25#include "AliFlowEventSimple.h"
26
26c4cbb9 27/**************************************
28 * AliFlowEventSimple: A simple event *
29 * for flow analysis *
30 * *
31 * authors: Naomi van der Kolk *
32 * (kolk@nikhef.nl) *
33 * Ante Bilandzic *
34 * (anteb@nikhef.nl) *
35 * ***********************************/
36
f1d945a1 37ClassImp(AliFlowEventSimple)
38
39//-----------------------------------------------------------------------
40
e35ddff0 41 AliFlowEventSimple::AliFlowEventSimple(Int_t aLenght):
d29ba078 42 fTrackCollection(NULL),
f1d945a1 43 fNumberOfTracks(0),
26c4cbb9 44 fEventNSelTracksIntFlow(0),
45 fUseWeightsPhi(kFALSE),
46 fUseWeightsPt(kFALSE),
47 fUseWeightsEta(kFALSE),
48 fPhiWeights(NULL),
49 fPtWeights(NULL),
50 fEtaWeights(NULL)
f1d945a1 51{
52 //constructor
e35ddff0 53 fTrackCollection = new TObjArray(aLenght) ;
f1d945a1 54}
55
56//-----------------------------------------------------------------------
57
e35ddff0 58AliFlowEventSimple::AliFlowEventSimple(const AliFlowEventSimple& anEvent):
bc6b015e 59 TObject(),
e35ddff0 60 fTrackCollection(anEvent.fTrackCollection),
61 fNumberOfTracks(anEvent.fNumberOfTracks),
26c4cbb9 62 fEventNSelTracksIntFlow(anEvent.fEventNSelTracksIntFlow),
63 fUseWeightsPhi(anEvent.fUseWeightsPhi),
64 fUseWeightsPt(anEvent.fUseWeightsPt),
65 fUseWeightsEta(anEvent.fUseWeightsEta),
66 fPhiWeights(anEvent.fPhiWeights),
67 fPtWeights(anEvent.fPtWeights),
68 fEtaWeights(anEvent.fEtaWeights)
f1d945a1 69{
70 //copy constructor
f1d945a1 71}
72
73//-----------------------------------------------------------------------
74
e35ddff0 75AliFlowEventSimple& AliFlowEventSimple::operator=(const AliFlowEventSimple& anEvent)
f1d945a1 76{
26c4cbb9 77 *fTrackCollection = *anEvent.fTrackCollection ;
e35ddff0 78 fNumberOfTracks = anEvent.fNumberOfTracks;
79 fEventNSelTracksIntFlow = anEvent.fEventNSelTracksIntFlow;
26c4cbb9 80 fUseWeightsPhi = anEvent.fUseWeightsPhi;
81 fUseWeightsPt = anEvent.fUseWeightsPt;
82 fUseWeightsEta = anEvent.fUseWeightsEta;
83 fPhiWeights = anEvent.fPhiWeights;
84 fPtWeights = anEvent.fPtWeights;
85 fEtaWeights = anEvent.fEtaWeights;
86
f1d945a1 87 return *this;
f1d945a1 88}
89
f1d945a1 90//-----------------------------------------------------------------------
91
92AliFlowEventSimple::~AliFlowEventSimple()
93{
94 //destructor
95 fTrackCollection->Delete() ; delete fTrackCollection ;
96}
97
98//-----------------------------------------------------------------------
99
100AliFlowTrackSimple* AliFlowEventSimple::GetTrack(Int_t i)
101{
102 //get track i from collection
e35ddff0 103 AliFlowTrackSimple* pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i) ;
104 return pTrack;
f1d945a1 105}
106
107//-----------------------------------------------------------------------
26c4cbb9 108AliFlowVector AliFlowEventSimple::GetQ(Int_t n)
f1d945a1 109{
26c4cbb9 110 //calculate Q-vector in harmonic n without weights (default harmonic n=2)
e35ddff0 111 Double_t dQX = 0.;
112 Double_t dQY = 0.;
113 AliFlowVector vQ;
114 vQ.Set(0.,0.);
9825d4a9 115
116 Int_t iOrder = n;
e35ddff0 117 Int_t iUsedTracks = 0;
26c4cbb9 118 Double_t dPhi=0.;
119 Double_t dPt=0;
120 Double_t dEta=0;
121
122 AliFlowTrackSimple* pTrack = NULL;
123
124 Int_t nBinsPhi=0;
125 Double_t dBinWidthPt=0.;
126 Double_t dNormPt=0.;
127 Double_t dBinWidthEta=0.;
128 Double_t dNormEta=0.;
129
130 Double_t wPhi=1.; //weight Phi
131 Double_t wPt=1.; //weight Pt
132 Double_t wEta=1.; //weight Eta
133
134 if(fUseWeightsPhi)
135 {
136 if(fPhiWeights)
137 {
138 nBinsPhi = fPhiWeights->GetNbinsX();
139 }else{cout<<" WARNING: couldn't find histogram phi_weights in the file weightsForTheSecondRun.root"<<endl;}
140 }
141
142 if(fUseWeightsPt)
143 {
144 if(fPtWeights)
145 {
146 dBinWidthPt = fPtWeights->GetBinWidth(1);//assuming that all bins have the same width
147 dNormPt = fPtWeights->Integral();
148 }else{cout<<" WARNING: couldn't find histogram pt_weights in the file weightsForTheSecondRun.root"<<endl;}
149 }
150
151 if(fUseWeightsEta)
152 {
153 if(fEtaWeights)
154 {
155 dBinWidthEta = fEtaWeights->GetBinWidth(1);//assuming that all bins have the same width
156 dNormEta = fEtaWeights->Integral();
157 }else{cout<<" WARNING: couldn't find histogram eta_weights in the file weightsForTheSecondRun.root"<<endl;}
158 }
159
160 for(Int_t i=0;i<fNumberOfTracks;i++)
161 {
162 pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i);
163 if(pTrack)
164 {
165 if(pTrack->UseForIntegratedFlow())
f1d945a1 166 {
26c4cbb9 167 dPhi = pTrack->Phi();
168 dPt = pTrack->Pt();
169 dEta = pTrack->Eta();
170 //determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
171 if(fUseWeightsPhi && fPhiWeights && (nBinsPhi!=0) && (fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*nBinsPhi/TMath::TwoPi())))!=0))
172 {
173 wPhi=pow(nBinsPhi*fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*nBinsPhi/TMath::TwoPi()))),-1);
174 }
175 //determine v'(pt) weight:
176 if(fUseWeightsPt && fPtWeights && dBinWidthPt && dNormPt)
177 {
178 wPt=fPtWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPt/dBinWidthPt)))/dNormPt;
179 }
180 //determine v'(eta) weight:
181 if(fUseWeightsEta && fEtaWeights && dBinWidthEta && dNormEta)
182 {
183 wEta=fEtaWeights->GetBinContent(1+(Int_t)(TMath::Floor(dEta/dBinWidthEta)))/dNormEta;
184 }
185 //building up the weighted Q-vector:
186 dQX += wPhi*wPt*wEta*TMath::Cos(iOrder*dPhi);
187 dQY += wPhi*wPt*wEta*TMath::Sin(iOrder*dPhi);
188 iUsedTracks++;
189 }//end of if (pTrack->UseForIntegratedFlow())
190 }//end of if (pTrack)
191 else {cerr << "no particle!!!"<<endl;}
192 }//loop over particles
193
e35ddff0 194 vQ.Set(dQX,dQY);
195 vQ.SetMult(iUsedTracks);
26c4cbb9 196
e35ddff0 197 return vQ;
f1d945a1 198
5fef318d 199}
200
201
26c4cbb9 202
203
204
205
206
207
208
209