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
24 // What do you need to know before starting analysis
25 // (by Marian Ivanov: marian.ivanov@cern.ch)
29 // 1. What is the AliESDtrack
30 // 2. What informations do we store
31 // 3. How to use the information for analysis
34 // 1.AliESDtrack is the container of the information about the track/particle
35 // reconstructed during Barrel Tracking.
36 // The track information is propagated from one tracking detector to
37 // other using the functionality of AliESDtrack - Current parameters.
39 // No global fit model is used.
40 // Barrel tracking use Kalman filtering technique, it gives optimal local
41 // track parameters at given point under certian assumptions.
43 // Kalman filter take into account additional effect which are
44 // difficult to handle using global fit.
46 // a.) Multiple scattering
48 // c.) Non homogenous magnetic field
50 // In general case, following barrel detectors are contributing to
51 // the Kalman track information:
56 // In general 3 reconstruction itteration are performed:
57 // 1. Find tracks - sequence TPC->ITS
58 // 2. PropagateBack - sequence ITS->TPC->TRD -> Outer PID detectors
59 // 3. Refit invward - sequence TRD->TPC->ITS
60 // The current tracks are updated after each detector (see bellow).
61 // In specical cases a track sanpshots are stored.
64 // For some type of analysis (+visualization) track local parameters at
65 // different position are neccesary. A snapshots during the track
66 // propagation are created.
67 // (See AliExternalTrackParam class for desctiption of variables and
70 // a. Current parameters - class itself (AliExternalTrackParam)
71 // Contributors: general case TRD->TPC->ITS
72 // Preferable usage: Decission - primary or secondary track
73 // NOTICE - By default the track parameters are stored at the DCA point
74 // to the primary vertex. optimal for primary tracks,
75 // far from optimal for secondary tracks.
76 // b. Constrained parameters - Kalman information updated with
77 // the Primary vertex information
78 // Contributors: general case TRD->TPC->ITS
79 // Preferable usage: Use only for tracks selected as primary
80 // NOTICE - not real constrain - taken as additional measurement
81 // with corresponding error
83 // const AliExternalTrackParam *GetConstrainedParam() const {return fCp;}
84 // c. Inner parameters - Track parameters at inner wall of the TPC
85 // Contributors: general case TRD->TPC
87 // const AliExternalTrackParam *GetInnerParam() const { return fIp;}
89 // d. TPCinnerparam - contributors - TPC only
91 // Preferable usage: Requested for HBT study
92 // (smaller correlations as using also ITS information)
93 // NOTICE - the track parameters are propagated to the DCA to
95 // Optimal for primary, far from optimal for secondary tracks
97 // const AliExternalTrackParam *GetTPCInnerParam() const {return fTPCInner;}
99 // e. Outer parameters -
100 // Contributors- general case - ITS-> TPC -> TRD
101 // The last point - Outer parameters radius is determined
102 // e.a) Local inclination angle bigger than threshold -
103 // Low momenta tracks
104 // e.a) Catastrofic energy losss in material
105 // e.b) Not further improvement (no space points)
107 // a.) Tracking: Starting parameter for Refit inward
110 // NOTICE: Should be not used for the physic analysis
112 // const AliExternalTrackParam *GetOuterParam() const { return fOp;}
114 //-----------------------------------------------------------------
117 #include <TParticle.h>
118 #include <TDatabasePDG.h>
120 #include "AliESDVertex.h"
121 #include "AliESDtrack.h"
122 #include "AliESDEvent.h"
123 #include "AliKalmanTrack.h"
124 #include "AliVTrack.h"
126 #include "AliTrackPointArray.h"
127 #include "TPolyMarker3D.h"
129 ClassImp(AliESDtrack)
131 void SetPIDValues(Double_t * dest, const Double_t * src, Int_t n) {
132 // This function copies "n" PID weights from "scr" to "dest"
133 // and normalizes their sum to 1 thus producing conditional probabilities.
134 // The negative weights are set to 0.
135 // In case all the weights are non-positive they are replaced by
136 // uniform probabilities
140 Float_t uniform = 1./(Float_t)n;
143 for (Int_t i=0; i<n; i++)
153 for (Int_t i=0; i<n; i++) dest[i] /= sum;
155 for (Int_t i=0; i<n; i++) dest[i] = uniform;
158 //_______________________________________________________________________
159 AliESDtrack::AliESDtrack() :
160 AliExternalTrackParam(),
167 fTPCClusterMap(159),//number of padrows
168 fTPCSharedMap(159),//number of padrows
179 fCaloIndex(kEMCALNoMatch),
185 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
188 fCdd(0),fCdz(0),fCzz(0),
204 fTOFsignalToT(99999),
205 fTOFsignalRaw(99999),
229 fVertexID(-2),// -2 means an orphan track
233 // The default ESD constructor
235 if (!OnlineMode()) fFriendTrack=new AliESDfriendTrack();
238 for (i=0; i<AliPID::kSPECIES; i++) {
248 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
249 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
250 for (i=0;i<kTRDnPlanes;i++) {
253 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
254 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
255 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
256 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
257 for (i=0;i<12;i++) {fITSModule[i]=-1;}
260 bool AliESDtrack::fgkOnlineMode=false;
262 //_______________________________________________________________________
263 AliESDtrack::AliESDtrack(const AliESDtrack& track):
264 AliExternalTrackParam(track),
271 fTPCClusterMap(track.fTPCClusterMap),
272 fTPCSharedMap(track.fTPCSharedMap),
273 fFlags(track.fFlags),
275 fLabel(track.fLabel),
276 fITSLabel(track.fITSLabel),
277 fTPCLabel(track.fTPCLabel),
278 fTRDLabel(track.fTRDLabel),
279 fTOFCalChannel(track.fTOFCalChannel),
280 fTOFindex(track.fTOFindex),
281 fHMPIDqn(track.fHMPIDqn),
282 fHMPIDcluIdx(track.fHMPIDcluIdx),
283 fCaloIndex(track.fCaloIndex),
284 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
285 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
286 fHMPIDsignal(track.fHMPIDsignal),
287 fTrackLength(track.fTrackLength),
288 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
289 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
290 fCchi2TPC(track.fCchi2TPC),
291 fD(track.fD),fZ(track.fZ),
292 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
293 fCchi2(track.fCchi2),
294 fITSchi2(track.fITSchi2),
295 fTPCchi2(track.fTPCchi2),
296 fTPCchi2Iter1(track.fTPCchi2Iter1),
297 fTRDchi2(track.fTRDchi2),
298 fTOFchi2(track.fTOFchi2),
299 fHMPIDchi2(track.fHMPIDchi2),
300 fGlobalChi2(track.fGlobalChi2),
301 fITSsignal(track.fITSsignal),
302 fTPCsignal(track.fTPCsignal),
303 fTPCsignalS(track.fTPCsignalS),
304 fTRDsignal(track.fTRDsignal),
305 fTRDQuality(track.fTRDQuality),
306 fTRDBudget(track.fTRDBudget),
307 fTOFsignal(track.fTOFsignal),
308 fTOFsignalToT(track.fTOFsignalToT),
309 fTOFsignalRaw(track.fTOFsignalRaw),
310 fTOFsignalDz(track.fTOFsignalDz),
311 fTOFsignalDx(track.fTOFsignalDx),
312 fTOFdeltaBC(track.fTOFdeltaBC),
313 fTOFl0l1(track.fTOFl0l1),
314 fCaloDx(track.fCaloDx),
315 fCaloDz(track.fCaloDz),
316 fHMPIDtrkX(track.fHMPIDtrkX),
317 fHMPIDtrkY(track.fHMPIDtrkY),
318 fHMPIDmipX(track.fHMPIDmipX),
319 fHMPIDmipY(track.fHMPIDmipY),
320 fTPCncls(track.fTPCncls),
321 fTPCnclsF(track.fTPCnclsF),
322 fTPCsignalN(track.fTPCsignalN),
323 fTPCnclsIter1(track.fTPCnclsIter1),
324 fTPCnclsFIter1(track.fTPCnclsIter1),
325 fITSncls(track.fITSncls),
326 fITSClusterMap(track.fITSClusterMap),
327 fITSSharedMap(track.fITSSharedMap),
328 fTRDncls(track.fTRDncls),
329 fTRDncls0(track.fTRDncls0),
330 fTRDntracklets(track.fTRDntracklets),
331 fTRDnSlices(track.fTRDnSlices),
333 fVertexID(track.fVertexID),
334 fESDEvent(track.fESDEvent)
339 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
340 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
342 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
344 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
345 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
346 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
347 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
348 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
350 for (Int_t i=0;i<kTRDnPlanes;i++) {
351 fTRDTimBin[i]=track.fTRDTimBin[i];
355 fTRDslices=new Double32_t[fTRDnSlices];
356 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
359 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
360 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
361 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
362 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
363 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
364 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
366 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
367 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
368 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
369 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
370 if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
372 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
375 //_______________________________________________________________________
376 AliESDtrack::AliESDtrack(const AliVTrack *track) :
377 AliExternalTrackParam(track),
384 fTPCClusterMap(159),//number of padrows
385 fTPCSharedMap(159),//number of padrows
396 fCaloIndex(kEMCALNoMatch),
402 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
405 fCdd(0),fCdz(0),fCzz(0),
421 fTOFsignalToT(99999),
422 fTOFsignalRaw(99999),
446 fVertexID(-2), // -2 means an orphan track
450 // ESD track from AliVTrack.
451 // This is not a copy constructor !
454 if (track->InheritsFrom("AliExternalTrackParam")) {
455 AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
456 AliWarning("Calling the default constructor...");
461 // Reset all the arrays
463 for (i=0; i<AliPID::kSPECIES; i++) {
473 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
474 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
475 for (i=0;i<kTRDnPlanes;i++) {
478 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
479 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
480 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
481 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
482 for (i=0;i<12;i++) {fITSModule[i]=-1;}
485 SetID(track->GetID());
487 // Set ITS cluster map
488 fITSClusterMap=track->GetITSClusterMap();
493 if(HasPointOnITSLayer(i)) fITSncls++;
497 fTPCncls=track->GetTPCNcls();
500 // Set the combined PID
501 const Double_t *pid = track->PID();
503 for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
505 // AliESD track label
506 SetLabel(track->GetLabel());
508 SetStatus(track->GetStatus());
511 //_______________________________________________________________________
512 AliESDtrack::AliESDtrack(TParticle * part) :
513 AliExternalTrackParam(),
520 fTPCClusterMap(159),//number of padrows
521 fTPCSharedMap(159),//number of padrows
532 fCaloIndex(kEMCALNoMatch),
538 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
541 fCdd(0),fCdz(0),fCzz(0),
557 fTOFsignalToT(99999),
558 fTOFsignalRaw(99999),
582 fVertexID(-2), // -2 means an orphan track
586 // ESD track from TParticle
589 // Reset all the arrays
591 for (i=0; i<AliPID::kSPECIES; i++) {
601 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
602 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
603 for (i=0;i<kTRDnPlanes;i++) {
606 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
607 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
608 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
609 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
610 for (i=0;i<12;i++) {fITSModule[i]=-1;}
612 // Calculate the AliExternalTrackParam content
619 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
620 alpha = part->Phi()*180./TMath::Pi();
621 if (alpha<0) alpha+= 360.;
622 if (alpha>360) alpha -= 360.;
624 Int_t sector = (Int_t)(alpha/20.);
625 alpha = 10. + 20.*sector;
627 alpha *= TMath::Pi();
629 // Covariance matrix: no errors, the parameters are exact
630 for (i=0; i<15; i++) covar[i]=0.;
632 // Get the vertex of origin and the momentum
633 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
634 TVector3 mom(part->Px(),part->Py(),part->Pz());
636 // Rotate to the local coordinate system (TPC sector)
640 // X of the referense plane
643 Int_t pdgCode = part->GetPdgCode();
646 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
650 param[2] = TMath::Sin(mom.Phi());
651 param[3] = mom.Pz()/mom.Pt();
652 param[4] = TMath::Sign(1/mom.Pt(),charge);
654 // Set AliExternalTrackParam
655 Set(xref, alpha, param, covar);
660 switch (TMath::Abs(pdgCode)) {
686 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
687 if (indexPID < AliPID::kSPECIES) {
693 fHMPIDr[indexPID]=1.;
696 // AliESD track label
697 SetLabel(part->GetUniqueID());
701 //_______________________________________________________________________
702 AliESDtrack::~AliESDtrack(){
704 // This is destructor according Coding Conventrions
706 //printf("Delete track\n");
712 if (fFriendTrack) delete fFriendTrack;
718 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
721 if(&source == this) return *this;
722 AliExternalTrackParam::operator=(source);
726 // we have the trackparam: assign or copy construct
727 if(fCp)*fCp = *source.fCp;
728 else fCp = new AliExternalTrackParam(*source.fCp);
731 // no track param delete the old one
737 // we have the trackparam: assign or copy construct
738 if(fIp)*fIp = *source.fIp;
739 else fIp = new AliExternalTrackParam(*source.fIp);
742 // no track param delete the old one
748 if(source.fTPCInner){
749 // we have the trackparam: assign or copy construct
750 if(fTPCInner) *fTPCInner = *source.fTPCInner;
751 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
754 // no track param delete the old one
755 if(fTPCInner)delete fTPCInner;
761 // we have the trackparam: assign or copy construct
762 if(fOp) *fOp = *source.fOp;
763 else fOp = new AliExternalTrackParam(*source.fOp);
766 // no track param delete the old one
773 // we have the trackparam: assign or copy construct
774 if(fHMPIDp) *fHMPIDp = *source.fHMPIDp;
775 else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
778 // no track param delete the old one
779 if(fHMPIDp)delete fHMPIDp;
784 // copy also the friend track
785 // use copy constructor
786 if(source.fFriendTrack){
787 // we have the trackparam: assign or copy construct
788 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
791 // no track param delete the old one
792 delete fFriendTrack; fFriendTrack= 0;
795 fTPCClusterMap = source.fTPCClusterMap;
796 fTPCSharedMap = source.fTPCSharedMap;
798 fFlags = source.fFlags;
800 fLabel = source.fLabel;
801 fITSLabel = source.fITSLabel;
802 for(int i = 0; i< 12;++i){
803 fITSModule[i] = source.fITSModule[i];
805 fTPCLabel = source.fTPCLabel;
806 fTRDLabel = source.fTRDLabel;
807 for(int i = 0; i< 3;++i){
808 fTOFLabel[i] = source.fTOFLabel[i];
810 fTOFCalChannel = source.fTOFCalChannel;
811 fTOFindex = source.fTOFindex;
812 fHMPIDqn = source.fHMPIDqn;
813 fHMPIDcluIdx = source.fHMPIDcluIdx;
814 fCaloIndex = source.fCaloIndex;
816 for(int i = 0; i< 3;++i){
817 fKinkIndexes[i] = source.fKinkIndexes[i];
818 fV0Indexes[i] = source.fV0Indexes[i];
821 for(int i = 0; i< AliPID::kSPECIES;++i){
822 fR[i] = source.fR[i];
823 fITSr[i] = source.fITSr[i];
824 fTPCr[i] = source.fTPCr[i];
825 fTRDr[i] = source.fTRDr[i];
826 fTOFr[i] = source.fTOFr[i];
827 fHMPIDr[i] = source.fHMPIDr[i];
828 fTrackTime[i] = source.fTrackTime[i];
831 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
832 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
833 fHMPIDsignal = source.fHMPIDsignal;
836 fTrackLength = source. fTrackLength;
837 fdTPC = source.fdTPC;
838 fzTPC = source.fzTPC;
839 fCddTPC = source.fCddTPC;
840 fCdzTPC = source.fCdzTPC;
841 fCzzTPC = source.fCzzTPC;
842 fCchi2TPC = source.fCchi2TPC;
849 fCchi2 = source.fCchi2;
851 fITSchi2 = source.fITSchi2;
852 fTPCchi2 = source.fTPCchi2;
853 fTPCchi2Iter1 = source.fTPCchi2Iter1;
854 fTRDchi2 = source.fTRDchi2;
855 fTOFchi2 = source.fTOFchi2;
856 fHMPIDchi2 = source.fHMPIDchi2;
858 fGlobalChi2 = source.fGlobalChi2;
860 fITSsignal = source.fITSsignal;
861 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
862 fTPCsignal = source.fTPCsignal;
863 fTPCsignalS = source.fTPCsignalS;
864 for(int i = 0; i< 4;++i){
865 fTPCPoints[i] = source.fTPCPoints[i];
867 fTRDsignal = source.fTRDsignal;
869 for(int i = 0;i < kTRDnPlanes;++i){
870 fTRDTimBin[i] = source.fTRDTimBin[i];
876 fTRDnSlices=source.fTRDnSlices;
878 fTRDslices=new Double32_t[fTRDnSlices];
879 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
882 fTRDQuality = source.fTRDQuality;
883 fTRDBudget = source.fTRDBudget;
884 fTOFsignal = source.fTOFsignal;
885 fTOFsignalToT = source.fTOFsignalToT;
886 fTOFsignalRaw = source.fTOFsignalRaw;
887 fTOFsignalDz = source.fTOFsignalDz;
888 fTOFsignalDx = source.fTOFsignalDx;
889 fTOFdeltaBC = source.fTOFdeltaBC;
890 fTOFl0l1 = source.fTOFl0l1;
892 for(int i = 0;i<10;++i){
893 fTOFInfo[i] = source.fTOFInfo[i];
896 fHMPIDtrkX = source.fHMPIDtrkX;
897 fHMPIDtrkY = source.fHMPIDtrkY;
898 fHMPIDmipX = source.fHMPIDmipX;
899 fHMPIDmipY = source.fHMPIDmipY;
901 fTPCncls = source.fTPCncls;
902 fTPCnclsF = source.fTPCnclsF;
903 fTPCsignalN = source.fTPCsignalN;
904 fTPCnclsIter1 = source.fTPCnclsIter1;
905 fTPCnclsFIter1 = source.fTPCnclsFIter1;
907 fITSncls = source.fITSncls;
908 fITSClusterMap = source.fITSClusterMap;
909 fITSSharedMap = source.fITSSharedMap;
910 fTRDncls = source.fTRDncls;
911 fTRDncls0 = source.fTRDncls0;
912 fTRDntracklets = source.fTRDntracklets;
913 fVertexID = source.fVertexID;
919 void AliESDtrack::Copy(TObject &obj) const {
921 // this overwrites the virtual TOBject::Copy()
922 // to allow run time copying without casting
925 if(this==&obj)return;
926 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
927 if(!robj)return; // not an AliESDtrack
934 void AliESDtrack::AddCalibObject(TObject * object){
936 // add calib object to the list
938 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
939 if (!fFriendTrack) return;
940 fFriendTrack->AddCalibObject(object);
943 TObject * AliESDtrack::GetCalibObject(Int_t index){
945 // return calib objct at given position
947 if (!fFriendTrack) return 0;
948 return fFriendTrack->GetCalibObject(index);
952 Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
954 // Fills the information of the TPC-only first reconstruction pass
955 // into the passed ESDtrack object. For consistency fTPCInner is also filled
960 // For data produced before r26675
961 // RelateToVertexTPC was not properly called during reco
962 // so you'll have to call it again, before FillTPCOnlyTrack
963 // Float_t p[2],cov[3];
964 // track->GetImpactParametersTPC(p,cov);
965 // if(p[0]==0&&p[1]==0) // <- Default values
966 // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
969 if(!fTPCInner)return kFALSE;
971 // fill the TPC track params to the global track parameters
972 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
975 track.fCdd = fCddTPC;
976 track.fCdz = fCdzTPC;
977 track.fCzz = fCzzTPC;
979 // copy the inner params
980 if(track.fIp) *track.fIp = *fIp;
981 else track.fIp = new AliExternalTrackParam(*fIp);
983 // copy the TPCinner parameters
984 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
985 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
988 track.fCddTPC = fCddTPC;
989 track.fCdzTPC = fCdzTPC;
990 track.fCzzTPC = fCzzTPC;
991 track.fCchi2TPC = fCchi2TPC;
993 // copy all other TPC specific parameters
995 // replace label by TPC label
996 track.fLabel = fTPCLabel;
997 track.fTPCLabel = fTPCLabel;
999 track.fTPCchi2 = fTPCchi2;
1000 track.fTPCchi2Iter1 = fTPCchi2Iter1;
1001 track.fTPCsignal = fTPCsignal;
1002 track.fTPCsignalS = fTPCsignalS;
1003 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
1005 track.fTPCncls = fTPCncls;
1006 track.fTPCnclsF = fTPCnclsF;
1007 track.fTPCsignalN = fTPCsignalN;
1008 track.fTPCnclsIter1 = fTPCnclsIter1;
1009 track.fTPCnclsFIter1 = fTPCnclsFIter1;
1012 for(int i=0;i<AliPID::kSPECIES;++i){
1013 track.fTPCr[i] = fTPCr[i];
1014 // combined PID is TPC only!
1015 track.fR[i] = fTPCr[i];
1017 track.fTPCClusterMap = fTPCClusterMap;
1018 track.fTPCSharedMap = fTPCSharedMap;
1022 track.fFlags = kTPCin;
1025 track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
1027 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
1033 //_______________________________________________________________________
1034 void AliESDtrack::MakeMiniESDtrack(){
1035 // Resets everything except
1036 // fFlags: Reconstruction status flags
1037 // fLabel: Track label
1038 // fID: Unique ID of the track
1039 // Impact parameter information
1040 // fR[AliPID::kSPECIES]: combined "detector response probability"
1041 // Running track parameters in the base class (AliExternalTrackParam)
1045 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
1047 // Reset track parameters constrained to the primary vertex
1050 // Reset track parameters at the inner wall of TPC
1052 delete fTPCInner;fTPCInner=0;
1053 // Reset track parameters at the inner wall of the TRD
1055 // Reset track parameters at the HMPID
1056 delete fHMPIDp;fHMPIDp = 0;
1059 // Reset ITS track related information
1065 for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
1066 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
1069 // Reset TPC related track information
1081 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
1083 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1084 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1085 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1087 // Reset TRD related track information
1092 for (Int_t i=0;i<kTRDnPlanes;i++) {
1095 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1100 delete[] fTRDslices;
1105 // Reset TOF related track information
1109 fTOFCalChannel = -1;
1110 fTOFsignalToT = 99999;
1111 fTOFsignalRaw = 99999;
1116 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
1117 for (Int_t i=0;i<3;i++) fTOFLabel[i] = -1;
1118 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1120 // Reset HMPID related track information
1125 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
1132 fCaloIndex = kEMCALNoMatch;
1134 // reset global track chi2
1137 fVertexID = -2; // an orphan track
1139 delete fFriendTrack; fFriendTrack = 0;
1142 //_______________________________________________________________________
1143 Int_t AliESDtrack::GetPID() const
1145 // Returns the particle most probable id
1147 for (i=0; i<AliPID::kSPECIES-1; i++) if (fR[i] != fR[i+1]) break;
1149 if (i == AliPID::kSPECIES-1) return AliPID::kPion; // If all the probabilities are equal, return the pion mass
1153 for (i=0; i<AliPID::kSPECIES; i++) if (fR[i]>max) {k=i; max=fR[i];}
1155 if (k==0) { // dE/dx "crossing points" in the TPC
1157 if ((p>0.38)&&(p<0.48))
1158 if (fR[0]<fR[3]*10.) return AliPID::kKaon;
1159 if ((p>0.75)&&(p<0.85))
1160 if (fR[0]<fR[4]*10.) return AliPID::kProton;
1161 return AliPID::kElectron;
1163 if (k==1) return AliPID::kMuon;
1164 if (k==2||k==-1) return AliPID::kPion;
1165 if (k==3) return AliPID::kKaon;
1166 if (k==4) return AliPID::kProton;
1167 AliWarning("Undefined PID !");
1168 return AliPID::kPion;
1171 //_______________________________________________________________________
1172 Int_t AliESDtrack::GetTOFBunchCrossing(Double_t b) const
1174 // Returns the number of bunch crossings after trigger (assuming 25ns spacing)
1175 const double kSpacing = 25e3; // min interbanch spacing
1176 const double kShift = 0;
1177 Int_t bcid = -1; // defualt one
1178 if (!IsOn(kTOFout) || !IsOn(kESDpid)) return bcid; // no info
1180 double tdif = fTOFsignal;
1181 if (IsOn(kTIME)) { // integrated time info is there
1183 tdif -= fTrackTime[pid];
1185 else { // assume integrated time info from TOF radius and momentum
1186 const double kRTOF = 385.;
1187 const double kCSpeed = 3.e-2; // cm/ps
1189 if (p<0.01) return bcid;
1190 double m = GetMass();
1191 double curv = GetC(b);
1192 double path = TMath::Abs(curv)>kAlmost0 ? // account for curvature
1193 2./curv*TMath::ASin(kRTOF*curv/2.)*TMath::Sqrt(1.+GetTgl()*GetTgl()) : kRTOF;
1194 tdif -= path/kCSpeed*TMath::Sqrt(1.+m*m/(p*p));
1196 bcid = TMath::Nint((tdif - kShift)/kSpacing);
1200 //______________________________________________________________________________
1201 Double_t AliESDtrack::M() const
1203 // Returns the assumed mass
1204 // (the pion mass, if the particle can't be identified properly).
1205 static Bool_t printerr=kTRUE;
1207 AliWarning("WARNING !!! ... THIS WILL BE PRINTED JUST ONCE !!!");
1209 AliWarning("This is the ESD mass. Use it with care !");
1214 //______________________________________________________________________________
1215 Double_t AliESDtrack::E() const
1217 // Returns the energy of the particle given its assumed mass.
1218 // Assumes the pion mass if the particle can't be identified properly.
1222 return TMath::Sqrt(p*p + m*m);
1225 //______________________________________________________________________________
1226 Double_t AliESDtrack::Y() const
1228 // Returns the rapidity of a particle given its assumed mass.
1229 // Assumes the pion mass if the particle can't be identified properly.
1233 if (e != TMath::Abs(pz)) { // energy was not equal to pz
1234 return 0.5*TMath::Log((e+pz)/(e-pz));
1235 } else { // energy was equal to pz
1240 //_______________________________________________________________________
1241 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
1243 // This function updates track's running parameters
1248 fLabel=t->GetLabel();
1250 if (t->IsStartedTimeIntegral()) {
1252 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
1253 SetIntegratedLength(t->GetIntegratedLength());
1256 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1258 if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1259 if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
1260 if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
1265 case kITSin: case kITSout: case kITSrefit:
1268 fITSncls=t->GetNumberOfClusters();
1270 Int_t* indexITS = new Int_t[AliESDfriendTrack::kMaxITScluster];
1271 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
1272 indexITS[i]=t->GetClusterIndex(i);
1275 Int_t l=(indexITS[i] & 0xf0000000) >> 28;
1276 SETBIT(fITSClusterMap,l);
1279 fFriendTrack->SetITSIndices(indexITS,AliESDfriendTrack::kMaxITScluster);
1283 fITSchi2=t->GetChi2();
1284 fITSsignal=t->GetPIDsignal();
1285 fITSLabel = t->GetLabel();
1286 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1287 if (flags==kITSout) {
1288 if (!fOp) fOp=new AliExternalTrackParam(*t);
1290 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1295 case kTPCin: case kTPCrefit:
1297 fTPCLabel = t->GetLabel();
1298 if (flags==kTPCin) {
1299 fTPCInner=new AliExternalTrackParam(*t);
1300 fTPCnclsIter1=t->GetNumberOfClusters();
1301 fTPCchi2Iter1=t->GetChi2();
1303 if (!fIp) fIp=new AliExternalTrackParam(*t);
1305 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1309 if (flags & kTPCout){
1310 if (!fOp) fOp=new AliExternalTrackParam(*t);
1312 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1314 fTPCncls=t->GetNumberOfClusters();
1315 fTPCchi2=t->GetChi2();
1318 {//prevrow must be declared in separate namespace, otherwise compiler cries:
1319 //"jump to case label crosses initialization of `Int_t prevrow'"
1320 Int_t* indexTPC = new Int_t[AliESDfriendTrack::kMaxTPCcluster];
1322 // for (Int_t i=0;i<fTPCncls;i++)
1323 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1325 indexTPC[i]=t->GetClusterIndex(i);
1326 Int_t idx = indexTPC[i];
1328 if (idx<0) continue;
1330 // Piotr's Cluster Map for HBT
1331 // ### please change accordingly if cluster array is changing
1332 // to "New TPC Tracking" style (with gaps in array)
1333 Int_t sect = (idx&0xff000000)>>24;
1334 Int_t row = (idx&0x00ff0000)>>16;
1335 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
1337 fTPCClusterMap.SetBitNumber(row,kTRUE);
1339 //Fill the gap between previous row and this row with 0 bits
1340 //In case ### pleas change it as well - just set bit 0 in case there
1341 //is no associated clusters for current "i"
1344 prevrow = row;//if previous bit was not assigned yet == this is the first one
1347 { //we don't know the order (inner to outer or reverse)
1348 //just to be save in case it is going to change
1361 for (Int_t j = n+1; j < m; j++)
1363 fTPCClusterMap.SetBitNumber(j,kFALSE);
1367 // End Of Piotr's Cluster Map for HBT
1369 fFriendTrack->SetTPCIndices(indexTPC,AliESDfriendTrack::kMaxTPCcluster);
1373 fTPCsignal=t->GetPIDsignal();
1377 case kTRDin: case kTRDrefit:
1381 fTRDLabel = t->GetLabel();
1382 fTRDchi2 = t->GetChi2();
1383 fTRDncls = t->GetNumberOfClusters();
1385 Int_t* indexTRD = new Int_t[AliESDfriendTrack::kMaxTRDcluster];
1386 for (Int_t i=0;i<AliESDfriendTrack::kMaxTRDcluster;i++) indexTRD[i]=-2;
1387 for (Int_t i=0;i<6;i++) indexTRD[i]=t->GetTrackletIndex(i);
1388 fFriendTrack->SetTRDIndices(indexTRD,AliESDfriendTrack::kMaxTRDcluster);
1392 fTRDsignal=t->GetPIDsignal();
1396 if (!fOp) fOp=new AliExternalTrackParam(*t);
1398 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1399 fTRDncls0 = t->GetNumberOfClusters();
1408 if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1410 fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1413 AliError("Wrong flag !");
1420 //_______________________________________________________________________
1421 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1422 //---------------------------------------------------------------------
1423 // This function returns external representation of the track parameters
1424 //---------------------------------------------------------------------
1426 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1429 //_______________________________________________________________________
1430 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1431 //---------------------------------------------------------------------
1432 // This function returns external representation of the cov. matrix
1433 //---------------------------------------------------------------------
1434 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1437 //_______________________________________________________________________
1438 Bool_t AliESDtrack::GetConstrainedExternalParameters
1439 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1440 //---------------------------------------------------------------------
1441 // This function returns the constrained external track parameters
1442 //---------------------------------------------------------------------
1443 if (!fCp) return kFALSE;
1444 alpha=fCp->GetAlpha();
1446 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1450 //_______________________________________________________________________
1452 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1453 //---------------------------------------------------------------------
1454 // This function returns the constrained external cov. matrix
1455 //---------------------------------------------------------------------
1456 if (!fCp) return kFALSE;
1457 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1462 AliESDtrack::GetInnerExternalParameters
1463 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1464 //---------------------------------------------------------------------
1465 // This function returns external representation of the track parameters
1466 // at the inner layer of TPC
1467 //---------------------------------------------------------------------
1468 if (!fIp) return kFALSE;
1469 alpha=fIp->GetAlpha();
1471 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1476 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1477 //---------------------------------------------------------------------
1478 // This function returns external representation of the cov. matrix
1479 // at the inner layer of TPC
1480 //---------------------------------------------------------------------
1481 if (!fIp) return kFALSE;
1482 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1487 AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1489 // This is a direct setter for the outer track parameters
1492 if (fOp) delete fOp;
1493 fOp=new AliExternalTrackParam(*p);
1497 AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1499 // This is a direct setter for the outer track parameters
1502 if (fHMPIDp) delete fHMPIDp;
1503 fHMPIDp=new AliExternalTrackParam(*p);
1507 AliESDtrack::GetOuterExternalParameters
1508 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1509 //---------------------------------------------------------------------
1510 // This function returns external representation of the track parameters
1511 // at the inner layer of TRD
1512 //---------------------------------------------------------------------
1513 if (!fOp) return kFALSE;
1514 alpha=fOp->GetAlpha();
1516 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1521 AliESDtrack::GetOuterHmpExternalParameters
1522 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1523 //---------------------------------------------------------------------
1524 // This function returns external representation of the track parameters
1525 // at the inner layer of TRD
1526 //---------------------------------------------------------------------
1527 if (!fHMPIDp) return kFALSE;
1528 alpha=fHMPIDp->GetAlpha();
1530 for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1535 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1536 //---------------------------------------------------------------------
1537 // This function returns external representation of the cov. matrix
1538 // at the inner layer of TRD
1539 //---------------------------------------------------------------------
1540 if (!fOp) return kFALSE;
1541 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1546 AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1547 //---------------------------------------------------------------------
1548 // This function returns external representation of the cov. matrix
1549 // at the inner layer of TRD
1550 //---------------------------------------------------------------------
1551 if (!fHMPIDp) return kFALSE;
1552 for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1556 Int_t AliESDtrack::GetNcls(Int_t idet) const
1558 // Get number of clusters by subdetector index
1572 if (fTOFindex != -1)
1578 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1579 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1590 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1592 // Get cluster index array by subdetector index
1597 ncls = GetITSclusters(idx);
1600 ncls = GetTPCclusters(idx);
1603 ncls = GetTRDclusters(idx);
1606 if (fTOFindex != -1) {
1614 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1615 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1616 idx[0] = GetHMPIDcluIdx();
1629 //_______________________________________________________________________
1630 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1631 // Returns the array with integrated times for each particle hypothesis
1632 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1635 //_______________________________________________________________________
1636 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1637 // Sets the array with integrated times for each particle hypotesis
1638 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1641 //_______________________________________________________________________
1642 void AliESDtrack::SetITSpid(const Double_t *p) {
1643 // Sets values for the probability of each particle type (in ITS)
1644 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1645 SetStatus(AliESDtrack::kITSpid);
1648 //_______________________________________________________________________
1649 void AliESDtrack::GetITSpid(Double_t *p) const {
1650 // Gets the probability of each particle type (in ITS)
1651 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1654 //_______________________________________________________________________
1655 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1656 //---------------------------------------------------------------------
1657 // This function returns indices of the assgined ITS clusters
1658 //---------------------------------------------------------------------
1659 if (idx && fFriendTrack) {
1660 Int_t *index=fFriendTrack->GetITSindices();
1661 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1662 if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1674 //_______________________________________________________________________
1675 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1676 Float_t &xloc,Float_t &zloc) const {
1677 //----------------------------------------------------------------------
1678 // This function encodes in the module number also the status of cluster association
1679 // "status" can have the following values:
1680 // 1 "found" (cluster is associated),
1681 // 2 "dead" (module is dead from OCDB),
1682 // 3 "skipped" (module or layer forced to be skipped),
1683 // 4 "outinz" (track out of z acceptance),
1684 // 5 "nocls" (no clusters in the road),
1685 // 6 "norefit" (cluster rejected during refit),
1686 // 7 "deadzspd" (holes in z in SPD)
1687 // Also given are the coordinates of the crossing point of track and module
1688 // (in the local module ref. system)
1689 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1690 //----------------------------------------------------------------------
1692 if(fITSModule[ilayer]==-1) {
1695 xloc=-99.; zloc=-99.;
1699 Int_t module = fITSModule[ilayer];
1701 idet = Int_t(module/1000000);
1703 module -= idet*1000000;
1705 status = Int_t(module/100000);
1707 module -= status*100000;
1709 Int_t signs = Int_t(module/10000);
1711 module-=signs*10000;
1713 Int_t xInt = Int_t(module/100);
1716 Int_t zInt = module;
1718 if(signs==1) { xInt*=1; zInt*=1; }
1719 if(signs==2) { xInt*=1; zInt*=-1; }
1720 if(signs==3) { xInt*=-1; zInt*=1; }
1721 if(signs==4) { xInt*=-1; zInt*=-1; }
1723 xloc = 0.1*(Float_t)xInt;
1724 zloc = 0.1*(Float_t)zInt;
1726 if(status==4) idet = -1;
1731 //_______________________________________________________________________
1732 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1733 //---------------------------------------------------------------------
1734 // This function returns indices of the assgined ITS clusters
1735 //---------------------------------------------------------------------
1736 if (idx && fFriendTrack) {
1737 Int_t *index=fFriendTrack->GetTPCindices();
1740 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1743 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=-2;
1749 //_______________________________________________________________________
1750 Float_t AliESDtrack::GetTPCClusterInfo(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1) const
1753 // TPC cluster information
1754 // type 0: get fraction of found/findable clusters with neighbourhood definition
1755 // 1: findable clusters with neighbourhood definition
1756 // 2: found clusters
1758 // definition of findable clusters:
1759 // a cluster is defined as findable if there is another cluster
1760 // within +- nNeighbours pad rows. The idea is to overcome threshold
1761 // effects with a very simple algorithm.
1764 if (type==2) return fTPCClusterMap.CountBits();
1768 Int_t last=-nNeighbours;
1770 Int_t upperBound=fTPCClusterMap.GetNbits();
1771 if (upperBound>row1) upperBound=row1;
1772 for (Int_t i=row0; i<upperBound; ++i){
1773 //look to current row
1774 if (fTPCClusterMap[i]) {
1780 //look to nNeighbours before
1781 if ((i-last)<=nNeighbours) {
1785 //look to nNeighbours after
1786 for (Int_t j=i+1; j<i+1+nNeighbours; ++j){
1787 if (fTPCClusterMap[j]){
1793 if (type==1) return findable;
1798 fraction=(Float_t)found/(Float_t)findable;
1803 return 0; // undefined type - default value
1806 //_______________________________________________________________________
1807 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1809 // GetDensity of the clusters on given region between row0 and row1
1810 // Dead zone effect takin into acoount
1812 if (!fFriendTrack) return 0.0;
1816 Int_t *index=fFriendTrack->GetTPCindices();
1817 for (Int_t i=row0;i<=row1;i++){
1818 Int_t idx = index[i];
1819 if (idx!=-1) good++; // track outside of dead zone
1822 Float_t density=0.5;
1823 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1827 //_______________________________________________________________________
1828 void AliESDtrack::SetTPCpid(const Double_t *p) {
1829 // Sets values for the probability of each particle type (in TPC)
1830 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1831 SetStatus(AliESDtrack::kTPCpid);
1834 //_______________________________________________________________________
1835 void AliESDtrack::GetTPCpid(Double_t *p) const {
1836 // Gets the probability of each particle type (in TPC)
1837 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1840 //_______________________________________________________________________
1841 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1842 //---------------------------------------------------------------------
1843 // This function returns indices of the assgined TRD clusters
1844 //---------------------------------------------------------------------
1845 if (idx && fFriendTrack) {
1846 Int_t *index=fFriendTrack->GetTRDindices();
1849 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1852 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=-2;
1858 //_______________________________________________________________________
1859 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1861 // This function returns the number of TRD tracklets used in tracking
1862 // and it fills the indices of these tracklets in the array "idx" as they
1863 // are registered in the TRD track list.
1866 // 1. The idx array has to be allocated with a size >= AliESDtrack::kTRDnPlanes
1867 // 2. The idx array store not only the index but also the layer of the tracklet.
1868 // Therefore tracks with TRD gaps contain default values for indices [-1]
1870 if (!fFriendTrack) return 0;
1871 if (!idx) return GetTRDntracklets();
1872 Int_t *index=fFriendTrack->GetTRDindices();
1874 for (Int_t i=0; i<kTRDnPlanes; i++){
1876 if(index[i]>=0) n++;
1884 //_______________________________________________________________________
1885 void AliESDtrack::SetTRDpid(const Double_t *p) {
1886 // Sets values for the probability of each particle type (in TRD)
1887 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1888 SetStatus(AliESDtrack::kTRDpid);
1891 //_______________________________________________________________________
1892 void AliESDtrack::GetTRDpid(Double_t *p) const {
1893 // Gets the probability of each particle type (in TRD)
1894 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1897 //_______________________________________________________________________
1898 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1900 // Sets the probability of particle type iSpecies to p (in TRD)
1901 fTRDr[iSpecies] = p;
1904 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1906 // Returns the probability of particle type iSpecies (in TRD)
1907 return fTRDr[iSpecies];
1910 //____________________________________________________
1911 Int_t AliESDtrack::GetNumberOfTRDslices() const
1913 // built in backward compatibility
1914 Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
1915 return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
1918 //____________________________________________________
1919 Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
1921 //Returns momentum estimation and optional its error (sp)
1922 // in TRD layer "plane".
1925 AliDebug(2, "No TRD info allocated for this track.");
1928 if ((plane<0) || (plane>=kTRDnPlanes)) {
1929 AliWarning(Form("Request for TRD plane[%d] outside range.", plane));
1933 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1934 // Protection for backward compatibility
1935 if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
1937 if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
1938 return fTRDslices[idx];
1941 //____________________________________________________
1942 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1943 //Gets the charge from the slice of the plane
1946 //AliError("No TRD slices allocated for this track !");
1949 if ((plane<0) || (plane>=kTRDnPlanes)) {
1950 AliError("Info for TRD plane not available !");
1953 Int_t ns=GetNumberOfTRDslices();
1954 if ((slice<-1) || (slice>=ns)) {
1955 //AliError("Wrong TRD slice !");
1959 if(slice>=0) return fTRDslices[plane*ns + slice];
1961 // return average of the dEdx measurements
1962 Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
1963 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
1967 //____________________________________________________
1968 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1969 //Sets the number of slices used for PID
1970 if (fTRDnSlices) return;
1973 fTRDslices=new Double32_t[fTRDnSlices];
1975 // set-up correctly the allocated memory
1976 memset(fTRDslices, 0, n*sizeof(Double32_t));
1977 for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
1980 //____________________________________________________
1981 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1982 //Sets the charge q in the slice of the plane
1984 AliError("No TRD slices allocated for this track !");
1987 if ((plane<0) || (plane>=kTRDnPlanes)) {
1988 AliError("Info for TRD plane not allocated !");
1991 Int_t ns=GetNumberOfTRDslices();
1992 if ((slice<0) || (slice>=ns)) {
1993 AliError("Wrong TRD slice !");
1996 Int_t n=plane*ns + slice;
2001 //____________________________________________________
2002 void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
2005 AliError("No TRD slices allocated for this track !");
2008 if ((plane<0) || (plane>=kTRDnPlanes)) {
2009 AliError("Info for TRD plane not allocated !");
2013 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
2014 // Protection for backward compatibility
2015 if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
2017 if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
2018 fTRDslices[idx] = p;
2022 //_______________________________________________________________________
2023 void AliESDtrack::SetTOFpid(const Double_t *p) {
2024 // Sets the probability of each particle type (in TOF)
2025 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
2026 SetStatus(AliESDtrack::kTOFpid);
2029 //_______________________________________________________________________
2030 void AliESDtrack::SetTOFLabel(const Int_t *p) {
2032 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
2035 //_______________________________________________________________________
2036 void AliESDtrack::GetTOFpid(Double_t *p) const {
2037 // Gets probabilities of each particle type (in TOF)
2038 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
2041 //_______________________________________________________________________
2042 void AliESDtrack::GetTOFLabel(Int_t *p) const {
2044 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
2047 //_______________________________________________________________________
2048 void AliESDtrack::GetTOFInfo(Float_t *info) const {
2050 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
2053 //_______________________________________________________________________
2054 void AliESDtrack::SetTOFInfo(Float_t*info) {
2056 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
2061 //_______________________________________________________________________
2062 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
2063 // Sets the probability of each particle type (in HMPID)
2064 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
2065 SetStatus(AliESDtrack::kHMPIDpid);
2068 //_______________________________________________________________________
2069 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
2070 // Gets probabilities of each particle type (in HMPID)
2071 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
2076 //_______________________________________________________________________
2077 void AliESDtrack::SetESDpid(const Double_t *p) {
2078 // Sets the probability of each particle type for the ESD track
2079 SetPIDValues(fR,p,AliPID::kSPECIES);
2080 SetStatus(AliESDtrack::kESDpid);
2083 //_______________________________________________________________________
2084 void AliESDtrack::GetESDpid(Double_t *p) const {
2085 // Gets probability of each particle type for the ESD track
2086 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
2089 //_______________________________________________________________________
2090 Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
2091 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2093 // Try to relate the TPC-only track parameters to the vertex "vtx",
2094 // if the (rough) transverse impact parameter is not bigger then "maxd".
2095 // Magnetic field is "b" (kG).
2097 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2098 // b) The impact parameters and their covariance matrix are calculated.
2099 // c) An attempt to constrain the TPC-only params to the vertex is done.
2100 // The constrained params are returned via "cParam".
2102 // In the case of success, the returned value is kTRUE
2103 // otherwise, it's kFALSE)
2106 if (!fTPCInner) return kFALSE;
2107 if (!vtx) return kFALSE;
2109 Double_t dz[2],cov[3];
2110 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2118 Double_t covar[6]; vtx->GetCovMatrix(covar);
2119 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2120 Double_t c[3]={covar[2],0.,covar[5]};
2122 Double_t chi2=GetPredictedChi2(p,c);
2123 if (chi2>kVeryBig) return kFALSE;
2127 if (!cParam) return kTRUE;
2129 *cParam = *fTPCInner;
2130 if (!cParam->Update(p,c)) return kFALSE;
2135 //_______________________________________________________________________
2136 Bool_t AliESDtrack::RelateToVertexTPCBxByBz(const AliESDVertex *vtx,
2137 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2139 // Try to relate the TPC-only track parameters to the vertex "vtx",
2140 // if the (rough) transverse impact parameter is not bigger then "maxd".
2142 // All three components of the magnetic field ,"b[3]" (kG),
2143 // are taken into account.
2145 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2146 // b) The impact parameters and their covariance matrix are calculated.
2147 // c) An attempt to constrain the TPC-only params to the vertex is done.
2148 // The constrained params are returned via "cParam".
2150 // In the case of success, the returned value is kTRUE
2151 // otherwise, it's kFALSE)
2154 if (!fTPCInner) return kFALSE;
2155 if (!vtx) return kFALSE;
2157 Double_t dz[2],cov[3];
2158 if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2166 Double_t covar[6]; vtx->GetCovMatrix(covar);
2167 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2168 Double_t c[3]={covar[2],0.,covar[5]};
2170 Double_t chi2=GetPredictedChi2(p,c);
2171 if (chi2>kVeryBig) return kFALSE;
2175 if (!cParam) return kTRUE;
2177 *cParam = *fTPCInner;
2178 if (!cParam->Update(p,c)) return kFALSE;
2183 //_______________________________________________________________________
2184 Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
2185 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2187 // Try to relate this track to the vertex "vtx",
2188 // if the (rough) transverse impact parameter is not bigger then "maxd".
2189 // Magnetic field is "b" (kG).
2191 // a) The track gets extapolated to the DCA to the vertex.
2192 // b) The impact parameters and their covariance matrix are calculated.
2193 // c) An attempt to constrain this track to the vertex is done.
2194 // The constrained params are returned via "cParam".
2196 // In the case of success, the returned value is kTRUE
2197 // (otherwise, it's kFALSE)
2200 if (!vtx) return kFALSE;
2202 Double_t dz[2],cov[3];
2203 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2211 Double_t covar[6]; vtx->GetCovMatrix(covar);
2212 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2213 Double_t c[3]={covar[2],0.,covar[5]};
2215 Double_t chi2=GetPredictedChi2(p,c);
2216 if (chi2>kVeryBig) return kFALSE;
2221 //--- Could now these lines be removed ? ---
2223 fCp=new AliExternalTrackParam(*this);
2225 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2226 //----------------------------------------
2228 fVertexID = vtx->GetID();
2230 if (!cParam) return kTRUE;
2233 if (!cParam->Update(p,c)) return kFALSE;
2238 //_______________________________________________________________________
2239 Bool_t AliESDtrack::RelateToVertexBxByBz(const AliESDVertex *vtx,
2240 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2242 // Try to relate this track to the vertex "vtx",
2243 // if the (rough) transverse impact parameter is not bigger then "maxd".
2244 // Magnetic field is "b" (kG).
2246 // a) The track gets extapolated to the DCA to the vertex.
2247 // b) The impact parameters and their covariance matrix are calculated.
2248 // c) An attempt to constrain this track to the vertex is done.
2249 // The constrained params are returned via "cParam".
2251 // In the case of success, the returned value is kTRUE
2252 // (otherwise, it's kFALSE)
2255 if (!vtx) return kFALSE;
2257 Double_t dz[2],cov[3];
2258 if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2266 Double_t covar[6]; vtx->GetCovMatrix(covar);
2267 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2268 Double_t c[3]={covar[2],0.,covar[5]};
2270 Double_t chi2=GetPredictedChi2(p,c);
2271 if (chi2>kVeryBig) return kFALSE;
2276 //--- Could now these lines be removed ? ---
2278 fCp=new AliExternalTrackParam(*this);
2280 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2281 //----------------------------------------
2283 fVertexID = vtx->GetID();
2285 if (!cParam) return kTRUE;
2288 if (!cParam->Update(p,c)) return kFALSE;
2293 //_______________________________________________________________________
2294 void AliESDtrack::Print(Option_t *) const {
2295 // Prints info on the track
2296 AliExternalTrackParam::Print();
2297 printf("ESD track info\n") ;
2298 Double_t p[AliPID::kSPECIESN] ;
2300 if( IsOn(kITSpid) ){
2301 printf("From ITS: ") ;
2303 for(index = 0 ; index < AliPID::kSPECIES; index++)
2304 printf("%f, ", p[index]) ;
2305 printf("\n signal = %f\n", GetITSsignal()) ;
2307 if( IsOn(kTPCpid) ){
2308 printf("From TPC: ") ;
2310 for(index = 0 ; index < AliPID::kSPECIES; index++)
2311 printf("%f, ", p[index]) ;
2312 printf("\n signal = %f\n", GetTPCsignal()) ;
2314 if( IsOn(kTRDpid) ){
2315 printf("From TRD: ") ;
2317 for(index = 0 ; index < AliPID::kSPECIES; index++)
2318 printf("%f, ", p[index]) ;
2319 printf("\n signal = %f\n", GetTRDsignal()) ;
2321 if( IsOn(kTOFpid) ){
2322 printf("From TOF: ") ;
2324 for(index = 0 ; index < AliPID::kSPECIES; index++)
2325 printf("%f, ", p[index]) ;
2326 printf("\n signal = %f\n", GetTOFsignal()) ;
2328 if( IsOn(kHMPIDpid) ){
2329 printf("From HMPID: ") ;
2331 for(index = 0 ; index < AliPID::kSPECIES; index++)
2332 printf("%f, ", p[index]) ;
2333 printf("\n signal = %f\n", GetHMPIDsignal()) ;
2339 // Draw functionality
2340 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
2342 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
2344 // Fill points in the polymarker
2347 arrayRef.AddLast(new AliExternalTrackParam(*this));
2348 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
2349 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
2350 if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
2352 Double_t mpos[3]={0,0,0};
2353 Int_t entries=arrayRef.GetEntries();
2354 for (Int_t i=0;i<entries;i++){
2356 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
2357 mpos[0]+=pos[0]/entries;
2358 mpos[1]+=pos[1]/entries;
2359 mpos[2]+=pos[2]/entries;
2361 // Rotate to the mean position
2363 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
2364 for (Int_t i=0;i<entries;i++){
2365 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
2366 if (!res) delete arrayRef.RemoveAt(i);
2369 for (Double_t r=minR; r<maxR; r+=stepR){
2371 Double_t mlpos[3]={0,0,0};
2372 for (Int_t i=0;i<entries;i++){
2373 Double_t point[3]={0,0,0};
2374 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
2375 if (!param) continue;
2376 if (param->GetXYZAt(r,magF,point)){
2377 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
2379 mlpos[0]+=point[0]*weight;
2380 mlpos[1]+=point[1]*weight;
2381 mlpos[2]+=point[2]*weight;
2388 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
2389 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
2395 //_______________________________________________________________________
2396 void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
2398 // Store the dE/dx samples measured by the two SSD and two SDD layers.
2399 // These samples are corrected for the track segment length.
2401 for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
2404 //_______________________________________________________________________
2405 void AliESDtrack::GetITSdEdxSamples(Double_t *s) const {
2407 // Get the dE/dx samples measured by the two SSD and two SDD layers.
2408 // These samples are corrected for the track segment length.
2410 for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];
2414 UShort_t AliESDtrack::GetTPCnclsS(Int_t i0,Int_t i1) const{
2416 // get number of shared TPC clusters
2418 return fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);
2421 UShort_t AliESDtrack::GetTPCncls(Int_t i0,Int_t i1) const{
2423 // get number of TPC clusters
2425 return fTPCClusterMap.CountBits(i0)-fTPCClusterMap.CountBits(i1);