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