]>
Commit | Line | Data |
---|---|---|
63d8b79d | 1 | //-*- Mode: C++ -*- |
2 | // ************************************************************************ | |
fbb9b71b | 3 | // This file is property of and copyright by the ALICE HLT Project * |
63d8b79d | 4 | // ALICE Experiment at CERN, All rights reserved. * |
5 | // See cxx source for full Copyright notice * | |
6 | // * | |
7 | //************************************************************************* | |
8 | ||
9 | #ifndef ALIHLTTPCCADATACOMPRESSOR_H | |
10 | #define ALIHLTTPCCADATACOMPRESSOR_H | |
11 | ||
12 | #include "AliHLTTPCCADef.h" | |
70e4a065 | 13 | #include "AliHLTTPCCACompressedInputData.h" |
63d8b79d | 14 | |
15 | /** | |
16 | * @class AliHLTTPCCADataCompressor | |
17 | * | |
18 | * The AliHLTTPCCADataCompressor class is used to | |
19 | * pack and unpack diffferent data, such as TPC cluster IDs, posistion, amplitude etc | |
20 | * | |
21 | */ | |
22 | class AliHLTTPCCADataCompressor | |
23 | { | |
fbb9b71b | 24 | public: |
63d8b79d | 25 | |
fbb9b71b | 26 | GPUhd() static unsigned int IRowIClu2IDrc( unsigned int iRow, unsigned int iCluster ) { |
27 | return ( iCluster << 8 ) + iRow; | |
28 | } | |
63d8b79d | 29 | |
fbb9b71b | 30 | GPUhd() static unsigned int IDrc2IRow( unsigned int IDrc ) { return ( IDrc % 256 ); } |
31 | GPUhd() static unsigned int IDrc2IClu( unsigned int IDrc ) { return ( IDrc >> 8 ); } | |
63d8b79d | 32 | |
63d8b79d | 33 | |
fbb9b71b | 34 | GPUhd() static unsigned int ISliceIRowIClu2IDsrc( unsigned int iSlice, unsigned int iRow, unsigned int iCluster ) { |
35 | return ( iCluster << 14 ) + ( iRow << 6 ) + iSlice; | |
36 | } | |
63d8b79d | 37 | |
fbb9b71b | 38 | GPUhd() static unsigned int IDsrc2ISlice( unsigned int IDsrc ) { return ( IDsrc % 64 ); } |
39 | GPUhd() static unsigned int IDsrc2IRow ( unsigned int IDsrc ) { return ( ( IDsrc >> 6 ) % 256 ); } | |
40 | GPUhd() static unsigned int IDsrc2IClu ( unsigned int IDsrc ) { return ( IDsrc >> 14 ); } | |
41 | ||
42 | ||
43 | GPUhd() static unsigned short YZ2UShort( float Y, float Z ); | |
44 | GPUhd() static float UShort2Y ( unsigned short iYZ ); | |
45 | GPUhd() static float UShort2Z ( unsigned short iYZ ); | |
63d8b79d | 46 | |
70e4a065 | 47 | static AliHLTTPCCACompressedCluster PackXYZ( int iRow, float X, float Y, float Z ) |
48 | { | |
49 | // pack the cluster | |
50 | ||
51 | // get coordinates in [um] | |
52 | ||
7f7a3f9d | 53 | Double_t rowX = GetRowX( iRow ); |
70e4a065 | 54 | |
55 | Double_t x = (X - rowX )*1.e4 + 32768.; | |
56 | Double_t y = Y*1.e4 + 8388608.; | |
57 | Double_t z = Z*1.e4 + 8388608.; | |
58 | ||
59 | // truncate if necessary | |
60 | if( x<0 ) x = 0; else if( x > 0x0000FFFF ) x = 0x0000FFFF; | |
61 | if( y<0 ) y = 0; else if( y > 0x00FFFFFF ) y = 0x00FFFFFF; | |
62 | if( z<0 ) z = 0; else if( z > 0x00FFFFFF ) z = 0x00FFFFFF; | |
63 | ||
64 | UInt_t ix0 = ( (UInt_t) x )&0x000000FF; | |
65 | UInt_t ix1 = (( (UInt_t) x )&0x0000FF00 )>>8; | |
66 | UInt_t iy = ( (UInt_t) y )&0x00FFFFFF; | |
67 | UInt_t iz = ( (UInt_t) z )&0x00FFFFFF; | |
68 | ||
69 | AliHLTTPCCACompressedCluster ret; | |
70 | ret.fP0 = (ix0<<24) + iy; | |
71 | ret.fP1 = (ix1<<24) + iz; | |
72 | return ret; | |
73 | } | |
74 | ||
75 | static void UnpackXYZ( int iRow, AliHLTTPCCACompressedCluster C, float &X, float &Y, float &Z ) | |
76 | { | |
7f7a3f9d | 77 | Double_t rowX = GetRowX( iRow ); |
70e4a065 | 78 | |
79 | UInt_t ix0 = C.fP0 >>24; | |
80 | UInt_t ix1 = C.fP1 >>24; | |
2fba026d | 81 | X = (float) ((ix1<<8) + ix0); |
82 | Y = (float) (C.fP0 & 0x00FFFFFF); | |
83 | Z = (float) (C.fP1 & 0x00FFFFFF); | |
84 | X = (float) ((X - 32768.)*1.e-4 + rowX); | |
85 | Y = (float) ((Y - 8388608.)*1.e-4); | |
86 | Z = (float) ((Z - 8388608.)*1.e-4); | |
70e4a065 | 87 | } |
88 | ||
7f7a3f9d | 89 | static float GetRowX( int iRow ){ |
90 | const float fgX[159] = | |
2fba026d | 91 | { 85.195f, |
92 | 85.945f, | |
93 | 86.695f, | |
94 | 87.445f, | |
95 | 88.195f, | |
96 | 88.945f, | |
97 | 89.695f, | |
98 | 90.445f, | |
99 | 91.195f, | |
100 | 91.945f, | |
101 | 92.695f, | |
102 | 93.445f, | |
103 | 94.195f, | |
104 | 94.945f, | |
105 | 95.695f, | |
106 | 96.445f, | |
107 | 97.195f, | |
108 | 97.945f, | |
109 | 98.695f, | |
110 | 99.445f, | |
111 | 100.195f, | |
112 | 100.945f, | |
113 | 101.695f, | |
114 | 102.445f, | |
115 | 103.195f, | |
116 | 103.945f, | |
117 | 104.695f, | |
118 | 105.445f, | |
119 | 106.195f, | |
120 | 106.945f, | |
121 | 107.695f, | |
122 | 108.445f, | |
123 | 109.195f, | |
124 | 109.945f, | |
125 | 110.695f, | |
126 | 111.445f, | |
127 | 112.195f, | |
128 | 112.945f, | |
129 | 113.695f, | |
130 | 114.445f, | |
131 | 115.195f, | |
132 | 115.945f, | |
133 | 116.695f, | |
134 | 117.445f, | |
135 | 118.195f, | |
136 | 118.945f, | |
137 | 119.695f, | |
138 | 120.445f, | |
139 | 121.195f, | |
140 | 121.945f, | |
141 | 122.695f, | |
142 | 123.445f, | |
143 | 124.195f, | |
144 | 124.945f, | |
145 | 125.695f, | |
146 | 126.445f, | |
147 | 127.195f, | |
148 | 127.945f, | |
149 | 128.695f, | |
150 | 129.445f, | |
151 | 130.195f, | |
152 | 130.945f, | |
153 | 131.695f, | |
154 | 135.180f, | |
155 | 136.180f, | |
156 | 137.180f, | |
157 | 138.180f, | |
158 | 139.180f, | |
159 | 140.180f, | |
160 | 141.180f, | |
161 | 142.180f, | |
162 | 143.180f, | |
163 | 144.180f, | |
164 | 145.180f, | |
165 | 146.180f, | |
166 | 147.180f, | |
167 | 148.180f, | |
168 | 149.180f, | |
169 | 150.180f, | |
170 | 151.180f, | |
171 | 152.180f, | |
172 | 153.180f, | |
173 | 154.180f, | |
174 | 155.180f, | |
175 | 156.180f, | |
176 | 157.180f, | |
177 | 158.180f, | |
178 | 159.180f, | |
179 | 160.180f, | |
180 | 161.180f, | |
181 | 162.180f, | |
182 | 163.180f, | |
183 | 164.180f, | |
184 | 165.180f, | |
185 | 166.180f, | |
186 | 167.180f, | |
187 | 168.180f, | |
188 | 169.180f, | |
189 | 170.180f, | |
190 | 171.180f, | |
191 | 172.180f, | |
192 | 173.180f, | |
193 | 174.180f, | |
194 | 175.180f, | |
195 | 176.180f, | |
196 | 177.180f, | |
197 | 178.180f, | |
198 | 179.180f, | |
199 | 180.180f, | |
200 | 181.180f, | |
201 | 182.180f, | |
202 | 183.180f, | |
203 | 184.180f, | |
204 | 185.180f, | |
205 | 186.180f, | |
206 | 187.180f, | |
207 | 188.180f, | |
208 | 189.180f, | |
209 | 190.180f, | |
210 | 191.180f, | |
211 | 192.180f, | |
212 | 193.180f, | |
213 | 194.180f, | |
214 | 195.180f, | |
215 | 196.180f, | |
216 | 197.180f, | |
217 | 198.180f, | |
218 | 199.430f, | |
219 | 200.930f, | |
220 | 202.430f, | |
221 | 203.930f, | |
222 | 205.430f, | |
223 | 206.930f, | |
224 | 208.430f, | |
225 | 209.930f, | |
226 | 211.430f, | |
227 | 212.930f, | |
228 | 214.430f, | |
229 | 215.930f, | |
230 | 217.430f, | |
231 | 218.930f, | |
232 | 220.430f, | |
233 | 221.930f, | |
234 | 223.430f, | |
235 | 224.930f, | |
236 | 226.430f, | |
237 | 227.930f, | |
238 | 229.430f, | |
239 | 230.930f, | |
240 | 232.430f, | |
241 | 233.930f, | |
242 | 235.430f, | |
243 | 236.930f, | |
244 | 238.430f, | |
245 | 239.930f, | |
246 | 241.430f, | |
247 | 242.930f, | |
248 | 244.430f, | |
249 | 245.930f }; | |
7f7a3f9d | 250 | return fgX[iRow]; |
251 | } | |
252 | ||
63d8b79d | 253 | }; |
254 | ||
255 | ||
256 | // Inline methods | |
257 | ||
258 | ||
fbb9b71b | 259 | GPUhd() inline unsigned short AliHLTTPCCADataCompressor::YZ2UShort( float Y, float Z ) |
260 | { | |
63d8b79d | 261 | // compress Y and Z coordinates in range [-3., 3.] to 16 bits |
262 | ||
fbb9b71b | 263 | const float kMult = 255. / 6.; |
7be9b0d7 | 264 | Y = ( Y + 3.f ) * kMult; |
265 | Z = ( Z + 3.f ) * kMult; | |
fbb9b71b | 266 | if ( Y < 0. ) Y = 0.; |
267 | else if ( Y > 255. ) Y = 255.; | |
268 | if ( Z < 0. ) Z = 0.; | |
269 | else if ( Z > 255. ) Z = 255.; | |
270 | return static_cast<unsigned short>( ( static_cast<unsigned int>( Y ) << 8 ) + static_cast<unsigned int>( Z ) ); | |
271 | } | |
272 | ||
273 | GPUhd() inline float AliHLTTPCCADataCompressor::UShort2Y( unsigned short iYZ ) | |
274 | { | |
63d8b79d | 275 | // extract Y coordinate from the compressed 16bits format to [-3.,3.] |
276 | ||
7be9b0d7 | 277 | const float kMult = 6.f / 255.f; |
278 | return ( iYZ >> 8 )*kMult - 3.f; | |
fbb9b71b | 279 | } |
63d8b79d | 280 | |
fbb9b71b | 281 | GPUhd() inline float AliHLTTPCCADataCompressor::UShort2Z( unsigned short iYZ ) |
282 | { | |
63d8b79d | 283 | // extract Z coordinate from the compressed 16bits format to [-3.,3.] |
284 | ||
7be9b0d7 | 285 | const float kMult = 6.f / 255.f; |
286 | return ( iYZ % 256 )*kMult - 3.f; | |
63d8b79d | 287 | } |
288 | ||
31649d4b | 289 | #endif //ALIHLTTPCCADATACOMPRESSOR_H |