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>
119 #include <TMatrixD.h>
121 #include "AliESDVertex.h"
122 #include "AliESDtrack.h"
123 #include "AliESDEvent.h"
124 #include "AliKalmanTrack.h"
125 #include "AliVTrack.h"
127 #include "AliTrackPointArray.h"
128 #include "TPolyMarker3D.h"
129 #include "AliTrackerBase.h"
130 #include "AliTPCdEdxInfo.h"
132 ClassImp(AliESDtrack)
134 void SetPIDValues(Double_t * dest, const Double_t * src, Int_t n) {
135 // This function copies "n" PID weights from "scr" to "dest"
136 // and normalizes their sum to 1 thus producing conditional probabilities.
137 // The negative weights are set to 0.
138 // In case all the weights are non-positive they are replaced by
139 // uniform probabilities
143 Float_t uniform = 1./(Float_t)n;
146 for (Int_t i=0; i<n; i++)
156 for (Int_t i=0; i<n; i++) dest[i] /= sum;
158 for (Int_t i=0; i<n; i++) dest[i] = uniform;
161 //_______________________________________________________________________
162 AliESDtrack::AliESDtrack() :
163 AliExternalTrackParam(),
170 fTPCFitMap(159),//number of padrows
171 fTPCClusterMap(159),//number of padrows
172 fTPCSharedMap(159),//number of padrows
183 fCaloIndex(kEMCALNoMatch),
189 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
192 fCdd(0),fCdz(0),fCzz(0),
209 fTOFsignalToT(99999),
210 fTOFsignalRaw(99999),
234 fVertexID(-2),// -2 means an orphan track
236 fCacheNCrossedRows(-10),
237 fCacheChi2TPCConstrainedVsGlobal(-10),
238 fCacheChi2TPCConstrainedVsGlobalVertex(0)
241 // The default ESD constructor
243 if (!OnlineMode()) fFriendTrack=new AliESDfriendTrack();
246 for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
247 for (i=0; i<AliPID::kSPECIES; i++) {
257 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
258 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
259 for (i=0;i<kTRDnPlanes;i++) {
262 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
263 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
264 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
265 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
266 for (i=0;i<12;i++) {fITSModule[i]=-1;}
269 bool AliESDtrack::fgkOnlineMode=false;
271 //_______________________________________________________________________
272 AliESDtrack::AliESDtrack(const AliESDtrack& track):
273 AliExternalTrackParam(track),
280 fTPCFitMap(track.fTPCFitMap),
281 fTPCClusterMap(track.fTPCClusterMap),
282 fTPCSharedMap(track.fTPCSharedMap),
283 fFlags(track.fFlags),
285 fLabel(track.fLabel),
286 fITSLabel(track.fITSLabel),
287 fTPCLabel(track.fTPCLabel),
288 fTRDLabel(track.fTRDLabel),
289 fTOFCalChannel(track.fTOFCalChannel),
290 fTOFindex(track.fTOFindex),
291 fHMPIDqn(track.fHMPIDqn),
292 fHMPIDcluIdx(track.fHMPIDcluIdx),
293 fCaloIndex(track.fCaloIndex),
294 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
295 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
296 fHMPIDsignal(track.fHMPIDsignal),
297 fTrackLength(track.fTrackLength),
298 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
299 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
300 fCchi2TPC(track.fCchi2TPC),
301 fD(track.fD),fZ(track.fZ),
302 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
303 fCchi2(track.fCchi2),
304 fITSchi2(track.fITSchi2),
305 fTPCchi2(track.fTPCchi2),
306 fTPCchi2Iter1(track.fTPCchi2Iter1),
307 fTRDchi2(track.fTRDchi2),
308 fTOFchi2(track.fTOFchi2),
309 fHMPIDchi2(track.fHMPIDchi2),
310 fGlobalChi2(track.fGlobalChi2),
311 fITSsignal(track.fITSsignal),
312 fTPCsignal(track.fTPCsignal),
313 fTPCsignalS(track.fTPCsignalS),
315 fTRDsignal(track.fTRDsignal),
316 fTRDQuality(track.fTRDQuality),
317 fTRDBudget(track.fTRDBudget),
318 fTOFsignal(track.fTOFsignal),
319 fTOFsignalToT(track.fTOFsignalToT),
320 fTOFsignalRaw(track.fTOFsignalRaw),
321 fTOFsignalDz(track.fTOFsignalDz),
322 fTOFsignalDx(track.fTOFsignalDx),
323 fTOFdeltaBC(track.fTOFdeltaBC),
324 fTOFl0l1(track.fTOFl0l1),
325 fCaloDx(track.fCaloDx),
326 fCaloDz(track.fCaloDz),
327 fHMPIDtrkX(track.fHMPIDtrkX),
328 fHMPIDtrkY(track.fHMPIDtrkY),
329 fHMPIDmipX(track.fHMPIDmipX),
330 fHMPIDmipY(track.fHMPIDmipY),
331 fTPCncls(track.fTPCncls),
332 fTPCnclsF(track.fTPCnclsF),
333 fTPCsignalN(track.fTPCsignalN),
334 fTPCnclsIter1(track.fTPCnclsIter1),
335 fTPCnclsFIter1(track.fTPCnclsIter1),
336 fITSncls(track.fITSncls),
337 fITSClusterMap(track.fITSClusterMap),
338 fITSSharedMap(track.fITSSharedMap),
339 fTRDncls(track.fTRDncls),
340 fTRDncls0(track.fTRDncls0),
341 fTRDntracklets(track.fTRDntracklets),
342 fTRDnSlices(track.fTRDnSlices),
344 fVertexID(track.fVertexID),
345 fESDEvent(track.fESDEvent),
346 fCacheNCrossedRows(track.fCacheNCrossedRows),
347 fCacheChi2TPCConstrainedVsGlobal(track.fCacheChi2TPCConstrainedVsGlobal),
348 fCacheChi2TPCConstrainedVsGlobalVertex(track.fCacheChi2TPCConstrainedVsGlobalVertex)
353 for (Int_t i=kNITSchi2Std;i--;) fITSchi2Std[i] = track.fTrackTime[i];
354 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
355 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
357 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
359 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
360 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
361 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
362 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
363 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
365 for (Int_t i=0;i<kTRDnPlanes;i++) {
366 fTRDTimBin[i]=track.fTRDTimBin[i];
370 fTRDslices=new Double32_t[fTRDnSlices];
371 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
375 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
376 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
377 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
378 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
379 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
380 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
382 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
383 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
384 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
385 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
386 if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
387 if (track.fTPCdEdxInfo) fTPCdEdxInfo = new AliTPCdEdxInfo(*track.fTPCdEdxInfo);
390 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
393 //_______________________________________________________________________
394 AliESDtrack::AliESDtrack(const AliVTrack *track) :
395 AliExternalTrackParam(track),
402 fTPCFitMap(159),//number of padrows
403 fTPCClusterMap(159),//number of padrows
404 fTPCSharedMap(159),//number of padrows
415 fCaloIndex(kEMCALNoMatch),
421 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
424 fCdd(0),fCdz(0),fCzz(0),
441 fTOFsignalToT(99999),
442 fTOFsignalRaw(99999),
466 fVertexID(-2), // -2 means an orphan track
468 fCacheNCrossedRows(-10),
469 fCacheChi2TPCConstrainedVsGlobal(-10),
470 fCacheChi2TPCConstrainedVsGlobalVertex(0)
473 // ESD track from AliVTrack.
474 // This is not a copy constructor !
477 if (track->InheritsFrom("AliExternalTrackParam")) {
478 AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
479 AliWarning("Calling the default constructor...");
484 // Reset all the arrays
486 for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
487 for (i=0; i<AliPID::kSPECIES; i++) {
497 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
498 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
499 for (i=0;i<kTRDnPlanes;i++) {
502 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
503 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
504 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
505 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
506 for (i=0;i<12;i++) {fITSModule[i]=-1;}
509 SetID(track->GetID());
511 // Set ITS cluster map
512 fITSClusterMap=track->GetITSClusterMap();
517 if(HasPointOnITSLayer(i)) fITSncls++;
521 fTPCncls=track->GetTPCNcls();
524 // Set the combined PID
525 const Double_t *pid = track->PID();
527 for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
529 // AliESD track label
530 SetLabel(track->GetLabel());
532 SetStatus(track->GetStatus());
535 //_______________________________________________________________________
536 AliESDtrack::AliESDtrack(TParticle * part) :
537 AliExternalTrackParam(),
544 fTPCFitMap(159),//number of padrows
545 fTPCClusterMap(159),//number of padrows
546 fTPCSharedMap(159),//number of padrows
557 fCaloIndex(kEMCALNoMatch),
563 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
566 fCdd(0),fCdz(0),fCzz(0),
583 fTOFsignalToT(99999),
584 fTOFsignalRaw(99999),
608 fVertexID(-2), // -2 means an orphan track
610 fCacheNCrossedRows(-10),
611 fCacheChi2TPCConstrainedVsGlobal(-10),
612 fCacheChi2TPCConstrainedVsGlobalVertex(0)
615 // ESD track from TParticle
618 // Reset all the arrays
620 for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
621 for (i=0; i<AliPID::kSPECIES; i++) {
631 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
632 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
633 for (i=0;i<kTRDnPlanes;i++) {
636 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
637 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
638 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
639 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
640 for (i=0;i<12;i++) {fITSModule[i]=-1;}
642 // Calculate the AliExternalTrackParam content
649 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
650 alpha = part->Phi()*180./TMath::Pi();
651 if (alpha<0) alpha+= 360.;
652 if (alpha>360) alpha -= 360.;
654 Int_t sector = (Int_t)(alpha/20.);
655 alpha = 10. + 20.*sector;
657 alpha *= TMath::Pi();
659 // Covariance matrix: no errors, the parameters are exact
660 for (i=0; i<15; i++) covar[i]=0.;
662 // Get the vertex of origin and the momentum
663 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
664 TVector3 mom(part->Px(),part->Py(),part->Pz());
666 // Rotate to the local coordinate system (TPC sector)
670 // X of the referense plane
673 Int_t pdgCode = part->GetPdgCode();
676 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
680 param[2] = TMath::Sin(mom.Phi());
681 param[3] = mom.Pz()/mom.Pt();
682 param[4] = TMath::Sign(1/mom.Pt(),charge);
684 // Set AliExternalTrackParam
685 Set(xref, alpha, param, covar);
690 switch (TMath::Abs(pdgCode)) {
716 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
717 if (indexPID < AliPID::kSPECIES) {
723 fHMPIDr[indexPID]=1.;
726 // AliESD track label
727 SetLabel(part->GetUniqueID());
731 //_______________________________________________________________________
732 AliESDtrack::~AliESDtrack(){
734 // This is destructor according Coding Conventrions
736 //printf("Delete track\n");
742 if (fFriendTrack) delete fFriendTrack;
743 if (fTPCdEdxInfo) delete fTPCdEdxInfo;
748 //Reset cached values - needed for TClonesArray in AliESDInputHandler
749 fCacheNCrossedRows = -10.;
750 fCacheChi2TPCConstrainedVsGlobal = -10.;
751 if(fCacheChi2TPCConstrainedVsGlobalVertex) fCacheChi2TPCConstrainedVsGlobalVertex = 0;
755 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
758 if(&source == this) return *this;
759 AliExternalTrackParam::operator=(source);
763 // we have the trackparam: assign or copy construct
764 if(fCp)*fCp = *source.fCp;
765 else fCp = new AliExternalTrackParam(*source.fCp);
768 // no track param delete the old one
774 // we have the trackparam: assign or copy construct
775 if(fIp)*fIp = *source.fIp;
776 else fIp = new AliExternalTrackParam(*source.fIp);
779 // no track param delete the old one
785 if(source.fTPCInner){
786 // we have the trackparam: assign or copy construct
787 if(fTPCInner) *fTPCInner = *source.fTPCInner;
788 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
791 // no track param delete the old one
792 if(fTPCInner)delete fTPCInner;
796 if(source.fTPCdEdxInfo) {
797 if(fTPCdEdxInfo) *fTPCdEdxInfo = *source.fTPCdEdxInfo;
798 fTPCdEdxInfo = new AliTPCdEdxInfo(*source.fTPCdEdxInfo);
802 // we have the trackparam: assign or copy construct
803 if(fOp) *fOp = *source.fOp;
804 else fOp = new AliExternalTrackParam(*source.fOp);
807 // no track param delete the old one
814 // we have the trackparam: assign or copy construct
815 if(fHMPIDp) *fHMPIDp = *source.fHMPIDp;
816 else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
819 // no track param delete the old one
820 if(fHMPIDp)delete fHMPIDp;
824 // copy also the friend track
825 // use copy constructor
826 if(source.fFriendTrack){
827 // we have the trackparam: assign or copy construct
828 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
831 // no track param delete the old one
832 delete fFriendTrack; fFriendTrack= 0;
835 fTPCFitMap = source.fTPCFitMap;
836 fTPCClusterMap = source.fTPCClusterMap;
837 fTPCSharedMap = source.fTPCSharedMap;
839 fFlags = source.fFlags;
841 fLabel = source.fLabel;
842 fITSLabel = source.fITSLabel;
843 for(int i = 0; i< 12;++i){
844 fITSModule[i] = source.fITSModule[i];
846 fTPCLabel = source.fTPCLabel;
847 fTRDLabel = source.fTRDLabel;
848 for(int i = 0; i< 3;++i){
849 fTOFLabel[i] = source.fTOFLabel[i];
851 fTOFCalChannel = source.fTOFCalChannel;
852 fTOFindex = source.fTOFindex;
853 fHMPIDqn = source.fHMPIDqn;
854 fHMPIDcluIdx = source.fHMPIDcluIdx;
855 fCaloIndex = source.fCaloIndex;
856 for (int i=kNITSchi2Std;i--;) fITSchi2Std[i] = source.fITSchi2Std[i];
857 for(int i = 0; i< 3;++i){
858 fKinkIndexes[i] = source.fKinkIndexes[i];
859 fV0Indexes[i] = source.fV0Indexes[i];
862 for(int i = 0; i< AliPID::kSPECIES;++i){
863 fR[i] = source.fR[i];
864 fITSr[i] = source.fITSr[i];
865 fTPCr[i] = source.fTPCr[i];
866 fTRDr[i] = source.fTRDr[i];
867 fTOFr[i] = source.fTOFr[i];
868 fHMPIDr[i] = source.fHMPIDr[i];
869 fTrackTime[i] = source.fTrackTime[i];
872 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
873 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
874 fHMPIDsignal = source.fHMPIDsignal;
877 fTrackLength = source. fTrackLength;
878 fdTPC = source.fdTPC;
879 fzTPC = source.fzTPC;
880 fCddTPC = source.fCddTPC;
881 fCdzTPC = source.fCdzTPC;
882 fCzzTPC = source.fCzzTPC;
883 fCchi2TPC = source.fCchi2TPC;
890 fCchi2 = source.fCchi2;
892 fITSchi2 = source.fITSchi2;
893 fTPCchi2 = source.fTPCchi2;
894 fTPCchi2Iter1 = source.fTPCchi2Iter1;
895 fTRDchi2 = source.fTRDchi2;
896 fTOFchi2 = source.fTOFchi2;
897 fHMPIDchi2 = source.fHMPIDchi2;
899 fGlobalChi2 = source.fGlobalChi2;
901 fITSsignal = source.fITSsignal;
902 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
903 fTPCsignal = source.fTPCsignal;
904 fTPCsignalS = source.fTPCsignalS;
905 for(int i = 0; i< 4;++i){
906 fTPCPoints[i] = source.fTPCPoints[i];
908 fTRDsignal = source.fTRDsignal;
910 for(int i = 0;i < kTRDnPlanes;++i){
911 fTRDTimBin[i] = source.fTRDTimBin[i];
917 fTRDnSlices=source.fTRDnSlices;
919 fTRDslices=new Double32_t[fTRDnSlices];
920 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
923 fTRDQuality = source.fTRDQuality;
924 fTRDBudget = source.fTRDBudget;
925 fTOFsignal = source.fTOFsignal;
926 fTOFsignalToT = source.fTOFsignalToT;
927 fTOFsignalRaw = source.fTOFsignalRaw;
928 fTOFsignalDz = source.fTOFsignalDz;
929 fTOFsignalDx = source.fTOFsignalDx;
930 fTOFdeltaBC = source.fTOFdeltaBC;
931 fTOFl0l1 = source.fTOFl0l1;
933 for(int i = 0;i<10;++i){
934 fTOFInfo[i] = source.fTOFInfo[i];
937 fHMPIDtrkX = source.fHMPIDtrkX;
938 fHMPIDtrkY = source.fHMPIDtrkY;
939 fHMPIDmipX = source.fHMPIDmipX;
940 fHMPIDmipY = source.fHMPIDmipY;
942 fTPCncls = source.fTPCncls;
943 fTPCnclsF = source.fTPCnclsF;
944 fTPCsignalN = source.fTPCsignalN;
945 fTPCnclsIter1 = source.fTPCnclsIter1;
946 fTPCnclsFIter1 = source.fTPCnclsFIter1;
948 fITSncls = source.fITSncls;
949 fITSClusterMap = source.fITSClusterMap;
950 fITSSharedMap = source.fITSSharedMap;
951 fTRDncls = source.fTRDncls;
952 fTRDncls0 = source.fTRDncls0;
953 fTRDntracklets = source.fTRDntracklets;
954 fVertexID = source.fVertexID;
956 fCacheNCrossedRows = source.fCacheNCrossedRows;
957 fCacheChi2TPCConstrainedVsGlobal = source.fCacheChi2TPCConstrainedVsGlobal;
958 fCacheChi2TPCConstrainedVsGlobalVertex = source.fCacheChi2TPCConstrainedVsGlobalVertex;
965 void AliESDtrack::Copy(TObject &obj) const {
967 // this overwrites the virtual TOBject::Copy()
968 // to allow run time copying without casting
971 if(this==&obj)return;
972 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
973 if(!robj)return; // not an AliESDtrack
980 void AliESDtrack::AddCalibObject(TObject * object){
982 // add calib object to the list
984 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
985 if (!fFriendTrack) return;
986 fFriendTrack->AddCalibObject(object);
989 TObject * AliESDtrack::GetCalibObject(Int_t index){
991 // return calib objct at given position
993 if (!fFriendTrack) return 0;
994 return fFriendTrack->GetCalibObject(index);
998 Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
1000 // Fills the information of the TPC-only first reconstruction pass
1001 // into the passed ESDtrack object. For consistency fTPCInner is also filled
1006 // For data produced before r26675
1007 // RelateToVertexTPC was not properly called during reco
1008 // so you'll have to call it again, before FillTPCOnlyTrack
1009 // Float_t p[2],cov[3];
1010 // track->GetImpactParametersTPC(p,cov);
1011 // if(p[0]==0&&p[1]==0) // <- Default values
1012 // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
1015 if(!fTPCInner)return kFALSE;
1017 // fill the TPC track params to the global track parameters
1018 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
1021 track.fCdd = fCddTPC;
1022 track.fCdz = fCdzTPC;
1023 track.fCzz = fCzzTPC;
1025 // copy the inner params
1026 if(track.fIp) *track.fIp = *fIp;
1027 else track.fIp = new AliExternalTrackParam(*fIp);
1029 // copy the TPCinner parameters
1030 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
1031 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
1032 track.fdTPC = fdTPC;
1033 track.fzTPC = fzTPC;
1034 track.fCddTPC = fCddTPC;
1035 track.fCdzTPC = fCdzTPC;
1036 track.fCzzTPC = fCzzTPC;
1037 track.fCchi2TPC = fCchi2TPC;
1039 // copy all other TPC specific parameters
1041 // replace label by TPC label
1042 track.fLabel = fTPCLabel;
1043 track.fTPCLabel = fTPCLabel;
1045 track.fTPCchi2 = fTPCchi2;
1046 track.fTPCchi2Iter1 = fTPCchi2Iter1;
1047 track.fTPCsignal = fTPCsignal;
1048 track.fTPCsignalS = fTPCsignalS;
1049 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
1051 track.fTPCncls = fTPCncls;
1052 track.fTPCnclsF = fTPCnclsF;
1053 track.fTPCsignalN = fTPCsignalN;
1054 track.fTPCnclsIter1 = fTPCnclsIter1;
1055 track.fTPCnclsFIter1 = fTPCnclsFIter1;
1058 for(int i=0;i<AliPID::kSPECIES;++i){
1059 track.fTPCr[i] = fTPCr[i];
1060 // combined PID is TPC only!
1061 track.fR[i] = fTPCr[i];
1063 track.fTPCFitMap = fTPCFitMap;
1064 track.fTPCClusterMap = fTPCClusterMap;
1065 track.fTPCSharedMap = fTPCSharedMap;
1069 track.fFlags = kTPCin;
1072 track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
1074 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
1080 //_______________________________________________________________________
1081 void AliESDtrack::MakeMiniESDtrack(){
1082 // Resets everything except
1083 // fFlags: Reconstruction status flags
1084 // fLabel: Track label
1085 // fID: Unique ID of the track
1086 // Impact parameter information
1087 // fR[AliPID::kSPECIES]: combined "detector response probability"
1088 // Running track parameters in the base class (AliExternalTrackParam)
1092 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
1094 // Reset track parameters constrained to the primary vertex
1097 // Reset track parameters at the inner wall of TPC
1099 delete fTPCInner;fTPCInner=0;
1100 // Reset track parameters at the inner wall of the TRD
1102 // Reset track parameters at the HMPID
1103 delete fHMPIDp;fHMPIDp = 0;
1106 // Reset ITS track related information
1112 for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
1113 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
1116 // Reset TPC related track information
1129 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
1131 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1132 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1133 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1135 // Reset TRD related track information
1140 for (Int_t i=0;i<kTRDnPlanes;i++) {
1143 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1148 delete[] fTRDslices;
1153 // Reset TOF related track information
1157 fTOFCalChannel = -1;
1158 fTOFsignalToT = 99999;
1159 fTOFsignalRaw = 99999;
1164 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
1165 for (Int_t i=0;i<3;i++) fTOFLabel[i] = -1;
1166 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1168 // Reset HMPID related track information
1173 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
1180 fCaloIndex = kEMCALNoMatch;
1182 // reset global track chi2
1185 fVertexID = -2; // an orphan track
1187 delete fFriendTrack; fFriendTrack = 0;
1190 //_______________________________________________________________________
1191 Int_t AliESDtrack::GetPID() const
1193 // Returns the particle most probable id
1195 for (i=0; i<AliPID::kSPECIES-1; i++) if (fR[i] != fR[i+1]) break;
1197 if (i == AliPID::kSPECIES-1) return AliPID::kPion; // If all the probabilities are equal, return the pion mass
1201 for (i=0; i<AliPID::kSPECIES; i++) if (fR[i]>max) {k=i; max=fR[i];}
1203 if (k==0) { // dE/dx "crossing points" in the TPC
1205 if ((p>0.38)&&(p<0.48))
1206 if (fR[0]<fR[3]*10.) return AliPID::kKaon;
1207 if ((p>0.75)&&(p<0.85))
1208 if (fR[0]<fR[4]*10.) return AliPID::kProton;
1209 return AliPID::kElectron;
1211 if (k==1) return AliPID::kMuon;
1212 if (k==2||k==-1) return AliPID::kPion;
1213 if (k==3) return AliPID::kKaon;
1214 if (k==4) return AliPID::kProton;
1215 AliWarning("Undefined PID !");
1216 return AliPID::kPion;
1219 //_______________________________________________________________________
1220 Int_t AliESDtrack::GetTOFBunchCrossing(Double_t b) const
1222 // Returns the number of bunch crossings after trigger (assuming 25ns spacing)
1223 const double kSpacing = 25e3; // min interbanch spacing
1224 const double kShift = 0;
1225 Int_t bcid = kTOFBCNA; // defualt one
1226 if (!IsOn(kTOFout) || !IsOn(kESDpid)) return bcid; // no info
1228 double tdif = fTOFsignal;
1229 if (IsOn(kTIME)) { // integrated time info is there
1231 tdif -= fTrackTime[pid];
1233 else { // assume integrated time info from TOF radius and momentum
1234 const double kRTOF = 385.;
1235 const double kCSpeed = 3.e-2; // cm/ps
1237 if (p<0.01) return bcid;
1238 double m = GetMass();
1239 double curv = GetC(b);
1240 double path = TMath::Abs(curv)>kAlmost0 ? // account for curvature
1241 2./curv*TMath::ASin(kRTOF*curv/2.)*TMath::Sqrt(1.+GetTgl()*GetTgl()) : kRTOF;
1242 tdif -= path/kCSpeed*TMath::Sqrt(1.+m*m/(p*p));
1244 bcid = TMath::Nint((tdif - kShift)/kSpacing);
1248 //______________________________________________________________________________
1249 Double_t AliESDtrack::M() const
1251 // Returns the assumed mass
1252 // (the pion mass, if the particle can't be identified properly).
1253 static Bool_t printerr=kTRUE;
1255 AliWarning("WARNING !!! ... THIS WILL BE PRINTED JUST ONCE !!!");
1257 AliWarning("This is the ESD mass. Use it with care !");
1262 //______________________________________________________________________________
1263 Double_t AliESDtrack::E() const
1265 // Returns the energy of the particle given its assumed mass.
1266 // Assumes the pion mass if the particle can't be identified properly.
1270 return TMath::Sqrt(p*p + m*m);
1273 //______________________________________________________________________________
1274 Double_t AliESDtrack::Y() const
1276 // Returns the rapidity of a particle given its assumed mass.
1277 // Assumes the pion mass if the particle can't be identified properly.
1281 if (e != TMath::Abs(pz)) { // energy was not equal to pz
1282 return 0.5*TMath::Log((e+pz)/(e-pz));
1283 } else { // energy was equal to pz
1288 //_______________________________________________________________________
1289 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
1291 // This function updates track's running parameters
1296 fLabel=t->GetLabel();
1298 if (t->IsStartedTimeIntegral()) {
1300 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
1301 SetIntegratedLength(t->GetIntegratedLength());
1304 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1306 if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1307 if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
1308 if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
1314 fITSchi2Std[0] = t->GetChi2();
1317 fITSchi2Std[1] = t->GetChi2();
1320 fITSchi2Std[2] = t->GetChi2();
1322 fITSncls=t->GetNumberOfClusters();
1324 Int_t* indexITS = new Int_t[AliESDfriendTrack::kMaxITScluster];
1325 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
1326 indexITS[i]=t->GetClusterIndex(i);
1329 Int_t l=(indexITS[i] & 0xf0000000) >> 28;
1330 SETBIT(fITSClusterMap,l);
1333 fFriendTrack->SetITSIndices(indexITS,AliESDfriendTrack::kMaxITScluster);
1337 fITSchi2=t->GetChi2();
1338 fITSsignal=t->GetPIDsignal();
1339 fITSLabel = t->GetLabel();
1340 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1341 if (flags==kITSout) {
1342 if (!fOp) fOp=new AliExternalTrackParam(*t);
1344 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1349 case kTPCin: case kTPCrefit:
1351 fTPCLabel = t->GetLabel();
1352 if (flags==kTPCin) {
1353 fTPCInner=new AliExternalTrackParam(*t);
1354 fTPCnclsIter1=t->GetNumberOfClusters();
1355 fTPCchi2Iter1=t->GetChi2();
1357 if (!fIp) fIp=new AliExternalTrackParam(*t);
1359 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1361 // Intentionally no break statement; need to set general TPC variables as well
1364 if (flags & kTPCout){
1365 if (!fOp) fOp=new AliExternalTrackParam(*t);
1367 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1369 fTPCncls=t->GetNumberOfClusters();
1370 fTPCchi2=t->GetChi2();
1372 if (fFriendTrack) { // Copy cluster indices
1373 Int_t* indexTPC = new Int_t[AliESDfriendTrack::kMaxTPCcluster];
1374 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1375 indexTPC[i]=t->GetClusterIndex(i);
1376 fFriendTrack->SetTPCIndices(indexTPC,AliESDfriendTrack::kMaxTPCcluster);
1379 fTPCsignal=t->GetPIDsignal();
1383 case kTRDin: case kTRDrefit:
1387 fTRDLabel = t->GetLabel();
1388 fTRDchi2 = t->GetChi2();
1389 fTRDncls = t->GetNumberOfClusters();
1391 Int_t* indexTRD = new Int_t[AliESDfriendTrack::kMaxTRDcluster];
1392 for (Int_t i=0;i<AliESDfriendTrack::kMaxTRDcluster;i++) indexTRD[i]=-2;
1393 for (Int_t i=0;i<6;i++) indexTRD[i]=t->GetTrackletIndex(i);
1394 fFriendTrack->SetTRDIndices(indexTRD,AliESDfriendTrack::kMaxTRDcluster);
1398 fTRDsignal=t->GetPIDsignal();
1402 if (!fOp) fOp=new AliExternalTrackParam(*t);
1404 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1405 fTRDncls0 = t->GetNumberOfClusters();
1414 if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1416 fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1419 AliError("Wrong flag !");
1426 //_______________________________________________________________________
1427 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1428 //---------------------------------------------------------------------
1429 // This function returns external representation of the track parameters
1430 //---------------------------------------------------------------------
1432 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1435 //_______________________________________________________________________
1436 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1437 //---------------------------------------------------------------------
1438 // This function returns external representation of the cov. matrix
1439 //---------------------------------------------------------------------
1440 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1443 //_______________________________________________________________________
1444 Bool_t AliESDtrack::GetConstrainedExternalParameters
1445 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1446 //---------------------------------------------------------------------
1447 // This function returns the constrained external track parameters
1448 //---------------------------------------------------------------------
1449 if (!fCp) return kFALSE;
1450 alpha=fCp->GetAlpha();
1452 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1456 //_______________________________________________________________________
1458 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1459 //---------------------------------------------------------------------
1460 // This function returns the constrained external cov. matrix
1461 //---------------------------------------------------------------------
1462 if (!fCp) return kFALSE;
1463 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1468 AliESDtrack::GetInnerExternalParameters
1469 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1470 //---------------------------------------------------------------------
1471 // This function returns external representation of the track parameters
1472 // at the inner layer of TPC
1473 //---------------------------------------------------------------------
1474 if (!fIp) return kFALSE;
1475 alpha=fIp->GetAlpha();
1477 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1482 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1483 //---------------------------------------------------------------------
1484 // This function returns external representation of the cov. matrix
1485 // at the inner layer of TPC
1486 //---------------------------------------------------------------------
1487 if (!fIp) return kFALSE;
1488 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1493 AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1495 // This is a direct setter for the outer track parameters
1498 if (fOp) delete fOp;
1499 fOp=new AliExternalTrackParam(*p);
1503 AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1505 // This is a direct setter for the outer track parameters
1508 if (fHMPIDp) delete fHMPIDp;
1509 fHMPIDp=new AliExternalTrackParam(*p);
1513 AliESDtrack::GetOuterExternalParameters
1514 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1515 //---------------------------------------------------------------------
1516 // This function returns external representation of the track parameters
1517 // at the inner layer of TRD
1518 //---------------------------------------------------------------------
1519 if (!fOp) return kFALSE;
1520 alpha=fOp->GetAlpha();
1522 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1527 AliESDtrack::GetOuterHmpExternalParameters
1528 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1529 //---------------------------------------------------------------------
1530 // This function returns external representation of the track parameters
1531 // at the inner layer of TRD
1532 //---------------------------------------------------------------------
1533 if (!fHMPIDp) return kFALSE;
1534 alpha=fHMPIDp->GetAlpha();
1536 for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1541 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1542 //---------------------------------------------------------------------
1543 // This function returns external representation of the cov. matrix
1544 // at the inner layer of TRD
1545 //---------------------------------------------------------------------
1546 if (!fOp) return kFALSE;
1547 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1552 AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1553 //---------------------------------------------------------------------
1554 // This function returns external representation of the cov. matrix
1555 // at the inner layer of TRD
1556 //---------------------------------------------------------------------
1557 if (!fHMPIDp) return kFALSE;
1558 for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1562 Int_t AliESDtrack::GetNcls(Int_t idet) const
1564 // Get number of clusters by subdetector index
1578 if (fTOFindex != -1)
1584 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1585 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1596 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1598 // Get cluster index array by subdetector index
1603 ncls = GetITSclusters(idx);
1606 ncls = GetTPCclusters(idx);
1609 ncls = GetTRDclusters(idx);
1612 if (fTOFindex != -1) {
1620 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1621 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1622 idx[0] = GetHMPIDcluIdx();
1635 //_______________________________________________________________________
1636 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1637 // Returns the array with integrated times for each particle hypothesis
1638 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1641 //_______________________________________________________________________
1642 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1643 // Sets the array with integrated times for each particle hypotesis
1644 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1647 //_______________________________________________________________________
1648 void AliESDtrack::SetITSpid(const Double_t *p) {
1649 // Sets values for the probability of each particle type (in ITS)
1650 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1651 SetStatus(AliESDtrack::kITSpid);
1654 //_______________________________________________________________________
1655 void AliESDtrack::GetITSpid(Double_t *p) const {
1656 // Gets the probability of each particle type (in ITS)
1657 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1660 //_______________________________________________________________________
1661 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1662 //---------------------------------------------------------------------
1663 // This function returns indices of the assgined ITS clusters
1664 //---------------------------------------------------------------------
1665 if (idx && fFriendTrack) {
1666 Int_t *index=fFriendTrack->GetITSindices();
1667 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1668 if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1680 //_______________________________________________________________________
1681 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1682 Float_t &xloc,Float_t &zloc) const {
1683 //----------------------------------------------------------------------
1684 // This function encodes in the module number also the status of cluster association
1685 // "status" can have the following values:
1686 // 1 "found" (cluster is associated),
1687 // 2 "dead" (module is dead from OCDB),
1688 // 3 "skipped" (module or layer forced to be skipped),
1689 // 4 "outinz" (track out of z acceptance),
1690 // 5 "nocls" (no clusters in the road),
1691 // 6 "norefit" (cluster rejected during refit),
1692 // 7 "deadzspd" (holes in z in SPD)
1693 // Also given are the coordinates of the crossing point of track and module
1694 // (in the local module ref. system)
1695 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1696 //----------------------------------------------------------------------
1698 if(fITSModule[ilayer]==-1) {
1701 xloc=-99.; zloc=-99.;
1705 Int_t module = fITSModule[ilayer];
1707 idet = Int_t(module/1000000);
1709 module -= idet*1000000;
1711 status = Int_t(module/100000);
1713 module -= status*100000;
1715 Int_t signs = Int_t(module/10000);
1717 module-=signs*10000;
1719 Int_t xInt = Int_t(module/100);
1722 Int_t zInt = module;
1724 if(signs==1) { xInt*=1; zInt*=1; }
1725 if(signs==2) { xInt*=1; zInt*=-1; }
1726 if(signs==3) { xInt*=-1; zInt*=1; }
1727 if(signs==4) { xInt*=-1; zInt*=-1; }
1729 xloc = 0.1*(Float_t)xInt;
1730 zloc = 0.1*(Float_t)zInt;
1732 if(status==4) idet = -1;
1737 //_______________________________________________________________________
1738 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1739 //---------------------------------------------------------------------
1740 // This function returns indices of the assgined ITS clusters
1741 //---------------------------------------------------------------------
1742 if (idx && fFriendTrack) {
1743 Int_t *index=fFriendTrack->GetTPCindices();
1746 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1749 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=-2;
1755 //_______________________________________________________________________
1756 Float_t AliESDtrack::GetTPCCrossedRows() const
1758 // This function calls GetTPCClusterInfo with some default parameters which are used in the track selection and caches the outcome
1759 // because GetTPCClusterInfo is quite time-consuming
1761 if (fCacheNCrossedRows > -1)
1762 return fCacheNCrossedRows;
1764 fCacheNCrossedRows = GetTPCClusterInfo(2, 1);
1765 return fCacheNCrossedRows;
1768 //_______________________________________________________________________
1769 Float_t AliESDtrack::GetTPCClusterInfo(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1) const
1772 // TPC cluster information
1773 // type 0: get fraction of found/findable clusters with neighbourhood definition
1774 // 1: findable clusters with neighbourhood definition
1775 // 2: found clusters
1777 // definition of findable clusters:
1778 // a cluster is defined as findable if there is another cluster
1779 // within +- nNeighbours pad rows. The idea is to overcome threshold
1780 // effects with a very simple algorithm.
1783 if (type==2) return fTPCClusterMap.CountBits();
1787 Int_t last=-nNeighbours;
1789 Int_t upperBound=fTPCClusterMap.GetNbits();
1790 if (upperBound>row1) upperBound=row1;
1791 for (Int_t i=row0; i<upperBound; ++i){
1792 //look to current row
1793 if (fTPCClusterMap[i]) {
1799 //look to nNeighbours before
1800 if ((i-last)<=nNeighbours) {
1804 //look to nNeighbours after
1805 for (Int_t j=i+1; j<i+1+nNeighbours; ++j){
1806 if (fTPCClusterMap[j]){
1812 if (type==1) return findable;
1817 fraction=(Float_t)found/(Float_t)findable;
1822 return 0; // undefined type - default value
1825 //_______________________________________________________________________
1826 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1828 // GetDensity of the clusters on given region between row0 and row1
1829 // Dead zone effect takin into acoount
1831 if (!fFriendTrack) return 0.0;
1835 Int_t *index=fFriendTrack->GetTPCindices();
1836 for (Int_t i=row0;i<=row1;i++){
1837 Int_t idx = index[i];
1838 if (idx!=-1) good++; // track outside of dead zone
1841 Float_t density=0.5;
1842 if (good>TMath::Max((row1-row0)*0.5,0.0)) density = Float_t(found)/Float_t(good);
1846 //_______________________________________________________________________
1847 void AliESDtrack::SetTPCpid(const Double_t *p) {
1848 // Sets values for the probability of each particle type (in TPC)
1849 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1850 SetStatus(AliESDtrack::kTPCpid);
1853 //_______________________________________________________________________
1854 void AliESDtrack::GetTPCpid(Double_t *p) const {
1855 // Gets the probability of each particle type (in TPC)
1856 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1859 //_______________________________________________________________________
1860 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1861 //---------------------------------------------------------------------
1862 // This function returns indices of the assgined TRD clusters
1863 //---------------------------------------------------------------------
1864 if (idx && fFriendTrack) {
1865 Int_t *index=fFriendTrack->GetTRDindices();
1868 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1871 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=-2;
1877 //_______________________________________________________________________
1878 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1880 // This function returns the number of TRD tracklets used in tracking
1881 // and it fills the indices of these tracklets in the array "idx" as they
1882 // are registered in the TRD track list.
1885 // 1. The idx array has to be allocated with a size >= AliESDtrack::kTRDnPlanes
1886 // 2. The idx array store not only the index but also the layer of the tracklet.
1887 // Therefore tracks with TRD gaps contain default values for indices [-1]
1889 if (!fFriendTrack) return 0;
1890 if (!idx) return GetTRDntracklets();
1891 Int_t *index=fFriendTrack->GetTRDindices();
1893 for (Int_t i=0; i<kTRDnPlanes; i++){
1895 if(index[i]>=0) n++;
1903 //_______________________________________________________________________
1904 void AliESDtrack::SetTRDpid(const Double_t *p) {
1905 // Sets values for the probability of each particle type (in TRD)
1906 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
1907 SetStatus(AliESDtrack::kTRDpid);
1910 //_______________________________________________________________________
1911 void AliESDtrack::GetTRDpid(Double_t *p) const {
1912 // Gets the probability of each particle type (in TRD)
1913 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
1916 //_______________________________________________________________________
1917 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1919 // Sets the probability of particle type iSpecies to p (in TRD)
1920 fTRDr[iSpecies] = p;
1923 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
1925 // Returns the probability of particle type iSpecies (in TRD)
1926 return fTRDr[iSpecies];
1929 //____________________________________________________
1930 Int_t AliESDtrack::GetNumberOfTRDslices() const
1932 // built in backward compatibility
1933 Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
1934 return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
1937 //____________________________________________________
1938 Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
1940 //Returns momentum estimation and optional its error (sp)
1941 // in TRD layer "plane".
1944 AliDebug(2, "No TRD info allocated for this track.");
1947 if ((plane<0) || (plane>=kTRDnPlanes)) {
1948 AliWarning(Form("Request for TRD plane[%d] outside range.", plane));
1952 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1953 // Protection for backward compatibility
1954 if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
1956 if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
1957 return fTRDslices[idx];
1960 //____________________________________________________
1961 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1962 //Gets the charge from the slice of the plane
1965 //AliError("No TRD slices allocated for this track !");
1968 if ((plane<0) || (plane>=kTRDnPlanes)) {
1969 AliError("Info for TRD plane not available !");
1972 Int_t ns=GetNumberOfTRDslices();
1973 if ((slice<-1) || (slice>=ns)) {
1974 //AliError("Wrong TRD slice !");
1978 if(slice>=0) return fTRDslices[plane*ns + slice];
1980 // return average of the dEdx measurements
1981 Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
1982 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
1986 //____________________________________________________
1987 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1988 //Sets the number of slices used for PID
1989 if (fTRDnSlices) return;
1992 fTRDslices=new Double32_t[fTRDnSlices];
1994 // set-up correctly the allocated memory
1995 memset(fTRDslices, 0, n*sizeof(Double32_t));
1996 for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
1999 //____________________________________________________
2000 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
2001 //Sets the charge q in the slice of the plane
2003 AliError("No TRD slices allocated for this track !");
2006 if ((plane<0) || (plane>=kTRDnPlanes)) {
2007 AliError("Info for TRD plane not allocated !");
2010 Int_t ns=GetNumberOfTRDslices();
2011 if ((slice<0) || (slice>=ns)) {
2012 AliError("Wrong TRD slice !");
2015 Int_t n=plane*ns + slice;
2020 //____________________________________________________
2021 void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
2024 AliError("No TRD slices allocated for this track !");
2027 if ((plane<0) || (plane>=kTRDnPlanes)) {
2028 AliError("Info for TRD plane not allocated !");
2032 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
2033 // Protection for backward compatibility
2034 if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
2036 if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
2037 fTRDslices[idx] = p;
2041 //_______________________________________________________________________
2042 void AliESDtrack::SetTOFpid(const Double_t *p) {
2043 // Sets the probability of each particle type (in TOF)
2044 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
2045 SetStatus(AliESDtrack::kTOFpid);
2048 //_______________________________________________________________________
2049 void AliESDtrack::SetTOFLabel(const Int_t *p) {
2051 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
2054 //_______________________________________________________________________
2055 void AliESDtrack::GetTOFpid(Double_t *p) const {
2056 // Gets probabilities of each particle type (in TOF)
2057 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
2060 //_______________________________________________________________________
2061 void AliESDtrack::GetTOFLabel(Int_t *p) const {
2063 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
2066 //_______________________________________________________________________
2067 void AliESDtrack::GetTOFInfo(Float_t *info) const {
2069 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
2072 //_______________________________________________________________________
2073 void AliESDtrack::SetTOFInfo(Float_t*info) {
2075 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
2080 //_______________________________________________________________________
2081 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
2082 // Sets the probability of each particle type (in HMPID)
2083 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
2084 SetStatus(AliESDtrack::kHMPIDpid);
2087 //_______________________________________________________________________
2088 void AliESDtrack::SetTPCdEdxInfo(AliTPCdEdxInfo * dEdxInfo){
2089 if(fTPCdEdxInfo) delete fTPCdEdxInfo;
2090 fTPCdEdxInfo = dEdxInfo;
2093 //_______________________________________________________________________
2094 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
2095 // Gets probabilities of each particle type (in HMPID)
2096 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
2101 //_______________________________________________________________________
2102 void AliESDtrack::SetESDpid(const Double_t *p) {
2103 // Sets the probability of each particle type for the ESD track
2104 SetPIDValues(fR,p,AliPID::kSPECIES);
2105 SetStatus(AliESDtrack::kESDpid);
2108 //_______________________________________________________________________
2109 void AliESDtrack::GetESDpid(Double_t *p) const {
2110 // Gets probability of each particle type for the ESD track
2111 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
2114 //_______________________________________________________________________
2115 Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
2116 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2118 // Try to relate the TPC-only track parameters to the vertex "vtx",
2119 // if the (rough) transverse impact parameter is not bigger then "maxd".
2120 // Magnetic field is "b" (kG).
2122 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2123 // b) The impact parameters and their covariance matrix are calculated.
2124 // c) An attempt to constrain the TPC-only params to the vertex is done.
2125 // The constrained params are returned via "cParam".
2127 // In the case of success, the returned value is kTRUE
2128 // otherwise, it's kFALSE)
2131 if (!fTPCInner) return kFALSE;
2132 if (!vtx) return kFALSE;
2134 Double_t dz[2],cov[3];
2135 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2143 Double_t covar[6]; vtx->GetCovMatrix(covar);
2144 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2145 Double_t c[3]={covar[2],0.,covar[5]};
2147 Double_t chi2=GetPredictedChi2(p,c);
2148 if (chi2>kVeryBig) return kFALSE;
2152 if (!cParam) return kTRUE;
2154 *cParam = *fTPCInner;
2155 if (!cParam->Update(p,c)) return kFALSE;
2160 //_______________________________________________________________________
2161 Bool_t AliESDtrack::RelateToVertexTPCBxByBz(const AliESDVertex *vtx,
2162 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2164 // Try to relate the TPC-only track parameters to the vertex "vtx",
2165 // if the (rough) transverse impact parameter is not bigger then "maxd".
2167 // All three components of the magnetic field ,"b[3]" (kG),
2168 // are taken into account.
2170 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2171 // b) The impact parameters and their covariance matrix are calculated.
2172 // c) An attempt to constrain the TPC-only params to the vertex is done.
2173 // The constrained params are returned via "cParam".
2175 // In the case of success, the returned value is kTRUE
2176 // otherwise, it's kFALSE)
2179 if (!fTPCInner) return kFALSE;
2180 if (!vtx) return kFALSE;
2182 Double_t dz[2],cov[3];
2183 if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2191 Double_t covar[6]; vtx->GetCovMatrix(covar);
2192 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2193 Double_t c[3]={covar[2],0.,covar[5]};
2195 Double_t chi2=GetPredictedChi2(p,c);
2196 if (chi2>kVeryBig) return kFALSE;
2200 if (!cParam) return kTRUE;
2202 *cParam = *fTPCInner;
2203 if (!cParam->Update(p,c)) return kFALSE;
2208 //_______________________________________________________________________
2209 Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
2210 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2212 // Try to relate this track to the vertex "vtx",
2213 // if the (rough) transverse impact parameter is not bigger then "maxd".
2214 // Magnetic field is "b" (kG).
2216 // a) The track gets extapolated to the DCA to the vertex.
2217 // b) The impact parameters and their covariance matrix are calculated.
2218 // c) An attempt to constrain this track to the vertex is done.
2219 // The constrained params are returned via "cParam".
2221 // In the case of success, the returned value is kTRUE
2222 // (otherwise, it's kFALSE)
2225 if (!vtx) return kFALSE;
2227 Double_t dz[2],cov[3];
2228 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2236 Double_t covar[6]; vtx->GetCovMatrix(covar);
2237 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2238 Double_t c[3]={covar[2],0.,covar[5]};
2240 Double_t chi2=GetPredictedChi2(p,c);
2241 if (chi2>kVeryBig) return kFALSE;
2246 //--- Could now these lines be removed ? ---
2248 fCp=new AliExternalTrackParam(*this);
2250 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2251 //----------------------------------------
2253 fVertexID = vtx->GetID();
2255 if (!cParam) return kTRUE;
2258 if (!cParam->Update(p,c)) return kFALSE;
2263 //_______________________________________________________________________
2264 Bool_t AliESDtrack::RelateToVertexBxByBz(const AliESDVertex *vtx,
2265 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2267 // Try to relate this track to the vertex "vtx",
2268 // if the (rough) transverse impact parameter is not bigger then "maxd".
2269 // Magnetic field is "b" (kG).
2271 // a) The track gets extapolated to the DCA to the vertex.
2272 // b) The impact parameters and their covariance matrix are calculated.
2273 // c) An attempt to constrain this track to the vertex is done.
2274 // The constrained params are returned via "cParam".
2276 // In the case of success, the returned value is kTRUE
2277 // (otherwise, it's kFALSE)
2280 if (!vtx) return kFALSE;
2282 Double_t dz[2],cov[3];
2283 if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2291 Double_t covar[6]; vtx->GetCovMatrix(covar);
2292 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2293 Double_t c[3]={covar[2],0.,covar[5]};
2295 Double_t chi2=GetPredictedChi2(p,c);
2296 if (chi2>kVeryBig) return kFALSE;
2301 //--- Could now these lines be removed ? ---
2303 fCp=new AliExternalTrackParam(*this);
2305 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2306 //----------------------------------------
2308 fVertexID = vtx->GetID();
2310 if (!cParam) return kTRUE;
2313 if (!cParam->Update(p,c)) return kFALSE;
2318 //_______________________________________________________________________
2319 void AliESDtrack::Print(Option_t *) const {
2320 // Prints info on the track
2321 AliExternalTrackParam::Print();
2322 printf("ESD track info\n") ;
2323 Double_t p[AliPID::kSPECIESN] ;
2325 if( IsOn(kITSpid) ){
2326 printf("From ITS: ") ;
2328 for(index = 0 ; index < AliPID::kSPECIES; index++)
2329 printf("%f, ", p[index]) ;
2330 printf("\n signal = %f\n", GetITSsignal()) ;
2332 if( IsOn(kTPCpid) ){
2333 printf("From TPC: ") ;
2335 for(index = 0 ; index < AliPID::kSPECIES; index++)
2336 printf("%f, ", p[index]) ;
2337 printf("\n signal = %f\n", GetTPCsignal()) ;
2339 if( IsOn(kTRDpid) ){
2340 printf("From TRD: ") ;
2342 for(index = 0 ; index < AliPID::kSPECIES; index++)
2343 printf("%f, ", p[index]) ;
2344 printf("\n signal = %f\n", GetTRDsignal()) ;
2346 if( IsOn(kTOFpid) ){
2347 printf("From TOF: ") ;
2349 for(index = 0 ; index < AliPID::kSPECIES; index++)
2350 printf("%f, ", p[index]) ;
2351 printf("\n signal = %f\n", GetTOFsignal()) ;
2353 if( IsOn(kHMPIDpid) ){
2354 printf("From HMPID: ") ;
2356 for(index = 0 ; index < AliPID::kSPECIES; index++)
2357 printf("%f, ", p[index]) ;
2358 printf("\n signal = %f\n", GetHMPIDsignal()) ;
2364 // Draw functionality
2365 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
2367 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
2369 // Fill points in the polymarker
2372 arrayRef.AddLast(new AliExternalTrackParam(*this));
2373 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
2374 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
2375 if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
2377 Double_t mpos[3]={0,0,0};
2378 Int_t entries=arrayRef.GetEntries();
2379 for (Int_t i=0;i<entries;i++){
2381 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
2382 mpos[0]+=pos[0]/entries;
2383 mpos[1]+=pos[1]/entries;
2384 mpos[2]+=pos[2]/entries;
2386 // Rotate to the mean position
2388 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
2389 for (Int_t i=0;i<entries;i++){
2390 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
2391 if (!res) delete arrayRef.RemoveAt(i);
2394 for (Double_t r=minR; r<maxR; r+=stepR){
2396 Double_t mlpos[3]={0,0,0};
2397 for (Int_t i=0;i<entries;i++){
2398 Double_t point[3]={0,0,0};
2399 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
2400 if (!param) continue;
2401 if (param->GetXYZAt(r,magF,point)){
2402 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
2404 mlpos[0]+=point[0]*weight;
2405 mlpos[1]+=point[1]*weight;
2406 mlpos[2]+=point[2]*weight;
2413 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
2414 // printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
2420 //_______________________________________________________________________
2421 void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
2423 // Store the dE/dx samples measured by the two SSD and two SDD layers.
2424 // These samples are corrected for the track segment length.
2426 for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
2429 //_______________________________________________________________________
2430 void AliESDtrack::GetITSdEdxSamples(Double_t *s) const {
2432 // Get the dE/dx samples measured by the two SSD and two SDD layers.
2433 // These samples are corrected for the track segment length.
2435 for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];
2439 UShort_t AliESDtrack::GetTPCnclsS(Int_t i0,Int_t i1) const{
2441 // get number of shared TPC clusters
2443 return fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);
2446 UShort_t AliESDtrack::GetTPCncls(Int_t i0,Int_t i1) const{
2448 // get number of TPC clusters
2450 return fTPCClusterMap.CountBits(i0)-fTPCClusterMap.CountBits(i1);
2453 //____________________________________________________________________
2454 Double_t AliESDtrack::GetChi2TPCConstrainedVsGlobal(const AliESDVertex* vtx) const
2456 // Calculates the chi2 between the TPC track (TPCinner) constrained to the primary vertex and the global track
2458 // Returns -1 in case the calculation failed
2460 // Value is cached as a non-persistent member.
2462 // Code adapted from original code by GSI group (Jacek, Marian, Michael)
2464 // cache, ignoring that a different vertex might be passed
2465 if (fCacheChi2TPCConstrainedVsGlobalVertex == vtx)
2466 return fCacheChi2TPCConstrainedVsGlobal;
2468 fCacheChi2TPCConstrainedVsGlobal = -1;
2469 fCacheChi2TPCConstrainedVsGlobalVertex = vtx;
2474 AliTrackerBase::GetBxByBz(x,b);
2477 AliWarning("Could not get TPC Inner Param.");
2478 return fCacheChi2TPCConstrainedVsGlobal;
2481 // clone for constraining
2482 AliExternalTrackParam* tpcInnerC = new AliExternalTrackParam(*fTPCInner);
2484 AliWarning("Clone of TPCInnerParam failed.");
2485 return fCacheChi2TPCConstrainedVsGlobal;
2488 // transform to the track reference frame
2489 Bool_t isOK = tpcInnerC->Rotate(GetAlpha());
2490 isOK &= tpcInnerC->PropagateTo(GetX(), b[2]);
2494 AliWarning("Rotation/Propagation of track failed.") ;
2495 return fCacheChi2TPCConstrainedVsGlobal;
2498 // constrain TPCinner
2499 isOK = tpcInnerC->ConstrainToVertex(vtx, b);
2501 // transform to the track reference frame
2502 isOK &= tpcInnerC->Rotate(GetAlpha());
2503 isOK &= tpcInnerC->PropagateTo(GetX(), b[2]);
2506 AliWarning("ConstrainTPCInner failed.") ;
2509 return fCacheChi2TPCConstrainedVsGlobal;
2512 // calculate chi2 between vi and vj vectors
2513 // with covi and covj covariance matrices
2514 // chi2ij = (vi-vj)^(T)*(covi+covj)^(-1)*(vi-vj)
2515 TMatrixD deltaT(5,1);
2516 TMatrixD delta(1,5);
2517 TMatrixD covarM(5,5);
2519 for (Int_t ipar=0; ipar<5; ipar++) {
2520 deltaT(ipar,0) = tpcInnerC->GetParameter()[ipar] - GetParameter()[ipar];
2521 delta(0,ipar) = tpcInnerC->GetParameter()[ipar] - GetParameter()[ipar];
2523 for (Int_t jpar=0; jpar<5; jpar++) {
2524 Int_t index = GetIndex(ipar,jpar);
2525 covarM(ipar,jpar) = GetCovariance()[index]+tpcInnerC->GetCovariance()[index];
2528 // chi2 distance TPC constrained and TPC+ITS
2529 TMatrixD covarMInv = covarM.Invert();
2530 TMatrixD mat2 = covarMInv*deltaT;
2531 TMatrixD chi2 = delta*mat2;
2536 fCacheChi2TPCConstrainedVsGlobal = chi2(0,0);
2537 return fCacheChi2TPCConstrainedVsGlobal;