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
21 //-----------------------------------------------------------------
24 #include <TParticle.h>
26 #include "AliESDVertex.h"
27 #include "AliESDtrack.h"
28 #include "AliKalmanTrack.h"
30 #include "AliTrackPointArray.h"
34 void SetPIDValues(Float_t * dest, const Double_t * src, Int_t n) {
35 // This function copies "n" PID weights from "scr" to "dest"
36 // and normalizes their sum to 1 thus producing conditional probabilities.
37 // The negative weights are set to 0.
38 // In case all the weights are non-positive they are replaced by
39 // uniform probabilities
43 Float_t uniform = 1./(Float_t)n;
46 for (Int_t i=0; i<n; i++)
56 for (Int_t i=0; i<n; i++) dest[i] /= sum;
58 for (Int_t i=0; i<n; i++) dest[i] = uniform;
61 //_______________________________________________________________________
62 AliESDtrack::AliESDtrack() :
63 AliExternalTrackParam(),
69 fCdd(0),fCdz(0),fCzz(0),
83 fTPCClusterMap(159),//number of padrows
84 fTPCSharedMap(159),//number of padrows
113 fEMCALindex(kEMCALNoMatch),
114 fFriendTrack(new AliESDfriendTrack())
117 // The default ESD constructor
120 for (i=0; i<AliPID::kSPECIES; i++) {
130 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
131 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
132 for (i=0;i<kNPlane;i++) {
133 for (j=0;j<kNSlice;j++) {
134 fTRDsignals[i][j]=0.;
138 for (i=0;i<4;i++) {fTPCPoints[i]=-1;}
139 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
140 for (i=0;i<10;i++) {fTOFInfo[i]=-1;}
143 //_______________________________________________________________________
144 AliESDtrack::AliESDtrack(const AliESDtrack& track):
145 AliExternalTrackParam(track),
146 fFlags(track.fFlags),
147 fLabel(track.fLabel),
149 fTrackLength(track.fTrackLength),
150 fD(track.fD),fZ(track.fZ),
151 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
152 fStopVertex(track.fStopVertex),
154 fCchi2(track.fCchi2),
157 fITSchi2(track.fITSchi2),
158 fITSncls(track.fITSncls),
159 fITSClusterMap(track.fITSClusterMap),
160 fITSsignal(track.fITSsignal),
161 fITSLabel(track.fITSLabel),
162 fTPCchi2(track.fTPCchi2),
163 fTPCncls(track.fTPCncls),
164 fTPCnclsF(track.fTPCnclsF),
165 fTPCClusterMap(track.fTPCClusterMap),
166 fTPCSharedMap(track.fTPCSharedMap),
167 fTPCsignal(track.fTPCsignal),
168 fTPCsignalN(track.fTPCsignalN),
169 fTPCsignalS(track.fTPCsignalS),
170 fTPCLabel(track.fTPCLabel),
171 fTRDchi2(track.fTRDchi2),
172 fTRDncls(track.fTRDncls),
173 fTRDncls0(track.fTRDncls0),
174 fTRDsignal(track.fTRDsignal),
175 fTRDLabel(track.fTRDLabel),
176 fTRDQuality(track.fTRDQuality),
177 fTRDBudget(track.fTRDBudget),
178 fTOFchi2(track.fTOFchi2),
179 fTOFindex(track.fTOFindex),
180 fTOFCalChannel(track.fTOFCalChannel),
181 fTOFsignal(track.fTOFsignal),
182 fTOFsignalToT(track.fTOFsignalToT),
183 fTOFsignalRaw(track.fTOFsignalRaw),
184 fTOFsignalDz(track.fTOFsignalDz),
185 fHMPIDchi2(track.fHMPIDchi2),
186 fHMPIDqn(track.fHMPIDqn),
187 fHMPIDcluIdx(track.fHMPIDcluIdx),
188 fHMPIDsignal(track.fHMPIDsignal),
189 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
190 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
191 fHMPIDtrkX(track.fHMPIDtrkX),
192 fHMPIDtrkY(track.fHMPIDtrkY),
193 fHMPIDmipX(track.fHMPIDmipX),
194 fHMPIDmipY(track.fHMPIDmipY),
195 fEMCALindex(track.fEMCALindex),
201 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
202 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
204 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
206 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
207 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
208 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
209 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
211 for (Int_t i=0;i<kNPlane;i++) {
212 for (Int_t j=0;j<kNSlice;j++) {
213 fTRDsignals[i][j]=track.fTRDsignals[i][j];
215 fTRDTimBin[i]=track.fTRDTimBin[i];
217 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
218 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
219 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
220 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
221 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
223 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
224 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
225 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
227 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
230 //_______________________________________________________________________
231 AliESDtrack::AliESDtrack(TParticle * part) :
232 AliExternalTrackParam(),
238 fCdd(0),fCdz(0),fCzz(0),
252 fTPCClusterMap(159),//number of padrows
253 fTPCSharedMap(159),//number of padrows
282 fEMCALindex(kEMCALNoMatch),
286 // ESD track from TParticle
289 // Reset all the arrays
291 for (i=0; i<AliPID::kSPECIES; i++) {
301 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
302 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
303 for (i=0;i<kNPlane;i++) {
304 for (j=0;j<kNSlice;j++) {
305 fTRDsignals[i][j]=0.;
309 for (i=0;i<4;i++) {fTPCPoints[i]=-1;}
310 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
311 for (i=0;i<10;i++) {fTOFInfo[i]=-1;}
313 // Calculate the AliExternalTrackParam content
320 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
321 alpha = part->Phi()*180./TMath::Pi();
322 if (alpha<0) alpha+= 360.;
323 if (alpha>360) alpha -= 360.;
325 Int_t sector = (Int_t)(alpha/20.);
326 alpha = 10. + 20.*sector;
328 alpha *= TMath::Pi();
330 // Covariance matrix: no errors, the parameters are exact
331 for (i=0; i<15; i++) covar[i]=0.;
333 // Get the vertex of origin and the momentum
334 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
335 TVector3 mom(part->Px(),part->Py(),part->Pz());
337 // Rotate to the local coordinate system (TPC sector)
341 // X of the referense plane
344 Int_t pdgCode = part->GetPdgCode();
347 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
351 param[2] = TMath::Sin(mom.Phi());
352 param[3] = mom.Pz()/mom.Pt();
353 param[4] = TMath::Sign(1/mom.Pt(),charge);
355 // Set AliExternalTrackParam
356 Set(xref, alpha, param, covar);
361 switch (TMath::Abs(pdgCode)) {
387 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
388 if (indexPID < AliPID::kSPECIES) {
394 fHMPIDr[indexPID]=1.;
397 // AliESD track label
398 SetLabel(part->GetUniqueID());
402 //_______________________________________________________________________
403 AliESDtrack::~AliESDtrack(){
405 // This is destructor according Coding Conventrions
407 //printf("Delete track\n");
414 void AliESDtrack::AddCalibObject(TObject * object){
416 // add calib object to the list
418 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
419 fFriendTrack->AddCalibObject(object);
422 TObject * AliESDtrack::GetCalibObject(Int_t index){
424 // return calib objct at given position
426 if (!fFriendTrack) return 0;
427 return fFriendTrack->GetCalibObject(index);
431 //_______________________________________________________________________
432 void AliESDtrack::MakeMiniESDtrack(){
433 // Resets everything except
434 // fFlags: Reconstruction status flags
435 // fLabel: Track label
436 // fID: Unique ID of the track
437 // fD: Impact parameter in XY-plane
438 // fZ: Impact parameter in Z
439 // fR[AliPID::kSPECIES]: combined "detector response probability"
440 // Running track parameters in the base class (AliExternalTrackParam)
443 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
446 // Reset track parameters constrained to the primary vertex
450 // Reset track parameters at the inner wall of TPC
453 // Reset track parameters at the inner wall of the TRD
456 // Reset ITS track related information
461 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
464 // Reset TPC related track information
473 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
475 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
476 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
477 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
479 // Reset TRD related track information
484 for (Int_t i=0;i<kNPlane;i++) {
485 for (Int_t j=0;j<kNSlice;j++) {
486 fTRDsignals[i][j] = 0;
490 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
495 // Reset TOF related track information
503 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
504 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
505 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
507 // Reset HMPID related track information
512 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
519 fEMCALindex = kEMCALNoMatch;
521 delete fFriendTrack; fFriendTrack = 0;
523 //_______________________________________________________________________
524 Double_t AliESDtrack::GetMass() const {
525 // Returns the mass of the most probable particle type
528 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
529 if (fR[i]>max) {k=i; max=fR[i];}
531 if (k==0) { // dE/dx "crossing points" in the TPC
533 if ((p>0.38)&&(p<0.48))
534 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
535 if ((p>0.75)&&(p<0.85))
536 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
539 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
540 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
541 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
542 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
543 AliWarning("Undefined mass !");
544 return AliPID::ParticleMass(AliPID::kPion);
547 //_______________________________________________________________________
548 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
550 // This function updates track's running parameters
556 fLabel=t->GetLabel();
558 if (t->IsStartedTimeIntegral()) {
560 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
561 SetIntegratedLength(t->GetIntegratedLength());
564 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
568 case kITSin: case kITSout: case kITSrefit:
569 fITSncls=t->GetNumberOfClusters();
570 index=fFriendTrack->GetITSindices();
571 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
572 index[i]=t->GetClusterIndex(i);
574 Int_t l=(index[i] & 0xf0000000) >> 28;
575 SETBIT(fITSClusterMap,l);
578 fITSchi2=t->GetChi2();
579 fITSsignal=t->GetPIDsignal();
580 fITSLabel = t->GetLabel();
583 case kTPCin: case kTPCrefit:
584 fTPCLabel = t->GetLabel();
585 if (!fIp) fIp=new AliExternalTrackParam(*t);
587 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
589 index=fFriendTrack->GetTPCindices();
590 if (flags & kTPCout){
591 if (!fOp) fOp=new AliExternalTrackParam(*t);
593 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
595 fTPCncls=t->GetNumberOfClusters();
596 fTPCchi2=t->GetChi2();
598 {//prevrow must be declared in separate namespace, otherwise compiler cries:
599 //"jump to case label crosses initialization of `Int_t prevrow'"
601 // for (Int_t i=0;i<fTPCncls;i++)
602 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
604 index[i]=t->GetClusterIndex(i);
605 Int_t idx = index[i];
609 // Piotr's Cluster Map for HBT
610 // ### please change accordingly if cluster array is changing
611 // to "New TPC Tracking" style (with gaps in array)
612 Int_t sect = (idx&0xff000000)>>24;
613 Int_t row = (idx&0x00ff0000)>>16;
614 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
616 fTPCClusterMap.SetBitNumber(row,kTRUE);
618 //Fill the gap between previous row and this row with 0 bits
619 //In case ### pleas change it as well - just set bit 0 in case there
620 //is no associated clusters for current "i"
623 prevrow = row;//if previous bit was not assigned yet == this is the first one
626 { //we don't know the order (inner to outer or reverse)
627 //just to be save in case it is going to change
640 for (Int_t j = n+1; j < m; j++)
642 fTPCClusterMap.SetBitNumber(j,kFALSE);
646 // End Of Piotr's Cluster Map for HBT
649 fTPCsignal=t->GetPIDsignal();
652 case kTRDout: case kTRDin: case kTRDrefit:
653 index=fFriendTrack->GetTRDindices();
654 fTRDLabel = t->GetLabel();
655 fTRDncls=t->GetNumberOfClusters();
656 fTRDchi2=t->GetChi2();
657 for (Int_t i=0;i<fTRDncls;i++) index[i]=t->GetClusterIndex(i);
658 fTRDsignal=t->GetPIDsignal();
661 if (!fOp) fOp=new AliExternalTrackParam(*t);
663 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
664 fTRDncls0 = t->GetNumberOfClusters();
673 AliError("Wrong flag !");
680 //_______________________________________________________________________
681 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
682 //---------------------------------------------------------------------
683 // This function returns external representation of the track parameters
684 //---------------------------------------------------------------------
686 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
689 //_______________________________________________________________________
690 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
691 //---------------------------------------------------------------------
692 // This function returns external representation of the cov. matrix
693 //---------------------------------------------------------------------
694 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
697 //_______________________________________________________________________
698 Bool_t AliESDtrack::GetConstrainedExternalParameters
699 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
700 //---------------------------------------------------------------------
701 // This function returns the constrained external track parameters
702 //---------------------------------------------------------------------
703 if (!fCp) return kFALSE;
704 alpha=fCp->GetAlpha();
706 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
710 //_______________________________________________________________________
712 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
713 //---------------------------------------------------------------------
714 // This function returns the constrained external cov. matrix
715 //---------------------------------------------------------------------
716 if (!fCp) return kFALSE;
717 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
722 AliESDtrack::GetInnerExternalParameters
723 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
724 //---------------------------------------------------------------------
725 // This function returns external representation of the track parameters
726 // at the inner layer of TPC
727 //---------------------------------------------------------------------
728 if (!fIp) return kFALSE;
729 alpha=fIp->GetAlpha();
731 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
736 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
737 //---------------------------------------------------------------------
738 // This function returns external representation of the cov. matrix
739 // at the inner layer of TPC
740 //---------------------------------------------------------------------
741 if (!fIp) return kFALSE;
742 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
747 AliESDtrack::GetOuterExternalParameters
748 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
749 //---------------------------------------------------------------------
750 // This function returns external representation of the track parameters
751 // at the inner layer of TRD
752 //---------------------------------------------------------------------
753 if (!fOp) return kFALSE;
754 alpha=fOp->GetAlpha();
756 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
761 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
762 //---------------------------------------------------------------------
763 // This function returns external representation of the cov. matrix
764 // at the inner layer of TRD
765 //---------------------------------------------------------------------
766 if (!fOp) return kFALSE;
767 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
771 Int_t AliESDtrack::GetNcls(Int_t idet) const
773 // Get number of clusters by subdetector index
796 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
798 // Get cluster index array by subdetector index
803 ncls = GetITSclusters(idx);
806 ncls = GetTPCclusters(idx);
809 ncls = GetTRDclusters(idx);
812 if (fTOFindex != 0) {
813 idx[0] = GetTOFcluster();
823 //_______________________________________________________________________
824 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
825 // Returns the array with integrated times for each particle hypothesis
826 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
829 //_______________________________________________________________________
830 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
831 // Sets the array with integrated times for each particle hypotesis
832 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
835 //_______________________________________________________________________
836 void AliESDtrack::SetITSpid(const Double_t *p) {
837 // Sets values for the probability of each particle type (in ITS)
838 SetPIDValues(fITSr,p,AliPID::kSPECIES);
839 SetStatus(AliESDtrack::kITSpid);
842 //_______________________________________________________________________
843 void AliESDtrack::GetITSpid(Double_t *p) const {
844 // Gets the probability of each particle type (in ITS)
845 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
848 //_______________________________________________________________________
849 Int_t AliESDtrack::GetITSclusters(Int_t *idx) const {
850 //---------------------------------------------------------------------
851 // This function returns indices of the assgined ITS clusters
852 //---------------------------------------------------------------------
854 Int_t *index=fFriendTrack->GetITSindices();
855 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) idx[i]=index[i];
860 //_______________________________________________________________________
861 Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
862 //---------------------------------------------------------------------
863 // This function returns indices of the assgined ITS clusters
864 //---------------------------------------------------------------------
866 Int_t *index=fFriendTrack->GetTPCindices();
867 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
872 Float_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
874 // GetDensity of the clusters on given region between row0 and row1
875 // Dead zone effect takin into acoount
880 Int_t *index=fFriendTrack->GetTPCindices();
881 for (Int_t i=row0;i<=row1;i++){
882 Int_t idx = index[i];
883 if (idx!=-1) good++; // track outside of dead zone
887 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
891 //_______________________________________________________________________
892 void AliESDtrack::SetTPCpid(const Double_t *p) {
893 // Sets values for the probability of each particle type (in TPC)
894 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
895 SetStatus(AliESDtrack::kTPCpid);
898 //_______________________________________________________________________
899 void AliESDtrack::GetTPCpid(Double_t *p) const {
900 // Gets the probability of each particle type (in TPC)
901 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
904 //_______________________________________________________________________
905 Int_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
906 //---------------------------------------------------------------------
907 // This function returns indices of the assgined TRD clusters
908 //---------------------------------------------------------------------
910 Int_t *index=fFriendTrack->GetTRDindices();
911 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
916 //_______________________________________________________________________
917 void AliESDtrack::SetTRDpid(const Double_t *p) {
918 // Sets values for the probability of each particle type (in TRD)
919 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
920 SetStatus(AliESDtrack::kTRDpid);
923 //_______________________________________________________________________
924 void AliESDtrack::GetTRDpid(Double_t *p) const {
925 // Gets the probability of each particle type (in TRD)
926 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
929 //_______________________________________________________________________
930 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
932 // Sets the probability of particle type iSpecies to p (in TRD)
936 Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
938 // Returns the probability of particle type iSpecies (in TRD)
939 return fTRDr[iSpecies];
942 //_______________________________________________________________________
943 void AliESDtrack::SetTOFpid(const Double_t *p) {
944 // Sets the probability of each particle type (in TOF)
945 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
946 SetStatus(AliESDtrack::kTOFpid);
949 //_______________________________________________________________________
950 void AliESDtrack::SetTOFLabel(const Int_t *p) {
952 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
955 //_______________________________________________________________________
956 void AliESDtrack::GetTOFpid(Double_t *p) const {
957 // Gets probabilities of each particle type (in TOF)
958 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
961 //_______________________________________________________________________
962 void AliESDtrack::GetTOFLabel(Int_t *p) const {
964 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
967 //_______________________________________________________________________
968 void AliESDtrack::GetTOFInfo(Float_t *info) const {
970 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
973 //_______________________________________________________________________
974 void AliESDtrack::SetTOFInfo(Float_t*info) {
976 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
981 //_______________________________________________________________________
982 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
983 // Sets the probability of each particle type (in HMPID)
984 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
985 SetStatus(AliESDtrack::kHMPIDpid);
988 //_______________________________________________________________________
989 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
990 // Gets probabilities of each particle type (in HMPID)
991 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
996 //_______________________________________________________________________
997 void AliESDtrack::SetESDpid(const Double_t *p) {
998 // Sets the probability of each particle type for the ESD track
999 SetPIDValues(fR,p,AliPID::kSPECIES);
1000 SetStatus(AliESDtrack::kESDpid);
1003 //_______________________________________________________________________
1004 void AliESDtrack::GetESDpid(Double_t *p) const {
1005 // Gets probability of each particle type for the ESD track
1006 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
1009 //_______________________________________________________________________
1010 Bool_t AliESDtrack::RelateToVertex
1011 (const AliESDVertex *vtx, Double_t b, Double_t maxd) {
1013 // Try to relate this track to the vertex "vtx",
1014 // if the (rough) transverse impact parameter is not bigger then "maxd".
1015 // Magnetic field is "b" (kG).
1017 // a) The track gets extapolated to the DCA to the vertex.
1018 // b) The impact parameters and their covariance matrix are calculated.
1019 // c) An attempt to constrain this track to the vertex is done.
1021 // In the case of success, the returned value is kTRUE
1022 // (otherwise, it's kFALSE)
1025 if (!vtx) return kFALSE;
1027 Double_t alpha=GetAlpha();
1028 Double_t sn=TMath::Sin(alpha), cs=TMath::Cos(alpha);
1029 Double_t x=GetX(), y=GetParameter()[0], snp=GetParameter()[2];
1030 Double_t xv= vtx->GetXv()*cs + vtx->GetYv()*sn;
1031 Double_t yv=-vtx->GetXv()*sn + vtx->GetYv()*cs, zv=vtx->GetZv();
1034 //Estimate the impact parameter neglecting the track curvature
1035 Double_t d=TMath::Abs(x*snp - y*TMath::Sqrt(1.- snp*snp));
1036 if (d > maxd) return kFALSE;
1038 //Propagate to the DCA
1039 Double_t crv=kB2C*b*GetParameter()[4];
1040 if (TMath::Abs(b) < kAlmost0Field) crv=0.;
1042 Double_t tgfv=-(crv*x - snp)/(crv*y + TMath::Sqrt(1.-snp*snp));
1043 sn=tgfv/TMath::Sqrt(1.+ tgfv*tgfv);
1044 if (TMath::Abs(tgfv)>0.) cs = sn/tgfv;
1048 yv=-xv*sn + yv*cs; xv=x;
1050 if (!Propagate(alpha+TMath::ASin(sn),xv,b)) return kFALSE;
1052 fD = GetParameter()[0] - yv;
1053 fZ = GetParameter()[1] - zv;
1055 Double_t cov[6]; vtx->GetCovMatrix(cov);
1057 //***** Improvements by A.Dainese
1058 alpha=GetAlpha(); sn=TMath::Sin(alpha); cs=TMath::Cos(alpha);
1059 Double_t s2ylocvtx = cov[0]*sn*sn + cov[2]*cs*cs - 2.*cov[1]*cs*sn;
1060 fCdd = GetCovariance()[0] + s2ylocvtx; // neglecting correlations
1061 fCdz = GetCovariance()[1]; // between (x,y) and z
1062 fCzz = GetCovariance()[2] + cov[5]; // in vertex's covariance matrix
1066 Double_t p[2]={yv,zv}, c[3]={cov[2],0.,cov[5]};
1067 Double_t chi2=GetPredictedChi2(p,c);
1069 if (chi2>77.) return kFALSE;
1071 AliExternalTrackParam tmp(*this);
1072 if (!tmp.Update(p,c)) return kFALSE;
1075 if (!fCp) fCp=new AliExternalTrackParam();
1076 new (fCp) AliExternalTrackParam(tmp);
1082 //_______________________________________________________________________
1083 void AliESDtrack::Print(Option_t *) const {
1084 // Prints info on the track
1086 printf("ESD track info\n") ;
1087 Double_t p[AliPID::kSPECIESN] ;
1089 if( IsOn(kITSpid) ){
1090 printf("From ITS: ") ;
1092 for(index = 0 ; index < AliPID::kSPECIES; index++)
1093 printf("%f, ", p[index]) ;
1094 printf("\n signal = %f\n", GetITSsignal()) ;
1096 if( IsOn(kTPCpid) ){
1097 printf("From TPC: ") ;
1099 for(index = 0 ; index < AliPID::kSPECIES; index++)
1100 printf("%f, ", p[index]) ;
1101 printf("\n signal = %f\n", GetTPCsignal()) ;
1103 if( IsOn(kTRDpid) ){
1104 printf("From TRD: ") ;
1106 for(index = 0 ; index < AliPID::kSPECIES; index++)
1107 printf("%f, ", p[index]) ;
1108 printf("\n signal = %f\n", GetTRDsignal()) ;
1110 if( IsOn(kTOFpid) ){
1111 printf("From TOF: ") ;
1113 for(index = 0 ; index < AliPID::kSPECIES; index++)
1114 printf("%f, ", p[index]) ;
1115 printf("\n signal = %f\n", GetTOFsignal()) ;
1117 if( IsOn(kHMPIDpid) ){
1118 printf("From HMPID: ") ;
1120 for(index = 0 ; index < AliPID::kSPECIES; index++)
1121 printf("%f, ", p[index]) ;
1122 printf("\n signal = %f\n", GetHMPIDsignal()) ;
1126 Bool_t AliESDtrack::PropagateTo(Double_t xToGo, Double_t b, Double_t mass,
1127 Double_t maxStep, Bool_t rotateTo, Double_t maxSnp){
1128 //----------------------------------------------------------------
1132 // Propagates this track to the plane X=xk (cm)
1133 // in the magnetic field "b" (kG),
1134 // the correction for the material is included
1136 // mass - mass used in propagation - used for energy loss correction
1137 // maxStep - maximal step for propagation
1138 //----------------------------------------------------------------
1139 const Double_t kEpsilon = 0.00001;
1140 Double_t xpos = GetX();
1141 Double_t dir = (xpos<xToGo) ? 1.:-1.;
1143 while ( (xToGo-xpos)*dir > kEpsilon){
1144 Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
1145 Double_t x = xpos+step;
1146 Double_t xyz0[3],xyz1[3],param[7];
1147 GetXYZ(xyz0); //starting global position
1148 if (!GetXYZAt(x,b,xyz1)) return kFALSE; // no prolongation
1149 xyz1[2]+=kEpsilon; // waiting for bug correction in geo
1150 AliKalmanTrack::MeanMaterialBudget(xyz0,xyz1,param);
1151 if (TMath::Abs(GetSnpAt(x,b)) >= maxSnp) return kFALSE;
1152 if (!AliExternalTrackParam::PropagateTo(x,b)) return kFALSE;
1154 Double_t rho=param[0],x0=param[1],distance=param[4];
1155 Double_t d=distance*rho/x0;
1157 if (!CorrectForMaterial(d,x0,mass)) return kFALSE;
1159 if (TMath::Abs(GetSnp()) >= maxSnp) return kFALSE;
1160 GetXYZ(xyz0); // global position
1161 Double_t alphan = TMath::ATan2(xyz0[1], xyz0[0]);
1163 Double_t ca=TMath::Cos(alphan-GetAlpha()),
1164 sa=TMath::Sin(alphan-GetAlpha());
1165 Double_t sf=GetSnp(), cf=TMath::Sqrt(1.- sf*sf);
1166 Double_t sinNew = sf*ca - cf*sa;
1167 if (TMath::Abs(sinNew) >= maxSnp) return kFALSE;
1168 if (!Rotate(alphan)) return kFALSE;