]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/TPCLib/tracking-ca/AliHLTTPCCAHitArea.cxx
bug fix: reconstruction crash when the output buffer size exceed
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAHitArea.cxx
... / ...
CommitLineData
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"
23class AliHLTTPCCARow;
24
25
26GPUd() void AliHLTTPCCAHitArea::Init( const AliHLTTPCCARow &row, const AliHLTTPCCASliceData &slice, float y, float z,
27 float dy, float dz )
28{
29 //initialisation
30 const AliHLTTPCCAGrid &grid = row.Grid();
31 fHitOffset = row.HitNumberOffset();
32 fY = y;
33 fZ = z;
34 fMinZ = z - dz;
35 fMaxZ = z + dz;
36 fMinY = y - dy;
37 fMaxY = y + dy;
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
42 fNy = grid.Ny();
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
45 fIz = bZmin;
46
47 // for given fIz (which is min atm.) get
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
52 fHitYfst = slice.FirstHitInBin( row, fIndYmin ); // first and
53 fHitYlst = slice.FirstHitInBin( row, fIndYmin + fBDY ); // last hit index in the bin
54#endif
55 fIh = fHitYfst;
56}
57
58GPUd() int AliHLTTPCCAHitArea::GetNext( const AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row,
59 const AliHLTTPCCASliceData &slice, AliHLTTPCCAHit *h )
60{
61 // get next hit index
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();
70
71 int ret = -1;
72 do {
73 while ( fIh >= fHitYlst ) {
74 if ( fIz >= fBZmax ) {
75 return -1;
76 }
77 // go to next z and start y from the min again
78 ++fIz;
79 fIndYmin += fNy;
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
84 fHitYfst = slice.FirstHitInBin( row, fIndYmin );
85 fHitYlst = slice.FirstHitInBin( row, fIndYmin + fBDY );
86#endif
87 fIh = fHitYfst;
88 }
89
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 );
96 h->SetZ( z0 + tracker.HitDataZ( row, fIh ) * stepZ );
97#endif
98
99 if ( 1 && ( h->Z() > fMaxZ || h->Z() < fMinZ || h->Y() < fMinY || h->Y() > fMaxY ) ) { //SG!!!
100 fIh++;
101 continue;
102 }
103 ret = fIh;
104 fIh++;
105 break;
106 } while ( 1 );
107 return ret;
108}
109
110
111/*
112int AliHLTTPCCAHitArea::GetBest( const AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row,
113 const int *content, AliHLTTPCCAHit *h)
114{
115 // get closest hit in the area
116 int best = -1;
117 float ds = 1.e10;
118 do {
119 AliHLTTPCCAHit hh;
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 ) {
126 ds = dds;
127 best = ih;
128 h = hh;
129 }
130 } while ( 1 );
131
132 return best;
133}
134*/