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"
27 GPUd() void AliHLTTPCCAGrid::CreateEmpty()
43 GPUd() void AliHLTTPCCAGrid::Create( float yMin, float yMax, float zMin, float zMax, float sy, float sz )
52 fNy = static_cast<unsigned int>( ( yMax - fYMin ) * fStepYInv + 1.f );
53 fNz = static_cast<unsigned int>( ( zMax - fZMin ) * fStepZInv + 1.f );
57 fYMax = fYMin + fNy * sy;
58 fZMax = fZMin + fNz * sz;
62 GPUd() int AliHLTTPCCAGrid::GetBin( float Y, float Z ) const
64 //* get the bin pointer
65 const int yBin = static_cast<int>( CAMath::FMulRZ( Y - fYMin, fStepYInv ) );
66 const int zBin = static_cast<int>( CAMath::FMulRZ( Z - fZMin, fStepZInv ) );
67 const int bin = CAMath::Mul24( zBin, fNy ) + yBin;
69 assert( bin < static_cast<int>( fN ) );
73 int AliHLTTPCCAGrid::GetBinBounded( float Y, float Z ) const
75 //* get the bin pointer
76 const int yBin = static_cast<int>( CAMath::FMulRZ( Y - fYMin, fStepYInv ) );
77 const int zBin = static_cast<int>( CAMath::FMulRZ( Z - fZMin, fStepZInv ) );
78 const int bin = CAMath::Mul24( zBin, fNy ) + yBin;
79 if ( bin < 0 ) return 0;
80 if ( bin >= static_cast<int>( fN ) ) return fN - 1;
84 GPUd() void AliHLTTPCCAGrid::GetBin( float Y, float Z, int *bY, int *bZ ) const
86 //* get the bin pointer
88 int bbY = ( int ) ( ( Y - fYMin ) * fStepYInv );
89 int bbZ = ( int ) ( ( Z - fZMin ) * fStepZInv );
91 if ( bbY < 0 ) bbY = 0;
92 else if ( bbY >= ( int )fNy ) bbY = fNy - 1;
93 if ( bbZ < 0 ) bbZ = 0;
94 else if ( bbZ >= ( int )fNz ) bbZ = fNz - 1;
95 *bY = ( unsigned int ) bbY;
96 *bZ = ( unsigned int ) bbZ;