]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCDigitReader.h
Adding a getter which would allow to acess the number of tracks per alignable element...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReader.h
CommitLineData
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 41class AliHLTTPCDigitReader : public AliHLTLogging {
a38a7850 42public:
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
122 /**
123 * Get the row number of the current value.
124 */
a38a7850 125 virtual int GetRow()=0;
84645eb0 126
127 /**
128 * Get the pad number of the current value.
129 */
a38a7850 130 virtual int GetPad()=0;
84645eb0 131
132 /**
133 * Get the current ADC value.
134 */
a38a7850 135 virtual int GetSignal()=0;
84645eb0 136
e03c4cc0 137 /**
138 * Get pointer to the the current ADC value.
139 */
140 virtual AliHLTUInt32_t* GetSignals();
141
84645eb0 142 /**
143 * Get the time bin of the current value.
e03c4cc0 144 * If @ref NextBunch has been used the function returns the
145 * first time bin of the bunch.
84645eb0 146 */
a38a7850 147 virtual int GetTime()=0;
148
27f5f8ed 149 /**
150 * Method to use old rcu fomat.
151 */
152 virtual void SetOldRCUFormat(Bool_t oldrcuformat);
153
01f43166 154 /**
155 * Method to set read unsorted flag.
156 */
157 virtual void SetUnsorted(Bool_t unsorted);
158
f44e97dc 159 /**
160 * Enable chaching of the current channel.
161 * Some of the readers allow random data access within one channel.
162 * The others have the possibility to cache the data in order to support
163 * this functionality. Caching is off by default.
164 * @param bCache the current channel is cached
165 */
166 void EnableCaching(bool bCache=false);
167
168 /**
169 * Rewind the current channel to the beginning.
170 * The function uses the reader methods @ref RewindCurrentChannel or
171 * @ref RewindToPrevChannel to set the stream position to the beginning of the
172 * current channel. If the reader is locked for a channel, the function
173 * rewinds to the begnning of that channel.
174 */
175 int RewindChannel();
176
177 /**
178 * Access operator to the data of a specific time bin.
179 * Not clear if we can manage this.
180 */
181 //int operator[](int timebin);
182
183 class LockGuard {
184 public:
185 /** constructor, locks reader for the current pad */
186 LockGuard(AliHLTTPCDigitReader& reader)
187 : fReader(reader)
188 {reader.fLckRow=reader.GetRow(); reader.fLckPad=reader.GetPad(); reader.SetFlag(kLocked);}
189 /** destructor, unlocks reader */
190 ~LockGuard()
191 {fReader.ClearFlag(kLocked|kChannelOverwrap); fReader.fLckRow=-1; fReader.fLckPad=-1;}
192
193 private:
194 /** instance of the controlled reader */
195 AliHLTTPCDigitReader& fReader; //!transient
196 };
197
198 enum {
199 /** reader locked for the current channel */
200 kLocked = 0x1,
201 /** stream position already at the next channel */
202 kChannelOverwrap = 0x2,
203 /** reader doe not allow channel rewind */
204 kNoRewind = 0x4,
e03c4cc0 205 /** warning missing fast access methods */
206 kWarnMissFastAccess = 0x8,
f44e97dc 207 /** channel caching enabled */
208 kChannelCaching = 0x100
209 };
a38a7850 210protected:
f44e97dc 211 /**
212 * Set the reader position to the next value.
213 * This is the reader specific method called by @ref Next.
e03c4cc0 214 * @return true if data is available, false if not
f44e97dc 215 */
216 virtual bool NextSignal()=0;
217
218 /**
219 * Set a status flag of the reader.
220 * @return current value of the status flags
221 */
222 unsigned int SetFlag(unsigned int flag);
a38a7850 223
f44e97dc 224 /**
225 * Clear a status flag of the reader.
226 * @return current value of the status flags
227 */
228 unsigned int ClearFlag(unsigned int flag);
229
230 /**
231 * Check a status flag of the reader.
232 */
f32b83e1 233 int CheckFlag(unsigned int flag) const {return (fFlags&flag)!=0;}
f44e97dc 234
235 /**
236 * Rewind to the beginning.of the current channel.
237 */
238 virtual int RewindCurrentChannel();
239
240 /**
241 * Rewind to the beginning of the previous channel.
242 */
243 virtual int RewindToPrevChannel();
244
a38a7850 245private:
e03c4cc0 246 /**
247 * Print a warning on the missing fast access methods.
248 * Set corresponding flag to avoid repetitive warnings.
249 */
250 void PrintMissingFastAccessWarning();
251
f44e97dc 252 /** pad/channel is locked */
253 unsigned int fFlags; //!transient
254
255 /** row the reader is locked to */
256 int fLckRow; //!transient
257
258 /** pad the reader is locked to */
259 int fLckPad; //!transient
a38a7850 260
261 ClassDef(AliHLTTPCDigitReader, 0)
262
263};
264#endif
265