]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDRawReader.h
Clean-up of include files
[u/mrichter/AliRoot.git] / FMD / AliFMDRawReader.h
1 #ifndef ALIFMDRAWREADER_H
2 #define ALIFMDRAWREADER_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
4  * reserved. 
5  *
6  * Latest changes by Christian Holm Christensen <cholm@nbi.dk>
7  *
8  * See cxx source for full Copyright notice                               
9  */
10 //____________________________________________________________________
11 // 
12 // Class to read ADC values from a AliRawReader object. 
13 // Note, that it uses an ALTRO reader, which is wrong. 
14 // Perhaps we need to implement it our selves
15 // 
16 /* $Id$ */
17 /** @file    AliFMDRawReader.h
18     @author  Christian Holm Christensen <cholm@nbi.dk>
19     @date    Mon Mar 27 12:45:23 2006
20     @brief   Class to read raw data 
21     @ingroup FMD_rec
22 */
23 #ifndef ROOT_TTask
24 # include <TTask.h>
25 #endif
26 #include "AliFMDUShortMap.h"
27
28 //____________________________________________________________________
29 class AliRawReader;
30 class AliAltroRawStreamV3;
31 class TTree;
32 class TClonesArray;
33 class TArrayS;
34 class AliFMDCalibSampleRate;
35 class AliFMDCalibStripRange;
36
37 //____________________________________________________________________
38 /** @brief Class to read ALTRO formated raw data from an AliRawReader
39     object. 
40     @code 
41     AliRawReader*    reader    = new AliRawReaderFile(0);
42     AliFMDRawReader* fmdReader = new AliFMDRawReader(reader);
43     TClonesArray*    array     = new TClonesArray("AliFMDDigit");
44     fmdReader->ReadAdcs(array);
45     @endcode 
46     @ingroup FMD_rec
47 */
48 class AliFMDRawReader : public TTask 
49 {
50 public:
51   /** 
52    * CTOR 
53    *
54    * @param reader Raw reader
55    * @param array  Output tree 
56    */
57   AliFMDRawReader(AliRawReader* reader, TTree* array);
58   /** 
59    * DTOR 
60    */
61   virtual ~AliFMDRawReader() {}
62   /** 
63    * Read in, and store in output tree 
64    *
65    * @param option Not used 
66    */
67   virtual void   Exec(Option_t* option="");
68   /**
69    * Read ADC's into a TClonesArray of AliFMDDigit objects. 
70    *
71    * @param array       Array to read into 
72    * @param summable    Create SDigits rather than digits 
73    * @param pedSub      Whether to do pedestal subtraction.
74    * @param noiseFactor If we do pedestal subtraction, then this is
75    *        the number we use to suppress remenants of the noise.
76    * 
77    * @return @c true on success 
78    */
79   virtual Bool_t ReadAdcs(TClonesArray* array);
80   /** 
81    * Read SOD event into passed objects.
82    * 
83    * @param samplerate   The sample rate object to fill
84    * @param striprange   The strip range object to fill
85    * @param pulseSize    The pulse size object to fill
86    * @param pulseLength  The pulse length (in events) object to fill
87    * 
88    * @return @c true on success
89    */  
90   virtual Bool_t ReadSODevent(AliFMDCalibSampleRate* samplerate, 
91                               AliFMDCalibStripRange* striprange, 
92                               TArrayS &pulseSize, 
93                               TArrayS &pulseLength, 
94                               Bool_t* detectors=0);
95   /** 
96    * Check of the data from DDL @a ddl is zero-suppressed
97    * 
98    * @param ddl DDL number (0-2)
99    * 
100    * @return @c true if the data from this DDL is zero-suppressed. 
101    */  
102   Bool_t IsZeroSuppressed(UShort_t ddl) const { return fZeroSuppress[ddl]; }
103   /** 
104    * The factor used to multiply the noise when making on-line
105    * pedestal subtraction.
106    * 
107    * @param ddl DDL number (0-2)
108    * 
109    * @return The factor used. 
110    */
111   UShort_t NoiseFactor(UShort_t ddl) const { return fNoiseFactor[ddl]; }
112
113   /** 
114    * Get the next signal
115    * 
116    * @param det  On return, the detector
117    * @param rng  On return, the ring
118    * @param sec  On return, the sector
119    * @param str  On return, the strip
120    * @param sam  On return, the sample
121    * @param rat  On return, the sample rate
122    * @param adc  On return, the ADC value
123    * @param zs   On return, whether zero-supp. is enabled
124    * @param fac  On return, the usd noise factor
125    * 
126    * @return true if valid data is returned
127    */
128   Bool_t NextSample(UShort_t& det, Char_t&   rng, UShort_t& sec, UShort_t& str,
129                     UShort_t& sam, UShort_t& rat, Short_t&  adc, 
130                     Bool_t&   zs,  UShort_t& fac);
131   /** 
132    * Get the next signal
133    * 
134    * @param det  On return, the detector
135    * @param rng  On return, the ring
136    * @param sec  On return, the sector
137    * @param str  On return, the strip
138    * @param adc  On return, the ADC value
139    * @param zs   On return, whether zero-supp. is enabled
140    * @param fac  On return, the usd noise factor
141    * 
142    * @return true if valid data is returned
143    */
144   Bool_t NextSignal(UShort_t& det, Char_t&   rng, 
145                     UShort_t& sec, UShort_t& str, 
146                     Short_t&  adc, Bool_t&   zs, 
147                     UShort_t& fac);
148   /** 
149    * Whether to keep a sample based on the rate used. 
150    * 
151    * @param samp Sample number 
152    * @param rate Over sampling rate
153    * 
154    * @return Whether to keep the sample or not
155    */
156   static Bool_t SelectSample(UShort_t samp, UShort_t rate);
157 protected:
158   /** 
159    * Copy constructor 
160    * 
161    * @param o Object to construct from
162    */  
163   AliFMDRawReader(const AliFMDRawReader& o) 
164     : TTask(o), 
165       fTree(0), 
166       fReader(0), 
167       fData(0),
168       fNbytes(0), 
169       fMinStrip(0), 
170       fMaxStrip(127),
171       fPreSamp(14+5),
172       fSeen(0)
173   {}
174   /** 
175    * Assignment operator
176    * 
177    * @return Reference to this object
178    */
179   AliFMDRawReader& operator=(const AliFMDRawReader&) { return *this; }
180   /** 
181    * Process a new DDL.  Sets the internal data members fZeroSuppress, 
182    * fSampleRate, and fNoiseFactor based on information in the RCU trailer. 
183    * 
184    * @param input Input stream
185    * @param det   On return, the detector number
186    * 
187    * @return negative value in case of problems, the DDL number otherwise
188    */
189   Int_t NewDDL(AliAltroRawStreamV3& input, UShort_t& det);
190   /** 
191    * Processs a new channel.  Sets the internal data members
192    * fMinStrip, fMaxStrip, and fPreSamp. 
193    * 
194    * @param input   Input stream
195    * @param det     Detector number
196    * @param ring    On return, the ring identifier 
197    * @param sec     On return, the sector number
198    * @param strbase On return, the strip base
199    * 
200    * @return negative value in case of problems, hardware address otherwise
201    */
202   Int_t NewChannel(const AliAltroRawStreamV3& input, 
203                    UShort_t det, Char_t&  ring, 
204                    UShort_t& sec, Short_t& strbase);
205
206   /** 
207    * Process a new timebin
208    * 
209    * @param input   Input stream
210    * @param i       Index into bunch data
211    * @param t       Time
212    * @param sec     Sector number
213    * @param strbase Base of strip numbers for this channel
214    * @param str     On return, the strip number
215    * @param samp    On return, the sample number
216    * 
217    * @return negative value in case of problems, ADC value otherwise
218    */  
219   Int_t NewSample(const AliAltroRawStreamV3& input, 
220                   Int_t i, UShort_t t, UShort_t sec,
221                   UShort_t  strbase, Short_t&  str, UShort_t& samp);
222
223   /** 
224    * 
225    * Get the number of words 
226    * 
227    * @return Number of 32bit words 
228    */
229   ULong_t GetNwords() const {return fNbytes / 4;}
230   /** 
231    * Get the next 32bit word from payload
232    * 
233    * @param idx Which 32bit word to get
234    * 
235    * @return 
236    */
237   UInt_t Get32bitWord(Int_t idx);
238   /** 
239    * Get short index for a given half-ring
240    * 
241    * @param det   Detector number
242    * @param ring  Ring identifer
243    * @param board Board number
244    * 
245    * @return 
246    */
247   Int_t GetHalfringIndex(UShort_t det, Char_t ring, UShort_t board) const;
248   TTree*          fTree;            //! Pointer to tree to read into 
249   AliRawReader*   fReader;          //! Pointer to raw reader 
250   UShort_t        fSampleRate[3];   // The sample rate (if 0,inferred from data)
251   UChar_t*        fData;            // Data pointer
252   ULong_t         fNbytes;          // Number of bytes
253   Bool_t          fZeroSuppress[3]; // Zero suppression flag
254   UShort_t        fNoiseFactor[3];  // Noise factor 
255   UShort_t        fMinStrip;        // Current minimum strip number (0)
256   UShort_t        fMaxStrip;        // Current maximum strip number (127)
257   UShort_t        fPreSamp;         // Current number of pre-samples (14+5)
258   AliFMDUShortMap fSeen;            // Seen strips 
259   
260   ClassDef(AliFMDRawReader, 0) // Read FMD raw data into a cache 
261 };
262
263 #endif
264 //____________________________________________________________________
265 //
266 // Local Variables:
267 //   mode: C++
268 // End:
269 //
270 // EOF
271 //
272