]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCAHitArea.cxx
OpenCL version of the HLT tracker added (the new code is not used in standard compila...
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAHitArea.cxx
CommitLineData
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"
43422963 23MEM_CLASS_PRE() class AliHLTTPCCARow;
00d07bcd 24
43422963 25MEM_TEMPLATE() GPUdi() void AliHLTTPCCAHitArea::Init( const MEM_TYPE( AliHLTTPCCARow) &row, GPUglobalref() const MEM_GLOBAL(AliHLTTPCCASliceData) &slice, float y, float z,
4acc2401 26 float dy, float dz )
fbb9b71b 27{
00d07bcd 28 //initialisation
4acc2401 29 fHitOffset = row.HitNumberOffset();
693d2443 30 fY = y;
31 fZ = z;
fbb9b71b 32 fMinZ = z - dz;
33 fMaxZ = z + dz;
34 fMinY = y - dy;
35 fMaxY = y + dy;
4acc2401 36 int bYmin, bZmin, bYmax; // boundary bin indexes
43422963 37 row.Grid().GetBin( fMinY, fMinZ, &bYmin, &bZmin );
38 row.Grid().GetBin( fMaxY, fMaxZ, &bYmax, &fBZmax );
4acc2401 39 fBDY = bYmax - bYmin + 1; // bin index span in y direction
43422963 40 fNy = row.Grid().Ny();
4acc2401 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
693d2443 43 fIz = bZmin;
4acc2401 44
45 // for given fIz (which is min atm.) get
b22af1bf 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
4acc2401 50 fHitYfst = slice.FirstHitInBin( row, fIndYmin ); // first and
51 fHitYlst = slice.FirstHitInBin( row, fIndYmin + fBDY ); // last hit index in the bin
b22af1bf 52#endif
fbb9b71b 53 fIh = fHitYfst;
00d07bcd 54}
55
43422963 56MEM_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 )
fbb9b71b 58{
00d07bcd 59 // get next hit index
4acc2401 60
61 // min coordinate
62 const float y0 = row.Grid().YMin();
63 const float z0 = row.Grid().ZMin();
64
65 // step vector
66 const float stepY = row.HstepY();
67 const float stepZ = row.HstepZ();
4687b8fc 68
fbb9b71b 69 int ret = -1;
70 do {
71 while ( fIh >= fHitYlst ) {
4acc2401 72 if ( fIz >= fBZmax ) {
73 return -1;
74 }
75 // go to next z and start y from the min again
76 ++fIz;
00d07bcd 77 fIndYmin += fNy;
b22af1bf 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
4acc2401 82 fHitYfst = slice.FirstHitInBin( row, fIndYmin );
83 fHitYlst = slice.FirstHitInBin( row, fIndYmin + fBDY );
b22af1bf 84#endif
00d07bcd 85 fIh = fHitYfst;
86 }
4687b8fc 87
b22af1bf 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 h->SetY( y0 + tracker.HitDataY( row, fIh ) * stepY );
4acc2401 94 h->SetZ( z0 + tracker.HitDataZ( row, fIh ) * stepZ );
b22af1bf 95#endif
fbb9b71b 96
4acc2401 97 if ( 1 && ( h->Z() > fMaxZ || h->Z() < fMinZ || h->Y() < fMinY || h->Y() > fMaxY ) ) { //SG!!!
00d07bcd 98 fIh++;
99 continue;
100 }
101 ret = fIh;
102 fIh++;
103 break;
fbb9b71b 104 } while ( 1 );
105 return ret;
00d07bcd 106}
107
108
4acc2401 109/*
110int AliHLTTPCCAHitArea::GetBest( const AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row,
111 const int *content, AliHLTTPCCAHit *h)
00d07bcd 112{
113 // get closest hit in the area
fbb9b71b 114 int best = -1;
115 float ds = 1.e10;
116 do {
00d07bcd 117 AliHLTTPCCAHit hh;
fbb9b71b 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 ) {
00d07bcd 124 ds = dds;
125 best = ih;
126 h = hh;
127 }
fbb9b71b 128 } while ( 1 );
00d07bcd 129
130 return best;
131}
4acc2401 132*/