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