]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.cxx
fixes initialization
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / 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   fFlowBits(0),
43   fSubEventBits(0)
44 {
45   //constructor 
46 }
47
48 //-----------------------------------------------------------------------
49 AliFlowTrackSimple::AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt, Double_t weight, Int_t charge):
50   TObject(),
51   fEta(eta),
52   fPt(pt),
53   fPhi(phi),
54   fTrackWeight(weight),
55   fCharge(charge),
56   fFlowBits(0),
57   fSubEventBits(0)
58 {
59   //constructor 
60 }
61
62 //-----------------------------------------------------------------------
63 AliFlowTrackSimple::AliFlowTrackSimple( TParticle* p ):
64   TObject(),
65   fEta(p->Eta()),
66   fPt(p->Pt()),
67   fPhi(p->Phi()),
68   fTrackWeight(1.),
69   fCharge(0),
70   fFlowBits(0),
71   fSubEventBits(0)
72 {
73   //ctor
74   TParticlePDG* ppdg = p->GetPDG();
75   fCharge = TMath::Nint(ppdg->Charge()/3.0);
76 }
77
78 //-----------------------------------------------------------------------
79 AliFlowTrackSimple::AliFlowTrackSimple(const AliFlowTrackSimple& aTrack):
80   TObject(aTrack),
81   fEta(aTrack.fEta),
82   fPt(aTrack.fPt),
83   fPhi(aTrack.fPhi),
84   fTrackWeight(aTrack.fTrackWeight),
85   fCharge(aTrack.fCharge),
86   fFlowBits(aTrack.fFlowBits),
87   fSubEventBits(aTrack.fSubEventBits)
88 {
89   //copy constructor 
90 }
91
92 //-----------------------------------------------------------------------
93 AliFlowTrackSimple* AliFlowTrackSimple::Clone(const char* /*option*/) const
94 {
95   //clone "constructor"
96   return new AliFlowTrackSimple(*this);
97 }
98
99 //-----------------------------------------------------------------------
100 AliFlowTrackSimple& AliFlowTrackSimple::operator=(const AliFlowTrackSimple& aTrack)
101 {
102   fEta = aTrack.fEta;
103   fPt = aTrack.fPt;
104   fPhi = aTrack.fPhi;
105   fTrackWeight = aTrack.fTrackWeight;
106   fCharge = aTrack.fCharge;
107   fFlowBits = aTrack.fFlowBits;
108   fSubEventBits = aTrack.fSubEventBits;
109
110   return *this;
111 }
112
113 //----------------------------------------------------------------------- 
114 AliFlowTrackSimple::~AliFlowTrackSimple()
115 {
116   //destructor
117   
118 }
119
120 //----------------------------------------------------------------------- 
121 void AliFlowTrackSimple::ResolutionPt(Double_t res)
122 {
123   //smear the pt by a gaussian with sigma=res
124   fPt += gRandom->Gaus(0.,res);
125 }
126
127 //----------------------------------------------------------------------- 
128 void AliFlowTrackSimple::AddV1( Double_t v1,
129                                 Double_t reactionPlaneAngle,
130                                 Double_t precisionPhi,
131                                 Int_t maxNumberOfIterations )
132 {
133   //afterburner, adds v1, uses Newton-Raphson iteration
134   Double_t phi0=fPhi;
135   Double_t f=0.;
136   Double_t fp=0.;
137   Double_t phiprev=0.;
138
139   for (Int_t i=0; i<maxNumberOfIterations; i++)
140   {
141     phiprev=fPhi; //store last value for comparison
142     f =  fPhi-phi0+2.0*v1*TMath::Sin(fPhi-reactionPlaneAngle);
143     fp = 1.0+2.0*v1*TMath::Cos(fPhi-reactionPlaneAngle); //first derivative
144     fPhi -= f/fp;
145     if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
146   }
147 }
148
149 //----------------------------------------------------------------------- 
150 void AliFlowTrackSimple::AddV2( Double_t v2,
151                                 Double_t reactionPlaneAngle,
152                                 Double_t precisionPhi,
153                                 Int_t maxNumberOfIterations )
154 {
155   //afterburner, adds v2, uses Newton-Raphson iteration
156   Double_t phi0=fPhi;
157   Double_t f=0.;
158   Double_t fp=0.;
159   Double_t phiprev=0.;
160
161   for (Int_t i=0; i<maxNumberOfIterations; i++)
162   {
163     phiprev=fPhi; //store last value for comparison
164     f =  fPhi-phi0+v2*TMath::Sin(2.*(fPhi-reactionPlaneAngle));
165     fp = 1.0+2.0*v2*TMath::Cos(2.*(fPhi-reactionPlaneAngle)); //first derivative
166     fPhi -= f/fp;
167     if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
168   }
169 }
170
171 //----------------------------------------------------------------------- 
172 void AliFlowTrackSimple::AddV4( Double_t v4,
173                                 Double_t reactionPlaneAngle,
174                                 Double_t precisionPhi,
175                                 Int_t maxNumberOfIterations )
176 {
177   //afterburner, adds v4, uses Newton-Raphson iteration
178   Double_t phi0=fPhi;
179   Double_t f=0.;
180   Double_t fp=0.;
181   Double_t phiprev=0.;
182
183   for (Int_t i=0; i<maxNumberOfIterations; i++)
184   {
185     phiprev=fPhi; //store last value for comparison
186     f =  fPhi-phi0+0.5*v4*TMath::Sin(4.*(fPhi-reactionPlaneAngle));
187     fp = 1.0+2.0*v4*TMath::Cos(4.*(fPhi-reactionPlaneAngle)); //first derivative
188     fPhi -= f/fp;
189     if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
190   }
191 }
192
193 //______________________________________________________________________________
194 void AliFlowTrackSimple::AddFlow( Double_t v1,
195                                   Double_t v2,
196                                   Double_t v4,
197                                   Double_t reactionPlaneAngle,
198                                   Double_t precisionPhi,
199                                   Int_t maxNumberOfIterations )
200 {
201   //afterburner, adds v1,v2,v4 uses Newton-Raphson iteration
202   Double_t phi0=fPhi;
203   Double_t f=0.;
204   Double_t fp=0.;
205   Double_t phiprev=0.;
206
207   for (Int_t i=0; i<maxNumberOfIterations; i++)
208   {
209     phiprev=fPhi; //store last value for comparison
210     f =  fPhi-phi0
211         +2.0*v1*TMath::Sin(fPhi-reactionPlaneAngle)
212         +    v2*TMath::Sin(2.*(fPhi-reactionPlaneAngle))
213         +0.5*v4*TMath::Sin(4.*(fPhi-reactionPlaneAngle))
214         ;
215     fp =  1.0
216          +2.0*(
217            +v1*TMath::Cos(fPhi-reactionPlaneAngle)
218            +v2*TMath::Cos(2.*(fPhi-reactionPlaneAngle))
219            +v4*TMath::Cos(4.*(fPhi-reactionPlaneAngle))
220          ); //first derivative
221     fPhi -= f/fp;
222     if (TMath::AreEqualAbs(phiprev,fPhi,precisionPhi)) break;
223   }
224 }
225
226 //______________________________________________________________________________
227 void AliFlowTrackSimple::Print( Option_t* /*option*/ ) const
228 {
229   //print stuff
230   printf("Phi: %.3f, Eta: %+.3f, Pt: %.3f, weight: %.3f",fPhi,fEta,fPt,fTrackWeight);
231   if (InRPSelection()) printf(", RP");
232   if (InPOISelection()) printf(", POI");
233   for (Int_t i=0; i<2; i++)
234   {
235     if (InSubevent(i)) printf(", subevent %i",i);
236   }
237   printf("\n");
238 }