]>
Commit | Line | Data |
---|---|---|
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 | #include <iostream> | |
30 | ||
31 | GPUd() void AliHLTTPCCAGrid::CreateEmpty() | |
32 | { | |
33 | //Create an empty grid | |
34 | fYMin = 0.f; | |
35 | fYMax = 1.f; | |
36 | fZMin = 0.f; | |
37 | fZMax = 1.f; | |
38 | ||
39 | fNy = 0; | |
40 | fNz = 0; | |
41 | fN = 0; | |
42 | ||
43 | fStepYInv = 1.f; | |
44 | fStepZInv = 1.f; | |
45 | } | |
46 | ||
47 | ||
48 | GPUd() void AliHLTTPCCAGrid::Create( float yMin, float yMax, float zMin, float zMax, float sy, float sz ) | |
49 | { | |
50 | //* Create the grid | |
51 | fYMin = yMin; | |
52 | fZMin = zMin; | |
53 | ||
54 | fStepYInv = 1.f / sy; | |
55 | fStepZInv = 1.f / sz; | |
56 | ||
57 | fNy = static_cast<unsigned int>( ( yMax - fYMin ) * fStepYInv + 1.f ); | |
58 | fNz = static_cast<unsigned int>( ( zMax - fZMin ) * fStepZInv + 1.f ); | |
59 | ||
60 | fN = fNy * fNz; | |
61 | ||
62 | fYMax = fYMin + fNy * sy; | |
63 | fZMax = fZMin + fNz * sz; | |
64 | } | |
65 | ||
66 | ||
67 | GPUd() int AliHLTTPCCAGrid::GetBin( float Y, float Z ) const | |
68 | { | |
69 | //* get the bin pointer | |
70 | const int yBin = static_cast<int>( CAMath::FMulRZ( Y - fYMin, fStepYInv ) ); | |
71 | const int zBin = static_cast<int>( CAMath::FMulRZ( Z - fZMin, fStepZInv ) ); | |
72 | const int bin = CAMath::Mul24( zBin, fNy ) + yBin; | |
73 | #ifndef HLTCA_GPUCODE | |
74 | assert( bin >= 0 ); | |
75 | assert( bin < static_cast<int>( fN ) ); | |
76 | #endif | |
77 | return bin; | |
78 | } | |
79 | ||
80 | int AliHLTTPCCAGrid::GetBinBounded( float Y, float Z ) const | |
81 | { | |
82 | //* get the bin pointer | |
83 | const int yBin = static_cast<int>( CAMath::FMulRZ( Y - fYMin, fStepYInv ) ); | |
84 | const int zBin = static_cast<int>( CAMath::FMulRZ( Z - fZMin, fStepZInv ) ); | |
85 | const int bin = CAMath::Mul24( zBin, fNy ) + yBin; | |
86 | if ( bin < 0 ) return 0; | |
87 | if ( bin >= static_cast<int>( fN ) ) return fN - 1; | |
88 | return bin; | |
89 | } | |
90 | ||
91 | GPUd() void AliHLTTPCCAGrid::GetBin( float Y, float Z, int* const bY, int* const bZ ) const | |
92 | { | |
93 | //* get the bin pointer | |
94 | ||
95 | int bbY = ( int ) ( ( Y - fYMin ) * fStepYInv ); | |
96 | int bbZ = ( int ) ( ( Z - fZMin ) * fStepZInv ); | |
97 | ||
98 | if ( bbY < 0 ) bbY = 0; | |
99 | else if ( bbY >= ( int )fNy ) bbY = fNy - 1; | |
100 | if ( bbZ < 0 ) bbZ = 0; | |
101 | else if ( bbZ >= ( int )fNz ) bbZ = fNz - 1; | |
102 | *bY = ( unsigned int ) bbY; | |
103 | *bZ = ( unsigned int ) bbZ; | |
104 | } |