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