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. *
17 //***************************************************************************
19 #include "AliHLTTPCCAGrid.h"
22 AliHLTTPCCAGrid::AliHLTTPCCAGrid(const AliHLTTPCCAGrid&)
23 :fGrid(0),fNy(0),fNz(0),fN(0),
24 fYMin(0),fYMax(0),fZMin(0),fZMax(0),fStepYInv(0),fStepZInv(0)
29 AliHLTTPCCAGrid& AliHLTTPCCAGrid::operator=(const AliHLTTPCCAGrid&)
35 void AliHLTTPCCAGrid::Create( Float_t yMin, Float_t yMax, Float_t zMin, Float_t zMax, Int_t n )
39 fYMin = TMath::Min(yMin,yMax);
40 fYMax = TMath::Max(yMin,yMax);
41 fZMin = TMath::Min(zMin,zMax);
42 fZMax = TMath::Max(zMin,zMax);
43 fNy = fNz = (Int_t) TMath::Sqrt( (Float_t) n );
44 fNy = TMath::Max(fNy,1);
45 fNz = TMath::Max(fNz,1);
47 if( fGrid ) delete[] fGrid;
48 fGrid = new void*[fN];
49 for( Int_t i=0; i<fN; i++ ) fGrid[i] = 0;
50 fStepYInv = (fYMax - fYMin);
51 fStepZInv = (fZMax - fZMin);
52 fStepYInv = ( fStepYInv>1.e-4 ) ?(fNy-1)/fStepYInv :0;
53 fStepZInv = ( fStepZInv>1.e-4 ) ?(fNz-1)/fStepZInv :0;
56 void **AliHLTTPCCAGrid::Get( Float_t Y, Float_t Z ) const
58 //* get the bin pointer
60 Int_t yBin = (Int_t) ( (Y-fYMin)*fStepYInv );
61 Int_t zBin = (Int_t) ( (Z-fZMin)*fStepZInv );
62 if( yBin<0 ) yBin = 0;
63 else if( yBin>=fNy ) yBin = fNy - 1;
64 if( zBin<0 ) zBin = 0;
65 else if( zBin>=fNz ) zBin = fNz - 1;
66 return fGrid + zBin*fNy + yBin;