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"
31 #include "TTreeStream.h"
32 #include "AliTPCRecoParam.h"
33 #include "AliTPCReconstructor.h"
36 //_________________________________________________________________________
37 AliTPCtrack::AliTPCtrack():
51 //-------------------------------------------------
52 // default constructor
53 //-------------------------------------------------
54 for (Int_t i=0; i<kMaxRow;i++) fIndex[i]=-2;
55 for (Int_t i=0; i<4;i++) fPoints[i]=0.;
56 for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
57 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
58 for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
61 //_________________________________________________________________________
65 AliTPCtrack::AliTPCtrack(Double_t x, Double_t alpha, const Double_t p[5],
66 const Double_t cov[15], Int_t index) :
80 //-----------------------------------------------------------------
81 // This is the main track constructor.
82 //-----------------------------------------------------------------
83 Double_t cnv=1./(AliTracker::GetBz()*kB2C);
93 Double_t c22 = x*x*cov[14] - 2*x*cov[12] + cov[5];
94 Double_t c32 = x*cov[13] - cov[8];
95 Double_t c20 = x*cov[10] - cov[3],
96 c21 = x*cov[11] - cov[4], c42 = x*cov[14] - cov[12];
102 cov[6 ], cov[7 ], c32, cov[9 ],
103 cov[10]*cnv, cov[11]*cnv, c42*cnv, cov[13]*cnv, cov[14]*cnv*cnv
106 Double_t mostProbablePt=AliExternalTrackParam::GetMostProbablePt();
107 Double_t p0=TMath::Sign(1/mostProbablePt,pp[4]);
108 Double_t w0=cc[14]/(cc[14] + p0*p0), w1=p0*p0/(cc[14] + p0*p0);
109 pp[4] = w0*p0 + w1*pp[4];
110 cc[10]*=w1; cc[11]*=w1; cc[12]*=w1; cc[13]*=w1; cc[14]*=w1;
114 SetNumberOfClusters(1);
117 for (Int_t i=1; i<kMaxRow;i++) fIndex[i]=-2;
118 for (Int_t i=0; i<4;i++) fPoints[i]=0.;
119 for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
120 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
121 for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
124 //_____________________________________________________________________________
125 AliTPCtrack::AliTPCtrack(const AliESDtrack& t, TTreeSRedirector *pcstream) :
127 fdEdx(t.GetTPCsignal()),
139 //-----------------------------------------------------------------
140 // Conversion AliESDtrack -> AliTPCtrack.
141 //-----------------------------------------------------------------
142 const Double_t kmaxC[4]={10,10,0.1,0.1}; // cuts on the rms /fP0,fP1,fP2,fP3
143 SetNumberOfClusters(t.GetTPCclusters(fIndex));
144 SetLabel(t.GetLabel());
145 SetMass(t.GetMassForTracking());
146 for (Int_t i=0; i<4;i++) fPoints[i]=0.;
147 for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
148 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
149 for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
151 // choose parameters to start
153 const AliTPCRecoParam * recoParam = AliTPCReconstructor::GetRecoParam();
155 AliExternalTrackParam param(t);
157 const AliExternalTrackParam *tpcout=(t.GetFriendTrack())? ((AliESDfriendTrack*)(t.GetFriendTrack()))->GetTPCOut():0;
158 const AliExternalTrackParam *tpcin = t.GetInnerParam();
159 const AliExternalTrackParam *tpc=(tpcout)?tpcout:tpcin;
160 if (!tpc) tpc=¶m;
161 Bool_t isOK=kTRUE;// RS recoParam->GetUseOuterDetectors();
162 if (param.GetCovariance()[0]>kmaxC[0]*kmaxC[0]) isOK=kFALSE;
163 if (param.GetCovariance()[2]>kmaxC[1]*kmaxC[1]) isOK=kFALSE;
164 if (param.GetCovariance()[5]>kmaxC[2]*kmaxC[2]) isOK=kFALSE;
165 if (param.GetCovariance()[9]>kmaxC[3]*kmaxC[3]) isOK=kFALSE;
166 param.Rotate(tpc->GetAlpha());
167 Double_t oldX=param.GetX(), oldY=param.GetY(), oldZ=param.GetZ();
173 isOK=AliTracker::PropagateTrackToBxByBz(¶m,tpc->GetX(),t.GetMass(),2.,kFALSE);
174 if (param.GetCovariance()[0]>kmaxC[0]*kmaxC[0]) isOK=kFALSE;
175 if (param.GetCovariance()[2]>kmaxC[1]*kmaxC[1]) isOK=kFALSE;
176 if (param.GetCovariance()[5]>kmaxC[2]*kmaxC[2]) isOK=kFALSE;
177 if (param.GetCovariance()[9]>kmaxC[3]*kmaxC[3]) isOK=kFALSE;
184 param.ResetCovariance(4.); // reset covariance if start from backup param
189 AliExternalTrackParam dummy;
190 AliExternalTrackParam *ptpc=(AliExternalTrackParam *)tpc;
191 // if (!ptpc) ptpc=&dummy;
192 AliESDtrack *esd= (AliESDtrack *)&t;
193 (*pcstream)<<"trackP"<<
194 "reject="<<reject<< // flag - rejection of current esd track parameters
195 "esd.="<<esd<< // original esd track
196 "tr.="<<¶m<< // starting track parameters
197 "out.="<<ptpc<< // backup tpc parameters
201 Set(param.GetX(),param.GetAlpha(),param.GetParameter(),param.GetCovariance());
203 if ((t.GetStatus()&AliESDtrack::kTIME) == 0) return;
205 Double_t times[AliPID::kSPECIESC];
206 t.GetIntegratedTimes(times,AliPID::kSPECIESC);
207 SetIntegratedTimes(times);
208 SetIntegratedLength(t.GetIntegratedLength());
211 Double_t dX=GetX()-oldX, dY=GetY()-oldY, dZ=GetZ()-oldZ;
212 Double_t d=TMath::Sqrt(dX*dX + dY*dY + dZ*dZ);
217 //_____________________________________________________________________________
218 AliTPCtrack::AliTPCtrack(const AliTPCtrack& t) :
222 fNFoundable(t.fNFoundable),
223 fBConstrain(t.fBConstrain),
224 fLastPoint(t.fLastPoint),
225 fFirstPoint(t.fFirstPoint),
226 fRemoval(t.fRemoval),
227 fTrackType(t.fTrackType),
229 fNShared(t.fNShared),
230 fReference(t.fReference)
233 //-----------------------------------------------------------------
234 // This is a track copy constructor.
235 //-----------------------------------------------------------------
236 Set(t.GetX(),t.GetAlpha(),t.GetParameter(),t.GetCovariance());
238 for (Int_t i=0; i<kMaxRow; i++) fIndex[i]=t.fIndex[i];
239 for (Int_t i=0; i<4;i++) fPoints[i]=t.fPoints[i];
240 for (Int_t i=0; i<12;i++) fKinkPoint[i]=t.fKinkPoint[i];
241 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=t.fKinkIndexes[i];
242 for (Int_t i=0; i<3;i++) fV0Indexes[i]=t.fV0Indexes[i];
245 AliTPCtrack& AliTPCtrack::operator=(const AliTPCtrack& o){
247 AliKalmanTrack::operator=(o);
249 for(Int_t i = 0;i<kMaxRow;++i)fIndex[i] = o.fIndex[i];
250 for(Int_t i = 0;i<4;++i)fPoints[i] = o.fPoints[i];
252 fNFoundable = o.fNFoundable;
253 fBConstrain = o.fBConstrain;
254 fLastPoint = o.fLastPoint;
255 fFirstPoint = o.fFirstPoint;
256 fTrackType = o.fTrackType;
258 fNShared = o.fNShared;
259 fReference = o.fReference;
260 for(Int_t i = 0;i<12;++i) fKinkPoint[i] = o.fKinkPoint[i];
262 for(Int_t i = 0;i<3;++i){
263 fKinkIndexes[i] = o.fKinkIndexes[i];
264 fV0Indexes[i] = o.fV0Indexes[i];
272 //_____________________________________________________________________________
273 Int_t AliTPCtrack::Compare(const TObject *o) const {
274 //-----------------------------------------------------------------
275 // This function compares tracks according to the their curvature
276 //-----------------------------------------------------------------
277 AliTPCtrack *t=(AliTPCtrack*)o;
278 //Double_t co=t->OneOverPt();
279 //Double_t c = OneOverPt();
280 Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
281 Double_t c =GetSigmaY2()*GetSigmaZ2();
283 else if (c<co) return -1;
287 Double_t AliTPCtrack::GetPredictedChi2(const AliCluster *c) const {
288 //-----------------------------------------------------------------
289 // This function calculates a predicted chi2 increment.
290 //-----------------------------------------------------------------
291 Double_t p[2]={c->GetY(), c->GetZ()};
292 Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
293 return AliExternalTrackParam::GetPredictedChi2(p,cov);
296 //_____________________________________________________________________________
297 Bool_t AliTPCtrack::PropagateTo(Double_t xk,Double_t rho,Double_t x0) {
298 //-----------------------------------------------------------------
299 // This function propagates a track to a reference plane x=xk.
300 // rho - density of the crossed matrial (g/cm^3)
301 // x0 - radiation length of the crossed material (g/cm^2)
302 //-----------------------------------------------------------------
306 if (!GetZAt(xk, bz,zat)) return kFALSE;
307 if (TMath::Abs(zat)>250.){
308 // Don't propagate track outside of the fiducial volume - material budget not proper one
310 //AliWarning("Propagate outside of fiducial volume");
314 Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
315 //if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
316 Double_t b[3]; GetBxByBz(b);
317 if (!AliExternalTrackParam::PropagateToBxByBz(xk,b)) return kFALSE;
319 Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) +
320 (GetY()-oldY)*(GetY()-oldY) +
321 (GetZ()-oldZ)*(GetZ()-oldZ));
322 if (IsStartedTimeIntegral() && GetX()>oldX) AddTimeStep(d);
324 if (oldX < xk) d = -d;
325 if (!AliExternalTrackParam::CorrectForMeanMaterial(d*rho/x0,d*rho,GetMass(),
326 kFALSE,AliExternalTrackParam::BetheBlochGas)) return kFALSE;
331 //_____________________________________________________________________________
333 AliTPCtrack::PropagateToVertex(const AliESDVertex *v,Double_t rho,Double_t x0)
335 //-----------------------------------------------------------------
336 // This function propagates tracks to the vertex
337 // rho - density of the crossed matrial (g/cm3)
338 // x0 - radiation length of the crossed material (g/cm2)
339 //-----------------------------------------------------------------
340 Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
342 //Double_t bz=GetBz();
343 //if (!PropagateToDCA(v,bz,kVeryBig)) return kFALSE;
344 Double_t b[3]; GetBxByBz(b);
345 if (!PropagateToDCABxByBz(v,b,kVeryBig)) return kFALSE;
347 Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) +
348 (GetY()-oldY)*(GetY()-oldY) +
349 (GetZ()-oldZ)*(GetZ()-oldZ));
351 if (oldX < GetX()) d = -d;
352 if (!AliExternalTrackParam::CorrectForMeanMaterial(d*rho/x0,d*rho,GetMass(),
353 kFALSE,AliExternalTrackParam::BetheBlochGas)) return kFALSE;
358 //_____________________________________________________________________________
359 Bool_t AliTPCtrack::Update(const AliCluster *c, Double_t chisq, Int_t index) {
360 //-----------------------------------------------------------------
361 // This function associates a cluster with this track.
362 //-----------------------------------------------------------------
363 Double_t p[2]={c->GetY(), c->GetZ()};
364 Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
366 if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
368 AliTracker::FillResiduals(this,p,cov,c->GetVolumeId());
370 Int_t n=GetNumberOfClusters();
372 SetNumberOfClusters(n+1);
373 SetChi2(GetChi2()+chisq);
378 ////////////////////////////////////////////////////////////////////////
381 Float_t AliTPCtrack::Density(Int_t row0, Int_t row1)
384 // calculate cluster density
387 //if (row0<fFirstPoint) row0 = fFirstPoint;
388 if (row1>fLastPoint) row1 = fLastPoint;
391 for (Int_t i=row0;i<=row1;i++){
392 // Int_t index = fClusterIndex[i];
393 Int_t index = fIndex[i];
394 if (index!=-1) good++;
395 if (index>0) found++;
398 if (good>0) density = Float_t(found)/Float_t(good);
403 Float_t AliTPCtrack::Density2(Int_t row0, Int_t row1)
406 // calculate cluster density
410 for (Int_t i=row0;i<=row1;i++){
411 Int_t index = fIndex[i];
412 if (index!=-1) good++;
413 if (index>0) found++;
416 if (good>0) density = Float_t(found)/Float_t(good);
420 void AliTPCtrack::UpdatePoints()
422 //--------------------------------------------------
423 //calculates first ,amx dens and last points
424 //--------------------------------------------------
425 Float_t density[160];
426 for (Int_t i=0;i<160;i++) density[i]=-1.;
434 for (Int_t i=0;i<160;i++){
435 Int_t last = i-range;
436 if (nall<range) nall++;
438 if (fIndex[last]>0&& (fIndex[last]&0x8000)==0) ngood--;
439 if (fIndex[last]==-1) undeff--;
441 if (fIndex[i]>0&& (fIndex[i]&0x8000)==0) ngood++;
442 if (fIndex[i]==-1) undeff++;
443 if (nall==range &&undeff<range/2) density[i-range/2] = Float_t(ngood)/Float_t(nall-undeff);
447 for (Int_t i=0;i<160;i++){
448 if (density[i]<0) continue;
449 if (density[i]>maxdens){
456 fPoints[3] = maxdens;
457 fPoints[1] = indexmax;
460 for (Int_t i=indexmax;i<160;i++){
461 if (density[i]<0) continue;
462 if (density[i]<maxdens/2.) {
469 for (Int_t i=indexmax;i>0;i--){
470 if (density[i]<0) continue;
471 if (density[i]<maxdens/2.) {