]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDRawReader.h
In AliMUONChamberCalibrationTask:
[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 TTree;
31 class TClonesArray;
32 class TArrayS;
33 class AliFMDCalibSampleRate;
34 class AliFMDCalibStripRange;
35
36 //____________________________________________________________________
37 /** @brief Class to read ALTRO formated raw data from an AliRawReader
38     object. 
39     @code 
40     AliRawReader*    reader    = new AliRawReaderFile(0);
41     AliFMDRawReader* fmdReader = new AliFMDRawReader(reader);
42     TClonesArray*    array     = new TClonesArray("AliFMDDigit");
43     fmdReader->ReadAdcs(array);
44     @endcode 
45     @ingroup FMD_rec
46 */
47 class AliFMDRawReader : public TTask 
48 {
49 public:
50   /** 
51    * CTOR 
52    *
53    * @param reader Raw reader
54    * @param array  Output tree 
55    */
56   AliFMDRawReader(AliRawReader* reader, TTree* array);
57   /** 
58    * DTOR 
59    */
60   virtual ~AliFMDRawReader() {}
61   /** 
62    * Read in, and store in output tree 
63    *
64    * @param option Not used 
65    */
66   virtual void   Exec(Option_t* option="");
67   /**
68    * Read ADC's into a TClonesArray of AliFMDDigit objects. 
69    *
70    * @param array       Array to read into 
71    * @param summable    Create SDigits rather than digits 
72    * @param pedSub      Whether to do pedestal subtraction.
73    * @param noiseFactor If we do pedestal subtraction, then this is
74    *        the number we use to suppress remenants of the noise.
75    * 
76    * @return @c true on success 
77    */
78   virtual Bool_t ReadAdcs(TClonesArray* array);
79   /** 
80    * Read SOD event into passed objects.
81    * 
82    * @param samplerate   The sample rate object to fill
83    * @param striprange   The strip range object to fill
84    * @param pulseSize    The pulse size object to fill
85    * @param pulseLength  The pulse length (in events) object to fill
86    * 
87    * @return @c true on success
88    */  
89   virtual Bool_t ReadSODevent(AliFMDCalibSampleRate* samplerate, 
90                               AliFMDCalibStripRange* striprange, 
91                               TArrayS &pulseSize, 
92                               TArrayS &pulseLength);
93   /** 
94    * Check of the data from DDL @a ddl is zero-suppressed
95    * 
96    * @param ddl DDL number (0-2)
97    * 
98    * @return @c true if the data from this DDL is zero-suppressed. 
99    */  
100   Bool_t IsZeroSuppressed(UShort_t ddl) const { return fZeroSuppress[ddl]; }
101   /** 
102    * The factor used to multiply the noise when making on-line
103    * pedestal subtraction.
104    * 
105    * @param ddl DDL number (0-2)
106    * 
107    * @return The factor used. 
108    */
109   UShort_t NoiseFactor(UShort_t ddl) const { return fNoiseFactor[ddl]; }
110
111   /** 
112    * Get the next signal
113    * 
114    * @param det  On return, the detector
115    * @param rng  On return, the ring
116    * @param sec  On return, the sector
117    * @param str  On return, the strip
118    * @param sam  On return, the sample
119    * @param rat  On return, the sample rate
120    * @param adc  On return, the ADC value
121    * @param zs   On return, whether zero-supp. is enabled
122    * @param fac  On return, the usd noise factor
123    * 
124    * @return true if valid data is returned
125    */
126   Bool_t NextSample(UShort_t& det, Char_t&   rng, UShort_t& sec, UShort_t& str,
127                     UShort_t& sam, UShort_t& rat, Short_t&  adc, 
128                     Bool_t&   zs,  UShort_t& fac);
129   /** 
130    * Get the next signal
131    * 
132    * @param det  On return, the detector
133    * @param rng  On return, the ring
134    * @param sec  On return, the sector
135    * @param str  On return, the strip
136    * @param adc  On return, the ADC value
137    * @param zs   On return, whether zero-supp. is enabled
138    * @param fac  On return, the usd noise factor
139    * 
140    * @return true if valid data is returned
141    */
142   Bool_t NextSignal(UShort_t& det, Char_t&   rng, 
143                     UShort_t& sec, UShort_t& str, 
144                     Short_t&  adc, Bool_t&   zs, 
145                     UShort_t& fac);
146   /** 
147    * Whether to keep a sample based on the rate used. 
148    * 
149    * @param samp Sample number 
150    * @param rate Over sampling rate
151    * 
152    * @return Whether to keep the sample or not
153    */
154   static Bool_t SelectSample(UShort_t samp, UShort_t rate);
155 protected:
156   AliFMDRawReader(const AliFMDRawReader& o) 
157     : TTask(o), 
158       fTree(0), 
159       fReader(0), 
160       fData(0),
161       fNbytes(0), 
162       fSeen(0)
163   {}
164   AliFMDRawReader& operator=(const AliFMDRawReader&) { return *this; }
165   ULong_t GetNwords() const {return fNbytes / 4;}
166   UInt_t Get32bitWord(Int_t idx);
167   Int_t GetHalfringIndex(UShort_t det, Char_t ring, UShort_t board);
168   TTree*          fTree;       //! Pointer to tree to read into 
169   AliRawReader*   fReader;     //! Pointer to raw reader 
170   UShort_t        fSampleRate[3]; // The sample rate (if 0, inferred from data)
171   UChar_t*        fData; 
172   ULong_t         fNbytes; 
173   Bool_t          fZeroSuppress[3];
174   UShort_t        fNoiseFactor[3];
175   AliFMDUShortMap fSeen;
176   
177   ClassDef(AliFMDRawReader, 0) // Read FMD raw data into a cache 
178 };
179
180 #endif
181 //____________________________________________________________________
182 //
183 // Local Variables:
184 //   mode: C++
185 // End:
186 //
187 // EOF
188 //