]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDtrack.cxx
Corrections needed on HP
[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
18// This is the class to deal with during the phisical analysis of data
19//
20// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
21//-----------------------------------------------------------------
22
23#include "TMath.h"
24
25#include "AliESDtrack.h"
26#include "AliKalmanTrack.h"
05e445cd 27#include "../ITS/AliITStrackV2.h"
ae982df3 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),
42fVertexX(0),
43fVertexY(0),
44fVertexZ(0),
45fVertexPx(0),
46fVertexPy(0),
47fVertexPz(0),
48fVertex(kFALSE),
49fTPCchi2(0),
05e445cd 50fTPCncls(0),
2bad268c 51fTPCsignal(0),
52fTRDchi2(0),
53fTRDncls(0),
54fTRDsignal(0),
55fTOFchi2(0),
56fTOFindex(0),
57fTOFsignal(0)
ae982df3 58{
59 //
60 // The default ESD constructor
61 //
2bad268c 62 for (Int_t i=0; i<kSPECIES; i++) {
63 fTrackTime[i]=0;
64 fR[i]=0;
65 fITSr[i]=0;
66 fTPCr[i]=0;
67 fTRDr[i]=0;
68 fTOFr[i]=0;
69 }
70 for (Int_t i=0; i<5; fRp[i++]);
71 for (Int_t i=0; i<15; fRc[i++]);
72 for (Int_t i=0; i<6; fITSindex[i++]);
73 for (Int_t i=0; i<180; fTPCindex[i++]);
ae982df3 74}
75
76//_______________________________________________________________________
77Float_t AliESDtrack::GetMass() const {
78 Float_t max=0.;
79 Int_t k=-1;
80 for (Int_t i=0; i<kSPECIES; i++) {
81 if (fR[i]>max) {k=i; max=fR[i];}
82 }
83 if (k==0) return 0.00051;
84 if (k==1) return 0.10566;
85 if (k==2||k==-1) return 0.13957;
86 if (k==3) return 0.49368;
87 if (k==4) return 0.93827;
88 Warning("GetMass()","Undefined mass !");
89 return 0.13957;
90}
91
92//_______________________________________________________________________
ad2f1f2b 93Bool_t AliESDtrack::UpdateTrackParams(AliKalmanTrack *t, ULong_t flags) {
ae982df3 94 //
95 // This function updates track's running parameters
96 //
97 switch (flags) {
ad2f1f2b 98
99 case kITSin:
100 case kITSout:
101 case kITSrefit:
ae982df3 102 fITSncls=t->GetNumberOfClusters();
103 fITSchi2=t->GetChi2();
104 for (Int_t i=0;i<fITSncls;i++) fITSindex[i]=t->GetClusterIndex(i);
105 fITSsignal=t->GetPIDsignal();
106 break;
ad2f1f2b 107
ae982df3 108 case kTPCin: case kTPCout: case kTPCrefit:
109 fTPCncls=t->GetNumberOfClusters();
110 fTPCchi2=t->GetChi2();
111 for (Int_t i=0;i<fTPCncls;i++) fTPCindex[i]=t->GetClusterIndex(i);
112 fTPCsignal=t->GetPIDsignal();
113 {Double_t mass=t->GetMass(); // preliminary mass setting
114 if (mass>0.5) fR[4]=1.; // used by
115 else if (mass<0.4) fR[2]=1.; // the ITS reconstruction
116 else fR[3]=1.;} //
117 break;
79e94bf8 118 case kTRDin: case kTRDout: case kTRDrefit:
119 fTRDncls=t->GetNumberOfClusters();
120 fTRDchi2=t->GetChi2();
121 fTRDsignal=t->GetPIDsignal();
122 break;
ae982df3 123 default:
124 Error("UpdateTrackParams()","Wrong flag !\n");
125 return kFALSE;
126 }
127
128 SetStatus(flags);
129 fLabel=t->GetLabel();
130
131 if (t->IsStartedTimeIntegral()) {
132 SetStatus(kTIME);
133 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
134 SetIntegratedLength(t->GetIntegratedLength());
135 }
136
137 fRalpha=t->GetAlpha();
138 t->GetExternalParameters(fRx,fRp);
139 t->GetExternalCovariance(fRc);
ad2f1f2b 140
141 if (flags == kITSin)
142 {
05e445cd 143 AliITStrackV2* itstrack = dynamic_cast<AliITStrackV2*>(t);
144 if (itstrack)
145 {
146 itstrack->PropagateTo(3.,0.0028,65.19);
147 itstrack->PropagateToVertex();
148
149 Double_t ralpha=t->GetAlpha();
150 Double_t rx; // X-coordinate of the track reference plane
151 Double_t rp[5]; // external track parameters
152 t->GetExternalParameters(rx,rp);
153
154 Double_t phi=TMath::ASin(rp[2]) + ralpha;
155 Double_t pt=1./TMath::Abs(rp[4]);
156 Double_t r=TMath::Sqrt(rx*rx + rp[0]*rp[0]);
157
158 fVertexX=r*TMath::Cos(phi);
159 fVertexY=r*TMath::Sin(phi);
160 fVertexZ=rp[1];
161
162 fVertexPx = pt*TMath::Cos(phi);
163 fVertexPy = pt*TMath::Sin(phi);
164 fVertexPz = pt*rp[3];
165 fVertex = kTRUE;
166 }
ad2f1f2b 167 }
168
ae982df3 169 return kTRUE;
170}
171
e23730c7 172//_______________________________________________________________________
173void AliESDtrack::GetExternalParametersAt(Double_t x, Double_t p[5]) const {
174 //---------------------------------------------------------------------
175 // This function returns external representation of the track parameters
176 // at the plane x
177 //---------------------------------------------------------------------
178 Double_t dx=x-fRx;
179 Double_t c=fRp[4]/AliKalmanTrack::GetConvConst();
180 Double_t f1=fRp[2], f2=f1 + c*dx;
181 Double_t r1=sqrt(1.- f1*f1), r2=sqrt(1.- f2*f2);
182
183 p[0]=fRp[0]+dx*(f1+f2)/(r1+r2);
184 p[1]=fRp[1]+dx*(f1+f2)/(f1*r2 + f2*r1)*fRp[3];
185 p[2]=fRp[2]+dx*c;
186 p[3]=fRp[3];
187 p[4]=fRp[4];
188}
189
ae982df3 190//_______________________________________________________________________
191void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
192 //---------------------------------------------------------------------
193 // This function returns external representation of the track parameters
194 //---------------------------------------------------------------------
195 x=fRx;
196 for (Int_t i=0; i<5; i++) p[i]=fRp[i];
197}
198
199Double_t AliESDtrack::GetP() const {
200 //---------------------------------------------------------------------
201 // This function returns the track momentum
202 //---------------------------------------------------------------------
203 Double_t lam=TMath::ATan(fRp[3]);
204 Double_t pt=1./TMath::Abs(fRp[4]);
205 return pt/TMath::Cos(lam);
206}
207
208void AliESDtrack::GetPxPyPz(Double_t *p) const {
209 //---------------------------------------------------------------------
210 // This function returns the global track momentum components
211 //---------------------------------------------------------------------
212 Double_t phi=TMath::ASin(fRp[2]) + fRalpha;
213 Double_t pt=1./TMath::Abs(fRp[4]);
214 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fRp[3];
215}
216
217void AliESDtrack::GetXYZ(Double_t *xyz) const {
218 //---------------------------------------------------------------------
219 // This function returns the global track position
220 //---------------------------------------------------------------------
221 Double_t phi=TMath::ASin(fRp[2]) + fRalpha;
222 Double_t r=TMath::Sqrt(fRx*fRx + fRp[0]*fRp[0]);
223 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fRp[1];
224}
225
226//_______________________________________________________________________
227void AliESDtrack::GetExternalCovariance(Double_t c[15]) const {
228 //---------------------------------------------------------------------
229 // This function returns external representation of the cov. matrix
230 //---------------------------------------------------------------------
231 for (Int_t i=0; i<15; i++) c[i]=fRc[i];
232}
233
234//_______________________________________________________________________
235void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
236 for (Int_t i=0; i<kSPECIES; i++) times[i]=fTrackTime[i];
237}
238
239//_______________________________________________________________________
240void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
241 for (Int_t i=0; i<kSPECIES; i++) fTrackTime[i]=times[i];
242}
243
c630aafd 244//_______________________________________________________________________
245void AliESDtrack::SetITSpid(const Double_t *p) {
246 for (Int_t i=0; i<kSPECIES; i++) fITSr[i]=p[i];
247 SetStatus(AliESDtrack::kITSpid);
248}
249
250//_______________________________________________________________________
251void AliESDtrack::GetITSpid(Double_t *p) const {
252 for (Int_t i=0; i<kSPECIES; i++) p[i]=fITSr[i];
253}
254
ae982df3 255//_______________________________________________________________________
256Int_t AliESDtrack::GetITSclusters(UInt_t *idx) const {
257 //---------------------------------------------------------------------
258 // This function returns indices of the assgined ITS clusters
259 //---------------------------------------------------------------------
260 for (Int_t i=0; i<fITSncls; i++) idx[i]=fITSindex[i];
261 return fITSncls;
262}
263
264//_______________________________________________________________________
05e445cd 265Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
ae982df3 266 //---------------------------------------------------------------------
267 // This function returns indices of the assgined ITS clusters
268 //---------------------------------------------------------------------
05e445cd 269 for (Int_t i=0; i<180; i++) idx[i]=fTPCindex[i]; // MI I prefer some constant
ae982df3 270 return fTPCncls;
271}
8c6a71ab 272
273//_______________________________________________________________________
274void AliESDtrack::SetTPCpid(const Double_t *p) {
275 for (Int_t i=0; i<kSPECIES; i++) fTPCr[i]=p[i];
276 SetStatus(AliESDtrack::kTPCpid);
277}
278
279//_______________________________________________________________________
280void AliESDtrack::GetTPCpid(Double_t *p) const {
281 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTPCr[i];
282}
283
c630aafd 284//_______________________________________________________________________
285void AliESDtrack::SetTRDpid(const Double_t *p) {
286 for (Int_t i=0; i<kSPECIES; i++) fTRDr[i]=p[i];
287 SetStatus(AliESDtrack::kTRDpid);
288}
289
290//_______________________________________________________________________
291void AliESDtrack::GetTRDpid(Double_t *p) const {
292 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTRDr[i];
293}
294
79e94bf8 295//_______________________________________________________________________
296void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
297{
298 fTRDr[iSpecies] = p;
299}
300
301Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
302{
303 return fTRDr[iSpecies];
304}
305
c630aafd 306//_______________________________________________________________________
307void AliESDtrack::SetTOFpid(const Double_t *p) {
308 for (Int_t i=0; i<kSPECIES; i++) fTOFr[i]=p[i];
309 SetStatus(AliESDtrack::kTOFpid);
310}
311
312//_______________________________________________________________________
313void AliESDtrack::GetTOFpid(Double_t *p) const {
314 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTOFr[i];
315}
316
8c6a71ab 317//_______________________________________________________________________
318void AliESDtrack::SetESDpid(const Double_t *p) {
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 {
325 for (Int_t i=0; i<kSPECIES; i++) p[i]=fR[i];
326}
327
ad2f1f2b 328void AliESDtrack::GetVertexXYZ(Double_t& x,Double_t& y, Double_t&z) const
329{
330//returns track position in DCA to vertex
331 x = fVertexX;
332 y = fVertexY;
333 z = fVertexZ;
334}
335void AliESDtrack::GetVertexPxPyPz(Double_t& px,Double_t& py, Double_t& pz) const
336{
337//returns track momentum in DCA to vertex
338 px = fVertexPx;
339 py = fVertexPy;
340 pz = fVertexPz;
341}