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