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