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