]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCDigitReaderPacked.h
activating individual HLT simulations from digits and raw data
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReaderPacked.h
1 // XEmacs -*-C++-*-
2 // @(#) $Id$
3
4 #ifndef ALIHLTTPCDIGITREADERPACKED_H
5 #define ALIHLTTPCDIGITREADERPACKED_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   AliHLTTPCDigitReaderPacked.h
12     @author Timm Steinbeck, Jochen Thaeder, Matthias Richter, Kenneth Aamodt
13     @date   
14     @brief  A digit reader implementation for simulated, packed TPC 'raw' data.
15 */
16
17 #include "AliHLTTPCDigitReader.h"
18 #include <vector>
19
20 class AliRawReaderMemory;
21 class AliTPCRawStream;
22
23 /**
24  * @class AliHLTTPCDigitReaderPacked
25  * A digit reader implementation for simulated, packed TPC 'raw' data.
26  * Includes reordering of the pads by default, sorting (and time and
27  * memory consuming intermediate storing of the data) can be disabled
28  * by @ref SetUnsorted() with argument <b>kTRUE</b>.
29  *
30  * @ingroup alihlt_tpc
31  */
32 class AliHLTTPCDigitReaderPacked : public AliHLTTPCDigitReader{
33 public:
34   /** standard constructor */
35   AliHLTTPCDigitReaderPacked(); 
36   /** destructor */
37   virtual ~AliHLTTPCDigitReaderPacked();
38   
39   /**
40    * Init the reader with a data block.
41    * The function fetches the first and last row for the readout partition
42    * from @ref AliHLTTPCTransform.
43    * @param ptr     pointer to data buffer
44    * @param size    size of the data buffer
45    * @param patch   patch (readout partition) number within the slice
46    * @param slice   sector no (0 to 35)
47    */
48   Int_t InitBlock(void* ptr,ULong_t size, Int_t patch, Int_t slice);
49   int Reset();
50   void SetUnsorted(bool unsorted){fUnsorted=unsorted;}
51   Bool_t NextSignal();
52   Int_t GetRow();
53   Int_t GetPad();
54   Int_t GetSignal();
55   Int_t GetTime();
56   bool NextChannel();
57   int NextBunch();
58   AliHLTUInt32_t GetAltroBlockHWaddr() const;
59   int GetRCUTrailerSize();
60   bool GetRCUTrailerData(UChar_t*& trData);
61   int GetBunchSize();
62   const UInt_t* GetSignals();
63   Int_t GetTimeOfUnsortedSignal();    
64
65   /**
66    * Compound to hold both the AliTPCRawStreamInstance and the RawReader
67    */
68   class AliHLTTPCRawStream {
69   public:
70     AliHLTTPCRawStream();
71     ~AliHLTTPCRawStream();
72
73     Bool_t SetMemory(Int_t ddlId, UChar_t* memory, ULong_t size );
74
75     bool Next();
76
77     Int_t GetRow() const;
78     Int_t GetPad() const;
79     Int_t GetTime() const;
80     Int_t GetSignal() const;
81     Int_t GetHWAddress() const;
82     Bool_t  GetRCUTrailerData(UChar_t*& data) const;
83     Int_t   GetRCUTrailerSize() const;
84
85   private:
86     /** copy constructor prohibited */
87     AliHLTTPCRawStream(const AliHLTTPCRawStream&);
88     /** assignment operator prohibited */
89     AliHLTTPCRawStream& operator=(const AliHLTTPCRawStream&);
90
91     AliRawReaderMemory *fRawMemoryReader; //!transient
92     AliTPCRawStream *fTPCRawStream; //!transient
93   };
94 protected:
95     
96 private:
97   /** copy constructor prohibited */
98   AliHLTTPCDigitReaderPacked(const AliHLTTPCDigitReaderPacked&);
99   /** assignment operator prohibited */
100   AliHLTTPCDigitReaderPacked& operator=(const AliHLTTPCDigitReaderPacked&);
101
102   /**
103    * Instance handling of the buffer to hold the sorted data.
104    * In order to keep memory consumption small, one global buffer will be used
105    * for the sorted data.
106    * This can actually be extended in order to support more than one global
107    * instance provided by a scheduler, but thats overkill for the moment.
108    */
109   static Int_t* GetBufferInstance();
110
111   /**
112    * Release an instance of the buffer.
113    */
114   static void ReleaseBufferInstance(Int_t* pInstance);
115
116   /**
117    * Instance handling of the TPCRawStream.
118    * In order to keep memory consumption small, one global instance of the
119    * TPCRawStream will be used to read data.
120    * This can actually be extended in order to support more than one global
121    * instance provided by a scheduler, but thats overkill for the moment.
122    */
123   AliHLTTPCRawStream* GetRawStreamInstance();
124
125   /**
126    * Release an instance of the TPCRawStream.
127    */
128   void ReleaseRawStreamInstance(AliHLTTPCRawStream* pInstance);
129
130   AliHLTTPCRawStream* fTPCRawStream; //!transient
131
132   Int_t fCurrentRow; //!transient
133   Int_t fCurrentPad; //!transient
134   Int_t fCurrentBin; //!transient
135  
136   Int_t fRowOffset; //!transient
137   Int_t fNRows; //!transient
138   Int_t fNPads; //!transient
139
140   static Int_t fNMaxRows; //!transient
141   static Int_t fNMaxPads; //!transient
142   static Int_t fNTimeBins; //!transient
143
144   Int_t *fData; //!transient
145
146   Bool_t fUnsorted; //!transient
147
148   /** array to hold bunch data */
149   vector<UInt_t> fDataBunch;                             //! transient
150   /** the current channel for bulk read mode */
151   Int_t fCurrentChannel;                                 //! transient
152   /** last NextSignal returned data */
153   Int_t fbHaveData;                                      //! transient
154
155   /** partition the reader is initialized for */
156   Int_t fCurrentPatch;                                   //! transient
157
158   /** the global free instance of sorted data buffer */
159   static Int_t* fgpFreeBufferInstance;                   //! transient
160   /** occupied instance */
161   static Int_t* fgpIssuedBufferInstance;                 //! transient
162
163   /** the global free instance of the TPCRawStream */
164   static AliHLTTPCRawStream* fgpFreeStreamInstance;      //! transient
165   /** occupied instance of the TPCRawStream */
166   static AliHLTTPCRawStream* fgpIssuedStreamInstance;    //! transient
167
168   /** counter for instances of the reader */
169   static Int_t fgObjectCount;                            //! transient
170
171   ClassDef(AliHLTTPCDigitReaderPacked, 0)
172         
173 };
174
175 #endif