StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AliHLTTPCCADataCompressor.h
1 //-*- Mode: C++ -*-
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 *
6 // *
7 //*************************************************************************
8 
9 #ifndef ALIHLTTPCCADATACOMPRESSOR_H
10 #define ALIHLTTPCCADATACOMPRESSOR_H
11 
12 #include "AliHLTTPCCADef.h"
13 
22 {
23  class RowCluster
24  {
25  public:
26  RowCluster(): fRow(0), fCluster(0) {}
27  RowCluster( unsigned int iRow, unsigned int iCluster )
28  : fRow( iRow ), fCluster( iCluster ) {}
29  unsigned int Row() const { return fRow; }
30  unsigned int Cluster() const { return fCluster; }
31  private:
32  unsigned int fRow : 8;
33  unsigned int fCluster : 24;
34  };
35 
37  {
38  public:
39  SliceRowCluster(): fSlice(0), fRow(0), fCluster(0) {}
40  SliceRowCluster( unsigned int s, unsigned int r, unsigned int c )
41  : fSlice( s ), fRow( r ), fCluster( c ) {}
42  unsigned int Slice() const { return fSlice; }
43  unsigned int Row() const { return fRow; }
44  unsigned int Cluster() const { return fCluster; }
45  private:
46  unsigned int fSlice : 6;
47  unsigned int fRow : 8;
48  unsigned int fCluster : 18;
49  };
50 
51  class YZ
52  {
53  public:
54  YZ() {}
55  YZ( float Y, float Z );
56  float Y() const;
57  float Z() const;
58  private:
59  unsigned char fY;
60  unsigned char fZ;
61  };
62 
63  // Inline methods
64 
65  inline YZ::YZ( float _Y, float _Z )
66  {
67  // compress Y and Z coordinates in range [-3., 3.] to 8 bits each
68 
69  const float kMult = 255. / 6.;
70  _Y = ( _Y + 3. ) * kMult;
71  _Z = ( _Z + 3. ) * kMult;
72  if ( _Y < 0.f ) {
73  fY = 0;
74  } else if ( _Y > 255.f ) {
75  fY = 255;
76  } else {
77  fY = static_cast<unsigned char>( CAMath::Round( _Y ) );
78  }
79  if ( _Z < 0.f ) {
80  fZ = 0;
81  } else if ( _Z > 255.f ) {
82  fZ = 255;
83  } else {
84  fZ = static_cast<unsigned char>( CAMath::Round( _Z ) );
85  }
86  }
87 
88  inline float YZ::Y() const
89  {
90  // extract Y coordinate from the compressed 16bits format to [-3.,3.]
91 
92  const float kMult = 6. / 255.;
93  return fY * kMult - 3.f;
94  }
95 
96  inline float YZ::Z() const
97  {
98  // extract Z coordinate from the compressed 16bits format to [-3.,3.]
99 
100  const float kMult = 6. / 255.;
101  return fZ * kMult - 3.f;
102  }
103 
104 } // namespace AliHLTTPCCADataCompressor
105 
106 namespace DataCompressor
107 {
108  using namespace AliHLTTPCCADataCompressor;
109 } // namespace DataCompressor
110 
111 #endif