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