2 // **************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project *
4 // ALICE Experiment at CERN, All rights reserved. *
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. *
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. *
18 //***************************************************************************
22 #include "AliHLTTPCCAGrid.h"
23 #include "AliHLTTPCCAMath.h"
29 #if !defined(__OPENCL__) || defined(HLTCA_HOSTCODE)
33 GPUdi() void AliHLTTPCCAGrid::CreateEmpty()
35 //Create an empty grid
50 GPUdi() void AliHLTTPCCAGrid::Create( float yMin, float yMax, float zMin, float zMax, float sy, float sz )
59 fNy = static_cast<unsigned int>( ( yMax - fYMin ) * fStepYInv + 1.f );
60 fNz = static_cast<unsigned int>( ( zMax - fZMin ) * fStepZInv + 1.f );
64 fYMax = fYMin + fNy * sy;
65 fZMax = fZMin + fNz * sz;
69 GPUdi() int AliHLTTPCCAGrid::GetBin( float Y, float Z ) const
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;
77 assert( bin < static_cast<int>( fN ) );
82 GPUdi() int AliHLTTPCCAGrid::GetBinBounded( float Y, float Z ) const
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;
93 GPUdi() void AliHLTTPCCAGrid::GetBin( float Y, float Z, int* const bY, int* const bZ ) const
95 //* get the bin pointer
97 int bbY = ( int ) ( ( Y - fYMin ) * fStepYInv );
98 int bbZ = ( int ) ( ( Z - fZMin ) * fStepZInv );
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;