Line data Source code
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 0 : fYMin = 0.f;
37 0 : fYMax = 1.f;
38 0 : fZMin = 0.f;
39 0 : fZMax = 1.f;
40 :
41 0 : fNy = 0;
42 0 : fNz = 0;
43 0 : fN = 0;
44 :
45 0 : fStepYInv = 1.f;
46 0 : fStepZInv = 1.f;
47 0 : }
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 0 : fYMin = yMin;
54 0 : fZMin = zMin;
55 :
56 0 : fStepYInv = 1.f / sy;
57 0 : fStepZInv = 1.f / sz;
58 :
59 0 : fNy = static_cast<unsigned int>( ( yMax - fYMin ) * fStepYInv + 1.f );
60 0 : fNz = static_cast<unsigned int>( ( zMax - fZMin ) * fStepZInv + 1.f );
61 :
62 0 : fN = fNy * fNz;
63 :
64 0 : fYMax = fYMin + fNy * sy;
65 0 : fZMax = fZMin + fNz * sz;
66 0 : }
67 :
68 :
69 : GPUdi() int AliHLTTPCCAGrid::GetBin( float Y, float Z ) const
70 : {
71 : //* get the bin pointer
72 0 : const int yBin = static_cast<int>( CAMath::FMulRZ( Y - fYMin, fStepYInv ) );
73 0 : const int zBin = static_cast<int>( CAMath::FMulRZ( Z - fZMin, fStepZInv ) );
74 0 : const int bin = CAMath::Mul24( zBin, fNy ) + yBin;
75 : #ifndef HLTCA_GPUCODE
76 0 : assert( bin >= 0 );
77 0 : assert( bin < static_cast<int>( fN ) );
78 : #endif
79 0 : return bin;
80 : }
81 :
82 : GPUdi() int AliHLTTPCCAGrid::GetBinBounded( float Y, float Z ) const
83 : {
84 : //* get the bin pointer
85 0 : const int yBin = static_cast<int>( CAMath::FMulRZ( Y - fYMin, fStepYInv ) );
86 0 : const int zBin = static_cast<int>( CAMath::FMulRZ( Z - fZMin, fStepZInv ) );
87 0 : const int bin = CAMath::Mul24( zBin, fNy ) + yBin;
88 0 : if ( bin < 0 ) return 0;
89 0 : if ( bin >= static_cast<int>( fN ) ) return fN - 1;
90 0 : return bin;
91 0 : }
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 0 : int bbY = ( int ) ( ( Y - fYMin ) * fStepYInv );
98 0 : int bbZ = ( int ) ( ( Z - fZMin ) * fStepZInv );
99 :
100 0 : if ( bbY < 0 ) bbY = 0;
101 0 : else if ( bbY >= ( int )fNy ) bbY = fNy - 1;
102 0 : if ( bbZ < 0 ) bbZ = 0;
103 0 : else if ( bbZ >= ( int )fNz ) bbZ = fNz - 1;
104 0 : *bY = ( unsigned int ) bbY;
105 0 : *bZ = ( unsigned int ) bbZ;
106 0 : }
|