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"
131 #include "AliDetectorPID.h"
133 ClassImp(AliESDtrack)
135 void SetPIDValues(Double_t * dest, const Double_t * src, Int_t n) {
136 // This function copies "n" PID weights from "scr" to "dest"
137 // and normalizes their sum to 1 thus producing conditional probabilities.
138 // The negative weights are set to 0.
139 // In case all the weights are non-positive they are replaced by
140 // uniform probabilities
144 Float_t uniform = 1./(Float_t)n;
147 for (Int_t i=0; i<n; i++)
157 for (Int_t i=0; i<n; i++) dest[i] /= sum;
159 for (Int_t i=0; i<n; i++) dest[i] = uniform;
162 //_______________________________________________________________________
163 AliESDtrack::AliESDtrack() :
164 AliExternalTrackParam(),
171 fTPCFitMap(159),//number of padrows
172 fTPCClusterMap(159),//number of padrows
173 fTPCSharedMap(159),//number of padrows
184 fCaloIndex(kEMCALNoMatch),
190 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
193 fCdd(0),fCdz(0),fCzz(0),
211 fTOFsignalToT(99999),
212 fTOFsignalRaw(99999),
238 fVertexID(-2),// -2 means an orphan track
240 fCacheNCrossedRows(-10),
241 fCacheChi2TPCConstrainedVsGlobal(-10),
242 fCacheChi2TPCConstrainedVsGlobalVertex(0),
244 fTrackPhiOnEMCal(-999),
245 fTrackEtaOnEMCal(-999)
248 // The default ESD constructor
250 if (!OnlineMode()) fFriendTrack=new AliESDfriendTrack();
253 for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
254 for (i=0; i<AliPID::kSPECIES; i++) {
264 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
265 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
266 for (i=0;i<kTRDnPlanes;i++) {
269 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
270 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
271 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
272 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
273 for (i=0;i<12;i++) {fITSModule[i]=-1;}
276 bool AliESDtrack::fgkOnlineMode=false;
278 //_______________________________________________________________________
279 AliESDtrack::AliESDtrack(const AliESDtrack& track):
280 AliExternalTrackParam(track),
287 fTPCFitMap(track.fTPCFitMap),
288 fTPCClusterMap(track.fTPCClusterMap),
289 fTPCSharedMap(track.fTPCSharedMap),
290 fFlags(track.fFlags),
292 fLabel(track.fLabel),
293 fITSLabel(track.fITSLabel),
294 fTPCLabel(track.fTPCLabel),
295 fTRDLabel(track.fTRDLabel),
296 fTOFCalChannel(track.fTOFCalChannel),
297 fTOFindex(track.fTOFindex),
298 fHMPIDqn(track.fHMPIDqn),
299 fHMPIDcluIdx(track.fHMPIDcluIdx),
300 fCaloIndex(track.fCaloIndex),
301 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
302 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
303 fHMPIDsignal(track.fHMPIDsignal),
304 fTrackLength(track.fTrackLength),
305 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
306 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
307 fCchi2TPC(track.fCchi2TPC),
308 fD(track.fD),fZ(track.fZ),
309 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
310 fCchi2(track.fCchi2),
311 fITSchi2(track.fITSchi2),
312 fTPCchi2(track.fTPCchi2),
313 fTPCchi2Iter1(track.fTPCchi2Iter1),
314 fTRDchi2(track.fTRDchi2),
315 fTOFchi2(track.fTOFchi2),
316 fHMPIDchi2(track.fHMPIDchi2),
317 fGlobalChi2(track.fGlobalChi2),
318 fITSsignal(track.fITSsignal),
319 fTPCsignal(track.fTPCsignal),
320 fTPCsignalTuned(track.fTPCsignalTuned),
321 fTPCsignalS(track.fTPCsignalS),
323 fTRDsignal(track.fTRDsignal),
324 fTRDQuality(track.fTRDQuality),
325 fTRDBudget(track.fTRDBudget),
326 fTOFsignal(track.fTOFsignal),
327 fTOFsignalToT(track.fTOFsignalToT),
328 fTOFsignalRaw(track.fTOFsignalRaw),
329 fTOFsignalDz(track.fTOFsignalDz),
330 fTOFsignalDx(track.fTOFsignalDx),
331 fTOFdeltaBC(track.fTOFdeltaBC),
332 fTOFl0l1(track.fTOFl0l1),
333 fCaloDx(track.fCaloDx),
334 fCaloDz(track.fCaloDz),
335 fHMPIDtrkX(track.fHMPIDtrkX),
336 fHMPIDtrkY(track.fHMPIDtrkY),
337 fHMPIDmipX(track.fHMPIDmipX),
338 fHMPIDmipY(track.fHMPIDmipY),
339 fTPCncls(track.fTPCncls),
340 fTPCnclsF(track.fTPCnclsF),
341 fTPCsignalN(track.fTPCsignalN),
342 fTPCnclsIter1(track.fTPCnclsIter1),
343 fTPCnclsFIter1(track.fTPCnclsIter1),
344 fITSncls(track.fITSncls),
345 fITSClusterMap(track.fITSClusterMap),
346 fITSSharedMap(track.fITSSharedMap),
347 fTRDncls(track.fTRDncls),
348 fTRDncls0(track.fTRDncls0),
349 fTRDntracklets(track.fTRDntracklets),
350 fTRDNchamberdEdx(track.fTRDNchamberdEdx),
351 fTRDNclusterdEdx(track.fTRDNclusterdEdx),
352 fTRDnSlices(track.fTRDnSlices),
354 fVertexID(track.fVertexID),
355 fESDEvent(track.fESDEvent),
356 fCacheNCrossedRows(track.fCacheNCrossedRows),
357 fCacheChi2TPCConstrainedVsGlobal(track.fCacheChi2TPCConstrainedVsGlobal),
358 fCacheChi2TPCConstrainedVsGlobalVertex(track.fCacheChi2TPCConstrainedVsGlobalVertex),
360 fTrackPhiOnEMCal(track.fTrackPhiOnEMCal),
361 fTrackEtaOnEMCal(track.fTrackEtaOnEMCal)
366 for (Int_t i=kNITSchi2Std;i--;) fITSchi2Std[i] = track.fTrackTime[i];
367 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
368 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
370 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
372 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
373 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
374 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
375 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
376 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
378 for (Int_t i=0;i<kTRDnPlanes;i++) {
379 fTRDTimBin[i]=track.fTRDTimBin[i];
383 fTRDslices=new Double32_t[fTRDnSlices];
384 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
387 if (track.fDetectorPID) fDetectorPID = new AliDetectorPID(*track.fDetectorPID);
389 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
390 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
391 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
392 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
393 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
394 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
396 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
397 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
398 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
399 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
400 if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
401 if (track.fTPCdEdxInfo) fTPCdEdxInfo = new AliTPCdEdxInfo(*track.fTPCdEdxInfo);
404 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
407 //_______________________________________________________________________
408 AliESDtrack::AliESDtrack(const AliVTrack *track) :
409 AliExternalTrackParam(track),
416 fTPCFitMap(159),//number of padrows
417 fTPCClusterMap(159),//number of padrows
418 fTPCSharedMap(159),//number of padrows
429 fCaloIndex(kEMCALNoMatch),
435 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
438 fCdd(0),fCdz(0),fCzz(0),
456 fTOFsignalToT(99999),
457 fTOFsignalRaw(99999),
483 fVertexID(-2), // -2 means an orphan track
485 fCacheNCrossedRows(-10),
486 fCacheChi2TPCConstrainedVsGlobal(-10),
487 fCacheChi2TPCConstrainedVsGlobalVertex(0),
489 fTrackPhiOnEMCal(-999),
490 fTrackEtaOnEMCal(-999)
493 // ESD track from AliVTrack.
494 // This is not a copy constructor !
497 if (track->InheritsFrom("AliExternalTrackParam")) {
498 AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
499 AliWarning("Calling the default constructor...");
504 // Reset all the arrays
506 for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
507 for (i=0; i<AliPID::kSPECIES; i++) {
517 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
518 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
519 for (i=0;i<kTRDnPlanes;i++) {
522 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
523 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
524 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
525 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
526 for (i=0;i<12;i++) {fITSModule[i]=-1;}
529 SetID(track->GetID());
531 // Set ITS cluster map
532 fITSClusterMap=track->GetITSClusterMap();
537 if(HasPointOnITSLayer(i)) fITSncls++;
541 fTPCncls=track->GetTPCNcls();
544 // Set the combined PID
545 const Double_t *pid = track->PID();
547 for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
549 // AliESD track label
550 SetLabel(track->GetLabel());
552 SetStatus(track->GetStatus());
555 //_______________________________________________________________________
556 AliESDtrack::AliESDtrack(TParticle * part) :
557 AliExternalTrackParam(),
564 fTPCFitMap(159),//number of padrows
565 fTPCClusterMap(159),//number of padrows
566 fTPCSharedMap(159),//number of padrows
577 fCaloIndex(kEMCALNoMatch),
583 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
586 fCdd(0),fCdz(0),fCzz(0),
604 fTOFsignalToT(99999),
605 fTOFsignalRaw(99999),
631 fVertexID(-2), // -2 means an orphan track
633 fCacheNCrossedRows(-10),
634 fCacheChi2TPCConstrainedVsGlobal(-10),
635 fCacheChi2TPCConstrainedVsGlobalVertex(0),
637 fTrackPhiOnEMCal(-999),
638 fTrackEtaOnEMCal(-999)
641 // ESD track from TParticle
644 // Reset all the arrays
646 for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
647 for (i=0; i<AliPID::kSPECIES; i++) {
657 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
658 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
659 for (i=0;i<kTRDnPlanes;i++) {
662 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
663 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
664 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
665 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
666 for (i=0;i<12;i++) {fITSModule[i]=-1;}
668 // Calculate the AliExternalTrackParam content
675 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
676 alpha = part->Phi()*180./TMath::Pi();
677 if (alpha<0) alpha+= 360.;
678 if (alpha>360) alpha -= 360.;
680 Int_t sector = (Int_t)(alpha/20.);
681 alpha = 10. + 20.*sector;
683 alpha *= TMath::Pi();
685 // Covariance matrix: no errors, the parameters are exact
686 for (i=0; i<15; i++) covar[i]=0.;
688 // Get the vertex of origin and the momentum
689 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
690 TVector3 mom(part->Px(),part->Py(),part->Pz());
692 // Rotate to the local coordinate system (TPC sector)
696 // X of the referense plane
699 Int_t pdgCode = part->GetPdgCode();
702 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
706 param[2] = TMath::Sin(mom.Phi());
707 param[3] = mom.Pz()/mom.Pt();
708 param[4] = TMath::Sign(1/mom.Pt(),charge);
710 // Set AliExternalTrackParam
711 Set(xref, alpha, param, covar);
716 switch (TMath::Abs(pdgCode)) {
742 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
743 if (indexPID < AliPID::kSPECIES) {
749 fHMPIDr[indexPID]=1.;
752 // AliESD track label
753 SetLabel(part->GetUniqueID());
757 //_______________________________________________________________________
758 AliESDtrack::~AliESDtrack(){
760 // This is destructor according Coding Conventrions
762 //printf("Delete track\n");
773 //Reset cached values - needed for TClonesArray in AliESDInputHandler
774 fCacheNCrossedRows = -10.;
775 fCacheChi2TPCConstrainedVsGlobal = -10.;
776 if(fCacheChi2TPCConstrainedVsGlobalVertex) fCacheChi2TPCConstrainedVsGlobalVertex = 0;
781 AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
784 if(&source == this) return *this;
785 AliExternalTrackParam::operator=(source);
789 // we have the trackparam: assign or copy construct
790 if(fCp)*fCp = *source.fCp;
791 else fCp = new AliExternalTrackParam(*source.fCp);
794 // no track param delete the old one
800 // we have the trackparam: assign or copy construct
801 if(fIp)*fIp = *source.fIp;
802 else fIp = new AliExternalTrackParam(*source.fIp);
805 // no track param delete the old one
811 if(source.fTPCInner){
812 // we have the trackparam: assign or copy construct
813 if(fTPCInner) *fTPCInner = *source.fTPCInner;
814 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
817 // no track param delete the old one
822 if(source.fTPCdEdxInfo) {
823 if(fTPCdEdxInfo) *fTPCdEdxInfo = *source.fTPCdEdxInfo;
824 fTPCdEdxInfo = new AliTPCdEdxInfo(*source.fTPCdEdxInfo);
828 // we have the trackparam: assign or copy construct
829 if(fOp) *fOp = *source.fOp;
830 else fOp = new AliExternalTrackParam(*source.fOp);
833 // no track param delete the old one
840 // we have the trackparam: assign or copy construct
841 if(fHMPIDp) *fHMPIDp = *source.fHMPIDp;
842 else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
845 // no track param delete the old one
850 // copy also the friend track
851 // use copy constructor
852 if(source.fFriendTrack){
853 // we have the trackparam: assign or copy construct
854 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
857 // no track param delete the old one
858 delete fFriendTrack; fFriendTrack= 0;
861 fTPCFitMap = source.fTPCFitMap;
862 fTPCClusterMap = source.fTPCClusterMap;
863 fTPCSharedMap = source.fTPCSharedMap;
865 fFlags = source.fFlags;
867 fLabel = source.fLabel;
868 fITSLabel = source.fITSLabel;
869 for(int i = 0; i< 12;++i){
870 fITSModule[i] = source.fITSModule[i];
872 fTPCLabel = source.fTPCLabel;
873 fTRDLabel = source.fTRDLabel;
874 for(int i = 0; i< 3;++i){
875 fTOFLabel[i] = source.fTOFLabel[i];
877 fTOFCalChannel = source.fTOFCalChannel;
878 fTOFindex = source.fTOFindex;
879 fHMPIDqn = source.fHMPIDqn;
880 fHMPIDcluIdx = source.fHMPIDcluIdx;
881 fCaloIndex = source.fCaloIndex;
882 for (int i=kNITSchi2Std;i--;) fITSchi2Std[i] = source.fITSchi2Std[i];
883 for(int i = 0; i< 3;++i){
884 fKinkIndexes[i] = source.fKinkIndexes[i];
885 fV0Indexes[i] = source.fV0Indexes[i];
888 for(int i = 0; i< AliPID::kSPECIES;++i){
889 fR[i] = source.fR[i];
890 fITSr[i] = source.fITSr[i];
891 fTPCr[i] = source.fTPCr[i];
892 fTRDr[i] = source.fTRDr[i];
893 fTOFr[i] = source.fTOFr[i];
894 fHMPIDr[i] = source.fHMPIDr[i];
895 fTrackTime[i] = source.fTrackTime[i];
898 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
899 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
900 fHMPIDsignal = source.fHMPIDsignal;
903 fTrackLength = source. fTrackLength;
904 fdTPC = source.fdTPC;
905 fzTPC = source.fzTPC;
906 fCddTPC = source.fCddTPC;
907 fCdzTPC = source.fCdzTPC;
908 fCzzTPC = source.fCzzTPC;
909 fCchi2TPC = source.fCchi2TPC;
916 fCchi2 = source.fCchi2;
918 fITSchi2 = source.fITSchi2;
919 fTPCchi2 = source.fTPCchi2;
920 fTPCchi2Iter1 = source.fTPCchi2Iter1;
921 fTRDchi2 = source.fTRDchi2;
922 fTOFchi2 = source.fTOFchi2;
923 fHMPIDchi2 = source.fHMPIDchi2;
925 fGlobalChi2 = source.fGlobalChi2;
927 fITSsignal = source.fITSsignal;
928 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
929 fTPCsignal = source.fTPCsignal;
930 fTPCsignalTuned = source.fTPCsignalTuned;
931 fTPCsignalS = source.fTPCsignalS;
932 for(int i = 0; i< 4;++i){
933 fTPCPoints[i] = source.fTPCPoints[i];
935 fTRDsignal = source.fTRDsignal;
936 fTRDNchamberdEdx = source.fTRDNchamberdEdx;
937 fTRDNclusterdEdx = source.fTRDNclusterdEdx;
939 for(int i = 0;i < kTRDnPlanes;++i){
940 fTRDTimBin[i] = source.fTRDTimBin[i];
946 fTRDnSlices=source.fTRDnSlices;
948 fTRDslices=new Double32_t[fTRDnSlices];
949 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
952 fTRDQuality = source.fTRDQuality;
953 fTRDBudget = source.fTRDBudget;
954 fTOFsignal = source.fTOFsignal;
955 fTOFsignalToT = source.fTOFsignalToT;
956 fTOFsignalRaw = source.fTOFsignalRaw;
957 fTOFsignalDz = source.fTOFsignalDz;
958 fTOFsignalDx = source.fTOFsignalDx;
959 fTOFdeltaBC = source.fTOFdeltaBC;
960 fTOFl0l1 = source.fTOFl0l1;
962 for(int i = 0;i<10;++i){
963 fTOFInfo[i] = source.fTOFInfo[i];
966 fHMPIDtrkX = source.fHMPIDtrkX;
967 fHMPIDtrkY = source.fHMPIDtrkY;
968 fHMPIDmipX = source.fHMPIDmipX;
969 fHMPIDmipY = source.fHMPIDmipY;
971 fTPCncls = source.fTPCncls;
972 fTPCnclsF = source.fTPCnclsF;
973 fTPCsignalN = source.fTPCsignalN;
974 fTPCnclsIter1 = source.fTPCnclsIter1;
975 fTPCnclsFIter1 = source.fTPCnclsFIter1;
977 fITSncls = source.fITSncls;
978 fITSClusterMap = source.fITSClusterMap;
979 fITSSharedMap = source.fITSSharedMap;
980 fTRDncls = source.fTRDncls;
981 fTRDncls0 = source.fTRDncls0;
982 fTRDntracklets = source.fTRDntracklets;
983 fVertexID = source.fVertexID;
985 fCacheNCrossedRows = source.fCacheNCrossedRows;
986 fCacheChi2TPCConstrainedVsGlobal = source.fCacheChi2TPCConstrainedVsGlobal;
987 fCacheChi2TPCConstrainedVsGlobalVertex = source.fCacheChi2TPCConstrainedVsGlobalVertex;
991 if (source.fDetectorPID) fDetectorPID = new AliDetectorPID(*source.fDetectorPID);
993 fTrackPhiOnEMCal= source.fTrackPhiOnEMCal;
994 fTrackEtaOnEMCal= source.fTrackEtaOnEMCal;
1001 void AliESDtrack::Copy(TObject &obj) const {
1003 // this overwrites the virtual TOBject::Copy()
1004 // to allow run time copying without casting
1007 if(this==&obj)return;
1008 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
1009 if(!robj)return; // not an AliESDtrack
1016 void AliESDtrack::AddCalibObject(TObject * object){
1018 // add calib object to the list
1020 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
1021 if (!fFriendTrack) return;
1022 fFriendTrack->AddCalibObject(object);
1025 TObject * AliESDtrack::GetCalibObject(Int_t index){
1027 // return calib objct at given position
1029 if (!fFriendTrack) return 0;
1030 return fFriendTrack->GetCalibObject(index);
1034 Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
1036 // Fills the information of the TPC-only first reconstruction pass
1037 // into the passed ESDtrack object. For consistency fTPCInner is also filled
1042 // For data produced before r26675
1043 // RelateToVertexTPC was not properly called during reco
1044 // so you'll have to call it again, before FillTPCOnlyTrack
1045 // Float_t p[2],cov[3];
1046 // track->GetImpactParametersTPC(p,cov);
1047 // if(p[0]==0&&p[1]==0) // <- Default values
1048 // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
1051 if(!fTPCInner)return kFALSE;
1053 // fill the TPC track params to the global track parameters
1054 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
1057 track.fCdd = fCddTPC;
1058 track.fCdz = fCdzTPC;
1059 track.fCzz = fCzzTPC;
1061 // copy the inner params
1062 if(track.fIp) *track.fIp = *fIp;
1063 else track.fIp = new AliExternalTrackParam(*fIp);
1065 // copy the TPCinner parameters
1066 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
1067 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
1068 track.fdTPC = fdTPC;
1069 track.fzTPC = fzTPC;
1070 track.fCddTPC = fCddTPC;
1071 track.fCdzTPC = fCdzTPC;
1072 track.fCzzTPC = fCzzTPC;
1073 track.fCchi2TPC = fCchi2TPC;
1075 // copy all other TPC specific parameters
1077 // replace label by TPC label
1078 track.fLabel = fTPCLabel;
1079 track.fTPCLabel = fTPCLabel;
1081 track.fTPCchi2 = fTPCchi2;
1082 track.fTPCchi2Iter1 = fTPCchi2Iter1;
1083 track.fTPCsignal = fTPCsignal;
1084 track.fTPCsignalTuned = fTPCsignalTuned;
1085 track.fTPCsignalS = fTPCsignalS;
1086 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
1088 track.fTPCncls = fTPCncls;
1089 track.fTPCnclsF = fTPCnclsF;
1090 track.fTPCsignalN = fTPCsignalN;
1091 track.fTPCnclsIter1 = fTPCnclsIter1;
1092 track.fTPCnclsFIter1 = fTPCnclsFIter1;
1095 for(int i=0;i<AliPID::kSPECIES;++i){
1096 track.fTPCr[i] = fTPCr[i];
1097 // combined PID is TPC only!
1098 track.fR[i] = fTPCr[i];
1100 track.fTPCFitMap = fTPCFitMap;
1101 track.fTPCClusterMap = fTPCClusterMap;
1102 track.fTPCSharedMap = fTPCSharedMap;
1106 track.fFlags = kTPCin;
1109 track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
1111 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
1117 //_______________________________________________________________________
1118 void AliESDtrack::MakeMiniESDtrack(){
1119 // Resets everything except
1120 // fFlags: Reconstruction status flags
1121 // fLabel: Track label
1122 // fID: Unique ID of the track
1123 // Impact parameter information
1124 // fR[AliPID::kSPECIES]: combined "detector response probability"
1125 // Running track parameters in the base class (AliExternalTrackParam)
1129 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
1131 // Reset track parameters constrained to the primary vertex
1134 // Reset track parameters at the inner wall of TPC
1136 delete fTPCInner;fTPCInner=0;
1137 // Reset track parameters at the inner wall of the TRD
1139 // Reset track parameters at the HMPID
1140 delete fHMPIDp;fHMPIDp = 0;
1143 // Reset ITS track related information
1149 for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
1150 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
1153 // Reset TPC related track information
1167 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
1169 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1170 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1171 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1173 // Reset TRD related track information
1178 fTRDNchamberdEdx = 0;
1179 fTRDNclusterdEdx = 0;
1181 for (Int_t i=0;i<kTRDnPlanes;i++) {
1184 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1189 delete[] fTRDslices;
1194 // Reset TOF related track information
1198 fTOFCalChannel = -1;
1199 fTOFsignalToT = 99999;
1200 fTOFsignalRaw = 99999;
1205 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
1206 for (Int_t i=0;i<3;i++) fTOFLabel[i] = -1;
1207 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1209 // Reset HMPID related track information
1214 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
1221 fCaloIndex = kEMCALNoMatch;
1223 // reset global track chi2
1226 fVertexID = -2; // an orphan track
1228 delete fFriendTrack; fFriendTrack = 0;
1231 //_______________________________________________________________________
1232 Int_t AliESDtrack::GetPID(Bool_t tpcOnly) const
1234 // Returns the particle most probable id
1236 const Double32_t *prob = 0;
1237 if (tpcOnly) { // check if TPCpid is valid
1239 for (i=0; i<AliPID::kSPECIES-1; i++) if (prob[i] != prob[i+1]) break;
1240 if (i == AliPID::kSPECIES-1) prob = 0; // not valid, try with combined pid
1242 if (!prob) { // either requested TPCpid is not valid or comb.pid is requested
1244 for (i=0; i<AliPID::kSPECIES-1; i++) if (prob[i] != prob[i+1]) break;
1245 if (i == AliPID::kSPECIES-1) return AliPID::kPion; // If all the probabilities are equal, return the pion mass
1250 for (i=0; i<AliPID::kSPECIES; i++) if (prob[i]>max) {k=i; max=prob[i];}
1252 if (k==0) { // dE/dx "crossing points" in the TPC
1254 if ((p>0.38)&&(p<0.48))
1255 if (prob[0]<prob[3]*10.) return AliPID::kKaon;
1256 if ((p>0.75)&&(p<0.85))
1257 if (prob[0]<prob[4]*10.) return AliPID::kProton;
1258 return AliPID::kElectron;
1260 if (k==1) return AliPID::kMuon;
1261 if (k==2||k==-1) return AliPID::kPion;
1262 if (k==3) return AliPID::kKaon;
1263 if (k==4) return AliPID::kProton;
1264 AliWarning("Undefined PID !");
1265 return AliPID::kPion;
1268 //_______________________________________________________________________
1269 Int_t AliESDtrack::GetTOFBunchCrossing(Double_t b, Bool_t pidTPConly) const
1271 // Returns the number of bunch crossings after trigger (assuming 25ns spacing)
1272 const double kSpacing = 25e3; // min interbanch spacing
1273 const double kShift = 0;
1274 Int_t bcid = kTOFBCNA; // defualt one
1275 if (!IsOn(kTOFout) || !IsOn(kESDpid)) return bcid; // no info
1277 double tdif = fTOFsignal;
1278 if (IsOn(kTIME)) { // integrated time info is there
1279 int pid = GetPID(pidTPConly);
1280 tdif -= fTrackTime[pid];
1282 else { // assume integrated time info from TOF radius and momentum
1283 const double kRTOF = 385.;
1284 const double kCSpeed = 3.e-2; // cm/ps
1286 if (p<0.01) return bcid;
1287 double m = GetMass(pidTPConly);
1288 double curv = GetC(b);
1289 double path = TMath::Abs(curv)>kAlmost0 ? // account for curvature
1290 2./curv*TMath::ASin(kRTOF*curv/2.)*TMath::Sqrt(1.+GetTgl()*GetTgl()) : kRTOF;
1291 tdif -= path/kCSpeed*TMath::Sqrt(1.+m*m/(p*p));
1293 bcid = TMath::Nint((tdif - kShift)/kSpacing);
1297 //______________________________________________________________________________
1298 Double_t AliESDtrack::M() const
1300 // Returns the assumed mass
1301 // (the pion mass, if the particle can't be identified properly).
1302 static Bool_t printerr=kTRUE;
1304 AliWarning("WARNING !!! ... THIS WILL BE PRINTED JUST ONCE !!!");
1306 AliWarning("This is the ESD mass. Use it with care !");
1311 //______________________________________________________________________________
1312 Double_t AliESDtrack::E() const
1314 // Returns the energy of the particle given its assumed mass.
1315 // Assumes the pion mass if the particle can't be identified properly.
1319 return TMath::Sqrt(p*p + m*m);
1322 //______________________________________________________________________________
1323 Double_t AliESDtrack::Y() const
1325 // Returns the rapidity of a particle given its assumed mass.
1326 // Assumes the pion mass if the particle can't be identified properly.
1330 if (e != TMath::Abs(pz)) { // energy was not equal to pz
1331 return 0.5*TMath::Log((e+pz)/(e-pz));
1332 } else { // energy was equal to pz
1337 //_______________________________________________________________________
1338 Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
1340 // This function updates track's running parameters
1345 fLabel=t->GetLabel();
1347 if (t->IsStartedTimeIntegral()) {
1349 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
1350 SetIntegratedLength(t->GetIntegratedLength());
1353 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1355 if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1356 if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
1357 if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
1363 fITSchi2Std[0] = t->GetChi2();
1366 fITSchi2Std[1] = t->GetChi2();
1369 fITSchi2Std[2] = t->GetChi2();
1371 fITSncls=t->GetNumberOfClusters();
1373 Int_t* indexITS = new Int_t[AliESDfriendTrack::kMaxITScluster];
1374 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
1375 indexITS[i]=t->GetClusterIndex(i);
1378 Int_t l=(indexITS[i] & 0xf0000000) >> 28;
1379 SETBIT(fITSClusterMap,l);
1382 fFriendTrack->SetITSIndices(indexITS,AliESDfriendTrack::kMaxITScluster);
1386 fITSchi2=t->GetChi2();
1387 fITSsignal=t->GetPIDsignal();
1388 fITSLabel = t->GetLabel();
1389 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1390 if (flags==kITSout) {
1391 if (!fOp) fOp=new AliExternalTrackParam(*t);
1393 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1398 case kTPCin: case kTPCrefit:
1400 fTPCLabel = t->GetLabel();
1401 if (flags==kTPCin) {
1402 fTPCInner=new AliExternalTrackParam(*t);
1403 fTPCnclsIter1=t->GetNumberOfClusters();
1404 fTPCchi2Iter1=t->GetChi2();
1406 if (!fIp) fIp=new AliExternalTrackParam(*t);
1408 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1410 // Intentionally no break statement; need to set general TPC variables as well
1413 if (flags & kTPCout){
1414 if (!fOp) fOp=new AliExternalTrackParam(*t);
1416 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1418 fTPCncls=t->GetNumberOfClusters();
1419 fTPCchi2=t->GetChi2();
1421 if (fFriendTrack) { // Copy cluster indices
1422 Int_t* indexTPC = new Int_t[AliESDfriendTrack::kMaxTPCcluster];
1423 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1424 indexTPC[i]=t->GetClusterIndex(i);
1425 fFriendTrack->SetTPCIndices(indexTPC,AliESDfriendTrack::kMaxTPCcluster);
1428 fTPCsignal=t->GetPIDsignal();
1432 case kTRDin: case kTRDrefit:
1436 fTRDLabel = t->GetLabel();
1437 fTRDchi2 = t->GetChi2();
1438 fTRDncls = t->GetNumberOfClusters();
1440 Int_t* indexTRD = new Int_t[AliESDfriendTrack::kMaxTRDcluster];
1441 for (Int_t i=0;i<AliESDfriendTrack::kMaxTRDcluster;i++) indexTRD[i]=-2;
1442 for (Int_t i=0;i<6;i++) indexTRD[i]=t->GetTrackletIndex(i);
1443 fFriendTrack->SetTRDIndices(indexTRD,AliESDfriendTrack::kMaxTRDcluster);
1447 //commented out by Xianguo
1448 //fTRDsignal=t->GetPIDsignal();
1452 if (!fOp) fOp=new AliExternalTrackParam(*t);
1454 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1455 fTRDncls0 = t->GetNumberOfClusters();
1464 if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1466 fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1469 AliError("Wrong flag !");
1476 //_______________________________________________________________________
1477 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1478 //---------------------------------------------------------------------
1479 // This function returns external representation of the track parameters
1480 //---------------------------------------------------------------------
1482 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1485 //_______________________________________________________________________
1486 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1487 //---------------------------------------------------------------------
1488 // This function returns external representation of the cov. matrix
1489 //---------------------------------------------------------------------
1490 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1493 //_______________________________________________________________________
1494 Bool_t AliESDtrack::GetConstrainedExternalParameters
1495 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1496 //---------------------------------------------------------------------
1497 // This function returns the constrained external track parameters
1498 //---------------------------------------------------------------------
1499 if (!fCp) return kFALSE;
1500 alpha=fCp->GetAlpha();
1502 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1506 //_______________________________________________________________________
1508 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1509 //---------------------------------------------------------------------
1510 // This function returns the constrained external cov. matrix
1511 //---------------------------------------------------------------------
1512 if (!fCp) return kFALSE;
1513 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1518 AliESDtrack::GetInnerExternalParameters
1519 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1520 //---------------------------------------------------------------------
1521 // This function returns external representation of the track parameters
1522 // at the inner layer of TPC
1523 //---------------------------------------------------------------------
1524 if (!fIp) return kFALSE;
1525 alpha=fIp->GetAlpha();
1527 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1532 AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1533 //---------------------------------------------------------------------
1534 // This function returns external representation of the cov. matrix
1535 // at the inner layer of TPC
1536 //---------------------------------------------------------------------
1537 if (!fIp) return kFALSE;
1538 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1543 AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1545 // This is a direct setter for the outer track parameters
1548 if (fOp) delete fOp;
1549 fOp=new AliExternalTrackParam(*p);
1553 AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1555 // This is a direct setter for the outer track parameters
1558 if (fHMPIDp) delete fHMPIDp;
1559 fHMPIDp=new AliExternalTrackParam(*p);
1563 AliESDtrack::GetOuterExternalParameters
1564 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1565 //---------------------------------------------------------------------
1566 // This function returns external representation of the track parameters
1567 // at the inner layer of TRD
1568 //---------------------------------------------------------------------
1569 if (!fOp) return kFALSE;
1570 alpha=fOp->GetAlpha();
1572 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1577 AliESDtrack::GetOuterHmpExternalParameters
1578 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1579 //---------------------------------------------------------------------
1580 // This function returns external representation of the track parameters
1581 // at the inner layer of TRD
1582 //---------------------------------------------------------------------
1583 if (!fHMPIDp) return kFALSE;
1584 alpha=fHMPIDp->GetAlpha();
1586 for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1591 AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1592 //---------------------------------------------------------------------
1593 // This function returns external representation of the cov. matrix
1594 // at the inner layer of TRD
1595 //---------------------------------------------------------------------
1596 if (!fOp) return kFALSE;
1597 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1602 AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1603 //---------------------------------------------------------------------
1604 // This function returns external representation of the cov. matrix
1605 // at the inner layer of TRD
1606 //---------------------------------------------------------------------
1607 if (!fHMPIDp) return kFALSE;
1608 for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1612 Int_t AliESDtrack::GetNcls(Int_t idet) const
1614 // Get number of clusters by subdetector index
1628 if (fTOFindex != -1)
1634 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1635 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1646 Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1648 // Get cluster index array by subdetector index
1653 ncls = GetITSclusters(idx);
1656 ncls = GetTPCclusters(idx);
1659 ncls = GetTRDclusters(idx);
1662 if (fTOFindex != -1) {
1670 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1671 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1672 idx[0] = GetHMPIDcluIdx();
1685 //_______________________________________________________________________
1686 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
1687 // Returns the array with integrated times for each particle hypothesis
1688 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
1691 //_______________________________________________________________________
1692 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
1693 // Sets the array with integrated times for each particle hypotesis
1694 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
1697 //_______________________________________________________________________
1698 void AliESDtrack::SetITSpid(const Double_t *p) {
1699 // Sets values for the probability of each particle type (in ITS)
1700 SetPIDValues(fITSr,p,AliPID::kSPECIES);
1701 SetStatus(AliESDtrack::kITSpid);
1704 //_______________________________________________________________________
1705 void AliESDtrack::GetITSpid(Double_t *p) const {
1706 // Gets the probability of each particle type (in ITS)
1707 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
1710 //_______________________________________________________________________
1711 Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1712 //---------------------------------------------------------------------
1713 // This function returns indices of the assgined ITS clusters
1714 //---------------------------------------------------------------------
1715 if (idx && fFriendTrack) {
1716 Int_t *index=fFriendTrack->GetITSindices();
1717 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1718 if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1730 //_______________________________________________________________________
1731 Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1732 Float_t &xloc,Float_t &zloc) const {
1733 //----------------------------------------------------------------------
1734 // This function encodes in the module number also the status of cluster association
1735 // "status" can have the following values:
1736 // 1 "found" (cluster is associated),
1737 // 2 "dead" (module is dead from OCDB),
1738 // 3 "skipped" (module or layer forced to be skipped),
1739 // 4 "outinz" (track out of z acceptance),
1740 // 5 "nocls" (no clusters in the road),
1741 // 6 "norefit" (cluster rejected during refit),
1742 // 7 "deadzspd" (holes in z in SPD)
1743 // Also given are the coordinates of the crossing point of track and module
1744 // (in the local module ref. system)
1745 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1746 //----------------------------------------------------------------------
1748 if(fITSModule[ilayer]==-1) {
1751 xloc=-99.; zloc=-99.;
1755 Int_t module = fITSModule[ilayer];
1757 idet = Int_t(module/1000000);
1759 module -= idet*1000000;
1761 status = Int_t(module/100000);
1763 module -= status*100000;
1765 Int_t signs = Int_t(module/10000);
1767 module-=signs*10000;
1769 Int_t xInt = Int_t(module/100);
1772 Int_t zInt = module;
1774 if(signs==1) { xInt*=1; zInt*=1; }
1775 if(signs==2) { xInt*=1; zInt*=-1; }
1776 if(signs==3) { xInt*=-1; zInt*=1; }
1777 if(signs==4) { xInt*=-1; zInt*=-1; }
1779 xloc = 0.1*(Float_t)xInt;
1780 zloc = 0.1*(Float_t)zInt;
1782 if(status==4) idet = -1;
1787 //_______________________________________________________________________
1788 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
1789 //---------------------------------------------------------------------
1790 // This function returns indices of the assgined ITS clusters
1791 //---------------------------------------------------------------------
1792 if (idx && fFriendTrack) {
1793 Int_t *index=fFriendTrack->GetTPCindices();
1796 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1799 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=-2;
1805 //_______________________________________________________________________
1806 Float_t AliESDtrack::GetTPCCrossedRows() const
1808 // This function calls GetTPCClusterInfo with some default parameters which are used in the track selection and caches the outcome
1809 // because GetTPCClusterInfo is quite time-consuming
1811 if (fCacheNCrossedRows > -1)
1812 return fCacheNCrossedRows;
1814 fCacheNCrossedRows = GetTPCClusterInfo(2, 1);
1815 return fCacheNCrossedRows;
1818 //_______________________________________________________________________
1819 Float_t AliESDtrack::GetTPCClusterInfo(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1, Int_t bitType ) const
1822 // TPC cluster information
1823 // type 0: get fraction of found/findable clusters with neighbourhood definition
1824 // 1: findable clusters with neighbourhood definition
1825 // 2: found clusters
1827 // 0 - all cluster used
1828 // 1 - clusters used for the kalman update
1829 // definition of findable clusters:
1830 // a cluster is defined as findable if there is another cluster
1831 // within +- nNeighbours pad rows. The idea is to overcome threshold
1832 // effects with a very simple algorithm.
1838 Int_t last=-nNeighbours;
1839 const TBits & clusterMap = (bitType%2==0) ? fTPCClusterMap : fTPCFitMap;
1841 Int_t upperBound=clusterMap.GetNbits();
1842 if (upperBound>row1) upperBound=row1;
1843 for (Int_t i=row0; i<upperBound; ++i){
1844 //look to current row
1845 if (clusterMap[i]) {
1851 //look to nNeighbours before
1852 if ((i-last)<=nNeighbours) {
1856 //look to nNeighbours after
1857 for (Int_t j=i+1; j<i+1+nNeighbours; ++j){
1864 if (type==2) return found;
1865 if (type==1) return findable;
1870 fraction=(Float_t)found/(Float_t)findable;
1875 return 0; // undefined type - default value
1878 //_______________________________________________________________________
1879 Float_t AliESDtrack::GetTPCClusterDensity(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1, Int_t bitType ) const
1882 // TPC cluster density - only rows where signal before and after given row are used
1883 // - slower function
1884 // type 0: get fraction of found/findable clusters with neighbourhood definition
1885 // 1: findable clusters with neighbourhood definition
1886 // 2: found clusters
1888 // 0 - all cluster used
1889 // 1 - clusters used for the kalman update
1890 // definition of findable clusters:
1891 // a cluster is defined as findable if there is another cluster
1892 // within +- nNeighbours pad rows. The idea is to overcome threshold
1893 // effects with a very simple algorithm.
1897 // Int_t last=-nNeighbours;
1898 const TBits & clusterMap = (bitType%2==0) ? fTPCClusterMap : fTPCFitMap;
1899 Int_t upperBound=clusterMap.GetNbits();
1900 if (upperBound>row1) upperBound=row1;
1901 for (Int_t i=row0; i<upperBound; ++i){
1903 Bool_t isDown=kFALSE;
1904 for (Int_t idelta=1; idelta<=nNeighbours; idelta++){
1905 if (i-idelta>=0 && clusterMap[i-idelta]) isDown=kTRUE;
1906 if (i+idelta<upperBound && clusterMap[i+idelta]) isUp=kTRUE;
1910 if (clusterMap[i]) ++found;
1913 if (type==2) return found;
1914 if (type==1) return findable;
1919 fraction=(Float_t)found/(Float_t)findable;
1924 return 0; // undefined type - default value
1930 //_______________________________________________________________________
1931 Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
1933 // GetDensity of the clusters on given region between row0 and row1
1934 // Dead zone effect takin into acoount
1936 if (!fFriendTrack) return 0.0;
1940 Int_t *index=fFriendTrack->GetTPCindices();
1941 for (Int_t i=row0;i<=row1;i++){
1942 Int_t idx = index[i];
1943 if (idx!=-1) good++; // track outside of dead zone
1946 Float_t density=0.5;
1947 if (good>TMath::Max((row1-row0)*0.5,0.0)) density = Float_t(found)/Float_t(good);
1951 //_______________________________________________________________________
1952 void AliESDtrack::SetTPCpid(const Double_t *p) {
1953 // Sets values for the probability of each particle type (in TPC)
1954 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
1955 SetStatus(AliESDtrack::kTPCpid);
1958 //_______________________________________________________________________
1959 void AliESDtrack::GetTPCpid(Double_t *p) const {
1960 // Gets the probability of each particle type (in TPC)
1961 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
1964 //_______________________________________________________________________
1965 UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
1966 //---------------------------------------------------------------------
1967 // This function returns indices of the assgined TRD clusters
1968 //---------------------------------------------------------------------
1969 if (idx && fFriendTrack) {
1970 Int_t *index=fFriendTrack->GetTRDindices();
1973 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1976 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=-2;
1982 //_______________________________________________________________________
1983 UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
1985 // This function returns the number of TRD tracklets used in tracking
1986 // and it fills the indices of these tracklets in the array "idx" as they
1987 // are registered in the TRD track list.
1990 // 1. The idx array has to be allocated with a size >= AliESDtrack::kTRDnPlanes
1991 // 2. The idx array store not only the index but also the layer of the tracklet.
1992 // Therefore tracks with TRD gaps contain default values for indices [-1]
1994 if (!fFriendTrack) return 0;
1995 if (!idx) return GetTRDntracklets();
1996 Int_t *index=fFriendTrack->GetTRDindices();
1998 for (Int_t i=0; i<kTRDnPlanes; i++){
2000 if(index[i]>=0) n++;
2008 //_______________________________________________________________________
2009 void AliESDtrack::SetTRDpid(const Double_t *p) {
2010 // Sets values for the probability of each particle type (in TRD)
2011 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
2012 SetStatus(AliESDtrack::kTRDpid);
2015 //_______________________________________________________________________
2016 void AliESDtrack::GetTRDpid(Double_t *p) const {
2017 // Gets the probability of each particle type (in TRD)
2018 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
2021 //_______________________________________________________________________
2022 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
2024 // Sets the probability of particle type iSpecies to p (in TRD)
2025 fTRDr[iSpecies] = p;
2028 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
2030 // Returns the probability of particle type iSpecies (in TRD)
2031 return fTRDr[iSpecies];
2034 //____________________________________________________
2035 Int_t AliESDtrack::GetNumberOfTRDslices() const
2037 // built in backward compatibility
2038 Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
2039 return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
2042 //____________________________________________________
2043 Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
2045 //Returns momentum estimation and optional its error (sp)
2046 // in TRD layer "plane".
2049 AliDebug(2, "No TRD info allocated for this track.");
2052 if ((plane<0) || (plane>=kTRDnPlanes)) {
2053 AliWarning(Form("Request for TRD plane[%d] outside range.", plane));
2057 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
2058 // Protection for backward compatibility
2059 if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
2061 if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
2062 return fTRDslices[idx];
2065 //____________________________________________________
2066 Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
2067 //Gets the charge from the slice of the plane
2070 //AliError("No TRD slices allocated for this track !");
2073 if ((plane<0) || (plane>=kTRDnPlanes)) {
2074 AliError("Info for TRD plane not available !");
2077 Int_t ns=GetNumberOfTRDslices();
2078 if ((slice<-1) || (slice>=ns)) {
2079 //AliError("Wrong TRD slice !");
2083 if(slice>=0) return fTRDslices[plane*ns + slice];
2085 // return average of the dEdx measurements
2086 Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
2087 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
2091 //____________________________________________________
2092 void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
2093 //Sets the number of slices used for PID
2094 if (fTRDnSlices) return;
2097 fTRDslices=new Double32_t[fTRDnSlices];
2099 // set-up correctly the allocated memory
2100 memset(fTRDslices, 0, n*sizeof(Double32_t));
2101 for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
2104 //____________________________________________________
2105 void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
2106 //Sets the charge q in the slice of the plane
2108 AliError("No TRD slices allocated for this track !");
2111 if ((plane<0) || (plane>=kTRDnPlanes)) {
2112 AliError("Info for TRD plane not allocated !");
2115 Int_t ns=GetNumberOfTRDslices();
2116 if ((slice<0) || (slice>=ns)) {
2117 AliError("Wrong TRD slice !");
2120 Int_t n=plane*ns + slice;
2125 //____________________________________________________
2126 void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
2129 AliError("No TRD slices allocated for this track !");
2132 if ((plane<0) || (plane>=kTRDnPlanes)) {
2133 AliError("Info for TRD plane not allocated !");
2137 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
2138 // Protection for backward compatibility
2139 if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
2141 if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
2142 fTRDslices[idx] = p;
2146 //_______________________________________________________________________
2147 void AliESDtrack::SetTOFpid(const Double_t *p) {
2148 // Sets the probability of each particle type (in TOF)
2149 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
2150 SetStatus(AliESDtrack::kTOFpid);
2153 //_______________________________________________________________________
2154 void AliESDtrack::SetTOFLabel(const Int_t *p) {
2156 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
2159 //_______________________________________________________________________
2160 void AliESDtrack::GetTOFpid(Double_t *p) const {
2161 // Gets probabilities of each particle type (in TOF)
2162 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
2165 //_______________________________________________________________________
2166 void AliESDtrack::GetTOFLabel(Int_t *p) const {
2168 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
2171 //_______________________________________________________________________
2172 void AliESDtrack::GetTOFInfo(Float_t *info) const {
2174 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
2177 //_______________________________________________________________________
2178 void AliESDtrack::SetTOFInfo(Float_t*info) {
2180 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
2185 //_______________________________________________________________________
2186 void AliESDtrack::SetHMPIDpid(const Double_t *p) {
2187 // Sets the probability of each particle type (in HMPID)
2188 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
2189 SetStatus(AliESDtrack::kHMPIDpid);
2192 //_______________________________________________________________________
2193 void AliESDtrack::SetTPCdEdxInfo(AliTPCdEdxInfo * dEdxInfo){
2194 if(fTPCdEdxInfo) delete fTPCdEdxInfo;
2195 fTPCdEdxInfo = dEdxInfo;
2198 //_______________________________________________________________________
2199 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
2200 // Gets probabilities of each particle type (in HMPID)
2201 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
2206 //_______________________________________________________________________
2207 void AliESDtrack::SetESDpid(const Double_t *p) {
2208 // Sets the probability of each particle type for the ESD track
2209 SetPIDValues(fR,p,AliPID::kSPECIES);
2210 SetStatus(AliESDtrack::kESDpid);
2213 //_______________________________________________________________________
2214 void AliESDtrack::GetESDpid(Double_t *p) const {
2215 // Gets probability of each particle type for the ESD track
2216 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
2219 //_______________________________________________________________________
2220 Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
2221 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2223 // Try to relate the TPC-only track parameters to the vertex "vtx",
2224 // if the (rough) transverse impact parameter is not bigger then "maxd".
2225 // Magnetic field is "b" (kG).
2227 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2228 // b) The impact parameters and their covariance matrix are calculated.
2229 // c) An attempt to constrain the TPC-only params to the vertex is done.
2230 // The constrained params are returned via "cParam".
2232 // In the case of success, the returned value is kTRUE
2233 // otherwise, it's kFALSE)
2236 if (!fTPCInner) return kFALSE;
2237 if (!vtx) return kFALSE;
2239 Double_t dz[2],cov[3];
2240 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2248 Double_t covar[6]; vtx->GetCovMatrix(covar);
2249 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2250 Double_t c[3]={covar[2],0.,covar[5]};
2252 Double_t chi2=GetPredictedChi2(p,c);
2253 if (chi2>kVeryBig) return kFALSE;
2257 if (!cParam) return kTRUE;
2259 *cParam = *fTPCInner;
2260 if (!cParam->Update(p,c)) return kFALSE;
2265 //_______________________________________________________________________
2266 Bool_t AliESDtrack::RelateToVertexTPCBxByBz(const AliESDVertex *vtx,
2267 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2269 // Try to relate the TPC-only track parameters to the vertex "vtx",
2270 // if the (rough) transverse impact parameter is not bigger then "maxd".
2272 // All three components of the magnetic field ,"b[3]" (kG),
2273 // are taken into account.
2275 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2276 // b) The impact parameters and their covariance matrix are calculated.
2277 // c) An attempt to constrain the TPC-only params to the vertex is done.
2278 // The constrained params are returned via "cParam".
2280 // In the case of success, the returned value is kTRUE
2281 // otherwise, it's kFALSE)
2284 if (!fTPCInner) return kFALSE;
2285 if (!vtx) return kFALSE;
2287 Double_t dz[2],cov[3];
2288 if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2296 Double_t covar[6]; vtx->GetCovMatrix(covar);
2297 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2298 Double_t c[3]={covar[2],0.,covar[5]};
2300 Double_t chi2=GetPredictedChi2(p,c);
2301 if (chi2>kVeryBig) return kFALSE;
2305 if (!cParam) return kTRUE;
2307 *cParam = *fTPCInner;
2308 if (!cParam->Update(p,c)) return kFALSE;
2313 //_______________________________________________________________________
2314 Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
2315 Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2317 // Try to relate this track to the vertex "vtx",
2318 // if the (rough) transverse impact parameter is not bigger then "maxd".
2319 // Magnetic field is "b" (kG).
2321 // a) The track gets extapolated to the DCA to the vertex.
2322 // b) The impact parameters and their covariance matrix are calculated.
2323 // c) An attempt to constrain this track to the vertex is done.
2324 // The constrained params are returned via "cParam".
2326 // In the case of success, the returned value is kTRUE
2327 // (otherwise, it's kFALSE)
2330 if (!vtx) return kFALSE;
2332 Double_t dz[2],cov[3];
2333 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2341 Double_t covar[6]; vtx->GetCovMatrix(covar);
2342 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2343 Double_t c[3]={covar[2],0.,covar[5]};
2345 Double_t chi2=GetPredictedChi2(p,c);
2346 if (chi2>kVeryBig) return kFALSE;
2351 //--- Could now these lines be removed ? ---
2353 fCp=new AliExternalTrackParam(*this);
2355 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2356 //----------------------------------------
2358 fVertexID = vtx->GetID();
2360 if (!cParam) return kTRUE;
2363 if (!cParam->Update(p,c)) return kFALSE;
2368 //_______________________________________________________________________
2369 Bool_t AliESDtrack::RelateToVertexBxByBz(const AliESDVertex *vtx,
2370 Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2372 // Try to relate this track to the vertex "vtx",
2373 // if the (rough) transverse impact parameter is not bigger then "maxd".
2374 // Magnetic field is "b" (kG).
2376 // a) The track gets extapolated to the DCA to the vertex.
2377 // b) The impact parameters and their covariance matrix are calculated.
2378 // c) An attempt to constrain this track to the vertex is done.
2379 // The constrained params are returned via "cParam".
2381 // In the case of success, the returned value is kTRUE
2382 // (otherwise, it's kFALSE)
2385 if (!vtx) return kFALSE;
2387 Double_t dz[2],cov[3];
2388 if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2396 Double_t covar[6]; vtx->GetCovMatrix(covar);
2397 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2398 Double_t c[3]={covar[2],0.,covar[5]};
2400 Double_t chi2=GetPredictedChi2(p,c);
2401 if (chi2>kVeryBig) return kFALSE;
2406 //--- Could now these lines be removed ? ---
2408 fCp=new AliExternalTrackParam(*this);
2410 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2411 //----------------------------------------
2413 fVertexID = vtx->GetID();
2415 if (!cParam) return kTRUE;
2418 if (!cParam->Update(p,c)) return kFALSE;
2423 //_______________________________________________________________________
2424 void AliESDtrack::Print(Option_t *) const {
2425 // Prints info on the track
2426 AliExternalTrackParam::Print();
2427 printf("ESD track info\n") ;
2428 Double_t p[AliPID::kSPECIES] ;
2430 if( IsOn(kITSpid) ){
2431 printf("From ITS: ") ;
2433 for(index = 0 ; index < AliPID::kSPECIES; index++)
2434 printf("%f, ", p[index]) ;
2435 printf("\n signal = %f\n", GetITSsignal()) ;
2437 if( IsOn(kTPCpid) ){
2438 printf("From TPC: ") ;
2440 for(index = 0 ; index < AliPID::kSPECIES; index++)
2441 printf("%f, ", p[index]) ;
2442 printf("\n signal = %f\n", GetTPCsignal()) ;
2444 if( IsOn(kTRDpid) ){
2445 printf("From TRD: ") ;
2447 for(index = 0 ; index < AliPID::kSPECIES; index++)
2448 printf("%f, ", p[index]) ;
2449 printf("\n signal = %f\n", GetTRDsignal()) ;
2450 printf("\n NchamberdEdx = %d\n", GetTRDNchamberdEdx()) ;
2451 printf("\n NclusterdEdx = %d\n", GetTRDNclusterdEdx()) ;
2453 if( IsOn(kTOFpid) ){
2454 printf("From TOF: ") ;
2456 for(index = 0 ; index < AliPID::kSPECIES; index++)
2457 printf("%f, ", p[index]) ;
2458 printf("\n signal = %f\n", GetTOFsignal()) ;
2460 if( IsOn(kHMPIDpid) ){
2461 printf("From HMPID: ") ;
2463 for(index = 0 ; index < AliPID::kSPECIES; index++)
2464 printf("%f, ", p[index]) ;
2465 printf("\n signal = %f\n", GetHMPIDsignal()) ;
2471 // Draw functionality
2472 // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
2474 void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
2476 // Fill points in the polymarker
2479 arrayRef.AddLast(new AliExternalTrackParam(*this));
2480 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
2481 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
2482 if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
2484 Double_t mpos[3]={0,0,0};
2485 Int_t entries=arrayRef.GetEntries();
2486 for (Int_t i=0;i<entries;i++){
2488 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
2489 mpos[0]+=pos[0]/entries;
2490 mpos[1]+=pos[1]/entries;
2491 mpos[2]+=pos[2]/entries;
2493 // Rotate to the mean position
2495 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
2496 for (Int_t i=0;i<entries;i++){
2497 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
2498 if (!res) delete arrayRef.RemoveAt(i);
2501 for (Double_t r=minR; r<maxR; r+=stepR){
2503 Double_t mlpos[3]={0,0,0};
2504 for (Int_t i=0;i<entries;i++){
2505 Double_t point[3]={0,0,0};
2506 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
2507 if (!param) continue;
2508 if (param->GetXYZAt(r,magF,point)){
2509 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
2511 mlpos[0]+=point[0]*weight;
2512 mlpos[1]+=point[1]*weight;
2513 mlpos[2]+=point[2]*weight;
2520 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
2521 // printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
2527 //_______________________________________________________________________
2528 void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
2530 // Store the dE/dx samples measured by the two SSD and two SDD layers.
2531 // These samples are corrected for the track segment length.
2533 for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
2536 //_______________________________________________________________________
2537 void AliESDtrack::GetITSdEdxSamples(Double_t *s) const {
2539 // Get the dE/dx samples measured by the two SSD and two SDD layers.
2540 // These samples are corrected for the track segment length.
2542 for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];
2546 UShort_t AliESDtrack::GetTPCnclsS(Int_t i0,Int_t i1) const{
2548 // get number of shared TPC clusters
2550 return fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);
2553 UShort_t AliESDtrack::GetTPCncls(Int_t i0,Int_t i1) const{
2555 // get number of TPC clusters
2557 return fTPCClusterMap.CountBits(i0)-fTPCClusterMap.CountBits(i1);
2560 //____________________________________________________________________
2561 Double_t AliESDtrack::GetChi2TPCConstrainedVsGlobal(const AliESDVertex* vtx) const
2563 // Calculates the chi2 between the TPC track (TPCinner) constrained to the primary vertex and the global track
2565 // Returns -1 in case the calculation failed
2567 // Value is cached as a non-persistent member.
2569 // Code adapted from original code by GSI group (Jacek, Marian, Michael)
2571 // cache, ignoring that a different vertex might be passed
2572 if (fCacheChi2TPCConstrainedVsGlobalVertex == vtx)
2573 return fCacheChi2TPCConstrainedVsGlobal;
2575 fCacheChi2TPCConstrainedVsGlobal = -1;
2576 fCacheChi2TPCConstrainedVsGlobalVertex = vtx;
2581 AliTrackerBase::GetBxByBz(x,b);
2584 AliWarning("Could not get TPC Inner Param.");
2585 return fCacheChi2TPCConstrainedVsGlobal;
2588 // clone for constraining
2589 AliExternalTrackParam* tpcInnerC = new AliExternalTrackParam(*fTPCInner);
2591 AliWarning("Clone of TPCInnerParam failed.");
2592 return fCacheChi2TPCConstrainedVsGlobal;
2595 // transform to the track reference frame
2596 Bool_t isOK = tpcInnerC->Rotate(GetAlpha());
2597 isOK &= tpcInnerC->PropagateTo(GetX(), b[2]);
2601 AliWarning("Rotation/Propagation of track failed.") ;
2602 return fCacheChi2TPCConstrainedVsGlobal;
2605 // constrain TPCinner
2606 isOK = tpcInnerC->ConstrainToVertex(vtx, b);
2608 // transform to the track reference frame
2609 isOK &= tpcInnerC->Rotate(GetAlpha());
2610 isOK &= tpcInnerC->PropagateTo(GetX(), b[2]);
2613 AliWarning("ConstrainTPCInner failed.") ;
2616 return fCacheChi2TPCConstrainedVsGlobal;
2619 // calculate chi2 between vi and vj vectors
2620 // with covi and covj covariance matrices
2621 // chi2ij = (vi-vj)^(T)*(covi+covj)^(-1)*(vi-vj)
2622 TMatrixD deltaT(5,1);
2623 TMatrixD delta(1,5);
2624 TMatrixD covarM(5,5);
2626 for (Int_t ipar=0; ipar<5; ipar++) {
2627 deltaT(ipar,0) = tpcInnerC->GetParameter()[ipar] - GetParameter()[ipar];
2628 delta(0,ipar) = tpcInnerC->GetParameter()[ipar] - GetParameter()[ipar];
2630 for (Int_t jpar=0; jpar<5; jpar++) {
2631 Int_t index = GetIndex(ipar,jpar);
2632 covarM(ipar,jpar) = GetCovariance()[index]+tpcInnerC->GetCovariance()[index];
2635 // chi2 distance TPC constrained and TPC+ITS
2636 TMatrixD covarMInv = covarM.Invert();
2637 TMatrixD mat2 = covarMInv*deltaT;
2638 TMatrixD chi2 = delta*mat2;
2643 fCacheChi2TPCConstrainedVsGlobal = chi2(0,0);
2644 return fCacheChi2TPCConstrainedVsGlobal;
2647 void AliESDtrack::SetDetectorPID(const AliDetectorPID *pid)
2650 // Set the detector PID
2652 if (fDetectorPID) delete fDetectorPID;