]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDParameters.cxx
Additiona TOF data members (S.Arcelli)
[u/mrichter/AliRoot.git] / FMD / AliFMDParameters.cxx
CommitLineData
1a1fdef7 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.
088f8e79 24// Eventually, this class will use the Conditions DB to get the
25// various parameters, which code can then request from here.
1a1fdef7 26//
8f6ee336 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
57c3c593 34#include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
35#include <AliCDBManager.h> // ALICDBMANAGER_H
36#include <AliCDBEntry.h> // ALICDBMANAGER_H
1a1fdef7 37#include <Riostream.h>
38
39//====================================================================
40ClassImp(AliFMDParameters)
41#if 0
42 ; // This is here to keep Emacs for indenting the next line
43#endif
44
45//____________________________________________________________________
46AliFMDParameters* AliFMDParameters::fgInstance = 0;
47
57c3c593 48//____________________________________________________________________
49const char* AliFMDParameters::fgkPulseGain = "FMD/Calib/PulseGain";
50const char* AliFMDParameters::fgkPedestal = "FMD/Calib/Pedestal";
51const char* AliFMDParameters::fgkDead = "FMD/Calib/Dead";
52const char* AliFMDParameters::fgkSampleRate = "FMD/Calib/SampleRate";
53const char* AliFMDParameters::fgkAltroMap = "FMD/Calib/AltroMap";
54const char* AliFMDParameters::fgkZeroSuppression = "FMD/Calib/ZeroSuppression";
55
56
1a1fdef7 57//____________________________________________________________________
58AliFMDParameters*
59AliFMDParameters::Instance()
60{
61 // Get static instance
62 if (!fgInstance) fgInstance = new AliFMDParameters;
63 return fgInstance;
64}
65
66//____________________________________________________________________
67AliFMDParameters::AliFMDParameters()
57c3c593 68 : fIsInit(kFALSE),
69 fSiDeDxMip(1.664),
8f6ee336 70 fFixedPulseGain(0),
71 fEdepMip(0),
72 fZeroSuppression(0),
73 fSampleRate(0),
74 fPedestal(0),
75 fPulseGain(0),
57c3c593 76 fDeadMap(0),
77 fAltroMap(0)
1a1fdef7 78{
79 // Default constructor
80 SetVA1MipRange();
81 SetAltroChannelSize();
82 SetChannelsPerAltro();
83 SetZeroSuppression();
84 SetSampleRate();
85 SetPedestal();
86 SetPedestalWidth();
87 SetPedestalFactor();
8f6ee336 88 SetThreshold();
1a1fdef7 89}
90
57c3c593 91//__________________________________________________________________
92void
93AliFMDParameters::Init()
94{
95 // Initialize the parameters manager. We need to get stuff from the
96 // CDB here.
97 if (fIsInit) return;
1e8f773e 98 InitPulseGain();
99 InitPedestal();
100 InitDeadMap();
101 InitSampleRate();
102 InitZeroSuppression();
103 InitAltroMap();
104 fIsInit = kTRUE;
57c3c593 105
1e8f773e 106}
107//__________________________________________________________________
108void
109AliFMDParameters::InitPulseGain()
110{
57c3c593 111 AliCDBManager* cdb = AliCDBManager::Instance();
112 AliCDBEntry* gain = cdb->Get(fgkPulseGain);
1e8f773e 113 if (!gain) {
114 AliWarning(Form("No %s found in CDB, perhaps you need to "
115 "use AliFMDCalibFaker?", fgkPulseGain));
116 return;
117 }
57c3c593 118
1e8f773e 119 AliDebug(1, Form("Got gain from CDB"));
120 fPulseGain = dynamic_cast<AliFMDCalibGain*>(gain->GetObject());
121 if (!fPulseGain) AliWarning("Invalid pulser gain object from CDB");
122}
123//__________________________________________________________________
124void
125AliFMDParameters::InitPedestal()
126{
127 AliCDBManager* cdb = AliCDBManager::Instance();
128 AliCDBEntry* pedestal = cdb->Get(fgkPedestal);
129 if (!pedestal) {
130 AliWarning(Form("No %s found in CDB, perhaps you need to "
131 "use AliFMDCalibFaker?", fgkPedestal));
132 return;
57c3c593 133 }
1e8f773e 134 AliDebug(1, Form("Got pedestal from CDB"));
135 fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject());
136 if (!fPedestal) AliWarning("Invalid pedestal object from CDB");
137}
138
139//__________________________________________________________________
140void
141AliFMDParameters::InitDeadMap()
142{
143 AliCDBManager* cdb = AliCDBManager::Instance();
144 AliCDBEntry* deadMap = cdb->Get(fgkDead);
145 if (!deadMap) {
146 AliWarning(Form("No %s found in CDB, perhaps you need to "
147 "use AliFMDCalibFaker?", fgkDead));
148 return;
57c3c593 149 }
1e8f773e 150 AliDebug(1, Form("Got dead map from CDB"));
151 fDeadMap = dynamic_cast<AliFMDCalibDeadMap*>(deadMap->GetObject());
152 if (!fDeadMap) AliWarning("Invalid dead map object from CDB");
153}
154
155//__________________________________________________________________
156void
157AliFMDParameters::InitZeroSuppression()
158{
159 AliCDBManager* cdb = AliCDBManager::Instance();
160 AliCDBEntry* zeroSup = cdb->Get(fgkZeroSuppression);
161 if (!zeroSup) {
162 AliWarning(Form("No %s found in CDB, perhaps you need to "
163 "use AliFMDCalibFaker?", fgkZeroSuppression));
164 return;
57c3c593 165 }
1e8f773e 166 AliDebug(1, Form("Got zero suppression from CDB"));
167 fZeroSuppression =
168 dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject());
169 if (!fZeroSuppression)AliWarning("Invalid zero suppression object from CDB");
170}
171
172//__________________________________________________________________
173void
174AliFMDParameters::InitSampleRate()
175{
176 AliCDBManager* cdb = AliCDBManager::Instance();
177 AliCDBEntry* sampRat = cdb->Get(fgkSampleRate);
178 if (!sampRat) {
179 AliWarning(Form("No %s found in CDB, perhaps you need to "
180 "use AliFMDCalibFaker?", fgkSampleRate));
181 return;
57c3c593 182 }
1e8f773e 183 AliDebug(1, Form("Got zero suppression from CDB"));
184 fSampleRate = dynamic_cast<AliFMDCalibSampleRate*>(sampRat->GetObject());
185 if (!fSampleRate) AliWarning("Invalid zero suppression object from CDB");
186}
187
188//__________________________________________________________________
189void
190AliFMDParameters::InitAltroMap()
191{
192 AliCDBManager* cdb = AliCDBManager::Instance();
193 AliCDBEntry* hwMap = cdb->Get(fgkAltroMap);
194 if (!hwMap) {
195 AliWarning(Form("No %s found in CDB, perhaps you need to "
196 "use AliFMDCalibFaker?", fgkAltroMap));
197 fAltroMap = new AliFMDAltroMapping;
198 return;
57c3c593 199 }
1e8f773e 200 AliDebug(1, Form("Got ALTRO map from CDB"));
201 fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject());
202 if (!fAltroMap) {
203 AliWarning("Invalid ALTRO map object from CDB");
204 fAltroMap = new AliFMDAltroMapping;
57c3c593 205 }
57c3c593 206}
207
1e8f773e 208
8f6ee336 209//__________________________________________________________________
210Float_t
211AliFMDParameters::GetThreshold() const
212{
213 if (!fPulseGain) return fFixedThreshold;
214 return fPulseGain->Threshold();
215}
216
217//__________________________________________________________________
218Float_t
219AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring,
220 UShort_t sector, UShort_t strip) const
221{
222 // Returns the pulser calibrated gain for strip # strip in sector #
223 // sector or ring id ring of detector # detector.
224 //
225 // For simulation, this is normally set to
226 //
227 // VA1_MIP_Range
228 // ------------------ * MIP_Energy_Loss
229 // ALTRO_channel_size
230 //
231 if (!fPulseGain) {
232 if (fFixedPulseGain <= 0)
233 fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize;
234 return fFixedPulseGain;
235 }
1e8f773e 236 AliDebug(50, Form("pulse gain for FMD%d%c[%2d,%3d]=%f",
237 detector, ring, sector, strip,
238 fPulseGain->Value(detector, ring, sector, strip)));
8f6ee336 239 return fPulseGain->Value(detector, ring, sector, strip);
240}
241
242//__________________________________________________________________
243Bool_t
244AliFMDParameters::IsDead(UShort_t detector, Char_t ring,
245 UShort_t sector, UShort_t strip) const
246{
247 if (!fDeadMap) return kFALSE;
1e8f773e 248 AliDebug(50, Form("Dead for FMD%d%c[%2d,%3d]=%s",
249 detector, ring, sector, strip,
250 fDeadMap->operator()(detector, ring, sector, strip) ?
251 "no" : "yes"));
8f6ee336 252 return fDeadMap->operator()(detector, ring, sector, strip);
253}
254
255//__________________________________________________________________
256UShort_t
257AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring,
258 UShort_t sector, UShort_t strip) const
259{
260 if (!fZeroSuppression) return fFixedZeroSuppression;
261 // Need to map strip to ALTRO chip.
1e8f773e 262 AliDebug(50, Form("zero sup. for FMD%d%c[%2d,%3d]=%f",
263 detector, ring, sector, strip,
264 fZeroSuppression->operator()(detector, ring,
265 sector, strip)));
8f6ee336 266 return fZeroSuppression->operator()(detector, ring, sector, strip/128);
267}
268
269//__________________________________________________________________
270UShort_t
271AliFMDParameters::GetSampleRate(UShort_t ddl) const
272{
273 if (!fSampleRate) return fFixedSampleRate;
274 // Need to map sector to digitizier card.
1e8f773e 275 AliDebug(50, Form("Sample rate for %d=%d", ddl, fSampleRate->Rate(ddl)));
8f6ee336 276 return fSampleRate->Rate(ddl);
277}
1a1fdef7 278
8f6ee336 279//__________________________________________________________________
280Float_t
281AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring,
282 UShort_t sector, UShort_t strip) const
283{
284 if (!fPedestal) return fFixedPedestal;
1e8f773e 285 AliDebug(50, Form("pedestal for FMD%d%c[%2d,%3d]=%f",
286 detector, ring, sector, strip,
287 fPedestal->Value(detector, ring, sector, strip)));
8f6ee336 288 return fPedestal->Value(detector, ring, sector, strip);
289}
290
291//__________________________________________________________________
292Float_t
293AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring,
294 UShort_t sector, UShort_t strip) const
295{
296 if (!fPedestal) return fFixedPedestalWidth;
1e8f773e 297 AliDebug(50, Form("pedetal width for FMD%d%c[%2d,%3d]=%f",
298 detector, ring, sector, strip,
299 fPedestal->Width(detector, ring, sector, strip)));
8f6ee336 300 return fPedestal->Width(detector, ring, sector, strip);
301}
302
1a1fdef7 303//__________________________________________________________________
57c3c593 304AliFMDAltroMapping*
305AliFMDParameters::GetAltroMap() const
306{
307 return fAltroMap;
1a1fdef7 308}
309
57c3c593 310
bf000c32 311//__________________________________________________________________
312Bool_t
313AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
314 Char_t& ring, UShort_t& sec,
315 UShort_t& str) const
316{
57c3c593 317 if (!fAltroMap) return kFALSE;
318 return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
bf000c32 319}
320
321//__________________________________________________________________
322Bool_t
323AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
57c3c593 324 UShort_t str, UInt_t& ddl,
325 UInt_t& addr) const
bf000c32 326{
57c3c593 327 if (!fAltroMap) return kFALSE;
328 return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
bf000c32 329}
330
57c3c593 331
332//__________________________________________________________________
333Float_t
334AliFMDParameters::GetEdepMip() const
335{
336 // Get energy deposited by a MIP in the silicon sensors
337 if (fEdepMip <= 0){
338 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
339 fEdepMip = (fSiDeDxMip
340 * fmd->GetRing('I')->GetSiThickness()
341 * fmd->GetSiDensity());
342 }
343 return fEdepMip;
344}
345
346
bf000c32 347
348
349
1a1fdef7 350//____________________________________________________________________
351//
352// EOF
353//