]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCModelTrack.cxx
L3 becomes HLT
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCModelTrack.cxx
1 // @(#) $Id$
2 // Original: AliHLTModelTrack.cxx,v 1.18 2005/02/14 11:50:11 hristov 
3 // Author: Anders Vestbo <mailto:vestbo$fi.uib.no>
4 //*-- Copyright &copy ALICE HLT Group
5 //_____________________________________________________________
6 // AliHLTTPCModelTrack
7 //
8 // 
9
10
11 #include "AliHLTTPCLogging.h"
12 #include "AliHLTTPCTransform.h"
13 #include "AliHLTTPCVertex.h"
14 #include "AliHLTTPCDataCompressorHelper.h"
15
16 #include "AliHLTTPCModelTrack.h"
17
18 #if __GNUC__ >= 3
19 using namespace std;
20 #endif
21
22 ClassImp(AliHLTTPCModelTrack)
23
24 AliHLTTPCModelTrack::AliHLTTPCModelTrack() 
25 {
26   // default constructor
27   fNClusters = 0;
28   fClusters = 0;
29   fOverlap = 0;
30   fPad=0;
31   fTime=0;
32   fNoverlaps=0;
33   fClusterCharge=0;
34   fTrackModel=0;
35   fCrossingAngle=0;
36   fParSigmaY2=0;
37   fParSigmaZ2=0;
38   fArraysCreated=kFALSE;
39 }
40
41
42 AliHLTTPCModelTrack::~AliHLTTPCModelTrack()
43 {
44   // destructor
45   DeleteArrays();
46 }
47
48 void AliHLTTPCModelTrack::DeleteArrays()
49 {
50   // deletes all arrays
51   if(fClusters)
52     delete [] fClusters;
53   if(fPad)
54     delete [] fPad;
55   if(fTime)
56     delete [] fTime;
57   if(fCrossingAngle)
58     delete [] fCrossingAngle;
59   if(fParSigmaY2)
60     delete [] fParSigmaY2;
61   if(fParSigmaZ2)
62     delete [] fParSigmaZ2;
63   if(fTrackModel)
64     delete fTrackModel;
65   if(fNoverlaps)
66     delete [] fNoverlaps;
67   if(fOverlap)
68     {
69       for(Int_t i=0; i<AliHLTTPCTransform::GetNRows(fPatch); i++)
70         delete [] fOverlap[i];
71       delete [] fOverlap;
72     }
73   fArraysCreated=kFALSE;
74 }
75
76 void AliHLTTPCModelTrack::Init(Int_t /*slice*/,Int_t patch)
77 {
78   // Initialization
79   if(fArraysCreated)
80     {               
81       DeleteArrays();
82     }
83   fNClusters=AliHLTTPCTransform::GetNRows(patch);
84   fPatch=patch;
85   Int_t nrows = AliHLTTPCTransform::GetNRows(fPatch);
86   fClusters = new AliHLTTPCClusterModel[nrows];
87   fPad = new Float_t[nrows];
88   fTime = new Float_t[nrows];
89   fCrossingAngle = new Float_t[nrows];
90   fParSigmaY2 = new Float_t[nrows];
91   fParSigmaZ2 = new Float_t[nrows];
92   fTrackModel = new AliHLTTPCTrackModel;
93   
94   fOverlap = new Int_t*[nrows];
95   fNoverlaps = new Int_t[nrows];
96   fMaxOverlaps = 5;
97   
98   memset(fNoverlaps,0,nrows*sizeof(Int_t));
99   memset(fClusters,0,nrows*sizeof(AliHLTTPCClusterModel));
100   memset(fPad,0,nrows*sizeof(Float_t));
101   memset(fTime,0,nrows*sizeof(Float_t));
102   memset(fCrossingAngle,0,nrows*sizeof(Float_t));
103   memset(fParSigmaY2,0,nrows*sizeof(Float_t));
104   memset(fParSigmaZ2,0,nrows*sizeof(Float_t));
105   memset(fTrackModel,0,sizeof(AliHLTTPCTrackModel));
106   for(Int_t i=0; i<nrows; i++)
107     {
108       fOverlap[i] = new Int_t[fMaxOverlaps];
109       for(Int_t j=0; j<fMaxOverlaps; j++)
110         fOverlap[i][j]=-1;
111       fClusters[i].fSlice = -1;
112     }
113   fArraysCreated=kTRUE;
114 }
115
116
117
118 void AliHLTTPCModelTrack::CalculateClusterWidths(Int_t row,Bool_t parametrize)
119 {
120   //Cluster widths
121   
122   Float_t xyz[3];
123   Int_t sr,lr;
124   Int_t index = row - AliHLTTPCTransform::GetFirstRow(fPatch);
125   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
126     {
127       cerr<<"AliHLTTPCModelTrack::CalculcateClusterWidths : Wrond index "<<index<<" row "<<row<<endl;
128       return;
129     }
130   Int_t patch = AliHLTTPCTransform::GetPatch(row);
131   AliHLTTPCTransform::Slice2Sector(0,row,sr,lr);
132   AliHLTTPCTransform::Raw2Local(xyz,sr,lr,GetPadHit(row),GetTimeHit(row));
133   fParSigmaY2[index] = AliHLTTPCTransform::GetParSigmaY2(row,xyz[2],GetCrossingAngleLUT(row));
134   fParSigmaZ2[index] = AliHLTTPCTransform::GetParSigmaZ2(row,xyz[2],GetTgl());
135   
136   if(parametrize)
137     {
138       fParSigmaY2[index] = (fParSigmaY2[index] + (1./12)*pow(AliHLTTPCTransform::GetPadPitchWidth(patch),2) );
139       fParSigmaY2[index] *= 0.108;
140       if(patch<2)
141         fParSigmaY2[index] *= 2.07;
142      
143       fParSigmaZ2[index] = (fParSigmaZ2[index] + (1./12)*pow(AliHLTTPCTransform::GetZWidth(),2) );
144       fParSigmaZ2[index] *= 0.169;
145       if(patch<2)
146         fParSigmaZ2[index] *= 1.77;
147     }
148   
149   //convert to raw coordinates:
150   fParSigmaY2[index] /= pow(AliHLTTPCTransform::GetPadPitchWidth(patch),2);
151   fParSigmaZ2[index] /= pow(AliHLTTPCTransform::GetZWidth(),2);
152 }
153
154 void AliHLTTPCModelTrack::SetCluster(Int_t row,Float_t fpad,Float_t ftime,Float_t charge,
155                                  Float_t sigmaY2,Float_t sigmaZ2,Int_t npads)
156 {
157   AliHLTTPCClusterModel *cl = GetClusterModel(row);
158   
159   //First bit: Cluster is present or not
160   //Second bit: Cluster was set, meaning an fit attempt was done (if true)
161   
162   cl->fPresent |= 0x2; //set second bit to true, because a fit attempt has been made
163   
164   Int_t patch = AliHLTTPCTransform::GetPatch(row);
165   if(!charge || npads == 1)
166     {
167       cl->fPresent &= ~0x1; //set first bit to false
168     }
169   else
170     {
171       cl->fPresent|=0x1;//set first bit to true
172       cl->fDPad = (fpad - GetPadHit(row))/(AliHLTTPCDataCompressorHelper::GetXYResidualStep(row)/AliHLTTPCTransform::GetPadPitchWidth(patch));
173       cl->fDTime = (ftime - GetTimeHit(row))/(AliHLTTPCDataCompressorHelper::GetZResidualStep(row)/AliHLTTPCTransform::GetZWidth());
174       cl->fDCharge = charge;
175       if(sigmaY2==0 && sigmaZ2==0)
176         {
177           cl->fDSigmaY=0;//if width is zero, shape is not supposed to be written
178           cl->fDSigmaZ=0;
179         }
180       else
181         {
182           //cl->fDSigmaY2 = (sigmaY2 - GetParSigmaY2(row))/(pow(AliHLTTPCDataCompressorHelper::GetXYWidthStep(),2)/pow(AliHLTTPCTransform::GetPadPitchWidth(patch),2));
183           //cl->fDSigmaZ2 = (sigmaZ2 - GetParSigmaZ2(row))/(pow(AliHLTTPCDataCompressorHelper::GetZWidthStep(),2)/pow(AliHLTTPCTransform::GetZWidth(),2));
184           cl->fDSigmaY = (sqrt(sigmaY2) - sqrt(GetParSigmaY2(row)))/(AliHLTTPCDataCompressorHelper::GetXYWidthStep()/AliHLTTPCTransform::GetPadPitchWidth(patch));
185           cl->fDSigmaZ = (sqrt(sigmaZ2) - sqrt(GetParSigmaZ2(row)))/(AliHLTTPCDataCompressorHelper::GetZWidthStep()/AliHLTTPCTransform::GetZWidth());
186         }
187       cl->fNPads = npads;
188     }
189 }
190
191
192 void AliHLTTPCModelTrack::Set(AliHLTTPCTrack *tpt)
193 {
194   // Sets track and does initialization
195   AliHLTTPCModelTrack *tr = (AliHLTTPCModelTrack*)tpt;
196   SetRowRange(tr->GetFirstRow(),tr->GetLastRow());
197   SetPhi0(tr->GetPhi0());
198   SetKappa(tr->GetKappa());
199   SetFirstPoint(tr->GetFirstPointX(),tr->GetFirstPointY(),tr->GetFirstPointZ());
200   SetLastPoint(tr->GetLastPointX(),tr->GetLastPointY(),tr->GetLastPointZ());
201   SetPt(tr->GetPt());
202   SetPsi(tr->GetPsi());
203   SetTgl(tr->GetTgl());
204   SetCharge(tr->GetCharge());
205   
206   if(fClusters)
207     {
208       cerr<<"AliHLTTPCModelTrack::Set : Init has already been called for this object!"<<endl;
209       return;
210     }
211
212   //Init(tr->fSlice,tr->fPatch);
213   Init(0,tr->fPatch);
214   memcpy(fClusters,tr->fClusters,AliHLTTPCTransform::GetNRows(fPatch)*sizeof(AliHLTTPCClusterModel));
215   memcpy(fPad,tr->fPad,AliHLTTPCTransform::GetNRows(fPatch)*sizeof(Float_t));
216   memcpy(fTime,tr->fTime,AliHLTTPCTransform::GetNRows(fPatch)*sizeof(Float_t));
217   memcpy(fParSigmaY2,tr->fParSigmaY2,AliHLTTPCTransform::GetNRows(fPatch)*sizeof(Float_t));
218   memcpy(fParSigmaZ2,tr->fParSigmaZ2,AliHLTTPCTransform::GetNRows(fPatch)*sizeof(Float_t));
219   memcpy(fCrossingAngle,tr->fCrossingAngle,AliHLTTPCTransform::GetNRows(fPatch)*sizeof(Float_t));
220   memcpy(fTrackModel,tr->fTrackModel,sizeof(AliHLTTPCTrackModel));
221
222 }
223
224 Int_t AliHLTTPCModelTrack::GetNPresentClusters()
225 {
226   //Return the number of assigned clusters to the track.
227   //Differs from fNClusters, which should be equal to the 
228   //number of padrows in the present patch.
229   
230   Int_t count=0;
231
232   for(Int_t i=AliHLTTPCTransform::GetFirstRow(fPatch); i<=AliHLTTPCTransform::GetLastRow(fPatch); i++)
233     if(IsPresent(i))
234       count++;
235
236   return count;
237 }
238
239 void AliHLTTPCModelTrack::FillModel()
240 {
241   //Fill the track structure
242   
243   if(fNClusters != AliHLTTPCTransform::GetNRows(fPatch))
244     {
245       cout<<"AliHLTTPCModelTrack::FillModel : fNClusters != nrows; beware, this could be caused by a bug!!!"<<endl;
246       fNClusters = AliHLTTPCTransform::GetNRows(fPatch);
247     }
248
249   if(!fTrackModel)
250     {
251       cerr<<"AliHLTTPCModelTrack::FillModel() : No trackmodel "<<endl;
252       return;
253     }
254   Double_t impact[3];
255   AliHLTTPCVertex vertex;
256   CalculateHelix();
257   GetClosestPoint(&vertex,impact[0],impact[1],impact[2]);
258   fTrackModel->fKappa = GetKappa();
259   fTrackModel->fPhi = atan2(impact[1],impact[0]);
260   fTrackModel->fD = sqrt(impact[0]*impact[0] + impact[1]*impact[1]);
261   fTrackModel->fZ0 = impact[2];
262   fTrackModel->fTgl = GetTgl();
263   
264   //We have to check on which of the vertex the track fit is lying
265   //This we need to encode the azimuthal angle coordinate of the center of curvature.
266   if(GetRadius() < sqrt(GetCenterX()*GetCenterX()+GetCenterY()*GetCenterY()))
267     fTrackModel->fD *=-1;
268   
269 }
270
271 void AliHLTTPCModelTrack::FillTrack()
272 {
273   //Fill the track parameters from the structure.
274   
275   if(!fTrackModel)
276     {
277       cerr<<"AliHLTTPCModelTrack::FillTrack() : No data!!"<<endl;
278       return;
279     }
280   SetKappa(fTrackModel->fKappa);
281   Double_t impact[3],psi;
282   Float_t trackPhi0 = fTrackModel->fPhi;
283   if(fTrackModel->fD < 0)
284     trackPhi0 += AliHLTTPCTransform::Pi();
285   Int_t charge = -1*(Int_t)copysign(1.,GetKappa());
286   impact[0] = fabs(fTrackModel->fD)*cos(fTrackModel->fPhi);
287   impact[1] = fabs(fTrackModel->fD)*sin(fTrackModel->fPhi);
288   impact[2] = fTrackModel->fZ0;
289
290   psi = trackPhi0 - charge*0.5*AliHLTTPCTransform::Pi();
291   if(psi < 0) 
292     psi += 2*AliHLTTPCTransform::Pi();
293
294   SetCharge(charge);
295   SetFirstPoint(impact[0],impact[1],impact[2]);
296   SetPsi(psi);
297   SetTgl(fTrackModel->fTgl);
298   SetPt((AliHLTTPCTransform::GetBFact()*AliHLTTPCTransform::GetBField())/fabs(GetKappa()));
299   fNClusters = AliHLTTPCTransform::GetNRows(fPatch);
300   CalculateHelix();
301   
302   for(Int_t i=AliHLTTPCTransform::GetFirstRow(fPatch); i<=AliHLTTPCTransform::GetLastRow(fPatch); i++)
303     {
304       AliHLTTPCClusterModel *cl = GetClusterModel(i);
305       if(!cl) continue;
306
307       if(cl->fSlice == -1)
308         {
309           SetPadHit(i,-1);
310           SetTimeHit(i,-1);
311           continue;
312         }
313       if(cl->fSlice < 0 || cl->fSlice > 35)
314         {
315           cerr<<"AliHLTTPCModelTrack::FillTrack : Slice out of range "<<cl->fSlice<<" on row "<<i<<endl;
316           exit(5);
317         }
318       
319       Float_t angle = 0;
320       
321       AliHLTTPCTransform::Local2GlobalAngle(&angle,cl->fSlice);
322       if(!CalculateReferencePoint(angle,AliHLTTPCTransform::Row2X(i)))
323         {
324           if(IsPresent(i))
325             {
326               cerr<<"AliHLTTPCModelTrack::FillTrack : Track does not cross slice "<<cl->fSlice<<" row "<<i<<" Points "
327                   <<GetPointX()<<" "<<GetPointY()<<" "<<GetPointZ()<<endl;
328               Print();
329               exit(5);
330             }
331           SetPadHit(i,-1);
332           SetTimeHit(i,-1);
333           continue;
334         }
335       Float_t hit[3] = {GetPointX(),GetPointY(),GetPointZ()};
336       Int_t sector,row;
337       AliHLTTPCTransform::Slice2Sector(cl->fSlice,i,sector,row);
338       AliHLTTPCTransform::Global2Raw(hit,sector,row);
339
340       SetPadHit(i,hit[1]);
341       SetTimeHit(i,hit[2]);
342
343       Float_t crossingangle = GetCrossingAngle(i,cl->fSlice);
344       
345       SetCrossingAngleLUT(i,crossingangle);
346       CalculateClusterWidths(i,kTRUE);
347       
348     }
349 }
350
351 void AliHLTTPCModelTrack::SetPadHit(Int_t row,Float_t pad)
352 {
353   // sets pad hit
354   Int_t index = row-AliHLTTPCTransform::GetFirstRow(fPatch);
355   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
356     {
357       cerr<<"AliHLTTPCModelTrack::SetPadHit() : Wrong index: "<<index<<endl;
358       return;
359     }
360   fPad[index]=pad;
361 }
362
363 void AliHLTTPCModelTrack::SetTimeHit(Int_t row,Float_t time)
364 {
365   // sets time hit
366   Int_t index = row-AliHLTTPCTransform::GetFirstRow(fPatch);
367   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
368     {
369       cerr<<"AliHLTTPCModelTrack::SetTimeHit() : Wrong index: "<<index<<endl;
370       return;
371     }
372   fTime[index]=time;
373 }
374
375 void AliHLTTPCModelTrack::SetCrossingAngleLUT(Int_t row,Float_t angle)
376 {
377   // sets LUT for crossing angle
378   Int_t index = row-AliHLTTPCTransform::GetFirstRow(fPatch);
379   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
380     {
381       cerr<<"AliHLTTPCModelTrack::SetCrossingAngle() : Wrong index: "<<index<<endl;
382       return;
383     }
384   fCrossingAngle[index]=angle;
385 }
386
387 void AliHLTTPCModelTrack::SetOverlap(Int_t row,Int_t id)
388 {
389   // sets overlap
390   Int_t index = row-AliHLTTPCTransform::GetFirstRow(fPatch);
391   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
392     {
393       cerr<<"AliHLTTPCModelTrack::SetOverlap() : Wrong index: "<<index<<endl;
394       return;
395     }
396   if(fNoverlaps[index] >= fMaxOverlaps) return;
397   fOverlap[index][fNoverlaps[index]++] = id;
398 }
399
400 Bool_t AliHLTTPCModelTrack::IsPresent(Int_t row)
401 {
402   AliHLTTPCClusterModel *cl = GetClusterModel(row);
403   return (Bool_t)(cl->fPresent & 0x1);
404 }
405
406 Bool_t AliHLTTPCModelTrack::IsSet(Int_t row)
407 {
408   // checks if row was set
409   AliHLTTPCClusterModel *cl = GetClusterModel(row);
410   return (Bool_t)(cl->fPresent & 0x2);
411 }
412
413 Int_t AliHLTTPCModelTrack::GetNPads(Int_t row)
414 {
415   // gets number of pads
416   AliHLTTPCClusterModel *cl = GetClusterModel(row);
417   return cl->fNPads;
418 }
419
420 Bool_t AliHLTTPCModelTrack::GetPad(Int_t row,Float_t &pad)
421 {
422   // gets pad
423   //(fpad - GetPadHit(row))/(AliHLTTPCDataCompressorHelper::GetXYResidualStep(row)/AliHLTTPCTransform::GetPadPitchWidth(patch));
424   AliHLTTPCClusterModel *cl = GetClusterModel(row);
425   Int_t patch = AliHLTTPCTransform::GetPatch(row);
426   pad = cl->fDPad*(AliHLTTPCDataCompressorHelper::GetXYResidualStep(row)/AliHLTTPCTransform::GetPadPitchWidth(patch)) + GetPadHit(row);
427   return IsPresent(row);
428 }
429
430 Bool_t AliHLTTPCModelTrack::GetTime(Int_t row,Float_t &time)
431 {
432   // gets time
433   AliHLTTPCClusterModel *cl = GetClusterModel(row);
434   time = cl->fDTime*(AliHLTTPCDataCompressorHelper::GetZResidualStep(row)/AliHLTTPCTransform::GetZWidth()) + GetTimeHit(row);
435   return IsPresent(row);
436 }
437
438 Bool_t AliHLTTPCModelTrack::GetClusterCharge(Int_t row,Int_t &charge)
439 {
440   // gets cluster's charge
441   AliHLTTPCClusterModel *cl = GetClusterModel(row);
442   charge = (Int_t)cl->fDCharge;// + AliHLTTPCDataCompressorHelperHelper::GetClusterCharge();
443   return IsPresent(row);
444 }
445
446 Bool_t AliHLTTPCModelTrack::GetSigmaY2(Int_t row,Float_t &sigma2)
447 {
448   // gets SigmaY2
449   //cl->fDSigmaY = (sqrt(sigmaY2) - sqrt(GetParSigmaY2(row)))/(AliHLTTPCDataCompressorHelper::GetXYWidthStep()/AliHLTTPCTransform::GetPadPitchWidth(patch));
450   AliHLTTPCClusterModel *cl = GetClusterModel(row);
451   Int_t patch = AliHLTTPCTransform::GetPatch(row);
452   Float_t sigma = cl->fDSigmaY*(AliHLTTPCDataCompressorHelper::GetXYWidthStep()/AliHLTTPCTransform::GetPadPitchWidth(patch)) + sqrt(GetParSigmaY2(row));
453   sigma2 = sigma*sigma;
454   return IsPresent(row);
455 }
456
457 Bool_t AliHLTTPCModelTrack::GetSigmaZ2(Int_t row,Float_t &sigma2)
458 {
459   // gets SigmaZ2
460   //cl->fDSigmaZ = (sqrt(sigmaZ2) - sqrt(GetParSigmaZ2(row)))/(AliHLTTPCDataCompressorHelper::GetZWidthStep()/AliHLTTPCTransform::GetZWidth());
461   AliHLTTPCClusterModel *cl = GetClusterModel(row);
462   Float_t sigma = cl->fDSigmaZ*(AliHLTTPCDataCompressorHelper::GetZWidthStep()/AliHLTTPCTransform::GetZWidth()) + sqrt(GetParSigmaZ2(row));
463   sigma2 = sigma*sigma;
464   return IsPresent(row);
465 }
466
467 Bool_t AliHLTTPCModelTrack::GetPadResidual(Int_t row,Float_t &res)
468 {
469   // gets pad residual
470   AliHLTTPCClusterModel *cl = GetClusterModel(row);
471   Int_t patch = AliHLTTPCTransform::GetPatch(row);
472   res = cl->fDPad*(AliHLTTPCDataCompressorHelper::GetXYResidualStep(row)/AliHLTTPCTransform::GetPadPitchWidth(patch));
473   return IsPresent(row);
474 }
475
476 Bool_t AliHLTTPCModelTrack::GetTimeResidual(Int_t row,Float_t &res)
477 {
478   // gets time residual
479   AliHLTTPCClusterModel *cl = GetClusterModel(row);
480   res = cl->fDTime*(AliHLTTPCDataCompressorHelper::GetZResidualStep(row)/AliHLTTPCTransform::GetZWidth());
481   return IsPresent(row);
482 }
483
484 Bool_t AliHLTTPCModelTrack::GetSigmaYResidual(Int_t row,Float_t &res)
485 {
486   // gets SigmaY residual (?)
487   AliHLTTPCClusterModel *cl = GetClusterModel(row);
488   Int_t patch = AliHLTTPCTransform::GetPatch(row);
489   res = cl->fDSigmaY*(AliHLTTPCDataCompressorHelper::GetXYWidthStep()/AliHLTTPCTransform::GetPadPitchWidth(patch));
490   return IsPresent(row);
491 }
492
493 Bool_t AliHLTTPCModelTrack::GetSigmaZResidual(Int_t row,Float_t &res)
494 {
495   // gets SigmaZ resigual (?)
496   AliHLTTPCClusterModel *cl = GetClusterModel(row);
497   res = cl->fDSigmaZ*(AliHLTTPCDataCompressorHelper::GetZWidthStep()/AliHLTTPCTransform::GetZWidth());
498   return IsPresent(row);
499 }
500
501 Int_t AliHLTTPCModelTrack::GetSlice(Int_t row)
502 {
503   // Gets slice
504   AliHLTTPCClusterModel *cl = GetClusterModel(row);
505   return cl->fSlice;
506 }
507
508 Float_t AliHLTTPCModelTrack::GetPadHit(Int_t row)
509 {
510   // Gets pad hit
511   Int_t index = row-AliHLTTPCTransform::GetFirstRow(fPatch);
512   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
513     {
514       cerr<<"AliHLTTPCModelTrack::GetPadHit() : Wrong index: "<<index<<" row "<<row<<endl;
515       return 0;
516     }
517   return fPad[index];
518 }
519
520 Float_t AliHLTTPCModelTrack::GetTimeHit(Int_t row)
521 {
522   // Gets time hit
523   Int_t index = row-AliHLTTPCTransform::GetFirstRow(fPatch);
524   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
525     {
526       cerr<<"AliHLTTPCModelTrack::GetTimeHit() : Wrong index: "<<index<<" row "<<row<<endl;
527       return 0;
528     }
529   return fTime[index];
530 }
531
532 Float_t AliHLTTPCModelTrack::GetCrossingAngleLUT(Int_t row)
533 {
534   // gets LUT for crossing angle
535   Int_t index = row-AliHLTTPCTransform::GetFirstRow(fPatch);
536   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
537     {
538       cerr<<"AliHLTTPCModelTrack::GetCrossingAngleLUT() : Wrong index: "<<index<<" row "<<row<<endl;
539       return 0;
540     }
541   return fCrossingAngle[index];
542 }
543
544 Float_t AliHLTTPCModelTrack::GetParSigmaY2(Int_t row)
545 {
546   // gets par SigmaY2 (?)
547   Int_t index = row-AliHLTTPCTransform::GetFirstRow(fPatch);
548   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
549     {
550       cerr<<"AliHLTTPCModelTrack::GetParSigmaY2() : Wrong index: "<<index<<" row "<<row<<endl;
551       return 0;
552     }
553   return fParSigmaY2[index];
554 }
555
556 Float_t AliHLTTPCModelTrack::GetParSigmaZ2(Int_t row)
557 {
558   // gets par SigmaZ2 (?)
559   Int_t index = row-AliHLTTPCTransform::GetFirstRow(fPatch);
560   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
561     {
562       cerr<<"AliHLTTPCModelTrack::GetParSigmaZ2() : Wrong index: "<<index<<" row "<<row<<endl;
563       return 0;
564     }
565   return fParSigmaZ2[index];
566 }
567
568 Int_t AliHLTTPCModelTrack::GetNOverlaps(Int_t row)
569 {
570   // gets number of overlaps
571   Int_t index = row - AliHLTTPCTransform::GetFirstRow(fPatch);
572   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
573     {
574       cerr<<"AliHLTTPCModelTrack::GetOverlap() : Wrong index: "<<index<<endl;
575       return 0;
576     }
577   return fNoverlaps[index];
578 }
579
580 Int_t *AliHLTTPCModelTrack::GetOverlaps(Int_t row)
581 {
582   // gets overlaps
583   Int_t index = row - AliHLTTPCTransform::GetFirstRow(fPatch);
584   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
585     {
586       cerr<<"AliHLTTPCModelTrack::GetOverlap() : Wrong index: "<<index<<endl;
587       return 0;
588     }
589   return fOverlap[index];
590 }
591
592 AliHLTTPCClusterModel *AliHLTTPCModelTrack::GetClusterModel(Int_t row)
593 {
594   // gets cluster model
595   if(!fClusters) return 0; 
596   Int_t index = row-AliHLTTPCTransform::GetFirstRow(fPatch);
597   if(index < 0 || index > AliHLTTPCTransform::GetNRows(fPatch))
598     {
599       cerr<<"AliHLTTPCModelTrack::GetClusterModel() : Wrong index: "<<index<<endl;
600       return 0;
601     }
602   return &fClusters[index];
603 }
604
605 void AliHLTTPCModelTrack::Print(Bool_t everything)
606 {
607   //Print info
608
609   cout<<"First point "<<GetFirstPointX()<<" "<<GetFirstPointY()<<" "<<GetFirstPointZ()<<endl;
610   cout<<"Last point "<<GetLastPointX()<<" "<<GetLastPointY()<<" "<<GetLastPointZ()<<endl;
611   cout<<"Pt "<<GetPt()<<" kappa "<<GetKappa()<<" tgl "<<GetTgl()<<" psi "<<GetPsi()<<" charge "<<GetCharge()<<endl;
612   cout<<"Center "<<GetCenterX()<<" "<<GetCenterY()<<endl<<endl;
613   if(!everything)
614     return;
615   cout<<"NHits "<<GetNClusters()<<endl;
616
617   cout<<"Clusters:"<<endl;
618   Int_t origslice=-1,counter=0;
619   Float_t fpad,ftime,sigmaY2,sigmaZ2;
620   for(Int_t i=AliHLTTPCTransform::GetFirstRow(fPatch); i<=AliHLTTPCTransform::GetLastRow(fPatch); i++)
621     {
622       AliHLTTPCClusterModel *cl = GetClusterModel(i);
623       
624       if(!IsPresent(i))
625         {
626           cout<<i<<" Empty"<<" Slice "<<cl->fSlice<<" Padcrossing "<<GetPadHit(i)<<" Timecrossing "<<GetTimeHit(i)<<" ";
627           //AliHLTTPCTransform::RawHLT2Global(xyz,cl->fSlice,i,GetPadHit(i),GetTimeHit(i));
628           //cout<<i<<" slice "<<cl->fSlice<<" x "<<xyz[0]<<" y "<<xyz[1]<<" z "<<xyz[2];
629         }
630       else
631         {
632           GetPad(i,fpad);
633           GetTime(i,ftime);
634           GetSigmaY2(i,sigmaY2);
635           GetSigmaZ2(i,sigmaZ2);
636           if(counter==0)
637             origslice=cl->fSlice;
638           else if(cl->fSlice != origslice)
639             cout<<"Change in slice "<<cl->fSlice<<" "<<origslice<<endl;
640           cout<<i<<" Slice "<<cl->fSlice<<" Dpad "<<cl->fDPad<<" Dtime "<<cl->fDTime<<" Dcharge "<<cl->fDCharge;
641           cout<<" sigmaY2 "<<sigmaY2<<" sigmaZ2 "<<sigmaZ2;
642           cout<<" parsigmaY2 "<<GetParSigmaY2(i)<<" parsigmaZ2 "<<GetParSigmaZ2(i);
643           cout<<" Pad "<<fpad<<" padhit "<<GetPadHit(i)<<" Time "<<ftime<<" timehit "<<GetTimeHit(i)<<" ";
644           counter++;
645         }
646       cout<<endl;
647     }
648 }
649
650 #ifdef do_mc
651 void AliHLTTPCModelTrack::SetClusterLabel(Int_t row,Int_t *trackID)
652 {
653   // sets cluster label
654   AliHLTTPCClusterModel *cl = GetClusterModel(row);
655   cl->fTrackID[0] = trackID[0];
656   cl->fTrackID[1] = trackID[1];
657   cl->fTrackID[2] = trackID[2];
658 #else
659   void AliHLTTPCModelTrack::SetClusterLabel(Int_t /*row*/,Int_t */*trackID*/)
660 {
661   // Does nothing if do_mc undefined
662   return;
663 #endif
664 }
665
666 #ifdef do_mc
667 void AliHLTTPCModelTrack::GetClusterLabel(Int_t row,Int_t *trackID)
668 {
669   // gets cluster label
670   AliHLTTPCClusterModel *cl = GetClusterModel(row);
671   trackID[0] = cl->fTrackID[0];
672   trackID[1] = cl->fTrackID[1];
673   trackID[2] = cl->fTrackID[2];
674 #else
675   void AliHLTTPCModelTrack::GetClusterLabel(Int_t /*row*/,Int_t */*trackID*/)
676 {
677   // Does nothing if do_mc undefined
678   return;
679 #endif
680 }
681