]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCDigitReader.h
Remove initialization of the tracklet pointer to get rid of compiler warning
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReader.h
1 // XEmacs -*-C++-*-
2 // @(#) $Id$
3
4 #ifndef ALIHLTTPCDIGITREADER_H
5 #define ALIHLTTPCDIGITREADER_H
6
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                               */
10
11 /** @file   AliHLTTPCDigitReader.h
12     @author Timm Steinbeck, Jochen Thaeder, Matthias Richter, Kenneth Aamodt
13     @date   
14     @brief  An abstract reader class for TPC data.
15 */
16
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
23 #include "AliHLTLogging.h"
24 #include "TObject.h"
25
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.
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.
39  * @ingroup alihlt_tpc
40  */
41 class AliHLTTPCDigitReader : public AliHLTLogging {
42 public:
43   /** standard constructor 
44    */
45   AliHLTTPCDigitReader();
46   /** destructor */
47   virtual ~AliHLTTPCDigitReader();
48   
49   /**
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
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    */
74   virtual int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice);
75
76   /**
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).
81    *
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
84    * channel.
85    * 
86    * The function does some basic stuff and forwards to @ref NextSignal.
87    * @return true if data is available, false if not
88    */
89   bool Next();
90
91   /**
92    * Get the row number of the current value.
93    */
94   virtual int GetRow()=0;
95
96   /**
97    * Get the pad number of the current value.
98    */
99   virtual int GetPad()=0;
100
101   /**
102    * Get the current ADC value.
103    */
104   virtual int GetSignal()=0;
105
106   /**
107    * Get the time bin of the current value.
108    */
109   virtual int GetTime()=0;
110
111   /**
112    * Method to use old rcu fomat.
113    */
114   virtual void SetOldRCUFormat(Bool_t oldrcuformat);
115
116   /**
117    * Method to set read unsorted flag.
118    */
119   virtual void SetUnsorted(Bool_t unsorted);
120
121   /**
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
127    */ 
128   void EnableCaching(bool bCache=false);
129
130   /**
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.
136    */
137   int RewindChannel();
138
139   /**
140    * Access operator to the data of a specific time bin.
141    * Not clear if we can manage this.
142    */
143   //int operator[](int timebin);
144
145   class LockGuard {
146   public:
147     /** constructor, locks reader for the current pad */
148     LockGuard(AliHLTTPCDigitReader& reader) 
149       : fReader(reader) 
150     {reader.fLckRow=reader.GetRow(); reader.fLckPad=reader.GetPad(); reader.SetFlag(kLocked);}
151     /** destructor, unlocks reader */
152     ~LockGuard()
153     {fReader.ClearFlag(kLocked|kChannelOverwrap); fReader.fLckRow=-1; fReader.fLckPad=-1;}
154
155   private:
156     /** instance of the controlled reader */
157     AliHLTTPCDigitReader& fReader;                                //!transient
158   };
159
160   enum {
161     /** reader locked for the current channel */
162     kLocked = 0x1,
163     /** stream position already at the next channel */
164     kChannelOverwrap = 0x2,
165     /** reader doe not allow channel rewind */
166     kNoRewind = 0x4,
167     /** channel caching enabled */
168     kChannelCaching = 0x100
169   };
170 protected:
171   /**
172    * Set the reader position to the next value.
173    * This is the reader specific method called by @ref Next.
174    */
175   virtual bool NextSignal()=0;
176
177   /**
178    * Set a status flag of the reader.
179    * @return current value of the status flags
180    */
181   unsigned int SetFlag(unsigned int flag);
182         
183   /**
184    * Clear a status flag of the reader.
185    * @return current value of the status flags
186    */
187   unsigned int ClearFlag(unsigned int flag);
188         
189   /**
190    * Check a status flag of the reader.
191    */
192   int CheckFlag(unsigned int flag) const {return (fFlags&flag)!=0;}
193
194   /**
195    * Rewind to the beginning.of the current channel.
196    */
197   virtual int RewindCurrentChannel();
198
199   /**
200    * Rewind to the beginning of the previous channel.
201    */
202   virtual int RewindToPrevChannel();
203
204 private:
205   /** pad/channel is locked */
206   unsigned int fFlags;                                    //!transient
207
208   /** row the reader is locked to */
209   int fLckRow;                                                //!transient
210
211   /** pad the reader is locked to */
212   int fLckPad;                                                //!transient
213
214   ClassDef(AliHLTTPCDigitReader, 0)
215     
216 };
217 #endif
218