call storage area LED instead of Signal
[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
e1e6896f 23#include <TMath.h>
49edfa08 24#include <TParticle.h>
ae982df3 25
49d13e89 26#include "AliESDVertex.h"
ae982df3 27#include "AliESDtrack.h"
28#include "AliKalmanTrack.h"
5f7789fc 29#include "AliLog.h"
15e85efa 30#include "AliTrackPointArray.h"
0c19adf7 31#include "TPolyMarker3D.h"
ae982df3 32
33ClassImp(AliESDtrack)
34
562dd0b4 35void SetPIDValues(Double_t * dest, const Double_t * src, Int_t n) {
d27bbc79 36 // This function copies "n" PID weights from "scr" to "dest"
37 // and normalizes their sum to 1 thus producing conditional probabilities.
38 // The negative weights are set to 0.
39 // In case all the weights are non-positive they are replaced by
40 // uniform probabilities
41
42 if (n<=0) return;
43
44 Float_t uniform = 1./(Float_t)n;
45
46 Float_t sum = 0;
47 for (Int_t i=0; i<n; i++)
48 if (src[i]>=0) {
49 sum+=src[i];
50 dest[i] = src[i];
51 }
52 else {
53 dest[i] = 0;
54 }
55
56 if(sum>0)
57 for (Int_t i=0; i<n; i++) dest[i] /= sum;
58 else
59 for (Int_t i=0; i<n; i++) dest[i] = uniform;
60}
61
ae982df3 62//_______________________________________________________________________
63AliESDtrack::AliESDtrack() :
c9ec41e8 64 AliExternalTrackParam(),
562dd0b4 65 fCp(0),
66 fIp(0),
67 fTPCInner(0),
68 fOp(0),
69 fFriendTrack(new AliESDfriendTrack()),
70 fTPCClusterMap(159),//number of padrows
71 fTPCSharedMap(159),//number of padrows
90e48c0c 72 fFlags(0),
90e48c0c 73 fID(0),
562dd0b4 74 fLabel(0),
75 fITSLabel(0),
76 fTPCLabel(0),
77 fTRDLabel(0),
78 fTOFCalChannel(0),
ce3f4882 79 fTOFindex(-1),
562dd0b4 80 fHMPIDqn(0),
81 fHMPIDcluIdx(0),
82 fEMCALindex(kEMCALNoMatch),
83 fHMPIDtrkTheta(0),
84 fHMPIDtrkPhi(0),
85 fHMPIDsignal(0),
90e48c0c 86 fTrackLength(0),
49d13e89 87 fD(0),fZ(0),
88 fCdd(0),fCdz(0),fCzz(0),
562dd0b4 89 fCchi2(0),
90e48c0c 90 fITSchi2(0),
90e48c0c 91 fTPCchi2(0),
562dd0b4 92 fTRDchi2(0),
93 fTOFchi2(0),
94 fHMPIDchi2(0),
95 fITSsignal(0),
90e48c0c 96 fTPCsignal(0),
e1d4c1b5 97 fTPCsignalS(0),
90e48c0c 98 fTRDsignal(0),
90e48c0c 99 fTRDQuality(0),
23d49657 100 fTRDBudget(0),
562dd0b4 101 fTOFsignal(0),
85324138 102 fTOFsignalToT(0),
d321691a 103 fTOFsignalRaw(0),
104 fTOFsignalDz(0),
562dd0b4 105 fHMPIDtrkX(0),
106 fHMPIDtrkY(0),
107 fHMPIDmipX(0),
108 fHMPIDmipY(0),
109 fTPCncls(0),
110 fTPCnclsF(0),
111 fTPCsignalN(0),
112 fITSncls(0),
113 fITSClusterMap(0),
114 fTRDncls(0),
115 fTRDncls0(0),
6984f7c1 116 fTRDpidQuality(0),
117 fTRDnSlices(0),
118 fTRDslices(0x0)
119
ae982df3 120{
121 //
122 // The default ESD constructor
123 //
6984f7c1 124 Int_t i;
6238d7a9 125 for (i=0; i<AliPID::kSPECIES; i++) {
4a78b8c5 126 fTrackTime[i]=0.;
562dd0b4 127 fR[i]=0.;
128 fITSr[i]=0.;
129 fTPCr[i]=0.;
130 fTRDr[i]=0.;
131 fTOFr[i]=0.;
132 fHMPIDr[i]=0.;
2bad268c 133 }
ac2f7574 134
ef7253ac 135 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
562dd0b4 136 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
6984f7c1 137 for (i=0;i<kTRDnPlanes;i++) {
562dd0b4 138 fTRDTimBin[i]=0;
6d45eaef 139 }
562dd0b4 140 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
141 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
142 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
89f1b176 143 for (i=0;i<12;i++) {fITSModule[i]=-1;}
c4d11b15 144}
145
146//_______________________________________________________________________
90e48c0c 147AliESDtrack::AliESDtrack(const AliESDtrack& track):
c9ec41e8 148 AliExternalTrackParam(track),
562dd0b4 149 fCp(0),
150 fIp(0),
151 fTPCInner(0),
152 fOp(0),
153 fFriendTrack(0),
154 fTPCClusterMap(track.fTPCClusterMap),
155 fTPCSharedMap(track.fTPCSharedMap),
90e48c0c 156 fFlags(track.fFlags),
90e48c0c 157 fID(track.fID),
562dd0b4 158 fLabel(track.fLabel),
159 fITSLabel(track.fITSLabel),
160 fTPCLabel(track.fTPCLabel),
161 fTRDLabel(track.fTRDLabel),
162 fTOFCalChannel(track.fTOFCalChannel),
163 fTOFindex(track.fTOFindex),
164 fHMPIDqn(track.fHMPIDqn),
165 fHMPIDcluIdx(track.fHMPIDcluIdx),
166 fEMCALindex(track.fEMCALindex),
167 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
168 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
169 fHMPIDsignal(track.fHMPIDsignal),
90e48c0c 170 fTrackLength(track.fTrackLength),
49d13e89 171 fD(track.fD),fZ(track.fZ),
172 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
90e48c0c 173 fCchi2(track.fCchi2),
90e48c0c 174 fITSchi2(track.fITSchi2),
90e48c0c 175 fTPCchi2(track.fTPCchi2),
562dd0b4 176 fTRDchi2(track.fTRDchi2),
177 fTOFchi2(track.fTOFchi2),
178 fHMPIDchi2(track.fHMPIDchi2),
179 fITSsignal(track.fITSsignal),
90e48c0c 180 fTPCsignal(track.fTPCsignal),
e1d4c1b5 181 fTPCsignalS(track.fTPCsignalS),
90e48c0c 182 fTRDsignal(track.fTRDsignal),
90e48c0c 183 fTRDQuality(track.fTRDQuality),
23d49657 184 fTRDBudget(track.fTRDBudget),
90e48c0c 185 fTOFsignal(track.fTOFsignal),
85324138 186 fTOFsignalToT(track.fTOFsignalToT),
d321691a 187 fTOFsignalRaw(track.fTOFsignalRaw),
188 fTOFsignalDz(track.fTOFsignalDz),
f4b3bbb7 189 fHMPIDtrkX(track.fHMPIDtrkX),
190 fHMPIDtrkY(track.fHMPIDtrkY),
191 fHMPIDmipX(track.fHMPIDmipX),
192 fHMPIDmipY(track.fHMPIDmipY),
562dd0b4 193 fTPCncls(track.fTPCncls),
194 fTPCnclsF(track.fTPCnclsF),
195 fTPCsignalN(track.fTPCsignalN),
196 fITSncls(track.fITSncls),
197 fITSClusterMap(track.fITSClusterMap),
198 fTRDncls(track.fTRDncls),
199 fTRDncls0(track.fTRDncls0),
6984f7c1 200 fTRDpidQuality(track.fTRDpidQuality),
201 fTRDnSlices(track.fTRDnSlices),
202 fTRDslices(0x0)
90e48c0c 203{
c4d11b15 204 //
205 //copy constructor
206 //
ef7253ac 207 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
208 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
c4d11b15 209 //
304864ab 210 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
c4d11b15 211 //
304864ab 212 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
51ad6848 213 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
214 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
215 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
c4d11b15 216 //
6984f7c1 217 for (Int_t i=0;i<kTRDnPlanes;i++) {
6d45eaef 218 fTRDTimBin[i]=track.fTRDTimBin[i];
eab5961e 219 }
6984f7c1 220
221 if (fTRDnSlices) {
222 fTRDslices=new Double32_t[fTRDnSlices];
223 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
224 }
225
304864ab 226 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
304864ab 227 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
51ad6848 228 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
229 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
89f1b176 230 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
f4b3bbb7 231 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
c9ec41e8 232
233 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
234 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
4aeb9470 235 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
c9ec41e8 236 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
15e85efa 237
8497bca0 238 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
ae982df3 239}
15e85efa 240
c4d11b15 241//_______________________________________________________________________
49edfa08 242AliESDtrack::AliESDtrack(TParticle * part) :
243 AliExternalTrackParam(),
562dd0b4 244 fCp(0),
245 fIp(0),
246 fTPCInner(0),
247 fOp(0),
248 fFriendTrack(0),
249 fTPCClusterMap(159),//number of padrows
250 fTPCSharedMap(159),//number of padrows
49edfa08 251 fFlags(0),
49edfa08 252 fID(0),
562dd0b4 253 fLabel(0),
254 fITSLabel(0),
255 fTPCLabel(0),
256 fTRDLabel(0),
257 fTOFCalChannel(0),
ce3f4882 258 fTOFindex(-1),
562dd0b4 259 fHMPIDqn(0),
260 fHMPIDcluIdx(0),
261 fEMCALindex(kEMCALNoMatch),
262 fHMPIDtrkTheta(0),
263 fHMPIDtrkPhi(0),
264 fHMPIDsignal(0),
49edfa08 265 fTrackLength(0),
266 fD(0),fZ(0),
267 fCdd(0),fCdz(0),fCzz(0),
562dd0b4 268 fCchi2(0),
49edfa08 269 fITSchi2(0),
49edfa08 270 fTPCchi2(0),
562dd0b4 271 fTRDchi2(0),
272 fTOFchi2(0),
273 fHMPIDchi2(0),
274 fITSsignal(0),
49edfa08 275 fTPCsignal(0),
49edfa08 276 fTPCsignalS(0),
49edfa08 277 fTRDsignal(0),
49edfa08 278 fTRDQuality(0),
279 fTRDBudget(0),
562dd0b4 280 fTOFsignal(0),
49edfa08 281 fTOFsignalToT(0),
d321691a 282 fTOFsignalRaw(0),
283 fTOFsignalDz(0),
562dd0b4 284 fHMPIDtrkX(0),
285 fHMPIDtrkY(0),
286 fHMPIDmipX(0),
287 fHMPIDmipY(0),
288 fTPCncls(0),
289 fTPCnclsF(0),
290 fTPCsignalN(0),
291 fITSncls(0),
292 fITSClusterMap(0),
293 fTRDncls(0),
294 fTRDncls0(0),
6984f7c1 295 fTRDpidQuality(0),
296 fTRDnSlices(0),
297 fTRDslices(0x0)
49edfa08 298{
299 //
300 // ESD track from TParticle
301 //
302
303 // Reset all the arrays
6984f7c1 304 Int_t i;
49edfa08 305 for (i=0; i<AliPID::kSPECIES; i++) {
306 fTrackTime[i]=0.;
307 fR[i]=0.;
308 fITSr[i]=0.;
309 fTPCr[i]=0.;
310 fTRDr[i]=0.;
311 fTOFr[i]=0.;
f4b3bbb7 312 fHMPIDr[i]=0.;
49edfa08 313 }
314
315 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
316 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
6984f7c1 317 for (i=0;i<kTRDnPlanes;i++) {
562dd0b4 318 fTRDTimBin[i]=0;
49edfa08 319 }
562dd0b4 320 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
321 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
322 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
89f1b176 323 for (i=0;i<12;i++) {fITSModule[i]=-1;}
49edfa08 324
325 // Calculate the AliExternalTrackParam content
326
327 Double_t xref;
328 Double_t alpha;
329 Double_t param[5];
330 Double_t covar[15];
331
332 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
333 alpha = part->Phi()*180./TMath::Pi();
334 if (alpha<0) alpha+= 360.;
335 if (alpha>360) alpha -= 360.;
336
337 Int_t sector = (Int_t)(alpha/20.);
338 alpha = 10. + 20.*sector;
339 alpha /= 180;
340 alpha *= TMath::Pi();
341
342 // Covariance matrix: no errors, the parameters are exact
6c27b212 343 for (i=0; i<15; i++) covar[i]=0.;
49edfa08 344
345 // Get the vertex of origin and the momentum
346 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
347 TVector3 mom(part->Px(),part->Py(),part->Pz());
348
349 // Rotate to the local coordinate system (TPC sector)
350 ver.RotateZ(-alpha);
351 mom.RotateZ(-alpha);
352
353 // X of the referense plane
354 xref = ver.X();
355
356 Int_t pdgCode = part->GetPdgCode();
357
358 Double_t charge =
359 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
360
361 param[0] = ver.Y();
362 param[1] = ver.Z();
363 param[2] = TMath::Sin(mom.Phi());
364 param[3] = mom.Pz()/mom.Pt();
365 param[4] = TMath::Sign(1/mom.Pt(),charge);
366
367 // Set AliExternalTrackParam
368 Set(xref, alpha, param, covar);
369
370 // Set the PID
371 Int_t indexPID = 99;
372
373 switch (TMath::Abs(pdgCode)) {
374
375 case 11: // electron
376 indexPID = 0;
377 break;
378
379 case 13: // muon
380 indexPID = 1;
381 break;
382
383 case 211: // pion
384 indexPID = 2;
385 break;
386
387 case 321: // kaon
388 indexPID = 3;
389 break;
390
391 case 2212: // proton
392 indexPID = 4;
393 break;
394
395 default:
396 break;
397 }
398
399 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
400 if (indexPID < AliPID::kSPECIES) {
401 fR[indexPID]=1.;
402 fITSr[indexPID]=1.;
403 fTPCr[indexPID]=1.;
404 fTRDr[indexPID]=1.;
405 fTOFr[indexPID]=1.;
f4b3bbb7 406 fHMPIDr[indexPID]=1.;
49edfa08 407
408 }
409 // AliESD track label
410 SetLabel(part->GetUniqueID());
411
412}
413
414//_______________________________________________________________________
c4d11b15 415AliESDtrack::~AliESDtrack(){
416 //
417 // This is destructor according Coding Conventrions
418 //
419 //printf("Delete track\n");
c9ec41e8 420 delete fIp;
4aeb9470 421 delete fTPCInner;
c9ec41e8 422 delete fOp;
423 delete fCp;
15e85efa 424 delete fFriendTrack;
6984f7c1 425 if(fTRDnSlices)
426 delete[] fTRDslices;
c4d11b15 427}
ae982df3 428
732a24fe 429AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
430
431
432 if(&source == this) return *this;
433 AliExternalTrackParam::operator=(source);
434
435
436 if(source.fCp){
437 // we have the trackparam: assign or copy construct
438 if(fCp)*fCp = *source.fCp;
439 else fCp = new AliExternalTrackParam(*source.fCp);
440 }
441 else{
442 // no track param delete the old one
443 if(fCp)delete fCp;
444 fCp = 0;
445 }
446
447 if(source.fIp){
448 // we have the trackparam: assign or copy construct
449 if(fIp)*fIp = *source.fIp;
450 else fIp = new AliExternalTrackParam(*source.fIp);
451 }
452 else{
453 // no track param delete the old one
454 if(fIp)delete fIp;
455 fIp = 0;
456 }
457
458
459 if(source.fTPCInner){
460 // we have the trackparam: assign or copy construct
461 if(fTPCInner) *fTPCInner = *source.fTPCInner;
462 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
463 }
464 else{
465 // no track param delete the old one
466 if(fTPCInner)delete fTPCInner;
467 fTPCInner = 0;
468 }
469
470
471 if(source.fOp){
472 // we have the trackparam: assign or copy construct
473 if(fOp) *fOp = *source.fOp;
474 else fOp = new AliExternalTrackParam(*source.fOp);
475 }
476 else{
477 // no track param delete the old one
478 if(fOp)delete fOp;
479 fOp = 0;
480 }
481
482 // copy also the friend track
483 // use copy constructor
484 if(source.fFriendTrack){
485 // we have the trackparam: assign or copy construct
486 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
487 }
488 else{
489 // no track param delete the old one
490 delete fFriendTrack; fFriendTrack= 0;
491 }
492
493 fTPCClusterMap = source.fTPCClusterMap;
494 fTPCSharedMap = source.fTPCSharedMap;
495 // the simple stuff
496 fFlags = source.fFlags;
497 fID = source.fID;
498 fLabel = source.fLabel;
499 fITSLabel = source.fITSLabel;
500 for(int i = 0; i< 12;++i){
501 fITSModule[i] = source.fITSModule[i];
502 }
503 fTPCLabel = source.fTPCLabel;
504 fTRDLabel = source.fTRDLabel;
505 for(int i = 0; i< 3;++i){
506 fTOFLabel[i] = source.fTOFLabel[i];
507 }
508 fTOFCalChannel = source.fTOFCalChannel;
509 fTOFindex = source.fTOFindex;
510 fHMPIDqn = source.fHMPIDqn;
511 fHMPIDcluIdx = source.fHMPIDcluIdx;
512 fEMCALindex = source.fEMCALindex;
513
514 for(int i = 0; i< 3;++i){
515 fKinkIndexes[i] = source.fKinkIndexes[i];
516 fV0Indexes[i] = source.fV0Indexes[i];
517 }
518
519 for(int i = 0; i< AliPID::kSPECIES;++i){
520 fR[i] = source.fR[i];
521 fITSr[i] = source.fITSr[i];
522 fTPCr[i] = source.fTPCr[i];
523 fTRDr[i] = source.fTRDr[i];
524 fTOFr[i] = source.fTOFr[i];
525 fHMPIDr[i] = source.fHMPIDr[i];
526 fTrackTime[i] = source.fTrackTime[i];
527 }
528
529 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
530 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
531 fHMPIDsignal = source.fHMPIDsignal;
532
533
534 fTrackLength = source. fTrackLength;
535 fD = source.fD;
536 fZ = source.fZ;
537 fCdd = source.fCdd;
538 fCdz = source.fCdz;
539 fCzz = source.fCzz;
540
541 fCchi2 = source.fCchi2;
542 fITSchi2 = source.fITSchi2;
543 fTPCchi2 = source.fTPCchi2;
544 fTRDchi2 = source.fTRDchi2;
545 fTOFchi2 = source.fTOFchi2;
546 fHMPIDchi2 = source.fHMPIDchi2;
547
548
549 fITSsignal = source.fITSsignal;
550 fTPCsignal = source.fTPCsignal;
551 fTPCsignalS = source.fTPCsignalS;
552 for(int i = 0; i< 4;++i){
553 fTPCPoints[i] = source.fTPCPoints[i];
554 }
555 fTRDsignal = source.fTRDsignal;
556
6984f7c1 557 for(int i = 0;i < kTRDnPlanes;++i){
732a24fe 558 fTRDTimBin[i] = source.fTRDTimBin[i];
732a24fe 559 }
6984f7c1 560
561 if(fTRDnSlices)
562 delete[] fTRDslices;
563 fTRDslices=0;
564 fTRDnSlices=source.fTRDnSlices;
565 if (fTRDnSlices) {
566 fTRDslices=new Double32_t[fTRDnSlices];
567 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
568 }
569
732a24fe 570 fTRDQuality = source.fTRDQuality;
571 fTRDBudget = source.fTRDBudget;
572 fTOFsignal = source.fTOFsignal;
573 fTOFsignalToT = source.fTOFsignalToT;
574 fTOFsignalRaw = source.fTOFsignalRaw;
575 fTOFsignalDz = source.fTOFsignalDz;
576
577 for(int i = 0;i<10;++i){
578 fTOFInfo[i] = source.fTOFInfo[i];
579 }
580
581 fHMPIDtrkX = source.fHMPIDtrkX;
582 fHMPIDtrkY = source.fHMPIDtrkY;
583 fHMPIDmipX = source.fHMPIDmipX;
584 fHMPIDmipY = source.fHMPIDmipY;
585
586 fTPCncls = source.fTPCncls;
587 fTPCnclsF = source.fTPCnclsF;
588 fTPCsignalN = source.fTPCsignalN;
589
590 fITSncls = source.fITSncls;
591 fITSClusterMap = source.fITSClusterMap;
592 fTRDncls = source.fTRDncls;
593 fTRDncls0 = source.fTRDncls0;
594 fTRDpidQuality = source.fTRDpidQuality;
595 return *this;
596}
597
598
599
600void AliESDtrack::Copy(TObject &obj) const {
601
602 // this overwrites the virtual TOBject::Copy()
603 // to allow run time copying without casting
604 // in AliESDEvent
605
606 if(this==&obj)return;
607 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
608 if(!robj)return; // not an AliESDtrack
609 *robj = *this;
610
611}
612
613
614
00dce61a 615void AliESDtrack::AddCalibObject(TObject * object){
616 //
617 // add calib object to the list
618 //
619 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
620 fFriendTrack->AddCalibObject(object);
621}
622
623TObject * AliESDtrack::GetCalibObject(Int_t index){
624 //
625 // return calib objct at given position
626 //
627 if (!fFriendTrack) return 0;
628 return fFriendTrack->GetCalibObject(index);
629}
630
631
ae982df3 632//_______________________________________________________________________
9559cbc4 633void AliESDtrack::MakeMiniESDtrack(){
634 // Resets everything except
635 // fFlags: Reconstruction status flags
636 // fLabel: Track label
637 // fID: Unique ID of the track
638 // fD: Impact parameter in XY-plane
639 // fZ: Impact parameter in Z
640 // fR[AliPID::kSPECIES]: combined "detector response probability"
8497bca0 641 // Running track parameters in the base class (AliExternalTrackParam)
9559cbc4 642
643 fTrackLength = 0;
562dd0b4 644
9559cbc4 645 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
9559cbc4 646
647 // Reset track parameters constrained to the primary vertex
562dd0b4 648 delete fCp;fCp = 0;
9559cbc4 649 fCchi2 = 0;
650
651 // Reset track parameters at the inner wall of TPC
562dd0b4 652 delete fIp;fIp = 0;
653 delete fTPCInner;fTPCInner=0;
9559cbc4 654 // Reset track parameters at the inner wall of the TRD
562dd0b4 655 delete fOp;fOp = 0;
656
9559cbc4 657
658 // Reset ITS track related information
659 fITSchi2 = 0;
9559cbc4 660 fITSncls = 0;
62665e7f 661 fITSClusterMap=0;
9559cbc4 662 fITSsignal = 0;
ef7253ac 663 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
9559cbc4 664 fITSLabel = 0;
9559cbc4 665
666 // Reset TPC related track information
667 fTPCchi2 = 0;
668 fTPCncls = 0;
e1d4c1b5 669 fTPCnclsF = 0;
9559cbc4 670 fTPCClusterMap = 0;
eb7f6854 671 fTPCSharedMap = 0;
9559cbc4 672 fTPCsignal= 0;
e1d4c1b5 673 fTPCsignalS= 0;
674 fTPCsignalN= 0;
9559cbc4 675 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
676 fTPCLabel=0;
677 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
678 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
679 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
680
681 // Reset TRD related track information
682 fTRDchi2 = 0;
683 fTRDncls = 0;
684 fTRDncls0 = 0;
9559cbc4 685 fTRDsignal = 0;
6984f7c1 686 for (Int_t i=0;i<kTRDnPlanes;i++) {
6d45eaef 687 fTRDTimBin[i] = 0;
9559cbc4 688 }
689 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
690 fTRDLabel = 0;
9559cbc4 691 fTRDQuality = 0;
562dd0b4 692 fTRDpidQuality = 0;
6984f7c1 693 if(fTRDnSlices)
694 delete[] fTRDslices;
695 fTRDslices=0x0;
696 fTRDnSlices=0;
23d49657 697 fTRDBudget = 0;
9559cbc4 698
699 // Reset TOF related track information
700 fTOFchi2 = 0;
ce3f4882 701 fTOFindex = -1;
9559cbc4 702 fTOFsignal = 0;
562dd0b4 703 fTOFCalChannel = 0;
85324138 704 fTOFsignalToT = 0;
d321691a 705 fTOFsignalRaw = 0;
706 fTOFsignalDz = 0;
9559cbc4 707 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
708 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
709 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
710
f4b3bbb7 711 // Reset HMPID related track information
712 fHMPIDchi2 = 0;
562dd0b4 713 fHMPIDqn = 0;
714 fHMPIDcluIdx = 0;
f4b3bbb7 715 fHMPIDsignal = 0;
716 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
562dd0b4 717 fHMPIDtrkTheta = 0;
718 fHMPIDtrkPhi = 0;
719 fHMPIDtrkX = 0;
720 fHMPIDtrkY = 0;
721 fHMPIDmipX = 0;
722 fHMPIDmipY = 0;
2e1dcd14 723 fEMCALindex = kEMCALNoMatch;
9559cbc4 724
15e85efa 725 delete fFriendTrack; fFriendTrack = 0;
9559cbc4 726}
727//_______________________________________________________________________
4a78b8c5 728Double_t AliESDtrack::GetMass() const {
4427806c 729 // Returns the mass of the most probable particle type
ae982df3 730 Float_t max=0.;
731 Int_t k=-1;
304864ab 732 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
ae982df3 733 if (fR[i]>max) {k=i; max=fR[i];}
734 }
db3989b3 735 if (k==0) { // dE/dx "crossing points" in the TPC
736 Double_t p=GetP();
737 if ((p>0.38)&&(p<0.48))
304864ab 738 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
db3989b3 739 if ((p>0.75)&&(p<0.85))
304864ab 740 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
db3989b3 741 return 0.00051;
742 }
304864ab 743 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
744 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
745 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
746 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
5f7789fc 747 AliWarning("Undefined mass !");
304864ab 748 return AliPID::ParticleMass(AliPID::kPion);
ae982df3 749}
750
aad8d435 751//______________________________________________________________________________
752Double_t AliESDtrack::E() const
753{
754 // Returns the energy of the particle given its assumed mass.
755 // Assumes the pion mass if the particle can't be identified properly.
756
757 Double_t m = M();
758 Double_t p = P();
759 return TMath::Sqrt(p*p + m*m);
760}
761
762//______________________________________________________________________________
763Double_t AliESDtrack::Y() const
764{
765 // Returns the rapidity of a particle given its assumed mass.
766 // Assumes the pion mass if the particle can't be identified properly.
767
768 Double_t e = E();
769 Double_t pz = Pz();
e03e4544 770 if (e != TMath::Abs(pz)) { // energy was not equal to pz
aad8d435 771 return 0.5*TMath::Log((e+pz)/(e-pz));
772 } else { // energy was equal to pz
773 return -999.;
774 }
775}
776
ae982df3 777//_______________________________________________________________________
c9ec41e8 778Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
ae982df3 779 //
780 // This function updates track's running parameters
781 //
15e85efa 782 Int_t *index=0;
15614b8b 783 Bool_t rc=kTRUE;
784
9b859005 785 SetStatus(flags);
786 fLabel=t->GetLabel();
787
788 if (t->IsStartedTimeIntegral()) {
789 SetStatus(kTIME);
790 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
791 SetIntegratedLength(t->GetIntegratedLength());
792 }
793
6c94f330 794 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
e1d4c1b5 795
ae982df3 796 switch (flags) {
ad2f1f2b 797
9b859005 798 case kITSin: case kITSout: case kITSrefit:
48704648 799 fITSClusterMap=0;
ae982df3 800 fITSncls=t->GetNumberOfClusters();
62665e7f 801 index=fFriendTrack->GetITSindices();
802 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
803 index[i]=t->GetClusterIndex(i);
804 if (i<fITSncls) {
805 Int_t l=(index[i] & 0xf0000000) >> 28;
806 SETBIT(fITSClusterMap,l);
807 }
808 }
ae982df3 809 fITSchi2=t->GetChi2();
ae982df3 810 fITSsignal=t->GetPIDsignal();
6e5b1b04 811 fITSLabel = t->GetLabel();
ae982df3 812 break;
ad2f1f2b 813
9b859005 814 case kTPCin: case kTPCrefit:
6e5b1b04 815 fTPCLabel = t->GetLabel();
4aeb9470 816 if (flags==kTPCin) fTPCInner=new AliExternalTrackParam(*t);
c9ec41e8 817 if (!fIp) fIp=new AliExternalTrackParam(*t);
6c94f330 818 else
819 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
9b859005 820 case kTPCout:
15e85efa 821 index=fFriendTrack->GetTPCindices();
1d303a24 822 if (flags & kTPCout){
823 if (!fOp) fOp=new AliExternalTrackParam(*t);
6c94f330 824 else
825 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1d303a24 826 }
e1d4c1b5 827 fTPCncls=t->GetNumberOfClusters();
ae982df3 828 fTPCchi2=t->GetChi2();
a866ac60 829
830 {//prevrow must be declared in separate namespace, otherwise compiler cries:
831 //"jump to case label crosses initialization of `Int_t prevrow'"
832 Int_t prevrow = -1;
6e5b1b04 833 // for (Int_t i=0;i<fTPCncls;i++)
15e85efa 834 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
a866ac60 835 {
15e85efa 836 index[i]=t->GetClusterIndex(i);
837 Int_t idx = index[i];
a866ac60 838
15e85efa 839 if (idx<0) continue;
9fe5b2ff 840
a866ac60 841 // Piotr's Cluster Map for HBT
842 // ### please change accordingly if cluster array is changing
843 // to "New TPC Tracking" style (with gaps in array)
a866ac60 844 Int_t sect = (idx&0xff000000)>>24;
845 Int_t row = (idx&0x00ff0000)>>16;
846 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
847
848 fTPCClusterMap.SetBitNumber(row,kTRUE);
849
850 //Fill the gap between previous row and this row with 0 bits
851 //In case ### pleas change it as well - just set bit 0 in case there
852 //is no associated clusters for current "i"
853 if (prevrow < 0)
854 {
855 prevrow = row;//if previous bit was not assigned yet == this is the first one
856 }
857 else
858 { //we don't know the order (inner to outer or reverse)
859 //just to be save in case it is going to change
860 Int_t n = 0, m = 0;
861 if (prevrow < row)
862 {
863 n = prevrow;
864 m = row;
865 }
866 else
867 {
868 n = row;
869 m = prevrow;
870 }
871
872 for (Int_t j = n+1; j < m; j++)
873 {
874 fTPCClusterMap.SetBitNumber(j,kFALSE);
875 }
876 prevrow = row;
877 }
878 // End Of Piotr's Cluster Map for HBT
879 }
880 }
ae982df3 881 fTPCsignal=t->GetPIDsignal();
ae982df3 882 break;
9b859005 883
23904d16 884 case kTRDout: case kTRDin: case kTRDrefit:
2f83b7a6 885 index = fFriendTrack->GetTRDindices();
51ad6848 886 fTRDLabel = t->GetLabel();
2f83b7a6 887 fTRDchi2 = t->GetChi2();
888 fTRDncls = t->GetNumberOfClusters();
5bc3e158 889 for (Int_t i=0;i<6;i++) index[i]=t->GetTrackletIndex(i);
890
79e94bf8 891 fTRDsignal=t->GetPIDsignal();
892 break;
c4d11b15 893 case kTRDbackup:
c9ec41e8 894 if (!fOp) fOp=new AliExternalTrackParam(*t);
6c94f330 895 else
896 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
c4d11b15 897 fTRDncls0 = t->GetNumberOfClusters();
898 break;
899 case kTOFin:
900 break;
901 case kTOFout:
902 break;
d0862fea 903 case kTRDStop:
904 break;
ae982df3 905 default:
5f7789fc 906 AliError("Wrong flag !");
ae982df3 907 return kFALSE;
908 }
909
15614b8b 910 return rc;
ae982df3 911}
912
913//_______________________________________________________________________
914void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
915 //---------------------------------------------------------------------
916 // This function returns external representation of the track parameters
917 //---------------------------------------------------------------------
c9ec41e8 918 x=GetX();
919 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
15614b8b 920}
921
67c3dcbe 922//_______________________________________________________________________
a866ac60 923void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
67c3dcbe 924 //---------------------------------------------------------------------
925 // This function returns external representation of the cov. matrix
926 //---------------------------------------------------------------------
c9ec41e8 927 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
67c3dcbe 928}
929
67c3dcbe 930//_______________________________________________________________________
c0b978f0 931Bool_t AliESDtrack::GetConstrainedExternalParameters
932 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
67c3dcbe 933 //---------------------------------------------------------------------
934 // This function returns the constrained external track parameters
935 //---------------------------------------------------------------------
c0b978f0 936 if (!fCp) return kFALSE;
937 alpha=fCp->GetAlpha();
c9ec41e8 938 x=fCp->GetX();
939 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
c0b978f0 940 return kTRUE;
67c3dcbe 941}
c9ec41e8 942
67c3dcbe 943//_______________________________________________________________________
c0b978f0 944Bool_t
67c3dcbe 945AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
946 //---------------------------------------------------------------------
947 // This function returns the constrained external cov. matrix
948 //---------------------------------------------------------------------
c0b978f0 949 if (!fCp) return kFALSE;
c9ec41e8 950 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
c0b978f0 951 return kTRUE;
67c3dcbe 952}
953
c0b978f0 954Bool_t
955AliESDtrack::GetInnerExternalParameters
956 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
957 //---------------------------------------------------------------------
c9ec41e8 958 // This function returns external representation of the track parameters
959 // at the inner layer of TPC
9b859005 960 //---------------------------------------------------------------------
c0b978f0 961 if (!fIp) return kFALSE;
962 alpha=fIp->GetAlpha();
c9ec41e8 963 x=fIp->GetX();
964 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
c0b978f0 965 return kTRUE;
9b859005 966}
967
c0b978f0 968Bool_t
969AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
c9ec41e8 970 //---------------------------------------------------------------------
971 // This function returns external representation of the cov. matrix
972 // at the inner layer of TPC
973 //---------------------------------------------------------------------
c0b978f0 974 if (!fIp) return kFALSE;
c9ec41e8 975 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
c0b978f0 976 return kTRUE;
9b859005 977}
978
c0b978f0 979Bool_t
980AliESDtrack::GetOuterExternalParameters
981 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
982 //---------------------------------------------------------------------
c9ec41e8 983 // This function returns external representation of the track parameters
984 // at the inner layer of TRD
a866ac60 985 //---------------------------------------------------------------------
c0b978f0 986 if (!fOp) return kFALSE;
987 alpha=fOp->GetAlpha();
c9ec41e8 988 x=fOp->GetX();
989 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
c0b978f0 990 return kTRUE;
a866ac60 991}
c9ec41e8 992
c0b978f0 993Bool_t
994AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
a866ac60 995 //---------------------------------------------------------------------
c9ec41e8 996 // This function returns external representation of the cov. matrix
997 // at the inner layer of TRD
a866ac60 998 //---------------------------------------------------------------------
c0b978f0 999 if (!fOp) return kFALSE;
c9ec41e8 1000 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
c0b978f0 1001 return kTRUE;
a866ac60 1002}
1003
98937d93 1004Int_t AliESDtrack::GetNcls(Int_t idet) const
1005{
1006 // Get number of clusters by subdetector index
1007 //
1008 Int_t ncls = 0;
1009 switch(idet){
1010 case 0:
1011 ncls = fITSncls;
1012 break;
1013 case 1:
1014 ncls = fTPCncls;
1015 break;
1016 case 2:
1017 ncls = fTRDncls;
1018 break;
1019 case 3:
ce3f4882 1020 if (fTOFindex != -1)
98937d93 1021 ncls = 1;
1022 break;
1023 default:
1024 break;
1025 }
1026 return ncls;
1027}
1028
ef7253ac 1029Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
98937d93 1030{
1031 // Get cluster index array by subdetector index
1032 //
1033 Int_t ncls = 0;
1034 switch(idet){
1035 case 0:
1036 ncls = GetITSclusters(idx);
1037 break;
1038 case 1:
ef7253ac 1039 ncls = GetTPCclusters(idx);
98937d93 1040 break;
1041 case 2:
1042 ncls = GetTRDclusters(idx);
1043 break;
1044 case 3:
ce3f4882 1045 if (fTOFindex != -1) {
1046 idx[0] = fTOFindex;
98937d93 1047 ncls = 1;
1048 }
1049 break;
313af949 1050 case 4: //PHOS
1051 break;
1052 case 5:
1053 if (fHMPIDcluIdx != 0) {
1054 idx[0] = GetHMPIDcluIdx();
1055 ncls = 1;
1056 }
1057 break;
1058 case 6: //EMCAL
1059 break;
98937d93 1060 default:
1061 break;
1062 }
1063 return ncls;
1064}
1065
ae982df3 1066//_______________________________________________________________________
ae982df3 1067void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
4427806c 1068 // Returns the array with integrated times for each particle hypothesis
304864ab 1069 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
ae982df3 1070}
1071
1072//_______________________________________________________________________
1073void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
4427806c 1074 // Sets the array with integrated times for each particle hypotesis
304864ab 1075 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
ae982df3 1076}
1077
1078//_______________________________________________________________________
4427806c 1079void AliESDtrack::SetITSpid(const Double_t *p) {
1080 // Sets values for the probability of each particle type (in ITS)
d27bbc79 1081 SetPIDValues(fITSr,p,AliPID::kSPECIES);
c630aafd 1082 SetStatus(AliESDtrack::kITSpid);
1083}
1084
1085//_______________________________________________________________________
1086void AliESDtrack::GetITSpid(Double_t *p) const {
4427806c 1087 // Gets the probability of each particle type (in ITS)
304864ab 1088 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
c630aafd 1089}
1090
1091//_______________________________________________________________________
562dd0b4 1092Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
ae982df3 1093 //---------------------------------------------------------------------
1094 // This function returns indices of the assgined ITS clusters
1095 //---------------------------------------------------------------------
15e85efa 1096 if (idx!=0) {
1097 Int_t *index=fFriendTrack->GetITSindices();
1098 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) idx[i]=index[i];
1099 }
ae982df3 1100 return fITSncls;
1101}
1102
1103//_______________________________________________________________________
89f1b176 1104Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1105 Float_t &xloc,Float_t &zloc) const {
1106 //----------------------------------------------------------------------
1107 // This function encodes in the module number also the status of cluster association
1108 // "status" can have the following values:
1109 // 1 "found" (cluster is associated),
1110 // 2 "dead" (module is dead from OCDB),
1111 // 3 "skipped" (module or layer forced to be skipped),
1112 // 4 "outinz" (track out of z acceptance),
1113 // 5 "nocls" (no clusters in the road),
1114 // 6 "norefit" (cluster rejected during refit),
1115 // 7 "deadzspd" (holes in z in SPD)
1116 // Also given are the coordinates of the crossing point of track and module
1117 // (in the local module ref. system)
1118 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1119 //----------------------------------------------------------------------
1120
1121 if(fITSModule[ilayer]==-1) {
1122 AliError("fModule was not set !");
1123 idet = -1;
1124 status=0;
1125 xloc=-99.; zloc=-99.;
1126 return kFALSE;
1127 }
1128
1129 Int_t module = fITSModule[ilayer];
1130
1131 idet = Int_t(module/1000000);
1132
1133 module -= idet*1000000;
1134
1135 status = Int_t(module/100000);
1136
1137 module -= status*100000;
1138
1139 Int_t signs = Int_t(module/10000);
1140
1141 module-=signs*10000;
1142
1143 Int_t xInt = Int_t(module/100);
1144 module -= xInt*100;
1145
1146 Int_t zInt = module;
1147
1148 if(signs==1) { xInt*=1; zInt*=1; }
1149 if(signs==2) { xInt*=1; zInt*=-1; }
1150 if(signs==3) { xInt*=-1; zInt*=1; }
1151 if(signs==4) { xInt*=-1; zInt*=-1; }
1152
1153 xloc = 0.1*(Float_t)xInt;
1154 zloc = 0.1*(Float_t)zInt;
1155
1156 if(status==4) idet = -1;
1157
1158 return kTRUE;
1159}
1160
1161//_______________________________________________________________________
562dd0b4 1162UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
ae982df3 1163 //---------------------------------------------------------------------
1164 // This function returns indices of the assgined ITS clusters
1165 //---------------------------------------------------------------------
15e85efa 1166 if (idx!=0) {
1167 Int_t *index=fFriendTrack->GetTPCindices();
1168 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1169 }
ae982df3 1170 return fTPCncls;
1171}
8c6a71ab 1172
562dd0b4 1173Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
81e97e0d 1174 //
1175 // GetDensity of the clusters on given region between row0 and row1
1176 // Dead zone effect takin into acoount
1177 //
1178 Int_t good = 0;
1179 Int_t found = 0;
1180 //
15e85efa 1181 Int_t *index=fFriendTrack->GetTPCindices();
81e97e0d 1182 for (Int_t i=row0;i<=row1;i++){
15e85efa 1183 Int_t idx = index[i];
1184 if (idx!=-1) good++; // track outside of dead zone
1185 if (idx>0) found++;
81e97e0d 1186 }
1187 Float_t density=0.5;
1188 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1189 return density;
1190}
c84a5e9e 1191
8c6a71ab 1192//_______________________________________________________________________
1193void AliESDtrack::SetTPCpid(const Double_t *p) {
4427806c 1194 // Sets values for the probability of each particle type (in TPC)
d27bbc79 1195 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
8c6a71ab 1196 SetStatus(AliESDtrack::kTPCpid);
1197}
1198
1199//_______________________________________________________________________
1200void AliESDtrack::GetTPCpid(Double_t *p) const {
4427806c 1201 // Gets the probability of each particle type (in TPC)
304864ab 1202 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
8c6a71ab 1203}
1204
1205//_______________________________________________________________________
562dd0b4 1206UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
bb2ceb1f 1207 //---------------------------------------------------------------------
1208 // This function returns indices of the assgined TRD clusters
1209 //---------------------------------------------------------------------
15e85efa 1210 if (idx!=0) {
1211 Int_t *index=fFriendTrack->GetTRDindices();
1212 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1213 }
bb2ceb1f 1214 return fTRDncls;
1215}
1216
1217//_______________________________________________________________________
5bc3e158 1218UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1219 //---------------------------------------------------------------------
1220 // This function returns indices of the assigned TRD tracklets
1221 //---------------------------------------------------------------------
1222 if (idx!=0) {
1223 Int_t *index=fFriendTrack->GetTRDindices();
1224 for (Int_t i=0; i<6/*AliESDfriendTrack::kMaxTRDcluster*/; i++) idx[i]=index[i];
1225 }
1226 return fTRDncls;
1227}
1228
1229//_______________________________________________________________________
c630aafd 1230void AliESDtrack::SetTRDpid(const Double_t *p) {
4427806c 1231 // Sets values for the probability of each particle type (in TRD)
d27bbc79 1232 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
c630aafd 1233 SetStatus(AliESDtrack::kTRDpid);
1234}
1235
1236//_______________________________________________________________________
1237void AliESDtrack::GetTRDpid(Double_t *p) const {
4427806c 1238 // Gets the probability of each particle type (in TRD)
304864ab 1239 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
c630aafd 1240}
1241
1242//_______________________________________________________________________
79e94bf8 1243void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1244{
4427806c 1245 // Sets the probability of particle type iSpecies to p (in TRD)
79e94bf8 1246 fTRDr[iSpecies] = p;
1247}
1248
562dd0b4 1249Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
79e94bf8 1250{
4427806c 1251 // Returns the probability of particle type iSpecies (in TRD)
79e94bf8 1252 return fTRDr[iSpecies];
1253}
1254
6984f7c1 1255void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1256 //Sets the number of slices used for PID
1257 if (fTRDnSlices != 0) return;
1258 fTRDnSlices=kTRDnPlanes*n;
1259 fTRDslices=new Double32_t[fTRDnSlices];
1260 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=-1.;
1261}
1262
1263void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1264 //Sets the charge q in the slice of the plane
1265 Int_t ns=GetNumberOfTRDslices();
1266 if (ns==0) {
1267 AliError("No TRD slices allocated for this track !");
1268 return;
1269 }
1270
1271 if ((plane<0) || (plane>=kTRDnPlanes)) {
1272 AliError("Wrong TRD plane !");
1273 return;
1274 }
1275 if ((slice<0) || (slice>=ns)) {
1276 AliError("Wrong TRD slice !");
1277 return;
1278 }
1279 Int_t n=plane*ns + slice;
1280 fTRDslices[n]=q;
1281}
1282
1283Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1284 //Gets the charge from the slice of the plane
1285 Int_t ns=GetNumberOfTRDslices();
1286 if (ns==0) {
1287 //AliError("No TRD slices allocated for this track !");
1288 return -1.;
1289 }
1290
1291 if ((plane<0) || (plane>=kTRDnPlanes)) {
1292 AliError("Wrong TRD plane !");
1293 return -1.;
1294 }
1295 if ((slice<-1) || (slice>=ns)) {
1296 //AliError("Wrong TRD slice !");
1297 return -1.;
1298 }
1299
1300 if (slice==-1) {
1301 Double_t q=0.;
1302 for (Int_t i=0; i<ns; i++) q+=fTRDslices[plane*ns + i];
1303 return q/ns;
1304 }
1305
1306 return fTRDslices[plane*ns + slice];
1307}
1308
1309
79e94bf8 1310//_______________________________________________________________________
c630aafd 1311void AliESDtrack::SetTOFpid(const Double_t *p) {
4427806c 1312 // Sets the probability of each particle type (in TOF)
d27bbc79 1313 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
c630aafd 1314 SetStatus(AliESDtrack::kTOFpid);
1315}
1316
1317//_______________________________________________________________________
51ad6848 1318void AliESDtrack::SetTOFLabel(const Int_t *p) {
1319 // Sets (in TOF)
1320 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1321}
1322
1323//_______________________________________________________________________
c630aafd 1324void AliESDtrack::GetTOFpid(Double_t *p) const {
4427806c 1325 // Gets probabilities of each particle type (in TOF)
304864ab 1326 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
c630aafd 1327}
1328
51ad6848 1329//_______________________________________________________________________
1330void AliESDtrack::GetTOFLabel(Int_t *p) const {
1331 // Gets (in TOF)
1332 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
1333}
1334
1335//_______________________________________________________________________
1336void AliESDtrack::GetTOFInfo(Float_t *info) const {
1337 // Gets (in TOF)
1338 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
1339}
1340
1341//_______________________________________________________________________
1342void AliESDtrack::SetTOFInfo(Float_t*info) {
1343 // Gets (in TOF)
1344 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
1345}
1346
4a78b8c5 1347
1348
1349//_______________________________________________________________________
f4b3bbb7 1350void AliESDtrack::SetHMPIDpid(const Double_t *p) {
1351 // Sets the probability of each particle type (in HMPID)
1352 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
1353 SetStatus(AliESDtrack::kHMPIDpid);
4a78b8c5 1354}
1355
1356//_______________________________________________________________________
f4b3bbb7 1357void AliESDtrack::GetHMPIDpid(Double_t *p) const {
1358 // Gets probabilities of each particle type (in HMPID)
1359 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
4a78b8c5 1360}
1361
1362
1363
c630aafd 1364//_______________________________________________________________________
8c6a71ab 1365void AliESDtrack::SetESDpid(const Double_t *p) {
4427806c 1366 // Sets the probability of each particle type for the ESD track
d27bbc79 1367 SetPIDValues(fR,p,AliPID::kSPECIES);
8c6a71ab 1368 SetStatus(AliESDtrack::kESDpid);
1369}
1370
1371//_______________________________________________________________________
1372void AliESDtrack::GetESDpid(Double_t *p) const {
4427806c 1373 // Gets probability of each particle type for the ESD track
304864ab 1374 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
8c6a71ab 1375}
1376
ac2f7574 1377//_______________________________________________________________________
49d13e89 1378Bool_t AliESDtrack::RelateToVertex
1379(const AliESDVertex *vtx, Double_t b, Double_t maxd) {
1380 //
1381 // Try to relate this track to the vertex "vtx",
1382 // if the (rough) transverse impact parameter is not bigger then "maxd".
1383 // Magnetic field is "b" (kG).
1384 //
1385 // a) The track gets extapolated to the DCA to the vertex.
1386 // b) The impact parameters and their covariance matrix are calculated.
1387 // c) An attempt to constrain this track to the vertex is done.
1388 //
1389 // In the case of success, the returned value is kTRUE
1390 // (otherwise, it's kFALSE)
1391 //
b5d34a4c 1392
1393 if (!vtx) return kFALSE;
1394
e99a34df 1395 Double_t dz[2],cov[3];
1396 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1397
1398 fD = dz[0];
1399 fZ = dz[1];
1400 fCdd = cov[0];
1401 fCdz = cov[1];
1402 fCzz = cov[2];
49d13e89 1403
e99a34df 1404 Double_t covar[6]; vtx->GetCovMatrix(covar);
1405 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1406 Double_t c[3]={covar[2],0.,covar[5]};
3231f9e5 1407
e99a34df 1408 Double_t chi2=GetPredictedChi2(p,c);
1409 if (chi2>77.) return kFALSE;
49d13e89 1410
e99a34df 1411 delete fCp;
1412 fCp=new AliExternalTrackParam(*this);
49d13e89 1413
e99a34df 1414 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
1415
1416 fCchi2=chi2;
49d13e89 1417 return kTRUE;
1418}
1419
1420//_______________________________________________________________________
ac2f7574 1421void AliESDtrack::Print(Option_t *) const {
1422 // Prints info on the track
1423
5f7789fc 1424 printf("ESD track info\n") ;
304864ab 1425 Double_t p[AliPID::kSPECIESN] ;
ac2f7574 1426 Int_t index = 0 ;
1427 if( IsOn(kITSpid) ){
1428 printf("From ITS: ") ;
1429 GetITSpid(p) ;
304864ab 1430 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 1431 printf("%f, ", p[index]) ;
1432 printf("\n signal = %f\n", GetITSsignal()) ;
1433 }
1434 if( IsOn(kTPCpid) ){
1435 printf("From TPC: ") ;
1436 GetTPCpid(p) ;
304864ab 1437 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 1438 printf("%f, ", p[index]) ;
1439 printf("\n signal = %f\n", GetTPCsignal()) ;
1440 }
1441 if( IsOn(kTRDpid) ){
1442 printf("From TRD: ") ;
1443 GetTRDpid(p) ;
304864ab 1444 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 1445 printf("%f, ", p[index]) ;
6984f7c1 1446 printf("\n signal = %f\n", GetTRDsignal()) ;
ac2f7574 1447 }
1448 if( IsOn(kTOFpid) ){
1449 printf("From TOF: ") ;
1450 GetTOFpid(p) ;
304864ab 1451 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 1452 printf("%f, ", p[index]) ;
1453 printf("\n signal = %f\n", GetTOFsignal()) ;
1454 }
f4b3bbb7 1455 if( IsOn(kHMPIDpid) ){
1456 printf("From HMPID: ") ;
1457 GetHMPIDpid(p) ;
304864ab 1458 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 1459 printf("%f, ", p[index]) ;
f4b3bbb7 1460 printf("\n signal = %f\n", GetHMPIDsignal()) ;
ac2f7574 1461 }
ac2f7574 1462}
6c94f330 1463
0c19adf7 1464
1465//
1466// Draw functionality
1467// Origin: Marian Ivanov, Marian.Ivanov@cern.ch
1468//
1469void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
1470 //
1471 // Fill points in the polymarker
1472 //
1473 TObjArray arrayRef;
1474 arrayRef.AddLast(new AliExternalTrackParam(*this));
1475 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
1476 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
1477 //
1478 Double_t mpos[3]={0,0,0};
1479 Int_t entries=arrayRef.GetEntries();
1480 for (Int_t i=0;i<entries;i++){
1481 Double_t pos[3];
1482 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
1483 mpos[0]+=pos[0]/entries;
1484 mpos[1]+=pos[1]/entries;
1485 mpos[2]+=pos[2]/entries;
1486 }
1487 // Rotate to the mean position
1488 //
1489 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
1490 for (Int_t i=0;i<entries;i++){
1491 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
1492 if (!res) delete arrayRef.RemoveAt(i);
1493 }
1494 Int_t counter=0;
1495 for (Double_t r=minR; r<maxR; r+=stepR){
1496 Double_t sweight=0;
1497 Double_t mlpos[3]={0,0,0};
1498 for (Int_t i=0;i<entries;i++){
1499 Double_t point[3]={0,0,0};
1500 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
1501 if (!param) continue;
1502 if (param->GetXYZAt(r,magF,point)){
1503 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
1504 sweight+=weight;
1505 mlpos[0]+=point[0]*weight;
1506 mlpos[1]+=point[1]*weight;
1507 mlpos[2]+=point[2]*weight;
1508 }
1509 }
1510 if (sweight>0){
1511 mlpos[0]/=sweight;
1512 mlpos[1]/=sweight;
1513 mlpos[2]/=sweight;
1514 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
1515 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
1516 counter++;
1517 }
1518 }
1519}