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