]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDtrack.cxx
Improve default constructor
[u/mrichter/AliRoot.git] / STEER / AliESDtrack.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 //-----------------------------------------------------------------
17 //           Implementation of the ESD track class
18 //   This is the class to deal with during the phisical analysis of data
19 //
20 //      Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
21 //-----------------------------------------------------------------
22
23 #include "TMath.h"
24
25 #include "AliESDtrack.h"
26 #include "AliKalmanTrack.h"
27 #include "../ITS/AliITStrackV2.h"
28
29 ClassImp(AliESDtrack)
30
31 //_______________________________________________________________________
32 AliESDtrack::AliESDtrack() : 
33 fFlags(0),
34 fLabel(0),
35 fTrackLength(0),
36 fStopVertex(0),
37 fRalpha(0),
38 fRx(0),
39 fITSchi2(0),
40 fITSncls(0),
41 fITSsignal(0),
42 fVertexX(0),
43 fVertexY(0),
44 fVertexZ(0),
45 fVertexPx(0),
46 fVertexPy(0),
47 fVertexPz(0),
48 fVertex(kFALSE),
49 fTPCchi2(0),
50 fTPCncls(0),
51 fTPCsignal(0),
52 fTRDchi2(0),
53 fTRDncls(0),
54 fTRDsignal(0),
55 fTOFchi2(0),
56 fTOFindex(0),
57 fTOFsignal(0)
58 {
59   //
60   // The default ESD constructor 
61   //
62   for (Int_t i=0; i<kSPECIES; i++) {
63     fTrackTime[i]=0;
64     fR[i]=0;
65     fITSr[i]=0;
66     fTPCr[i]=0;
67     fTRDr[i]=0;
68     fTOFr[i]=0;
69   }
70   for (Int_t i=0; i<5; fRp[i++]);
71   for (Int_t i=0; i<15; fRc[i++]);
72   for (Int_t i=0; i<6; fITSindex[i++]);
73   for (Int_t i=0; i<180; fTPCindex[i++]);
74 }
75
76 //_______________________________________________________________________
77 Float_t AliESDtrack::GetMass() const {
78   Float_t max=0.;
79   Int_t k=-1;
80   for (Int_t i=0; i<kSPECIES; i++) {
81     if (fR[i]>max) {k=i; max=fR[i];}
82   }
83   if (k==0) return 0.00051;
84   if (k==1) return 0.10566;
85   if (k==2||k==-1) return 0.13957;
86   if (k==3) return 0.49368;
87   if (k==4) return 0.93827;
88   Warning("GetMass()","Undefined mass !");
89   return 0.13957;
90 }
91
92 //_______________________________________________________________________
93 Bool_t AliESDtrack::UpdateTrackParams(AliKalmanTrack *t, ULong_t flags) {
94   //
95   // This function updates track's running parameters 
96   //
97   switch (flags) {
98     
99   case kITSin:
100   case kITSout: 
101   case kITSrefit:
102     fITSncls=t->GetNumberOfClusters();
103     fITSchi2=t->GetChi2();
104     for (Int_t i=0;i<fITSncls;i++) fITSindex[i]=t->GetClusterIndex(i);
105     fITSsignal=t->GetPIDsignal();
106     break;
107     
108   case kTPCin: case kTPCout: case kTPCrefit:
109     fTPCncls=t->GetNumberOfClusters();
110     fTPCchi2=t->GetChi2();
111     for (Int_t i=0;i<fTPCncls;i++) fTPCindex[i]=t->GetClusterIndex(i);
112     fTPCsignal=t->GetPIDsignal();
113     {Double_t mass=t->GetMass();    // preliminary mass setting 
114     if (mass>0.5) fR[4]=1.;         //        used by
115     else if (mass<0.4) fR[2]=1.;    // the ITS reconstruction
116     else fR[3]=1.;}                 //
117     break;
118   case kTRDin: case kTRDout: case kTRDrefit:
119     fTRDncls=t->GetNumberOfClusters();
120     fTRDchi2=t->GetChi2();
121     fTRDsignal=t->GetPIDsignal();
122     break;
123   default: 
124     Error("UpdateTrackParams()","Wrong flag !\n");
125     return kFALSE;
126   }
127
128   SetStatus(flags);
129   fLabel=t->GetLabel();
130
131   if (t->IsStartedTimeIntegral()) {
132     SetStatus(kTIME);
133     Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
134     SetIntegratedLength(t->GetIntegratedLength());
135   }
136
137   fRalpha=t->GetAlpha();
138   t->GetExternalParameters(fRx,fRp);
139   t->GetExternalCovariance(fRc);
140   
141   if (flags == kITSin)
142    {
143      AliITStrackV2* itstrack = dynamic_cast<AliITStrackV2*>(t);
144      if (itstrack)
145       {
146         itstrack->PropagateTo(3.,0.0028,65.19);
147         itstrack->PropagateToVertex();
148         
149         Double_t ralpha=t->GetAlpha();
150         Double_t rx;      // X-coordinate of the track reference plane 
151         Double_t rp[5];   // external track parameters  
152         t->GetExternalParameters(rx,rp);
153    
154         Double_t phi=TMath::ASin(rp[2]) + ralpha;
155         Double_t pt=1./TMath::Abs(rp[4]);
156         Double_t r=TMath::Sqrt(rx*rx + rp[0]*rp[0]);
157         
158         fVertexX=r*TMath::Cos(phi); 
159         fVertexY=r*TMath::Sin(phi); 
160         fVertexZ=rp[1]; 
161         
162         fVertexPx = pt*TMath::Cos(phi); 
163         fVertexPy = pt*TMath::Sin(phi); 
164         fVertexPz = pt*rp[3]; 
165         fVertex = kTRUE;
166       }
167    }
168   
169   return kTRUE;
170 }
171
172 //_______________________________________________________________________
173 void AliESDtrack::GetExternalParametersAt(Double_t x, Double_t p[5]) const {
174   //---------------------------------------------------------------------
175   // This function returns external representation of the track parameters
176   // at the plane x
177   //---------------------------------------------------------------------
178   Double_t dx=x-fRx;
179   Double_t c=fRp[4]/AliKalmanTrack::GetConvConst();
180   Double_t f1=fRp[2], f2=f1 + c*dx;
181   Double_t r1=sqrt(1.- f1*f1), r2=sqrt(1.- f2*f2);    
182
183   p[0]=fRp[0]+dx*(f1+f2)/(r1+r2);
184   p[1]=fRp[1]+dx*(f1+f2)/(f1*r2 + f2*r1)*fRp[3];
185   p[2]=fRp[2]+dx*c;
186   p[3]=fRp[3];
187   p[4]=fRp[4];
188 }
189
190 //_______________________________________________________________________
191 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
192   //---------------------------------------------------------------------
193   // This function returns external representation of the track parameters
194   //---------------------------------------------------------------------
195   x=fRx;
196   for (Int_t i=0; i<5; i++) p[i]=fRp[i];
197 }
198
199 Double_t AliESDtrack::GetP() const {
200   //---------------------------------------------------------------------
201   // This function returns the track momentum
202   //---------------------------------------------------------------------
203   Double_t lam=TMath::ATan(fRp[3]);
204   Double_t pt=1./TMath::Abs(fRp[4]);
205   return pt/TMath::Cos(lam);
206 }
207
208 void AliESDtrack::GetPxPyPz(Double_t *p) const {
209   //---------------------------------------------------------------------
210   // This function returns the global track momentum components
211   //---------------------------------------------------------------------
212   Double_t phi=TMath::ASin(fRp[2]) + fRalpha;
213   Double_t pt=1./TMath::Abs(fRp[4]);
214   p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fRp[3]; 
215 }
216
217 void AliESDtrack::GetXYZ(Double_t *xyz) const {
218   //---------------------------------------------------------------------
219   // This function returns the global track position
220   //---------------------------------------------------------------------
221   Double_t phi=TMath::ASin(fRp[2]) + fRalpha;
222   Double_t r=TMath::Sqrt(fRx*fRx + fRp[0]*fRp[0]);
223   xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fRp[1]; 
224 }
225
226 //_______________________________________________________________________
227 void AliESDtrack::GetExternalCovariance(Double_t c[15]) const {
228   //---------------------------------------------------------------------
229   // This function returns external representation of the cov. matrix
230   //---------------------------------------------------------------------
231   for (Int_t i=0; i<15; i++) c[i]=fRc[i];
232 }
233
234 //_______________________________________________________________________
235 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
236   for (Int_t i=0; i<kSPECIES; i++) times[i]=fTrackTime[i];
237 }
238
239 //_______________________________________________________________________
240 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
241   for (Int_t i=0; i<kSPECIES; i++) fTrackTime[i]=times[i];
242 }
243
244 //_______________________________________________________________________
245 void AliESDtrack::SetITSpid(const Double_t *p) {  
246   for (Int_t i=0; i<kSPECIES; i++) fITSr[i]=p[i];
247   SetStatus(AliESDtrack::kITSpid);
248 }
249
250 //_______________________________________________________________________
251 void AliESDtrack::GetITSpid(Double_t *p) const {
252   for (Int_t i=0; i<kSPECIES; i++) p[i]=fITSr[i];
253 }
254
255 //_______________________________________________________________________
256 Int_t AliESDtrack::GetITSclusters(UInt_t *idx) const {
257   //---------------------------------------------------------------------
258   // This function returns indices of the assgined ITS clusters 
259   //---------------------------------------------------------------------
260   for (Int_t i=0; i<fITSncls; i++) idx[i]=fITSindex[i];
261   return fITSncls;
262 }
263
264 //_______________________________________________________________________
265 Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
266   //---------------------------------------------------------------------
267   // This function returns indices of the assgined ITS clusters 
268   //---------------------------------------------------------------------
269   for (Int_t i=0; i<180; i++) idx[i]=fTPCindex[i];  // MI I prefer some constant
270   return fTPCncls;
271 }
272
273 //_______________________________________________________________________
274 void AliESDtrack::SetTPCpid(const Double_t *p) {  
275   for (Int_t i=0; i<kSPECIES; i++) fTPCr[i]=p[i];
276   SetStatus(AliESDtrack::kTPCpid);
277 }
278
279 //_______________________________________________________________________
280 void AliESDtrack::GetTPCpid(Double_t *p) const {
281   for (Int_t i=0; i<kSPECIES; i++) p[i]=fTPCr[i];
282 }
283
284 //_______________________________________________________________________
285 void AliESDtrack::SetTRDpid(const Double_t *p) {  
286   for (Int_t i=0; i<kSPECIES; i++) fTRDr[i]=p[i];
287   SetStatus(AliESDtrack::kTRDpid);
288 }
289
290 //_______________________________________________________________________
291 void AliESDtrack::GetTRDpid(Double_t *p) const {
292   for (Int_t i=0; i<kSPECIES; i++) p[i]=fTRDr[i];
293 }
294
295 //_______________________________________________________________________
296 void    AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
297 {
298   fTRDr[iSpecies] = p;
299 }
300
301 Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
302 {
303   return fTRDr[iSpecies];
304 }
305
306 //_______________________________________________________________________
307 void AliESDtrack::SetTOFpid(const Double_t *p) {  
308   for (Int_t i=0; i<kSPECIES; i++) fTOFr[i]=p[i];
309   SetStatus(AliESDtrack::kTOFpid);
310 }
311
312 //_______________________________________________________________________
313 void AliESDtrack::GetTOFpid(Double_t *p) const {
314   for (Int_t i=0; i<kSPECIES; i++) p[i]=fTOFr[i];
315 }
316
317 //_______________________________________________________________________
318 void AliESDtrack::SetESDpid(const Double_t *p) {  
319   for (Int_t i=0; i<kSPECIES; i++) fR[i]=p[i];
320   SetStatus(AliESDtrack::kESDpid);
321 }
322
323 //_______________________________________________________________________
324 void AliESDtrack::GetESDpid(Double_t *p) const {
325   for (Int_t i=0; i<kSPECIES; i++) p[i]=fR[i];
326 }
327
328 void AliESDtrack::GetVertexXYZ(Double_t& x,Double_t& y, Double_t&z) const
329 {
330 //returns track position in DCA to vertex  
331   x = fVertexX;
332   y = fVertexY;
333   z = fVertexZ;
334 }
335 void AliESDtrack::GetVertexPxPyPz(Double_t& px,Double_t& py, Double_t& pz) const
336 {
337 //returns track momentum in DCA to vertex  
338   px = fVertexPx;
339   py = fVertexPy;
340   pz = fVertexPz;
341 }