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
112 fEMCALindex(kEMCALNoMatch),
113 fFriendTrack(new AliESDfriendTrack())
116 // The default ESD constructor
119 for (i=0; i<AliPID::kSPECIES; i++) {
129 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
130 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
131 for (i=0;i<kNPlane;i++) {
132 for (j=0;j<kNSlice;j++) {
133 fTRDsignals[i][j]=0.;
137 for (i=0;i<4;i++) {fTPCPoints[i]=-1;}
138 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
139 for (i=0;i<10;i++) {fTOFInfo[i]=-1;}
142 //_______________________________________________________________________
143 AliESDtrack::AliESDtrack(const AliESDtrack& track):
144 AliExternalTrackParam(track),
145 fFlags(track.fFlags),
146 fLabel(track.fLabel),
148 fTrackLength(track.fTrackLength),
149 fD(track.fD),fZ(track.fZ),
150 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
151 fStopVertex(track.fStopVertex),
153 fCchi2(track.fCchi2),
156 fITSchi2(track.fITSchi2),
157 fITSncls(track.fITSncls),
158 fITSClusterMap(track.fITSClusterMap),
159 fITSsignal(track.fITSsignal),
160 fITSLabel(track.fITSLabel),
161 fTPCchi2(track.fTPCchi2),
162 fTPCncls(track.fTPCncls),
163 fTPCnclsF(track.fTPCnclsF),
164 fTPCClusterMap(track.fTPCClusterMap),
165 fTPCsignal(track.fTPCsignal),
166 fTPCsignalN(track.fTPCsignalN),
167 fTPCsignalS(track.fTPCsignalS),
168 fTPCLabel(track.fTPCLabel),
169 fTRDchi2(track.fTRDchi2),
170 fTRDncls(track.fTRDncls),
171 fTRDncls0(track.fTRDncls0),
172 fTRDsignal(track.fTRDsignal),
173 fTRDLabel(track.fTRDLabel),
174 fTRDQuality(track.fTRDQuality),
175 fTRDBudget(track.fTRDBudget),
176 fTOFchi2(track.fTOFchi2),
177 fTOFindex(track.fTOFindex),
178 fTOFCalChannel(track.fTOFCalChannel),
179 fTOFsignal(track.fTOFsignal),
180 fTOFsignalToT(track.fTOFsignalToT),
181 fTOFsignalRaw(track.fTOFsignalRaw),
182 fTOFsignalDz(track.fTOFsignalDz),
183 fHMPIDchi2(track.fHMPIDchi2),
184 fHMPIDqn(track.fHMPIDqn),
185 fHMPIDcluIdx(track.fHMPIDcluIdx),
186 fHMPIDsignal(track.fHMPIDsignal),
187 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
188 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
189 fHMPIDtrkX(track.fHMPIDtrkX),
190 fHMPIDtrkY(track.fHMPIDtrkY),
191 fHMPIDmipX(track.fHMPIDmipX),
192 fHMPIDmipY(track.fHMPIDmipY),
193 fEMCALindex(track.fEMCALindex),
199 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
200 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
202 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
204 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
205 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
206 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
207 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
209 for (Int_t i=0;i<kNPlane;i++) {
210 for (Int_t j=0;j<kNSlice;j++) {
211 fTRDsignals[i][j]=track.fTRDsignals[i][j];
213 fTRDTimBin[i]=track.fTRDTimBin[i];
215 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
216 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
217 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
218 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
219 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
221 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
222 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
223 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
225 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
228 //_______________________________________________________________________
229 AliESDtrack::AliESDtrack(TParticle * part) :
230 AliExternalTrackParam(),
236 fCdd(0),fCdz(0),fCzz(0),
250 fTPCClusterMap(159),//number of padrows
279 fEMCALindex(kEMCALNoMatch),
283 // ESD track from TParticle
286 // Reset all the arrays
288 for (i=0; i<AliPID::kSPECIES; i++) {
298 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
299 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
300 for (i=0;i<kNPlane;i++) {
301 for (j=0;j<kNSlice;j++) {
302 fTRDsignals[i][j]=0.;
306 for (i=0;i<4;i++) {fTPCPoints[i]=-1;}
307 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
308 for (i=0;i<10;i++) {fTOFInfo[i]=-1;}
310 // Calculate the AliExternalTrackParam content
317 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
318 alpha = part->Phi()*180./TMath::Pi();
319 if (alpha<0) alpha+= 360.;
320 if (alpha>360) alpha -= 360.;
322 Int_t sector = (Int_t)(alpha/20.);
323 alpha = 10. + 20.*sector;
325 alpha *= TMath::Pi();
327 // Covariance matrix: no errors, the parameters are exact
328 for (i=0; i<15; i++) covar[i]=0.;
330 // Get the vertex of origin and the momentum
331 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
332 TVector3 mom(part->Px(),part->Py(),part->Pz());
334 // Rotate to the local coordinate system (TPC sector)
338 // X of the referense plane
341 Int_t pdgCode = part->GetPdgCode();
344 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
348 param[2] = TMath::Sin(mom.Phi());
349 param[3] = mom.Pz()/mom.Pt();
350 param[4] = TMath::Sign(1/mom.Pt(),charge);
352 // Set AliExternalTrackParam
353 Set(xref, alpha, param, covar);
358 switch (TMath::Abs(pdgCode)) {
384 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
385 if (indexPID < AliPID::kSPECIES) {
391 fHMPIDr[indexPID]=1.;
394 // AliESD track label
395 SetLabel(part->GetUniqueID());
399 //_______________________________________________________________________
400 AliESDtrack::~AliESDtrack(){
402 // This is destructor according Coding Conventrions
404 //printf("Delete track\n");
411 void AliESDtrack::AddCalibObject(TObject * object){
413 // add calib object to the list
415 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
416 fFriendTrack->AddCalibObject(object);
419 TObject * AliESDtrack::GetCalibObject(Int_t index){
421 // return calib objct at given position
423 if (!fFriendTrack) return 0;
424 return fFriendTrack->GetCalibObject(index);
428 //_______________________________________________________________________
429 void AliESDtrack::MakeMiniESDtrack(){
430 // Resets everything except
431 // fFlags: Reconstruction status flags
432 // fLabel: Track label
433 // fID: Unique ID of the track
434 // fD: Impact parameter in XY-plane
435 // fZ: Impact parameter in Z
436 // fR[AliPID::kSPECIES]: combined "detector response probability"
437 // Running track parameters in the base class (AliExternalTrackParam)
440 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
443 // Reset track parameters constrained to the primary vertex
447 // Reset track parameters at the inner wall of TPC
450 // Reset track parameters at the inner wall of the TRD
453 // Reset ITS track related information
458 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
461 // Reset TPC related track information
469 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
471 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
472 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
473 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
475 // Reset TRD related track information
480 for (Int_t i=0;i<kNPlane;i++) {
481 for (Int_t j=0;j<kNSlice;j++) {
482 fTRDsignals[i][j] = 0;
486 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
491 // Reset TOF related track information
499 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
500 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
501 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
503 // Reset HMPID related track information
508 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
515 fEMCALindex = kEMCALNoMatch;
517 delete fFriendTrack; fFriendTrack = 0;
519 //_______________________________________________________________________
520 Double_t AliESDtrack::GetMass() const {
521 // Returns the mass of the most probable particle type
524 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
525 if (fR[i]>max) {k=i; max=fR[i];}
527 if (k==0) { // dE/dx "crossing points" in the TPC
529 if ((p>0.38)&&(p<0.48))
530 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
531 if ((p>0.75)&&(p<0.85))
532 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
535 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
536 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
537 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
538 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
539 AliWarning("Undefined mass !");
540 return AliPID::ParticleMass(AliPID::kPion);
543 //_______________________________________________________________________
544 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
546 // This function updates track's running parameters
552 fLabel=t->GetLabel();
554 if (t->IsStartedTimeIntegral()) {
556 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
557 SetIntegratedLength(t->GetIntegratedLength());
560 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
564 case kITSin: case kITSout: case kITSrefit:
565 fITSncls=t->GetNumberOfClusters();
566 index=fFriendTrack->GetITSindices();
567 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
568 index[i]=t->GetClusterIndex(i);
570 Int_t l=(index[i] & 0xf0000000) >> 28;
571 SETBIT(fITSClusterMap,l);
574 fITSchi2=t->GetChi2();
575 fITSsignal=t->GetPIDsignal();
576 fITSLabel = t->GetLabel();
579 case kTPCin: case kTPCrefit:
580 fTPCLabel = t->GetLabel();
581 if (!fIp) fIp=new AliExternalTrackParam(*t);
583 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
585 index=fFriendTrack->GetTPCindices();
586 if (flags & kTPCout){
587 if (!fOp) fOp=new AliExternalTrackParam(*t);
589 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
591 fTPCncls=t->GetNumberOfClusters();
592 fTPCchi2=t->GetChi2();
594 {//prevrow must be declared in separate namespace, otherwise compiler cries:
595 //"jump to case label crosses initialization of `Int_t prevrow'"
597 // for (Int_t i=0;i<fTPCncls;i++)
598 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
600 index[i]=t->GetClusterIndex(i);
601 Int_t idx = index[i];
605 // Piotr's Cluster Map for HBT
606 // ### please change accordingly if cluster array is changing
607 // to "New TPC Tracking" style (with gaps in array)
608 Int_t sect = (idx&0xff000000)>>24;
609 Int_t row = (idx&0x00ff0000)>>16;
610 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
612 fTPCClusterMap.SetBitNumber(row,kTRUE);
614 //Fill the gap between previous row and this row with 0 bits
615 //In case ### pleas change it as well - just set bit 0 in case there
616 //is no associated clusters for current "i"
619 prevrow = row;//if previous bit was not assigned yet == this is the first one
622 { //we don't know the order (inner to outer or reverse)
623 //just to be save in case it is going to change
636 for (Int_t j = n+1; j < m; j++)
638 fTPCClusterMap.SetBitNumber(j,kFALSE);
642 // End Of Piotr's Cluster Map for HBT
645 fTPCsignal=t->GetPIDsignal();
648 case kTRDout: case kTRDin: case kTRDrefit:
649 index=fFriendTrack->GetTRDindices();
650 fTRDLabel = t->GetLabel();
651 fTRDncls=t->GetNumberOfClusters();
652 fTRDchi2=t->GetChi2();
653 for (Int_t i=0;i<fTRDncls;i++) index[i]=t->GetClusterIndex(i);
654 fTRDsignal=t->GetPIDsignal();
657 if (!fOp) fOp=new AliExternalTrackParam(*t);
659 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
660 fTRDncls0 = t->GetNumberOfClusters();
669 AliError("Wrong flag !");
676 //_______________________________________________________________________
677 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
678 //---------------------------------------------------------------------
679 // This function returns external representation of the track parameters
680 //---------------------------------------------------------------------
682 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
685 //_______________________________________________________________________
686 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
687 //---------------------------------------------------------------------
688 // This function returns external representation of the cov. matrix
689 //---------------------------------------------------------------------
690 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
693 //_______________________________________________________________________
694 Bool_t AliESDtrack::GetConstrainedExternalParameters
695 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
696 //---------------------------------------------------------------------
697 // This function returns the constrained external track parameters
698 //---------------------------------------------------------------------
699 if (!fCp) return kFALSE;
700 alpha=fCp->GetAlpha();
702 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
706 //_______________________________________________________________________
708 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
709 //---------------------------------------------------------------------
710 // This function returns the constrained external cov. matrix
711 //---------------------------------------------------------------------
712 if (!fCp) return kFALSE;
713 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
718 AliESDtrack::GetInnerExternalParameters
719 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
720 //---------------------------------------------------------------------
721 // This function returns external representation of the track parameters
722 // at the inner layer of TPC
723 //---------------------------------------------------------------------
724 if (!fIp) return kFALSE;
725 alpha=fIp->GetAlpha();
727 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
732 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
733 //---------------------------------------------------------------------
734 // This function returns external representation of the cov. matrix
735 // at the inner layer of TPC
736 //---------------------------------------------------------------------
737 if (!fIp) return kFALSE;
738 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
743 AliESDtrack::GetOuterExternalParameters
744 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
745 //---------------------------------------------------------------------
746 // This function returns external representation of the track parameters
747 // at the inner layer of TRD
748 //---------------------------------------------------------------------
749 if (!fOp) return kFALSE;
750 alpha=fOp->GetAlpha();
752 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
757 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
758 //---------------------------------------------------------------------
759 // This function returns external representation of the cov. matrix
760 // at the inner layer of TRD
761 //---------------------------------------------------------------------
762 if (!fOp) return kFALSE;
763 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
767 Int_t AliESDtrack::GetNcls(Int_t idet) const
769 // Get number of clusters by subdetector index
792 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
794 // Get cluster index array by subdetector index
799 ncls = GetITSclusters(idx);
802 ncls = GetTPCclusters(idx);
805 ncls = GetTRDclusters(idx);
808 if (fTOFindex != 0) {
809 idx[0] = GetTOFcluster();
819 //_______________________________________________________________________
820 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
821 // Returns the array with integrated times for each particle hypothesis
822 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
825 //_______________________________________________________________________
826 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
827 // Sets the array with integrated times for each particle hypotesis
828 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
831 //_______________________________________________________________________
832 void AliESDtrack::SetITSpid(const Double_t *p) {
833 // Sets values for the probability of each particle type (in ITS)
834 SetPIDValues(fITSr,p,AliPID::kSPECIES);
835 SetStatus(AliESDtrack::kITSpid);
838 //_______________________________________________________________________
839 void AliESDtrack::GetITSpid(Double_t *p) const {
840 // Gets the probability of each particle type (in ITS)
841 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
844 //_______________________________________________________________________
845 Int_t AliESDtrack::GetITSclusters(Int_t *idx) const {
846 //---------------------------------------------------------------------
847 // This function returns indices of the assgined ITS clusters
848 //---------------------------------------------------------------------
850 Int_t *index=fFriendTrack->GetITSindices();
851 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) idx[i]=index[i];
856 //_______________________________________________________________________
857 Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
858 //---------------------------------------------------------------------
859 // This function returns indices of the assgined ITS clusters
860 //---------------------------------------------------------------------
862 Int_t *index=fFriendTrack->GetTPCindices();
863 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
868 Float_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
870 // GetDensity of the clusters on given region between row0 and row1
871 // Dead zone effect takin into acoount
876 Int_t *index=fFriendTrack->GetTPCindices();
877 for (Int_t i=row0;i<=row1;i++){
878 Int_t idx = index[i];
879 if (idx!=-1) good++; // track outside of dead zone
883 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
887 //_______________________________________________________________________
888 void AliESDtrack::SetTPCpid(const Double_t *p) {
889 // Sets values for the probability of each particle type (in TPC)
890 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
891 SetStatus(AliESDtrack::kTPCpid);
894 //_______________________________________________________________________
895 void AliESDtrack::GetTPCpid(Double_t *p) const {
896 // Gets the probability of each particle type (in TPC)
897 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
900 //_______________________________________________________________________
901 Int_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
902 //---------------------------------------------------------------------
903 // This function returns indices of the assgined TRD clusters
904 //---------------------------------------------------------------------
906 Int_t *index=fFriendTrack->GetTRDindices();
907 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
912 //_______________________________________________________________________
913 void AliESDtrack::SetTRDpid(const Double_t *p) {
914 // Sets values for the probability of each particle type (in TRD)
915 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
916 SetStatus(AliESDtrack::kTRDpid);
919 //_______________________________________________________________________
920 void AliESDtrack::GetTRDpid(Double_t *p) const {
921 // Gets the probability of each particle type (in TRD)
922 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
925 //_______________________________________________________________________
926 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
928 // Sets the probability of particle type iSpecies to p (in TRD)
932 Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
934 // Returns the probability of particle type iSpecies (in TRD)
935 return fTRDr[iSpecies];
938 //_______________________________________________________________________
939 void AliESDtrack::SetTOFpid(const Double_t *p) {
940 // Sets the probability of each particle type (in TOF)
941 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
942 SetStatus(AliESDtrack::kTOFpid);
945 //_______________________________________________________________________
946 void AliESDtrack::SetTOFLabel(const Int_t *p) {
948 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
951 //_______________________________________________________________________
952 void AliESDtrack::GetTOFpid(Double_t *p) const {
953 // Gets probabilities of each particle type (in TOF)
954 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
957 //_______________________________________________________________________
958 void AliESDtrack::GetTOFLabel(Int_t *p) const {
960 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
963 //_______________________________________________________________________
964 void AliESDtrack::GetTOFInfo(Float_t *info) const {
966 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
969 //_______________________________________________________________________
970 void AliESDtrack::SetTOFInfo(Float_t*info) {
972 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
977 //_______________________________________________________________________
978 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
979 // Sets the probability of each particle type (in HMPID)
980 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
981 SetStatus(AliESDtrack::kHMPIDpid);
984 //_______________________________________________________________________
985 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
986 // Gets probabilities of each particle type (in HMPID)
987 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
992 //_______________________________________________________________________
993 void AliESDtrack::SetESDpid(const Double_t *p) {
994 // Sets the probability of each particle type for the ESD track
995 SetPIDValues(fR,p,AliPID::kSPECIES);
996 SetStatus(AliESDtrack::kESDpid);
999 //_______________________________________________________________________
1000 void AliESDtrack::GetESDpid(Double_t *p) const {
1001 // Gets probability of each particle type for the ESD track
1002 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
1005 //_______________________________________________________________________
1006 Bool_t AliESDtrack::RelateToVertex
1007 (const AliESDVertex *vtx, Double_t b, Double_t maxd) {
1009 // Try to relate this track to the vertex "vtx",
1010 // if the (rough) transverse impact parameter is not bigger then "maxd".
1011 // Magnetic field is "b" (kG).
1013 // a) The track gets extapolated to the DCA to the vertex.
1014 // b) The impact parameters and their covariance matrix are calculated.
1015 // c) An attempt to constrain this track to the vertex is done.
1017 // In the case of success, the returned value is kTRUE
1018 // (otherwise, it's kFALSE)
1021 if (!vtx) return kFALSE;
1023 Double_t alpha=GetAlpha();
1024 Double_t sn=TMath::Sin(alpha), cs=TMath::Cos(alpha);
1025 Double_t x=GetX(), y=GetParameter()[0], snp=GetParameter()[2];
1026 Double_t xv= vtx->GetXv()*cs + vtx->GetYv()*sn;
1027 Double_t yv=-vtx->GetXv()*sn + vtx->GetYv()*cs, zv=vtx->GetZv();
1030 //Estimate the impact parameter neglecting the track curvature
1031 Double_t d=TMath::Abs(x*snp - y*TMath::Sqrt(1.- snp*snp));
1032 if (d > maxd) return kFALSE;
1034 //Propagate to the DCA
1035 Double_t crv=kB2C*b*GetParameter()[4];
1036 if (TMath::Abs(b) < kAlmost0Field) crv=0.;
1038 Double_t tgfv=-(crv*x - snp)/(crv*y + TMath::Sqrt(1.-snp*snp));
1039 sn=tgfv/TMath::Sqrt(1.+ tgfv*tgfv);
1040 if (TMath::Abs(tgfv)>0.) cs = sn/tgfv;
1044 yv=-xv*sn + yv*cs; xv=x;
1046 if (!Propagate(alpha+TMath::ASin(sn),xv,b)) return kFALSE;
1048 fD = GetParameter()[0] - yv;
1049 fZ = GetParameter()[1] - zv;
1051 Double_t cov[6]; vtx->GetCovMatrix(cov);
1053 //***** Improvements by A.Dainese
1054 alpha=GetAlpha(); sn=TMath::Sin(alpha); cs=TMath::Cos(alpha);
1055 Double_t s2ylocvtx = cov[0]*sn*sn + cov[2]*cs*cs - 2.*cov[1]*cs*sn;
1056 fCdd = GetCovariance()[0] + s2ylocvtx; // neglecting correlations
1057 fCdz = GetCovariance()[1]; // between (x,y) and z
1058 fCzz = GetCovariance()[2] + cov[5]; // in vertex's covariance matrix
1062 Double_t p[2]={yv,zv}, c[3]={cov[2],0.,cov[5]};
1063 Double_t chi2=GetPredictedChi2(p,c);
1065 if (chi2>77.) return kFALSE;
1067 AliExternalTrackParam tmp(*this);
1068 if (!tmp.Update(p,c)) return kFALSE;
1071 if (!fCp) fCp=new AliExternalTrackParam();
1072 new (fCp) AliExternalTrackParam(tmp);
1078 //_______________________________________________________________________
1079 void AliESDtrack::Print(Option_t *) const {
1080 // Prints info on the track
1082 printf("ESD track info\n") ;
1083 Double_t p[AliPID::kSPECIESN] ;
1085 if( IsOn(kITSpid) ){
1086 printf("From ITS: ") ;
1088 for(index = 0 ; index < AliPID::kSPECIES; index++)
1089 printf("%f, ", p[index]) ;
1090 printf("\n signal = %f\n", GetITSsignal()) ;
1092 if( IsOn(kTPCpid) ){
1093 printf("From TPC: ") ;
1095 for(index = 0 ; index < AliPID::kSPECIES; index++)
1096 printf("%f, ", p[index]) ;
1097 printf("\n signal = %f\n", GetTPCsignal()) ;
1099 if( IsOn(kTRDpid) ){
1100 printf("From TRD: ") ;
1102 for(index = 0 ; index < AliPID::kSPECIES; index++)
1103 printf("%f, ", p[index]) ;
1104 printf("\n signal = %f\n", GetTRDsignal()) ;
1106 if( IsOn(kTOFpid) ){
1107 printf("From TOF: ") ;
1109 for(index = 0 ; index < AliPID::kSPECIES; index++)
1110 printf("%f, ", p[index]) ;
1111 printf("\n signal = %f\n", GetTOFsignal()) ;
1113 if( IsOn(kHMPIDpid) ){
1114 printf("From HMPID: ") ;
1116 for(index = 0 ; index < AliPID::kSPECIES; index++)
1117 printf("%f, ", p[index]) ;
1118 printf("\n signal = %f\n", GetHMPIDsignal()) ;
1122 Bool_t AliESDtrack::PropagateTo(Double_t xToGo, Double_t b, Double_t mass,
1123 Double_t maxStep, Bool_t rotateTo, Double_t maxSnp){
1124 //----------------------------------------------------------------
1128 // Propagates this track to the plane X=xk (cm)
1129 // in the magnetic field "b" (kG),
1130 // the correction for the material is included
1132 // mass - mass used in propagation - used for energy loss correction
1133 // maxStep - maximal step for propagation
1134 //----------------------------------------------------------------
1135 const Double_t kEpsilon = 0.00001;
1136 Double_t xpos = GetX();
1137 Double_t dir = (xpos<xToGo) ? 1.:-1.;
1139 while ( (xToGo-xpos)*dir > kEpsilon){
1140 Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
1141 Double_t x = xpos+step;
1142 Double_t xyz0[3],xyz1[3],param[7];
1143 GetXYZ(xyz0); //starting global position
1144 if (!GetXYZAt(x,b,xyz1)) return kFALSE; // no prolongation
1145 xyz1[2]+=kEpsilon; // waiting for bug correction in geo
1146 AliKalmanTrack::MeanMaterialBudget(xyz0,xyz1,param);
1147 if (TMath::Abs(GetSnpAt(x,b)) >= maxSnp) return kFALSE;
1148 if (!AliExternalTrackParam::PropagateTo(x,b)) return kFALSE;
1150 Double_t rho=param[0],x0=param[1],distance=param[4];
1151 Double_t d=distance*rho/x0;
1153 if (!CorrectForMaterial(d,x0,mass)) return kFALSE;
1155 if (TMath::Abs(GetSnp()) >= maxSnp) return kFALSE;
1156 GetXYZ(xyz0); // global position
1157 Double_t alphan = TMath::ATan2(xyz0[1], xyz0[0]);
1159 Double_t ca=TMath::Cos(alphan-GetAlpha()),
1160 sa=TMath::Sin(alphan-GetAlpha());
1161 Double_t sf=GetSnp(), cf=TMath::Sqrt(1.- sf*sf);
1162 Double_t sinNew = sf*ca - cf*sa;
1163 if (TMath::Abs(sinNew) >= maxSnp) return kFALSE;
1164 if (!Rotate(alphan)) return kFALSE;