ESD track based on AliExternalTrackParam. Class redesign and clean-up (Yu.Belikov)
[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//_______________________________________________________________________
524void
525AliESDtrack::GetConstrainedExternalParameters(Double_t &x, Double_t p[5])const{
526 //---------------------------------------------------------------------
527 // This function returns the constrained external track parameters
528 //---------------------------------------------------------------------
c9ec41e8 529 if (!fCp) return;
530 x=fCp->GetX();
531 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
67c3dcbe 532}
c9ec41e8 533
67c3dcbe 534//_______________________________________________________________________
535void
536AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
537 //---------------------------------------------------------------------
538 // This function returns the constrained external cov. matrix
539 //---------------------------------------------------------------------
c9ec41e8 540 if (!fCp) return;
541 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
67c3dcbe 542}
543
c9ec41e8 544void AliESDtrack::GetInnerExternalParameters(Double_t &x, Double_t p[5]) const
545{
546 //---------------------------------------------------------------------
547 // This function returns external representation of the track parameters
548 // at the inner layer of TPC
9b859005 549 //---------------------------------------------------------------------
c9ec41e8 550 if (!fIp) return;
551 x=fIp->GetX();
552 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
9b859005 553}
554
c9ec41e8 555void AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const
556{
557 //---------------------------------------------------------------------
558 // This function returns external representation of the cov. matrix
559 // at the inner layer of TPC
560 //---------------------------------------------------------------------
561 if (!fIp) return;
562 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
9b859005 563}
564
c9ec41e8 565void AliESDtrack::GetOuterExternalParameters(Double_t &x, Double_t p[5]) const
a866ac60 566{
a866ac60 567 //---------------------------------------------------------------------
c9ec41e8 568 // This function returns external representation of the track parameters
569 // at the inner layer of TRD
a866ac60 570 //---------------------------------------------------------------------
c9ec41e8 571 if (!fOp) return;
572 x=fOp->GetX();
573 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
a866ac60 574}
c9ec41e8 575
576void AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const
a866ac60 577{
a866ac60 578 //---------------------------------------------------------------------
c9ec41e8 579 // This function returns external representation of the cov. matrix
580 // at the inner layer of TRD
a866ac60 581 //---------------------------------------------------------------------
c9ec41e8 582 if (!fOp) return;
583 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
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//_______________________________________________________________________
ae982df3 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
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
666//_______________________________________________________________________
ae982df3 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
716//_______________________________________________________________________
bb2ceb1f 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
726//_______________________________________________________________________
c630aafd 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
739//_______________________________________________________________________
79e94bf8 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
752//_______________________________________________________________________
c630aafd 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
759//_______________________________________________________________________
51ad6848 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
765//_______________________________________________________________________
c630aafd 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
c630aafd 832//_______________________________________________________________________
8c6a71ab 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
ac2f7574 845//_______________________________________________________________________
846void AliESDtrack::Print(Option_t *) const {
847 // Prints info on the track
848
5f7789fc 849 printf("ESD track info\n") ;
304864ab 850 Double_t p[AliPID::kSPECIESN] ;
ac2f7574 851 Int_t index = 0 ;
852 if( IsOn(kITSpid) ){
853 printf("From ITS: ") ;
854 GetITSpid(p) ;
304864ab 855 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 856 printf("%f, ", p[index]) ;
857 printf("\n signal = %f\n", GetITSsignal()) ;
858 }
859 if( IsOn(kTPCpid) ){
860 printf("From TPC: ") ;
861 GetTPCpid(p) ;
304864ab 862 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 863 printf("%f, ", p[index]) ;
864 printf("\n signal = %f\n", GetTPCsignal()) ;
865 }
866 if( IsOn(kTRDpid) ){
867 printf("From TRD: ") ;
868 GetTRDpid(p) ;
304864ab 869 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 870 printf("%f, ", p[index]) ;
871 printf("\n signal = %f\n", GetTRDsignal()) ;
872 }
873 if( IsOn(kTOFpid) ){
874 printf("From TOF: ") ;
875 GetTOFpid(p) ;
304864ab 876 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 877 printf("%f, ", p[index]) ;
878 printf("\n signal = %f\n", GetTOFsignal()) ;
879 }
880 if( IsOn(kRICHpid) ){
038834e7 881 printf("From RICH: ") ;
ac2f7574 882 GetRICHpid(p) ;
304864ab 883 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 884 printf("%f, ", p[index]) ;
885 printf("\n signal = %f\n", GetRICHsignal()) ;
886 }
887 if( IsOn(kPHOSpid) ){
888 printf("From PHOS: ") ;
889 GetPHOSpid(p) ;
304864ab 890 for(index = 0 ; index < AliPID::kSPECIESN; index++)
ac2f7574 891 printf("%f, ", p[index]) ;
892 printf("\n signal = %f\n", GetPHOSsignal()) ;
893 }
704be597 894 if( IsOn(kEMCALpid) ){
895 printf("From EMCAL: ") ;
896 GetEMCALpid(p) ;
304864ab 897 for(index = 0 ; index < AliPID::kSPECIESN; index++)
704be597 898 printf("%f, ", p[index]) ;
899 printf("\n signal = %f\n", GetEMCALsignal()) ;
900 }
ac2f7574 901}