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 fEMCALindex(kEMCALNoMatch),
185 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
188 fCdd(0),fCdz(0),fCzz(0),
224 fVertexID(-2),// -2 means an orphan track
228 // The default ESD constructor
231 for (i=0; i<AliPID::kSPECIES; i++) {
241 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
242 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
243 for (i=0;i<kTRDnPlanes;i++) {
246 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
247 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
248 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
249 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
250 for (i=0;i<12;i++) {fITSModule[i]=-1;}
253 //_______________________________________________________________________
254 AliESDtrack::AliESDtrack(const AliESDtrack& track):
255 AliExternalTrackParam(track),
262 fTPCClusterMap(track.fTPCClusterMap),
263 fTPCSharedMap(track.fTPCSharedMap),
264 fFlags(track.fFlags),
266 fLabel(track.fLabel),
267 fITSLabel(track.fITSLabel),
268 fTPCLabel(track.fTPCLabel),
269 fTRDLabel(track.fTRDLabel),
270 fTOFCalChannel(track.fTOFCalChannel),
271 fTOFindex(track.fTOFindex),
272 fHMPIDqn(track.fHMPIDqn),
273 fHMPIDcluIdx(track.fHMPIDcluIdx),
274 fEMCALindex(track.fEMCALindex),
275 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
276 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
277 fHMPIDsignal(track.fHMPIDsignal),
278 fTrackLength(track.fTrackLength),
279 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
280 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
281 fCchi2TPC(track.fCchi2TPC),
282 fD(track.fD),fZ(track.fZ),
283 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
284 fCchi2(track.fCchi2),
285 fITSchi2(track.fITSchi2),
286 fTPCchi2(track.fTPCchi2),
287 fTPCchi2Iter1(track.fTPCchi2Iter1),
288 fTRDchi2(track.fTRDchi2),
289 fTOFchi2(track.fTOFchi2),
290 fHMPIDchi2(track.fHMPIDchi2),
291 fGlobalChi2(track.fGlobalChi2),
292 fITSsignal(track.fITSsignal),
293 fTPCsignal(track.fTPCsignal),
294 fTPCsignalS(track.fTPCsignalS),
295 fTRDsignal(track.fTRDsignal),
296 fTRDQuality(track.fTRDQuality),
297 fTRDBudget(track.fTRDBudget),
298 fTOFsignal(track.fTOFsignal),
299 fTOFsignalToT(track.fTOFsignalToT),
300 fTOFsignalRaw(track.fTOFsignalRaw),
301 fTOFsignalDz(track.fTOFsignalDz),
302 fTOFsignalDx(track.fTOFsignalDx),
303 fHMPIDtrkX(track.fHMPIDtrkX),
304 fHMPIDtrkY(track.fHMPIDtrkY),
305 fHMPIDmipX(track.fHMPIDmipX),
306 fHMPIDmipY(track.fHMPIDmipY),
307 fTPCncls(track.fTPCncls),
308 fTPCnclsF(track.fTPCnclsF),
309 fTPCsignalN(track.fTPCsignalN),
310 fTPCnclsIter1(track.fTPCnclsIter1),
311 fTPCnclsFIter1(track.fTPCnclsIter1),
312 fITSncls(track.fITSncls),
313 fITSClusterMap(track.fITSClusterMap),
314 fTRDncls(track.fTRDncls),
315 fTRDncls0(track.fTRDncls0),
316 fTRDntracklets(track.fTRDntracklets),
317 fTRDnSlices(track.fTRDnSlices),
319 fVertexID(track.fVertexID),
320 fESDEvent(track.fESDEvent)
325 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
326 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
328 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
330 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
331 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
332 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
333 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
334 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
336 for (Int_t i=0;i<kTRDnPlanes;i++) {
337 fTRDTimBin[i]=track.fTRDTimBin[i];
341 fTRDslices=new Double32_t[fTRDnSlices];
342 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
345 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
346 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
347 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
348 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
349 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
350 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
352 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
353 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
354 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
355 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
356 if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
358 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
361 //_______________________________________________________________________
362 AliESDtrack::AliESDtrack(const AliVTrack *track) :
363 AliExternalTrackParam(track),
370 fTPCClusterMap(159),//number of padrows
371 fTPCSharedMap(159),//number of padrows
382 fEMCALindex(kEMCALNoMatch),
388 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
391 fCdd(0),fCdz(0),fCzz(0),
427 fVertexID(-2), // -2 means an orphan track
431 // ESD track from AliVTrack.
432 // This is not a copy constructor !
435 if (track->InheritsFrom("AliExternalTrackParam")) {
436 AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
437 AliWarning("Calling the default constructor...");
442 // Reset all the arrays
444 for (i=0; i<AliPID::kSPECIES; i++) {
454 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
455 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
456 for (i=0;i<kTRDnPlanes;i++) {
459 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
460 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
461 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
462 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
463 for (i=0;i<12;i++) {fITSModule[i]=-1;}
466 SetID(track->GetID());
468 // Set ITS cluster map
469 fITSClusterMap=track->GetITSClusterMap();
473 if(HasPointOnITSLayer(i)) fITSncls++;
476 // Set the combined PID
477 const Double_t *pid = track->PID();
479 for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
481 // AliESD track label
482 SetLabel(track->GetLabel());
484 SetStatus(track->GetStatus());
487 //_______________________________________________________________________
488 AliESDtrack::AliESDtrack(TParticle * part) :
489 AliExternalTrackParam(),
496 fTPCClusterMap(159),//number of padrows
497 fTPCSharedMap(159),//number of padrows
508 fEMCALindex(kEMCALNoMatch),
514 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
517 fCdd(0),fCdz(0),fCzz(0),
553 fVertexID(-2), // -2 means an orphan track
557 // ESD track from TParticle
560 // Reset all the arrays
562 for (i=0; i<AliPID::kSPECIES; i++) {
572 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
573 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
574 for (i=0;i<kTRDnPlanes;i++) {
577 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
578 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
579 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
580 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
581 for (i=0;i<12;i++) {fITSModule[i]=-1;}
583 // Calculate the AliExternalTrackParam content
590 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
591 alpha = part->Phi()*180./TMath::Pi();
592 if (alpha<0) alpha+= 360.;
593 if (alpha>360) alpha -= 360.;
595 Int_t sector = (Int_t)(alpha/20.);
596 alpha = 10. + 20.*sector;
598 alpha *= TMath::Pi();
600 // Covariance matrix: no errors, the parameters are exact
601 for (i=0; i<15; i++) covar[i]=0.;
603 // Get the vertex of origin and the momentum
604 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
605 TVector3 mom(part->Px(),part->Py(),part->Pz());
607 // Rotate to the local coordinate system (TPC sector)
611 // X of the referense plane
614 Int_t pdgCode = part->GetPdgCode();
617 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
621 param[2] = TMath::Sin(mom.Phi());
622 param[3] = mom.Pz()/mom.Pt();
623 param[4] = TMath::Sign(1/mom.Pt(),charge);
625 // Set AliExternalTrackParam
626 Set(xref, alpha, param, covar);
631 switch (TMath::Abs(pdgCode)) {
657 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
658 if (indexPID < AliPID::kSPECIES) {
664 fHMPIDr[indexPID]=1.;
667 // AliESD track label
668 SetLabel(part->GetUniqueID());
672 //_______________________________________________________________________
673 AliESDtrack::~AliESDtrack(){
675 // This is destructor according Coding Conventrions
677 //printf("Delete track\n");
688 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
691 if(&source == this) return *this;
692 AliExternalTrackParam::operator=(source);
696 // we have the trackparam: assign or copy construct
697 if(fCp)*fCp = *source.fCp;
698 else fCp = new AliExternalTrackParam(*source.fCp);
701 // no track param delete the old one
707 // we have the trackparam: assign or copy construct
708 if(fIp)*fIp = *source.fIp;
709 else fIp = new AliExternalTrackParam(*source.fIp);
712 // no track param delete the old one
718 if(source.fTPCInner){
719 // we have the trackparam: assign or copy construct
720 if(fTPCInner) *fTPCInner = *source.fTPCInner;
721 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
724 // no track param delete the old one
725 if(fTPCInner)delete fTPCInner;
731 // we have the trackparam: assign or copy construct
732 if(fOp) *fOp = *source.fOp;
733 else fOp = new AliExternalTrackParam(*source.fOp);
736 // no track param delete the old one
743 // we have the trackparam: assign or copy construct
744 if(fHMPIDp) *fHMPIDp = *source.fHMPIDp;
745 else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
748 // no track param delete the old one
749 if(fHMPIDp)delete fHMPIDp;
754 // copy also the friend track
755 // use copy constructor
756 if(source.fFriendTrack){
757 // we have the trackparam: assign or copy construct
758 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
761 // no track param delete the old one
762 delete fFriendTrack; fFriendTrack= 0;
765 fTPCClusterMap = source.fTPCClusterMap;
766 fTPCSharedMap = source.fTPCSharedMap;
768 fFlags = source.fFlags;
770 fLabel = source.fLabel;
771 fITSLabel = source.fITSLabel;
772 for(int i = 0; i< 12;++i){
773 fITSModule[i] = source.fITSModule[i];
775 fTPCLabel = source.fTPCLabel;
776 fTRDLabel = source.fTRDLabel;
777 for(int i = 0; i< 3;++i){
778 fTOFLabel[i] = source.fTOFLabel[i];
780 fTOFCalChannel = source.fTOFCalChannel;
781 fTOFindex = source.fTOFindex;
782 fHMPIDqn = source.fHMPIDqn;
783 fHMPIDcluIdx = source.fHMPIDcluIdx;
784 fEMCALindex = source.fEMCALindex;
786 for(int i = 0; i< 3;++i){
787 fKinkIndexes[i] = source.fKinkIndexes[i];
788 fV0Indexes[i] = source.fV0Indexes[i];
791 for(int i = 0; i< AliPID::kSPECIES;++i){
792 fR[i] = source.fR[i];
793 fITSr[i] = source.fITSr[i];
794 fTPCr[i] = source.fTPCr[i];
795 fTRDr[i] = source.fTRDr[i];
796 fTOFr[i] = source.fTOFr[i];
797 fHMPIDr[i] = source.fHMPIDr[i];
798 fTrackTime[i] = source.fTrackTime[i];
801 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
802 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
803 fHMPIDsignal = source.fHMPIDsignal;
806 fTrackLength = source. fTrackLength;
807 fdTPC = source.fdTPC;
808 fzTPC = source.fzTPC;
809 fCddTPC = source.fCddTPC;
810 fCdzTPC = source.fCdzTPC;
811 fCzzTPC = source.fCzzTPC;
812 fCchi2TPC = source.fCchi2TPC;
819 fCchi2 = source.fCchi2;
821 fITSchi2 = source.fITSchi2;
822 fTPCchi2 = source.fTPCchi2;
823 fTPCchi2Iter1 = source.fTPCchi2Iter1;
824 fTRDchi2 = source.fTRDchi2;
825 fTOFchi2 = source.fTOFchi2;
826 fHMPIDchi2 = source.fHMPIDchi2;
828 fGlobalChi2 = source.fGlobalChi2;
830 fITSsignal = source.fITSsignal;
831 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
832 fTPCsignal = source.fTPCsignal;
833 fTPCsignalS = source.fTPCsignalS;
834 for(int i = 0; i< 4;++i){
835 fTPCPoints[i] = source.fTPCPoints[i];
837 fTRDsignal = source.fTRDsignal;
839 for(int i = 0;i < kTRDnPlanes;++i){
840 fTRDTimBin[i] = source.fTRDTimBin[i];
846 fTRDnSlices=source.fTRDnSlices;
848 fTRDslices=new Double32_t[fTRDnSlices];
849 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
852 fTRDQuality = source.fTRDQuality;
853 fTRDBudget = source.fTRDBudget;
854 fTOFsignal = source.fTOFsignal;
855 fTOFsignalToT = source.fTOFsignalToT;
856 fTOFsignalRaw = source.fTOFsignalRaw;
857 fTOFsignalDz = source.fTOFsignalDz;
858 fTOFsignalDx = source.fTOFsignalDx;
860 for(int i = 0;i<10;++i){
861 fTOFInfo[i] = source.fTOFInfo[i];
864 fHMPIDtrkX = source.fHMPIDtrkX;
865 fHMPIDtrkY = source.fHMPIDtrkY;
866 fHMPIDmipX = source.fHMPIDmipX;
867 fHMPIDmipY = source.fHMPIDmipY;
869 fTPCncls = source.fTPCncls;
870 fTPCnclsF = source.fTPCnclsF;
871 fTPCsignalN = source.fTPCsignalN;
872 fTPCnclsIter1 = source.fTPCnclsIter1;
873 fTPCnclsFIter1 = source.fTPCnclsFIter1;
875 fITSncls = source.fITSncls;
876 fITSClusterMap = source.fITSClusterMap;
877 fTRDncls = source.fTRDncls;
878 fTRDncls0 = source.fTRDncls0;
879 fTRDntracklets = source.fTRDntracklets;
880 fVertexID = source.fVertexID;
886 void AliESDtrack::Copy(TObject &obj) const {
888 // this overwrites the virtual TOBject::Copy()
889 // to allow run time copying without casting
892 if(this==&obj)return;
893 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
894 if(!robj)return; // not an AliESDtrack
901 void AliESDtrack::AddCalibObject(TObject * object){
903 // add calib object to the list
905 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
906 fFriendTrack->AddCalibObject(object);
909 TObject * AliESDtrack::GetCalibObject(Int_t index){
911 // return calib objct at given position
913 if (!fFriendTrack) return 0;
914 return fFriendTrack->GetCalibObject(index);
918 Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
920 // Fills the information of the TPC-only first reconstruction pass
921 // into the passed ESDtrack object. For consistency fTPCInner is also filled
926 // For data produced before r26675
927 // RelateToVertexTPC was not properly called during reco
928 // so you'll have to call it again, before FillTPCOnlyTrack
929 // Float_t p[2],cov[3];
930 // track->GetImpactParametersTPC(p,cov);
931 // if(p[0]==0&&p[1]==0) // <- Default values
932 // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
935 if(!fTPCInner)return kFALSE;
937 // fill the TPC track params to the global track parameters
938 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
941 track.fCdd = fCddTPC;
942 track.fCdz = fCdzTPC;
943 track.fCzz = fCzzTPC;
945 // copy the TPCinner parameters
946 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
947 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
950 track.fCddTPC = fCddTPC;
951 track.fCdzTPC = fCdzTPC;
952 track.fCzzTPC = fCzzTPC;
953 track.fCchi2TPC = fCchi2TPC;
956 // copy all other TPC specific parameters
958 // replace label by TPC label
959 track.fLabel = fTPCLabel;
960 track.fTPCLabel = fTPCLabel;
962 track.fTPCchi2 = fTPCchi2;
963 track.fTPCchi2Iter1 = fTPCchi2Iter1;
964 track.fTPCsignal = fTPCsignal;
965 track.fTPCsignalS = fTPCsignalS;
966 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
968 track.fTPCncls = fTPCncls;
969 track.fTPCnclsF = fTPCnclsF;
970 track.fTPCsignalN = fTPCsignalN;
971 track.fTPCnclsIter1 = fTPCnclsIter1;
972 track.fTPCnclsFIter1 = fTPCnclsFIter1;
975 for(int i=0;i<AliPID::kSPECIES;++i){
976 track.fTPCr[i] = fTPCr[i];
977 // combined PID is TPC only!
978 track.fR[i] = fTPCr[i];
980 track.fTPCClusterMap = fTPCClusterMap;
981 track.fTPCSharedMap = fTPCSharedMap;
985 track.fFlags = kTPCin;
988 track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
990 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
996 //_______________________________________________________________________
997 void AliESDtrack::MakeMiniESDtrack(){
998 // Resets everything except
999 // fFlags: Reconstruction status flags
1000 // fLabel: Track label
1001 // fID: Unique ID of the track
1002 // Impact parameter information
1003 // fR[AliPID::kSPECIES]: combined "detector response probability"
1004 // Running track parameters in the base class (AliExternalTrackParam)
1008 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
1010 // Reset track parameters constrained to the primary vertex
1013 // Reset track parameters at the inner wall of TPC
1015 delete fTPCInner;fTPCInner=0;
1016 // Reset track parameters at the inner wall of the TRD
1018 // Reset track parameters at the HMPID
1019 delete fHMPIDp;fHMPIDp = 0;
1022 // Reset ITS track related information
1027 for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
1028 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
1031 // Reset TPC related track information
1043 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
1045 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1046 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1047 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1049 // Reset TRD related track information
1054 for (Int_t i=0;i<kTRDnPlanes;i++) {
1057 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1062 delete[] fTRDslices;
1067 // Reset TOF related track information
1076 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
1077 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
1078 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1080 // Reset HMPID related track information
1085 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
1092 fEMCALindex = kEMCALNoMatch;
1094 // reset global track chi2
1097 fVertexID = -2; // an orphan track
1099 delete fFriendTrack; fFriendTrack = 0;
1101 //_______________________________________________________________________
1102 Double_t AliESDtrack::GetMass() const {
1103 // Returns the mass of the most probable particle type
1106 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
1107 if (fR[i]>max) {k=i; max=fR[i];}
1109 if (k==0) { // dE/dx "crossing points" in the TPC
1111 if ((p>0.38)&&(p<0.48))
1112 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
1113 if ((p>0.75)&&(p<0.85))
1114 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
1117 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
1118 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
1119 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
1120 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
1121 AliWarning("Undefined mass !");
1122 return AliPID::ParticleMass(AliPID::kPion);
1125 //______________________________________________________________________________
1126 Double_t AliESDtrack::E() const
1128 // Returns the energy of the particle given its assumed mass.
1129 // Assumes the pion mass if the particle can't be identified properly.
1133 return TMath::Sqrt(p*p + m*m);
1136 //______________________________________________________________________________
1137 Double_t AliESDtrack::Y() const
1139 // Returns the rapidity of a particle given its assumed mass.
1140 // Assumes the pion mass if the particle can't be identified properly.
1144 if (e != TMath::Abs(pz)) { // energy was not equal to pz
1145 return 0.5*TMath::Log((e+pz)/(e-pz));
1146 } else { // energy was equal to pz
1151 //_______________________________________________________________________
1152 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
1154 // This function updates track's running parameters
1160 fLabel=t->GetLabel();
1162 if (t->IsStartedTimeIntegral()) {
1164 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
1165 SetIntegratedLength(t->GetIntegratedLength());
1168 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1169 if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1170 if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
1171 if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
1175 case kITSin: case kITSout: case kITSrefit:
1177 fITSncls=t->GetNumberOfClusters();
1178 index=fFriendTrack->GetITSindices();
1179 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
1180 index[i]=t->GetClusterIndex(i);
1182 Int_t l=(index[i] & 0xf0000000) >> 28;
1183 SETBIT(fITSClusterMap,l);
1186 fITSchi2=t->GetChi2();
1187 fITSsignal=t->GetPIDsignal();
1188 fITSLabel = t->GetLabel();
1189 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1190 if (flags==kITSout) {
1191 if (!fOp) fOp=new AliExternalTrackParam(*t);
1193 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1197 case kTPCin: case kTPCrefit:
1198 fTPCLabel = t->GetLabel();
1199 if (flags==kTPCin) {
1200 fTPCInner=new AliExternalTrackParam(*t);
1201 fTPCnclsIter1=t->GetNumberOfClusters();
1202 fTPCchi2Iter1=t->GetChi2();
1204 if (!fIp) fIp=new AliExternalTrackParam(*t);
1206 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1208 index=fFriendTrack->GetTPCindices();
1209 if (flags & kTPCout){
1210 if (!fOp) fOp=new AliExternalTrackParam(*t);
1212 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1214 fTPCncls=t->GetNumberOfClusters();
1215 fTPCchi2=t->GetChi2();
1217 {//prevrow must be declared in separate namespace, otherwise compiler cries:
1218 //"jump to case label crosses initialization of `Int_t prevrow'"
1220 // for (Int_t i=0;i<fTPCncls;i++)
1221 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1223 index[i]=t->GetClusterIndex(i);
1224 Int_t idx = index[i];
1226 if (idx<0) continue;
1228 // Piotr's Cluster Map for HBT
1229 // ### please change accordingly if cluster array is changing
1230 // to "New TPC Tracking" style (with gaps in array)
1231 Int_t sect = (idx&0xff000000)>>24;
1232 Int_t row = (idx&0x00ff0000)>>16;
1233 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
1235 fTPCClusterMap.SetBitNumber(row,kTRUE);
1237 //Fill the gap between previous row and this row with 0 bits
1238 //In case ### pleas change it as well - just set bit 0 in case there
1239 //is no associated clusters for current "i"
1242 prevrow = row;//if previous bit was not assigned yet == this is the first one
1245 { //we don't know the order (inner to outer or reverse)
1246 //just to be save in case it is going to change
1259 for (Int_t j = n+1; j < m; j++)
1261 fTPCClusterMap.SetBitNumber(j,kFALSE);
1265 // End Of Piotr's Cluster Map for HBT
1268 fTPCsignal=t->GetPIDsignal();
1271 case kTRDin: case kTRDrefit:
1274 index = fFriendTrack->GetTRDindices();
1275 fTRDLabel = t->GetLabel();
1276 fTRDchi2 = t->GetChi2();
1277 fTRDncls = t->GetNumberOfClusters();
1278 for (Int_t i=0;i<6;i++) index[i]=t->GetTrackletIndex(i);
1280 fTRDsignal=t->GetPIDsignal();
1283 if (!fOp) fOp=new AliExternalTrackParam(*t);
1285 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1286 fTRDncls0 = t->GetNumberOfClusters();
1295 if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1297 fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1300 AliError("Wrong flag !");
1307 //_______________________________________________________________________
1308 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1309 //---------------------------------------------------------------------
1310 // This function returns external representation of the track parameters
1311 //---------------------------------------------------------------------
1313 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1316 //_______________________________________________________________________
1317 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1318 //---------------------------------------------------------------------
1319 // This function returns external representation of the cov. matrix
1320 //---------------------------------------------------------------------
1321 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1324 //_______________________________________________________________________
1325 Bool_t AliESDtrack::GetConstrainedExternalParameters
1326 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1327 //---------------------------------------------------------------------
1328 // This function returns the constrained external track parameters
1329 //---------------------------------------------------------------------
1330 if (!fCp) return kFALSE;
1331 alpha=fCp->GetAlpha();
1333 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1337 //_______________________________________________________________________
1339 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1340 //---------------------------------------------------------------------
1341 // This function returns the constrained external cov. matrix
1342 //---------------------------------------------------------------------
1343 if (!fCp) return kFALSE;
1344 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1349 AliESDtrack::GetInnerExternalParameters
1350 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1351 //---------------------------------------------------------------------
1352 // This function returns external representation of the track parameters
1353 // at the inner layer of TPC
1354 //---------------------------------------------------------------------
1355 if (!fIp) return kFALSE;
1356 alpha=fIp->GetAlpha();
1358 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1363 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1364 //---------------------------------------------------------------------
1365 // This function returns external representation of the cov. matrix
1366 // at the inner layer of TPC
1367 //---------------------------------------------------------------------
1368 if (!fIp) return kFALSE;
1369 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1374 AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1376 // This is a direct setter for the outer track parameters
1379 if (fOp) delete fOp;
1380 fOp=new AliExternalTrackParam(*p);
1384 AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1386 // This is a direct setter for the outer track parameters
1389 if (fHMPIDp) delete fHMPIDp;
1390 fHMPIDp=new AliExternalTrackParam(*p);
1394 AliESDtrack::GetOuterExternalParameters
1395 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1396 //---------------------------------------------------------------------
1397 // This function returns external representation of the track parameters
1398 // at the inner layer of TRD
1399 //---------------------------------------------------------------------
1400 if (!fOp) return kFALSE;
1401 alpha=fOp->GetAlpha();
1403 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1408 AliESDtrack::GetOuterHmpExternalParameters
1409 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1410 //---------------------------------------------------------------------
1411 // This function returns external representation of the track parameters
1412 // at the inner layer of TRD
1413 //---------------------------------------------------------------------
1414 if (!fHMPIDp) return kFALSE;
1415 alpha=fHMPIDp->GetAlpha();
1417 for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1422 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1423 //---------------------------------------------------------------------
1424 // This function returns external representation of the cov. matrix
1425 // at the inner layer of TRD
1426 //---------------------------------------------------------------------
1427 if (!fOp) return kFALSE;
1428 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1433 AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1434 //---------------------------------------------------------------------
1435 // This function returns external representation of the cov. matrix
1436 // at the inner layer of TRD
1437 //---------------------------------------------------------------------
1438 if (!fHMPIDp) return kFALSE;
1439 for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1443 Int_t AliESDtrack::GetNcls(Int_t idet) const
1445 // Get number of clusters by subdetector index
1459 if (fTOFindex != -1)
1465 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1466 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1477 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1479 // Get cluster index array by subdetector index
1484 ncls = GetITSclusters(idx);
1487 ncls = GetTPCclusters(idx);
1490 ncls = GetTRDclusters(idx);
1493 if (fTOFindex != -1) {
1501 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1502 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1503 idx[0] = GetHMPIDcluIdx();
1516 //_______________________________________________________________________
1517 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1518 // Returns the array with integrated times for each particle hypothesis
1519 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1522 //_______________________________________________________________________
1523 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1524 // Sets the array with integrated times for each particle hypotesis
1525 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1528 //_______________________________________________________________________
1529 void AliESDtrack::SetITSpid(const Double_t *p) {
1530 // Sets values for the probability of each particle type (in ITS)
1531 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1532 SetStatus(AliESDtrack::kITSpid);
1535 //_______________________________________________________________________
1536 void AliESDtrack::GetITSpid(Double_t *p) const {
1537 // Gets the probability of each particle type (in ITS)
1538 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1541 //_______________________________________________________________________
1542 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1543 //---------------------------------------------------------------------
1544 // This function returns indices of the assgined ITS clusters
1545 //---------------------------------------------------------------------
1547 Int_t *index=fFriendTrack->GetITSindices();
1548 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1549 if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1550 else idx[i]=index[i];
1556 //_______________________________________________________________________
1557 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1558 Float_t &xloc,Float_t &zloc) const {
1559 //----------------------------------------------------------------------
1560 // This function encodes in the module number also the status of cluster association
1561 // "status" can have the following values:
1562 // 1 "found" (cluster is associated),
1563 // 2 "dead" (module is dead from OCDB),
1564 // 3 "skipped" (module or layer forced to be skipped),
1565 // 4 "outinz" (track out of z acceptance),
1566 // 5 "nocls" (no clusters in the road),
1567 // 6 "norefit" (cluster rejected during refit),
1568 // 7 "deadzspd" (holes in z in SPD)
1569 // Also given are the coordinates of the crossing point of track and module
1570 // (in the local module ref. system)
1571 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1572 //----------------------------------------------------------------------
1574 if(fITSModule[ilayer]==-1) {
1577 xloc=-99.; zloc=-99.;
1581 Int_t module = fITSModule[ilayer];
1583 idet = Int_t(module/1000000);
1585 module -= idet*1000000;
1587 status = Int_t(module/100000);
1589 module -= status*100000;
1591 Int_t signs = Int_t(module/10000);
1593 module-=signs*10000;
1595 Int_t xInt = Int_t(module/100);
1598 Int_t zInt = module;
1600 if(signs==1) { xInt*=1; zInt*=1; }
1601 if(signs==2) { xInt*=1; zInt*=-1; }
1602 if(signs==3) { xInt*=-1; zInt*=1; }
1603 if(signs==4) { xInt*=-1; zInt*=-1; }
1605 xloc = 0.1*(Float_t)xInt;
1606 zloc = 0.1*(Float_t)zInt;
1608 if(status==4) idet = -1;
1613 //_______________________________________________________________________
1614 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1615 //---------------------------------------------------------------------
1616 // This function returns indices of the assgined ITS clusters
1617 //---------------------------------------------------------------------
1619 Int_t *index=fFriendTrack->GetTPCindices();
1620 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1625 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1627 // GetDensity of the clusters on given region between row0 and row1
1628 // Dead zone effect takin into acoount
1633 Int_t *index=fFriendTrack->GetTPCindices();
1634 for (Int_t i=row0;i<=row1;i++){
1635 Int_t idx = index[i];
1636 if (idx!=-1) good++; // track outside of dead zone
1639 Float_t density=0.5;
1640 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1644 //_______________________________________________________________________
1645 void AliESDtrack::SetTPCpid(const Double_t *p) {
1646 // Sets values for the probability of each particle type (in TPC)
1647 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1648 SetStatus(AliESDtrack::kTPCpid);
1651 //_______________________________________________________________________
1652 void AliESDtrack::GetTPCpid(Double_t *p) const {
1653 // Gets the probability of each particle type (in TPC)
1654 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1657 //_______________________________________________________________________
1658 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1659 //---------------------------------------------------------------------
1660 // This function returns indices of the assgined TRD clusters
1661 //---------------------------------------------------------------------
1663 Int_t *index=fFriendTrack->GetTRDindices();
1664 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1669 //_______________________________________________________________________
1670 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1672 // This function returns the number of TRD tracklets used in tracking
1673 // and it fills the indices of these tracklets in the array "idx" as they
1674 // are registered in the TRD track list.
1677 // 1. The idx array has to be allocated with a size >= AliESDtrack::kTRDnPlanes
1678 // 2. The idx array store not only the index but also the layer of the tracklet.
1679 // Therefore tracks with TRD gaps contain default values for indices [-1]
1681 if (!idx) return GetTRDntracklets();
1682 Int_t *index=fFriendTrack->GetTRDindices(), n(0);
1683 for (Int_t i=0; i<kTRDnPlanes; i++){
1684 if(index[i]>=0) n++;
1690 //_______________________________________________________________________
1691 void AliESDtrack::SetTRDpid(const Double_t *p) {
1692 // Sets values for the probability of each particle type (in TRD)
1693 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1694 SetStatus(AliESDtrack::kTRDpid);
1697 //_______________________________________________________________________
1698 void AliESDtrack::GetTRDpid(Double_t *p) const {
1699 // Gets the probability of each particle type (in TRD)
1700 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1703 //_______________________________________________________________________
1704 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1706 // Sets the probability of particle type iSpecies to p (in TRD)
1707 fTRDr[iSpecies] = p;
1710 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1712 // Returns the probability of particle type iSpecies (in TRD)
1713 return fTRDr[iSpecies];
1716 //____________________________________________________
1717 Int_t AliESDtrack::GetNumberOfTRDslices() const
1719 // built in backward compatibility
1720 Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
1721 return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
1724 //____________________________________________________
1725 Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
1727 //Returns momentum estimation and optional its error (sp)
1728 // in TRD layer "plane".
1731 AliError("No TRD info allocated for this track !");
1734 if ((plane<0) || (plane>=kTRDnPlanes)) {
1735 AliError("Info for TRD plane not available!");
1739 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1740 // Protection for backward compatibility
1741 if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
1743 if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
1744 return fTRDslices[idx];
1747 //____________________________________________________
1748 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1749 //Gets the charge from the slice of the plane
1752 //AliError("No TRD slices allocated for this track !");
1755 if ((plane<0) || (plane>=kTRDnPlanes)) {
1756 AliError("Info for TRD plane not available !");
1759 Int_t ns=GetNumberOfTRDslices();
1760 if ((slice<-1) || (slice>=ns)) {
1761 //AliError("Wrong TRD slice !");
1765 if(slice>=0) return fTRDslices[plane*ns + slice];
1767 // return average of the dEdx measurements
1768 Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
1769 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
1773 //____________________________________________________
1774 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1775 //Sets the number of slices used for PID
1776 if (fTRDnSlices) return;
1779 fTRDslices=new Double32_t[fTRDnSlices];
1781 // set-up correctly the allocated memory
1782 memset(fTRDslices, 0, n*sizeof(Double32_t));
1783 for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
1786 //____________________________________________________
1787 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1788 //Sets the charge q in the slice of the plane
1790 AliError("No TRD slices allocated for this track !");
1793 if ((plane<0) || (plane>=kTRDnPlanes)) {
1794 AliError("Info for TRD plane not allocated !");
1797 Int_t ns=GetNumberOfTRDslices();
1798 if ((slice<0) || (slice>=ns)) {
1799 AliError("Wrong TRD slice !");
1802 Int_t n=plane*ns + slice;
1807 //____________________________________________________
1808 void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
1811 AliError("No TRD slices allocated for this track !");
1814 if ((plane<0) || (plane>=kTRDnPlanes)) {
1815 AliError("Info for TRD plane not allocated !");
1819 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1820 // Protection for backward compatibility
1821 if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
1823 if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
1824 fTRDslices[idx] = p;
1828 //_______________________________________________________________________
1829 void AliESDtrack::SetTOFpid(const Double_t *p) {
1830 // Sets the probability of each particle type (in TOF)
1831 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
1832 SetStatus(AliESDtrack::kTOFpid);
1835 //_______________________________________________________________________
1836 void AliESDtrack::SetTOFLabel(const Int_t *p) {
1838 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1841 //_______________________________________________________________________
1842 void AliESDtrack::GetTOFpid(Double_t *p) const {
1843 // Gets probabilities of each particle type (in TOF)
1844 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
1847 //_______________________________________________________________________
1848 void AliESDtrack::GetTOFLabel(Int_t *p) const {
1850 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
1853 //_______________________________________________________________________
1854 void AliESDtrack::GetTOFInfo(Float_t *info) const {
1856 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
1859 //_______________________________________________________________________
1860 void AliESDtrack::SetTOFInfo(Float_t*info) {
1862 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
1867 //_______________________________________________________________________
1868 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
1869 // Sets the probability of each particle type (in HMPID)
1870 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
1871 SetStatus(AliESDtrack::kHMPIDpid);
1874 //_______________________________________________________________________
1875 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
1876 // Gets probabilities of each particle type (in HMPID)
1877 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
1882 //_______________________________________________________________________
1883 void AliESDtrack::SetESDpid(const Double_t *p) {
1884 // Sets the probability of each particle type for the ESD track
1885 SetPIDValues(fR,p,AliPID::kSPECIES);
1886 SetStatus(AliESDtrack::kESDpid);
1889 //_______________________________________________________________________
1890 void AliESDtrack::GetESDpid(Double_t *p) const {
1891 // Gets probability of each particle type for the ESD track
1892 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
1895 //_______________________________________________________________________
1896 Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
1897 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
1899 // Try to relate the TPC-only track parameters to the vertex "vtx",
1900 // if the (rough) transverse impact parameter is not bigger then "maxd".
1901 // Magnetic field is "b" (kG).
1903 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
1904 // b) The impact parameters and their covariance matrix are calculated.
1905 // c) An attempt to constrain the TPC-only params to the vertex is done.
1906 // The constrained params are returned via "cParam".
1908 // In the case of success, the returned value is kTRUE
1909 // otherwise, it's kFALSE)
1912 if (!fTPCInner) return kFALSE;
1913 if (!vtx) return kFALSE;
1915 Double_t dz[2],cov[3];
1916 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1924 Double_t covar[6]; vtx->GetCovMatrix(covar);
1925 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1926 Double_t c[3]={covar[2],0.,covar[5]};
1928 Double_t chi2=GetPredictedChi2(p,c);
1929 if (chi2>kVeryBig) return kFALSE;
1933 if (!cParam) return kTRUE;
1935 *cParam = *fTPCInner;
1936 if (!cParam->Update(p,c)) return kFALSE;
1941 //_______________________________________________________________________
1942 Bool_t AliESDtrack::RelateToVertexTPCBxByBz(const AliESDVertex *vtx,
1943 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
1945 // Try to relate the TPC-only track parameters to the vertex "vtx",
1946 // if the (rough) transverse impact parameter is not bigger then "maxd".
1948 // All three components of the magnetic field ,"b[3]" (kG),
1949 // are taken into account.
1951 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
1952 // b) The impact parameters and their covariance matrix are calculated.
1953 // c) An attempt to constrain the TPC-only params to the vertex is done.
1954 // The constrained params are returned via "cParam".
1956 // In the case of success, the returned value is kTRUE
1957 // otherwise, it's kFALSE)
1960 if (!fTPCInner) return kFALSE;
1961 if (!vtx) return kFALSE;
1963 Double_t dz[2],cov[3];
1964 if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
1972 Double_t covar[6]; vtx->GetCovMatrix(covar);
1973 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1974 Double_t c[3]={covar[2],0.,covar[5]};
1976 Double_t chi2=GetPredictedChi2(p,c);
1977 if (chi2>kVeryBig) return kFALSE;
1981 if (!cParam) return kTRUE;
1983 *cParam = *fTPCInner;
1984 if (!cParam->Update(p,c)) return kFALSE;
1989 //_______________________________________________________________________
1990 Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
1991 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
1993 // Try to relate this track to the vertex "vtx",
1994 // if the (rough) transverse impact parameter is not bigger then "maxd".
1995 // Magnetic field is "b" (kG).
1997 // a) The track gets extapolated to the DCA to the vertex.
1998 // b) The impact parameters and their covariance matrix are calculated.
1999 // c) An attempt to constrain this track to the vertex is done.
2000 // The constrained params are returned via "cParam".
2002 // In the case of success, the returned value is kTRUE
2003 // (otherwise, it's kFALSE)
2006 if (!vtx) return kFALSE;
2008 Double_t dz[2],cov[3];
2009 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2017 Double_t covar[6]; vtx->GetCovMatrix(covar);
2018 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2019 Double_t c[3]={covar[2],0.,covar[5]};
2021 Double_t chi2=GetPredictedChi2(p,c);
2022 if (chi2>kVeryBig) return kFALSE;
2027 //--- Could now these lines be removed ? ---
2029 fCp=new AliExternalTrackParam(*this);
2031 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2032 //----------------------------------------
2034 fVertexID = vtx->GetID();
2036 if (!cParam) return kTRUE;
2039 if (!cParam->Update(p,c)) return kFALSE;
2044 //_______________________________________________________________________
2045 Bool_t AliESDtrack::RelateToVertexBxByBz(const AliESDVertex *vtx,
2046 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2048 // Try to relate this track to the vertex "vtx",
2049 // if the (rough) transverse impact parameter is not bigger then "maxd".
2050 // Magnetic field is "b" (kG).
2052 // a) The track gets extapolated to the DCA to the vertex.
2053 // b) The impact parameters and their covariance matrix are calculated.
2054 // c) An attempt to constrain this track to the vertex is done.
2055 // The constrained params are returned via "cParam".
2057 // In the case of success, the returned value is kTRUE
2058 // (otherwise, it's kFALSE)
2061 if (!vtx) return kFALSE;
2063 Double_t dz[2],cov[3];
2064 if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2072 Double_t covar[6]; vtx->GetCovMatrix(covar);
2073 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2074 Double_t c[3]={covar[2],0.,covar[5]};
2076 Double_t chi2=GetPredictedChi2(p,c);
2077 if (chi2>kVeryBig) return kFALSE;
2082 //--- Could now these lines be removed ? ---
2084 fCp=new AliExternalTrackParam(*this);
2086 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2087 //----------------------------------------
2089 fVertexID = vtx->GetID();
2091 if (!cParam) return kTRUE;
2094 if (!cParam->Update(p,c)) return kFALSE;
2099 //_______________________________________________________________________
2100 void AliESDtrack::Print(Option_t *) const {
2101 // Prints info on the track
2102 AliExternalTrackParam::Print();
2103 printf("ESD track info\n") ;
2104 Double_t p[AliPID::kSPECIESN] ;
2106 if( IsOn(kITSpid) ){
2107 printf("From ITS: ") ;
2109 for(index = 0 ; index < AliPID::kSPECIES; index++)
2110 printf("%f, ", p[index]) ;
2111 printf("\n signal = %f\n", GetITSsignal()) ;
2113 if( IsOn(kTPCpid) ){
2114 printf("From TPC: ") ;
2116 for(index = 0 ; index < AliPID::kSPECIES; index++)
2117 printf("%f, ", p[index]) ;
2118 printf("\n signal = %f\n", GetTPCsignal()) ;
2120 if( IsOn(kTRDpid) ){
2121 printf("From TRD: ") ;
2123 for(index = 0 ; index < AliPID::kSPECIES; index++)
2124 printf("%f, ", p[index]) ;
2125 printf("\n signal = %f\n", GetTRDsignal()) ;
2127 if( IsOn(kTOFpid) ){
2128 printf("From TOF: ") ;
2130 for(index = 0 ; index < AliPID::kSPECIES; index++)
2131 printf("%f, ", p[index]) ;
2132 printf("\n signal = %f\n", GetTOFsignal()) ;
2134 if( IsOn(kHMPIDpid) ){
2135 printf("From HMPID: ") ;
2137 for(index = 0 ; index < AliPID::kSPECIES; index++)
2138 printf("%f, ", p[index]) ;
2139 printf("\n signal = %f\n", GetHMPIDsignal()) ;
2145 // Draw functionality
2146 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
2148 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
2150 // Fill points in the polymarker
2153 arrayRef.AddLast(new AliExternalTrackParam(*this));
2154 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
2155 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
2156 if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
2158 Double_t mpos[3]={0,0,0};
2159 Int_t entries=arrayRef.GetEntries();
2160 for (Int_t i=0;i<entries;i++){
2162 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
2163 mpos[0]+=pos[0]/entries;
2164 mpos[1]+=pos[1]/entries;
2165 mpos[2]+=pos[2]/entries;
2167 // Rotate to the mean position
2169 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
2170 for (Int_t i=0;i<entries;i++){
2171 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
2172 if (!res) delete arrayRef.RemoveAt(i);
2175 for (Double_t r=minR; r<maxR; r+=stepR){
2177 Double_t mlpos[3]={0,0,0};
2178 for (Int_t i=0;i<entries;i++){
2179 Double_t point[3]={0,0,0};
2180 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
2181 if (!param) continue;
2182 if (param->GetXYZAt(r,magF,point)){
2183 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
2185 mlpos[0]+=point[0]*weight;
2186 mlpos[1]+=point[1]*weight;
2187 mlpos[2]+=point[2]*weight;
2194 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
2195 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
2201 //_______________________________________________________________________
2202 void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
2204 // Store the dE/dx samples measured by the two SSD and two SDD layers.
2205 // These samples are corrected for the track segment length.
2207 for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
2210 //_______________________________________________________________________
2211 void AliESDtrack::GetITSdEdxSamples(Double_t *s) const {
2213 // Get the dE/dx samples measured by the two SSD and two SDD layers.
2214 // These samples are corrected for the track segment length.
2216 for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];
2220 UShort_t AliESDtrack::GetTPCnclsS(Int_t i0,Int_t i1) const{
2222 // get number of shared clusters
2224 return fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);