]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCADataCompressor.h
TPC CA Global Merger component added
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCADataCompressor.h
CommitLineData
63d8b79d 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
14/**
15 * @class AliHLTTPCCADataCompressor
16 *
17 * The AliHLTTPCCADataCompressor class is used to
18 * pack and unpack diffferent data, such as TPC cluster IDs, posistion, amplitude etc
19 *
20 */
21class AliHLTTPCCADataCompressor
22{
23public:
24
25 GPUhd() static UInt_t IRowIClu2IDrc( UInt_t iRow, UInt_t iCluster ){
26 return (iCluster<<8)+iRow;
27 }
28
29 GPUhd() static UInt_t IDrc2IRow( UInt_t IDrc ){ return ( IDrc%256 ); }
30 GPUhd() static UInt_t IDrc2IClu( UInt_t IDrc ){ return ( IDrc>>8 ); }
31
32
33 GPUhd() static UInt_t ISliceIRowIClu2IDsrc( UInt_t iSlice, UInt_t iRow, UInt_t iCluster ){
34 return (iCluster<<14) + (iRow<<6) + iSlice;
35 }
36
37 GPUhd() static UInt_t IDsrc2ISlice( UInt_t IDsrc ){ return ( IDsrc%64 ); }
38 GPUhd() static UInt_t IDsrc2IRow ( UInt_t IDsrc ){ return ( (IDsrc>>6)%256 ); }
39 GPUhd() static UInt_t IDsrc2IClu ( UInt_t IDsrc ){ return ( IDsrc>>14 ); }
40
41
42 GPUhd() static UShort_t YZ2UShort( Float_t Y, Float_t Z );
43 GPUhd() static Float_t UShort2Y ( UShort_t iYZ );
44 GPUhd() static Float_t UShort2Z ( UShort_t iYZ );
45
46};
47
48
49// Inline methods
50
51
52GPUhd() inline UShort_t AliHLTTPCCADataCompressor::YZ2UShort( Float_t Y, Float_t Z )
53{
54 // compress Y and Z coordinates in range [-3., 3.] to 16 bits
55
56 const Float_t kMult = 255./6.;
57 Y = (Y+3.)*kMult;
58 Z = (Z+3.)*kMult;
59 if( Y<0. ) Y = 0.;
60 else if( Y>255. ) Y = 255.;
61 if( Z<0. ) Z = 0.;
62 else if( Z>255. ) Z = 255.;
e1f2d1c3 63 return static_cast<UShort_t>( ( static_cast<UInt_t>( Y )<<8) + static_cast<UInt_t>( Z ) );
63d8b79d 64}
65
66GPUhd() inline Float_t AliHLTTPCCADataCompressor::UShort2Y( UShort_t iYZ )
67{
68 // extract Y coordinate from the compressed 16bits format to [-3.,3.]
69
70 const Float_t kMult = 6./255.;
e1f2d1c3 71 return (iYZ >> 8)*kMult - 3.;
63d8b79d 72}
73
74GPUhd() inline Float_t AliHLTTPCCADataCompressor::UShort2Z( UShort_t iYZ )
75{
76 // extract Z coordinate from the compressed 16bits format to [-3.,3.]
77
78 const Float_t kMult = 6./255.;
e1f2d1c3 79 return (iYZ % 256)*kMult - 3.;
63d8b79d 80}
81
82#endif