]>
Commit | Line | Data |
---|---|---|
d9950a5a | 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 | /* $Id$ */ | |
17 | ||
203967fc | 18 | #include "AliLog.h" |
eb38ed55 | 19 | #include "AliESDtrack.h" |
41880fac | 20 | #include "AliTracker.h" |
eb38ed55 | 21 | |
d9950a5a | 22 | #include "AliTRDtrackV1.h" |
23 | #include "AliTRDcluster.h" | |
24 | #include "AliTRDcalibDB.h" | |
3afdab72 | 25 | #include "AliTRDReconstructor.h" |
d9950a5a | 26 | #include "AliTRDrecoParam.h" |
27 | ||
d9950a5a | 28 | ClassImp(AliTRDtrackV1) |
29 | ||
0906e73e | 30 | /////////////////////////////////////////////////////////////////////////////// |
31 | // // | |
32 | // Represents a reconstructed TRD track // | |
33 | // Local TRD Kalman track // | |
34 | // // | |
35 | // Authors: // | |
36 | // Alex Bercuci <A.Bercuci@gsi.de> // | |
37 | // Markus Fasel <M.Fasel@gsi.de> // | |
38 | // // | |
39 | /////////////////////////////////////////////////////////////////////////////// | |
d9950a5a | 40 | |
41 | //_______________________________________________________________ | |
3b57a3f7 | 42 | AliTRDtrackV1::AliTRDtrackV1() : AliKalmanTrack() |
43 | ,fPIDquality(0) | |
44 | ,fDE(0.) | |
215f7116 | 45 | ,fReconstructor(0x0) |
3b57a3f7 | 46 | ,fBackupTrack(0x0) |
e3cf3d02 | 47 | ,fTrackLow(0x0) |
48 | ,fTrackHigh(0x0) | |
0906e73e | 49 | { |
d9950a5a | 50 | // |
51 | // Default constructor | |
52 | // | |
6e49cfdb | 53 | //printf("AliTRDtrackV1::AliTRDtrackV1()\n"); |
e44586fb | 54 | |
3b57a3f7 | 55 | for(int i =0; i<3; i++) fBudget[i] = 0.; |
56 | ||
57 | Float_t pid = 1./AliPID::kSPECIES; | |
58 | for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid; | |
59 | ||
60 | for(int ip=0; ip<kNplane; ip++){ | |
61 | fTrackletIndex[ip] = 0xffff; | |
62 | fTracklet[ip] = 0x0; | |
63 | } | |
d9950a5a | 64 | } |
65 | ||
66 | //_______________________________________________________________ | |
3b57a3f7 | 67 | AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &ref) : AliKalmanTrack(ref) |
68 | ,fPIDquality(ref.fPIDquality) | |
69 | ,fDE(ref.fDE) | |
215f7116 | 70 | ,fReconstructor(ref.fReconstructor) |
3b57a3f7 | 71 | ,fBackupTrack(0x0) |
e3cf3d02 | 72 | ,fTrackLow(0x0) |
73 | ,fTrackHigh(0x0) | |
d9950a5a | 74 | { |
75 | // | |
3b57a3f7 | 76 | // Copy constructor |
d9950a5a | 77 | // |
78 | ||
6e49cfdb | 79 | //printf("AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &)\n"); |
29b87567 | 80 | SetBit(kOwner, kFALSE); |
3b57a3f7 | 81 | for(int ip=0; ip<kNplane; ip++){ |
82 | fTrackletIndex[ip] = ref.fTrackletIndex[ip]; | |
83 | fTracklet[ip] = ref.fTracklet[ip]; | |
84 | } | |
e3cf3d02 | 85 | if(ref.fTrackLow) fTrackLow = new AliExternalTrackParam(*ref.fTrackLow); |
86 | if(ref.fTrackHigh) fTrackHigh = new AliExternalTrackParam(*ref.fTrackHigh); | |
87 | ||
3b57a3f7 | 88 | for (Int_t i = 0; i < 3;i++) fBudget[i] = ref.fBudget[i]; |
89 | ||
90 | for(Int_t is = 0; is<AliPID::kSPECIES; is++) fPID[is] = ref.fPID[is]; | |
91 | ||
92 | AliKalmanTrack::SetNumberOfClusters(ref.GetNumberOfClusters()); | |
d9950a5a | 93 | } |
94 | ||
95 | //_______________________________________________________________ | |
3b57a3f7 | 96 | AliTRDtrackV1::AliTRDtrackV1(const AliESDtrack &t) : AliKalmanTrack() |
97 | ,fPIDquality(0) | |
98 | ,fDE(0.) | |
215f7116 | 99 | ,fReconstructor(0x0) |
3b57a3f7 | 100 | ,fBackupTrack(0x0) |
e3cf3d02 | 101 | ,fTrackLow(0x0) |
102 | ,fTrackHigh(0x0) | |
d9950a5a | 103 | { |
104 | // | |
3b57a3f7 | 105 | // Constructor from AliESDtrack |
d9950a5a | 106 | // |
107 | ||
3b57a3f7 | 108 | SetLabel(t.GetLabel()); |
109 | SetChi2(0.0); | |
110 | SetMass(t.GetMass()); | |
111 | AliKalmanTrack::SetNumberOfClusters(t.GetTRDncls()); | |
112 | Int_t ti[kNplane]; t.GetTRDtracklets(&ti[0]); | |
113 | for(int ip=0; ip<kNplane; ip++){ | |
114 | fTrackletIndex[ip] = ti[ip] < 0 ? 0xffff : ti[ip]; | |
115 | fTracklet[ip] = 0x0; | |
116 | } | |
117 | for(int i =0; i<3; i++) fBudget[i] = 0.; | |
118 | ||
119 | Float_t pid = 1./AliPID::kSPECIES; | |
120 | for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid; | |
121 | ||
122 | const AliExternalTrackParam *par = &t; | |
123 | if (t.GetStatus() & AliESDtrack::kTRDbackup) { | |
124 | par = t.GetOuterParam(); | |
125 | if (!par) { | |
126 | AliError("No backup info!"); | |
127 | par = &t; | |
128 | } | |
129 | } | |
130 | Set(par->GetX() | |
131 | ,par->GetAlpha() | |
132 | ,par->GetParameter() | |
133 | ,par->GetCovariance()); | |
134 | ||
135 | if(t.GetStatus() & AliESDtrack::kTIME) { | |
136 | StartTimeIntegral(); | |
137 | Double_t times[10]; | |
138 | t.GetIntegratedTimes(times); | |
139 | SetIntegratedTimes(times); | |
140 | SetIntegratedLength(t.GetIntegratedLength()); | |
141 | } | |
d9950a5a | 142 | } |
143 | ||
d9950a5a | 144 | //_______________________________________________________________ |
eb38ed55 | 145 | AliTRDtrackV1::AliTRDtrackV1(AliTRDseedV1 *trklts, const Double_t p[5], const Double_t cov[15] |
3b57a3f7 | 146 | , Double_t x, Double_t alpha) : AliKalmanTrack() |
147 | ,fPIDquality(0) | |
148 | ,fDE(0.) | |
215f7116 | 149 | ,fReconstructor(0x0) |
3b57a3f7 | 150 | ,fBackupTrack(0x0) |
e3cf3d02 | 151 | ,fTrackLow(0x0) |
152 | ,fTrackHigh(0x0) | |
d9950a5a | 153 | { |
0906e73e | 154 | // |
155 | // The stand alone tracking constructor | |
156 | // TEMPORARY !!!!!!!!!!! | |
157 | // to check : | |
158 | // 1. covariance matrix | |
159 | // 2. dQdl calculation | |
160 | // | |
d9950a5a | 161 | |
fb17de1f | 162 | Double_t cnv = GetBz() < 1.e-5 ? 1.e5 : 1.0 / (GetBz() * kB2C); |
163 | // Double_t cnv = 1.0 / (GetBz() * kB2C); | |
d9950a5a | 164 | |
165 | Double_t pp[5] = { p[0] | |
166 | , p[1] | |
93f695a3 | 167 | , p[2] |
d9950a5a | 168 | , p[3] |
169 | , p[4]*cnv }; | |
170 | ||
171 | Double_t c22 = x*x*cov[14] - 2*x*cov[12] + cov[ 5]; | |
172 | Double_t c32 = x*cov[13] - cov[ 8]; | |
173 | Double_t c20 = x*cov[10] - cov[ 3]; | |
174 | Double_t c21 = x*cov[11] - cov[ 4]; | |
175 | Double_t c42 = x*cov[14] - cov[12]; | |
176 | ||
177 | Double_t cc[15] = { cov[ 0] | |
178 | , cov[ 1], cov[ 2] | |
179 | , c20, c21, c22 | |
180 | , cov[ 6], cov[ 7], c32, cov[ 9] | |
181 | , cov[10]*cnv, cov[11]*cnv, c42*cnv, cov[13]*cnv, cov[14]*cnv*cnv }; | |
ae3fbe1f | 182 | |
183 | Double_t mostProbablePt=AliExternalTrackParam::GetMostProbablePt(); | |
184 | Double_t p0=TMath::Sign(1/mostProbablePt,pp[4]); | |
185 | Double_t w0=cc[14]/(cc[14] + p0*p0), w1=p0*p0/(cc[14] + p0*p0); | |
186 | pp[4] = w0*p0 + w1*pp[4]; | |
187 | cc[10]*=w1; cc[11]*=w1; cc[12]*=w1; cc[13]*=w1; cc[14]*=w1; | |
188 | ||
d9950a5a | 189 | Set(x,alpha,pp,cc); |
41702fec | 190 | Int_t ncls = 0; |
3b57a3f7 | 191 | for(int iplane=0; iplane<kNplane; iplane++){ |
41702fec | 192 | fTrackletIndex[iplane] = 0xffff; |
193 | if(!trklts[iplane].IsOK()) fTracklet[iplane] = 0x0; | |
194 | else{ | |
76b60503 | 195 | fTracklet[iplane] = &trklts[iplane]; |
41702fec | 196 | ncls += fTracklet[iplane]->GetN(); |
197 | } | |
d9950a5a | 198 | } |
41702fec | 199 | AliKalmanTrack::SetNumberOfClusters(ncls); |
200 | for(int i =0; i<3; i++) fBudget[i] = 0.; | |
201 | ||
202 | Float_t pid = 1./AliPID::kSPECIES; | |
203 | for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid; | |
204 | ||
d9950a5a | 205 | } |
206 | ||
bb56afff | 207 | //_______________________________________________________________ |
3b57a3f7 | 208 | AliTRDtrackV1::~AliTRDtrackV1() |
bb56afff | 209 | { |
e44586fb | 210 | //AliInfo(""); |
6e49cfdb | 211 | //printf("I-AliTRDtrackV1::~AliTRDtrackV1() : Owner[%s]\n", TestBit(kOwner)?"YES":"NO"); |
76b60503 | 212 | |
e3cf3d02 | 213 | if(fBackupTrack) delete fBackupTrack; fBackupTrack = 0x0; |
214 | ||
215 | if(fTrackLow) delete fTrackLow; fTrackLow = 0x0; | |
216 | if(fTrackHigh) delete fTrackHigh; fTrackHigh = 0x0; | |
bb56afff | 217 | |
76b60503 | 218 | for(Int_t ip=0; ip<kNplane; ip++){ |
219 | if(TestBit(kOwner) && fTracklet[ip]) delete fTracklet[ip]; | |
220 | fTracklet[ip] = 0x0; | |
221 | fTrackletIndex[ip] = 0xffff; | |
3b57a3f7 | 222 | } |
223 | } | |
224 | ||
225 | //_______________________________________________________________ | |
226 | Bool_t AliTRDtrackV1::CookLabel(Float_t wrong) | |
227 | { | |
228 | // set MC label for this track | |
229 | ||
bb56afff | 230 | Int_t s[kMAXCLUSTERSPERTRACK][2]; |
231 | for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) { | |
232 | s[i][0] = -1; | |
233 | s[i][1] = 0; | |
234 | } | |
3b57a3f7 | 235 | |
bb56afff | 236 | Bool_t labelAdded; |
3b57a3f7 | 237 | Int_t label; |
238 | AliTRDcluster *c = 0x0; | |
239 | for (Int_t ip = 0; ip < kNplane; ip++) { | |
240 | if(fTrackletIndex[ip] == 0xffff) continue; | |
8d2bec9e | 241 | for (Int_t ic = 0; ic < AliTRDseedV1::kNclusters; ic++) { |
3b57a3f7 | 242 | if(!(c = fTracklet[ip]->GetClusters(ic))) continue; |
243 | for (Int_t k = 0; k < 3; k++) { | |
244 | label = c->GetLabel(k); | |
245 | labelAdded = kFALSE; | |
246 | Int_t j = 0; | |
247 | if (label >= 0) { | |
248 | while ((!labelAdded) && (j < kMAXCLUSTERSPERTRACK)) { | |
249 | if ((s[j][0] == label) || | |
250 | (s[j][1] == 0)) { | |
251 | s[j][0] = label; | |
252 | s[j][1]++; | |
253 | labelAdded = kTRUE; | |
254 | } | |
255 | j++; | |
256 | } | |
257 | } | |
258 | } | |
259 | } | |
260 | } | |
261 | ||
bb56afff | 262 | Int_t max = 0; |
263 | label = -123456789; | |
264 | for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) { | |
265 | if (s[i][1] <= max) continue; | |
3b57a3f7 | 266 | max = s[i][1]; |
267 | label = s[i][0]; | |
bb56afff | 268 | } |
3b57a3f7 | 269 | |
bb56afff | 270 | if ((1. - Float_t(max)/GetNumberOfClusters()) > wrong) label = -label; |
3b57a3f7 | 271 | |
bb56afff | 272 | SetLabel(label); |
3b57a3f7 | 273 | |
274 | return kTRUE; | |
bb56afff | 275 | } |
276 | ||
d9950a5a | 277 | //_______________________________________________________________ |
278 | Bool_t AliTRDtrackV1::CookPID() | |
279 | { | |
0906e73e | 280 | // |
281 | // Cook the PID information | |
282 | // | |
3b57a3f7 | 283 | |
284 | // Reset the a priori probabilities | |
285 | Double_t pid = 1. / AliPID::kSPECIES; | |
0906e73e | 286 | for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) { |
3b57a3f7 | 287 | fPID[ispec] = pid; |
288 | } | |
289 | fPIDquality = 0; | |
290 | ||
291 | // steer PID calculation @ tracklet level | |
e3cf3d02 | 292 | Float_t *prob = 0x0; |
3b57a3f7 | 293 | for(int ip=0; ip<kNplane; ip++){ |
294 | if(fTrackletIndex[ip] == 0xffff) continue; | |
295 | if(!fTracklet[ip]->IsOK()) continue; | |
ed15ef4f | 296 | if(!(prob = fTracklet[ip]->GetProbability(kTRUE))) return kFALSE; |
3b57a3f7 | 297 | |
298 | Int_t nspec = 0; // quality check of tracklet dEdx | |
299 | for(int ispec=0; ispec<AliPID::kSPECIES; ispec++){ | |
300 | if(prob[ispec] < 0.) continue; | |
301 | fPID[ispec] *= prob[ispec]; | |
302 | nspec++; | |
303 | } | |
304 | if(!nspec) continue; | |
305 | ||
306 | fPIDquality++; | |
0906e73e | 307 | } |
0906e73e | 308 | |
309 | // no tracklet found for PID calculations | |
310 | if(!fPIDquality) return kTRUE; | |
3b57a3f7 | 311 | |
312 | // slot for PID calculation @ track level | |
313 | ||
314 | ||
0906e73e | 315 | // normalize probabilities |
316 | Double_t probTotal = 0.0; | |
317 | for (Int_t is = 0; is < AliPID::kSPECIES; is++) probTotal += fPID[is]; | |
3b57a3f7 | 318 | |
319 | ||
0906e73e | 320 | if (probTotal <= 0.0) { |
321 | AliWarning("The total probability over all species <= 0. This may be caused by some error in the reference data."); | |
d9950a5a | 322 | return kFALSE; |
323 | } | |
3b57a3f7 | 324 | |
0906e73e | 325 | for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) fPID[iSpecies] /= probTotal; |
3b57a3f7 | 326 | |
0906e73e | 327 | return kTRUE; |
d9950a5a | 328 | } |
329 | ||
0349cc67 | 330 | //_______________________________________________________________ |
331 | AliTRDcluster* AliTRDtrackV1::GetCluster(Int_t id) | |
332 | { | |
333 | Int_t n = 0; | |
334 | for(Int_t ip=0; ip<kNplane; ip++){ | |
335 | if(!fTracklet[ip]) continue; | |
336 | if(n+fTracklet[ip]->GetN() <= id){ | |
337 | n+=fTracklet[ip]->GetN(); | |
338 | continue; | |
339 | } | |
340 | AliTRDcluster *c = 0x0; | |
8d2bec9e | 341 | for(Int_t ic=AliTRDseedV1::kNclusters; ic--;){ |
0349cc67 | 342 | if(!(c = fTracklet[ip]->GetClusters(ic))) continue; |
343 | ||
344 | if(n<id){n++; continue;} | |
345 | return c; | |
346 | } | |
347 | } | |
348 | return 0x0; | |
349 | } | |
350 | ||
3b57a3f7 | 351 | //_______________________________________________________________ |
352 | Int_t AliTRDtrackV1::GetClusterIndex(Int_t id) const | |
353 | { | |
354 | Int_t n = 0; | |
355 | for(Int_t ip=0; ip<kNplane; ip++){ | |
356 | if(!fTracklet[ip]) continue; | |
76b60503 | 357 | if(n+fTracklet[ip]->GetN() <= id){ |
3b57a3f7 | 358 | n+=fTracklet[ip]->GetN(); |
359 | continue; | |
360 | } | |
76b60503 | 361 | AliTRDcluster *c = 0x0; |
8d2bec9e | 362 | for(Int_t ic=AliTRDseedV1::kNclusters; ic--;){ |
76b60503 | 363 | if(!(c = fTracklet[ip]->GetClusters(ic))) continue; |
364 | ||
365 | if(n<id){n++; continue;} | |
3b57a3f7 | 366 | return fTracklet[ip]->GetIndexes(ic); |
367 | } | |
368 | } | |
369 | return -1; | |
0906e73e | 370 | } |
d9950a5a | 371 | |
372 | //_______________________________________________________________ | |
373 | Double_t AliTRDtrackV1::GetPredictedChi2(const AliTRDseedV1 *trklt) const | |
374 | { | |
ed15ef4f | 375 | // Compute chi2 between tracklet and track. The value is calculated at the radial position of the track |
376 | // equal to the reference radial position of the tracklet (see AliTRDseedV1) | |
377 | // | |
378 | // The chi2 estimator is computed according to the following formula | |
379 | // BEGIN_LATEX | |
380 | // #chi^{2}=(X_{trklt}-X_{track})(C_{trklt}+C_{track})^{-1}(X_{trklt}-X_{track})^{T} | |
381 | // END_LATEX | |
382 | // where X=(y z), the position of the track/tracklet in the yz plane | |
383 | // | |
384 | ||
385 | Double_t x = GetX(); | |
386 | Double_t p[2] = { trklt->GetYat(x), trklt->GetZat(x)}; | |
387 | Double_t cov[3]; trklt->GetCovAt(x, cov); | |
388 | return AliExternalTrackParam::GetPredictedChi2(p, cov); | |
3b57a3f7 | 389 | } |
d9950a5a | 390 | |
203967fc | 391 | //_______________________________________________________________ |
392 | Bool_t AliTRDtrackV1::IsEqual(const TObject *o) const | |
393 | { | |
394 | if (!o) return kFALSE; | |
395 | const AliTRDtrackV1 *inTrack = dynamic_cast<const AliTRDtrackV1*>(o); | |
396 | if (!inTrack) return kFALSE; | |
397 | ||
398 | if ( fPIDquality != inTrack->GetPIDquality() ) return kFALSE; | |
399 | ||
400 | for(Int_t i = 0; i < AliPID::kSPECIES; i++){ | |
401 | if ( fPID[i] != inTrack->GetPID(i) ) return kFALSE; | |
402 | } | |
403 | ||
404 | for (Int_t i = 0; i < 3; i++){ | |
405 | if ( fBudget[i] != inTrack->GetBudget(i) ) return kFALSE; | |
406 | } | |
407 | if ( fDE != inTrack->GetEdep() ) return kFALSE; | |
408 | if ( fFakeRatio != inTrack->GetFakeRatio() ) return kFALSE; | |
409 | if ( fChi2 != inTrack->GetChi2() ) return kFALSE; | |
410 | if ( fMass != inTrack->GetMass() ) return kFALSE; | |
411 | if ( fLab != inTrack->GetLabel() ) return kFALSE; | |
412 | if ( fN != inTrack->GetNumberOfClusters() ) return kFALSE; | |
413 | if ( AliKalmanTrack::GetIntegratedLength() != inTrack->GetIntegratedLength() ) return kFALSE; | |
414 | ||
415 | if ( GetX() != inTrack->GetX() ) return kFALSE; | |
416 | if ( GetAlpha() != inTrack->GetAlpha() ) return kFALSE; | |
417 | const Double_t *inP = inTrack->GetParameter(); | |
418 | const Double_t *curP = GetParameter(); | |
419 | for (Int_t i = 0; i < 5; i++){ | |
420 | if ( curP[i] != inP[i]) return kFALSE; | |
421 | } | |
422 | const Double_t *inC = inTrack->GetCovariance(); | |
423 | const Double_t *curC = GetCovariance(); | |
424 | for (Int_t i = 0; i < 15; i++){ | |
425 | if ( curC[i] != inC[i]) return kFALSE; | |
426 | } | |
427 | ||
428 | for (Int_t iTracklet = 0; iTracklet < kNplane; iTracklet++){ | |
429 | AliTRDseedV1 *curTracklet = fTracklet[iTracklet]; | |
430 | AliTRDseedV1 *inTracklet = inTrack->GetTracklet(iTracklet); | |
431 | if (curTracklet && inTracklet){ | |
432 | if (! curTracklet->IsEqual(inTracklet) ) { | |
433 | curTracklet->Print(); | |
434 | inTracklet->Print(); | |
435 | return kFALSE; | |
436 | } | |
437 | } else { | |
438 | // if one tracklet exists, and corresponding | |
439 | // in other track doesn't - return kFALSE | |
440 | if(inTracklet || curTracklet) return kFALSE; | |
441 | } | |
442 | } | |
443 | ||
444 | return kTRUE; | |
445 | } | |
446 | ||
22a4ab0c | 447 | //_______________________________________________________________ |
448 | Bool_t AliTRDtrackV1::IsElectron() const | |
449 | { | |
215f7116 | 450 | if(GetPID(0) > fReconstructor->GetRecoParam()->GetPIDThreshold(GetP())) return kTRUE; |
22a4ab0c | 451 | return kFALSE; |
452 | } | |
453 | ||
3b57a3f7 | 454 | |
455 | //_____________________________________________________________________________ | |
456 | void AliTRDtrackV1::MakeBackupTrack() | |
457 | { | |
458 | // | |
459 | // Creates a backup track | |
460 | // | |
461 | ||
462 | if(fBackupTrack) { | |
463 | fBackupTrack->~AliTRDtrackV1(); | |
464 | new(fBackupTrack) AliTRDtrackV1((AliTRDtrackV1&)(*this)); | |
592fdd48 | 465 | return; |
3b57a3f7 | 466 | } |
467 | fBackupTrack = new AliTRDtrackV1((AliTRDtrackV1&)(*this)); | |
d9950a5a | 468 | } |
469 | ||
3b57a3f7 | 470 | //_____________________________________________________________________________ |
471 | Int_t AliTRDtrackV1::GetProlongation(Double_t xk, Double_t &y, Double_t &z) | |
472 | { | |
473 | // | |
474 | // Find a prolongation at given x | |
475 | // Return 0 if it does not exist | |
476 | // | |
477 | ||
478 | Double_t bz = GetBz(); | |
479 | if (!AliExternalTrackParam::GetYAt(xk,bz,y)) return 0; | |
480 | if (!AliExternalTrackParam::GetZAt(xk,bz,z)) return 0; | |
481 | ||
482 | return 1; | |
483 | ||
484 | } | |
485 | ||
486 | //_____________________________________________________________________________ | |
487 | Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho) | |
0906e73e | 488 | { |
489 | // | |
3b57a3f7 | 490 | // Propagates this track to a reference plane defined by "xk" [cm] |
491 | // correcting for the mean crossed material. | |
0906e73e | 492 | // |
3b57a3f7 | 493 | // "xx0" - thickness/rad.length [units of the radiation length] |
494 | // "xrho" - thickness*density [g/cm^2] | |
495 | // | |
0906e73e | 496 | |
3b57a3f7 | 497 | if (xk == GetX()) { |
498 | return kTRUE; | |
499 | } | |
500 | ||
501 | Double_t oldX = GetX(); | |
502 | Double_t oldY = GetY(); | |
503 | Double_t oldZ = GetZ(); | |
504 | ||
505 | Double_t bz = GetBz(); | |
506 | ||
507 | if (!AliExternalTrackParam::PropagateTo(xk,bz)) { | |
508 | return kFALSE; | |
509 | } | |
510 | ||
511 | Double_t x = GetX(); | |
512 | Double_t y = GetY(); | |
513 | Double_t z = GetZ(); | |
514 | ||
515 | if (oldX < xk) { | |
516 | xrho = -xrho; | |
517 | if (IsStartedTimeIntegral()) { | |
518 | Double_t l2 = TMath::Sqrt((x-oldX)*(x-oldX) | |
519 | + (y-oldY)*(y-oldY) | |
520 | + (z-oldZ)*(z-oldZ)); | |
521 | Double_t crv = AliExternalTrackParam::GetC(bz); | |
522 | if (TMath::Abs(l2*crv) > 0.0001) { | |
523 | // Make correction for curvature if neccesary | |
524 | l2 = 0.5 * TMath::Sqrt((x-oldX)*(x-oldX) | |
525 | + (y-oldY)*(y-oldY)); | |
526 | l2 = 2.0 * TMath::ASin(l2 * crv) / crv; | |
527 | l2 = TMath::Sqrt(l2*l2 + (z-oldZ)*(z-oldZ)); | |
528 | } | |
529 | AddTimeStep(l2); | |
530 | } | |
531 | } | |
532 | ||
fd40f855 | 533 | if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0, xrho, GetMass())) return kFALSE; |
534 | ||
3b57a3f7 | 535 | |
536 | { | |
537 | ||
538 | // Energy losses | |
539 | Double_t p2 = (1.0 + GetTgl()*GetTgl()) / (GetSigned1Pt()*GetSigned1Pt()); | |
540 | Double_t beta2 = p2 / (p2 + GetMass()*GetMass()); | |
541 | if ((beta2 < 1.0e-10) || | |
542 | ((5940.0 * beta2/(1.0 - beta2 + 1.0e-10) - beta2) < 0.0)) { | |
543 | return kFALSE; | |
544 | } | |
545 | ||
546 | Double_t dE = 0.153e-3 / beta2 | |
547 | * (TMath::Log(5940.0 * beta2/(1.0 - beta2 + 1.0e-10)) - beta2) | |
548 | * xrho; | |
549 | fBudget[0] += xrho; | |
550 | ||
551 | /* | |
552 | // Suspicious part - think about it ? | |
553 | Double_t kinE = TMath::Sqrt(p2); | |
554 | if (dE > 0.8*kinE) dE = 0.8 * kinE; // | |
555 | if (dE < 0) dE = 0.0; // Not valid region for Bethe bloch | |
556 | */ | |
557 | ||
558 | fDE += dE; | |
559 | ||
560 | /* | |
561 | // Suspicious ! I.B. | |
562 | Double_t sigmade = 0.07 * TMath::Sqrt(TMath::Abs(dE)); // Energy loss fluctuation | |
563 | Double_t sigmac2 = sigmade*sigmade*fC*fC*(p2+GetMass()*GetMass())/(p2*p2); | |
564 | fCcc += sigmac2; | |
565 | fCee += fX*fX * sigmac2; | |
566 | */ | |
567 | ||
568 | } | |
569 | ||
570 | return kTRUE; | |
0906e73e | 571 | } |
3b57a3f7 | 572 | |
87a7fa94 | 573 | //_____________________________________________________________________________ |
3b57a3f7 | 574 | Int_t AliTRDtrackV1::PropagateToR(Double_t r,Double_t step) |
87a7fa94 | 575 | { |
576 | // | |
3b57a3f7 | 577 | // Propagate track to the radial position |
578 | // Rotation always connected to the last track position | |
87a7fa94 | 579 | // |
580 | ||
3b57a3f7 | 581 | Double_t xyz0[3]; |
582 | Double_t xyz1[3]; | |
583 | Double_t y; | |
584 | Double_t z; | |
585 | ||
586 | Double_t radius = TMath::Sqrt(GetX()*GetX() + GetY()*GetY()); | |
587 | // Direction +- | |
588 | Double_t dir = (radius > r) ? -1.0 : 1.0; | |
589 | ||
590 | for (Double_t x = radius+dir*step; dir*x < dir*r; x += dir*step) { | |
591 | ||
592 | GetXYZ(xyz0); | |
593 | Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]); | |
594 | Rotate(alpha,kTRUE); | |
595 | GetXYZ(xyz0); | |
596 | GetProlongation(x,y,z); | |
597 | xyz1[0] = x * TMath::Cos(alpha) + y * TMath::Sin(alpha); | |
598 | xyz1[1] = x * TMath::Sin(alpha) - y * TMath::Cos(alpha); | |
599 | xyz1[2] = z; | |
600 | Double_t param[7]; | |
83dea92e | 601 | if(AliTracker::MeanMaterialBudget(xyz0,xyz1,param)<=0.) return -1; |
3b57a3f7 | 602 | if (param[1] <= 0) { |
603 | param[1] = 100000000; | |
604 | } | |
605 | PropagateTo(x,param[1],param[0]*param[4]); | |
606 | ||
607 | } | |
608 | ||
609 | GetXYZ(xyz0); | |
610 | Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]); | |
611 | Rotate(alpha,kTRUE); | |
612 | GetXYZ(xyz0); | |
613 | GetProlongation(r,y,z); | |
614 | xyz1[0] = r * TMath::Cos(alpha) + y * TMath::Sin(alpha); | |
615 | xyz1[1] = r * TMath::Sin(alpha) - y * TMath::Cos(alpha); | |
616 | xyz1[2] = z; | |
617 | Double_t param[7]; | |
83dea92e | 618 | if(AliTracker::MeanMaterialBudget(xyz0,xyz1,param) <= 0.) return -1; |
3b57a3f7 | 619 | |
620 | if (param[1] <= 0) { | |
621 | param[1] = 100000000; | |
87a7fa94 | 622 | } |
3b57a3f7 | 623 | PropagateTo(r,param[1],param[0]*param[4]); |
624 | ||
625 | return 0; | |
626 | ||
87a7fa94 | 627 | } |
628 | ||
203967fc | 629 | //_____________________________________________________________________________ |
630 | void AliTRDtrackV1::Print(Option_t *o) const | |
631 | { | |
632 | AliInfo(Form("PID q[%d] [%4.1f %4.1f %4.1f %4.1f %4.1f]", fPIDquality, 1.E2*fPID[0], 1.E2*fPID[1], 1.E2*fPID[2], 1.E2*fPID[3], 1.E2*fPID[4])); | |
633 | AliInfo(Form("Material[%5.2f %5.2f %5.2f]", fBudget[0], fBudget[1], fBudget[2])); | |
634 | ||
635 | AliInfo(Form("x[%7.2f] t[%7.4f] alpha[%f] mass[%f]", GetX(), GetIntegratedLength(), GetAlpha(), fMass)); | |
636 | AliInfo(Form("Ntr[%1d] Ncl[%3d] lab[%3d]", GetNumberOfTracklets(), fN, fLab)); | |
637 | ||
638 | if(strcmp(o, "a")!=0) return; | |
639 | printf("|X| = ("); | |
640 | const Double_t *curP = GetParameter(); | |
641 | for (Int_t i = 0; i < 5; i++) printf("%7.2f ", curP[i]); | |
642 | printf(")\n"); | |
643 | ||
644 | printf("|V| = \n"); | |
645 | const Double_t *curC = GetCovariance(); | |
646 | for (Int_t i = 0, j=4, k=0; i<15; i++, k++){ | |
647 | printf("%7.2f ", curC[i]); | |
648 | if(k==j){ | |
649 | printf("\n"); | |
650 | k=-1; j--; | |
651 | } | |
652 | } | |
653 | ||
654 | for(Int_t ip=0; ip<kNplane; ip++){ | |
655 | if(!fTracklet[ip]) continue; | |
656 | fTracklet[ip]->Print(o); | |
657 | } | |
658 | } | |
659 | ||
660 | ||
3b57a3f7 | 661 | //_____________________________________________________________________________ |
662 | Bool_t AliTRDtrackV1::Rotate(Double_t alpha, Bool_t absolute) | |
663 | { | |
664 | // | |
665 | // Rotates track parameters in R*phi plane | |
666 | // if absolute rotation alpha is in global system | |
667 | // otherwise alpha rotation is relative to the current rotation angle | |
668 | // | |
669 | ||
670 | if (absolute) alpha -= GetAlpha(); | |
671 | //else fNRotate++; | |
672 | ||
673 | return AliExternalTrackParam::Rotate(GetAlpha()+alpha); | |
674 | } | |
87a7fa94 | 675 | |
eb38ed55 | 676 | //___________________________________________________________ |
677 | void AliTRDtrackV1::SetNumberOfClusters() | |
678 | { | |
679 | // Calculate the number of clusters attached to this track | |
680 | ||
3b57a3f7 | 681 | Int_t ncls = 0; |
682 | for(int ip=0; ip<kNplane; ip++){ | |
683 | if(fTracklet[ip] && fTrackletIndex[ip] != 0xffff) ncls += fTracklet[ip]->GetN(); | |
684 | } | |
685 | AliKalmanTrack::SetNumberOfClusters(ncls); | |
eb38ed55 | 686 | } |
687 | ||
688 | ||
0906e73e | 689 | //_______________________________________________________________ |
3b57a3f7 | 690 | void AliTRDtrackV1::SetOwner() |
0906e73e | 691 | { |
692 | // | |
693 | // Toggle ownership of tracklets | |
694 | // | |
695 | ||
e44586fb | 696 | if(TestBit(kOwner)) return; |
3b57a3f7 | 697 | for (Int_t ip = 0; ip < kNplane; ip++) { |
698 | if(fTrackletIndex[ip] == 0xffff) continue; | |
699 | fTracklet[ip] = new AliTRDseedV1(*fTracklet[ip]); | |
700 | fTracklet[ip]->SetOwner(); | |
701 | } | |
e44586fb | 702 | SetBit(kOwner); |
0906e73e | 703 | } |
704 | ||
d9950a5a | 705 | //_______________________________________________________________ |
3b57a3f7 | 706 | void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *trklt, Int_t index) |
d9950a5a | 707 | { |
708 | // | |
0906e73e | 709 | // Set the tracklets |
d9950a5a | 710 | // |
3b57a3f7 | 711 | Int_t plane = trklt->GetPlane(); |
76b60503 | 712 | |
3b57a3f7 | 713 | fTracklet[plane] = trklt; |
714 | fTrackletIndex[plane] = index; | |
d9950a5a | 715 | } |
716 | ||
e3cf3d02 | 717 | //_______________________________________________________________ |
718 | void AliTRDtrackV1::SetTrackLow() | |
719 | { | |
720 | const AliExternalTrackParam *op = dynamic_cast<const AliExternalTrackParam*>(this); | |
721 | fTrackLow = fTrackLow ? new(fTrackLow) AliExternalTrackParam(*op) : new AliExternalTrackParam(*op); | |
722 | } | |
723 | ||
724 | //_______________________________________________________________ | |
725 | void AliTRDtrackV1::SetTrackHigh(const AliExternalTrackParam *op) | |
726 | { | |
727 | if(!op) op = dynamic_cast<const AliExternalTrackParam*>(this); | |
728 | fTrackHigh = fTrackHigh ? new(fTrackHigh) AliExternalTrackParam(*op) : new AliExternalTrackParam(*op); | |
729 | } | |
730 | ||
181d2c97 | 731 | //_______________________________________________________________ |
732 | void AliTRDtrackV1::UnsetTracklet(Int_t plane) | |
733 | { | |
734 | if(plane<0 && plane >= kNplane) return; | |
735 | fTrackletIndex[plane] = 0xffff; | |
736 | fTracklet[plane] = 0x0; | |
737 | } | |
738 | ||
739 | ||
d9950a5a | 740 | //_______________________________________________________________ |
0906e73e | 741 | Bool_t AliTRDtrackV1::Update(AliTRDseedV1 *trklt, Double_t chisq) |
d9950a5a | 742 | { |
743 | // | |
3b57a3f7 | 744 | // Update track and tracklet parameters |
d9950a5a | 745 | // |
3b57a3f7 | 746 | |
b1957d3c | 747 | Double_t x = GetX(); |
d9950a5a | 748 | Double_t p[2] = { trklt->GetYat(x) |
749 | , trklt->GetZat(x) }; | |
fd40f855 | 750 | Double_t cov[3]/*, covR[3], cov0[3]*/; |
b1957d3c | 751 | |
752 | // printf("\tD[%3d] Ly[%d] Trk: x[%f] y[%f] z[%f]\n", trklt->GetDetector(), trklt->GetPlane(), GetX(), GetY(), GetZ()); | |
753 | // // | |
754 | // Double_t xref = trklt->GetXref(); | |
755 | // trklt->GetCovAt(xref, covR); | |
756 | // printf("xr=%5.3f y=%f+-%f z=%f+-%f (covYZ=%f)\n", xref, trklt->GetYat(xref), TMath::Sqrt(covR[0]), trklt->GetZat(xref), TMath::Sqrt(covR[2]), covR[1]); | |
757 | // | |
758 | // Double_t x0 = trklt->GetX0(); | |
759 | // trklt->GetCovAt(x0, cov0); | |
760 | // printf("x0=%5.3f y=%f+-%f z=%f+-%f (covYZ=%f)\n", x0, trklt->GetYat(x0), TMath::Sqrt(cov0[0]), trklt->GetZat(x0), TMath::Sqrt(cov0[2]), cov0[1]); | |
761 | // | |
762 | // trklt->GetCovAt(x, cov); | |
763 | // printf("x =%5.3f y=%f+-%f z=%f+-%f (covYZ=%f)\n", x, p[0], TMath::Sqrt(cov[0]), p[1], TMath::Sqrt(cov[2]), cov[1]); | |
764 | // | |
765 | // const Double_t *cc = GetCovariance(); | |
766 | // printf("yklm[0] = %f +- %f\n", GetY(), TMath::Sqrt(cc[0])); | |
767 | ||
768 | trklt->GetCovAt(x, cov); | |
d9950a5a | 769 | if(!AliExternalTrackParam::Update(p, cov)) return kFALSE; |
b1957d3c | 770 | // cc = GetCovariance(); |
771 | // printf("yklm[1] = %f +- %f\n", GetY(), TMath::Sqrt(cc[0])); | |
772 | ||
3b57a3f7 | 773 | AliTRDcluster *c = 0x0; |
774 | Int_t ic = 0; while(!(c = trklt->GetClusters(ic))) ic++; | |
775 | AliTracker::FillResiduals(this, p, cov, c->GetVolumeId()); | |
776 | ||
d9950a5a | 777 | // Register info to track |
3b57a3f7 | 778 | SetNumberOfClusters(); |
d9950a5a | 779 | SetChi2(GetChi2() + chisq); |
3b57a3f7 | 780 | return kTRUE; |
d9950a5a | 781 | } |
782 | ||
783 | //_______________________________________________________________ | |
0906e73e | 784 | void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track) |
d9950a5a | 785 | { |
786 | // | |
6984f7c1 | 787 | // Update the TRD PID information in the ESD track |
d9950a5a | 788 | // |
6984f7c1 | 789 | |
0d83b3a5 | 790 | Int_t nslices = fReconstructor->IsEightSlices() ? (Int_t)AliTRDpidUtil::kNNslices : (Int_t)AliTRDpidUtil::kLQslices; |
215f7116 | 791 | track->SetNumberOfTRDslices(nslices); |
3b57a3f7 | 792 | |
ed15ef4f | 793 | Int_t n = 0; |
6984f7c1 | 794 | for (Int_t ip = 0; ip < kNplane; ip++) { |
3b57a3f7 | 795 | if(fTrackletIndex[ip] == 0xffff) continue; |
ed15ef4f | 796 | n++; |
2b436dfa | 797 | if(!fTracklet[ip]->IsOK()) continue; |
215f7116 | 798 | fTracklet[ip]->CookdEdx(nslices); |
3b57a3f7 | 799 | Float_t *dedx = fTracklet[ip]->GetdEdx(); |
215f7116 | 800 | for (Int_t js = 0; js < nslices; js++, dedx++) track->SetTRDslice(*dedx, ip, js); |
6984f7c1 | 801 | } |
0906e73e | 802 | |
ed15ef4f | 803 | if(!fPIDquality) track->SetTRDntracklets(n); |
804 | else { | |
805 | track->SetTRDpid(fPID); | |
806 | n |= (fPIDquality<<3); | |
807 | track->SetTRDntracklets(n); | |
808 | } | |
d9950a5a | 809 | } |