]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDParameters.cxx
New FMD calibrations from Christian Holm
[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 **************************************************************************/
1a1fdef7 15/* $Id$ */
c2fc1258 16/** @file AliFMDParameters.cxx
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Mon Mar 27 12:44:26 2006
19 @brief Manager of FMD parameters
20*/
1a1fdef7 21//____________________________________________________________________
22//
23// Forward Multiplicity Detector based on Silicon wafers.
24//
25// This class is a singleton that handles various parameters of
26// the FMD detectors.
088f8e79 27// Eventually, this class will use the Conditions DB to get the
28// various parameters, which code can then request from here.
1a1fdef7 29//
8f6ee336 30#include "AliLog.h" // ALILOG_H
31#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
32#include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
33#include "AliFMDRing.h" // ALIFMDRING_H
34#include "AliFMDCalibGain.h" // ALIFMDCALIBGAIN_H
35#include "AliFMDCalibPedestal.h" // ALIFMDCALIBPEDESTAL_H
c2fc1258 36#include "AliFMDCalibSampleRate.h" // ALIFMDCALIBSAMPLERATE_H
37#include "AliFMDCalibStripRange.h" // ALIFMDCALIBSTRIPRANGE_H
57c3c593 38#include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
39#include <AliCDBManager.h> // ALICDBMANAGER_H
40#include <AliCDBEntry.h> // ALICDBMANAGER_H
1a1fdef7 41#include <Riostream.h>
42
43//====================================================================
44ClassImp(AliFMDParameters)
45#if 0
46 ; // This is here to keep Emacs for indenting the next line
47#endif
48
49//____________________________________________________________________
50AliFMDParameters* AliFMDParameters::fgInstance = 0;
51
57c3c593 52//____________________________________________________________________
53const char* AliFMDParameters::fgkPulseGain = "FMD/Calib/PulseGain";
54const char* AliFMDParameters::fgkPedestal = "FMD/Calib/Pedestal";
55const char* AliFMDParameters::fgkDead = "FMD/Calib/Dead";
56const char* AliFMDParameters::fgkSampleRate = "FMD/Calib/SampleRate";
57const char* AliFMDParameters::fgkAltroMap = "FMD/Calib/AltroMap";
58const char* AliFMDParameters::fgkZeroSuppression = "FMD/Calib/ZeroSuppression";
c2fc1258 59const char* AliFMDParameters::fgkStripRange = "FMD/Calib/StripRange";
57c3c593 60
61
1a1fdef7 62//____________________________________________________________________
63AliFMDParameters*
64AliFMDParameters::Instance()
65{
66 // Get static instance
67 if (!fgInstance) fgInstance = new AliFMDParameters;
68 return fgInstance;
69}
70
71//____________________________________________________________________
72AliFMDParameters::AliFMDParameters()
57c3c593 73 : fIsInit(kFALSE),
02a27b50 74 fkSiDeDxMip(1.664),
8f6ee336 75 fFixedPulseGain(0),
76 fEdepMip(0),
77 fZeroSuppression(0),
78 fSampleRate(0),
79 fPedestal(0),
80 fPulseGain(0),
57c3c593 81 fDeadMap(0),
c2fc1258 82 fAltroMap(0),
83 fStripRange(0)
1a1fdef7 84{
85 // Default constructor
86 SetVA1MipRange();
87 SetAltroChannelSize();
88 SetChannelsPerAltro();
89 SetZeroSuppression();
90 SetSampleRate();
91 SetPedestal();
92 SetPedestalWidth();
93 SetPedestalFactor();
8f6ee336 94 SetThreshold();
c2fc1258 95 SetStripRange();
1a1fdef7 96}
97
57c3c593 98//__________________________________________________________________
99void
100AliFMDParameters::Init()
101{
102 // Initialize the parameters manager. We need to get stuff from the
103 // CDB here.
104 if (fIsInit) return;
1e8f773e 105 InitPulseGain();
106 InitPedestal();
107 InitDeadMap();
108 InitSampleRate();
109 InitZeroSuppression();
110 InitAltroMap();
111 fIsInit = kTRUE;
57c3c593 112
1e8f773e 113}
c2fc1258 114
115//__________________________________________________________________
116void
117AliFMDParameters::Print(Option_t* option) const
118{
02a27b50 119 // Print information.
120 // If option contains an 'A' then everything is printed.
c2fc1258 121 TString opt(option);
122 Bool_t showStrips = opt.Contains("a", TString::kIgnoreCase);
123 for (UShort_t det=1 ; det <= 3; det++) {
124 std::cout << "FMD" << det << std::endl;
125 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
126 for (Char_t* ring = rings; *ring != '\0'; ring++) {
127 std::cout << " Ring " << *ring << std::endl;
128 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
129 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
130 for (UShort_t sec = 0; sec < nSec; sec++) {
131 UShort_t min = GetMinStrip(det, *ring, sec, 0);
132 UShort_t max = GetMaxStrip(det, *ring, sec, 0);
133 UShort_t rate = GetSampleRate(det, *ring, sec, 0);
134 std::cout << " Sector " << std::setw(2) << sec
135 << " Strip range: " << std::setw(3) << min << ","
136 << std::setw(3) << max << " Rate: " << std::setw(2)
137 << rate << std::endl;
138 if (!showStrips) continue;
139 std::cout
140 << " Strip | Pedestal | Gain | ZS thr. | Address\n"
141 << "--------+-------------------+----------+---------+---------"
142 << std::endl;
143 for (UShort_t str = 0; str < nStr; str++) {
144 std::cout << " " << std::setw(3) << str << " | ";
145 if (IsDead(det, *ring, sec, str)) {
146 std::cout << "dead" << std::endl;
147 continue;
148 }
149 UInt_t ddl, addr;
150 Detector2Hardware(det, *ring, sec, str, ddl, addr);
151 std::cout << std::setw(7) << GetPedestal(det, *ring, sec, str)
152 << "+/-" << std::setw(7)
153 << GetPedestalWidth(det, *ring, sec, str)
154 << " | " << std::setw(8)
155 << GetPulseGain(det, *ring, sec, str)
156 << " | " << std::setw(5)
157 << GetZeroSuppression(det, *ring, sec, str)
158 << " | 0x" << std::hex << std::setw(4)
159 << std::setfill('0') << ddl << ",0x" << std::setw(3)
160 << addr << std::dec << std::setfill(' ') << std::endl;
161 }
162 }
163 }
164 }
165}
166
167//__________________________________________________________________
168void
169AliFMDParameters::SetStripRange(UShort_t min, UShort_t max)
170{
02a27b50 171 // Set fixed strip range
c2fc1258 172 fFixedMinStrip = min;
173 fFixedMaxStrip = max;
174}
175
1e8f773e 176//__________________________________________________________________
177void
178AliFMDParameters::InitPulseGain()
179{
02a27b50 180 // Get pulse gain from CDB or used fixed
57c3c593 181 AliCDBManager* cdb = AliCDBManager::Instance();
182 AliCDBEntry* gain = cdb->Get(fgkPulseGain);
1e8f773e 183 if (!gain) {
184 AliWarning(Form("No %s found in CDB, perhaps you need to "
185 "use AliFMDCalibFaker?", fgkPulseGain));
186 return;
187 }
57c3c593 188
1e8f773e 189 AliDebug(1, Form("Got gain from CDB"));
190 fPulseGain = dynamic_cast<AliFMDCalibGain*>(gain->GetObject());
191 if (!fPulseGain) AliWarning("Invalid pulser gain object from CDB");
192}
193//__________________________________________________________________
194void
195AliFMDParameters::InitPedestal()
196{
02a27b50 197 // Initialize the pedestals from CDB
1e8f773e 198 AliCDBManager* cdb = AliCDBManager::Instance();
199 AliCDBEntry* pedestal = cdb->Get(fgkPedestal);
200 if (!pedestal) {
201 AliWarning(Form("No %s found in CDB, perhaps you need to "
202 "use AliFMDCalibFaker?", fgkPedestal));
203 return;
57c3c593 204 }
1e8f773e 205 AliDebug(1, Form("Got pedestal from CDB"));
206 fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject());
207 if (!fPedestal) AliWarning("Invalid pedestal object from CDB");
208}
209
210//__________________________________________________________________
211void
212AliFMDParameters::InitDeadMap()
213{
02a27b50 214 // Get Dead-channel-map from CDB
1e8f773e 215 AliCDBManager* cdb = AliCDBManager::Instance();
216 AliCDBEntry* deadMap = cdb->Get(fgkDead);
217 if (!deadMap) {
218 AliWarning(Form("No %s found in CDB, perhaps you need to "
219 "use AliFMDCalibFaker?", fgkDead));
220 return;
57c3c593 221 }
1e8f773e 222 AliDebug(1, Form("Got dead map from CDB"));
223 fDeadMap = dynamic_cast<AliFMDCalibDeadMap*>(deadMap->GetObject());
224 if (!fDeadMap) AliWarning("Invalid dead map object from CDB");
225}
226
227//__________________________________________________________________
228void
229AliFMDParameters::InitZeroSuppression()
230{
02a27b50 231 // Get 0-suppression from CDB
1e8f773e 232 AliCDBManager* cdb = AliCDBManager::Instance();
233 AliCDBEntry* zeroSup = cdb->Get(fgkZeroSuppression);
234 if (!zeroSup) {
235 AliWarning(Form("No %s found in CDB, perhaps you need to "
236 "use AliFMDCalibFaker?", fgkZeroSuppression));
237 return;
57c3c593 238 }
1e8f773e 239 AliDebug(1, Form("Got zero suppression from CDB"));
240 fZeroSuppression =
241 dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject());
242 if (!fZeroSuppression)AliWarning("Invalid zero suppression object from CDB");
243}
244
245//__________________________________________________________________
246void
247AliFMDParameters::InitSampleRate()
248{
02a27b50 249 // get Sample rate from CDB
1e8f773e 250 AliCDBManager* cdb = AliCDBManager::Instance();
251 AliCDBEntry* sampRat = cdb->Get(fgkSampleRate);
252 if (!sampRat) {
253 AliWarning(Form("No %s found in CDB, perhaps you need to "
254 "use AliFMDCalibFaker?", fgkSampleRate));
255 return;
57c3c593 256 }
1e8f773e 257 AliDebug(1, Form("Got zero suppression from CDB"));
258 fSampleRate = dynamic_cast<AliFMDCalibSampleRate*>(sampRat->GetObject());
259 if (!fSampleRate) AliWarning("Invalid zero suppression object from CDB");
260}
261
262//__________________________________________________________________
263void
264AliFMDParameters::InitAltroMap()
265{
02a27b50 266 // Get hardware mapping from CDB
1e8f773e 267 AliCDBManager* cdb = AliCDBManager::Instance();
268 AliCDBEntry* hwMap = cdb->Get(fgkAltroMap);
269 if (!hwMap) {
270 AliWarning(Form("No %s found in CDB, perhaps you need to "
271 "use AliFMDCalibFaker?", fgkAltroMap));
272 fAltroMap = new AliFMDAltroMapping;
273 return;
57c3c593 274 }
1e8f773e 275 AliDebug(1, Form("Got ALTRO map from CDB"));
276 fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject());
277 if (!fAltroMap) {
278 AliWarning("Invalid ALTRO map object from CDB");
279 fAltroMap = new AliFMDAltroMapping;
57c3c593 280 }
57c3c593 281}
282
c2fc1258 283//__________________________________________________________________
284void
285AliFMDParameters::InitStripRange()
286{
02a27b50 287 // Get strips read-out from CDB
c2fc1258 288 AliCDBManager* cdb = AliCDBManager::Instance();
289 AliCDBEntry* range = cdb->Get(fgkStripRange);
290 if (!range) {
291 AliWarning(Form("No %s found in CDB, perhaps you need to "
292 "use AliFMDCalibFaker?", fgkStripRange));
293 return;
294 }
295 AliDebug(1, Form("Got strip range from CDB"));
296 fStripRange = dynamic_cast<AliFMDCalibStripRange*>(range->GetObject());
297 if (!fStripRange) AliWarning("Invalid strip range object from CDB");
298}
299
1e8f773e 300
8f6ee336 301//__________________________________________________________________
302Float_t
303AliFMDParameters::GetThreshold() const
304{
02a27b50 305 // Get threshold from CDB
8f6ee336 306 if (!fPulseGain) return fFixedThreshold;
307 return fPulseGain->Threshold();
308}
309
310//__________________________________________________________________
311Float_t
312AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring,
313 UShort_t sector, UShort_t strip) const
314{
315 // Returns the pulser calibrated gain for strip # strip in sector #
316 // sector or ring id ring of detector # detector.
317 //
318 // For simulation, this is normally set to
319 //
320 // VA1_MIP_Range
321 // ------------------ * MIP_Energy_Loss
322 // ALTRO_channel_size
323 //
324 if (!fPulseGain) {
325 if (fFixedPulseGain <= 0)
326 fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize;
327 return fFixedPulseGain;
328 }
1e8f773e 329 AliDebug(50, Form("pulse gain for FMD%d%c[%2d,%3d]=%f",
330 detector, ring, sector, strip,
331 fPulseGain->Value(detector, ring, sector, strip)));
8f6ee336 332 return fPulseGain->Value(detector, ring, sector, strip);
333}
334
335//__________________________________________________________________
336Bool_t
337AliFMDParameters::IsDead(UShort_t detector, Char_t ring,
338 UShort_t sector, UShort_t strip) const
339{
02a27b50 340 // Check if the channel is dead
8f6ee336 341 if (!fDeadMap) return kFALSE;
1e8f773e 342 AliDebug(50, Form("Dead for FMD%d%c[%2d,%3d]=%s",
343 detector, ring, sector, strip,
344 fDeadMap->operator()(detector, ring, sector, strip) ?
345 "no" : "yes"));
8f6ee336 346 return fDeadMap->operator()(detector, ring, sector, strip);
347}
348
349//__________________________________________________________________
350UShort_t
351AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring,
352 UShort_t sector, UShort_t strip) const
353{
02a27b50 354 // Get zero suppression threshold
8f6ee336 355 if (!fZeroSuppression) return fFixedZeroSuppression;
356 // Need to map strip to ALTRO chip.
1e8f773e 357 AliDebug(50, Form("zero sup. for FMD%d%c[%2d,%3d]=%f",
358 detector, ring, sector, strip,
359 fZeroSuppression->operator()(detector, ring,
360 sector, strip)));
8f6ee336 361 return fZeroSuppression->operator()(detector, ring, sector, strip/128);
362}
363
364//__________________________________________________________________
365UShort_t
c2fc1258 366AliFMDParameters::GetSampleRate(UShort_t det, Char_t ring, UShort_t sector,
367 UShort_t str) const
8f6ee336 368{
02a27b50 369 // Get sampl rate
8f6ee336 370 if (!fSampleRate) return fFixedSampleRate;
371 // Need to map sector to digitizier card.
c2fc1258 372 UInt_t ret = fSampleRate->Rate(det, ring, sector, str);
373 AliDebug(50, Form("Sample rate for FMD%d%c[%2d,%3d]=%d",
374 det, ring, sector, str, ret));
375 return ret;
376}
377
378//__________________________________________________________________
379UShort_t
380AliFMDParameters::GetMinStrip(UShort_t det, Char_t ring, UShort_t sector,
381 UShort_t str) const
382{
02a27b50 383 // Get strip range read out
c2fc1258 384 if (!fStripRange) return fFixedMinStrip;
385 // Need to map sector to digitizier card.
386 UInt_t ret = fStripRange->Min(det, ring, sector, str);
387 AliDebug(50, Form("Min strip # for FMD%d%c[%2d,%3d]=%d",
388 det, ring, sector, str, ret));
389 return ret;
390}
391
392//__________________________________________________________________
393UShort_t
394AliFMDParameters::GetMaxStrip(UShort_t det, Char_t ring, UShort_t sector,
395 UShort_t str) const
396{
02a27b50 397 // Get strip range read out
c2fc1258 398 if (!fStripRange) return fFixedMaxStrip;
399 // Need to map sector to digitizier card.
400 UInt_t ret = fStripRange->Max(det, ring, sector, str);
401 AliDebug(50, Form("Max strip # for FMD%d%c[%2d,%3d]=%d",
402 det, ring, sector, str, ret));
403 return ret;
8f6ee336 404}
1a1fdef7 405
8f6ee336 406//__________________________________________________________________
407Float_t
408AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring,
409 UShort_t sector, UShort_t strip) const
410{
02a27b50 411 // Get the pedesal
8f6ee336 412 if (!fPedestal) return fFixedPedestal;
1e8f773e 413 AliDebug(50, Form("pedestal for FMD%d%c[%2d,%3d]=%f",
414 detector, ring, sector, strip,
415 fPedestal->Value(detector, ring, sector, strip)));
8f6ee336 416 return fPedestal->Value(detector, ring, sector, strip);
417}
418
419//__________________________________________________________________
420Float_t
421AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring,
422 UShort_t sector, UShort_t strip) const
423{
02a27b50 424 // Get the pedesal
8f6ee336 425 if (!fPedestal) return fFixedPedestalWidth;
1e8f773e 426 AliDebug(50, Form("pedetal width for FMD%d%c[%2d,%3d]=%f",
427 detector, ring, sector, strip,
428 fPedestal->Width(detector, ring, sector, strip)));
8f6ee336 429 return fPedestal->Width(detector, ring, sector, strip);
430}
431
1a1fdef7 432//__________________________________________________________________
57c3c593 433AliFMDAltroMapping*
434AliFMDParameters::GetAltroMap() const
435{
02a27b50 436 // Get the hardware address to detector index map
57c3c593 437 return fAltroMap;
1a1fdef7 438}
439
57c3c593 440
bf000c32 441//__________________________________________________________________
442Bool_t
443AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
444 Char_t& ring, UShort_t& sec,
445 UShort_t& str) const
446{
02a27b50 447 // Map hardware address to detector index
57c3c593 448 if (!fAltroMap) return kFALSE;
449 return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
bf000c32 450}
451
452//__________________________________________________________________
453Bool_t
454AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
57c3c593 455 UShort_t str, UInt_t& ddl,
456 UInt_t& addr) const
bf000c32 457{
02a27b50 458 // Map detector index to hardware address
57c3c593 459 if (!fAltroMap) return kFALSE;
460 return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
bf000c32 461}
462
57c3c593 463
464//__________________________________________________________________
465Float_t
466AliFMDParameters::GetEdepMip() const
467{
468 // Get energy deposited by a MIP in the silicon sensors
469 if (fEdepMip <= 0){
470 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
02a27b50 471 fEdepMip = (fkSiDeDxMip
57c3c593 472 * fmd->GetRing('I')->GetSiThickness()
473 * fmd->GetSiDensity());
474 }
475 return fEdepMip;
476}
477
478
bf000c32 479
480
481
1a1fdef7 482//____________________________________________________________________
483//
484// EOF
485//