]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCDataCompressorHelper.cxx
documentation; deprecated defines deleted
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDataCompressorHelper.cxx
1 // @(#) $Id$
2 // Original: AliHLTDataCompressorHelper.cxx,v 1.5 2004/06/15 10:26:57 hristov Exp $
3
4 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
5 //*-- Copyright &copy ALICE HLT Group
6
7 #include "AliHLTStdIncludes.h"
8 #include "AliHLTTPCRootTypes.h"
9 #include "AliHLTTPCTransform.h"
10
11 #include "AliHLTTPCDataCompressorHelper.h"
12
13 #if __GNUC__ >= 3
14 using namespace std;
15 #endif
16
17 //_____________________________________________________________
18 //
19 //  AliHLTTPCDataCompression
20 //
21 // Interface class; binary <-> AliROOT handling of TPC data compression classes.
22 //
23
24
25 ClassImp(AliHLTTPCDataCompressorHelper)
26
27 AliHLTTPCDataCompressorHelper::AliHLTTPCDataCompressorHelper() 
28 {
29 }
30
31 AliHLTTPCDataCompressorHelper::~AliHLTTPCDataCompressorHelper() 
32 {
33 }
34
35 Int_t AliHLTTPCDataCompressorHelper::fgNumTimeBits = 12;
36 Int_t AliHLTTPCDataCompressorHelper::fgNumPadBits = 12;
37 Int_t AliHLTTPCDataCompressorHelper::fgNumChargeBits = 14;
38 Int_t AliHLTTPCDataCompressorHelper::fgNumShapeBits = 14;
39 Float_t AliHLTTPCDataCompressorHelper::fgXYResidualStep1 = 0.03;
40 Float_t AliHLTTPCDataCompressorHelper::fgXYResidualStep2 = 0.03;
41 Float_t AliHLTTPCDataCompressorHelper::fgXYResidualStep3 = 0.03;
42 Float_t AliHLTTPCDataCompressorHelper::fgZResidualStep1 = 0.05;
43 Float_t AliHLTTPCDataCompressorHelper::fgZResidualStep2 = 0.05;
44 Float_t AliHLTTPCDataCompressorHelper::fgZResidualStep3 = 0.05;
45 Float_t AliHLTTPCDataCompressorHelper::fgXYWidthStep = 0.005;
46 Float_t AliHLTTPCDataCompressorHelper::fgZWidthStep = 0.005;
47 Int_t AliHLTTPCDataCompressorHelper::fgClusterCharge = 100;
48 Int_t AliHLTTPCDataCompressorHelper::fgNumPadBitsRemaining = 18;
49 Int_t AliHLTTPCDataCompressorHelper::fgNumTimeBitsRemaining = 19;
50 Int_t AliHLTTPCDataCompressorHelper::fgNumShapeBitsRemaining = 11;
51
52 void AliHLTTPCDataCompressorHelper::SetBitNumbers(Int_t pad,Int_t time,Int_t charge,Int_t shape)
53 {
54   // sets the numbers of bits
55   fgNumPadBits = pad;
56   fgNumTimeBits = time;
57   fgNumChargeBits = charge;
58   fgNumShapeBits = shape;
59 }
60
61 void AliHLTTPCDataCompressorHelper::SetTransverseResolutions(Float_t res1,Float_t res2,Float_t res3,Float_t width)
62 {
63   // sets the transverse resolution
64   fgXYResidualStep1 = res1;
65   fgXYResidualStep2 = res2;
66   fgXYResidualStep3 = res3;
67   fgXYWidthStep = width;
68 }
69
70 void AliHLTTPCDataCompressorHelper::SetLongitudinalResolutions(Float_t res1,Float_t res2,Float_t res3,Float_t width)
71 {
72   // sets the longitudinal resolution
73   fgZResidualStep1 = res1;
74   fgZResidualStep2 = res2;
75   fgZResidualStep3 = res3;
76   fgZWidthStep = width;
77 }
78
79 void AliHLTTPCDataCompressorHelper::SetRemainingBitNumbers(Int_t pad,Int_t time,Int_t shape)
80 {
81   // sets the numbers of remaining bits
82   fgNumPadBitsRemaining = pad;
83   fgNumTimeBitsRemaining = time;
84   fgNumShapeBitsRemaining = shape;
85 }
86
87 Float_t AliHLTTPCDataCompressorHelper::GetXYResidualStep(Int_t row) 
88 {
89   // gets the XY residual step
90   if(row < AliHLTTPCTransform::GetNRowLow())
91     return fgXYResidualStep1;
92   else if(row < AliHLTTPCTransform::GetNRowLow() + AliHLTTPCTransform::GetNRowUp1())
93     return fgXYResidualStep2;
94   else if(row < AliHLTTPCTransform::GetNRowLow() + AliHLTTPCTransform::GetNRowUp1() + AliHLTTPCTransform::GetNRowUp2())
95     return fgXYResidualStep3;
96   else
97     {
98       cerr<<"AliHLTTPCDataCompressorHelper::GetXYResidualStep : Wrong row number "<<row<<endl;
99       return -1;
100     }
101 }
102
103 Float_t AliHLTTPCDataCompressorHelper::GetZResidualStep(Int_t row) 
104 {
105   // gets the Z residual step
106   if(row < AliHLTTPCTransform::GetNRowLow())
107     return fgZResidualStep1;
108   else if(row < AliHLTTPCTransform::GetNRowLow() + AliHLTTPCTransform::GetNRowUp1())
109     return fgZResidualStep2;
110   else if(row < AliHLTTPCTransform::GetNRowLow() + AliHLTTPCTransform::GetNRowUp1() + AliHLTTPCTransform::GetNRowUp2())
111     return fgZResidualStep3;
112   else
113     {
114       cerr<<"AliHLTTPCDataCompressorHelper::GetXYResidualStep : Wrong row number "<<row<<endl;
115       return -1;
116     }
117 }
118
119 Float_t AliHLTTPCDataCompressorHelper::GetPadPrecisionFactor()
120 {
121   // gets pad precision factor
122   Int_t nbits = fgNumPadBitsRemaining;
123   if(nbits >=21)
124     return 10000;
125   if(nbits >= 18)
126     return 1000;
127   if(nbits >= 14) 
128     return 100;
129   if(nbits >= 11)
130     return 10;
131   if(nbits >= 8)
132     return 1;
133   else 
134     {
135       cerr<<"AliHLTTPCDataCompressorHelper::GetRemainingPadFactor : Too few bits for the pad direction: "<<nbits<<endl;
136       return 1;
137     }
138 }
139
140 Float_t AliHLTTPCDataCompressorHelper::GetTimePrecisionFactor()
141 {
142   // gest time precision factor
143   Int_t nbits = fgNumTimeBitsRemaining;
144   if(nbits >=23)
145     return 10000;
146   if(nbits >= 19)
147     return 1000;
148   if(nbits >= 16) 
149     return 100;
150   if(nbits >= 13)
151     return 10;
152   if(nbits >= 9)
153     return 1;
154   else 
155     {
156       cerr<<"AliHLTTPCDataCompressorHelper::GetRemainingPadFactor : Too few bits for the pad direction: "<<nbits<<endl;
157       return 1;
158     }
159 }
160
161
162 Int_t AliHLTTPCDataCompressorHelper::Nint(Double_t x)
163 {
164    // Round to nearest integer. Rounds half integers 
165    // to the nearest even integer.
166
167    Int_t i=0;
168    if (x >= 0) {
169       i = Int_t(x + 0.5);
170       if (x + 0.5 == Double_t(i) && i & 1) i--;
171    } else {
172       i = Int_t(x - 0.5);
173       if (x - 0.5 == Double_t(i) && i & 1) i++;
174
175    }
176    return i;
177 }