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