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