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