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