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 **************************************************************************/
18 //-----------------------------------------------------------------
19 // Implementation of the TPC track class
20 // This class is used by the AliTPCtracker class
21 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
22 //-----------------------------------------------------------------
24 #include <Riostream.h>
26 #include "AliTPCtrack.h"
27 #include "AliCluster.h"
28 #include "AliTracker.h"
29 #include "AliESDtrack.h"
30 #include "AliESDVertex.h"
34 //_________________________________________________________________________
35 AliTPCtrack::AliTPCtrack():
49 //-------------------------------------------------
50 // default constructor
51 //-------------------------------------------------
52 for (Int_t i=0; i<kMaxRow;i++) fIndex[i]=-2;
53 for (Int_t i=0; i<4;i++) fPoints[i]=0.;
54 for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
55 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
56 for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
59 //_________________________________________________________________________
63 AliTPCtrack::AliTPCtrack(Double_t x, Double_t alpha, const Double_t p[5],
64 const Double_t cov[15], Int_t index) :
78 //-----------------------------------------------------------------
79 // This is the main track constructor.
80 //-----------------------------------------------------------------
81 Double_t cnv=1./(AliTracker::GetBz()*kB2C);
91 Double_t c22 = x*x*cov[14] - 2*x*cov[12] + cov[5];
92 Double_t c32 = x*cov[13] - cov[8];
93 Double_t c20 = x*cov[10] - cov[3],
94 c21 = x*cov[11] - cov[4], c42 = x*cov[14] - cov[12];
100 cov[6 ], cov[7 ], c32, cov[9 ],
101 cov[10]*cnv, cov[11]*cnv, c42*cnv, cov[13]*cnv, cov[14]*cnv*cnv
104 Double_t mostProbablePt=AliExternalTrackParam::GetMostProbablePt();
105 Double_t p0=TMath::Sign(1/mostProbablePt,pp[4]);
106 Double_t w0=cc[14]/(cc[14] + p0*p0), w1=p0*p0/(cc[14] + p0*p0);
107 pp[4] = w0*p0 + w1*pp[4];
108 cc[10]*=w1; cc[11]*=w1; cc[12]*=w1; cc[13]*=w1; cc[14]*=w1;
112 SetNumberOfClusters(1);
115 for (Int_t i=1; i<kMaxRow;i++) fIndex[i]=-2;
116 for (Int_t i=0; i<4;i++) fPoints[i]=0.;
117 for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
118 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
119 for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
122 //_____________________________________________________________________________
123 AliTPCtrack::AliTPCtrack(const AliESDtrack& t) :
125 fdEdx(t.GetTPCsignal()),
137 //-----------------------------------------------------------------
138 // Conversion AliESDtrack -> AliTPCtrack.
139 //-----------------------------------------------------------------
140 SetNumberOfClusters(t.GetTPCclusters(fIndex));
141 SetLabel(t.GetLabel());
142 SetMass(t.GetMass());
143 for (Int_t i=0; i<4;i++) fPoints[i]=0.;
144 for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
145 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
146 for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
148 Set(t.GetX(),t.GetAlpha(),t.GetParameter(),t.GetCovariance());
150 if ((t.GetStatus()&AliESDtrack::kTIME) == 0) return;
152 Double_t times[10]; t.GetIntegratedTimes(times); SetIntegratedTimes(times);
153 SetIntegratedLength(t.GetIntegratedLength());
156 //_____________________________________________________________________________
157 AliTPCtrack::AliTPCtrack(const AliTPCtrack& t) :
161 fNFoundable(t.fNFoundable),
162 fBConstrain(t.fBConstrain),
163 fLastPoint(t.fLastPoint),
164 fFirstPoint(t.fFirstPoint),
165 fRemoval(t.fRemoval),
166 fTrackType(t.fTrackType),
168 fNShared(t.fNShared),
169 fReference(t.fReference)
172 //-----------------------------------------------------------------
173 // This is a track copy constructor.
174 //-----------------------------------------------------------------
175 Set(t.GetX(),t.GetAlpha(),t.GetParameter(),t.GetCovariance());
177 for (Int_t i=0; i<kMaxRow; i++) fIndex[i]=t.fIndex[i];
178 for (Int_t i=0; i<4;i++) fPoints[i]=t.fPoints[i];
179 for (Int_t i=0; i<12;i++) fKinkPoint[i]=t.fKinkPoint[i];
180 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=t.fKinkIndexes[i];
181 for (Int_t i=0; i<3;i++) fV0Indexes[i]=t.fV0Indexes[i];
184 AliTPCtrack& AliTPCtrack::operator=(const AliTPCtrack& o){
186 AliKalmanTrack::operator=(o);
188 for(Int_t i = 0;i<kMaxRow;++i)fIndex[i] = o.fIndex[i];
189 for(Int_t i = 0;i<4;++i)fPoints[i] = o.fPoints[i];
191 fNFoundable = o.fNFoundable;
192 fBConstrain = o.fBConstrain;
193 fLastPoint = o.fLastPoint;
194 fFirstPoint = o.fFirstPoint;
195 fTrackType = o.fTrackType;
197 fNShared = o.fNShared;
198 fReference = o.fReference;
199 for(Int_t i = 0;i<12;++i) fKinkPoint[i] = o.fKinkPoint[i];
201 for(Int_t i = 0;i<3;++i){
202 fKinkIndexes[i] = o.fKinkIndexes[i];
203 fV0Indexes[i] = o.fV0Indexes[i];
211 //_____________________________________________________________________________
212 Int_t AliTPCtrack::Compare(const TObject *o) const {
213 //-----------------------------------------------------------------
214 // This function compares tracks according to the their curvature
215 //-----------------------------------------------------------------
216 AliTPCtrack *t=(AliTPCtrack*)o;
217 //Double_t co=t->OneOverPt();
218 //Double_t c = OneOverPt();
219 Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
220 Double_t c =GetSigmaY2()*GetSigmaZ2();
222 else if (c<co) return -1;
226 Double_t AliTPCtrack::GetPredictedChi2(const AliCluster *c) const {
227 //-----------------------------------------------------------------
228 // This function calculates a predicted chi2 increment.
229 //-----------------------------------------------------------------
230 Double_t p[2]={c->GetY(), c->GetZ()};
231 Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
232 return AliExternalTrackParam::GetPredictedChi2(p,cov);
235 //_____________________________________________________________________________
236 Bool_t AliTPCtrack::PropagateTo(Double_t xk,Double_t rho,Double_t x0) {
237 //-----------------------------------------------------------------
238 // This function propagates a track to a reference plane x=xk.
239 // rho - density of the crossed matrial (g/cm^3)
240 // x0 - radiation length of the crossed material (g/cm^2)
241 //-----------------------------------------------------------------
242 Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
245 if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
247 Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) +
248 (GetY()-oldY)*(GetY()-oldY) +
249 (GetZ()-oldZ)*(GetZ()-oldZ));
250 if (IsStartedTimeIntegral() && GetX()>oldX) AddTimeStep(d);
252 if (oldX < xk) d = -d;
253 if (!AliExternalTrackParam::CorrectForMeanMaterial(d*rho/x0,d*rho,GetMass(),
254 kFALSE,AliExternalTrackParam::BetheBlochGas)) return kFALSE;
259 //_____________________________________________________________________________
261 AliTPCtrack::PropagateToVertex(const AliESDVertex *v,Double_t rho,Double_t x0)
263 //-----------------------------------------------------------------
264 // This function propagates tracks to the vertex
265 // rho - density of the crossed matrial (g/cm3)
266 // x0 - radiation length of the crossed material (g/cm2)
267 //-----------------------------------------------------------------
268 Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
271 if (!PropagateToDCA(v,bz,kVeryBig)) return kFALSE;
273 Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) +
274 (GetY()-oldY)*(GetY()-oldY) +
275 (GetZ()-oldZ)*(GetZ()-oldZ));
277 if (oldX < GetX()) d = -d;
278 if (!AliExternalTrackParam::CorrectForMeanMaterial(d*rho/x0,d*rho,GetMass(),
279 kFALSE,AliExternalTrackParam::BetheBlochGas)) return kFALSE;
284 //_____________________________________________________________________________
285 Bool_t AliTPCtrack::Update(const AliCluster *c, Double_t chisq, Int_t index) {
286 //-----------------------------------------------------------------
287 // This function associates a cluster with this track.
288 //-----------------------------------------------------------------
289 Double_t p[2]={c->GetY(), c->GetZ()};
290 Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
292 if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
294 AliTracker::FillResiduals(this,p,cov,c->GetVolumeId());
296 Int_t n=GetNumberOfClusters();
298 SetNumberOfClusters(n+1);
299 SetChi2(GetChi2()+chisq);
304 ////////////////////////////////////////////////////////////////////////
307 Float_t AliTPCtrack::Density(Int_t row0, Int_t row1)
310 // calculate cluster density
313 //if (row0<fFirstPoint) row0 = fFirstPoint;
314 if (row1>fLastPoint) row1 = fLastPoint;
317 for (Int_t i=row0;i<=row1;i++){
318 // Int_t index = fClusterIndex[i];
319 Int_t index = fIndex[i];
320 if (index!=-1) good++;
321 if (index>0) found++;
324 if (good>0) density = Float_t(found)/Float_t(good);
329 Float_t AliTPCtrack::Density2(Int_t row0, Int_t row1)
332 // calculate cluster density
336 for (Int_t i=row0;i<=row1;i++){
337 Int_t index = fIndex[i];
338 if (index!=-1) good++;
339 if (index>0) found++;
342 if (good>0) density = Float_t(found)/Float_t(good);
346 void AliTPCtrack::UpdatePoints()
348 //--------------------------------------------------
349 //calculates first ,amx dens and last points
350 //--------------------------------------------------
351 Float_t density[160];
352 for (Int_t i=0;i<160;i++) density[i]=-1.;
360 for (Int_t i=0;i<160;i++){
361 Int_t last = i-range;
362 if (nall<range) nall++;
364 if (fIndex[last]>0&& (fIndex[last]&0x8000)==0) ngood--;
365 if (fIndex[last]==-1) undeff--;
367 if (fIndex[i]>0&& (fIndex[i]&0x8000)==0) ngood++;
368 if (fIndex[i]==-1) undeff++;
369 if (nall==range &&undeff<range/2) density[i-range/2] = Float_t(ngood)/Float_t(nall-undeff);
373 for (Int_t i=0;i<160;i++){
374 if (density[i]<0) continue;
375 if (density[i]>maxdens){
382 fPoints[3] = maxdens;
383 fPoints[1] = indexmax;
386 for (Int_t i=indexmax;i<160;i++){
387 if (density[i]<0) continue;
388 if (density[i]<maxdens/2.) {
395 for (Int_t i=indexmax;i>0;i--){
396 if (density[i]<0) continue;
397 if (density[i]<maxdens/2.) {