Consistent treatment of Post/Clean
[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),
67c3dcbe 39fCchi2(1e10),
2bad268c 40fITSchi2(0),
ae982df3 41fITSncls(0),
2bad268c 42fITSsignal(0),
2bad268c 43fTPCchi2(0),
05e445cd 44fTPCncls(0),
2bad268c 45fTPCsignal(0),
46fTRDchi2(0),
47fTRDncls(0),
48fTRDsignal(0),
49fTOFchi2(0),
50fTOFindex(0),
bb2ceb1f 51fTOFsignal(-1)
ae982df3 52{
53 //
54 // The default ESD constructor
55 //
2bad268c 56 for (Int_t i=0; i<kSPECIES; i++) {
57 fTrackTime[i]=0;
58 fR[i]=0;
59 fITSr[i]=0;
60 fTPCr[i]=0;
61 fTRDr[i]=0;
62 fTOFr[i]=0;
63 }
bb2ceb1f 64 Int_t i;
65 for (i=0; i<5; i++) fRp[i]=0.;
66 for (i=0; i<15; i++) fRc[i]=0.;
67 for (i=0; i<6; i++) fITSindex[i]=0;
68 for (i=0; i<180; i++) fTPCindex[i]=0;
ae982df3 69}
70
71//_______________________________________________________________________
72Float_t AliESDtrack::GetMass() const {
4427806c 73 // Returns the mass of the most probable particle type
ae982df3 74 Float_t max=0.;
75 Int_t k=-1;
76 for (Int_t i=0; i<kSPECIES; i++) {
77 if (fR[i]>max) {k=i; max=fR[i];}
78 }
79 if (k==0) return 0.00051;
80 if (k==1) return 0.10566;
81 if (k==2||k==-1) return 0.13957;
82 if (k==3) return 0.49368;
83 if (k==4) return 0.93827;
84 Warning("GetMass()","Undefined mass !");
85 return 0.13957;
86}
87
88//_______________________________________________________________________
ad2f1f2b 89Bool_t AliESDtrack::UpdateTrackParams(AliKalmanTrack *t, ULong_t flags) {
ae982df3 90 //
91 // This function updates track's running parameters
92 //
9b859005 93 SetStatus(flags);
94 fLabel=t->GetLabel();
95
96 if (t->IsStartedTimeIntegral()) {
97 SetStatus(kTIME);
98 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
99 SetIntegratedLength(t->GetIntegratedLength());
100 }
101
102 fRalpha=t->GetAlpha();
103 t->GetExternalParameters(fRx,fRp);
104 t->GetExternalCovariance(fRc);
105
ae982df3 106 switch (flags) {
ad2f1f2b 107
9b859005 108 case kITSin: case kITSout: case kITSrefit:
ae982df3 109 fITSncls=t->GetNumberOfClusters();
110 fITSchi2=t->GetChi2();
111 for (Int_t i=0;i<fITSncls;i++) fITSindex[i]=t->GetClusterIndex(i);
112 fITSsignal=t->GetPIDsignal();
113 break;
ad2f1f2b 114
9b859005 115 case kTPCin: case kTPCrefit:
116 fIalpha=fRalpha;
117 fIx=fRx;
118 {
119 Int_t i;
120 for (i=0; i<5; i++) fIp[i]=fRp[i];
121 for (i=0; i<15;i++) fIc[i]=fRc[i];
122 }
123 case kTPCout:
ae982df3 124 fTPCncls=t->GetNumberOfClusters();
125 fTPCchi2=t->GetChi2();
126 for (Int_t i=0;i<fTPCncls;i++) fTPCindex[i]=t->GetClusterIndex(i);
127 fTPCsignal=t->GetPIDsignal();
128 {Double_t mass=t->GetMass(); // preliminary mass setting
129 if (mass>0.5) fR[4]=1.; // used by
130 else if (mass<0.4) fR[2]=1.; // the ITS reconstruction
131 else fR[3]=1.;} //
132 break;
9b859005 133
672b5f43 134 case kTRDout:
135 { //requested by the PHOS ("temporary solution")
136 Double_t r=474.;
137 t->PropagateTo(r,30.,0.);
138 fOalpha=fRalpha;
139 fOx=fRx;
140 Int_t i;
141 for (i=0; i<5; i++) fOp[i]=fRp[i];
142 for (i=0; i<15;i++) fOc[i]=fRc[i];
143 }
144 case kTRDin: case kTRDrefit:
79e94bf8 145 fTRDncls=t->GetNumberOfClusters();
146 fTRDchi2=t->GetChi2();
bb2ceb1f 147 for (Int_t i=0;i<fTRDncls;i++) fTRDindex[i]=t->GetClusterIndex(i);
79e94bf8 148 fTRDsignal=t->GetPIDsignal();
149 break;
9b859005 150
ae982df3 151 default:
152 Error("UpdateTrackParams()","Wrong flag !\n");
153 return kFALSE;
154 }
155
ae982df3 156 return kTRUE;
157}
158
159//_______________________________________________________________________
67c3dcbe 160void
161AliESDtrack::SetConstrainedTrackParams(AliKalmanTrack *t, Double_t chi2) {
162 //
163 // This function sets the constrained track parameters
164 //
165 fCalpha=t->GetAlpha();
166 t->GetExternalParameters(fCx,fCp);
167 t->GetExternalCovariance(fCc);
168 fCchi2=chi2;
169}
170
171
172//_______________________________________________________________________
ae982df3 173void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
174 //---------------------------------------------------------------------
175 // This function returns external representation of the track parameters
176 //---------------------------------------------------------------------
177 x=fRx;
178 for (Int_t i=0; i<5; i++) p[i]=fRp[i];
179}
67c3dcbe 180//_______________________________________________________________________
181void AliESDtrack::GetExternalCovariance(Double_t c[15]) const {
182 //---------------------------------------------------------------------
183 // This function returns external representation of the cov. matrix
184 //---------------------------------------------------------------------
185 for (Int_t i=0; i<15; i++) c[i]=fRc[i];
186}
187
188
189//_______________________________________________________________________
190void
191AliESDtrack::GetConstrainedExternalParameters(Double_t &x, Double_t p[5])const{
192 //---------------------------------------------------------------------
193 // This function returns the constrained external track parameters
194 //---------------------------------------------------------------------
195 x=fCx;
196 for (Int_t i=0; i<5; i++) p[i]=fCp[i];
197}
198//_______________________________________________________________________
199void
200AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
201 //---------------------------------------------------------------------
202 // This function returns the constrained external cov. matrix
203 //---------------------------------------------------------------------
204 for (Int_t i=0; i<15; i++) c[i]=fCc[i];
205}
206
ae982df3 207
208Double_t AliESDtrack::GetP() const {
209 //---------------------------------------------------------------------
210 // This function returns the track momentum
211 //---------------------------------------------------------------------
212 Double_t lam=TMath::ATan(fRp[3]);
213 Double_t pt=1./TMath::Abs(fRp[4]);
214 return pt/TMath::Cos(lam);
215}
216
67c3dcbe 217void AliESDtrack::GetConstrainedPxPyPz(Double_t *p) const {
218 //---------------------------------------------------------------------
219 // This function returns the constrained global track momentum components
220 //---------------------------------------------------------------------
221 Double_t phi=TMath::ASin(fCp[2]) + fCalpha;
222 Double_t pt=1./TMath::Abs(fCp[4]);
223 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fCp[3];
224}
225void AliESDtrack::GetConstrainedXYZ(Double_t *xyz) const {
226 //---------------------------------------------------------------------
227 // This function returns the global track position
228 //---------------------------------------------------------------------
229 Double_t phi=TMath::ATan2(fCp[0],fCx) + fCalpha;
230 Double_t r=TMath::Sqrt(fCx*fCx + fCp[0]*fCp[0]);
231 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fCp[1];
232}
233
ae982df3 234void AliESDtrack::GetPxPyPz(Double_t *p) const {
235 //---------------------------------------------------------------------
236 // This function returns the global track momentum components
237 //---------------------------------------------------------------------
238 Double_t phi=TMath::ASin(fRp[2]) + fRalpha;
239 Double_t pt=1./TMath::Abs(fRp[4]);
240 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fRp[3];
241}
ae982df3 242void AliESDtrack::GetXYZ(Double_t *xyz) const {
243 //---------------------------------------------------------------------
244 // This function returns the global track position
245 //---------------------------------------------------------------------
bb2ceb1f 246 Double_t phi=TMath::ATan2(fRp[0],fRx) + fRalpha;
ae982df3 247 Double_t r=TMath::Sqrt(fRx*fRx + fRp[0]*fRp[0]);
248 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fRp[1];
249}
250
67c3dcbe 251
9b859005 252void AliESDtrack::GetInnerPxPyPz(Double_t *p) const {
253 //---------------------------------------------------------------------
254 // This function returns the global track momentum components
255 // af the entrance of the TPC
256 //---------------------------------------------------------------------
257 Double_t phi=TMath::ASin(fIp[2]) + fIalpha;
258 Double_t pt=1./TMath::Abs(fIp[4]);
259 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fIp[3];
260}
261
262void AliESDtrack::GetInnerXYZ(Double_t *xyz) const {
263 //---------------------------------------------------------------------
264 // This function returns the global track position
265 // af the entrance of the TPC
266 //---------------------------------------------------------------------
267 Double_t phi=TMath::ATan2(fIp[0],fIx) + fIalpha;
268 Double_t r=TMath::Sqrt(fIx*fIx + fIp[0]*fIp[0]);
269 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fIp[1];
270}
271
672b5f43 272void AliESDtrack::GetOuterPxPyPz(Double_t *p) const {
273 //---------------------------------------------------------------------
274 // This function returns the global track momentum components
275 // af the radius of the PHOS
276 //---------------------------------------------------------------------
277 Double_t phi=TMath::ASin(fOp[2]) + fOalpha;
278 Double_t pt=1./TMath::Abs(fOp[4]);
279 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fOp[3];
280}
281
282void AliESDtrack::GetOuterXYZ(Double_t *xyz) const {
283 //---------------------------------------------------------------------
284 // This function returns the global track position
285 // af the radius of the PHOS
286 //---------------------------------------------------------------------
287 Double_t phi=TMath::ATan2(fOp[0],fOx) + fOalpha;
288 Double_t r=TMath::Sqrt(fOx*fOx + fOp[0]*fOp[0]);
289 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fOp[1];
290}
291
ae982df3 292//_______________________________________________________________________
ae982df3 293void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
4427806c 294 // Returns the array with integrated times for each particle hypothesis
ae982df3 295 for (Int_t i=0; i<kSPECIES; i++) times[i]=fTrackTime[i];
296}
297
298//_______________________________________________________________________
299void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
4427806c 300 // Sets the array with integrated times for each particle hypotesis
ae982df3 301 for (Int_t i=0; i<kSPECIES; i++) fTrackTime[i]=times[i];
302}
303
304//_______________________________________________________________________
4427806c 305void AliESDtrack::SetITSpid(const Double_t *p) {
306 // Sets values for the probability of each particle type (in ITS)
c630aafd 307 for (Int_t i=0; i<kSPECIES; i++) fITSr[i]=p[i];
308 SetStatus(AliESDtrack::kITSpid);
309}
310
311//_______________________________________________________________________
312void AliESDtrack::GetITSpid(Double_t *p) const {
4427806c 313 // Gets the probability of each particle type (in ITS)
c630aafd 314 for (Int_t i=0; i<kSPECIES; i++) p[i]=fITSr[i];
315}
316
317//_______________________________________________________________________
ae982df3 318Int_t AliESDtrack::GetITSclusters(UInt_t *idx) const {
319 //---------------------------------------------------------------------
320 // This function returns indices of the assgined ITS clusters
321 //---------------------------------------------------------------------
322 for (Int_t i=0; i<fITSncls; i++) idx[i]=fITSindex[i];
323 return fITSncls;
324}
325
326//_______________________________________________________________________
05e445cd 327Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
ae982df3 328 //---------------------------------------------------------------------
329 // This function returns indices of the assgined ITS clusters
330 //---------------------------------------------------------------------
05e445cd 331 for (Int_t i=0; i<180; i++) idx[i]=fTPCindex[i]; // MI I prefer some constant
ae982df3 332 return fTPCncls;
333}
8c6a71ab 334
335//_______________________________________________________________________
336void AliESDtrack::SetTPCpid(const Double_t *p) {
4427806c 337 // Sets values for the probability of each particle type (in TPC)
8c6a71ab 338 for (Int_t i=0; i<kSPECIES; i++) fTPCr[i]=p[i];
339 SetStatus(AliESDtrack::kTPCpid);
340}
341
342//_______________________________________________________________________
343void AliESDtrack::GetTPCpid(Double_t *p) const {
4427806c 344 // Gets the probability of each particle type (in TPC)
8c6a71ab 345 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTPCr[i];
346}
347
348//_______________________________________________________________________
bb2ceb1f 349Int_t AliESDtrack::GetTRDclusters(UInt_t *idx) const {
350 //---------------------------------------------------------------------
351 // This function returns indices of the assgined TRD clusters
352 //---------------------------------------------------------------------
353 for (Int_t i=0; i<90; i++) idx[i]=fTRDindex[i]; // MI I prefer some constant
354 return fTRDncls;
355}
356
357//_______________________________________________________________________
c630aafd 358void AliESDtrack::SetTRDpid(const Double_t *p) {
4427806c 359 // Sets values for the probability of each particle type (in TRD)
c630aafd 360 for (Int_t i=0; i<kSPECIES; i++) fTRDr[i]=p[i];
361 SetStatus(AliESDtrack::kTRDpid);
362}
363
364//_______________________________________________________________________
365void AliESDtrack::GetTRDpid(Double_t *p) const {
4427806c 366 // Gets the probability of each particle type (in TRD)
c630aafd 367 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTRDr[i];
368}
369
370//_______________________________________________________________________
79e94bf8 371void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
372{
4427806c 373 // Sets the probability of particle type iSpecies to p (in TRD)
79e94bf8 374 fTRDr[iSpecies] = p;
375}
376
377Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
378{
4427806c 379 // Returns the probability of particle type iSpecies (in TRD)
79e94bf8 380 return fTRDr[iSpecies];
381}
382
383//_______________________________________________________________________
c630aafd 384void AliESDtrack::SetTOFpid(const Double_t *p) {
4427806c 385 // Sets the probability of each particle type (in TOF)
c630aafd 386 for (Int_t i=0; i<kSPECIES; i++) fTOFr[i]=p[i];
387 SetStatus(AliESDtrack::kTOFpid);
388}
389
390//_______________________________________________________________________
391void AliESDtrack::GetTOFpid(Double_t *p) const {
4427806c 392 // Gets probabilities of each particle type (in TOF)
c630aafd 393 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTOFr[i];
394}
395
396//_______________________________________________________________________
8c6a71ab 397void AliESDtrack::SetESDpid(const Double_t *p) {
4427806c 398 // Sets the probability of each particle type for the ESD track
8c6a71ab 399 for (Int_t i=0; i<kSPECIES; i++) fR[i]=p[i];
400 SetStatus(AliESDtrack::kESDpid);
401}
402
403//_______________________________________________________________________
404void AliESDtrack::GetESDpid(Double_t *p) const {
4427806c 405 // Gets probability of each particle type for the ESD track
8c6a71ab 406 for (Int_t i=0; i<kSPECIES; i++) p[i]=fR[i];
407}
408