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