]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCAGrid.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 / AliHLTTPCCAGrid.cxx
1 // $Id$
2 // **************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project          *
4 // ALICE Experiment at CERN, All rights reserved.                           *
5 //                                                                          *
6 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7 //                  Ivan Kisel <kisel@kip.uni-heidelberg.de>                *
8 //                  for The ALICE HLT Project.                              *
9 //                                                                          *
10 // Permission to use, copy, modify and distribute this software and its     *
11 // documentation strictly for non-commercial purposes is hereby granted     *
12 // without fee, provided that the above copyright notice appears in all     *
13 // copies and that both the copyright notice and this permission notice     *
14 // appear in the supporting documentation. The authors make no claims       *
15 // about the suitability of this software for any purpose. It is            *
16 // provided "as is" without express or implied warranty.                    *
17 //                                                                          *
18 //***************************************************************************
19
20
21
22 #include "AliHLTTPCCAGrid.h"
23 #include "AliHLTTPCCAMath.h"
24
25 #ifndef assert
26 #include <assert.h>
27 #endif
28
29 #if !defined(__OPENCL__) || defined(HLTCA_HOSTCODE)
30 #include <iostream>
31 #endif
32
33 GPUdi() void AliHLTTPCCAGrid::CreateEmpty()
34 {
35   //Create an empty grid
36   fYMin = 0.f;
37   fYMax = 1.f;
38   fZMin = 0.f;
39   fZMax = 1.f;
40
41   fNy = 0;
42   fNz = 0;
43   fN = 0;
44
45   fStepYInv = 1.f;
46   fStepZInv = 1.f;
47 }
48
49
50 GPUdi() void AliHLTTPCCAGrid::Create( float yMin, float yMax, float zMin, float zMax, float sy, float sz )
51 {
52   //* Create the grid
53   fYMin = yMin;
54   fZMin = zMin;
55
56   fStepYInv = 1.f / sy;
57   fStepZInv = 1.f / sz;
58
59   fNy = static_cast<unsigned int>( ( yMax - fYMin ) * fStepYInv + 1.f );
60   fNz = static_cast<unsigned int>( ( zMax - fZMin ) * fStepZInv + 1.f );
61
62   fN = fNy * fNz;
63
64   fYMax = fYMin + fNy * sy;
65   fZMax = fZMin + fNz * sz;
66 }
67
68
69 GPUdi() int AliHLTTPCCAGrid::GetBin( float Y, float Z ) const
70 {
71   //* get the bin pointer
72   const int yBin = static_cast<int>( CAMath::FMulRZ( Y - fYMin, fStepYInv ) );
73   const int zBin = static_cast<int>( CAMath::FMulRZ( Z - fZMin, fStepZInv ) );
74   const int bin = CAMath::Mul24( zBin, fNy ) + yBin;
75 #ifndef HLTCA_GPUCODE
76   assert( bin >= 0 );
77   assert( bin < static_cast<int>( fN ) );
78 #endif
79   return bin;
80 }
81
82 GPUdi() int AliHLTTPCCAGrid::GetBinBounded( float Y, float Z ) const
83 {
84   //* get the bin pointer
85   const int yBin = static_cast<int>( CAMath::FMulRZ( Y - fYMin, fStepYInv ) );
86   const int zBin = static_cast<int>( CAMath::FMulRZ( Z - fZMin, fStepZInv ) );
87   const int bin = CAMath::Mul24( zBin, fNy ) + yBin;
88   if ( bin < 0 ) return 0;
89   if ( bin >= static_cast<int>( fN ) ) return fN - 1;
90   return bin;
91 }
92
93 GPUdi() void AliHLTTPCCAGrid::GetBin( float Y, float Z, int* const bY, int* const bZ ) const
94 {
95   //* get the bin pointer
96
97   int bbY = ( int ) ( ( Y - fYMin ) * fStepYInv );
98   int bbZ = ( int ) ( ( Z - fZMin ) * fStepZInv );
99
100   if ( bbY < 0 ) bbY = 0;
101   else if ( bbY >= ( int )fNy ) bbY = fNy - 1;
102   if ( bbZ < 0 ) bbZ = 0;
103   else if ( bbZ >= ( int )fNz ) bbZ = fNz - 1;
104   *bY = ( unsigned int ) bbY;
105   *bZ = ( unsigned int ) bbZ;
106 }