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