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