]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDtrack.cxx
new AliSplineFit class. Performs recursive fits to data point arrays
[u/mrichter/AliRoot.git] / STEER / AliESDtrack.cxx
CommitLineData
ae982df3 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
ae982df3 15//-----------------------------------------------------------------
16// Implementation of the ESD track class
4427806c 17// ESD = Event Summary Data
15614b8b 18// This is the class to deal with during the phisics analysis of data
4427806c 19// Origin: Iouri Belikov, CERN
20// e-mail: Jouri.Belikov@cern.ch
ae982df3 21//-----------------------------------------------------------------
22
e1e6896f 23#include <TMath.h>
49edfa08 24#include <TParticle.h>
ae982df3 25
49d13e89 26#include "AliESDVertex.h"
ae982df3 27#include "AliESDtrack.h"
28#include "AliKalmanTrack.h"
5f7789fc 29#include "AliLog.h"
15e85efa 30#include "AliTrackPointArray.h"
ae982df3 31
32ClassImp(AliESDtrack)
33
d27bbc79 34void SetPIDValues(Float_t * dest, const Double_t * src, Int_t n) {
35 // This function copies "n" PID weights from "scr" to "dest"
36 // and normalizes their sum to 1 thus producing conditional probabilities.
37 // The negative weights are set to 0.
38 // In case all the weights are non-positive they are replaced by
39 // uniform probabilities
40
41 if (n<=0) return;
42
43 Float_t uniform = 1./(Float_t)n;
44
45 Float_t sum = 0;
46 for (Int_t i=0; i<n; i++)
47 if (src[i]>=0) {
48 sum+=src[i];
49 dest[i] = src[i];
50 }
51 else {
52 dest[i] = 0;
53 }
54
55 if(sum>0)
56 for (Int_t i=0; i<n; i++) dest[i] /= sum;
57 else
58 for (Int_t i=0; i<n; i++) dest[i] = uniform;
59}
60
ae982df3 61//_______________________________________________________________________
62AliESDtrack::AliESDtrack() :
c9ec41e8 63 AliExternalTrackParam(),
90e48c0c 64 fFlags(0),
65 fLabel(0),
66 fID(0),
67 fTrackLength(0),
49d13e89 68 fD(0),fZ(0),
69 fCdd(0),fCdz(0),fCzz(0),
90e48c0c 70 fStopVertex(0),
c9ec41e8 71 fCp(0),
90e48c0c 72 fCchi2(1e10),
c9ec41e8 73 fIp(0),
74 fOp(0),
90e48c0c 75 fITSchi2(0),
76 fITSncls(0),
62665e7f 77 fITSClusterMap(0),
90e48c0c 78 fITSsignal(0),
79 fITSLabel(0),
90e48c0c 80 fTPCchi2(0),
81 fTPCncls(0),
e1d4c1b5 82 fTPCnclsF(0),
90e48c0c 83 fTPCClusterMap(159),//number of padrows
84 fTPCsignal(0),
e1d4c1b5 85 fTPCsignalN(0),
86 fTPCsignalS(0),
90e48c0c 87 fTPCLabel(0),
88 fTRDchi2(0),
89 fTRDncls(0),
90 fTRDncls0(0),
91 fTRDsignal(0),
92 fTRDLabel(0),
93 fTRDQuality(0),
23d49657 94 fTRDBudget(0),
90e48c0c 95 fTOFchi2(0),
96 fTOFindex(0),
85324138 97 fTOFCalChannel(-1),
90e48c0c 98 fTOFsignal(-1),
85324138 99 fTOFsignalToT(0),
f4b3bbb7 100 fHMPIDchi2(1e10),
101 fHMPIDqn(-1),
102 fHMPIDcluIdx(-1),
103 fHMPIDsignal(-1),
104 fHMPIDtrkTheta(-1),
105 fHMPIDtrkPhi(-1),
106 fHMPIDtrkX(-1),
107 fHMPIDtrkY(-1),
108 fHMPIDmipX(-1),
109 fHMPIDmipY(-1),
2e1dcd14 110 fEMCALindex(kEMCALNoMatch),
15e85efa 111 fFriendTrack(new AliESDfriendTrack())
ae982df3 112{
113 //
114 // The default ESD constructor
115 //
6d45eaef 116 Int_t i, j;
6238d7a9 117 for (i=0; i<AliPID::kSPECIES; i++) {
4a78b8c5 118 fTrackTime[i]=0.;
119 fR[i]=1.;
120 fITSr[i]=1.;
121 fTPCr[i]=1.;
122 fTRDr[i]=1.;
123 fTOFr[i]=1.;
f4b3bbb7 124 fHMPIDr[i]=1.;
2bad268c 125 }
ac2f7574 126
ef7253ac 127 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
128 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
6d45eaef 129 for (i=0;i<kNPlane;i++) {
130 for (j=0;j<kNSlice;j++) {
131 fTRDsignals[i][j]=0.;
132 }
133 fTRDTimBin[i]=-1;
134 }
c9ec41e8 135 for (i=0;i<4;i++) {fTPCPoints[i]=-1;}
136 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
137 for (i=0;i<10;i++) {fTOFInfo[i]=-1;}
c4d11b15 138}
139
140//_______________________________________________________________________
90e48c0c 141AliESDtrack::AliESDtrack(const AliESDtrack& track):
c9ec41e8 142 AliExternalTrackParam(track),
90e48c0c 143 fFlags(track.fFlags),
144 fLabel(track.fLabel),
145 fID(track.fID),
146 fTrackLength(track.fTrackLength),
49d13e89 147 fD(track.fD),fZ(track.fZ),
148 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
90e48c0c 149 fStopVertex(track.fStopVertex),
c9ec41e8 150 fCp(0),
90e48c0c 151 fCchi2(track.fCchi2),
c9ec41e8 152 fIp(0),
153 fOp(0),
90e48c0c 154 fITSchi2(track.fITSchi2),
155 fITSncls(track.fITSncls),
62665e7f 156 fITSClusterMap(track.fITSClusterMap),
90e48c0c 157 fITSsignal(track.fITSsignal),
158 fITSLabel(track.fITSLabel),
90e48c0c 159 fTPCchi2(track.fTPCchi2),
160 fTPCncls(track.fTPCncls),
e1d4c1b5 161 fTPCnclsF(track.fTPCnclsF),
90e48c0c 162 fTPCClusterMap(track.fTPCClusterMap),
163 fTPCsignal(track.fTPCsignal),
e1d4c1b5 164 fTPCsignalN(track.fTPCsignalN),
165 fTPCsignalS(track.fTPCsignalS),
90e48c0c 166 fTPCLabel(track.fTPCLabel),
167 fTRDchi2(track.fTRDchi2),
168 fTRDncls(track.fTRDncls),
169 fTRDncls0(track.fTRDncls0),
170 fTRDsignal(track.fTRDsignal),
171 fTRDLabel(track.fTRDLabel),
172 fTRDQuality(track.fTRDQuality),
23d49657 173 fTRDBudget(track.fTRDBudget),
90e48c0c 174 fTOFchi2(track.fTOFchi2),
175 fTOFindex(track.fTOFindex),
85324138 176 fTOFCalChannel(track.fTOFCalChannel),
90e48c0c 177 fTOFsignal(track.fTOFsignal),
85324138 178 fTOFsignalToT(track.fTOFsignalToT),
f4b3bbb7 179 fHMPIDchi2(track.fHMPIDchi2),
180 fHMPIDqn(track.fHMPIDqn),
181 fHMPIDcluIdx(track.fHMPIDcluIdx),
182 fHMPIDsignal(track.fHMPIDsignal),
183 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
184 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
185 fHMPIDtrkX(track.fHMPIDtrkX),
186 fHMPIDtrkY(track.fHMPIDtrkY),
187 fHMPIDmipX(track.fHMPIDmipX),
188 fHMPIDmipY(track.fHMPIDmipY),
2e1dcd14 189 fEMCALindex(track.fEMCALindex),
8497bca0 190 fFriendTrack(0)
90e48c0c 191{
c4d11b15 192 //
193 //copy constructor
194 //
ef7253ac 195 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
196 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
c4d11b15 197 //
304864ab 198 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
c4d11b15 199 //
304864ab 200 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
51ad6848 201 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
202 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
203 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
c4d11b15 204 //
eab5961e 205 for (Int_t i=0;i<kNPlane;i++) {
6d45eaef 206 for (Int_t j=0;j<kNSlice;j++) {
207 fTRDsignals[i][j]=track.fTRDsignals[i][j];
208 }
209 fTRDTimBin[i]=track.fTRDTimBin[i];
eab5961e 210 }
304864ab 211 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
304864ab 212 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
51ad6848 213 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
214 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
f4b3bbb7 215 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
c9ec41e8 216
217 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
218 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
219 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
15e85efa 220
8497bca0 221 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
ae982df3 222}
15e85efa 223
49edfa08 224//_______________________________________________________________________
225AliESDtrack::AliESDtrack(TParticle * part) :
226 AliExternalTrackParam(),
227 fFlags(0),
228 fLabel(0),
229 fID(0),
230 fTrackLength(0),
231 fD(0),fZ(0),
232 fCdd(0),fCdz(0),fCzz(0),
233 fStopVertex(0),
234 fCp(0),
235 fCchi2(1e10),
236 fIp(0),
237 fOp(0),
238 fITSchi2(0),
239 fITSncls(0),
62665e7f 240 fITSClusterMap(0),
49edfa08 241 fITSsignal(0),
242 fITSLabel(0),
243 fTPCchi2(0),
244 fTPCncls(0),
245 fTPCnclsF(0),
246 fTPCClusterMap(159),//number of padrows
247 fTPCsignal(0),
248 fTPCsignalN(0),
249 fTPCsignalS(0),
250 fTPCLabel(0),
251 fTRDchi2(0),
252 fTRDncls(0),
253 fTRDncls0(0),
254 fTRDsignal(0),
255 fTRDLabel(0),
256 fTRDQuality(0),
257 fTRDBudget(0),
258 fTOFchi2(0),
259 fTOFindex(0),
260 fTOFCalChannel(-1),
261 fTOFsignal(-1),
262 fTOFsignalToT(0),
f4b3bbb7 263 fHMPIDchi2(1e10),
264 fHMPIDqn(-1),
265 fHMPIDcluIdx(-1),
266 fHMPIDsignal(-1),
267 fHMPIDtrkTheta(-1),
268 fHMPIDtrkPhi(-1),
269 fHMPIDtrkX(-1),
270 fHMPIDtrkY(-1),
271 fHMPIDmipX(-1),
272 fHMPIDmipY(-1),
49edfa08 273 fEMCALindex(kEMCALNoMatch),
274 fFriendTrack(0)
275{
276 //
277 // ESD track from TParticle
278 //
279
280 // Reset all the arrays
281 Int_t i, j;
282 for (i=0; i<AliPID::kSPECIES; i++) {
283 fTrackTime[i]=0.;
284 fR[i]=0.;
285 fITSr[i]=0.;
286 fTPCr[i]=0.;
287 fTRDr[i]=0.;
288 fTOFr[i]=0.;
f4b3bbb7 289 fHMPIDr[i]=0.;
49edfa08 290 }
291
292 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
293 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
294 for (i=0;i<kNPlane;i++) {
295 for (j=0;j<kNSlice;j++) {
296 fTRDsignals[i][j]=0.;
297 }
298 fTRDTimBin[i]=-1;
299 }
300 for (i=0;i<4;i++) {fTPCPoints[i]=-1;}
301 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
302 for (i=0;i<10;i++) {fTOFInfo[i]=-1;}
303
304 // Calculate the AliExternalTrackParam content
305
306 Double_t xref;
307 Double_t alpha;
308 Double_t param[5];
309 Double_t covar[15];
310
311 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
312 alpha = part->Phi()*180./TMath::Pi();
313 if (alpha<0) alpha+= 360.;
314 if (alpha>360) alpha -= 360.;
315
316 Int_t sector = (Int_t)(alpha/20.);
317 alpha = 10. + 20.*sector;
318 alpha /= 180;
319 alpha *= TMath::Pi();
320
321 // Covariance matrix: no errors, the parameters are exact
322 for (Int_t i=0; i<15; i++) covar[i]=0.;
323
324 // Get the vertex of origin and the momentum
325 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
326 TVector3 mom(part->Px(),part->Py(),part->Pz());
327
328 // Rotate to the local coordinate system (TPC sector)
329 ver.RotateZ(-alpha);
330 mom.RotateZ(-alpha);
331
332 // X of the referense plane
333 xref = ver.X();
334
335 Int_t pdgCode = part->GetPdgCode();
336
337 Double_t charge =
338 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
339
340 param[0] = ver.Y();
341 param[1] = ver.Z();
342 param[2] = TMath::Sin(mom.Phi());
343 param[3] = mom.Pz()/mom.Pt();
344 param[4] = TMath::Sign(1/mom.Pt(),charge);
345
346 // Set AliExternalTrackParam
347 Set(xref, alpha, param, covar);
348
349 // Set the PID
350 Int_t indexPID = 99;
351
352 switch (TMath::Abs(pdgCode)) {
353
354 case 11: // electron
355 indexPID = 0;
356 break;
357
358 case 13: // muon
359 indexPID = 1;
360 break;
361
362 case 211: // pion
363 indexPID = 2;
364 break;
365
366 case 321: // kaon
367 indexPID = 3;
368 break;
369
370 case 2212: // proton
371 indexPID = 4;
372 break;
373
374 default:
375 break;
376 }
377
378 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
379 if (indexPID < AliPID::kSPECIES) {
380 fR[indexPID]=1.;
381 fITSr[indexPID]=1.;
382 fTPCr[indexPID]=1.;
383 fTRDr[indexPID]=1.;
384 fTOFr[indexPID]=1.;
f4b3bbb7 385 fHMPIDr[indexPID]=1.;
49edfa08 386
387 }
388 // AliESD track label
389 SetLabel(part->GetUniqueID());
390
391}
392
c4d11b15 393//_______________________________________________________________________
394AliESDtrack::~AliESDtrack(){
395 //
396 // This is destructor according Coding Conventrions
397 //
398 //printf("Delete track\n");
c9ec41e8 399 delete fIp;
400 delete fOp;
401 delete fCp;
15e85efa 402 delete fFriendTrack;
c4d11b15 403}
ae982df3 404
00dce61a 405void AliESDtrack::AddCalibObject(TObject * object){
406 //
407 // add calib object to the list
408 //
409 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
410 fFriendTrack->AddCalibObject(object);
411}
412
413TObject * AliESDtrack::GetCalibObject(Int_t index){
414 //
415 // return calib objct at given position
416 //
417 if (!fFriendTrack) return 0;
418 return fFriendTrack->GetCalibObject(index);
419}
420
421
9559cbc4 422//_______________________________________________________________________
423void AliESDtrack::MakeMiniESDtrack(){
424 // Resets everything except
425 // fFlags: Reconstruction status flags
426 // fLabel: Track label
427 // fID: Unique ID of the track
428 // fD: Impact parameter in XY-plane
429 // fZ: Impact parameter in Z
430 // fR[AliPID::kSPECIES]: combined "detector response probability"
8497bca0 431 // Running track parameters in the base class (AliExternalTrackParam)
9559cbc4 432
433 fTrackLength = 0;
434 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
435 fStopVertex = 0;
436
437 // Reset track parameters constrained to the primary vertex
c9ec41e8 438 fCp = 0;
9559cbc4 439 fCchi2 = 0;
440
441 // Reset track parameters at the inner wall of TPC
c9ec41e8 442 fIp = 0;
9559cbc4 443
444 // Reset track parameters at the inner wall of the TRD
c9ec41e8 445 fOp = 0;
9559cbc4 446
447 // Reset ITS track related information
448 fITSchi2 = 0;
9559cbc4 449 fITSncls = 0;
62665e7f 450 fITSClusterMap=0;
9559cbc4 451 fITSsignal = 0;
ef7253ac 452 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
9559cbc4 453 fITSLabel = 0;
9559cbc4 454
455 // Reset TPC related track information
456 fTPCchi2 = 0;
457 fTPCncls = 0;
e1d4c1b5 458 fTPCnclsF = 0;
9559cbc4 459 fTPCClusterMap = 0;
460 fTPCsignal= 0;
e1d4c1b5 461 fTPCsignalS= 0;
462 fTPCsignalN= 0;
9559cbc4 463 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
464 fTPCLabel=0;
465 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
466 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
467 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
468
469 // Reset TRD related track information
470 fTRDchi2 = 0;
471 fTRDncls = 0;
472 fTRDncls0 = 0;
9559cbc4 473 fTRDsignal = 0;
474 for (Int_t i=0;i<kNPlane;i++) {
6d45eaef 475 for (Int_t j=0;j<kNSlice;j++) {
476 fTRDsignals[i][j] = 0;
477 }
478 fTRDTimBin[i] = 0;
9559cbc4 479 }
480 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
481 fTRDLabel = 0;
9559cbc4 482 fTRDQuality = 0;
23d49657 483 fTRDBudget = 0;
9559cbc4 484
485 // Reset TOF related track information
486 fTOFchi2 = 0;
487 fTOFindex = 0;
488 fTOFsignal = 0;
85324138 489 fTOFCalChannel = -1;
490 fTOFsignalToT = 0;
9559cbc4 491 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
492 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
493 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
494
f4b3bbb7 495 // Reset HMPID related track information
496 fHMPIDchi2 = 0;
497 fHMPIDqn = -1;
498 fHMPIDcluIdx = -1;
499 fHMPIDsignal = 0;
500 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
501 fHMPIDtrkTheta = -1;
502 fHMPIDtrkPhi = -1;
503 fHMPIDtrkX = -1;
504 fHMPIDtrkY = -1;
505 fHMPIDmipX = -1;
506 fHMPIDmipY = -1;
2e1dcd14 507 fEMCALindex = kEMCALNoMatch;
9559cbc4 508
15e85efa 509 delete fFriendTrack; fFriendTrack = 0;
9559cbc4 510}
ae982df3 511//_______________________________________________________________________
4a78b8c5 512Double_t AliESDtrack::GetMass() const {
4427806c 513 // Returns the mass of the most probable particle type
ae982df3 514 Float_t max=0.;
515 Int_t k=-1;
304864ab 516 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
ae982df3 517 if (fR[i]>max) {k=i; max=fR[i];}
518 }
db3989b3 519 if (k==0) { // dE/dx "crossing points" in the TPC
520 Double_t p=GetP();
521 if ((p>0.38)&&(p<0.48))
304864ab 522 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
db3989b3 523 if ((p>0.75)&&(p<0.85))
304864ab 524 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
db3989b3 525 return 0.00051;
526 }
304864ab 527 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
528 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
529 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
530 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
5f7789fc 531 AliWarning("Undefined mass !");
304864ab 532 return AliPID::ParticleMass(AliPID::kPion);
ae982df3 533}
534
535//_______________________________________________________________________
c9ec41e8 536Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
ae982df3 537 //
538 // This function updates track's running parameters
539 //
15e85efa 540 Int_t *index=0;
15614b8b 541 Bool_t rc=kTRUE;
542
9b859005 543 SetStatus(flags);
544 fLabel=t->GetLabel();
545
546 if (t->IsStartedTimeIntegral()) {
547 SetStatus(kTIME);
548 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
549 SetIntegratedLength(t->GetIntegratedLength());
550 }
551
6c94f330 552 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
e1d4c1b5 553
ae982df3 554 switch (flags) {
ad2f1f2b 555
9b859005 556 case kITSin: case kITSout: case kITSrefit:
ae982df3 557 fITSncls=t->GetNumberOfClusters();
62665e7f 558 index=fFriendTrack->GetITSindices();
559 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
560 index[i]=t->GetClusterIndex(i);
561 if (i<fITSncls) {
562 Int_t l=(index[i] & 0xf0000000) >> 28;
563 SETBIT(fITSClusterMap,l);
564 }
565 }
ae982df3 566 fITSchi2=t->GetChi2();
ae982df3 567 fITSsignal=t->GetPIDsignal();
6e5b1b04 568 fITSLabel = t->GetLabel();
ae982df3 569 break;
ad2f1f2b 570
9b859005 571 case kTPCin: case kTPCrefit:
6e5b1b04 572 fTPCLabel = t->GetLabel();
c9ec41e8 573 if (!fIp) fIp=new AliExternalTrackParam(*t);
6c94f330 574 else
575 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
9b859005 576 case kTPCout:
15e85efa 577 index=fFriendTrack->GetTPCindices();
1d303a24 578 if (flags & kTPCout){
579 if (!fOp) fOp=new AliExternalTrackParam(*t);
6c94f330 580 else
581 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1d303a24 582 }
e1d4c1b5 583 fTPCncls=t->GetNumberOfClusters();
ae982df3 584 fTPCchi2=t->GetChi2();
a866ac60 585
586 {//prevrow must be declared in separate namespace, otherwise compiler cries:
587 //"jump to case label crosses initialization of `Int_t prevrow'"
588 Int_t prevrow = -1;
6e5b1b04 589 // for (Int_t i=0;i<fTPCncls;i++)
15e85efa 590 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
a866ac60 591 {
15e85efa 592 index[i]=t->GetClusterIndex(i);
593 Int_t idx = index[i];
a866ac60 594
15e85efa 595 if (idx<0) continue;
9fe5b2ff 596
a866ac60 597 // Piotr's Cluster Map for HBT
598 // ### please change accordingly if cluster array is changing
599 // to "New TPC Tracking" style (with gaps in array)
a866ac60 600 Int_t sect = (idx&0xff000000)>>24;
601 Int_t row = (idx&0x00ff0000)>>16;
602 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
603
604 fTPCClusterMap.SetBitNumber(row,kTRUE);
605
606 //Fill the gap between previous row and this row with 0 bits
607 //In case ### pleas change it as well - just set bit 0 in case there
608 //is no associated clusters for current "i"
609 if (prevrow < 0)
610 {
611 prevrow = row;//if previous bit was not assigned yet == this is the first one
612 }
613 else
614 { //we don't know the order (inner to outer or reverse)
615 //just to be save in case it is going to change
616 Int_t n = 0, m = 0;
617 if (prevrow < row)
618 {
619 n = prevrow;
620 m = row;
621 }
622 else
623 {
624 n = row;
625 m = prevrow;
626 }
627
628 for (Int_t j = n+1; j < m; j++)
629 {
630 fTPCClusterMap.SetBitNumber(j,kFALSE);
631 }
632 prevrow = row;
633 }
634 // End Of Piotr's Cluster Map for HBT
635 }
636 }
ae982df3 637 fTPCsignal=t->GetPIDsignal();
ae982df3 638 break;
9b859005 639
23904d16 640 case kTRDout: case kTRDin: case kTRDrefit:
15e85efa 641 index=fFriendTrack->GetTRDindices();
51ad6848 642 fTRDLabel = t->GetLabel();
79e94bf8 643 fTRDncls=t->GetNumberOfClusters();
644 fTRDchi2=t->GetChi2();
15e85efa 645 for (Int_t i=0;i<fTRDncls;i++) index[i]=t->GetClusterIndex(i);
79e94bf8 646 fTRDsignal=t->GetPIDsignal();
647 break;
c4d11b15 648 case kTRDbackup:
c9ec41e8 649 if (!fOp) fOp=new AliExternalTrackParam(*t);
6c94f330 650 else
651 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
c4d11b15 652 fTRDncls0 = t->GetNumberOfClusters();
653 break;
654 case kTOFin:
655 break;
656 case kTOFout:
657 break;
d0862fea 658 case kTRDStop:
659 break;
ae982df3 660 default:
5f7789fc 661 AliError("Wrong flag !");
ae982df3 662 return kFALSE;
663 }
664
15614b8b 665 return rc;
ae982df3 666}
667
668//_______________________________________________________________________
669void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
670 //---------------------------------------------------------------------
671 // This function returns external representation of the track parameters
672 //---------------------------------------------------------------------
c9ec41e8 673 x=GetX();
674 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
15614b8b 675}
676
67c3dcbe 677//_______________________________________________________________________
a866ac60 678void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
67c3dcbe 679 //---------------------------------------------------------------------
680 // This function returns external representation of the cov. matrix
681 //---------------------------------------------------------------------
c9ec41e8 682 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
67c3dcbe 683}
684
67c3dcbe 685//_______________________________________________________________________
c0b978f0 686Bool_t AliESDtrack::GetConstrainedExternalParameters
687 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
67c3dcbe 688 //---------------------------------------------------------------------
689 // This function returns the constrained external track parameters
690 //---------------------------------------------------------------------
c0b978f0 691 if (!fCp) return kFALSE;
692 alpha=fCp->GetAlpha();
c9ec41e8 693 x=fCp->GetX();
694 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
c0b978f0 695 return kTRUE;
67c3dcbe 696}
c9ec41e8 697
67c3dcbe 698//_______________________________________________________________________
c0b978f0 699Bool_t
67c3dcbe 700AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
701 //---------------------------------------------------------------------
702 // This function returns the constrained external cov. matrix
703 //---------------------------------------------------------------------
c0b978f0 704 if (!fCp) return kFALSE;
c9ec41e8 705 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
c0b978f0 706 return kTRUE;
67c3dcbe 707}
708
c0b978f0 709Bool_t
710AliESDtrack::GetInnerExternalParameters
711 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
712 //---------------------------------------------------------------------
c9ec41e8 713 // This function returns external representation of the track parameters
714 // at the inner layer of TPC
9b859005 715 //---------------------------------------------------------------------
c0b978f0 716 if (!fIp) return kFALSE;
717 alpha=fIp->GetAlpha();
c9ec41e8 718 x=fIp->GetX();
719 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
c0b978f0 720 return kTRUE;
9b859005 721}
722
c0b978f0 723Bool_t
724AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
c9ec41e8 725 //---------------------------------------------------------------------
726 // This function returns external representation of the cov. matrix
727 // at the inner layer of TPC
728 //---------------------------------------------------------------------
c0b978f0 729 if (!fIp) return kFALSE;
c9ec41e8 730 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
c0b978f0 731 return kTRUE;
9b859005 732}
733
c0b978f0 734Bool_t
735AliESDtrack::GetOuterExternalParameters
736 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
737 //---------------------------------------------------------------------
c9ec41e8 738 // This function returns external representation of the track parameters
739 // at the inner layer of TRD
a866ac60 740 //---------------------------------------------------------------------
c0b978f0 741 if (!fOp) return kFALSE;
742 alpha=fOp->GetAlpha();
c9ec41e8 743 x=fOp->GetX();
744 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
c0b978f0 745 return kTRUE;
a866ac60 746}
c9ec41e8 747
c0b978f0 748Bool_t
749AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
a866ac60 750 //---------------------------------------------------------------------
c9ec41e8 751 // This function returns external representation of the cov. matrix
752 // at the inner layer of TRD
a866ac60 753 //---------------------------------------------------------------------
c0b978f0 754 if (!fOp) return kFALSE;
c9ec41e8 755 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
c0b978f0 756 return kTRUE;
a866ac60 757}
758
98937d93 759Int_t AliESDtrack::GetNcls(Int_t idet) const
760{
761 // Get number of clusters by subdetector index
762 //
763 Int_t ncls = 0;
764 switch(idet){
765 case 0:
766 ncls = fITSncls;
767 break;
768 case 1:
769 ncls = fTPCncls;
770 break;
771 case 2:
772 ncls = fTRDncls;
773 break;
774 case 3:
775 if (fTOFindex != 0)
776 ncls = 1;
777 break;
778 default:
779 break;
780 }
781 return ncls;
782}
783
ef7253ac 784Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
98937d93 785{
786 // Get cluster index array by subdetector index
787 //
788 Int_t ncls = 0;
789 switch(idet){
790 case 0:
791 ncls = GetITSclusters(idx);
792 break;
793 case 1:
ef7253ac 794 ncls = GetTPCclusters(idx);
98937d93 795 break;
796 case 2:
797 ncls = GetTRDclusters(idx);
798 break;
799 case 3:
800 if (fTOFindex != 0) {
801 idx[0] = GetTOFcluster();
802 ncls = 1;
803 }
804 break;
805 default:
806 break;
807 }
808 return ncls;
809}
810
ae982df3 811//_______________________________________________________________________
812void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
4427806c 813 // Returns the array with integrated times for each particle hypothesis
304864ab 814 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
ae982df3 815}
816
817//_______________________________________________________________________
818void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
4427806c 819 // Sets the array with integrated times for each particle hypotesis
304864ab 820 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
ae982df3 821}
822
c630aafd 823//_______________________________________________________________________
4427806c 824void AliESDtrack::SetITSpid(const Double_t *p) {
825 // Sets values for the probability of each particle type (in ITS)
d27bbc79 826 SetPIDValues(fITSr,p,AliPID::kSPECIES);
c630aafd 827 SetStatus(AliESDtrack::kITSpid);
828}
829
830//_______________________________________________________________________
831void AliESDtrack::GetITSpid(Double_t *p) const {
4427806c 832 // Gets the probability of each particle type (in ITS)
304864ab 833 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
c630aafd 834}
835
ae982df3 836//_______________________________________________________________________
ef7253ac 837Int_t AliESDtrack::GetITSclusters(Int_t *idx) const {
ae982df3 838 //---------------------------------------------------------------------
839 // This function returns indices of the assgined ITS clusters
840 //---------------------------------------------------------------------
15e85efa 841 if (idx!=0) {
842 Int_t *index=fFriendTrack->GetITSindices();
843 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) idx[i]=index[i];
844 }
ae982df3 845 return fITSncls;
846}
847
848//_______________________________________________________________________
05e445cd 849Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
ae982df3 850 //---------------------------------------------------------------------
851 // This function returns indices of the assgined ITS clusters
852 //---------------------------------------------------------------------
15e85efa 853 if (idx!=0) {
854 Int_t *index=fFriendTrack->GetTPCindices();
855 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
856 }
ae982df3 857 return fTPCncls;
858}
8c6a71ab 859
81e97e0d 860Float_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
861 //
862 // GetDensity of the clusters on given region between row0 and row1
863 // Dead zone effect takin into acoount
864 //
865 Int_t good = 0;
866 Int_t found = 0;
867 //
15e85efa 868 Int_t *index=fFriendTrack->GetTPCindices();
81e97e0d 869 for (Int_t i=row0;i<=row1;i++){
15e85efa 870 Int_t idx = index[i];
871 if (idx!=-1) good++; // track outside of dead zone
872 if (idx>0) found++;
81e97e0d 873 }
874 Float_t density=0.5;
875 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
876 return density;
877}
c84a5e9e 878
8c6a71ab 879//_______________________________________________________________________
880void AliESDtrack::SetTPCpid(const Double_t *p) {
4427806c 881 // Sets values for the probability of each particle type (in TPC)
d27bbc79 882 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
8c6a71ab 883 SetStatus(AliESDtrack::kTPCpid);
884}
885
886//_______________________________________________________________________
887void AliESDtrack::GetTPCpid(Double_t *p) const {
4427806c 888 // Gets the probability of each particle type (in TPC)
304864ab 889 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
8c6a71ab 890}
891
bb2ceb1f 892//_______________________________________________________________________
ef7253ac 893Int_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
bb2ceb1f 894 //---------------------------------------------------------------------
895 // This function returns indices of the assgined TRD clusters
896 //---------------------------------------------------------------------
15e85efa 897 if (idx!=0) {
898 Int_t *index=fFriendTrack->GetTRDindices();
899 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
900 }
bb2ceb1f 901 return fTRDncls;
902}
903
c630aafd 904//_______________________________________________________________________
905void AliESDtrack::SetTRDpid(const Double_t *p) {
4427806c 906 // Sets values for the probability of each particle type (in TRD)
d27bbc79 907 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
c630aafd 908 SetStatus(AliESDtrack::kTRDpid);
909}
910
911//_______________________________________________________________________
912void AliESDtrack::GetTRDpid(Double_t *p) const {
4427806c 913 // Gets the probability of each particle type (in TRD)
304864ab 914 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
c630aafd 915}
916
79e94bf8 917//_______________________________________________________________________
918void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
919{
4427806c 920 // Sets the probability of particle type iSpecies to p (in TRD)
79e94bf8 921 fTRDr[iSpecies] = p;
922}
923
924Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
925{
4427806c 926 // Returns the probability of particle type iSpecies (in TRD)
79e94bf8 927 return fTRDr[iSpecies];
928}
929
c630aafd 930//_______________________________________________________________________
931void AliESDtrack::SetTOFpid(const Double_t *p) {
4427806c 932 // Sets the probability of each particle type (in TOF)
d27bbc79 933 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
c630aafd 934 SetStatus(AliESDtrack::kTOFpid);
935}
936
51ad6848 937//_______________________________________________________________________
938void AliESDtrack::SetTOFLabel(const Int_t *p) {
939 // Sets (in TOF)
940 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
941}
942
c630aafd 943//_______________________________________________________________________
944void AliESDtrack::GetTOFpid(Double_t *p) const {
4427806c 945 // Gets probabilities of each particle type (in TOF)
304864ab 946 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
c630aafd 947}
948
51ad6848 949//_______________________________________________________________________
950void AliESDtrack::GetTOFLabel(Int_t *p) const {
951 // Gets (in TOF)
952 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
953}
954
955//_______________________________________________________________________
956void AliESDtrack::GetTOFInfo(Float_t *info) const {
957 // Gets (in TOF)
958 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
959}
960
961//_______________________________________________________________________
962void AliESDtrack::SetTOFInfo(Float_t*info) {
963 // Gets (in TOF)
964 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
965}
966
4a78b8c5 967
968
4a78b8c5 969//_______________________________________________________________________
f4b3bbb7 970void AliESDtrack::SetHMPIDpid(const Double_t *p) {
971 // Sets the probability of each particle type (in HMPID)
972 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
973 SetStatus(AliESDtrack::kHMPIDpid);
4a78b8c5 974}
975
976//_______________________________________________________________________
f4b3bbb7 977void AliESDtrack::GetHMPIDpid(Double_t *p) const {
978 // Gets probabilities of each particle type (in HMPID)
979 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
4a78b8c5 980}
981
982
983
8c6a71ab 984//_______________________________________________________________________
985void AliESDtrack::SetESDpid(const Double_t *p) {
4427806c 986 // Sets the probability of each particle type for the ESD track
d27bbc79 987 SetPIDValues(fR,p,AliPID::kSPECIES);
8c6a71ab 988 SetStatus(AliESDtrack::kESDpid);
989}
990
991//_______________________________________________________________________
992void AliESDtrack::GetESDpid(Double_t *p) const {
4427806c 993 // Gets probability of each particle type for the ESD track
304864ab 994 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
8c6a71ab 995}
996
49d13e89 997//_______________________________________________________________________
998Bool_t AliESDtrack::RelateToVertex
999(const AliESDVertex *vtx, Double_t b, Double_t maxd) {
1000 //
1001 // Try to relate this track to the vertex "vtx",
1002 // if the (rough) transverse impact parameter is not bigger then "maxd".
1003 // Magnetic field is "b" (kG).
1004 //
1005 // a) The track gets extapolated to the DCA to the vertex.
1006 // b) The impact parameters and their covariance matrix are calculated.
1007 // c) An attempt to constrain this track to the vertex is done.
1008 //
1009 // In the case of success, the returned value is kTRUE
1010 // (otherwise, it's kFALSE)
1011 //
b5d34a4c 1012
1013 if (!vtx) return kFALSE;
1014
49d13e89 1015 Double_t alpha=GetAlpha();
1016 Double_t sn=TMath::Sin(alpha), cs=TMath::Cos(alpha);
1017 Double_t x=GetX(), y=GetParameter()[0], snp=GetParameter()[2];
1018 Double_t xv= vtx->GetXv()*cs + vtx->GetYv()*sn;
1019 Double_t yv=-vtx->GetXv()*sn + vtx->GetYv()*cs, zv=vtx->GetZv();
1020 x-=xv; y-=yv;
1021
1022 //Estimate the impact parameter neglecting the track curvature
1023 Double_t d=TMath::Abs(x*snp - y*TMath::Sqrt(1.- snp*snp));
1024 if (d > maxd) return kFALSE;
1025
1026 //Propagate to the DCA
5773defd 1027 Double_t crv=kB2C*b*GetParameter()[4];
1028 if (TMath::Abs(b) < kAlmost0Field) crv=0.;
1029
49d13e89 1030 Double_t tgfv=-(crv*x - snp)/(crv*y + TMath::Sqrt(1.-snp*snp));
f54395bf 1031 sn=tgfv/TMath::Sqrt(1.+ tgfv*tgfv);
1032 if (TMath::Abs(tgfv)>0.) cs = sn/tgfv;
1033 else cs=1.;
49d13e89 1034
1035 x = xv*cs + yv*sn;
1036 yv=-xv*sn + yv*cs; xv=x;
1037
1038 if (!Propagate(alpha+TMath::ASin(sn),xv,b)) return kFALSE;
1039
1040 fD = GetParameter()[0] - yv;
1041 fZ = GetParameter()[1] - zv;
1042
1043 Double_t cov[6]; vtx->GetCovMatrix(cov);
3231f9e5 1044
1045 //***** Improvements by A.Dainese
1046 alpha=GetAlpha(); sn=TMath::Sin(alpha); cs=TMath::Cos(alpha);
1047 Double_t s2ylocvtx = cov[0]*sn*sn + cov[2]*cs*cs - 2.*cov[1]*cs*sn;
1048 fCdd = GetCovariance()[0] + s2ylocvtx; // neglecting correlations
b67517ef 1049 fCdz = GetCovariance()[1]; // between (x,y) and z
3231f9e5 1050 fCzz = GetCovariance()[2] + cov[5]; // in vertex's covariance matrix
1051 //*****
49d13e89 1052
1053 {//Try to constrain
1054 Double_t p[2]={yv,zv}, c[3]={cov[2],0.,cov[5]};
1055 Double_t chi2=GetPredictedChi2(p,c);
1056
1057 if (chi2>77.) return kFALSE;
1058
1059 AliExternalTrackParam tmp(*this);
1060 if (!tmp.Update(p,c)) return kFALSE;
1061
1062 fCchi2=chi2;
1063 if (!fCp) fCp=new AliExternalTrackParam();
1064 new (fCp) AliExternalTrackParam(tmp);
1065 }
1066
1067 return kTRUE;
1068}
1069
ac2f7574 1070//_______________________________________________________________________
1071void AliESDtrack::Print(Option_t *) const {
1072 // Prints info on the track
1073
5f7789fc 1074 printf("ESD track info\n") ;
304864ab 1075 Double_t p[AliPID::kSPECIESN] ;
ac2f7574 1076 Int_t index = 0 ;
1077 if( IsOn(kITSpid) ){
1078 printf("From ITS: ") ;
1079 GetITSpid(p) ;
304864ab 1080 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 1081 printf("%f, ", p[index]) ;
1082 printf("\n signal = %f\n", GetITSsignal()) ;
1083 }
1084 if( IsOn(kTPCpid) ){
1085 printf("From TPC: ") ;
1086 GetTPCpid(p) ;
304864ab 1087 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 1088 printf("%f, ", p[index]) ;
1089 printf("\n signal = %f\n", GetTPCsignal()) ;
1090 }
1091 if( IsOn(kTRDpid) ){
1092 printf("From TRD: ") ;
1093 GetTRDpid(p) ;
304864ab 1094 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 1095 printf("%f, ", p[index]) ;
1096 printf("\n signal = %f\n", GetTRDsignal()) ;
1097 }
1098 if( IsOn(kTOFpid) ){
1099 printf("From TOF: ") ;
1100 GetTOFpid(p) ;
304864ab 1101 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 1102 printf("%f, ", p[index]) ;
1103 printf("\n signal = %f\n", GetTOFsignal()) ;
1104 }
f4b3bbb7 1105 if( IsOn(kHMPIDpid) ){
1106 printf("From HMPID: ") ;
1107 GetHMPIDpid(p) ;
304864ab 1108 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 1109 printf("%f, ", p[index]) ;
f4b3bbb7 1110 printf("\n signal = %f\n", GetHMPIDsignal()) ;
ac2f7574 1111 }
ac2f7574 1112}
6c94f330 1113
1114Bool_t AliESDtrack::PropagateTo(Double_t xToGo, Double_t b, Double_t mass,
1115Double_t maxStep, Bool_t rotateTo, Double_t maxSnp){
1116 //----------------------------------------------------------------
1117 //
1118 // MI's function
1119 //
1120 // Propagates this track to the plane X=xk (cm)
1121 // in the magnetic field "b" (kG),
1122 // the correction for the material is included
1123 //
1124 // mass - mass used in propagation - used for energy loss correction
1125 // maxStep - maximal step for propagation
1126 //----------------------------------------------------------------
1127 const Double_t kEpsilon = 0.00001;
1128 Double_t xpos = GetX();
1129 Double_t dir = (xpos<xToGo) ? 1.:-1.;
1130 //
1131 while ( (xToGo-xpos)*dir > kEpsilon){
1132 Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
1133 Double_t x = xpos+step;
1134 Double_t xyz0[3],xyz1[3],param[7];
1135 GetXYZ(xyz0); //starting global position
1136 if (!GetXYZAt(x,b,xyz1)) return kFALSE; // no prolongation
1137 xyz1[2]+=kEpsilon; // waiting for bug correction in geo
1138 AliKalmanTrack::MeanMaterialBudget(xyz0,xyz1,param);
1139 if (TMath::Abs(GetSnpAt(x,b)) >= maxSnp) return kFALSE;
1140 if (!AliExternalTrackParam::PropagateTo(x,b)) return kFALSE;
1141
1142 Double_t rho=param[0],x0=param[1],distance=param[4];
1143 Double_t d=distance*rho/x0;
1144
1145 if (!CorrectForMaterial(d,x0,mass)) return kFALSE;
1146 if (rotateTo){
1147 if (TMath::Abs(GetSnp()) >= maxSnp) return kFALSE;
1148 GetXYZ(xyz0); // global position
1149 Double_t alphan = TMath::ATan2(xyz0[1], xyz0[0]);
1150 //
1151 Double_t ca=TMath::Cos(alphan-GetAlpha()),
1152 sa=TMath::Sin(alphan-GetAlpha());
1153 Double_t sf=GetSnp(), cf=TMath::Sqrt(1.- sf*sf);
1154 Double_t sinNew = sf*ca - cf*sa;
1155 if (TMath::Abs(sinNew) >= maxSnp) return kFALSE;
1156 if (!Rotate(alphan)) return kFALSE;
1157 }
1158 xpos = GetX();
1159 }
1160 return kTRUE;
1161}