1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
21 //____________________________________________________________________
23 // Forward Multiplicity Detector based on Silicon wafers.
25 // This class is a singleton that handles various parameters of
27 // Eventually, this class will use the Conditions DB to get the
28 // various parameters, which code can then request from here.
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
36 #include "AliFMDCalibSampleRate.h" // ALIFMDCALIBSAMPLERATE_H
37 #include "AliFMDCalibStripRange.h" // ALIFMDCALIBSTRIPRANGE_H
38 #include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
39 #include <AliCDBManager.h> // ALICDBMANAGER_H
40 #include <AliCDBEntry.h> // ALICDBMANAGER_H
41 #include <Riostream.h>
43 //====================================================================
44 ClassImp(AliFMDParameters)
46 ; // This is here to keep Emacs for indenting the next line
49 //____________________________________________________________________
50 AliFMDParameters* AliFMDParameters::fgInstance = 0;
52 //____________________________________________________________________
53 const char* AliFMDParameters::fgkPulseGain = "FMD/Calib/PulseGain";
54 const char* AliFMDParameters::fgkPedestal = "FMD/Calib/Pedestal";
55 const char* AliFMDParameters::fgkDead = "FMD/Calib/Dead";
56 const char* AliFMDParameters::fgkSampleRate = "FMD/Calib/SampleRate";
57 const char* AliFMDParameters::fgkAltroMap = "FMD/Calib/AltroMap";
58 const char* AliFMDParameters::fgkZeroSuppression = "FMD/Calib/ZeroSuppression";
59 const char* AliFMDParameters::fgkStripRange = "FMD/Calib/StripRange";
62 //____________________________________________________________________
64 AliFMDParameters::Instance()
66 // Get static instance
67 if (!fgInstance) fgInstance = new AliFMDParameters;
71 //____________________________________________________________________
72 AliFMDParameters::AliFMDParameters()
85 // Default constructor
87 SetAltroChannelSize();
88 SetChannelsPerAltro();
98 //__________________________________________________________________
100 AliFMDParameters::Init()
102 // Initialize the parameters manager. We need to get stuff from the
109 InitZeroSuppression();
115 //__________________________________________________________________
117 AliFMDParameters::Print(Option_t* option) const
119 // Print information.
120 // If option contains an 'A' then everything is printed.
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;
140 << " Strip | Pedestal | Gain | ZS thr. | Address\n"
141 << "--------+-------------------+----------+---------+---------"
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;
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;
167 //__________________________________________________________________
169 AliFMDParameters::SetStripRange(UShort_t min, UShort_t max)
171 // Set fixed strip range
172 fFixedMinStrip = min;
173 fFixedMaxStrip = max;
176 //__________________________________________________________________
178 AliFMDParameters::InitPulseGain()
180 // Get pulse gain from CDB or used fixed
181 AliCDBManager* cdb = AliCDBManager::Instance();
182 AliCDBEntry* gain = cdb->Get(fgkPulseGain);
184 AliWarning(Form("No %s found in CDB, perhaps you need to "
185 "use AliFMDCalibFaker?", fgkPulseGain));
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");
193 //__________________________________________________________________
195 AliFMDParameters::InitPedestal()
197 // Initialize the pedestals from CDB
198 AliCDBManager* cdb = AliCDBManager::Instance();
199 AliCDBEntry* pedestal = cdb->Get(fgkPedestal);
201 AliWarning(Form("No %s found in CDB, perhaps you need to "
202 "use AliFMDCalibFaker?", fgkPedestal));
205 AliDebug(1, Form("Got pedestal from CDB"));
206 fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject());
207 if (!fPedestal) AliWarning("Invalid pedestal object from CDB");
210 //__________________________________________________________________
212 AliFMDParameters::InitDeadMap()
214 // Get Dead-channel-map from CDB
215 AliCDBManager* cdb = AliCDBManager::Instance();
216 AliCDBEntry* deadMap = cdb->Get(fgkDead);
218 AliWarning(Form("No %s found in CDB, perhaps you need to "
219 "use AliFMDCalibFaker?", fgkDead));
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");
227 //__________________________________________________________________
229 AliFMDParameters::InitZeroSuppression()
231 // Get 0-suppression from CDB
232 AliCDBManager* cdb = AliCDBManager::Instance();
233 AliCDBEntry* zeroSup = cdb->Get(fgkZeroSuppression);
235 AliWarning(Form("No %s found in CDB, perhaps you need to "
236 "use AliFMDCalibFaker?", fgkZeroSuppression));
239 AliDebug(1, Form("Got zero suppression from CDB"));
241 dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject());
242 if (!fZeroSuppression)AliWarning("Invalid zero suppression object from CDB");
245 //__________________________________________________________________
247 AliFMDParameters::InitSampleRate()
249 // get Sample rate from CDB
250 AliCDBManager* cdb = AliCDBManager::Instance();
251 AliCDBEntry* sampRat = cdb->Get(fgkSampleRate);
253 AliWarning(Form("No %s found in CDB, perhaps you need to "
254 "use AliFMDCalibFaker?", fgkSampleRate));
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");
262 //__________________________________________________________________
264 AliFMDParameters::InitAltroMap()
266 // Get hardware mapping from CDB
267 AliCDBManager* cdb = AliCDBManager::Instance();
268 AliCDBEntry* hwMap = cdb->Get(fgkAltroMap);
270 AliWarning(Form("No %s found in CDB, perhaps you need to "
271 "use AliFMDCalibFaker?", fgkAltroMap));
272 fAltroMap = new AliFMDAltroMapping;
275 AliDebug(1, Form("Got ALTRO map from CDB"));
276 fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject());
278 AliWarning("Invalid ALTRO map object from CDB");
279 fAltroMap = new AliFMDAltroMapping;
283 //__________________________________________________________________
285 AliFMDParameters::InitStripRange()
287 // Get strips read-out from CDB
288 AliCDBManager* cdb = AliCDBManager::Instance();
289 AliCDBEntry* range = cdb->Get(fgkStripRange);
291 AliWarning(Form("No %s found in CDB, perhaps you need to "
292 "use AliFMDCalibFaker?", fgkStripRange));
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");
301 //__________________________________________________________________
303 AliFMDParameters::GetThreshold() const
305 // Get threshold from CDB
306 if (!fPulseGain) return fFixedThreshold;
307 return fPulseGain->Threshold();
310 //__________________________________________________________________
312 AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring,
313 UShort_t sector, UShort_t strip) const
315 // Returns the pulser calibrated gain for strip # strip in sector #
316 // sector or ring id ring of detector # detector.
318 // For simulation, this is normally set to
321 // ------------------ * MIP_Energy_Loss
322 // ALTRO_channel_size
325 if (fFixedPulseGain <= 0)
326 fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize;
327 return fFixedPulseGain;
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)));
332 return fPulseGain->Value(detector, ring, sector, strip);
335 //__________________________________________________________________
337 AliFMDParameters::IsDead(UShort_t detector, Char_t ring,
338 UShort_t sector, UShort_t strip) const
340 // Check if the channel is dead
341 if (!fDeadMap) return kFALSE;
342 AliDebug(50, Form("Dead for FMD%d%c[%2d,%3d]=%s",
343 detector, ring, sector, strip,
344 fDeadMap->operator()(detector, ring, sector, strip) ?
346 return fDeadMap->operator()(detector, ring, sector, strip);
349 //__________________________________________________________________
351 AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring,
352 UShort_t sector, UShort_t strip) const
354 // Get zero suppression threshold
355 if (!fZeroSuppression) return fFixedZeroSuppression;
356 // Need to map strip to ALTRO chip.
357 AliDebug(50, Form("zero sup. for FMD%d%c[%2d,%3d]=%f",
358 detector, ring, sector, strip,
359 fZeroSuppression->operator()(detector, ring,
361 return fZeroSuppression->operator()(detector, ring, sector, strip/128);
364 //__________________________________________________________________
366 AliFMDParameters::GetSampleRate(UShort_t det, Char_t ring, UShort_t sector,
370 if (!fSampleRate) return fFixedSampleRate;
371 // Need to map sector to digitizier card.
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));
378 //__________________________________________________________________
380 AliFMDParameters::GetMinStrip(UShort_t det, Char_t ring, UShort_t sector,
383 // Get strip range read out
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));
392 //__________________________________________________________________
394 AliFMDParameters::GetMaxStrip(UShort_t det, Char_t ring, UShort_t sector,
397 // Get strip range read out
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));
406 //__________________________________________________________________
408 AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring,
409 UShort_t sector, UShort_t strip) const
412 if (!fPedestal) return fFixedPedestal;
413 AliDebug(50, Form("pedestal for FMD%d%c[%2d,%3d]=%f",
414 detector, ring, sector, strip,
415 fPedestal->Value(detector, ring, sector, strip)));
416 return fPedestal->Value(detector, ring, sector, strip);
419 //__________________________________________________________________
421 AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring,
422 UShort_t sector, UShort_t strip) const
425 if (!fPedestal) return fFixedPedestalWidth;
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)));
429 return fPedestal->Width(detector, ring, sector, strip);
432 //__________________________________________________________________
434 AliFMDParameters::GetAltroMap() const
436 // Get the hardware address to detector index map
441 //__________________________________________________________________
443 AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
444 Char_t& ring, UShort_t& sec,
447 // Map hardware address to detector index
448 if (!fAltroMap) return kFALSE;
449 return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
452 //__________________________________________________________________
454 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
455 UShort_t str, UInt_t& ddl,
458 // Map detector index to hardware address
459 if (!fAltroMap) return kFALSE;
460 return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
464 //__________________________________________________________________
466 AliFMDParameters::GetEdepMip() const
468 // Get energy deposited by a MIP in the silicon sensors
470 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
471 fEdepMip = (fkSiDeDxMip
472 * fmd->GetRing('I')->GetSiThickness()
473 * fmd->GetSiDensity());
482 //____________________________________________________________________