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),
228 fVertexID(-2),// -2 means an orphan track
232 // The default ESD constructor
235 for (i=0; i<AliPID::kSPECIES; i++) {
245 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
246 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
247 for (i=0;i<kTRDnPlanes;i++) {
250 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
251 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
252 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
253 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
254 for (i=0;i<12;i++) {fITSModule[i]=-1;}
257 //_______________________________________________________________________
258 AliESDtrack::AliESDtrack(const AliESDtrack& track):
259 AliExternalTrackParam(track),
266 fTPCClusterMap(track.fTPCClusterMap),
267 fTPCSharedMap(track.fTPCSharedMap),
268 fFlags(track.fFlags),
270 fLabel(track.fLabel),
271 fITSLabel(track.fITSLabel),
272 fTPCLabel(track.fTPCLabel),
273 fTRDLabel(track.fTRDLabel),
274 fTOFCalChannel(track.fTOFCalChannel),
275 fTOFindex(track.fTOFindex),
276 fHMPIDqn(track.fHMPIDqn),
277 fHMPIDcluIdx(track.fHMPIDcluIdx),
278 fCaloIndex(track.fCaloIndex),
279 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
280 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
281 fHMPIDsignal(track.fHMPIDsignal),
282 fTrackLength(track.fTrackLength),
283 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
284 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
285 fCchi2TPC(track.fCchi2TPC),
286 fD(track.fD),fZ(track.fZ),
287 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
288 fCchi2(track.fCchi2),
289 fITSchi2(track.fITSchi2),
290 fTPCchi2(track.fTPCchi2),
291 fTPCchi2Iter1(track.fTPCchi2Iter1),
292 fTRDchi2(track.fTRDchi2),
293 fTOFchi2(track.fTOFchi2),
294 fHMPIDchi2(track.fHMPIDchi2),
295 fGlobalChi2(track.fGlobalChi2),
296 fITSsignal(track.fITSsignal),
297 fTPCsignal(track.fTPCsignal),
298 fTPCsignalS(track.fTPCsignalS),
299 fTRDsignal(track.fTRDsignal),
300 fTRDQuality(track.fTRDQuality),
301 fTRDBudget(track.fTRDBudget),
302 fTOFsignal(track.fTOFsignal),
303 fTOFsignalToT(track.fTOFsignalToT),
304 fTOFsignalRaw(track.fTOFsignalRaw),
305 fTOFsignalDz(track.fTOFsignalDz),
306 fTOFsignalDx(track.fTOFsignalDx),
307 fTOFdeltaBC(track.fTOFdeltaBC),
308 fTOFl0l1(track.fTOFl0l1),
309 fCaloDx(track.fCaloDx),
310 fCaloDz(track.fCaloDz),
311 fHMPIDtrkX(track.fHMPIDtrkX),
312 fHMPIDtrkY(track.fHMPIDtrkY),
313 fHMPIDmipX(track.fHMPIDmipX),
314 fHMPIDmipY(track.fHMPIDmipY),
315 fTPCncls(track.fTPCncls),
316 fTPCnclsF(track.fTPCnclsF),
317 fTPCsignalN(track.fTPCsignalN),
318 fTPCnclsIter1(track.fTPCnclsIter1),
319 fTPCnclsFIter1(track.fTPCnclsIter1),
320 fITSncls(track.fITSncls),
321 fITSClusterMap(track.fITSClusterMap),
322 fTRDncls(track.fTRDncls),
323 fTRDncls0(track.fTRDncls0),
324 fTRDntracklets(track.fTRDntracklets),
325 fTRDnSlices(track.fTRDnSlices),
327 fVertexID(track.fVertexID),
328 fESDEvent(track.fESDEvent)
333 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
334 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
336 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
338 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
339 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
340 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
341 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
342 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
344 for (Int_t i=0;i<kTRDnPlanes;i++) {
345 fTRDTimBin[i]=track.fTRDTimBin[i];
349 fTRDslices=new Double32_t[fTRDnSlices];
350 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
353 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
354 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
355 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
356 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
357 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
358 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
360 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
361 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
362 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
363 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
364 if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
366 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
369 //_______________________________________________________________________
370 AliESDtrack::AliESDtrack(const AliVTrack *track) :
371 AliExternalTrackParam(track),
378 fTPCClusterMap(159),//number of padrows
379 fTPCSharedMap(159),//number of padrows
390 fCaloIndex(kEMCALNoMatch),
396 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
399 fCdd(0),fCdz(0),fCzz(0),
439 fVertexID(-2), // -2 means an orphan track
443 // ESD track from AliVTrack.
444 // This is not a copy constructor !
447 if (track->InheritsFrom("AliExternalTrackParam")) {
448 AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
449 AliWarning("Calling the default constructor...");
454 // Reset all the arrays
456 for (i=0; i<AliPID::kSPECIES; i++) {
466 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
467 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
468 for (i=0;i<kTRDnPlanes;i++) {
471 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
472 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
473 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
474 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
475 for (i=0;i<12;i++) {fITSModule[i]=-1;}
478 SetID(track->GetID());
480 // Set ITS cluster map
481 fITSClusterMap=track->GetITSClusterMap();
485 if(HasPointOnITSLayer(i)) fITSncls++;
488 // Set the combined PID
489 const Double_t *pid = track->PID();
491 for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
493 // AliESD track label
494 SetLabel(track->GetLabel());
496 SetStatus(track->GetStatus());
499 //_______________________________________________________________________
500 AliESDtrack::AliESDtrack(TParticle * part) :
501 AliExternalTrackParam(),
508 fTPCClusterMap(159),//number of padrows
509 fTPCSharedMap(159),//number of padrows
520 fCaloIndex(kEMCALNoMatch),
526 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
529 fCdd(0),fCdz(0),fCzz(0),
569 fVertexID(-2), // -2 means an orphan track
573 // ESD track from TParticle
576 // Reset all the arrays
578 for (i=0; i<AliPID::kSPECIES; i++) {
588 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
589 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
590 for (i=0;i<kTRDnPlanes;i++) {
593 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
594 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
595 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
596 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
597 for (i=0;i<12;i++) {fITSModule[i]=-1;}
599 // Calculate the AliExternalTrackParam content
606 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
607 alpha = part->Phi()*180./TMath::Pi();
608 if (alpha<0) alpha+= 360.;
609 if (alpha>360) alpha -= 360.;
611 Int_t sector = (Int_t)(alpha/20.);
612 alpha = 10. + 20.*sector;
614 alpha *= TMath::Pi();
616 // Covariance matrix: no errors, the parameters are exact
617 for (i=0; i<15; i++) covar[i]=0.;
619 // Get the vertex of origin and the momentum
620 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
621 TVector3 mom(part->Px(),part->Py(),part->Pz());
623 // Rotate to the local coordinate system (TPC sector)
627 // X of the referense plane
630 Int_t pdgCode = part->GetPdgCode();
633 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
637 param[2] = TMath::Sin(mom.Phi());
638 param[3] = mom.Pz()/mom.Pt();
639 param[4] = TMath::Sign(1/mom.Pt(),charge);
641 // Set AliExternalTrackParam
642 Set(xref, alpha, param, covar);
647 switch (TMath::Abs(pdgCode)) {
673 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
674 if (indexPID < AliPID::kSPECIES) {
680 fHMPIDr[indexPID]=1.;
683 // AliESD track label
684 SetLabel(part->GetUniqueID());
688 //_______________________________________________________________________
689 AliESDtrack::~AliESDtrack(){
691 // This is destructor according Coding Conventrions
693 //printf("Delete track\n");
704 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
707 if(&source == this) return *this;
708 AliExternalTrackParam::operator=(source);
712 // we have the trackparam: assign or copy construct
713 if(fCp)*fCp = *source.fCp;
714 else fCp = new AliExternalTrackParam(*source.fCp);
717 // no track param delete the old one
723 // we have the trackparam: assign or copy construct
724 if(fIp)*fIp = *source.fIp;
725 else fIp = new AliExternalTrackParam(*source.fIp);
728 // no track param delete the old one
734 if(source.fTPCInner){
735 // we have the trackparam: assign or copy construct
736 if(fTPCInner) *fTPCInner = *source.fTPCInner;
737 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
740 // no track param delete the old one
741 if(fTPCInner)delete fTPCInner;
747 // we have the trackparam: assign or copy construct
748 if(fOp) *fOp = *source.fOp;
749 else fOp = new AliExternalTrackParam(*source.fOp);
752 // no track param delete the old one
759 // we have the trackparam: assign or copy construct
760 if(fHMPIDp) *fHMPIDp = *source.fHMPIDp;
761 else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
764 // no track param delete the old one
765 if(fHMPIDp)delete fHMPIDp;
770 // copy also the friend track
771 // use copy constructor
772 if(source.fFriendTrack){
773 // we have the trackparam: assign or copy construct
774 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
777 // no track param delete the old one
778 delete fFriendTrack; fFriendTrack= 0;
781 fTPCClusterMap = source.fTPCClusterMap;
782 fTPCSharedMap = source.fTPCSharedMap;
784 fFlags = source.fFlags;
786 fLabel = source.fLabel;
787 fITSLabel = source.fITSLabel;
788 for(int i = 0; i< 12;++i){
789 fITSModule[i] = source.fITSModule[i];
791 fTPCLabel = source.fTPCLabel;
792 fTRDLabel = source.fTRDLabel;
793 for(int i = 0; i< 3;++i){
794 fTOFLabel[i] = source.fTOFLabel[i];
796 fTOFCalChannel = source.fTOFCalChannel;
797 fTOFindex = source.fTOFindex;
798 fHMPIDqn = source.fHMPIDqn;
799 fHMPIDcluIdx = source.fHMPIDcluIdx;
800 fCaloIndex = source.fCaloIndex;
802 for(int i = 0; i< 3;++i){
803 fKinkIndexes[i] = source.fKinkIndexes[i];
804 fV0Indexes[i] = source.fV0Indexes[i];
807 for(int i = 0; i< AliPID::kSPECIES;++i){
808 fR[i] = source.fR[i];
809 fITSr[i] = source.fITSr[i];
810 fTPCr[i] = source.fTPCr[i];
811 fTRDr[i] = source.fTRDr[i];
812 fTOFr[i] = source.fTOFr[i];
813 fHMPIDr[i] = source.fHMPIDr[i];
814 fTrackTime[i] = source.fTrackTime[i];
817 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
818 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
819 fHMPIDsignal = source.fHMPIDsignal;
822 fTrackLength = source. fTrackLength;
823 fdTPC = source.fdTPC;
824 fzTPC = source.fzTPC;
825 fCddTPC = source.fCddTPC;
826 fCdzTPC = source.fCdzTPC;
827 fCzzTPC = source.fCzzTPC;
828 fCchi2TPC = source.fCchi2TPC;
835 fCchi2 = source.fCchi2;
837 fITSchi2 = source.fITSchi2;
838 fTPCchi2 = source.fTPCchi2;
839 fTPCchi2Iter1 = source.fTPCchi2Iter1;
840 fTRDchi2 = source.fTRDchi2;
841 fTOFchi2 = source.fTOFchi2;
842 fHMPIDchi2 = source.fHMPIDchi2;
844 fGlobalChi2 = source.fGlobalChi2;
846 fITSsignal = source.fITSsignal;
847 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
848 fTPCsignal = source.fTPCsignal;
849 fTPCsignalS = source.fTPCsignalS;
850 for(int i = 0; i< 4;++i){
851 fTPCPoints[i] = source.fTPCPoints[i];
853 fTRDsignal = source.fTRDsignal;
855 for(int i = 0;i < kTRDnPlanes;++i){
856 fTRDTimBin[i] = source.fTRDTimBin[i];
862 fTRDnSlices=source.fTRDnSlices;
864 fTRDslices=new Double32_t[fTRDnSlices];
865 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
868 fTRDQuality = source.fTRDQuality;
869 fTRDBudget = source.fTRDBudget;
870 fTOFsignal = source.fTOFsignal;
871 fTOFsignalToT = source.fTOFsignalToT;
872 fTOFsignalRaw = source.fTOFsignalRaw;
873 fTOFsignalDz = source.fTOFsignalDz;
874 fTOFsignalDx = source.fTOFsignalDx;
875 fTOFdeltaBC = source.fTOFdeltaBC;
876 fTOFl0l1 = source.fTOFl0l1;
878 for(int i = 0;i<10;++i){
879 fTOFInfo[i] = source.fTOFInfo[i];
882 fHMPIDtrkX = source.fHMPIDtrkX;
883 fHMPIDtrkY = source.fHMPIDtrkY;
884 fHMPIDmipX = source.fHMPIDmipX;
885 fHMPIDmipY = source.fHMPIDmipY;
887 fTPCncls = source.fTPCncls;
888 fTPCnclsF = source.fTPCnclsF;
889 fTPCsignalN = source.fTPCsignalN;
890 fTPCnclsIter1 = source.fTPCnclsIter1;
891 fTPCnclsFIter1 = source.fTPCnclsFIter1;
893 fITSncls = source.fITSncls;
894 fITSClusterMap = source.fITSClusterMap;
895 fTRDncls = source.fTRDncls;
896 fTRDncls0 = source.fTRDncls0;
897 fTRDntracklets = source.fTRDntracklets;
898 fVertexID = source.fVertexID;
904 void AliESDtrack::Copy(TObject &obj) const {
906 // this overwrites the virtual TOBject::Copy()
907 // to allow run time copying without casting
910 if(this==&obj)return;
911 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
912 if(!robj)return; // not an AliESDtrack
919 void AliESDtrack::AddCalibObject(TObject * object){
921 // add calib object to the list
923 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
924 fFriendTrack->AddCalibObject(object);
927 TObject * AliESDtrack::GetCalibObject(Int_t index){
929 // return calib objct at given position
931 if (!fFriendTrack) return 0;
932 return fFriendTrack->GetCalibObject(index);
936 Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
938 // Fills the information of the TPC-only first reconstruction pass
939 // into the passed ESDtrack object. For consistency fTPCInner is also filled
944 // For data produced before r26675
945 // RelateToVertexTPC was not properly called during reco
946 // so you'll have to call it again, before FillTPCOnlyTrack
947 // Float_t p[2],cov[3];
948 // track->GetImpactParametersTPC(p,cov);
949 // if(p[0]==0&&p[1]==0) // <- Default values
950 // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
953 if(!fTPCInner)return kFALSE;
955 // fill the TPC track params to the global track parameters
956 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
959 track.fCdd = fCddTPC;
960 track.fCdz = fCdzTPC;
961 track.fCzz = fCzzTPC;
963 // copy the TPCinner parameters
964 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
965 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
968 track.fCddTPC = fCddTPC;
969 track.fCdzTPC = fCdzTPC;
970 track.fCzzTPC = fCzzTPC;
971 track.fCchi2TPC = fCchi2TPC;
974 // copy all other TPC specific parameters
976 // replace label by TPC label
977 track.fLabel = fTPCLabel;
978 track.fTPCLabel = fTPCLabel;
980 track.fTPCchi2 = fTPCchi2;
981 track.fTPCchi2Iter1 = fTPCchi2Iter1;
982 track.fTPCsignal = fTPCsignal;
983 track.fTPCsignalS = fTPCsignalS;
984 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
986 track.fTPCncls = fTPCncls;
987 track.fTPCnclsF = fTPCnclsF;
988 track.fTPCsignalN = fTPCsignalN;
989 track.fTPCnclsIter1 = fTPCnclsIter1;
990 track.fTPCnclsFIter1 = fTPCnclsFIter1;
993 for(int i=0;i<AliPID::kSPECIES;++i){
994 track.fTPCr[i] = fTPCr[i];
995 // combined PID is TPC only!
996 track.fR[i] = fTPCr[i];
998 track.fTPCClusterMap = fTPCClusterMap;
999 track.fTPCSharedMap = fTPCSharedMap;
1003 track.fFlags = kTPCin;
1006 track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
1008 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
1014 //_______________________________________________________________________
1015 void AliESDtrack::MakeMiniESDtrack(){
1016 // Resets everything except
1017 // fFlags: Reconstruction status flags
1018 // fLabel: Track label
1019 // fID: Unique ID of the track
1020 // Impact parameter information
1021 // fR[AliPID::kSPECIES]: combined "detector response probability"
1022 // Running track parameters in the base class (AliExternalTrackParam)
1026 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
1028 // Reset track parameters constrained to the primary vertex
1031 // Reset track parameters at the inner wall of TPC
1033 delete fTPCInner;fTPCInner=0;
1034 // Reset track parameters at the inner wall of the TRD
1036 // Reset track parameters at the HMPID
1037 delete fHMPIDp;fHMPIDp = 0;
1040 // Reset ITS track related information
1045 for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
1046 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
1049 // Reset TPC related track information
1061 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
1063 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1064 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1065 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1067 // Reset TRD related track information
1072 for (Int_t i=0;i<kTRDnPlanes;i++) {
1075 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1080 delete[] fTRDslices;
1085 // Reset TOF related track information
1096 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
1097 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
1098 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1100 // Reset HMPID related track information
1105 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
1112 fCaloIndex = kEMCALNoMatch;
1114 // reset global track chi2
1117 fVertexID = -2; // an orphan track
1119 delete fFriendTrack; fFriendTrack = 0;
1121 //_______________________________________________________________________
1122 Double_t AliESDtrack::GetMass() const {
1123 // Returns the mass of the most probable particle type
1126 for (i=0; i<AliPID::kSPECIES-1; i++) {
1127 if (fR[i] != fR[i+1]) break;
1129 // If all the probabilities are equal, return the pion mass
1130 if (i == AliPID::kSPECIES-1) return AliPID::ParticleMass(AliPID::kPion);
1134 for (i=0; i<AliPID::kSPECIES; i++) {
1135 if (fR[i]>max) {k=i; max=fR[i];}
1137 if (k==0) { // dE/dx "crossing points" in the TPC
1139 if ((p>0.38)&&(p<0.48))
1140 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
1141 if ((p>0.75)&&(p<0.85))
1142 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
1145 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
1146 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
1147 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
1148 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
1149 AliWarning("Undefined mass !");
1150 return AliPID::ParticleMass(AliPID::kPion);
1153 //______________________________________________________________________________
1154 Double_t AliESDtrack::E() const
1156 // Returns the energy of the particle given its assumed mass.
1157 // Assumes the pion mass if the particle can't be identified properly.
1161 return TMath::Sqrt(p*p + m*m);
1164 //______________________________________________________________________________
1165 Double_t AliESDtrack::Y() const
1167 // Returns the rapidity of a particle given its assumed mass.
1168 // Assumes the pion mass if the particle can't be identified properly.
1172 if (e != TMath::Abs(pz)) { // energy was not equal to pz
1173 return 0.5*TMath::Log((e+pz)/(e-pz));
1174 } else { // energy was equal to pz
1179 //_______________________________________________________________________
1180 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
1182 // This function updates track's running parameters
1187 fLabel=t->GetLabel();
1189 if (t->IsStartedTimeIntegral()) {
1191 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
1192 SetIntegratedLength(t->GetIntegratedLength());
1195 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1196 if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1197 if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
1198 if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
1202 case kITSin: case kITSout: case kITSrefit:
1205 fITSncls=t->GetNumberOfClusters();
1206 Int_t* indexITS = new Int_t[AliESDfriendTrack::kMaxITScluster];
1207 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
1208 indexITS[i]=t->GetClusterIndex(i);
1211 Int_t l=(indexITS[i] & 0xf0000000) >> 28;
1212 SETBIT(fITSClusterMap,l);
1215 fFriendTrack->SetITSIndices(indexITS,AliESDfriendTrack::kMaxITScluster);
1218 fITSchi2=t->GetChi2();
1219 fITSsignal=t->GetPIDsignal();
1220 fITSLabel = t->GetLabel();
1221 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1222 if (flags==kITSout) {
1223 if (!fOp) fOp=new AliExternalTrackParam(*t);
1225 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1230 case kTPCin: case kTPCrefit:
1232 fTPCLabel = t->GetLabel();
1233 if (flags==kTPCin) {
1234 fTPCInner=new AliExternalTrackParam(*t);
1235 fTPCnclsIter1=t->GetNumberOfClusters();
1236 fTPCchi2Iter1=t->GetChi2();
1238 if (!fIp) fIp=new AliExternalTrackParam(*t);
1240 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1244 Int_t* indexTPC = new Int_t[AliESDfriendTrack::kMaxTPCcluster];
1245 if (flags & kTPCout){
1246 if (!fOp) fOp=new AliExternalTrackParam(*t);
1248 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1250 fTPCncls=t->GetNumberOfClusters();
1251 fTPCchi2=t->GetChi2();
1253 {//prevrow must be declared in separate namespace, otherwise compiler cries:
1254 //"jump to case label crosses initialization of `Int_t prevrow'"
1256 // for (Int_t i=0;i<fTPCncls;i++)
1257 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1259 indexTPC[i]=t->GetClusterIndex(i);
1260 Int_t idx = indexTPC[i];
1262 if (idx<0) continue;
1264 // Piotr's Cluster Map for HBT
1265 // ### please change accordingly if cluster array is changing
1266 // to "New TPC Tracking" style (with gaps in array)
1267 Int_t sect = (idx&0xff000000)>>24;
1268 Int_t row = (idx&0x00ff0000)>>16;
1269 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
1271 fTPCClusterMap.SetBitNumber(row,kTRUE);
1273 //Fill the gap between previous row and this row with 0 bits
1274 //In case ### pleas change it as well - just set bit 0 in case there
1275 //is no associated clusters for current "i"
1278 prevrow = row;//if previous bit was not assigned yet == this is the first one
1281 { //we don't know the order (inner to outer or reverse)
1282 //just to be save in case it is going to change
1295 for (Int_t j = n+1; j < m; j++)
1297 fTPCClusterMap.SetBitNumber(j,kFALSE);
1301 // End Of Piotr's Cluster Map for HBT
1303 fFriendTrack->SetTPCIndices(indexTPC,AliESDfriendTrack::kMaxTPCcluster);
1307 fTPCsignal=t->GetPIDsignal();
1311 case kTRDin: case kTRDrefit:
1315 fTRDLabel = t->GetLabel();
1316 fTRDchi2 = t->GetChi2();
1317 fTRDncls = t->GetNumberOfClusters();
1318 Int_t* indexTRD = new Int_t[AliESDfriendTrack::kMaxTRDcluster];
1319 for (Int_t i=0;i<AliESDfriendTrack::kMaxTRDcluster;i++) indexTRD[i]=-2;
1320 for (Int_t i=0;i<6;i++) indexTRD[i]=t->GetTrackletIndex(i);
1321 fFriendTrack->SetTRDIndices(indexTRD,AliESDfriendTrack::kMaxTRDcluster);
1325 fTRDsignal=t->GetPIDsignal();
1329 if (!fOp) fOp=new AliExternalTrackParam(*t);
1331 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1332 fTRDncls0 = t->GetNumberOfClusters();
1341 if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1343 fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1346 AliError("Wrong flag !");
1353 //_______________________________________________________________________
1354 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1355 //---------------------------------------------------------------------
1356 // This function returns external representation of the track parameters
1357 //---------------------------------------------------------------------
1359 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1362 //_______________________________________________________________________
1363 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1364 //---------------------------------------------------------------------
1365 // This function returns external representation of the cov. matrix
1366 //---------------------------------------------------------------------
1367 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1370 //_______________________________________________________________________
1371 Bool_t AliESDtrack::GetConstrainedExternalParameters
1372 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1373 //---------------------------------------------------------------------
1374 // This function returns the constrained external track parameters
1375 //---------------------------------------------------------------------
1376 if (!fCp) return kFALSE;
1377 alpha=fCp->GetAlpha();
1379 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1383 //_______________________________________________________________________
1385 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1386 //---------------------------------------------------------------------
1387 // This function returns the constrained external cov. matrix
1388 //---------------------------------------------------------------------
1389 if (!fCp) return kFALSE;
1390 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1395 AliESDtrack::GetInnerExternalParameters
1396 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1397 //---------------------------------------------------------------------
1398 // This function returns external representation of the track parameters
1399 // at the inner layer of TPC
1400 //---------------------------------------------------------------------
1401 if (!fIp) return kFALSE;
1402 alpha=fIp->GetAlpha();
1404 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1409 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1410 //---------------------------------------------------------------------
1411 // This function returns external representation of the cov. matrix
1412 // at the inner layer of TPC
1413 //---------------------------------------------------------------------
1414 if (!fIp) return kFALSE;
1415 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1420 AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1422 // This is a direct setter for the outer track parameters
1425 if (fOp) delete fOp;
1426 fOp=new AliExternalTrackParam(*p);
1430 AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1432 // This is a direct setter for the outer track parameters
1435 if (fHMPIDp) delete fHMPIDp;
1436 fHMPIDp=new AliExternalTrackParam(*p);
1440 AliESDtrack::GetOuterExternalParameters
1441 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1442 //---------------------------------------------------------------------
1443 // This function returns external representation of the track parameters
1444 // at the inner layer of TRD
1445 //---------------------------------------------------------------------
1446 if (!fOp) return kFALSE;
1447 alpha=fOp->GetAlpha();
1449 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1454 AliESDtrack::GetOuterHmpExternalParameters
1455 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1456 //---------------------------------------------------------------------
1457 // This function returns external representation of the track parameters
1458 // at the inner layer of TRD
1459 //---------------------------------------------------------------------
1460 if (!fHMPIDp) return kFALSE;
1461 alpha=fHMPIDp->GetAlpha();
1463 for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1468 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1469 //---------------------------------------------------------------------
1470 // This function returns external representation of the cov. matrix
1471 // at the inner layer of TRD
1472 //---------------------------------------------------------------------
1473 if (!fOp) return kFALSE;
1474 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1479 AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1480 //---------------------------------------------------------------------
1481 // This function returns external representation of the cov. matrix
1482 // at the inner layer of TRD
1483 //---------------------------------------------------------------------
1484 if (!fHMPIDp) return kFALSE;
1485 for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1489 Int_t AliESDtrack::GetNcls(Int_t idet) const
1491 // Get number of clusters by subdetector index
1505 if (fTOFindex != -1)
1511 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1512 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1523 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1525 // Get cluster index array by subdetector index
1530 ncls = GetITSclusters(idx);
1533 ncls = GetTPCclusters(idx);
1536 ncls = GetTRDclusters(idx);
1539 if (fTOFindex != -1) {
1547 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1548 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1549 idx[0] = GetHMPIDcluIdx();
1562 //_______________________________________________________________________
1563 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1564 // Returns the array with integrated times for each particle hypothesis
1565 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1568 //_______________________________________________________________________
1569 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1570 // Sets the array with integrated times for each particle hypotesis
1571 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1574 //_______________________________________________________________________
1575 void AliESDtrack::SetITSpid(const Double_t *p) {
1576 // Sets values for the probability of each particle type (in ITS)
1577 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1578 SetStatus(AliESDtrack::kITSpid);
1581 //_______________________________________________________________________
1582 void AliESDtrack::GetITSpid(Double_t *p) const {
1583 // Gets the probability of each particle type (in ITS)
1584 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1587 //_______________________________________________________________________
1588 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1589 //---------------------------------------------------------------------
1590 // This function returns indices of the assgined ITS clusters
1591 //---------------------------------------------------------------------
1593 Int_t *index=fFriendTrack->GetITSindices();
1594 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1595 if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1607 //_______________________________________________________________________
1608 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1609 Float_t &xloc,Float_t &zloc) const {
1610 //----------------------------------------------------------------------
1611 // This function encodes in the module number also the status of cluster association
1612 // "status" can have the following values:
1613 // 1 "found" (cluster is associated),
1614 // 2 "dead" (module is dead from OCDB),
1615 // 3 "skipped" (module or layer forced to be skipped),
1616 // 4 "outinz" (track out of z acceptance),
1617 // 5 "nocls" (no clusters in the road),
1618 // 6 "norefit" (cluster rejected during refit),
1619 // 7 "deadzspd" (holes in z in SPD)
1620 // Also given are the coordinates of the crossing point of track and module
1621 // (in the local module ref. system)
1622 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1623 //----------------------------------------------------------------------
1625 if(fITSModule[ilayer]==-1) {
1628 xloc=-99.; zloc=-99.;
1632 Int_t module = fITSModule[ilayer];
1634 idet = Int_t(module/1000000);
1636 module -= idet*1000000;
1638 status = Int_t(module/100000);
1640 module -= status*100000;
1642 Int_t signs = Int_t(module/10000);
1644 module-=signs*10000;
1646 Int_t xInt = Int_t(module/100);
1649 Int_t zInt = module;
1651 if(signs==1) { xInt*=1; zInt*=1; }
1652 if(signs==2) { xInt*=1; zInt*=-1; }
1653 if(signs==3) { xInt*=-1; zInt*=1; }
1654 if(signs==4) { xInt*=-1; zInt*=-1; }
1656 xloc = 0.1*(Float_t)xInt;
1657 zloc = 0.1*(Float_t)zInt;
1659 if(status==4) idet = -1;
1664 //_______________________________________________________________________
1665 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1666 //---------------------------------------------------------------------
1667 // This function returns indices of the assgined ITS clusters
1668 //---------------------------------------------------------------------
1670 Int_t *index=fFriendTrack->GetTPCindices();
1673 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1676 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=-2;
1682 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1684 // GetDensity of the clusters on given region between row0 and row1
1685 // Dead zone effect takin into acoount
1690 Int_t *index=fFriendTrack->GetTPCindices();
1691 for (Int_t i=row0;i<=row1;i++){
1692 Int_t idx = index[i];
1693 if (idx!=-1) good++; // track outside of dead zone
1696 Float_t density=0.5;
1697 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1701 //_______________________________________________________________________
1702 void AliESDtrack::SetTPCpid(const Double_t *p) {
1703 // Sets values for the probability of each particle type (in TPC)
1704 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1705 SetStatus(AliESDtrack::kTPCpid);
1708 //_______________________________________________________________________
1709 void AliESDtrack::GetTPCpid(Double_t *p) const {
1710 // Gets the probability of each particle type (in TPC)
1711 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1714 //_______________________________________________________________________
1715 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1716 //---------------------------------------------------------------------
1717 // This function returns indices of the assgined TRD clusters
1718 //---------------------------------------------------------------------
1720 Int_t *index=fFriendTrack->GetTRDindices();
1723 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1726 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=-2;
1732 //_______________________________________________________________________
1733 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1735 // This function returns the number of TRD tracklets used in tracking
1736 // and it fills the indices of these tracklets in the array "idx" as they
1737 // are registered in the TRD track list.
1740 // 1. The idx array has to be allocated with a size >= AliESDtrack::kTRDnPlanes
1741 // 2. The idx array store not only the index but also the layer of the tracklet.
1742 // Therefore tracks with TRD gaps contain default values for indices [-1]
1744 if (!idx) return GetTRDntracklets();
1745 Int_t *index=fFriendTrack->GetTRDindices();
1747 for (Int_t i=0; i<kTRDnPlanes; i++){
1749 if(index[i]>=0) n++;
1757 //_______________________________________________________________________
1758 void AliESDtrack::SetTRDpid(const Double_t *p) {
1759 // Sets values for the probability of each particle type (in TRD)
1760 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1761 SetStatus(AliESDtrack::kTRDpid);
1764 //_______________________________________________________________________
1765 void AliESDtrack::GetTRDpid(Double_t *p) const {
1766 // Gets the probability of each particle type (in TRD)
1767 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1770 //_______________________________________________________________________
1771 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1773 // Sets the probability of particle type iSpecies to p (in TRD)
1774 fTRDr[iSpecies] = p;
1777 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1779 // Returns the probability of particle type iSpecies (in TRD)
1780 return fTRDr[iSpecies];
1783 //____________________________________________________
1784 Int_t AliESDtrack::GetNumberOfTRDslices() const
1786 // built in backward compatibility
1787 Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
1788 return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
1791 //____________________________________________________
1792 Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
1794 //Returns momentum estimation and optional its error (sp)
1795 // in TRD layer "plane".
1798 AliError("No TRD info allocated for this track !");
1801 if ((plane<0) || (plane>=kTRDnPlanes)) {
1802 AliError("Info for TRD plane not available!");
1806 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1807 // Protection for backward compatibility
1808 if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
1810 if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
1811 return fTRDslices[idx];
1814 //____________________________________________________
1815 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1816 //Gets the charge from the slice of the plane
1819 //AliError("No TRD slices allocated for this track !");
1822 if ((plane<0) || (plane>=kTRDnPlanes)) {
1823 AliError("Info for TRD plane not available !");
1826 Int_t ns=GetNumberOfTRDslices();
1827 if ((slice<-1) || (slice>=ns)) {
1828 //AliError("Wrong TRD slice !");
1832 if(slice>=0) return fTRDslices[plane*ns + slice];
1834 // return average of the dEdx measurements
1835 Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
1836 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
1840 //____________________________________________________
1841 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1842 //Sets the number of slices used for PID
1843 if (fTRDnSlices) return;
1846 fTRDslices=new Double32_t[fTRDnSlices];
1848 // set-up correctly the allocated memory
1849 memset(fTRDslices, 0, n*sizeof(Double32_t));
1850 for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
1853 //____________________________________________________
1854 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1855 //Sets the charge q in the slice of the plane
1857 AliError("No TRD slices allocated for this track !");
1860 if ((plane<0) || (plane>=kTRDnPlanes)) {
1861 AliError("Info for TRD plane not allocated !");
1864 Int_t ns=GetNumberOfTRDslices();
1865 if ((slice<0) || (slice>=ns)) {
1866 AliError("Wrong TRD slice !");
1869 Int_t n=plane*ns + slice;
1874 //____________________________________________________
1875 void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
1878 AliError("No TRD slices allocated for this track !");
1881 if ((plane<0) || (plane>=kTRDnPlanes)) {
1882 AliError("Info for TRD plane not allocated !");
1886 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1887 // Protection for backward compatibility
1888 if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
1890 if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
1891 fTRDslices[idx] = p;
1895 //_______________________________________________________________________
1896 void AliESDtrack::SetTOFpid(const Double_t *p) {
1897 // Sets the probability of each particle type (in TOF)
1898 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
1899 SetStatus(AliESDtrack::kTOFpid);
1902 //_______________________________________________________________________
1903 void AliESDtrack::SetTOFLabel(const Int_t *p) {
1905 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1908 //_______________________________________________________________________
1909 void AliESDtrack::GetTOFpid(Double_t *p) const {
1910 // Gets probabilities of each particle type (in TOF)
1911 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
1914 //_______________________________________________________________________
1915 void AliESDtrack::GetTOFLabel(Int_t *p) const {
1917 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
1920 //_______________________________________________________________________
1921 void AliESDtrack::GetTOFInfo(Float_t *info) const {
1923 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
1926 //_______________________________________________________________________
1927 void AliESDtrack::SetTOFInfo(Float_t*info) {
1929 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
1934 //_______________________________________________________________________
1935 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
1936 // Sets the probability of each particle type (in HMPID)
1937 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
1938 SetStatus(AliESDtrack::kHMPIDpid);
1941 //_______________________________________________________________________
1942 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
1943 // Gets probabilities of each particle type (in HMPID)
1944 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
1949 //_______________________________________________________________________
1950 void AliESDtrack::SetESDpid(const Double_t *p) {
1951 // Sets the probability of each particle type for the ESD track
1952 SetPIDValues(fR,p,AliPID::kSPECIES);
1953 SetStatus(AliESDtrack::kESDpid);
1956 //_______________________________________________________________________
1957 void AliESDtrack::GetESDpid(Double_t *p) const {
1958 // Gets probability of each particle type for the ESD track
1959 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
1962 //_______________________________________________________________________
1963 Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
1964 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
1966 // Try to relate the TPC-only track parameters to the vertex "vtx",
1967 // if the (rough) transverse impact parameter is not bigger then "maxd".
1968 // Magnetic field is "b" (kG).
1970 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
1971 // b) The impact parameters and their covariance matrix are calculated.
1972 // c) An attempt to constrain the TPC-only params to the vertex is done.
1973 // The constrained params are returned via "cParam".
1975 // In the case of success, the returned value is kTRUE
1976 // otherwise, it's kFALSE)
1979 if (!fTPCInner) return kFALSE;
1980 if (!vtx) return kFALSE;
1982 Double_t dz[2],cov[3];
1983 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1991 Double_t covar[6]; vtx->GetCovMatrix(covar);
1992 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1993 Double_t c[3]={covar[2],0.,covar[5]};
1995 Double_t chi2=GetPredictedChi2(p,c);
1996 if (chi2>kVeryBig) return kFALSE;
2000 if (!cParam) return kTRUE;
2002 *cParam = *fTPCInner;
2003 if (!cParam->Update(p,c)) return kFALSE;
2008 //_______________________________________________________________________
2009 Bool_t AliESDtrack::RelateToVertexTPCBxByBz(const AliESDVertex *vtx,
2010 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2012 // Try to relate the TPC-only track parameters to the vertex "vtx",
2013 // if the (rough) transverse impact parameter is not bigger then "maxd".
2015 // All three components of the magnetic field ,"b[3]" (kG),
2016 // are taken into account.
2018 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2019 // b) The impact parameters and their covariance matrix are calculated.
2020 // c) An attempt to constrain the TPC-only params to the vertex is done.
2021 // The constrained params are returned via "cParam".
2023 // In the case of success, the returned value is kTRUE
2024 // otherwise, it's kFALSE)
2027 if (!fTPCInner) return kFALSE;
2028 if (!vtx) return kFALSE;
2030 Double_t dz[2],cov[3];
2031 if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2039 Double_t covar[6]; vtx->GetCovMatrix(covar);
2040 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2041 Double_t c[3]={covar[2],0.,covar[5]};
2043 Double_t chi2=GetPredictedChi2(p,c);
2044 if (chi2>kVeryBig) return kFALSE;
2048 if (!cParam) return kTRUE;
2050 *cParam = *fTPCInner;
2051 if (!cParam->Update(p,c)) return kFALSE;
2056 //_______________________________________________________________________
2057 Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
2058 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2060 // Try to relate this track to the vertex "vtx",
2061 // if the (rough) transverse impact parameter is not bigger then "maxd".
2062 // Magnetic field is "b" (kG).
2064 // a) The track gets extapolated to the DCA to the vertex.
2065 // b) The impact parameters and their covariance matrix are calculated.
2066 // c) An attempt to constrain this track to the vertex is done.
2067 // The constrained params are returned via "cParam".
2069 // In the case of success, the returned value is kTRUE
2070 // (otherwise, it's kFALSE)
2073 if (!vtx) return kFALSE;
2075 Double_t dz[2],cov[3];
2076 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2084 Double_t covar[6]; vtx->GetCovMatrix(covar);
2085 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2086 Double_t c[3]={covar[2],0.,covar[5]};
2088 Double_t chi2=GetPredictedChi2(p,c);
2089 if (chi2>kVeryBig) return kFALSE;
2094 //--- Could now these lines be removed ? ---
2096 fCp=new AliExternalTrackParam(*this);
2098 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2099 //----------------------------------------
2101 fVertexID = vtx->GetID();
2103 if (!cParam) return kTRUE;
2106 if (!cParam->Update(p,c)) return kFALSE;
2111 //_______________________________________________________________________
2112 Bool_t AliESDtrack::RelateToVertexBxByBz(const AliESDVertex *vtx,
2113 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2115 // Try to relate this track to the vertex "vtx",
2116 // if the (rough) transverse impact parameter is not bigger then "maxd".
2117 // Magnetic field is "b" (kG).
2119 // a) The track gets extapolated to the DCA to the vertex.
2120 // b) The impact parameters and their covariance matrix are calculated.
2121 // c) An attempt to constrain this track to the vertex is done.
2122 // The constrained params are returned via "cParam".
2124 // In the case of success, the returned value is kTRUE
2125 // (otherwise, it's kFALSE)
2128 if (!vtx) return kFALSE;
2130 Double_t dz[2],cov[3];
2131 if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2139 Double_t covar[6]; vtx->GetCovMatrix(covar);
2140 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2141 Double_t c[3]={covar[2],0.,covar[5]};
2143 Double_t chi2=GetPredictedChi2(p,c);
2144 if (chi2>kVeryBig) return kFALSE;
2149 //--- Could now these lines be removed ? ---
2151 fCp=new AliExternalTrackParam(*this);
2153 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2154 //----------------------------------------
2156 fVertexID = vtx->GetID();
2158 if (!cParam) return kTRUE;
2161 if (!cParam->Update(p,c)) return kFALSE;
2166 //_______________________________________________________________________
2167 void AliESDtrack::Print(Option_t *) const {
2168 // Prints info on the track
2169 AliExternalTrackParam::Print();
2170 printf("ESD track info\n") ;
2171 Double_t p[AliPID::kSPECIESN] ;
2173 if( IsOn(kITSpid) ){
2174 printf("From ITS: ") ;
2176 for(index = 0 ; index < AliPID::kSPECIES; index++)
2177 printf("%f, ", p[index]) ;
2178 printf("\n signal = %f\n", GetITSsignal()) ;
2180 if( IsOn(kTPCpid) ){
2181 printf("From TPC: ") ;
2183 for(index = 0 ; index < AliPID::kSPECIES; index++)
2184 printf("%f, ", p[index]) ;
2185 printf("\n signal = %f\n", GetTPCsignal()) ;
2187 if( IsOn(kTRDpid) ){
2188 printf("From TRD: ") ;
2190 for(index = 0 ; index < AliPID::kSPECIES; index++)
2191 printf("%f, ", p[index]) ;
2192 printf("\n signal = %f\n", GetTRDsignal()) ;
2194 if( IsOn(kTOFpid) ){
2195 printf("From TOF: ") ;
2197 for(index = 0 ; index < AliPID::kSPECIES; index++)
2198 printf("%f, ", p[index]) ;
2199 printf("\n signal = %f\n", GetTOFsignal()) ;
2201 if( IsOn(kHMPIDpid) ){
2202 printf("From HMPID: ") ;
2204 for(index = 0 ; index < AliPID::kSPECIES; index++)
2205 printf("%f, ", p[index]) ;
2206 printf("\n signal = %f\n", GetHMPIDsignal()) ;
2212 // Draw functionality
2213 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
2215 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
2217 // Fill points in the polymarker
2220 arrayRef.AddLast(new AliExternalTrackParam(*this));
2221 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
2222 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
2223 if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
2225 Double_t mpos[3]={0,0,0};
2226 Int_t entries=arrayRef.GetEntries();
2227 for (Int_t i=0;i<entries;i++){
2229 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
2230 mpos[0]+=pos[0]/entries;
2231 mpos[1]+=pos[1]/entries;
2232 mpos[2]+=pos[2]/entries;
2234 // Rotate to the mean position
2236 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
2237 for (Int_t i=0;i<entries;i++){
2238 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
2239 if (!res) delete arrayRef.RemoveAt(i);
2242 for (Double_t r=minR; r<maxR; r+=stepR){
2244 Double_t mlpos[3]={0,0,0};
2245 for (Int_t i=0;i<entries;i++){
2246 Double_t point[3]={0,0,0};
2247 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
2248 if (!param) continue;
2249 if (param->GetXYZAt(r,magF,point)){
2250 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
2252 mlpos[0]+=point[0]*weight;
2253 mlpos[1]+=point[1]*weight;
2254 mlpos[2]+=point[2]*weight;
2261 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
2262 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
2268 //_______________________________________________________________________
2269 void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
2271 // Store the dE/dx samples measured by the two SSD and two SDD layers.
2272 // These samples are corrected for the track segment length.
2274 for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
2277 //_______________________________________________________________________
2278 void AliESDtrack::GetITSdEdxSamples(Double_t *s) const {
2280 // Get the dE/dx samples measured by the two SSD and two SDD layers.
2281 // These samples are corrected for the track segment length.
2283 for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];
2287 UShort_t AliESDtrack::GetTPCnclsS(Int_t i0,Int_t i1) const{
2289 // get number of shared clusters
2291 return fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);