]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCAGrid.cxx
wrong #ifdef removed
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAGrid.cxx
CommitLineData
d54804bf 1// $Id$
ce565086 2// **************************************************************************
fbb9b71b 3// This file is property of and copyright by the ALICE HLT Project *
d54804bf 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. *
ce565086 17// *
d54804bf 18//***************************************************************************
19
ce565086 20
21
d54804bf 22#include "AliHLTTPCCAGrid.h"
00d07bcd 23#include "AliHLTTPCCAMath.h"
7be9b0d7 24
25#ifndef assert
4acc2401 26#include <assert.h>
7be9b0d7 27#endif
28
59a3711a 29#include <iostream>
d54804bf 30
4acc2401 31GPUd() void AliHLTTPCCAGrid::CreateEmpty()
d54804bf 32{
b22af1bf 33 //Create an empty grid
4acc2401 34 fYMin = 0.f;
35 fYMax = 1.f;
36 fZMin = 0.f;
37 fZMax = 1.f;
fbb9b71b 38
4acc2401 39 fNy = 0;
40 fNz = 0;
41 fN = 0;
42
43 fStepYInv = 1.f;
44 fStepZInv = 1.f;
d54804bf 45}
46
4acc2401 47
fbb9b71b 48GPUd() void AliHLTTPCCAGrid::Create( float yMin, float yMax, float zMin, float zMax, float sy, float sz )
d54804bf 49{
00d07bcd 50 //* Create the grid
4acc2401 51 fYMin = yMin;
52 fZMin = zMin;
00d07bcd 53
4acc2401 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;
fbb9b71b 61
fbb9b71b 62 fYMax = fYMin + fNy * sy;
63 fZMax = fZMin + fNz * sz;
d54804bf 64}
65
4acc2401 66
67GPUd() int AliHLTTPCCAGrid::GetBin( float Y, float Z ) const
d54804bf 68{
00d07bcd 69 //* get the bin pointer
4acc2401 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;
7be9b0d7 73#ifndef HLTCA_GPUCODE
4acc2401 74 assert( bin >= 0 );
75 assert( bin < static_cast<int>( fN ) );
7be9b0d7 76#endif
4acc2401 77 return bin;
78}
fbb9b71b 79
4acc2401 80int 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;
d54804bf 89}
90
b22af1bf 91GPUd() void AliHLTTPCCAGrid::GetBin( float Y, float Z, int* const bY, int* const bZ ) const
d54804bf 92{
93 //* get the bin pointer
94
fbb9b71b 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;
4acc2401 102 *bY = ( unsigned int ) bbY;
103 *bZ = ( unsigned int ) bbZ;
d54804bf 104}