]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCDataCompressorHelper.cxx
removing DigitReaderPacked and DigitReaderDecoder, all raw data processing goes via...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDataCompressorHelper.cxx
CommitLineData
a6c02c85 1// @(#) $Id$
4aa41877 2// Original: AliHLTDataCompressorHelper.cxx,v 1.5 2004/06/15 10:26:57 hristov Exp $
a6c02c85 3
297174de 4//**************************************************************************
5//* This file is property of and copyright by the ALICE HLT Project *
6//* ALICE Experiment at CERN, All rights reserved. *
7//* *
8//* Primary Authors: Anders Vestbo *
9//* for The ALICE HLT Project. *
10//* *
11//* Permission to use, copy, modify and distribute this software and its *
12//* documentation strictly for non-commercial purposes is hereby granted *
13//* without fee, provided that the above copyright notice appears in all *
14//* copies and that both the copyright notice and this permission notice *
15//* appear in the supporting documentation. The authors make no claims *
16//* about the suitability of this software for any purpose. It is *
17//* provided "as is" without express or implied warranty. *
18//**************************************************************************
a6c02c85 19
85869391 20#include "AliHLTStdIncludes.h"
a6c02c85 21#include "AliHLTTPCRootTypes.h"
22#include "AliHLTTPCTransform.h"
23
24#include "AliHLTTPCDataCompressorHelper.h"
25
26#if __GNUC__ >= 3
27using namespace std;
28#endif
29
30//_____________________________________________________________
31//
32// AliHLTTPCDataCompression
33//
34// Interface class; binary <-> AliROOT handling of TPC data compression classes.
35//
36
37
38ClassImp(AliHLTTPCDataCompressorHelper)
39
600e6a1b 40AliHLTTPCDataCompressorHelper::AliHLTTPCDataCompressorHelper()
41{
42}
43
44AliHLTTPCDataCompressorHelper::~AliHLTTPCDataCompressorHelper()
45{
46}
a6c02c85 47
48Int_t AliHLTTPCDataCompressorHelper::fgNumTimeBits = 12;
49Int_t AliHLTTPCDataCompressorHelper::fgNumPadBits = 12;
50Int_t AliHLTTPCDataCompressorHelper::fgNumChargeBits = 14;
51Int_t AliHLTTPCDataCompressorHelper::fgNumShapeBits = 14;
52Float_t AliHLTTPCDataCompressorHelper::fgXYResidualStep1 = 0.03;
53Float_t AliHLTTPCDataCompressorHelper::fgXYResidualStep2 = 0.03;
54Float_t AliHLTTPCDataCompressorHelper::fgXYResidualStep3 = 0.03;
55Float_t AliHLTTPCDataCompressorHelper::fgZResidualStep1 = 0.05;
56Float_t AliHLTTPCDataCompressorHelper::fgZResidualStep2 = 0.05;
57Float_t AliHLTTPCDataCompressorHelper::fgZResidualStep3 = 0.05;
58Float_t AliHLTTPCDataCompressorHelper::fgXYWidthStep = 0.005;
59Float_t AliHLTTPCDataCompressorHelper::fgZWidthStep = 0.005;
60Int_t AliHLTTPCDataCompressorHelper::fgClusterCharge = 100;
61Int_t AliHLTTPCDataCompressorHelper::fgNumPadBitsRemaining = 18;
62Int_t AliHLTTPCDataCompressorHelper::fgNumTimeBitsRemaining = 19;
63Int_t AliHLTTPCDataCompressorHelper::fgNumShapeBitsRemaining = 11;
64
65void AliHLTTPCDataCompressorHelper::SetBitNumbers(Int_t pad,Int_t time,Int_t charge,Int_t shape)
66{
67 // sets the numbers of bits
68 fgNumPadBits = pad;
69 fgNumTimeBits = time;
70 fgNumChargeBits = charge;
71 fgNumShapeBits = shape;
72}
73
74void AliHLTTPCDataCompressorHelper::SetTransverseResolutions(Float_t res1,Float_t res2,Float_t res3,Float_t width)
75{
76 // sets the transverse resolution
77 fgXYResidualStep1 = res1;
78 fgXYResidualStep2 = res2;
79 fgXYResidualStep3 = res3;
80 fgXYWidthStep = width;
81}
82
83void AliHLTTPCDataCompressorHelper::SetLongitudinalResolutions(Float_t res1,Float_t res2,Float_t res3,Float_t width)
84{
85 // sets the longitudinal resolution
86 fgZResidualStep1 = res1;
87 fgZResidualStep2 = res2;
88 fgZResidualStep3 = res3;
89 fgZWidthStep = width;
90}
91
92void AliHLTTPCDataCompressorHelper::SetRemainingBitNumbers(Int_t pad,Int_t time,Int_t shape)
93{
94 // sets the numbers of remaining bits
95 fgNumPadBitsRemaining = pad;
96 fgNumTimeBitsRemaining = time;
97 fgNumShapeBitsRemaining = shape;
98}
99
100Float_t AliHLTTPCDataCompressorHelper::GetXYResidualStep(Int_t row)
101{
102 // gets the XY residual step
103 if(row < AliHLTTPCTransform::GetNRowLow())
104 return fgXYResidualStep1;
105 else if(row < AliHLTTPCTransform::GetNRowLow() + AliHLTTPCTransform::GetNRowUp1())
106 return fgXYResidualStep2;
107 else if(row < AliHLTTPCTransform::GetNRowLow() + AliHLTTPCTransform::GetNRowUp1() + AliHLTTPCTransform::GetNRowUp2())
108 return fgXYResidualStep3;
109 else
110 {
111 cerr<<"AliHLTTPCDataCompressorHelper::GetXYResidualStep : Wrong row number "<<row<<endl;
112 return -1;
113 }
114}
115
116Float_t AliHLTTPCDataCompressorHelper::GetZResidualStep(Int_t row)
117{
118 // gets the Z residual step
119 if(row < AliHLTTPCTransform::GetNRowLow())
120 return fgZResidualStep1;
121 else if(row < AliHLTTPCTransform::GetNRowLow() + AliHLTTPCTransform::GetNRowUp1())
122 return fgZResidualStep2;
123 else if(row < AliHLTTPCTransform::GetNRowLow() + AliHLTTPCTransform::GetNRowUp1() + AliHLTTPCTransform::GetNRowUp2())
124 return fgZResidualStep3;
125 else
126 {
127 cerr<<"AliHLTTPCDataCompressorHelper::GetXYResidualStep : Wrong row number "<<row<<endl;
128 return -1;
129 }
130}
131
132Float_t AliHLTTPCDataCompressorHelper::GetPadPrecisionFactor()
133{
134 // gets pad precision factor
135 Int_t nbits = fgNumPadBitsRemaining;
136 if(nbits >=21)
137 return 10000;
138 if(nbits >= 18)
139 return 1000;
140 if(nbits >= 14)
141 return 100;
142 if(nbits >= 11)
143 return 10;
144 if(nbits >= 8)
145 return 1;
146 else
147 {
148 cerr<<"AliHLTTPCDataCompressorHelper::GetRemainingPadFactor : Too few bits for the pad direction: "<<nbits<<endl;
149 return 1;
150 }
151}
152
153Float_t AliHLTTPCDataCompressorHelper::GetTimePrecisionFactor()
154{
155 // gest time precision factor
156 Int_t nbits = fgNumTimeBitsRemaining;
157 if(nbits >=23)
158 return 10000;
159 if(nbits >= 19)
160 return 1000;
161 if(nbits >= 16)
162 return 100;
163 if(nbits >= 13)
164 return 10;
165 if(nbits >= 9)
166 return 1;
167 else
168 {
169 cerr<<"AliHLTTPCDataCompressorHelper::GetRemainingPadFactor : Too few bits for the pad direction: "<<nbits<<endl;
170 return 1;
171 }
172}
173
174
175Int_t AliHLTTPCDataCompressorHelper::Nint(Double_t x)
176{
177 // Round to nearest integer. Rounds half integers
178 // to the nearest even integer.
179
180 Int_t i=0;
181 if (x >= 0) {
182 i = Int_t(x + 0.5);
183 if (x + 0.5 == Double_t(i) && i & 1) i--;
184 } else {
185 i = Int_t(x - 0.5);
186 if (x - 0.5 == Double_t(i) && i & 1) i++;
187
188 }
189 return i;
190}