1 // **************************************************************************
2 // This file is property of and copyright by the ALICE HLT Project *
3 // ALICE Experiment at CERN, All rights reserved. *
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. *
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. *
17 //***************************************************************************
19 #include "AliHLTTPCCAHitArea.h"
20 #include "AliHLTTPCCATracker.h"
21 #include "AliHLTTPCCAGrid.h"
22 #include "AliHLTTPCCAHit.h"
23 MEM_CLASS_PRE() class AliHLTTPCCARow;
25 MEM_TEMPLATE() GPUdi() void AliHLTTPCCAHitArea::Init( const MEM_TYPE( AliHLTTPCCARow) &row, GPUglobalref() const MEM_GLOBAL(AliHLTTPCCASliceData) &slice, float y, float z,
29 fHitOffset = row.HitNumberOffset();
36 int bYmin, bZmin, bYmax; // boundary bin indexes
37 row.Grid().GetBin( fMinY, fMinZ, &bYmin, &bZmin );
38 row.Grid().GetBin( fMaxY, fMaxZ, &bYmax, &fBZmax );
39 fBDY = bYmax - bYmin + 1; // bin index span in y direction
40 fNy = row.Grid().Ny();
41 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
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);
50 fHitYfst = slice.FirstHitInBin( row, fIndYmin ); // first and
51 fHitYlst = slice.FirstHitInBin( row, fIndYmin + fBDY ); // last hit index in the bin
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 )
62 const float y0 = row.Grid().YMin();
63 const float z0 = row.Grid().ZMin();
66 const float stepY = row.HstepY();
67 const float stepZ = row.HstepZ();
71 while ( fIh >= fHitYlst ) {
72 if ( fIz >= fBZmax ) {
75 // go to next z and start y from the min again
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);
82 fHitYfst = slice.FirstHitInBin( row, fIndYmin );
83 fHitYlst = slice.FirstHitInBin( row, fIndYmin + fBDY );
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 );
93 h->SetY( y0 + tracker.HitDataY( row, fIh ) * stepY );
94 h->SetZ( z0 + tracker.HitDataZ( row, fIh ) * stepZ );
97 if ( 1 && ( h->Z() > fMaxZ || h->Z() < fMinZ || h->Y() < fMinY || h->Y() > fMaxY ) ) { //SG!!!
110 int AliHLTTPCCAHitArea::GetBest( const AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row,
111 const int *content, AliHLTTPCCAHit *h)
113 // get closest hit in the area
118 int ih = GetNext( tracker, row, content, hh );
120 float dy = hh.Y() - fY;
121 float dz = hh.Z() - fZ;
122 float dds = dy * dy + dz * dz;