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
99 static AliFMDParameters* Instance();
101 /** Initialize the manager. This tries to read the parameters from
102 CDB. If that fails, the class uses the hard-coded parameters.
104 void Init(Bool_t forceReInit=kFALSE,
105 UInt_t what = (kPulseGain|kPedestal|kDeadMap|kSampleRate|
106 kZeroSuppression|kAltroMap));
107 /** Initialize the manager. This tries to read the parameters from
108 CDB. If that fails, the class uses the hard-coded parameters.
110 void Init(AliFMDPreprocessor* pp,
111 Bool_t forceReInit=kFALSE,
112 UInt_t what = (kPulseGain|kPedestal|kDeadMap|kSampleRate|
113 kZeroSuppression|kAltroMap));
114 /** Print all parameters.
115 @param option Option string */
116 void Print(Option_t* option="A") const;
118 @param option What to draw. Should be one of
120 - threshold Threshold
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
130 void Draw(Option_t* option="pedestal");
133 /** @name Set various `Fixed' parameters */
134 /** @param r How many MIP signals we can fit in the VA1
135 pre-amps. (default and design is 20) */
136 void SetVA1MipRange(UShort_t r=20) { fVA1MipRange = r; }
137 /** @param s Maximum number of the ADC (ALTRO). This is a 10 bit
138 ADC so, the maximum number is 1024 */
139 void SetAltroChannelSize(UShort_t s=1024) { fAltroChannelSize = s;}
140 /** @param size The number of strips multiplexed into one ALTRO
141 channel. That is, how many strips is connected to one VA1
143 void SetChannelsPerAltro(UShort_t size=128) { fChannelsPerAltro = size; }
144 /** @param f Factor to use for accepting a signal. */
145 void SetPedestalFactor(Float_t f=3) { fPedestalFactor = f; }
149 /** @name Set various variable parameter defaults */
150 /** @param s Zero suppression threshold in ADC counts */
151 void SetZeroSuppression(UShort_t s=0) { fFixedZeroSuppression = s; }
152 /** @param r How many times we oversample each strip. */
153 void SetSampleRate(UShort_t r=1) { fFixedSampleRate = r ;}//(r>2?2:r);}
154 void SetSampleRate(AliFMDCalibSampleRate* r) { fSampleRate = r; }
155 /** @param p Pedestal value in ADC counts */
156 void SetPedestal(Float_t p=10) { fFixedPedestal = p; }
157 /** @param w Pedestal width in ADC counts */
158 void SetPedestalWidth(Float_t w=1) { fFixedPedestalWidth = w; }
159 /** @param t Threshold used for 1 MIP acceptance. */
160 void SetThreshold(Float_t t=0) { fFixedThreshold = t; }
161 /** Range of strips read out
162 @param min Minimum strip number (0-127).
163 @param max Maximum strip number (0-127). */
164 void SetStripRange(UShort_t min=0, UShort_t max=127);
165 /** Whether raw data is in the old ALTRO format (i.e., no RCU
166 trailer), or in the new format (with a trailer).
167 @param yes if true the raw data has RCU trailer */
168 void UseRcuTrailer(Bool_t yes=kTRUE) { fHasRcuTrailer = yes; }
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 Get variable parameters */
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; }
283 /** Translate hardware address to detector coordinates
284 @param ddl DDL number
285 @param board Board address
287 @param channel Channel #
288 @param det On return, Detector # (1-3)
289 @param ring On return, Ring ID ('I' or 'O')
290 @param sec On return, Sector number (0-39)
291 @param str On return, Strip number (0-511)
292 @return @c true on success. */
293 Bool_t Hardware2Detector(UInt_t ddl, UInt_t board,
294 UInt_t chip, UInt_t channel,
295 UShort_t& det, Char_t& ring,
296 UShort_t& sec, UShort_t& str) const;
297 /** Translate hardware address to detector coordinates
298 @param ddl DDL number
299 @param addr Hardware address
300 @param det On return, Detector # (1-3)
301 @param ring On return, Ring ID ('I' or 'O')
302 @param sec On return, Sector number (0-39)
303 @param str On return, Strip number (0-511)
304 @return @c true on success. */
305 Bool_t Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
306 Char_t& ring, UShort_t& sec, UShort_t& str) const;
308 /** Translate detector coordinates to hardware address
309 @param det Detector # (1-3)
310 @param ring Ring ID ('I' or 'O')
311 @param sec Sector number (0-39)
312 @param str Strip number (0-511)
313 @param ddl On return, DDL number
314 @param board On return, Board address
315 @param chip On return, Chip #
316 @param channel On return, Channel #
317 @return @c true on success. */
318 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
319 UShort_t sec, UShort_t str,
320 UInt_t& ddl, UInt_t& board,
321 UInt_t& chip, UInt_t& channel) const;
322 /** Translate detector coordinates to hardware address
323 @param det Detector # (1-3)
324 @param ring Ring ID ('I' or 'O')
325 @param sec Sector number (0-39)
326 @param str Strip number (0-511)
327 @param ddl On return, DDL number
328 @param addr On return, Hardware address
329 @return @c true on success. */
330 Bool_t Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
331 UShort_t str, UInt_t& ddl, UInt_t& addr) const;
332 /** Get the map that translates hardware to detector coordinates
333 @return Get the map that translates hardware to detector
335 AliFMDAltroMapping* GetAltroMap() const;
336 /** Whether raw data is in the old ALTRO format (i.e., no RCU
337 trailer), or in the new format (with a trailer).
338 @return false if the raw data has no RCU trailer */
339 Bool_t HasRcuTrailer() const { return fHasRcuTrailer; }
340 /** Whether raw data has full common data header (8 32bit words) or
341 the older invalid format (7 32bit words with bogus entries)
342 @return false if the raw data has incomplete data header */
343 Bool_t HasCompleteHeader() const { return fHasCompleteHeader; }
347 static const char* PulseGainPath() { return fgkPulseGain; }
348 static const char* PedestalPath() { return fgkPedestal; }
349 static const char* DeadPath() { return fgkDead; }
350 static const char* SampleRatePath() { return fgkSampleRate; }
351 static const char* AltroMapPath() { return fgkAltroMap; }
352 static const char* ZeroSuppressionPath() { return fgkZeroSuppression; }
353 static const char* StripRangePath() { return fgkStripRange; }
354 static const char* GetPedestalShuttleID() {return fkPedestalShuttleID;}
355 static const char* GetGainShuttleID() {return fkGainShuttleID;}
356 static const char* GetConditionsShuttleID() {return fkConditionsShuttleID;}
361 AliFMDParameters(const AliFMDParameters& o)
364 fkSiDeDxMip(o.fkSiDeDxMip),
365 fVA1MipRange(o.fVA1MipRange),
366 fAltroChannelSize(o.fAltroChannelSize),
367 fChannelsPerAltro(o.fChannelsPerAltro),
368 fPedestalFactor(o.fPedestalFactor),
369 fFixedPedestal(o.fFixedPedestal),
370 fFixedPedestalWidth(o.fFixedPedestalWidth),
371 fFixedZeroSuppression(o.fFixedZeroSuppression),
372 fFixedSampleRate(o.fFixedSampleRate),
373 fFixedThreshold(o.fFixedThreshold),
374 fFixedMinStrip(o.fFixedMinStrip),
375 fFixedMaxStrip(o.fFixedMaxStrip),
376 fFixedPulseGain(o.fFixedPulseGain),
377 fEdepMip(o.fEdepMip),
378 fHasRcuTrailer(o.fHasRcuTrailer),
379 fHasCompleteHeader(o.fHasCompleteHeader),
380 fZeroSuppression(o.fZeroSuppression),
381 fSampleRate(o.fSampleRate),
382 fPedestal(o.fPedestal),
383 fPulseGain(o.fPulseGain),
384 fDeadMap(o.fDeadMap),
385 fAltroMap(o.fAltroMap),
386 fStripRange(o.fStripRange)
388 /** Assignement operator
389 @return Reference to this */
390 AliFMDParameters& operator=(const AliFMDParameters&) { return *this; }
392 virtual ~AliFMDParameters() {}
393 /** Singleton instance */
394 static AliFMDParameters* fgInstance; // Static singleton instance
395 /** Get an entry from either global AliCDBManager or passed
397 @param path Path to CDB object.
398 @param pp AliFMDPreprocessor
399 @param fatal If true, raise a fatal flag if we didn't get the entry.
400 @return AliCDBEntry if found */
401 AliCDBEntry* GetEntry(const char* path, AliFMDPreprocessor* pp,
402 Bool_t fatal=kTRUE) const;
403 /** Initialize gains. Try to get them from CDB */
404 void InitPulseGain(AliFMDPreprocessor* pp=0);
405 /** Initialize pedestals. Try to get them from CDB */
406 void InitPedestal(AliFMDPreprocessor* pp=0);
407 /** Initialize dead map. Try to get it from CDB */
408 void InitDeadMap(AliFMDPreprocessor* pp=0);
409 /** Initialize sample rates. Try to get them from CDB */
410 void InitSampleRate(AliFMDPreprocessor* pp=0);
411 /** Initialize zero suppression thresholds. Try to get them from CDB */
412 void InitZeroSuppression(AliFMDPreprocessor* pp=0);
413 /** Initialize hardware map. Try to get it from CDB */
414 void InitAltroMap(AliFMDPreprocessor* pp=0);
415 /** Initialize strip range. Try to get it from CDB */
416 void InitStripRange(AliFMDPreprocessor* pp=0);
418 Bool_t fIsInit; // Whether we've been initialised
420 static const char* fgkPulseGain; // Path to PulseGain calib object
421 static const char* fgkPedestal; // Path to Pedestal calib object
422 static const char* fgkDead; // Path to Dead calib object
423 static const char* fgkSampleRate; // Path to SampleRate calib object
424 static const char* fgkAltroMap; // Path to AltroMap calib object
425 static const char* fgkZeroSuppression; // Path to ZeroSuppression cal object
426 static const char* fgkStripRange; // Path to strip range cal object
427 const Float_t fkSiDeDxMip; // MIP dE/dx in Silicon
428 UShort_t fVA1MipRange; // # MIPs the pre-amp can do
429 UShort_t fAltroChannelSize; // Largest # to store in 1 ADC ch.
430 UShort_t fChannelsPerAltro; // Number of pre-amp. chan/adc chan.
431 Float_t fPedestalFactor; // Number of pedestal widths
433 Float_t fFixedPedestal; // Pedestal to subtract
434 Float_t fFixedPedestalWidth; // Width of pedestal
435 UShort_t fFixedZeroSuppression; // Threshold for zero-suppression
436 UShort_t fFixedSampleRate; // Times the ALTRO samples pre-amp.
437 Float_t fFixedThreshold; // Threshold in ADC counts
438 UShort_t fFixedMinStrip; // Minimum strip read-out
439 UShort_t fFixedMaxStrip; // Maximum strip read-out
440 mutable Float_t fFixedPulseGain; //! Gain (cached)
441 mutable Float_t fEdepMip; //! Cache of energy loss for a MIP
442 Bool_t fHasRcuTrailer; // if the raw data has RCU trailer
443 Bool_t fHasCompleteHeader; // raw data has incomplete data header
445 static const char* fkPedestalShuttleID; // Shuttle/preprocessor ID for pedestals
446 static const char* fkGainShuttleID; // Shuttle/preprocessor ID for gains
447 static const char* fkConditionsShuttleID; // Shuttle/preprocessor ID for conditions
449 AliFMDCalibZeroSuppression* fZeroSuppression; // Zero suppression from CDB
450 AliFMDCalibSampleRate* fSampleRate; // Sample rate from CDB
451 AliFMDCalibPedestal* fPedestal; // Pedestals
452 AliFMDCalibGain* fPulseGain; // Pulser gain
453 AliFMDCalibDeadMap* fDeadMap; // Pulser gain
454 AliFMDAltroMapping* fAltroMap; // Map of hardware
455 AliFMDCalibStripRange* fStripRange; // Strip range
457 ClassDef(AliFMDParameters,5) // Manager of parameters
461 //____________________________________________________________________