]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCtrack.cxx
Remove obsolete class AliTPCclusterLMI (Marian)
[u/mrichter/AliRoot.git] / TPC / AliTPCtrack.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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 /* $Id$ */
17
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 //-----------------------------------------------------------------
23
24 #include <Riostream.h>
25
26 #include "AliTPCtrack.h"
27 #include "AliCluster.h"
28 #include "AliTracker.h"
29 #include "AliESDtrack.h"
30
31 ClassImp(AliTPCtrack)
32
33 //_________________________________________________________________________
34 AliTPCtrack::AliTPCtrack(): 
35   AliKalmanTrack(),
36   fdEdx(0),
37   fSdEdx(1e10),
38   fNFoundable(0),
39   fBConstrain(kFALSE),
40   fLastPoint(-1),
41   fFirstPoint(-1),
42   fRemoval(0),
43   fTrackType(0),
44   fLab2(-1),
45   fNShared(0),
46   fReference()
47 {
48   //-------------------------------------------------
49   // default constructor
50   //-------------------------------------------------
51   for (Int_t i=0; i<kMaxRow;i++) fIndex[i]=-2;
52   for (Int_t i=0; i<4;i++) fPoints[i]=0.;
53   for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
54   for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
55   for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
56 }
57
58 //_________________________________________________________________________
59
60
61
62 AliTPCtrack::AliTPCtrack(Double_t x, Double_t alpha, const Double_t p[5],
63                          const Double_t cov[15], Int_t index) :
64   AliKalmanTrack(),
65   fdEdx(0),
66   fSdEdx(1e10),
67   fNFoundable(0),
68   fBConstrain(kFALSE),
69   fLastPoint(0),
70   fFirstPoint(0),
71   fRemoval(0),
72   fTrackType(0),
73   fLab2(0),
74   fNShared(0),
75   fReference()
76 {
77   //-----------------------------------------------------------------
78   // This is the main track constructor.
79   //-----------------------------------------------------------------
80
81   Double_t cnv=1./(GetBz()*kB2C);
82
83   Double_t pp[5]={
84     p[0],
85     p[1],
86     x*p[4] - p[2],
87     p[3],
88     p[4]*cnv
89   };
90
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];
95
96   Double_t cc[15]={
97     cov[0 ],
98     cov[1 ],     cov[2 ],
99     c20,         c21,         c22,
100     cov[6 ],     cov[7 ],     c32,     cov[9 ],
101     cov[10]*cnv, cov[11]*cnv, c42*cnv, cov[13]*cnv, cov[14]*cnv*cnv
102   };
103
104   Set(x,alpha,pp,cc);
105
106   SetNumberOfClusters(1);
107   
108   fIndex[0]=index;
109   for (Int_t i=1; i<kMaxRow;i++) fIndex[i]=-2;
110   for (Int_t i=0; i<4;i++) fPoints[i]=0.;
111   for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
112   for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
113   for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
114 }
115
116 //_____________________________________________________________________________
117 AliTPCtrack::AliTPCtrack(const AliESDtrack& t) :
118   AliKalmanTrack(),
119   fdEdx(t.GetTPCsignal()),
120   fSdEdx(1e10),
121   fNFoundable(0),
122   fBConstrain(kFALSE),
123   fLastPoint(0),
124   fFirstPoint(0),
125   fRemoval(0),
126   fTrackType(0),
127   fLab2(0),
128   fNShared(0),
129   fReference()
130 {
131   //-----------------------------------------------------------------
132   // Conversion AliESDtrack -> AliTPCtrack.
133   //-----------------------------------------------------------------
134   SetNumberOfClusters(t.GetTPCclusters(fIndex));
135   SetLabel(t.GetLabel());
136   SetMass(t.GetMass());
137   for (Int_t i=0; i<4;i++) fPoints[i]=0.;
138   for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
139   for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
140   for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
141
142   Set(t.GetX(),t.GetAlpha(),t.GetParameter(),t.GetCovariance());
143
144   if ((t.GetStatus()&AliESDtrack::kTIME) == 0) return;
145   StartTimeIntegral();
146   Double_t times[10]; t.GetIntegratedTimes(times); SetIntegratedTimes(times);
147   SetIntegratedLength(t.GetIntegratedLength());
148 }
149
150 //_____________________________________________________________________________
151 AliTPCtrack::AliTPCtrack(const AliTPCtrack& t) :
152   AliKalmanTrack(t),
153   fdEdx(t.fdEdx),
154   fSdEdx(t.fSdEdx),
155   fNFoundable(t.fNFoundable),
156   fBConstrain(t.fBConstrain),
157   fLastPoint(t.fLastPoint),
158   fFirstPoint(t.fFirstPoint),
159   fRemoval(t.fRemoval),
160   fTrackType(t.fTrackType),
161   fLab2(t.fLab2),
162   fNShared(t.fNShared),
163   fReference(t.fReference)
164
165 {
166   //-----------------------------------------------------------------
167   // This is a track copy constructor.
168   //-----------------------------------------------------------------
169   Set(t.GetX(),t.GetAlpha(),t.GetParameter(),t.GetCovariance());
170
171   for (Int_t i=0; i<kMaxRow; i++) fIndex[i]=t.fIndex[i];
172   for (Int_t i=0; i<4;i++) fPoints[i]=t.fPoints[i];
173   for (Int_t i=0; i<12;i++) fKinkPoint[i]=t.fKinkPoint[i];
174   for (Int_t i=0; i<3;i++) fKinkIndexes[i]=t.fKinkIndexes[i];
175   for (Int_t i=0; i<3;i++) fV0Indexes[i]=t.fV0Indexes[i];
176 }
177
178 //_____________________________________________________________________________
179 Int_t AliTPCtrack::Compare(const TObject *o) const {
180   //-----------------------------------------------------------------
181   // This function compares tracks according to the their curvature
182   //-----------------------------------------------------------------
183   AliTPCtrack *t=(AliTPCtrack*)o;
184   //Double_t co=TMath::Abs(t->Get1Pt());
185   //Double_t c =TMath::Abs(Get1Pt());
186   Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
187   Double_t c =GetSigmaY2()*GetSigmaZ2();
188   if (c>co) return 1;
189   else if (c<co) return -1;
190   return 0;
191 }
192
193 Double_t AliTPCtrack::GetPredictedChi2(const AliCluster *c) const {
194   //-----------------------------------------------------------------
195   // This function calculates a predicted chi2 increment.
196   //-----------------------------------------------------------------
197   Double_t p[2]={c->GetY(), c->GetZ()};
198   Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
199   return AliExternalTrackParam::GetPredictedChi2(p,cov);
200 }
201
202 //_____________________________________________________________________________
203 Bool_t AliTPCtrack::PropagateTo(Double_t xk,Double_t rho,Double_t x0) {
204   //-----------------------------------------------------------------
205   //  This function propagates a track to a reference plane x=xk.
206   //  rho - density of the crossed matrial (g/cm^3)
207   //  x0  - radiation length of the crossed material (g/cm^2) 
208   //-----------------------------------------------------------------
209   Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
210
211   Double_t bz=GetBz();
212   if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
213
214   Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) + 
215                            (GetY()-oldY)*(GetY()-oldY) + 
216                            (GetZ()-oldZ)*(GetZ()-oldZ));
217   if (IsStartedTimeIntegral() && GetX()>oldX) AddTimeStep(d);
218
219   if (oldX < xk) d = -d;
220   if (!AliExternalTrackParam::CorrectForMaterial(d*rho/x0,x0,GetMass())) 
221      return kFALSE;
222
223   return kTRUE;
224 }
225
226 //_____________________________________________________________________________
227 Bool_t 
228 AliTPCtrack::PropagateToVertex(const AliESDVertex *v,Double_t d,Double_t x0) 
229 {
230   //-----------------------------------------------------------------
231   // This function propagates tracks to the vertex.
232   //-----------------------------------------------------------------
233   Double_t bz=GetBz();
234   if (PropagateToDCA(v,bz,kVeryBig))
235    if (AliExternalTrackParam::CorrectForMaterial(d,x0,GetMass())) return kTRUE;
236   return kFALSE;
237 }
238
239 //_____________________________________________________________________________
240 Bool_t AliTPCtrack::Update(const AliCluster *c, Double_t chisq, Int_t index) {
241   //-----------------------------------------------------------------
242   // This function associates a cluster with this track.
243   //-----------------------------------------------------------------
244   Double_t p[2]={c->GetY(), c->GetZ()};
245   Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
246
247   if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
248
249   Int_t n=GetNumberOfClusters();
250   fIndex[n]=index;
251   SetNumberOfClusters(n+1);
252   SetChi2(GetChi2()+chisq);
253
254   return kTRUE;
255 }
256
257 ////////////////////////////////////////////////////////////////////////
258 // MI ADDITION
259
260 Float_t AliTPCtrack::Density(Int_t row0, Int_t row1)
261 {
262   //
263   // calculate cluster density
264   Int_t good  = 0;
265   Int_t found = 0;
266   //if (row0<fFirstPoint) row0 = fFirstPoint;
267   if (row1>fLastPoint) row1 = fLastPoint;
268
269   
270   for (Int_t i=row0;i<=row1;i++){ 
271     //    Int_t index = fClusterIndex[i];
272     Int_t index = fIndex[i];
273     if (index!=-1)  good++;
274     if (index>0)    found++;
275   }
276   Float_t density=0;
277   if (good>0) density = Float_t(found)/Float_t(good);
278   return density;
279 }
280
281
282 Float_t AliTPCtrack::Density2(Int_t row0, Int_t row1)
283 {
284   //
285   // calculate cluster density
286   Int_t good  = 0;
287   Int_t found = 0;
288   //  
289   for (Int_t i=row0;i<=row1;i++){     
290     Int_t index = fIndex[i];
291     if (index!=-1)  good++;
292     if (index>0)    found++;
293   }
294   Float_t density=0;
295   if (good>0) density = Float_t(found)/Float_t(good);
296   return density;
297 }
298
299 void  AliTPCtrack::UpdatePoints()
300 {
301   //--------------------------------------------------
302   //calculates first ,amx dens and last points
303   //--------------------------------------------------
304   Float_t density[160];
305   for (Int_t i=0;i<160;i++) density[i]=-1.;
306   fPoints[0]= 160;
307   fPoints[1] = -1;
308   //
309   Int_t ngood=0;
310   Int_t undeff=0;
311   Int_t nall =0;
312   Int_t range=20;
313   for (Int_t i=0;i<160;i++){
314     Int_t last = i-range;
315     if (nall<range) nall++;
316     if (last>=0){
317       if (fIndex[last]>0&& (fIndex[last]&0x8000)==0) ngood--;
318       if (fIndex[last]==-1) undeff--;
319     }
320     if (fIndex[i]>0&& (fIndex[i]&0x8000)==0)   ngood++;
321     if (fIndex[i]==-1) undeff++;
322     if (nall==range &&undeff<range/2) density[i-range/2] = Float_t(ngood)/Float_t(nall-undeff);
323   }
324   Float_t maxdens=0;
325   Int_t indexmax =0;
326   for (Int_t i=0;i<160;i++){
327     if (density[i]<0) continue;
328     if (density[i]>maxdens){
329       maxdens=density[i];
330       indexmax=i;
331     }
332   }
333   //
334   //max dens point
335   fPoints[3] = maxdens;
336   fPoints[1] = indexmax;
337   //
338   // last point
339   for (Int_t i=indexmax;i<160;i++){
340     if (density[i]<0) continue;
341     if (density[i]<maxdens/2.) {
342       break;
343     }
344     fPoints[2]=i;
345   }
346   //
347   // first point
348   for (Int_t i=indexmax;i>0;i--){
349     if (density[i]<0) continue;
350     if (density[i]<maxdens/2.) {
351       break;
352     }
353     fPoints[0]=i;
354   }
355   //
356 }
357
358 Double_t AliTPCtrack::GetBz() const {
359   //
360   // returns Bz component of the magnetic field (kG)
361   //
362   if (AliTracker::UniformField()) return AliTracker::GetBz();
363   Double_t r[3]; GetXYZ(r);
364   return AliTracker::GetBz(r);
365 }
366