]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/comp/AliHLTDataCompressorHelper.cxx
Bogdan: new version of MUON visualization.
[u/mrichter/AliRoot.git] / HLT / comp / AliHLTDataCompressorHelper.cxx
CommitLineData
4aa41877 1// @(#) $Id$
2
3// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
4//*-- Copyright &copy ALICE HLT Group
5
6#include "AliHLTStandardIncludes.h"
7
8#include "AliHLTRootTypes.h"
9#include "AliHLTTransform.h"
10
11#include "AliHLTDataCompressorHelper.h"
12
13#if __GNUC__ >= 3
14using namespace std;
15#endif
16
17//_____________________________________________________________
18//
19// AliHLTDataCompression
20//
21// Interface class; binary <-> AliROOT handling of TPC data compression classes.
22//
23
24
25ClassImp(AliHLTDataCompressorHelper)
26
27
28Int_t AliHLTDataCompressorHelper::fgNumTimeBits = 12;
29Int_t AliHLTDataCompressorHelper::fgNumPadBits = 12;
30Int_t AliHLTDataCompressorHelper::fgNumChargeBits = 14;
31Int_t AliHLTDataCompressorHelper::fgNumShapeBits = 14;
32Float_t AliHLTDataCompressorHelper::fgXYResidualStep1 = 0.03;
33Float_t AliHLTDataCompressorHelper::fgXYResidualStep2 = 0.03;
34Float_t AliHLTDataCompressorHelper::fgXYResidualStep3 = 0.03;
35Float_t AliHLTDataCompressorHelper::fgZResidualStep1 = 0.05;
36Float_t AliHLTDataCompressorHelper::fgZResidualStep2 = 0.05;
37Float_t AliHLTDataCompressorHelper::fgZResidualStep3 = 0.05;
38Float_t AliHLTDataCompressorHelper::fgXYWidthStep = 0.005;
39Float_t AliHLTDataCompressorHelper::fgZWidthStep = 0.005;
40Int_t AliHLTDataCompressorHelper::fgClusterCharge = 100;
41Int_t AliHLTDataCompressorHelper::fgNumPadBitsRemaining = 18;
42Int_t AliHLTDataCompressorHelper::fgNumTimeBitsRemaining = 19;
43Int_t AliHLTDataCompressorHelper::fgNumShapeBitsRemaining = 11;
44
45void AliHLTDataCompressorHelper::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
54void AliHLTDataCompressorHelper::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
63void AliHLTDataCompressorHelper::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
72void AliHLTDataCompressorHelper::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
80Float_t AliHLTDataCompressorHelper::GetXYResidualStep(Int_t row)
81{
82 // gets the XY residual step
83 if(row < AliHLTTransform::GetNRowLow())
84 return fgXYResidualStep1;
85 else if(row < AliHLTTransform::GetNRowLow() + AliHLTTransform::GetNRowUp1())
86 return fgXYResidualStep2;
87 else if(row < AliHLTTransform::GetNRowLow() + AliHLTTransform::GetNRowUp1() + AliHLTTransform::GetNRowUp2())
88 return fgXYResidualStep3;
89 else
90 {
91 cerr<<"AliHLTDataCompressorHelper::GetXYResidualStep : Wrong row number "<<row<<endl;
92 return -1;
93 }
94}
95
96Float_t AliHLTDataCompressorHelper::GetZResidualStep(Int_t row)
97{
98 // gets the Z residual step
99 if(row < AliHLTTransform::GetNRowLow())
100 return fgZResidualStep1;
101 else if(row < AliHLTTransform::GetNRowLow() + AliHLTTransform::GetNRowUp1())
102 return fgZResidualStep2;
103 else if(row < AliHLTTransform::GetNRowLow() + AliHLTTransform::GetNRowUp1() + AliHLTTransform::GetNRowUp2())
104 return fgZResidualStep3;
105 else
106 {
107 cerr<<"AliHLTDataCompressorHelper::GetXYResidualStep : Wrong row number "<<row<<endl;
108 return -1;
109 }
110}
111
112Float_t AliHLTDataCompressorHelper::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<<"AliHLTDataCompressorHelper::GetRemainingPadFactor : Too few bits for the pad direction: "<<nbits<<endl;
129 return 1;
130 }
131}
132
133Float_t AliHLTDataCompressorHelper::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<<"AliHLTDataCompressorHelper::GetRemainingPadFactor : Too few bits for the pad direction: "<<nbits<<endl;
150 return 1;
151 }
152}
153
154
155Int_t AliHLTDataCompressorHelper::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}