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