]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDParameters.h
Added documentation of each file.
[u/mrichter/AliRoot.git] / FMD / AliFMDParameters.h
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  */
10 /** @file    AliFMDParameters.h
11     @author  Christian Holm Christensen <cholm@nbi.dk>
12     @date    Mon Mar 27 12:44:43 2006
13     @brief   Manager of FMD parameters
14 */
15 //____________________________________________________________________
16 //
17 //  Singleton class to handle various parameters (not geometry) of the
18 //  FMD
19 //  Should get ata fromm Conditions DB.
20 //
21 #ifndef ROOT_TNamed
22 # include <TNamed.h>
23 #endif
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
33 typedef AliFMDUShortMap AliFMDCalibZeroSuppression;
34 typedef AliFMDBoolMap   AliFMDCalibDeadMap;
35 class AliFMDCalibPedestal;
36 class AliFMDCalibGain;
37 class AliFMDCalibSampleRate;
38 class AliFMDCalibStripRange;
39 class AliFMDAltroMapping;
40
41 /** @brief This class is a singleton that handles various parameters
42     of the FMD detectors.  
43     This class reads from the Conditions DB to get the various
44     parameters, which code can then request from here. In that way,
45     all code uses the same data, and the interface is consistent.
46      
47     Some of the parameter managed are 
48     - @c fPedestal, @c fPedestalWidth
49       Mean and width of the pedestal.  The pedestal is simulated
50       by a Guassian, but derived classes my override MakePedestal
51       to simulate it differently (or pick it up from a database).
52     - @c fVA1MipRange
53       The dymamic MIP range of the VA1_ALICE pre-amplifier chip 
54     - @c fAltroChannelSize
55       The largest number plus one that can be stored in one
56       channel in one time step in the ALTRO ADC chip. 
57     - @c fSampleRate
58       How many times the ALTRO ADC chip samples the VA1_ALICE
59       pre-amplifier signal.   The VA1_ALICE chip is read-out at
60       10MHz, while it's possible to drive the ALTRO chip at
61       25MHz.  That means, that the ALTRO chip can have time to
62       sample each VA1_ALICE signal up to 2 times.  Although it's
63       not certain this feature will be used in the production,
64       we'd like have the option, and so it should be reflected in
65       the code.
66
67     @ingroup FMD_base
68 */
69 class AliFMDParameters : public TNamed
70 {
71 public:
72   /** Singleton access
73       @return  single to */
74   static AliFMDParameters* Instance();
75
76   /** Initialize the manager.  This tries to read the parameters from
77       CDB.  If that fails, the class uses the hard-coded parameters. 
78    */
79   void Init();
80   /** Print all parameters. 
81       @param option Option string */
82   void Print(Option_t* option="A") const;
83   
84   /** @{ */
85   /** @name Set various `Fixed' parameters */
86   /** @param r How many MIP signals we can fit in the VA1
87       pre-amps. (default and design is 20) */
88   void SetVA1MipRange(UShort_t r=20)          { fVA1MipRange = r; }
89   /** @param s Maximum number of the ADC (ALTRO).  This is a 10 bit
90       ADC so, the maximum number is 1024 */
91   void SetAltroChannelSize(UShort_t s=1024)   { fAltroChannelSize = s;}
92   /** @param size The number of strips multiplexed into one ALTRO
93       channel. That is, how many strips is connected to one VA1
94       pre-amp. */
95   void SetChannelsPerAltro(UShort_t size=128) { fChannelsPerAltro = size; }
96   /** @param f Factor to use for accepting a signal. */
97   void SetPedestalFactor(Float_t f=3)         { fPedestalFactor = f; }
98   /** @} */
99
100   /** @{ */
101   /** @name Set various variable parameter defaults */
102   /** @param s Zero suppression threshold in ADC counts */
103   void SetZeroSuppression(UShort_t s=0)       { fFixedZeroSuppression = s; }
104   /** @param r How many times we oversample each strip. */
105   void SetSampleRate(UShort_t r=1)            { fFixedSampleRate = (r>2?2:r);}
106   /** @param p Pedestal value in ADC counts */
107   void SetPedestal(Float_t p=10)              { fFixedPedestal = p; }
108   /** @param w Pedestal width in ADC counts */
109   void SetPedestalWidth(Float_t w=1)          { fFixedPedestalWidth = w; }
110   /** @param t Threshold used for 1 MIP acceptance. */
111   void SetThreshold(Float_t t=0)              { fFixedThreshold = t; }
112   /** Range of strips read out 
113       @param min Minimum strip number (0-127). 
114       @param max Maximum strip number (0-127). */
115   void SetStripRange(UShort_t min=0, UShort_t max=127);
116   /** @} */
117
118   /** @{ */
119   /** @name Get `Fixed' various parameters */
120   /** @return Number of MIP signals that fit inside a VA1 channel  */
121   UShort_t GetVA1MipRange()          const { return fVA1MipRange; }
122   /** @return The maximum count in the ADC */
123   UShort_t GetAltroChannelSize()     const { return fAltroChannelSize; }
124   /** @return Number of strips muliplexed into one ADC channel */
125   UShort_t GetChannelsPerAltro()     const { return fChannelsPerAltro; }
126   /** @return The average energy deposited by one MIP */
127   Float_t  GetEdepMip()              const;
128   /** @return The factor used of signal acceptance */
129   Float_t  GetPedestalFactor()       const { return fPedestalFactor; }
130   /** @} */
131
132   /** @{ */
133   /** @name Get variable parameters */
134   /** Whether the strip is considered dead
135       @param detector Detector # (1-3)
136       @param ring     Ring ID ('I' or 'O')
137       @param sector   Sector number (0-39)
138       @param strip    Strip number (0-511)
139       @return @c true if the strip is considered dead, @c false if
140       it's OK. */
141   Bool_t   IsDead(UShort_t detector, 
142                   Char_t ring, 
143                   UShort_t sector, 
144                   UShort_t strip) const;
145   Float_t  GetThreshold() const;
146   /** Gain of pre-amp. 
147       @param detector Detector # (1-3)
148       @param ring     Ring ID ('I' or 'O')
149       @param sector   Sector number (0-39)
150       @param strip    Strip number (0-511)
151       @return Gain of pre-amp.  */
152   Float_t  GetPulseGain(UShort_t detector, 
153                         Char_t ring, 
154                         UShort_t sector, 
155                         UShort_t strip) const;
156   /** Get mean of pedestal
157       @param detector Detector # (1-3)
158       @param ring     Ring ID ('I' or 'O')
159       @param sector   Sector number (0-39)
160       @param strip    Strip number (0-511)
161       @return Mean of pedestal */
162   Float_t  GetPedestal(UShort_t detector, 
163                        Char_t ring, 
164                        UShort_t sector, 
165                        UShort_t strip) const;
166   /** Width of pedestal
167       @param detector Detector # (1-3)
168       @param ring     Ring ID ('I' or 'O')
169       @param sector   Sector number (0-39)
170       @param strip    Strip number (0-511)
171       @return Width of pedestal */
172   Float_t  GetPedestalWidth(UShort_t detector, 
173                             Char_t ring, 
174                             UShort_t sector, 
175                             UShort_t strip) const;
176   /** zero suppression threshold (in ADC counts)
177       @param detector Detector # (1-3)
178       @param ring     Ring ID ('I' or 'O')
179       @param sector   Sector number (0-39)
180       @param strip    Strip number (0-511)
181       @return zero suppression threshold (in ADC counts) */
182   UShort_t GetZeroSuppression(UShort_t detector, 
183                               Char_t ring, 
184                               UShort_t sector, 
185                               UShort_t strip) const;
186   /** Get the sampling rate
187       @param detector Detector # (1-3)
188       @param ring     Ring ID ('I' or 'O')
189       @param sector   Sector number (0-39)
190       @param strip    Strip number (0-511)
191       @return The sampling rate */
192   UShort_t GetSampleRate(UShort_t detector, 
193                          Char_t ring, 
194                          UShort_t sector, 
195                          UShort_t strip) const;
196   /** Get the minimum strip in the read-out range
197       @param detector Detector # (1-3)
198       @param ring     Ring ID ('I' or 'O')
199       @param sector   Sector number (0-39)
200       @param strip    Strip number (0-511)
201       @return Minimum strip */
202   UShort_t GetMinStrip(UShort_t detector, 
203                        Char_t ring, 
204                        UShort_t sector, 
205                        UShort_t strip) const;
206   /** Get the maximum strip in the read-out range
207       @param detector Detector # (1-3)
208       @param ring     Ring ID ('I' or 'O')
209       @param sector   Sector number (0-39)
210       @param strip    Strip number (0-511)
211       @return Maximum strip */
212   UShort_t GetMaxStrip(UShort_t detector, 
213                        Char_t ring, 
214                        UShort_t sector, 
215                        UShort_t strip) const;
216   /** Translate hardware address to detector coordinates 
217       @param ddl      DDL number 
218       @param addr     Hardware address
219       @param det      On return, Detector # (1-3)
220       @param ring     On return, Ring ID ('I' or 'O')
221       @param sec      On return, Sector number (0-39)
222       @param str      On return, Strip number (0-511)
223       @return @c true on success. */
224   Bool_t   Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
225                              Char_t& ring, UShort_t& sec, UShort_t& str) const;
226   /** Translate detector coordinates to hardware address 
227       @param det      Detector # (1-3)
228       @param ring     Ring ID ('I' or 'O')
229       @param sec      Sector number (0-39)
230       @param str      Strip number (0-511)
231       @param ddl      On return, DDL number 
232       @param addr     On return, Hardware address
233       @return @c true on success. */
234   Bool_t   Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec, 
235                              UShort_t str, UInt_t& ddl, UInt_t& addr) const;
236   /** Get the map that translates hardware to detector coordinates 
237       @return Get the map that translates hardware to detector
238       coordinates */ 
239   AliFMDAltroMapping* GetAltroMap() const;
240   /** @} */
241
242   enum { 
243     kBaseDDL = 0x1000 // DDL offset for the FMD
244   };
245   static const char* fgkPulseGain;       // Path to PulseGain calib object
246   static const char* fgkPedestal;        // Path to Pedestal calib object
247   static const char* fgkDead;            // Path to Dead calib object
248   static const char* fgkSampleRate;      // Path to SampleRate calib object
249   static const char* fgkAltroMap;        // Path to AltroMap calib object
250   static const char* fgkZeroSuppression; // Path to ZeroSuppression cal object
251   static const char* fgkStripRange;      // Path to strip range cal object
252 protected:
253   /** CTOR  */
254   AliFMDParameters();
255   /** DTOR */
256   virtual ~AliFMDParameters() {}
257   /** Singleton instance  */
258   static AliFMDParameters* fgInstance;   // Static singleton instance
259   /** Initialize gains.  Try to get them from CDB */
260   void InitPulseGain();
261   /** Initialize pedestals.  Try to get them from CDB */
262   void InitPedestal();
263   /** Initialize dead map.  Try to get it from CDB */
264   void InitDeadMap();
265   /** Initialize sample rates.  Try to get them from CDB */
266   void InitSampleRate();
267   /** Initialize zero suppression thresholds.  Try to get them from CDB */
268   void InitZeroSuppression();
269   /** Initialize hardware map.  Try to get it from CDB */
270   void InitAltroMap();
271   /** Initialize strip range.  Try to get it from CDB */
272   void InitStripRange();
273
274   Bool_t          fIsInit;               // Whether we've been initialised  
275
276   const Float_t   fSiDeDxMip;            // MIP dE/dx in Silicon
277   UShort_t        fVA1MipRange;          // # MIPs the pre-amp can do    
278   UShort_t        fAltroChannelSize;     // Largest # to store in 1 ADC ch.
279   UShort_t        fChannelsPerAltro;     // Number of pre-amp. chan/adc chan.
280   Float_t         fPedestalFactor;       // Number of pedestal widths
281
282   Float_t         fFixedPedestal;        // Pedestal to subtract
283   Float_t         fFixedPedestalWidth;   // Width of pedestal
284   UShort_t        fFixedZeroSuppression; // Threshold for zero-suppression
285   UShort_t        fFixedSampleRate;      // Times the ALTRO samples pre-amp.
286   Float_t         fFixedThreshold;       //
287   UShort_t        fFixedMinStrip;
288   UShort_t        fFixedMaxStrip;
289   mutable Float_t fFixedPulseGain;       //! Gain (cached)
290   mutable Float_t fEdepMip;              //! Cache of energy loss for a MIP
291   
292   AliFMDCalibZeroSuppression* fZeroSuppression; // Zero suppression from CDB
293   AliFMDCalibSampleRate*      fSampleRate;      // Sample rate from CDB 
294   AliFMDCalibPedestal*        fPedestal;        // Pedestals 
295   AliFMDCalibGain*            fPulseGain;       // Pulser gain
296   AliFMDCalibDeadMap*         fDeadMap;         // Pulser gain
297   AliFMDAltroMapping*         fAltroMap;        // Map of hardware
298   AliFMDCalibStripRange*      fStripRange;      // Strip range
299   
300   ClassDef(AliFMDParameters,4)
301 };
302
303 #endif
304 //____________________________________________________________________
305 //
306 // Local Variables:
307 //   mode: C++
308 // End:
309 //
310 // EOF
311 //
312