]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDParameters.h
Fixed raw reading and writing. Problem was, that Cvetan had
[u/mrichter/AliRoot.git] / FMD / AliFMDParameters.h
CommitLineData
1a1fdef7 1#ifndef ALIFMDPARAMETERS_H
2#define ALIFMDPARAMETERS_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 */
1a1fdef7 10//____________________________________________________________________
11//
12// Singleton class to handle various parameters (not geometry) of the
13// FMD
088f8e79 14// Should get ata fromm Conditions DB.
1a1fdef7 15//
02a27b50 16/** @file AliFMDParameters.h
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Mon Mar 27 12:44:43 2006
19 @brief Manager of FMD parameters
20*/
1a1fdef7 21#ifndef ROOT_TNamed
22# include <TNamed.h>
23#endif
8f6ee336 24#ifndef ROOT_TArrayI
25# include <TArrayI.h>
26#endif
27#ifndef ALIFMDUSHORTMAP_H
28# include <AliFMDUShortMap.h>
29#endif
30#ifndef ALIFMDBOOLMAP_H
31# include <AliFMDBoolMap.h>
32#endif
33typedef AliFMDUShortMap AliFMDCalibZeroSuppression;
34typedef AliFMDBoolMap AliFMDCalibDeadMap;
35class AliFMDCalibPedestal;
36class AliFMDCalibGain;
37class AliFMDCalibSampleRate;
c2fc1258 38class AliFMDCalibStripRange;
57c3c593 39class AliFMDAltroMapping;
dc02d468 40class AliCDBEntry;
41class AliFMDPreprocessor;
42
02a27b50 43//____________________________________________________________________
44//
45// Singleton class to handle various parameters (not geometry) of the
46// FMD
47// Should get ata fromm Conditions DB.
48//
1a1fdef7 49
c2fc1258 50/** @brief This class is a singleton that handles various parameters
51 of the FMD detectors.
52 This class reads from the Conditions DB to get the various
53 parameters, which code can then request from here. In that way,
54 all code uses the same data, and the interface is consistent.
9f662337 55
56 Some of the parameter managed are
57 - @c fPedestal, @c fPedestalWidth
58 Mean and width of the pedestal. The pedestal is simulated
59 by a Guassian, but derived classes my override MakePedestal
60 to simulate it differently (or pick it up from a database).
61 - @c fVA1MipRange
62 The dymamic MIP range of the VA1_ALICE pre-amplifier chip
63 - @c fAltroChannelSize
64 The largest number plus one that can be stored in one
65 channel in one time step in the ALTRO ADC chip.
66 - @c fSampleRate
67 How many times the ALTRO ADC chip samples the VA1_ALICE
68 pre-amplifier signal. The VA1_ALICE chip is read-out at
69 10MHz, while it's possible to drive the ALTRO chip at
70 25MHz. That means, that the ALTRO chip can have time to
71 sample each VA1_ALICE signal up to 2 times. Although it's
72 not certain this feature will be used in the production,
73 we'd like have the option, and so it should be reflected in
74 the code.
75
76 @ingroup FMD_base
77*/
1a1fdef7 78class AliFMDParameters : public TNamed
79{
80public:
f6449cc0 81 /** Enumeration of things to initialize */
82 enum What {
83 /** Pulser gain */
84 kPulseGain = 0x1, // Pulser gain
85 /** Pedestals and noise */
86 kPedestal = 0x2, // Pedestal and noise
87 /** Dead channel map */
88 kDeadMap = 0x4, // Dead channel map
89 /** Over sampling rate */
90 kSampleRate = 0x8, // Over sampling rate
91 /** Zero suppression parameters */
92 kZeroSuppression = 0x10, // Zero suppression parameters
93 /** ALTRO data map */
94 kAltroMap = 0x20 // Altro channel map
95 };
96
9f662337 97 /** Singleton access
98 @return single to */
1a1fdef7 99 static AliFMDParameters* Instance();
57c3c593 100
9f662337 101 /** Initialize the manager. This tries to read the parameters from
102 CDB. If that fails, the class uses the hard-coded parameters.
103 */
f6449cc0 104 void Init(Bool_t forceReInit=kFALSE,
105 UInt_t what = (kPulseGain|kPedestal|kDeadMap|kSampleRate|
106 kZeroSuppression|kAltroMap));
dc02d468 107 /** Initialize the manager. This tries to read the parameters from
108 CDB. If that fails, the class uses the hard-coded parameters.
109 */
110 void Init(AliFMDPreprocessor* pp,
111 Bool_t forceReInit=kFALSE,
112 UInt_t what = (kPulseGain|kPedestal|kDeadMap|kSampleRate|
113 kZeroSuppression|kAltroMap));
c2fc1258 114 /** Print all parameters.
115 @param option Option string */
116 void Print(Option_t* option="A") const;
6169f936 117 /** Draw parameters.
118 @param option What to draw. Should be one of
119 - dead Dead channels
120 - threshold Threshold
121 - gain Gain
122 - pedestal Pedestal
123 - noise Noise (or pedestal width)
124 - zero Zero suppression
125 - rate Sampling rate (VA1 clock / ALTRO clock)
126 - min Minimum strip read out
127 - max Maximum strip read out
128 - map hardware address
129 */
130 void Draw(Option_t* option="pedestal");
1a1fdef7 131
9f662337 132 /** @{ */
133 /** @name Set various `Fixed' parameters */
c2fc1258 134 /** @param r How many MIP signals we can fit in the VA1
135 pre-amps. (default and design is 20) */
8f6ee336 136 void SetVA1MipRange(UShort_t r=20) { fVA1MipRange = r; }
c2fc1258 137 /** @param s Maximum number of the ADC (ALTRO). This is a 10 bit
138 ADC so, the maximum number is 1024 */
8f6ee336 139 void SetAltroChannelSize(UShort_t s=1024) { fAltroChannelSize = s;}
c2fc1258 140 /** @param size The number of strips multiplexed into one ALTRO
141 channel. That is, how many strips is connected to one VA1
142 pre-amp. */
8f6ee336 143 void SetChannelsPerAltro(UShort_t size=128) { fChannelsPerAltro = size; }
c2fc1258 144 /** @param f Factor to use for accepting a signal. */
8f6ee336 145 void SetPedestalFactor(Float_t f=3) { fPedestalFactor = f; }
9f662337 146 /** @} */
8f6ee336 147
9f662337 148 /** @{ */
149 /** @name Set various variable parameter defaults */
c2fc1258 150 /** @param s Zero suppression threshold in ADC counts */
8f6ee336 151 void SetZeroSuppression(UShort_t s=0) { fFixedZeroSuppression = s; }
c2fc1258 152 /** @param r How many times we oversample each strip. */
8f6ee336 153 void SetSampleRate(UShort_t r=1) { fFixedSampleRate = (r>2?2:r);}
c2fc1258 154 /** @param p Pedestal value in ADC counts */
8f6ee336 155 void SetPedestal(Float_t p=10) { fFixedPedestal = p; }
c2fc1258 156 /** @param w Pedestal width in ADC counts */
8f6ee336 157 void SetPedestalWidth(Float_t w=1) { fFixedPedestalWidth = w; }
c2fc1258 158 /** @param t Threshold used for 1 MIP acceptance. */
8f6ee336 159 void SetThreshold(Float_t t=0) { fFixedThreshold = t; }
c2fc1258 160 /** Range of strips read out
161 @param min Minimum strip number (0-127).
162 @param max Maximum strip number (0-127). */
163 void SetStripRange(UShort_t min=0, UShort_t max=127);
625d7886 164 /** Whether raw data is in the old ALTRO format (i.e., no RCU
165 trailer), or in the new format (with a trailer).
166 @param yes if true the raw data has RCU trailer */
167 void UseRcuTrailer(Bool_t yes=kTRUE) { fHasRcuTrailer = yes; }
168 /** Whether raw data has full common data header (8 32bit words) or
169 the older invalid format (7 32bit words with bogus entries)
170 @param yes if true the raw data has complete data header */
171 void UseCompleteHeader(Bool_t yes=kTRUE) { fHasCompleteHeader = yes; }
9f662337 172 /** @} */
1a1fdef7 173
9f662337 174 /** @{ */
175 /** @name Get `Fixed' various parameters */
c2fc1258 176 /** @return Number of MIP signals that fit inside a VA1 channel */
1a1fdef7 177 UShort_t GetVA1MipRange() const { return fVA1MipRange; }
c2fc1258 178 /** @return The maximum count in the ADC */
1a1fdef7 179 UShort_t GetAltroChannelSize() const { return fAltroChannelSize; }
c2fc1258 180 /** @return Number of strips muliplexed into one ADC channel */
1a1fdef7 181 UShort_t GetChannelsPerAltro() const { return fChannelsPerAltro; }
c2fc1258 182 /** @return The average energy deposited by one MIP */
1a1fdef7 183 Float_t GetEdepMip() const;
c2fc1258 184 /** @return The factor used of signal acceptance */
1a1fdef7 185 Float_t GetPedestalFactor() const { return fPedestalFactor; }
9f662337 186 /** @} */
1a1fdef7 187
9f662337 188 /** @{ */
189 /** @name Get variable parameters */
c2fc1258 190 /** Whether the strip is considered dead
191 @param detector Detector # (1-3)
192 @param ring Ring ID ('I' or 'O')
193 @param sector Sector number (0-39)
194 @param strip Strip number (0-511)
195 @return @c true if the strip is considered dead, @c false if
196 it's OK. */
8f6ee336 197 Bool_t IsDead(UShort_t detector,
198 Char_t ring,
199 UShort_t sector,
200 UShort_t strip) const;
201 Float_t GetThreshold() const;
c2fc1258 202 /** Gain of pre-amp.
203 @param detector Detector # (1-3)
204 @param ring Ring ID ('I' or 'O')
205 @param sector Sector number (0-39)
206 @param strip Strip number (0-511)
207 @return Gain of pre-amp. */
8f6ee336 208 Float_t GetPulseGain(UShort_t detector,
209 Char_t ring,
210 UShort_t sector,
211 UShort_t strip) const;
c2fc1258 212 /** Get mean of pedestal
213 @param detector Detector # (1-3)
214 @param ring Ring ID ('I' or 'O')
215 @param sector Sector number (0-39)
216 @param strip Strip number (0-511)
217 @return Mean of pedestal */
8f6ee336 218 Float_t GetPedestal(UShort_t detector,
219 Char_t ring,
220 UShort_t sector,
221 UShort_t strip) const;
c2fc1258 222 /** Width of pedestal
223 @param detector Detector # (1-3)
224 @param ring Ring ID ('I' or 'O')
225 @param sector Sector number (0-39)
226 @param strip Strip number (0-511)
227 @return Width of pedestal */
8f6ee336 228 Float_t GetPedestalWidth(UShort_t detector,
229 Char_t ring,
230 UShort_t sector,
231 UShort_t strip) const;
c2fc1258 232 /** zero suppression threshold (in ADC counts)
233 @param detector Detector # (1-3)
234 @param ring Ring ID ('I' or 'O')
235 @param sector Sector number (0-39)
236 @param strip Strip number (0-511)
237 @return zero suppression threshold (in ADC counts) */
8f6ee336 238 UShort_t GetZeroSuppression(UShort_t detector,
239 Char_t ring,
240 UShort_t sector,
241 UShort_t strip) const;
c2fc1258 242 /** Get the sampling rate
243 @param detector Detector # (1-3)
244 @param ring Ring ID ('I' or 'O')
245 @param sector Sector number (0-39)
246 @param strip Strip number (0-511)
247 @return The sampling rate */
248 UShort_t GetSampleRate(UShort_t detector,
249 Char_t ring,
250 UShort_t sector,
251 UShort_t strip) const;
252 /** Get the minimum strip in the read-out range
253 @param detector Detector # (1-3)
254 @param ring Ring ID ('I' or 'O')
255 @param sector Sector number (0-39)
256 @param strip Strip number (0-511)
257 @return Minimum strip */
258 UShort_t GetMinStrip(UShort_t detector,
259 Char_t ring,
260 UShort_t sector,
261 UShort_t strip) const;
262 /** Get the maximum strip in the read-out range
263 @param detector Detector # (1-3)
264 @param ring Ring ID ('I' or 'O')
265 @param sector Sector number (0-39)
266 @param strip Strip number (0-511)
267 @return Maximum strip */
268 UShort_t GetMaxStrip(UShort_t detector,
269 Char_t ring,
270 UShort_t sector,
271 UShort_t strip) const;
625d7886 272 /** Get the number of pre-samples in ALTRO channels
273 @param detector Detector # (1-3)
274 @param ring Ring ID ('I' or 'O')
275 @param sector Sector number (0-39)
276 @param strip Strip number (0-511)
277 @return Maximum strip */
278 UShort_t GetPreSamples(UShort_t,
279 Char_t,
280 UShort_t,
281 UShort_t) const { return 14+5; }
f6449cc0 282 /** Translate hardware address to detector coordinates
283 @param ddl DDL number
284 @param board Board address
285 @param chip Chip #
286 @param channel Channel #
287 @param det On return, Detector # (1-3)
288 @param ring On return, Ring ID ('I' or 'O')
289 @param sec On return, Sector number (0-39)
290 @param str On return, Strip number (0-511)
291 @return @c true on success. */
292 Bool_t Hardware2Detector(UInt_t ddl, UInt_t board,
293 UInt_t chip, UInt_t channel,
294 UShort_t& det, Char_t& ring,
295 UShort_t& sec, UShort_t& str) const;
c2fc1258 296 /** Translate hardware address to detector coordinates
297 @param ddl DDL number
298 @param addr Hardware address
299 @param det On return, Detector # (1-3)
300 @param ring On return, Ring ID ('I' or 'O')
301 @param sec On return, Sector number (0-39)
302 @param str On return, Strip number (0-511)
303 @return @c true on success. */
bf000c32 304 Bool_t Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
305 Char_t& ring, UShort_t& sec, UShort_t& str) const;
f6449cc0 306
307 /** Translate detector coordinates to hardware address
308 @param det Detector # (1-3)
309 @param ring Ring ID ('I' or 'O')
310 @param sec Sector number (0-39)
311 @param str Strip number (0-511)
312 @param ddl On return, DDL number
313 @param board On return, Board address
314 @param chip On return, Chip #
315 @param channel On return, Channel #
316 @return @c true on success. */
317 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
318 UShort_t sec, UShort_t str,
319 UInt_t& ddl, UInt_t& board,
320 UInt_t& chip, UInt_t& channel) const;
c2fc1258 321 /** Translate detector coordinates to hardware address
322 @param det Detector # (1-3)
323 @param ring Ring ID ('I' or 'O')
324 @param sec Sector number (0-39)
325 @param str Strip number (0-511)
326 @param ddl On return, DDL number
327 @param addr On return, Hardware address
328 @return @c true on success. */
bf000c32 329 Bool_t Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
330 UShort_t str, UInt_t& ddl, UInt_t& addr) const;
c2fc1258 331 /** Get the map that translates hardware to detector coordinates
332 @return Get the map that translates hardware to detector
333 coordinates */
57c3c593 334 AliFMDAltroMapping* GetAltroMap() const;
625d7886 335 /** Whether raw data is in the old ALTRO format (i.e., no RCU
336 trailer), or in the new format (with a trailer).
337 @return false if the raw data has no RCU trailer */
338 Bool_t HasRcuTrailer() const { return fHasRcuTrailer; }
339 /** Whether raw data has full common data header (8 32bit words) or
340 the older invalid format (7 32bit words with bogus entries)
341 @return false if the raw data has incomplete data header */
342 Bool_t HasCompleteHeader() const { return fHasCompleteHeader; }
343
9f662337 344 /** @} */
345
02a27b50 346 static const char* PulseGainPath() { return fgkPulseGain; }
347 static const char* PedestalPath() { return fgkPedestal; }
348 static const char* DeadPath() { return fgkDead; }
349 static const char* SampleRatePath() { return fgkSampleRate; }
350 static const char* AltroMapPath() { return fgkAltroMap; }
351 static const char* ZeroSuppressionPath() { return fgkZeroSuppression; }
352 static const char* StripRangePath() { return fgkStripRange; }
497e0e62 353protected:
9f662337 354 /** CTOR */
497e0e62 355 AliFMDParameters();
02a27b50 356 /** CTOR */
357 AliFMDParameters(const AliFMDParameters& o)
b5ee4425 358 : TNamed(o),
359 fIsInit(o.fIsInit),
360 fkSiDeDxMip(o.fkSiDeDxMip),
361 fVA1MipRange(o.fVA1MipRange),
362 fAltroChannelSize(o.fAltroChannelSize),
363 fChannelsPerAltro(o.fChannelsPerAltro),
364 fPedestalFactor(o.fPedestalFactor),
365 fFixedPedestal(o.fFixedPedestal),
366 fFixedPedestalWidth(o.fFixedPedestalWidth),
367 fFixedZeroSuppression(o.fFixedZeroSuppression),
368 fFixedSampleRate(o.fFixedSampleRate),
369 fFixedThreshold(o.fFixedThreshold),
370 fFixedMinStrip(o.fFixedMinStrip),
371 fFixedMaxStrip(o.fFixedMaxStrip),
372 fFixedPulseGain(o.fFixedPulseGain),
373 fEdepMip(o.fEdepMip),
625d7886 374 fHasRcuTrailer(o.fHasRcuTrailer),
375 fHasCompleteHeader(o.fHasCompleteHeader),
b5ee4425 376 fZeroSuppression(o.fZeroSuppression),
377 fSampleRate(o.fSampleRate),
378 fPedestal(o.fPedestal),
379 fPulseGain(o.fPulseGain),
380 fDeadMap(o.fDeadMap),
381 fAltroMap(o.fAltroMap),
382 fStripRange(o.fStripRange)
383 {}
02a27b50 384 /** Assignement operator
385 @return Reference to this */
386 AliFMDParameters& operator=(const AliFMDParameters&) { return *this; }
9f662337 387 /** DTOR */
497e0e62 388 virtual ~AliFMDParameters() {}
9f662337 389 /** Singleton instance */
497e0e62 390 static AliFMDParameters* fgInstance; // Static singleton instance
dc02d468 391 /** Get an entry from either global AliCDBManager or passed
392 AliFMDPreprocessor.
393 @param path Path to CDB object.
394 @param pp AliFMDPreprocessor
395 @param fatal If true, raise a fatal flag if we didn't get the entry.
396 @return AliCDBEntry if found */
397 AliCDBEntry* GetEntry(const char* path, AliFMDPreprocessor* pp,
398 Bool_t fatal=kTRUE) const;
9f662337 399 /** Initialize gains. Try to get them from CDB */
dc02d468 400 void InitPulseGain(AliFMDPreprocessor* pp=0);
9f662337 401 /** Initialize pedestals. Try to get them from CDB */
dc02d468 402 void InitPedestal(AliFMDPreprocessor* pp=0);
9f662337 403 /** Initialize dead map. Try to get it from CDB */
dc02d468 404 void InitDeadMap(AliFMDPreprocessor* pp=0);
9f662337 405 /** Initialize sample rates. Try to get them from CDB */
dc02d468 406 void InitSampleRate(AliFMDPreprocessor* pp=0);
9f662337 407 /** Initialize zero suppression thresholds. Try to get them from CDB */
dc02d468 408 void InitZeroSuppression(AliFMDPreprocessor* pp=0);
9f662337 409 /** Initialize hardware map. Try to get it from CDB */
dc02d468 410 void InitAltroMap(AliFMDPreprocessor* pp=0);
c2fc1258 411 /** Initialize strip range. Try to get it from CDB */
dc02d468 412 void InitStripRange(AliFMDPreprocessor* pp=0);
57c3c593 413
414 Bool_t fIsInit; // Whether we've been initialised
415
02a27b50 416 static const char* fgkPulseGain; // Path to PulseGain calib object
417 static const char* fgkPedestal; // Path to Pedestal calib object
418 static const char* fgkDead; // Path to Dead calib object
419 static const char* fgkSampleRate; // Path to SampleRate calib object
420 static const char* fgkAltroMap; // Path to AltroMap calib object
421 static const char* fgkZeroSuppression; // Path to ZeroSuppression cal object
422 static const char* fgkStripRange; // Path to strip range cal object
423 const Float_t fkSiDeDxMip; // MIP dE/dx in Silicon
8f6ee336 424 UShort_t fVA1MipRange; // # MIPs the pre-amp can do
425 UShort_t fAltroChannelSize; // Largest # to store in 1 ADC ch.
426 UShort_t fChannelsPerAltro; // Number of pre-amp. chan/adc chan.
427 Float_t fPedestalFactor; // Number of pedestal widths
1a1fdef7 428
8f6ee336 429 Float_t fFixedPedestal; // Pedestal to subtract
430 Float_t fFixedPedestalWidth; // Width of pedestal
431 UShort_t fFixedZeroSuppression; // Threshold for zero-suppression
432 UShort_t fFixedSampleRate; // Times the ALTRO samples pre-amp.
02a27b50 433 Float_t fFixedThreshold; // Threshold in ADC counts
434 UShort_t fFixedMinStrip; // Minimum strip read-out
435 UShort_t fFixedMaxStrip; // Maximum strip read-out
8f6ee336 436 mutable Float_t fFixedPulseGain; //! Gain (cached)
437 mutable Float_t fEdepMip; //! Cache of energy loss for a MIP
625d7886 438 Bool_t fHasRcuTrailer; // if the raw data has RCU trailer
439 Bool_t fHasCompleteHeader; // raw data has incomplete data header
8f6ee336 440
441 AliFMDCalibZeroSuppression* fZeroSuppression; // Zero suppression from CDB
442 AliFMDCalibSampleRate* fSampleRate; // Sample rate from CDB
443 AliFMDCalibPedestal* fPedestal; // Pedestals
444 AliFMDCalibGain* fPulseGain; // Pulser gain
445 AliFMDCalibDeadMap* fDeadMap; // Pulser gain
57c3c593 446 AliFMDAltroMapping* fAltroMap; // Map of hardware
c2fc1258 447 AliFMDCalibStripRange* fStripRange; // Strip range
8f6ee336 448
02a27b50 449 ClassDef(AliFMDParameters,5) // Manager of parameters
1a1fdef7 450};
451
452#endif
453//____________________________________________________________________
454//
455// Local Variables:
456// mode: C++
457// End:
458//
459// EOF
460//
461