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