2 // ************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project *
4 // ALICE Experiment at CERN, All rights reserved. *
5 // See cxx source for full Copyright notice *
7 //*************************************************************************
9 #ifndef ALIHLTTPCCADATACOMPRESSOR_H
10 #define ALIHLTTPCCADATACOMPRESSOR_H
12 #include "AliHLTTPCCADef.h"
15 * @class AliHLTTPCCADataCompressor
17 * The AliHLTTPCCADataCompressor class is used to
18 * pack and unpack diffferent data, such as TPC cluster IDs, posistion, amplitude etc
21 class AliHLTTPCCADataCompressor
25 GPUhd() static unsigned int IRowIClu2IDrc( unsigned int iRow, unsigned int iCluster ) {
26 return ( iCluster << 8 ) + iRow;
29 GPUhd() static unsigned int IDrc2IRow( unsigned int IDrc ) { return ( IDrc % 256 ); }
30 GPUhd() static unsigned int IDrc2IClu( unsigned int IDrc ) { return ( IDrc >> 8 ); }
33 GPUhd() static unsigned int ISliceIRowIClu2IDsrc( unsigned int iSlice, unsigned int iRow, unsigned int iCluster ) {
34 return ( iCluster << 14 ) + ( iRow << 6 ) + iSlice;
37 GPUhd() static unsigned int IDsrc2ISlice( unsigned int IDsrc ) { return ( IDsrc % 64 ); }
38 GPUhd() static unsigned int IDsrc2IRow ( unsigned int IDsrc ) { return ( ( IDsrc >> 6 ) % 256 ); }
39 GPUhd() static unsigned int IDsrc2IClu ( unsigned int IDsrc ) { return ( IDsrc >> 14 ); }
42 GPUhd() static unsigned short YZ2UShort( float Y, float Z );
43 GPUhd() static float UShort2Y ( unsigned short iYZ );
44 GPUhd() static float UShort2Z ( unsigned short iYZ );
52 GPUhd() inline unsigned short AliHLTTPCCADataCompressor::YZ2UShort( float Y, float Z )
54 // compress Y and Z coordinates in range [-3., 3.] to 16 bits
56 const float kMult = 255. / 6.;
57 Y = ( Y + 3.f ) * kMult;
58 Z = ( Z + 3.f ) * kMult;
60 else if ( Y > 255. ) Y = 255.;
62 else if ( Z > 255. ) Z = 255.;
63 return static_cast<unsigned short>( ( static_cast<unsigned int>( Y ) << 8 ) + static_cast<unsigned int>( Z ) );
66 GPUhd() inline float AliHLTTPCCADataCompressor::UShort2Y( unsigned short iYZ )
68 // extract Y coordinate from the compressed 16bits format to [-3.,3.]
70 const float kMult = 6.f / 255.f;
71 return ( iYZ >> 8 )*kMult - 3.f;
74 GPUhd() inline float AliHLTTPCCADataCompressor::UShort2Z( unsigned short iYZ )
76 // extract Z coordinate from the compressed 16bits format to [-3.,3.]
78 const float kMult = 6.f / 255.f;
79 return ( iYZ % 256 )*kMult - 3.f;