StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AliHLTTPCCAGrid.h
1 //-*- Mode: C++ -*-
2 // $Id: AliHLTTPCCAGrid.h,v 1.1 2016/02/05 23:27:27 fisyak Exp $
3 // ************************************************************************
4 // This file is property of and copyright by the ALICE HLT Project *
5 // ALICE Experiment at CERN, All rights reserved. *
6 // See cxx source for full Copyright notice *
7 // *
8 //*************************************************************************
9 
10 #ifndef ALIHLTTPCCAGRID_H
11 #define ALIHLTTPCCAGRID_H
12 
13 #include "AliHLTTPCCADef.h"
14 #include "AliHLTTPCCAMath.h"
15 
25  public:
26  void CreateEmpty();
27  void Create1( float y, float z, float sy, float sz );
28  void Create( float yMin, float yMax, float zMin, float zMax, float sy, float sz );
29 
30  int GetBin( float Y, float Z ) const;
34  ushort_v GetBinBounded( const sfloat_v &Y, const sfloat_v &Z ) const;
35  void GetBinBounded( const sfloat_v &Y, const sfloat_v &Z, ushort_v *bY, ushort_v *bZ ) const;
36 
37  static ushort_v GetBinBounded( const AliHLTTPCCAGrid *array, const ushort_v &indexes, const sfloat_v &Y, const sfloat_v &Z );
38  static void GetBinBounded( const AliHLTTPCCAGrid *array, const ushort_v &indexes, const sfloat_v &Y, const sfloat_v &Z, ushort_v *bY, ushort_v *bZ );
39  static ushort_v Ny( const AliHLTTPCCAGrid *array, const ushort_v &indexes ) { return ushort_v( array, &AliHLTTPCCAGrid::fNy, indexes ); }
40 
41  void GetBinBounds( int iBin, float &Ymin, float &Ymax, float &Zmin, float &Zmax) const;
42 
43  unsigned int N() const { return fN; }
44  unsigned short Ny() const { return fNy; }
45  unsigned short Nz() const { return fNz; }
46 
47  private:
48 
49  unsigned int fN; //* total N bins
50  unsigned short fNy; //* N bins in Y
51  unsigned short fNz; //* N bins in Z
52  float fYMinOverStep; //* minimal Y value * fStepYInv
53  float fZMinOverStep; //* minimal Z value * fStepZInv
54  float fStepYInv; //* inverse bin size in Y
55  float fStepZInv; //* inverse bin size in Z
56 };
57 
58 inline ushort_v AliHLTTPCCAGrid::GetBinBounded( const AliHLTTPCCAGrid *array, const ushort_v &indexes, const sfloat_v &Y, const sfloat_v &Z )
59 {
60 // const sfloat_v fZMinOverStep( array, &AliHLTTPCCAGrid::fZMinOverStep, indexes );
61 // const sfloat_v fStepZInv( array, &AliHLTTPCCAGrid::fStepZInv, indexes );
62 // const ushort_v fNz( array, &AliHLTTPCCAGrid::fNz, indexes );
63 // ushort_v zBin = ( Z * fStepZInv - fZMinOverStep ).staticCast<unsigned short>();
64 // zBin = CAMath::Max( ushort_v( Vc::Zero ), CAMath::Min( ushort_v( fNz - 1 ), zBin ) );
65 //
66 // const sfloat_v fYMinOverStep( array, &AliHLTTPCCAGrid::fYMinOverStep, indexes );
67 // const sfloat_v fStepYInv( array, &AliHLTTPCCAGrid::fStepYInv, indexes );
68 // const ushort_v fNy( array, &AliHLTTPCCAGrid::fNy, indexes );
69 // ushort_v yBin = ( Y * fStepYInv - fYMinOverStep ).staticCast<unsigned short>();
70 // yBin = CAMath::Max( ushort_v( Vc::Zero ), CAMath::Min( ushort_v( fNy - 1 ), yBin ) );
71 
72  const sfloat_v fZMinOverStep( array, &AliHLTTPCCAGrid::fZMinOverStep, indexes );
73  const sfloat_v fStepZInv( array, &AliHLTTPCCAGrid::fStepZInv, indexes );
74  const ushort_v fNz( array, &AliHLTTPCCAGrid::fNz, indexes );
75  short_v zBin = ( Z * fStepZInv - fZMinOverStep ).staticCast<short_v>();
76  ushort_v zBin2 = CAMath::Max( short_v( Vc::Zero ), CAMath::Min( short_v( fNz - 1 ), zBin ) ).staticCast<ushort_v>();
77 
78  const sfloat_v fYMinOverStep( array, &AliHLTTPCCAGrid::fYMinOverStep, indexes );
79  const sfloat_v fStepYInv( array, &AliHLTTPCCAGrid::fStepYInv, indexes );
80  const ushort_v fNy( array, &AliHLTTPCCAGrid::fNy, indexes );
81  short_v yBin = ( Y * fStepYInv - fYMinOverStep ).staticCast<short_v>();
82  ushort_v yBin2 = CAMath::Max( short_v( Vc::Zero ), CAMath::Min( short_v( fNy - 1 ), yBin ) ).staticCast<ushort_v>();
83  return zBin2 * fNy + yBin2;
84 }
85 
86 inline void AliHLTTPCCAGrid::GetBinBounded( const AliHLTTPCCAGrid *array, const ushort_v &indexes, const sfloat_v &Y, const sfloat_v &Z, ushort_v *bY, ushort_v *bZ )
87 {
88 // const sfloat_v fYMinOverStep( array, &AliHLTTPCCAGrid::fYMinOverStep, indexes );
89 // const sfloat_v fStepYInv( array, &AliHLTTPCCAGrid::fStepYInv, indexes );
90 // const ushort_v fNy( array, &AliHLTTPCCAGrid::fNy, indexes );
91 // const ushort_v &yBin = ( Y * fStepYInv - fYMinOverStep ).staticCast<unsigned short>();
92 // *bY = CAMath::Max( ushort_v( Vc::Zero ), CAMath::Min( fNy - 1, yBin ) );
93 //
94 // const sfloat_v fZMinOverStep( array, &AliHLTTPCCAGrid::fZMinOverStep, indexes );
95 // const sfloat_v fStepZInv( array, &AliHLTTPCCAGrid::fStepZInv, indexes );
96 // const ushort_v fNz( array, &AliHLTTPCCAGrid::fNz, indexes );
97 // const ushort_v &zBin = ( Z * fStepZInv - fZMinOverStep ).staticCast<unsigned short>();
98 // *bZ = CAMath::Max( ushort_v( Vc::Zero ), CAMath::Min( fNz - 1, zBin ) );
99 
100  const sfloat_v fYMinOverStep( array, &AliHLTTPCCAGrid::fYMinOverStep, indexes );
101  const sfloat_v fStepYInv( array, &AliHLTTPCCAGrid::fStepYInv, indexes );
102  const ushort_v fNy( array, &AliHLTTPCCAGrid::fNy, indexes );
103  const short_v fNy2 = fNy.staticCast<short_v>();
104  const short_v &yBin = ( Y * fStepYInv - fYMinOverStep ).staticCast<short_v>();
105  *bY = CAMath::Max( short_v( Vc::Zero ), CAMath::Min( fNy2 - 1, yBin ) ).staticCast<ushort_v>();
106 
107  const sfloat_v fZMinOverStep( array, &AliHLTTPCCAGrid::fZMinOverStep, indexes );
108  const sfloat_v fStepZInv( array, &AliHLTTPCCAGrid::fStepZInv, indexes );
109  const ushort_v fNz( array, &AliHLTTPCCAGrid::fNz, indexes );
110  const short_v fNz2 = fNz.staticCast<short_v>();
111  const short_v &zBin = ( Z * fStepZInv - fZMinOverStep ).staticCast<short_v>();
112  *bZ = CAMath::Max( short_v( Vc::Zero ), CAMath::Min( fNz2 - 1, zBin ) ).staticCast<ushort_v>();
113 }
114 
115 inline ushort_v AliHLTTPCCAGrid::GetBinBounded( const sfloat_v &Y, const sfloat_v &Z ) const
116 {
117  //* get the bin pointer
118 
119  ushort_v yBin, zBin;
120  GetBinBounded( Y, Z, &yBin, &zBin );
121  return zBin * fNy + yBin;
122 
123  // XXX: the code below can wrap incorrectly because saturation is only done after
124  // calculation of bin:
125 //X const ushort_v &yBin = ( Y * fStepYInv - fYMinOverStep ).staticCast<unsigned short>();
126 //X const ushort_v &zBin = ( Z * fStepZInv - fZMinOverStep ).staticCast<unsigned short>();
127 //X const ushort_v &bin = zBin * fNy + yBin;
128 //X
129 //X return CAMath::Max( ushort_v( Vc::Zero ), CAMath::Min( ushort_v( fN - 1 ), bin ) );
130 }
131 
132 inline void AliHLTTPCCAGrid::GetBinBounded( const sfloat_v &Y, const sfloat_v &Z, ushort_v *bY, ushort_v *bZ ) const
133 {
134  //* get the bin pointer
135 
136 // const ushort_v &yBin = ( Y * fStepYInv - fYMinOverStep ).staticCast<unsigned short>();
137 // const ushort_v &zBin = ( Z * fStepZInv - fZMinOverStep ).staticCast<unsigned short>();
138 //
139 // *bY = CAMath::Max( ushort_v( Vc::Zero ), CAMath::Min( ushort_v( fNy - 1 ), yBin ) );
140 // *bZ = CAMath::Max( ushort_v( Vc::Zero ), CAMath::Min( ushort_v( fNz - 1 ), zBin ) );
141 // IKu bag was here : -1 = 65000 > 0 !
142 
143  const short_v &yBin = ( Y * fStepYInv - fYMinOverStep ).staticCast<short_v>();
144  const short_v &zBin = ( Z * fStepZInv - fZMinOverStep ).staticCast<short_v>();
145 
146  *bY = CAMath::Max( short_v( Vc::Zero ), CAMath::Min( short_v( fNy - 1 ), yBin ) ).staticCast<ushort_v>();
147  *bZ = CAMath::Max( short_v( Vc::Zero ), CAMath::Min( short_v( fNz - 1 ), zBin ) ).staticCast<ushort_v>();
148 
149 }
150 
151 #endif
ushort_v GetBinBounded(const sfloat_v &Y, const sfloat_v &Z) const