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