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