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),
226 fVertexID(-2),// -2 means an orphan track
230 // The default ESD constructor
233 for (i=0; i<AliPID::kSPECIES; i++) {
243 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
244 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
245 for (i=0;i<kTRDnPlanes;i++) {
248 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
249 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
250 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
251 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
252 for (i=0;i<12;i++) {fITSModule[i]=-1;}
255 //_______________________________________________________________________
256 AliESDtrack::AliESDtrack(const AliESDtrack& track):
257 AliExternalTrackParam(track),
264 fTPCClusterMap(track.fTPCClusterMap),
265 fTPCSharedMap(track.fTPCSharedMap),
266 fFlags(track.fFlags),
268 fLabel(track.fLabel),
269 fITSLabel(track.fITSLabel),
270 fTPCLabel(track.fTPCLabel),
271 fTRDLabel(track.fTRDLabel),
272 fTOFCalChannel(track.fTOFCalChannel),
273 fTOFindex(track.fTOFindex),
274 fHMPIDqn(track.fHMPIDqn),
275 fHMPIDcluIdx(track.fHMPIDcluIdx),
276 fCaloIndex(track.fCaloIndex),
277 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
278 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
279 fHMPIDsignal(track.fHMPIDsignal),
280 fTrackLength(track.fTrackLength),
281 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
282 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
283 fCchi2TPC(track.fCchi2TPC),
284 fD(track.fD),fZ(track.fZ),
285 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
286 fCchi2(track.fCchi2),
287 fITSchi2(track.fITSchi2),
288 fTPCchi2(track.fTPCchi2),
289 fTPCchi2Iter1(track.fTPCchi2Iter1),
290 fTRDchi2(track.fTRDchi2),
291 fTOFchi2(track.fTOFchi2),
292 fHMPIDchi2(track.fHMPIDchi2),
293 fGlobalChi2(track.fGlobalChi2),
294 fITSsignal(track.fITSsignal),
295 fTPCsignal(track.fTPCsignal),
296 fTPCsignalS(track.fTPCsignalS),
297 fTRDsignal(track.fTRDsignal),
298 fTRDQuality(track.fTRDQuality),
299 fTRDBudget(track.fTRDBudget),
300 fTOFsignal(track.fTOFsignal),
301 fTOFsignalToT(track.fTOFsignalToT),
302 fTOFsignalRaw(track.fTOFsignalRaw),
303 fTOFsignalDz(track.fTOFsignalDz),
304 fTOFsignalDx(track.fTOFsignalDx),
305 fCaloDx(track.fCaloDx),
306 fCaloDz(track.fCaloDz),
307 fHMPIDtrkX(track.fHMPIDtrkX),
308 fHMPIDtrkY(track.fHMPIDtrkY),
309 fHMPIDmipX(track.fHMPIDmipX),
310 fHMPIDmipY(track.fHMPIDmipY),
311 fTPCncls(track.fTPCncls),
312 fTPCnclsF(track.fTPCnclsF),
313 fTPCsignalN(track.fTPCsignalN),
314 fTPCnclsIter1(track.fTPCnclsIter1),
315 fTPCnclsFIter1(track.fTPCnclsIter1),
316 fITSncls(track.fITSncls),
317 fITSClusterMap(track.fITSClusterMap),
318 fTRDncls(track.fTRDncls),
319 fTRDncls0(track.fTRDncls0),
320 fTRDntracklets(track.fTRDntracklets),
321 fTRDnSlices(track.fTRDnSlices),
323 fVertexID(track.fVertexID),
324 fESDEvent(track.fESDEvent)
329 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
330 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
332 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
334 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
335 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
336 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
337 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
338 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
340 for (Int_t i=0;i<kTRDnPlanes;i++) {
341 fTRDTimBin[i]=track.fTRDTimBin[i];
345 fTRDslices=new Double32_t[fTRDnSlices];
346 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
349 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
350 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
351 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
352 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
353 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
354 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
356 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
357 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
358 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
359 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
360 if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
362 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
365 //_______________________________________________________________________
366 AliESDtrack::AliESDtrack(const AliVTrack *track) :
367 AliExternalTrackParam(track),
374 fTPCClusterMap(159),//number of padrows
375 fTPCSharedMap(159),//number of padrows
386 fCaloIndex(kEMCALNoMatch),
392 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
395 fCdd(0),fCdz(0),fCzz(0),
433 fVertexID(-2), // -2 means an orphan track
437 // ESD track from AliVTrack.
438 // This is not a copy constructor !
441 if (track->InheritsFrom("AliExternalTrackParam")) {
442 AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
443 AliWarning("Calling the default constructor...");
448 // Reset all the arrays
450 for (i=0; i<AliPID::kSPECIES; i++) {
460 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
461 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
462 for (i=0;i<kTRDnPlanes;i++) {
465 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
466 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
467 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
468 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
469 for (i=0;i<12;i++) {fITSModule[i]=-1;}
472 SetID(track->GetID());
474 // Set ITS cluster map
475 fITSClusterMap=track->GetITSClusterMap();
479 if(HasPointOnITSLayer(i)) fITSncls++;
482 // Set the combined PID
483 const Double_t *pid = track->PID();
485 for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
487 // AliESD track label
488 SetLabel(track->GetLabel());
490 SetStatus(track->GetStatus());
493 //_______________________________________________________________________
494 AliESDtrack::AliESDtrack(TParticle * part) :
495 AliExternalTrackParam(),
502 fTPCClusterMap(159),//number of padrows
503 fTPCSharedMap(159),//number of padrows
514 fCaloIndex(kEMCALNoMatch),
520 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
523 fCdd(0),fCdz(0),fCzz(0),
561 fVertexID(-2), // -2 means an orphan track
565 // ESD track from TParticle
568 // Reset all the arrays
570 for (i=0; i<AliPID::kSPECIES; i++) {
580 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
581 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
582 for (i=0;i<kTRDnPlanes;i++) {
585 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
586 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
587 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
588 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
589 for (i=0;i<12;i++) {fITSModule[i]=-1;}
591 // Calculate the AliExternalTrackParam content
598 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
599 alpha = part->Phi()*180./TMath::Pi();
600 if (alpha<0) alpha+= 360.;
601 if (alpha>360) alpha -= 360.;
603 Int_t sector = (Int_t)(alpha/20.);
604 alpha = 10. + 20.*sector;
606 alpha *= TMath::Pi();
608 // Covariance matrix: no errors, the parameters are exact
609 for (i=0; i<15; i++) covar[i]=0.;
611 // Get the vertex of origin and the momentum
612 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
613 TVector3 mom(part->Px(),part->Py(),part->Pz());
615 // Rotate to the local coordinate system (TPC sector)
619 // X of the referense plane
622 Int_t pdgCode = part->GetPdgCode();
625 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
629 param[2] = TMath::Sin(mom.Phi());
630 param[3] = mom.Pz()/mom.Pt();
631 param[4] = TMath::Sign(1/mom.Pt(),charge);
633 // Set AliExternalTrackParam
634 Set(xref, alpha, param, covar);
639 switch (TMath::Abs(pdgCode)) {
665 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
666 if (indexPID < AliPID::kSPECIES) {
672 fHMPIDr[indexPID]=1.;
675 // AliESD track label
676 SetLabel(part->GetUniqueID());
680 //_______________________________________________________________________
681 AliESDtrack::~AliESDtrack(){
683 // This is destructor according Coding Conventrions
685 //printf("Delete track\n");
696 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
699 if(&source == this) return *this;
700 AliExternalTrackParam::operator=(source);
704 // we have the trackparam: assign or copy construct
705 if(fCp)*fCp = *source.fCp;
706 else fCp = new AliExternalTrackParam(*source.fCp);
709 // no track param delete the old one
715 // we have the trackparam: assign or copy construct
716 if(fIp)*fIp = *source.fIp;
717 else fIp = new AliExternalTrackParam(*source.fIp);
720 // no track param delete the old one
726 if(source.fTPCInner){
727 // we have the trackparam: assign or copy construct
728 if(fTPCInner) *fTPCInner = *source.fTPCInner;
729 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
732 // no track param delete the old one
733 if(fTPCInner)delete fTPCInner;
739 // we have the trackparam: assign or copy construct
740 if(fOp) *fOp = *source.fOp;
741 else fOp = new AliExternalTrackParam(*source.fOp);
744 // no track param delete the old one
751 // we have the trackparam: assign or copy construct
752 if(fHMPIDp) *fHMPIDp = *source.fHMPIDp;
753 else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
756 // no track param delete the old one
757 if(fHMPIDp)delete fHMPIDp;
762 // copy also the friend track
763 // use copy constructor
764 if(source.fFriendTrack){
765 // we have the trackparam: assign or copy construct
766 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
769 // no track param delete the old one
770 delete fFriendTrack; fFriendTrack= 0;
773 fTPCClusterMap = source.fTPCClusterMap;
774 fTPCSharedMap = source.fTPCSharedMap;
776 fFlags = source.fFlags;
778 fLabel = source.fLabel;
779 fITSLabel = source.fITSLabel;
780 for(int i = 0; i< 12;++i){
781 fITSModule[i] = source.fITSModule[i];
783 fTPCLabel = source.fTPCLabel;
784 fTRDLabel = source.fTRDLabel;
785 for(int i = 0; i< 3;++i){
786 fTOFLabel[i] = source.fTOFLabel[i];
788 fTOFCalChannel = source.fTOFCalChannel;
789 fTOFindex = source.fTOFindex;
790 fHMPIDqn = source.fHMPIDqn;
791 fHMPIDcluIdx = source.fHMPIDcluIdx;
792 fCaloIndex = source.fCaloIndex;
794 for(int i = 0; i< 3;++i){
795 fKinkIndexes[i] = source.fKinkIndexes[i];
796 fV0Indexes[i] = source.fV0Indexes[i];
799 for(int i = 0; i< AliPID::kSPECIES;++i){
800 fR[i] = source.fR[i];
801 fITSr[i] = source.fITSr[i];
802 fTPCr[i] = source.fTPCr[i];
803 fTRDr[i] = source.fTRDr[i];
804 fTOFr[i] = source.fTOFr[i];
805 fHMPIDr[i] = source.fHMPIDr[i];
806 fTrackTime[i] = source.fTrackTime[i];
809 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
810 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
811 fHMPIDsignal = source.fHMPIDsignal;
814 fTrackLength = source. fTrackLength;
815 fdTPC = source.fdTPC;
816 fzTPC = source.fzTPC;
817 fCddTPC = source.fCddTPC;
818 fCdzTPC = source.fCdzTPC;
819 fCzzTPC = source.fCzzTPC;
820 fCchi2TPC = source.fCchi2TPC;
827 fCchi2 = source.fCchi2;
829 fITSchi2 = source.fITSchi2;
830 fTPCchi2 = source.fTPCchi2;
831 fTPCchi2Iter1 = source.fTPCchi2Iter1;
832 fTRDchi2 = source.fTRDchi2;
833 fTOFchi2 = source.fTOFchi2;
834 fHMPIDchi2 = source.fHMPIDchi2;
836 fGlobalChi2 = source.fGlobalChi2;
838 fITSsignal = source.fITSsignal;
839 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
840 fTPCsignal = source.fTPCsignal;
841 fTPCsignalS = source.fTPCsignalS;
842 for(int i = 0; i< 4;++i){
843 fTPCPoints[i] = source.fTPCPoints[i];
845 fTRDsignal = source.fTRDsignal;
847 for(int i = 0;i < kTRDnPlanes;++i){
848 fTRDTimBin[i] = source.fTRDTimBin[i];
854 fTRDnSlices=source.fTRDnSlices;
856 fTRDslices=new Double32_t[fTRDnSlices];
857 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
860 fTRDQuality = source.fTRDQuality;
861 fTRDBudget = source.fTRDBudget;
862 fTOFsignal = source.fTOFsignal;
863 fTOFsignalToT = source.fTOFsignalToT;
864 fTOFsignalRaw = source.fTOFsignalRaw;
865 fTOFsignalDz = source.fTOFsignalDz;
866 fTOFsignalDx = source.fTOFsignalDx;
868 for(int i = 0;i<10;++i){
869 fTOFInfo[i] = source.fTOFInfo[i];
872 fHMPIDtrkX = source.fHMPIDtrkX;
873 fHMPIDtrkY = source.fHMPIDtrkY;
874 fHMPIDmipX = source.fHMPIDmipX;
875 fHMPIDmipY = source.fHMPIDmipY;
877 fTPCncls = source.fTPCncls;
878 fTPCnclsF = source.fTPCnclsF;
879 fTPCsignalN = source.fTPCsignalN;
880 fTPCnclsIter1 = source.fTPCnclsIter1;
881 fTPCnclsFIter1 = source.fTPCnclsFIter1;
883 fITSncls = source.fITSncls;
884 fITSClusterMap = source.fITSClusterMap;
885 fTRDncls = source.fTRDncls;
886 fTRDncls0 = source.fTRDncls0;
887 fTRDntracklets = source.fTRDntracklets;
888 fVertexID = source.fVertexID;
894 void AliESDtrack::Copy(TObject &obj) const {
896 // this overwrites the virtual TOBject::Copy()
897 // to allow run time copying without casting
900 if(this==&obj)return;
901 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
902 if(!robj)return; // not an AliESDtrack
909 void AliESDtrack::AddCalibObject(TObject * object){
911 // add calib object to the list
913 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
914 fFriendTrack->AddCalibObject(object);
917 TObject * AliESDtrack::GetCalibObject(Int_t index){
919 // return calib objct at given position
921 if (!fFriendTrack) return 0;
922 return fFriendTrack->GetCalibObject(index);
926 Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
928 // Fills the information of the TPC-only first reconstruction pass
929 // into the passed ESDtrack object. For consistency fTPCInner is also filled
934 // For data produced before r26675
935 // RelateToVertexTPC was not properly called during reco
936 // so you'll have to call it again, before FillTPCOnlyTrack
937 // Float_t p[2],cov[3];
938 // track->GetImpactParametersTPC(p,cov);
939 // if(p[0]==0&&p[1]==0) // <- Default values
940 // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
943 if(!fTPCInner)return kFALSE;
945 // fill the TPC track params to the global track parameters
946 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
949 track.fCdd = fCddTPC;
950 track.fCdz = fCdzTPC;
951 track.fCzz = fCzzTPC;
953 // copy the TPCinner parameters
954 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
955 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
958 track.fCddTPC = fCddTPC;
959 track.fCdzTPC = fCdzTPC;
960 track.fCzzTPC = fCzzTPC;
961 track.fCchi2TPC = fCchi2TPC;
964 // copy all other TPC specific parameters
966 // replace label by TPC label
967 track.fLabel = fTPCLabel;
968 track.fTPCLabel = fTPCLabel;
970 track.fTPCchi2 = fTPCchi2;
971 track.fTPCchi2Iter1 = fTPCchi2Iter1;
972 track.fTPCsignal = fTPCsignal;
973 track.fTPCsignalS = fTPCsignalS;
974 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
976 track.fTPCncls = fTPCncls;
977 track.fTPCnclsF = fTPCnclsF;
978 track.fTPCsignalN = fTPCsignalN;
979 track.fTPCnclsIter1 = fTPCnclsIter1;
980 track.fTPCnclsFIter1 = fTPCnclsFIter1;
983 for(int i=0;i<AliPID::kSPECIES;++i){
984 track.fTPCr[i] = fTPCr[i];
985 // combined PID is TPC only!
986 track.fR[i] = fTPCr[i];
988 track.fTPCClusterMap = fTPCClusterMap;
989 track.fTPCSharedMap = fTPCSharedMap;
993 track.fFlags = kTPCin;
996 track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
998 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
1004 //_______________________________________________________________________
1005 void AliESDtrack::MakeMiniESDtrack(){
1006 // Resets everything except
1007 // fFlags: Reconstruction status flags
1008 // fLabel: Track label
1009 // fID: Unique ID of the track
1010 // Impact parameter information
1011 // fR[AliPID::kSPECIES]: combined "detector response probability"
1012 // Running track parameters in the base class (AliExternalTrackParam)
1016 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
1018 // Reset track parameters constrained to the primary vertex
1021 // Reset track parameters at the inner wall of TPC
1023 delete fTPCInner;fTPCInner=0;
1024 // Reset track parameters at the inner wall of the TRD
1026 // Reset track parameters at the HMPID
1027 delete fHMPIDp;fHMPIDp = 0;
1030 // Reset ITS track related information
1035 for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
1036 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
1039 // Reset TPC related track information
1051 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
1053 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1054 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1055 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1057 // Reset TRD related track information
1062 for (Int_t i=0;i<kTRDnPlanes;i++) {
1065 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1070 delete[] fTRDslices;
1075 // Reset TOF related track information
1084 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
1085 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
1086 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1088 // Reset HMPID related track information
1093 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
1100 fCaloIndex = kEMCALNoMatch;
1102 // reset global track chi2
1105 fVertexID = -2; // an orphan track
1107 delete fFriendTrack; fFriendTrack = 0;
1109 //_______________________________________________________________________
1110 Double_t AliESDtrack::GetMass() const {
1111 // Returns the mass of the most probable particle type
1114 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
1115 if (fR[i]>max) {k=i; max=fR[i];}
1117 if (k==0) { // dE/dx "crossing points" in the TPC
1119 if ((p>0.38)&&(p<0.48))
1120 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
1121 if ((p>0.75)&&(p<0.85))
1122 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
1125 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
1126 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
1127 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
1128 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
1129 AliWarning("Undefined mass !");
1130 return AliPID::ParticleMass(AliPID::kPion);
1133 //______________________________________________________________________________
1134 Double_t AliESDtrack::E() const
1136 // Returns the energy of the particle given its assumed mass.
1137 // Assumes the pion mass if the particle can't be identified properly.
1141 return TMath::Sqrt(p*p + m*m);
1144 //______________________________________________________________________________
1145 Double_t AliESDtrack::Y() const
1147 // Returns the rapidity of a particle given its assumed mass.
1148 // Assumes the pion mass if the particle can't be identified properly.
1152 if (e != TMath::Abs(pz)) { // energy was not equal to pz
1153 return 0.5*TMath::Log((e+pz)/(e-pz));
1154 } else { // energy was equal to pz
1159 //_______________________________________________________________________
1160 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
1162 // This function updates track's running parameters
1168 fLabel=t->GetLabel();
1170 if (t->IsStartedTimeIntegral()) {
1172 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
1173 SetIntegratedLength(t->GetIntegratedLength());
1176 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1177 if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1178 if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
1179 if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
1183 case kITSin: case kITSout: case kITSrefit:
1185 fITSncls=t->GetNumberOfClusters();
1186 index=fFriendTrack->GetITSindices();
1187 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
1188 index[i]=t->GetClusterIndex(i);
1190 Int_t l=(index[i] & 0xf0000000) >> 28;
1191 SETBIT(fITSClusterMap,l);
1194 fITSchi2=t->GetChi2();
1195 fITSsignal=t->GetPIDsignal();
1196 fITSLabel = t->GetLabel();
1197 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1198 if (flags==kITSout) {
1199 if (!fOp) fOp=new AliExternalTrackParam(*t);
1201 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1205 case kTPCin: case kTPCrefit:
1206 fTPCLabel = t->GetLabel();
1207 if (flags==kTPCin) {
1208 fTPCInner=new AliExternalTrackParam(*t);
1209 fTPCnclsIter1=t->GetNumberOfClusters();
1210 fTPCchi2Iter1=t->GetChi2();
1212 if (!fIp) fIp=new AliExternalTrackParam(*t);
1214 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1216 index=fFriendTrack->GetTPCindices();
1217 if (flags & kTPCout){
1218 if (!fOp) fOp=new AliExternalTrackParam(*t);
1220 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1222 fTPCncls=t->GetNumberOfClusters();
1223 fTPCchi2=t->GetChi2();
1225 {//prevrow must be declared in separate namespace, otherwise compiler cries:
1226 //"jump to case label crosses initialization of `Int_t prevrow'"
1228 // for (Int_t i=0;i<fTPCncls;i++)
1229 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1231 index[i]=t->GetClusterIndex(i);
1232 Int_t idx = index[i];
1234 if (idx<0) continue;
1236 // Piotr's Cluster Map for HBT
1237 // ### please change accordingly if cluster array is changing
1238 // to "New TPC Tracking" style (with gaps in array)
1239 Int_t sect = (idx&0xff000000)>>24;
1240 Int_t row = (idx&0x00ff0000)>>16;
1241 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
1243 fTPCClusterMap.SetBitNumber(row,kTRUE);
1245 //Fill the gap between previous row and this row with 0 bits
1246 //In case ### pleas change it as well - just set bit 0 in case there
1247 //is no associated clusters for current "i"
1250 prevrow = row;//if previous bit was not assigned yet == this is the first one
1253 { //we don't know the order (inner to outer or reverse)
1254 //just to be save in case it is going to change
1267 for (Int_t j = n+1; j < m; j++)
1269 fTPCClusterMap.SetBitNumber(j,kFALSE);
1273 // End Of Piotr's Cluster Map for HBT
1276 fTPCsignal=t->GetPIDsignal();
1279 case kTRDin: case kTRDrefit:
1282 index = fFriendTrack->GetTRDindices();
1283 fTRDLabel = t->GetLabel();
1284 fTRDchi2 = t->GetChi2();
1285 fTRDncls = t->GetNumberOfClusters();
1286 for (Int_t i=0;i<6;i++) index[i]=t->GetTrackletIndex(i);
1288 fTRDsignal=t->GetPIDsignal();
1291 if (!fOp) fOp=new AliExternalTrackParam(*t);
1293 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1294 fTRDncls0 = t->GetNumberOfClusters();
1303 if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1305 fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1308 AliError("Wrong flag !");
1315 //_______________________________________________________________________
1316 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1317 //---------------------------------------------------------------------
1318 // This function returns external representation of the track parameters
1319 //---------------------------------------------------------------------
1321 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1324 //_______________________________________________________________________
1325 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1326 //---------------------------------------------------------------------
1327 // This function returns external representation of the cov. matrix
1328 //---------------------------------------------------------------------
1329 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1332 //_______________________________________________________________________
1333 Bool_t AliESDtrack::GetConstrainedExternalParameters
1334 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1335 //---------------------------------------------------------------------
1336 // This function returns the constrained external track parameters
1337 //---------------------------------------------------------------------
1338 if (!fCp) return kFALSE;
1339 alpha=fCp->GetAlpha();
1341 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1345 //_______________________________________________________________________
1347 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1348 //---------------------------------------------------------------------
1349 // This function returns the constrained external cov. matrix
1350 //---------------------------------------------------------------------
1351 if (!fCp) return kFALSE;
1352 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1357 AliESDtrack::GetInnerExternalParameters
1358 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1359 //---------------------------------------------------------------------
1360 // This function returns external representation of the track parameters
1361 // at the inner layer of TPC
1362 //---------------------------------------------------------------------
1363 if (!fIp) return kFALSE;
1364 alpha=fIp->GetAlpha();
1366 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1371 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1372 //---------------------------------------------------------------------
1373 // This function returns external representation of the cov. matrix
1374 // at the inner layer of TPC
1375 //---------------------------------------------------------------------
1376 if (!fIp) return kFALSE;
1377 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1382 AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1384 // This is a direct setter for the outer track parameters
1387 if (fOp) delete fOp;
1388 fOp=new AliExternalTrackParam(*p);
1392 AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1394 // This is a direct setter for the outer track parameters
1397 if (fHMPIDp) delete fHMPIDp;
1398 fHMPIDp=new AliExternalTrackParam(*p);
1402 AliESDtrack::GetOuterExternalParameters
1403 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1404 //---------------------------------------------------------------------
1405 // This function returns external representation of the track parameters
1406 // at the inner layer of TRD
1407 //---------------------------------------------------------------------
1408 if (!fOp) return kFALSE;
1409 alpha=fOp->GetAlpha();
1411 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1416 AliESDtrack::GetOuterHmpExternalParameters
1417 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1418 //---------------------------------------------------------------------
1419 // This function returns external representation of the track parameters
1420 // at the inner layer of TRD
1421 //---------------------------------------------------------------------
1422 if (!fHMPIDp) return kFALSE;
1423 alpha=fHMPIDp->GetAlpha();
1425 for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1430 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1431 //---------------------------------------------------------------------
1432 // This function returns external representation of the cov. matrix
1433 // at the inner layer of TRD
1434 //---------------------------------------------------------------------
1435 if (!fOp) return kFALSE;
1436 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1441 AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1442 //---------------------------------------------------------------------
1443 // This function returns external representation of the cov. matrix
1444 // at the inner layer of TRD
1445 //---------------------------------------------------------------------
1446 if (!fHMPIDp) return kFALSE;
1447 for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1451 Int_t AliESDtrack::GetNcls(Int_t idet) const
1453 // Get number of clusters by subdetector index
1467 if (fTOFindex != -1)
1473 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1474 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1485 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1487 // Get cluster index array by subdetector index
1492 ncls = GetITSclusters(idx);
1495 ncls = GetTPCclusters(idx);
1498 ncls = GetTRDclusters(idx);
1501 if (fTOFindex != -1) {
1509 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1510 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1511 idx[0] = GetHMPIDcluIdx();
1524 //_______________________________________________________________________
1525 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1526 // Returns the array with integrated times for each particle hypothesis
1527 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1530 //_______________________________________________________________________
1531 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1532 // Sets the array with integrated times for each particle hypotesis
1533 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1536 //_______________________________________________________________________
1537 void AliESDtrack::SetITSpid(const Double_t *p) {
1538 // Sets values for the probability of each particle type (in ITS)
1539 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1540 SetStatus(AliESDtrack::kITSpid);
1543 //_______________________________________________________________________
1544 void AliESDtrack::GetITSpid(Double_t *p) const {
1545 // Gets the probability of each particle type (in ITS)
1546 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1549 //_______________________________________________________________________
1550 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1551 //---------------------------------------------------------------------
1552 // This function returns indices of the assgined ITS clusters
1553 //---------------------------------------------------------------------
1555 Int_t *index=fFriendTrack->GetITSindices();
1556 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1557 if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1558 else idx[i]=index[i];
1564 //_______________________________________________________________________
1565 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1566 Float_t &xloc,Float_t &zloc) const {
1567 //----------------------------------------------------------------------
1568 // This function encodes in the module number also the status of cluster association
1569 // "status" can have the following values:
1570 // 1 "found" (cluster is associated),
1571 // 2 "dead" (module is dead from OCDB),
1572 // 3 "skipped" (module or layer forced to be skipped),
1573 // 4 "outinz" (track out of z acceptance),
1574 // 5 "nocls" (no clusters in the road),
1575 // 6 "norefit" (cluster rejected during refit),
1576 // 7 "deadzspd" (holes in z in SPD)
1577 // Also given are the coordinates of the crossing point of track and module
1578 // (in the local module ref. system)
1579 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1580 //----------------------------------------------------------------------
1582 if(fITSModule[ilayer]==-1) {
1585 xloc=-99.; zloc=-99.;
1589 Int_t module = fITSModule[ilayer];
1591 idet = Int_t(module/1000000);
1593 module -= idet*1000000;
1595 status = Int_t(module/100000);
1597 module -= status*100000;
1599 Int_t signs = Int_t(module/10000);
1601 module-=signs*10000;
1603 Int_t xInt = Int_t(module/100);
1606 Int_t zInt = module;
1608 if(signs==1) { xInt*=1; zInt*=1; }
1609 if(signs==2) { xInt*=1; zInt*=-1; }
1610 if(signs==3) { xInt*=-1; zInt*=1; }
1611 if(signs==4) { xInt*=-1; zInt*=-1; }
1613 xloc = 0.1*(Float_t)xInt;
1614 zloc = 0.1*(Float_t)zInt;
1616 if(status==4) idet = -1;
1621 //_______________________________________________________________________
1622 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1623 //---------------------------------------------------------------------
1624 // This function returns indices of the assgined ITS clusters
1625 //---------------------------------------------------------------------
1627 Int_t *index=fFriendTrack->GetTPCindices();
1628 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1633 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1635 // GetDensity of the clusters on given region between row0 and row1
1636 // Dead zone effect takin into acoount
1641 Int_t *index=fFriendTrack->GetTPCindices();
1642 for (Int_t i=row0;i<=row1;i++){
1643 Int_t idx = index[i];
1644 if (idx!=-1) good++; // track outside of dead zone
1647 Float_t density=0.5;
1648 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1652 //_______________________________________________________________________
1653 void AliESDtrack::SetTPCpid(const Double_t *p) {
1654 // Sets values for the probability of each particle type (in TPC)
1655 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1656 SetStatus(AliESDtrack::kTPCpid);
1659 //_______________________________________________________________________
1660 void AliESDtrack::GetTPCpid(Double_t *p) const {
1661 // Gets the probability of each particle type (in TPC)
1662 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1665 //_______________________________________________________________________
1666 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1667 //---------------------------------------------------------------------
1668 // This function returns indices of the assgined TRD clusters
1669 //---------------------------------------------------------------------
1671 Int_t *index=fFriendTrack->GetTRDindices();
1672 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1677 //_______________________________________________________________________
1678 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1680 // This function returns the number of TRD tracklets used in tracking
1681 // and it fills the indices of these tracklets in the array "idx" as they
1682 // are registered in the TRD track list.
1685 // 1. The idx array has to be allocated with a size >= AliESDtrack::kTRDnPlanes
1686 // 2. The idx array store not only the index but also the layer of the tracklet.
1687 // Therefore tracks with TRD gaps contain default values for indices [-1]
1689 if (!idx) return GetTRDntracklets();
1690 Int_t *index=fFriendTrack->GetTRDindices(), n(0);
1691 for (Int_t i=0; i<kTRDnPlanes; i++){
1692 if(index[i]>=0) n++;
1698 //_______________________________________________________________________
1699 void AliESDtrack::SetTRDpid(const Double_t *p) {
1700 // Sets values for the probability of each particle type (in TRD)
1701 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1702 SetStatus(AliESDtrack::kTRDpid);
1705 //_______________________________________________________________________
1706 void AliESDtrack::GetTRDpid(Double_t *p) const {
1707 // Gets the probability of each particle type (in TRD)
1708 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1711 //_______________________________________________________________________
1712 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1714 // Sets the probability of particle type iSpecies to p (in TRD)
1715 fTRDr[iSpecies] = p;
1718 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1720 // Returns the probability of particle type iSpecies (in TRD)
1721 return fTRDr[iSpecies];
1724 //____________________________________________________
1725 Int_t AliESDtrack::GetNumberOfTRDslices() const
1727 // built in backward compatibility
1728 Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
1729 return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
1732 //____________________________________________________
1733 Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
1735 //Returns momentum estimation and optional its error (sp)
1736 // in TRD layer "plane".
1739 AliError("No TRD info allocated for this track !");
1742 if ((plane<0) || (plane>=kTRDnPlanes)) {
1743 AliError("Info for TRD plane not available!");
1747 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1748 // Protection for backward compatibility
1749 if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
1751 if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
1752 return fTRDslices[idx];
1755 //____________________________________________________
1756 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1757 //Gets the charge from the slice of the plane
1760 //AliError("No TRD slices allocated for this track !");
1763 if ((plane<0) || (plane>=kTRDnPlanes)) {
1764 AliError("Info for TRD plane not available !");
1767 Int_t ns=GetNumberOfTRDslices();
1768 if ((slice<-1) || (slice>=ns)) {
1769 //AliError("Wrong TRD slice !");
1773 if(slice>=0) return fTRDslices[plane*ns + slice];
1775 // return average of the dEdx measurements
1776 Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
1777 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
1781 //____________________________________________________
1782 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1783 //Sets the number of slices used for PID
1784 if (fTRDnSlices) return;
1787 fTRDslices=new Double32_t[fTRDnSlices];
1789 // set-up correctly the allocated memory
1790 memset(fTRDslices, 0, n*sizeof(Double32_t));
1791 for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
1794 //____________________________________________________
1795 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1796 //Sets the charge q in the slice of the plane
1798 AliError("No TRD slices allocated for this track !");
1801 if ((plane<0) || (plane>=kTRDnPlanes)) {
1802 AliError("Info for TRD plane not allocated !");
1805 Int_t ns=GetNumberOfTRDslices();
1806 if ((slice<0) || (slice>=ns)) {
1807 AliError("Wrong TRD slice !");
1810 Int_t n=plane*ns + slice;
1815 //____________________________________________________
1816 void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
1819 AliError("No TRD slices allocated for this track !");
1822 if ((plane<0) || (plane>=kTRDnPlanes)) {
1823 AliError("Info for TRD plane not allocated !");
1827 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1828 // Protection for backward compatibility
1829 if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
1831 if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
1832 fTRDslices[idx] = p;
1836 //_______________________________________________________________________
1837 void AliESDtrack::SetTOFpid(const Double_t *p) {
1838 // Sets the probability of each particle type (in TOF)
1839 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
1840 SetStatus(AliESDtrack::kTOFpid);
1843 //_______________________________________________________________________
1844 void AliESDtrack::SetTOFLabel(const Int_t *p) {
1846 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1849 //_______________________________________________________________________
1850 void AliESDtrack::GetTOFpid(Double_t *p) const {
1851 // Gets probabilities of each particle type (in TOF)
1852 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
1855 //_______________________________________________________________________
1856 void AliESDtrack::GetTOFLabel(Int_t *p) const {
1858 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
1861 //_______________________________________________________________________
1862 void AliESDtrack::GetTOFInfo(Float_t *info) const {
1864 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
1867 //_______________________________________________________________________
1868 void AliESDtrack::SetTOFInfo(Float_t*info) {
1870 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
1875 //_______________________________________________________________________
1876 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
1877 // Sets the probability of each particle type (in HMPID)
1878 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
1879 SetStatus(AliESDtrack::kHMPIDpid);
1882 //_______________________________________________________________________
1883 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
1884 // Gets probabilities of each particle type (in HMPID)
1885 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
1890 //_______________________________________________________________________
1891 void AliESDtrack::SetESDpid(const Double_t *p) {
1892 // Sets the probability of each particle type for the ESD track
1893 SetPIDValues(fR,p,AliPID::kSPECIES);
1894 SetStatus(AliESDtrack::kESDpid);
1897 //_______________________________________________________________________
1898 void AliESDtrack::GetESDpid(Double_t *p) const {
1899 // Gets probability of each particle type for the ESD track
1900 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
1903 //_______________________________________________________________________
1904 Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
1905 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
1907 // Try to relate the TPC-only track parameters to the vertex "vtx",
1908 // if the (rough) transverse impact parameter is not bigger then "maxd".
1909 // Magnetic field is "b" (kG).
1911 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
1912 // b) The impact parameters and their covariance matrix are calculated.
1913 // c) An attempt to constrain the TPC-only params to the vertex is done.
1914 // The constrained params are returned via "cParam".
1916 // In the case of success, the returned value is kTRUE
1917 // otherwise, it's kFALSE)
1920 if (!fTPCInner) return kFALSE;
1921 if (!vtx) return kFALSE;
1923 Double_t dz[2],cov[3];
1924 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1932 Double_t covar[6]; vtx->GetCovMatrix(covar);
1933 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1934 Double_t c[3]={covar[2],0.,covar[5]};
1936 Double_t chi2=GetPredictedChi2(p,c);
1937 if (chi2>kVeryBig) return kFALSE;
1941 if (!cParam) return kTRUE;
1943 *cParam = *fTPCInner;
1944 if (!cParam->Update(p,c)) return kFALSE;
1949 //_______________________________________________________________________
1950 Bool_t AliESDtrack::RelateToVertexTPCBxByBz(const AliESDVertex *vtx,
1951 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
1953 // Try to relate the TPC-only track parameters to the vertex "vtx",
1954 // if the (rough) transverse impact parameter is not bigger then "maxd".
1956 // All three components of the magnetic field ,"b[3]" (kG),
1957 // are taken into account.
1959 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
1960 // b) The impact parameters and their covariance matrix are calculated.
1961 // c) An attempt to constrain the TPC-only params to the vertex is done.
1962 // The constrained params are returned via "cParam".
1964 // In the case of success, the returned value is kTRUE
1965 // otherwise, it's kFALSE)
1968 if (!fTPCInner) return kFALSE;
1969 if (!vtx) return kFALSE;
1971 Double_t dz[2],cov[3];
1972 if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
1980 Double_t covar[6]; vtx->GetCovMatrix(covar);
1981 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1982 Double_t c[3]={covar[2],0.,covar[5]};
1984 Double_t chi2=GetPredictedChi2(p,c);
1985 if (chi2>kVeryBig) return kFALSE;
1989 if (!cParam) return kTRUE;
1991 *cParam = *fTPCInner;
1992 if (!cParam->Update(p,c)) return kFALSE;
1997 //_______________________________________________________________________
1998 Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
1999 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2001 // Try to relate this track to the vertex "vtx",
2002 // if the (rough) transverse impact parameter is not bigger then "maxd".
2003 // Magnetic field is "b" (kG).
2005 // a) The track gets extapolated to the DCA to the vertex.
2006 // b) The impact parameters and their covariance matrix are calculated.
2007 // c) An attempt to constrain this track to the vertex is done.
2008 // The constrained params are returned via "cParam".
2010 // In the case of success, the returned value is kTRUE
2011 // (otherwise, it's kFALSE)
2014 if (!vtx) return kFALSE;
2016 Double_t dz[2],cov[3];
2017 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2025 Double_t covar[6]; vtx->GetCovMatrix(covar);
2026 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2027 Double_t c[3]={covar[2],0.,covar[5]};
2029 Double_t chi2=GetPredictedChi2(p,c);
2030 if (chi2>kVeryBig) return kFALSE;
2035 //--- Could now these lines be removed ? ---
2037 fCp=new AliExternalTrackParam(*this);
2039 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2040 //----------------------------------------
2042 fVertexID = vtx->GetID();
2044 if (!cParam) return kTRUE;
2047 if (!cParam->Update(p,c)) return kFALSE;
2052 //_______________________________________________________________________
2053 Bool_t AliESDtrack::RelateToVertexBxByBz(const AliESDVertex *vtx,
2054 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2056 // Try to relate this track to the vertex "vtx",
2057 // if the (rough) transverse impact parameter is not bigger then "maxd".
2058 // Magnetic field is "b" (kG).
2060 // a) The track gets extapolated to the DCA to the vertex.
2061 // b) The impact parameters and their covariance matrix are calculated.
2062 // c) An attempt to constrain this track to the vertex is done.
2063 // The constrained params are returned via "cParam".
2065 // In the case of success, the returned value is kTRUE
2066 // (otherwise, it's kFALSE)
2069 if (!vtx) return kFALSE;
2071 Double_t dz[2],cov[3];
2072 if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2080 Double_t covar[6]; vtx->GetCovMatrix(covar);
2081 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2082 Double_t c[3]={covar[2],0.,covar[5]};
2084 Double_t chi2=GetPredictedChi2(p,c);
2085 if (chi2>kVeryBig) return kFALSE;
2090 //--- Could now these lines be removed ? ---
2092 fCp=new AliExternalTrackParam(*this);
2094 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2095 //----------------------------------------
2097 fVertexID = vtx->GetID();
2099 if (!cParam) return kTRUE;
2102 if (!cParam->Update(p,c)) return kFALSE;
2107 //_______________________________________________________________________
2108 void AliESDtrack::Print(Option_t *) const {
2109 // Prints info on the track
2110 AliExternalTrackParam::Print();
2111 printf("ESD track info\n") ;
2112 Double_t p[AliPID::kSPECIESN] ;
2114 if( IsOn(kITSpid) ){
2115 printf("From ITS: ") ;
2117 for(index = 0 ; index < AliPID::kSPECIES; index++)
2118 printf("%f, ", p[index]) ;
2119 printf("\n signal = %f\n", GetITSsignal()) ;
2121 if( IsOn(kTPCpid) ){
2122 printf("From TPC: ") ;
2124 for(index = 0 ; index < AliPID::kSPECIES; index++)
2125 printf("%f, ", p[index]) ;
2126 printf("\n signal = %f\n", GetTPCsignal()) ;
2128 if( IsOn(kTRDpid) ){
2129 printf("From TRD: ") ;
2131 for(index = 0 ; index < AliPID::kSPECIES; index++)
2132 printf("%f, ", p[index]) ;
2133 printf("\n signal = %f\n", GetTRDsignal()) ;
2135 if( IsOn(kTOFpid) ){
2136 printf("From TOF: ") ;
2138 for(index = 0 ; index < AliPID::kSPECIES; index++)
2139 printf("%f, ", p[index]) ;
2140 printf("\n signal = %f\n", GetTOFsignal()) ;
2142 if( IsOn(kHMPIDpid) ){
2143 printf("From HMPID: ") ;
2145 for(index = 0 ; index < AliPID::kSPECIES; index++)
2146 printf("%f, ", p[index]) ;
2147 printf("\n signal = %f\n", GetHMPIDsignal()) ;
2153 // Draw functionality
2154 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
2156 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
2158 // Fill points in the polymarker
2161 arrayRef.AddLast(new AliExternalTrackParam(*this));
2162 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
2163 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
2164 if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
2166 Double_t mpos[3]={0,0,0};
2167 Int_t entries=arrayRef.GetEntries();
2168 for (Int_t i=0;i<entries;i++){
2170 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
2171 mpos[0]+=pos[0]/entries;
2172 mpos[1]+=pos[1]/entries;
2173 mpos[2]+=pos[2]/entries;
2175 // Rotate to the mean position
2177 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
2178 for (Int_t i=0;i<entries;i++){
2179 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
2180 if (!res) delete arrayRef.RemoveAt(i);
2183 for (Double_t r=minR; r<maxR; r+=stepR){
2185 Double_t mlpos[3]={0,0,0};
2186 for (Int_t i=0;i<entries;i++){
2187 Double_t point[3]={0,0,0};
2188 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
2189 if (!param) continue;
2190 if (param->GetXYZAt(r,magF,point)){
2191 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
2193 mlpos[0]+=point[0]*weight;
2194 mlpos[1]+=point[1]*weight;
2195 mlpos[2]+=point[2]*weight;
2202 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
2203 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
2209 //_______________________________________________________________________
2210 void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
2212 // Store the dE/dx samples measured by the two SSD and two SDD layers.
2213 // These samples are corrected for the track segment length.
2215 for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
2218 //_______________________________________________________________________
2219 void AliESDtrack::GetITSdEdxSamples(Double_t *s) const {
2221 // Get the dE/dx samples measured by the two SSD and two SDD layers.
2222 // These samples are corrected for the track segment length.
2224 for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];
2228 UShort_t AliESDtrack::GetTPCnclsS(Int_t i0,Int_t i1) const{
2230 // get number of shared clusters
2232 return fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);