]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCDigitReaderRaw.h
commit from Jochen
[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
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#if defined(HAVE_TPC_MAPPING)
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.
84645eb0 35 * @ingroup alihlt_tpc
36 */
db16520a 37class AliHLTTPCDigitReaderRaw : public AliHLTTPCDigitReader {
38public:
f3f599e0 39
40 /** decode mode of the reader */
41 enum RawReaderMode {
42 /** 0: RCU Data format as delivered during TPC commissioning, pads/padrows
43 * are sorted, RCU trailer is one 32 bit word. */
44 kSorted1Trailerword=0,
45 /** 1: As 0, but pads/padrows are delivered "as is", without sorting */
46 kUnsorted1Trailerword,
47 /** 2: As 0, but RCU trailer is 3 32 bit words. */
48 kSorted3Trailerword,
49 /** 3: As 1, but RCU trailer is 3 32 bit words. */
50 kUnsorted3Trailerword,
51 /** 4: As 0, but RCU trailer is 2 32 bit words. */
52 kSorted2Trailerword,
53 /** 5: As 1, but RCU trailer is 2 32 bit words. */
54 kUnsorted2Trailerword,
55 /** number of modes */
56 kNofRawReaderModes
57 };
58
84645eb0 59 /** standard constructor
60 * @param formatVersion Data Format version numbers:
61 * - 0: RCU Data format as delivered during TPC commissioning, pads/padrows
62 * are sorted, RCU trailer is one 32 bit word.
63 * - 1: As 0, but pads/padrows are delivered "as is", without sorting
64 * - 2: As 0, but RCU trailer is 3 32 bit words.
65 * - 3: As 1, but RCU trailer is 3 32 bit words.
f3f599e0 66 * - 4: As 0, but RCU trailer is 2 32 bit words.
67 * - 5: As 1, but RCU trailer is 2 32 bit words.
84645eb0 68 */
69 AliHLTTPCDigitReaderRaw( unsigned formatVersion );
70 /** not a valid copy constructor, defined according to effective C++ style */
71 AliHLTTPCDigitReaderRaw(const AliHLTTPCDigitReaderRaw&);
72 /** not a valid assignment op, but defined according to effective C++ style */
73 AliHLTTPCDigitReaderRaw& operator=(const AliHLTTPCDigitReaderRaw&);
74 /** destructor */
75 virtual ~AliHLTTPCDigitReaderRaw();
db16520a 76
84645eb0 77 /**
78 * Init the reader with a data block.
79 * The function fetches the first and last row for the readout partition
80 * from @ref AliHLTTransform.
81 * @param ptr pointer to data buffer
82 * @param size size of the data buffer
83 * @param patch patch (readout partition) number within the slice
84 * @param slice sector no (0 to 35)
85 */
86 virtual int InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice);
87
78b557c2 88 /**
89 * Old Init function.
90 * <b>Note:</b> This method is for backward compatibility only, not for further
91 * use. The <i>firstrow</i> and <i>lastrow</i> parameters are fetched from
92 * @ref AliHLTTPCTransform. The method is implemented in the raw reader base class
93 * but is defined here to keep the signature of the library interface.
94 *
95 * @param ptr pointer to data buffer
96 * @param size size of the data buffer
97 * @param firstrow first row occuring in the data
98 * @param lastrow last row occuring in the data
99 * @param patch patch (readout partition) number within the slice
100 * @param slice sector no (0 to 35)
101 */
102 int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice);
103
db16520a 104 // Deliver values sorted for format 0, otherwise pass through to corresponding *Real* method
84645eb0 105 virtual bool Next();
106 virtual int GetRow();
107 virtual int GetPad();
108 virtual int GetSignal();
109 virtual int GetTime();
db16520a 110
111 bool Verify( bool verify )
112 {
113 bool old = fVerify;
114 fVerify=verify;
115 return old;
116 }
117
118 bool GetVerify() const
119 {
120 return fVerify;
121 }
122
123 // Deliver values unsorted
124 bool RealNext();
125 int GetRealRow();
126 int GetRealPad();
127 int GetRealSignal();
128 int GetRealTime();
129
130 // Low level methods for accessing the data
5235c3e9 131 AliHLTUInt32_t GetRCUTrailer( unsigned offset=0 );
db16520a 132 bool NextAltroBlock();
133 AliHLTUInt32_t GetAltroBlockHWaddr();
134 unsigned GetAltroBlock10BitWordCnt();
135 AliHLTUInt64_t GetAltroBlock40BitWord( unsigned long ndx ); // ndx counts from end, 0 is last
136 AliHLTUInt16_t GetAltroBlock10BitWord( unsigned long ndx );
137 AliHLTUInt16_t GetAltroBlockReal10BitWord( unsigned long ndx );
138
139 unsigned GetAltroBlockPositionBytes() const
140 {return fAltroBlockPositionBytes;}
141 unsigned GetAltroBlockLengthBytes() const
142 {return fAltroBlockLengthBytes;}
143
144 // Return length of trailing RCU data block in bytes
145 unsigned GetRCUDataBlockLength() const;
146 unsigned GetCommonDataHeaderSize() const;
147
148 Bool_t ApplyMapping();
149
150 Int_t GetRow( unsigned patch, unsigned hw_addr );
151 Int_t GetPad( unsigned patch, unsigned hw_addr );
152 unsigned GetMaxHWA( unsigned patch );
153
f3f599e0 154 /**
155 * This function decodes the rawreadermode set in HLT***Components
156 * or the AliHLTGUI and returns the integer value of @ref RawReaderMode.
157 * @param mode const Char_t * argument <br>
158 * sorted_3_trailerword -> @ref kSorted3Trailerword <br>
159 * sorted_2_trailerword -> @ref kSorted2Trailerword <br>
160 * sorted_1_trailerword -> @ref kSorted1Trailerword <br>
161 * unsorted_3_trailerword -> @ref kUnsorted3Trailerword <br>
162 * unsorted_2_trailerword -> @ref kUnsorted2Trailerword <br>
163 * unsorted_1_trailerword -> @ref kUnsorted1Trailerword <br>
164 * @return rawreadermode @ref RawReaderMode and -1 if decoding fails
165 */
166 static Int_t DecodeMode(const Char_t *mode);
167
168 /**
169 * This function sets the rawreadermode from an enum.
170 * The name was chosen in order to use the two methods with either
171 * a Char_t array or an Int_t.
172 * @param mode mode enum @ref RawReaderMode
173 * @return rawreadermode @ref RawReaderMode and -1 if decoding fails
174 */
175 static Int_t DecodeMode(Int_t mode);
176
db16520a 177protected:
178
179 AliHLTUInt8_t* fBuffer;
180 unsigned long fBufferSize;
181 /*
182 Int_t fFirstRow;
183 Int_t fLastRow;
184 */
185 Int_t fPatch;
186 Int_t fSlice;
187 Int_t fRow;
188 Int_t fPad;
189
190 unsigned fAltroBlockPositionBytes;
191 unsigned fAltroBlockLengthBytes;
192
193 AliHLTUInt16_t fAltroBlockHWAddress;
194 AliHLTUInt16_t fAltroBlock10BitWordCnt;
195 AliHLTUInt16_t fAltroBlock10BitFillWordCnt;
196
197 unsigned fDataFormatVersion;
198
199 unsigned fBunchPosition;
200 unsigned fBunchTimebinStart;
201 unsigned fBunchLength;
202 unsigned fWordInBunch;
203
204 bool fVerify;
205
206private:
207 static Int_t fMapping_0[3200][2];
208 static Int_t fMapping_1[3584][2];
209 static Int_t fMapping_2[3200][2];
210 static Int_t fMapping_3[3328][2];
211 static Int_t fMapping_4[3328][2];
212 static Int_t fMapping_5[3328][2];
213
214 static unsigned fMaxHWA[6];
215
216 // For reordering
217 Int_t fCurrentRow;
218 Int_t fCurrentPad;
219 Int_t fCurrentBin;
220
221 Int_t fRowOffset;
222 Int_t fNRows;
223
224 Int_t fNMaxRows;
225 Int_t fNMaxPads;
226 Int_t fNTimeBins;
227
228 Int_t *fData;
229
230
231 ClassDef(AliHLTTPCDigitReaderRaw, 0)
232
233};
234
235#else
236// add a dummy class to make CINT happy
237class AliHLTTPCDigitReaderRaw : public AliHLTLogging{
238public:
239 AliHLTTPCDigitReaderRaw()
240 {
241 HLTFatal("AliHLTTPCDigitReaderRaw not build");
242 }
243};
244#endif //#if defined(HAVE_TPC_MAPPING)
245
246#endif
247