Taking into account primary vertex position (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 **************************************************************************/
15
16//-----------------------------------------------------------------
17// Implementation of the ESD track class
4427806c 18// ESD = Event Summary Data
ae982df3 19// This is the class to deal with during the phisical analysis of data
4427806c 20// Origin: Iouri Belikov, CERN
21// e-mail: Jouri.Belikov@cern.ch
ae982df3 22//-----------------------------------------------------------------
23
24#include "TMath.h"
25
26#include "AliESDtrack.h"
27#include "AliKalmanTrack.h"
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),
44fOalpha(0),
45fOx(0),
2bad268c 46fITSchi2(0),
ae982df3 47fITSncls(0),
2bad268c 48fITSsignal(0),
2bad268c 49fTPCchi2(0),
05e445cd 50fTPCncls(0),
a866ac60 51fTPCClusterMap(159),//number of padrows
2bad268c 52fTPCsignal(0),
53fTRDchi2(0),
54fTRDncls(0),
55fTRDsignal(0),
56fTOFchi2(0),
57fTOFindex(0),
4a78b8c5 58fTOFsignal(-1),
59fPHOSsignal(-1),
60fRICHsignal(-1)
ae982df3 61{
62 //
63 // The default ESD constructor
64 //
2bad268c 65 for (Int_t i=0; i<kSPECIES; i++) {
4a78b8c5 66 fTrackTime[i]=0.;
67 fR[i]=1.;
68 fITSr[i]=1.;
69 fTPCr[i]=1.;
70 fTRDr[i]=1.;
71 fTOFr[i]=1.;
72 fPHOSr[i]=1.;
73 fRICHr[i]=1.;
2bad268c 74 }
4a78b8c5 75 fPHOSpos[0]=fPHOSpos[1]=fPHOSpos[2]=0.;
bb2ceb1f 76 Int_t i;
a866ac60 77 for (i=0; i<5; i++) { fRp[i]=0.; fCp[i]=0.; fIp[i]=0.; fOp[i]=0.;}
78 for (i=0; i<15; i++) { fRc[i]=0.; fCc[i]=0.; fIc[i]=0.; fOc[i]=0.; }
79 for (i=0; i<6; i++) { fITSindex[i]=0; }
80 for (i=0; i<180; i++){ fTPCindex[i]=0; }
81 for (i=0; i<90; i++) { fTRDindex[i]=0; }
6e5b1b04 82 fTPCLabel = 0;
83 fTRDLabel = 0;
84 fITSLabel = 0;
85
ae982df3 86}
87
88//_______________________________________________________________________
4a78b8c5 89Double_t AliESDtrack::GetMass() const {
4427806c 90 // Returns the mass of the most probable particle type
ae982df3 91 Float_t max=0.;
92 Int_t k=-1;
93 for (Int_t i=0; i<kSPECIES; i++) {
94 if (fR[i]>max) {k=i; max=fR[i];}
95 }
96 if (k==0) return 0.00051;
97 if (k==1) return 0.10566;
98 if (k==2||k==-1) return 0.13957;
99 if (k==3) return 0.49368;
100 if (k==4) return 0.93827;
101 Warning("GetMass()","Undefined mass !");
102 return 0.13957;
103}
104
105//_______________________________________________________________________
ad2f1f2b 106Bool_t AliESDtrack::UpdateTrackParams(AliKalmanTrack *t, ULong_t flags) {
ae982df3 107 //
108 // This function updates track's running parameters
109 //
9b859005 110 SetStatus(flags);
111 fLabel=t->GetLabel();
112
113 if (t->IsStartedTimeIntegral()) {
114 SetStatus(kTIME);
115 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
116 SetIntegratedLength(t->GetIntegratedLength());
117 }
118
119 fRalpha=t->GetAlpha();
120 t->GetExternalParameters(fRx,fRp);
121 t->GetExternalCovariance(fRc);
122
ae982df3 123 switch (flags) {
ad2f1f2b 124
9b859005 125 case kITSin: case kITSout: case kITSrefit:
ae982df3 126 fITSncls=t->GetNumberOfClusters();
127 fITSchi2=t->GetChi2();
128 for (Int_t i=0;i<fITSncls;i++) fITSindex[i]=t->GetClusterIndex(i);
129 fITSsignal=t->GetPIDsignal();
6e5b1b04 130 fITSLabel = t->GetLabel();
babd135a 131 fITSFakeRatio = t->GetFakeRatio();
ae982df3 132 break;
ad2f1f2b 133
9b859005 134 case kTPCin: case kTPCrefit:
6e5b1b04 135 fTPCLabel = t->GetLabel();
9b859005 136 fIalpha=fRalpha;
137 fIx=fRx;
138 {
139 Int_t i;
140 for (i=0; i<5; i++) fIp[i]=fRp[i];
141 for (i=0; i<15;i++) fIc[i]=fRc[i];
142 }
143 case kTPCout:
a866ac60 144
ae982df3 145 fTPCncls=t->GetNumberOfClusters();
146 fTPCchi2=t->GetChi2();
a866ac60 147
148 {//prevrow must be declared in separate namespace, otherwise compiler cries:
149 //"jump to case label crosses initialization of `Int_t prevrow'"
150 Int_t prevrow = -1;
6e5b1b04 151 // for (Int_t i=0;i<fTPCncls;i++)
152 for (Int_t i=0;i<160;i++)
a866ac60 153 {
154 fTPCindex[i]=t->GetClusterIndex(i);
155
156 // Piotr's Cluster Map for HBT
157 // ### please change accordingly if cluster array is changing
158 // to "New TPC Tracking" style (with gaps in array)
159 Int_t idx = fTPCindex[i];
160 Int_t sect = (idx&0xff000000)>>24;
161 Int_t row = (idx&0x00ff0000)>>16;
162 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
163
164 fTPCClusterMap.SetBitNumber(row,kTRUE);
165
166 //Fill the gap between previous row and this row with 0 bits
167 //In case ### pleas change it as well - just set bit 0 in case there
168 //is no associated clusters for current "i"
169 if (prevrow < 0)
170 {
171 prevrow = row;//if previous bit was not assigned yet == this is the first one
172 }
173 else
174 { //we don't know the order (inner to outer or reverse)
175 //just to be save in case it is going to change
176 Int_t n = 0, m = 0;
177 if (prevrow < row)
178 {
179 n = prevrow;
180 m = row;
181 }
182 else
183 {
184 n = row;
185 m = prevrow;
186 }
187
188 for (Int_t j = n+1; j < m; j++)
189 {
190 fTPCClusterMap.SetBitNumber(j,kFALSE);
191 }
192 prevrow = row;
193 }
194 // End Of Piotr's Cluster Map for HBT
195 }
196 }
ae982df3 197 fTPCsignal=t->GetPIDsignal();
198 {Double_t mass=t->GetMass(); // preliminary mass setting
199 if (mass>0.5) fR[4]=1.; // used by
200 else if (mass<0.4) fR[2]=1.; // the ITS reconstruction
a866ac60 201 else fR[3]=1.;}
202 //
ae982df3 203 break;
9b859005 204
672b5f43 205 case kTRDout:
206 { //requested by the PHOS ("temporary solution")
258fa377 207 Double_t r=460.;
e964f790 208 if (t->PropagateTo(r,30.,0.)) {
209 fOalpha=t->GetAlpha();
210 t->GetExternalParameters(fOx,fOp);
211 t->GetExternalCovariance(fOc);
212 }
672b5f43 213 }
214 case kTRDin: case kTRDrefit:
6e5b1b04 215 fTRDLabel = t->GetLabel();
216
79e94bf8 217 fTRDncls=t->GetNumberOfClusters();
218 fTRDchi2=t->GetChi2();
bb2ceb1f 219 for (Int_t i=0;i<fTRDncls;i++) fTRDindex[i]=t->GetClusterIndex(i);
79e94bf8 220 fTRDsignal=t->GetPIDsignal();
221 break;
d0862fea 222 case kTRDStop:
223 break;
ae982df3 224 default:
225 Error("UpdateTrackParams()","Wrong flag !\n");
226 return kFALSE;
227 }
228
ae982df3 229 return kTRUE;
230}
231
232//_______________________________________________________________________
67c3dcbe 233void
234AliESDtrack::SetConstrainedTrackParams(AliKalmanTrack *t, Double_t chi2) {
235 //
236 // This function sets the constrained track parameters
237 //
238 fCalpha=t->GetAlpha();
239 t->GetExternalParameters(fCx,fCp);
240 t->GetExternalCovariance(fCc);
241 fCchi2=chi2;
242}
243
244
245//_______________________________________________________________________
ae982df3 246void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
247 //---------------------------------------------------------------------
248 // This function returns external representation of the track parameters
249 //---------------------------------------------------------------------
250 x=fRx;
251 for (Int_t i=0; i<5; i++) p[i]=fRp[i];
252}
67c3dcbe 253//_______________________________________________________________________
a866ac60 254void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
67c3dcbe 255 //---------------------------------------------------------------------
256 // This function returns external representation of the cov. matrix
257 //---------------------------------------------------------------------
a866ac60 258 for (Int_t i=0; i<15; i++) cov[i]=fRc[i];
67c3dcbe 259}
260
261
262//_______________________________________________________________________
263void
264AliESDtrack::GetConstrainedExternalParameters(Double_t &x, Double_t p[5])const{
265 //---------------------------------------------------------------------
266 // This function returns the constrained external track parameters
267 //---------------------------------------------------------------------
268 x=fCx;
269 for (Int_t i=0; i<5; i++) p[i]=fCp[i];
270}
271//_______________________________________________________________________
272void
273AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
274 //---------------------------------------------------------------------
275 // This function returns the constrained external cov. matrix
276 //---------------------------------------------------------------------
277 for (Int_t i=0; i<15; i++) c[i]=fCc[i];
278}
279
ae982df3 280
281Double_t AliESDtrack::GetP() const {
282 //---------------------------------------------------------------------
283 // This function returns the track momentum
284 //---------------------------------------------------------------------
285 Double_t lam=TMath::ATan(fRp[3]);
286 Double_t pt=1./TMath::Abs(fRp[4]);
287 return pt/TMath::Cos(lam);
288}
289
67c3dcbe 290void AliESDtrack::GetConstrainedPxPyPz(Double_t *p) const {
291 //---------------------------------------------------------------------
292 // This function returns the constrained global track momentum components
293 //---------------------------------------------------------------------
294 Double_t phi=TMath::ASin(fCp[2]) + fCalpha;
295 Double_t pt=1./TMath::Abs(fCp[4]);
296 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fCp[3];
297}
298void AliESDtrack::GetConstrainedXYZ(Double_t *xyz) const {
299 //---------------------------------------------------------------------
300 // This function returns the global track position
301 //---------------------------------------------------------------------
302 Double_t phi=TMath::ATan2(fCp[0],fCx) + fCalpha;
303 Double_t r=TMath::Sqrt(fCx*fCx + fCp[0]*fCp[0]);
304 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fCp[1];
305}
306
ae982df3 307void AliESDtrack::GetPxPyPz(Double_t *p) const {
308 //---------------------------------------------------------------------
309 // This function returns the global track momentum components
310 //---------------------------------------------------------------------
311 Double_t phi=TMath::ASin(fRp[2]) + fRalpha;
312 Double_t pt=1./TMath::Abs(fRp[4]);
313 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fRp[3];
314}
ae982df3 315void AliESDtrack::GetXYZ(Double_t *xyz) const {
316 //---------------------------------------------------------------------
317 // This function returns the global track position
318 //---------------------------------------------------------------------
bb2ceb1f 319 Double_t phi=TMath::ATan2(fRp[0],fRx) + fRalpha;
ae982df3 320 Double_t r=TMath::Sqrt(fRx*fRx + fRp[0]*fRp[0]);
321 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fRp[1];
322}
323
67c3dcbe 324
9b859005 325void AliESDtrack::GetInnerPxPyPz(Double_t *p) const {
326 //---------------------------------------------------------------------
327 // This function returns the global track momentum components
328 // af the entrance of the TPC
329 //---------------------------------------------------------------------
e964f790 330 if (fIx==0) {p[0]=p[1]=p[2]=0.; return;}
9b859005 331 Double_t phi=TMath::ASin(fIp[2]) + fIalpha;
332 Double_t pt=1./TMath::Abs(fIp[4]);
333 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fIp[3];
334}
335
336void AliESDtrack::GetInnerXYZ(Double_t *xyz) const {
337 //---------------------------------------------------------------------
338 // This function returns the global track position
339 // af the entrance of the TPC
340 //---------------------------------------------------------------------
e964f790 341 if (fIx==0) {xyz[0]=xyz[1]=xyz[2]=0.; return;}
9b859005 342 Double_t phi=TMath::ATan2(fIp[0],fIx) + fIalpha;
343 Double_t r=TMath::Sqrt(fIx*fIx + fIp[0]*fIp[0]);
344 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fIp[1];
345}
346
a866ac60 347void AliESDtrack::GetInnerExternalParameters(Double_t &x, Double_t p[5]) const
348{
349 //skowron
350 //---------------------------------------------------------------------
351 // This function returns external representation of the track parameters at Inner Layer of TPC
352 //---------------------------------------------------------------------
353 x=fIx;
354 for (Int_t i=0; i<5; i++) p[i]=fIp[i];
355}
356void AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const
357{
358 //skowron
359 //---------------------------------------------------------------------
360 // This function returns external representation of the cov. matrix at Inner Layer of TPC
361 //---------------------------------------------------------------------
362 for (Int_t i=0; i<15; i++) cov[i]=fIc[i];
363
364}
365
672b5f43 366void AliESDtrack::GetOuterPxPyPz(Double_t *p) const {
367 //---------------------------------------------------------------------
368 // This function returns the global track momentum components
369 // af the radius of the PHOS
370 //---------------------------------------------------------------------
e964f790 371 if (fOx==0) {p[0]=p[1]=p[2]=0.; return;}
672b5f43 372 Double_t phi=TMath::ASin(fOp[2]) + fOalpha;
373 Double_t pt=1./TMath::Abs(fOp[4]);
374 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fOp[3];
375}
376
377void AliESDtrack::GetOuterXYZ(Double_t *xyz) const {
378 //---------------------------------------------------------------------
379 // This function returns the global track position
380 // af the radius of the PHOS
381 //---------------------------------------------------------------------
e964f790 382 if (fOx==0) {xyz[0]=xyz[1]=xyz[2]=0.; return;}
672b5f43 383 Double_t phi=TMath::ATan2(fOp[0],fOx) + fOalpha;
384 Double_t r=TMath::Sqrt(fOx*fOx + fOp[0]*fOp[0]);
385 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fOp[1];
386}
387
ae982df3 388//_______________________________________________________________________
ae982df3 389void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
4427806c 390 // Returns the array with integrated times for each particle hypothesis
ae982df3 391 for (Int_t i=0; i<kSPECIES; i++) times[i]=fTrackTime[i];
392}
393
394//_______________________________________________________________________
395void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
4427806c 396 // Sets the array with integrated times for each particle hypotesis
ae982df3 397 for (Int_t i=0; i<kSPECIES; i++) fTrackTime[i]=times[i];
398}
399
400//_______________________________________________________________________
4427806c 401void AliESDtrack::SetITSpid(const Double_t *p) {
402 // Sets values for the probability of each particle type (in ITS)
c630aafd 403 for (Int_t i=0; i<kSPECIES; i++) fITSr[i]=p[i];
404 SetStatus(AliESDtrack::kITSpid);
405}
406
babd135a 407void AliESDtrack::SetITSChi2MIP(const Float_t *chi2mip){
408 for (Int_t i=0; i<6; i++) fITSchi2MIP[i]=chi2mip[i];
409}
c630aafd 410//_______________________________________________________________________
411void AliESDtrack::GetITSpid(Double_t *p) const {
4427806c 412 // Gets the probability of each particle type (in ITS)
c630aafd 413 for (Int_t i=0; i<kSPECIES; i++) p[i]=fITSr[i];
414}
415
416//_______________________________________________________________________
ae982df3 417Int_t AliESDtrack::GetITSclusters(UInt_t *idx) const {
418 //---------------------------------------------------------------------
419 // This function returns indices of the assgined ITS clusters
420 //---------------------------------------------------------------------
421 for (Int_t i=0; i<fITSncls; i++) idx[i]=fITSindex[i];
422 return fITSncls;
423}
424
425//_______________________________________________________________________
05e445cd 426Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
ae982df3 427 //---------------------------------------------------------------------
428 // This function returns indices of the assgined ITS clusters
429 //---------------------------------------------------------------------
d1420ddf 430 if (idx!=0)
431 for (Int_t i=0; i<180; i++) idx[i]=fTPCindex[i]; // MI I prefer some constant
ae982df3 432 return fTPCncls;
433}
8c6a71ab 434
435//_______________________________________________________________________
436void AliESDtrack::SetTPCpid(const Double_t *p) {
4427806c 437 // Sets values for the probability of each particle type (in TPC)
8c6a71ab 438 for (Int_t i=0; i<kSPECIES; i++) fTPCr[i]=p[i];
439 SetStatus(AliESDtrack::kTPCpid);
440}
441
442//_______________________________________________________________________
443void AliESDtrack::GetTPCpid(Double_t *p) const {
4427806c 444 // Gets the probability of each particle type (in TPC)
8c6a71ab 445 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTPCr[i];
446}
447
448//_______________________________________________________________________
bb2ceb1f 449Int_t AliESDtrack::GetTRDclusters(UInt_t *idx) const {
450 //---------------------------------------------------------------------
451 // This function returns indices of the assgined TRD clusters
452 //---------------------------------------------------------------------
d1420ddf 453 if (idx!=0)
454 for (Int_t i=0; i<90; i++) idx[i]=fTRDindex[i]; // MI I prefer some constant
bb2ceb1f 455 return fTRDncls;
456}
457
458//_______________________________________________________________________
c630aafd 459void AliESDtrack::SetTRDpid(const Double_t *p) {
4427806c 460 // Sets values for the probability of each particle type (in TRD)
c630aafd 461 for (Int_t i=0; i<kSPECIES; i++) fTRDr[i]=p[i];
462 SetStatus(AliESDtrack::kTRDpid);
463}
464
465//_______________________________________________________________________
466void AliESDtrack::GetTRDpid(Double_t *p) const {
4427806c 467 // Gets the probability of each particle type (in TRD)
c630aafd 468 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTRDr[i];
469}
470
471//_______________________________________________________________________
79e94bf8 472void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
473{
4427806c 474 // Sets the probability of particle type iSpecies to p (in TRD)
79e94bf8 475 fTRDr[iSpecies] = p;
476}
477
478Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
479{
4427806c 480 // Returns the probability of particle type iSpecies (in TRD)
79e94bf8 481 return fTRDr[iSpecies];
482}
483
484//_______________________________________________________________________
c630aafd 485void AliESDtrack::SetTOFpid(const Double_t *p) {
4427806c 486 // Sets the probability of each particle type (in TOF)
c630aafd 487 for (Int_t i=0; i<kSPECIES; i++) fTOFr[i]=p[i];
488 SetStatus(AliESDtrack::kTOFpid);
489}
490
491//_______________________________________________________________________
492void AliESDtrack::GetTOFpid(Double_t *p) const {
4427806c 493 // Gets probabilities of each particle type (in TOF)
c630aafd 494 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTOFr[i];
495}
496
4a78b8c5 497
498
499//_______________________________________________________________________
500void AliESDtrack::SetPHOSpid(const Double_t *p) {
501 // Sets the probability of each particle type (in PHOS)
502 for (Int_t i=0; i<kSPECIES; i++) fPHOSr[i]=p[i];
503 SetStatus(AliESDtrack::kPHOSpid);
504}
505
506//_______________________________________________________________________
507void AliESDtrack::GetPHOSpid(Double_t *p) const {
508 // Gets probabilities of each particle type (in PHOS)
509 for (Int_t i=0; i<kSPECIES; i++) p[i]=fPHOSr[i];
510}
511
512
513//_______________________________________________________________________
514void AliESDtrack::SetRICHpid(const Double_t *p) {
515 // Sets the probability of each particle type (in RICH)
516 for (Int_t i=0; i<kSPECIES; i++) fRICHr[i]=p[i];
517 SetStatus(AliESDtrack::kRICHpid);
518}
519
520//_______________________________________________________________________
521void AliESDtrack::GetRICHpid(Double_t *p) const {
522 // Gets probabilities of each particle type (in RICH)
523 for (Int_t i=0; i<kSPECIES; i++) p[i]=fRICHr[i];
524}
525
526
527
c630aafd 528//_______________________________________________________________________
8c6a71ab 529void AliESDtrack::SetESDpid(const Double_t *p) {
4427806c 530 // Sets the probability of each particle type for the ESD track
8c6a71ab 531 for (Int_t i=0; i<kSPECIES; i++) fR[i]=p[i];
532 SetStatus(AliESDtrack::kESDpid);
533}
534
535//_______________________________________________________________________
536void AliESDtrack::GetESDpid(Double_t *p) const {
4427806c 537 // Gets probability of each particle type for the ESD track
8c6a71ab 538 for (Int_t i=0; i<kSPECIES; i++) p[i]=fR[i];
539}
540