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 // 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.
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>
45 #include <Riostream.h>
51 //====================================================================
52 ClassImp(AliFMDParameters)
54 ; // This is here to keep Emacs for indenting the next line
57 //____________________________________________________________________
58 AliFMDParameters* AliFMDParameters::fgInstance = 0;
60 //____________________________________________________________________
61 const char* AliFMDParameters::fgkPulseGain = "FMD/Calib/PulseGain";
62 const char* AliFMDParameters::fgkPedestal = "FMD/Calib/Pedestal";
63 const char* AliFMDParameters::fgkDead = "FMD/Calib/Dead";
64 const char* AliFMDParameters::fgkSampleRate = "FMD/Calib/SampleRate";
65 const char* AliFMDParameters::fgkAltroMap = "FMD/Calib/AltroMap";
66 const char* AliFMDParameters::fgkZeroSuppression = "FMD/Calib/ZeroSuppression";
67 const char* AliFMDParameters::fgkStripRange = "FMD/Calib/StripRange";
68 const char* AliFMDParameters::fkPedestalShuttleID = "pedestals";
69 const char* AliFMDParameters::fkGainShuttleID = "gains";
70 const char* AliFMDParameters::fkConditionsShuttleID = "conditions";
72 //____________________________________________________________________
74 AliFMDParameters::Instance()
76 // Get static instance
77 if (!fgInstance) fgInstance = new AliFMDParameters;
81 //____________________________________________________________________
82 AliFMDParameters::AliFMDParameters()
91 fZSPedSubtract(kFALSE),
93 fFixedPedestalWidth(0),
94 fFixedZeroSuppression(0),
101 fHasCompleteHeader(kTRUE),
110 // Default constructor
112 SetAltroChannelSize();
113 SetChannelsPerAltro();
114 SetZeroSuppression();
121 fAltroMap = new AliFMDAltroMapping;
124 //__________________________________________________________________
126 AliFMDParameters::Init(Bool_t forceReInit, UInt_t what)
128 // Initialize the parameters manager. We need to get stuff from the
130 if (forceReInit) fIsInit = kFALSE;
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();
141 //__________________________________________________________________
143 AliFMDParameters::Init(AliFMDPreprocessor* pp, Bool_t forceReInit, UInt_t what)
145 // Initialize the parameters manager. We need to get stuff from the
147 if (forceReInit) fIsInit = kFALSE;
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);
159 //__________________________________________________________________
161 AliFMDParameters::CheckFile(const char* prefix,
166 f = (Form("%s%d.csv", prefix, number));
167 AliFMDDebug(5, ("Checking if %s exists in %s ...", f.Data(), path));
168 f = gSystem->Which(path, f.Data());
169 AliFMDDebug(5, ("Got back '%s'", f.Data()));
173 //__________________________________________________________________
175 AliFMDParameters::Init(const char* path, Bool_t forceReInit, UInt_t what)
177 // Initialize the parameters manager. Pedestals, gains, strip
178 // range, and sample rate is read from local comma separated value
179 // files if available. Otherwise, the calibrations are obtained
181 if (forceReInit) fIsInit = kFALSE;
184 AliFMDCalibStripRange* range = 0;
185 AliFMDCalibSampleRate* rate = 0;
186 AliFMDCalibPedestal* peds = 0;
187 AliFMDCalibGain* gains = 0;
189 for (Int_t i = 1; i <= 3; i++) {
191 if (((what & kSampleRate) || (what & kStripRange)) &&
192 CheckFile("conditions", path, i, f)) {
193 if (!rate && (what & kSampleRate)) rate = new AliFMDCalibSampleRate;
194 if (!range && (what & kStripRange)) range = new AliFMDCalibStripRange;
195 std::ifstream in(f.Data());
196 if (range) range->ReadFromFile(in);
197 if (rate) rate->ReadFromFile(in);
200 if ((what & kPedestal) && CheckFile("peds", path, i, f)) {
201 if (!peds) peds = new AliFMDCalibPedestal;
202 std::ifstream in(f.Data());
203 peds->ReadFromFile(in);
206 if ((what & kPulseGain) && CheckFile("gains", path, i, f)) {
207 if (!gains) gains = new AliFMDCalibGain;
208 std::ifstream in(f.Data());
209 gains->ReadFromFile(in);
214 if (range) what &= ~kStripRange;
215 if (rate) what &= ~kSampleRate;
216 if (peds) what &= ~kPedestal;
217 if (gains) what &= ~kPulseGain;
221 if (range) SetStripRange(range);
222 if (rate) SetSampleRate(rate);
223 if (peds) SetPedestal(peds);
224 if (gains) SetGain(gains);
229 //__________________________________________________________________
231 AliFMDParameters::MakeDeadMap(Float_t maxNoise,
236 fDeadMap = fPedestal->MakeDeadMap(maxNoise, fDeadMap);
238 fDeadMap = fPulseGain->MakeDeadMap(minGain, maxGain, fDeadMap);
240 //__________________________________________________________________
241 #define DET2IDX(det,ring,sec,str) \
242 (det * 1000 + (ring == 'I' ? 0 : 512) + str)
244 //__________________________________________________________________
246 AliFMDParameters::Draw(Option_t* option)
250 kLocalPulseGain, // Path to PulseGain calib object
251 kLocalThreshold, // Path to PulseGain calib object
252 kLocalPedestal, // Path to Pedestal calib object
253 kLocalPedestalWidth, // Path to Pedestal calib object
254 kLocalDead, // Path to Dead calib object
255 kLocalSampleRate, // Path to SampleRate calib object
256 kLocalAltroMap, // Path to AltroMap calib object
257 kLocalZeroSuppression, // Path to ZeroSuppression cal object
258 kLocalMinStripRange, // Path to strip range cal object
259 kLocalMaxStripRange // Path to strip range cal object
262 if (opt.Contains("dead", TString::kIgnoreCase))
264 else if (opt.Contains("threshold",TString::kIgnoreCase))
265 what = kLocalThreshold;
266 else if (opt.Contains("gain",TString::kIgnoreCase))
267 what = kLocalPulseGain;
268 else if (opt.Contains("pedestal",TString::kIgnoreCase))
269 what = kLocalPedestal;
270 else if (opt.Contains("noise",TString::kIgnoreCase))
271 what = kLocalPedestalWidth;
272 else if (opt.Contains("zero",TString::kIgnoreCase))
273 what = kLocalZeroSuppression;
274 else if (opt.Contains("rate",TString::kIgnoreCase))
275 what = kLocalSampleRate;
276 else if (opt.Contains("min",TString::kIgnoreCase))
277 what = kLocalMinStripRange;
278 else if (opt.Contains("max",TString::kIgnoreCase))
279 what = kLocalMaxStripRange;
280 else if (opt.Contains("map",TString::kIgnoreCase))
281 what = kLocalAltroMap;
283 Warning("Draw", "unknown parameter: %s\n\tShould be one of\n\t"
284 "dead, threshold, gain, pedestal, noise, zero, rate, "
290 TArrayD xbins(3 * 512 + 2 * 256 + 5);
293 for (UShort_t det = 1; det <= 3; det++) {
294 UShort_t nRings = (det == 1 ? 1 : 2);
295 for (UShort_t iring = 0; iring < nRings; iring++) {
296 UShort_t nStrip = (iring == 0 ? 512 : 256);
297 Char_t ring = (iring == 0 ? 'I' : 'O');
298 for (UShort_t str = 0; str < nStrip; str++) {
299 // UShort_t nSec = (iring == 0 ? 20 : 40);
300 // Char_t ring = (iring == 0 ? 'I' : 'O');
301 // for (UShort_t sec = 0; sec < nSec; sec++) {
302 Int_t idx = DET2IDX(det, ring, 0, str);
303 // Int_t idx = DET2IDX(det, ring, sec, 0);
305 xbins[i-1] = idx - .5;
316 for (/*Int_t*/ i = 0; i < ybins.fN; i++) ybins[i] = Float_t(i - .5);
317 TH2D* hist = new TH2D("calib", Form("Calibration %s", option),
318 xbins.fN-1, xbins.fArray,
319 ybins.fN-1, ybins.fArray);
320 hist->GetXaxis()->SetTitle("1000 #times detector + 512 #times ring + strip");
321 hist->GetYaxis()->SetTitle("sector");
323 // hist->Draw("Lego");
326 for (UShort_t det = 1; det <= 3; det++) {
327 UShort_t nRings = (det == 1 ? 1 : 2);
328 for (UShort_t iring = 0; iring < nRings; iring++) {
329 UShort_t nSector = (iring == 0 ? 20 : 40);
330 UShort_t nStrip = (iring == 0 ? 512 : 256);
331 Char_t ring = (iring == 0 ? 'I' : 'O');
332 for (UShort_t sec = 0; sec < nSector; sec++) {
333 for (UShort_t str = 0; str < nStrip; str++) {
334 Int_t idx = DET2IDX(det, ring, sec, str);
335 UShort_t ddl, addr, time, sam=0;
338 case kLocalPulseGain: // Path to PulseGain calib object
339 val = GetPulseGain(det,ring,sec,str); break;
340 case kLocalThreshold: // Path to PulseGain calib object
341 val = GetThreshold(); break;
342 case kLocalPedestal: // Path to Pedestal calib object
343 val = GetPedestal(det,ring,sec,str); break;
344 case kLocalPedestalWidth: // Path to Pedestal calib object
345 val = GetPedestalWidth(det,ring,sec,str); break;
346 case kLocalDead: // Path to Dead calib object
347 val = IsDead(det,ring,sec,str); break;
348 case kLocalSampleRate: // Path to SampleRate calib object
349 val = GetSampleRate(det,ring,sec,str); break;
350 case kLocalAltroMap: // Path to AltroMap calib object
351 Detector2Hardware(det,ring,sec,str,sam,ddl,addr,time);
353 case kLocalZeroSuppression: // Path to ZeroSuppression cal object
354 val = GetZeroSuppression(det,ring,sec,str); break;
355 case kLocalMinStripRange: // Path to strip range cal object
356 val = GetMinStrip(det,ring,sec,str); break;
357 case kLocalMaxStripRange: // Path to strip range cal object
358 val = GetMaxStrip(det,ring,sec,str); break;
360 hist->Fill(idx,sec,val);
361 // hist->Fill(idx,str,val);
369 //__________________________________________________________________
371 AliFMDParameters::Print(Option_t* option) const
373 // Print information.
374 // If option contains an 'A' then everything is printed.
375 // If the option contains the string "FMD" the function will search
376 // for detector, ring, sector, and strip numbers to print, in the
379 // FMD<detector><ring>[<sector>,<string>]
381 // The wild card '*' means all of <detector>, <ring>, <sector>, or
384 Bool_t showStrips = opt.Contains("a", TString::kIgnoreCase);
385 UShort_t ds[] = { 1, 2, 3, 0 };
386 Char_t rs[] = { 'I', 'O', '\0' };
387 UShort_t minStrip = 0;
388 UShort_t maxStrip = 512;
389 UShort_t minSector = 0;
390 UShort_t maxSector = 40;
393 if (opt.Contains("fmd",TString::kIgnoreCase)) {
394 Int_t i = opt.Index("fmd",TString::kIgnoreCase);
395 Int_t j = opt.Index("]",TString::kIgnoreCase);
410 std::stringstream s(opt(i+4, j-i-3).Data());
411 while (state != kEnd) {
412 Char_t tmp = s.peek();
413 if (tmp == ' ' || tmp == '\t') {
418 case kReadDet: { // First, try to kRead the detector
419 if (tmp == '*') s.get();
428 state = (s.bad() ? kEnd : kReadRing);
430 case kReadRing: { // Then try to read the ring;
433 if (ring != '*' && !s.bad()) {
437 state = (s.bad() ? kEnd : kReadLbrack);
439 case kReadLbrack: { // Try to read a left bracket
442 state = (s.bad() ? kEnd : kReadSector);
444 case kReadSector: { // Try to read a sector
445 if (tmp == '*') s.get();
454 state = (s.bad() ? kEnd : kReadComma);
456 case kReadComma: { // Try to read a left bracket
459 state = (s.bad() ? kEnd : kReadStrip);
461 case kReadStrip: { // Try to read a strip
462 if (tmp == '*') s.get();
471 state = (s.bad() ? kEnd : kReadRbrack);
473 case kReadRbrack: { // Try to read a left bracket
485 while ((det = *(dp++))) {
489 while ((ring = *(rp++))) {
490 if (det == 1 && ring == 'O') continue;
491 UShort_t min = GetMinStrip(det, ring, 0, 0);
492 UShort_t max = GetMaxStrip(det, ring, 0, 0);
493 std::cout << "FMD" << det << ring
495 << std::setw(3) << min << ","
496 << std::setw(3) << max << std::endl;
498 UShort_t nSec = ( ring == 'I' ? 20 : 40 );
499 UShort_t nStr = ( ring == 'I' ? 512 : 256 );
500 for (UShort_t sec = minSector; sec < maxSector && sec < nSec; sec++) {
502 UShort_t rate = GetSampleRate(det, ring, sec, 0);
503 std::cout << "FMD" << det << ring << "[" << std::setw(2) << sec
504 << "] sample rate: " << rate << std::endl;
506 if (!showStrips) continue;
508 << " Strip | Pedestal | Gain | ZS thr. | Address\n"
509 << "--------+-------------------+------------+---------+---------"
511 for (UShort_t str = minStrip; str < nStr && str < maxStrip; str++) {
512 if (str == minStrip) std::cout << std::setw(3) << sec << ",";
513 else std::cout << " ";
514 std::cout << std::setw(3) << str << " | ";
515 if (IsDead(det, ring, sec, str)) {
516 std::cout << "dead" << std::endl;
519 UShort_t ddl, addr, time, sam=0;
520 Detector2Hardware(det, ring, sec, str, sam, ddl, addr, time);
521 std::cout << std::setw(7) << GetPedestal(det, ring, sec, str)
522 << "+/-" << std::setw(7)
523 << GetPedestalWidth(det, ring, sec, str)
524 << " | " << std::setw(10)
525 << GetPulseGain(det, ring, sec, str)
526 << " | " << std::setw(7)
527 << GetZeroSuppression(det, ring, sec, str)
528 << " | 0x" << std::hex << std::setw(4)
529 << std::setfill('0') << ddl << ",0x" << std::setw(3)
530 << addr << std::dec << std::setfill(' ') << std::endl;
534 << "============================================================="
541 //__________________________________________________________________
543 AliFMDParameters::SetStripRange(UShort_t min, UShort_t max)
545 // Set fixed strip range
546 fFixedMinStrip = min;
547 fFixedMaxStrip = max;
550 //__________________________________________________________________
552 AliFMDParameters::GetEntry(const char* path, AliFMDPreprocessor* pp,
555 // Get an entry from the CDB or via preprocessor
556 AliCDBEntry* entry = 0;
558 AliCDBManager* cdb = AliCDBManager::Instance();
559 entry = cdb->Get(path);
562 const char* third = gSystem->BaseName(path);
563 const char* second = gSystem->BaseName(gSystem->DirName(path));
564 entry = pp->GetFromCDB(second, third);
567 TString msg(Form("No %s found in CDB, perhaps you need to "
568 "use AliFMDCalibFaker?", path));
569 if (fatal) { AliFatal(msg.Data()); }
570 else AliLog::Message(AliLog::kWarning, msg.Data(), "FMD",
571 "AliFMDParameters", "GetEntry", __FILE__,
579 //__________________________________________________________________
581 AliFMDParameters::InitPulseGain(AliFMDPreprocessor* pp)
583 // Get pulse gain from CDB or used fixed
584 AliCDBEntry* gain = GetEntry(fgkPulseGain, pp);
587 AliFMDDebug(5, ("Got gain from CDB"));
588 fPulseGain = dynamic_cast<AliFMDCalibGain*>(gain->GetObject());
589 if (!fPulseGain) AliFatal("Invalid pulser gain object from CDB");
591 //__________________________________________________________________
593 AliFMDParameters::InitPedestal(AliFMDPreprocessor* pp)
595 // Initialize the pedestals from CDB
596 AliCDBEntry* pedestal = GetEntry(fgkPedestal, pp);
597 if (!pedestal) return;
599 AliFMDDebug(5, ("Got pedestal from CDB"));
600 fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject());
601 if (!fPedestal) AliFatal("Invalid pedestal object from CDB");
604 //__________________________________________________________________
606 AliFMDParameters::InitDeadMap(AliFMDPreprocessor* pp)
608 // Get Dead-channel-map from CDB
609 AliCDBEntry* deadMap = GetEntry(fgkDead, pp);
610 if (!deadMap) return;
612 AliFMDDebug(5, ("Got dead map from CDB"));
613 fDeadMap = dynamic_cast<AliFMDCalibDeadMap*>(deadMap->GetObject());
614 if (!fDeadMap) AliFatal("Invalid dead map object from CDB");
617 //__________________________________________________________________
619 AliFMDParameters::InitZeroSuppression(AliFMDPreprocessor* pp)
621 // Get 0-suppression from CDB
622 AliCDBEntry* zeroSup = GetEntry(fgkZeroSuppression, pp);
623 if (!zeroSup) return;
624 AliFMDDebug(5, ("Got zero suppression from CDB"));
626 dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject());
627 if (!fZeroSuppression)AliFatal("Invalid zero suppression object from CDB");
630 //__________________________________________________________________
632 AliFMDParameters::InitSampleRate(AliFMDPreprocessor* pp)
634 // get Sample rate from CDB
635 AliCDBEntry* sampRat = GetEntry(fgkSampleRate, pp);
636 if (!sampRat) return;
637 AliFMDDebug(5, ("Got zero suppression from CDB"));
638 fSampleRate = dynamic_cast<AliFMDCalibSampleRate*>(sampRat->GetObject());
639 if (!fSampleRate) AliFatal("Invalid zero suppression object from CDB");
642 //__________________________________________________________________
644 AliFMDParameters::InitAltroMap(AliFMDPreprocessor* pp)
646 // Get hardware mapping from CDB
651 AliCDBEntry* hwMap = GetEntry(fgkAltroMap, pp, kFALSE);
654 AliFMDDebug(5, ("Got ALTRO map from CDB"));
655 fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject());
657 AliFatal("Invalid ALTRO map object from CDB");
658 fAltroMap = new AliFMDAltroMapping;
662 //__________________________________________________________________
664 AliFMDParameters::InitStripRange(AliFMDPreprocessor* pp)
666 // Get strips read-out from CDB
667 AliCDBEntry* range = GetEntry(fgkStripRange, pp);
669 AliFMDDebug(5, ("Got strip range from CDB"));
670 fStripRange = dynamic_cast<AliFMDCalibStripRange*>(range->GetObject());
671 if (!fStripRange) AliFatal("Invalid strip range object from CDB");
675 //__________________________________________________________________
677 AliFMDParameters::GetThreshold() const
679 // Get threshold from CDB
680 if (!fPulseGain) return fFixedThreshold;
681 return fPulseGain->Threshold();
684 //__________________________________________________________________
686 AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring,
687 UShort_t sector, UShort_t strip) const
689 // Returns the pulser calibrated gain for strip # strip in sector #
690 // sector or ring id ring of detector # detector.
692 // For simulation, this is normally set to
695 // ------------------ * MIP_Energy_Loss
696 // ALTRO_channel_size
699 if (fFixedPulseGain <= 0)
700 fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize;
701 return fFixedPulseGain;
703 AliFMDDebug(50, ("pulse gain for FMD%d%c[%2d,%3d]=%f",
704 detector, ring, sector, strip,
705 fPulseGain->Value(detector, ring, sector, strip)));
706 return fPulseGain->Value(detector, ring, sector, strip);
709 //__________________________________________________________________
711 AliFMDParameters::IsDead(UShort_t detector, Char_t ring,
712 UShort_t sector, UShort_t strip) const
714 // Check if the channel is dead
715 if (!fDeadMap) return kFALSE;
716 AliFMDDebug(50, ("Dead for FMD%d%c[%2d,%3d]=%s",
717 detector, ring, sector, strip,
718 fDeadMap->operator()(detector, ring, sector, strip) ?
720 return fDeadMap->operator()(detector, ring, sector, strip);
723 //__________________________________________________________________
725 AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring,
726 UShort_t sector, UShort_t strip) const
728 // Get zero suppression threshold
729 if (!fZeroSuppression) return fFixedZeroSuppression;
730 // Need to map strip to ALTRO chip.
731 AliFMDDebug(50, ("zero sup. for FMD%d%c[%2d,%3d]=%d",
732 detector, ring, sector, strip,
733 fZeroSuppression->operator()(detector, ring,
735 return fZeroSuppression->operator()(detector, ring, sector, strip/128);
738 //__________________________________________________________________
740 AliFMDParameters::GetSampleRate(UShort_t det, Char_t ring, UShort_t sector,
744 if (!fSampleRate) return fFixedSampleRate;
745 // Need to map sector to digitizier card.
746 UInt_t ret = fSampleRate->Rate(det, ring, sector, str);
747 AliFMDDebug(50, ("Sample rate for FMD%d%c[%2d,%3d]=%d",
748 det, ring, sector, str, ret));
752 //__________________________________________________________________
754 AliFMDParameters::GetMinStrip(UShort_t det, Char_t ring, UShort_t sector,
757 // Get strip range read out
758 if (!fStripRange) return fFixedMinStrip;
759 // Need to map sector to digitizier card.
760 UInt_t ret = fStripRange->Min(det, ring, sector, str);
761 AliFMDDebug(50, ("Min strip # for FMD%d%c[%2d,%3d]=%d",
762 det, ring, sector, str, ret));
766 //__________________________________________________________________
768 AliFMDParameters::GetMaxStrip(UShort_t det, Char_t ring, UShort_t sector,
771 // Get strip range read out
772 if (!fStripRange) return fFixedMaxStrip;
773 // Need to map sector to digitizier card.
774 UInt_t ret = fStripRange->Max(det, ring, sector, str);
775 AliFMDDebug(50, ("Max strip # for FMD%d%c[%2d,%3d]=%d",
776 det, ring, sector, str, ret));
780 //__________________________________________________________________
782 AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring,
783 UShort_t sector, UShort_t strip) const
786 if (!fPedestal) return fFixedPedestal;
787 AliFMDDebug(50, ("pedestal for FMD%d%c[%2d,%3d]=%f",
788 detector, ring, sector, strip,
789 fPedestal->Value(detector, ring, sector, strip)));
790 return fPedestal->Value(detector, ring, sector, strip);
793 //__________________________________________________________________
795 AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring,
796 UShort_t sector, UShort_t strip) const
799 if (!fPedestal) return fFixedPedestalWidth;
800 AliFMDDebug(50, ("pedetal width for FMD%d%c[%2d,%3d]=%f",
801 detector, ring, sector, strip,
802 fPedestal->Width(detector, ring, sector, strip)));
803 return fPedestal->Width(detector, ring, sector, strip);
806 //__________________________________________________________________
808 AliFMDParameters::GetAltroMap() const
810 // Get the hardware address to detector index map
815 //____________________________________________________________________
817 AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t addr,
819 UShort_t& det, Char_t& ring,
820 UShort_t& sec, Short_t& str,
823 // Translate a hardware address to detector coordinates.
825 // See also Hardware2Detector that accepts 4 inputs
826 if (!fAltroMap) return kFALSE;
827 UShort_t board, chip, chan;
828 fAltroMap->ChannelAddress(addr, board, chip, chan);
829 return Hardware2Detector(ddl,board,chip,chan,timebin,det,ring,sec,str,sam);
831 //____________________________________________________________________
833 AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t board,
834 UShort_t chip, UShort_t chan,
836 UShort_t& det, Char_t& ring,
837 UShort_t& sec, Short_t& str,
840 // Translate a hardware address to detector coordinates.
842 // See also Hardware2Detector that accepts 4 inputs
843 if (!fAltroMap) return kFALSE;
844 if (fAltroMap->DDL2Detector(ddl) < 0) return kFALSE;
845 Short_t stripBase = 0;
846 if (!fAltroMap->Channel2StripBase(board,chip,chan, ring, sec, stripBase))
848 UShort_t preSamples = GetPreSamples(det, ring, sec, stripBase);
849 UShort_t sampleRate = GetSampleRate(det, ring, sec, stripBase);
850 Short_t stripOff = 0;
851 fAltroMap->Timebin2Strip(sec, timebin, preSamples, sampleRate, stripOff, sam);
852 str = stripBase + stripOff;
853 AliFMDDebug(50, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d"
854 " (pre=%2d, rate=%d)",
855 ddl, board, chip, chan, timebin,
856 det, ring, sec, str, sam, preSamples, sampleRate));
861 //__________________________________________________________________
863 AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t board,
864 UShort_t chip, UShort_t chan,
865 UShort_t& det, Char_t& ring,
866 UShort_t& sec, Short_t& str) const
868 // Map hardware address to detector index
869 if (!fAltroMap) return kFALSE;
870 return fAltroMap->Hardware2Detector(ddl,board,chip,chan, det,ring,sec,str);
872 //__________________________________________________________________
874 AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t addr,
875 UShort_t& det, Char_t& ring,
876 UShort_t& sec, Short_t& str) const
878 // Map hardware address to detector index
879 if (!fAltroMap) return kFALSE;
880 return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
884 //____________________________________________________________________
886 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
887 UShort_t sec, UShort_t str,
889 UShort_t& ddl, UShort_t& board,
890 UShort_t& altro, UShort_t& channel,
891 UShort_t& timebin) const
893 if (!fAltroMap) return kFALSE;
894 UShort_t preSamples = GetPreSamples(det, ring, sec, str);
895 UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
896 UShort_t strip = str - GetMinStrip(det,ring,sec,str);
897 return fAltroMap->Detector2Hardware(det, ring, sec, strip, sam,
898 preSamples, sampleRate,
899 ddl, board, altro, channel, timebin);
904 //____________________________________________________________________
906 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
907 UShort_t sec, UShort_t str,
909 UShort_t& ddl, UShort_t& addr,
910 UShort_t& timebin) const
912 if (!fAltroMap) return kFALSE;
913 UShort_t preSamples = GetPreSamples(det, ring, sec, str);
914 UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
915 UShort_t strip = str - GetMinStrip(det,ring,sec,str);
916 return fAltroMap->Detector2Hardware(det, ring, sec, strip, sam,
917 preSamples, sampleRate,
922 //__________________________________________________________________
924 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
925 UShort_t sec, UShort_t str,
926 UShort_t& ddl, UShort_t& board,
927 UShort_t& chip, UShort_t& chan) const
929 // Map detector index to hardware address
930 if (!fAltroMap) return kFALSE;
931 return fAltroMap->Detector2Hardware(det,ring,sec,str, ddl,board,chip,chan);
934 //__________________________________________________________________
936 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
937 UShort_t sec, UShort_t str,
938 UShort_t& ddl, UShort_t& addr) const
940 // Map detector index to hardware address
941 if (!fAltroMap) return kFALSE;
942 return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
946 //__________________________________________________________________
948 AliFMDParameters::GetEdepMip() const
950 // Get energy deposited by a MIP in the silicon sensors
952 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
953 fEdepMip = (fkSiDeDxMip
954 * fmd->GetRing('I')->GetSiThickness()
955 * fmd->GetSiDensity());
959 //____________________________________________________________________
961 AliFMDParameters::GetDACPerMIP() const
963 //This is the conversion from the Digital-to-Analog-Converter setting
964 // to the number of MIPs. The number was measured in the NBI lab during
971 //____________________________________________________________________