Truncate Z vertex at 3 sigma (was at one sigma)
[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
23#include "TMath.h"
24
49d13e89 25#include "AliESDVertex.h"
ae982df3 26#include "AliESDtrack.h"
15e85efa 27#include "AliESDfriendTrack.h"
ae982df3 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),
77 fITSsignal(0),
78 fITSLabel(0),
79 fITSFakeRatio(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),
90e48c0c 100 fRICHchi2(1e10),
101 fRICHncls(0),
102 fRICHindex(0),
103 fRICHsignal(-1),
2714766e 104 fRICHtheta(-1),
105 fRICHphi(-1),
106 fRICHdx(-1),
107 fRICHdy(-1),
108 fRICHmipX(-1),
109 fRICHmipY(-1),
15e85efa 110 fPoints(0),
111 fFriendTrack(new AliESDfriendTrack())
ae982df3 112{
113 //
114 // The default ESD constructor
115 //
6238d7a9 116 Int_t i;
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.;
4a78b8c5 124 fRICHr[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;}
eab5961e 129 for (i=0;i<kNPlane;i++) {fTRDsignals[i]=0.; fTRDTimBin[i]=-1;}
c9ec41e8 130 for (i=0;i<4;i++) {fTPCPoints[i]=-1;}
131 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
132 for (i=0;i<10;i++) {fTOFInfo[i]=-1;}
c4d11b15 133}
134
135//_______________________________________________________________________
90e48c0c 136AliESDtrack::AliESDtrack(const AliESDtrack& track):
c9ec41e8 137 AliExternalTrackParam(track),
90e48c0c 138 fFlags(track.fFlags),
139 fLabel(track.fLabel),
140 fID(track.fID),
141 fTrackLength(track.fTrackLength),
49d13e89 142 fD(track.fD),fZ(track.fZ),
143 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
90e48c0c 144 fStopVertex(track.fStopVertex),
c9ec41e8 145 fCp(0),
90e48c0c 146 fCchi2(track.fCchi2),
c9ec41e8 147 fIp(0),
148 fOp(0),
90e48c0c 149 fITSchi2(track.fITSchi2),
150 fITSncls(track.fITSncls),
151 fITSsignal(track.fITSsignal),
152 fITSLabel(track.fITSLabel),
153 fITSFakeRatio(track.fITSFakeRatio),
90e48c0c 154 fTPCchi2(track.fTPCchi2),
155 fTPCncls(track.fTPCncls),
e1d4c1b5 156 fTPCnclsF(track.fTPCnclsF),
90e48c0c 157 fTPCClusterMap(track.fTPCClusterMap),
158 fTPCsignal(track.fTPCsignal),
e1d4c1b5 159 fTPCsignalN(track.fTPCsignalN),
160 fTPCsignalS(track.fTPCsignalS),
90e48c0c 161 fTPCLabel(track.fTPCLabel),
162 fTRDchi2(track.fTRDchi2),
163 fTRDncls(track.fTRDncls),
164 fTRDncls0(track.fTRDncls0),
165 fTRDsignal(track.fTRDsignal),
166 fTRDLabel(track.fTRDLabel),
167 fTRDQuality(track.fTRDQuality),
23d49657 168 fTRDBudget(track.fTRDBudget),
90e48c0c 169 fTOFchi2(track.fTOFchi2),
170 fTOFindex(track.fTOFindex),
85324138 171 fTOFCalChannel(track.fTOFCalChannel),
90e48c0c 172 fTOFsignal(track.fTOFsignal),
85324138 173 fTOFsignalToT(track.fTOFsignalToT),
90e48c0c 174 fRICHchi2(track.fRICHchi2),
175 fRICHncls(track.fRICHncls),
176 fRICHindex(track.fRICHindex),
177 fRICHsignal(track.fRICHsignal),
178 fRICHtheta(track.fRICHtheta),
179 fRICHphi(track.fRICHphi),
180 fRICHdx(track.fRICHdx),
6238d7a9 181 fRICHdy(track.fRICHdy),
182 fRICHmipX(track.fRICHmipX),
15e85efa 183 fRICHmipY(track.fRICHmipY),
184 fPoints(0),
185 fFriendTrack(new AliESDfriendTrack(*(track.fFriendTrack)))
90e48c0c 186{
c4d11b15 187 //
188 //copy constructor
189 //
ef7253ac 190 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
191 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
c4d11b15 192 //
304864ab 193 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
c4d11b15 194 //
304864ab 195 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
51ad6848 196 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
197 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
198 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
c4d11b15 199 //
eab5961e 200 for (Int_t i=0;i<kNPlane;i++) {
201 fTRDsignals[i]=track.fTRDsignals[i];
202 fTRDTimBin[i]=track.fTRDTimBin[i];
203 }
304864ab 204 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
304864ab 205 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
51ad6848 206 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
207 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
304864ab 208 for (Int_t i=0;i<AliPID::kSPECIES;i++) fRICHr[i]=track.fRICHr[i];
c9ec41e8 209
210 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
211 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
212 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
15e85efa 213
214 if (track.fPoints) fPoints=new AliTrackPointArray(*(track.fPoints));
ae982df3 215}
15e85efa 216
c4d11b15 217//_______________________________________________________________________
218AliESDtrack::~AliESDtrack(){
219 //
220 // This is destructor according Coding Conventrions
221 //
222 //printf("Delete track\n");
c9ec41e8 223 delete fIp;
224 delete fOp;
225 delete fCp;
15e85efa 226 delete fFriendTrack;
98937d93 227 delete fPoints;
c4d11b15 228}
ae982df3 229
230//_______________________________________________________________________
9559cbc4 231void AliESDtrack::MakeMiniESDtrack(){
232 // Resets everything except
233 // fFlags: Reconstruction status flags
234 // fLabel: Track label
235 // fID: Unique ID of the track
236 // fD: Impact parameter in XY-plane
237 // fZ: Impact parameter in Z
238 // fR[AliPID::kSPECIES]: combined "detector response probability"
239 // Running track parameters
240 // fRalpha: track rotation angle
241 // fRx: X-coordinate of the track reference plane
242 // fRp[5]: external track parameters
243 // fRc[15]: external cov. matrix of the track parameters
244
245 fTrackLength = 0;
246 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
247 fStopVertex = 0;
248
249 // Reset track parameters constrained to the primary vertex
c9ec41e8 250 fCp = 0;
9559cbc4 251 fCchi2 = 0;
252
253 // Reset track parameters at the inner wall of TPC
c9ec41e8 254 fIp = 0;
9559cbc4 255
256 // Reset track parameters at the inner wall of the TRD
c9ec41e8 257 fOp = 0;
9559cbc4 258
259 // Reset ITS track related information
260 fITSchi2 = 0;
9559cbc4 261 fITSncls = 0;
9559cbc4 262 fITSsignal = 0;
ef7253ac 263 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
9559cbc4 264 fITSLabel = 0;
265 fITSFakeRatio = 0;
9559cbc4 266
267 // Reset TPC related track information
268 fTPCchi2 = 0;
269 fTPCncls = 0;
e1d4c1b5 270 fTPCnclsF = 0;
9559cbc4 271 fTPCClusterMap = 0;
272 fTPCsignal= 0;
e1d4c1b5 273 fTPCsignalS= 0;
274 fTPCsignalN= 0;
9559cbc4 275 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
276 fTPCLabel=0;
277 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
278 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
279 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
280
281 // Reset TRD related track information
282 fTRDchi2 = 0;
283 fTRDncls = 0;
284 fTRDncls0 = 0;
9559cbc4 285 fTRDsignal = 0;
286 for (Int_t i=0;i<kNPlane;i++) {
287 fTRDsignals[i] = 0;
288 fTRDTimBin[i] = 0;
289 }
290 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
291 fTRDLabel = 0;
9559cbc4 292 fTRDQuality = 0;
23d49657 293 fTRDBudget = 0;
9559cbc4 294
295 // Reset TOF related track information
296 fTOFchi2 = 0;
297 fTOFindex = 0;
298 fTOFsignal = 0;
85324138 299 fTOFCalChannel = -1;
300 fTOFsignalToT = 0;
9559cbc4 301 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
302 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
303 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
304
9559cbc4 305 // Reset RICH related track information
306 fRICHchi2 = 0;
307 fRICHncls = 0;
308 fRICHindex = 0;
309 fRICHsignal = 0;
310 for (Int_t i=0;i<AliPID::kSPECIES;i++) fRICHr[i] = 0;
311 fRICHtheta = 0;
312 fRICHphi = 0;
313 fRICHdx = 0;
314 fRICHdy = 0;
315
15e85efa 316 delete fFriendTrack; fFriendTrack = 0;
317 delete fPoints; fPoints = 0;
9559cbc4 318}
319//_______________________________________________________________________
4a78b8c5 320Double_t AliESDtrack::GetMass() const {
4427806c 321 // Returns the mass of the most probable particle type
ae982df3 322 Float_t max=0.;
323 Int_t k=-1;
304864ab 324 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
ae982df3 325 if (fR[i]>max) {k=i; max=fR[i];}
326 }
db3989b3 327 if (k==0) { // dE/dx "crossing points" in the TPC
328 Double_t p=GetP();
329 if ((p>0.38)&&(p<0.48))
304864ab 330 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
db3989b3 331 if ((p>0.75)&&(p<0.85))
304864ab 332 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
db3989b3 333 return 0.00051;
334 }
304864ab 335 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
336 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
337 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
338 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
5f7789fc 339 AliWarning("Undefined mass !");
304864ab 340 return AliPID::ParticleMass(AliPID::kPion);
ae982df3 341}
342
343//_______________________________________________________________________
c9ec41e8 344Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
ae982df3 345 //
346 // This function updates track's running parameters
347 //
15e85efa 348 Int_t *index=0;
15614b8b 349 Bool_t rc=kTRUE;
350
9b859005 351 SetStatus(flags);
352 fLabel=t->GetLabel();
353
354 if (t->IsStartedTimeIntegral()) {
355 SetStatus(kTIME);
356 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
357 SetIntegratedLength(t->GetIntegratedLength());
358 }
359
c9ec41e8 360 Set(*t);
e1d4c1b5 361
ae982df3 362 switch (flags) {
ad2f1f2b 363
9b859005 364 case kITSin: case kITSout: case kITSrefit:
15e85efa 365 index=fFriendTrack->GetITSindices();
366 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++)
367 index[i]=t->GetClusterIndex(i);
ae982df3 368 fITSncls=t->GetNumberOfClusters();
369 fITSchi2=t->GetChi2();
ae982df3 370 fITSsignal=t->GetPIDsignal();
6e5b1b04 371 fITSLabel = t->GetLabel();
babd135a 372 fITSFakeRatio = t->GetFakeRatio();
ae982df3 373 break;
ad2f1f2b 374
9b859005 375 case kTPCin: case kTPCrefit:
6e5b1b04 376 fTPCLabel = t->GetLabel();
c9ec41e8 377 if (!fIp) fIp=new AliExternalTrackParam(*t);
378 else fIp->Set(*t);
9b859005 379 case kTPCout:
15e85efa 380 index=fFriendTrack->GetTPCindices();
1d303a24 381 if (flags & kTPCout){
382 if (!fOp) fOp=new AliExternalTrackParam(*t);
383 else fOp->Set(*t);
384 }
e1d4c1b5 385 fTPCncls=t->GetNumberOfClusters();
ae982df3 386 fTPCchi2=t->GetChi2();
a866ac60 387
388 {//prevrow must be declared in separate namespace, otherwise compiler cries:
389 //"jump to case label crosses initialization of `Int_t prevrow'"
390 Int_t prevrow = -1;
6e5b1b04 391 // for (Int_t i=0;i<fTPCncls;i++)
15e85efa 392 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
a866ac60 393 {
15e85efa 394 index[i]=t->GetClusterIndex(i);
395 Int_t idx = index[i];
a866ac60 396
15e85efa 397 if (idx<0) continue;
9fe5b2ff 398
a866ac60 399 // Piotr's Cluster Map for HBT
400 // ### please change accordingly if cluster array is changing
401 // to "New TPC Tracking" style (with gaps in array)
a866ac60 402 Int_t sect = (idx&0xff000000)>>24;
403 Int_t row = (idx&0x00ff0000)>>16;
404 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
405
406 fTPCClusterMap.SetBitNumber(row,kTRUE);
407
408 //Fill the gap between previous row and this row with 0 bits
409 //In case ### pleas change it as well - just set bit 0 in case there
410 //is no associated clusters for current "i"
411 if (prevrow < 0)
412 {
413 prevrow = row;//if previous bit was not assigned yet == this is the first one
414 }
415 else
416 { //we don't know the order (inner to outer or reverse)
417 //just to be save in case it is going to change
418 Int_t n = 0, m = 0;
419 if (prevrow < row)
420 {
421 n = prevrow;
422 m = row;
423 }
424 else
425 {
426 n = row;
427 m = prevrow;
428 }
429
430 for (Int_t j = n+1; j < m; j++)
431 {
432 fTPCClusterMap.SetBitNumber(j,kFALSE);
433 }
434 prevrow = row;
435 }
436 // End Of Piotr's Cluster Map for HBT
437 }
438 }
ae982df3 439 fTPCsignal=t->GetPIDsignal();
ae982df3 440 break;
9b859005 441
23904d16 442 case kTRDout: case kTRDin: case kTRDrefit:
15e85efa 443 index=fFriendTrack->GetTRDindices();
51ad6848 444 fTRDLabel = t->GetLabel();
79e94bf8 445 fTRDncls=t->GetNumberOfClusters();
446 fTRDchi2=t->GetChi2();
15e85efa 447 for (Int_t i=0;i<fTRDncls;i++) index[i]=t->GetClusterIndex(i);
79e94bf8 448 fTRDsignal=t->GetPIDsignal();
449 break;
c4d11b15 450 case kTRDbackup:
c9ec41e8 451 if (!fOp) fOp=new AliExternalTrackParam(*t);
452 else fOp->Set(*t);
c4d11b15 453 fTRDncls0 = t->GetNumberOfClusters();
454 break;
455 case kTOFin:
456 break;
457 case kTOFout:
458 break;
d0862fea 459 case kTRDStop:
460 break;
ae982df3 461 default:
5f7789fc 462 AliError("Wrong flag !");
ae982df3 463 return kFALSE;
464 }
465
15614b8b 466 return rc;
ae982df3 467}
468
469//_______________________________________________________________________
470void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
471 //---------------------------------------------------------------------
472 // This function returns external representation of the track parameters
473 //---------------------------------------------------------------------
c9ec41e8 474 x=GetX();
475 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
15614b8b 476}
477
67c3dcbe 478//_______________________________________________________________________
a866ac60 479void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
67c3dcbe 480 //---------------------------------------------------------------------
481 // This function returns external representation of the cov. matrix
482 //---------------------------------------------------------------------
c9ec41e8 483 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
67c3dcbe 484}
485
67c3dcbe 486//_______________________________________________________________________
c0b978f0 487Bool_t AliESDtrack::GetConstrainedExternalParameters
488 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
67c3dcbe 489 //---------------------------------------------------------------------
490 // This function returns the constrained external track parameters
491 //---------------------------------------------------------------------
c0b978f0 492 if (!fCp) return kFALSE;
493 alpha=fCp->GetAlpha();
c9ec41e8 494 x=fCp->GetX();
495 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
c0b978f0 496 return kTRUE;
67c3dcbe 497}
c9ec41e8 498
67c3dcbe 499//_______________________________________________________________________
c0b978f0 500Bool_t
67c3dcbe 501AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
502 //---------------------------------------------------------------------
503 // This function returns the constrained external cov. matrix
504 //---------------------------------------------------------------------
c0b978f0 505 if (!fCp) return kFALSE;
c9ec41e8 506 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
c0b978f0 507 return kTRUE;
67c3dcbe 508}
509
c0b978f0 510Bool_t
511AliESDtrack::GetInnerExternalParameters
512 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
513 //---------------------------------------------------------------------
c9ec41e8 514 // This function returns external representation of the track parameters
515 // at the inner layer of TPC
9b859005 516 //---------------------------------------------------------------------
c0b978f0 517 if (!fIp) return kFALSE;
518 alpha=fIp->GetAlpha();
c9ec41e8 519 x=fIp->GetX();
520 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
c0b978f0 521 return kTRUE;
9b859005 522}
523
c0b978f0 524Bool_t
525AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
c9ec41e8 526 //---------------------------------------------------------------------
527 // This function returns external representation of the cov. matrix
528 // at the inner layer of TPC
529 //---------------------------------------------------------------------
c0b978f0 530 if (!fIp) return kFALSE;
c9ec41e8 531 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
c0b978f0 532 return kTRUE;
9b859005 533}
534
c0b978f0 535Bool_t
536AliESDtrack::GetOuterExternalParameters
537 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
538 //---------------------------------------------------------------------
c9ec41e8 539 // This function returns external representation of the track parameters
540 // at the inner layer of TRD
a866ac60 541 //---------------------------------------------------------------------
c0b978f0 542 if (!fOp) return kFALSE;
543 alpha=fOp->GetAlpha();
c9ec41e8 544 x=fOp->GetX();
545 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
c0b978f0 546 return kTRUE;
a866ac60 547}
c9ec41e8 548
c0b978f0 549Bool_t
550AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
a866ac60 551 //---------------------------------------------------------------------
c9ec41e8 552 // This function returns external representation of the cov. matrix
553 // at the inner layer of TRD
a866ac60 554 //---------------------------------------------------------------------
c0b978f0 555 if (!fOp) return kFALSE;
c9ec41e8 556 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
c0b978f0 557 return kTRUE;
a866ac60 558}
559
98937d93 560Int_t AliESDtrack::GetNcls(Int_t idet) const
561{
562 // Get number of clusters by subdetector index
563 //
564 Int_t ncls = 0;
565 switch(idet){
566 case 0:
567 ncls = fITSncls;
568 break;
569 case 1:
570 ncls = fTPCncls;
571 break;
572 case 2:
573 ncls = fTRDncls;
574 break;
575 case 3:
576 if (fTOFindex != 0)
577 ncls = 1;
578 break;
579 default:
580 break;
581 }
582 return ncls;
583}
584
ef7253ac 585Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
98937d93 586{
587 // Get cluster index array by subdetector index
588 //
589 Int_t ncls = 0;
590 switch(idet){
591 case 0:
592 ncls = GetITSclusters(idx);
593 break;
594 case 1:
ef7253ac 595 ncls = GetTPCclusters(idx);
98937d93 596 break;
597 case 2:
598 ncls = GetTRDclusters(idx);
599 break;
600 case 3:
601 if (fTOFindex != 0) {
602 idx[0] = GetTOFcluster();
603 ncls = 1;
604 }
605 break;
606 default:
607 break;
608 }
609 return ncls;
610}
611
ae982df3 612//_______________________________________________________________________
ae982df3 613void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
4427806c 614 // Returns the array with integrated times for each particle hypothesis
304864ab 615 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
ae982df3 616}
617
618//_______________________________________________________________________
619void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
4427806c 620 // Sets the array with integrated times for each particle hypotesis
304864ab 621 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
ae982df3 622}
623
624//_______________________________________________________________________
4427806c 625void AliESDtrack::SetITSpid(const Double_t *p) {
626 // Sets values for the probability of each particle type (in ITS)
d27bbc79 627 SetPIDValues(fITSr,p,AliPID::kSPECIES);
c630aafd 628 SetStatus(AliESDtrack::kITSpid);
629}
630
631//_______________________________________________________________________
632void AliESDtrack::GetITSpid(Double_t *p) const {
4427806c 633 // Gets the probability of each particle type (in ITS)
304864ab 634 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
c630aafd 635}
636
637//_______________________________________________________________________
ef7253ac 638Int_t AliESDtrack::GetITSclusters(Int_t *idx) const {
ae982df3 639 //---------------------------------------------------------------------
640 // This function returns indices of the assgined ITS clusters
641 //---------------------------------------------------------------------
15e85efa 642 if (idx!=0) {
643 Int_t *index=fFriendTrack->GetITSindices();
644 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) idx[i]=index[i];
645 }
ae982df3 646 return fITSncls;
647}
648
649//_______________________________________________________________________
05e445cd 650Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
ae982df3 651 //---------------------------------------------------------------------
652 // This function returns indices of the assgined ITS clusters
653 //---------------------------------------------------------------------
15e85efa 654 if (idx!=0) {
655 Int_t *index=fFriendTrack->GetTPCindices();
656 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
657 }
ae982df3 658 return fTPCncls;
659}
8c6a71ab 660
81e97e0d 661Float_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
662 //
663 // GetDensity of the clusters on given region between row0 and row1
664 // Dead zone effect takin into acoount
665 //
666 Int_t good = 0;
667 Int_t found = 0;
668 //
15e85efa 669 Int_t *index=fFriendTrack->GetTPCindices();
81e97e0d 670 for (Int_t i=row0;i<=row1;i++){
15e85efa 671 Int_t idx = index[i];
672 if (idx!=-1) good++; // track outside of dead zone
673 if (idx>0) found++;
81e97e0d 674 }
675 Float_t density=0.5;
676 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
677 return density;
678}
c84a5e9e 679
8c6a71ab 680//_______________________________________________________________________
681void AliESDtrack::SetTPCpid(const Double_t *p) {
4427806c 682 // Sets values for the probability of each particle type (in TPC)
d27bbc79 683 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
8c6a71ab 684 SetStatus(AliESDtrack::kTPCpid);
685}
686
687//_______________________________________________________________________
688void AliESDtrack::GetTPCpid(Double_t *p) const {
4427806c 689 // Gets the probability of each particle type (in TPC)
304864ab 690 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
8c6a71ab 691}
692
693//_______________________________________________________________________
ef7253ac 694Int_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
bb2ceb1f 695 //---------------------------------------------------------------------
696 // This function returns indices of the assgined TRD clusters
697 //---------------------------------------------------------------------
15e85efa 698 if (idx!=0) {
699 Int_t *index=fFriendTrack->GetTRDindices();
700 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
701 }
bb2ceb1f 702 return fTRDncls;
703}
704
705//_______________________________________________________________________
c630aafd 706void AliESDtrack::SetTRDpid(const Double_t *p) {
4427806c 707 // Sets values for the probability of each particle type (in TRD)
d27bbc79 708 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
c630aafd 709 SetStatus(AliESDtrack::kTRDpid);
710}
711
712//_______________________________________________________________________
713void AliESDtrack::GetTRDpid(Double_t *p) const {
4427806c 714 // Gets the probability of each particle type (in TRD)
304864ab 715 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
c630aafd 716}
717
718//_______________________________________________________________________
79e94bf8 719void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
720{
4427806c 721 // Sets the probability of particle type iSpecies to p (in TRD)
79e94bf8 722 fTRDr[iSpecies] = p;
723}
724
725Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
726{
4427806c 727 // Returns the probability of particle type iSpecies (in TRD)
79e94bf8 728 return fTRDr[iSpecies];
729}
730
731//_______________________________________________________________________
c630aafd 732void AliESDtrack::SetTOFpid(const Double_t *p) {
4427806c 733 // Sets the probability of each particle type (in TOF)
d27bbc79 734 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
c630aafd 735 SetStatus(AliESDtrack::kTOFpid);
736}
737
738//_______________________________________________________________________
51ad6848 739void AliESDtrack::SetTOFLabel(const Int_t *p) {
740 // Sets (in TOF)
741 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
742}
743
744//_______________________________________________________________________
c630aafd 745void AliESDtrack::GetTOFpid(Double_t *p) const {
4427806c 746 // Gets probabilities of each particle type (in TOF)
304864ab 747 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
c630aafd 748}
749
51ad6848 750//_______________________________________________________________________
751void AliESDtrack::GetTOFLabel(Int_t *p) const {
752 // Gets (in TOF)
753 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
754}
755
756//_______________________________________________________________________
757void AliESDtrack::GetTOFInfo(Float_t *info) const {
758 // Gets (in TOF)
759 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
760}
761
762//_______________________________________________________________________
763void AliESDtrack::SetTOFInfo(Float_t*info) {
764 // Gets (in TOF)
765 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
766}
767
4a78b8c5 768
769
770//_______________________________________________________________________
4a78b8c5 771void AliESDtrack::SetRICHpid(const Double_t *p) {
772 // Sets the probability of each particle type (in RICH)
d27bbc79 773 SetPIDValues(fRICHr,p,AliPID::kSPECIES);
4a78b8c5 774 SetStatus(AliESDtrack::kRICHpid);
775}
776
777//_______________________________________________________________________
778void AliESDtrack::GetRICHpid(Double_t *p) const {
779 // Gets probabilities of each particle type (in RICH)
304864ab 780 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fRICHr[i];
4a78b8c5 781}
782
783
784
c630aafd 785//_______________________________________________________________________
8c6a71ab 786void AliESDtrack::SetESDpid(const Double_t *p) {
4427806c 787 // Sets the probability of each particle type for the ESD track
d27bbc79 788 SetPIDValues(fR,p,AliPID::kSPECIES);
8c6a71ab 789 SetStatus(AliESDtrack::kESDpid);
790}
791
792//_______________________________________________________________________
793void AliESDtrack::GetESDpid(Double_t *p) const {
4427806c 794 // Gets probability of each particle type for the ESD track
304864ab 795 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
8c6a71ab 796}
797
ac2f7574 798//_______________________________________________________________________
49d13e89 799Bool_t AliESDtrack::RelateToVertex
800(const AliESDVertex *vtx, Double_t b, Double_t maxd) {
801 //
802 // Try to relate this track to the vertex "vtx",
803 // if the (rough) transverse impact parameter is not bigger then "maxd".
804 // Magnetic field is "b" (kG).
805 //
806 // a) The track gets extapolated to the DCA to the vertex.
807 // b) The impact parameters and their covariance matrix are calculated.
808 // c) An attempt to constrain this track to the vertex is done.
809 //
810 // In the case of success, the returned value is kTRUE
811 // (otherwise, it's kFALSE)
812 //
813 Double_t alpha=GetAlpha();
814 Double_t sn=TMath::Sin(alpha), cs=TMath::Cos(alpha);
815 Double_t x=GetX(), y=GetParameter()[0], snp=GetParameter()[2];
816 Double_t xv= vtx->GetXv()*cs + vtx->GetYv()*sn;
817 Double_t yv=-vtx->GetXv()*sn + vtx->GetYv()*cs, zv=vtx->GetZv();
818 x-=xv; y-=yv;
819
820 //Estimate the impact parameter neglecting the track curvature
821 Double_t d=TMath::Abs(x*snp - y*TMath::Sqrt(1.- snp*snp));
822 if (d > maxd) return kFALSE;
823
824 //Propagate to the DCA
825 Double_t crv=0.299792458e-3*b*GetParameter()[4];
826 Double_t tgfv=-(crv*x - snp)/(crv*y + TMath::Sqrt(1.-snp*snp));
f54395bf 827 sn=tgfv/TMath::Sqrt(1.+ tgfv*tgfv);
828 if (TMath::Abs(tgfv)>0.) cs = sn/tgfv;
829 else cs=1.;
49d13e89 830
831 x = xv*cs + yv*sn;
832 yv=-xv*sn + yv*cs; xv=x;
833
834 if (!Propagate(alpha+TMath::ASin(sn),xv,b)) return kFALSE;
835
836 fD = GetParameter()[0] - yv;
837 fZ = GetParameter()[1] - zv;
838
839 Double_t cov[6]; vtx->GetCovMatrix(cov);
840 fCdd = GetCovariance()[0] + cov[2]; // neglecting non-diagonals
841 fCdz = GetCovariance()[1]; // in the vertex's
842 fCzz = GetCovariance()[2] + cov[5]; // covariance matrix
843
844 {//Try to constrain
845 Double_t p[2]={yv,zv}, c[3]={cov[2],0.,cov[5]};
846 Double_t chi2=GetPredictedChi2(p,c);
847
848 if (chi2>77.) return kFALSE;
849
850 AliExternalTrackParam tmp(*this);
851 if (!tmp.Update(p,c)) return kFALSE;
852
853 fCchi2=chi2;
854 if (!fCp) fCp=new AliExternalTrackParam();
855 new (fCp) AliExternalTrackParam(tmp);
856 }
857
858 return kTRUE;
859}
860
15e85efa 861void AliESDtrack::SetTrackPointArray(AliTrackPointArray *points) {
862 fPoints=points;
863 //fFriendTrack->SetTrackPointArray(points);
864}
865const AliTrackPointArray *AliESDtrack::GetTrackPointArray() const {
866 return fPoints;
867 //return fFriendTrack->GetTrackPointArray();
868}
869
49d13e89 870//_______________________________________________________________________
ac2f7574 871void AliESDtrack::Print(Option_t *) const {
872 // Prints info on the track
873
5f7789fc 874 printf("ESD track info\n") ;
304864ab 875 Double_t p[AliPID::kSPECIESN] ;
ac2f7574 876 Int_t index = 0 ;
877 if( IsOn(kITSpid) ){
878 printf("From ITS: ") ;
879 GetITSpid(p) ;
304864ab 880 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 881 printf("%f, ", p[index]) ;
882 printf("\n signal = %f\n", GetITSsignal()) ;
883 }
884 if( IsOn(kTPCpid) ){
885 printf("From TPC: ") ;
886 GetTPCpid(p) ;
304864ab 887 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 888 printf("%f, ", p[index]) ;
889 printf("\n signal = %f\n", GetTPCsignal()) ;
890 }
891 if( IsOn(kTRDpid) ){
892 printf("From TRD: ") ;
893 GetTRDpid(p) ;
304864ab 894 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 895 printf("%f, ", p[index]) ;
896 printf("\n signal = %f\n", GetTRDsignal()) ;
897 }
898 if( IsOn(kTOFpid) ){
899 printf("From TOF: ") ;
900 GetTOFpid(p) ;
304864ab 901 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 902 printf("%f, ", p[index]) ;
903 printf("\n signal = %f\n", GetTOFsignal()) ;
904 }
905 if( IsOn(kRICHpid) ){
038834e7 906 printf("From RICH: ") ;
ac2f7574 907 GetRICHpid(p) ;
304864ab 908 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 909 printf("%f, ", p[index]) ;
910 printf("\n signal = %f\n", GetRICHsignal()) ;
911 }
ac2f7574 912}