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