1 #ifndef ALIFMDRAWREADER_H
2 #define ALIFMDRAWREADER_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
6 * Latest changes by Christian Holm Christensen <cholm@nbi.dk>
8 * See cxx source for full Copyright notice
10 //____________________________________________________________________
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
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
26 #include "AliFMDUShortMap.h"
28 //____________________________________________________________________
30 class AliAltroRawStreamV3;
34 class AliFMDCalibSampleRate;
35 class AliFMDCalibStripRange;
37 //____________________________________________________________________
38 /** @brief Class to read ALTRO formated raw data from an AliRawReader
41 AliRawReader* reader = new AliRawReaderFile(0);
42 AliFMDRawReader* fmdReader = new AliFMDRawReader(reader);
43 TClonesArray* array = new TClonesArray("AliFMDDigit");
44 fmdReader->ReadAdcs(array);
48 class AliFMDRawReader : public TTask
54 * @param reader Raw reader
55 * @param array Output tree
57 AliFMDRawReader(AliRawReader* reader, TTree* array);
61 virtual ~AliFMDRawReader() {}
63 * Read in, and store in output tree
65 * @param option Not used
67 virtual void Exec(Option_t* option="");
69 * Read ADC's into a TClonesArray of AliFMDDigit objects.
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.
77 * @return @c true on success
79 virtual Bool_t ReadAdcs(TClonesArray* array);
81 * Read SOD event into passed objects.
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
88 * @return @c true on success
90 virtual Bool_t ReadSODevent(AliFMDCalibSampleRate* samplerate,
91 AliFMDCalibStripRange* striprange,
96 * Check of the data from DDL @a ddl is zero-suppressed
98 * @param ddl DDL number (0-2)
100 * @return @c true if the data from this DDL is zero-suppressed.
102 Bool_t IsZeroSuppressed(UShort_t ddl) const { return fZeroSuppress[ddl]; }
104 * The factor used to multiply the noise when making on-line
105 * pedestal subtraction.
107 * @param ddl DDL number (0-2)
109 * @return The factor used.
111 UShort_t NoiseFactor(UShort_t ddl) const { return fNoiseFactor[ddl]; }
114 * Get the next signal
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
126 * @return true if valid data is returned
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);
132 * Get the next signal
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
142 * @return true if valid data is returned
144 Bool_t NextSignal(UShort_t& det, Char_t& rng,
145 UShort_t& sec, UShort_t& str,
146 Short_t& adc, Bool_t& zs,
149 * Whether to keep a sample based on the rate used.
151 * @param samp Sample number
152 * @param rate Over sampling rate
154 * @return Whether to keep the sample or not
156 static Bool_t SelectSample(UShort_t samp, UShort_t rate);
161 * @param o Object to construct from
163 AliFMDRawReader(const AliFMDRawReader& o)
175 * Assignment operator
177 * @return Reference to this object
179 AliFMDRawReader& operator=(const AliFMDRawReader&) { return *this; }
181 * Process a new DDL. Sets the internal data members fZeroSuppress,
182 * fSampleRate, and fNoiseFactor based on information in the RCU trailer.
184 * @param input Input stream
185 * @param det On return, the detector number
187 * @return negative value in case of problems, the DDL number otherwise
189 Int_t NewDDL(AliAltroRawStreamV3& input, UShort_t& det);
191 * Processs a new channel. Sets the internal data members
192 * fMinStrip, fMaxStrip, and fPreSamp.
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
200 * @return negative value in case of problems, hardware address otherwise
202 Int_t NewChannel(AliAltroRawStreamV3& input, UShort_t det, Char_t& ring,
203 UShort_t& sec, Short_t& strbase);
206 * Process a new timebin
208 * @param input Input stream
209 * @param i Index into bunch data
211 * @param sec Sector number
212 * @param strbase Base of strip numbers for this channel
213 * @param str On return, the strip number
214 * @param samp On return, the sample number
216 * @return negative value in case of problems, ADC value otherwise
218 Int_t NewSample(AliAltroRawStreamV3& input, Int_t i, UShort_t t, UShort_t sec,
219 UShort_t strbase, Short_t& str, UShort_t& samp);
223 * Get the number of words
225 * @return Number of 32bit words
227 ULong_t GetNwords() const {return fNbytes / 4;}
229 * Get the next 32bit word from payload
231 * @param idx Which 32bit word to get
235 UInt_t Get32bitWord(Int_t idx);
237 * Get short index for a given half-ring
239 * @param det Detector number
240 * @param ring Ring identifer
241 * @param board Board number
245 Int_t GetHalfringIndex(UShort_t det, Char_t ring, UShort_t board);
246 TTree* fTree; //! Pointer to tree to read into
247 AliRawReader* fReader; //! Pointer to raw reader
248 UShort_t fSampleRate[3]; // The sample rate (if 0,inferred from data)
249 UChar_t* fData; // Data pointer
250 ULong_t fNbytes; // Number of bytes
251 Bool_t fZeroSuppress[3]; // Zero suppression flag
252 UShort_t fNoiseFactor[3]; // Noise factor
253 UShort_t fMinStrip; // Current minimum strip number (0)
254 UShort_t fMaxStrip; // Current maximum strip number (127)
255 UShort_t fPreSamp; // Current number of pre-samples (14+5)
256 AliFMDUShortMap fSeen;
258 ClassDef(AliFMDRawReader, 0) // Read FMD raw data into a cache
262 //____________________________________________________________________