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