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