]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCAHitArea.cxx
A tracker update: significant clean up, reorganise of the data structures, p-p track...
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAHitArea.cxx
1 //***************************************************************************
2 // This file is property of and copyright by the ALICE HLT Project          * 
3 // ALICE Experiment at CERN, All rights reserved.                           *
4 //                                                                          *
5 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
6 //                  Ivan Kisel <kisel@kip.uni-heidelberg.de>                *
7 //                  for The ALICE HLT Project.                              *
8 //                                                                          *
9 // Permission to use, copy, modify and distribute this software and its     *
10 // documentation strictly for non-commercial purposes is hereby granted     *
11 // without fee, provided that the above copyright notice appears in all     *
12 // copies and that both the copyright notice and this permission notice     *
13 // appear in the supporting documentation. The authors make no claims       *
14 // about the suitability of this software for any purpose. It is            *
15 // provided "as is" without express or implied warranty.                    *
16 //***************************************************************************
17
18 #include "AliHLTTPCCAHitArea.h"
19 #include "AliHLTTPCCATracker.h"
20 #include "AliHLTTPCCAGrid.h"
21 #include "AliHLTTPCCAHit.h"
22 #include "AliHLTTPCCARow.h"
23
24
25 GPUd() void AliHLTTPCCAHitAreaInit( AliHLTTPCCAHitArea &a,  AliHLTTPCCAGrid &grid, UShort_t *content, UInt_t hitoffset, Float_t y, Float_t z, Float_t dy, Float_t dz )
26
27   // initialisation
28
29   a.HitOffset() = hitoffset;
30   a.Y() = y;
31   a.Z() = z;
32   a.MinZ() = z-dz; 
33   a.MaxZ() = z+dz;
34   a.MinY() = y-dy;
35   a.MaxY() = y+dy;
36   UInt_t bYmin, bZmin, bYmax;  
37   grid.GetBin(a.MinY(), a.MinZ(), bYmin, bZmin);
38   grid.GetBin(a.MaxY(), a.MaxZ(), bYmax, a.BZmax());  
39   a.BDY() = bYmax - bYmin + 1;
40   a.Ny() = grid.Ny();
41   a.IndYmin() = bZmin*a.Ny() + bYmin;
42   a.Iz() = bZmin;
43   a.HitYfst() = content[a.IndYmin()];
44   a.HitYlst() = content[a.IndYmin() + a.BDY()];    
45   a.Ih() = a.HitYfst(); 
46 }
47
48
49 GPUd() void AliHLTTPCCAHitArea::Init( AliHLTTPCCAGrid &grid, UShort_t *content, UInt_t hitoffset, Float_t y, Float_t z, Float_t dy, Float_t dz )
50
51   //initialisation
52   AliHLTTPCCAHitAreaInit(*this, grid, content, hitoffset, y, z, dy, dz);
53 }
54
55 GPUd() Int_t AliHLTTPCCAHitArea::GetNext(AliHLTTPCCATracker &tracker, AliHLTTPCCARow &row, UShort_t *content, AliHLTTPCCAHit &h)
56 {    
57   // get next hit index
58   Float_t y0 = row.Grid().YMin();
59   Float_t z0 = row.Grid().ZMin();
60   Float_t stepY = row.HstepY();
61   Float_t stepZ = row.HstepZ();
62   uint4* tmpint4 = tracker.RowData() + row.FullOffset();
63   ushort2 *hits = reinterpret_cast<ushort2*>(tmpint4);
64
65   Int_t ret = -1;
66   do{
67     while( fIh>=fHitYlst ){
68       if( fIz>=fBZmax ) return -1;
69       fIz++;
70       fIndYmin += fNy;
71       fHitYfst = content[fIndYmin];
72       fHitYlst = content[fIndYmin + fBDY];
73       fIh = fHitYfst;
74     }
75
76     {
77       ushort2 hh = hits[fIh];
78       h.Y() = y0 + hh.x*stepY;
79       h.Z() = z0 + hh.y*stepZ;
80     }
81     //h = tracker.Hits()[ fHitOffset + fIh ];    
82     
83     if( h.fZ>fMaxZ || h.fZ<fMinZ || h.fY<fMinY || h.fY>fMaxY ){
84       fIh++;
85       continue;
86     }
87     ret = fIh;
88     fIh++;
89     break;
90   } while(1);
91   return ret; 
92 }
93
94
95
96 GPUd() Int_t AliHLTTPCCAHitArea::GetBest(AliHLTTPCCATracker &tracker, AliHLTTPCCARow &row, UShort_t *content, AliHLTTPCCAHit &h)
97 {
98   // get closest hit in the area
99   Int_t best = -1;
100   Float_t ds = 1.e10;
101   do{
102     AliHLTTPCCAHit hh;
103     Int_t ih=GetNext( tracker, row, content, hh ); 
104     if( ih<0 ) break;
105     Float_t dy = hh.fY - fY;
106     Float_t dz = hh.fZ - fZ;
107     Float_t dds = dy*dy+dz*dz;
108     if( dds<ds ){
109       ds = dds;
110       best = ih;
111       h = hh;
112     }
113   }while(1);
114
115   return best;
116 }
117