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 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
90 fCdd(0),fCdz(0),fCzz(0),
124 // The default ESD constructor
127 for (i=0; i<AliPID::kSPECIES; i++) {
137 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
138 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
139 for (i=0;i<kTRDnPlanes;i++) {
142 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
143 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
144 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
145 for (i=0;i<12;i++) {fITSModule[i]=-1;}
148 //_______________________________________________________________________
149 AliESDtrack::AliESDtrack(const AliESDtrack& track):
150 AliExternalTrackParam(track),
156 fTPCClusterMap(track.fTPCClusterMap),
157 fTPCSharedMap(track.fTPCSharedMap),
158 fFlags(track.fFlags),
160 fLabel(track.fLabel),
161 fITSLabel(track.fITSLabel),
162 fTPCLabel(track.fTPCLabel),
163 fTRDLabel(track.fTRDLabel),
164 fTOFCalChannel(track.fTOFCalChannel),
165 fTOFindex(track.fTOFindex),
166 fHMPIDqn(track.fHMPIDqn),
167 fHMPIDcluIdx(track.fHMPIDcluIdx),
168 fEMCALindex(track.fEMCALindex),
169 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
170 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
171 fHMPIDsignal(track.fHMPIDsignal),
172 fTrackLength(track.fTrackLength),
173 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
174 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
175 fD(track.fD),fZ(track.fZ),
176 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
177 fCchi2(track.fCchi2),
178 fITSchi2(track.fITSchi2),
179 fTPCchi2(track.fTPCchi2),
180 fTRDchi2(track.fTRDchi2),
181 fTOFchi2(track.fTOFchi2),
182 fHMPIDchi2(track.fHMPIDchi2),
183 fITSsignal(track.fITSsignal),
184 fTPCsignal(track.fTPCsignal),
185 fTPCsignalS(track.fTPCsignalS),
186 fTRDsignal(track.fTRDsignal),
187 fTRDQuality(track.fTRDQuality),
188 fTRDBudget(track.fTRDBudget),
189 fTOFsignal(track.fTOFsignal),
190 fTOFsignalToT(track.fTOFsignalToT),
191 fTOFsignalRaw(track.fTOFsignalRaw),
192 fTOFsignalDz(track.fTOFsignalDz),
193 fHMPIDtrkX(track.fHMPIDtrkX),
194 fHMPIDtrkY(track.fHMPIDtrkY),
195 fHMPIDmipX(track.fHMPIDmipX),
196 fHMPIDmipY(track.fHMPIDmipY),
197 fTPCncls(track.fTPCncls),
198 fTPCnclsF(track.fTPCnclsF),
199 fTPCsignalN(track.fTPCsignalN),
200 fITSncls(track.fITSncls),
201 fITSClusterMap(track.fITSClusterMap),
202 fTRDncls(track.fTRDncls),
203 fTRDncls0(track.fTRDncls0),
204 fTRDpidQuality(track.fTRDpidQuality),
205 fTRDnSlices(track.fTRDnSlices),
211 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
212 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
214 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
216 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
217 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
218 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
219 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
221 for (Int_t i=0;i<kTRDnPlanes;i++) {
222 fTRDTimBin[i]=track.fTRDTimBin[i];
226 fTRDslices=new Double32_t[fTRDnSlices];
227 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
230 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
231 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
232 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
233 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
234 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
235 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
237 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
238 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
239 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
240 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
242 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
245 //_______________________________________________________________________
246 AliESDtrack::AliESDtrack(TParticle * part) :
247 AliExternalTrackParam(),
253 fTPCClusterMap(159),//number of padrows
254 fTPCSharedMap(159),//number of padrows
265 fEMCALindex(kEMCALNoMatch),
271 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
273 fCdd(0),fCdz(0),fCzz(0),
306 // ESD track from TParticle
309 // Reset all the arrays
311 for (i=0; i<AliPID::kSPECIES; i++) {
321 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
322 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
323 for (i=0;i<kTRDnPlanes;i++) {
326 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
327 for (i=0;i<3;i++) {fTOFLabel[i]=0;}
328 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
329 for (i=0;i<12;i++) {fITSModule[i]=-1;}
331 // Calculate the AliExternalTrackParam content
338 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
339 alpha = part->Phi()*180./TMath::Pi();
340 if (alpha<0) alpha+= 360.;
341 if (alpha>360) alpha -= 360.;
343 Int_t sector = (Int_t)(alpha/20.);
344 alpha = 10. + 20.*sector;
346 alpha *= TMath::Pi();
348 // Covariance matrix: no errors, the parameters are exact
349 for (i=0; i<15; i++) covar[i]=0.;
351 // Get the vertex of origin and the momentum
352 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
353 TVector3 mom(part->Px(),part->Py(),part->Pz());
355 // Rotate to the local coordinate system (TPC sector)
359 // X of the referense plane
362 Int_t pdgCode = part->GetPdgCode();
365 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
369 param[2] = TMath::Sin(mom.Phi());
370 param[3] = mom.Pz()/mom.Pt();
371 param[4] = TMath::Sign(1/mom.Pt(),charge);
373 // Set AliExternalTrackParam
374 Set(xref, alpha, param, covar);
379 switch (TMath::Abs(pdgCode)) {
405 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
406 if (indexPID < AliPID::kSPECIES) {
412 fHMPIDr[indexPID]=1.;
415 // AliESD track label
416 SetLabel(part->GetUniqueID());
420 //_______________________________________________________________________
421 AliESDtrack::~AliESDtrack(){
423 // This is destructor according Coding Conventrions
425 //printf("Delete track\n");
435 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
438 if(&source == this) return *this;
439 AliExternalTrackParam::operator=(source);
443 // we have the trackparam: assign or copy construct
444 if(fCp)*fCp = *source.fCp;
445 else fCp = new AliExternalTrackParam(*source.fCp);
448 // no track param delete the old one
454 // we have the trackparam: assign or copy construct
455 if(fIp)*fIp = *source.fIp;
456 else fIp = new AliExternalTrackParam(*source.fIp);
459 // no track param delete the old one
465 if(source.fTPCInner){
466 // we have the trackparam: assign or copy construct
467 if(fTPCInner) *fTPCInner = *source.fTPCInner;
468 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
471 // no track param delete the old one
472 if(fTPCInner)delete fTPCInner;
478 // we have the trackparam: assign or copy construct
479 if(fOp) *fOp = *source.fOp;
480 else fOp = new AliExternalTrackParam(*source.fOp);
483 // no track param delete the old one
488 // copy also the friend track
489 // use copy constructor
490 if(source.fFriendTrack){
491 // we have the trackparam: assign or copy construct
492 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
495 // no track param delete the old one
496 delete fFriendTrack; fFriendTrack= 0;
499 fTPCClusterMap = source.fTPCClusterMap;
500 fTPCSharedMap = source.fTPCSharedMap;
502 fFlags = source.fFlags;
504 fLabel = source.fLabel;
505 fITSLabel = source.fITSLabel;
506 for(int i = 0; i< 12;++i){
507 fITSModule[i] = source.fITSModule[i];
509 fTPCLabel = source.fTPCLabel;
510 fTRDLabel = source.fTRDLabel;
511 for(int i = 0; i< 3;++i){
512 fTOFLabel[i] = source.fTOFLabel[i];
514 fTOFCalChannel = source.fTOFCalChannel;
515 fTOFindex = source.fTOFindex;
516 fHMPIDqn = source.fHMPIDqn;
517 fHMPIDcluIdx = source.fHMPIDcluIdx;
518 fEMCALindex = source.fEMCALindex;
520 for(int i = 0; i< 3;++i){
521 fKinkIndexes[i] = source.fKinkIndexes[i];
522 fV0Indexes[i] = source.fV0Indexes[i];
525 for(int i = 0; i< AliPID::kSPECIES;++i){
526 fR[i] = source.fR[i];
527 fITSr[i] = source.fITSr[i];
528 fTPCr[i] = source.fTPCr[i];
529 fTRDr[i] = source.fTRDr[i];
530 fTOFr[i] = source.fTOFr[i];
531 fHMPIDr[i] = source.fHMPIDr[i];
532 fTrackTime[i] = source.fTrackTime[i];
535 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
536 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
537 fHMPIDsignal = source.fHMPIDsignal;
540 fTrackLength = source. fTrackLength;
541 fdTPC = source.fdTPC;
542 fzTPC = source.fzTPC;
543 fCddTPC = source.fCddTPC;
544 fCdzTPC = source.fCdzTPC;
545 fCzzTPC = source.fCzzTPC;
552 fCchi2 = source.fCchi2;
553 fITSchi2 = source.fITSchi2;
554 fTPCchi2 = source.fTPCchi2;
555 fTRDchi2 = source.fTRDchi2;
556 fTOFchi2 = source.fTOFchi2;
557 fHMPIDchi2 = source.fHMPIDchi2;
560 fITSsignal = source.fITSsignal;
561 fTPCsignal = source.fTPCsignal;
562 fTPCsignalS = source.fTPCsignalS;
563 for(int i = 0; i< 4;++i){
564 fTPCPoints[i] = source.fTPCPoints[i];
566 fTRDsignal = source.fTRDsignal;
568 for(int i = 0;i < kTRDnPlanes;++i){
569 fTRDTimBin[i] = source.fTRDTimBin[i];
575 fTRDnSlices=source.fTRDnSlices;
577 fTRDslices=new Double32_t[fTRDnSlices];
578 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
581 fTRDQuality = source.fTRDQuality;
582 fTRDBudget = source.fTRDBudget;
583 fTOFsignal = source.fTOFsignal;
584 fTOFsignalToT = source.fTOFsignalToT;
585 fTOFsignalRaw = source.fTOFsignalRaw;
586 fTOFsignalDz = source.fTOFsignalDz;
588 for(int i = 0;i<10;++i){
589 fTOFInfo[i] = source.fTOFInfo[i];
592 fHMPIDtrkX = source.fHMPIDtrkX;
593 fHMPIDtrkY = source.fHMPIDtrkY;
594 fHMPIDmipX = source.fHMPIDmipX;
595 fHMPIDmipY = source.fHMPIDmipY;
597 fTPCncls = source.fTPCncls;
598 fTPCnclsF = source.fTPCnclsF;
599 fTPCsignalN = source.fTPCsignalN;
601 fITSncls = source.fITSncls;
602 fITSClusterMap = source.fITSClusterMap;
603 fTRDncls = source.fTRDncls;
604 fTRDncls0 = source.fTRDncls0;
605 fTRDpidQuality = source.fTRDpidQuality;
611 void AliESDtrack::Copy(TObject &obj) const {
613 // this overwrites the virtual TOBject::Copy()
614 // to allow run time copying without casting
617 if(this==&obj)return;
618 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
619 if(!robj)return; // not an AliESDtrack
626 void AliESDtrack::AddCalibObject(TObject * object){
628 // add calib object to the list
630 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
631 fFriendTrack->AddCalibObject(object);
634 TObject * AliESDtrack::GetCalibObject(Int_t index){
636 // return calib objct at given position
638 if (!fFriendTrack) return 0;
639 return fFriendTrack->GetCalibObject(index);
643 const Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
645 // Fills the information of the TPC-only first reconstruction pass
646 // into the passed ESDtrack object. For consistency fTPCInner is also filled
649 if(!fTPCInner)return kFALSE;
651 // fill the TPC track params to the global track parameters
652 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
655 track.fCdd = fCddTPC;
656 track.fCdz = fCdzTPC;
657 track.fCzz = fCzzTPC;
659 // copy the TPCinner parameters
660 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
661 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
664 track.fCddTPC = fCddTPC;
665 track.fCdzTPC = fCdzTPC;
666 track.fCzzTPC = fCzzTPC;
669 // copy all other TPC specific parameters
671 // replace label by TPC label
672 track.fLabel = fTPCLabel;
673 track.fTPCLabel = fTPCLabel;
675 track.fTPCchi2 = fTPCchi2;
676 track.fTPCsignal = fTPCsignal;
677 track.fTPCsignalS = fTPCsignalS;
678 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
680 track.fTPCncls = fTPCncls;
681 track.fTPCnclsF = fTPCnclsF;
682 track.fTPCsignalN = fTPCsignalN;
685 for(int i=0;i<AliPID::kSPECIES;++i){
686 track.fTPCr[i] = fTPCr[i];
687 // combined PID is TPC only!
688 track.fR[i] = fTPCr[i];
690 track.fTPCClusterMap = fTPCClusterMap;
691 track.fTPCSharedMap = fTPCSharedMap;
695 track.fFlags = kTPCin;
699 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
705 //_______________________________________________________________________
706 void AliESDtrack::MakeMiniESDtrack(){
707 // Resets everything except
708 // fFlags: Reconstruction status flags
709 // fLabel: Track label
710 // fID: Unique ID of the track
711 // Impact parameter information
712 // fR[AliPID::kSPECIES]: combined "detector response probability"
713 // Running track parameters in the base class (AliExternalTrackParam)
717 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
719 // Reset track parameters constrained to the primary vertex
723 // Reset track parameters at the inner wall of TPC
725 delete fTPCInner;fTPCInner=0;
726 // Reset track parameters at the inner wall of the TRD
730 // Reset ITS track related information
735 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
738 // Reset TPC related track information
747 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
749 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
750 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
751 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
753 // Reset TRD related track information
758 for (Int_t i=0;i<kTRDnPlanes;i++) {
761 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
771 // Reset TOF related track information
779 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
780 for (Int_t i=0;i<3;i++) fTOFLabel[i] = 0;
781 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
783 // Reset HMPID related track information
788 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
795 fEMCALindex = kEMCALNoMatch;
797 delete fFriendTrack; fFriendTrack = 0;
799 //_______________________________________________________________________
800 Double_t AliESDtrack::GetMass() const {
801 // Returns the mass of the most probable particle type
804 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
805 if (fR[i]>max) {k=i; max=fR[i];}
807 if (k==0) { // dE/dx "crossing points" in the TPC
809 if ((p>0.38)&&(p<0.48))
810 if (fR[0]<fR[3]*10.) return AliPID::ParticleMass(AliPID::kKaon);
811 if ((p>0.75)&&(p<0.85))
812 if (fR[0]<fR[4]*10.) return AliPID::ParticleMass(AliPID::kProton);
815 if (k==1) return AliPID::ParticleMass(AliPID::kMuon);
816 if (k==2||k==-1) return AliPID::ParticleMass(AliPID::kPion);
817 if (k==3) return AliPID::ParticleMass(AliPID::kKaon);
818 if (k==4) return AliPID::ParticleMass(AliPID::kProton);
819 AliWarning("Undefined mass !");
820 return AliPID::ParticleMass(AliPID::kPion);
823 //______________________________________________________________________________
824 Double_t AliESDtrack::E() const
826 // Returns the energy of the particle given its assumed mass.
827 // Assumes the pion mass if the particle can't be identified properly.
831 return TMath::Sqrt(p*p + m*m);
834 //______________________________________________________________________________
835 Double_t AliESDtrack::Y() const
837 // Returns the rapidity of a particle given its assumed mass.
838 // Assumes the pion mass if the particle can't be identified properly.
842 if (e != TMath::Abs(pz)) { // energy was not equal to pz
843 return 0.5*TMath::Log((e+pz)/(e-pz));
844 } else { // energy was equal to pz
849 //_______________________________________________________________________
850 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
852 // This function updates track's running parameters
858 fLabel=t->GetLabel();
860 if (t->IsStartedTimeIntegral()) {
862 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
863 SetIntegratedLength(t->GetIntegratedLength());
866 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
870 case kITSin: case kITSout: case kITSrefit:
872 fITSncls=t->GetNumberOfClusters();
873 index=fFriendTrack->GetITSindices();
874 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
875 index[i]=t->GetClusterIndex(i);
877 Int_t l=(index[i] & 0xf0000000) >> 28;
878 SETBIT(fITSClusterMap,l);
881 fITSchi2=t->GetChi2();
882 fITSsignal=t->GetPIDsignal();
883 fITSLabel = t->GetLabel();
884 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
885 if (flags==kITSout) {
886 if (!fOp) fOp=new AliExternalTrackParam(*t);
888 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
892 case kTPCin: case kTPCrefit:
893 fTPCLabel = t->GetLabel();
894 if (flags==kTPCin) fTPCInner=new AliExternalTrackParam(*t);
895 if (!fIp) fIp=new AliExternalTrackParam(*t);
897 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
899 index=fFriendTrack->GetTPCindices();
900 if (flags & kTPCout){
901 if (!fOp) fOp=new AliExternalTrackParam(*t);
903 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
905 fTPCncls=t->GetNumberOfClusters();
906 fTPCchi2=t->GetChi2();
908 {//prevrow must be declared in separate namespace, otherwise compiler cries:
909 //"jump to case label crosses initialization of `Int_t prevrow'"
911 // for (Int_t i=0;i<fTPCncls;i++)
912 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
914 index[i]=t->GetClusterIndex(i);
915 Int_t idx = index[i];
919 // Piotr's Cluster Map for HBT
920 // ### please change accordingly if cluster array is changing
921 // to "New TPC Tracking" style (with gaps in array)
922 Int_t sect = (idx&0xff000000)>>24;
923 Int_t row = (idx&0x00ff0000)>>16;
924 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
926 fTPCClusterMap.SetBitNumber(row,kTRUE);
928 //Fill the gap between previous row and this row with 0 bits
929 //In case ### pleas change it as well - just set bit 0 in case there
930 //is no associated clusters for current "i"
933 prevrow = row;//if previous bit was not assigned yet == this is the first one
936 { //we don't know the order (inner to outer or reverse)
937 //just to be save in case it is going to change
950 for (Int_t j = n+1; j < m; j++)
952 fTPCClusterMap.SetBitNumber(j,kFALSE);
956 // End Of Piotr's Cluster Map for HBT
959 fTPCsignal=t->GetPIDsignal();
962 case kTRDout: case kTRDin: case kTRDrefit:
963 index = fFriendTrack->GetTRDindices();
964 fTRDLabel = t->GetLabel();
965 fTRDchi2 = t->GetChi2();
966 fTRDncls = t->GetNumberOfClusters();
967 for (Int_t i=0;i<6;i++) index[i]=t->GetTrackletIndex(i);
969 fTRDsignal=t->GetPIDsignal();
972 if (!fOp) fOp=new AliExternalTrackParam(*t);
974 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
975 fTRDncls0 = t->GetNumberOfClusters();
984 AliError("Wrong flag !");
991 //_______________________________________________________________________
992 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
993 //---------------------------------------------------------------------
994 // This function returns external representation of the track parameters
995 //---------------------------------------------------------------------
997 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1000 //_______________________________________________________________________
1001 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1002 //---------------------------------------------------------------------
1003 // This function returns external representation of the cov. matrix
1004 //---------------------------------------------------------------------
1005 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1008 //_______________________________________________________________________
1009 Bool_t AliESDtrack::GetConstrainedExternalParameters
1010 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1011 //---------------------------------------------------------------------
1012 // This function returns the constrained external track parameters
1013 //---------------------------------------------------------------------
1014 if (!fCp) return kFALSE;
1015 alpha=fCp->GetAlpha();
1017 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1021 //_______________________________________________________________________
1023 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1024 //---------------------------------------------------------------------
1025 // This function returns the constrained external cov. matrix
1026 //---------------------------------------------------------------------
1027 if (!fCp) return kFALSE;
1028 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1033 AliESDtrack::GetInnerExternalParameters
1034 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1035 //---------------------------------------------------------------------
1036 // This function returns external representation of the track parameters
1037 // at the inner layer of TPC
1038 //---------------------------------------------------------------------
1039 if (!fIp) return kFALSE;
1040 alpha=fIp->GetAlpha();
1042 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1047 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1048 //---------------------------------------------------------------------
1049 // This function returns external representation of the cov. matrix
1050 // at the inner layer of TPC
1051 //---------------------------------------------------------------------
1052 if (!fIp) return kFALSE;
1053 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1058 AliESDtrack::GetOuterExternalParameters
1059 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1060 //---------------------------------------------------------------------
1061 // This function returns external representation of the track parameters
1062 // at the inner layer of TRD
1063 //---------------------------------------------------------------------
1064 if (!fOp) return kFALSE;
1065 alpha=fOp->GetAlpha();
1067 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1072 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1073 //---------------------------------------------------------------------
1074 // This function returns external representation of the cov. matrix
1075 // at the inner layer of TRD
1076 //---------------------------------------------------------------------
1077 if (!fOp) return kFALSE;
1078 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1082 Int_t AliESDtrack::GetNcls(Int_t idet) const
1084 // Get number of clusters by subdetector index
1098 if (fTOFindex != -1)
1107 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1109 // Get cluster index array by subdetector index
1114 ncls = GetITSclusters(idx);
1117 ncls = GetTPCclusters(idx);
1120 ncls = GetTRDclusters(idx);
1123 if (fTOFindex != -1) {
1131 if (fHMPIDcluIdx != 0) {
1132 idx[0] = GetHMPIDcluIdx();
1144 //_______________________________________________________________________
1145 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1146 // Returns the array with integrated times for each particle hypothesis
1147 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1150 //_______________________________________________________________________
1151 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1152 // Sets the array with integrated times for each particle hypotesis
1153 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1156 //_______________________________________________________________________
1157 void AliESDtrack::SetITSpid(const Double_t *p) {
1158 // Sets values for the probability of each particle type (in ITS)
1159 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1160 SetStatus(AliESDtrack::kITSpid);
1163 //_______________________________________________________________________
1164 void AliESDtrack::GetITSpid(Double_t *p) const {
1165 // Gets the probability of each particle type (in ITS)
1166 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1169 //_______________________________________________________________________
1170 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1171 //---------------------------------------------------------------------
1172 // This function returns indices of the assgined ITS clusters
1173 //---------------------------------------------------------------------
1175 Int_t *index=fFriendTrack->GetITSindices();
1176 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) idx[i]=index[i];
1181 //_______________________________________________________________________
1182 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1183 Float_t &xloc,Float_t &zloc) const {
1184 //----------------------------------------------------------------------
1185 // This function encodes in the module number also the status of cluster association
1186 // "status" can have the following values:
1187 // 1 "found" (cluster is associated),
1188 // 2 "dead" (module is dead from OCDB),
1189 // 3 "skipped" (module or layer forced to be skipped),
1190 // 4 "outinz" (track out of z acceptance),
1191 // 5 "nocls" (no clusters in the road),
1192 // 6 "norefit" (cluster rejected during refit),
1193 // 7 "deadzspd" (holes in z in SPD)
1194 // Also given are the coordinates of the crossing point of track and module
1195 // (in the local module ref. system)
1196 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1197 //----------------------------------------------------------------------
1199 if(fITSModule[ilayer]==-1) {
1200 AliError("fModule was not set !");
1203 xloc=-99.; zloc=-99.;
1207 Int_t module = fITSModule[ilayer];
1209 idet = Int_t(module/1000000);
1211 module -= idet*1000000;
1213 status = Int_t(module/100000);
1215 module -= status*100000;
1217 Int_t signs = Int_t(module/10000);
1219 module-=signs*10000;
1221 Int_t xInt = Int_t(module/100);
1224 Int_t zInt = module;
1226 if(signs==1) { xInt*=1; zInt*=1; }
1227 if(signs==2) { xInt*=1; zInt*=-1; }
1228 if(signs==3) { xInt*=-1; zInt*=1; }
1229 if(signs==4) { xInt*=-1; zInt*=-1; }
1231 xloc = 0.1*(Float_t)xInt;
1232 zloc = 0.1*(Float_t)zInt;
1234 if(status==4) idet = -1;
1239 //_______________________________________________________________________
1240 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1241 //---------------------------------------------------------------------
1242 // This function returns indices of the assgined ITS clusters
1243 //---------------------------------------------------------------------
1245 Int_t *index=fFriendTrack->GetTPCindices();
1246 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1251 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1253 // GetDensity of the clusters on given region between row0 and row1
1254 // Dead zone effect takin into acoount
1259 Int_t *index=fFriendTrack->GetTPCindices();
1260 for (Int_t i=row0;i<=row1;i++){
1261 Int_t idx = index[i];
1262 if (idx!=-1) good++; // track outside of dead zone
1265 Float_t density=0.5;
1266 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1270 //_______________________________________________________________________
1271 void AliESDtrack::SetTPCpid(const Double_t *p) {
1272 // Sets values for the probability of each particle type (in TPC)
1273 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1274 SetStatus(AliESDtrack::kTPCpid);
1277 //_______________________________________________________________________
1278 void AliESDtrack::GetTPCpid(Double_t *p) const {
1279 // Gets the probability of each particle type (in TPC)
1280 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1283 //_______________________________________________________________________
1284 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1285 //---------------------------------------------------------------------
1286 // This function returns indices of the assgined TRD clusters
1287 //---------------------------------------------------------------------
1289 Int_t *index=fFriendTrack->GetTRDindices();
1290 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1295 //_______________________________________________________________________
1296 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1297 //---------------------------------------------------------------------
1298 // This function returns indices of the assigned TRD tracklets
1299 //---------------------------------------------------------------------
1301 Int_t *index=fFriendTrack->GetTRDindices();
1302 for (Int_t i=0; i<6/*AliESDfriendTrack::kMaxTRDcluster*/; i++) idx[i]=index[i];
1307 //_______________________________________________________________________
1308 void AliESDtrack::SetTRDpid(const Double_t *p) {
1309 // Sets values for the probability of each particle type (in TRD)
1310 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1311 SetStatus(AliESDtrack::kTRDpid);
1314 //_______________________________________________________________________
1315 void AliESDtrack::GetTRDpid(Double_t *p) const {
1316 // Gets the probability of each particle type (in TRD)
1317 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1320 //_______________________________________________________________________
1321 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1323 // Sets the probability of particle type iSpecies to p (in TRD)
1324 fTRDr[iSpecies] = p;
1327 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1329 // Returns the probability of particle type iSpecies (in TRD)
1330 return fTRDr[iSpecies];
1333 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1334 //Sets the number of slices used for PID
1335 if (fTRDnSlices != 0) return;
1336 fTRDnSlices=kTRDnPlanes*n;
1337 fTRDslices=new Double32_t[fTRDnSlices];
1338 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=-1.;
1341 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1342 //Sets the charge q in the slice of the plane
1343 Int_t ns=GetNumberOfTRDslices();
1345 AliError("No TRD slices allocated for this track !");
1349 if ((plane<0) || (plane>=kTRDnPlanes)) {
1350 AliError("Wrong TRD plane !");
1353 if ((slice<0) || (slice>=ns)) {
1354 AliError("Wrong TRD slice !");
1357 Int_t n=plane*ns + slice;
1361 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1362 //Gets the charge from the slice of the plane
1363 Int_t ns=GetNumberOfTRDslices();
1365 //AliError("No TRD slices allocated for this track !");
1369 if ((plane<0) || (plane>=kTRDnPlanes)) {
1370 AliError("Wrong TRD plane !");
1373 if ((slice<-1) || (slice>=ns)) {
1374 //AliError("Wrong TRD slice !");
1380 for (Int_t i=0; i<ns; i++) q+=fTRDslices[plane*ns + i];
1384 return fTRDslices[plane*ns + slice];
1388 //_______________________________________________________________________
1389 void AliESDtrack::SetTOFpid(const Double_t *p) {
1390 // Sets the probability of each particle type (in TOF)
1391 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
1392 SetStatus(AliESDtrack::kTOFpid);
1395 //_______________________________________________________________________
1396 void AliESDtrack::SetTOFLabel(const Int_t *p) {
1398 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1401 //_______________________________________________________________________
1402 void AliESDtrack::GetTOFpid(Double_t *p) const {
1403 // Gets probabilities of each particle type (in TOF)
1404 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
1407 //_______________________________________________________________________
1408 void AliESDtrack::GetTOFLabel(Int_t *p) const {
1410 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
1413 //_______________________________________________________________________
1414 void AliESDtrack::GetTOFInfo(Float_t *info) const {
1416 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
1419 //_______________________________________________________________________
1420 void AliESDtrack::SetTOFInfo(Float_t*info) {
1422 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
1427 //_______________________________________________________________________
1428 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
1429 // Sets the probability of each particle type (in HMPID)
1430 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
1431 SetStatus(AliESDtrack::kHMPIDpid);
1434 //_______________________________________________________________________
1435 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
1436 // Gets probabilities of each particle type (in HMPID)
1437 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
1442 //_______________________________________________________________________
1443 void AliESDtrack::SetESDpid(const Double_t *p) {
1444 // Sets the probability of each particle type for the ESD track
1445 SetPIDValues(fR,p,AliPID::kSPECIES);
1446 SetStatus(AliESDtrack::kESDpid);
1449 //_______________________________________________________________________
1450 void AliESDtrack::GetESDpid(Double_t *p) const {
1451 // Gets probability of each particle type for the ESD track
1452 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
1455 //_______________________________________________________________________
1456 Bool_t AliESDtrack::RelateToVertexTPC
1457 (const AliESDVertex *vtx, Double_t b, Double_t maxd) {
1459 // Try to relate the TPC-only track paramters to the vertex "vtx",
1460 // if the (rough) transverse impact parameter is not bigger then "maxd".
1461 // Magnetic field is "b" (kG).
1463 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
1464 // b) The impact parameters and their covariance matrix are calculated.
1467 if (!fTPCInner) return kFALSE;
1468 if (!vtx) return kFALSE;
1470 Double_t dz[2],cov[3];
1471 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1482 //_______________________________________________________________________
1483 Bool_t AliESDtrack::RelateToVertex
1484 (const AliESDVertex *vtx, Double_t b, Double_t maxd) {
1486 // Try to relate this track to the vertex "vtx",
1487 // if the (rough) transverse impact parameter is not bigger then "maxd".
1488 // Magnetic field is "b" (kG).
1490 // a) The track gets extapolated to the DCA to the vertex.
1491 // b) The impact parameters and their covariance matrix are calculated.
1492 // c) An attempt to constrain this track to the vertex is done.
1494 // In the case of success, the returned value is kTRUE
1495 // (otherwise, it's kFALSE)
1498 if (!vtx) return kFALSE;
1500 Double_t dz[2],cov[3];
1501 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
1509 Double_t covar[6]; vtx->GetCovMatrix(covar);
1510 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
1511 Double_t c[3]={covar[2],0.,covar[5]};
1513 Double_t chi2=GetPredictedChi2(p,c);
1514 if (chi2>77.) return kFALSE;
1517 fCp=new AliExternalTrackParam(*this);
1519 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
1525 //_______________________________________________________________________
1526 void AliESDtrack::Print(Option_t *) const {
1527 // Prints info on the track
1528 AliExternalTrackParam::Print();
1529 printf("ESD track info\n") ;
1530 Double_t p[AliPID::kSPECIESN] ;
1532 if( IsOn(kITSpid) ){
1533 printf("From ITS: ") ;
1535 for(index = 0 ; index < AliPID::kSPECIES; index++)
1536 printf("%f, ", p[index]) ;
1537 printf("\n signal = %f\n", GetITSsignal()) ;
1539 if( IsOn(kTPCpid) ){
1540 printf("From TPC: ") ;
1542 for(index = 0 ; index < AliPID::kSPECIES; index++)
1543 printf("%f, ", p[index]) ;
1544 printf("\n signal = %f\n", GetTPCsignal()) ;
1546 if( IsOn(kTRDpid) ){
1547 printf("From TRD: ") ;
1549 for(index = 0 ; index < AliPID::kSPECIES; index++)
1550 printf("%f, ", p[index]) ;
1551 printf("\n signal = %f\n", GetTRDsignal()) ;
1553 if( IsOn(kTOFpid) ){
1554 printf("From TOF: ") ;
1556 for(index = 0 ; index < AliPID::kSPECIES; index++)
1557 printf("%f, ", p[index]) ;
1558 printf("\n signal = %f\n", GetTOFsignal()) ;
1560 if( IsOn(kHMPIDpid) ){
1561 printf("From HMPID: ") ;
1563 for(index = 0 ; index < AliPID::kSPECIES; index++)
1564 printf("%f, ", p[index]) ;
1565 printf("\n signal = %f\n", GetHMPIDsignal()) ;
1571 // Draw functionality
1572 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
1574 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
1576 // Fill points in the polymarker
1579 arrayRef.AddLast(new AliExternalTrackParam(*this));
1580 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
1581 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
1583 Double_t mpos[3]={0,0,0};
1584 Int_t entries=arrayRef.GetEntries();
1585 for (Int_t i=0;i<entries;i++){
1587 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
1588 mpos[0]+=pos[0]/entries;
1589 mpos[1]+=pos[1]/entries;
1590 mpos[2]+=pos[2]/entries;
1592 // Rotate to the mean position
1594 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
1595 for (Int_t i=0;i<entries;i++){
1596 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
1597 if (!res) delete arrayRef.RemoveAt(i);
1600 for (Double_t r=minR; r<maxR; r+=stepR){
1602 Double_t mlpos[3]={0,0,0};
1603 for (Int_t i=0;i<entries;i++){
1604 Double_t point[3]={0,0,0};
1605 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
1606 if (!param) continue;
1607 if (param->GetXYZAt(r,magF,point)){
1608 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
1610 mlpos[0]+=point[0]*weight;
1611 mlpos[1]+=point[1]*weight;
1612 mlpos[2]+=point[2]*weight;
1619 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
1620 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);