]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDParameters.cxx
New defaults values
[u/mrichter/AliRoot.git] / FMD / AliFMDParameters.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //____________________________________________________________________
19 //                                                                          
20 // Forward Multiplicity Detector based on Silicon wafers. 
21 //
22 // This class is a singleton that handles various parameters of
23 // the FMD detectors.  
24 // Eventually, this class will use the Conditions DB to get the
25 // various parameters, which code can then request from here.
26 //                                                       
27 #include "AliLog.h"                // ALILOG_H
28 #include "AliFMDParameters.h"      // ALIFMDPARAMETERS_H
29 #include "AliFMDGeometry.h"        // ALIFMDGEOMETRY_H
30 #include "AliFMDRing.h"            // ALIFMDRING_H
31 #include "AliFMDCalibGain.h"       // ALIFMDCALIBGAIN_H
32 #include "AliFMDCalibPedestal.h"   // ALIFMDCALIBPEDESTAL_H
33 #include "AliFMDCalibSampleRate.h" // ALIFMDCALIBPEDESTAL_H
34 #include "AliFMDAltroMapping.h"    // ALIFMDALTROMAPPING_H
35 #include <AliCDBManager.h>         // ALICDBMANAGER_H
36 #include <AliCDBEntry.h>           // ALICDBMANAGER_H
37 #include <Riostream.h>
38
39 //====================================================================
40 ClassImp(AliFMDParameters)
41 #if 0
42   ; // This is here to keep Emacs for indenting the next line
43 #endif
44
45 //____________________________________________________________________
46 AliFMDParameters* AliFMDParameters::fgInstance = 0;
47
48 //____________________________________________________________________
49 const char* AliFMDParameters::fgkPulseGain       = "FMD/Calib/PulseGain";
50 const char* AliFMDParameters::fgkPedestal        = "FMD/Calib/Pedestal";
51 const char* AliFMDParameters::fgkDead            = "FMD/Calib/Dead";
52 const char* AliFMDParameters::fgkSampleRate      = "FMD/Calib/SampleRate";
53 const char* AliFMDParameters::fgkAltroMap        = "FMD/Calib/AltroMap";
54 const char* AliFMDParameters::fgkZeroSuppression = "FMD/Calib/ZeroSuppression";
55
56
57 //____________________________________________________________________
58 AliFMDParameters* 
59 AliFMDParameters::Instance() 
60 {
61   // Get static instance 
62   if (!fgInstance) fgInstance = new AliFMDParameters;
63   return fgInstance;
64 }
65
66 //____________________________________________________________________
67 AliFMDParameters::AliFMDParameters() 
68   : fIsInit(kFALSE),
69     fSiDeDxMip(1.664), 
70     fFixedPulseGain(0), 
71     fEdepMip(0),
72     fZeroSuppression(0), 
73     fSampleRate(0), 
74     fPedestal(0), 
75     fPulseGain(0), 
76     fDeadMap(0), 
77     fAltroMap(0)
78 {
79   // Default constructor 
80   SetVA1MipRange();
81   SetAltroChannelSize();
82   SetChannelsPerAltro();
83   SetZeroSuppression();
84   SetSampleRate();
85   SetPedestal();
86   SetPedestalWidth();
87   SetPedestalFactor();
88   SetThreshold();
89 }
90
91 //__________________________________________________________________
92 void
93 AliFMDParameters::Init()
94 {
95   // Initialize the parameters manager.  We need to get stuff from the
96   // CDB here. 
97   if (fIsInit) return;
98   
99   AliCDBManager* cdb      = AliCDBManager::Instance();
100   AliCDBEntry*   gain     = cdb->Get(fgkPulseGain);
101   AliCDBEntry*   pedestal = cdb->Get(fgkPedestal);
102   AliCDBEntry*   deadMap  = cdb->Get(fgkDead);
103   AliCDBEntry*   zeroSup  = cdb->Get(fgkZeroSuppression);
104   AliCDBEntry*   sampRat  = cdb->Get(fgkSampleRate);
105   AliCDBEntry*   hwMap    = cdb->Get(fgkAltroMap);       
106   
107   if (gain) {
108     AliDebug(1, Form("Got gain from CDB"));
109     fPulseGain = dynamic_cast<AliFMDCalibGain*>(gain->GetObject());
110     if (!fPulseGain) 
111       AliWarning("Invalid pulser gain object from CDB");
112   }
113   if (pedestal) {
114     AliDebug(1, Form("Got pedestal from CDB"));
115     fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject());
116     if (!fPedestal) 
117       AliWarning("Invalid pedestal object from CDB");
118   }
119   if (deadMap) {
120     AliDebug(1, Form("Got dead map from CDB"));
121     fDeadMap = dynamic_cast<AliFMDCalibDeadMap*>(deadMap->GetObject());
122     if (!fDeadMap) 
123       AliWarning("Invalid dead map object from CDB");
124   }
125   if (zeroSup) {
126     AliDebug(1, Form("Got zero suppression from CDB"));
127     fZeroSuppression = 
128       dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject());
129     if (!fZeroSuppression) 
130       AliWarning("Invalid zero suppression object from CDB");
131   }
132   if (sampRat) {
133     AliDebug(1, Form("Got zero suppression from CDB"));
134     fSampleRate = 
135       dynamic_cast<AliFMDCalibSampleRate*>(sampRat->GetObject());
136     if (!fSampleRate) 
137       AliWarning("Invalid zero suppression object from CDB");
138   }
139   if (hwMap) {
140     AliDebug(1, Form("Got ALTRO map from CDB"));
141     fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject());
142     if (!fAltroMap) 
143       AliWarning("Invalid ALTRO map object from CDB");
144   }
145   if (!fAltroMap) fAltroMap = new AliFMDAltroMapping;
146   
147   fIsInit = kTRUE;
148 }
149
150 //__________________________________________________________________
151 Float_t
152 AliFMDParameters::GetThreshold() const
153 {
154   if (!fPulseGain) return fFixedThreshold;
155   return fPulseGain->Threshold();
156 }
157
158 //__________________________________________________________________
159 Float_t
160 AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring, 
161                                UShort_t sector, UShort_t strip) const
162 {
163   // Returns the pulser calibrated gain for strip # strip in sector #
164   // sector or ring id ring of detector # detector. 
165   // 
166   // For simulation, this is normally set to 
167   // 
168   //       VA1_MIP_Range 
169   //    ------------------ * MIP_Energy_Loss
170   //    ALTRO_channel_size
171   // 
172   if (!fPulseGain) { 
173     if (fFixedPulseGain <= 0)
174       fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize;
175     return fFixedPulseGain;
176   }  
177   return fPulseGain->Value(detector, ring, sector, strip);
178 }
179
180 //__________________________________________________________________
181 Bool_t
182 AliFMDParameters::IsDead(UShort_t detector, Char_t ring, 
183                          UShort_t sector, UShort_t strip) const
184 {
185   if (!fDeadMap) return kFALSE;
186   return fDeadMap->operator()(detector, ring, sector, strip);
187 }
188
189 //__________________________________________________________________
190 UShort_t
191 AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring, 
192                                      UShort_t sector, UShort_t strip) const
193 {
194   if (!fZeroSuppression) return fFixedZeroSuppression;
195   // Need to map strip to ALTRO chip. 
196   return fZeroSuppression->operator()(detector, ring, sector, strip/128);
197 }
198
199 //__________________________________________________________________
200 UShort_t
201 AliFMDParameters::GetSampleRate(UShort_t ddl) const
202 {
203   if (!fSampleRate) return fFixedSampleRate;
204   // Need to map sector to digitizier card. 
205   return fSampleRate->Rate(ddl);
206 }
207
208 //__________________________________________________________________
209 Float_t
210 AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring, 
211                               UShort_t sector, UShort_t strip) const
212 {
213   if (!fPedestal) return fFixedPedestal;
214   return fPedestal->Value(detector, ring, sector, strip);
215 }
216
217 //__________________________________________________________________
218 Float_t
219 AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring, 
220                                    UShort_t sector, UShort_t strip) const
221 {
222   if (!fPedestal) return fFixedPedestalWidth;
223   return fPedestal->Width(detector, ring, sector, strip);
224 }
225   
226 //__________________________________________________________________
227 AliFMDAltroMapping*
228 AliFMDParameters::GetAltroMap() const
229 {
230   return fAltroMap;
231 }
232
233
234 //__________________________________________________________________
235 Bool_t
236 AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
237                                     Char_t& ring, UShort_t& sec, 
238                                     UShort_t& str) const
239 {
240   if (!fAltroMap) return kFALSE;
241   return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
242 }
243
244 //__________________________________________________________________
245 Bool_t
246 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec, 
247                                     UShort_t str, UInt_t& ddl, 
248                                     UInt_t& addr) const                       
249 {
250   if (!fAltroMap) return kFALSE;
251   return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
252 }
253
254
255 //__________________________________________________________________
256 Float_t
257 AliFMDParameters::GetEdepMip() const 
258
259   // Get energy deposited by a MIP in the silicon sensors
260   if (fEdepMip <= 0){
261     AliFMDGeometry* fmd = AliFMDGeometry::Instance();
262     fEdepMip = (fSiDeDxMip 
263                 * fmd->GetRing('I')->GetSiThickness() 
264                 * fmd->GetSiDensity());
265   }
266   return fEdepMip;
267 }
268
269
270   
271   
272   
273 //____________________________________________________________________
274 //
275 // EOF
276 //