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