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