]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDtrack.cxx
Changes in RICH signal (Yu.Belikov, RICH)
[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 //           Implementation of the ESD track class
17 //   ESD = Event Summary Data
18 //   This is the class to deal with during the phisics analysis of data
19 //      Origin: Iouri Belikov, CERN
20 //      e-mail: Jouri.Belikov@cern.ch
21 //-----------------------------------------------------------------
22
23 #include "TMath.h"
24
25 #include "AliESDtrack.h"
26 #include "AliKalmanTrack.h"
27 #include "AliLog.h"
28
29 ClassImp(AliESDtrack)
30
31 //_______________________________________________________________________
32 AliESDtrack::AliESDtrack() : 
33 fFlags(0),
34 fLabel(0),
35 fID(0),
36 fTrackLength(0),
37 fD(0),
38 fZ(0),
39 fStopVertex(0),
40 fRalpha(0),
41 fRx(0),
42 fCalpha(0),
43 fCx(0),
44 fCchi2(1e10),
45 fIalpha(0),
46 fIx(0),
47 fTalpha(0),
48 fTx(0),
49 fITSchi2(0),
50 fITSncls(0),
51 fITSsignal(0),
52 fTPCchi2(0),
53 fTPCncls(0),
54 fTPCClusterMap(159),//number of padrows
55 fTPCsignal(0),
56 fTRDchi2(0),
57 fTRDncls(0),
58 fTRDncls0(0),
59 fTRDsignal(0),
60 fTOFchi2(0),
61 fTOFindex(0),
62 fTOFsignal(-1),
63 fPHOSsignal(-1),
64 fEMCALsignal(-1),
65 fRICHchi2(1e10),
66 fRICHncls(0),
67 fRICHindex(0),
68 fRICHsignal(-1),
69 fRICHtheta(0),
70 fRICHphi(0),
71 fRICHdx(0),
72 fRICHdy(0)
73 {
74   //
75   // The default ESD constructor 
76   //
77   for (Int_t i=0; i<AliPID::kSPECIES; i++) {
78     fTrackTime[i]=0.;
79     fR[i]=1.;
80     fITSr[i]=1.;
81     fTPCr[i]=1.;
82     fTRDr[i]=1.;
83     fTOFr[i]=1.;
84     fRICHr[i]=1.;
85   }
86   
87   for (Int_t i=0; i<AliPID::kSPECIESN; i++) {
88     fPHOSr[i]  = 1.;
89     fEMCALr[i] = 1.;
90   }
91
92  
93   fPHOSpos[0]=fPHOSpos[1]=fPHOSpos[2]=0.;
94   fEMCALpos[0]=fEMCALpos[1]=fEMCALpos[2]=0.;
95   Int_t i;
96   for (i=0; i<5; i++)  { 
97     fRp[i]=fCp[i]=fIp[i]=fTp[i]=0.;
98   }
99   for (i=0; i<15; i++) { 
100     fRc[i]=fCc[i]=fIc[i]=fTc[i]=0.;  
101   }
102   for (i=0; i<6; i++)  { fITSindex[i]=0; }
103   for (i=0; i<180; i++){ fTPCindex[i]=0; }
104   for (i=0; i<3;i++)   { fKinkIndexes[i]=0;}
105   for (i=0; i<3;i++)   { fV0Indexes[i]=-1;}
106   for (i=0; i<130; i++) { fTRDindex[i]=0; }
107   for (i=0;i<kNPlane;i++) {fTRDsignals[i]=0.; fTRDTimBin[i]=-1;}
108   for (Int_t i=0;i<4;i++) {fTPCPoints[i]=-1;}
109   for (Int_t i=0;i<3;i++) {fTOFLabel[i]=-1;}
110   for (Int_t i=0;i<10;i++) {fTOFInfo[i]=-1;}
111   fTPCLabel = 0;
112   fTRDLabel = 0;
113   fITSLabel = 0;
114   fITStrack = 0;
115   fTRDtrack = 0;  
116 }
117
118 //_______________________________________________________________________
119
120 AliESDtrack::AliESDtrack(const AliESDtrack& track):TObject(track){
121   //
122   //copy constructor
123   //
124   fFlags = track.fFlags;
125   fLabel =track.fLabel;
126   fID = track.fID;
127   fTrackLength =track.fTrackLength;
128   fD=track.fD; fZ=track.fZ;
129   for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] =track.fTrackTime[i];
130   for (Int_t i=0;i<AliPID::kSPECIES;i++)  fR[i] =track.fR[i];
131   fStopVertex =track.fStopVertex;
132   //
133   fRalpha =track.fRalpha;
134   fRx =track.fRx;
135   for (Int_t i=0;i<5;i++) fRp[i] =track.fRp[i];
136   for (Int_t i=0;i<15;i++) fRc[i] =track.fRc[i];
137   //
138   fCalpha =track.fCalpha;
139   fCx =track.fCx;
140   for (Int_t i=0;i<5;i++) fCp[i] =track.fCp[i];
141   for (Int_t i=0;i<15;i++)  fCc[i] =track.fCc[i];
142   fCchi2 =track.fCchi2;
143   //
144   fIalpha =track.fIalpha;
145   fIx =track.fIx;
146   for (Int_t i=0;i<5;i++) fIp[i] =track.fIp[i];
147   for (Int_t i=0;i<15;i++)  fIc[i] =track.fIc[i];
148   //
149   fTalpha =track.fTalpha;
150   fTx =track.fTx;
151   for (Int_t i=0;i<5;i++) fTp[i] =track.fTp[i];
152   for (Int_t i=0;i<15;i++)  fTc[i] =track.fTc[i];
153   //
154   fITSchi2 =track.fITSchi2;
155   for (Int_t i=0;i<12;i++) fITSchi2MIP[i] =track.fITSchi2MIP[i];
156   fITSncls =track.fITSncls;       
157   for (Int_t i=0;i<6;i++) fITSindex[i]=track.fITSindex[i];    
158   fITSsignal =track.fITSsignal;     
159   for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i]; 
160   fITSLabel =track.fITSLabel;       
161   fITSFakeRatio =track.fITSFakeRatio;   
162   fITStrack =0;  //coping separatelly - in user code
163   //
164   fTPCchi2 =track.fTPCchi2;       
165   fTPCncls =track.fTPCncls;       
166   for (Int_t i=0;i<180;i++) fTPCindex[i]=track.fTPCindex[i];  
167   fTPCClusterMap=track.fTPCClusterMap;  
168   fTPCsignal=track.fTPCsignal;      
169   for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i]; 
170   fTPCLabel=track.fTPCLabel;       
171   for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
172   for (Int_t i=0; i<3;i++)   { fKinkIndexes[i]=track.fKinkIndexes[i];}
173   for (Int_t i=0; i<3;i++)   { fV0Indexes[i]=track.fV0Indexes[i];}
174   //
175   fTRDchi2=track.fTRDchi2;        
176   fTRDncls=track.fTRDncls;       
177   fTRDncls0=track.fTRDncls0;       
178   for (Int_t i=0;i<130;i++) fTRDindex[i]=track.fTRDindex[i];   
179   fTRDsignal=track.fTRDsignal;      
180   for (Int_t i=0;i<kNPlane;i++) {
181       fTRDsignals[i]=track.fTRDsignals[i]; 
182       fTRDTimBin[i]=track.fTRDTimBin[i];
183   }
184   for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i]; 
185   fTRDLabel=track.fTRDLabel;       
186   fTRDtrack=0; 
187   //
188   fTOFchi2=track.fTOFchi2;        
189   fTOFindex=track.fTOFindex;       
190   fTOFsignal=track.fTOFsignal;      
191   for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
192   for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
193   for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
194   //
195   for (Int_t i=0;i<3;i++) fPHOSpos[i]=track.fPHOSpos[i]; 
196   fPHOSsignal=track.fPHOSsignal; 
197   for (Int_t i=0;i<AliPID::kSPECIESN;i++) fPHOSr[i]=track.fPHOSr[i]; 
198   //
199   for (Int_t i=0;i<3;i++) fEMCALpos[i]=track.fEMCALpos[i]; 
200   fEMCALsignal=track.fEMCALsignal; 
201   for (Int_t i=0;i<AliPID::kSPECIESN;i++) fEMCALr[i]=track.fEMCALr[i]; 
202   //
203   fRICHchi2=track.fRICHchi2;     
204   fRICHncls=track.fRICHncls;     
205   fRICHindex=track.fRICHindex;     
206   fRICHsignal=track.fRICHsignal;     
207   for (Int_t i=0;i<AliPID::kSPECIES;i++) fRICHr[i]=track.fRICHr[i];
208   fRICHtheta=track.fRICHtheta;     
209   fRICHphi=track.fRICHphi;      
210   fRICHdx=track.fRICHdx;     
211   fRICHdy=track.fRICHdy;      
212 }
213 //_______________________________________________________________________
214 AliESDtrack::~AliESDtrack(){ 
215   //
216   // This is destructor according Coding Conventrions 
217   //
218   //printf("Delete track\n");
219   delete fITStrack;
220   delete fTRDtrack;  
221 }
222
223 //_______________________________________________________________________
224 Double_t AliESDtrack::GetMass() const {
225   // Returns the mass of the most probable particle type
226   Float_t max=0.;
227   Int_t k=-1;
228   for (Int_t i=0; i<AliPID::kSPECIES; i++) {
229     if (fR[i]>max) {k=i; max=fR[i];}
230   }
231   if (k==0) { // dE/dx "crossing points" in the TPC
232      Double_t p=GetP();
233      if ((p>0.38)&&(p<0.48))
234         if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
235      if ((p>0.75)&&(p<0.85))
236         if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
237      return 0.00051;
238   }
239   if (k==1) return AliPID::ParticleMass(AliPID::kMuon); 
240   if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
241   if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
242   if (k==4) return AliPID::ParticleMass(AliPID::kProton);
243   AliWarning("Undefined mass !");
244   return AliPID::ParticleMass(AliPID::kPion);
245 }
246
247 //_______________________________________________________________________
248 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags) {
249   //
250   // This function updates track's running parameters 
251   //
252   Bool_t rc=kTRUE;
253
254   SetStatus(flags);
255   fLabel=t->GetLabel();
256
257   if (t->IsStartedTimeIntegral()) {
258     SetStatus(kTIME);
259     Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
260     SetIntegratedLength(t->GetIntegratedLength());
261   }
262
263   fRalpha=t->GetAlpha();
264   t->GetExternalParameters(fRx,fRp);
265   t->GetExternalCovariance(fRc);
266
267   switch (flags) {
268     
269   case kITSin: case kITSout: case kITSrefit:
270     fITSncls=t->GetNumberOfClusters();
271     fITSchi2=t->GetChi2();
272     for (Int_t i=0;i<fITSncls;i++) fITSindex[i]=t->GetClusterIndex(i);
273     fITSsignal=t->GetPIDsignal();
274     fITSLabel = t->GetLabel();
275     fITSFakeRatio = t->GetFakeRatio();
276     break;
277     
278   case kTPCin: case kTPCrefit:
279     fTPCLabel = t->GetLabel();
280     fIalpha=fRalpha;
281     fIx=fRx;    
282     {
283       Int_t i;
284       for (i=0; i<5; i++) fIp[i]=fRp[i];
285       for (i=0; i<15;i++) fIc[i]=fRc[i];
286     }
287   case kTPCout:
288   
289     fTPCncls=t->GetNumberOfClusters();
290     fTPCchi2=t->GetChi2();
291     
292      {//prevrow must be declared in separate namespace, otherwise compiler cries:
293       //"jump to case label crosses initialization of `Int_t prevrow'"
294        Int_t prevrow = -1;
295        //       for (Int_t i=0;i<fTPCncls;i++) 
296        for (Int_t i=0;i<160;i++) 
297         {
298           fTPCindex[i]=t->GetClusterIndex(i);
299
300           // Piotr's Cluster Map for HBT  
301           // ### please change accordingly if cluster array is changing 
302           // to "New TPC Tracking" style (with gaps in array) 
303           Int_t idx = fTPCindex[i];
304           Int_t sect = (idx&0xff000000)>>24;
305           Int_t row = (idx&0x00ff0000)>>16;
306           if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
307
308           fTPCClusterMap.SetBitNumber(row,kTRUE);
309
310           //Fill the gap between previous row and this row with 0 bits
311           //In case  ###  pleas change it as well - just set bit 0 in case there 
312           //is no associated clusters for current "i"
313           if (prevrow < 0) 
314            {
315              prevrow = row;//if previous bit was not assigned yet == this is the first one
316            }
317           else
318            { //we don't know the order (inner to outer or reverse)
319              //just to be save in case it is going to change
320              Int_t n = 0, m = 0;
321              if (prevrow < row)
322               {
323                 n = prevrow;
324                 m = row;
325               }
326              else
327               {
328                 n = row;
329                 m = prevrow;
330               }
331
332              for (Int_t j = n+1; j < m; j++)
333               {
334                 fTPCClusterMap.SetBitNumber(j,kFALSE);
335               }
336              prevrow = row; 
337            }
338           // End Of Piotr's Cluster Map for HBT
339         }
340      }
341     fTPCsignal=t->GetPIDsignal();
342     {Double_t mass=t->GetMass();    // preliminary mass setting 
343     if (mass>0.5) fR[4]=1.;         //        used by
344     else if (mass<0.4) fR[2]=1.;    // the ITS reconstruction
345     else fR[3]=1.;}
346                      //
347     break;
348
349   case kTRDout: case kTRDin: case kTRDrefit:
350     fTRDLabel = t->GetLabel(); 
351     fTRDncls=t->GetNumberOfClusters();
352     fTRDchi2=t->GetChi2();
353     for (Int_t i=0;i<fTRDncls;i++) fTRDindex[i]=t->GetClusterIndex(i);
354     fTRDsignal=t->GetPIDsignal();
355     break;
356   case kTRDbackup:
357     t->GetExternalParameters(fTx,fTp);
358     t->GetExternalCovariance(fTc);
359     fTalpha = t->GetAlpha();
360     fTRDncls0 = t->GetNumberOfClusters(); 
361     break;
362   case kTOFin: 
363     break;
364   case kTOFout: 
365     break;
366   case kTRDStop:
367     break;
368   default: 
369     AliError("Wrong flag !");
370     return kFALSE;
371   }
372
373   return rc;
374 }
375
376 //_______________________________________________________________________
377 void 
378 AliESDtrack::SetConstrainedTrackParams(const AliKalmanTrack *t, Double_t chi2) {
379   //
380   // This function sets the constrained track parameters 
381   //
382   Int_t i;
383   Double_t x,buf[15];
384   fCalpha=t->GetAlpha();
385   t->GetExternalParameters(x,buf); fCx=x;
386   for (i=0; i<5; i++) fCp[i]=buf[i];
387   t->GetExternalCovariance(buf);
388   for (i=0; i<15; i++) fCc[i]=buf[i];
389   fCchi2=chi2;
390 }
391
392
393 //_______________________________________________________________________
394 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
395   //---------------------------------------------------------------------
396   // This function returns external representation of the track parameters
397   //---------------------------------------------------------------------
398   x=fRx;
399   for (Int_t i=0; i<5; i++) p[i]=fRp[i];
400 }
401
402 //_______________________________________________________________________
403 Bool_t AliESDtrack::GetExternalParametersAt(Double_t x, Double_t p[5]) const {
404   //---------------------------------------------------------------------
405   // This function returns external representation of the track parameters
406   // at the position given by the first argument 
407   //---------------------------------------------------------------------
408   Double_t dx=x-fRx;
409   Double_t f1=fRp[2], f2=f1 + dx*fRp[4]/AliKalmanTrack::GetConvConst();
410
411   if (TMath::Abs(f2) >= 0.9999) return kFALSE;
412   
413   Double_t r1=TMath::Sqrt(1.- f1*f1), r2=TMath::Sqrt(1.- f2*f2);
414   p[0] = fRp[0] + dx*(f1+f2)/(r1+r2);
415   p[1] = fRp[1] + dx*(f1+f2)/(f1*r2 + f2*r1)*fRp[3];
416   p[2] = f2;
417   p[3] = fRp[3];
418   p[4] = fRp[4];
419
420   return kTRUE;
421 }
422
423 //_______________________________________________________________________
424 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
425   //---------------------------------------------------------------------
426   // This function returns external representation of the cov. matrix
427   //---------------------------------------------------------------------
428   for (Int_t i=0; i<15; i++) cov[i]=fRc[i];
429 }
430
431
432 //_______________________________________________________________________
433 void 
434 AliESDtrack::GetConstrainedExternalParameters(Double_t &x, Double_t p[5])const{
435   //---------------------------------------------------------------------
436   // This function returns the constrained external track parameters
437   //---------------------------------------------------------------------
438   x=fCx;
439   for (Int_t i=0; i<5; i++) p[i]=fCp[i];
440 }
441 //_______________________________________________________________________
442 void 
443 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
444   //---------------------------------------------------------------------
445   // This function returns the constrained external cov. matrix
446   //---------------------------------------------------------------------
447   for (Int_t i=0; i<15; i++) c[i]=fCc[i];
448 }
449
450
451 Double_t AliESDtrack::GetP() const {
452   //---------------------------------------------------------------------
453   // This function returns the track momentum
454   // Results for (nearly) straight tracks are meaningless !
455   //---------------------------------------------------------------------
456   if (TMath::Abs(fRp[4])<=0) return 0;
457   Double_t pt=1./TMath::Abs(fRp[4]);
458   return pt*TMath::Sqrt(1.+ fRp[3]*fRp[3]);
459 }
460
461 Bool_t Local2GlobalMomentum(Double_t p[3],Double_t alpha) {
462   //----------------------------------------------------------------
463   // This function performs local->global transformation of the
464   // track momentum.
465   // When called, the arguments are:
466   //    p[0] = 1/pt of the track;
467   //    p[1] = sine of local azim. angle of the track momentum;
468   //    p[2] = tangent of the track momentum dip angle;
469   //   alpha - rotation angle. 
470   // The result is returned as:
471   //    p[0] = px
472   //    p[1] = py
473   //    p[2] = pz
474   // Results for (nearly) straight tracks are meaningless !
475   //----------------------------------------------------------------
476   if (TMath::Abs(p[0])<=0)        return kFALSE;
477   if (TMath::Abs(p[1])> 0.999999) return kFALSE;
478
479   Double_t pt=1./TMath::Abs(p[0]);
480   Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha);
481   Double_t r=TMath::Sqrt(1 - p[1]*p[1]);
482   p[0]=pt*(r*cs - p[1]*sn); p[1]=pt*(p[1]*cs + r*sn); p[2]=pt*p[2];
483
484   return kTRUE;
485 }
486
487 Bool_t Local2GlobalPosition(Double_t r[3],Double_t alpha) {
488   //----------------------------------------------------------------
489   // This function performs local->global transformation of the
490   // track position.
491   // When called, the arguments are:
492   //    r[0] = local x
493   //    r[1] = local y
494   //    r[2] = local z
495   //   alpha - rotation angle. 
496   // The result is returned as:
497   //    r[0] = global x
498   //    r[1] = global y
499   //    r[2] = global z
500   //----------------------------------------------------------------
501   Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha), x=r[0];
502   r[0]=x*cs - r[1]*sn; r[1]=x*sn + r[1]*cs;
503
504   return kTRUE;
505 }
506
507 Bool_t AliESDtrack::GetConstrainedPxPyPz(Double_t *p) const {
508   //---------------------------------------------------------------------
509   // This function returns the constrained global track momentum components
510   // Results for (nearly) straight tracks are meaningless !
511   //---------------------------------------------------------------------
512   p[0]=fCp[4]; p[1]=fCp[2]; p[2]=fCp[3];
513   return Local2GlobalMomentum(p,fCalpha);
514 }  
515
516 Bool_t AliESDtrack::GetConstrainedXYZ(Double_t *r) const {
517   //---------------------------------------------------------------------
518   // This function returns the constrained global track position
519   //---------------------------------------------------------------------
520   r[0]=fCx; r[1]=fCp[0]; r[2]=fCp[1];
521   return Local2GlobalPosition(r,fCalpha);
522 }
523
524 Bool_t AliESDtrack::GetPxPyPz(Double_t *p) const {
525   //---------------------------------------------------------------------
526   // This function returns the global track momentum components
527   // Results for (nearly) straight tracks are meaningless !
528   //---------------------------------------------------------------------
529   p[0]=fRp[4]; p[1]=fRp[2]; p[2]=fRp[3];
530   return Local2GlobalMomentum(p,fRalpha);
531 }
532
533 Bool_t AliESDtrack::GetXYZ(Double_t *r) const {
534   //---------------------------------------------------------------------
535   // This function returns the global track position
536   //---------------------------------------------------------------------
537   r[0]=fRx; r[1]=fRp[0]; r[2]=fRp[1];
538   return Local2GlobalPosition(r,fRalpha);
539 }
540
541 void AliESDtrack::GetCovariance(Double_t cv[21]) const {
542   //---------------------------------------------------------------------
543   // This function returns the global covariance matrix of the track params
544   // 
545   // Cov(x,x) ... :   cv[0]
546   // Cov(y,x) ... :   cv[1]  cv[2]
547   // Cov(z,x) ... :   cv[3]  cv[4]  cv[5]
548   // Cov(px,x)... :   cv[6]  cv[7]  cv[8]  cv[9]
549   // Cov(py,x)... :   cv[10] cv[11] cv[12] cv[13] cv[14]
550   // Cov(pz,x)... :   cv[15] cv[16] cv[17] cv[18] cv[19] cv[20]
551   //
552   // Results for (nearly) straight tracks are meaningless !
553   //---------------------------------------------------------------------
554   if (TMath::Abs(fRp[4])<=0) {
555      for (Int_t i=0; i<21; i++) cv[i]=0.;
556      return;
557   }
558   if (TMath::Abs(fRp[2]) > 0.999999) {
559      for (Int_t i=0; i<21; i++) cv[i]=0.;
560      return;
561   }
562   Double_t pt=1./TMath::Abs(fRp[4]);
563   Double_t cs=TMath::Cos(fRalpha), sn=TMath::Sin(fRalpha);
564   Double_t r=TMath::Sqrt(1-fRp[2]*fRp[2]);
565
566   Double_t m00=-sn, m10=cs;
567   Double_t m23=-pt*(sn + fRp[2]*cs/r), m43=-pt*pt*(r*cs - fRp[2]*sn);
568   Double_t m24= pt*(cs - fRp[2]*sn/r), m44=-pt*pt*(r*sn + fRp[2]*cs);
569   Double_t m35=pt, m45=-pt*pt*fRp[3];
570
571   cv[0]=fRc[0]*m00*m00;
572   cv[1]=fRc[0]*m00*m10; 
573   cv[2]=fRc[0]*m10*m10;
574   cv[3]=fRc[1]*m00; 
575   cv[4]=fRc[1]*m10; 
576   cv[5]=fRc[2];
577   cv[6]=m00*(fRc[3]*m23+fRc[10]*m43); 
578   cv[7]=m10*(fRc[3]*m23+fRc[10]*m43); 
579   cv[8]=fRc[4]*m23+fRc[11]*m43; 
580   cv[9]=m23*(fRc[5]*m23+fRc[12]*m43)+m43*(fRc[12]*m23+fRc[14]*m43);
581   cv[10]=m00*(fRc[3]*m24+fRc[10]*m44); 
582   cv[11]=m10*(fRc[3]*m24+fRc[10]*m44); 
583   cv[12]=fRc[4]*m24+fRc[11]*m44; 
584   cv[13]=m23*(fRc[5]*m24+fRc[12]*m44)+m43*(fRc[12]*m24+fRc[14]*m44);
585   cv[14]=m24*(fRc[5]*m24+fRc[12]*m44)+m44*(fRc[12]*m24+fRc[14]*m44);
586   cv[15]=m00*(fRc[6]*m35+fRc[10]*m45); 
587   cv[16]=m10*(fRc[6]*m35+fRc[10]*m45); 
588   cv[17]=fRc[7]*m35+fRc[11]*m45; 
589   cv[18]=m23*(fRc[8]*m35+fRc[12]*m45)+m43*(fRc[13]*m35+fRc[14]*m45);
590   cv[19]=m24*(fRc[8]*m35+fRc[12]*m45)+m44*(fRc[13]*m35+fRc[14]*m45); 
591   cv[20]=m35*(fRc[9]*m35+fRc[13]*m45)+m45*(fRc[13]*m35+fRc[14]*m45);
592 }
593
594 Bool_t AliESDtrack::GetInnerPxPyPz(Double_t *p) const {
595   //---------------------------------------------------------------------
596   // This function returns the global track momentum components
597   // af the entrance of the TPC
598   //---------------------------------------------------------------------
599   p[0]=fIp[4]; p[1]=fIp[2]; p[2]=fIp[3];
600   return Local2GlobalMomentum(p,fIalpha);
601 }
602
603 Bool_t AliESDtrack::GetInnerXYZ(Double_t *r) const {
604   //---------------------------------------------------------------------
605   // This function returns the global track position
606   // af the entrance of the TPC
607   //---------------------------------------------------------------------
608   if (fIx==0) return kFALSE;
609   r[0]=fIx; r[1]=fIp[0]; r[2]=fIp[1];
610   return Local2GlobalPosition(r,fIalpha);
611 }
612
613 void AliESDtrack::GetInnerExternalParameters(Double_t &x, Double_t p[5]) const 
614 {
615   //skowron
616  //---------------------------------------------------------------------
617   // This function returns external representation of the track parameters at Inner Layer of TPC
618   //---------------------------------------------------------------------
619   x=fIx;
620   for (Int_t i=0; i<5; i++) p[i]=fIp[i];
621 }
622 void AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const
623 {
624  //skowron
625  //---------------------------------------------------------------------
626  // This function returns external representation of the cov. matrix at Inner Layer of TPC
627  //---------------------------------------------------------------------
628  for (Int_t i=0; i<15; i++) cov[i]=fIc[i];
629  
630 }
631
632 void  AliESDtrack::GetTRDExternalParameters(Double_t &x, Double_t&alpha, Double_t p[5], Double_t cov[15]) const
633 {
634   //
635   //this function returns TRD parameters
636   //
637   x=fTx;
638   alpha = fTalpha; 
639   for (Int_t i=0; i<5; i++) p[i]=fTp[i];
640   for (Int_t i=0; i<15; i++) cov[i]=fTc[i];
641 }
642
643 Bool_t AliESDtrack::GetPxPyPzAt(Double_t x,Double_t *p) const {
644   //---------------------------------------------------------------------
645   // This function returns the global track momentum components
646   // at the position "x" using the helix track approximation
647   //---------------------------------------------------------------------
648   p[0]=fRp[4]; 
649   p[1]=fRp[2]+(x-fRx)*fRp[4]/AliKalmanTrack::GetConvConst(); 
650   p[2]=fRp[3];
651   return Local2GlobalMomentum(p,fRalpha);
652 }
653
654 Bool_t AliESDtrack::GetXYZAt(Double_t x, Double_t *r) const {
655   //---------------------------------------------------------------------
656   // This function returns the global track position
657   // af the radius "x" using the helix track approximation
658   //---------------------------------------------------------------------
659   Double_t dx=x-fRx;
660   Double_t f1=fRp[2], f2=f1 + dx*fRp[4]/AliKalmanTrack::GetConvConst();
661
662   if (TMath::Abs(f2) >= 0.9999) return kFALSE;
663   
664   Double_t r1=TMath::Sqrt(1.- f1*f1), r2=TMath::Sqrt(1.- f2*f2);
665   r[0] = x;
666   r[1] = fRp[0] + dx*(f1+f2)/(r1+r2);
667   r[2] = fRp[1] + dx*(f1+f2)/(f1*r2 + f2*r1)*fRp[3];
668   return Local2GlobalPosition(r,fRalpha);
669 }
670
671 //_______________________________________________________________________
672 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
673   // Returns the array with integrated times for each particle hypothesis
674   for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
675 }
676
677 //_______________________________________________________________________
678 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
679   // Sets the array with integrated times for each particle hypotesis
680   for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
681 }
682
683 //_______________________________________________________________________
684 void AliESDtrack::SetITSpid(const Double_t *p) {
685   // Sets values for the probability of each particle type (in ITS)
686   for (Int_t i=0; i<AliPID::kSPECIES; i++) fITSr[i]=p[i];
687   SetStatus(AliESDtrack::kITSpid);
688 }
689
690 void AliESDtrack::SetITSChi2MIP(const Float_t *chi2mip){
691   for (Int_t i=0; i<12; i++) fITSchi2MIP[i]=chi2mip[i];
692 }
693 //_______________________________________________________________________
694 void AliESDtrack::GetITSpid(Double_t *p) const {
695   // Gets the probability of each particle type (in ITS)
696   for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
697 }
698
699 //_______________________________________________________________________
700 Int_t AliESDtrack::GetITSclusters(UInt_t *idx) const {
701   //---------------------------------------------------------------------
702   // This function returns indices of the assgined ITS clusters 
703   //---------------------------------------------------------------------
704   for (Int_t i=0; i<fITSncls; i++) idx[i]=fITSindex[i];
705   return fITSncls;
706 }
707
708 //_______________________________________________________________________
709 Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
710   //---------------------------------------------------------------------
711   // This function returns indices of the assgined ITS clusters 
712   //---------------------------------------------------------------------
713   if (idx!=0)
714     for (Int_t i=0; i<180; i++) idx[i]=fTPCindex[i];  // MI I prefer some constant
715   return fTPCncls;
716 }
717
718 //_______________________________________________________________________
719 void AliESDtrack::SetTPCpid(const Double_t *p) {  
720   // Sets values for the probability of each particle type (in TPC)
721   for (Int_t i=0; i<AliPID::kSPECIES; i++) fTPCr[i]=p[i];
722   SetStatus(AliESDtrack::kTPCpid);
723 }
724
725 //_______________________________________________________________________
726 void AliESDtrack::GetTPCpid(Double_t *p) const {
727   // Gets the probability of each particle type (in TPC)
728   for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
729 }
730
731 //_______________________________________________________________________
732 Int_t AliESDtrack::GetTRDclusters(UInt_t *idx) const {
733   //---------------------------------------------------------------------
734   // This function returns indices of the assgined TRD clusters 
735   //---------------------------------------------------------------------
736   if (idx!=0)
737     for (Int_t i=0; i<130; i++) idx[i]=fTRDindex[i];  // MI I prefer some constant
738   return fTRDncls;
739 }
740
741 //_______________________________________________________________________
742 void AliESDtrack::SetTRDpid(const Double_t *p) {  
743   // Sets values for the probability of each particle type (in TRD)
744   for (Int_t i=0; i<AliPID::kSPECIES; i++) fTRDr[i]=p[i];
745   SetStatus(AliESDtrack::kTRDpid);
746 }
747
748 //_______________________________________________________________________
749 void AliESDtrack::GetTRDpid(Double_t *p) const {
750   // Gets the probability of each particle type (in TRD)
751   for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
752 }
753
754 //_______________________________________________________________________
755 void    AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
756 {
757   // Sets the probability of particle type iSpecies to p (in TRD)
758   fTRDr[iSpecies] = p;
759 }
760
761 Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
762 {
763   // Returns the probability of particle type iSpecies (in TRD)
764   return fTRDr[iSpecies];
765 }
766
767 //_______________________________________________________________________
768 void AliESDtrack::SetTOFpid(const Double_t *p) {  
769   // Sets the probability of each particle type (in TOF)
770   for (Int_t i=0; i<AliPID::kSPECIES; i++) fTOFr[i]=p[i];
771   SetStatus(AliESDtrack::kTOFpid);
772 }
773
774 //_______________________________________________________________________
775 void AliESDtrack::SetTOFLabel(const Int_t *p) {  
776   // Sets  (in TOF)
777   for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
778 }
779
780 //_______________________________________________________________________
781 void AliESDtrack::GetTOFpid(Double_t *p) const {
782   // Gets probabilities of each particle type (in TOF)
783   for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
784 }
785
786 //_______________________________________________________________________
787 void AliESDtrack::GetTOFLabel(Int_t *p) const {
788   // Gets (in TOF)
789   for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
790 }
791
792 //_______________________________________________________________________
793 void AliESDtrack::GetTOFInfo(Float_t *info) const {
794   // Gets (in TOF)
795   for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
796 }
797
798 //_______________________________________________________________________
799 void AliESDtrack::SetTOFInfo(Float_t*info) {
800   // Gets (in TOF)
801   for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
802 }
803
804
805
806 //_______________________________________________________________________
807 void AliESDtrack::SetPHOSpid(const Double_t *p) {  
808   // Sets the probability of each particle type (in PHOS)
809   for (Int_t i=0; i<AliPID::kSPECIESN; i++) fPHOSr[i]=p[i];
810   SetStatus(AliESDtrack::kPHOSpid);
811 }
812
813 //_______________________________________________________________________
814 void AliESDtrack::GetPHOSpid(Double_t *p) const {
815   // Gets probabilities of each particle type (in PHOS)
816   for (Int_t i=0; i<AliPID::kSPECIESN; i++) p[i]=fPHOSr[i];
817 }
818
819 //_______________________________________________________________________
820 void AliESDtrack::SetEMCALpid(const Double_t *p) {  
821   // Sets the probability of each particle type (in EMCAL)
822   for (Int_t i=0; i<AliPID::kSPECIESN; i++) fEMCALr[i]=p[i];
823   SetStatus(AliESDtrack::kEMCALpid);
824 }
825
826 //_______________________________________________________________________
827 void AliESDtrack::GetEMCALpid(Double_t *p) const {
828   // Gets probabilities of each particle type (in EMCAL)
829   for (Int_t i=0; i<AliPID::kSPECIESN; i++) p[i]=fEMCALr[i];
830 }
831
832 //_______________________________________________________________________
833 void AliESDtrack::SetRICHpid(const Double_t *p) {  
834   // Sets the probability of each particle type (in RICH)
835   for (Int_t i=0; i<AliPID::kSPECIES; i++) fRICHr[i]=p[i];
836   SetStatus(AliESDtrack::kRICHpid);
837 }
838
839 //_______________________________________________________________________
840 void AliESDtrack::GetRICHpid(Double_t *p) const {
841   // Gets probabilities of each particle type (in RICH)
842   for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fRICHr[i];
843 }
844
845
846
847 //_______________________________________________________________________
848 void AliESDtrack::SetESDpid(const Double_t *p) {  
849   // Sets the probability of each particle type for the ESD track
850   for (Int_t i=0; i<AliPID::kSPECIES; i++) fR[i]=p[i];
851   SetStatus(AliESDtrack::kESDpid);
852 }
853
854 //_______________________________________________________________________
855 void AliESDtrack::GetESDpid(Double_t *p) const {
856   // Gets probability of each particle type for the ESD track
857   for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
858 }
859
860 //_______________________________________________________________________
861 void AliESDtrack::Print(Option_t *) const {
862   // Prints info on the track
863   
864   printf("ESD track info\n") ; 
865   Double_t p[AliPID::kSPECIESN] ; 
866   Int_t index = 0 ; 
867   if( IsOn(kITSpid) ){
868     printf("From ITS: ") ; 
869     GetITSpid(p) ; 
870     for(index = 0 ; index < AliPID::kSPECIES; index++) 
871       printf("%f, ", p[index]) ;
872     printf("\n           signal = %f\n", GetITSsignal()) ;
873   } 
874   if( IsOn(kTPCpid) ){
875     printf("From TPC: ") ; 
876     GetTPCpid(p) ; 
877     for(index = 0 ; index < AliPID::kSPECIES; index++) 
878       printf("%f, ", p[index]) ;
879     printf("\n           signal = %f\n", GetTPCsignal()) ;
880   }
881   if( IsOn(kTRDpid) ){
882     printf("From TRD: ") ; 
883     GetTRDpid(p) ; 
884     for(index = 0 ; index < AliPID::kSPECIES; index++) 
885       printf("%f, ", p[index]) ;
886     printf("\n           signal = %f\n", GetTRDsignal()) ;
887   }
888   if( IsOn(kTOFpid) ){
889     printf("From TOF: ") ; 
890     GetTOFpid(p) ; 
891     for(index = 0 ; index < AliPID::kSPECIES; index++) 
892       printf("%f, ", p[index]) ;
893     printf("\n           signal = %f\n", GetTOFsignal()) ;
894   }
895   if( IsOn(kRICHpid) ){
896     printf("From TOF: ") ; 
897     GetRICHpid(p) ; 
898     for(index = 0 ; index < AliPID::kSPECIES; index++) 
899       printf("%f, ", p[index]) ;
900     printf("\n           signal = %f\n", GetRICHsignal()) ;
901   }
902   if( IsOn(kPHOSpid) ){
903     printf("From PHOS: ") ; 
904     GetPHOSpid(p) ; 
905     for(index = 0 ; index < AliPID::kSPECIESN; index++) 
906       printf("%f, ", p[index]) ;
907     printf("\n           signal = %f\n", GetPHOSsignal()) ;
908   }
909   if( IsOn(kEMCALpid) ){
910     printf("From EMCAL: ") ; 
911     GetEMCALpid(p) ; 
912     for(index = 0 ; index < AliPID::kSPECIESN; index++) 
913       printf("%f, ", p[index]) ;
914     printf("\n           signal = %f\n", GetEMCALsignal()) ;
915   }
916