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