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