]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDParameters.h
- Set of changes needed for merging aod files in CAF. Some fixes also for event mixing.
[u/mrichter/AliRoot.git] / FMD / AliFMDParameters.h
CommitLineData
1a1fdef7 1#ifndef ALIFMDPARAMETERS_H
2#define ALIFMDPARAMETERS_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
4 * reserved.
5 *
6 * Latest changes by Christian Holm Christensen <cholm@nbi.dk>
7 *
8 * See cxx source for full Copyright notice
9 */
1a1fdef7 10//____________________________________________________________________
11//
12// Singleton class to handle various parameters (not geometry) of the
13// FMD
088f8e79 14// Should get ata fromm Conditions DB.
1a1fdef7 15//
02a27b50 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
20*/
1a1fdef7 21#ifndef ROOT_TNamed
22# include <TNamed.h>
23#endif
8f6ee336 24#ifndef ROOT_TArrayI
25# include <TArrayI.h>
26#endif
27#ifndef ALIFMDUSHORTMAP_H
28# include <AliFMDUShortMap.h>
29#endif
30#ifndef ALIFMDBOOLMAP_H
31# include <AliFMDBoolMap.h>
32#endif
33typedef AliFMDUShortMap AliFMDCalibZeroSuppression;
34typedef AliFMDBoolMap AliFMDCalibDeadMap;
35class AliFMDCalibPedestal;
36class AliFMDCalibGain;
37class AliFMDCalibSampleRate;
c2fc1258 38class AliFMDCalibStripRange;
57c3c593 39class AliFMDAltroMapping;
dc02d468 40class AliCDBEntry;
41class AliFMDPreprocessor;
42
02a27b50 43//____________________________________________________________________
44//
45// Singleton class to handle various parameters (not geometry) of the
46// FMD
47// Should get ata fromm Conditions DB.
48//
1a1fdef7 49
c2fc1258 50/** @brief This class is a singleton that handles various parameters
51 of the FMD detectors.
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.
9f662337 55
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).
61 - @c fVA1MipRange
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.
66 - @c fSampleRate
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
74 the code.
75
76 @ingroup FMD_base
77*/
1a1fdef7 78class AliFMDParameters : public TNamed
79{
80public:
f6449cc0 81 /** Enumeration of things to initialize */
82 enum What {
83 /** Pulser gain */
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
93 /** ALTRO data map */
94 kAltroMap = 0x20 // Altro channel map
95 };
96
9f662337 97 /** Singleton access
98 @return single to */
1a1fdef7 99 static AliFMDParameters* Instance();
57c3c593 100
9f662337 101 /** Initialize the manager. This tries to read the parameters from
102 CDB. If that fails, the class uses the hard-coded parameters.
103 */
f6449cc0 104 void Init(Bool_t forceReInit=kFALSE,
105 UInt_t what = (kPulseGain|kPedestal|kDeadMap|kSampleRate|
106 kZeroSuppression|kAltroMap));
dc02d468 107 /** Initialize the manager. This tries to read the parameters from
108 CDB. If that fails, the class uses the hard-coded parameters.
109 */
110 void Init(AliFMDPreprocessor* pp,
111 Bool_t forceReInit=kFALSE,
112 UInt_t what = (kPulseGain|kPedestal|kDeadMap|kSampleRate|
113 kZeroSuppression|kAltroMap));
c2fc1258 114 /** Print all parameters.
115 @param option Option string */
116 void Print(Option_t* option="A") const;
6169f936 117 /** Draw parameters.
118 @param option What to draw. Should be one of
119 - dead Dead channels
120 - threshold Threshold
121 - gain Gain
122 - pedestal Pedestal
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
129 */
130 void Draw(Option_t* option="pedestal");
1a1fdef7 131
9f662337 132 /** @{ */
133 /** @name Set various `Fixed' parameters */
c2fc1258 134 /** @param r How many MIP signals we can fit in the VA1
135 pre-amps. (default and design is 20) */
8f6ee336 136 void SetVA1MipRange(UShort_t r=20) { fVA1MipRange = r; }
c2fc1258 137 /** @param s Maximum number of the ADC (ALTRO). This is a 10 bit
138 ADC so, the maximum number is 1024 */
8f6ee336 139 void SetAltroChannelSize(UShort_t s=1024) { fAltroChannelSize = s;}
c2fc1258 140 /** @param size The number of strips multiplexed into one ALTRO
141 channel. That is, how many strips is connected to one VA1
142 pre-amp. */
8f6ee336 143 void SetChannelsPerAltro(UShort_t size=128) { fChannelsPerAltro = size; }
c2fc1258 144 /** @param f Factor to use for accepting a signal. */
8f6ee336 145 void SetPedestalFactor(Float_t f=3) { fPedestalFactor = f; }
9f662337 146 /** @} */
8f6ee336 147
9f662337 148 /** @{ */
149 /** @name Set various variable parameter defaults */
c2fc1258 150 /** @param s Zero suppression threshold in ADC counts */
8f6ee336 151 void SetZeroSuppression(UShort_t s=0) { fFixedZeroSuppression = s; }
c2fc1258 152 /** @param r How many times we oversample each strip. */
f743c846 153 void SetSampleRate(UShort_t r=1) { fFixedSampleRate = r ;}//(r>2?2:r);}
6acbd49f 154 void SetSampleRate(AliFMDCalibSampleRate* r) { fSampleRate = r; }
c2fc1258 155 /** @param p Pedestal value in ADC counts */
8f6ee336 156 void SetPedestal(Float_t p=10) { fFixedPedestal = p; }
c2fc1258 157 /** @param w Pedestal width in ADC counts */
8f6ee336 158 void SetPedestalWidth(Float_t w=1) { fFixedPedestalWidth = w; }
c2fc1258 159 /** @param t Threshold used for 1 MIP acceptance. */
8f6ee336 160 void SetThreshold(Float_t t=0) { fFixedThreshold = t; }
c2fc1258 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);
625d7886 165 /** Whether raw data has full common data header (8 32bit words) or
166 the older invalid format (7 32bit words with bogus entries)
167 @param yes if true the raw data has complete data header */
168 void UseCompleteHeader(Bool_t yes=kTRUE) { fHasCompleteHeader = yes; }
9f662337 169 /** @} */
1a1fdef7 170
9f662337 171 /** @{ */
172 /** @name Get `Fixed' various parameters */
c2fc1258 173 /** @return Number of MIP signals that fit inside a VA1 channel */
1a1fdef7 174 UShort_t GetVA1MipRange() const { return fVA1MipRange; }
c2fc1258 175 /** @return The maximum count in the ADC */
1a1fdef7 176 UShort_t GetAltroChannelSize() const { return fAltroChannelSize; }
c2fc1258 177 /** @return Number of strips muliplexed into one ADC channel */
1a1fdef7 178 UShort_t GetChannelsPerAltro() const { return fChannelsPerAltro; }
c2fc1258 179 /** @return The average energy deposited by one MIP */
1a1fdef7 180 Float_t GetEdepMip() const;
c2fc1258 181 /** @return The factor used of signal acceptance */
1a1fdef7 182 Float_t GetPedestalFactor() const { return fPedestalFactor; }
9f662337 183 /** @} */
1a1fdef7 184
9f662337 185 /** @{ */
186 /** @name Get variable parameters */
c2fc1258 187 /** Whether the strip is considered dead
188 @param detector Detector # (1-3)
189 @param ring Ring ID ('I' or 'O')
190 @param sector Sector number (0-39)
191 @param strip Strip number (0-511)
192 @return @c true if the strip is considered dead, @c false if
193 it's OK. */
8f6ee336 194 Bool_t IsDead(UShort_t detector,
195 Char_t ring,
196 UShort_t sector,
197 UShort_t strip) const;
198 Float_t GetThreshold() const;
c2fc1258 199 /** Gain of pre-amp.
200 @param detector Detector # (1-3)
201 @param ring Ring ID ('I' or 'O')
202 @param sector Sector number (0-39)
203 @param strip Strip number (0-511)
204 @return Gain of pre-amp. */
8f6ee336 205 Float_t GetPulseGain(UShort_t detector,
206 Char_t ring,
207 UShort_t sector,
208 UShort_t strip) const;
c2fc1258 209 /** Get mean of pedestal
210 @param detector Detector # (1-3)
211 @param ring Ring ID ('I' or 'O')
212 @param sector Sector number (0-39)
213 @param strip Strip number (0-511)
214 @return Mean of pedestal */
8f6ee336 215 Float_t GetPedestal(UShort_t detector,
216 Char_t ring,
217 UShort_t sector,
218 UShort_t strip) const;
c2fc1258 219 /** Width of pedestal
220 @param detector Detector # (1-3)
221 @param ring Ring ID ('I' or 'O')
222 @param sector Sector number (0-39)
223 @param strip Strip number (0-511)
224 @return Width of pedestal */
8f6ee336 225 Float_t GetPedestalWidth(UShort_t detector,
226 Char_t ring,
227 UShort_t sector,
228 UShort_t strip) const;
c2fc1258 229 /** zero suppression threshold (in ADC counts)
230 @param detector Detector # (1-3)
231 @param ring Ring ID ('I' or 'O')
232 @param sector Sector number (0-39)
233 @param strip Strip number (0-511)
234 @return zero suppression threshold (in ADC counts) */
8f6ee336 235 UShort_t GetZeroSuppression(UShort_t detector,
236 Char_t ring,
237 UShort_t sector,
238 UShort_t strip) const;
c2fc1258 239 /** Get the sampling rate
240 @param detector Detector # (1-3)
241 @param ring Ring ID ('I' or 'O')
242 @param sector Sector number (0-39)
243 @param strip Strip number (0-511)
244 @return The sampling rate */
245 UShort_t GetSampleRate(UShort_t detector,
246 Char_t ring,
247 UShort_t sector,
248 UShort_t strip) const;
249 /** Get the minimum strip in the read-out range
250 @param detector Detector # (1-3)
251 @param ring Ring ID ('I' or 'O')
252 @param sector Sector number (0-39)
253 @param strip Strip number (0-511)
254 @return Minimum strip */
255 UShort_t GetMinStrip(UShort_t detector,
256 Char_t ring,
257 UShort_t sector,
258 UShort_t strip) const;
259 /** Get the maximum strip in the read-out range
260 @param detector Detector # (1-3)
261 @param ring Ring ID ('I' or 'O')
262 @param sector Sector number (0-39)
263 @param strip Strip number (0-511)
264 @return Maximum strip */
265 UShort_t GetMaxStrip(UShort_t detector,
266 Char_t ring,
267 UShort_t sector,
268 UShort_t strip) const;
625d7886 269 /** Get the number of pre-samples in ALTRO channels
270 @param detector Detector # (1-3)
271 @param ring Ring ID ('I' or 'O')
272 @param sector Sector number (0-39)
273 @param strip Strip number (0-511)
274 @return Maximum strip */
275 UShort_t GetPreSamples(UShort_t,
276 Char_t,
277 UShort_t,
278 UShort_t) const { return 14+5; }
f6449cc0 279 /** Translate hardware address to detector coordinates
280 @param ddl DDL number
281 @param board Board address
282 @param chip Chip #
283 @param channel Channel #
284 @param det On return, Detector # (1-3)
285 @param ring On return, Ring ID ('I' or 'O')
286 @param sec On return, Sector number (0-39)
287 @param str On return, Strip number (0-511)
288 @return @c true on success. */
289 Bool_t Hardware2Detector(UInt_t ddl, UInt_t board,
290 UInt_t chip, UInt_t channel,
291 UShort_t& det, Char_t& ring,
292 UShort_t& sec, UShort_t& str) const;
c2fc1258 293 /** Translate hardware address to detector coordinates
294 @param ddl DDL number
295 @param addr Hardware address
296 @param det On return, Detector # (1-3)
297 @param ring On return, Ring ID ('I' or 'O')
298 @param sec On return, Sector number (0-39)
299 @param str On return, Strip number (0-511)
300 @return @c true on success. */
bf000c32 301 Bool_t Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
302 Char_t& ring, UShort_t& sec, UShort_t& str) const;
f6449cc0 303
304 /** Translate detector coordinates to hardware address
305 @param det Detector # (1-3)
306 @param ring Ring ID ('I' or 'O')
307 @param sec Sector number (0-39)
308 @param str Strip number (0-511)
309 @param ddl On return, DDL number
310 @param board On return, Board address
311 @param chip On return, Chip #
312 @param channel On return, Channel #
313 @return @c true on success. */
314 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
315 UShort_t sec, UShort_t str,
316 UInt_t& ddl, UInt_t& board,
317 UInt_t& chip, UInt_t& channel) const;
c2fc1258 318 /** Translate detector coordinates to hardware address
319 @param det Detector # (1-3)
320 @param ring Ring ID ('I' or 'O')
321 @param sec Sector number (0-39)
322 @param str Strip number (0-511)
323 @param ddl On return, DDL number
324 @param addr On return, Hardware address
325 @return @c true on success. */
bf000c32 326 Bool_t Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
327 UShort_t str, UInt_t& ddl, UInt_t& addr) const;
c2fc1258 328 /** Get the map that translates hardware to detector coordinates
329 @return Get the map that translates hardware to detector
330 coordinates */
57c3c593 331 AliFMDAltroMapping* GetAltroMap() const;
625d7886 332 /** Whether raw data has full common data header (8 32bit words) or
333 the older invalid format (7 32bit words with bogus entries)
334 @return false if the raw data has incomplete data header */
335 Bool_t HasCompleteHeader() const { return fHasCompleteHeader; }
336
9f662337 337 /** @} */
338
02a27b50 339 static const char* PulseGainPath() { return fgkPulseGain; }
340 static const char* PedestalPath() { return fgkPedestal; }
341 static const char* DeadPath() { return fgkDead; }
342 static const char* SampleRatePath() { return fgkSampleRate; }
343 static const char* AltroMapPath() { return fgkAltroMap; }
344 static const char* ZeroSuppressionPath() { return fgkZeroSuppression; }
345 static const char* StripRangePath() { return fgkStripRange; }
6cd5cd4d 346 static const char* GetPedestalShuttleID() {return fkPedestalShuttleID;}
347 static const char* GetGainShuttleID() {return fkGainShuttleID;}
348 static const char* GetConditionsShuttleID() {return fkConditionsShuttleID;}
497e0e62 349protected:
9f662337 350 /** CTOR */
497e0e62 351 AliFMDParameters();
02a27b50 352 /** CTOR */
353 AliFMDParameters(const AliFMDParameters& o)
b5ee4425 354 : TNamed(o),
355 fIsInit(o.fIsInit),
356 fkSiDeDxMip(o.fkSiDeDxMip),
357 fVA1MipRange(o.fVA1MipRange),
358 fAltroChannelSize(o.fAltroChannelSize),
359 fChannelsPerAltro(o.fChannelsPerAltro),
360 fPedestalFactor(o.fPedestalFactor),
361 fFixedPedestal(o.fFixedPedestal),
362 fFixedPedestalWidth(o.fFixedPedestalWidth),
363 fFixedZeroSuppression(o.fFixedZeroSuppression),
364 fFixedSampleRate(o.fFixedSampleRate),
365 fFixedThreshold(o.fFixedThreshold),
366 fFixedMinStrip(o.fFixedMinStrip),
367 fFixedMaxStrip(o.fFixedMaxStrip),
368 fFixedPulseGain(o.fFixedPulseGain),
369 fEdepMip(o.fEdepMip),
625d7886 370 fHasCompleteHeader(o.fHasCompleteHeader),
b5ee4425 371 fZeroSuppression(o.fZeroSuppression),
372 fSampleRate(o.fSampleRate),
373 fPedestal(o.fPedestal),
374 fPulseGain(o.fPulseGain),
375 fDeadMap(o.fDeadMap),
376 fAltroMap(o.fAltroMap),
377 fStripRange(o.fStripRange)
378 {}
02a27b50 379 /** Assignement operator
380 @return Reference to this */
381 AliFMDParameters& operator=(const AliFMDParameters&) { return *this; }
9f662337 382 /** DTOR */
497e0e62 383 virtual ~AliFMDParameters() {}
9f662337 384 /** Singleton instance */
497e0e62 385 static AliFMDParameters* fgInstance; // Static singleton instance
dc02d468 386 /** Get an entry from either global AliCDBManager or passed
387 AliFMDPreprocessor.
388 @param path Path to CDB object.
389 @param pp AliFMDPreprocessor
390 @param fatal If true, raise a fatal flag if we didn't get the entry.
391 @return AliCDBEntry if found */
392 AliCDBEntry* GetEntry(const char* path, AliFMDPreprocessor* pp,
393 Bool_t fatal=kTRUE) const;
9f662337 394 /** Initialize gains. Try to get them from CDB */
dc02d468 395 void InitPulseGain(AliFMDPreprocessor* pp=0);
9f662337 396 /** Initialize pedestals. Try to get them from CDB */
dc02d468 397 void InitPedestal(AliFMDPreprocessor* pp=0);
9f662337 398 /** Initialize dead map. Try to get it from CDB */
dc02d468 399 void InitDeadMap(AliFMDPreprocessor* pp=0);
9f662337 400 /** Initialize sample rates. Try to get them from CDB */
dc02d468 401 void InitSampleRate(AliFMDPreprocessor* pp=0);
9f662337 402 /** Initialize zero suppression thresholds. Try to get them from CDB */
dc02d468 403 void InitZeroSuppression(AliFMDPreprocessor* pp=0);
9f662337 404 /** Initialize hardware map. Try to get it from CDB */
dc02d468 405 void InitAltroMap(AliFMDPreprocessor* pp=0);
c2fc1258 406 /** Initialize strip range. Try to get it from CDB */
dc02d468 407 void InitStripRange(AliFMDPreprocessor* pp=0);
57c3c593 408
6cd5cd4d 409 Bool_t fIsInit; // Whether we've been initialised
57c3c593 410
6cd5cd4d 411 static const char* fgkPulseGain; // Path to PulseGain calib object
412 static const char* fgkPedestal; // Path to Pedestal calib object
413 static const char* fgkDead; // Path to Dead calib object
414 static const char* fgkSampleRate; // Path to SampleRate calib object
415 static const char* fgkAltroMap; // Path to AltroMap calib object
416 static const char* fgkZeroSuppression; // Path to ZeroSuppression cal object
417 static const char* fgkStripRange; // Path to strip range cal object
418 const Float_t fkSiDeDxMip; // MIP dE/dx in Silicon
419 UShort_t fVA1MipRange; // # MIPs the pre-amp can do
420 UShort_t fAltroChannelSize; // Largest # to store in 1 ADC ch.
421 UShort_t fChannelsPerAltro; // Number of pre-amp. chan/adc chan.
422 Float_t fPedestalFactor; // Number of pedestal widths
1a1fdef7 423
6cd5cd4d 424 Float_t fFixedPedestal; // Pedestal to subtract
425 Float_t fFixedPedestalWidth; // Width of pedestal
426 UShort_t fFixedZeroSuppression; // Threshold for zero-suppression
427 UShort_t fFixedSampleRate; // Times the ALTRO samples pre-amp.
428 Float_t fFixedThreshold; // Threshold in ADC counts
429 UShort_t fFixedMinStrip; // Minimum strip read-out
430 UShort_t fFixedMaxStrip; // Maximum strip read-out
431 mutable Float_t fFixedPulseGain; //! Gain (cached)
432 mutable Float_t fEdepMip; //! Cache of energy loss for a MIP
6cd5cd4d 433 Bool_t fHasCompleteHeader; // raw data has incomplete data header
434
435 static const char* fkPedestalShuttleID; // Shuttle/preprocessor ID for pedestals
436 static const char* fkGainShuttleID; // Shuttle/preprocessor ID for gains
437 static const char* fkConditionsShuttleID; // Shuttle/preprocessor ID for conditions
8f6ee336 438
439 AliFMDCalibZeroSuppression* fZeroSuppression; // Zero suppression from CDB
440 AliFMDCalibSampleRate* fSampleRate; // Sample rate from CDB
441 AliFMDCalibPedestal* fPedestal; // Pedestals
442 AliFMDCalibGain* fPulseGain; // Pulser gain
443 AliFMDCalibDeadMap* fDeadMap; // Pulser gain
57c3c593 444 AliFMDAltroMapping* fAltroMap; // Map of hardware
c2fc1258 445 AliFMDCalibStripRange* fStripRange; // Strip range
8f6ee336 446
9a090ccd 447 ClassDef(AliFMDParameters,6) // Manager of parameters
1a1fdef7 448};
449
450#endif
451//____________________________________________________________________
452//
453// Local Variables:
454// mode: C++
455// End:
456//
457// EOF
458//
459