]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDParameters.cxx
Small patch for file copying for special outputs in proof mode (M.Vala)
[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.
6169f936 27// The manager normally serves the parameters from the Conditions
28// Database (CDB). These are retrivied by the member function
29// `Init'. Optionally, the class can serve hard-coded constants, if
30// no CDB is available.
1a1fdef7 31//
f95a63c4 32#include "AliFMDDebug.h" // ALILOG_H
8f6ee336 33#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
34#include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
35#include "AliFMDRing.h" // ALIFMDRING_H
36#include "AliFMDCalibGain.h" // ALIFMDCALIBGAIN_H
37#include "AliFMDCalibPedestal.h" // ALIFMDCALIBPEDESTAL_H
c2fc1258 38#include "AliFMDCalibSampleRate.h" // ALIFMDCALIBSAMPLERATE_H
39#include "AliFMDCalibStripRange.h" // ALIFMDCALIBSTRIPRANGE_H
57c3c593 40#include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
41#include <AliCDBManager.h> // ALICDBMANAGER_H
42#include <AliCDBEntry.h> // ALICDBMANAGER_H
dc02d468 43#include <AliFMDPreprocessor.h>
44#include <AliLog.h>
1a1fdef7 45#include <Riostream.h>
8ec606c2 46#include <sstream>
dc02d468 47#include <TSystem.h>
6169f936 48#include <TArrayF.h>
49#include <TH2D.h>
1a1fdef7 50
51//====================================================================
52ClassImp(AliFMDParameters)
53#if 0
54 ; // This is here to keep Emacs for indenting the next line
55#endif
56
57//____________________________________________________________________
58AliFMDParameters* AliFMDParameters::fgInstance = 0;
59
57c3c593 60//____________________________________________________________________
77186f44 61const char* AliFMDParameters::fgkPulseGain = "FMD/Calib/PulseGain";
62const char* AliFMDParameters::fgkPedestal = "FMD/Calib/Pedestal";
63const char* AliFMDParameters::fgkDead = "FMD/Calib/Dead";
64const char* AliFMDParameters::fgkSampleRate = "FMD/Calib/SampleRate";
65const char* AliFMDParameters::fgkAltroMap = "FMD/Calib/AltroMap";
66const char* AliFMDParameters::fgkZeroSuppression = "FMD/Calib/ZeroSuppression";
67const char* AliFMDParameters::fgkStripRange = "FMD/Calib/StripRange";
68const char* AliFMDParameters::fkPedestalShuttleID = "pedestals";
69const char* AliFMDParameters::fkGainShuttleID = "gains";
70const char* AliFMDParameters::fkConditionsShuttleID = "conditions";
57c3c593 71
1a1fdef7 72//____________________________________________________________________
73AliFMDParameters*
74AliFMDParameters::Instance()
75{
76 // Get static instance
77 if (!fgInstance) fgInstance = new AliFMDParameters;
78 return fgInstance;
79}
80
81//____________________________________________________________________
82AliFMDParameters::AliFMDParameters()
57c3c593 83 : fIsInit(kFALSE),
02a27b50 84 fkSiDeDxMip(1.664),
b5ee4425 85 fVA1MipRange(0),
86 fAltroChannelSize(0),
87 fChannelsPerAltro(0),
88 fPedestalFactor(0),
89 fFixedPedestal(0),
90 fFixedPedestalWidth(0),
91 fFixedZeroSuppression(0),
92 fFixedSampleRate(0),
93 fFixedThreshold(0),
94 fFixedMinStrip(0),
95 fFixedMaxStrip(0),
8f6ee336 96 fFixedPulseGain(0),
97 fEdepMip(0),
625d7886 98 fHasCompleteHeader(kTRUE),
8f6ee336 99 fZeroSuppression(0),
100 fSampleRate(0),
101 fPedestal(0),
102 fPulseGain(0),
57c3c593 103 fDeadMap(0),
c2fc1258 104 fAltroMap(0),
105 fStripRange(0)
1a1fdef7 106{
107 // Default constructor
108 SetVA1MipRange();
109 SetAltroChannelSize();
110 SetChannelsPerAltro();
111 SetZeroSuppression();
112 SetSampleRate();
113 SetPedestal();
114 SetPedestalWidth();
115 SetPedestalFactor();
8f6ee336 116 SetThreshold();
c2fc1258 117 SetStripRange();
06ca6759 118 fAltroMap = new AliFMDAltroMapping;
1a1fdef7 119}
120
57c3c593 121//__________________________________________________________________
122void
f6449cc0 123AliFMDParameters::Init(Bool_t forceReInit, UInt_t what)
57c3c593 124{
125 // Initialize the parameters manager. We need to get stuff from the
126 // CDB here.
a9579262 127 if (forceReInit) fIsInit = kFALSE;
57c3c593 128 if (fIsInit) return;
f6449cc0 129 if (what & kPulseGain) InitPulseGain();
130 if (what & kPedestal) InitPedestal();
131 if (what & kDeadMap) InitDeadMap();
132 if (what & kSampleRate) InitSampleRate();
133 if (what & kZeroSuppression) InitZeroSuppression();
134 if (what & kAltroMap) InitAltroMap();
6bf06d81 135 if (what & kStripRange) InitStripRange();
1e8f773e 136 fIsInit = kTRUE;
dc02d468 137}
138//__________________________________________________________________
139void
140AliFMDParameters::Init(AliFMDPreprocessor* pp, Bool_t forceReInit, UInt_t what)
141{
142 // Initialize the parameters manager. We need to get stuff from the
143 // CDB here.
144 if (forceReInit) fIsInit = kFALSE;
145 if (fIsInit) return;
146 if (what & kPulseGain) InitPulseGain(pp);
147 if (what & kPedestal) InitPedestal(pp);
148 if (what & kDeadMap) InitDeadMap(pp);
149 if (what & kSampleRate) InitSampleRate(pp);
150 if (what & kZeroSuppression) InitZeroSuppression(pp);
151 if (what & kAltroMap) InitAltroMap(pp);
6bf06d81 152 if (what & kStripRange) InitStripRange(pp);
dc02d468 153 fIsInit = kTRUE;
1e8f773e 154}
c2fc1258 155
6169f936 156//__________________________________________________________________
157#define DET2IDX(det,ring,sec,str) \
a9579262 158 (det * 1000 + (ring == 'I' ? 0 : 512) + str)
6169f936 159
160//__________________________________________________________________
161void
162AliFMDParameters::Draw(Option_t* option)
163{
164 TString opt(option);
165 enum {
458e52e8 166 kLocalPulseGain, // Path to PulseGain calib object
167 kLocalThreshold, // Path to PulseGain calib object
168 kLocalPedestal, // Path to Pedestal calib object
169 kLocalPedestalWidth, // Path to Pedestal calib object
170 kLocalDead, // Path to Dead calib object
171 kLocalSampleRate, // Path to SampleRate calib object
172 kLocalAltroMap, // Path to AltroMap calib object
173 kLocalZeroSuppression, // Path to ZeroSuppression cal object
174 kLocalMinStripRange, // Path to strip range cal object
175 kLocalMaxStripRange // Path to strip range cal object
6169f936 176 } what;
6169f936 177
178 if (opt.Contains("dead", TString::kIgnoreCase))
458e52e8 179 what = kLocalDead;
6169f936 180 else if (opt.Contains("threshold",TString::kIgnoreCase))
458e52e8 181 what = kLocalThreshold;
6169f936 182 else if (opt.Contains("gain",TString::kIgnoreCase))
458e52e8 183 what = kLocalPulseGain;
6169f936 184 else if (opt.Contains("pedestal",TString::kIgnoreCase))
458e52e8 185 what = kLocalPedestal;
6169f936 186 else if (opt.Contains("noise",TString::kIgnoreCase))
458e52e8 187 what = kLocalPedestalWidth;
6169f936 188 else if (opt.Contains("zero",TString::kIgnoreCase))
458e52e8 189 what = kLocalZeroSuppression;
6169f936 190 else if (opt.Contains("rate",TString::kIgnoreCase))
458e52e8 191 what = kLocalSampleRate;
6169f936 192 else if (opt.Contains("min",TString::kIgnoreCase))
458e52e8 193 what = kLocalMinStripRange;
6169f936 194 else if (opt.Contains("max",TString::kIgnoreCase))
458e52e8 195 what = kLocalMaxStripRange;
6169f936 196 else if (opt.Contains("map",TString::kIgnoreCase))
458e52e8 197 what = kLocalAltroMap;
6169f936 198 else {
199 Warning("Draw", "unknown parameter: %s\n\tShould be one of\n\t"
200 "dead, threshold, gain, pedestal, noise, zero, rate, "
201 "min, max, map",
202 option);
203 return;
204 }
205
206 TArrayD xbins(3 * 512 + 2 * 256 + 5);
207 Int_t i = 1;
208 Bool_t skip = kTRUE;
209 for (UShort_t det = 1; det <= 3; det++) {
210 UShort_t nRings = (det == 1 ? 1 : 2);
211 for (UShort_t iring = 0; iring < nRings; iring++) {
212 UShort_t nStrip = (iring == 0 ? 512 : 256);
213 Char_t ring = (iring == 0 ? 'I' : 'O');
214 for (UShort_t str = 0; str < nStrip; str++) {
a9579262 215 // UShort_t nSec = (iring == 0 ? 20 : 40);
216 // Char_t ring = (iring == 0 ? 'I' : 'O');
217 // for (UShort_t sec = 0; sec < nSec; sec++) {
6169f936 218 Int_t idx = DET2IDX(det, ring, 0, str);
a9579262 219 // Int_t idx = DET2IDX(det, ring, sec, 0);
6169f936 220 if (skip) {
221 xbins[i-1] = idx - .5;
222 skip = kFALSE;
223 }
224 xbins[i] = idx + .5;
225 i++;
226 }
227 skip = kTRUE;
228 i++;
229 }
230 }
231 TArrayD ybins(41);
458e52e8 232 for (/*Int_t*/ i = 0; i < ybins.fN; i++) ybins[i] = Float_t(i - .5);
6169f936 233 TH2D* hist = new TH2D("calib", Form("Calibration %s", option),
234 xbins.fN-1, xbins.fArray,
235 ybins.fN-1, ybins.fArray);
a9579262 236 hist->GetXaxis()->SetTitle("1000 #times detector + 512 #times ring + strip");
237 hist->GetYaxis()->SetTitle("sector");
238
6169f936 239 // hist->Draw("Lego");
240 // return;
241
242 for (UShort_t det = 1; det <= 3; det++) {
243 UShort_t nRings = (det == 1 ? 1 : 2);
244 for (UShort_t iring = 0; iring < nRings; iring++) {
245 UShort_t nSector = (iring == 0 ? 20 : 40);
246 UShort_t nStrip = (iring == 0 ? 512 : 256);
247 Char_t ring = (iring == 0 ? 'I' : 'O');
248 for (UShort_t sec = 0; sec < nSector; sec++) {
249 for (UShort_t str = 0; str < nStrip; str++) {
250 Int_t idx = DET2IDX(det, ring, sec, str);
251 UInt_t ddl, addr;
252 Double_t val = 0;
253 switch (what) {
458e52e8 254 case kLocalPulseGain: // Path to PulseGain calib object
6169f936 255 val = GetPulseGain(det,ring,sec,str); break;
458e52e8 256 case kLocalThreshold: // Path to PulseGain calib object
6169f936 257 val = GetThreshold(); break;
458e52e8 258 case kLocalPedestal: // Path to Pedestal calib object
6169f936 259 val = GetPedestal(det,ring,sec,str); break;
458e52e8 260 case kLocalPedestalWidth: // Path to Pedestal calib object
6169f936 261 val = GetPedestalWidth(det,ring,sec,str); break;
458e52e8 262 case kLocalDead: // Path to Dead calib object
6169f936 263 val = IsDead(det,ring,sec,str); break;
458e52e8 264 case kLocalSampleRate: // Path to SampleRate calib object
6169f936 265 val = GetSampleRate(det,ring,sec,str); break;
458e52e8 266 case kLocalAltroMap: // Path to AltroMap calib object
6169f936 267 Detector2Hardware(det,ring,sec,str, ddl, addr);
268 val = addr; break;
458e52e8 269 case kLocalZeroSuppression: // Path to ZeroSuppression cal object
6169f936 270 val = GetZeroSuppression(det,ring,sec,str); break;
458e52e8 271 case kLocalMinStripRange: // Path to strip range cal object
6169f936 272 val = GetMinStrip(det,ring,sec,str); break;
458e52e8 273 case kLocalMaxStripRange: // Path to strip range cal object
6169f936 274 val = GetMaxStrip(det,ring,sec,str); break;
275 }
276 hist->Fill(idx,sec,val);
a9579262 277 // hist->Fill(idx,str,val);
6169f936 278 }
279 }
280 }
281 }
282 hist->Draw("lego");
283}
284
c2fc1258 285//__________________________________________________________________
286void
287AliFMDParameters::Print(Option_t* option) const
288{
02a27b50 289 // Print information.
290 // If option contains an 'A' then everything is printed.
a9579262 291 // If the option contains the string "FMD" the function will search
292 // for detector, ring, sector, and strip numbers to print, in the
293 // format
294 //
295 // FMD<detector><ring>[<sector>,<string>]
296 //
297 // The wild card '*' means all of <detector>, <ring>, <sector>, or
298 // <strip>.
c2fc1258 299 TString opt(option);
a9579262 300 Bool_t showStrips = opt.Contains("a", TString::kIgnoreCase);
301 UShort_t ds[] = { 1, 2, 3, 0 };
302 Char_t rs[] = { 'I', 'O', '\0' };
303 UShort_t minStrip = 0;
304 UShort_t maxStrip = 512;
305 UShort_t minSector = 0;
306 UShort_t maxSector = 40;
307
308
8ec606c2 309 if (opt.Contains("fmd",TString::kIgnoreCase)) {
7868d9e2 310 Int_t i = opt.Index("fmd",TString::kIgnoreCase);
311 Int_t j = opt.Index("]",TString::kIgnoreCase);
312 if (j != kNPOS)
313 showStrips = kTRUE;
314 else
315 j = opt.Length();
a9579262 316 enum {
97e94238 317 kReadDet,
318 kReadRing,
319 kReadLbrack,
320 kReadSector,
321 kReadComma,
322 kReadStrip,
323 kReadRbrack,
324 kEnd
325 } state = kReadDet;
8ec606c2 326 std::stringstream s(opt(i+4, j-i-3).Data());
97e94238 327 while (state != kEnd) {
a9579262 328 Char_t tmp = s.peek();
329 if (tmp == ' ' || tmp == '\t') {
330 s.get();
331 continue;
332 }
333 switch (state) {
97e94238 334 case kReadDet: { // First, try to kRead the detector
a9579262 335 if (tmp == '*') s.get();
336 else {
337 UShort_t det;
338 s >> det;
339 if (!s.bad()) {
340 ds[0] = det;
341 ds[1] = 0;
342 }
343 }
97e94238 344 state = (s.bad() ? kEnd : kReadRing);
a9579262 345 } break;
97e94238 346 case kReadRing: { // Then try to read the ring;
a9579262 347 Char_t ring;
348 s >> ring;
349 if (ring != '*' && !s.bad()) {
350 rs[0] = ring;
351 rs[1] = '\0';
352 }
97e94238 353 state = (s.bad() ? kEnd : kReadLbrack);
a9579262 354 } break;
97e94238 355 case kReadLbrack: { // Try to read a left bracket
a9579262 356 Char_t lbrack;
357 s >> lbrack;
97e94238 358 state = (s.bad() ? kEnd : kReadSector);
a9579262 359 } break;
97e94238 360 case kReadSector: { // Try to read a sector
a9579262 361 if (tmp == '*') s.get();
362 else {
363 UShort_t sec;
364 s >> sec;
365 if (!s.bad()) {
366 minSector = sec;
367 maxSector = sec + 1;
368 }
369 }
97e94238 370 state = (s.bad() ? kEnd : kReadComma);
a9579262 371 } break;
97e94238 372 case kReadComma: { // Try to read a left bracket
a9579262 373 Char_t comma;
374 s >> comma;
97e94238 375 state = (s.bad() ? kEnd : kReadStrip);
a9579262 376 } break;
97e94238 377 case kReadStrip: { // Try to read a strip
a9579262 378 if (tmp == '*') s.get();
379 else {
380 UShort_t str;
381 s >> str;
382 if (!s.bad()) {
383 minStrip = str;
384 maxStrip = str + 1;
385 }
386 }
97e94238 387 state = (s.bad() ? kEnd : kReadRbrack);
a9579262 388 } break;
97e94238 389 case kReadRbrack: { // Try to read a left bracket
a9579262 390 Char_t rbrack;
391 s >> rbrack;
97e94238 392 state = kEnd;
a9579262 393 } break;
97e94238 394 case kEnd:
a9579262 395 break;
396 }
397 }
8ec606c2 398 }
a9579262 399 UShort_t* dp = ds;
400 UShort_t det;
401 while ((det = *(dp++))) {
402
403 Char_t* rp = rs;
404 Char_t ring;
405 while ((ring = *(rp++))) {
406 if (det == 1 && ring == 'O') continue;
407 UShort_t min = GetMinStrip(det, ring, 0, 0);
408 UShort_t max = GetMaxStrip(det, ring, 0, 0);
409 UShort_t rate = GetSampleRate(det, ring, 0, 0);
410 std::cout << "FMD" << det << ring
411 << " Strip range: "
412 << std::setw(3) << min << ","
413 << std::setw(3) << max << " Rate: "
414 << std::setw(2) << rate << std::endl;
415
416 if (!showStrips) continue;
417 UShort_t nSec = ( ring == 'I' ? 20 : 40 );
418 UShort_t nStr = ( ring == 'I' ? 512 : 256 );
419 for (UShort_t sec = minSector; sec < maxSector && sec < nSec; sec++) {
c2fc1258 420 std::cout
8ec606c2 421 << " Strip | Pedestal | Gain | ZS thr. | Address\n"
422 << "--------+-------------------+------------+---------+---------"
c2fc1258 423 << std::endl;
a9579262 424 for (UShort_t str = minStrip; str < nStr && str < maxStrip; str++) {
425 if (str == minStrip) std::cout << std::setw(3) << sec << ",";
426 else std::cout << " ";
427 std::cout << std::setw(3) << str << " | ";
428 if (IsDead(det, ring, sec, str)) {
c2fc1258 429 std::cout << "dead" << std::endl;
430 continue;
431 }
432 UInt_t ddl, addr;
a9579262 433 Detector2Hardware(det, ring, sec, str, ddl, addr);
434 std::cout << std::setw(7) << GetPedestal(det, ring, sec, str)
c2fc1258 435 << "+/-" << std::setw(7)
a9579262 436 << GetPedestalWidth(det, ring, sec, str)
8ec606c2 437 << " | " << std::setw(10)
a9579262 438 << GetPulseGain(det, ring, sec, str)
439 << " | " << std::setw(7)
440 << GetZeroSuppression(det, ring, sec, str)
c2fc1258 441 << " | 0x" << std::hex << std::setw(4)
442 << std::setfill('0') << ddl << ",0x" << std::setw(3)
443 << addr << std::dec << std::setfill(' ') << std::endl;
a9579262 444 } // for (strip)
445 } // for (sector)
446 std::cout
447 << "============================================================="
448 << std::endl;
449 } // while (ring)
450 } // while (det)
451
c2fc1258 452}
453
454//__________________________________________________________________
455void
456AliFMDParameters::SetStripRange(UShort_t min, UShort_t max)
457{
02a27b50 458 // Set fixed strip range
c2fc1258 459 fFixedMinStrip = min;
460 fFixedMaxStrip = max;
461}
462
dc02d468 463//__________________________________________________________________
464AliCDBEntry*
465AliFMDParameters::GetEntry(const char* path, AliFMDPreprocessor* pp,
466 Bool_t fatal) const
467{
468 // Get an entry from the CDB or via preprocessor
469 AliCDBEntry* entry = 0;
470 if (!pp) {
471 AliCDBManager* cdb = AliCDBManager::Instance();
472 entry = cdb->Get(path);
473 }
474 else {
475 const char* third = gSystem->BaseName(path);
476 const char* second = gSystem->BaseName(gSystem->DirName(path));
477 entry = pp->GetFromCDB(second, third);
478 }
479 if (!entry) {
480 TString msg(Form("No %s found in CDB, perhaps you need to "
481 "use AliFMDCalibFaker?", path));
482 if (fatal) { AliFatal(msg.Data()); }
483 else AliLog::Message(AliLog::kWarning, msg.Data(), "FMD",
484 "AliFMDParameters", "GetEntry", __FILE__,
485 __LINE__);
486 return 0;
487 }
488 return entry;
489}
490
491
1e8f773e 492//__________________________________________________________________
493void
dc02d468 494AliFMDParameters::InitPulseGain(AliFMDPreprocessor* pp)
1e8f773e 495{
02a27b50 496 // Get pulse gain from CDB or used fixed
dc02d468 497 AliCDBEntry* gain = GetEntry(fgkPulseGain, pp);
498 if (!gain) return;
57c3c593 499
42f1b2f5 500 AliFMDDebug(5, ("Got gain from CDB"));
1e8f773e 501 fPulseGain = dynamic_cast<AliFMDCalibGain*>(gain->GetObject());
f95a63c4 502 if (!fPulseGain) AliFatal("Invalid pulser gain object from CDB");
1e8f773e 503}
504//__________________________________________________________________
505void
dc02d468 506AliFMDParameters::InitPedestal(AliFMDPreprocessor* pp)
1e8f773e 507{
02a27b50 508 // Initialize the pedestals from CDB
dc02d468 509 AliCDBEntry* pedestal = GetEntry(fgkPedestal, pp);
510 if (!pedestal) return;
511
42f1b2f5 512 AliFMDDebug(5, ("Got pedestal from CDB"));
1e8f773e 513 fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject());
f95a63c4 514 if (!fPedestal) AliFatal("Invalid pedestal object from CDB");
1e8f773e 515}
516
517//__________________________________________________________________
518void
dc02d468 519AliFMDParameters::InitDeadMap(AliFMDPreprocessor* pp)
1e8f773e 520{
02a27b50 521 // Get Dead-channel-map from CDB
dc02d468 522 AliCDBEntry* deadMap = GetEntry(fgkDead, pp);
523 if (!deadMap) return;
524
42f1b2f5 525 AliFMDDebug(5, ("Got dead map from CDB"));
1e8f773e 526 fDeadMap = dynamic_cast<AliFMDCalibDeadMap*>(deadMap->GetObject());
f95a63c4 527 if (!fDeadMap) AliFatal("Invalid dead map object from CDB");
1e8f773e 528}
529
530//__________________________________________________________________
531void
dc02d468 532AliFMDParameters::InitZeroSuppression(AliFMDPreprocessor* pp)
1e8f773e 533{
02a27b50 534 // Get 0-suppression from CDB
dc02d468 535 AliCDBEntry* zeroSup = GetEntry(fgkZeroSuppression, pp);
536 if (!zeroSup) return;
42f1b2f5 537 AliFMDDebug(5, ("Got zero suppression from CDB"));
1e8f773e 538 fZeroSuppression =
539 dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject());
f95a63c4 540 if (!fZeroSuppression)AliFatal("Invalid zero suppression object from CDB");
1e8f773e 541}
542
543//__________________________________________________________________
544void
dc02d468 545AliFMDParameters::InitSampleRate(AliFMDPreprocessor* pp)
1e8f773e 546{
02a27b50 547 // get Sample rate from CDB
dc02d468 548 AliCDBEntry* sampRat = GetEntry(fgkSampleRate, pp);
549 if (!sampRat) return;
42f1b2f5 550 AliFMDDebug(5, ("Got zero suppression from CDB"));
1e8f773e 551 fSampleRate = dynamic_cast<AliFMDCalibSampleRate*>(sampRat->GetObject());
f95a63c4 552 if (!fSampleRate) AliFatal("Invalid zero suppression object from CDB");
1e8f773e 553}
554
555//__________________________________________________________________
556void
dc02d468 557AliFMDParameters::InitAltroMap(AliFMDPreprocessor* pp)
1e8f773e 558{
02a27b50 559 // Get hardware mapping from CDB
06ca6759 560 if (fAltroMap) {
561 delete fAltroMap;
562 fAltroMap = 0;
563 }
458e52e8 564 AliCDBEntry* hwMap = GetEntry(fgkAltroMap, pp, kFALSE);
dc02d468 565 if (!hwMap) return;
566
42f1b2f5 567 AliFMDDebug(5, ("Got ALTRO map from CDB"));
1e8f773e 568 fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject());
569 if (!fAltroMap) {
f95a63c4 570 AliFatal("Invalid ALTRO map object from CDB");
1e8f773e 571 fAltroMap = new AliFMDAltroMapping;
57c3c593 572 }
57c3c593 573}
574
c2fc1258 575//__________________________________________________________________
576void
dc02d468 577AliFMDParameters::InitStripRange(AliFMDPreprocessor* pp)
c2fc1258 578{
02a27b50 579 // Get strips read-out from CDB
dc02d468 580 AliCDBEntry* range = GetEntry(fgkStripRange, pp);
581 if (!range) return;
42f1b2f5 582 AliFMDDebug(5, ("Got strip range from CDB"));
c2fc1258 583 fStripRange = dynamic_cast<AliFMDCalibStripRange*>(range->GetObject());
f95a63c4 584 if (!fStripRange) AliFatal("Invalid strip range object from CDB");
c2fc1258 585}
586
1e8f773e 587
8f6ee336 588//__________________________________________________________________
589Float_t
590AliFMDParameters::GetThreshold() const
591{
02a27b50 592 // Get threshold from CDB
8f6ee336 593 if (!fPulseGain) return fFixedThreshold;
594 return fPulseGain->Threshold();
595}
596
597//__________________________________________________________________
598Float_t
599AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring,
600 UShort_t sector, UShort_t strip) const
601{
602 // Returns the pulser calibrated gain for strip # strip in sector #
603 // sector or ring id ring of detector # detector.
604 //
605 // For simulation, this is normally set to
606 //
607 // VA1_MIP_Range
608 // ------------------ * MIP_Energy_Loss
609 // ALTRO_channel_size
610 //
611 if (!fPulseGain) {
612 if (fFixedPulseGain <= 0)
613 fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize;
614 return fFixedPulseGain;
615 }
f95a63c4 616 AliFMDDebug(50, ("pulse gain for FMD%d%c[%2d,%3d]=%f",
1e8f773e 617 detector, ring, sector, strip,
618 fPulseGain->Value(detector, ring, sector, strip)));
8f6ee336 619 return fPulseGain->Value(detector, ring, sector, strip);
620}
621
622//__________________________________________________________________
623Bool_t
624AliFMDParameters::IsDead(UShort_t detector, Char_t ring,
625 UShort_t sector, UShort_t strip) const
626{
02a27b50 627 // Check if the channel is dead
8f6ee336 628 if (!fDeadMap) return kFALSE;
f95a63c4 629 AliFMDDebug(50, ("Dead for FMD%d%c[%2d,%3d]=%s",
1e8f773e 630 detector, ring, sector, strip,
631 fDeadMap->operator()(detector, ring, sector, strip) ?
632 "no" : "yes"));
8f6ee336 633 return fDeadMap->operator()(detector, ring, sector, strip);
634}
635
636//__________________________________________________________________
637UShort_t
638AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring,
639 UShort_t sector, UShort_t strip) const
640{
02a27b50 641 // Get zero suppression threshold
8f6ee336 642 if (!fZeroSuppression) return fFixedZeroSuppression;
643 // Need to map strip to ALTRO chip.
f95a63c4 644 AliFMDDebug(50, ("zero sup. for FMD%d%c[%2d,%3d]=%f",
1e8f773e 645 detector, ring, sector, strip,
646 fZeroSuppression->operator()(detector, ring,
647 sector, strip)));
8f6ee336 648 return fZeroSuppression->operator()(detector, ring, sector, strip/128);
649}
650
651//__________________________________________________________________
652UShort_t
c2fc1258 653AliFMDParameters::GetSampleRate(UShort_t det, Char_t ring, UShort_t sector,
654 UShort_t str) const
8f6ee336 655{
02a27b50 656 // Get sampl rate
8f6ee336 657 if (!fSampleRate) return fFixedSampleRate;
658 // Need to map sector to digitizier card.
c2fc1258 659 UInt_t ret = fSampleRate->Rate(det, ring, sector, str);
f95a63c4 660 AliFMDDebug(50, ("Sample rate for FMD%d%c[%2d,%3d]=%d",
c2fc1258 661 det, ring, sector, str, ret));
662 return ret;
663}
664
665//__________________________________________________________________
666UShort_t
667AliFMDParameters::GetMinStrip(UShort_t det, Char_t ring, UShort_t sector,
668 UShort_t str) const
669{
02a27b50 670 // Get strip range read out
c2fc1258 671 if (!fStripRange) return fFixedMinStrip;
672 // Need to map sector to digitizier card.
673 UInt_t ret = fStripRange->Min(det, ring, sector, str);
f95a63c4 674 AliFMDDebug(50, ("Min strip # for FMD%d%c[%2d,%3d]=%d",
c2fc1258 675 det, ring, sector, str, ret));
676 return ret;
677}
678
679//__________________________________________________________________
680UShort_t
681AliFMDParameters::GetMaxStrip(UShort_t det, Char_t ring, UShort_t sector,
682 UShort_t str) const
683{
02a27b50 684 // Get strip range read out
c2fc1258 685 if (!fStripRange) return fFixedMaxStrip;
686 // Need to map sector to digitizier card.
687 UInt_t ret = fStripRange->Max(det, ring, sector, str);
f95a63c4 688 AliFMDDebug(50, ("Max strip # for FMD%d%c[%2d,%3d]=%d",
c2fc1258 689 det, ring, sector, str, ret));
690 return ret;
8f6ee336 691}
1a1fdef7 692
8f6ee336 693//__________________________________________________________________
694Float_t
695AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring,
696 UShort_t sector, UShort_t strip) const
697{
02a27b50 698 // Get the pedesal
8f6ee336 699 if (!fPedestal) return fFixedPedestal;
f95a63c4 700 AliFMDDebug(50, ("pedestal for FMD%d%c[%2d,%3d]=%f",
1e8f773e 701 detector, ring, sector, strip,
702 fPedestal->Value(detector, ring, sector, strip)));
8f6ee336 703 return fPedestal->Value(detector, ring, sector, strip);
704}
705
706//__________________________________________________________________
707Float_t
708AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring,
709 UShort_t sector, UShort_t strip) const
710{
02a27b50 711 // Get the pedesal
8f6ee336 712 if (!fPedestal) return fFixedPedestalWidth;
f95a63c4 713 AliFMDDebug(50, ("pedetal width for FMD%d%c[%2d,%3d]=%f",
1e8f773e 714 detector, ring, sector, strip,
715 fPedestal->Width(detector, ring, sector, strip)));
8f6ee336 716 return fPedestal->Width(detector, ring, sector, strip);
717}
718
1a1fdef7 719//__________________________________________________________________
57c3c593 720AliFMDAltroMapping*
721AliFMDParameters::GetAltroMap() const
722{
02a27b50 723 // Get the hardware address to detector index map
57c3c593 724 return fAltroMap;
1a1fdef7 725}
726
57c3c593 727
bf000c32 728//__________________________________________________________________
729Bool_t
f6449cc0 730AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t board,
731 UInt_t chip, UInt_t chan,
732 UShort_t& det, Char_t& ring,
733 UShort_t& sec, UShort_t& str) const
734{
735 // Map hardware address to detector index
736 if (!fAltroMap) return kFALSE;
737 return fAltroMap->Hardware2Detector(ddl,board,chip,chan, det,ring,sec,str);
738}
739//__________________________________________________________________
740Bool_t
741AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t addr,
742 UShort_t& det, Char_t& ring,
743 UShort_t& sec, UShort_t& str) const
bf000c32 744{
02a27b50 745 // Map hardware address to detector index
57c3c593 746 if (!fAltroMap) return kFALSE;
747 return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
bf000c32 748}
749
750//__________________________________________________________________
751Bool_t
f6449cc0 752AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
753 UShort_t sec, UShort_t str,
754 UInt_t& ddl, UInt_t& board,
755 UInt_t& chip, UInt_t& chan) const
756{
757 // Map detector index to hardware address
758 if (!fAltroMap) return kFALSE;
759 return fAltroMap->Detector2Hardware(det,ring,sec,str, ddl,board,chip,chan);
760}
761
762//__________________________________________________________________
763Bool_t
764AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
765 UShort_t sec, UShort_t str,
766 UInt_t& ddl, UInt_t& addr) const
bf000c32 767{
02a27b50 768 // Map detector index to hardware address
57c3c593 769 if (!fAltroMap) return kFALSE;
770 return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
bf000c32 771}
772
57c3c593 773
774//__________________________________________________________________
775Float_t
776AliFMDParameters::GetEdepMip() const
777{
778 // Get energy deposited by a MIP in the silicon sensors
779 if (fEdepMip <= 0){
780 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
02a27b50 781 fEdepMip = (fkSiDeDxMip
57c3c593 782 * fmd->GetRing('I')->GetSiThickness()
783 * fmd->GetSiDensity());
784 }
785 return fEdepMip;
786}
787
788
bf000c32 789
790
791
1a1fdef7 792//____________________________________________________________________
793//
794// EOF
795//