4 #ifndef ALIHLTTPCDIGITREADER_H
5 #define ALIHLTTPCDIGITREADER_H
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 */
11 /** @file AliHLTTPCDigitReader.h
12 @author Timm Steinbeck, Jochen Thaeder, Matthias Richter, Kenneth Aamodt
14 @brief An abstract reader class for TPC data.
17 // see below for class documentation
19 // refer to README to build package
21 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
23 #include "AliHLTLogging.h"
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.
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).
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.
41 class AliHLTTPCDigitReader : public AliHLTLogging {
43 /** standard constructor
45 AliHLTTPCDigitReader();
47 virtual ~AliHLTTPCDigitReader();
50 * Init the reader with a data block.
51 * The function fetches the first and last row for the readout partition
52 * from @ref AliHLTTPCTransform. The method is pure virtual and must be implemented
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)
59 virtual int InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice)=0;
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.
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)
74 virtual int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice);
77 * Set the reader position to the next value.
78 * If the reader was not yet initialized, initialization is carried out and
79 * the position set to the beginning of the stream (which is in essence the
80 * end of the data block due to the back-linked list).
82 * If the reader is locked for a pad/channel, Next operates only on the data
83 * belonging to the current channel and returns false at the end of the
86 * The function does some basic stuff and forwards to @ref NextSignal.
87 * @return true if data is available, false if not
92 * Get the row number of the current value.
94 virtual int GetRow()=0;
97 * Get the pad number of the current value.
99 virtual int GetPad()=0;
102 * Get the current ADC value.
104 virtual int GetSignal()=0;
107 * Get the time bin of the current value.
109 virtual int GetTime()=0;
112 * Method to use old rcu fomat.
114 virtual void SetOldRCUFormat(Bool_t oldrcuformat);
117 * Method to set read unsorted flag.
119 virtual void SetUnsorted(Bool_t unsorted);
122 * Enable chaching of the current channel.
123 * Some of the readers allow random data access within one channel.
124 * The others have the possibility to cache the data in order to support
125 * this functionality. Caching is off by default.
126 * @param bCache the current channel is cached
128 void EnableCaching(bool bCache=false);
131 * Rewind the current channel to the beginning.
132 * The function uses the reader methods @ref RewindCurrentChannel or
133 * @ref RewindToPrevChannel to set the stream position to the beginning of the
134 * current channel. If the reader is locked for a channel, the function
135 * rewinds to the begnning of that channel.
140 * Access operator to the data of a specific time bin.
141 * Not clear if we can manage this.
143 //int operator[](int timebin);
147 /** constructor, locks reader for the current pad */
148 LockGuard(AliHLTTPCDigitReader& reader)
150 {reader.fLckRow=reader.GetRow(); reader.fLckPad=reader.GetPad(); reader.SetFlag(kLocked);}
151 /** destructor, unlocks reader */
153 {fReader.ClearFlag(kLocked|kChannelOverwrap); fReader.fLckRow=-1; fReader.fLckPad=-1;}
156 /** instance of the controlled reader */
157 AliHLTTPCDigitReader& fReader; //!transient
161 /** reader locked for the current channel */
163 /** stream position already at the next channel */
164 kChannelOverwrap = 0x2,
165 /** reader doe not allow channel rewind */
167 /** channel caching enabled */
168 kChannelCaching = 0x100
172 * Set the reader position to the next value.
173 * This is the reader specific method called by @ref Next.
175 virtual bool NextSignal()=0;
178 * Set a status flag of the reader.
179 * @return current value of the status flags
181 unsigned int SetFlag(unsigned int flag);
184 * Clear a status flag of the reader.
185 * @return current value of the status flags
187 unsigned int ClearFlag(unsigned int flag);
190 * Check a status flag of the reader.
192 int CheckFlag(unsigned int flag) const {return (fFlags&flag)!=0;}
195 * Rewind to the beginning.of the current channel.
197 virtual int RewindCurrentChannel();
200 * Rewind to the beginning of the previous channel.
202 virtual int RewindToPrevChannel();
205 /** pad/channel is locked */
206 unsigned int fFlags; //!transient
208 /** row the reader is locked to */
209 int fLckRow; //!transient
211 /** pad the reader is locked to */
212 int fLckPad; //!transient
214 ClassDef(AliHLTTPCDigitReader, 0)