]>
Commit | Line | Data |
---|---|---|
a38a7850 | 1 | // XEmacs -*-C++-*- |
2 | // @(#) $Id$ | |
3 | ||
4 | #ifndef ALIHLTTPCDIGITREADER_H | |
5 | #define ALIHLTTPCDIGITREADER_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 * | |
a38a7850 | 10 | |
600e6a1b | 11 | /** @file AliHLTTPCDigitReader.h |
27f5f8ed | 12 | @author Timm Steinbeck, Jochen Thaeder, Matthias Richter, Kenneth Aamodt |
84645eb0 | 13 | @date |
14 | @brief An abstract reader class for TPC data. | |
15 | */ | |
a38a7850 | 16 | |
db16520a | 17 | #include "AliHLTLogging.h" |
a38a7850 | 18 | #include "TObject.h" |
19 | ||
84645eb0 | 20 | /** |
21 | * @class AliHLTTPCDigitReader | |
22 | * An abstract reader class for the TPC data. The Data is treated as a stream | |
23 | * of data points, each containing row number, pad number, time bin and ADC | |
24 | * value. The class hides the actual encoding of the data stream for the sub- | |
25 | * sequent components like the cluster finder. | |
f44e97dc | 26 | * |
27 | * Some of the data decoders allow random access of the data within one channel. | |
28 | * This functionality is available for all readers if caching is enabled (see | |
29 | * @ref EnableCaching). | |
30 | * | |
31 | * The digit reader can be locked for the current channel. If locked, function | |
32 | * @ref Next will return false if data of the current channel is finnished. | |
84645eb0 | 33 | * @ingroup alihlt_tpc |
34 | */ | |
db16520a | 35 | class AliHLTTPCDigitReader : public AliHLTLogging { |
a38a7850 | 36 | public: |
f44e97dc | 37 | /** standard constructor |
38 | */ | |
a38a7850 | 39 | AliHLTTPCDigitReader(); |
84645eb0 | 40 | /** destructor */ |
a38a7850 | 41 | virtual ~AliHLTTPCDigitReader(); |
42 | ||
84645eb0 | 43 | /** |
44 | * Init the reader with a data block. | |
45 | * The function fetches the first and last row for the readout partition | |
600e6a1b | 46 | * from @ref AliHLTTPCTransform. The method is pure virtual and must be implemented |
84645eb0 | 47 | * by the child class. |
48 | * @param ptr pointer to data buffer | |
49 | * @param size size of the data buffer | |
50 | * @param patch patch (readout partition) number within the slice | |
51 | * @param slice sector no (0 to 35) | |
52 | */ | |
53 | virtual int InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice)=0; | |
54 | ||
55 | /** | |
56 | * Old Init function. | |
57 | * <b>Note:</b> This method is for backward compatibility only, not for further | |
58 | * use. The <i>firstrow</i> and <i>lastrow</i> parameters are fetched from | |
59 | * @ref AliHLTTPCTransform. | |
60 | * | |
61 | * @param ptr pointer to data buffer | |
62 | * @param size size of the data buffer | |
63 | * @param firstrow first row occuring in the data | |
64 | * @param lastrow last row occuring in the data | |
65 | * @param patch patch (readout partition) number within the slice | |
66 | * @param slice sector no (0 to 35) | |
67 | */ | |
78b557c2 | 68 | virtual int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice); |
84645eb0 | 69 | |
e03c4cc0 | 70 | enum { |
71 | kNextSignal = 1, | |
72 | kNextChannel, | |
73 | kNextBunch, | |
74 | kLastValidModifier | |
75 | }; | |
76 | ||
84645eb0 | 77 | /** |
78 | * Set the reader position to the next value. | |
79 | * If the reader was not yet initialized, initialization is carried out and | |
80 | * the position set to the beginning of the stream (which is in essence the | |
81 | * end of the data block due to the back-linked list). | |
f44e97dc | 82 | * |
e03c4cc0 | 83 | * The modifiers determine the unit of the positioning: |
84 | * - @ref kNextSignal set to the next signal value | |
85 | * - @ref kNextChannel set at the beginning of the next channel | |
86 | * - @ref kNextBunch set at the beginning of the next bunch within the | |
87 | * current channel. | |
88 | * | |
f44e97dc | 89 | * If the reader is locked for a pad/channel, Next operates only on the data |
90 | * belonging to the current channel and returns false at the end of the | |
91 | * channel. | |
92 | * | |
e03c4cc0 | 93 | * The function does some basic stuff and forwards to @ref NextSignal, @ref |
94 | * NextBunch or @ref NextChannel depending on the modifer. This function is | |
95 | * also necessary if the common sorting is going to be used (not yet implemented) | |
f44e97dc | 96 | * @return true if data is available, false if not |
84645eb0 | 97 | */ |
e03c4cc0 | 98 | bool Next(int type=kNextSignal); |
99 | ||
100 | /** | |
101 | * Set stream position to the next Pad (ALTRO channel). | |
102 | * This is the direct entry to data access on a channel/bunch basis suited | |
103 | * for fast data access. | |
104 | * @return true if data is available, false if not | |
105 | */ | |
106 | virtual bool NextChannel(); | |
107 | ||
108 | /** | |
109 | * Set stream to the next ALTRO bunch within the current pad. | |
110 | * This is the direct entry to data access on a channel/bunch basis suited | |
111 | * for fast data access. | |
112 | * @return bunch length, 0 if no data bunch available in the current pad | |
113 | */ | |
114 | virtual int NextBunch(); | |
84645eb0 | 115 | |
70d0b23e | 116 | /** |
117 | * Get current hardware address. | |
118 | */ | |
119 | virtual AliHLTUInt32_t GetAltroBlockHWaddr() const; | |
120 | ||
84645eb0 | 121 | /** |
122 | * Get the row number of the current value. | |
123 | */ | |
a38a7850 | 124 | virtual int GetRow()=0; |
84645eb0 | 125 | |
126 | /** | |
127 | * Get the pad number of the current value. | |
128 | */ | |
a38a7850 | 129 | virtual int GetPad()=0; |
84645eb0 | 130 | |
131 | /** | |
132 | * Get the current ADC value. | |
133 | */ | |
a38a7850 | 134 | virtual int GetSignal()=0; |
84645eb0 | 135 | |
e03c4cc0 | 136 | /** |
137 | * Get pointer to the the current ADC value. | |
138 | */ | |
7dceaa9b | 139 | virtual const UInt_t* GetSignals(); |
e03c4cc0 | 140 | |
84645eb0 | 141 | /** |
142 | * Get the time bin of the current value. | |
e03c4cc0 | 143 | * If @ref NextBunch has been used the function returns the |
144 | * first time bin of the bunch. | |
84645eb0 | 145 | */ |
a38a7850 | 146 | virtual int GetTime()=0; |
147 | ||
27f5f8ed | 148 | /** |
149 | * Method to use old rcu fomat. | |
150 | */ | |
151 | virtual void SetOldRCUFormat(Bool_t oldrcuformat); | |
152 | ||
01f43166 | 153 | /** |
154 | * Method to set read unsorted flag. | |
155 | */ | |
156 | virtual void SetUnsorted(Bool_t unsorted); | |
157 | ||
f44e97dc | 158 | /** |
159 | * Enable chaching of the current channel. | |
160 | * Some of the readers allow random data access within one channel. | |
161 | * The others have the possibility to cache the data in order to support | |
162 | * this functionality. Caching is off by default. | |
163 | * @param bCache the current channel is cached | |
164 | */ | |
165 | void EnableCaching(bool bCache=false); | |
166 | ||
167 | /** | |
168 | * Rewind the current channel to the beginning. | |
169 | * The function uses the reader methods @ref RewindCurrentChannel or | |
170 | * @ref RewindToPrevChannel to set the stream position to the beginning of the | |
171 | * current channel. If the reader is locked for a channel, the function | |
172 | * rewinds to the begnning of that channel. | |
173 | */ | |
174 | int RewindChannel(); | |
175 | ||
7dceaa9b | 176 | /** |
177 | * Returns the bunch size. Used by the fast decoder. | |
178 | */ | |
179 | virtual int GetBunchSize(); | |
180 | ||
d2f725e4 | 181 | /** |
182 | * Returns the row offset. Used by the fast decoder. | |
183 | */ | |
184 | virtual int GetRowOffset() const; | |
185 | ||
f44e97dc | 186 | /** |
187 | * Access operator to the data of a specific time bin. | |
188 | * Not clear if we can manage this. | |
189 | */ | |
190 | //int operator[](int timebin); | |
191 | ||
192 | class LockGuard { | |
193 | public: | |
194 | /** constructor, locks reader for the current pad */ | |
195 | LockGuard(AliHLTTPCDigitReader& reader) | |
196 | : fReader(reader) | |
197 | {reader.fLckRow=reader.GetRow(); reader.fLckPad=reader.GetPad(); reader.SetFlag(kLocked);} | |
198 | /** destructor, unlocks reader */ | |
199 | ~LockGuard() | |
200 | {fReader.ClearFlag(kLocked|kChannelOverwrap); fReader.fLckRow=-1; fReader.fLckPad=-1;} | |
201 | ||
202 | private: | |
203 | /** instance of the controlled reader */ | |
204 | AliHLTTPCDigitReader& fReader; //!transient | |
205 | }; | |
206 | ||
207 | enum { | |
208 | /** reader locked for the current channel */ | |
209 | kLocked = 0x1, | |
210 | /** stream position already at the next channel */ | |
211 | kChannelOverwrap = 0x2, | |
212 | /** reader doe not allow channel rewind */ | |
213 | kNoRewind = 0x4, | |
e03c4cc0 | 214 | /** warning missing fast access methods */ |
215 | kWarnMissFastAccess = 0x8, | |
f44e97dc | 216 | /** channel caching enabled */ |
217 | kChannelCaching = 0x100 | |
218 | }; | |
a38a7850 | 219 | protected: |
f44e97dc | 220 | /** |
221 | * Set the reader position to the next value. | |
222 | * This is the reader specific method called by @ref Next. | |
e03c4cc0 | 223 | * @return true if data is available, false if not |
f44e97dc | 224 | */ |
225 | virtual bool NextSignal()=0; | |
226 | ||
227 | /** | |
228 | * Set a status flag of the reader. | |
229 | * @return current value of the status flags | |
230 | */ | |
231 | unsigned int SetFlag(unsigned int flag); | |
a38a7850 | 232 | |
f44e97dc | 233 | /** |
234 | * Clear a status flag of the reader. | |
235 | * @return current value of the status flags | |
236 | */ | |
237 | unsigned int ClearFlag(unsigned int flag); | |
238 | ||
239 | /** | |
240 | * Check a status flag of the reader. | |
241 | */ | |
f32b83e1 | 242 | int CheckFlag(unsigned int flag) const {return (fFlags&flag)!=0;} |
f44e97dc | 243 | |
244 | /** | |
245 | * Rewind to the beginning.of the current channel. | |
246 | */ | |
247 | virtual int RewindCurrentChannel(); | |
248 | ||
249 | /** | |
250 | * Rewind to the beginning of the previous channel. | |
251 | */ | |
252 | virtual int RewindToPrevChannel(); | |
253 | ||
a38a7850 | 254 | private: |
e03c4cc0 | 255 | /** |
256 | * Print a warning on the missing fast access methods. | |
257 | * Set corresponding flag to avoid repetitive warnings. | |
258 | */ | |
259 | void PrintMissingFastAccessWarning(); | |
260 | ||
f44e97dc | 261 | /** pad/channel is locked */ |
262 | unsigned int fFlags; //!transient | |
263 | ||
264 | /** row the reader is locked to */ | |
265 | int fLckRow; //!transient | |
266 | ||
267 | /** pad the reader is locked to */ | |
268 | int fLckPad; //!transient | |
a38a7850 | 269 | |
270 | ClassDef(AliHLTTPCDigitReader, 0) | |
271 | ||
272 | }; | |
273 | #endif | |
274 |