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