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 #include "AliFMDCalibFwd.h"
29 class AliFMDPreprocessor;
31 //____________________________________________________________________
33 // Singleton class to handle various parameters (not geometry) of the
35 // Should get ata fromm Conditions DB.
38 /** @brief This class is a singleton that handles various parameters
40 This class reads from the Conditions DB to get the various
41 parameters, which code can then request from here. In that way,
42 all code uses the same data, and the interface is consistent.
44 Some of the parameter managed are
45 - @c fPedestal, @c fPedestalWidth
46 Mean and width of the pedestal. The pedestal is simulated
47 by a Guassian, but derived classes my override MakePedestal
48 to simulate it differently (or pick it up from a database).
50 The dymamic MIP range of the VA1_ALICE pre-amplifier chip
51 - @c fAltroChannelSize
52 The largest number plus one that can be stored in one
53 channel in one time step in the ALTRO ADC chip.
55 How many times the ALTRO ADC chip samples the VA1_ALICE
56 pre-amplifier signal. The VA1_ALICE chip is read-out at
57 10MHz, while it's possible to drive the ALTRO chip at
58 25MHz. That means, that the ALTRO chip can have time to
59 sample each VA1_ALICE signal up to 2 times. Although it's
60 not certain this feature will be used in the production,
61 we'd like have the option, and so it should be reflected in
66 class AliFMDParameters : public TNamed
69 /** Enumeration of things to initialize */
72 kPulseGain = 0x1, // Pulser gain
73 /** Pedestals and noise */
74 kPedestal = 0x2, // Pedestal and noise
75 /** Dead channel map */
76 kDeadMap = 0x4, // Dead channel map
77 /** Over sampling rate */
78 kSampleRate = 0x8, // Over sampling rate
79 /** Zero suppression parameters */
80 kZeroSuppression = 0x10, // Zero suppression parameters
82 kAltroMap = 0x20, // Altro channel map
84 kStripRange = 0x40 //Strip range,
87 kAll = (kPulseGain|kPedestal|kDeadMap|kSampleRate|
88 kZeroSuppression|kAltroMap|kStripRange)
97 static AliFMDParameters* Instance();
100 * Initialize the manager. This tries to read the parameters from
101 * CDB. If that fails, the class uses the hard-coded parameters.
103 * @param forceReInit Force (re-)initalize flag
104 * @param what What to initialize
106 void Init(Bool_t forceReInit=kFALSE, UInt_t what=kAll );
108 * Initialize the manager. This tries to read the parameters from
109 * CDB. If that fails, the class uses the hard-coded parameters.
111 * @param pp Preprocessor
112 * @param forceReInit Force (re-)initalize flag
113 * @param what What to initialize
115 void Init(AliFMDPreprocessor* pp,
116 Bool_t forceReInit=kFALSE,
119 * Initialize the manager. This will try to read some calibrations
120 * (sample rate, strip range, gains, pedestals) from local comma
121 * separated value (CSV) files in the directory pointed at by @a
122 * path. If they are not found, then they will be retrieved from
123 * OCDB as appropriately. Other calibrations are always read from
126 * The CSV files should be named as
128 * - Pedestals: <tt>peds</tt><i>det_number</i><tt>.csv</tt>
129 * - Gains: <tt>gains</tt><i>det_number</i><tt>.csv</tt>
130 * - Sample Rate: <tt>conditions</tt><i>det_number</i><tt>.csv</tt>
131 * - Strip Range: <tt>conditions</tt><i>det_number</i><tt>.csv</tt>
133 * where <i>det_number</i> is the detector number (1, 2, or 3).
135 * @param path Where to look for the CSV files
136 * @param forceReInit Always reinitialise
137 * @param what What calibrations to load.
139 void Init(const char* path,
140 Bool_t forceReInit=kFALSE,
144 * Automatically generate a dead map from the pedestals and gains.
145 * A channel is marked as dead of the noise is too high (currently
146 * more than 10 ADC counts), or the gain is unreasonable (currently
147 * larger than 10, or smaller than 0.1).
149 * The procedure does not overwrite channels previously marked as
150 * dead - e.g., channels marked as dead in the calibration loaded
151 * from OCDB will continue to be marked as dead. That is, this
152 * procedure will never make a channel un-dead.
154 * @param maxNoise Maximum noise value before a channel is marked
156 * @param minGain Minimum value of the calibrated gain before a
157 * channel is considered dead.
158 * @param maxGain Maximum value of the calibrated gain before a
159 * channel is considered dead.
161 void MakeDeadMap(Float_t maxNoise=10, Float_t minGain=.1, Float_t maxGain=10);
163 * Print all parameters.
165 * If option contains an 'A' then everything is printed.
167 * If the option contains the string "FMD" the function will search
168 * for detector, ring, sector, and strip numbers to print, in
172 * FMD<detector><ring>[<sector>,<string>]
175 * The wild card '*' means all of <detector>, <ring>, <sector>, or
178 * @param option Option string
180 void Print(Option_t* option="A") const;
184 * @param option What to draw. Should be one of
185 * - dead Dead channels
186 * - threshold Threshold
188 * - pedestal Pedestal
189 * - noise Noise (or pedestal width)
190 * - zero Zero suppression
191 * - rate Sampling rate (VA1 clock / ALTRO clock)
192 * - min Minimum strip read out
193 * - max Maximum strip read out
194 * - map hardware address
196 void Draw(Option_t* option="pedestal");
199 /** @name Set various `Fixed' parameters */
201 * @param r How many MIP signals we can fit in the VA1
202 * pre-amps. (default and design is 20)
204 void SetVA1MipRange(UShort_t r=20) { fVA1MipRange = r; }
206 * @param s Maximum number of the ADC (ALTRO). This is a 10 bit
207 * ADC so, the maximum number is 1024
209 void SetAltroChannelSize(UShort_t s=1024) { fAltroChannelSize = s;}
211 * @param size The number of strips multiplexed into one ALTRO
212 * channel. That is, how many strips is connected to one VA1
215 void SetChannelsPerAltro(UShort_t size=128) { fChannelsPerAltro = size; }
217 * @param f Factor to use for accepting a signal.
219 void SetPedestalFactor(Float_t f=3) { fPedestalFactor = f; }
221 * @param n Number of pre-samples to keep during zero-suppression -
222 * only used in simulation.
224 void SetZSPreSamples(UShort_t n=1) { fZSPre = (n & 0x3); }
226 * @param n Number of post-samples to keep during zero-suppression -
227 * only used in simulation.
229 void SetZSPostSamples(UShort_t n=1) { fZSPost = (n & 0x3); }
231 * @param use If true, do pedestal subtraction before zero
232 * suppression - only used in simulation
234 void SetZSPedSubtract(Bool_t use=kTRUE) { fZSPedSubtract = use; }
238 /** @name Set various variable parameter defaults */
240 * @param s Zero suppression threshold in ADC counts
242 void SetZeroSuppression(UShort_t s=1) { fFixedZeroSuppression = s; }
244 * @param r How many times we oversample each strip.
246 void SetSampleRate(UShort_t r=2) { fFixedSampleRate = r ;}//(r>2?2:r);}
248 * @param r How many times we oversample each strip.
250 void SetSampleRate(AliFMDCalibSampleRate* r) { fSampleRate = r; }
252 * @param p Pedestal value in ADC counts
254 void SetPedestal(Float_t p=100) { fFixedPedestal = p; }
256 * @param p Pedestal map
258 void SetPedestal(AliFMDCalibPedestal* p) { fPedestal = p; }
260 * @param w Pedestal width in ADC counts
262 void SetPedestalWidth(Float_t w=2) { fFixedPedestalWidth = w; }
264 * @param t Threshold used for 1 MIP acceptance.
266 void SetThreshold(Float_t t=0) { fFixedThreshold = t; }
268 * Range of strips read out
270 * @param min Minimum strip number (0-127).
271 * @param max Maximum strip number (0-127).
273 void SetStripRange(UShort_t min=0, UShort_t max=127);
275 * set the strip range from object
277 * @param r Strip range object
279 void SetStripRange(AliFMDCalibStripRange* r) { fStripRange = r; }
281 * Whether raw data has full common data header (8 32bit words) or
282 * the older invalid format (7 32bit words with bogus entries)
284 * @param yes if true the raw data has complete data header
286 void UseCompleteHeader(Bool_t yes=kTRUE) { fHasCompleteHeader = yes; }
290 void SetGain(AliFMDCalibGain* g) { fPulseGain = g; }
294 void SetGain(Float_t g=2) { fFixedPulseGain = g; }
298 /** @name Get `Fixed' various parameters */
300 * @return Number of MIP signals that fit inside a VA1 channel
302 UShort_t GetVA1MipRange() const { return fVA1MipRange; }
304 * @return The maximum count in the ADC
306 UShort_t GetAltroChannelSize() const { return fAltroChannelSize; }
308 * @return Number of strips muliplexed into one ADC channel
310 UShort_t GetChannelsPerAltro() const { return fChannelsPerAltro; }
312 * @return The average energy deposited by one MIP
314 Float_t GetEdepMip() const;
316 * This is the conversion from Digital-to-Analog-Converter setting
317 * to the number of MIPs. The number was measured in the NBI lab during
320 * @return The conversion factor from DAC to ADC
322 Float_t GetDACPerMIP() const;
324 * @return The factor used of signal acceptance
326 Float_t GetPedestalFactor() const { return fPedestalFactor; }
328 * @param n Number of pre-samples to keep during zero-suppression -
329 * only used in simulation.
331 UShort_t GetZSPreSamples() const { return fZSPre; }
333 * @param n Number of post-samples to keep during zero-suppression -
334 * only used in simulation.
336 UShort_t GetZSPostSamples() const { return fZSPost; }
338 * @param use If true, do pedestal subtraction before zero
339 * suppression - only used in simulation
341 Bool_t IsZSPedSubtract() const { return fZSPedSubtract; }
345 /** @name Various varible conditions */
347 * Whether the strip is considered dead
349 * @param detector Detector # (1-3)
350 * @param ring Ring ID ('I' or 'O')
351 * @param sector Sector number (0-39)
352 * @param strip Strip number (0-511)
354 * @return @c true if the strip is considered dead, @c false if it's
357 Bool_t IsDead(UShort_t detector,
360 UShort_t strip) const;
362 * Get the threshold in the pulser gain
365 * @return Threshold from pulser
367 Float_t GetThreshold() const;
369 * Gain of pre-amp. for strip, sector, ring, detector
371 * For simulations this is normally set to
374 * \frac{\mbox{VA1_MIP_Range}{\mbox{ALTRO_channel_size}}\mbox{MIP_Energy_Loss}
378 * @param detector Detector # (1-3)
379 * @param ring Ring ID ('I' or 'O')
380 * @param sector Sector number (0-39)
381 * @param strip Strip number (0-511)
383 * @return Gain of pre-amp.
385 Float_t GetPulseGain(UShort_t detector,
388 UShort_t strip) const;
390 * Get mean of pedestal
392 * @param detector Detector # (1-3)
393 * @param ring Ring ID ('I' or 'O')
394 * @param sector Sector number (0-39)
395 * @param strip Strip number (0-511)
397 * @return Mean of pedestal
399 Float_t GetPedestal(UShort_t detector,
402 UShort_t strip) const;
406 * @param detector Detector # (1-3)
407 * @param ring Ring ID ('I' or 'O')
408 * @param sector Sector number (0-39)
409 * @param strip Strip number (0-511)
411 * @return Width of pedestal
413 Float_t GetPedestalWidth(UShort_t detector,
416 UShort_t strip) const;
418 * zero suppression threshold (in ADC counts)
420 * @param detector Detector # (1-3)
421 * @param ring Ring ID ('I' or 'O')
422 * @param sector Sector number (0-39)
423 * @param strip Strip number (0-511)
425 * @return zero suppression threshold (in ADC counts)
427 UShort_t GetZeroSuppression(UShort_t detector,
430 UShort_t strip) const;
432 * Get the sampling rate
434 * @param detector Detector # (1-3)
435 * @param ring Ring ID ('I' or 'O')
436 * @param sector Sector number (0-39)
437 * @param strip Strip number (0-511)
439 * @return The sampling rate
441 UShort_t GetSampleRate(UShort_t detector,
444 UShort_t strip) const;
446 * Get the minimum strip in the read-out range
448 * @param detector Detector # (1-3)
449 * @param ring Ring ID ('I' or 'O')
450 * @param sector Sector number (0-39)
451 * @param strip Strip number (0-511)
453 * @return Minimum strip
455 UShort_t GetMinStrip(UShort_t detector,
458 UShort_t strip) const;
460 * Get the maximum strip in the read-out range
462 * @param detector Detector # (1-3)
463 * @param ring Ring ID ('I' or 'O')
464 * @param sector Sector number (0-39)
465 * @param strip Strip number (0-511)
467 * @return Maximum strip
469 UShort_t GetMaxStrip(UShort_t detector,
472 UShort_t strip) const;
474 * Get the number of pre-samples in ALTRO channels
476 * @param detector Detector # (1-3)
477 * @param ring Ring ID ('I' or 'O')
478 * @param sector Sector number (0-39)
479 * @param strip Strip number (0-511)
481 * @return Maximum strip
483 UShort_t GetPreSamples(UShort_t,
486 UShort_t) const { return 14+5; }
491 * @name Hardware to detector translation (and inverse)
494 * Map a hardware address into a detector index.
496 * @param ddl Hardware DDL number
497 * @param board FEC number
498 * @param altro ALTRO number
499 * @param channel Channel number
500 * @param timebin Timebin
501 * @param det On return, the detector #
502 * @param ring On return, the ring ID
503 * @param sec On return, the sector #
504 * @param str On return, the base of strip #
505 * @param sam On return, the sample number for this strip
507 * @return @c true on success, false otherwise
509 Bool_t Hardware2Detector(UShort_t ddl, UShort_t board,
510 UShort_t altro, UShort_t chan,
512 UShort_t& det, Char_t& ring,
513 UShort_t& sec, Short_t& str,
514 UShort_t& sam) const;
516 * Map a hardware address into a detector index.
518 * @param ddl Hardware DDL number
519 * @param hwaddr Hardware address.
520 * @param timebin Timebin
521 * @param det On return, the detector #
522 * @param ring On return, the ring ID
523 * @param sec On return, the sector #
524 * @param str On return, the base of strip #
525 * @param sam On return, the sample number for this strip
527 * @return @c true on success, false otherwise
529 Bool_t Hardware2Detector(UShort_t ddl, UShort_t hwaddr,
531 UShort_t& det, Char_t& ring,
532 UShort_t& sec, Short_t& str,
533 UShort_t& sam) const;
536 * Map a detector index into a hardware address.
538 * @param det The detector #
539 * @param ring The ring ID
540 * @param sec The sector #
541 * @param str The strip #
542 * @param sam The sample number
543 * @param ddl On return, hardware DDL number
544 * @param board On return, the FEC board address (local to DDL)
545 * @param altro On return, the ALTRO number (local to FEC)
546 * @param channel On return, the channel number (local to ALTRO)
547 * @param timebin On return, the timebin number (local to ALTRO)
549 * @return @c true on success, false otherwise
551 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
552 UShort_t sec, UShort_t str,
554 UShort_t& ddl, UShort_t& board,
555 UShort_t& altro, UShort_t& channel,
556 UShort_t& timebin) const;
558 * Map a detector index into a hardware address.
560 * @param det The detector #
561 * @param ring The ring ID
562 * @param sec The sector #
563 * @param str The strip #
564 * @param sam The sample number
565 * @param ddl On return, hardware DDL number
566 * @param hwaddr On return, hardware address.
567 * @param timebin On return, the timebin number (local to ALTRO)
569 * @return @c true on success, false otherwise
571 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
572 UShort_t sec, UShort_t str,
574 UShort_t& ddl, UShort_t& hwaddr,
575 UShort_t& timebin) const;
577 * Get the map that translates hardware to detector coordinates
579 * @return Get the map that translates hardware to detector
582 AliFMDAltroMapping* GetAltroMap() const;
584 * Whether raw data has full common data header (8 32bit words) or
585 * the older invalid format (7 32bit words with bogus entries)
587 * @return false if the raw data has incomplete data header
589 Bool_t HasCompleteHeader() const { return fHasCompleteHeader; }
593 static const char* PulseGainPath() { return fgkPulseGain; }
594 static const char* PedestalPath() { return fgkPedestal; }
595 static const char* DeadPath() { return fgkDead; }
596 static const char* SampleRatePath() { return fgkSampleRate; }
597 static const char* AltroMapPath() { return fgkAltroMap; }
598 static const char* ZeroSuppressionPath() { return fgkZeroSuppression; }
599 static const char* StripRangePath() { return fgkStripRange; }
600 static const char* GetPedestalShuttleID() {return fkPedestalShuttleID;}
601 static const char* GetGainShuttleID() {return fkGainShuttleID;}
602 static const char* GetConditionsShuttleID() {return fkConditionsShuttleID;}
612 AliFMDParameters(const AliFMDParameters& o)
615 fkSiDeDxMip(o.fkSiDeDxMip),
616 fVA1MipRange(o.fVA1MipRange),
617 fAltroChannelSize(o.fAltroChannelSize),
618 fChannelsPerAltro(o.fChannelsPerAltro),
619 fPedestalFactor(o.fPedestalFactor),
622 fZSPedSubtract(o.fZSPedSubtract),
623 fFixedPedestal(o.fFixedPedestal),
624 fFixedPedestalWidth(o.fFixedPedestalWidth),
625 fFixedZeroSuppression(o.fFixedZeroSuppression),
626 fFixedSampleRate(o.fFixedSampleRate),
627 fFixedThreshold(o.fFixedThreshold),
628 fFixedMinStrip(o.fFixedMinStrip),
629 fFixedMaxStrip(o.fFixedMaxStrip),
630 fFixedPulseGain(o.fFixedPulseGain),
631 fEdepMip(o.fEdepMip),
632 fHasCompleteHeader(o.fHasCompleteHeader),
633 fZeroSuppression(o.fZeroSuppression),
634 fSampleRate(o.fSampleRate),
635 fPedestal(o.fPedestal),
636 fPulseGain(o.fPulseGain),
637 fDeadMap(o.fDeadMap),
638 fAltroMap(o.fAltroMap),
639 fStripRange(o.fStripRange)
642 * Assignement operator
644 * @return Reference to this
646 AliFMDParameters& operator=(const AliFMDParameters&) { return *this; }
650 virtual ~AliFMDParameters() {}
654 static AliFMDParameters* fgInstance; // Static singleton instance
656 * Check if the file <i>prefix</i><i>number</i> exists in @a path,
657 * and write the full path to @a f.
659 * @param prefix File prefix (cond, peds, gains, ...)
660 * @param path Path to files
661 * @param number Detector number (1, 2, or 3)
662 * @param f On return full path to file (if found)
664 * @return @c true if file exists and is readable, @c false otherwise
666 Bool_t CheckFile(const char* prefix, const char* path,
667 int number, TString& f) const;
669 * Get an entry from either global AliCDBManager or passed
670 * AliFMDPreprocessor.
672 * @param path Path to CDB object.
673 * @param pp AliFMDPreprocessor
674 * @param fatal If true, raise a fatal flag if we didn't get the entry.
675 * @return AliCDBEntry if found
677 AliCDBEntry* GetEntry(const char* path, AliFMDPreprocessor* pp,
678 Bool_t fatal=kTRUE) const;
680 * Initialize gains. Try to get them from CDB
682 * @param pp Pre-processor if called from shuttle
684 void InitPulseGain(AliFMDPreprocessor* pp=0);
686 * Initialize pedestals. Try to get them from CDB
688 * @param pp Pre-processor if called from shuttle
690 void InitPedestal(AliFMDPreprocessor* pp=0);
692 * Initialize dead map. Try to get it from CDB
694 * @param pp Pre-processor if called from shuttle
696 void InitDeadMap(AliFMDPreprocessor* pp=0);
698 * Initialize sample rates. Try to get them from CDB
700 * @param pp Pre-processor if called from shuttle
702 void InitSampleRate(AliFMDPreprocessor* pp=0);
704 * Initialize zero suppression thresholds. Try to get them from CDB
706 * @param pp Pre-processor if called from shuttle
708 void InitZeroSuppression(AliFMDPreprocessor* pp=0);
710 * Initialize hardware map. Try to get it from CDB
712 * @param pp Pre-processor if called from shuttle
714 void InitAltroMap(AliFMDPreprocessor* pp=0);
716 * Initialize strip range. Try to get it from CDB
718 * @param pp Pre-processor if called from shuttle
720 void InitStripRange(AliFMDPreprocessor* pp=0);
722 Bool_t fIsInit; // Whether we've been initialised
724 static const char* fgkPulseGain; // Path to PulseGain calib object
725 static const char* fgkPedestal; // Path to Pedestal calib object
726 static const char* fgkDead; // Path to Dead calib object
727 static const char* fgkSampleRate; // Path to SampleRate calib object
728 static const char* fgkAltroMap; // Path to AltroMap calib object
729 static const char* fgkZeroSuppression; // Path to ZeroSuppression cal object
730 static const char* fgkStripRange; // Path to strip range cal object
731 const Float_t fkSiDeDxMip; // MIP dE/dx in Silicon
732 UShort_t fVA1MipRange; // # MIPs the pre-amp can do
733 UShort_t fAltroChannelSize; // Largest # to store in 1 ADC ch.
734 UShort_t fChannelsPerAltro; // Number of pre-amp. chan/adc chan.
735 Float_t fPedestalFactor; // Number of pedestal widths
736 UShort_t fZSPre; // Number of pre-samples in ZS
737 UShort_t fZSPost; // Number of post-samples in ZS
738 Bool_t fZSPedSubtract; // Pedestal subtraction before ZS
740 Float_t fFixedPedestal; // Pedestal to subtract
741 Float_t fFixedPedestalWidth; // Width of pedestal
742 UShort_t fFixedZeroSuppression; // Threshold for zero-suppression
743 UShort_t fFixedSampleRate; // Times the ALTRO samples pre-amp.
744 Float_t fFixedThreshold; // Threshold in ADC counts
745 UShort_t fFixedMinStrip; // Minimum strip read-out
746 UShort_t fFixedMaxStrip; // Maximum strip read-out
747 mutable Float_t fFixedPulseGain; //! Gain (cached)
748 mutable Float_t fEdepMip; //! Cache of energy loss for a MIP
749 Bool_t fHasCompleteHeader; // raw data has incomplete data header
751 static const char* fkPedestalShuttleID; // Shuttle/preprocessor ID for pedestals
752 static const char* fkGainShuttleID; // Shuttle/preprocessor ID for gains
753 static const char* fkConditionsShuttleID; // Shuttle/preprocessor ID for conditions
755 AliFMDCalibZeroSuppression* fZeroSuppression; // Zero suppression from CDB
756 AliFMDCalibSampleRate* fSampleRate; // Sample rate from CDB
757 AliFMDCalibPedestal* fPedestal; // Pedestals
758 AliFMDCalibGain* fPulseGain; // Pulser gain
759 AliFMDCalibDeadMap* fDeadMap; // Pulser gain
760 AliFMDAltroMapping* fAltroMap; // Map of hardware
761 AliFMDCalibStripRange* fStripRange; // Strip range
763 ClassDef(AliFMDParameters,6) // Manager of parameters
766 //__________________________________________________________________
768 AliFMDParameters::SetStripRange(UShort_t min, UShort_t max)
770 // Set fixed strip range
771 fFixedMinStrip = min;
772 fFixedMaxStrip = max;
776 //____________________________________________________________________