]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.cxx
rulechecker fixes from Mikolaj
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowTrackSimple.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
16/* $Id$ */
17
f1d945a1 18// AliFlowTrackSimple:
19// A simple track class to the the AliFlowEventSimple for flow analysis
20//
21//
22// author: N. van der Kolk (kolk@nikhef.nl)
929098e4 23// mods: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch)
f1d945a1 24
bc231a12 25#include "TObject.h"
929098e4 26#include "TParticle.h"
701f71c1 27#include "TParticlePDG.h"
929098e4 28#include "AliFlowTrackSimple.h"
7382279b 29#include "TRandom.h"
701f71c1 30#include "TMath.h"
f1d945a1 31
32ClassImp(AliFlowTrackSimple)
33
34//-----------------------------------------------------------------------
929098e4 35AliFlowTrackSimple::AliFlowTrackSimple():
bc231a12 36 TObject(),
f1d945a1 37 fEta(0),
38 fPt(0),
39 fPhi(0),
44e060e0 40 fTrackWeight(1.),
701f71c1 41 fCharge(0),
fb03b63f 42 fFlowBits(0),
6e214c87 43 fSubEventBits(0),
41dc4195 44 fID(-1)
f1d945a1 45{
46 //constructor
929098e4 47}
48
244c607a 49//-----------------------------------------------------------------------
701f71c1 50AliFlowTrackSimple::AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt, Double_t weight, Int_t charge):
bc231a12 51 TObject(),
244c607a 52 fEta(eta),
53 fPt(pt),
54 fPhi(phi),
44e060e0 55 fTrackWeight(weight),
701f71c1 56 fCharge(charge),
244c607a 57 fFlowBits(0),
6e214c87 58 fSubEventBits(0),
41dc4195 59 fID(-1)
244c607a 60{
61 //constructor
62}
63
929098e4 64//-----------------------------------------------------------------------
701f71c1 65AliFlowTrackSimple::AliFlowTrackSimple( TParticle* p ):
bc231a12 66 TObject(),
929098e4 67 fEta(p->Eta()),
68 fPt(p->Pt()),
69 fPhi(p->Phi()),
44e060e0 70 fTrackWeight(1.),
701f71c1 71 fCharge(0),
929098e4 72 fFlowBits(0),
6e214c87 73 fSubEventBits(0),
41dc4195 74 fID(-1)
929098e4 75{
76 //ctor
701f71c1 77 TParticlePDG* ppdg = p->GetPDG();
78 fCharge = TMath::Nint(ppdg->Charge()/3.0);
f1d945a1 79}
80
7d27a354 81//-----------------------------------------------------------------------
82void AliFlowTrackSimple::Set(TParticle* p)
83{
84 //set from a TParticle
85 fEta = p->Eta();
86 fPt = p->Pt();
87 fPhi = p->Phi();
88 fTrackWeight = 1.;
89 TParticlePDG* ppdg = p->GetPDG();
90 fCharge = TMath::Nint(ppdg->Charge()/3.0);
91}
92
bc6b015e 93//-----------------------------------------------------------------------
bc6b015e 94AliFlowTrackSimple::AliFlowTrackSimple(const AliFlowTrackSimple& aTrack):
bc231a12 95 TObject(aTrack),
bc6b015e 96 fEta(aTrack.fEta),
97 fPt(aTrack.fPt),
98 fPhi(aTrack.fPhi),
44e060e0 99 fTrackWeight(aTrack.fTrackWeight),
701f71c1 100 fCharge(aTrack.fCharge),
fb03b63f 101 fFlowBits(aTrack.fFlowBits),
6e214c87 102 fSubEventBits(aTrack.fSubEventBits),
41dc4195 103 fID(aTrack.fID)
bc6b015e 104{
105 //copy constructor
106}
bc231a12 107
bc6b015e 108//-----------------------------------------------------------------------
65ef7d1a 109AliFlowTrackSimple* AliFlowTrackSimple::Clone(const char* /*option*/) const
bc231a12 110{
111 //clone "constructor"
112 return new AliFlowTrackSimple(*this);
113}
bc6b015e 114
bc231a12 115//-----------------------------------------------------------------------
bc6b015e 116AliFlowTrackSimple& AliFlowTrackSimple::operator=(const AliFlowTrackSimple& aTrack)
117{
cc0afcfc 118 //assignment
bc6b015e 119 fEta = aTrack.fEta;
120 fPt = aTrack.fPt;
121 fPhi = aTrack.fPhi;
44e060e0 122 fTrackWeight = aTrack.fTrackWeight;
701f71c1 123 fCharge = aTrack.fCharge;
bc6b015e 124 fFlowBits = aTrack.fFlowBits;
fb03b63f 125 fSubEventBits = aTrack.fSubEventBits;
41dc4195 126 fID = aTrack.fID;
bc6b015e 127
128 return *this;
bc6b015e 129}
130
f1d945a1 131//-----------------------------------------------------------------------
f1d945a1 132AliFlowTrackSimple::~AliFlowTrackSimple()
133{
134 //destructor
135
136}
137
7382279b 138//-----------------------------------------------------------------------
244c607a 139void AliFlowTrackSimple::ResolutionPt(Double_t res)
7382279b 140{
244c607a 141 //smear the pt by a gaussian with sigma=res
142 fPt += gRandom->Gaus(0.,res);
7382279b 143}
144
145//-----------------------------------------------------------------------
bc231a12 146void AliFlowTrackSimple::AddV1( Double_t v1,
147 Double_t reactionPlaneAngle,
148 Double_t precisionPhi,
149 Int_t maxNumberOfIterations )
150{
151 //afterburner, adds v1, uses Newton-Raphson iteration
152 Double_t phi0=fPhi;
c855d803 153 Double_t f=0.;
154 Double_t fp=0.;
155 Double_t phiprev=0.;
bc231a12 156
157 for (Int_t i=0; i<maxNumberOfIterations; i++)
158 {
159 phiprev=fPhi; //store last value for comparison
160 f = fPhi-phi0+2.0*v1*TMath::Sin(fPhi-reactionPlaneAngle);
161 fp = 1.0+2.0*v1*TMath::Cos(fPhi-reactionPlaneAngle); //first derivative
162 fPhi -= f/fp;
163 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
164 }
165}
166
167//-----------------------------------------------------------------------
168void AliFlowTrackSimple::AddV2( Double_t v2,
169 Double_t reactionPlaneAngle,
170 Double_t precisionPhi,
171 Int_t maxNumberOfIterations )
7382279b 172{
244c607a 173 //afterburner, adds v2, uses Newton-Raphson iteration
174 Double_t phi0=fPhi;
c855d803 175 Double_t f=0.;
176 Double_t fp=0.;
177 Double_t phiprev=0.;
bc231a12 178
179 for (Int_t i=0; i<maxNumberOfIterations; i++)
180 {
181 phiprev=fPhi; //store last value for comparison
182 f = fPhi-phi0+v2*TMath::Sin(2.*(fPhi-reactionPlaneAngle));
183 fp = 1.0+2.0*v2*TMath::Cos(2.*(fPhi-reactionPlaneAngle)); //first derivative
184 fPhi -= f/fp;
185 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
186 }
187}
188
bff213ad 189//-----------------------------------------------------------------------
190void AliFlowTrackSimple::AddV3( Double_t v3,
191 Double_t reactionPlaneAngle,
192 Double_t precisionPhi,
193 Int_t maxNumberOfIterations )
194{
195 //afterburner, adds v3, uses Newton-Raphson iteration
196 Double_t phi0=fPhi;
197 Double_t f=0.;
198 Double_t fp=0.;
199 Double_t phiprev=0.;
200
201 for (Int_t i=0; i<maxNumberOfIterations; i++)
202 {
203 phiprev=fPhi; //store last value for comparison
204 f = fPhi-phi0+2./3.*v3*TMath::Sin(3.*(fPhi-reactionPlaneAngle));
205 fp = 1.0+2.0*v3*TMath::Cos(3.*(fPhi-reactionPlaneAngle)); //first derivative
206 fPhi -= f/fp;
207 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
208 }
209}
210
bc231a12 211//-----------------------------------------------------------------------
212void AliFlowTrackSimple::AddV4( Double_t v4,
213 Double_t reactionPlaneAngle,
214 Double_t precisionPhi,
215 Int_t maxNumberOfIterations )
216{
217 //afterburner, adds v4, uses Newton-Raphson iteration
218 Double_t phi0=fPhi;
c855d803 219 Double_t f=0.;
220 Double_t fp=0.;
221 Double_t phiprev=0.;
bc231a12 222
223 for (Int_t i=0; i<maxNumberOfIterations; i++)
224 {
225 phiprev=fPhi; //store last value for comparison
226 f = fPhi-phi0+0.5*v4*TMath::Sin(4.*(fPhi-reactionPlaneAngle));
227 fp = 1.0+2.0*v4*TMath::Cos(4.*(fPhi-reactionPlaneAngle)); //first derivative
228 fPhi -= f/fp;
229 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
230 }
231}
232
1a80f9f6 233//-----------------------------------------------------------------------
234void AliFlowTrackSimple::AddV5( Double_t v5,
235 Double_t reactionPlaneAngle,
236 Double_t precisionPhi,
237 Int_t maxNumberOfIterations )
238{
239 //afterburner, adds v4, uses Newton-Raphson iteration
240 Double_t phi0=fPhi;
241 Double_t f=0.;
242 Double_t fp=0.;
243 Double_t phiprev=0.;
244
245 for (Int_t i=0; i<maxNumberOfIterations; i++)
246 {
247 phiprev=fPhi; //store last value for comparison
248 f = fPhi-phi0+0.4*v5*TMath::Sin(5.*(fPhi-reactionPlaneAngle));
249 fp = 1.0+2.0*v5*TMath::Cos(5.*(fPhi-reactionPlaneAngle)); //first derivative
250 fPhi -= f/fp;
251 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
252 }
253}
254
255//______________________________________________________________________________
256void AliFlowTrackSimple::AddFlow( Double_t v1,
257 Double_t v2,
258 Double_t v3,
259 Double_t v4,
260 Double_t v5,
261 Double_t rp1,
262 Double_t rp2,
263 Double_t rp3,
264 Double_t rp4,
265 Double_t rp5,
266 Double_t precisionPhi,
267 Int_t maxNumberOfIterations )
268{
269 //afterburner, adds v1,v2,v4 uses Newton-Raphson iteration
270 Double_t phi0=fPhi;
271 Double_t f=0.;
272 Double_t fp=0.;
273 Double_t phiprev=0.;
274
275 for (Int_t i=0; i<maxNumberOfIterations; i++)
276 {
277 phiprev=fPhi; //store last value for comparison
278 f = fPhi-phi0
279 +2.0* v1*TMath::Sin( fPhi-rp1)
280 + v2*TMath::Sin(2.*(fPhi-rp2))
281 +2./3.*v3*TMath::Sin(3.*(fPhi-rp3))
282 +0.5* v4*TMath::Sin(4.*(fPhi-rp4))
283 +0.4* v5*TMath::Sin(5.*(fPhi-rp5))
284 ;
285 fp = 1.0
286 +2.0*(
287 +v1*TMath::Cos( fPhi-rp1)
288 +v2*TMath::Cos(2.*(fPhi-rp2))
289 +v3*TMath::Cos(3.*(fPhi-rp3))
290 +v4*TMath::Cos(4.*(fPhi-rp4))
291 +v5*TMath::Cos(5.*(fPhi-rp5))
292 ); //first derivative
293 fPhi -= f/fp;
294 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
295 }
296}
297
298//______________________________________________________________________________
299void AliFlowTrackSimple::AddFlow( Double_t v1,
300 Double_t v2,
301 Double_t v3,
302 Double_t v4,
303 Double_t v5,
304 Double_t rp,
305 Double_t precisionPhi,
306 Int_t maxNumberOfIterations )
307{
308 //afterburner, adds v1,v2,v4 uses Newton-Raphson iteration
309 AddFlow(v1,v2,v3,v4,v5,rp,rp,rp,rp,rp,precisionPhi,maxNumberOfIterations);
310}
311
bc231a12 312//______________________________________________________________________________
313void AliFlowTrackSimple::AddFlow( Double_t v1,
314 Double_t v2,
bff213ad 315 Double_t v3,
bc231a12 316 Double_t v4,
317 Double_t reactionPlaneAngle,
318 Double_t precisionPhi,
319 Int_t maxNumberOfIterations )
320{
321 //afterburner, adds v1,v2,v4 uses Newton-Raphson iteration
322 Double_t phi0=fPhi;
c855d803 323 Double_t f=0.;
324 Double_t fp=0.;
325 Double_t phiprev=0.;
244c607a 326
327 for (Int_t i=0; i<maxNumberOfIterations; i++)
328 {
329 phiprev=fPhi; //store last value for comparison
bc231a12 330 f = fPhi-phi0
bff213ad 331 +2.0* v1*TMath::Sin( fPhi-reactionPlaneAngle)
332 + v2*TMath::Sin(2.*(fPhi-reactionPlaneAngle))
333 +2./3.*v3*TMath::Sin(3.*(fPhi-reactionPlaneAngle))
334 +0.5* v4*TMath::Sin(4.*(fPhi-reactionPlaneAngle))
bc231a12 335 ;
336 fp = 1.0
337 +2.0*(
bff213ad 338 +v1*TMath::Cos( fPhi-reactionPlaneAngle)
bc231a12 339 +v2*TMath::Cos(2.*(fPhi-reactionPlaneAngle))
bff213ad 340 +v3*TMath::Cos(3.*(fPhi-reactionPlaneAngle))
bc231a12 341 +v4*TMath::Cos(4.*(fPhi-reactionPlaneAngle))
342 ); //first derivative
244c607a 343 fPhi -= f/fp;
344 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
345 }
7382279b 346}
bc231a12 347
348//______________________________________________________________________________
65ef7d1a 349void AliFlowTrackSimple::Print( Option_t* /*option*/ ) const
bc231a12 350{
351 //print stuff
44e060e0 352 printf("Phi: %.3f, Eta: %+.3f, Pt: %.3f, weight: %.3f",fPhi,fEta,fPt,fTrackWeight);
dd91b595 353 if (InRPSelection()) printf(", RP");
354 if (InPOISelection()) printf(", POI");
355 for (Int_t i=0; i<2; i++)
356 {
357 if (InSubevent(i)) printf(", subevent %i",i);
358 }
359 printf("\n");
bc231a12 360}
7d27a354 361
362//______________________________________________________________________________
363void AliFlowTrackSimple::Clear(Option_t*)
364{
365 //clear track
366 fEta=0.0;
367 fPt=0.0;
368 fPhi=0.0;
369 fTrackWeight=1.0;
370 fCharge=0;
371 fFlowBits.ResetAllBits();
372 fSubEventBits.ResetAllBits();
373 fID=-1;
374}