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