1 #ifndef ALIFMDPARAMETERS_H
2 #define ALIFMDPARAMETERS_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 // Singleton class to handle various parameters (not geometry) of the
14 // Should get ata fromm Conditions DB.
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
27 #ifndef ALIFMDUSHORTMAP_H
28 # include <AliFMDUShortMap.h>
30 #ifndef ALIFMDBOOLMAP_H
31 # include <AliFMDBoolMap.h>
33 typedef AliFMDUShortMap AliFMDCalibZeroSuppression;
34 typedef AliFMDBoolMap AliFMDCalibDeadMap;
35 class AliFMDCalibPedestal;
36 class AliFMDCalibGain;
37 class AliFMDCalibSampleRate;
38 class AliFMDCalibStripRange;
39 class AliFMDAltroMapping;
41 class AliFMDPreprocessor;
43 //____________________________________________________________________
45 // Singleton class to handle various parameters (not geometry) of the
47 // Should get ata fromm Conditions DB.
50 /** @brief This class is a singleton that handles various parameters
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.
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).
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.
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
78 class AliFMDParameters : public TNamed
81 /** Enumeration of things to initialize */
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
94 kAltroMap = 0x20, // Altro channel map
96 kStripRange = 0x40 //Strip range
102 static AliFMDParameters* Instance();
104 /** Initialize the manager. This tries to read the parameters from
105 CDB. If that fails, the class uses the hard-coded parameters.
107 void Init(Bool_t forceReInit=kFALSE,
108 UInt_t what = (kPulseGain|kPedestal|kDeadMap|kSampleRate|
109 kZeroSuppression|kAltroMap|kStripRange));
110 /** Initialize the manager. This tries to read the parameters from
111 CDB. If that fails, the class uses the hard-coded parameters.
113 void Init(AliFMDPreprocessor* pp,
114 Bool_t forceReInit=kFALSE,
115 UInt_t what = (kPulseGain|kPedestal|kDeadMap|kSampleRate|
116 kZeroSuppression|kAltroMap|kStripRange));
117 /** Print all parameters.
118 @param option Option string */
119 void Print(Option_t* option="A") const;
121 @param option What to draw. Should be one of
123 - threshold Threshold
126 - noise Noise (or pedestal width)
127 - zero Zero suppression
128 - rate Sampling rate (VA1 clock / ALTRO clock)
129 - min Minimum strip read out
130 - max Maximum strip read out
131 - map hardware address
133 void Draw(Option_t* option="pedestal");
136 /** @name Set various `Fixed' parameters */
137 /** @param r How many MIP signals we can fit in the VA1
138 pre-amps. (default and design is 20) */
139 void SetVA1MipRange(UShort_t r=20) { fVA1MipRange = r; }
140 /** @param s Maximum number of the ADC (ALTRO). This is a 10 bit
141 ADC so, the maximum number is 1024 */
142 void SetAltroChannelSize(UShort_t s=1024) { fAltroChannelSize = s;}
143 /** @param size The number of strips multiplexed into one ALTRO
144 channel. That is, how many strips is connected to one VA1
146 void SetChannelsPerAltro(UShort_t size=128) { fChannelsPerAltro = size; }
147 /** @param f Factor to use for accepting a signal. */
148 void SetPedestalFactor(Float_t f=3) { fPedestalFactor = f; }
152 /** @name Set various variable parameter defaults */
153 /** @param s Zero suppression threshold in ADC counts */
154 void SetZeroSuppression(UShort_t s=0) { fFixedZeroSuppression = s; }
155 /** @param r How many times we oversample each strip. */
156 void SetSampleRate(UShort_t r=1) { fFixedSampleRate = r ;}//(r>2?2:r);}
157 void SetSampleRate(AliFMDCalibSampleRate* r) { fSampleRate = r; }
158 /** @param p Pedestal value in ADC counts */
159 void SetPedestal(Float_t p=10) { fFixedPedestal = p; }
160 /** @param w Pedestal width in ADC counts */
161 void SetPedestalWidth(Float_t w=1) { fFixedPedestalWidth = w; }
162 /** @param t Threshold used for 1 MIP acceptance. */
163 void SetThreshold(Float_t t=0) { fFixedThreshold = t; }
164 /** Range of strips read out
165 @param min Minimum strip number (0-127).
166 @param max Maximum strip number (0-127). */
167 void SetStripRange(UShort_t min=0, UShort_t max=127);
168 void SetStripRange(AliFMDCalibStripRange* r) { fStripRange = r; }
169 /** Whether raw data has full common data header (8 32bit words) or
170 the older invalid format (7 32bit words with bogus entries)
171 @param yes if true the raw data has complete data header */
172 void UseCompleteHeader(Bool_t yes=kTRUE) { fHasCompleteHeader = yes; }
176 /** @name Get `Fixed' various parameters */
177 /** @return Number of MIP signals that fit inside a VA1 channel */
178 UShort_t GetVA1MipRange() const { return fVA1MipRange; }
179 /** @return The maximum count in the ADC */
180 UShort_t GetAltroChannelSize() const { return fAltroChannelSize; }
181 /** @return Number of strips muliplexed into one ADC channel */
182 UShort_t GetChannelsPerAltro() const { return fChannelsPerAltro; }
183 /** @return The average energy deposited by one MIP */
184 Float_t GetEdepMip() const;
185 /** @return The factor used of signal acceptance */
186 Float_t GetPedestalFactor() const { return fPedestalFactor; }
190 /** @name Various varible conditions */
191 /** Whether the strip is considered dead
192 @param detector Detector # (1-3)
193 @param ring Ring ID ('I' or 'O')
194 @param sector Sector number (0-39)
195 @param strip Strip number (0-511)
196 @return @c true if the strip is considered dead, @c false if
198 Bool_t IsDead(UShort_t detector,
201 UShort_t strip) const;
202 Float_t GetThreshold() const;
204 @param detector Detector # (1-3)
205 @param ring Ring ID ('I' or 'O')
206 @param sector Sector number (0-39)
207 @param strip Strip number (0-511)
208 @return Gain of pre-amp. */
209 Float_t GetPulseGain(UShort_t detector,
212 UShort_t strip) const;
213 /** Get mean of pedestal
214 @param detector Detector # (1-3)
215 @param ring Ring ID ('I' or 'O')
216 @param sector Sector number (0-39)
217 @param strip Strip number (0-511)
218 @return Mean of pedestal */
219 Float_t GetPedestal(UShort_t detector,
222 UShort_t strip) const;
223 /** Width of pedestal
224 @param detector Detector # (1-3)
225 @param ring Ring ID ('I' or 'O')
226 @param sector Sector number (0-39)
227 @param strip Strip number (0-511)
228 @return Width of pedestal */
229 Float_t GetPedestalWidth(UShort_t detector,
232 UShort_t strip) const;
233 /** zero suppression threshold (in ADC counts)
234 @param detector Detector # (1-3)
235 @param ring Ring ID ('I' or 'O')
236 @param sector Sector number (0-39)
237 @param strip Strip number (0-511)
238 @return zero suppression threshold (in ADC counts) */
239 UShort_t GetZeroSuppression(UShort_t detector,
242 UShort_t strip) const;
243 /** Get the sampling rate
244 @param detector Detector # (1-3)
245 @param ring Ring ID ('I' or 'O')
246 @param sector Sector number (0-39)
247 @param strip Strip number (0-511)
248 @return The sampling rate */
249 UShort_t GetSampleRate(UShort_t detector,
252 UShort_t strip) const;
253 /** Get the minimum strip in the read-out range
254 @param detector Detector # (1-3)
255 @param ring Ring ID ('I' or 'O')
256 @param sector Sector number (0-39)
257 @param strip Strip number (0-511)
258 @return Minimum strip */
259 UShort_t GetMinStrip(UShort_t detector,
262 UShort_t strip) const;
263 /** Get the maximum strip in the read-out range
264 @param detector Detector # (1-3)
265 @param ring Ring ID ('I' or 'O')
266 @param sector Sector number (0-39)
267 @param strip Strip number (0-511)
268 @return Maximum strip */
269 UShort_t GetMaxStrip(UShort_t detector,
272 UShort_t strip) const;
273 /** Get the number of pre-samples in ALTRO channels
274 @param detector Detector # (1-3)
275 @param ring Ring ID ('I' or 'O')
276 @param sector Sector number (0-39)
277 @param strip Strip number (0-511)
278 @return Maximum strip */
279 UShort_t GetPreSamples(UShort_t,
282 UShort_t) const { return 14+5; }
286 @name Hardware to detector translation (and inverse) */
287 /** Map a hardware address into a detector index.
288 @param ddl Hardware DDL number
289 @param board FEC number
290 @param altro ALTRO number
291 @param channel Channel number
292 @param timebin Timebin
293 @param det On return, the detector #
294 @param ring On return, the ring ID
295 @param sec On return, the sector #
296 @param str On return, the base of strip #
297 @param sam On return, the sample number for this strip
298 @return @c true on success, false otherwise */
299 Bool_t Hardware2Detector(UInt_t ddl, UInt_t board,
300 UInt_t altro, UInt_t chan,
302 UShort_t& det, Char_t& ring,
303 UShort_t& sec, Short_t& str,
304 UShort_t& sam) const;
305 /** Translate hardware address to detector coordinates
306 @param ddl DDL number
307 @param board Board address
309 @param channel Channel #
310 @param det On return, Detector # (1-3)
311 @param ring On return, Ring ID ('I' or 'O')
312 @param sec On return, Sector number (0-39)
313 @param str On return, Strip number (0-511)
314 @return @c true on success. */
315 Bool_t Hardware2Detector(UInt_t ddl, UInt_t board,
316 UInt_t chip, UInt_t channel,
317 UShort_t& det, Char_t& ring,
318 UShort_t& sec, Short_t& str) const;
319 /** Map a hardware address into a detector index.
320 @param ddl Hardware DDL number
321 @param hwaddr Hardware address.
322 @param timebin Timebin
323 @param det On return, the detector #
324 @param ring On return, the ring ID
325 @param sec On return, the sector #
326 @param str On return, the base of strip #
327 @param sam On return, the sample number for this strip
328 @return @c true on success, false otherwise */
329 Bool_t Hardware2Detector(UInt_t ddl, UInt_t hwaddr,
331 UShort_t& det, Char_t& ring,
332 UShort_t& sec, Short_t& str,
333 UShort_t& sam) const;
334 /** Translate hardware address to detector coordinates
335 @param ddl DDL number
336 @param addr Hardware address
337 @param det On return, Detector # (1-3)
338 @param ring On return, Ring ID ('I' or 'O')
339 @param sec On return, Sector number (0-39)
340 @param str On return, Strip number (0-511)
341 @return @c true on success. */
342 Bool_t Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
343 Char_t& ring, UShort_t& sec, Short_t& str) const;
345 /** Map a detector index into a hardware address.
346 @param det The detector #
347 @param ring The ring ID
348 @param sec The sector #
349 @param str The strip #
350 @param sam The sample number
351 @param ddl On return, hardware DDL number
352 @param board On return, the FEC board address (local to DDL)
353 @param altro On return, the ALTRO number (local to FEC)
354 @param channel On return, the channel number (local to ALTRO)
355 @param timebin On return, the timebin number (local to ALTRO)
356 @return @c true on success, false otherwise */
357 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
358 UShort_t sec, UShort_t str,
360 UInt_t& ddl, UInt_t& board,
361 UInt_t& altro, UInt_t& channel,
362 UShort_t& timebin) const;
363 /** Translate detector coordinates to hardware address
364 @param det Detector # (1-3)
365 @param ring Ring ID ('I' or 'O')
366 @param sec Sector number (0-39)
367 @param str Strip number (0-511)
368 @param ddl On return, DDL number
369 @param board On return, Board address
370 @param chip On return, Chip #
371 @param channel On return, Channel #
372 @return @c true on success. */
373 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
374 UShort_t sec, UShort_t str,
375 UInt_t& ddl, UInt_t& board,
376 UInt_t& chip, UInt_t& channel) const;
377 /** Map a detector index into a hardware address.
378 @param det The detector #
379 @param ring The ring ID
380 @param sec The sector #
381 @param str The strip #
382 @param sam The sample number
383 @param ddl On return, hardware DDL number
384 @param hwaddr On return, hardware address.
385 @param timebin On return, the timebin number (local to ALTRO)
386 @return @c true on success, false otherwise */
387 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
388 UShort_t sec, UShort_t str,
390 UInt_t& ddl, UInt_t& hwaddr,
391 UShort_t& timebin) const;
392 /** Translate detector coordinates to hardware address
393 @param det Detector # (1-3)
394 @param ring Ring ID ('I' or 'O')
395 @param sec Sector number (0-39)
396 @param str Strip number (0-511)
397 @param ddl On return, DDL number
398 @param addr On return, Hardware address
399 @return @c true on success. */
400 Bool_t Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
401 UShort_t str, UInt_t& ddl, UInt_t& addr) const;
402 /** Get the map that translates hardware to detector coordinates
403 @return Get the map that translates hardware to detector
405 AliFMDAltroMapping* GetAltroMap() const;
406 /** Whether raw data has full common data header (8 32bit words) or
407 the older invalid format (7 32bit words with bogus entries)
408 @return false if the raw data has incomplete data header */
409 Bool_t HasCompleteHeader() const { return fHasCompleteHeader; }
413 static const char* PulseGainPath() { return fgkPulseGain; }
414 static const char* PedestalPath() { return fgkPedestal; }
415 static const char* DeadPath() { return fgkDead; }
416 static const char* SampleRatePath() { return fgkSampleRate; }
417 static const char* AltroMapPath() { return fgkAltroMap; }
418 static const char* ZeroSuppressionPath() { return fgkZeroSuppression; }
419 static const char* StripRangePath() { return fgkStripRange; }
420 static const char* GetPedestalShuttleID() {return fkPedestalShuttleID;}
421 static const char* GetGainShuttleID() {return fkGainShuttleID;}
422 static const char* GetConditionsShuttleID() {return fkConditionsShuttleID;}
427 AliFMDParameters(const AliFMDParameters& o)
430 fkSiDeDxMip(o.fkSiDeDxMip),
431 fVA1MipRange(o.fVA1MipRange),
432 fAltroChannelSize(o.fAltroChannelSize),
433 fChannelsPerAltro(o.fChannelsPerAltro),
434 fPedestalFactor(o.fPedestalFactor),
435 fFixedPedestal(o.fFixedPedestal),
436 fFixedPedestalWidth(o.fFixedPedestalWidth),
437 fFixedZeroSuppression(o.fFixedZeroSuppression),
438 fFixedSampleRate(o.fFixedSampleRate),
439 fFixedThreshold(o.fFixedThreshold),
440 fFixedMinStrip(o.fFixedMinStrip),
441 fFixedMaxStrip(o.fFixedMaxStrip),
442 fFixedPulseGain(o.fFixedPulseGain),
443 fEdepMip(o.fEdepMip),
444 fHasCompleteHeader(o.fHasCompleteHeader),
445 fZeroSuppression(o.fZeroSuppression),
446 fSampleRate(o.fSampleRate),
447 fPedestal(o.fPedestal),
448 fPulseGain(o.fPulseGain),
449 fDeadMap(o.fDeadMap),
450 fAltroMap(o.fAltroMap),
451 fStripRange(o.fStripRange)
453 /** Assignement operator
454 @return Reference to this */
455 AliFMDParameters& operator=(const AliFMDParameters&) { return *this; }
457 virtual ~AliFMDParameters() {}
458 /** Singleton instance */
459 static AliFMDParameters* fgInstance; // Static singleton instance
460 /** Get an entry from either global AliCDBManager or passed
462 @param path Path to CDB object.
463 @param pp AliFMDPreprocessor
464 @param fatal If true, raise a fatal flag if we didn't get the entry.
465 @return AliCDBEntry if found */
466 AliCDBEntry* GetEntry(const char* path, AliFMDPreprocessor* pp,
467 Bool_t fatal=kTRUE) const;
468 /** Initialize gains. Try to get them from CDB */
469 void InitPulseGain(AliFMDPreprocessor* pp=0);
470 /** Initialize pedestals. Try to get them from CDB */
471 void InitPedestal(AliFMDPreprocessor* pp=0);
472 /** Initialize dead map. Try to get it from CDB */
473 void InitDeadMap(AliFMDPreprocessor* pp=0);
474 /** Initialize sample rates. Try to get them from CDB */
475 void InitSampleRate(AliFMDPreprocessor* pp=0);
476 /** Initialize zero suppression thresholds. Try to get them from CDB */
477 void InitZeroSuppression(AliFMDPreprocessor* pp=0);
478 /** Initialize hardware map. Try to get it from CDB */
479 void InitAltroMap(AliFMDPreprocessor* pp=0);
480 /** Initialize strip range. Try to get it from CDB */
481 void InitStripRange(AliFMDPreprocessor* pp=0);
483 Bool_t fIsInit; // Whether we've been initialised
485 static const char* fgkPulseGain; // Path to PulseGain calib object
486 static const char* fgkPedestal; // Path to Pedestal calib object
487 static const char* fgkDead; // Path to Dead calib object
488 static const char* fgkSampleRate; // Path to SampleRate calib object
489 static const char* fgkAltroMap; // Path to AltroMap calib object
490 static const char* fgkZeroSuppression; // Path to ZeroSuppression cal object
491 static const char* fgkStripRange; // Path to strip range cal object
492 const Float_t fkSiDeDxMip; // MIP dE/dx in Silicon
493 UShort_t fVA1MipRange; // # MIPs the pre-amp can do
494 UShort_t fAltroChannelSize; // Largest # to store in 1 ADC ch.
495 UShort_t fChannelsPerAltro; // Number of pre-amp. chan/adc chan.
496 Float_t fPedestalFactor; // Number of pedestal widths
498 Float_t fFixedPedestal; // Pedestal to subtract
499 Float_t fFixedPedestalWidth; // Width of pedestal
500 UShort_t fFixedZeroSuppression; // Threshold for zero-suppression
501 UShort_t fFixedSampleRate; // Times the ALTRO samples pre-amp.
502 Float_t fFixedThreshold; // Threshold in ADC counts
503 UShort_t fFixedMinStrip; // Minimum strip read-out
504 UShort_t fFixedMaxStrip; // Maximum strip read-out
505 mutable Float_t fFixedPulseGain; //! Gain (cached)
506 mutable Float_t fEdepMip; //! Cache of energy loss for a MIP
507 Bool_t fHasCompleteHeader; // raw data has incomplete data header
509 static const char* fkPedestalShuttleID; // Shuttle/preprocessor ID for pedestals
510 static const char* fkGainShuttleID; // Shuttle/preprocessor ID for gains
511 static const char* fkConditionsShuttleID; // Shuttle/preprocessor ID for conditions
513 AliFMDCalibZeroSuppression* fZeroSuppression; // Zero suppression from CDB
514 AliFMDCalibSampleRate* fSampleRate; // Sample rate from CDB
515 AliFMDCalibPedestal* fPedestal; // Pedestals
516 AliFMDCalibGain* fPulseGain; // Pulser gain
517 AliFMDCalibDeadMap* fDeadMap; // Pulser gain
518 AliFMDAltroMapping* fAltroMap; // Map of hardware
519 AliFMDCalibStripRange* fStripRange; // Strip range
521 ClassDef(AliFMDParameters,6) // Manager of parameters
525 //____________________________________________________________________