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; }
149 /** @param n Number of pre-samples to keep during zero-suppression -
150 only used in simulation. */
151 void SetZSPreSamples(UShort_t n=1) { fZSPre = (n & 0x3); }
152 /** @param n Number of post-samples to keep during zero-suppression -
153 only used in simulation. */
154 void SetZSPostSamples(UShort_t n=1) { fZSPost = (n & 0x3); }
155 /** @param use If true, do pedestal subtraction before zero
156 suppression - only used in simulation */
157 void SetZSPedSubtract(Bool_t use=kTRUE) { fZSPedSubtract = use; }
161 /** @name Set various variable parameter defaults */
162 /** @param s Zero suppression threshold in ADC counts */
163 void SetZeroSuppression(UShort_t s=0) { fFixedZeroSuppression = s; }
164 /** @param r How many times we oversample each strip. */
165 void SetSampleRate(UShort_t r=1) { fFixedSampleRate = r ;}//(r>2?2:r);}
166 void SetSampleRate(AliFMDCalibSampleRate* r) { fSampleRate = r; }
167 /** @param p Pedestal value in ADC counts */
168 void SetPedestal(Float_t p=10) { fFixedPedestal = p; }
169 /** @param p Pedestal map */
170 void SetPedestal(AliFMDCalibPedestal* p) { fPedestal = p; }
171 /** @param w Pedestal width in ADC counts */
172 void SetPedestalWidth(Float_t w=1) { fFixedPedestalWidth = w; }
173 /** @param t Threshold used for 1 MIP acceptance. */
174 void SetThreshold(Float_t t=0) { fFixedThreshold = t; }
175 /** Range of strips read out
176 @param min Minimum strip number (0-127).
177 @param max Maximum strip number (0-127). */
178 void SetStripRange(UShort_t min=0, UShort_t max=127);
179 void SetStripRange(AliFMDCalibStripRange* r) { fStripRange = r; }
180 /** Whether raw data has full common data header (8 32bit words) or
181 the older invalid format (7 32bit words with bogus entries)
182 @param yes if true the raw data has complete data header */
183 void UseCompleteHeader(Bool_t yes=kTRUE) { fHasCompleteHeader = yes; }
184 /** @param g Gain map */
185 void SetGain(AliFMDCalibGain* g) { fPulseGain = g; }
189 /** @name Get `Fixed' various parameters */
190 /** @return Number of MIP signals that fit inside a VA1 channel */
191 UShort_t GetVA1MipRange() const { return fVA1MipRange; }
192 /** @return The maximum count in the ADC */
193 UShort_t GetAltroChannelSize() const { return fAltroChannelSize; }
194 /** @return Number of strips muliplexed into one ADC channel */
195 UShort_t GetChannelsPerAltro() const { return fChannelsPerAltro; }
196 /** @return The average energy deposited by one MIP */
197 Float_t GetEdepMip() const;
198 /** @return The conversion factor from DAC to ADC */
199 Float_t GetDACPerMIP() const;
200 /** @return The factor used of signal acceptance */
201 Float_t GetPedestalFactor() const { return fPedestalFactor; }
202 /** @param n Number of pre-samples to keep during zero-suppression -
203 only used in simulation. */
204 UShort_t GetZSPreSamples() const { return fZSPre; }
205 /** @param n Number of post-samples to keep during zero-suppression -
206 only used in simulation. */
207 UShort_t GetZSPostSamples() const { return fZSPost; }
208 /** @param use If true, do pedestal subtraction before zero
209 suppression - only used in simulation */
210 Bool_t IsZSPedSubtract() const { return fZSPedSubtract; }
214 /** @name Various varible conditions */
215 /** Whether the strip is considered dead
216 @param detector Detector # (1-3)
217 @param ring Ring ID ('I' or 'O')
218 @param sector Sector number (0-39)
219 @param strip Strip number (0-511)
220 @return @c true if the strip is considered dead, @c false if
222 Bool_t IsDead(UShort_t detector,
225 UShort_t strip) const;
226 Float_t GetThreshold() const;
228 @param detector Detector # (1-3)
229 @param ring Ring ID ('I' or 'O')
230 @param sector Sector number (0-39)
231 @param strip Strip number (0-511)
232 @return Gain of pre-amp. */
233 Float_t GetPulseGain(UShort_t detector,
236 UShort_t strip) const;
237 /** Get mean of pedestal
238 @param detector Detector # (1-3)
239 @param ring Ring ID ('I' or 'O')
240 @param sector Sector number (0-39)
241 @param strip Strip number (0-511)
242 @return Mean of pedestal */
243 Float_t GetPedestal(UShort_t detector,
246 UShort_t strip) const;
247 /** Width of pedestal
248 @param detector Detector # (1-3)
249 @param ring Ring ID ('I' or 'O')
250 @param sector Sector number (0-39)
251 @param strip Strip number (0-511)
252 @return Width of pedestal */
253 Float_t GetPedestalWidth(UShort_t detector,
256 UShort_t strip) const;
257 /** zero suppression threshold (in ADC counts)
258 @param detector Detector # (1-3)
259 @param ring Ring ID ('I' or 'O')
260 @param sector Sector number (0-39)
261 @param strip Strip number (0-511)
262 @return zero suppression threshold (in ADC counts) */
263 UShort_t GetZeroSuppression(UShort_t detector,
266 UShort_t strip) const;
267 /** Get the sampling rate
268 @param detector Detector # (1-3)
269 @param ring Ring ID ('I' or 'O')
270 @param sector Sector number (0-39)
271 @param strip Strip number (0-511)
272 @return The sampling rate */
273 UShort_t GetSampleRate(UShort_t detector,
276 UShort_t strip) const;
277 /** Get the minimum strip in the read-out range
278 @param detector Detector # (1-3)
279 @param ring Ring ID ('I' or 'O')
280 @param sector Sector number (0-39)
281 @param strip Strip number (0-511)
282 @return Minimum strip */
283 UShort_t GetMinStrip(UShort_t detector,
286 UShort_t strip) const;
287 /** Get the maximum strip in the read-out range
288 @param detector Detector # (1-3)
289 @param ring Ring ID ('I' or 'O')
290 @param sector Sector number (0-39)
291 @param strip Strip number (0-511)
292 @return Maximum strip */
293 UShort_t GetMaxStrip(UShort_t detector,
296 UShort_t strip) const;
297 /** Get the number of pre-samples in ALTRO channels
298 @param detector Detector # (1-3)
299 @param ring Ring ID ('I' or 'O')
300 @param sector Sector number (0-39)
301 @param strip Strip number (0-511)
302 @return Maximum strip */
303 UShort_t GetPreSamples(UShort_t,
306 UShort_t) const { return 14+5; }
310 @name Hardware to detector translation (and inverse) */
311 /** Map a hardware address into a detector index.
312 @param ddl Hardware DDL number
313 @param board FEC number
314 @param altro ALTRO number
315 @param channel Channel number
316 @param timebin Timebin
317 @param det On return, the detector #
318 @param ring On return, the ring ID
319 @param sec On return, the sector #
320 @param str On return, the base of strip #
321 @param sam On return, the sample number for this strip
322 @return @c true on success, false otherwise */
323 Bool_t Hardware2Detector(UShort_t ddl, UShort_t board,
324 UShort_t altro, UShort_t chan,
326 UShort_t& det, Char_t& ring,
327 UShort_t& sec, Short_t& str,
328 UShort_t& sam) const;
329 /** Map a hardware address into a detector index.
330 @param ddl Hardware DDL number
331 @param hwaddr Hardware address.
332 @param timebin Timebin
333 @param det On return, the detector #
334 @param ring On return, the ring ID
335 @param sec On return, the sector #
336 @param str On return, the base of strip #
337 @param sam On return, the sample number for this strip
338 @return @c true on success, false otherwise */
339 Bool_t Hardware2Detector(UShort_t ddl, UShort_t hwaddr,
341 UShort_t& det, Char_t& ring,
342 UShort_t& sec, Short_t& str,
343 UShort_t& sam) const;
345 /** Translate hardware address to detector coordinates
346 @param ddl DDL number
347 @param board Board address
349 @param channel Channel #
350 @param det On return, Detector # (1-3)
351 @param ring On return, Ring ID ('I' or 'O')
352 @param sec On return, Sector number (0-39)
353 @param str On return, Strip number (0-511)
354 @return @c true on success. */
355 Bool_t Hardware2Detector(UShort_t ddl, UShort_t board,
356 UShort_t chip, UShort_t channel,
357 UShort_t& det, Char_t& ring,
358 UShort_t& sec, Short_t& str) const;
359 /** Translate hardware address to detector coordinates
360 @param ddl DDL number
361 @param addr Hardware address
362 @param det On return, Detector # (1-3)
363 @param ring On return, Ring ID ('I' or 'O')
364 @param sec On return, Sector number (0-39)
365 @param str On return, Strip number (0-511)
366 @return @c true on success. */
367 Bool_t Hardware2Detector(UShort_t ddl, UShort_t addr, UShort_t& det,
368 Char_t& ring, UShort_t& sec, Short_t& str) const;
371 /** Map a detector index into a hardware address.
372 @param det The detector #
373 @param ring The ring ID
374 @param sec The sector #
375 @param str The strip #
376 @param sam The sample number
377 @param ddl On return, hardware DDL number
378 @param board On return, the FEC board address (local to DDL)
379 @param altro On return, the ALTRO number (local to FEC)
380 @param channel On return, the channel number (local to ALTRO)
381 @param timebin On return, the timebin number (local to ALTRO)
382 @return @c true on success, false otherwise */
383 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
384 UShort_t sec, UShort_t str,
386 UShort_t& ddl, UShort_t& board,
387 UShort_t& altro, UShort_t& channel,
388 UShort_t& timebin) const;
389 /** Map a detector index into a hardware address.
390 @param det The detector #
391 @param ring The ring ID
392 @param sec The sector #
393 @param str The strip #
394 @param sam The sample number
395 @param ddl On return, hardware DDL number
396 @param hwaddr On return, hardware address.
397 @param timebin On return, the timebin number (local to ALTRO)
398 @return @c true on success, false otherwise */
399 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
400 UShort_t sec, UShort_t str,
402 UShort_t& ddl, UShort_t& hwaddr,
403 UShort_t& timebin) const;
405 /** Translate detector coordinates to hardware address
406 @param det Detector # (1-3)
407 @param ring Ring ID ('I' or 'O')
408 @param sec Sector number (0-39)
409 @param str Strip number (0-511)
410 @param ddl On return, DDL number
411 @param board On return, Board address
412 @param chip On return, Chip #
413 @param channel On return, Channel #
414 @return @c true on success. */
415 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
416 UShort_t sec, UShort_t str,
417 UShort_t& ddl, UShort_t& board,
418 UShort_t& chip, UShort_t& channel) const;
419 /** Translate detector coordinates to hardware address
420 @param det Detector # (1-3)
421 @param ring Ring ID ('I' or 'O')
422 @param sec Sector number (0-39)
423 @param str Strip number (0-511)
424 @param ddl On return, DDL number
425 @param addr On return, Hardware address
426 @return @c true on success. */
427 Bool_t Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
428 UShort_t str, UShort_t& ddl, UShort_t& addr) const;
430 /** Get the map that translates hardware to detector coordinates
431 @return Get the map that translates hardware to detector
433 AliFMDAltroMapping* GetAltroMap() const;
434 /** Whether raw data has full common data header (8 32bit words) or
435 the older invalid format (7 32bit words with bogus entries)
436 @return false if the raw data has incomplete data header */
437 Bool_t HasCompleteHeader() const { return fHasCompleteHeader; }
441 static const char* PulseGainPath() { return fgkPulseGain; }
442 static const char* PedestalPath() { return fgkPedestal; }
443 static const char* DeadPath() { return fgkDead; }
444 static const char* SampleRatePath() { return fgkSampleRate; }
445 static const char* AltroMapPath() { return fgkAltroMap; }
446 static const char* ZeroSuppressionPath() { return fgkZeroSuppression; }
447 static const char* StripRangePath() { return fgkStripRange; }
448 static const char* GetPedestalShuttleID() {return fkPedestalShuttleID;}
449 static const char* GetGainShuttleID() {return fkGainShuttleID;}
450 static const char* GetConditionsShuttleID() {return fkConditionsShuttleID;}
455 AliFMDParameters(const AliFMDParameters& o)
458 fkSiDeDxMip(o.fkSiDeDxMip),
459 fVA1MipRange(o.fVA1MipRange),
460 fAltroChannelSize(o.fAltroChannelSize),
461 fChannelsPerAltro(o.fChannelsPerAltro),
462 fPedestalFactor(o.fPedestalFactor),
465 fZSPedSubtract(o.fZSPedSubtract),
466 fFixedPedestal(o.fFixedPedestal),
467 fFixedPedestalWidth(o.fFixedPedestalWidth),
468 fFixedZeroSuppression(o.fFixedZeroSuppression),
469 fFixedSampleRate(o.fFixedSampleRate),
470 fFixedThreshold(o.fFixedThreshold),
471 fFixedMinStrip(o.fFixedMinStrip),
472 fFixedMaxStrip(o.fFixedMaxStrip),
473 fFixedPulseGain(o.fFixedPulseGain),
474 fEdepMip(o.fEdepMip),
475 fHasCompleteHeader(o.fHasCompleteHeader),
476 fZeroSuppression(o.fZeroSuppression),
477 fSampleRate(o.fSampleRate),
478 fPedestal(o.fPedestal),
479 fPulseGain(o.fPulseGain),
480 fDeadMap(o.fDeadMap),
481 fAltroMap(o.fAltroMap),
482 fStripRange(o.fStripRange)
484 /** Assignement operator
485 @return Reference to this */
486 AliFMDParameters& operator=(const AliFMDParameters&) { return *this; }
488 virtual ~AliFMDParameters() {}
489 /** Singleton instance */
490 static AliFMDParameters* fgInstance; // Static singleton instance
491 /** Get an entry from either global AliCDBManager or passed
493 @param path Path to CDB object.
494 @param pp AliFMDPreprocessor
495 @param fatal If true, raise a fatal flag if we didn't get the entry.
496 @return AliCDBEntry if found */
497 AliCDBEntry* GetEntry(const char* path, AliFMDPreprocessor* pp,
498 Bool_t fatal=kTRUE) const;
499 /** Initialize gains. Try to get them from CDB */
500 void InitPulseGain(AliFMDPreprocessor* pp=0);
501 /** Initialize pedestals. Try to get them from CDB */
502 void InitPedestal(AliFMDPreprocessor* pp=0);
503 /** Initialize dead map. Try to get it from CDB */
504 void InitDeadMap(AliFMDPreprocessor* pp=0);
505 /** Initialize sample rates. Try to get them from CDB */
506 void InitSampleRate(AliFMDPreprocessor* pp=0);
507 /** Initialize zero suppression thresholds. Try to get them from CDB */
508 void InitZeroSuppression(AliFMDPreprocessor* pp=0);
509 /** Initialize hardware map. Try to get it from CDB */
510 void InitAltroMap(AliFMDPreprocessor* pp=0);
511 /** Initialize strip range. Try to get it from CDB */
512 void InitStripRange(AliFMDPreprocessor* pp=0);
514 Bool_t fIsInit; // Whether we've been initialised
516 static const char* fgkPulseGain; // Path to PulseGain calib object
517 static const char* fgkPedestal; // Path to Pedestal calib object
518 static const char* fgkDead; // Path to Dead calib object
519 static const char* fgkSampleRate; // Path to SampleRate calib object
520 static const char* fgkAltroMap; // Path to AltroMap calib object
521 static const char* fgkZeroSuppression; // Path to ZeroSuppression cal object
522 static const char* fgkStripRange; // Path to strip range cal object
523 const Float_t fkSiDeDxMip; // MIP dE/dx in Silicon
524 UShort_t fVA1MipRange; // # MIPs the pre-amp can do
525 UShort_t fAltroChannelSize; // Largest # to store in 1 ADC ch.
526 UShort_t fChannelsPerAltro; // Number of pre-amp. chan/adc chan.
527 Float_t fPedestalFactor; // Number of pedestal widths
528 UShort_t fZSPre; // Number of pre-samples in ZS
529 UShort_t fZSPost; // Number of post-samples in ZS
530 Bool_t fZSPedSubtract; // Pedestal subtraction before ZS
532 Float_t fFixedPedestal; // Pedestal to subtract
533 Float_t fFixedPedestalWidth; // Width of pedestal
534 UShort_t fFixedZeroSuppression; // Threshold for zero-suppression
535 UShort_t fFixedSampleRate; // Times the ALTRO samples pre-amp.
536 Float_t fFixedThreshold; // Threshold in ADC counts
537 UShort_t fFixedMinStrip; // Minimum strip read-out
538 UShort_t fFixedMaxStrip; // Maximum strip read-out
539 mutable Float_t fFixedPulseGain; //! Gain (cached)
540 mutable Float_t fEdepMip; //! Cache of energy loss for a MIP
541 Bool_t fHasCompleteHeader; // raw data has incomplete data header
543 static const char* fkPedestalShuttleID; // Shuttle/preprocessor ID for pedestals
544 static const char* fkGainShuttleID; // Shuttle/preprocessor ID for gains
545 static const char* fkConditionsShuttleID; // Shuttle/preprocessor ID for conditions
547 AliFMDCalibZeroSuppression* fZeroSuppression; // Zero suppression from CDB
548 AliFMDCalibSampleRate* fSampleRate; // Sample rate from CDB
549 AliFMDCalibPedestal* fPedestal; // Pedestals
550 AliFMDCalibGain* fPulseGain; // Pulser gain
551 AliFMDCalibDeadMap* fDeadMap; // Pulser gain
552 AliFMDAltroMapping* fAltroMap; // Map of hardware
553 AliFMDCalibStripRange* fStripRange; // Strip range
555 ClassDef(AliFMDParameters,6) // Manager of parameters
559 //____________________________________________________________________