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