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
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 != 0) {
1046 idx[0] = GetTOFcluster();
1056 //_______________________________________________________________________
1057 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1058 // Returns the array with integrated times for each particle hypothesis
1059 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1062 //_______________________________________________________________________
1063 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1064 // Sets the array with integrated times for each particle hypotesis
1065 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1068 //_______________________________________________________________________
1069 void AliESDtrack::SetITSpid(const Double_t *p) {
1070 // Sets values for the probability of each particle type (in ITS)
1071 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1072 SetStatus(AliESDtrack::kITSpid);
1075 //_______________________________________________________________________
1076 void AliESDtrack::GetITSpid(Double_t *p) const {
1077 // Gets the probability of each particle type (in ITS)
1078 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1081 //_______________________________________________________________________
1082 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1083 //---------------------------------------------------------------------
1084 // This function returns indices of the assgined ITS clusters
1085 //---------------------------------------------------------------------
1087 Int_t *index=fFriendTrack->GetITSindices();
1088 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) idx[i]=index[i];
1093 //_______________________________________________________________________
1094 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1095 Float_t &xloc,Float_t &zloc) const {
1096 //----------------------------------------------------------------------
1097 // This function encodes in the module number also the status of cluster association
1098 // "status" can have the following values:
1099 // 1 "found" (cluster is associated),
1100 // 2 "dead" (module is dead from OCDB),
1101 // 3 "skipped" (module or layer forced to be skipped),
1102 // 4 "outinz" (track out of z acceptance),
1103 // 5 "nocls" (no clusters in the road),
1104 // 6 "norefit" (cluster rejected during refit),
1105 // 7 "deadzspd" (holes in z in SPD)
1106 // Also given are the coordinates of the crossing point of track and module
1107 // (in the local module ref. system)
1108 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1109 //----------------------------------------------------------------------
1111 if(fITSModule[ilayer]==-1) {
1112 AliError("fModule was not set !");
1115 xloc=-99.; zloc=-99.;
1119 Int_t module = fITSModule[ilayer];
1121 idet = Int_t(module/1000000);
1123 module -= idet*1000000;
1125 status = Int_t(module/100000);
1127 module -= status*100000;
1129 Int_t signs = Int_t(module/10000);
1131 module-=signs*10000;
1133 Int_t xInt = Int_t(module/100);
1136 Int_t zInt = module;
1138 if(signs==1) { xInt*=1; zInt*=1; }
1139 if(signs==2) { xInt*=1; zInt*=-1; }
1140 if(signs==3) { xInt*=-1; zInt*=1; }
1141 if(signs==4) { xInt*=-1; zInt*=-1; }
1143 xloc = 0.1*(Float_t)xInt;
1144 zloc = 0.1*(Float_t)zInt;
1146 if(status==4) idet = -1;
1151 //_______________________________________________________________________
1152 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1153 //---------------------------------------------------------------------
1154 // This function returns indices of the assgined ITS clusters
1155 //---------------------------------------------------------------------
1157 Int_t *index=fFriendTrack->GetTPCindices();
1158 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1163 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1165 // GetDensity of the clusters on given region between row0 and row1
1166 // Dead zone effect takin into acoount
1171 Int_t *index=fFriendTrack->GetTPCindices();
1172 for (Int_t i=row0;i<=row1;i++){
1173 Int_t idx = index[i];
1174 if (idx!=-1) good++; // track outside of dead zone
1177 Float_t density=0.5;
1178 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1182 //_______________________________________________________________________
1183 void AliESDtrack::SetTPCpid(const Double_t *p) {
1184 // Sets values for the probability of each particle type (in TPC)
1185 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1186 SetStatus(AliESDtrack::kTPCpid);
1189 //_______________________________________________________________________
1190 void AliESDtrack::GetTPCpid(Double_t *p) const {
1191 // Gets the probability of each particle type (in TPC)
1192 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1195 //_______________________________________________________________________
1196 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1197 //---------------------------------------------------------------------
1198 // This function returns indices of the assgined TRD clusters
1199 //---------------------------------------------------------------------
1201 Int_t *index=fFriendTrack->GetTRDindices();
1202 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1207 //_______________________________________________________________________
1208 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1209 //---------------------------------------------------------------------
1210 // This function returns indices of the assigned TRD tracklets
1211 //---------------------------------------------------------------------
1213 Int_t *index=fFriendTrack->GetTRDindices();
1214 for (Int_t i=0; i<6/*AliESDfriendTrack::kMaxTRDcluster*/; i++) idx[i]=index[i];
1219 //_______________________________________________________________________
1220 void AliESDtrack::SetTRDpid(const Double_t *p) {
1221 // Sets values for the probability of each particle type (in TRD)
1222 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1223 SetStatus(AliESDtrack::kTRDpid);
1226 //_______________________________________________________________________
1227 void AliESDtrack::GetTRDpid(Double_t *p) const {
1228 // Gets the probability of each particle type (in TRD)
1229 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1232 //_______________________________________________________________________
1233 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1235 // Sets the probability of particle type iSpecies to p (in TRD)
1236 fTRDr[iSpecies] = p;
1239 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1241 // Returns the probability of particle type iSpecies (in TRD)
1242 return fTRDr[iSpecies];
1245 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1246 //Sets the number of slices used for PID
1247 if (fTRDnSlices != 0) return;
1248 fTRDnSlices=kTRDnPlanes*n;
1249 fTRDslices=new Double32_t[fTRDnSlices];
1250 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=-1.;
1253 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1254 //Sets the charge q in the slice of the plane
1255 Int_t ns=GetNumberOfTRDslices();
1257 AliError("No TRD slices allocated for this track !");
1261 if ((plane<0) || (plane>=kTRDnPlanes)) {
1262 AliError("Wrong TRD plane !");
1265 if ((slice<0) || (slice>=ns)) {
1266 AliError("Wrong TRD slice !");
1269 Int_t n=plane*ns + slice;
1273 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1274 //Gets the charge from the slice of the plane
1275 Int_t ns=GetNumberOfTRDslices();
1277 //AliError("No TRD slices allocated for this track !");
1281 if ((plane<0) || (plane>=kTRDnPlanes)) {
1282 AliError("Wrong TRD plane !");
1285 if ((slice<-1) || (slice>=ns)) {
1286 //AliError("Wrong TRD slice !");
1292 for (Int_t i=0; i<ns; i++) q+=fTRDslices[plane*ns + i];
1296 return fTRDslices[plane*ns + slice];
1300 //_______________________________________________________________________
1301 void AliESDtrack::SetTOFpid(const Double_t *p) {
1302 // Sets the probability of each particle type (in TOF)
1303 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
1304 SetStatus(AliESDtrack::kTOFpid);
1307 //_______________________________________________________________________
1308 void AliESDtrack::SetTOFLabel(const Int_t *p) {
1310 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1313 //_______________________________________________________________________
1314 void AliESDtrack::GetTOFpid(Double_t *p) const {
1315 // Gets probabilities of each particle type (in TOF)
1316 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
1319 //_______________________________________________________________________
1320 void AliESDtrack::GetTOFLabel(Int_t *p) const {
1322 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
1325 //_______________________________________________________________________
1326 void AliESDtrack::GetTOFInfo(Float_t *info) const {
1328 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
1331 //_______________________________________________________________________
1332 void AliESDtrack::SetTOFInfo(Float_t*info) {
1334 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
1339 //_______________________________________________________________________
1340 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
1341 // Sets the probability of each particle type (in HMPID)
1342 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
1343 SetStatus(AliESDtrack::kHMPIDpid);
1346 //_______________________________________________________________________
1347 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
1348 // Gets probabilities of each particle type (in HMPID)
1349 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
1354 //_______________________________________________________________________
1355 void AliESDtrack::SetESDpid(const Double_t *p) {
1356 // Sets the probability of each particle type for the ESD track
1357 SetPIDValues(fR,p,AliPID::kSPECIES);
1358 SetStatus(AliESDtrack::kESDpid);
1361 //_______________________________________________________________________
1362 void AliESDtrack::GetESDpid(Double_t *p) const {
1363 // Gets probability of each particle type for the ESD track
1364 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
1367 //_______________________________________________________________________
1368 Bool_t AliESDtrack::RelateToVertex
1369 (const AliESDVertex *vtx, Double_t b, Double_t maxd) {
1371 // Try to relate this track to the vertex "vtx",
1372 // if the (rough) transverse impact parameter is not bigger then "maxd".
1373 // Magnetic field is "b" (kG).
1375 // a) The track gets extapolated to the DCA to the vertex.
1376 // b) The impact parameters and their covariance matrix are calculated.
1377 // c) An attempt to constrain this track to the vertex is done.
1379 // In the case of success, the returned value is kTRUE
1380 // (otherwise, it's kFALSE)
1383 if (!vtx) return kFALSE;
1385 Double_t dz[2],cov[3];
1386 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1394 Double_t covar[6]; vtx->GetCovMatrix(covar);
1395 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1396 Double_t c[3]={covar[2],0.,covar[5]};
1398 Double_t chi2=GetPredictedChi2(p,c);
1399 if (chi2>77.) return kFALSE;
1402 fCp=new AliExternalTrackParam(*this);
1404 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
1410 //_______________________________________________________________________
1411 void AliESDtrack::Print(Option_t *) const {
1412 // Prints info on the track
1414 printf("ESD track info\n") ;
1415 Double_t p[AliPID::kSPECIESN] ;
1417 if( IsOn(kITSpid) ){
1418 printf("From ITS: ") ;
1420 for(index = 0 ; index < AliPID::kSPECIES; index++)
1421 printf("%f, ", p[index]) ;
1422 printf("\n signal = %f\n", GetITSsignal()) ;
1424 if( IsOn(kTPCpid) ){
1425 printf("From TPC: ") ;
1427 for(index = 0 ; index < AliPID::kSPECIES; index++)
1428 printf("%f, ", p[index]) ;
1429 printf("\n signal = %f\n", GetTPCsignal()) ;
1431 if( IsOn(kTRDpid) ){
1432 printf("From TRD: ") ;
1434 for(index = 0 ; index < AliPID::kSPECIES; index++)
1435 printf("%f, ", p[index]) ;
1436 printf("\n signal = %f\n", GetTRDsignal()) ;
1438 if( IsOn(kTOFpid) ){
1439 printf("From TOF: ") ;
1441 for(index = 0 ; index < AliPID::kSPECIES; index++)
1442 printf("%f, ", p[index]) ;
1443 printf("\n signal = %f\n", GetTOFsignal()) ;
1445 if( IsOn(kHMPIDpid) ){
1446 printf("From HMPID: ") ;
1448 for(index = 0 ; index < AliPID::kSPECIES; index++)
1449 printf("%f, ", p[index]) ;
1450 printf("\n signal = %f\n", GetHMPIDsignal()) ;
1456 // Draw functionality
1457 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
1459 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
1461 // Fill points in the polymarker
1464 arrayRef.AddLast(new AliExternalTrackParam(*this));
1465 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
1466 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
1468 Double_t mpos[3]={0,0,0};
1469 Int_t entries=arrayRef.GetEntries();
1470 for (Int_t i=0;i<entries;i++){
1472 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
1473 mpos[0]+=pos[0]/entries;
1474 mpos[1]+=pos[1]/entries;
1475 mpos[2]+=pos[2]/entries;
1477 // Rotate to the mean position
1479 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
1480 for (Int_t i=0;i<entries;i++){
1481 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
1482 if (!res) delete arrayRef.RemoveAt(i);
1485 for (Double_t r=minR; r<maxR; r+=stepR){
1487 Double_t mlpos[3]={0,0,0};
1488 for (Int_t i=0;i<entries;i++){
1489 Double_t point[3]={0,0,0};
1490 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
1491 if (!param) continue;
1492 if (param->GetXYZAt(r,magF,point)){
1493 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
1495 mlpos[0]+=point[0]*weight;
1496 mlpos[1]+=point[1]*weight;
1497 mlpos[2]+=point[2]*weight;
1504 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
1505 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);