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