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),
109 fOfflineTriggerLowCut(0.1),
110 fOfflineTriggerHitCut(0.6)
112 // Default constructor
114 SetAltroChannelSize();
115 SetChannelsPerAltro();
116 SetZeroSuppression();
123 fAltroMap = new AliFMDAltroMapping;
126 //__________________________________________________________________
128 AliFMDParameters::Init(Bool_t forceReInit, UInt_t what)
130 // Initialize the parameters manager. We need to get stuff from the
132 if (forceReInit) fIsInit = kFALSE;
134 if (what & kPulseGain) InitPulseGain();
135 if (what & kPedestal) InitPedestal();
136 if (what & kDeadMap) InitDeadMap();
137 if (what & kSampleRate) InitSampleRate();
138 if (what & kZeroSuppression) InitZeroSuppression();
139 if (what & kAltroMap) InitAltroMap();
140 if (what & kStripRange) InitStripRange();
143 //__________________________________________________________________
145 AliFMDParameters::Init(AliFMDPreprocessor* pp, Bool_t forceReInit, UInt_t what)
147 // Initialize the parameters manager. We need to get stuff from the
149 if (forceReInit) fIsInit = kFALSE;
151 if (what & kPulseGain) InitPulseGain(pp);
152 if (what & kPedestal) InitPedestal(pp);
153 if (what & kDeadMap) InitDeadMap(pp);
154 if (what & kSampleRate) InitSampleRate(pp);
155 if (what & kZeroSuppression) InitZeroSuppression(pp);
156 if (what & kAltroMap) InitAltroMap(pp);
157 if (what & kStripRange) InitStripRange(pp);
161 //__________________________________________________________________
163 AliFMDParameters::CheckFile(const char* prefix,
168 f = (Form("%s%d.csv", prefix, number));
169 AliFMDDebug(5, ("Checking if %s exists in %s ...", f.Data(), path));
170 f = gSystem->Which(path, f.Data());
171 AliFMDDebug(5, ("Got back '%s'", f.Data()));
175 //__________________________________________________________________
177 AliFMDParameters::Init(const char* path, Bool_t forceReInit, UInt_t what)
179 // Initialize the parameters manager. Pedestals, gains, strip
180 // range, and sample rate is read from local comma separated value
181 // files if available. Otherwise, the calibrations are obtained
183 if (forceReInit) fIsInit = kFALSE;
186 AliFMDCalibStripRange* range = 0;
187 AliFMDCalibSampleRate* rate = 0;
188 AliFMDCalibPedestal* peds = 0;
189 AliFMDCalibGain* gains = 0;
191 for (Int_t i = 1; i <= 3; i++) {
193 if (((what & kSampleRate) || (what & kStripRange)) &&
194 CheckFile("conditions", path, i, f)) {
195 if (!rate && (what & kSampleRate)) rate = new AliFMDCalibSampleRate;
196 if (!range && (what & kStripRange)) range = new AliFMDCalibStripRange;
197 std::ifstream in(f.Data());
198 if (range) range->ReadFromFile(in);
199 if (rate) rate->ReadFromFile(in);
202 if ((what & kPedestal) && CheckFile("peds", path, i, f)) {
203 if (!peds) peds = new AliFMDCalibPedestal;
204 std::ifstream in(f.Data());
205 peds->ReadFromFile(in);
208 if ((what & kPulseGain) && CheckFile("gains", path, i, f)) {
209 if (!gains) gains = new AliFMDCalibGain;
210 std::ifstream in(f.Data());
211 gains->ReadFromFile(in);
216 if (range) what &= ~kStripRange;
217 if (rate) what &= ~kSampleRate;
218 if (peds) what &= ~kPedestal;
219 if (gains) what &= ~kPulseGain;
223 if (range) SetStripRange(range);
224 if (rate) SetSampleRate(rate);
225 if (peds) SetPedestal(peds);
226 if (gains) SetGain(gains);
231 //__________________________________________________________________
233 AliFMDParameters::MakeDeadMap(Float_t maxNoise,
238 fDeadMap = fPedestal->MakeDeadMap(maxNoise, fDeadMap);
240 fDeadMap = fPulseGain->MakeDeadMap(minGain, maxGain, fDeadMap);
242 //__________________________________________________________________
243 #define DET2IDX(det,ring,sec,str) \
244 (det * 1000 + (ring == 'I' ? 0 : 512) + str)
246 //__________________________________________________________________
248 AliFMDParameters::Draw(Option_t* option)
252 kLocalPulseGain, // Path to PulseGain calib object
253 kLocalThreshold, // Path to PulseGain calib object
254 kLocalPedestal, // Path to Pedestal calib object
255 kLocalPedestalWidth, // Path to Pedestal calib object
256 kLocalDead, // Path to Dead calib object
257 kLocalSampleRate, // Path to SampleRate calib object
258 kLocalAltroMap, // Path to AltroMap calib object
259 kLocalZeroSuppression, // Path to ZeroSuppression cal object
260 kLocalMinStripRange, // Path to strip range cal object
261 kLocalMaxStripRange // Path to strip range cal object
264 if (opt.Contains("dead", TString::kIgnoreCase))
266 else if (opt.Contains("threshold",TString::kIgnoreCase))
267 what = kLocalThreshold;
268 else if (opt.Contains("gain",TString::kIgnoreCase))
269 what = kLocalPulseGain;
270 else if (opt.Contains("pedestal",TString::kIgnoreCase))
271 what = kLocalPedestal;
272 else if (opt.Contains("noise",TString::kIgnoreCase))
273 what = kLocalPedestalWidth;
274 else if (opt.Contains("zero",TString::kIgnoreCase))
275 what = kLocalZeroSuppression;
276 else if (opt.Contains("rate",TString::kIgnoreCase))
277 what = kLocalSampleRate;
278 else if (opt.Contains("min",TString::kIgnoreCase))
279 what = kLocalMinStripRange;
280 else if (opt.Contains("max",TString::kIgnoreCase))
281 what = kLocalMaxStripRange;
282 else if (opt.Contains("map",TString::kIgnoreCase))
283 what = kLocalAltroMap;
285 Warning("Draw", "unknown parameter: %s\n\tShould be one of\n\t"
286 "dead, threshold, gain, pedestal, noise, zero, rate, "
292 TArrayD xbins(3 * 512 + 2 * 256 + 5);
295 for (UShort_t det = 1; det <= 3; det++) {
296 UShort_t nRings = (det == 1 ? 1 : 2);
297 for (UShort_t iring = 0; iring < nRings; iring++) {
298 UShort_t nStrip = (iring == 0 ? 512 : 256);
299 Char_t ring = (iring == 0 ? 'I' : 'O');
300 for (UShort_t str = 0; str < nStrip; str++) {
301 // UShort_t nSec = (iring == 0 ? 20 : 40);
302 // Char_t ring = (iring == 0 ? 'I' : 'O');
303 // for (UShort_t sec = 0; sec < nSec; sec++) {
304 Int_t idx = DET2IDX(det, ring, 0, str);
305 // Int_t idx = DET2IDX(det, ring, sec, 0);
307 xbins[i-1] = idx - .5;
318 for (/*Int_t*/ i = 0; i < ybins.fN; i++) ybins[i] = Float_t(i - .5);
319 TH2D* hist = new TH2D("calib", Form("Calibration %s", option),
320 xbins.fN-1, xbins.fArray,
321 ybins.fN-1, ybins.fArray);
322 hist->GetXaxis()->SetTitle("1000 #times detector + 512 #times ring + strip");
323 hist->GetYaxis()->SetTitle("sector");
325 // hist->Draw("Lego");
328 for (UShort_t det = 1; det <= 3; det++) {
329 UShort_t nRings = (det == 1 ? 1 : 2);
330 for (UShort_t iring = 0; iring < nRings; iring++) {
331 UShort_t nSector = (iring == 0 ? 20 : 40);
332 UShort_t nStrip = (iring == 0 ? 512 : 256);
333 Char_t ring = (iring == 0 ? 'I' : 'O');
334 for (UShort_t sec = 0; sec < nSector; sec++) {
335 for (UShort_t str = 0; str < nStrip; str++) {
336 Int_t idx = DET2IDX(det, ring, sec, str);
337 UShort_t ddl, addr, time, sam=0;
340 case kLocalPulseGain: // Path to PulseGain calib object
341 val = GetPulseGain(det,ring,sec,str); break;
342 case kLocalThreshold: // Path to PulseGain calib object
343 val = GetThreshold(); break;
344 case kLocalPedestal: // Path to Pedestal calib object
345 val = GetPedestal(det,ring,sec,str); break;
346 case kLocalPedestalWidth: // Path to Pedestal calib object
347 val = GetPedestalWidth(det,ring,sec,str); break;
348 case kLocalDead: // Path to Dead calib object
349 val = IsDead(det,ring,sec,str); break;
350 case kLocalSampleRate: // Path to SampleRate calib object
351 val = GetSampleRate(det,ring,sec,str); break;
352 case kLocalAltroMap: // Path to AltroMap calib object
353 Detector2Hardware(det,ring,sec,str,sam,ddl,addr,time);
355 case kLocalZeroSuppression: // Path to ZeroSuppression cal object
356 val = GetZeroSuppression(det,ring,sec,str); break;
357 case kLocalMinStripRange: // Path to strip range cal object
358 val = GetMinStrip(det,ring,sec,str); break;
359 case kLocalMaxStripRange: // Path to strip range cal object
360 val = GetMaxStrip(det,ring,sec,str); break;
362 hist->Fill(idx,sec,val);
363 // hist->Fill(idx,str,val);
371 //__________________________________________________________________
373 AliFMDParameters::Print(Option_t* option) const
375 // Print information.
376 // If option contains an 'A' then everything is printed.
377 // If the option contains the string "FMD" the function will search
378 // for detector, ring, sector, and strip numbers to print, in the
381 // FMD<detector><ring>[<sector>,<string>]
383 // The wild card '*' means all of <detector>, <ring>, <sector>, or
386 Bool_t showStrips = opt.Contains("a", TString::kIgnoreCase);
387 UShort_t ds[] = { 1, 2, 3, 0 };
388 Char_t rs[] = { 'I', 'O', '\0' };
389 UShort_t minStrip = 0;
390 UShort_t maxStrip = 512;
391 UShort_t minSector = 0;
392 UShort_t maxSector = 40;
395 if (opt.Contains("fmd",TString::kIgnoreCase)) {
396 Int_t i = opt.Index("fmd",TString::kIgnoreCase);
397 Int_t j = opt.Index("]",TString::kIgnoreCase);
412 std::stringstream s(opt(i+4, j-i-3).Data());
413 while (state != kEnd) {
414 Char_t tmp = s.peek();
415 if (tmp == ' ' || tmp == '\t') {
420 case kReadDet: { // First, try to kRead the detector
421 if (tmp == '*') s.get();
430 state = (s.bad() ? kEnd : kReadRing);
432 case kReadRing: { // Then try to read the ring;
435 if (ring != '*' && !s.bad()) {
439 state = (s.bad() ? kEnd : kReadLbrack);
441 case kReadLbrack: { // Try to read a left bracket
444 state = (s.bad() ? kEnd : kReadSector);
446 case kReadSector: { // Try to read a sector
447 if (tmp == '*') s.get();
456 state = (s.bad() ? kEnd : kReadComma);
458 case kReadComma: { // Try to read a left bracket
461 state = (s.bad() ? kEnd : kReadStrip);
463 case kReadStrip: { // Try to read a strip
464 if (tmp == '*') s.get();
473 state = (s.bad() ? kEnd : kReadRbrack);
475 case kReadRbrack: { // Try to read a left bracket
487 while ((det = *(dp++))) {
491 while ((ring = *(rp++))) {
492 if (det == 1 && ring == 'O') continue;
493 UShort_t min = GetMinStrip(det, ring, 0, 0);
494 UShort_t max = GetMaxStrip(det, ring, 0, 0);
495 std::cout << "FMD" << det << ring
497 << std::setw(3) << min << ","
498 << std::setw(3) << max << std::endl;
500 UShort_t nSec = ( ring == 'I' ? 20 : 40 );
501 UShort_t nStr = ( ring == 'I' ? 512 : 256 );
502 for (UShort_t sec = minSector; sec < maxSector && sec < nSec; sec++) {
504 UShort_t rate = GetSampleRate(det, ring, sec, 0);
505 std::cout << "FMD" << det << ring << "[" << std::setw(2) << sec
506 << "] sample rate: " << rate << std::endl;
508 if (!showStrips) continue;
510 << " Strip | Pedestal | Gain | ZS thr. | Address\n"
511 << "--------+-------------------+------------+---------+---------"
513 for (UShort_t str = minStrip; str < nStr && str < maxStrip; str++) {
514 if (str == minStrip) std::cout << std::setw(3) << sec << ",";
515 else std::cout << " ";
516 std::cout << std::setw(3) << str << " | ";
517 if (IsDead(det, ring, sec, str)) {
518 std::cout << "dead" << std::endl;
521 UShort_t ddl, addr, time, sam=0;
522 Detector2Hardware(det, ring, sec, str, sam, ddl, addr, time);
523 std::cout << std::setw(7) << GetPedestal(det, ring, sec, str)
524 << "+/-" << std::setw(7)
525 << GetPedestalWidth(det, ring, sec, str)
526 << " | " << std::setw(10)
527 << GetPulseGain(det, ring, sec, str)
528 << " | " << std::setw(7)
529 << GetZeroSuppression(det, ring, sec, str)
530 << " | 0x" << std::hex << std::setw(4)
531 << std::setfill('0') << ddl << ",0x" << std::setw(3)
532 << addr << std::dec << std::setfill(' ') << std::endl;
536 << "============================================================="
543 //__________________________________________________________________
545 AliFMDParameters::SetStripRange(UShort_t min, UShort_t max)
547 // Set fixed strip range
548 fFixedMinStrip = min;
549 fFixedMaxStrip = max;
552 //__________________________________________________________________
554 AliFMDParameters::GetEntry(const char* path, AliFMDPreprocessor* pp,
557 // Get an entry from the CDB or via preprocessor
558 AliCDBEntry* entry = 0;
560 AliCDBManager* cdb = AliCDBManager::Instance();
561 entry = cdb->Get(path);
564 const char* third = gSystem->BaseName(path);
565 const char* second = gSystem->BaseName(gSystem->DirName(path));
566 entry = pp->GetFromCDB(second, third);
569 TString msg(Form("No %s found in CDB, perhaps you need to "
570 "use AliFMDCalibFaker?", path));
571 if (fatal) { AliFatal(msg.Data()); }
572 else AliLog::Message(AliLog::kWarning, msg.Data(), "FMD",
573 "AliFMDParameters", "GetEntry", __FILE__,
581 //__________________________________________________________________
583 AliFMDParameters::InitPulseGain(AliFMDPreprocessor* pp)
585 // Get pulse gain from CDB or used fixed
586 AliCDBEntry* gain = GetEntry(fgkPulseGain, pp);
589 AliFMDDebug(5, ("Got gain from CDB"));
590 fPulseGain = dynamic_cast<AliFMDCalibGain*>(gain->GetObject());
591 if (!fPulseGain) AliFatal("Invalid pulser gain object from CDB");
593 //__________________________________________________________________
595 AliFMDParameters::InitPedestal(AliFMDPreprocessor* pp)
597 // Initialize the pedestals from CDB
598 AliCDBEntry* pedestal = GetEntry(fgkPedestal, pp);
599 if (!pedestal) return;
601 AliFMDDebug(5, ("Got pedestal from CDB"));
602 fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject());
603 if (!fPedestal) AliFatal("Invalid pedestal object from CDB");
606 //__________________________________________________________________
608 AliFMDParameters::InitDeadMap(AliFMDPreprocessor* pp)
610 // Get Dead-channel-map from CDB
611 AliCDBEntry* deadMap = GetEntry(fgkDead, pp);
612 if (!deadMap) return;
614 AliFMDDebug(5, ("Got dead map from CDB"));
615 fDeadMap = dynamic_cast<AliFMDCalibDeadMap*>(deadMap->GetObject());
616 if (!fDeadMap) AliFatal("Invalid dead map object from CDB");
619 //__________________________________________________________________
621 AliFMDParameters::InitZeroSuppression(AliFMDPreprocessor* pp)
623 // Get 0-suppression from CDB
624 AliCDBEntry* zeroSup = GetEntry(fgkZeroSuppression, pp);
625 if (!zeroSup) return;
626 AliFMDDebug(5, ("Got zero suppression from CDB"));
628 dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject());
629 if (!fZeroSuppression)AliFatal("Invalid zero suppression object from CDB");
632 //__________________________________________________________________
634 AliFMDParameters::InitSampleRate(AliFMDPreprocessor* pp)
636 // get Sample rate from CDB
637 AliCDBEntry* sampRat = GetEntry(fgkSampleRate, pp);
638 if (!sampRat) return;
639 AliFMDDebug(5, ("Got zero suppression from CDB"));
640 fSampleRate = dynamic_cast<AliFMDCalibSampleRate*>(sampRat->GetObject());
641 if (!fSampleRate) AliFatal("Invalid zero suppression object from CDB");
644 //__________________________________________________________________
646 AliFMDParameters::InitAltroMap(AliFMDPreprocessor* pp)
648 // Get hardware mapping from CDB
653 AliCDBEntry* hwMap = GetEntry(fgkAltroMap, pp, kFALSE);
656 AliFMDDebug(5, ("Got ALTRO map from CDB"));
657 fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject());
659 AliFatal("Invalid ALTRO map object from CDB");
660 fAltroMap = new AliFMDAltroMapping;
664 //__________________________________________________________________
666 AliFMDParameters::InitStripRange(AliFMDPreprocessor* pp)
668 // Get strips read-out from CDB
669 AliCDBEntry* range = GetEntry(fgkStripRange, pp);
671 AliFMDDebug(5, ("Got strip range from CDB"));
672 fStripRange = dynamic_cast<AliFMDCalibStripRange*>(range->GetObject());
673 if (!fStripRange) AliFatal("Invalid strip range object from CDB");
677 //__________________________________________________________________
679 AliFMDParameters::GetThreshold() const
681 // Get threshold from CDB
682 if (!fPulseGain) return fFixedThreshold;
683 return fPulseGain->Threshold();
686 //__________________________________________________________________
688 AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring,
689 UShort_t sector, UShort_t strip) const
691 // Returns the pulser calibrated gain for strip # strip in sector #
692 // sector or ring id ring of detector # detector.
694 // For simulation, this is normally set to
697 // ------------------ * MIP_Energy_Loss
698 // ALTRO_channel_size
701 if (fFixedPulseGain <= 0)
702 fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize;
703 return fFixedPulseGain;
705 AliFMDDebug(50, ("pulse gain for FMD%d%c[%2d,%3d]=%f",
706 detector, ring, sector, strip,
707 fPulseGain->Value(detector, ring, sector, strip)));
708 return fPulseGain->Value(detector, ring, sector, strip);
711 //__________________________________________________________________
713 AliFMDParameters::IsDead(UShort_t detector, Char_t ring,
714 UShort_t sector, UShort_t strip) const
716 // Check if the channel is dead
717 if (!fDeadMap) return kFALSE;
718 AliFMDDebug(50, ("Dead for FMD%d%c[%2d,%3d]=%s",
719 detector, ring, sector, strip,
720 fDeadMap->operator()(detector, ring, sector, strip) ?
722 return fDeadMap->operator()(detector, ring, sector, strip);
725 //__________________________________________________________________
727 AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring,
728 UShort_t sector, UShort_t strip) const
730 // Get zero suppression threshold
731 if (!fZeroSuppression) return fFixedZeroSuppression;
732 // Need to map strip to ALTRO chip.
733 AliFMDDebug(50, ("zero sup. for FMD%d%c[%2d,%3d]=%f",
734 detector, ring, sector, strip,
735 fZeroSuppression->operator()(detector, ring,
737 return fZeroSuppression->operator()(detector, ring, sector, strip/128);
740 //__________________________________________________________________
742 AliFMDParameters::GetSampleRate(UShort_t det, Char_t ring, UShort_t sector,
746 if (!fSampleRate) return fFixedSampleRate;
747 // Need to map sector to digitizier card.
748 UInt_t ret = fSampleRate->Rate(det, ring, sector, str);
749 AliFMDDebug(50, ("Sample rate for FMD%d%c[%2d,%3d]=%d",
750 det, ring, sector, str, ret));
754 //__________________________________________________________________
756 AliFMDParameters::GetMinStrip(UShort_t det, Char_t ring, UShort_t sector,
759 // Get strip range read out
760 if (!fStripRange) return fFixedMinStrip;
761 // Need to map sector to digitizier card.
762 UInt_t ret = fStripRange->Min(det, ring, sector, str);
763 AliFMDDebug(50, ("Min strip # for FMD%d%c[%2d,%3d]=%d",
764 det, ring, sector, str, ret));
768 //__________________________________________________________________
770 AliFMDParameters::GetMaxStrip(UShort_t det, Char_t ring, UShort_t sector,
773 // Get strip range read out
774 if (!fStripRange) return fFixedMaxStrip;
775 // Need to map sector to digitizier card.
776 UInt_t ret = fStripRange->Max(det, ring, sector, str);
777 AliFMDDebug(50, ("Max strip # for FMD%d%c[%2d,%3d]=%d",
778 det, ring, sector, str, ret));
782 //__________________________________________________________________
784 AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring,
785 UShort_t sector, UShort_t strip) const
788 if (!fPedestal) return fFixedPedestal;
789 AliFMDDebug(50, ("pedestal for FMD%d%c[%2d,%3d]=%f",
790 detector, ring, sector, strip,
791 fPedestal->Value(detector, ring, sector, strip)));
792 return fPedestal->Value(detector, ring, sector, strip);
795 //__________________________________________________________________
797 AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring,
798 UShort_t sector, UShort_t strip) const
801 if (!fPedestal) return fFixedPedestalWidth;
802 AliFMDDebug(50, ("pedetal width for FMD%d%c[%2d,%3d]=%f",
803 detector, ring, sector, strip,
804 fPedestal->Width(detector, ring, sector, strip)));
805 return fPedestal->Width(detector, ring, sector, strip);
808 //__________________________________________________________________
810 AliFMDParameters::GetAltroMap() const
812 // Get the hardware address to detector index map
817 //____________________________________________________________________
819 AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t addr,
821 UShort_t& det, Char_t& ring,
822 UShort_t& sec, Short_t& str,
825 // Translate a hardware address to detector coordinates.
827 // See also Hardware2Detector that accepts 4 inputs
828 if (!fAltroMap) return kFALSE;
829 UShort_t board, chip, chan;
830 fAltroMap->ChannelAddress(addr, board, chip, chan);
831 return Hardware2Detector(ddl,board,chip,chan,timebin,det,ring,sec,str,sam);
833 //____________________________________________________________________
835 AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t board,
836 UShort_t chip, UShort_t chan,
838 UShort_t& det, Char_t& ring,
839 UShort_t& sec, Short_t& str,
842 // Translate a hardware address to detector coordinates.
844 // See also Hardware2Detector that accepts 4 inputs
845 if (!fAltroMap) return kFALSE;
846 if (fAltroMap->DDL2Detector(ddl) < 0) return kFALSE;
847 Short_t stripBase = 0;
848 if (!fAltroMap->Channel2StripBase(board,chip,chan, ring, sec, stripBase))
850 UShort_t preSamples = GetPreSamples(det, ring, sec, stripBase);
851 UShort_t sampleRate = GetSampleRate(det, ring, sec, stripBase);
852 Short_t stripOff = 0;
853 fAltroMap->Timebin2Strip(sec, timebin, preSamples, sampleRate, stripOff, sam);
854 str = stripBase + stripOff;
855 AliFMDDebug(50, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d"
856 " (pre=%2d, rate=%d)",
857 ddl, board, chip, chan, timebin,
858 det, ring, sec, str, sam, preSamples, sampleRate));
863 //__________________________________________________________________
865 AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t board,
866 UShort_t chip, UShort_t chan,
867 UShort_t& det, Char_t& ring,
868 UShort_t& sec, Short_t& str) const
870 // Map hardware address to detector index
871 if (!fAltroMap) return kFALSE;
872 return fAltroMap->Hardware2Detector(ddl,board,chip,chan, det,ring,sec,str);
874 //__________________________________________________________________
876 AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t addr,
877 UShort_t& det, Char_t& ring,
878 UShort_t& sec, Short_t& str) const
880 // Map hardware address to detector index
881 if (!fAltroMap) return kFALSE;
882 return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
886 //____________________________________________________________________
888 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
889 UShort_t sec, UShort_t str,
891 UShort_t& ddl, UShort_t& board,
892 UShort_t& altro, UShort_t& channel,
893 UShort_t& timebin) const
895 if (!fAltroMap) return kFALSE;
896 UShort_t preSamples = GetPreSamples(det, ring, sec, str);
897 UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
898 UShort_t strip = str - GetMinStrip(det,ring,sec,str);
899 return fAltroMap->Detector2Hardware(det, ring, sec, strip, sam,
900 preSamples, sampleRate,
901 ddl, board, altro, channel, timebin);
906 //____________________________________________________________________
908 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
909 UShort_t sec, UShort_t str,
911 UShort_t& ddl, UShort_t& addr,
912 UShort_t& timebin) const
914 if (!fAltroMap) return kFALSE;
915 UShort_t preSamples = GetPreSamples(det, ring, sec, str);
916 UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
917 UShort_t strip = str - GetMinStrip(det,ring,sec,str);
918 return fAltroMap->Detector2Hardware(det, ring, sec, strip, sam,
919 preSamples, sampleRate,
924 //__________________________________________________________________
926 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
927 UShort_t sec, UShort_t str,
928 UShort_t& ddl, UShort_t& board,
929 UShort_t& chip, UShort_t& chan) const
931 // Map detector index to hardware address
932 if (!fAltroMap) return kFALSE;
933 return fAltroMap->Detector2Hardware(det,ring,sec,str, ddl,board,chip,chan);
936 //__________________________________________________________________
938 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
939 UShort_t sec, UShort_t str,
940 UShort_t& ddl, UShort_t& addr) const
942 // Map detector index to hardware address
943 if (!fAltroMap) return kFALSE;
944 return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
948 //__________________________________________________________________
950 AliFMDParameters::GetEdepMip() const
952 // Get energy deposited by a MIP in the silicon sensors
954 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
955 fEdepMip = (fkSiDeDxMip
956 * fmd->GetRing('I')->GetSiThickness()
957 * fmd->GetSiDensity());
961 //____________________________________________________________________
963 AliFMDParameters::GetDACPerMIP() const
965 //This is the conversion from the Digital-to-Analog-Converter setting
966 // to the number of MIPs. The number was measured in the NBI lab during
973 //____________________________________________________________________