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),
220 fVertexID(-2) // -2 means an orphan track
223 // The default ESD constructor
226 for (i=0; i<AliPID::kSPECIES; i++) {
236 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
237 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
238 for (i=0;i<kTRDnPlanes;i++) {
241 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
242 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
243 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
244 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
245 for (i=0;i<12;i++) {fITSModule[i]=-1;}
248 //_______________________________________________________________________
249 AliESDtrack::AliESDtrack(const AliESDtrack& track):
250 AliExternalTrackParam(track),
257 fTPCClusterMap(track.fTPCClusterMap),
258 fTPCSharedMap(track.fTPCSharedMap),
259 fFlags(track.fFlags),
261 fLabel(track.fLabel),
262 fITSLabel(track.fITSLabel),
263 fTPCLabel(track.fTPCLabel),
264 fTRDLabel(track.fTRDLabel),
265 fTOFCalChannel(track.fTOFCalChannel),
266 fTOFindex(track.fTOFindex),
267 fHMPIDqn(track.fHMPIDqn),
268 fHMPIDcluIdx(track.fHMPIDcluIdx),
269 fEMCALindex(track.fEMCALindex),
270 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
271 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
272 fHMPIDsignal(track.fHMPIDsignal),
273 fTrackLength(track.fTrackLength),
274 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
275 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
276 fCchi2TPC(track.fCchi2TPC),
277 fD(track.fD),fZ(track.fZ),
278 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
279 fCchi2(track.fCchi2),
280 fITSchi2(track.fITSchi2),
281 fTPCchi2(track.fTPCchi2),
282 fTRDchi2(track.fTRDchi2),
283 fTOFchi2(track.fTOFchi2),
284 fHMPIDchi2(track.fHMPIDchi2),
285 fGlobalChi2(track.fGlobalChi2),
286 fITSsignal(track.fITSsignal),
287 fTPCsignal(track.fTPCsignal),
288 fTPCsignalS(track.fTPCsignalS),
289 fTRDsignal(track.fTRDsignal),
290 fTRDQuality(track.fTRDQuality),
291 fTRDBudget(track.fTRDBudget),
292 fTOFsignal(track.fTOFsignal),
293 fTOFsignalToT(track.fTOFsignalToT),
294 fTOFsignalRaw(track.fTOFsignalRaw),
295 fTOFsignalDz(track.fTOFsignalDz),
296 fTOFsignalDx(track.fTOFsignalDx),
297 fHMPIDtrkX(track.fHMPIDtrkX),
298 fHMPIDtrkY(track.fHMPIDtrkY),
299 fHMPIDmipX(track.fHMPIDmipX),
300 fHMPIDmipY(track.fHMPIDmipY),
301 fTPCncls(track.fTPCncls),
302 fTPCnclsF(track.fTPCnclsF),
303 fTPCsignalN(track.fTPCsignalN),
304 fITSncls(track.fITSncls),
305 fITSClusterMap(track.fITSClusterMap),
306 fTRDncls(track.fTRDncls),
307 fTRDncls0(track.fTRDncls0),
308 fTRDntracklets(track.fTRDntracklets),
309 fTRDnSlices(track.fTRDnSlices),
311 fVertexID(track.fVertexID)
316 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
317 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
319 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
321 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
322 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
323 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
324 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
325 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
327 for (Int_t i=0;i<kTRDnPlanes;i++) {
328 fTRDTimBin[i]=track.fTRDTimBin[i];
332 fTRDslices=new Double32_t[fTRDnSlices];
333 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
336 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
337 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
338 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
339 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
340 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
341 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
343 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
344 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
345 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
346 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
347 if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
349 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
352 //_______________________________________________________________________
353 AliESDtrack::AliESDtrack(const AliVTrack *track) :
354 AliExternalTrackParam(track),
361 fTPCClusterMap(159),//number of padrows
362 fTPCSharedMap(159),//number of padrows
373 fEMCALindex(kEMCALNoMatch),
379 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
382 fCdd(0),fCdz(0),fCzz(0),
415 fVertexID(-2) // -2 means an orphan track
418 // ESD track from AliVTrack.
419 // This is not a copy constructor !
422 if (track->InheritsFrom("AliExternalTrackParam")) {
423 AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
424 AliWarning("Calling the default constructor...");
429 // Reset all the arrays
431 for (i=0; i<AliPID::kSPECIES; i++) {
441 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
442 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
443 for (i=0;i<kTRDnPlanes;i++) {
446 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
447 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
448 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
449 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
450 for (i=0;i<12;i++) {fITSModule[i]=-1;}
453 SetID(track->GetID());
455 // Set ITS cluster map
456 fITSClusterMap=track->GetITSClusterMap();
460 if(HasPointOnITSLayer(i)) fITSncls++;
463 // Set the combined PID
464 const Double_t *pid = track->PID();
466 for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
468 // AliESD track label
469 SetLabel(track->GetLabel());
471 SetStatus(track->GetStatus());
474 //_______________________________________________________________________
475 AliESDtrack::AliESDtrack(TParticle * part) :
476 AliExternalTrackParam(),
483 fTPCClusterMap(159),//number of padrows
484 fTPCSharedMap(159),//number of padrows
495 fEMCALindex(kEMCALNoMatch),
501 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
504 fCdd(0),fCdz(0),fCzz(0),
537 fVertexID(-2) // -2 means an orphan track
540 // ESD track from TParticle
543 // Reset all the arrays
545 for (i=0; i<AliPID::kSPECIES; i++) {
555 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
556 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
557 for (i=0;i<kTRDnPlanes;i++) {
560 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
561 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
562 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
563 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
564 for (i=0;i<12;i++) {fITSModule[i]=-1;}
566 // Calculate the AliExternalTrackParam content
573 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
574 alpha = part->Phi()*180./TMath::Pi();
575 if (alpha<0) alpha+= 360.;
576 if (alpha>360) alpha -= 360.;
578 Int_t sector = (Int_t)(alpha/20.);
579 alpha = 10. + 20.*sector;
581 alpha *= TMath::Pi();
583 // Covariance matrix: no errors, the parameters are exact
584 for (i=0; i<15; i++) covar[i]=0.;
586 // Get the vertex of origin and the momentum
587 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
588 TVector3 mom(part->Px(),part->Py(),part->Pz());
590 // Rotate to the local coordinate system (TPC sector)
594 // X of the referense plane
597 Int_t pdgCode = part->GetPdgCode();
600 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
604 param[2] = TMath::Sin(mom.Phi());
605 param[3] = mom.Pz()/mom.Pt();
606 param[4] = TMath::Sign(1/mom.Pt(),charge);
608 // Set AliExternalTrackParam
609 Set(xref, alpha, param, covar);
614 switch (TMath::Abs(pdgCode)) {
640 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
641 if (indexPID < AliPID::kSPECIES) {
647 fHMPIDr[indexPID]=1.;
650 // AliESD track label
651 SetLabel(part->GetUniqueID());
655 //_______________________________________________________________________
656 AliESDtrack::~AliESDtrack(){
658 // This is destructor according Coding Conventrions
660 //printf("Delete track\n");
671 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
674 if(&source == this) return *this;
675 AliExternalTrackParam::operator=(source);
679 // we have the trackparam: assign or copy construct
680 if(fCp)*fCp = *source.fCp;
681 else fCp = new AliExternalTrackParam(*source.fCp);
684 // no track param delete the old one
690 // we have the trackparam: assign or copy construct
691 if(fIp)*fIp = *source.fIp;
692 else fIp = new AliExternalTrackParam(*source.fIp);
695 // no track param delete the old one
701 if(source.fTPCInner){
702 // we have the trackparam: assign or copy construct
703 if(fTPCInner) *fTPCInner = *source.fTPCInner;
704 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
707 // no track param delete the old one
708 if(fTPCInner)delete fTPCInner;
714 // we have the trackparam: assign or copy construct
715 if(fOp) *fOp = *source.fOp;
716 else fOp = new AliExternalTrackParam(*source.fOp);
719 // no track param delete the old one
726 // we have the trackparam: assign or copy construct
727 if(fHMPIDp) *fHMPIDp = *source.fHMPIDp;
728 else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
731 // no track param delete the old one
732 if(fHMPIDp)delete fHMPIDp;
737 // copy also the friend track
738 // use copy constructor
739 if(source.fFriendTrack){
740 // we have the trackparam: assign or copy construct
741 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
744 // no track param delete the old one
745 delete fFriendTrack; fFriendTrack= 0;
748 fTPCClusterMap = source.fTPCClusterMap;
749 fTPCSharedMap = source.fTPCSharedMap;
751 fFlags = source.fFlags;
753 fLabel = source.fLabel;
754 fITSLabel = source.fITSLabel;
755 for(int i = 0; i< 12;++i){
756 fITSModule[i] = source.fITSModule[i];
758 fTPCLabel = source.fTPCLabel;
759 fTRDLabel = source.fTRDLabel;
760 for(int i = 0; i< 3;++i){
761 fTOFLabel[i] = source.fTOFLabel[i];
763 fTOFCalChannel = source.fTOFCalChannel;
764 fTOFindex = source.fTOFindex;
765 fHMPIDqn = source.fHMPIDqn;
766 fHMPIDcluIdx = source.fHMPIDcluIdx;
767 fEMCALindex = source.fEMCALindex;
769 for(int i = 0; i< 3;++i){
770 fKinkIndexes[i] = source.fKinkIndexes[i];
771 fV0Indexes[i] = source.fV0Indexes[i];
774 for(int i = 0; i< AliPID::kSPECIES;++i){
775 fR[i] = source.fR[i];
776 fITSr[i] = source.fITSr[i];
777 fTPCr[i] = source.fTPCr[i];
778 fTRDr[i] = source.fTRDr[i];
779 fTOFr[i] = source.fTOFr[i];
780 fHMPIDr[i] = source.fHMPIDr[i];
781 fTrackTime[i] = source.fTrackTime[i];
784 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
785 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
786 fHMPIDsignal = source.fHMPIDsignal;
789 fTrackLength = source. fTrackLength;
790 fdTPC = source.fdTPC;
791 fzTPC = source.fzTPC;
792 fCddTPC = source.fCddTPC;
793 fCdzTPC = source.fCdzTPC;
794 fCzzTPC = source.fCzzTPC;
795 fCchi2TPC = source.fCchi2TPC;
802 fCchi2 = source.fCchi2;
804 fITSchi2 = source.fITSchi2;
805 fTPCchi2 = source.fTPCchi2;
806 fTRDchi2 = source.fTRDchi2;
807 fTOFchi2 = source.fTOFchi2;
808 fHMPIDchi2 = source.fHMPIDchi2;
810 fGlobalChi2 = source.fGlobalChi2;
812 fITSsignal = source.fITSsignal;
813 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
814 fTPCsignal = source.fTPCsignal;
815 fTPCsignalS = source.fTPCsignalS;
816 for(int i = 0; i< 4;++i){
817 fTPCPoints[i] = source.fTPCPoints[i];
819 fTRDsignal = source.fTRDsignal;
821 for(int i = 0;i < kTRDnPlanes;++i){
822 fTRDTimBin[i] = source.fTRDTimBin[i];
828 fTRDnSlices=source.fTRDnSlices;
830 fTRDslices=new Double32_t[fTRDnSlices];
831 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
834 fTRDQuality = source.fTRDQuality;
835 fTRDBudget = source.fTRDBudget;
836 fTOFsignal = source.fTOFsignal;
837 fTOFsignalToT = source.fTOFsignalToT;
838 fTOFsignalRaw = source.fTOFsignalRaw;
839 fTOFsignalDz = source.fTOFsignalDz;
840 fTOFsignalDx = source.fTOFsignalDx;
842 for(int i = 0;i<10;++i){
843 fTOFInfo[i] = source.fTOFInfo[i];
846 fHMPIDtrkX = source.fHMPIDtrkX;
847 fHMPIDtrkY = source.fHMPIDtrkY;
848 fHMPIDmipX = source.fHMPIDmipX;
849 fHMPIDmipY = source.fHMPIDmipY;
851 fTPCncls = source.fTPCncls;
852 fTPCnclsF = source.fTPCnclsF;
853 fTPCsignalN = source.fTPCsignalN;
855 fITSncls = source.fITSncls;
856 fITSClusterMap = source.fITSClusterMap;
857 fTRDncls = source.fTRDncls;
858 fTRDncls0 = source.fTRDncls0;
859 fTRDntracklets = source.fTRDntracklets;
860 fVertexID = source.fVertexID;
866 void AliESDtrack::Copy(TObject &obj) const {
868 // this overwrites the virtual TOBject::Copy()
869 // to allow run time copying without casting
872 if(this==&obj)return;
873 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
874 if(!robj)return; // not an AliESDtrack
881 void AliESDtrack::AddCalibObject(TObject * object){
883 // add calib object to the list
885 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
886 fFriendTrack->AddCalibObject(object);
889 TObject * AliESDtrack::GetCalibObject(Int_t index){
891 // return calib objct at given position
893 if (!fFriendTrack) return 0;
894 return fFriendTrack->GetCalibObject(index);
898 Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
900 // Fills the information of the TPC-only first reconstruction pass
901 // into the passed ESDtrack object. For consistency fTPCInner is also filled
906 // For data produced before r26675
907 // RelateToVertexTPC was not properly called during reco
908 // so you'll have to call it again, before FillTPCOnlyTrack
909 // Float_t p[2],cov[3];
910 // track->GetImpactParametersTPC(p,cov);
911 // if(p[0]==0&&p[1]==0) // <- Default values
912 // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
915 if(!fTPCInner)return kFALSE;
917 // fill the TPC track params to the global track parameters
918 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
921 track.fCdd = fCddTPC;
922 track.fCdz = fCdzTPC;
923 track.fCzz = fCzzTPC;
925 // copy the TPCinner parameters
926 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
927 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
930 track.fCddTPC = fCddTPC;
931 track.fCdzTPC = fCdzTPC;
932 track.fCzzTPC = fCzzTPC;
933 track.fCchi2TPC = fCchi2TPC;
936 // copy all other TPC specific parameters
938 // replace label by TPC label
939 track.fLabel = fTPCLabel;
940 track.fTPCLabel = fTPCLabel;
942 track.fTPCchi2 = fTPCchi2;
943 track.fTPCsignal = fTPCsignal;
944 track.fTPCsignalS = fTPCsignalS;
945 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
947 track.fTPCncls = fTPCncls;
948 track.fTPCnclsF = fTPCnclsF;
949 track.fTPCsignalN = fTPCsignalN;
952 for(int i=0;i<AliPID::kSPECIES;++i){
953 track.fTPCr[i] = fTPCr[i];
954 // combined PID is TPC only!
955 track.fR[i] = fTPCr[i];
957 track.fTPCClusterMap = fTPCClusterMap;
958 track.fTPCSharedMap = fTPCSharedMap;
962 track.fFlags = kTPCin;
965 track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
967 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
973 //_______________________________________________________________________
974 void AliESDtrack::MakeMiniESDtrack(){
975 // Resets everything except
976 // fFlags: Reconstruction status flags
977 // fLabel: Track label
978 // fID: Unique ID of the track
979 // Impact parameter information
980 // fR[AliPID::kSPECIES]: combined "detector response probability"
981 // Running track parameters in the base class (AliExternalTrackParam)
985 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
987 // Reset track parameters constrained to the primary vertex
990 // Reset track parameters at the inner wall of TPC
992 delete fTPCInner;fTPCInner=0;
993 // Reset track parameters at the inner wall of the TRD
995 // Reset track parameters at the HMPID
996 delete fHMPIDp;fHMPIDp = 0;
999 // Reset ITS track related information
1004 for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
1005 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
1008 // Reset TPC related track information
1017 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
1019 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1020 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1021 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1023 // Reset TRD related track information
1028 for (Int_t i=0;i<kTRDnPlanes;i++) {
1031 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1036 delete[] fTRDslices;
1041 // Reset TOF related track information
1050 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
1051 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
1052 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1054 // Reset HMPID related track information
1059 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
1066 fEMCALindex = kEMCALNoMatch;
1068 // reset global track chi2
1071 fVertexID = -2; // an orphan track
1073 delete fFriendTrack; fFriendTrack = 0;
1075 //_______________________________________________________________________
1076 Double_t AliESDtrack::GetMass() const {
1077 // Returns the mass of the most probable particle type
1080 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
1081 if (fR[i]>max) {k=i; max=fR[i];}
1083 if (k==0) { // dE/dx "crossing points" in the TPC
1085 if ((p>0.38)&&(p<0.48))
1086 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
1087 if ((p>0.75)&&(p<0.85))
1088 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
1091 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
1092 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
1093 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
1094 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
1095 AliWarning("Undefined mass !");
1096 return AliPID::ParticleMass(AliPID::kPion);
1099 //______________________________________________________________________________
1100 Double_t AliESDtrack::E() const
1102 // Returns the energy of the particle given its assumed mass.
1103 // Assumes the pion mass if the particle can't be identified properly.
1107 return TMath::Sqrt(p*p + m*m);
1110 //______________________________________________________________________________
1111 Double_t AliESDtrack::Y() const
1113 // Returns the rapidity of a particle given its assumed mass.
1114 // Assumes the pion mass if the particle can't be identified properly.
1118 if (e != TMath::Abs(pz)) { // energy was not equal to pz
1119 return 0.5*TMath::Log((e+pz)/(e-pz));
1120 } else { // energy was equal to pz
1125 //_______________________________________________________________________
1126 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
1128 // This function updates track's running parameters
1134 fLabel=t->GetLabel();
1136 if (t->IsStartedTimeIntegral()) {
1138 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
1139 SetIntegratedLength(t->GetIntegratedLength());
1142 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1143 if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1144 if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
1145 if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
1149 case kITSin: case kITSout: case kITSrefit:
1151 fITSncls=t->GetNumberOfClusters();
1152 index=fFriendTrack->GetITSindices();
1153 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
1154 index[i]=t->GetClusterIndex(i);
1156 Int_t l=(index[i] & 0xf0000000) >> 28;
1157 SETBIT(fITSClusterMap,l);
1160 fITSchi2=t->GetChi2();
1161 fITSsignal=t->GetPIDsignal();
1162 fITSLabel = t->GetLabel();
1163 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1164 if (flags==kITSout) {
1165 if (!fOp) fOp=new AliExternalTrackParam(*t);
1167 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1171 case kTPCin: case kTPCrefit:
1172 fTPCLabel = t->GetLabel();
1173 if (flags==kTPCin) fTPCInner=new AliExternalTrackParam(*t);
1174 if (!fIp) fIp=new AliExternalTrackParam(*t);
1176 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1178 index=fFriendTrack->GetTPCindices();
1179 if (flags & kTPCout){
1180 if (!fOp) fOp=new AliExternalTrackParam(*t);
1182 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1184 fTPCncls=t->GetNumberOfClusters();
1185 fTPCchi2=t->GetChi2();
1187 {//prevrow must be declared in separate namespace, otherwise compiler cries:
1188 //"jump to case label crosses initialization of `Int_t prevrow'"
1190 // for (Int_t i=0;i<fTPCncls;i++)
1191 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1193 index[i]=t->GetClusterIndex(i);
1194 Int_t idx = index[i];
1196 if (idx<0) continue;
1198 // Piotr's Cluster Map for HBT
1199 // ### please change accordingly if cluster array is changing
1200 // to "New TPC Tracking" style (with gaps in array)
1201 Int_t sect = (idx&0xff000000)>>24;
1202 Int_t row = (idx&0x00ff0000)>>16;
1203 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
1205 fTPCClusterMap.SetBitNumber(row,kTRUE);
1207 //Fill the gap between previous row and this row with 0 bits
1208 //In case ### pleas change it as well - just set bit 0 in case there
1209 //is no associated clusters for current "i"
1212 prevrow = row;//if previous bit was not assigned yet == this is the first one
1215 { //we don't know the order (inner to outer or reverse)
1216 //just to be save in case it is going to change
1229 for (Int_t j = n+1; j < m; j++)
1231 fTPCClusterMap.SetBitNumber(j,kFALSE);
1235 // End Of Piotr's Cluster Map for HBT
1238 fTPCsignal=t->GetPIDsignal();
1241 case kTRDin: case kTRDrefit:
1244 index = fFriendTrack->GetTRDindices();
1245 fTRDLabel = t->GetLabel();
1246 fTRDchi2 = t->GetChi2();
1247 fTRDncls = t->GetNumberOfClusters();
1248 for (Int_t i=0;i<6;i++) index[i]=t->GetTrackletIndex(i);
1250 fTRDsignal=t->GetPIDsignal();
1253 if (!fOp) fOp=new AliExternalTrackParam(*t);
1255 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1256 fTRDncls0 = t->GetNumberOfClusters();
1265 if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1267 fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1270 AliError("Wrong flag !");
1277 //_______________________________________________________________________
1278 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1279 //---------------------------------------------------------------------
1280 // This function returns external representation of the track parameters
1281 //---------------------------------------------------------------------
1283 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1286 //_______________________________________________________________________
1287 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1288 //---------------------------------------------------------------------
1289 // This function returns external representation of the cov. matrix
1290 //---------------------------------------------------------------------
1291 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1294 //_______________________________________________________________________
1295 Bool_t AliESDtrack::GetConstrainedExternalParameters
1296 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1297 //---------------------------------------------------------------------
1298 // This function returns the constrained external track parameters
1299 //---------------------------------------------------------------------
1300 if (!fCp) return kFALSE;
1301 alpha=fCp->GetAlpha();
1303 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1307 //_______________________________________________________________________
1309 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1310 //---------------------------------------------------------------------
1311 // This function returns the constrained external cov. matrix
1312 //---------------------------------------------------------------------
1313 if (!fCp) return kFALSE;
1314 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1319 AliESDtrack::GetInnerExternalParameters
1320 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1321 //---------------------------------------------------------------------
1322 // This function returns external representation of the track parameters
1323 // at the inner layer of TPC
1324 //---------------------------------------------------------------------
1325 if (!fIp) return kFALSE;
1326 alpha=fIp->GetAlpha();
1328 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1333 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1334 //---------------------------------------------------------------------
1335 // This function returns external representation of the cov. matrix
1336 // at the inner layer of TPC
1337 //---------------------------------------------------------------------
1338 if (!fIp) return kFALSE;
1339 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1344 AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1346 // This is a direct setter for the outer track parameters
1349 if (fOp) delete fOp;
1350 fOp=new AliExternalTrackParam(*p);
1354 AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1356 // This is a direct setter for the outer track parameters
1359 if (fHMPIDp) delete fHMPIDp;
1360 fHMPIDp=new AliExternalTrackParam(*p);
1364 AliESDtrack::GetOuterExternalParameters
1365 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1366 //---------------------------------------------------------------------
1367 // This function returns external representation of the track parameters
1368 // at the inner layer of TRD
1369 //---------------------------------------------------------------------
1370 if (!fOp) return kFALSE;
1371 alpha=fOp->GetAlpha();
1373 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1378 AliESDtrack::GetOuterHmpExternalParameters
1379 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1380 //---------------------------------------------------------------------
1381 // This function returns external representation of the track parameters
1382 // at the inner layer of TRD
1383 //---------------------------------------------------------------------
1384 if (!fHMPIDp) return kFALSE;
1385 alpha=fHMPIDp->GetAlpha();
1387 for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1392 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1393 //---------------------------------------------------------------------
1394 // This function returns external representation of the cov. matrix
1395 // at the inner layer of TRD
1396 //---------------------------------------------------------------------
1397 if (!fOp) return kFALSE;
1398 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1403 AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1404 //---------------------------------------------------------------------
1405 // This function returns external representation of the cov. matrix
1406 // at the inner layer of TRD
1407 //---------------------------------------------------------------------
1408 if (!fHMPIDp) return kFALSE;
1409 for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1413 Int_t AliESDtrack::GetNcls(Int_t idet) const
1415 // Get number of clusters by subdetector index
1429 if (fTOFindex != -1)
1435 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1436 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1447 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1449 // Get cluster index array by subdetector index
1454 ncls = GetITSclusters(idx);
1457 ncls = GetTPCclusters(idx);
1460 ncls = GetTRDclusters(idx);
1463 if (fTOFindex != -1) {
1471 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1472 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1473 idx[0] = GetHMPIDcluIdx();
1486 //_______________________________________________________________________
1487 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1488 // Returns the array with integrated times for each particle hypothesis
1489 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1492 //_______________________________________________________________________
1493 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1494 // Sets the array with integrated times for each particle hypotesis
1495 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1498 //_______________________________________________________________________
1499 void AliESDtrack::SetITSpid(const Double_t *p) {
1500 // Sets values for the probability of each particle type (in ITS)
1501 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1502 SetStatus(AliESDtrack::kITSpid);
1505 //_______________________________________________________________________
1506 void AliESDtrack::GetITSpid(Double_t *p) const {
1507 // Gets the probability of each particle type (in ITS)
1508 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1511 //_______________________________________________________________________
1512 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1513 //---------------------------------------------------------------------
1514 // This function returns indices of the assgined ITS clusters
1515 //---------------------------------------------------------------------
1517 Int_t *index=fFriendTrack->GetITSindices();
1518 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1519 if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1520 else idx[i]=index[i];
1526 //_______________________________________________________________________
1527 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1528 Float_t &xloc,Float_t &zloc) const {
1529 //----------------------------------------------------------------------
1530 // This function encodes in the module number also the status of cluster association
1531 // "status" can have the following values:
1532 // 1 "found" (cluster is associated),
1533 // 2 "dead" (module is dead from OCDB),
1534 // 3 "skipped" (module or layer forced to be skipped),
1535 // 4 "outinz" (track out of z acceptance),
1536 // 5 "nocls" (no clusters in the road),
1537 // 6 "norefit" (cluster rejected during refit),
1538 // 7 "deadzspd" (holes in z in SPD)
1539 // Also given are the coordinates of the crossing point of track and module
1540 // (in the local module ref. system)
1541 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1542 //----------------------------------------------------------------------
1544 if(fITSModule[ilayer]==-1) {
1547 xloc=-99.; zloc=-99.;
1551 Int_t module = fITSModule[ilayer];
1553 idet = Int_t(module/1000000);
1555 module -= idet*1000000;
1557 status = Int_t(module/100000);
1559 module -= status*100000;
1561 Int_t signs = Int_t(module/10000);
1563 module-=signs*10000;
1565 Int_t xInt = Int_t(module/100);
1568 Int_t zInt = module;
1570 if(signs==1) { xInt*=1; zInt*=1; }
1571 if(signs==2) { xInt*=1; zInt*=-1; }
1572 if(signs==3) { xInt*=-1; zInt*=1; }
1573 if(signs==4) { xInt*=-1; zInt*=-1; }
1575 xloc = 0.1*(Float_t)xInt;
1576 zloc = 0.1*(Float_t)zInt;
1578 if(status==4) idet = -1;
1583 //_______________________________________________________________________
1584 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1585 //---------------------------------------------------------------------
1586 // This function returns indices of the assgined ITS clusters
1587 //---------------------------------------------------------------------
1589 Int_t *index=fFriendTrack->GetTPCindices();
1590 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1595 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1597 // GetDensity of the clusters on given region between row0 and row1
1598 // Dead zone effect takin into acoount
1603 Int_t *index=fFriendTrack->GetTPCindices();
1604 for (Int_t i=row0;i<=row1;i++){
1605 Int_t idx = index[i];
1606 if (idx!=-1) good++; // track outside of dead zone
1609 Float_t density=0.5;
1610 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1614 //_______________________________________________________________________
1615 void AliESDtrack::SetTPCpid(const Double_t *p) {
1616 // Sets values for the probability of each particle type (in TPC)
1617 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1618 SetStatus(AliESDtrack::kTPCpid);
1621 //_______________________________________________________________________
1622 void AliESDtrack::GetTPCpid(Double_t *p) const {
1623 // Gets the probability of each particle type (in TPC)
1624 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1627 //_______________________________________________________________________
1628 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1629 //---------------------------------------------------------------------
1630 // This function returns indices of the assgined TRD clusters
1631 //---------------------------------------------------------------------
1633 Int_t *index=fFriendTrack->GetTRDindices();
1634 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1639 //_______________________________________________________________________
1640 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1641 //---------------------------------------------------------------------
1642 // This function returns indices of the assigned TRD tracklets
1643 //---------------------------------------------------------------------
1645 Int_t *index=fFriendTrack->GetTRDindices();
1646 for (Int_t i=0; i<6/*AliESDfriendTrack::kMaxTRDcluster*/; i++) idx[i]=index[i];
1651 //_______________________________________________________________________
1652 void AliESDtrack::SetTRDpid(const Double_t *p) {
1653 // Sets values for the probability of each particle type (in TRD)
1654 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1655 SetStatus(AliESDtrack::kTRDpid);
1658 //_______________________________________________________________________
1659 void AliESDtrack::GetTRDpid(Double_t *p) const {
1660 // Gets the probability of each particle type (in TRD)
1661 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1664 //_______________________________________________________________________
1665 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1667 // Sets the probability of particle type iSpecies to p (in TRD)
1668 fTRDr[iSpecies] = p;
1671 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1673 // Returns the probability of particle type iSpecies (in TRD)
1674 return fTRDr[iSpecies];
1677 //____________________________________________________
1678 Int_t AliESDtrack::GetNumberOfTRDslices() const
1680 // built in backward compatibility
1681 Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
1682 return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
1685 //____________________________________________________
1686 Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
1688 //Returns momentum estimation and optional its error (sp)
1689 // in TRD layer "plane".
1692 AliError("No TRD info allocated for this track !");
1695 if ((plane<0) || (plane>=kTRDnPlanes)) {
1696 AliError("Info for TRD plane not available!");
1700 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1701 // Protection for backward compatibility
1702 if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
1704 if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
1705 return fTRDslices[idx];
1708 //____________________________________________________
1709 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1710 //Gets the charge from the slice of the plane
1713 //AliError("No TRD slices allocated for this track !");
1716 if ((plane<0) || (plane>=kTRDnPlanes)) {
1717 AliError("Info for TRD plane not available !");
1720 Int_t ns=GetNumberOfTRDslices();
1721 if ((slice<-1) || (slice>=ns)) {
1722 //AliError("Wrong TRD slice !");
1726 if(slice>=0) return fTRDslices[plane*ns + slice];
1728 // return average of the dEdx measurements
1729 Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
1730 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
1734 //____________________________________________________
1735 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1736 //Sets the number of slices used for PID
1737 if (fTRDnSlices) return;
1740 fTRDslices=new Double32_t[fTRDnSlices];
1742 // set-up correctly the allocated memory
1743 memset(fTRDslices, 0, n*sizeof(Double32_t));
1744 for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
1747 //____________________________________________________
1748 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1749 //Sets the charge q in the slice of the plane
1751 AliError("No TRD slices allocated for this track !");
1754 if ((plane<0) || (plane>=kTRDnPlanes)) {
1755 AliError("Info for TRD plane not allocated !");
1758 Int_t ns=GetNumberOfTRDslices();
1759 if ((slice<0) || (slice>=ns)) {
1760 AliError("Wrong TRD slice !");
1763 Int_t n=plane*ns + slice;
1768 //____________________________________________________
1769 void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
1772 AliError("No TRD slices allocated for this track !");
1775 if ((plane<0) || (plane>=kTRDnPlanes)) {
1776 AliError("Info for TRD plane not allocated !");
1780 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1781 // Protection for backward compatibility
1782 if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
1784 if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
1785 fTRDslices[idx] = p;
1789 //_______________________________________________________________________
1790 void AliESDtrack::SetTOFpid(const Double_t *p) {
1791 // Sets the probability of each particle type (in TOF)
1792 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
1793 SetStatus(AliESDtrack::kTOFpid);
1796 //_______________________________________________________________________
1797 void AliESDtrack::SetTOFLabel(const Int_t *p) {
1799 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1802 //_______________________________________________________________________
1803 void AliESDtrack::GetTOFpid(Double_t *p) const {
1804 // Gets probabilities of each particle type (in TOF)
1805 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
1808 //_______________________________________________________________________
1809 void AliESDtrack::GetTOFLabel(Int_t *p) const {
1811 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
1814 //_______________________________________________________________________
1815 void AliESDtrack::GetTOFInfo(Float_t *info) const {
1817 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
1820 //_______________________________________________________________________
1821 void AliESDtrack::SetTOFInfo(Float_t*info) {
1823 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
1828 //_______________________________________________________________________
1829 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
1830 // Sets the probability of each particle type (in HMPID)
1831 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
1832 SetStatus(AliESDtrack::kHMPIDpid);
1835 //_______________________________________________________________________
1836 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
1837 // Gets probabilities of each particle type (in HMPID)
1838 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
1843 //_______________________________________________________________________
1844 void AliESDtrack::SetESDpid(const Double_t *p) {
1845 // Sets the probability of each particle type for the ESD track
1846 SetPIDValues(fR,p,AliPID::kSPECIES);
1847 SetStatus(AliESDtrack::kESDpid);
1850 //_______________________________________________________________________
1851 void AliESDtrack::GetESDpid(Double_t *p) const {
1852 // Gets probability of each particle type for the ESD track
1853 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
1856 //_______________________________________________________________________
1857 Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
1858 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
1860 // Try to relate the TPC-only track parameters to the vertex "vtx",
1861 // if the (rough) transverse impact parameter is not bigger then "maxd".
1862 // Magnetic field is "b" (kG).
1864 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
1865 // b) The impact parameters and their covariance matrix are calculated.
1866 // c) An attempt to constrain the TPC-only params to the vertex is done.
1867 // The constrained params are returned via "cParam".
1869 // In the case of success, the returned value is kTRUE
1870 // otherwise, it's kFALSE)
1873 if (!fTPCInner) return kFALSE;
1874 if (!vtx) return kFALSE;
1876 Double_t dz[2],cov[3];
1877 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1885 Double_t covar[6]; vtx->GetCovMatrix(covar);
1886 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1887 Double_t c[3]={covar[2],0.,covar[5]};
1889 Double_t chi2=GetPredictedChi2(p,c);
1890 if (chi2>kVeryBig) return kFALSE;
1894 if (!cParam) return kTRUE;
1896 *cParam = *fTPCInner;
1897 if (!cParam->Update(p,c)) return kFALSE;
1902 //_______________________________________________________________________
1903 Bool_t AliESDtrack::RelateToVertexTPCBxByBz(const AliESDVertex *vtx,
1904 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
1906 // Try to relate the TPC-only track parameters to the vertex "vtx",
1907 // if the (rough) transverse impact parameter is not bigger then "maxd".
1909 // All three components of the magnetic field ,"b[3]" (kG),
1910 // are taken into account.
1912 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
1913 // b) The impact parameters and their covariance matrix are calculated.
1914 // c) An attempt to constrain the TPC-only params to the vertex is done.
1915 // The constrained params are returned via "cParam".
1917 // In the case of success, the returned value is kTRUE
1918 // otherwise, it's kFALSE)
1921 if (!fTPCInner) return kFALSE;
1922 if (!vtx) return kFALSE;
1924 Double_t dz[2],cov[3];
1925 if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
1933 Double_t covar[6]; vtx->GetCovMatrix(covar);
1934 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1935 Double_t c[3]={covar[2],0.,covar[5]};
1937 Double_t chi2=GetPredictedChi2(p,c);
1938 if (chi2>kVeryBig) return kFALSE;
1942 if (!cParam) return kTRUE;
1944 *cParam = *fTPCInner;
1945 if (!cParam->Update(p,c)) return kFALSE;
1950 //_______________________________________________________________________
1951 Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
1952 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
1954 // Try to relate this track to the vertex "vtx",
1955 // if the (rough) transverse impact parameter is not bigger then "maxd".
1956 // Magnetic field is "b" (kG).
1958 // a) The track gets extapolated to the DCA to the vertex.
1959 // b) The impact parameters and their covariance matrix are calculated.
1960 // c) An attempt to constrain this track to the vertex is done.
1961 // The constrained params are returned via "cParam".
1963 // In the case of success, the returned value is kTRUE
1964 // (otherwise, it's kFALSE)
1967 if (!vtx) return kFALSE;
1969 Double_t dz[2],cov[3];
1970 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1978 Double_t covar[6]; vtx->GetCovMatrix(covar);
1979 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1980 Double_t c[3]={covar[2],0.,covar[5]};
1982 Double_t chi2=GetPredictedChi2(p,c);
1983 if (chi2>kVeryBig) return kFALSE;
1988 //--- Could now these lines be removed ? ---
1990 fCp=new AliExternalTrackParam(*this);
1992 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
1993 //----------------------------------------
1995 fVertexID = vtx->GetID();
1997 if (!cParam) return kTRUE;
2000 if (!cParam->Update(p,c)) return kFALSE;
2005 //_______________________________________________________________________
2006 Bool_t AliESDtrack::RelateToVertexBxByBz(const AliESDVertex *vtx,
2007 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2009 // Try to relate this track to the vertex "vtx",
2010 // if the (rough) transverse impact parameter is not bigger then "maxd".
2011 // Magnetic field is "b" (kG).
2013 // a) The track gets extapolated to the DCA to the vertex.
2014 // b) The impact parameters and their covariance matrix are calculated.
2015 // c) An attempt to constrain this track to the vertex is done.
2016 // The constrained params are returned via "cParam".
2018 // In the case of success, the returned value is kTRUE
2019 // (otherwise, it's kFALSE)
2022 if (!vtx) return kFALSE;
2024 Double_t dz[2],cov[3];
2025 if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2033 Double_t covar[6]; vtx->GetCovMatrix(covar);
2034 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2035 Double_t c[3]={covar[2],0.,covar[5]};
2037 Double_t chi2=GetPredictedChi2(p,c);
2038 if (chi2>kVeryBig) return kFALSE;
2043 //--- Could now these lines be removed ? ---
2045 fCp=new AliExternalTrackParam(*this);
2047 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2048 //----------------------------------------
2050 fVertexID = vtx->GetID();
2052 if (!cParam) return kTRUE;
2055 if (!cParam->Update(p,c)) return kFALSE;
2060 //_______________________________________________________________________
2061 void AliESDtrack::Print(Option_t *) const {
2062 // Prints info on the track
2063 AliExternalTrackParam::Print();
2064 printf("ESD track info\n") ;
2065 Double_t p[AliPID::kSPECIESN] ;
2067 if( IsOn(kITSpid) ){
2068 printf("From ITS: ") ;
2070 for(index = 0 ; index < AliPID::kSPECIES; index++)
2071 printf("%f, ", p[index]) ;
2072 printf("\n signal = %f\n", GetITSsignal()) ;
2074 if( IsOn(kTPCpid) ){
2075 printf("From TPC: ") ;
2077 for(index = 0 ; index < AliPID::kSPECIES; index++)
2078 printf("%f, ", p[index]) ;
2079 printf("\n signal = %f\n", GetTPCsignal()) ;
2081 if( IsOn(kTRDpid) ){
2082 printf("From TRD: ") ;
2084 for(index = 0 ; index < AliPID::kSPECIES; index++)
2085 printf("%f, ", p[index]) ;
2086 printf("\n signal = %f\n", GetTRDsignal()) ;
2088 if( IsOn(kTOFpid) ){
2089 printf("From TOF: ") ;
2091 for(index = 0 ; index < AliPID::kSPECIES; index++)
2092 printf("%f, ", p[index]) ;
2093 printf("\n signal = %f\n", GetTOFsignal()) ;
2095 if( IsOn(kHMPIDpid) ){
2096 printf("From HMPID: ") ;
2098 for(index = 0 ; index < AliPID::kSPECIES; index++)
2099 printf("%f, ", p[index]) ;
2100 printf("\n signal = %f\n", GetHMPIDsignal()) ;
2106 // Draw functionality
2107 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
2109 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
2111 // Fill points in the polymarker
2114 arrayRef.AddLast(new AliExternalTrackParam(*this));
2115 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
2116 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
2117 if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
2119 Double_t mpos[3]={0,0,0};
2120 Int_t entries=arrayRef.GetEntries();
2121 for (Int_t i=0;i<entries;i++){
2123 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
2124 mpos[0]+=pos[0]/entries;
2125 mpos[1]+=pos[1]/entries;
2126 mpos[2]+=pos[2]/entries;
2128 // Rotate to the mean position
2130 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
2131 for (Int_t i=0;i<entries;i++){
2132 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
2133 if (!res) delete arrayRef.RemoveAt(i);
2136 for (Double_t r=minR; r<maxR; r+=stepR){
2138 Double_t mlpos[3]={0,0,0};
2139 for (Int_t i=0;i<entries;i++){
2140 Double_t point[3]={0,0,0};
2141 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
2142 if (!param) continue;
2143 if (param->GetXYZAt(r,magF,point)){
2144 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
2146 mlpos[0]+=point[0]*weight;
2147 mlpos[1]+=point[1]*weight;
2148 mlpos[2]+=point[2]*weight;
2155 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
2156 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
2162 //_______________________________________________________________________
2163 void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
2165 // Store the dE/dx samples measured by the two SSD and two SDD layers.
2166 // These samples are corrected for the track segment length.
2168 for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
2171 //_______________________________________________________________________
2172 void AliESDtrack::GetITSdEdxSamples(Double_t *s) const {
2174 // Get the dE/dx samples measured by the two SSD and two SDD layers.
2175 // These samples are corrected for the track segment length.
2177 for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];