]>
Commit | Line | Data |
---|---|---|
1f1942b8 | 1 | // @(#) $Id$ |
2 | ||
3 | // Author: Anders Vestbo <mailto:vestbo@fi.uib.no> | |
4 | //*-- Copyright © ALICE HLT Group | |
5 | ||
6 | #include "AliL3StandardIncludes.h" | |
7 | ||
8 | #include "AliL3RootTypes.h" | |
9 | #include "AliL3Transform.h" | |
10 | ||
11 | #include "AliL3DataCompressorHelper.h" | |
12 | ||
0bd0c1ef | 13 | #if __GNUC__ == 3 |
1f1942b8 | 14 | using namespace std; |
15 | #endif | |
16 | ||
17 | //_____________________________________________________________ | |
18 | // | |
19 | // AliL3DataCompression | |
20 | // | |
21 | // Interface class; binary <-> AliROOT handling of TPC data compression classes. | |
22 | // | |
23 | ||
24 | ||
25 | ClassImp(AliL3DataCompressorHelper) | |
26 | ||
27 | ||
b4686276 | 28 | Int_t AliL3DataCompressorHelper::fgNumTimeBits = 12; |
29 | Int_t AliL3DataCompressorHelper::fgNumPadBits = 12; | |
30 | Int_t AliL3DataCompressorHelper::fgNumChargeBits = 14; | |
31 | Int_t AliL3DataCompressorHelper::fgNumShapeBits = 14; | |
32 | Float_t AliL3DataCompressorHelper::fgXYResidualStep1 = 0.03; | |
33 | Float_t AliL3DataCompressorHelper::fgXYResidualStep2 = 0.03; | |
34 | Float_t AliL3DataCompressorHelper::fgXYResidualStep3 = 0.03; | |
35 | Float_t AliL3DataCompressorHelper::fgZResidualStep1 = 0.05; | |
36 | Float_t AliL3DataCompressorHelper::fgZResidualStep2 = 0.05; | |
37 | Float_t AliL3DataCompressorHelper::fgZResidualStep3 = 0.05; | |
38 | Float_t AliL3DataCompressorHelper::fgXYWidthStep = 0.005; | |
39 | Float_t AliL3DataCompressorHelper::fgZWidthStep = 0.005; | |
40 | Int_t AliL3DataCompressorHelper::fgClusterCharge = 100; | |
41 | Int_t AliL3DataCompressorHelper::fgNumPadBitsRemaining = 18; | |
42 | Int_t AliL3DataCompressorHelper::fgNumTimeBitsRemaining = 19; | |
43 | Int_t AliL3DataCompressorHelper::fgNumShapeBitsRemaining = 11; | |
1f1942b8 | 44 | |
45 | void AliL3DataCompressorHelper::SetBitNumbers(Int_t pad,Int_t time,Int_t charge,Int_t shape) | |
46 | { | |
b4686276 | 47 | // sets the numbers of bits |
48 | fgNumPadBits = pad; | |
49 | fgNumTimeBits = time; | |
50 | fgNumChargeBits = charge; | |
51 | fgNumShapeBits = shape; | |
1f1942b8 | 52 | } |
53 | ||
54 | void AliL3DataCompressorHelper::SetTransverseResolutions(Float_t res1,Float_t res2,Float_t res3,Float_t width) | |
55 | { | |
b4686276 | 56 | // sets the transverse resolution |
57 | fgXYResidualStep1 = res1; | |
58 | fgXYResidualStep2 = res2; | |
59 | fgXYResidualStep3 = res3; | |
60 | fgXYWidthStep = width; | |
1f1942b8 | 61 | } |
62 | ||
63 | void AliL3DataCompressorHelper::SetLongitudinalResolutions(Float_t res1,Float_t res2,Float_t res3,Float_t width) | |
64 | { | |
b4686276 | 65 | // sets the longitudinal resolution |
66 | fgZResidualStep1 = res1; | |
67 | fgZResidualStep2 = res2; | |
68 | fgZResidualStep3 = res3; | |
69 | fgZWidthStep = width; | |
1f1942b8 | 70 | } |
71 | ||
5a31e9df | 72 | void AliL3DataCompressorHelper::SetRemainingBitNumbers(Int_t pad,Int_t time,Int_t shape) |
73 | { | |
b4686276 | 74 | // sets the numbers of remaining bits |
75 | fgNumPadBitsRemaining = pad; | |
76 | fgNumTimeBitsRemaining = time; | |
77 | fgNumShapeBitsRemaining = shape; | |
5a31e9df | 78 | } |
79 | ||
b4686276 | 80 | Float_t AliL3DataCompressorHelper::GetXYResidualStep(Int_t row) |
1f1942b8 | 81 | { |
b4686276 | 82 | // gets the XY residual step |
1f1942b8 | 83 | if(row < AliL3Transform::GetNRowLow()) |
b4686276 | 84 | return fgXYResidualStep1; |
1f1942b8 | 85 | else if(row < AliL3Transform::GetNRowLow() + AliL3Transform::GetNRowUp1()) |
b4686276 | 86 | return fgXYResidualStep2; |
1f1942b8 | 87 | else if(row < AliL3Transform::GetNRowLow() + AliL3Transform::GetNRowUp1() + AliL3Transform::GetNRowUp2()) |
b4686276 | 88 | return fgXYResidualStep3; |
1f1942b8 | 89 | else |
90 | { | |
91 | cerr<<"AliL3DataCompressorHelper::GetXYResidualStep : Wrong row number "<<row<<endl; | |
92 | return -1; | |
93 | } | |
94 | } | |
95 | ||
b4686276 | 96 | Float_t AliL3DataCompressorHelper::GetZResidualStep(Int_t row) |
1f1942b8 | 97 | { |
b4686276 | 98 | // gets the Z residual step |
1f1942b8 | 99 | if(row < AliL3Transform::GetNRowLow()) |
b4686276 | 100 | return fgZResidualStep1; |
1f1942b8 | 101 | else if(row < AliL3Transform::GetNRowLow() + AliL3Transform::GetNRowUp1()) |
b4686276 | 102 | return fgZResidualStep2; |
1f1942b8 | 103 | else if(row < AliL3Transform::GetNRowLow() + AliL3Transform::GetNRowUp1() + AliL3Transform::GetNRowUp2()) |
b4686276 | 104 | return fgZResidualStep3; |
1f1942b8 | 105 | else |
106 | { | |
107 | cerr<<"AliL3DataCompressorHelper::GetXYResidualStep : Wrong row number "<<row<<endl; | |
108 | return -1; | |
109 | } | |
110 | } | |
5a31e9df | 111 | |
b4686276 | 112 | Float_t AliL3DataCompressorHelper::GetPadPrecisionFactor() |
5a31e9df | 113 | { |
b4686276 | 114 | // gets pad precision factor |
115 | Int_t nbits = fgNumPadBitsRemaining; | |
5a31e9df | 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<<"AliL3DataCompressorHelper::GetRemainingPadFactor : Too few bits for the pad direction: "<<nbits<<endl; | |
129 | return 1; | |
130 | } | |
131 | } | |
132 | ||
b4686276 | 133 | Float_t AliL3DataCompressorHelper::GetTimePrecisionFactor() |
5a31e9df | 134 | { |
b4686276 | 135 | // gest time precision factor |
136 | Int_t nbits = fgNumTimeBitsRemaining; | |
5a31e9df | 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<<"AliL3DataCompressorHelper::GetRemainingPadFactor : Too few bits for the pad direction: "<<nbits<<endl; | |
150 | return 1; | |
151 | } | |
152 | } | |
de3c3890 | 153 | |
154 | ||
155 | Int_t AliL3DataCompressorHelper::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 | } |