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