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
120 Bool_t showStrips = opt.Contains("a", TString::kIgnoreCase);
121 for (UShort_t det=1 ; det <= 3; det++) {
122 std::cout << "FMD" << det << std::endl;
123 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
124 for (Char_t* ring = rings; *ring != '\0'; ring++) {
125 std::cout << " Ring " << *ring << std::endl;
126 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
127 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
128 for (UShort_t sec = 0; sec < nSec; sec++) {
129 UShort_t min = GetMinStrip(det, *ring, sec, 0);
130 UShort_t max = GetMaxStrip(det, *ring, sec, 0);
131 UShort_t rate = GetSampleRate(det, *ring, sec, 0);
132 std::cout << " Sector " << std::setw(2) << sec
133 << " Strip range: " << std::setw(3) << min << ","
134 << std::setw(3) << max << " Rate: " << std::setw(2)
135 << rate << std::endl;
136 if (!showStrips) continue;
138 << " Strip | Pedestal | Gain | ZS thr. | Address\n"
139 << "--------+-------------------+----------+---------+---------"
141 for (UShort_t str = 0; str < nStr; str++) {
142 std::cout << " " << std::setw(3) << str << " | ";
143 if (IsDead(det, *ring, sec, str)) {
144 std::cout << "dead" << std::endl;
148 Detector2Hardware(det, *ring, sec, str, ddl, addr);
149 std::cout << std::setw(7) << GetPedestal(det, *ring, sec, str)
150 << "+/-" << std::setw(7)
151 << GetPedestalWidth(det, *ring, sec, str)
152 << " | " << std::setw(8)
153 << GetPulseGain(det, *ring, sec, str)
154 << " | " << std::setw(5)
155 << GetZeroSuppression(det, *ring, sec, str)
156 << " | 0x" << std::hex << std::setw(4)
157 << std::setfill('0') << ddl << ",0x" << std::setw(3)
158 << addr << std::dec << std::setfill(' ') << std::endl;
165 //__________________________________________________________________
167 AliFMDParameters::SetStripRange(UShort_t min, UShort_t max)
169 fFixedMinStrip = min;
170 fFixedMaxStrip = max;
173 //__________________________________________________________________
175 AliFMDParameters::InitPulseGain()
177 AliCDBManager* cdb = AliCDBManager::Instance();
178 AliCDBEntry* gain = cdb->Get(fgkPulseGain);
180 AliWarning(Form("No %s found in CDB, perhaps you need to "
181 "use AliFMDCalibFaker?", fgkPulseGain));
185 AliDebug(1, Form("Got gain from CDB"));
186 fPulseGain = dynamic_cast<AliFMDCalibGain*>(gain->GetObject());
187 if (!fPulseGain) AliWarning("Invalid pulser gain object from CDB");
189 //__________________________________________________________________
191 AliFMDParameters::InitPedestal()
193 AliCDBManager* cdb = AliCDBManager::Instance();
194 AliCDBEntry* pedestal = cdb->Get(fgkPedestal);
196 AliWarning(Form("No %s found in CDB, perhaps you need to "
197 "use AliFMDCalibFaker?", fgkPedestal));
200 AliDebug(1, Form("Got pedestal from CDB"));
201 fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject());
202 if (!fPedestal) AliWarning("Invalid pedestal object from CDB");
205 //__________________________________________________________________
207 AliFMDParameters::InitDeadMap()
209 AliCDBManager* cdb = AliCDBManager::Instance();
210 AliCDBEntry* deadMap = cdb->Get(fgkDead);
212 AliWarning(Form("No %s found in CDB, perhaps you need to "
213 "use AliFMDCalibFaker?", fgkDead));
216 AliDebug(1, Form("Got dead map from CDB"));
217 fDeadMap = dynamic_cast<AliFMDCalibDeadMap*>(deadMap->GetObject());
218 if (!fDeadMap) AliWarning("Invalid dead map object from CDB");
221 //__________________________________________________________________
223 AliFMDParameters::InitZeroSuppression()
225 AliCDBManager* cdb = AliCDBManager::Instance();
226 AliCDBEntry* zeroSup = cdb->Get(fgkZeroSuppression);
228 AliWarning(Form("No %s found in CDB, perhaps you need to "
229 "use AliFMDCalibFaker?", fgkZeroSuppression));
232 AliDebug(1, Form("Got zero suppression from CDB"));
234 dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject());
235 if (!fZeroSuppression)AliWarning("Invalid zero suppression object from CDB");
238 //__________________________________________________________________
240 AliFMDParameters::InitSampleRate()
242 AliCDBManager* cdb = AliCDBManager::Instance();
243 AliCDBEntry* sampRat = cdb->Get(fgkSampleRate);
245 AliWarning(Form("No %s found in CDB, perhaps you need to "
246 "use AliFMDCalibFaker?", fgkSampleRate));
249 AliDebug(1, Form("Got zero suppression from CDB"));
250 fSampleRate = dynamic_cast<AliFMDCalibSampleRate*>(sampRat->GetObject());
251 if (!fSampleRate) AliWarning("Invalid zero suppression object from CDB");
254 //__________________________________________________________________
256 AliFMDParameters::InitAltroMap()
258 AliCDBManager* cdb = AliCDBManager::Instance();
259 AliCDBEntry* hwMap = cdb->Get(fgkAltroMap);
261 AliWarning(Form("No %s found in CDB, perhaps you need to "
262 "use AliFMDCalibFaker?", fgkAltroMap));
263 fAltroMap = new AliFMDAltroMapping;
266 AliDebug(1, Form("Got ALTRO map from CDB"));
267 fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject());
269 AliWarning("Invalid ALTRO map object from CDB");
270 fAltroMap = new AliFMDAltroMapping;
274 //__________________________________________________________________
276 AliFMDParameters::InitStripRange()
278 AliCDBManager* cdb = AliCDBManager::Instance();
279 AliCDBEntry* range = cdb->Get(fgkStripRange);
281 AliWarning(Form("No %s found in CDB, perhaps you need to "
282 "use AliFMDCalibFaker?", fgkStripRange));
285 AliDebug(1, Form("Got strip range from CDB"));
286 fStripRange = dynamic_cast<AliFMDCalibStripRange*>(range->GetObject());
287 if (!fStripRange) AliWarning("Invalid strip range object from CDB");
291 //__________________________________________________________________
293 AliFMDParameters::GetThreshold() const
295 if (!fPulseGain) return fFixedThreshold;
296 return fPulseGain->Threshold();
299 //__________________________________________________________________
301 AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring,
302 UShort_t sector, UShort_t strip) const
304 // Returns the pulser calibrated gain for strip # strip in sector #
305 // sector or ring id ring of detector # detector.
307 // For simulation, this is normally set to
310 // ------------------ * MIP_Energy_Loss
311 // ALTRO_channel_size
314 if (fFixedPulseGain <= 0)
315 fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize;
316 return fFixedPulseGain;
318 AliDebug(50, Form("pulse gain for FMD%d%c[%2d,%3d]=%f",
319 detector, ring, sector, strip,
320 fPulseGain->Value(detector, ring, sector, strip)));
321 return fPulseGain->Value(detector, ring, sector, strip);
324 //__________________________________________________________________
326 AliFMDParameters::IsDead(UShort_t detector, Char_t ring,
327 UShort_t sector, UShort_t strip) const
329 if (!fDeadMap) return kFALSE;
330 AliDebug(50, Form("Dead for FMD%d%c[%2d,%3d]=%s",
331 detector, ring, sector, strip,
332 fDeadMap->operator()(detector, ring, sector, strip) ?
334 return fDeadMap->operator()(detector, ring, sector, strip);
337 //__________________________________________________________________
339 AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring,
340 UShort_t sector, UShort_t strip) const
342 if (!fZeroSuppression) return fFixedZeroSuppression;
343 // Need to map strip to ALTRO chip.
344 AliDebug(50, Form("zero sup. for FMD%d%c[%2d,%3d]=%f",
345 detector, ring, sector, strip,
346 fZeroSuppression->operator()(detector, ring,
348 return fZeroSuppression->operator()(detector, ring, sector, strip/128);
351 //__________________________________________________________________
353 AliFMDParameters::GetSampleRate(UShort_t det, Char_t ring, UShort_t sector,
356 if (!fSampleRate) return fFixedSampleRate;
357 // Need to map sector to digitizier card.
358 UInt_t ret = fSampleRate->Rate(det, ring, sector, str);
359 AliDebug(50, Form("Sample rate for FMD%d%c[%2d,%3d]=%d",
360 det, ring, sector, str, ret));
364 //__________________________________________________________________
366 AliFMDParameters::GetMinStrip(UShort_t det, Char_t ring, UShort_t sector,
369 if (!fStripRange) return fFixedMinStrip;
370 // Need to map sector to digitizier card.
371 UInt_t ret = fStripRange->Min(det, ring, sector, str);
372 AliDebug(50, Form("Min strip # for FMD%d%c[%2d,%3d]=%d",
373 det, ring, sector, str, ret));
377 //__________________________________________________________________
379 AliFMDParameters::GetMaxStrip(UShort_t det, Char_t ring, UShort_t sector,
382 if (!fStripRange) return fFixedMaxStrip;
383 // Need to map sector to digitizier card.
384 UInt_t ret = fStripRange->Max(det, ring, sector, str);
385 AliDebug(50, Form("Max strip # for FMD%d%c[%2d,%3d]=%d",
386 det, ring, sector, str, ret));
390 //__________________________________________________________________
392 AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring,
393 UShort_t sector, UShort_t strip) const
395 if (!fPedestal) return fFixedPedestal;
396 AliDebug(50, Form("pedestal for FMD%d%c[%2d,%3d]=%f",
397 detector, ring, sector, strip,
398 fPedestal->Value(detector, ring, sector, strip)));
399 return fPedestal->Value(detector, ring, sector, strip);
402 //__________________________________________________________________
404 AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring,
405 UShort_t sector, UShort_t strip) const
407 if (!fPedestal) return fFixedPedestalWidth;
408 AliDebug(50, Form("pedetal width for FMD%d%c[%2d,%3d]=%f",
409 detector, ring, sector, strip,
410 fPedestal->Width(detector, ring, sector, strip)));
411 return fPedestal->Width(detector, ring, sector, strip);
414 //__________________________________________________________________
416 AliFMDParameters::GetAltroMap() const
422 //__________________________________________________________________
424 AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
425 Char_t& ring, UShort_t& sec,
428 if (!fAltroMap) return kFALSE;
429 return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
432 //__________________________________________________________________
434 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
435 UShort_t str, UInt_t& ddl,
438 if (!fAltroMap) return kFALSE;
439 return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
443 //__________________________________________________________________
445 AliFMDParameters::GetEdepMip() const
447 // Get energy deposited by a MIP in the silicon sensors
449 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
450 fEdepMip = (fSiDeDxMip
451 * fmd->GetRing('I')->GetSiThickness()
452 * fmd->GetSiDensity());
461 //____________________________________________________________________