]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDtrack.cxx
Macro to read the ESD event
[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
67c3dcbe 232//_______________________________________________________________________
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
ae982df3 245//_______________________________________________________________________
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 //---------------------------------------------------------------------
2157f4f2 285 if (TMath::Abs(fRp[4])<=0) return 0;
ae982df3 286 Double_t lam=TMath::ATan(fRp[3]);
287 Double_t pt=1./TMath::Abs(fRp[4]);
288 return pt/TMath::Cos(lam);
289}
290
67c3dcbe 291void AliESDtrack::GetConstrainedPxPyPz(Double_t *p) const {
292 //---------------------------------------------------------------------
293 // This function returns the constrained global track momentum components
294 //---------------------------------------------------------------------
2157f4f2 295 if (TMath::Abs(fCp[4])<=0) {
296 p[0]=p[1]=p[2]=0;
297 return;
298 }
67c3dcbe 299 Double_t phi=TMath::ASin(fCp[2]) + fCalpha;
300 Double_t pt=1./TMath::Abs(fCp[4]);
301 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fCp[3];
302}
303void AliESDtrack::GetConstrainedXYZ(Double_t *xyz) const {
304 //---------------------------------------------------------------------
305 // This function returns the global track position
306 //---------------------------------------------------------------------
307 Double_t phi=TMath::ATan2(fCp[0],fCx) + fCalpha;
308 Double_t r=TMath::Sqrt(fCx*fCx + fCp[0]*fCp[0]);
309 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fCp[1];
310}
311
ae982df3 312void AliESDtrack::GetPxPyPz(Double_t *p) const {
313 //---------------------------------------------------------------------
314 // This function returns the global track momentum components
315 //---------------------------------------------------------------------
2157f4f2 316 if (TMath::Abs(fRp[4])<=0) {
317 p[0]=p[1]=p[2]=0;
318 return;
319 }
ae982df3 320 Double_t phi=TMath::ASin(fRp[2]) + fRalpha;
321 Double_t pt=1./TMath::Abs(fRp[4]);
322 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fRp[3];
323}
ae982df3 324void AliESDtrack::GetXYZ(Double_t *xyz) const {
325 //---------------------------------------------------------------------
326 // This function returns the global track position
327 //---------------------------------------------------------------------
bb2ceb1f 328 Double_t phi=TMath::ATan2(fRp[0],fRx) + fRalpha;
ae982df3 329 Double_t r=TMath::Sqrt(fRx*fRx + fRp[0]*fRp[0]);
330 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fRp[1];
331}
332
67c3dcbe 333
9b859005 334void AliESDtrack::GetInnerPxPyPz(Double_t *p) const {
335 //---------------------------------------------------------------------
336 // This function returns the global track momentum components
337 // af the entrance of the TPC
338 //---------------------------------------------------------------------
e964f790 339 if (fIx==0) {p[0]=p[1]=p[2]=0.; return;}
9b859005 340 Double_t phi=TMath::ASin(fIp[2]) + fIalpha;
341 Double_t pt=1./TMath::Abs(fIp[4]);
342 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fIp[3];
343}
344
345void AliESDtrack::GetInnerXYZ(Double_t *xyz) const {
346 //---------------------------------------------------------------------
347 // This function returns the global track position
348 // af the entrance of the TPC
349 //---------------------------------------------------------------------
e964f790 350 if (fIx==0) {xyz[0]=xyz[1]=xyz[2]=0.; return;}
9b859005 351 Double_t phi=TMath::ATan2(fIp[0],fIx) + fIalpha;
352 Double_t r=TMath::Sqrt(fIx*fIx + fIp[0]*fIp[0]);
353 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fIp[1];
354}
355
a866ac60 356void AliESDtrack::GetInnerExternalParameters(Double_t &x, Double_t p[5]) const
357{
358 //skowron
359 //---------------------------------------------------------------------
360 // This function returns external representation of the track parameters at Inner Layer of TPC
361 //---------------------------------------------------------------------
362 x=fIx;
363 for (Int_t i=0; i<5; i++) p[i]=fIp[i];
364}
365void AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const
366{
367 //skowron
368 //---------------------------------------------------------------------
369 // This function returns external representation of the cov. matrix at Inner Layer of TPC
370 //---------------------------------------------------------------------
371 for (Int_t i=0; i<15; i++) cov[i]=fIc[i];
372
373}
374
672b5f43 375void AliESDtrack::GetOuterPxPyPz(Double_t *p) const {
376 //---------------------------------------------------------------------
377 // This function returns the global track momentum components
378 // af the radius of the PHOS
379 //---------------------------------------------------------------------
e964f790 380 if (fOx==0) {p[0]=p[1]=p[2]=0.; return;}
672b5f43 381 Double_t phi=TMath::ASin(fOp[2]) + fOalpha;
382 Double_t pt=1./TMath::Abs(fOp[4]);
383 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fOp[3];
384}
385
386void AliESDtrack::GetOuterXYZ(Double_t *xyz) const {
387 //---------------------------------------------------------------------
388 // This function returns the global track position
389 // af the radius of the PHOS
390 //---------------------------------------------------------------------
e964f790 391 if (fOx==0) {xyz[0]=xyz[1]=xyz[2]=0.; return;}
672b5f43 392 Double_t phi=TMath::ATan2(fOp[0],fOx) + fOalpha;
393 Double_t r=TMath::Sqrt(fOx*fOx + fOp[0]*fOp[0]);
394 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fOp[1];
395}
396
ae982df3 397//_______________________________________________________________________
398void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
4427806c 399 // Returns the array with integrated times for each particle hypothesis
ae982df3 400 for (Int_t i=0; i<kSPECIES; i++) times[i]=fTrackTime[i];
401}
402
403//_______________________________________________________________________
404void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
4427806c 405 // Sets the array with integrated times for each particle hypotesis
ae982df3 406 for (Int_t i=0; i<kSPECIES; i++) fTrackTime[i]=times[i];
407}
408
c630aafd 409//_______________________________________________________________________
4427806c 410void AliESDtrack::SetITSpid(const Double_t *p) {
411 // Sets values for the probability of each particle type (in ITS)
c630aafd 412 for (Int_t i=0; i<kSPECIES; i++) fITSr[i]=p[i];
413 SetStatus(AliESDtrack::kITSpid);
414}
415
babd135a 416void AliESDtrack::SetITSChi2MIP(const Float_t *chi2mip){
417 for (Int_t i=0; i<6; i++) fITSchi2MIP[i]=chi2mip[i];
418}
c630aafd 419//_______________________________________________________________________
420void AliESDtrack::GetITSpid(Double_t *p) const {
4427806c 421 // Gets the probability of each particle type (in ITS)
c630aafd 422 for (Int_t i=0; i<kSPECIES; i++) p[i]=fITSr[i];
423}
424
ae982df3 425//_______________________________________________________________________
426Int_t AliESDtrack::GetITSclusters(UInt_t *idx) const {
427 //---------------------------------------------------------------------
428 // This function returns indices of the assgined ITS clusters
429 //---------------------------------------------------------------------
430 for (Int_t i=0; i<fITSncls; i++) idx[i]=fITSindex[i];
431 return fITSncls;
432}
433
434//_______________________________________________________________________
05e445cd 435Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
ae982df3 436 //---------------------------------------------------------------------
437 // This function returns indices of the assgined ITS clusters
438 //---------------------------------------------------------------------
d1420ddf 439 if (idx!=0)
440 for (Int_t i=0; i<180; i++) idx[i]=fTPCindex[i]; // MI I prefer some constant
ae982df3 441 return fTPCncls;
442}
8c6a71ab 443
444//_______________________________________________________________________
445void AliESDtrack::SetTPCpid(const Double_t *p) {
4427806c 446 // Sets values for the probability of each particle type (in TPC)
8c6a71ab 447 for (Int_t i=0; i<kSPECIES; i++) fTPCr[i]=p[i];
448 SetStatus(AliESDtrack::kTPCpid);
449}
450
451//_______________________________________________________________________
452void AliESDtrack::GetTPCpid(Double_t *p) const {
4427806c 453 // Gets the probability of each particle type (in TPC)
8c6a71ab 454 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTPCr[i];
455}
456
bb2ceb1f 457//_______________________________________________________________________
458Int_t AliESDtrack::GetTRDclusters(UInt_t *idx) const {
459 //---------------------------------------------------------------------
460 // This function returns indices of the assgined TRD clusters
461 //---------------------------------------------------------------------
d1420ddf 462 if (idx!=0)
463 for (Int_t i=0; i<90; i++) idx[i]=fTRDindex[i]; // MI I prefer some constant
bb2ceb1f 464 return fTRDncls;
465}
466
c630aafd 467//_______________________________________________________________________
468void AliESDtrack::SetTRDpid(const Double_t *p) {
4427806c 469 // Sets values for the probability of each particle type (in TRD)
c630aafd 470 for (Int_t i=0; i<kSPECIES; i++) fTRDr[i]=p[i];
471 SetStatus(AliESDtrack::kTRDpid);
472}
473
474//_______________________________________________________________________
475void AliESDtrack::GetTRDpid(Double_t *p) const {
4427806c 476 // Gets the probability of each particle type (in TRD)
c630aafd 477 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTRDr[i];
478}
479
79e94bf8 480//_______________________________________________________________________
481void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
482{
4427806c 483 // Sets the probability of particle type iSpecies to p (in TRD)
79e94bf8 484 fTRDr[iSpecies] = p;
485}
486
487Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
488{
4427806c 489 // Returns the probability of particle type iSpecies (in TRD)
79e94bf8 490 return fTRDr[iSpecies];
491}
492
c630aafd 493//_______________________________________________________________________
494void AliESDtrack::SetTOFpid(const Double_t *p) {
4427806c 495 // Sets the probability of each particle type (in TOF)
c630aafd 496 for (Int_t i=0; i<kSPECIES; i++) fTOFr[i]=p[i];
497 SetStatus(AliESDtrack::kTOFpid);
498}
499
500//_______________________________________________________________________
501void AliESDtrack::GetTOFpid(Double_t *p) const {
4427806c 502 // Gets probabilities of each particle type (in TOF)
c630aafd 503 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTOFr[i];
504}
505
4a78b8c5 506
507
508//_______________________________________________________________________
509void AliESDtrack::SetPHOSpid(const Double_t *p) {
510 // Sets the probability of each particle type (in PHOS)
511 for (Int_t i=0; i<kSPECIES; i++) fPHOSr[i]=p[i];
512 SetStatus(AliESDtrack::kPHOSpid);
513}
514
515//_______________________________________________________________________
516void AliESDtrack::GetPHOSpid(Double_t *p) const {
517 // Gets probabilities of each particle type (in PHOS)
518 for (Int_t i=0; i<kSPECIES; i++) p[i]=fPHOSr[i];
519}
520
521
522//_______________________________________________________________________
523void AliESDtrack::SetRICHpid(const Double_t *p) {
524 // Sets the probability of each particle type (in RICH)
525 for (Int_t i=0; i<kSPECIES; i++) fRICHr[i]=p[i];
526 SetStatus(AliESDtrack::kRICHpid);
527}
528
529//_______________________________________________________________________
530void AliESDtrack::GetRICHpid(Double_t *p) const {
531 // Gets probabilities of each particle type (in RICH)
532 for (Int_t i=0; i<kSPECIES; i++) p[i]=fRICHr[i];
533}
534
535
536
8c6a71ab 537//_______________________________________________________________________
538void AliESDtrack::SetESDpid(const Double_t *p) {
4427806c 539 // Sets the probability of each particle type for the ESD track
8c6a71ab 540 for (Int_t i=0; i<kSPECIES; i++) fR[i]=p[i];
541 SetStatus(AliESDtrack::kESDpid);
542}
543
544//_______________________________________________________________________
545void AliESDtrack::GetESDpid(Double_t *p) const {
4427806c 546 // Gets probability of each particle type for the ESD track
8c6a71ab 547 for (Int_t i=0; i<kSPECIES; i++) p[i]=fR[i];
548}
549