- moved AliHLTDisplay files from TPCLib to TPCLib/OnlineDisplay
[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.
33 * @ingroup alihlt_tpc
34 */
db16520a 35class AliHLTTPCDigitReaderRaw : public AliHLTTPCDigitReader {
36public:
84645eb0 37 /** standard constructor
38 * @param formatVersion Data Format version numbers:
39 * - 0: RCU Data format as delivered during TPC commissioning, pads/padrows
40 * are sorted, RCU trailer is one 32 bit word.
41 * - 1: As 0, but pads/padrows are delivered "as is", without sorting
42 * - 2: As 0, but RCU trailer is 3 32 bit words.
43 * - 3: As 1, but RCU trailer is 3 32 bit words.
44 */
45 AliHLTTPCDigitReaderRaw( unsigned formatVersion );
46 /** not a valid copy constructor, defined according to effective C++ style */
47 AliHLTTPCDigitReaderRaw(const AliHLTTPCDigitReaderRaw&);
48 /** not a valid assignment op, but defined according to effective C++ style */
49 AliHLTTPCDigitReaderRaw& operator=(const AliHLTTPCDigitReaderRaw&);
50 /** destructor */
51 virtual ~AliHLTTPCDigitReaderRaw();
db16520a 52
84645eb0 53 /**
54 * Init the reader with a data block.
55 * The function fetches the first and last row for the readout partition
56 * from @ref AliHLTTransform.
57 * @param ptr pointer to data buffer
58 * @param size size of the data buffer
59 * @param patch patch (readout partition) number within the slice
60 * @param slice sector no (0 to 35)
61 */
62 virtual int InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice);
63
78b557c2 64 /**
65 * Old Init function.
66 * <b>Note:</b> This method is for backward compatibility only, not for further
67 * use. The <i>firstrow</i> and <i>lastrow</i> parameters are fetched from
68 * @ref AliHLTTPCTransform. The method is implemented in the raw reader base class
69 * but is defined here to keep the signature of the library interface.
70 *
71 * @param ptr pointer to data buffer
72 * @param size size of the data buffer
73 * @param firstrow first row occuring in the data
74 * @param lastrow last row occuring in the data
75 * @param patch patch (readout partition) number within the slice
76 * @param slice sector no (0 to 35)
77 */
78 int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice);
79
db16520a 80 // Deliver values sorted for format 0, otherwise pass through to corresponding *Real* method
84645eb0 81 virtual bool Next();
82 virtual int GetRow();
83 virtual int GetPad();
84 virtual int GetSignal();
85 virtual int GetTime();
db16520a 86
87 bool Verify( bool verify )
88 {
89 bool old = fVerify;
90 fVerify=verify;
91 return old;
92 }
93
94 bool GetVerify() const
95 {
96 return fVerify;
97 }
98
99 // Deliver values unsorted
100 bool RealNext();
101 int GetRealRow();
102 int GetRealPad();
103 int GetRealSignal();
104 int GetRealTime();
105
106 // Low level methods for accessing the data
107 AliHLTUInt32_t GetRCUTrailer();
108 bool NextAltroBlock();
109 AliHLTUInt32_t GetAltroBlockHWaddr();
110 unsigned GetAltroBlock10BitWordCnt();
111 AliHLTUInt64_t GetAltroBlock40BitWord( unsigned long ndx ); // ndx counts from end, 0 is last
112 AliHLTUInt16_t GetAltroBlock10BitWord( unsigned long ndx );
113 AliHLTUInt16_t GetAltroBlockReal10BitWord( unsigned long ndx );
114
115 unsigned GetAltroBlockPositionBytes() const
116 {return fAltroBlockPositionBytes;}
117 unsigned GetAltroBlockLengthBytes() const
118 {return fAltroBlockLengthBytes;}
119
120 // Return length of trailing RCU data block in bytes
121 unsigned GetRCUDataBlockLength() const;
122 unsigned GetCommonDataHeaderSize() const;
123
124 Bool_t ApplyMapping();
125
126 Int_t GetRow( unsigned patch, unsigned hw_addr );
127 Int_t GetPad( unsigned patch, unsigned hw_addr );
128 unsigned GetMaxHWA( unsigned patch );
129
130protected:
131
132 AliHLTUInt8_t* fBuffer;
133 unsigned long fBufferSize;
134 /*
135 Int_t fFirstRow;
136 Int_t fLastRow;
137 */
138 Int_t fPatch;
139 Int_t fSlice;
140 Int_t fRow;
141 Int_t fPad;
142
143 unsigned fAltroBlockPositionBytes;
144 unsigned fAltroBlockLengthBytes;
145
146 AliHLTUInt16_t fAltroBlockHWAddress;
147 AliHLTUInt16_t fAltroBlock10BitWordCnt;
148 AliHLTUInt16_t fAltroBlock10BitFillWordCnt;
149
150 unsigned fDataFormatVersion;
151
152 unsigned fBunchPosition;
153 unsigned fBunchTimebinStart;
154 unsigned fBunchLength;
155 unsigned fWordInBunch;
156
157 bool fVerify;
158
159private:
160 static Int_t fMapping_0[3200][2];
161 static Int_t fMapping_1[3584][2];
162 static Int_t fMapping_2[3200][2];
163 static Int_t fMapping_3[3328][2];
164 static Int_t fMapping_4[3328][2];
165 static Int_t fMapping_5[3328][2];
166
167 static unsigned fMaxHWA[6];
168
169 // For reordering
170 Int_t fCurrentRow;
171 Int_t fCurrentPad;
172 Int_t fCurrentBin;
173
174 Int_t fRowOffset;
175 Int_t fNRows;
176
177 Int_t fNMaxRows;
178 Int_t fNMaxPads;
179 Int_t fNTimeBins;
180
181 Int_t *fData;
182
183
184 ClassDef(AliHLTTPCDigitReaderRaw, 0)
185
186};
187
188#else
189// add a dummy class to make CINT happy
190class AliHLTTPCDigitReaderRaw : public AliHLTLogging{
191public:
192 AliHLTTPCDigitReaderRaw()
193 {
194 HLTFatal("AliHLTTPCDigitReaderRaw not build");
195 }
196};
197#endif //#if defined(HAVE_TPC_MAPPING)
198
199#endif
200