New defaults values
[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;
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
8f6ee336 150//__________________________________________________________________
151Float_t
152AliFMDParameters::GetThreshold() const
153{
154 if (!fPulseGain) return fFixedThreshold;
155 return fPulseGain->Threshold();
156}
157
158//__________________________________________________________________
159Float_t
160AliFMDParameters::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//__________________________________________________________________
181Bool_t
182AliFMDParameters::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//__________________________________________________________________
190UShort_t
191AliFMDParameters::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//__________________________________________________________________
200UShort_t
201AliFMDParameters::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}
1a1fdef7 207
8f6ee336 208//__________________________________________________________________
209Float_t
210AliFMDParameters::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//__________________________________________________________________
218Float_t
219AliFMDParameters::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
1a1fdef7 226//__________________________________________________________________
57c3c593 227AliFMDAltroMapping*
228AliFMDParameters::GetAltroMap() const
229{
230 return fAltroMap;
1a1fdef7 231}
232
57c3c593 233
bf000c32 234//__________________________________________________________________
235Bool_t
236AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
237 Char_t& ring, UShort_t& sec,
238 UShort_t& str) const
239{
57c3c593 240 if (!fAltroMap) return kFALSE;
241 return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
bf000c32 242}
243
244//__________________________________________________________________
245Bool_t
246AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
57c3c593 247 UShort_t str, UInt_t& ddl,
248 UInt_t& addr) const
bf000c32 249{
57c3c593 250 if (!fAltroMap) return kFALSE;
251 return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
bf000c32 252}
253
57c3c593 254
255//__________________________________________________________________
256Float_t
257AliFMDParameters::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
bf000c32 270
271
272
1a1fdef7 273//____________________________________________________________________
274//
275// EOF
276//