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