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