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"
31 #include "TPolyMarker3D.h"
35 void SetPIDValues(Double_t * dest, const Double_t * src, Int_t n) {
36 // This function copies "n" PID weights from "scr" to "dest"
37 // and normalizes their sum to 1 thus producing conditional probabilities.
38 // The negative weights are set to 0.
39 // In case all the weights are non-positive they are replaced by
40 // uniform probabilities
44 Float_t uniform = 1./(Float_t)n;
47 for (Int_t i=0; i<n; i++)
57 for (Int_t i=0; i<n; i++) dest[i] /= sum;
59 for (Int_t i=0; i<n; i++) dest[i] = uniform;
62 //_______________________________________________________________________
63 AliESDtrack::AliESDtrack() :
64 AliExternalTrackParam(),
69 fFriendTrack(new AliESDfriendTrack()),
70 fTPCClusterMap(159),//number of padrows
71 fTPCSharedMap(159),//number of padrows
82 fEMCALindex(kEMCALNoMatch),
88 fCdd(0),fCdz(0),fCzz(0),
122 // The default ESD constructor
125 for (i=0; i<AliPID::kSPECIES; i++) {
135 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
136 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
137 for (i=0;i<kTRDnPlanes;i++) {
140 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
141 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
142 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
143 for (i=0;i<12;i++) {fITSModule[i]=-1;}
146 //_______________________________________________________________________
147 AliESDtrack::AliESDtrack(const AliESDtrack& track):
148 AliExternalTrackParam(track),
154 fTPCClusterMap(track.fTPCClusterMap),
155 fTPCSharedMap(track.fTPCSharedMap),
156 fFlags(track.fFlags),
158 fLabel(track.fLabel),
159 fITSLabel(track.fITSLabel),
160 fTPCLabel(track.fTPCLabel),
161 fTRDLabel(track.fTRDLabel),
162 fTOFCalChannel(track.fTOFCalChannel),
163 fTOFindex(track.fTOFindex),
164 fHMPIDqn(track.fHMPIDqn),
165 fHMPIDcluIdx(track.fHMPIDcluIdx),
166 fEMCALindex(track.fEMCALindex),
167 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
168 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
169 fHMPIDsignal(track.fHMPIDsignal),
170 fTrackLength(track.fTrackLength),
171 fD(track.fD),fZ(track.fZ),
172 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
173 fCchi2(track.fCchi2),
174 fITSchi2(track.fITSchi2),
175 fTPCchi2(track.fTPCchi2),
176 fTRDchi2(track.fTRDchi2),
177 fTOFchi2(track.fTOFchi2),
178 fHMPIDchi2(track.fHMPIDchi2),
179 fITSsignal(track.fITSsignal),
180 fTPCsignal(track.fTPCsignal),
181 fTPCsignalS(track.fTPCsignalS),
182 fTRDsignal(track.fTRDsignal),
183 fTRDQuality(track.fTRDQuality),
184 fTRDBudget(track.fTRDBudget),
185 fTOFsignal(track.fTOFsignal),
186 fTOFsignalToT(track.fTOFsignalToT),
187 fTOFsignalRaw(track.fTOFsignalRaw),
188 fTOFsignalDz(track.fTOFsignalDz),
189 fHMPIDtrkX(track.fHMPIDtrkX),
190 fHMPIDtrkY(track.fHMPIDtrkY),
191 fHMPIDmipX(track.fHMPIDmipX),
192 fHMPIDmipY(track.fHMPIDmipY),
193 fTPCncls(track.fTPCncls),
194 fTPCnclsF(track.fTPCnclsF),
195 fTPCsignalN(track.fTPCsignalN),
196 fITSncls(track.fITSncls),
197 fITSClusterMap(track.fITSClusterMap),
198 fTRDncls(track.fTRDncls),
199 fTRDncls0(track.fTRDncls0),
200 fTRDpidQuality(track.fTRDpidQuality),
201 fTRDnSlices(track.fTRDnSlices),
207 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
208 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
210 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
212 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
213 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
214 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
215 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
217 for (Int_t i=0;i<kTRDnPlanes;i++) {
218 fTRDTimBin[i]=track.fTRDTimBin[i];
222 fTRDslices=new Double32_t[fTRDnSlices];
223 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
226 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
227 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
228 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
229 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
230 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
231 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
233 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
234 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
235 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
236 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
238 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
241 //_______________________________________________________________________
242 AliESDtrack::AliESDtrack(TParticle * part) :
243 AliExternalTrackParam(),
249 fTPCClusterMap(159),//number of padrows
250 fTPCSharedMap(159),//number of padrows
261 fEMCALindex(kEMCALNoMatch),
267 fCdd(0),fCdz(0),fCzz(0),
300 // ESD track from TParticle
303 // Reset all the arrays
305 for (i=0; i<AliPID::kSPECIES; i++) {
315 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
316 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
317 for (i=0;i<kTRDnPlanes;i++) {
320 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
321 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
322 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
323 for (i=0;i<12;i++) {fITSModule[i]=-1;}
325 // Calculate the AliExternalTrackParam content
332 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
333 alpha = part->Phi()*180./TMath::Pi();
334 if (alpha<0) alpha+= 360.;
335 if (alpha>360) alpha -= 360.;
337 Int_t sector = (Int_t)(alpha/20.);
338 alpha = 10. + 20.*sector;
340 alpha *= TMath::Pi();
342 // Covariance matrix: no errors, the parameters are exact
343 for (i=0; i<15; i++) covar[i]=0.;
345 // Get the vertex of origin and the momentum
346 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
347 TVector3 mom(part->Px(),part->Py(),part->Pz());
349 // Rotate to the local coordinate system (TPC sector)
353 // X of the referense plane
356 Int_t pdgCode = part->GetPdgCode();
359 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
363 param[2] = TMath::Sin(mom.Phi());
364 param[3] = mom.Pz()/mom.Pt();
365 param[4] = TMath::Sign(1/mom.Pt(),charge);
367 // Set AliExternalTrackParam
368 Set(xref, alpha, param, covar);
373 switch (TMath::Abs(pdgCode)) {
399 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
400 if (indexPID < AliPID::kSPECIES) {
406 fHMPIDr[indexPID]=1.;
409 // AliESD track label
410 SetLabel(part->GetUniqueID());
414 //_______________________________________________________________________
415 AliESDtrack::~AliESDtrack(){
417 // This is destructor according Coding Conventrions
419 //printf("Delete track\n");
429 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
432 if(&source == this) return *this;
433 AliExternalTrackParam::operator=(source);
437 // we have the trackparam: assign or copy construct
438 if(fCp)*fCp = *source.fCp;
439 else fCp = new AliExternalTrackParam(*source.fCp);
442 // no track param delete the old one
448 // we have the trackparam: assign or copy construct
449 if(fIp)*fIp = *source.fIp;
450 else fIp = new AliExternalTrackParam(*source.fIp);
453 // no track param delete the old one
459 if(source.fTPCInner){
460 // we have the trackparam: assign or copy construct
461 if(fTPCInner) *fTPCInner = *source.fTPCInner;
462 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
465 // no track param delete the old one
466 if(fTPCInner)delete fTPCInner;
472 // we have the trackparam: assign or copy construct
473 if(fOp) *fOp = *source.fOp;
474 else fOp = new AliExternalTrackParam(*source.fOp);
477 // no track param delete the old one
482 // copy also the friend track
483 // use copy constructor
484 if(source.fFriendTrack){
485 // we have the trackparam: assign or copy construct
486 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
489 // no track param delete the old one
490 delete fFriendTrack; fFriendTrack= 0;
493 fTPCClusterMap = source.fTPCClusterMap;
494 fTPCSharedMap = source.fTPCSharedMap;
496 fFlags = source.fFlags;
498 fLabel = source.fLabel;
499 fITSLabel = source.fITSLabel;
500 for(int i = 0; i< 12;++i){
501 fITSModule[i] = source.fITSModule[i];
503 fTPCLabel = source.fTPCLabel;
504 fTRDLabel = source.fTRDLabel;
505 for(int i = 0; i< 3;++i){
506 fTOFLabel[i] = source.fTOFLabel[i];
508 fTOFCalChannel = source.fTOFCalChannel;
509 fTOFindex = source.fTOFindex;
510 fHMPIDqn = source.fHMPIDqn;
511 fHMPIDcluIdx = source.fHMPIDcluIdx;
512 fEMCALindex = source.fEMCALindex;
514 for(int i = 0; i< 3;++i){
515 fKinkIndexes[i] = source.fKinkIndexes[i];
516 fV0Indexes[i] = source.fV0Indexes[i];
519 for(int i = 0; i< AliPID::kSPECIES;++i){
520 fR[i] = source.fR[i];
521 fITSr[i] = source.fITSr[i];
522 fTPCr[i] = source.fTPCr[i];
523 fTRDr[i] = source.fTRDr[i];
524 fTOFr[i] = source.fTOFr[i];
525 fHMPIDr[i] = source.fHMPIDr[i];
526 fTrackTime[i] = source.fTrackTime[i];
529 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
530 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
531 fHMPIDsignal = source.fHMPIDsignal;
534 fTrackLength = source. fTrackLength;
541 fCchi2 = source.fCchi2;
542 fITSchi2 = source.fITSchi2;
543 fTPCchi2 = source.fTPCchi2;
544 fTRDchi2 = source.fTRDchi2;
545 fTOFchi2 = source.fTOFchi2;
546 fHMPIDchi2 = source.fHMPIDchi2;
549 fITSsignal = source.fITSsignal;
550 fTPCsignal = source.fTPCsignal;
551 fTPCsignalS = source.fTPCsignalS;
552 for(int i = 0; i< 4;++i){
553 fTPCPoints[i] = source.fTPCPoints[i];
555 fTRDsignal = source.fTRDsignal;
557 for(int i = 0;i < kTRDnPlanes;++i){
558 fTRDTimBin[i] = source.fTRDTimBin[i];
564 fTRDnSlices=source.fTRDnSlices;
566 fTRDslices=new Double32_t[fTRDnSlices];
567 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
570 fTRDQuality = source.fTRDQuality;
571 fTRDBudget = source.fTRDBudget;
572 fTOFsignal = source.fTOFsignal;
573 fTOFsignalToT = source.fTOFsignalToT;
574 fTOFsignalRaw = source.fTOFsignalRaw;
575 fTOFsignalDz = source.fTOFsignalDz;
577 for(int i = 0;i<10;++i){
578 fTOFInfo[i] = source.fTOFInfo[i];
581 fHMPIDtrkX = source.fHMPIDtrkX;
582 fHMPIDtrkY = source.fHMPIDtrkY;
583 fHMPIDmipX = source.fHMPIDmipX;
584 fHMPIDmipY = source.fHMPIDmipY;
586 fTPCncls = source.fTPCncls;
587 fTPCnclsF = source.fTPCnclsF;
588 fTPCsignalN = source.fTPCsignalN;
590 fITSncls = source.fITSncls;
591 fITSClusterMap = source.fITSClusterMap;
592 fTRDncls = source.fTRDncls;
593 fTRDncls0 = source.fTRDncls0;
594 fTRDpidQuality = source.fTRDpidQuality;
600 void AliESDtrack::Copy(TObject &obj) const {
602 // this overwrites the virtual TOBject::Copy()
603 // to allow run time copying without casting
606 if(this==&obj)return;
607 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
608 if(!robj)return; // not an AliESDtrack
615 void AliESDtrack::AddCalibObject(TObject * object){
617 // add calib object to the list
619 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
620 fFriendTrack->AddCalibObject(object);
623 TObject * AliESDtrack::GetCalibObject(Int_t index){
625 // return calib objct at given position
627 if (!fFriendTrack) return 0;
628 return fFriendTrack->GetCalibObject(index);
632 //_______________________________________________________________________
633 void AliESDtrack::MakeMiniESDtrack(){
634 // Resets everything except
635 // fFlags: Reconstruction status flags
636 // fLabel: Track label
637 // fID: Unique ID of the track
638 // fD: Impact parameter in XY-plane
639 // fZ: Impact parameter in Z
640 // fR[AliPID::kSPECIES]: combined "detector response probability"
641 // Running track parameters in the base class (AliExternalTrackParam)
645 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
647 // Reset track parameters constrained to the primary vertex
651 // Reset track parameters at the inner wall of TPC
653 delete fTPCInner;fTPCInner=0;
654 // Reset track parameters at the inner wall of the TRD
658 // Reset ITS track related information
663 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
666 // Reset TPC related track information
675 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
677 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
678 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
679 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
681 // Reset TRD related track information
686 for (Int_t i=0;i<kTRDnPlanes;i++) {
689 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
699 // Reset TOF related track information
707 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
708 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
709 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
711 // Reset HMPID related track information
716 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
723 fEMCALindex = kEMCALNoMatch;
725 delete fFriendTrack; fFriendTrack = 0;
727 //_______________________________________________________________________
728 Double_t AliESDtrack::GetMass() const {
729 // Returns the mass of the most probable particle type
732 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
733 if (fR[i]>max) {k=i; max=fR[i];}
735 if (k==0) { // dE/dx "crossing points" in the TPC
737 if ((p>0.38)&&(p<0.48))
738 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
739 if ((p>0.75)&&(p<0.85))
740 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
743 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
744 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
745 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
746 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
747 AliWarning("Undefined mass !");
748 return AliPID::ParticleMass(AliPID::kPion);
751 //______________________________________________________________________________
752 Double_t AliESDtrack::E() const
754 // Returns the energy of the particle given its assumed mass.
755 // Assumes the pion mass if the particle can't be identified properly.
759 return TMath::Sqrt(p*p + m*m);
762 //______________________________________________________________________________
763 Double_t AliESDtrack::Y() const
765 // Returns the rapidity of a particle given its assumed mass.
766 // Assumes the pion mass if the particle can't be identified properly.
770 if (e != TMath::Abs(pz)) { // energy was not equal to pz
771 return 0.5*TMath::Log((e+pz)/(e-pz));
772 } else { // energy was equal to pz
777 //_______________________________________________________________________
778 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
780 // This function updates track's running parameters
786 fLabel=t->GetLabel();
788 if (t->IsStartedTimeIntegral()) {
790 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
791 SetIntegratedLength(t->GetIntegratedLength());
794 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
798 case kITSin: case kITSout: case kITSrefit:
800 fITSncls=t->GetNumberOfClusters();
801 index=fFriendTrack->GetITSindices();
802 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
803 index[i]=t->GetClusterIndex(i);
805 Int_t l=(index[i] & 0xf0000000) >> 28;
806 SETBIT(fITSClusterMap,l);
809 fITSchi2=t->GetChi2();
810 fITSsignal=t->GetPIDsignal();
811 fITSLabel = t->GetLabel();
814 case kTPCin: case kTPCrefit:
815 fTPCLabel = t->GetLabel();
816 if (flags==kTPCin) fTPCInner=new AliExternalTrackParam(*t);
817 if (!fIp) fIp=new AliExternalTrackParam(*t);
819 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
821 index=fFriendTrack->GetTPCindices();
822 if (flags & kTPCout){
823 if (!fOp) fOp=new AliExternalTrackParam(*t);
825 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
827 fTPCncls=t->GetNumberOfClusters();
828 fTPCchi2=t->GetChi2();
830 {//prevrow must be declared in separate namespace, otherwise compiler cries:
831 //"jump to case label crosses initialization of `Int_t prevrow'"
833 // for (Int_t i=0;i<fTPCncls;i++)
834 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
836 index[i]=t->GetClusterIndex(i);
837 Int_t idx = index[i];
841 // Piotr's Cluster Map for HBT
842 // ### please change accordingly if cluster array is changing
843 // to "New TPC Tracking" style (with gaps in array)
844 Int_t sect = (idx&0xff000000)>>24;
845 Int_t row = (idx&0x00ff0000)>>16;
846 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
848 fTPCClusterMap.SetBitNumber(row,kTRUE);
850 //Fill the gap between previous row and this row with 0 bits
851 //In case ### pleas change it as well - just set bit 0 in case there
852 //is no associated clusters for current "i"
855 prevrow = row;//if previous bit was not assigned yet == this is the first one
858 { //we don't know the order (inner to outer or reverse)
859 //just to be save in case it is going to change
872 for (Int_t j = n+1; j < m; j++)
874 fTPCClusterMap.SetBitNumber(j,kFALSE);
878 // End Of Piotr's Cluster Map for HBT
881 fTPCsignal=t->GetPIDsignal();
884 case kTRDout: case kTRDin: case kTRDrefit:
885 index = fFriendTrack->GetTRDindices();
886 fTRDLabel = t->GetLabel();
887 fTRDchi2 = t->GetChi2();
888 fTRDncls = t->GetNumberOfClusters();
889 for (Int_t i=0;i<6;i++) index[i]=t->GetTrackletIndex(i);
891 fTRDsignal=t->GetPIDsignal();
894 if (!fOp) fOp=new AliExternalTrackParam(*t);
896 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
897 fTRDncls0 = t->GetNumberOfClusters();
906 AliError("Wrong flag !");
913 //_______________________________________________________________________
914 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
915 //---------------------------------------------------------------------
916 // This function returns external representation of the track parameters
917 //---------------------------------------------------------------------
919 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
922 //_______________________________________________________________________
923 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
924 //---------------------------------------------------------------------
925 // This function returns external representation of the cov. matrix
926 //---------------------------------------------------------------------
927 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
930 //_______________________________________________________________________
931 Bool_t AliESDtrack::GetConstrainedExternalParameters
932 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
933 //---------------------------------------------------------------------
934 // This function returns the constrained external track parameters
935 //---------------------------------------------------------------------
936 if (!fCp) return kFALSE;
937 alpha=fCp->GetAlpha();
939 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
943 //_______________________________________________________________________
945 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
946 //---------------------------------------------------------------------
947 // This function returns the constrained external cov. matrix
948 //---------------------------------------------------------------------
949 if (!fCp) return kFALSE;
950 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
955 AliESDtrack::GetInnerExternalParameters
956 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
957 //---------------------------------------------------------------------
958 // This function returns external representation of the track parameters
959 // at the inner layer of TPC
960 //---------------------------------------------------------------------
961 if (!fIp) return kFALSE;
962 alpha=fIp->GetAlpha();
964 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
969 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
970 //---------------------------------------------------------------------
971 // This function returns external representation of the cov. matrix
972 // at the inner layer of TPC
973 //---------------------------------------------------------------------
974 if (!fIp) return kFALSE;
975 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
980 AliESDtrack::GetOuterExternalParameters
981 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
982 //---------------------------------------------------------------------
983 // This function returns external representation of the track parameters
984 // at the inner layer of TRD
985 //---------------------------------------------------------------------
986 if (!fOp) return kFALSE;
987 alpha=fOp->GetAlpha();
989 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
994 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
995 //---------------------------------------------------------------------
996 // This function returns external representation of the cov. matrix
997 // at the inner layer of TRD
998 //---------------------------------------------------------------------
999 if (!fOp) return kFALSE;
1000 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1004 Int_t AliESDtrack::GetNcls(Int_t idet) const
1006 // Get number of clusters by subdetector index
1020 if (fTOFindex != -1)
1029 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1031 // Get cluster index array by subdetector index
1036 ncls = GetITSclusters(idx);
1039 ncls = GetTPCclusters(idx);
1042 ncls = GetTRDclusters(idx);
1045 if (fTOFindex != -1) {
1053 if (fHMPIDcluIdx != 0) {
1054 idx[0] = GetHMPIDcluIdx();
1066 //_______________________________________________________________________
1067 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1068 // Returns the array with integrated times for each particle hypothesis
1069 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1072 //_______________________________________________________________________
1073 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1074 // Sets the array with integrated times for each particle hypotesis
1075 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1078 //_______________________________________________________________________
1079 void AliESDtrack::SetITSpid(const Double_t *p) {
1080 // Sets values for the probability of each particle type (in ITS)
1081 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1082 SetStatus(AliESDtrack::kITSpid);
1085 //_______________________________________________________________________
1086 void AliESDtrack::GetITSpid(Double_t *p) const {
1087 // Gets the probability of each particle type (in ITS)
1088 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1091 //_______________________________________________________________________
1092 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1093 //---------------------------------------------------------------------
1094 // This function returns indices of the assgined ITS clusters
1095 //---------------------------------------------------------------------
1097 Int_t *index=fFriendTrack->GetITSindices();
1098 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) idx[i]=index[i];
1103 //_______________________________________________________________________
1104 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1105 Float_t &xloc,Float_t &zloc) const {
1106 //----------------------------------------------------------------------
1107 // This function encodes in the module number also the status of cluster association
1108 // "status" can have the following values:
1109 // 1 "found" (cluster is associated),
1110 // 2 "dead" (module is dead from OCDB),
1111 // 3 "skipped" (module or layer forced to be skipped),
1112 // 4 "outinz" (track out of z acceptance),
1113 // 5 "nocls" (no clusters in the road),
1114 // 6 "norefit" (cluster rejected during refit),
1115 // 7 "deadzspd" (holes in z in SPD)
1116 // Also given are the coordinates of the crossing point of track and module
1117 // (in the local module ref. system)
1118 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1119 //----------------------------------------------------------------------
1121 if(fITSModule[ilayer]==-1) {
1122 AliError("fModule was not set !");
1125 xloc=-99.; zloc=-99.;
1129 Int_t module = fITSModule[ilayer];
1131 idet = Int_t(module/1000000);
1133 module -= idet*1000000;
1135 status = Int_t(module/100000);
1137 module -= status*100000;
1139 Int_t signs = Int_t(module/10000);
1141 module-=signs*10000;
1143 Int_t xInt = Int_t(module/100);
1146 Int_t zInt = module;
1148 if(signs==1) { xInt*=1; zInt*=1; }
1149 if(signs==2) { xInt*=1; zInt*=-1; }
1150 if(signs==3) { xInt*=-1; zInt*=1; }
1151 if(signs==4) { xInt*=-1; zInt*=-1; }
1153 xloc = 0.1*(Float_t)xInt;
1154 zloc = 0.1*(Float_t)zInt;
1156 if(status==4) idet = -1;
1161 //_______________________________________________________________________
1162 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1163 //---------------------------------------------------------------------
1164 // This function returns indices of the assgined ITS clusters
1165 //---------------------------------------------------------------------
1167 Int_t *index=fFriendTrack->GetTPCindices();
1168 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1173 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1175 // GetDensity of the clusters on given region between row0 and row1
1176 // Dead zone effect takin into acoount
1181 Int_t *index=fFriendTrack->GetTPCindices();
1182 for (Int_t i=row0;i<=row1;i++){
1183 Int_t idx = index[i];
1184 if (idx!=-1) good++; // track outside of dead zone
1187 Float_t density=0.5;
1188 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1192 //_______________________________________________________________________
1193 void AliESDtrack::SetTPCpid(const Double_t *p) {
1194 // Sets values for the probability of each particle type (in TPC)
1195 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1196 SetStatus(AliESDtrack::kTPCpid);
1199 //_______________________________________________________________________
1200 void AliESDtrack::GetTPCpid(Double_t *p) const {
1201 // Gets the probability of each particle type (in TPC)
1202 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1205 //_______________________________________________________________________
1206 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1207 //---------------------------------------------------------------------
1208 // This function returns indices of the assgined TRD clusters
1209 //---------------------------------------------------------------------
1211 Int_t *index=fFriendTrack->GetTRDindices();
1212 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1217 //_______________________________________________________________________
1218 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1219 //---------------------------------------------------------------------
1220 // This function returns indices of the assigned TRD tracklets
1221 //---------------------------------------------------------------------
1223 Int_t *index=fFriendTrack->GetTRDindices();
1224 for (Int_t i=0; i<6/*AliESDfriendTrack::kMaxTRDcluster*/; i++) idx[i]=index[i];
1229 //_______________________________________________________________________
1230 void AliESDtrack::SetTRDpid(const Double_t *p) {
1231 // Sets values for the probability of each particle type (in TRD)
1232 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1233 SetStatus(AliESDtrack::kTRDpid);
1236 //_______________________________________________________________________
1237 void AliESDtrack::GetTRDpid(Double_t *p) const {
1238 // Gets the probability of each particle type (in TRD)
1239 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1242 //_______________________________________________________________________
1243 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1245 // Sets the probability of particle type iSpecies to p (in TRD)
1246 fTRDr[iSpecies] = p;
1249 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1251 // Returns the probability of particle type iSpecies (in TRD)
1252 return fTRDr[iSpecies];
1255 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1256 //Sets the number of slices used for PID
1257 if (fTRDnSlices != 0) return;
1258 fTRDnSlices=kTRDnPlanes*n;
1259 fTRDslices=new Double32_t[fTRDnSlices];
1260 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=-1.;
1263 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1264 //Sets the charge q in the slice of the plane
1265 Int_t ns=GetNumberOfTRDslices();
1267 AliError("No TRD slices allocated for this track !");
1271 if ((plane<0) || (plane>=kTRDnPlanes)) {
1272 AliError("Wrong TRD plane !");
1275 if ((slice<0) || (slice>=ns)) {
1276 AliError("Wrong TRD slice !");
1279 Int_t n=plane*ns + slice;
1283 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1284 //Gets the charge from the slice of the plane
1285 Int_t ns=GetNumberOfTRDslices();
1287 //AliError("No TRD slices allocated for this track !");
1291 if ((plane<0) || (plane>=kTRDnPlanes)) {
1292 AliError("Wrong TRD plane !");
1295 if ((slice<-1) || (slice>=ns)) {
1296 //AliError("Wrong TRD slice !");
1302 for (Int_t i=0; i<ns; i++) q+=fTRDslices[plane*ns + i];
1306 return fTRDslices[plane*ns + slice];
1310 //_______________________________________________________________________
1311 void AliESDtrack::SetTOFpid(const Double_t *p) {
1312 // Sets the probability of each particle type (in TOF)
1313 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
1314 SetStatus(AliESDtrack::kTOFpid);
1317 //_______________________________________________________________________
1318 void AliESDtrack::SetTOFLabel(const Int_t *p) {
1320 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1323 //_______________________________________________________________________
1324 void AliESDtrack::GetTOFpid(Double_t *p) const {
1325 // Gets probabilities of each particle type (in TOF)
1326 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
1329 //_______________________________________________________________________
1330 void AliESDtrack::GetTOFLabel(Int_t *p) const {
1332 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
1335 //_______________________________________________________________________
1336 void AliESDtrack::GetTOFInfo(Float_t *info) const {
1338 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
1341 //_______________________________________________________________________
1342 void AliESDtrack::SetTOFInfo(Float_t*info) {
1344 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
1349 //_______________________________________________________________________
1350 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
1351 // Sets the probability of each particle type (in HMPID)
1352 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
1353 SetStatus(AliESDtrack::kHMPIDpid);
1356 //_______________________________________________________________________
1357 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
1358 // Gets probabilities of each particle type (in HMPID)
1359 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
1364 //_______________________________________________________________________
1365 void AliESDtrack::SetESDpid(const Double_t *p) {
1366 // Sets the probability of each particle type for the ESD track
1367 SetPIDValues(fR,p,AliPID::kSPECIES);
1368 SetStatus(AliESDtrack::kESDpid);
1371 //_______________________________________________________________________
1372 void AliESDtrack::GetESDpid(Double_t *p) const {
1373 // Gets probability of each particle type for the ESD track
1374 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
1377 //_______________________________________________________________________
1378 Bool_t AliESDtrack::RelateToVertex
1379 (const AliESDVertex *vtx, Double_t b, Double_t maxd) {
1381 // Try to relate this track to the vertex "vtx",
1382 // if the (rough) transverse impact parameter is not bigger then "maxd".
1383 // Magnetic field is "b" (kG).
1385 // a) The track gets extapolated to the DCA to the vertex.
1386 // b) The impact parameters and their covariance matrix are calculated.
1387 // c) An attempt to constrain this track to the vertex is done.
1389 // In the case of success, the returned value is kTRUE
1390 // (otherwise, it's kFALSE)
1393 if (!vtx) return kFALSE;
1395 Double_t dz[2],cov[3];
1396 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1404 Double_t covar[6]; vtx->GetCovMatrix(covar);
1405 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1406 Double_t c[3]={covar[2],0.,covar[5]};
1408 Double_t chi2=GetPredictedChi2(p,c);
1409 if (chi2>77.) return kFALSE;
1412 fCp=new AliExternalTrackParam(*this);
1414 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
1420 //_______________________________________________________________________
1421 void AliESDtrack::Print(Option_t *) const {
1422 // Prints info on the track
1424 printf("ESD track info\n") ;
1425 Double_t p[AliPID::kSPECIESN] ;
1427 if( IsOn(kITSpid) ){
1428 printf("From ITS: ") ;
1430 for(index = 0 ; index < AliPID::kSPECIES; index++)
1431 printf("%f, ", p[index]) ;
1432 printf("\n signal = %f\n", GetITSsignal()) ;
1434 if( IsOn(kTPCpid) ){
1435 printf("From TPC: ") ;
1437 for(index = 0 ; index < AliPID::kSPECIES; index++)
1438 printf("%f, ", p[index]) ;
1439 printf("\n signal = %f\n", GetTPCsignal()) ;
1441 if( IsOn(kTRDpid) ){
1442 printf("From TRD: ") ;
1444 for(index = 0 ; index < AliPID::kSPECIES; index++)
1445 printf("%f, ", p[index]) ;
1446 printf("\n signal = %f\n", GetTRDsignal()) ;
1448 if( IsOn(kTOFpid) ){
1449 printf("From TOF: ") ;
1451 for(index = 0 ; index < AliPID::kSPECIES; index++)
1452 printf("%f, ", p[index]) ;
1453 printf("\n signal = %f\n", GetTOFsignal()) ;
1455 if( IsOn(kHMPIDpid) ){
1456 printf("From HMPID: ") ;
1458 for(index = 0 ; index < AliPID::kSPECIES; index++)
1459 printf("%f, ", p[index]) ;
1460 printf("\n signal = %f\n", GetHMPIDsignal()) ;
1466 // Draw functionality
1467 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
1469 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
1471 // Fill points in the polymarker
1474 arrayRef.AddLast(new AliExternalTrackParam(*this));
1475 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
1476 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
1478 Double_t mpos[3]={0,0,0};
1479 Int_t entries=arrayRef.GetEntries();
1480 for (Int_t i=0;i<entries;i++){
1482 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
1483 mpos[0]+=pos[0]/entries;
1484 mpos[1]+=pos[1]/entries;
1485 mpos[2]+=pos[2]/entries;
1487 // Rotate to the mean position
1489 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
1490 for (Int_t i=0;i<entries;i++){
1491 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
1492 if (!res) delete arrayRef.RemoveAt(i);
1495 for (Double_t r=minR; r<maxR; r+=stepR){
1497 Double_t mlpos[3]={0,0,0};
1498 for (Int_t i=0;i<entries;i++){
1499 Double_t point[3]={0,0,0};
1500 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
1501 if (!param) continue;
1502 if (param->GetXYZAt(r,magF,point)){
1503 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
1505 mlpos[0]+=point[0]*weight;
1506 mlpos[1]+=point[1]*weight;
1507 mlpos[2]+=point[2]*weight;
1514 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
1515 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);