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