Line data Source code
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 :
19 : #include "AliHLTTPCCAHitArea.h"
20 : #include "AliHLTTPCCATracker.h"
21 : #include "AliHLTTPCCAGrid.h"
22 : #include "AliHLTTPCCAHit.h"
23 : MEM_CLASS_PRE() class AliHLTTPCCARow;
24 :
25 : MEM_TEMPLATE() GPUdi() void AliHLTTPCCAHitArea::Init( const MEM_TYPE( AliHLTTPCCARow) &row, GPUglobalref() const MEM_GLOBAL(AliHLTTPCCASliceData) &slice, float y, float z,
26 : float dy, float dz )
27 : {
28 : //initialisation
29 0 : fHitOffset = row.HitNumberOffset();
30 0 : fY = y;
31 0 : fZ = z;
32 0 : fMinZ = z - dz;
33 0 : fMaxZ = z + dz;
34 0 : fMinY = y - dy;
35 0 : fMaxY = y + dy;
36 0 : int bYmin, bZmin, bYmax; // boundary bin indexes
37 0 : row.Grid().GetBin( fMinY, fMinZ, &bYmin, &bZmin );
38 0 : row.Grid().GetBin( fMaxY, fMaxZ, &bYmax, &fBZmax );
39 0 : fBDY = bYmax - bYmin + 1; // bin index span in y direction
40 0 : fNy = row.Grid().Ny();
41 0 : fIndYmin = bZmin * fNy + bYmin; // same as grid.GetBin(fMinY, fMinZ), i.e. the smallest bin index of interest
42 : // fIndYmin + fBDY then is the largest bin index of interest with the same Z
43 0 : fIz = bZmin;
44 :
45 : // for given fIz (which is min atm.) get
46 : #ifdef HLTCA_GPU_TEXTURE_FETCHa
47 : fHitYfst = tex1Dfetch(gAliTexRefu, ((char*) slice.FirstHitInBin(row) - slice.GPUTextureBaseConst()) / sizeof(unsigned short) + fIndYmin);
48 : fHitYlst = tex1Dfetch(gAliTexRefu, ((char*) slice.FirstHitInBin(row) - slice.GPUTextureBaseConst()) / sizeof(unsigned short) + fIndYmin + fBDY);
49 : #else
50 0 : fHitYfst = slice.FirstHitInBin( row, fIndYmin ); // first and
51 0 : fHitYlst = slice.FirstHitInBin( row, fIndYmin + fBDY ); // last hit index in the bin
52 : #endif
53 0 : fIh = fHitYfst;
54 0 : }
55 :
56 : MEM_TEMPLATE() GPUdi() int AliHLTTPCCAHitArea::GetNext( GPUconstant() const MEM_CONSTANT(AliHLTTPCCATracker) &tracker, const MEM_TYPE( AliHLTTPCCARow) &row,
57 : GPUglobalref() const MEM_GLOBAL(AliHLTTPCCASliceData) &slice, AliHLTTPCCAHit *h )
58 : {
59 : // get next hit index
60 :
61 : // min coordinate
62 0 : const float y0 = row.Grid().YMin();
63 0 : const float z0 = row.Grid().ZMin();
64 :
65 : // step vector
66 0 : const float stepY = row.HstepY();
67 0 : const float stepZ = row.HstepZ();
68 :
69 : int ret = -1;
70 0 : do {
71 0 : while ( fIh >= fHitYlst ) {
72 0 : if ( fIz >= fBZmax ) {
73 0 : return -1;
74 : }
75 : // go to next z and start y from the min again
76 0 : ++fIz;
77 0 : fIndYmin += fNy;
78 : #ifdef HLTCA_GPU_TEXTURE_FETCHa
79 : fHitYfst = tex1Dfetch(gAliTexRefu, ((char*) slice.FirstHitInBin(row) - slice.GPUTextureBaseConst()) / sizeof(unsigned short) + fIndYmin);
80 : fHitYlst = tex1Dfetch(gAliTexRefu, ((char*) slice.FirstHitInBin(row) - slice.GPUTextureBaseConst()) / sizeof(unsigned short) + fIndYmin + fBDY);
81 : #else
82 0 : fHitYfst = slice.FirstHitInBin( row, fIndYmin );
83 0 : fHitYlst = slice.FirstHitInBin( row, fIndYmin + fBDY );
84 : #endif
85 0 : fIh = fHitYfst;
86 : }
87 :
88 : #ifdef HLTCA_GPU_TEXTURE_FETCHa
89 : ushort2 tmpval = tex1Dfetch(gAliTexRefu2, ((char*) slice.HitData(row) - slice.GPUTextureBaseConst()) / sizeof(ushort2) + fIh);;
90 : h->SetY( y0 + tmpval.x * stepY );
91 : h->SetZ( z0 + tmpval.y * stepZ );
92 : #else
93 0 : h->SetY( y0 + tracker.HitDataY( row, fIh ) * stepY );
94 0 : h->SetZ( z0 + tracker.HitDataZ( row, fIh ) * stepZ );
95 : #endif
96 :
97 0 : if ( 1 && ( h->Z() > fMaxZ || h->Z() < fMinZ || h->Y() < fMinY || h->Y() > fMaxY ) ) { //SG!!!
98 0 : fIh++;
99 : continue;
100 : }
101 0 : ret = fIh;
102 0 : fIh++;
103 : break;
104 0 : } while ( 1 );
105 0 : return ret;
106 0 : }
107 :
108 :
109 : /*
110 : int AliHLTTPCCAHitArea::GetBest( const AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row,
111 : const int *content, AliHLTTPCCAHit *h)
112 : {
113 : // get closest hit in the area
114 : int best = -1;
115 : float ds = 1.e10;
116 : do {
117 : AliHLTTPCCAHit hh;
118 : int ih = GetNext( tracker, row, content, hh );
119 : if ( ih < 0 ) break;
120 : float dy = hh.Y() - fY;
121 : float dz = hh.Z() - fZ;
122 : float dds = dy * dy + dz * dz;
123 : if ( dds < ds ) {
124 : ds = dds;
125 : best = ih;
126 : h = hh;
127 : }
128 : } while ( 1 );
129 :
130 : return best;
131 : }
132 : */
|