New library for the ITS HLT code (C.Cheshkov)
[u/mrichter/AliRoot.git] / STEER / AliESDtrack.cxx
CommitLineData
ae982df3 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 **************************************************************************/
ae982df3 15//-----------------------------------------------------------------
16// Implementation of the ESD track class
4427806c 17// ESD = Event Summary Data
15614b8b 18// This is the class to deal with during the phisics analysis of data
4427806c 19// Origin: Iouri Belikov, CERN
20// e-mail: Jouri.Belikov@cern.ch
ae982df3 21//-----------------------------------------------------------------
22
23#include "TMath.h"
24
25#include "AliESDtrack.h"
26#include "AliKalmanTrack.h"
5f7789fc 27#include "AliLog.h"
ae982df3 28
29ClassImp(AliESDtrack)
30
31//_______________________________________________________________________
32AliESDtrack::AliESDtrack() :
2bad268c 33fFlags(0),
34fLabel(0),
35fTrackLength(0),
36fStopVertex(0),
37fRalpha(0),
38fRx(0),
a866ac60 39fCalpha(0),
40fCx(0),
67c3dcbe 41fCchi2(1e10),
a866ac60 42fIalpha(0),
43fIx(0),
c4d11b15 44fTalpha(0),
45fTx(0),
2bad268c 46fITSchi2(0),
ae982df3 47fITSncls(0),
2bad268c 48fITSsignal(0),
2bad268c 49fTPCchi2(0),
05e445cd 50fTPCncls(0),
a866ac60 51fTPCClusterMap(159),//number of padrows
2bad268c 52fTPCsignal(0),
53fTRDchi2(0),
54fTRDncls(0),
c4d11b15 55fTRDncls0(0),
2bad268c 56fTRDsignal(0),
57fTOFchi2(0),
ea776286 58fTOFindex(0),
4a78b8c5 59fTOFsignal(-1),
60fPHOSsignal(-1),
704be597 61fEMCALsignal(-1),
4a78b8c5 62fRICHsignal(-1)
ae982df3 63{
64 //
65 // The default ESD constructor
66 //
51ad6848 67 fID =0;
2bad268c 68 for (Int_t i=0; i<kSPECIES; i++) {
4a78b8c5 69 fTrackTime[i]=0.;
70 fR[i]=1.;
71 fITSr[i]=1.;
72 fTPCr[i]=1.;
73 fTRDr[i]=1.;
74 fTOFr[i]=1.;
4a78b8c5 75 fRICHr[i]=1.;
2bad268c 76 }
ac2f7574 77
704be597 78 for (Int_t i=0; i<kSPECIESN; i++) {
79 fPHOSr[i] = 1.;
80 fEMCALr[i] = 1.;
81 }
82
ac2f7574 83
4a78b8c5 84 fPHOSpos[0]=fPHOSpos[1]=fPHOSpos[2]=0.;
704be597 85 fEMCALpos[0]=fEMCALpos[1]=fEMCALpos[2]=0.;
bb2ceb1f 86 Int_t i;
15614b8b 87 for (i=0; i<5; i++) {
23904d16 88 fRp[i]=fCp[i]=fIp[i]=fTp[i]=0.;
15614b8b 89 }
90 for (i=0; i<15; i++) {
23904d16 91 fRc[i]=fCc[i]=fIc[i]=fTc[i]=0.;
15614b8b 92 }
a866ac60 93 for (i=0; i<6; i++) { fITSindex[i]=0; }
94 for (i=0; i<180; i++){ fTPCindex[i]=0; }
51ad6848 95 for (i=0; i<3;i++) { fKinkIndexes[i]=0;}
96 for (i=0; i<3;i++) { fV0Indexes[i]=-1;}
c4d11b15 97 for (i=0; i<130; i++) { fTRDindex[i]=0; }
51ad6848 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;}
6e5b1b04 101 fTPCLabel = 0;
102 fTRDLabel = 0;
103 fITSLabel = 0;
c4d11b15 104 fITStrack = 0;
105 fTRDtrack = 0;
106}
107
108//_______________________________________________________________________
109
110AliESDtrack::AliESDtrack(const AliESDtrack& track):TObject(track){
111 //
112 //copy constructor
113 //
51ad6848 114 fID = track.fID;
c4d11b15 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 //
c4d11b15 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;
51ad6848 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];}
c4d11b15 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];
51ad6848 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];
c4d11b15 179 //
180 for (Int_t i=0;i<3;i++) fPHOSpos[i]=track.fPHOSpos[i];
181 fPHOSsignal=track.fPHOSsignal;
4162b1d0 182 for (Int_t i=0;i<kSPECIESN;i++) fPHOSr[i]=track.fPHOSr[i];
c4d11b15 183 //
184 for (Int_t i=0;i<3;i++) fEMCALpos[i]=track.fEMCALpos[i];
185 fEMCALsignal=track.fEMCALsignal;
4162b1d0 186 for (Int_t i=0;i<kSPECIESN;i++) fEMCALr[i]=track.fEMCALr[i];
c4d11b15 187 //
188 fRICHsignal=track.fRICHsignal;
189 for (Int_t i=0;i<kSPECIES;i++) fRICHr[i]=track.fRICHr[i];
190
ac2f7574 191
ae982df3 192}
c4d11b15 193//_______________________________________________________________________
194AliESDtrack::~AliESDtrack(){
195 //
196 // This is destructor according Coding Conventrions
197 //
198 //printf("Delete track\n");
3fd96ae3 199 delete fITStrack;
200 delete fTRDtrack;
c4d11b15 201}
ae982df3 202
203//_______________________________________________________________________
4a78b8c5 204Double_t AliESDtrack::GetMass() const {
4427806c 205 // Returns the mass of the most probable particle type
ae982df3 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 }
db3989b3 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 }
c4d11b15 219 if (k==1) return 0.10566;
ae982df3 220 if (k==2||k==-1) return 0.13957;
221 if (k==3) return 0.49368;
222 if (k==4) return 0.93827;
5f7789fc 223 AliWarning("Undefined mass !");
ae982df3 224 return 0.13957;
225}
226
227//_______________________________________________________________________
15614b8b 228Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags) {
ae982df3 229 //
230 // This function updates track's running parameters
231 //
15614b8b 232 Bool_t rc=kTRUE;
233
9b859005 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
ae982df3 247 switch (flags) {
ad2f1f2b 248
9b859005 249 case kITSin: case kITSout: case kITSrefit:
ae982df3 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();
6e5b1b04 254 fITSLabel = t->GetLabel();
babd135a 255 fITSFakeRatio = t->GetFakeRatio();
ae982df3 256 break;
ad2f1f2b 257
9b859005 258 case kTPCin: case kTPCrefit:
6e5b1b04 259 fTPCLabel = t->GetLabel();
9b859005 260 fIalpha=fRalpha;
51ad6848 261 fIx=fRx;
9b859005 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:
a866ac60 268
ae982df3 269 fTPCncls=t->GetNumberOfClusters();
270 fTPCchi2=t->GetChi2();
a866ac60 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;
6e5b1b04 275 // for (Int_t i=0;i<fTPCncls;i++)
276 for (Int_t i=0;i<160;i++)
a866ac60 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 }
ae982df3 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
a866ac60 325 else fR[3]=1.;}
326 //
ae982df3 327 break;
9b859005 328
23904d16 329 case kTRDout: case kTRDin: case kTRDrefit:
51ad6848 330 fTRDLabel = t->GetLabel();
79e94bf8 331 fTRDncls=t->GetNumberOfClusters();
332 fTRDchi2=t->GetChi2();
bb2ceb1f 333 for (Int_t i=0;i<fTRDncls;i++) fTRDindex[i]=t->GetClusterIndex(i);
79e94bf8 334 fTRDsignal=t->GetPIDsignal();
335 break;
c4d11b15 336 case kTRDbackup:
337 t->GetExternalParameters(fTx,fTp);
338 t->GetExternalCovariance(fTc);
35f4ab61 339 fTalpha = t->GetAlpha();
c4d11b15 340 fTRDncls0 = t->GetNumberOfClusters();
341 break;
342 case kTOFin:
343 break;
344 case kTOFout:
345 break;
d0862fea 346 case kTRDStop:
347 break;
ae982df3 348 default:
5f7789fc 349 AliError("Wrong flag !");
ae982df3 350 return kFALSE;
351 }
352
15614b8b 353 return rc;
ae982df3 354}
355
356//_______________________________________________________________________
67c3dcbe 357void
5ccd1720 358AliESDtrack::SetConstrainedTrackParams(const AliKalmanTrack *t, Double_t chi2) {
67c3dcbe 359 //
360 // This function sets the constrained track parameters
361 //
db3989b3 362 Int_t i;
363 Double_t x,buf[15];
67c3dcbe 364 fCalpha=t->GetAlpha();
db3989b3 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];
67c3dcbe 369 fCchi2=chi2;
370}
371
372
373//_______________________________________________________________________
ae982df3 374void 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}
15614b8b 381
382//_______________________________________________________________________
383Bool_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
67c3dcbe 403//_______________________________________________________________________
a866ac60 404void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
67c3dcbe 405 //---------------------------------------------------------------------
406 // This function returns external representation of the cov. matrix
407 //---------------------------------------------------------------------
a866ac60 408 for (Int_t i=0; i<15; i++) cov[i]=fRc[i];
67c3dcbe 409}
410
411
412//_______________________________________________________________________
413void
414AliESDtrack::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//_______________________________________________________________________
422void
423AliESDtrack::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
ae982df3 430
431Double_t AliESDtrack::GetP() const {
432 //---------------------------------------------------------------------
433 // This function returns the track momentum
b322ab2f 434 // Results for (nearly) straight tracks are meaningless !
ae982df3 435 //---------------------------------------------------------------------
2157f4f2 436 if (TMath::Abs(fRp[4])<=0) return 0;
ae982df3 437 Double_t pt=1./TMath::Abs(fRp[4]);
5bc70ad8 438 return pt*TMath::Sqrt(1.+ fRp[3]*fRp[3]);
ae982df3 439}
440
09c96efc 441Bool_t Local2GlobalMomentum(Double_t p[3],Double_t alpha) {
442 //----------------------------------------------------------------
443 // This function performs local->global transformation of the
444 // track momentum.
445 // When called, the arguments are:
446 // p[0] = 1/pt of the track;
447 // p[1] = sine of local azim. angle of the track momentum;
448 // p[2] = tangent of the track momentum dip angle;
449 // alpha - rotation angle.
450 // The result is returned as:
451 // p[0] = px
452 // p[1] = py
453 // p[2] = pz
454 // Results for (nearly) straight tracks are meaningless !
455 //----------------------------------------------------------------
456 if (TMath::Abs(p[0])<=0) return kFALSE;
457 if (TMath::Abs(p[1])> 0.999999) return kFALSE;
458
459 Double_t pt=1./TMath::Abs(p[0]);
460 Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha);
461 Double_t r=TMath::Sqrt(1 - p[1]*p[1]);
462 p[0]=pt*(r*cs - p[1]*sn); p[1]=pt*(p[1]*cs + r*sn); p[2]=pt*p[2];
463
464 return kTRUE;
465}
466
467Bool_t Local2GlobalPosition(Double_t r[3],Double_t alpha) {
468 //----------------------------------------------------------------
469 // This function performs local->global transformation of the
470 // track position.
471 // When called, the arguments are:
472 // r[0] = local x
473 // r[1] = local y
474 // r[2] = local z
475 // alpha - rotation angle.
476 // The result is returned as:
477 // r[0] = global x
478 // r[1] = global y
479 // r[2] = global z
480 //----------------------------------------------------------------
481 Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha), x=r[0];
482 r[0]=x*cs - r[1]*sn; r[1]=x*sn + r[1]*cs;
483
484 return kTRUE;
485}
486
487Bool_t AliESDtrack::GetConstrainedPxPyPz(Double_t *p) const {
67c3dcbe 488 //---------------------------------------------------------------------
489 // This function returns the constrained global track momentum components
b322ab2f 490 // Results for (nearly) straight tracks are meaningless !
67c3dcbe 491 //---------------------------------------------------------------------
09c96efc 492 p[0]=fCp[4]; p[1]=fCp[2]; p[2]=fCp[3];
493 return Local2GlobalMomentum(p,fCalpha);
494}
b322ab2f 495
09c96efc 496Bool_t AliESDtrack::GetConstrainedXYZ(Double_t *r) const {
67c3dcbe 497 //---------------------------------------------------------------------
09c96efc 498 // This function returns the constrained global track position
67c3dcbe 499 //---------------------------------------------------------------------
09c96efc 500 r[0]=fCx; r[1]=fCp[0]; r[2]=fCp[1];
501 return Local2GlobalPosition(r,fCalpha);
67c3dcbe 502}
503
09c96efc 504Bool_t AliESDtrack::GetPxPyPz(Double_t *p) const {
ae982df3 505 //---------------------------------------------------------------------
506 // This function returns the global track momentum components
b322ab2f 507 // Results for (nearly) straight tracks are meaningless !
ae982df3 508 //---------------------------------------------------------------------
09c96efc 509 p[0]=fRp[4]; p[1]=fRp[2]; p[2]=fRp[3];
510 return Local2GlobalMomentum(p,fRalpha);
ae982df3 511}
b322ab2f 512
09c96efc 513Bool_t AliESDtrack::GetXYZ(Double_t *r) const {
ae982df3 514 //---------------------------------------------------------------------
515 // This function returns the global track position
516 //---------------------------------------------------------------------
09c96efc 517 r[0]=fRx; r[1]=fRp[0]; r[2]=fRp[1];
518 return Local2GlobalPosition(r,fRalpha);
ae982df3 519}
520
b322ab2f 521void AliESDtrack::GetCovariance(Double_t cv[21]) const {
522 //---------------------------------------------------------------------
523 // This function returns the global covariance matrix of the track params
524 //
525 // Cov(x,x) ... : cv[0]
526 // Cov(y,x) ... : cv[1] cv[2]
527 // Cov(z,x) ... : cv[3] cv[4] cv[5]
528 // Cov(px,x)... : cv[6] cv[7] cv[8] cv[9]
23904d16 529 // Cov(py,x)... : cv[10] cv[11] cv[12] cv[13] cv[14]
530 // Cov(pz,x)... : cv[15] cv[16] cv[17] cv[18] cv[19] cv[20]
b322ab2f 531 //
532 // Results for (nearly) straight tracks are meaningless !
533 //---------------------------------------------------------------------
534 if (TMath::Abs(fRp[4])<=0) {
535 for (Int_t i=0; i<21; i++) cv[i]=0.;
536 return;
537 }
538 if (TMath::Abs(fRp[2]) > 0.999999) {
539 for (Int_t i=0; i<21; i++) cv[i]=0.;
540 return;
541 }
542 Double_t pt=1./TMath::Abs(fRp[4]);
543 Double_t cs=TMath::Cos(fRalpha), sn=TMath::Sin(fRalpha);
544 Double_t r=TMath::Sqrt(1-fRp[2]*fRp[2]);
545
546 Double_t m00=-sn, m10=cs;
547 Double_t m23=-pt*(sn + fRp[2]*cs/r), m43=-pt*pt*(r*cs - fRp[2]*sn);
548 Double_t m24= pt*(cs - fRp[2]*sn/r), m44=-pt*pt*(r*sn + fRp[2]*cs);
549 Double_t m35=pt, m45=-pt*pt*fRp[3];
550
551 cv[0]=fRc[0]*m00*m00;
552 cv[1]=fRc[0]*m00*m10;
553 cv[2]=fRc[0]*m10*m10;
554 cv[3]=fRc[1]*m00;
555 cv[4]=fRc[1]*m10;
556 cv[5]=fRc[2];
557 cv[6]=m00*(fRc[3]*m23+fRc[10]*m43);
558 cv[7]=m10*(fRc[3]*m23+fRc[10]*m43);
559 cv[8]=fRc[4]*m23+fRc[11]*m43;
560 cv[9]=m23*(fRc[5]*m23+fRc[12]*m43)+m43*(fRc[12]*m23+fRc[14]*m43);
561 cv[10]=m00*(fRc[3]*m24+fRc[10]*m44);
562 cv[11]=m10*(fRc[3]*m24+fRc[10]*m44);
563 cv[12]=fRc[4]*m24+fRc[11]*m44;
564 cv[13]=m23*(fRc[5]*m24+fRc[12]*m44)+m43*(fRc[12]*m24+fRc[14]*m44);
565 cv[14]=m24*(fRc[5]*m24+fRc[12]*m44)+m44*(fRc[12]*m24+fRc[14]*m44);
566 cv[15]=m00*(fRc[6]*m35+fRc[10]*m45);
567 cv[16]=m10*(fRc[6]*m35+fRc[10]*m45);
568 cv[17]=fRc[7]*m35+fRc[11]*m45;
569 cv[18]=m23*(fRc[8]*m35+fRc[12]*m45)+m43*(fRc[13]*m35+fRc[14]*m45);
570 cv[19]=m24*(fRc[8]*m35+fRc[12]*m45)+m44*(fRc[13]*m35+fRc[14]*m45);
571 cv[20]=m35*(fRc[9]*m35+fRc[13]*m45)+m45*(fRc[13]*m35+fRc[14]*m45);
572}
67c3dcbe 573
09c96efc 574Bool_t AliESDtrack::GetInnerPxPyPz(Double_t *p) const {
9b859005 575 //---------------------------------------------------------------------
576 // This function returns the global track momentum components
577 // af the entrance of the TPC
578 //---------------------------------------------------------------------
09c96efc 579 p[0]=fIp[4]; p[1]=fIp[2]; p[2]=fIp[3];
580 return Local2GlobalMomentum(p,fIalpha);
9b859005 581}
582
09c96efc 583Bool_t AliESDtrack::GetInnerXYZ(Double_t *r) const {
9b859005 584 //---------------------------------------------------------------------
585 // This function returns the global track position
586 // af the entrance of the TPC
587 //---------------------------------------------------------------------
09c96efc 588 if (fIx==0) return kFALSE;
589 r[0]=fIx; r[1]=fIp[0]; r[2]=fIp[1];
590 return Local2GlobalPosition(r,fIalpha);
9b859005 591}
592
a866ac60 593void AliESDtrack::GetInnerExternalParameters(Double_t &x, Double_t p[5]) const
594{
595 //skowron
596 //---------------------------------------------------------------------
597 // This function returns external representation of the track parameters at Inner Layer of TPC
598 //---------------------------------------------------------------------
599 x=fIx;
600 for (Int_t i=0; i<5; i++) p[i]=fIp[i];
601}
602void AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const
603{
604 //skowron
605 //---------------------------------------------------------------------
606 // This function returns external representation of the cov. matrix at Inner Layer of TPC
607 //---------------------------------------------------------------------
608 for (Int_t i=0; i<15; i++) cov[i]=fIc[i];
609
610}
611
35f4ab61 612void AliESDtrack::GetTRDExternalParameters(Double_t &x, Double_t&alpha, Double_t p[5], Double_t cov[15]) const
c4d11b15 613{
614 //
615 //this function returns TRD parameters
616 //
617 x=fTx;
35f4ab61 618 alpha = fTalpha;
c4d11b15 619 for (Int_t i=0; i<5; i++) p[i]=fTp[i];
620 for (Int_t i=0; i<15; i++) cov[i]=fTc[i];
621}
622
23904d16 623Bool_t AliESDtrack::GetPxPyPzAt(Double_t x,Double_t *p) const {
672b5f43 624 //---------------------------------------------------------------------
625 // This function returns the global track momentum components
23904d16 626 // at the position "x" using the helix track approximation
672b5f43 627 //---------------------------------------------------------------------
09c96efc 628 p[0]=fRp[4];
629 p[1]=fRp[2]+(x-fRx)*fRp[4]/AliKalmanTrack::GetConvConst();
630 p[2]=fRp[3];
631 return Local2GlobalMomentum(p,fRalpha);
672b5f43 632}
633
09c96efc 634Bool_t AliESDtrack::GetXYZAt(Double_t x, Double_t *r) const {
3fd96ae3 635 //---------------------------------------------------------------------
636 // This function returns the global track position
23904d16 637 // af the radius "x" using the helix track approximation
3fd96ae3 638 //---------------------------------------------------------------------
23904d16 639 Double_t dx=x-fRx;
640 Double_t f1=fRp[2], f2=f1 + dx*fRp[4]/AliKalmanTrack::GetConvConst();
641
642 if (TMath::Abs(f2) >= 0.9999) return kFALSE;
643
644 Double_t r1=TMath::Sqrt(1.- f1*f1), r2=TMath::Sqrt(1.- f2*f2);
09c96efc 645 r[0] = x;
646 r[1] = fRp[0] + dx*(f1+f2)/(r1+r2);
647 r[2] = fRp[1] + dx*(f1+f2)/(f1*r2 + f2*r1)*fRp[3];
648 return Local2GlobalPosition(r,fRalpha);
23904d16 649}
672b5f43 650
ae982df3 651//_______________________________________________________________________
ae982df3 652void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
4427806c 653 // Returns the array with integrated times for each particle hypothesis
ae982df3 654 for (Int_t i=0; i<kSPECIES; i++) times[i]=fTrackTime[i];
655}
656
657//_______________________________________________________________________
658void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
4427806c 659 // Sets the array with integrated times for each particle hypotesis
ae982df3 660 for (Int_t i=0; i<kSPECIES; i++) fTrackTime[i]=times[i];
661}
662
663//_______________________________________________________________________
4427806c 664void AliESDtrack::SetITSpid(const Double_t *p) {
665 // Sets values for the probability of each particle type (in ITS)
c630aafd 666 for (Int_t i=0; i<kSPECIES; i++) fITSr[i]=p[i];
667 SetStatus(AliESDtrack::kITSpid);
668}
669
babd135a 670void AliESDtrack::SetITSChi2MIP(const Float_t *chi2mip){
c4d11b15 671 for (Int_t i=0; i<12; i++) fITSchi2MIP[i]=chi2mip[i];
babd135a 672}
c630aafd 673//_______________________________________________________________________
674void AliESDtrack::GetITSpid(Double_t *p) const {
4427806c 675 // Gets the probability of each particle type (in ITS)
c630aafd 676 for (Int_t i=0; i<kSPECIES; i++) p[i]=fITSr[i];
677}
678
679//_______________________________________________________________________
ae982df3 680Int_t AliESDtrack::GetITSclusters(UInt_t *idx) const {
681 //---------------------------------------------------------------------
682 // This function returns indices of the assgined ITS clusters
683 //---------------------------------------------------------------------
684 for (Int_t i=0; i<fITSncls; i++) idx[i]=fITSindex[i];
685 return fITSncls;
686}
687
688//_______________________________________________________________________
05e445cd 689Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
ae982df3 690 //---------------------------------------------------------------------
691 // This function returns indices of the assgined ITS clusters
692 //---------------------------------------------------------------------
d1420ddf 693 if (idx!=0)
694 for (Int_t i=0; i<180; i++) idx[i]=fTPCindex[i]; // MI I prefer some constant
ae982df3 695 return fTPCncls;
696}
8c6a71ab 697
698//_______________________________________________________________________
699void AliESDtrack::SetTPCpid(const Double_t *p) {
4427806c 700 // Sets values for the probability of each particle type (in TPC)
8c6a71ab 701 for (Int_t i=0; i<kSPECIES; i++) fTPCr[i]=p[i];
702 SetStatus(AliESDtrack::kTPCpid);
703}
704
705//_______________________________________________________________________
706void AliESDtrack::GetTPCpid(Double_t *p) const {
4427806c 707 // Gets the probability of each particle type (in TPC)
8c6a71ab 708 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTPCr[i];
709}
710
711//_______________________________________________________________________
bb2ceb1f 712Int_t AliESDtrack::GetTRDclusters(UInt_t *idx) const {
713 //---------------------------------------------------------------------
714 // This function returns indices of the assgined TRD clusters
715 //---------------------------------------------------------------------
d1420ddf 716 if (idx!=0)
c4d11b15 717 for (Int_t i=0; i<130; i++) idx[i]=fTRDindex[i]; // MI I prefer some constant
bb2ceb1f 718 return fTRDncls;
719}
720
721//_______________________________________________________________________
c630aafd 722void AliESDtrack::SetTRDpid(const Double_t *p) {
4427806c 723 // Sets values for the probability of each particle type (in TRD)
c630aafd 724 for (Int_t i=0; i<kSPECIES; i++) fTRDr[i]=p[i];
725 SetStatus(AliESDtrack::kTRDpid);
726}
727
728//_______________________________________________________________________
729void AliESDtrack::GetTRDpid(Double_t *p) const {
4427806c 730 // Gets the probability of each particle type (in TRD)
c630aafd 731 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTRDr[i];
732}
733
734//_______________________________________________________________________
79e94bf8 735void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
736{
4427806c 737 // Sets the probability of particle type iSpecies to p (in TRD)
79e94bf8 738 fTRDr[iSpecies] = p;
739}
740
741Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
742{
4427806c 743 // Returns the probability of particle type iSpecies (in TRD)
79e94bf8 744 return fTRDr[iSpecies];
745}
746
747//_______________________________________________________________________
c630aafd 748void AliESDtrack::SetTOFpid(const Double_t *p) {
4427806c 749 // Sets the probability of each particle type (in TOF)
c630aafd 750 for (Int_t i=0; i<kSPECIES; i++) fTOFr[i]=p[i];
751 SetStatus(AliESDtrack::kTOFpid);
752}
753
754//_______________________________________________________________________
51ad6848 755void AliESDtrack::SetTOFLabel(const Int_t *p) {
756 // Sets (in TOF)
757 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
758}
759
760//_______________________________________________________________________
c630aafd 761void AliESDtrack::GetTOFpid(Double_t *p) const {
4427806c 762 // Gets probabilities of each particle type (in TOF)
c630aafd 763 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTOFr[i];
764}
765
51ad6848 766//_______________________________________________________________________
767void AliESDtrack::GetTOFLabel(Int_t *p) const {
768 // Gets (in TOF)
769 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
770}
771
772//_______________________________________________________________________
773void AliESDtrack::GetTOFInfo(Float_t *info) const {
774 // Gets (in TOF)
775 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
776}
777
778//_______________________________________________________________________
779void AliESDtrack::SetTOFInfo(Float_t*info) {
780 // Gets (in TOF)
781 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
782}
783
4a78b8c5 784
785
786//_______________________________________________________________________
787void AliESDtrack::SetPHOSpid(const Double_t *p) {
788 // Sets the probability of each particle type (in PHOS)
ac2f7574 789 for (Int_t i=0; i<kSPECIESN; i++) fPHOSr[i]=p[i];
4a78b8c5 790 SetStatus(AliESDtrack::kPHOSpid);
791}
792
793//_______________________________________________________________________
794void AliESDtrack::GetPHOSpid(Double_t *p) const {
795 // Gets probabilities of each particle type (in PHOS)
ac2f7574 796 for (Int_t i=0; i<kSPECIESN; i++) p[i]=fPHOSr[i];
4a78b8c5 797}
798
704be597 799//_______________________________________________________________________
800void AliESDtrack::SetEMCALpid(const Double_t *p) {
801 // Sets the probability of each particle type (in EMCAL)
802 for (Int_t i=0; i<kSPECIESN; i++) fEMCALr[i]=p[i];
803 SetStatus(AliESDtrack::kEMCALpid);
804}
805
806//_______________________________________________________________________
807void AliESDtrack::GetEMCALpid(Double_t *p) const {
808 // Gets probabilities of each particle type (in EMCAL)
809 for (Int_t i=0; i<kSPECIESN; i++) p[i]=fEMCALr[i];
810}
4a78b8c5 811
812//_______________________________________________________________________
813void AliESDtrack::SetRICHpid(const Double_t *p) {
814 // Sets the probability of each particle type (in RICH)
815 for (Int_t i=0; i<kSPECIES; i++) fRICHr[i]=p[i];
816 SetStatus(AliESDtrack::kRICHpid);
817}
818
819//_______________________________________________________________________
820void AliESDtrack::GetRICHpid(Double_t *p) const {
821 // Gets probabilities of each particle type (in RICH)
822 for (Int_t i=0; i<kSPECIES; i++) p[i]=fRICHr[i];
823}
824
825
826
c630aafd 827//_______________________________________________________________________
8c6a71ab 828void AliESDtrack::SetESDpid(const Double_t *p) {
4427806c 829 // Sets the probability of each particle type for the ESD track
8c6a71ab 830 for (Int_t i=0; i<kSPECIES; i++) fR[i]=p[i];
831 SetStatus(AliESDtrack::kESDpid);
832}
833
834//_______________________________________________________________________
835void AliESDtrack::GetESDpid(Double_t *p) const {
4427806c 836 // Gets probability of each particle type for the ESD track
8c6a71ab 837 for (Int_t i=0; i<kSPECIES; i++) p[i]=fR[i];
838}
839
ac2f7574 840//_______________________________________________________________________
841void AliESDtrack::Print(Option_t *) const {
842 // Prints info on the track
843
5f7789fc 844 printf("ESD track info\n") ;
ac2f7574 845 Double_t p[kSPECIESN] ;
846 Int_t index = 0 ;
847 if( IsOn(kITSpid) ){
848 printf("From ITS: ") ;
849 GetITSpid(p) ;
850 for(index = 0 ; index < kSPECIES; index++)
851 printf("%f, ", p[index]) ;
852 printf("\n signal = %f\n", GetITSsignal()) ;
853 }
854 if( IsOn(kTPCpid) ){
855 printf("From TPC: ") ;
856 GetTPCpid(p) ;
857 for(index = 0 ; index < kSPECIES; index++)
858 printf("%f, ", p[index]) ;
859 printf("\n signal = %f\n", GetTPCsignal()) ;
860 }
861 if( IsOn(kTRDpid) ){
862 printf("From TRD: ") ;
863 GetTRDpid(p) ;
864 for(index = 0 ; index < kSPECIES; index++)
865 printf("%f, ", p[index]) ;
866 printf("\n signal = %f\n", GetTRDsignal()) ;
867 }
868 if( IsOn(kTOFpid) ){
869 printf("From TOF: ") ;
870 GetTOFpid(p) ;
871 for(index = 0 ; index < kSPECIES; index++)
872 printf("%f, ", p[index]) ;
873 printf("\n signal = %f\n", GetTOFsignal()) ;
874 }
875 if( IsOn(kRICHpid) ){
876 printf("From TOF: ") ;
877 GetRICHpid(p) ;
878 for(index = 0 ; index < kSPECIES; index++)
879 printf("%f, ", p[index]) ;
880 printf("\n signal = %f\n", GetRICHsignal()) ;
881 }
882 if( IsOn(kPHOSpid) ){
883 printf("From PHOS: ") ;
884 GetPHOSpid(p) ;
885 for(index = 0 ; index < kSPECIESN; index++)
886 printf("%f, ", p[index]) ;
887 printf("\n signal = %f\n", GetPHOSsignal()) ;
888 }
704be597 889 if( IsOn(kEMCALpid) ){
890 printf("From EMCAL: ") ;
891 GetEMCALpid(p) ;
892 for(index = 0 ; index < kSPECIESN; index++)
893 printf("%f, ", p[index]) ;
894 printf("\n signal = %f\n", GetEMCALsignal()) ;
895 }
ac2f7574 896}