1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
15 //-----------------------------------------------------------------
16 // Implementation of the ESD track class
17 // ESD = Event Summary Data
18 // This is the class to deal with during the phisics analysis of data
19 // Origin: Iouri Belikov, CERN
20 // e-mail: Jouri.Belikov@cern.ch
24 // What do you need to know before starting analysis
25 // (by Marian Ivanov: marian.ivanov@cern.ch)
29 // 1. What is the AliESDtrack
30 // 2. What informations do we store
31 // 3. How to use the information for analysis
34 // 1.AliESDtrack is the container of the information about the track/particle
35 // reconstructed during Barrel Tracking.
36 // The track information is propagated from one tracking detector to
37 // other using the functionality of AliESDtrack - Current parameters.
39 // No global fit model is used.
40 // Barrel tracking use Kalman filtering technique, it gives optimal local
41 // track parameters at given point under certian assumptions.
43 // Kalman filter take into account additional effect which are
44 // difficult to handle using global fit.
46 // a.) Multiple scattering
48 // c.) Non homogenous magnetic field
50 // In general case, following barrel detectors are contributing to
51 // the Kalman track information:
56 // In general 3 reconstruction itteration are performed:
57 // 1. Find tracks - sequence TPC->ITS
58 // 2. PropagateBack - sequence ITS->TPC->TRD -> Outer PID detectors
59 // 3. Refit invward - sequence TRD->TPC->ITS
60 // The current tracks are updated after each detector (see bellow).
61 // In specical cases a track sanpshots are stored.
64 // For some type of analysis (+visualization) track local parameters at
65 // different position are neccesary. A snapshots during the track
66 // propagation are created.
67 // (See AliExternalTrackParam class for desctiption of variables and
70 // a. Current parameters - class itself (AliExternalTrackParam)
71 // Contributors: general case TRD->TPC->ITS
72 // Preferable usage: Decission - primary or secondary track
73 // NOTICE - By default the track parameters are stored at the DCA point
74 // to the primary vertex. optimal for primary tracks,
75 // far from optimal for secondary tracks.
76 // b. Constrained parameters - Kalman information updated with
77 // the Primary vertex information
78 // Contributors: general case TRD->TPC->ITS
79 // Preferable usage: Use only for tracks selected as primary
80 // NOTICE - not real constrain - taken as additional measurement
81 // with corresponding error
83 // const AliExternalTrackParam *GetConstrainedParam() const {return fCp;}
84 // c. Inner parameters - Track parameters at inner wall of the TPC
85 // Contributors: general case TRD->TPC
87 // const AliExternalTrackParam *GetInnerParam() const { return fIp;}
89 // d. TPCinnerparam - contributors - TPC only
91 // Preferable usage: Requested for HBT study
92 // (smaller correlations as using also ITS information)
93 // NOTICE - the track parameters are propagated to the DCA to
95 // Optimal for primary, far from optimal for secondary tracks
97 // const AliExternalTrackParam *GetTPCInnerParam() const {return fTPCInner;}
99 // e. Outer parameters -
100 // Contributors- general case - ITS-> TPC -> TRD
101 // The last point - Outer parameters radius is determined
102 // e.a) Local inclination angle bigger than threshold -
103 // Low momenta tracks
104 // e.a) Catastrofic energy losss in material
105 // e.b) Not further improvement (no space points)
107 // a.) Tracking: Starting parameter for Refit inward
110 // NOTICE: Should be not used for the physic analysis
112 // const AliExternalTrackParam *GetOuterParam() const { return fOp;}
114 //-----------------------------------------------------------------
117 #include <TParticle.h>
118 #include <TDatabasePDG.h>
120 #include "AliESDVertex.h"
121 #include "AliESDtrack.h"
122 #include "AliESDEvent.h"
123 #include "AliKalmanTrack.h"
124 #include "AliVTrack.h"
126 #include "AliTrackPointArray.h"
127 #include "TPolyMarker3D.h"
129 ClassImp(AliESDtrack)
131 void SetPIDValues(Double_t * dest, const Double_t * src, Int_t n) {
132 // This function copies "n" PID weights from "scr" to "dest"
133 // and normalizes their sum to 1 thus producing conditional probabilities.
134 // The negative weights are set to 0.
135 // In case all the weights are non-positive they are replaced by
136 // uniform probabilities
140 Float_t uniform = 1./(Float_t)n;
143 for (Int_t i=0; i<n; i++)
153 for (Int_t i=0; i<n; i++) dest[i] /= sum;
155 for (Int_t i=0; i<n; i++) dest[i] = uniform;
158 //_______________________________________________________________________
159 AliESDtrack::AliESDtrack() :
160 AliExternalTrackParam(),
166 fFriendTrack(new AliESDfriendTrack()),
167 fTPCClusterMap(159),//number of padrows
168 fTPCSharedMap(159),//number of padrows
179 fCaloIndex(kEMCALNoMatch),
185 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
188 fCdd(0),fCdz(0),fCzz(0),
204 fTOFsignalToT(99999),
205 fTOFsignalRaw(99999),
229 fVertexID(-2),// -2 means an orphan track
233 // The default ESD constructor
236 for (i=0; i<AliPID::kSPECIES; i++) {
246 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
247 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
248 for (i=0;i<kTRDnPlanes;i++) {
251 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
252 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
253 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
254 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
255 for (i=0;i<12;i++) {fITSModule[i]=-1;}
258 //_______________________________________________________________________
259 AliESDtrack::AliESDtrack(const AliESDtrack& track):
260 AliExternalTrackParam(track),
267 fTPCClusterMap(track.fTPCClusterMap),
268 fTPCSharedMap(track.fTPCSharedMap),
269 fFlags(track.fFlags),
271 fLabel(track.fLabel),
272 fITSLabel(track.fITSLabel),
273 fTPCLabel(track.fTPCLabel),
274 fTRDLabel(track.fTRDLabel),
275 fTOFCalChannel(track.fTOFCalChannel),
276 fTOFindex(track.fTOFindex),
277 fHMPIDqn(track.fHMPIDqn),
278 fHMPIDcluIdx(track.fHMPIDcluIdx),
279 fCaloIndex(track.fCaloIndex),
280 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
281 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
282 fHMPIDsignal(track.fHMPIDsignal),
283 fTrackLength(track.fTrackLength),
284 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
285 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
286 fCchi2TPC(track.fCchi2TPC),
287 fD(track.fD),fZ(track.fZ),
288 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
289 fCchi2(track.fCchi2),
290 fITSchi2(track.fITSchi2),
291 fTPCchi2(track.fTPCchi2),
292 fTPCchi2Iter1(track.fTPCchi2Iter1),
293 fTRDchi2(track.fTRDchi2),
294 fTOFchi2(track.fTOFchi2),
295 fHMPIDchi2(track.fHMPIDchi2),
296 fGlobalChi2(track.fGlobalChi2),
297 fITSsignal(track.fITSsignal),
298 fTPCsignal(track.fTPCsignal),
299 fTPCsignalS(track.fTPCsignalS),
300 fTRDsignal(track.fTRDsignal),
301 fTRDQuality(track.fTRDQuality),
302 fTRDBudget(track.fTRDBudget),
303 fTOFsignal(track.fTOFsignal),
304 fTOFsignalToT(track.fTOFsignalToT),
305 fTOFsignalRaw(track.fTOFsignalRaw),
306 fTOFsignalDz(track.fTOFsignalDz),
307 fTOFsignalDx(track.fTOFsignalDx),
308 fTOFdeltaBC(track.fTOFdeltaBC),
309 fTOFl0l1(track.fTOFl0l1),
310 fCaloDx(track.fCaloDx),
311 fCaloDz(track.fCaloDz),
312 fHMPIDtrkX(track.fHMPIDtrkX),
313 fHMPIDtrkY(track.fHMPIDtrkY),
314 fHMPIDmipX(track.fHMPIDmipX),
315 fHMPIDmipY(track.fHMPIDmipY),
316 fTPCncls(track.fTPCncls),
317 fTPCnclsF(track.fTPCnclsF),
318 fTPCsignalN(track.fTPCsignalN),
319 fTPCnclsIter1(track.fTPCnclsIter1),
320 fTPCnclsFIter1(track.fTPCnclsIter1),
321 fITSncls(track.fITSncls),
322 fITSClusterMap(track.fITSClusterMap),
323 fITSSharedMap(track.fITSSharedMap),
324 fTRDncls(track.fTRDncls),
325 fTRDncls0(track.fTRDncls0),
326 fTRDntracklets(track.fTRDntracklets),
327 fTRDnSlices(track.fTRDnSlices),
329 fVertexID(track.fVertexID),
330 fESDEvent(track.fESDEvent)
335 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
336 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
338 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
340 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
341 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
342 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
343 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
344 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
346 for (Int_t i=0;i<kTRDnPlanes;i++) {
347 fTRDTimBin[i]=track.fTRDTimBin[i];
351 fTRDslices=new Double32_t[fTRDnSlices];
352 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
355 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
356 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
357 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
358 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
359 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
360 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
362 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
363 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
364 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
365 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
366 if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
368 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
371 //_______________________________________________________________________
372 AliESDtrack::AliESDtrack(const AliVTrack *track) :
373 AliExternalTrackParam(track),
380 fTPCClusterMap(159),//number of padrows
381 fTPCSharedMap(159),//number of padrows
392 fCaloIndex(kEMCALNoMatch),
398 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
401 fCdd(0),fCdz(0),fCzz(0),
417 fTOFsignalToT(99999),
418 fTOFsignalRaw(99999),
442 fVertexID(-2), // -2 means an orphan track
446 // ESD track from AliVTrack.
447 // This is not a copy constructor !
450 if (track->InheritsFrom("AliExternalTrackParam")) {
451 AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
452 AliWarning("Calling the default constructor...");
457 // Reset all the arrays
459 for (i=0; i<AliPID::kSPECIES; i++) {
469 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
470 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
471 for (i=0;i<kTRDnPlanes;i++) {
474 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
475 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
476 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
477 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
478 for (i=0;i<12;i++) {fITSModule[i]=-1;}
481 SetID(track->GetID());
483 // Set ITS cluster map
484 fITSClusterMap=track->GetITSClusterMap();
489 if(HasPointOnITSLayer(i)) fITSncls++;
493 fTPCncls=track->GetTPCNcls();
496 // Set the combined PID
497 const Double_t *pid = track->PID();
499 for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
501 // AliESD track label
502 SetLabel(track->GetLabel());
504 SetStatus(track->GetStatus());
507 //_______________________________________________________________________
508 AliESDtrack::AliESDtrack(TParticle * part) :
509 AliExternalTrackParam(),
516 fTPCClusterMap(159),//number of padrows
517 fTPCSharedMap(159),//number of padrows
528 fCaloIndex(kEMCALNoMatch),
534 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
537 fCdd(0),fCdz(0),fCzz(0),
553 fTOFsignalToT(99999),
554 fTOFsignalRaw(99999),
578 fVertexID(-2), // -2 means an orphan track
582 // ESD track from TParticle
585 // Reset all the arrays
587 for (i=0; i<AliPID::kSPECIES; i++) {
597 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
598 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
599 for (i=0;i<kTRDnPlanes;i++) {
602 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
603 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
604 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
605 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
606 for (i=0;i<12;i++) {fITSModule[i]=-1;}
608 // Calculate the AliExternalTrackParam content
615 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
616 alpha = part->Phi()*180./TMath::Pi();
617 if (alpha<0) alpha+= 360.;
618 if (alpha>360) alpha -= 360.;
620 Int_t sector = (Int_t)(alpha/20.);
621 alpha = 10. + 20.*sector;
623 alpha *= TMath::Pi();
625 // Covariance matrix: no errors, the parameters are exact
626 for (i=0; i<15; i++) covar[i]=0.;
628 // Get the vertex of origin and the momentum
629 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
630 TVector3 mom(part->Px(),part->Py(),part->Pz());
632 // Rotate to the local coordinate system (TPC sector)
636 // X of the referense plane
639 Int_t pdgCode = part->GetPdgCode();
642 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
646 param[2] = TMath::Sin(mom.Phi());
647 param[3] = mom.Pz()/mom.Pt();
648 param[4] = TMath::Sign(1/mom.Pt(),charge);
650 // Set AliExternalTrackParam
651 Set(xref, alpha, param, covar);
656 switch (TMath::Abs(pdgCode)) {
682 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
683 if (indexPID < AliPID::kSPECIES) {
689 fHMPIDr[indexPID]=1.;
692 // AliESD track label
693 SetLabel(part->GetUniqueID());
697 //_______________________________________________________________________
698 AliESDtrack::~AliESDtrack(){
700 // This is destructor according Coding Conventrions
702 //printf("Delete track\n");
713 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
716 if(&source == this) return *this;
717 AliExternalTrackParam::operator=(source);
721 // we have the trackparam: assign or copy construct
722 if(fCp)*fCp = *source.fCp;
723 else fCp = new AliExternalTrackParam(*source.fCp);
726 // no track param delete the old one
732 // we have the trackparam: assign or copy construct
733 if(fIp)*fIp = *source.fIp;
734 else fIp = new AliExternalTrackParam(*source.fIp);
737 // no track param delete the old one
743 if(source.fTPCInner){
744 // we have the trackparam: assign or copy construct
745 if(fTPCInner) *fTPCInner = *source.fTPCInner;
746 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
749 // no track param delete the old one
750 if(fTPCInner)delete fTPCInner;
756 // we have the trackparam: assign or copy construct
757 if(fOp) *fOp = *source.fOp;
758 else fOp = new AliExternalTrackParam(*source.fOp);
761 // no track param delete the old one
768 // we have the trackparam: assign or copy construct
769 if(fHMPIDp) *fHMPIDp = *source.fHMPIDp;
770 else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
773 // no track param delete the old one
774 if(fHMPIDp)delete fHMPIDp;
779 // copy also the friend track
780 // use copy constructor
781 if(source.fFriendTrack){
782 // we have the trackparam: assign or copy construct
783 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
786 // no track param delete the old one
787 delete fFriendTrack; fFriendTrack= 0;
790 fTPCClusterMap = source.fTPCClusterMap;
791 fTPCSharedMap = source.fTPCSharedMap;
793 fFlags = source.fFlags;
795 fLabel = source.fLabel;
796 fITSLabel = source.fITSLabel;
797 for(int i = 0; i< 12;++i){
798 fITSModule[i] = source.fITSModule[i];
800 fTPCLabel = source.fTPCLabel;
801 fTRDLabel = source.fTRDLabel;
802 for(int i = 0; i< 3;++i){
803 fTOFLabel[i] = source.fTOFLabel[i];
805 fTOFCalChannel = source.fTOFCalChannel;
806 fTOFindex = source.fTOFindex;
807 fHMPIDqn = source.fHMPIDqn;
808 fHMPIDcluIdx = source.fHMPIDcluIdx;
809 fCaloIndex = source.fCaloIndex;
811 for(int i = 0; i< 3;++i){
812 fKinkIndexes[i] = source.fKinkIndexes[i];
813 fV0Indexes[i] = source.fV0Indexes[i];
816 for(int i = 0; i< AliPID::kSPECIES;++i){
817 fR[i] = source.fR[i];
818 fITSr[i] = source.fITSr[i];
819 fTPCr[i] = source.fTPCr[i];
820 fTRDr[i] = source.fTRDr[i];
821 fTOFr[i] = source.fTOFr[i];
822 fHMPIDr[i] = source.fHMPIDr[i];
823 fTrackTime[i] = source.fTrackTime[i];
826 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
827 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
828 fHMPIDsignal = source.fHMPIDsignal;
831 fTrackLength = source. fTrackLength;
832 fdTPC = source.fdTPC;
833 fzTPC = source.fzTPC;
834 fCddTPC = source.fCddTPC;
835 fCdzTPC = source.fCdzTPC;
836 fCzzTPC = source.fCzzTPC;
837 fCchi2TPC = source.fCchi2TPC;
844 fCchi2 = source.fCchi2;
846 fITSchi2 = source.fITSchi2;
847 fTPCchi2 = source.fTPCchi2;
848 fTPCchi2Iter1 = source.fTPCchi2Iter1;
849 fTRDchi2 = source.fTRDchi2;
850 fTOFchi2 = source.fTOFchi2;
851 fHMPIDchi2 = source.fHMPIDchi2;
853 fGlobalChi2 = source.fGlobalChi2;
855 fITSsignal = source.fITSsignal;
856 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
857 fTPCsignal = source.fTPCsignal;
858 fTPCsignalS = source.fTPCsignalS;
859 for(int i = 0; i< 4;++i){
860 fTPCPoints[i] = source.fTPCPoints[i];
862 fTRDsignal = source.fTRDsignal;
864 for(int i = 0;i < kTRDnPlanes;++i){
865 fTRDTimBin[i] = source.fTRDTimBin[i];
871 fTRDnSlices=source.fTRDnSlices;
873 fTRDslices=new Double32_t[fTRDnSlices];
874 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
877 fTRDQuality = source.fTRDQuality;
878 fTRDBudget = source.fTRDBudget;
879 fTOFsignal = source.fTOFsignal;
880 fTOFsignalToT = source.fTOFsignalToT;
881 fTOFsignalRaw = source.fTOFsignalRaw;
882 fTOFsignalDz = source.fTOFsignalDz;
883 fTOFsignalDx = source.fTOFsignalDx;
884 fTOFdeltaBC = source.fTOFdeltaBC;
885 fTOFl0l1 = source.fTOFl0l1;
887 for(int i = 0;i<10;++i){
888 fTOFInfo[i] = source.fTOFInfo[i];
891 fHMPIDtrkX = source.fHMPIDtrkX;
892 fHMPIDtrkY = source.fHMPIDtrkY;
893 fHMPIDmipX = source.fHMPIDmipX;
894 fHMPIDmipY = source.fHMPIDmipY;
896 fTPCncls = source.fTPCncls;
897 fTPCnclsF = source.fTPCnclsF;
898 fTPCsignalN = source.fTPCsignalN;
899 fTPCnclsIter1 = source.fTPCnclsIter1;
900 fTPCnclsFIter1 = source.fTPCnclsFIter1;
902 fITSncls = source.fITSncls;
903 fITSClusterMap = source.fITSClusterMap;
904 fITSSharedMap = source.fITSSharedMap;
905 fTRDncls = source.fTRDncls;
906 fTRDncls0 = source.fTRDncls0;
907 fTRDntracklets = source.fTRDntracklets;
908 fVertexID = source.fVertexID;
914 void AliESDtrack::Copy(TObject &obj) const {
916 // this overwrites the virtual TOBject::Copy()
917 // to allow run time copying without casting
920 if(this==&obj)return;
921 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
922 if(!robj)return; // not an AliESDtrack
929 void AliESDtrack::AddCalibObject(TObject * object){
931 // add calib object to the list
933 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
934 fFriendTrack->AddCalibObject(object);
937 TObject * AliESDtrack::GetCalibObject(Int_t index){
939 // return calib objct at given position
941 if (!fFriendTrack) return 0;
942 return fFriendTrack->GetCalibObject(index);
946 Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
948 // Fills the information of the TPC-only first reconstruction pass
949 // into the passed ESDtrack object. For consistency fTPCInner is also filled
954 // For data produced before r26675
955 // RelateToVertexTPC was not properly called during reco
956 // so you'll have to call it again, before FillTPCOnlyTrack
957 // Float_t p[2],cov[3];
958 // track->GetImpactParametersTPC(p,cov);
959 // if(p[0]==0&&p[1]==0) // <- Default values
960 // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
963 if(!fTPCInner)return kFALSE;
965 // fill the TPC track params to the global track parameters
966 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
969 track.fCdd = fCddTPC;
970 track.fCdz = fCdzTPC;
971 track.fCzz = fCzzTPC;
973 // copy the inner params
974 if(track.fIp) *track.fIp = *fIp;
975 else track.fIp = new AliExternalTrackParam(*fIp);
977 // copy the TPCinner parameters
978 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
979 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
982 track.fCddTPC = fCddTPC;
983 track.fCdzTPC = fCdzTPC;
984 track.fCzzTPC = fCzzTPC;
985 track.fCchi2TPC = fCchi2TPC;
987 // copy all other TPC specific parameters
989 // replace label by TPC label
990 track.fLabel = fTPCLabel;
991 track.fTPCLabel = fTPCLabel;
993 track.fTPCchi2 = fTPCchi2;
994 track.fTPCchi2Iter1 = fTPCchi2Iter1;
995 track.fTPCsignal = fTPCsignal;
996 track.fTPCsignalS = fTPCsignalS;
997 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
999 track.fTPCncls = fTPCncls;
1000 track.fTPCnclsF = fTPCnclsF;
1001 track.fTPCsignalN = fTPCsignalN;
1002 track.fTPCnclsIter1 = fTPCnclsIter1;
1003 track.fTPCnclsFIter1 = fTPCnclsFIter1;
1006 for(int i=0;i<AliPID::kSPECIES;++i){
1007 track.fTPCr[i] = fTPCr[i];
1008 // combined PID is TPC only!
1009 track.fR[i] = fTPCr[i];
1011 track.fTPCClusterMap = fTPCClusterMap;
1012 track.fTPCSharedMap = fTPCSharedMap;
1016 track.fFlags = kTPCin;
1019 track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
1021 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
1027 //_______________________________________________________________________
1028 void AliESDtrack::MakeMiniESDtrack(){
1029 // Resets everything except
1030 // fFlags: Reconstruction status flags
1031 // fLabel: Track label
1032 // fID: Unique ID of the track
1033 // Impact parameter information
1034 // fR[AliPID::kSPECIES]: combined "detector response probability"
1035 // Running track parameters in the base class (AliExternalTrackParam)
1039 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
1041 // Reset track parameters constrained to the primary vertex
1044 // Reset track parameters at the inner wall of TPC
1046 delete fTPCInner;fTPCInner=0;
1047 // Reset track parameters at the inner wall of the TRD
1049 // Reset track parameters at the HMPID
1050 delete fHMPIDp;fHMPIDp = 0;
1053 // Reset ITS track related information
1059 for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
1060 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
1063 // Reset TPC related track information
1075 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
1077 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1078 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1079 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1081 // Reset TRD related track information
1086 for (Int_t i=0;i<kTRDnPlanes;i++) {
1089 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1094 delete[] fTRDslices;
1099 // Reset TOF related track information
1103 fTOFCalChannel = -1;
1104 fTOFsignalToT = 99999;
1105 fTOFsignalRaw = 99999;
1110 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
1111 for (Int_t i=0;i<3;i++) fTOFLabel[i] = -1;
1112 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1114 // Reset HMPID related track information
1119 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
1126 fCaloIndex = kEMCALNoMatch;
1128 // reset global track chi2
1131 fVertexID = -2; // an orphan track
1133 delete fFriendTrack; fFriendTrack = 0;
1135 //_______________________________________________________________________
1136 Double_t AliESDtrack::GetMass() const {
1137 // Returns the mass of the most probable particle type
1140 for (i=0; i<AliPID::kSPECIES-1; i++) {
1141 if (fR[i] != fR[i+1]) break;
1143 // If all the probabilities are equal, return the pion mass
1144 if (i == AliPID::kSPECIES-1) return AliPID::ParticleMass(AliPID::kPion);
1148 for (i=0; i<AliPID::kSPECIES; i++) {
1149 if (fR[i]>max) {k=i; max=fR[i];}
1151 if (k==0) { // dE/dx "crossing points" in the TPC
1153 if ((p>0.38)&&(p<0.48))
1154 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
1155 if ((p>0.75)&&(p<0.85))
1156 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
1159 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
1160 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
1161 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
1162 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
1163 AliWarning("Undefined mass !");
1164 return AliPID::ParticleMass(AliPID::kPion);
1167 //______________________________________________________________________________
1168 Double_t AliESDtrack::M() const
1170 // Returns the assumed mass
1171 // (the pion mass, if the particle can't be identified properly).
1172 static Bool_t printerr=kTRUE;
1174 AliWarning("WARNING !!! ... THIS WILL BE PRINTED JUST ONCE !!!");
1176 AliWarning("This is the ESD mass. Use it with care !");
1181 //______________________________________________________________________________
1182 Double_t AliESDtrack::E() const
1184 // Returns the energy of the particle given its assumed mass.
1185 // Assumes the pion mass if the particle can't be identified properly.
1189 return TMath::Sqrt(p*p + m*m);
1192 //______________________________________________________________________________
1193 Double_t AliESDtrack::Y() const
1195 // Returns the rapidity of a particle given its assumed mass.
1196 // Assumes the pion mass if the particle can't be identified properly.
1200 if (e != TMath::Abs(pz)) { // energy was not equal to pz
1201 return 0.5*TMath::Log((e+pz)/(e-pz));
1202 } else { // energy was equal to pz
1207 //_______________________________________________________________________
1208 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
1210 // This function updates track's running parameters
1215 fLabel=t->GetLabel();
1217 if (t->IsStartedTimeIntegral()) {
1219 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
1220 SetIntegratedLength(t->GetIntegratedLength());
1223 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1224 if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1225 if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
1226 if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
1230 case kITSin: case kITSout: case kITSrefit:
1233 fITSncls=t->GetNumberOfClusters();
1234 Int_t* indexITS = new Int_t[AliESDfriendTrack::kMaxITScluster];
1235 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
1236 indexITS[i]=t->GetClusterIndex(i);
1239 Int_t l=(indexITS[i] & 0xf0000000) >> 28;
1240 SETBIT(fITSClusterMap,l);
1243 fFriendTrack->SetITSIndices(indexITS,AliESDfriendTrack::kMaxITScluster);
1246 fITSchi2=t->GetChi2();
1247 fITSsignal=t->GetPIDsignal();
1248 fITSLabel = t->GetLabel();
1249 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1250 if (flags==kITSout) {
1251 if (!fOp) fOp=new AliExternalTrackParam(*t);
1253 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1258 case kTPCin: case kTPCrefit:
1260 fTPCLabel = t->GetLabel();
1261 if (flags==kTPCin) {
1262 fTPCInner=new AliExternalTrackParam(*t);
1263 fTPCnclsIter1=t->GetNumberOfClusters();
1264 fTPCchi2Iter1=t->GetChi2();
1266 if (!fIp) fIp=new AliExternalTrackParam(*t);
1268 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1272 Int_t* indexTPC = new Int_t[AliESDfriendTrack::kMaxTPCcluster];
1273 if (flags & kTPCout){
1274 if (!fOp) fOp=new AliExternalTrackParam(*t);
1276 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1278 fTPCncls=t->GetNumberOfClusters();
1279 fTPCchi2=t->GetChi2();
1281 {//prevrow must be declared in separate namespace, otherwise compiler cries:
1282 //"jump to case label crosses initialization of `Int_t prevrow'"
1284 // for (Int_t i=0;i<fTPCncls;i++)
1285 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1287 indexTPC[i]=t->GetClusterIndex(i);
1288 Int_t idx = indexTPC[i];
1290 if (idx<0) continue;
1292 // Piotr's Cluster Map for HBT
1293 // ### please change accordingly if cluster array is changing
1294 // to "New TPC Tracking" style (with gaps in array)
1295 Int_t sect = (idx&0xff000000)>>24;
1296 Int_t row = (idx&0x00ff0000)>>16;
1297 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
1299 fTPCClusterMap.SetBitNumber(row,kTRUE);
1301 //Fill the gap between previous row and this row with 0 bits
1302 //In case ### pleas change it as well - just set bit 0 in case there
1303 //is no associated clusters for current "i"
1306 prevrow = row;//if previous bit was not assigned yet == this is the first one
1309 { //we don't know the order (inner to outer or reverse)
1310 //just to be save in case it is going to change
1323 for (Int_t j = n+1; j < m; j++)
1325 fTPCClusterMap.SetBitNumber(j,kFALSE);
1329 // End Of Piotr's Cluster Map for HBT
1331 fFriendTrack->SetTPCIndices(indexTPC,AliESDfriendTrack::kMaxTPCcluster);
1335 fTPCsignal=t->GetPIDsignal();
1339 case kTRDin: case kTRDrefit:
1343 fTRDLabel = t->GetLabel();
1344 fTRDchi2 = t->GetChi2();
1345 fTRDncls = t->GetNumberOfClusters();
1346 Int_t* indexTRD = new Int_t[AliESDfriendTrack::kMaxTRDcluster];
1347 for (Int_t i=0;i<AliESDfriendTrack::kMaxTRDcluster;i++) indexTRD[i]=-2;
1348 for (Int_t i=0;i<6;i++) indexTRD[i]=t->GetTrackletIndex(i);
1349 fFriendTrack->SetTRDIndices(indexTRD,AliESDfriendTrack::kMaxTRDcluster);
1353 fTRDsignal=t->GetPIDsignal();
1357 if (!fOp) fOp=new AliExternalTrackParam(*t);
1359 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1360 fTRDncls0 = t->GetNumberOfClusters();
1369 if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1371 fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1374 AliError("Wrong flag !");
1381 //_______________________________________________________________________
1382 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1383 //---------------------------------------------------------------------
1384 // This function returns external representation of the track parameters
1385 //---------------------------------------------------------------------
1387 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1390 //_______________________________________________________________________
1391 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1392 //---------------------------------------------------------------------
1393 // This function returns external representation of the cov. matrix
1394 //---------------------------------------------------------------------
1395 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1398 //_______________________________________________________________________
1399 Bool_t AliESDtrack::GetConstrainedExternalParameters
1400 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1401 //---------------------------------------------------------------------
1402 // This function returns the constrained external track parameters
1403 //---------------------------------------------------------------------
1404 if (!fCp) return kFALSE;
1405 alpha=fCp->GetAlpha();
1407 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1411 //_______________________________________________________________________
1413 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1414 //---------------------------------------------------------------------
1415 // This function returns the constrained external cov. matrix
1416 //---------------------------------------------------------------------
1417 if (!fCp) return kFALSE;
1418 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1423 AliESDtrack::GetInnerExternalParameters
1424 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1425 //---------------------------------------------------------------------
1426 // This function returns external representation of the track parameters
1427 // at the inner layer of TPC
1428 //---------------------------------------------------------------------
1429 if (!fIp) return kFALSE;
1430 alpha=fIp->GetAlpha();
1432 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1437 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1438 //---------------------------------------------------------------------
1439 // This function returns external representation of the cov. matrix
1440 // at the inner layer of TPC
1441 //---------------------------------------------------------------------
1442 if (!fIp) return kFALSE;
1443 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1448 AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1450 // This is a direct setter for the outer track parameters
1453 if (fOp) delete fOp;
1454 fOp=new AliExternalTrackParam(*p);
1458 AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1460 // This is a direct setter for the outer track parameters
1463 if (fHMPIDp) delete fHMPIDp;
1464 fHMPIDp=new AliExternalTrackParam(*p);
1468 AliESDtrack::GetOuterExternalParameters
1469 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1470 //---------------------------------------------------------------------
1471 // This function returns external representation of the track parameters
1472 // at the inner layer of TRD
1473 //---------------------------------------------------------------------
1474 if (!fOp) return kFALSE;
1475 alpha=fOp->GetAlpha();
1477 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1482 AliESDtrack::GetOuterHmpExternalParameters
1483 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1484 //---------------------------------------------------------------------
1485 // This function returns external representation of the track parameters
1486 // at the inner layer of TRD
1487 //---------------------------------------------------------------------
1488 if (!fHMPIDp) return kFALSE;
1489 alpha=fHMPIDp->GetAlpha();
1491 for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1496 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1497 //---------------------------------------------------------------------
1498 // This function returns external representation of the cov. matrix
1499 // at the inner layer of TRD
1500 //---------------------------------------------------------------------
1501 if (!fOp) return kFALSE;
1502 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1507 AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1508 //---------------------------------------------------------------------
1509 // This function returns external representation of the cov. matrix
1510 // at the inner layer of TRD
1511 //---------------------------------------------------------------------
1512 if (!fHMPIDp) return kFALSE;
1513 for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1517 Int_t AliESDtrack::GetNcls(Int_t idet) const
1519 // Get number of clusters by subdetector index
1533 if (fTOFindex != -1)
1539 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1540 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1551 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1553 // Get cluster index array by subdetector index
1558 ncls = GetITSclusters(idx);
1561 ncls = GetTPCclusters(idx);
1564 ncls = GetTRDclusters(idx);
1567 if (fTOFindex != -1) {
1575 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1576 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1577 idx[0] = GetHMPIDcluIdx();
1590 //_______________________________________________________________________
1591 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1592 // Returns the array with integrated times for each particle hypothesis
1593 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1596 //_______________________________________________________________________
1597 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1598 // Sets the array with integrated times for each particle hypotesis
1599 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1602 //_______________________________________________________________________
1603 void AliESDtrack::SetITSpid(const Double_t *p) {
1604 // Sets values for the probability of each particle type (in ITS)
1605 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1606 SetStatus(AliESDtrack::kITSpid);
1609 //_______________________________________________________________________
1610 void AliESDtrack::GetITSpid(Double_t *p) const {
1611 // Gets the probability of each particle type (in ITS)
1612 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1615 //_______________________________________________________________________
1616 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1617 //---------------------------------------------------------------------
1618 // This function returns indices of the assgined ITS clusters
1619 //---------------------------------------------------------------------
1621 Int_t *index=fFriendTrack->GetITSindices();
1622 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1623 if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1635 //_______________________________________________________________________
1636 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1637 Float_t &xloc,Float_t &zloc) const {
1638 //----------------------------------------------------------------------
1639 // This function encodes in the module number also the status of cluster association
1640 // "status" can have the following values:
1641 // 1 "found" (cluster is associated),
1642 // 2 "dead" (module is dead from OCDB),
1643 // 3 "skipped" (module or layer forced to be skipped),
1644 // 4 "outinz" (track out of z acceptance),
1645 // 5 "nocls" (no clusters in the road),
1646 // 6 "norefit" (cluster rejected during refit),
1647 // 7 "deadzspd" (holes in z in SPD)
1648 // Also given are the coordinates of the crossing point of track and module
1649 // (in the local module ref. system)
1650 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1651 //----------------------------------------------------------------------
1653 if(fITSModule[ilayer]==-1) {
1656 xloc=-99.; zloc=-99.;
1660 Int_t module = fITSModule[ilayer];
1662 idet = Int_t(module/1000000);
1664 module -= idet*1000000;
1666 status = Int_t(module/100000);
1668 module -= status*100000;
1670 Int_t signs = Int_t(module/10000);
1672 module-=signs*10000;
1674 Int_t xInt = Int_t(module/100);
1677 Int_t zInt = module;
1679 if(signs==1) { xInt*=1; zInt*=1; }
1680 if(signs==2) { xInt*=1; zInt*=-1; }
1681 if(signs==3) { xInt*=-1; zInt*=1; }
1682 if(signs==4) { xInt*=-1; zInt*=-1; }
1684 xloc = 0.1*(Float_t)xInt;
1685 zloc = 0.1*(Float_t)zInt;
1687 if(status==4) idet = -1;
1692 //_______________________________________________________________________
1693 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1694 //---------------------------------------------------------------------
1695 // This function returns indices of the assgined ITS clusters
1696 //---------------------------------------------------------------------
1698 Int_t *index=fFriendTrack->GetTPCindices();
1701 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1704 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=-2;
1710 //_______________________________________________________________________
1711 Float_t AliESDtrack::GetTPCClusterInfo(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1) const
1714 // TPC cluster information
1715 // type 0: get fraction of found/findable clusters with neighbourhood definition
1716 // 1: findable clusters with neighbourhood definition
1717 // 2: found clusters
1719 // definition of findable clusters:
1720 // a cluster is defined as findable if there is another cluster
1721 // within +- nNeighbours pad rows. The idea is to overcome threshold
1722 // effects with a very simple algorithm.
1725 if (type==2) return fTPCClusterMap.CountBits();
1729 Int_t last=-nNeighbours;
1731 for (Int_t i=row0; i<row1; ++i){
1732 //look to current row
1733 if (fTPCClusterMap[i]) {
1739 //look to nNeighbours before
1740 if ((i-last)<=nNeighbours) {
1744 //look to nNeighbours after
1745 for (Int_t j=i+1; j<i+1+nNeighbours; ++j){
1746 if (fTPCClusterMap[j]){
1752 if (type==1) return findable;
1757 fraction=(Float_t)found/(Float_t)findable;
1762 return 0; // undefined type - default value
1765 //_______________________________________________________________________
1766 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1768 // GetDensity of the clusters on given region between row0 and row1
1769 // Dead zone effect takin into acoount
1774 Int_t *index=fFriendTrack->GetTPCindices();
1775 for (Int_t i=row0;i<=row1;i++){
1776 Int_t idx = index[i];
1777 if (idx!=-1) good++; // track outside of dead zone
1780 Float_t density=0.5;
1781 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1785 //_______________________________________________________________________
1786 void AliESDtrack::SetTPCpid(const Double_t *p) {
1787 // Sets values for the probability of each particle type (in TPC)
1788 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1789 SetStatus(AliESDtrack::kTPCpid);
1792 //_______________________________________________________________________
1793 void AliESDtrack::GetTPCpid(Double_t *p) const {
1794 // Gets the probability of each particle type (in TPC)
1795 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1798 //_______________________________________________________________________
1799 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1800 //---------------------------------------------------------------------
1801 // This function returns indices of the assgined TRD clusters
1802 //---------------------------------------------------------------------
1804 Int_t *index=fFriendTrack->GetTRDindices();
1807 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1810 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=-2;
1816 //_______________________________________________________________________
1817 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1819 // This function returns the number of TRD tracklets used in tracking
1820 // and it fills the indices of these tracklets in the array "idx" as they
1821 // are registered in the TRD track list.
1824 // 1. The idx array has to be allocated with a size >= AliESDtrack::kTRDnPlanes
1825 // 2. The idx array store not only the index but also the layer of the tracklet.
1826 // Therefore tracks with TRD gaps contain default values for indices [-1]
1828 if (!idx) return GetTRDntracklets();
1829 Int_t *index=fFriendTrack->GetTRDindices();
1831 for (Int_t i=0; i<kTRDnPlanes; i++){
1833 if(index[i]>=0) n++;
1841 //_______________________________________________________________________
1842 void AliESDtrack::SetTRDpid(const Double_t *p) {
1843 // Sets values for the probability of each particle type (in TRD)
1844 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1845 SetStatus(AliESDtrack::kTRDpid);
1848 //_______________________________________________________________________
1849 void AliESDtrack::GetTRDpid(Double_t *p) const {
1850 // Gets the probability of each particle type (in TRD)
1851 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1854 //_______________________________________________________________________
1855 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1857 // Sets the probability of particle type iSpecies to p (in TRD)
1858 fTRDr[iSpecies] = p;
1861 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1863 // Returns the probability of particle type iSpecies (in TRD)
1864 return fTRDr[iSpecies];
1867 //____________________________________________________
1868 Int_t AliESDtrack::GetNumberOfTRDslices() const
1870 // built in backward compatibility
1871 Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
1872 return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
1875 //____________________________________________________
1876 Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
1878 //Returns momentum estimation and optional its error (sp)
1879 // in TRD layer "plane".
1882 AliDebug(2, "No TRD info allocated for this track.");
1885 if ((plane<0) || (plane>=kTRDnPlanes)) {
1886 AliWarning(Form("Request for TRD plane[%d] outside range.", plane));
1890 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1891 // Protection for backward compatibility
1892 if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
1894 if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
1895 return fTRDslices[idx];
1898 //____________________________________________________
1899 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1900 //Gets the charge from the slice of the plane
1903 //AliError("No TRD slices allocated for this track !");
1906 if ((plane<0) || (plane>=kTRDnPlanes)) {
1907 AliError("Info for TRD plane not available !");
1910 Int_t ns=GetNumberOfTRDslices();
1911 if ((slice<-1) || (slice>=ns)) {
1912 //AliError("Wrong TRD slice !");
1916 if(slice>=0) return fTRDslices[plane*ns + slice];
1918 // return average of the dEdx measurements
1919 Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
1920 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
1924 //____________________________________________________
1925 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1926 //Sets the number of slices used for PID
1927 if (fTRDnSlices) return;
1930 fTRDslices=new Double32_t[fTRDnSlices];
1932 // set-up correctly the allocated memory
1933 memset(fTRDslices, 0, n*sizeof(Double32_t));
1934 for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
1937 //____________________________________________________
1938 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1939 //Sets the charge q in the slice of the plane
1941 AliError("No TRD slices allocated for this track !");
1944 if ((plane<0) || (plane>=kTRDnPlanes)) {
1945 AliError("Info for TRD plane not allocated !");
1948 Int_t ns=GetNumberOfTRDslices();
1949 if ((slice<0) || (slice>=ns)) {
1950 AliError("Wrong TRD slice !");
1953 Int_t n=plane*ns + slice;
1958 //____________________________________________________
1959 void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
1962 AliError("No TRD slices allocated for this track !");
1965 if ((plane<0) || (plane>=kTRDnPlanes)) {
1966 AliError("Info for TRD plane not allocated !");
1970 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1971 // Protection for backward compatibility
1972 if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
1974 if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
1975 fTRDslices[idx] = p;
1979 //_______________________________________________________________________
1980 void AliESDtrack::SetTOFpid(const Double_t *p) {
1981 // Sets the probability of each particle type (in TOF)
1982 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
1983 SetStatus(AliESDtrack::kTOFpid);
1986 //_______________________________________________________________________
1987 void AliESDtrack::SetTOFLabel(const Int_t *p) {
1989 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1992 //_______________________________________________________________________
1993 void AliESDtrack::GetTOFpid(Double_t *p) const {
1994 // Gets probabilities of each particle type (in TOF)
1995 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
1998 //_______________________________________________________________________
1999 void AliESDtrack::GetTOFLabel(Int_t *p) const {
2001 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
2004 //_______________________________________________________________________
2005 void AliESDtrack::GetTOFInfo(Float_t *info) const {
2007 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
2010 //_______________________________________________________________________
2011 void AliESDtrack::SetTOFInfo(Float_t*info) {
2013 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
2018 //_______________________________________________________________________
2019 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
2020 // Sets the probability of each particle type (in HMPID)
2021 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
2022 SetStatus(AliESDtrack::kHMPIDpid);
2025 //_______________________________________________________________________
2026 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
2027 // Gets probabilities of each particle type (in HMPID)
2028 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
2033 //_______________________________________________________________________
2034 void AliESDtrack::SetESDpid(const Double_t *p) {
2035 // Sets the probability of each particle type for the ESD track
2036 SetPIDValues(fR,p,AliPID::kSPECIES);
2037 SetStatus(AliESDtrack::kESDpid);
2040 //_______________________________________________________________________
2041 void AliESDtrack::GetESDpid(Double_t *p) const {
2042 // Gets probability of each particle type for the ESD track
2043 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
2046 //_______________________________________________________________________
2047 Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
2048 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2050 // Try to relate the TPC-only track parameters to the vertex "vtx",
2051 // if the (rough) transverse impact parameter is not bigger then "maxd".
2052 // Magnetic field is "b" (kG).
2054 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2055 // b) The impact parameters and their covariance matrix are calculated.
2056 // c) An attempt to constrain the TPC-only params to the vertex is done.
2057 // The constrained params are returned via "cParam".
2059 // In the case of success, the returned value is kTRUE
2060 // otherwise, it's kFALSE)
2063 if (!fTPCInner) return kFALSE;
2064 if (!vtx) return kFALSE;
2066 Double_t dz[2],cov[3];
2067 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2075 Double_t covar[6]; vtx->GetCovMatrix(covar);
2076 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2077 Double_t c[3]={covar[2],0.,covar[5]};
2079 Double_t chi2=GetPredictedChi2(p,c);
2080 if (chi2>kVeryBig) return kFALSE;
2084 if (!cParam) return kTRUE;
2086 *cParam = *fTPCInner;
2087 if (!cParam->Update(p,c)) return kFALSE;
2092 //_______________________________________________________________________
2093 Bool_t AliESDtrack::RelateToVertexTPCBxByBz(const AliESDVertex *vtx,
2094 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2096 // Try to relate the TPC-only track parameters to the vertex "vtx",
2097 // if the (rough) transverse impact parameter is not bigger then "maxd".
2099 // All three components of the magnetic field ,"b[3]" (kG),
2100 // are taken into account.
2102 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2103 // b) The impact parameters and their covariance matrix are calculated.
2104 // c) An attempt to constrain the TPC-only params to the vertex is done.
2105 // The constrained params are returned via "cParam".
2107 // In the case of success, the returned value is kTRUE
2108 // otherwise, it's kFALSE)
2111 if (!fTPCInner) return kFALSE;
2112 if (!vtx) return kFALSE;
2114 Double_t dz[2],cov[3];
2115 if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2123 Double_t covar[6]; vtx->GetCovMatrix(covar);
2124 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2125 Double_t c[3]={covar[2],0.,covar[5]};
2127 Double_t chi2=GetPredictedChi2(p,c);
2128 if (chi2>kVeryBig) return kFALSE;
2132 if (!cParam) return kTRUE;
2134 *cParam = *fTPCInner;
2135 if (!cParam->Update(p,c)) return kFALSE;
2140 //_______________________________________________________________________
2141 Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
2142 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2144 // Try to relate this track to the vertex "vtx",
2145 // if the (rough) transverse impact parameter is not bigger then "maxd".
2146 // Magnetic field is "b" (kG).
2148 // a) The track gets extapolated to the DCA to the vertex.
2149 // b) The impact parameters and their covariance matrix are calculated.
2150 // c) An attempt to constrain this track to the vertex is done.
2151 // The constrained params are returned via "cParam".
2153 // In the case of success, the returned value is kTRUE
2154 // (otherwise, it's kFALSE)
2157 if (!vtx) return kFALSE;
2159 Double_t dz[2],cov[3];
2160 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2168 Double_t covar[6]; vtx->GetCovMatrix(covar);
2169 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2170 Double_t c[3]={covar[2],0.,covar[5]};
2172 Double_t chi2=GetPredictedChi2(p,c);
2173 if (chi2>kVeryBig) return kFALSE;
2178 //--- Could now these lines be removed ? ---
2180 fCp=new AliExternalTrackParam(*this);
2182 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2183 //----------------------------------------
2185 fVertexID = vtx->GetID();
2187 if (!cParam) return kTRUE;
2190 if (!cParam->Update(p,c)) return kFALSE;
2195 //_______________________________________________________________________
2196 Bool_t AliESDtrack::RelateToVertexBxByBz(const AliESDVertex *vtx,
2197 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2199 // Try to relate this track to the vertex "vtx",
2200 // if the (rough) transverse impact parameter is not bigger then "maxd".
2201 // Magnetic field is "b" (kG).
2203 // a) The track gets extapolated to the DCA to the vertex.
2204 // b) The impact parameters and their covariance matrix are calculated.
2205 // c) An attempt to constrain this track to the vertex is done.
2206 // The constrained params are returned via "cParam".
2208 // In the case of success, the returned value is kTRUE
2209 // (otherwise, it's kFALSE)
2212 if (!vtx) return kFALSE;
2214 Double_t dz[2],cov[3];
2215 if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2223 Double_t covar[6]; vtx->GetCovMatrix(covar);
2224 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2225 Double_t c[3]={covar[2],0.,covar[5]};
2227 Double_t chi2=GetPredictedChi2(p,c);
2228 if (chi2>kVeryBig) return kFALSE;
2233 //--- Could now these lines be removed ? ---
2235 fCp=new AliExternalTrackParam(*this);
2237 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2238 //----------------------------------------
2240 fVertexID = vtx->GetID();
2242 if (!cParam) return kTRUE;
2245 if (!cParam->Update(p,c)) return kFALSE;
2250 //_______________________________________________________________________
2251 void AliESDtrack::Print(Option_t *) const {
2252 // Prints info on the track
2253 AliExternalTrackParam::Print();
2254 printf("ESD track info\n") ;
2255 Double_t p[AliPID::kSPECIESN] ;
2257 if( IsOn(kITSpid) ){
2258 printf("From ITS: ") ;
2260 for(index = 0 ; index < AliPID::kSPECIES; index++)
2261 printf("%f, ", p[index]) ;
2262 printf("\n signal = %f\n", GetITSsignal()) ;
2264 if( IsOn(kTPCpid) ){
2265 printf("From TPC: ") ;
2267 for(index = 0 ; index < AliPID::kSPECIES; index++)
2268 printf("%f, ", p[index]) ;
2269 printf("\n signal = %f\n", GetTPCsignal()) ;
2271 if( IsOn(kTRDpid) ){
2272 printf("From TRD: ") ;
2274 for(index = 0 ; index < AliPID::kSPECIES; index++)
2275 printf("%f, ", p[index]) ;
2276 printf("\n signal = %f\n", GetTRDsignal()) ;
2278 if( IsOn(kTOFpid) ){
2279 printf("From TOF: ") ;
2281 for(index = 0 ; index < AliPID::kSPECIES; index++)
2282 printf("%f, ", p[index]) ;
2283 printf("\n signal = %f\n", GetTOFsignal()) ;
2285 if( IsOn(kHMPIDpid) ){
2286 printf("From HMPID: ") ;
2288 for(index = 0 ; index < AliPID::kSPECIES; index++)
2289 printf("%f, ", p[index]) ;
2290 printf("\n signal = %f\n", GetHMPIDsignal()) ;
2296 // Draw functionality
2297 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
2299 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
2301 // Fill points in the polymarker
2304 arrayRef.AddLast(new AliExternalTrackParam(*this));
2305 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
2306 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
2307 if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
2309 Double_t mpos[3]={0,0,0};
2310 Int_t entries=arrayRef.GetEntries();
2311 for (Int_t i=0;i<entries;i++){
2313 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
2314 mpos[0]+=pos[0]/entries;
2315 mpos[1]+=pos[1]/entries;
2316 mpos[2]+=pos[2]/entries;
2318 // Rotate to the mean position
2320 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
2321 for (Int_t i=0;i<entries;i++){
2322 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
2323 if (!res) delete arrayRef.RemoveAt(i);
2326 for (Double_t r=minR; r<maxR; r+=stepR){
2328 Double_t mlpos[3]={0,0,0};
2329 for (Int_t i=0;i<entries;i++){
2330 Double_t point[3]={0,0,0};
2331 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
2332 if (!param) continue;
2333 if (param->GetXYZAt(r,magF,point)){
2334 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
2336 mlpos[0]+=point[0]*weight;
2337 mlpos[1]+=point[1]*weight;
2338 mlpos[2]+=point[2]*weight;
2345 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
2346 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
2352 //_______________________________________________________________________
2353 void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
2355 // Store the dE/dx samples measured by the two SSD and two SDD layers.
2356 // These samples are corrected for the track segment length.
2358 for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
2361 //_______________________________________________________________________
2362 void AliESDtrack::GetITSdEdxSamples(Double_t *s) const {
2364 // Get the dE/dx samples measured by the two SSD and two SDD layers.
2365 // These samples are corrected for the track segment length.
2367 for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];
2371 UShort_t AliESDtrack::GetTPCnclsS(Int_t i0,Int_t i1) const{
2373 // get number of shared TPC clusters
2375 return fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);
2378 UShort_t AliESDtrack::GetTPCncls(Int_t i0,Int_t i1) const{
2380 // get number of TPC clusters
2382 return fTPCClusterMap.CountBits(i0)-fTPCClusterMap.CountBits(i1);