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