]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCAHitArea.cxx
Update of the HLT CA tracker
[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
50 GPUd() void AliHLTTPCCAHitArea::Init( const AliHLTTPCCAGrid &grid, UShort_t *content, UInt_t hitoffset, Float_t y, Float_t z, Float_t dy, Float_t dz )
51
52   //initialisation
53
54   fHitOffset = hitoffset;
55   fY = y;
56   fZ = z;
57   fMinZ = z-dz; 
58   fMaxZ = z+dz;
59   fMinY = y-dy;
60   fMaxY = y+dy;
61   UInt_t bYmin, bZmin, bYmax;  
62   grid.GetBin( fMinY, fMinZ, bYmin, bZmin);
63   grid.GetBin( fMaxY, fMaxZ, bYmax, fBZmax);  
64   fBDY = bYmax - bYmin + 1;
65   fNy = grid.Ny();
66   fIndYmin = bZmin*fNy + bYmin;
67   fIz = bZmin;
68   fHitYfst = content[fIndYmin];
69   fHitYlst = content[fIndYmin + fBDY];    
70   fIh = fHitYfst; 
71 }
72
73
74 GPUd() Int_t AliHLTTPCCAHitArea::GetNext(AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row, UShort_t *content, AliHLTTPCCAHit &h)
75 {    
76   // get next hit index
77   Float_t y0 = row.Grid().YMin();
78   Float_t z0 = row.Grid().ZMin();
79   Float_t stepY = row.HstepY();
80   Float_t stepZ = row.HstepZ();
81   const uint4* tmpint4 = tracker.RowData() + row.FullOffset();
82   const ushort2 *hits = reinterpret_cast<const ushort2*>(tmpint4);
83
84   Int_t ret = -1;
85   do{
86     while( fIh>=fHitYlst ){
87       if( fIz>=fBZmax ) return -1;
88       fIz++;
89       fIndYmin += fNy;
90       fHitYfst = content[fIndYmin];
91       fHitYlst = content[fIndYmin + fBDY];
92       fIh = fHitYfst;
93     }
94
95     {
96       ushort2 hh = hits[fIh];
97       h.SetY( y0 + hh.x*stepY );
98       h.SetZ( z0 + hh.y*stepZ );
99     }
100     //h = tracker.Hits()[ fHitOffset + fIh ];    
101     
102     if( 0 && (h.Z()>fMaxZ || h.Z()<fMinZ || h.Y()<fMinY || h.Y()>fMaxY )){ //SG!!!
103       fIh++;
104       continue;
105     }
106     ret = fIh;
107     fIh++;
108     break;
109   } while(1);
110   return ret; 
111 }
112
113
114
115 GPUd() Int_t AliHLTTPCCAHitArea::GetBest(AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row, UShort_t *content, AliHLTTPCCAHit &h)
116 {
117   // get closest hit in the area
118   Int_t best = -1;
119   Float_t ds = 1.e10;
120   do{
121     AliHLTTPCCAHit hh;
122     Int_t ih=GetNext( tracker, row, content, hh ); 
123     if( ih<0 ) break;
124     Float_t dy = hh.Y() - fY;
125     Float_t dz = hh.Z() - fZ;
126     Float_t dds = dy*dy+dz*dz;
127     if( dds<ds ){
128       ds = dds;
129       best = ih;
130       h = hh;
131     }
132   }while(1);
133
134   return best;
135 }
136