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