]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/FLOW/Base/AliFlowTrackSimple.cxx
Moving/split PWG2/FLOW to PWGCF/FLOW, PWG/FLOW/Base, PWG/FLOW/Tasks, PWG/Glauber
[u/mrichter/AliRoot.git] / PWG / FLOW / Base / 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
2047680a 119 if (&aTrack==this) return *this; //handle self assignmnet
bc6b015e 120 fEta = aTrack.fEta;
121 fPt = aTrack.fPt;
122 fPhi = aTrack.fPhi;
44e060e0 123 fTrackWeight = aTrack.fTrackWeight;
701f71c1 124 fCharge = aTrack.fCharge;
bc6b015e 125 fFlowBits = aTrack.fFlowBits;
fb03b63f 126 fSubEventBits = aTrack.fSubEventBits;
41dc4195 127 fID = aTrack.fID;
bc6b015e 128
129 return *this;
bc6b015e 130}
131
f1d945a1 132//-----------------------------------------------------------------------
f1d945a1 133AliFlowTrackSimple::~AliFlowTrackSimple()
134{
135 //destructor
136
137}
138
7382279b 139//-----------------------------------------------------------------------
244c607a 140void AliFlowTrackSimple::ResolutionPt(Double_t res)
7382279b 141{
244c607a 142 //smear the pt by a gaussian with sigma=res
143 fPt += gRandom->Gaus(0.,res);
7382279b 144}
145
146//-----------------------------------------------------------------------
bc231a12 147void AliFlowTrackSimple::AddV1( Double_t v1,
148 Double_t reactionPlaneAngle,
149 Double_t precisionPhi,
150 Int_t maxNumberOfIterations )
151{
152 //afterburner, adds v1, uses Newton-Raphson iteration
153 Double_t phi0=fPhi;
c855d803 154 Double_t f=0.;
155 Double_t fp=0.;
156 Double_t phiprev=0.;
bc231a12 157
158 for (Int_t i=0; i<maxNumberOfIterations; i++)
159 {
160 phiprev=fPhi; //store last value for comparison
161 f = fPhi-phi0+2.0*v1*TMath::Sin(fPhi-reactionPlaneAngle);
162 fp = 1.0+2.0*v1*TMath::Cos(fPhi-reactionPlaneAngle); //first derivative
163 fPhi -= f/fp;
164 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
165 }
166}
167
168//-----------------------------------------------------------------------
169void AliFlowTrackSimple::AddV2( Double_t v2,
170 Double_t reactionPlaneAngle,
171 Double_t precisionPhi,
172 Int_t maxNumberOfIterations )
7382279b 173{
244c607a 174 //afterburner, adds v2, uses Newton-Raphson iteration
175 Double_t phi0=fPhi;
c855d803 176 Double_t f=0.;
177 Double_t fp=0.;
178 Double_t phiprev=0.;
bc231a12 179
180 for (Int_t i=0; i<maxNumberOfIterations; i++)
181 {
182 phiprev=fPhi; //store last value for comparison
183 f = fPhi-phi0+v2*TMath::Sin(2.*(fPhi-reactionPlaneAngle));
184 fp = 1.0+2.0*v2*TMath::Cos(2.*(fPhi-reactionPlaneAngle)); //first derivative
185 fPhi -= f/fp;
186 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
187 }
188}
189
bff213ad 190//-----------------------------------------------------------------------
191void AliFlowTrackSimple::AddV3( Double_t v3,
192 Double_t reactionPlaneAngle,
193 Double_t precisionPhi,
194 Int_t maxNumberOfIterations )
195{
196 //afterburner, adds v3, uses Newton-Raphson iteration
197 Double_t phi0=fPhi;
198 Double_t f=0.;
199 Double_t fp=0.;
200 Double_t phiprev=0.;
201
202 for (Int_t i=0; i<maxNumberOfIterations; i++)
203 {
204 phiprev=fPhi; //store last value for comparison
205 f = fPhi-phi0+2./3.*v3*TMath::Sin(3.*(fPhi-reactionPlaneAngle));
206 fp = 1.0+2.0*v3*TMath::Cos(3.*(fPhi-reactionPlaneAngle)); //first derivative
207 fPhi -= f/fp;
208 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
209 }
210}
211
bc231a12 212//-----------------------------------------------------------------------
213void AliFlowTrackSimple::AddV4( Double_t v4,
214 Double_t reactionPlaneAngle,
215 Double_t precisionPhi,
216 Int_t maxNumberOfIterations )
217{
218 //afterburner, adds v4, uses Newton-Raphson iteration
219 Double_t phi0=fPhi;
c855d803 220 Double_t f=0.;
221 Double_t fp=0.;
222 Double_t phiprev=0.;
bc231a12 223
224 for (Int_t i=0; i<maxNumberOfIterations; i++)
225 {
226 phiprev=fPhi; //store last value for comparison
227 f = fPhi-phi0+0.5*v4*TMath::Sin(4.*(fPhi-reactionPlaneAngle));
228 fp = 1.0+2.0*v4*TMath::Cos(4.*(fPhi-reactionPlaneAngle)); //first derivative
229 fPhi -= f/fp;
230 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
231 }
232}
233
1a80f9f6 234//-----------------------------------------------------------------------
235void AliFlowTrackSimple::AddV5( Double_t v5,
236 Double_t reactionPlaneAngle,
237 Double_t precisionPhi,
238 Int_t maxNumberOfIterations )
239{
240 //afterburner, adds v4, uses Newton-Raphson iteration
241 Double_t phi0=fPhi;
242 Double_t f=0.;
243 Double_t fp=0.;
244 Double_t phiprev=0.;
245
246 for (Int_t i=0; i<maxNumberOfIterations; i++)
247 {
248 phiprev=fPhi; //store last value for comparison
249 f = fPhi-phi0+0.4*v5*TMath::Sin(5.*(fPhi-reactionPlaneAngle));
250 fp = 1.0+2.0*v5*TMath::Cos(5.*(fPhi-reactionPlaneAngle)); //first derivative
251 fPhi -= f/fp;
252 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
253 }
254}
255
256//______________________________________________________________________________
257void AliFlowTrackSimple::AddFlow( Double_t v1,
258 Double_t v2,
259 Double_t v3,
260 Double_t v4,
261 Double_t v5,
262 Double_t rp1,
263 Double_t rp2,
264 Double_t rp3,
265 Double_t rp4,
266 Double_t rp5,
267 Double_t precisionPhi,
268 Int_t maxNumberOfIterations )
269{
270 //afterburner, adds v1,v2,v4 uses Newton-Raphson iteration
271 Double_t phi0=fPhi;
272 Double_t f=0.;
273 Double_t fp=0.;
274 Double_t phiprev=0.;
275
276 for (Int_t i=0; i<maxNumberOfIterations; i++)
277 {
278 phiprev=fPhi; //store last value for comparison
279 f = fPhi-phi0
280 +2.0* v1*TMath::Sin( fPhi-rp1)
281 + v2*TMath::Sin(2.*(fPhi-rp2))
282 +2./3.*v3*TMath::Sin(3.*(fPhi-rp3))
283 +0.5* v4*TMath::Sin(4.*(fPhi-rp4))
284 +0.4* v5*TMath::Sin(5.*(fPhi-rp5))
285 ;
286 fp = 1.0
287 +2.0*(
288 +v1*TMath::Cos( fPhi-rp1)
289 +v2*TMath::Cos(2.*(fPhi-rp2))
290 +v3*TMath::Cos(3.*(fPhi-rp3))
291 +v4*TMath::Cos(4.*(fPhi-rp4))
292 +v5*TMath::Cos(5.*(fPhi-rp5))
293 ); //first derivative
294 fPhi -= f/fp;
295 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
296 }
297}
298
299//______________________________________________________________________________
300void AliFlowTrackSimple::AddFlow( Double_t v1,
301 Double_t v2,
302 Double_t v3,
303 Double_t v4,
304 Double_t v5,
305 Double_t rp,
306 Double_t precisionPhi,
307 Int_t maxNumberOfIterations )
308{
309 //afterburner, adds v1,v2,v4 uses Newton-Raphson iteration
310 AddFlow(v1,v2,v3,v4,v5,rp,rp,rp,rp,rp,precisionPhi,maxNumberOfIterations);
311}
312
bc231a12 313//______________________________________________________________________________
314void AliFlowTrackSimple::AddFlow( Double_t v1,
315 Double_t v2,
bff213ad 316 Double_t v3,
bc231a12 317 Double_t v4,
318 Double_t reactionPlaneAngle,
319 Double_t precisionPhi,
320 Int_t maxNumberOfIterations )
321{
322 //afterburner, adds v1,v2,v4 uses Newton-Raphson iteration
323 Double_t phi0=fPhi;
c855d803 324 Double_t f=0.;
325 Double_t fp=0.;
326 Double_t phiprev=0.;
244c607a 327
328 for (Int_t i=0; i<maxNumberOfIterations; i++)
329 {
330 phiprev=fPhi; //store last value for comparison
bc231a12 331 f = fPhi-phi0
bff213ad 332 +2.0* v1*TMath::Sin( fPhi-reactionPlaneAngle)
333 + v2*TMath::Sin(2.*(fPhi-reactionPlaneAngle))
334 +2./3.*v3*TMath::Sin(3.*(fPhi-reactionPlaneAngle))
335 +0.5* v4*TMath::Sin(4.*(fPhi-reactionPlaneAngle))
bc231a12 336 ;
337 fp = 1.0
338 +2.0*(
bff213ad 339 +v1*TMath::Cos( fPhi-reactionPlaneAngle)
bc231a12 340 +v2*TMath::Cos(2.*(fPhi-reactionPlaneAngle))
bff213ad 341 +v3*TMath::Cos(3.*(fPhi-reactionPlaneAngle))
bc231a12 342 +v4*TMath::Cos(4.*(fPhi-reactionPlaneAngle))
343 ); //first derivative
244c607a 344 fPhi -= f/fp;
345 if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
346 }
7382279b 347}
bc231a12 348
349//______________________________________________________________________________
65ef7d1a 350void AliFlowTrackSimple::Print( Option_t* /*option*/ ) const
bc231a12 351{
352 //print stuff
44e060e0 353 printf("Phi: %.3f, Eta: %+.3f, Pt: %.3f, weight: %.3f",fPhi,fEta,fPt,fTrackWeight);
dd91b595 354 if (InRPSelection()) printf(", RP");
355 if (InPOISelection()) printf(", POI");
356 for (Int_t i=0; i<2; i++)
357 {
358 if (InSubevent(i)) printf(", subevent %i",i);
359 }
360 printf("\n");
bc231a12 361}
7d27a354 362
363//______________________________________________________________________________
364void AliFlowTrackSimple::Clear(Option_t*)
365{
366 //clear track
367 fEta=0.0;
368 fPt=0.0;
369 fPhi=0.0;
370 fTrackWeight=1.0;
371 fCharge=0;
372 fFlowBits.ResetAllBits();
373 fSubEventBits.ResetAllBits();
374 fID=-1;
375}