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 "AliKalmanTrack.h"
123 #include "AliVTrack.h"
125 #include "AliTrackPointArray.h"
126 #include "TPolyMarker3D.h"
128 ClassImp(AliESDtrack)
130 void SetPIDValues(Double_t * dest, const Double_t * src, Int_t n) {
131 // This function copies "n" PID weights from "scr" to "dest"
132 // and normalizes their sum to 1 thus producing conditional probabilities.
133 // The negative weights are set to 0.
134 // In case all the weights are non-positive they are replaced by
135 // uniform probabilities
139 Float_t uniform = 1./(Float_t)n;
142 for (Int_t i=0; i<n; i++)
152 for (Int_t i=0; i<n; i++) dest[i] /= sum;
154 for (Int_t i=0; i<n; i++) dest[i] = uniform;
157 //_______________________________________________________________________
158 AliESDtrack::AliESDtrack() :
159 AliExternalTrackParam(),
165 fFriendTrack(new AliESDfriendTrack()),
166 fTPCClusterMap(159),//number of padrows
167 fTPCSharedMap(159),//number of padrows
178 fEMCALindex(kEMCALNoMatch),
184 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
187 fCdd(0),fCdz(0),fCzz(0),
219 fVertexID(-2) // -2 means an orphan track
222 // The default ESD constructor
225 for (i=0; i<AliPID::kSPECIES; i++) {
235 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
236 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
237 for (i=0;i<kTRDnPlanes;i++) {
240 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
241 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
242 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
243 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
244 for (i=0;i<12;i++) {fITSModule[i]=-1;}
247 //_______________________________________________________________________
248 AliESDtrack::AliESDtrack(const AliESDtrack& track):
249 AliExternalTrackParam(track),
256 fTPCClusterMap(track.fTPCClusterMap),
257 fTPCSharedMap(track.fTPCSharedMap),
258 fFlags(track.fFlags),
260 fLabel(track.fLabel),
261 fITSLabel(track.fITSLabel),
262 fTPCLabel(track.fTPCLabel),
263 fTRDLabel(track.fTRDLabel),
264 fTOFCalChannel(track.fTOFCalChannel),
265 fTOFindex(track.fTOFindex),
266 fHMPIDqn(track.fHMPIDqn),
267 fHMPIDcluIdx(track.fHMPIDcluIdx),
268 fEMCALindex(track.fEMCALindex),
269 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
270 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
271 fHMPIDsignal(track.fHMPIDsignal),
272 fTrackLength(track.fTrackLength),
273 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
274 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
275 fCchi2TPC(track.fCchi2TPC),
276 fD(track.fD),fZ(track.fZ),
277 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
278 fCchi2(track.fCchi2),
279 fITSchi2(track.fITSchi2),
280 fTPCchi2(track.fTPCchi2),
281 fTRDchi2(track.fTRDchi2),
282 fTOFchi2(track.fTOFchi2),
283 fHMPIDchi2(track.fHMPIDchi2),
284 fGlobalChi2(track.fGlobalChi2),
285 fITSsignal(track.fITSsignal),
286 fTPCsignal(track.fTPCsignal),
287 fTPCsignalS(track.fTPCsignalS),
288 fTRDsignal(track.fTRDsignal),
289 fTRDQuality(track.fTRDQuality),
290 fTRDBudget(track.fTRDBudget),
291 fTOFsignal(track.fTOFsignal),
292 fTOFsignalToT(track.fTOFsignalToT),
293 fTOFsignalRaw(track.fTOFsignalRaw),
294 fTOFsignalDz(track.fTOFsignalDz),
295 fHMPIDtrkX(track.fHMPIDtrkX),
296 fHMPIDtrkY(track.fHMPIDtrkY),
297 fHMPIDmipX(track.fHMPIDmipX),
298 fHMPIDmipY(track.fHMPIDmipY),
299 fTPCncls(track.fTPCncls),
300 fTPCnclsF(track.fTPCnclsF),
301 fTPCsignalN(track.fTPCsignalN),
302 fITSncls(track.fITSncls),
303 fITSClusterMap(track.fITSClusterMap),
304 fTRDncls(track.fTRDncls),
305 fTRDncls0(track.fTRDncls0),
306 fTRDntracklets(track.fTRDntracklets),
307 fTRDnSlices(track.fTRDnSlices),
309 fVertexID(track.fVertexID)
314 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
315 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
317 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
319 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
320 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
321 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
322 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
323 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
325 for (Int_t i=0;i<kTRDnPlanes;i++) {
326 fTRDTimBin[i]=track.fTRDTimBin[i];
330 fTRDslices=new Double32_t[fTRDnSlices];
331 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
334 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
335 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
336 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
337 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
338 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
339 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
341 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
342 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
343 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
344 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
345 if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
347 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
350 //_______________________________________________________________________
351 AliESDtrack::AliESDtrack(const AliVTrack *track) :
352 AliExternalTrackParam(track),
359 fTPCClusterMap(159),//number of padrows
360 fTPCSharedMap(159),//number of padrows
371 fEMCALindex(kEMCALNoMatch),
377 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
380 fCdd(0),fCdz(0),fCzz(0),
412 fVertexID(-2) // -2 means an orphan track
415 // ESD track from AliVTrack.
416 // This is not a copy constructor !
419 if (track->InheritsFrom("AliExternalTrackParam")) {
420 AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
421 AliWarning("Calling the default constructor...");
426 // Reset all the arrays
428 for (i=0; i<AliPID::kSPECIES; i++) {
438 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
439 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
440 for (i=0;i<kTRDnPlanes;i++) {
443 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
444 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
445 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
446 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
447 for (i=0;i<12;i++) {fITSModule[i]=-1;}
450 SetID(track->GetID());
452 // Set ITS cluster map
453 fITSClusterMap=track->GetITSClusterMap();
457 if(HasPointOnITSLayer(i)) fITSncls++;
460 // Set the combined PID
461 const Double_t *pid = track->PID();
463 for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
465 // AliESD track label
466 SetLabel(track->GetLabel());
468 SetStatus(track->GetStatus());
471 //_______________________________________________________________________
472 AliESDtrack::AliESDtrack(TParticle * part) :
473 AliExternalTrackParam(),
480 fTPCClusterMap(159),//number of padrows
481 fTPCSharedMap(159),//number of padrows
492 fEMCALindex(kEMCALNoMatch),
498 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
501 fCdd(0),fCdz(0),fCzz(0),
533 fVertexID(-2) // -2 means an orphan track
536 // ESD track from TParticle
539 // Reset all the arrays
541 for (i=0; i<AliPID::kSPECIES; i++) {
551 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
552 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
553 for (i=0;i<kTRDnPlanes;i++) {
556 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
557 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
558 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
559 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
560 for (i=0;i<12;i++) {fITSModule[i]=-1;}
562 // Calculate the AliExternalTrackParam content
569 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
570 alpha = part->Phi()*180./TMath::Pi();
571 if (alpha<0) alpha+= 360.;
572 if (alpha>360) alpha -= 360.;
574 Int_t sector = (Int_t)(alpha/20.);
575 alpha = 10. + 20.*sector;
577 alpha *= TMath::Pi();
579 // Covariance matrix: no errors, the parameters are exact
580 for (i=0; i<15; i++) covar[i]=0.;
582 // Get the vertex of origin and the momentum
583 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
584 TVector3 mom(part->Px(),part->Py(),part->Pz());
586 // Rotate to the local coordinate system (TPC sector)
590 // X of the referense plane
593 Int_t pdgCode = part->GetPdgCode();
596 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
600 param[2] = TMath::Sin(mom.Phi());
601 param[3] = mom.Pz()/mom.Pt();
602 param[4] = TMath::Sign(1/mom.Pt(),charge);
604 // Set AliExternalTrackParam
605 Set(xref, alpha, param, covar);
610 switch (TMath::Abs(pdgCode)) {
636 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
637 if (indexPID < AliPID::kSPECIES) {
643 fHMPIDr[indexPID]=1.;
646 // AliESD track label
647 SetLabel(part->GetUniqueID());
651 //_______________________________________________________________________
652 AliESDtrack::~AliESDtrack(){
654 // This is destructor according Coding Conventrions
656 //printf("Delete track\n");
667 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
670 if(&source == this) return *this;
671 AliExternalTrackParam::operator=(source);
675 // we have the trackparam: assign or copy construct
676 if(fCp)*fCp = *source.fCp;
677 else fCp = new AliExternalTrackParam(*source.fCp);
680 // no track param delete the old one
686 // we have the trackparam: assign or copy construct
687 if(fIp)*fIp = *source.fIp;
688 else fIp = new AliExternalTrackParam(*source.fIp);
691 // no track param delete the old one
697 if(source.fTPCInner){
698 // we have the trackparam: assign or copy construct
699 if(fTPCInner) *fTPCInner = *source.fTPCInner;
700 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
703 // no track param delete the old one
704 if(fTPCInner)delete fTPCInner;
710 // we have the trackparam: assign or copy construct
711 if(fOp) *fOp = *source.fOp;
712 else fOp = new AliExternalTrackParam(*source.fOp);
715 // no track param delete the old one
722 // we have the trackparam: assign or copy construct
723 if(fOp) *fHMPIDp = *source.fHMPIDp;
724 else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
727 // no track param delete the old one
728 if(fHMPIDp)delete fHMPIDp;
733 // copy also the friend track
734 // use copy constructor
735 if(source.fFriendTrack){
736 // we have the trackparam: assign or copy construct
737 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
740 // no track param delete the old one
741 delete fFriendTrack; fFriendTrack= 0;
744 fTPCClusterMap = source.fTPCClusterMap;
745 fTPCSharedMap = source.fTPCSharedMap;
747 fFlags = source.fFlags;
749 fLabel = source.fLabel;
750 fITSLabel = source.fITSLabel;
751 for(int i = 0; i< 12;++i){
752 fITSModule[i] = source.fITSModule[i];
754 fTPCLabel = source.fTPCLabel;
755 fTRDLabel = source.fTRDLabel;
756 for(int i = 0; i< 3;++i){
757 fTOFLabel[i] = source.fTOFLabel[i];
759 fTOFCalChannel = source.fTOFCalChannel;
760 fTOFindex = source.fTOFindex;
761 fHMPIDqn = source.fHMPIDqn;
762 fHMPIDcluIdx = source.fHMPIDcluIdx;
763 fEMCALindex = source.fEMCALindex;
765 for(int i = 0; i< 3;++i){
766 fKinkIndexes[i] = source.fKinkIndexes[i];
767 fV0Indexes[i] = source.fV0Indexes[i];
770 for(int i = 0; i< AliPID::kSPECIES;++i){
771 fR[i] = source.fR[i];
772 fITSr[i] = source.fITSr[i];
773 fTPCr[i] = source.fTPCr[i];
774 fTRDr[i] = source.fTRDr[i];
775 fTOFr[i] = source.fTOFr[i];
776 fHMPIDr[i] = source.fHMPIDr[i];
777 fTrackTime[i] = source.fTrackTime[i];
780 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
781 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
782 fHMPIDsignal = source.fHMPIDsignal;
785 fTrackLength = source. fTrackLength;
786 fdTPC = source.fdTPC;
787 fzTPC = source.fzTPC;
788 fCddTPC = source.fCddTPC;
789 fCdzTPC = source.fCdzTPC;
790 fCzzTPC = source.fCzzTPC;
791 fCchi2TPC = source.fCchi2TPC;
798 fCchi2 = source.fCchi2;
800 fITSchi2 = source.fITSchi2;
801 fTPCchi2 = source.fTPCchi2;
802 fTRDchi2 = source.fTRDchi2;
803 fTOFchi2 = source.fTOFchi2;
804 fHMPIDchi2 = source.fHMPIDchi2;
806 fGlobalChi2 = source.fGlobalChi2;
808 fITSsignal = source.fITSsignal;
809 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
810 fTPCsignal = source.fTPCsignal;
811 fTPCsignalS = source.fTPCsignalS;
812 for(int i = 0; i< 4;++i){
813 fTPCPoints[i] = source.fTPCPoints[i];
815 fTRDsignal = source.fTRDsignal;
817 for(int i = 0;i < kTRDnPlanes;++i){
818 fTRDTimBin[i] = source.fTRDTimBin[i];
824 fTRDnSlices=source.fTRDnSlices;
826 fTRDslices=new Double32_t[fTRDnSlices];
827 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
830 fTRDQuality = source.fTRDQuality;
831 fTRDBudget = source.fTRDBudget;
832 fTOFsignal = source.fTOFsignal;
833 fTOFsignalToT = source.fTOFsignalToT;
834 fTOFsignalRaw = source.fTOFsignalRaw;
835 fTOFsignalDz = source.fTOFsignalDz;
837 for(int i = 0;i<10;++i){
838 fTOFInfo[i] = source.fTOFInfo[i];
841 fHMPIDtrkX = source.fHMPIDtrkX;
842 fHMPIDtrkY = source.fHMPIDtrkY;
843 fHMPIDmipX = source.fHMPIDmipX;
844 fHMPIDmipY = source.fHMPIDmipY;
846 fTPCncls = source.fTPCncls;
847 fTPCnclsF = source.fTPCnclsF;
848 fTPCsignalN = source.fTPCsignalN;
850 fITSncls = source.fITSncls;
851 fITSClusterMap = source.fITSClusterMap;
852 fTRDncls = source.fTRDncls;
853 fTRDncls0 = source.fTRDncls0;
854 fTRDntracklets = source.fTRDntracklets;
855 fVertexID = source.fVertexID;
861 void AliESDtrack::Copy(TObject &obj) const {
863 // this overwrites the virtual TOBject::Copy()
864 // to allow run time copying without casting
867 if(this==&obj)return;
868 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
869 if(!robj)return; // not an AliESDtrack
876 void AliESDtrack::AddCalibObject(TObject * object){
878 // add calib object to the list
880 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
881 fFriendTrack->AddCalibObject(object);
884 TObject * AliESDtrack::GetCalibObject(Int_t index){
886 // return calib objct at given position
888 if (!fFriendTrack) return 0;
889 return fFriendTrack->GetCalibObject(index);
893 Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
895 // Fills the information of the TPC-only first reconstruction pass
896 // into the passed ESDtrack object. For consistency fTPCInner is also filled
901 // For data produced before r26675
902 // RelateToVertexTPC was not properly called during reco
903 // so you'll have to call it again, before FillTPCOnlyTrack
904 // Float_t p[2],cov[3];
905 // track->GetImpactParametersTPC(p,cov);
906 // if(p[0]==0&&p[1]==0) // <- Default values
907 // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
910 if(!fTPCInner)return kFALSE;
912 // fill the TPC track params to the global track parameters
913 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
916 track.fCdd = fCddTPC;
917 track.fCdz = fCdzTPC;
918 track.fCzz = fCzzTPC;
920 // copy the TPCinner parameters
921 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
922 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
925 track.fCddTPC = fCddTPC;
926 track.fCdzTPC = fCdzTPC;
927 track.fCzzTPC = fCzzTPC;
928 track.fCchi2TPC = fCchi2TPC;
931 // copy all other TPC specific parameters
933 // replace label by TPC label
934 track.fLabel = fTPCLabel;
935 track.fTPCLabel = fTPCLabel;
937 track.fTPCchi2 = fTPCchi2;
938 track.fTPCsignal = fTPCsignal;
939 track.fTPCsignalS = fTPCsignalS;
940 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
942 track.fTPCncls = fTPCncls;
943 track.fTPCnclsF = fTPCnclsF;
944 track.fTPCsignalN = fTPCsignalN;
947 for(int i=0;i<AliPID::kSPECIES;++i){
948 track.fTPCr[i] = fTPCr[i];
949 // combined PID is TPC only!
950 track.fR[i] = fTPCr[i];
952 track.fTPCClusterMap = fTPCClusterMap;
953 track.fTPCSharedMap = fTPCSharedMap;
957 track.fFlags = kTPCin;
960 track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
962 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
968 //_______________________________________________________________________
969 void AliESDtrack::MakeMiniESDtrack(){
970 // Resets everything except
971 // fFlags: Reconstruction status flags
972 // fLabel: Track label
973 // fID: Unique ID of the track
974 // Impact parameter information
975 // fR[AliPID::kSPECIES]: combined "detector response probability"
976 // Running track parameters in the base class (AliExternalTrackParam)
980 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
982 // Reset track parameters constrained to the primary vertex
985 // Reset track parameters at the inner wall of TPC
987 delete fTPCInner;fTPCInner=0;
988 // Reset track parameters at the inner wall of the TRD
990 // Reset track parameters at the HMPID
991 delete fHMPIDp;fHMPIDp = 0;
994 // Reset ITS track related information
999 for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
1000 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
1003 // Reset TPC related track information
1012 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
1014 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1015 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1016 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1018 // Reset TRD related track information
1023 for (Int_t i=0;i<kTRDnPlanes;i++) {
1026 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1031 delete[] fTRDslices;
1036 // Reset TOF related track information
1044 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
1045 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
1046 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1048 // Reset HMPID related track information
1053 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
1060 fEMCALindex = kEMCALNoMatch;
1062 // reset global track chi2
1065 fVertexID = -2; // an orphan track
1067 delete fFriendTrack; fFriendTrack = 0;
1069 //_______________________________________________________________________
1070 Double_t AliESDtrack::GetMass() const {
1071 // Returns the mass of the most probable particle type
1074 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
1075 if (fR[i]>max) {k=i; max=fR[i];}
1077 if (k==0) { // dE/dx "crossing points" in the TPC
1079 if ((p>0.38)&&(p<0.48))
1080 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
1081 if ((p>0.75)&&(p<0.85))
1082 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
1085 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
1086 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
1087 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
1088 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
1089 AliWarning("Undefined mass !");
1090 return AliPID::ParticleMass(AliPID::kPion);
1093 //______________________________________________________________________________
1094 Double_t AliESDtrack::E() const
1096 // Returns the energy of the particle given its assumed mass.
1097 // Assumes the pion mass if the particle can't be identified properly.
1101 return TMath::Sqrt(p*p + m*m);
1104 //______________________________________________________________________________
1105 Double_t AliESDtrack::Y() const
1107 // Returns the rapidity of a particle given its assumed mass.
1108 // Assumes the pion mass if the particle can't be identified properly.
1112 if (e != TMath::Abs(pz)) { // energy was not equal to pz
1113 return 0.5*TMath::Log((e+pz)/(e-pz));
1114 } else { // energy was equal to pz
1119 //_______________________________________________________________________
1120 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
1122 // This function updates track's running parameters
1128 fLabel=t->GetLabel();
1130 if (t->IsStartedTimeIntegral()) {
1132 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
1133 SetIntegratedLength(t->GetIntegratedLength());
1136 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1137 if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1138 if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
1139 if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
1143 case kITSin: case kITSout: case kITSrefit:
1145 fITSncls=t->GetNumberOfClusters();
1146 index=fFriendTrack->GetITSindices();
1147 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
1148 index[i]=t->GetClusterIndex(i);
1150 Int_t l=(index[i] & 0xf0000000) >> 28;
1151 SETBIT(fITSClusterMap,l);
1154 fITSchi2=t->GetChi2();
1155 fITSsignal=t->GetPIDsignal();
1156 fITSLabel = t->GetLabel();
1157 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1158 if (flags==kITSout) {
1159 if (!fOp) fOp=new AliExternalTrackParam(*t);
1161 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1165 case kTPCin: case kTPCrefit:
1166 fTPCLabel = t->GetLabel();
1167 if (flags==kTPCin) fTPCInner=new AliExternalTrackParam(*t);
1168 if (!fIp) fIp=new AliExternalTrackParam(*t);
1170 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1172 index=fFriendTrack->GetTPCindices();
1173 if (flags & kTPCout){
1174 if (!fOp) fOp=new AliExternalTrackParam(*t);
1176 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1178 fTPCncls=t->GetNumberOfClusters();
1179 fTPCchi2=t->GetChi2();
1181 {//prevrow must be declared in separate namespace, otherwise compiler cries:
1182 //"jump to case label crosses initialization of `Int_t prevrow'"
1184 // for (Int_t i=0;i<fTPCncls;i++)
1185 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1187 index[i]=t->GetClusterIndex(i);
1188 Int_t idx = index[i];
1190 if (idx<0) continue;
1192 // Piotr's Cluster Map for HBT
1193 // ### please change accordingly if cluster array is changing
1194 // to "New TPC Tracking" style (with gaps in array)
1195 Int_t sect = (idx&0xff000000)>>24;
1196 Int_t row = (idx&0x00ff0000)>>16;
1197 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
1199 fTPCClusterMap.SetBitNumber(row,kTRUE);
1201 //Fill the gap between previous row and this row with 0 bits
1202 //In case ### pleas change it as well - just set bit 0 in case there
1203 //is no associated clusters for current "i"
1206 prevrow = row;//if previous bit was not assigned yet == this is the first one
1209 { //we don't know the order (inner to outer or reverse)
1210 //just to be save in case it is going to change
1223 for (Int_t j = n+1; j < m; j++)
1225 fTPCClusterMap.SetBitNumber(j,kFALSE);
1229 // End Of Piotr's Cluster Map for HBT
1232 fTPCsignal=t->GetPIDsignal();
1235 case kTRDin: case kTRDrefit:
1238 index = fFriendTrack->GetTRDindices();
1239 fTRDLabel = t->GetLabel();
1240 fTRDchi2 = t->GetChi2();
1241 fTRDncls = t->GetNumberOfClusters();
1242 for (Int_t i=0;i<6;i++) index[i]=t->GetTrackletIndex(i);
1244 fTRDsignal=t->GetPIDsignal();
1247 if (!fOp) fOp=new AliExternalTrackParam(*t);
1249 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1250 fTRDncls0 = t->GetNumberOfClusters();
1259 if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1261 fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1264 AliError("Wrong flag !");
1271 //_______________________________________________________________________
1272 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1273 //---------------------------------------------------------------------
1274 // This function returns external representation of the track parameters
1275 //---------------------------------------------------------------------
1277 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1280 //_______________________________________________________________________
1281 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1282 //---------------------------------------------------------------------
1283 // This function returns external representation of the cov. matrix
1284 //---------------------------------------------------------------------
1285 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1288 //_______________________________________________________________________
1289 Bool_t AliESDtrack::GetConstrainedExternalParameters
1290 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1291 //---------------------------------------------------------------------
1292 // This function returns the constrained external track parameters
1293 //---------------------------------------------------------------------
1294 if (!fCp) return kFALSE;
1295 alpha=fCp->GetAlpha();
1297 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1301 //_______________________________________________________________________
1303 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1304 //---------------------------------------------------------------------
1305 // This function returns the constrained external cov. matrix
1306 //---------------------------------------------------------------------
1307 if (!fCp) return kFALSE;
1308 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1313 AliESDtrack::GetInnerExternalParameters
1314 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1315 //---------------------------------------------------------------------
1316 // This function returns external representation of the track parameters
1317 // at the inner layer of TPC
1318 //---------------------------------------------------------------------
1319 if (!fIp) return kFALSE;
1320 alpha=fIp->GetAlpha();
1322 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1327 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1328 //---------------------------------------------------------------------
1329 // This function returns external representation of the cov. matrix
1330 // at the inner layer of TPC
1331 //---------------------------------------------------------------------
1332 if (!fIp) return kFALSE;
1333 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1338 AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1340 // This is a direct setter for the outer track parameters
1343 if (fOp) delete fOp;
1344 fOp=new AliExternalTrackParam(*p);
1348 AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1350 // This is a direct setter for the outer track parameters
1353 if (fHMPIDp) delete fHMPIDp;
1354 fHMPIDp=new AliExternalTrackParam(*p);
1358 AliESDtrack::GetOuterExternalParameters
1359 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1360 //---------------------------------------------------------------------
1361 // This function returns external representation of the track parameters
1362 // at the inner layer of TRD
1363 //---------------------------------------------------------------------
1364 if (!fOp) return kFALSE;
1365 alpha=fOp->GetAlpha();
1367 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1372 AliESDtrack::GetOuterHmpExternalParameters
1373 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1374 //---------------------------------------------------------------------
1375 // This function returns external representation of the track parameters
1376 // at the inner layer of TRD
1377 //---------------------------------------------------------------------
1378 if (!fHMPIDp) return kFALSE;
1379 alpha=fHMPIDp->GetAlpha();
1381 for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1386 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1387 //---------------------------------------------------------------------
1388 // This function returns external representation of the cov. matrix
1389 // at the inner layer of TRD
1390 //---------------------------------------------------------------------
1391 if (!fOp) return kFALSE;
1392 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1397 AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1398 //---------------------------------------------------------------------
1399 // This function returns external representation of the cov. matrix
1400 // at the inner layer of TRD
1401 //---------------------------------------------------------------------
1402 if (!fHMPIDp) return kFALSE;
1403 for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1407 Int_t AliESDtrack::GetNcls(Int_t idet) const
1409 // Get number of clusters by subdetector index
1423 if (fTOFindex != -1)
1429 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1430 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1441 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1443 // Get cluster index array by subdetector index
1448 ncls = GetITSclusters(idx);
1451 ncls = GetTPCclusters(idx);
1454 ncls = GetTRDclusters(idx);
1457 if (fTOFindex != -1) {
1465 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1466 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1467 idx[0] = GetHMPIDcluIdx();
1480 //_______________________________________________________________________
1481 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1482 // Returns the array with integrated times for each particle hypothesis
1483 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1486 //_______________________________________________________________________
1487 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1488 // Sets the array with integrated times for each particle hypotesis
1489 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1492 //_______________________________________________________________________
1493 void AliESDtrack::SetITSpid(const Double_t *p) {
1494 // Sets values for the probability of each particle type (in ITS)
1495 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1496 SetStatus(AliESDtrack::kITSpid);
1499 //_______________________________________________________________________
1500 void AliESDtrack::GetITSpid(Double_t *p) const {
1501 // Gets the probability of each particle type (in ITS)
1502 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1505 //_______________________________________________________________________
1506 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1507 //---------------------------------------------------------------------
1508 // This function returns indices of the assgined ITS clusters
1509 //---------------------------------------------------------------------
1511 Int_t *index=fFriendTrack->GetITSindices();
1512 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1513 if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1514 else idx[i]=index[i];
1520 //_______________________________________________________________________
1521 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1522 Float_t &xloc,Float_t &zloc) const {
1523 //----------------------------------------------------------------------
1524 // This function encodes in the module number also the status of cluster association
1525 // "status" can have the following values:
1526 // 1 "found" (cluster is associated),
1527 // 2 "dead" (module is dead from OCDB),
1528 // 3 "skipped" (module or layer forced to be skipped),
1529 // 4 "outinz" (track out of z acceptance),
1530 // 5 "nocls" (no clusters in the road),
1531 // 6 "norefit" (cluster rejected during refit),
1532 // 7 "deadzspd" (holes in z in SPD)
1533 // Also given are the coordinates of the crossing point of track and module
1534 // (in the local module ref. system)
1535 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1536 //----------------------------------------------------------------------
1538 if(fITSModule[ilayer]==-1) {
1541 xloc=-99.; zloc=-99.;
1545 Int_t module = fITSModule[ilayer];
1547 idet = Int_t(module/1000000);
1549 module -= idet*1000000;
1551 status = Int_t(module/100000);
1553 module -= status*100000;
1555 Int_t signs = Int_t(module/10000);
1557 module-=signs*10000;
1559 Int_t xInt = Int_t(module/100);
1562 Int_t zInt = module;
1564 if(signs==1) { xInt*=1; zInt*=1; }
1565 if(signs==2) { xInt*=1; zInt*=-1; }
1566 if(signs==3) { xInt*=-1; zInt*=1; }
1567 if(signs==4) { xInt*=-1; zInt*=-1; }
1569 xloc = 0.1*(Float_t)xInt;
1570 zloc = 0.1*(Float_t)zInt;
1572 if(status==4) idet = -1;
1577 //_______________________________________________________________________
1578 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1579 //---------------------------------------------------------------------
1580 // This function returns indices of the assgined ITS clusters
1581 //---------------------------------------------------------------------
1583 Int_t *index=fFriendTrack->GetTPCindices();
1584 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1589 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1591 // GetDensity of the clusters on given region between row0 and row1
1592 // Dead zone effect takin into acoount
1597 Int_t *index=fFriendTrack->GetTPCindices();
1598 for (Int_t i=row0;i<=row1;i++){
1599 Int_t idx = index[i];
1600 if (idx!=-1) good++; // track outside of dead zone
1603 Float_t density=0.5;
1604 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1608 //_______________________________________________________________________
1609 void AliESDtrack::SetTPCpid(const Double_t *p) {
1610 // Sets values for the probability of each particle type (in TPC)
1611 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1612 SetStatus(AliESDtrack::kTPCpid);
1615 //_______________________________________________________________________
1616 void AliESDtrack::GetTPCpid(Double_t *p) const {
1617 // Gets the probability of each particle type (in TPC)
1618 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1621 //_______________________________________________________________________
1622 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1623 //---------------------------------------------------------------------
1624 // This function returns indices of the assgined TRD clusters
1625 //---------------------------------------------------------------------
1627 Int_t *index=fFriendTrack->GetTRDindices();
1628 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1633 //_______________________________________________________________________
1634 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1635 //---------------------------------------------------------------------
1636 // This function returns indices of the assigned TRD tracklets
1637 //---------------------------------------------------------------------
1639 Int_t *index=fFriendTrack->GetTRDindices();
1640 for (Int_t i=0; i<6/*AliESDfriendTrack::kMaxTRDcluster*/; i++) idx[i]=index[i];
1645 //_______________________________________________________________________
1646 void AliESDtrack::SetTRDpid(const Double_t *p) {
1647 // Sets values for the probability of each particle type (in TRD)
1648 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1649 SetStatus(AliESDtrack::kTRDpid);
1652 //_______________________________________________________________________
1653 void AliESDtrack::GetTRDpid(Double_t *p) const {
1654 // Gets the probability of each particle type (in TRD)
1655 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1658 //_______________________________________________________________________
1659 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1661 // Sets the probability of particle type iSpecies to p (in TRD)
1662 fTRDr[iSpecies] = p;
1665 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1667 // Returns the probability of particle type iSpecies (in TRD)
1668 return fTRDr[iSpecies];
1671 //____________________________________________________
1672 Int_t AliESDtrack::GetNumberOfTRDslices() const
1674 // built in backward compatibility
1675 Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
1676 return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
1679 //____________________________________________________
1680 Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
1682 //Returns momentum estimation and optional its error (sp)
1683 // in TRD layer "plane".
1686 AliError("No TRD info allocated for this track !");
1689 if ((plane<0) || (plane>=kTRDnPlanes)) {
1690 AliError("Info for TRD plane not available!");
1694 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1695 // Protection for backward compatibility
1696 if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
1698 if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
1699 return fTRDslices[idx];
1702 //____________________________________________________
1703 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1704 //Gets the charge from the slice of the plane
1707 //AliError("No TRD slices allocated for this track !");
1710 if ((plane<0) || (plane>=kTRDnPlanes)) {
1711 AliError("Info for TRD plane not available !");
1714 Int_t ns=GetNumberOfTRDslices();
1715 if ((slice<-1) || (slice>=ns)) {
1716 //AliError("Wrong TRD slice !");
1720 if(slice>=0) return fTRDslices[plane*ns + slice];
1722 // return average of the dEdx measurements
1723 Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
1724 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
1728 //____________________________________________________
1729 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1730 //Sets the number of slices used for PID
1731 if (fTRDnSlices) return;
1734 fTRDslices=new Double32_t[fTRDnSlices];
1736 // set-up correctly the allocated memory
1737 memset(fTRDslices, 0, n*sizeof(Double32_t));
1738 for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
1741 //____________________________________________________
1742 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1743 //Sets the charge q in the slice of the plane
1745 AliError("No TRD slices allocated for this track !");
1748 if ((plane<0) || (plane>=kTRDnPlanes)) {
1749 AliError("Info for TRD plane not allocated !");
1752 Int_t ns=GetNumberOfTRDslices();
1753 if ((slice<0) || (slice>=ns)) {
1754 AliError("Wrong TRD slice !");
1757 Int_t n=plane*ns + slice;
1762 //____________________________________________________
1763 void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
1766 AliError("No TRD slices allocated for this track !");
1769 if ((plane<0) || (plane>=kTRDnPlanes)) {
1770 AliError("Info for TRD plane not allocated !");
1774 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1775 // Protection for backward compatibility
1776 if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
1778 if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
1779 fTRDslices[idx] = p;
1783 //_______________________________________________________________________
1784 void AliESDtrack::SetTOFpid(const Double_t *p) {
1785 // Sets the probability of each particle type (in TOF)
1786 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
1787 SetStatus(AliESDtrack::kTOFpid);
1790 //_______________________________________________________________________
1791 void AliESDtrack::SetTOFLabel(const Int_t *p) {
1793 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1796 //_______________________________________________________________________
1797 void AliESDtrack::GetTOFpid(Double_t *p) const {
1798 // Gets probabilities of each particle type (in TOF)
1799 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
1802 //_______________________________________________________________________
1803 void AliESDtrack::GetTOFLabel(Int_t *p) const {
1805 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
1808 //_______________________________________________________________________
1809 void AliESDtrack::GetTOFInfo(Float_t *info) const {
1811 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
1814 //_______________________________________________________________________
1815 void AliESDtrack::SetTOFInfo(Float_t*info) {
1817 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
1822 //_______________________________________________________________________
1823 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
1824 // Sets the probability of each particle type (in HMPID)
1825 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
1826 SetStatus(AliESDtrack::kHMPIDpid);
1829 //_______________________________________________________________________
1830 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
1831 // Gets probabilities of each particle type (in HMPID)
1832 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
1837 //_______________________________________________________________________
1838 void AliESDtrack::SetESDpid(const Double_t *p) {
1839 // Sets the probability of each particle type for the ESD track
1840 SetPIDValues(fR,p,AliPID::kSPECIES);
1841 SetStatus(AliESDtrack::kESDpid);
1844 //_______________________________________________________________________
1845 void AliESDtrack::GetESDpid(Double_t *p) const {
1846 // Gets probability of each particle type for the ESD track
1847 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
1850 //_______________________________________________________________________
1851 Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
1852 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
1854 // Try to relate the TPC-only track parameters to the vertex "vtx",
1855 // if the (rough) transverse impact parameter is not bigger then "maxd".
1856 // Magnetic field is "b" (kG).
1858 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
1859 // b) The impact parameters and their covariance matrix are calculated.
1860 // c) An attempt to constrain the TPC-only params to the vertex is done.
1861 // The constrained params are returned via "cParam".
1863 // In the case of success, the returned value is kTRUE
1864 // otherwise, it's kFALSE)
1867 if (!fTPCInner) return kFALSE;
1868 if (!vtx) return kFALSE;
1870 Double_t dz[2],cov[3];
1871 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1879 Double_t covar[6]; vtx->GetCovMatrix(covar);
1880 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1881 Double_t c[3]={covar[2],0.,covar[5]};
1883 Double_t chi2=GetPredictedChi2(p,c);
1884 if (chi2>kVeryBig) return kFALSE;
1888 if (!cParam) return kTRUE;
1890 *cParam = *fTPCInner;
1891 if (!cParam->Update(p,c)) return kFALSE;
1896 //_______________________________________________________________________
1897 Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
1898 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
1900 // Try to relate this track to the vertex "vtx",
1901 // if the (rough) transverse impact parameter is not bigger then "maxd".
1902 // Magnetic field is "b" (kG).
1904 // a) The track gets extapolated to the DCA to the vertex.
1905 // b) The impact parameters and their covariance matrix are calculated.
1906 // c) An attempt to constrain this track to the vertex is done.
1907 // The constrained params are returned via "cParam".
1909 // In the case of success, the returned value is kTRUE
1910 // (otherwise, it's kFALSE)
1913 if (!vtx) return kFALSE;
1915 Double_t dz[2],cov[3];
1916 if (!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;
1934 //--- Could now these lines be removed ? ---
1936 fCp=new AliExternalTrackParam(*this);
1938 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
1939 //----------------------------------------
1941 fVertexID = vtx->GetID();
1943 if (!cParam) return kTRUE;
1946 if (!cParam->Update(p,c)) return kFALSE;
1951 //_______________________________________________________________________
1952 void AliESDtrack::Print(Option_t *) const {
1953 // Prints info on the track
1954 AliExternalTrackParam::Print();
1955 printf("ESD track info\n") ;
1956 Double_t p[AliPID::kSPECIESN] ;
1958 if( IsOn(kITSpid) ){
1959 printf("From ITS: ") ;
1961 for(index = 0 ; index < AliPID::kSPECIES; index++)
1962 printf("%f, ", p[index]) ;
1963 printf("\n signal = %f\n", GetITSsignal()) ;
1965 if( IsOn(kTPCpid) ){
1966 printf("From TPC: ") ;
1968 for(index = 0 ; index < AliPID::kSPECIES; index++)
1969 printf("%f, ", p[index]) ;
1970 printf("\n signal = %f\n", GetTPCsignal()) ;
1972 if( IsOn(kTRDpid) ){
1973 printf("From TRD: ") ;
1975 for(index = 0 ; index < AliPID::kSPECIES; index++)
1976 printf("%f, ", p[index]) ;
1977 printf("\n signal = %f\n", GetTRDsignal()) ;
1979 if( IsOn(kTOFpid) ){
1980 printf("From TOF: ") ;
1982 for(index = 0 ; index < AliPID::kSPECIES; index++)
1983 printf("%f, ", p[index]) ;
1984 printf("\n signal = %f\n", GetTOFsignal()) ;
1986 if( IsOn(kHMPIDpid) ){
1987 printf("From HMPID: ") ;
1989 for(index = 0 ; index < AliPID::kSPECIES; index++)
1990 printf("%f, ", p[index]) ;
1991 printf("\n signal = %f\n", GetHMPIDsignal()) ;
1997 // Draw functionality
1998 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
2000 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
2002 // Fill points in the polymarker
2005 arrayRef.AddLast(new AliExternalTrackParam(*this));
2006 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
2007 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
2008 if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
2010 Double_t mpos[3]={0,0,0};
2011 Int_t entries=arrayRef.GetEntries();
2012 for (Int_t i=0;i<entries;i++){
2014 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
2015 mpos[0]+=pos[0]/entries;
2016 mpos[1]+=pos[1]/entries;
2017 mpos[2]+=pos[2]/entries;
2019 // Rotate to the mean position
2021 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
2022 for (Int_t i=0;i<entries;i++){
2023 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
2024 if (!res) delete arrayRef.RemoveAt(i);
2027 for (Double_t r=minR; r<maxR; r+=stepR){
2029 Double_t mlpos[3]={0,0,0};
2030 for (Int_t i=0;i<entries;i++){
2031 Double_t point[3]={0,0,0};
2032 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
2033 if (!param) continue;
2034 if (param->GetXYZAt(r,magF,point)){
2035 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
2037 mlpos[0]+=point[0]*weight;
2038 mlpos[1]+=point[1]*weight;
2039 mlpos[2]+=point[2]*weight;
2046 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
2047 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
2053 //_______________________________________________________________________
2054 void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
2056 // Store the dE/dx samples measured by the two SSD and two SDD layers.
2057 // These samples are corrected for the track segment length.
2059 for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
2062 //_______________________________________________________________________
2063 void AliESDtrack::GetITSdEdxSamples(Double_t *s) const {
2065 // Get the dE/dx samples measured by the two SSD and two SDD layers.
2066 // These samples are corrected for the track segment length.
2068 for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];