]>
Commit | Line | Data |
---|---|---|
db16520a | 1 | // XEmacs -*-C++-*- |
2 | // @(#) $Id$ | |
3 | ||
4 | #ifndef ALIHLTTPCDIGITREADERRAW_H | |
5 | #define ALIHLTTPCDIGITREADERRAW_H | |
6 | ||
7 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
8 | * See cxx source for full Copyright notice */ | |
9 | ||
84645eb0 | 10 | /** @file AliHLTTPCDigitReaderRaw.h |
11 | @author Timm Steinbeck, Jochen Thaeder, Matthias Richter | |
12 | @date | |
13 | @brief A digit reader implementation for the RAW data coming from the RCU. | |
14 | */ | |
db16520a | 15 | |
16 | #include "TObject.h" | |
17 | ||
db16520a | 18 | #include "AliHLTTPCDigitReader.h" |
19 | #include "AliHLTDataTypes.h" | |
20 | ||
84645eb0 | 21 | /** |
22 | * @class AliHLTTPCDigitReaderRaw | |
23 | * A digit reader implementation for the RAW data coming from the RCU. | |
24 | * The reader decodes the data package to the level of the ALtro 10 bit words. | |
25 | * | |
26 | * The reader supports the following data format modes: | |
27 | * - 0: RCU Data format as delivered during TPC commissioning, pads/padrows | |
28 | * are sorted, RCU trailer is one 32 bit word. | |
29 | * - 1: As 0, but pads/padrows are delivered "as is", without sorting | |
30 | * - 2: As 0, but RCU trailer is 3 32 bit words. | |
31 | * - 3: As 1, but RCU trailer is 3 32 bit words. | |
5235c3e9 | 32 | * - 4: As 0, but RCU trailer is 2 32 bit words. |
33 | * - 5: As 1, but RCU trailer is 2 32 bit words. | |
84645eb0 | 34 | * @ingroup alihlt_tpc |
35 | */ | |
db16520a | 36 | class AliHLTTPCDigitReaderRaw : public AliHLTTPCDigitReader { |
37 | public: | |
f3f599e0 | 38 | |
39 | /** decode mode of the reader */ | |
40 | enum RawReaderMode { | |
41 | /** 0: RCU Data format as delivered during TPC commissioning, pads/padrows | |
42 | * are sorted, RCU trailer is one 32 bit word. */ | |
43 | kSorted1Trailerword=0, | |
44 | /** 1: As 0, but pads/padrows are delivered "as is", without sorting */ | |
45 | kUnsorted1Trailerword, | |
46 | /** 2: As 0, but RCU trailer is 3 32 bit words. */ | |
47 | kSorted3Trailerword, | |
48 | /** 3: As 1, but RCU trailer is 3 32 bit words. */ | |
49 | kUnsorted3Trailerword, | |
50 | /** 4: As 0, but RCU trailer is 2 32 bit words. */ | |
51 | kSorted2Trailerword, | |
52 | /** 5: As 1, but RCU trailer is 2 32 bit words. */ | |
53 | kUnsorted2Trailerword, | |
54 | /** number of modes */ | |
55 | kNofRawReaderModes | |
56 | }; | |
57 | ||
84645eb0 | 58 | /** standard constructor |
59 | * @param formatVersion Data Format version numbers: | |
60 | * - 0: RCU Data format as delivered during TPC commissioning, pads/padrows | |
61 | * are sorted, RCU trailer is one 32 bit word. | |
62 | * - 1: As 0, but pads/padrows are delivered "as is", without sorting | |
63 | * - 2: As 0, but RCU trailer is 3 32 bit words. | |
64 | * - 3: As 1, but RCU trailer is 3 32 bit words. | |
f3f599e0 | 65 | * - 4: As 0, but RCU trailer is 2 32 bit words. |
66 | * - 5: As 1, but RCU trailer is 2 32 bit words. | |
84645eb0 | 67 | */ |
68 | AliHLTTPCDigitReaderRaw( unsigned formatVersion ); | |
69 | /** not a valid copy constructor, defined according to effective C++ style */ | |
6235cd38 | 70 | AliHLTTPCDigitReaderRaw(const AliHLTTPCDigitReaderRaw& src); |
84645eb0 | 71 | /** not a valid assignment op, but defined according to effective C++ style */ |
6235cd38 | 72 | AliHLTTPCDigitReaderRaw& operator=(const AliHLTTPCDigitReaderRaw& src); |
84645eb0 | 73 | /** destructor */ |
74 | virtual ~AliHLTTPCDigitReaderRaw(); | |
db16520a | 75 | |
84645eb0 | 76 | /** |
77 | * Init the reader with a data block. | |
78 | * The function fetches the first and last row for the readout partition | |
8e984e21 | 79 | * from @ref AliHLTTPCTransform. |
84645eb0 | 80 | * @param ptr pointer to data buffer |
81 | * @param size size of the data buffer | |
82 | * @param patch patch (readout partition) number within the slice | |
83 | * @param slice sector no (0 to 35) | |
84 | */ | |
85 | virtual int InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice); | |
86 | ||
78b557c2 | 87 | /** |
88 | * Old Init function. | |
89 | * <b>Note:</b> This method is for backward compatibility only, not for further | |
90 | * use. The <i>firstrow</i> and <i>lastrow</i> parameters are fetched from | |
91 | * @ref AliHLTTPCTransform. The method is implemented in the raw reader base class | |
92 | * but is defined here to keep the signature of the library interface. | |
93 | * | |
94 | * @param ptr pointer to data buffer | |
95 | * @param size size of the data buffer | |
96 | * @param firstrow first row occuring in the data | |
97 | * @param lastrow last row occuring in the data | |
98 | * @param patch patch (readout partition) number within the slice | |
99 | * @param slice sector no (0 to 35) | |
100 | */ | |
101 | int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice); | |
102 | ||
db16520a | 103 | // Deliver values sorted for format 0, otherwise pass through to corresponding *Real* method |
84645eb0 | 104 | virtual bool Next(); |
105 | virtual int GetRow(); | |
106 | virtual int GetPad(); | |
107 | virtual int GetSignal(); | |
108 | virtual int GetTime(); | |
db16520a | 109 | |
110 | bool Verify( bool verify ) | |
111 | { | |
112 | bool old = fVerify; | |
113 | fVerify=verify; | |
114 | return old; | |
115 | } | |
116 | ||
117 | bool GetVerify() const | |
118 | { | |
119 | return fVerify; | |
120 | } | |
121 | ||
6235cd38 | 122 | // |
db16520a | 123 | // Deliver values unsorted |
6235cd38 | 124 | // |
125 | /** unsorted next value */ | |
126 | bool RealNext(); | |
127 | /** row of current value */ | |
128 | int GetRealRow() const; | |
129 | /** pad of current value */ | |
130 | int GetRealPad() const; | |
131 | /** signal of current value */ | |
132 | int GetRealSignal(); | |
133 | /** time of current value */ | |
134 | int GetRealTime() const; | |
db16520a | 135 | |
6235cd38 | 136 | // |
db16520a | 137 | // Low level methods for accessing the data |
6235cd38 | 138 | // |
139 | /** get rcu trailer word of the raw data */ | |
140 | AliHLTUInt32_t GetRCUTrailer( unsigned offset=0 ) const; | |
141 | ||
142 | /** move to next altro block and set internal variables */ | |
143 | bool NextAltroBlock(); | |
144 | ||
145 | /** hardware address of the current altro block */ | |
146 | AliHLTUInt32_t GetAltroBlockHWaddr() const; | |
147 | ||
148 | /** get no of 10bit words in the current altro block */ | |
149 | unsigned GetAltroBlock10BitWordCnt() const; | |
150 | ||
151 | /** ndx counts from end, 0 is last */ | |
152 | AliHLTUInt64_t GetAltroBlock40BitWord( unsigned long ndx ) const; | |
153 | ||
154 | /** ndx counts from end, 0 is last */ | |
155 | AliHLTUInt16_t GetAltroBlock10BitWord( unsigned long ndx ); | |
156 | ||
157 | /** ndx counts from end, 0 is last */ | |
158 | AliHLTUInt16_t GetAltroBlockReal10BitWord( unsigned long ndx ); | |
db16520a | 159 | |
160 | unsigned GetAltroBlockPositionBytes() const | |
161 | {return fAltroBlockPositionBytes;} | |
162 | unsigned GetAltroBlockLengthBytes() const | |
163 | {return fAltroBlockLengthBytes;} | |
164 | ||
6235cd38 | 165 | /** Return length of trailing RCU data block in bytes */ |
db16520a | 166 | unsigned GetRCUDataBlockLength() const; |
167 | unsigned GetCommonDataHeaderSize() const; | |
168 | ||
169 | Bool_t ApplyMapping(); | |
170 | ||
6235cd38 | 171 | Int_t GetRow( unsigned patch, unsigned hwAddr ); |
172 | Int_t GetPad( unsigned patch, unsigned hwAddr ); | |
173 | unsigned GetMaxHWA( unsigned patch ) const; | |
db16520a | 174 | |
f3f599e0 | 175 | /** |
176 | * This function decodes the rawreadermode set in HLT***Components | |
177 | * or the AliHLTGUI and returns the integer value of @ref RawReaderMode. | |
178 | * @param mode const Char_t * argument <br> | |
179 | * sorted_3_trailerword -> @ref kSorted3Trailerword <br> | |
180 | * sorted_2_trailerword -> @ref kSorted2Trailerword <br> | |
181 | * sorted_1_trailerword -> @ref kSorted1Trailerword <br> | |
182 | * unsorted_3_trailerword -> @ref kUnsorted3Trailerword <br> | |
183 | * unsorted_2_trailerword -> @ref kUnsorted2Trailerword <br> | |
184 | * unsorted_1_trailerword -> @ref kUnsorted1Trailerword <br> | |
185 | * @return rawreadermode @ref RawReaderMode and -1 if decoding fails | |
186 | */ | |
187 | static Int_t DecodeMode(const Char_t *mode); | |
188 | ||
189 | /** | |
190 | * This function sets the rawreadermode from an enum. | |
191 | * The name was chosen in order to use the two methods with either | |
192 | * a Char_t array or an Int_t. | |
193 | * @param mode mode enum @ref RawReaderMode | |
194 | * @return rawreadermode @ref RawReaderMode and -1 if decoding fails | |
195 | */ | |
196 | static Int_t DecodeMode(Int_t mode); | |
197 | ||
db16520a | 198 | protected: |
199 | ||
6235cd38 | 200 | /** the raw data buffer (external buffer) */ |
201 | AliHLTUInt8_t* fBuffer; //! transient | |
202 | /** size of the raw data buffer */ | |
203 | unsigned long fBufferSize; // see above | |
db16520a | 204 | /* |
205 | Int_t fFirstRow; | |
206 | Int_t fLastRow; | |
207 | */ | |
2a083ac4 | 208 | |
6235cd38 | 209 | /** patch (readout partition) specification of the raw data buffer */ |
210 | Int_t fPatch; // see above | |
211 | ||
212 | /** slice (sector) specification of the raw data buffer */ | |
213 | Int_t fSlice; // see above | |
2a083ac4 | 214 | |
6235cd38 | 215 | /** the current row no */ |
216 | Int_t fRow; // see above | |
217 | ||
218 | /** the current pad no */ | |
219 | Int_t fPad; // see above | |
220 | ||
221 | ||
222 | /** position of the current ALTRO block*/ | |
223 | unsigned fAltroBlockPositionBytes; // see above | |
224 | ||
225 | /** length of the current ALTRO block*/ | |
226 | unsigned fAltroBlockLengthBytes; // see above | |
2a083ac4 | 227 | |
6235cd38 | 228 | /** hardware of the current ALTRO block*/ |
229 | AliHLTUInt16_t fAltroBlockHWAddress; // see above | |
230 | ||
231 | /** no of 10 bit words in the current ALTRO block*/ | |
232 | AliHLTUInt16_t fAltroBlock10BitWordCnt; // see above | |
233 | ||
234 | /** no of additional 10 bit fill words in the current ALTRO block*/ | |
235 | AliHLTUInt16_t fAltroBlock10BitFillWordCnt; // see above | |
236 | ||
237 | /** version of data format */ | |
238 | unsigned fDataFormatVersion; // see above | |
239 | ||
240 | /** position of the current bunch of timebins */ | |
241 | unsigned fBunchPosition; // see above | |
242 | /** first timebin of current bunch */ | |
243 | unsigned fBunchTimebinStart; // see above | |
244 | /** length of current bunch */ | |
245 | unsigned fBunchLength; // see above | |
246 | /** word counter in bunch */ | |
247 | unsigned fWordInBunch; // see above | |
db16520a | 248 | |
6235cd38 | 249 | /** verify the consistency of the Altro blocks */ |
250 | bool fVerify; // see above | |
db16520a | 251 | |
252 | private: | |
8e984e21 | 253 | /** number of patches */ |
6235cd38 | 254 | static const Int_t fgkNofPatches=6; // see above |
8e984e21 | 255 | /** dimension of each mapping array */ |
6235cd38 | 256 | static const Int_t fgkMappingDimension=2; // see above |
8e984e21 | 257 | |
258 | /** size of mapping arrays */ | |
6235cd38 | 259 | static const Int_t fgkMapping0Size=3200; // see above |
8e984e21 | 260 | /** size of mapping array for patch 1 */ |
6235cd38 | 261 | static const Int_t fgkMapping1Size=3584; // see above |
8e984e21 | 262 | /** size of mapping array for patch 2 */ |
6235cd38 | 263 | static const Int_t fgkMapping2Size=3200; // see above |
8e984e21 | 264 | /** size of mapping array for patch 3 */ |
6235cd38 | 265 | static const Int_t fgkMapping3Size=3328; // see above |
8e984e21 | 266 | /** size of mapping array for patch 4 */ |
6235cd38 | 267 | static const Int_t fgkMapping4Size=3328; // see above |
8e984e21 | 268 | /** size of mapping array for patch 5 */ |
6235cd38 | 269 | static const Int_t fgkMapping5Size=3328; // see above |
8e984e21 | 270 | |
271 | /** mapping array for patch 0 */ | |
6235cd38 | 272 | static Int_t fgMapping0[fgkMapping0Size][fgkMappingDimension]; // see above |
8e984e21 | 273 | /** mapping array for patch 1 */ |
6235cd38 | 274 | static Int_t fgMapping1[fgkMapping1Size][fgkMappingDimension]; // see above |
8e984e21 | 275 | /** mapping array for patch 2 */ |
6235cd38 | 276 | static Int_t fgMapping2[fgkMapping2Size][fgkMappingDimension]; // see above |
8e984e21 | 277 | /** mapping array for patch 3 */ |
6235cd38 | 278 | static Int_t fgMapping3[fgkMapping3Size][fgkMappingDimension]; // see above |
8e984e21 | 279 | /** mapping array for patch 4 */ |
6235cd38 | 280 | static Int_t fgMapping4[fgkMapping4Size][fgkMappingDimension]; // see above |
8e984e21 | 281 | /** mapping array for patch 5 */ |
6235cd38 | 282 | static Int_t fgMapping5[fgkMapping5Size][fgkMappingDimension]; // see above |
8e984e21 | 283 | |
6235cd38 | 284 | static unsigned fgMaxHWA[fgkNofPatches]; // see above |
db16520a | 285 | |
286 | // For reordering | |
2a083ac4 | 287 | /** current row */ |
288 | Int_t fCurrentRow; // see above | |
289 | /** current pad */ | |
290 | Int_t fCurrentPad; // see above | |
291 | /** current bin */ | |
292 | Int_t fCurrentBin; // see above | |
db16520a | 293 | |
2a083ac4 | 294 | /** ofsset of the first row */ |
295 | Int_t fRowOffset; // see above | |
296 | /** nimber of rows */ | |
297 | Int_t fNRows; // see above | |
298 | ||
299 | /** max number of rows */ | |
300 | Int_t fNMaxRows; // see above | |
301 | /** max number of pads */ | |
302 | Int_t fNMaxPads; // see above | |
303 | /** number of time bins */ | |
304 | Int_t fNTimeBins; // see above | |
305 | ||
306 | Int_t *fData; //! transient | |
db16520a | 307 | |
8e984e21 | 308 | /** indicate a virgin object and throw the warnig only once */ |
2a083ac4 | 309 | Int_t fMapErrThrown; //! transient |
db16520a | 310 | |
8e984e21 | 311 | ClassDef(AliHLTTPCDigitReaderRaw, 1) |
db16520a | 312 | |
313 | }; | |
314 | ||
db16520a | 315 | #endif |