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 *************************************************************************
17 * @file AliFMDParameters.cxx
18 * @author Christian Holm Christensen <cholm@nbi.dk>
19 * @date Mon Mar 27 12:44:26 2006
20 * @brief Manager of FMD parameters
22 //____________________________________________________________________
24 // Forward Multiplicity Detector based on Silicon wafers.
26 // This class is a singleton that handles various parameters of
28 // The manager normally serves the parameters from the Conditions
29 // Database (CDB). These are retrivied by the member function
30 // `Init'. Optionally, the class can serve hard-coded constants, if
31 // no CDB is available.
33 #include "AliFMDDebug.h" // ALILOG_H
34 #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
35 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
36 #include "AliFMDRing.h" // ALIFMDRING_H
37 #include "AliFMDCalibGain.h" // ALIFMDCALIBGAIN_H
38 #include "AliFMDCalibPedestal.h" // ALIFMDCALIBPEDESTAL_H
39 #include "AliFMDCalibSampleRate.h" // ALIFMDCALIBSAMPLERATE_H
40 #include "AliFMDCalibStripRange.h" // ALIFMDCALIBSTRIPRANGE_H
41 #include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
42 #include <AliCDBManager.h> // ALICDBMANAGER_H
43 #include <AliCDBEntry.h> // ALICDBMANAGER_H
44 #include <AliFMDPreprocessor.h>
46 #include <Riostream.h>
52 //====================================================================
53 ClassImp(AliFMDParameters)
55 ; // This is here to keep Emacs for indenting the next line
58 //____________________________________________________________________
59 AliFMDParameters* AliFMDParameters::fgInstance = 0;
61 //____________________________________________________________________
62 const char* AliFMDParameters::fgkPulseGain = "FMD/Calib/PulseGain";
63 const char* AliFMDParameters::fgkPedestal = "FMD/Calib/Pedestal";
64 const char* AliFMDParameters::fgkDead = "FMD/Calib/Dead";
65 const char* AliFMDParameters::fgkSampleRate = "FMD/Calib/SampleRate";
66 const char* AliFMDParameters::fgkAltroMap = "FMD/Calib/AltroMap";
67 const char* AliFMDParameters::fgkZeroSuppression = "FMD/Calib/ZeroSuppression";
68 const char* AliFMDParameters::fgkStripRange = "FMD/Calib/StripRange";
69 const char* AliFMDParameters::fkPedestalShuttleID = "pedestals";
70 const char* AliFMDParameters::fkGainShuttleID = "gains";
71 const char* AliFMDParameters::fkConditionsShuttleID = "conditions";
73 //____________________________________________________________________
75 AliFMDParameters::Instance()
78 // Get static instance
80 if (!fgInstance) fgInstance = new AliFMDParameters;
84 //____________________________________________________________________
85 AliFMDParameters::AliFMDParameters()
94 fZSPedSubtract(kFALSE),
96 fFixedPedestalWidth(0),
97 fFixedZeroSuppression(0),
104 fHasCompleteHeader(kTRUE),
114 // Default constructor
117 SetAltroChannelSize();
118 SetChannelsPerAltro();
119 SetZeroSuppression();
126 fAltroMap = new AliFMDAltroMapping;
129 //__________________________________________________________________
131 AliFMDParameters::Init(Bool_t forceReInit, UInt_t what)
134 // Initialize the manager. This tries to read the parameters from
135 // CDB. If that fails, the class uses the hard-coded parameters.
138 // forceReInit Force (re-)initalize flag
139 // what What to initialize
141 if (forceReInit) fIsInit = kFALSE;
143 if (what & kPulseGain) InitPulseGain();
144 if (what & kPedestal) InitPedestal();
145 if (what & kDeadMap) InitDeadMap();
146 if (what & kSampleRate) InitSampleRate();
147 if (what & kZeroSuppression) InitZeroSuppression();
148 if (what & kAltroMap) InitAltroMap();
149 if (what & kStripRange) InitStripRange();
152 //__________________________________________________________________
154 AliFMDParameters::Init(AliFMDPreprocessor* pp, Bool_t forceReInit, UInt_t what)
157 // Initialize the manager. This tries to read the parameters from
158 // CDB. If that fails, the class uses the hard-coded parameters.
162 // forceReInit Force (re-)initalize flag
163 // what What to initialize
165 if (forceReInit) fIsInit = kFALSE;
167 if (what & kPulseGain) InitPulseGain(pp);
168 if (what & kPedestal) InitPedestal(pp);
169 if (what & kDeadMap) InitDeadMap(pp);
170 if (what & kSampleRate) InitSampleRate(pp);
171 if (what & kZeroSuppression) InitZeroSuppression(pp);
172 if (what & kAltroMap) InitAltroMap(pp);
173 if (what & kStripRange) InitStripRange(pp);
177 //__________________________________________________________________
179 AliFMDParameters::CheckFile(const char* prefix,
185 // Check if the file <i>prefix</i><i>number</i> exists in @a path,
186 // and write the full path to @a f.
189 // prefix File prefix (cond, peds, gains, ...)
190 // path Path to files
191 // number Detector number (1, 2, or 3)
192 // f On return full path to file (if found)
195 // @c true if file exists and is readable, @c false otherwise
197 f = (Form("%s%d.csv", prefix, number));
198 AliFMDDebug(5, ("Checking if %s exists in %s ...", f.Data(), path));
199 f = gSystem->Which(path, f.Data());
200 AliFMDDebug(5, ("Got back '%s'", f.Data()));
204 //__________________________________________________________________
206 AliFMDParameters::Init(const char* path, Bool_t forceReInit, UInt_t what)
209 // Initialize the manager. This will try to read some calibrations
210 // (sample rate, strip range, gains, pedestals) from local comma
211 // separated value (CSV) files in the directory pointed at by @a
212 // path. If they are not found, then they will be retrieved from
213 // OCDB as appropriately. Other calibrations are always read from
216 // The CSV files should be named as
218 // - Pedestals: <tt>peds</tt><i>det_number</i><tt>.csv</tt>
219 // - Gains: <tt>gains</tt><i>det_number</i><tt>.csv</tt>
220 // - Sample Rate: <tt>conditions</tt><i>det_number</i><tt>.csv</tt>
221 // - Strip Range: <tt>conditions</tt><i>det_number</i><tt>.csv</tt>
223 // where <i>det_number</i> is the detector number (1, 2, or 3).
226 // path Where to look for the CSV files
227 // forceReInit Always reinitialise
228 // what What calibrations to load.
230 if (forceReInit) fIsInit = kFALSE;
233 AliFMDCalibStripRange* range = 0;
234 AliFMDCalibSampleRate* rate = 0;
235 AliFMDCalibPedestal* peds = 0;
236 AliFMDCalibGain* gains = 0;
238 for (Int_t i = 1; i <= 3; i++) {
240 if (((what & kSampleRate) || (what & kStripRange)) &&
241 CheckFile("conditions", path, i, f)) {
242 if (!rate && (what & kSampleRate)) rate = new AliFMDCalibSampleRate;
243 if (!range && (what & kStripRange)) range = new AliFMDCalibStripRange;
244 std::ifstream in(f.Data());
245 if (range) range->ReadFromFile(in);
246 if (rate) rate->ReadFromFile(in);
249 if ((what & kPedestal) && CheckFile("peds", path, i, f)) {
250 if (!peds) peds = new AliFMDCalibPedestal;
251 std::ifstream in(f.Data());
252 peds->ReadFromFile(in);
255 if ((what & kPulseGain) && CheckFile("gains", path, i, f)) {
256 if (!gains) gains = new AliFMDCalibGain;
257 std::ifstream in(f.Data());
258 gains->ReadFromFile(in);
263 if (range) what &= ~kStripRange;
264 if (rate) what &= ~kSampleRate;
265 if (peds) what &= ~kPedestal;
266 if (gains) what &= ~kPulseGain;
270 if (range) SetStripRange(range);
271 if (rate) SetSampleRate(rate);
272 if (peds) SetPedestal(peds);
273 if (gains) SetGain(gains);
278 //__________________________________________________________________
280 AliFMDParameters::MakeDeadMap(Float_t maxNoise,
285 // Automatically generate a dead map from the pedestals and gains.
286 // A channel is marked as dead of the noise is too high (currently
287 // more than 10 ADC counts), or the gain is unreasonable (currently
288 // larger than 10, or smaller than 0.1).
290 // The procedure does not overwrite channels previously marked as
291 // dead - e.g., channels marked as dead in the calibration loaded
292 // from OCDB will continue to be marked as dead. That is, this
293 // procedure will never make a channel un-dead.
296 // maxNoise Maximum noise value before a channel is marked
298 // minGain Minimum value of the calibrated gain before a
299 // channel is considered dead.
300 // maxGain Maximum value of the calibrated gain before a
301 // channel is considered dead.
304 fDeadMap = fPedestal->MakeDeadMap(maxNoise, fDeadMap);
306 fDeadMap = fPulseGain->MakeDeadMap(minGain, maxGain, fDeadMap);
308 //__________________________________________________________________
309 #define DET2IDX(det,ring,sec,str) \
310 (det * 1000 + (ring == 'I' ? 0 : 512) + str)
312 //__________________________________________________________________
314 AliFMDParameters::Draw(Option_t* option)
320 // option What to draw. Should be one of
321 // - dead Dead channels
322 // - threshold Threshold
324 // - pedestal Pedestal
325 // - noise Noise (or pedestal width)
326 // - zero Zero suppression
327 // - rate Sampling rate (VA1 clock / ALTRO clock)
328 // - min Minimum strip read out
329 // - max Maximum strip read out
330 // - map hardware address
334 kLocalPulseGain, // Path to PulseGain calib object
335 kLocalThreshold, // Path to PulseGain calib object
336 kLocalPedestal, // Path to Pedestal calib object
337 kLocalPedestalWidth, // Path to Pedestal calib object
338 kLocalDead, // Path to Dead calib object
339 kLocalSampleRate, // Path to SampleRate calib object
340 kLocalAltroMap, // Path to AltroMap calib object
341 kLocalZeroSuppression, // Path to ZeroSuppression cal object
342 kLocalMinStripRange, // Path to strip range cal object
343 kLocalMaxStripRange // Path to strip range cal object
346 if (opt.Contains("dead", TString::kIgnoreCase))
348 else if (opt.Contains("threshold",TString::kIgnoreCase))
349 what = kLocalThreshold;
350 else if (opt.Contains("gain",TString::kIgnoreCase))
351 what = kLocalPulseGain;
352 else if (opt.Contains("pedestal",TString::kIgnoreCase))
353 what = kLocalPedestal;
354 else if (opt.Contains("noise",TString::kIgnoreCase))
355 what = kLocalPedestalWidth;
356 else if (opt.Contains("zero",TString::kIgnoreCase))
357 what = kLocalZeroSuppression;
358 else if (opt.Contains("rate",TString::kIgnoreCase))
359 what = kLocalSampleRate;
360 else if (opt.Contains("min",TString::kIgnoreCase))
361 what = kLocalMinStripRange;
362 else if (opt.Contains("max",TString::kIgnoreCase))
363 what = kLocalMaxStripRange;
364 else if (opt.Contains("map",TString::kIgnoreCase))
365 what = kLocalAltroMap;
367 Warning("Draw", "unknown parameter: %s\n\tShould be one of\n\t"
368 "dead, threshold, gain, pedestal, noise, zero, rate, "
374 TArrayD xbins(3 * 512 + 2 * 256 + 5);
377 for (UShort_t det = 1; det <= 3; det++) {
378 UShort_t nRings = (det == 1 ? 1 : 2);
379 for (UShort_t iring = 0; iring < nRings; iring++) {
380 UShort_t nStrip = (iring == 0 ? 512 : 256);
381 Char_t ring = (iring == 0 ? 'I' : 'O');
382 for (UShort_t str = 0; str < nStrip; str++) {
383 // UShort_t nSec = (iring == 0 ? 20 : 40);
384 // Char_t ring = (iring == 0 ? 'I' : 'O');
385 // for (UShort_t sec = 0; sec < nSec; sec++) {
386 Int_t idx = DET2IDX(det, ring, 0, str);
387 // Int_t idx = DET2IDX(det, ring, sec, 0);
389 xbins[i-1] = idx - .5;
400 for (/*Int_t*/ i = 0; i < ybins.fN; i++) ybins[i] = Float_t(i - .5);
401 TH2D* hist = new TH2D("calib", Form("Calibration %s", option),
402 xbins.fN-1, xbins.fArray,
403 ybins.fN-1, ybins.fArray);
404 hist->GetXaxis()->SetTitle("1000 #times detector + 512 #times ring + strip");
405 hist->GetYaxis()->SetTitle("sector");
407 // hist->Draw("Lego");
410 for (UShort_t det = 1; det <= 3; det++) {
411 UShort_t nRings = (det == 1 ? 1 : 2);
412 for (UShort_t iring = 0; iring < nRings; iring++) {
413 UShort_t nSector = (iring == 0 ? 20 : 40);
414 UShort_t nStrip = (iring == 0 ? 512 : 256);
415 Char_t ring = (iring == 0 ? 'I' : 'O');
416 for (UShort_t sec = 0; sec < nSector; sec++) {
417 for (UShort_t str = 0; str < nStrip; str++) {
418 Int_t idx = DET2IDX(det, ring, sec, str);
419 UShort_t ddl, addr, time, sam=0;
422 case kLocalPulseGain: // Path to PulseGain calib object
423 val = GetPulseGain(det,ring,sec,str); break;
424 case kLocalThreshold: // Path to PulseGain calib object
425 val = GetThreshold(); break;
426 case kLocalPedestal: // Path to Pedestal calib object
427 val = GetPedestal(det,ring,sec,str); break;
428 case kLocalPedestalWidth: // Path to Pedestal calib object
429 val = GetPedestalWidth(det,ring,sec,str); break;
430 case kLocalDead: // Path to Dead calib object
431 val = IsDead(det,ring,sec,str); break;
432 case kLocalSampleRate: // Path to SampleRate calib object
433 val = GetSampleRate(det,ring,sec,str); break;
434 case kLocalAltroMap: // Path to AltroMap calib object
435 Detector2Hardware(det,ring,sec,str,sam,ddl,addr,time);
437 case kLocalZeroSuppression: // Path to ZeroSuppression cal object
438 val = GetZeroSuppression(det,ring,sec,str); break;
439 case kLocalMinStripRange: // Path to strip range cal object
440 val = GetMinStrip(det,ring,sec,str); break;
441 case kLocalMaxStripRange: // Path to strip range cal object
442 val = GetMaxStrip(det,ring,sec,str); break;
444 hist->Fill(idx,sec,val);
445 // hist->Fill(idx,str,val);
453 //__________________________________________________________________
455 AliFMDParameters::Print(Option_t* option) const
457 // Print information.
458 // If option contains an 'A' then everything is printed.
459 // If the option contains the string "FMD" the function will search
460 // for detector, ring, sector, and strip numbers to print, in the
463 // FMD<detector><ring>[<sector>,<string>]
465 // The wild card '*' means all of <detector>, <ring>, <sector>, or
468 Bool_t showStrips = opt.Contains("a", TString::kIgnoreCase);
469 UShort_t ds[] = { 1, 2, 3, 0 };
470 Char_t rs[] = { 'I', 'O', '\0' };
471 UShort_t minStrip = 0;
472 UShort_t maxStrip = 512;
473 UShort_t minSector = 0;
474 UShort_t maxSector = 40;
477 if (opt.Contains("fmd",TString::kIgnoreCase)) {
478 Int_t i = opt.Index("fmd",TString::kIgnoreCase);
479 Int_t j = opt.Index("]",TString::kIgnoreCase);
494 std::stringstream s(opt(i+4, j-i-3).Data());
495 while (state != kEnd) {
496 Char_t tmp = s.peek();
497 if (tmp == ' ' || tmp == '\t') {
502 case kReadDet: { // First, try to kRead the detector
503 if (tmp == '*') s.get();
512 state = (s.bad() ? kEnd : kReadRing);
514 case kReadRing: { // Then try to read the ring;
517 if (ring != '*' && !s.bad()) {
521 state = (s.bad() ? kEnd : kReadLbrack);
523 case kReadLbrack: { // Try to read a left bracket
526 state = (s.bad() ? kEnd : kReadSector);
528 case kReadSector: { // Try to read a sector
529 if (tmp == '*') s.get();
538 state = (s.bad() ? kEnd : kReadComma);
540 case kReadComma: { // Try to read a left bracket
543 state = (s.bad() ? kEnd : kReadStrip);
545 case kReadStrip: { // Try to read a strip
546 if (tmp == '*') s.get();
555 state = (s.bad() ? kEnd : kReadRbrack);
557 case kReadRbrack: { // Try to read a left bracket
569 while ((det = *(dp++))) {
573 while ((ring = *(rp++))) {
574 if (det == 1 && ring == 'O') continue;
575 UShort_t min = GetMinStrip(det, ring, 0, 0);
576 UShort_t max = GetMaxStrip(det, ring, 0, 0);
577 std::cout << "FMD" << det << ring
579 << std::setw(3) << min << ","
580 << std::setw(3) << max << std::endl;
582 UShort_t nSec = ( ring == 'I' ? 20 : 40 );
583 UShort_t nStr = ( ring == 'I' ? 512 : 256 );
584 for (UShort_t sec = minSector; sec < maxSector && sec < nSec; sec++) {
586 UShort_t rate = GetSampleRate(det, ring, sec, 0);
587 std::cout << "FMD" << det << ring << "[" << std::setw(2) << sec
588 << "] sample rate: " << rate << std::endl;
590 if (!showStrips) continue;
592 << " Strip | Pedestal | Gain | ZS thr. | Address\n"
593 << "--------+-------------------+------------+---------+---------"
595 for (UShort_t str = minStrip; str < nStr && str < maxStrip; str++) {
596 if (str == minStrip) std::cout << std::setw(3) << sec << ",";
597 else std::cout << " ";
598 std::cout << std::setw(3) << str << " | ";
599 if (IsDead(det, ring, sec, str)) {
600 std::cout << "dead" << std::endl;
603 UShort_t ddl, addr, time, sam=0;
604 Detector2Hardware(det, ring, sec, str, sam, ddl, addr, time);
605 std::cout << std::setw(7) << GetPedestal(det, ring, sec, str)
606 << "+/-" << std::setw(7)
607 << GetPedestalWidth(det, ring, sec, str)
608 << " | " << std::setw(10)
609 << GetPulseGain(det, ring, sec, str)
610 << " | " << std::setw(7)
611 << GetZeroSuppression(det, ring, sec, str)
612 << " | 0x" << std::hex << std::setw(4)
613 << std::setfill('0') << ddl << ",0x" << std::setw(3)
614 << addr << std::dec << std::setfill(' ') << std::endl;
618 << "============================================================="
625 //__________________________________________________________________
627 AliFMDParameters::GetEntry(const char* path, AliFMDPreprocessor* pp,
631 // Get an entry from either global AliCDBManager or passed
632 // AliFMDPreprocessor.
635 // path Path to CDB object.
636 // pp AliFMDPreprocessor
637 // fatal If true, raise a fatal flag if we didn't get the entry.
639 // AliCDBEntry if found
641 AliCDBEntry* entry = 0;
643 AliCDBManager* cdb = AliCDBManager::Instance();
644 entry = cdb->Get(path);
647 const char* third = gSystem->BaseName(path);
648 const char* second = gSystem->BaseName(gSystem->DirName(path));
649 entry = pp->GetFromCDB(second, third);
652 TString msg(Form("No %s found in CDB, perhaps you need to "
653 "use AliFMDCalibFaker?", path));
654 if (fatal) { AliFatal(msg.Data()); }
655 else AliLog::Message(AliLog::kWarning, msg.Data(), "FMD",
656 "AliFMDParameters", "GetEntry", __FILE__,
664 //__________________________________________________________________
666 AliFMDParameters::InitPulseGain(AliFMDPreprocessor* pp)
669 // Initialize gains. Try to get them from CDB
672 // pp Pre-processor if called from shuttle
674 AliCDBEntry* gain = GetEntry(fgkPulseGain, pp);
677 AliFMDDebug(5, ("Got gain from CDB"));
678 fPulseGain = dynamic_cast<AliFMDCalibGain*>(gain->GetObject());
679 if (!fPulseGain) AliFatal("Invalid pulser gain object from CDB");
681 //__________________________________________________________________
683 AliFMDParameters::InitPedestal(AliFMDPreprocessor* pp)
686 // Initialize pedestals. Try to get them from CDB
689 // pp Pre-processor if called from shuttle
691 AliCDBEntry* pedestal = GetEntry(fgkPedestal, pp);
692 if (!pedestal) return;
694 AliFMDDebug(5, ("Got pedestal from CDB"));
695 fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject());
696 if (!fPedestal) AliFatal("Invalid pedestal object from CDB");
699 //__________________________________________________________________
701 AliFMDParameters::InitDeadMap(AliFMDPreprocessor* pp)
704 // Initialize dead map. Try to get it from CDB
707 // pp Pre-processor if called from shuttle
709 AliCDBEntry* deadMap = GetEntry(fgkDead, pp);
710 if (!deadMap) return;
712 AliFMDDebug(5, ("Got dead map from CDB"));
713 fDeadMap = dynamic_cast<AliFMDCalibDeadMap*>(deadMap->GetObject());
714 if (!fDeadMap) AliFatal("Invalid dead map object from CDB");
717 //__________________________________________________________________
719 AliFMDParameters::InitZeroSuppression(AliFMDPreprocessor* pp)
722 // Initialize zero suppression thresholds. Try to get them from CDB
725 // pp Pre-processor if called from shuttle
727 AliCDBEntry* zeroSup = GetEntry(fgkZeroSuppression, pp);
728 if (!zeroSup) return;
729 AliFMDDebug(5, ("Got zero suppression from CDB"));
731 dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject());
732 if (!fZeroSuppression)AliFatal("Invalid zero suppression object from CDB");
735 //__________________________________________________________________
737 AliFMDParameters::InitSampleRate(AliFMDPreprocessor* pp)
740 // Initialize sample rates. Try to get them from CDB
743 // pp Pre-processor if called from shuttle
745 AliCDBEntry* sampRat = GetEntry(fgkSampleRate, pp);
746 if (!sampRat) return;
747 AliFMDDebug(5, ("Got zero suppression from CDB"));
748 fSampleRate = dynamic_cast<AliFMDCalibSampleRate*>(sampRat->GetObject());
749 if (!fSampleRate) AliFatal("Invalid zero suppression object from CDB");
752 //__________________________________________________________________
754 AliFMDParameters::InitAltroMap(AliFMDPreprocessor* pp)
757 // Initialize hardware map. Try to get it from CDB
760 // pp Pre-processor if called from shuttle
766 AliCDBEntry* hwMap = GetEntry(fgkAltroMap, pp, kFALSE);
769 AliFMDDebug(5, ("Got ALTRO map from CDB"));
770 fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject());
772 AliFatal("Invalid ALTRO map object from CDB");
773 fAltroMap = new AliFMDAltroMapping;
777 //__________________________________________________________________
779 AliFMDParameters::InitStripRange(AliFMDPreprocessor* pp)
782 // Initialize strip range. Try to get it from CDB
785 // pp Pre-processor if called from shuttle
787 AliCDBEntry* range = GetEntry(fgkStripRange, pp);
789 AliFMDDebug(5, ("Got strip range from CDB"));
790 fStripRange = dynamic_cast<AliFMDCalibStripRange*>(range->GetObject());
791 if (!fStripRange) AliFatal("Invalid strip range object from CDB");
795 //__________________________________________________________________
797 AliFMDParameters::GetThreshold() const
800 // Get the threshold in the pulser gain
804 // Threshold from pulser
806 if (!fPulseGain) return fFixedThreshold;
807 return fPulseGain->Threshold();
810 //__________________________________________________________________
812 AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring,
813 UShort_t sector, UShort_t strip) const
816 // Gain of pre-amp. for strip, sector, ring, detector
818 // For simulations this is normally set to
821 // \frac{\mbox{VA1_MIP_Range}{\mbox{ALTRO_channel_size}}\mbox{MIP_Energy_Loss}
826 // detector Detector # (1-3)
827 // ring Ring ID ('I' or 'O')
828 // sector Sector number (0-39)
829 // strip Strip number (0-511)
835 if (fFixedPulseGain <= 0)
836 fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize;
837 return fFixedPulseGain;
839 AliFMDDebug(50, ("pulse gain for FMD%d%c[%2d,%3d]=%f",
840 detector, ring, sector, strip,
841 fPulseGain->Value(detector, ring, sector, strip)));
842 return fPulseGain->Value(detector, ring, sector, strip);
845 //__________________________________________________________________
847 AliFMDParameters::IsDead(UShort_t detector, Char_t ring,
848 UShort_t sector, UShort_t strip) const
851 // Whether the strip is considered dead
854 // detector Detector # (1-3)
855 // ring Ring ID ('I' or 'O')
856 // sector Sector number (0-39)
857 // strip Strip number (0-511)
860 // @c true if the strip is considered dead, @c false if it's
863 if (!fDeadMap) return kFALSE;
864 AliFMDDebug(50, ("Dead for FMD%d%c[%2d,%3d]=%s",
865 detector, ring, sector, strip,
866 fDeadMap->operator()(detector, ring, sector, strip) ?
868 return fDeadMap->operator()(detector, ring, sector, strip);
871 //__________________________________________________________________
873 AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring,
874 UShort_t sector, UShort_t strip) const
877 // zero suppression threshold (in ADC counts)
880 // detector Detector # (1-3)
881 // ring Ring ID ('I' or 'O')
882 // sector Sector number (0-39)
883 // strip Strip number (0-511)
886 // zero suppression threshold (in ADC counts)
888 if (!fZeroSuppression) return fFixedZeroSuppression;
889 // Need to map strip to ALTRO chip.
890 AliFMDDebug(50, ("zero sup. for FMD%d%c[%2d,%3d]=%d",
891 detector, ring, sector, strip,
892 fZeroSuppression->operator()(detector, ring,
894 return fZeroSuppression->operator()(detector, ring, sector, strip/128);
897 //__________________________________________________________________
899 AliFMDParameters::GetSampleRate(UShort_t det, Char_t ring, UShort_t sector,
903 // Get the sampling rate
906 // detector Detector # (1-3)
907 // ring Ring ID ('I' or 'O')
908 // sector Sector number (0-39)
909 // strip Strip number (0-511)
914 if (!fSampleRate) return fFixedSampleRate;
915 // Need to map sector to digitizier card.
916 UInt_t ret = fSampleRate->Rate(det, ring, sector, str);
917 AliFMDDebug(50, ("Sample rate for FMD%d%c[%2d,%3d]=%d",
918 det, ring, sector, str, ret));
922 //__________________________________________________________________
924 AliFMDParameters::GetMinStrip(UShort_t det, Char_t ring, UShort_t sector,
928 // Get the minimum strip in the read-out range
931 // detector Detector # (1-3)
932 // ring Ring ID ('I' or 'O')
933 // sector Sector number (0-39)
934 // strip Strip number (0-511)
939 if (!fStripRange) return fFixedMinStrip;
940 // Need to map sector to digitizier card.
941 UInt_t ret = fStripRange->Min(det, ring, sector, str);
942 AliFMDDebug(50, ("Min strip # for FMD%d%c[%2d,%3d]=%d",
943 det, ring, sector, str, ret));
947 //__________________________________________________________________
949 AliFMDParameters::GetMaxStrip(UShort_t det, Char_t ring, UShort_t sector,
953 // Get the maximum strip in the read-out range
956 // detector Detector # (1-3)
957 // ring Ring ID ('I' or 'O')
958 // sector Sector number (0-39)
959 // strip Strip number (0-511)
964 if (!fStripRange) return fFixedMaxStrip;
965 // Need to map sector to digitizier card.
966 UInt_t ret = fStripRange->Max(det, ring, sector, str);
967 AliFMDDebug(50, ("Max strip # for FMD%d%c[%2d,%3d]=%d",
968 det, ring, sector, str, ret));
972 //__________________________________________________________________
974 AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring,
975 UShort_t sector, UShort_t strip) const
978 // Get mean of pedestal
981 // detector Detector # (1-3)
982 // ring Ring ID ('I' or 'O')
983 // sector Sector number (0-39)
984 // strip Strip number (0-511)
989 if (!fPedestal) return fFixedPedestal;
990 AliFMDDebug(50, ("pedestal for FMD%d%c[%2d,%3d]=%f",
991 detector, ring, sector, strip,
992 fPedestal->Value(detector, ring, sector, strip)));
993 return fPedestal->Value(detector, ring, sector, strip);
996 //__________________________________________________________________
998 AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring,
999 UShort_t sector, UShort_t strip) const
1002 // Width of pedestal
1005 // detector Detector # (1-3)
1006 // ring Ring ID ('I' or 'O')
1007 // sector Sector number (0-39)
1008 // strip Strip number (0-511)
1011 // Width of pedestal
1013 if (!fPedestal) return fFixedPedestalWidth;
1014 AliFMDDebug(50, ("pedetal width for FMD%d%c[%2d,%3d]=%f",
1015 detector, ring, sector, strip,
1016 fPedestal->Width(detector, ring, sector, strip)));
1017 return fPedestal->Width(detector, ring, sector, strip);
1020 //__________________________________________________________________
1022 AliFMDParameters::GetAltroMap() const
1025 // Get the map that translates hardware to detector coordinates
1028 // Get the map that translates hardware to detector
1035 //____________________________________________________________________
1037 AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t addr,
1039 UShort_t& det, Char_t& ring,
1040 UShort_t& sec, Short_t& str,
1041 UShort_t& sam) const
1044 // Map a hardware address into a detector index.
1047 // ddl Hardware DDL number
1048 // addr Hardware address.
1050 // det On return, the detector #
1051 // ring On return, the ring ID
1052 // sec On return, the sector #
1053 // str On return, the base of strip #
1054 // sam On return, the sample number for this strip
1057 // @c true on success, false otherwise
1059 if (!fAltroMap) return kFALSE;
1060 UShort_t board, chip, chan;
1061 fAltroMap->ChannelAddress(addr, board, chip, chan);
1062 return Hardware2Detector(ddl,board,chip,chan,timebin,det,ring,sec,str,sam);
1064 //____________________________________________________________________
1066 AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t board,
1067 UShort_t chip, UShort_t chan,
1069 UShort_t& det, Char_t& ring,
1070 UShort_t& sec, Short_t& str,
1071 UShort_t& sam) const
1074 // Map a hardware address into a detector index.
1077 // ddl Hardware DDL number
1079 // altro ALTRO number
1080 // channel Channel number
1082 // det On return, the detector #
1083 // ring On return, the ring ID
1084 // sec On return, the sector #
1085 // str On return, the base of strip #
1086 // sam On return, the sample number for this strip
1089 // @c true on success, false otherwise
1091 if (!fAltroMap) return kFALSE;
1092 if (fAltroMap->DDL2Detector(ddl) < 0) return kFALSE;
1093 Short_t stripBase = 0;
1094 if (!fAltroMap->Channel2StripBase(board,chip,chan, ring, sec, stripBase))
1096 UShort_t preSamples = GetPreSamples(det, ring, sec, stripBase);
1097 UShort_t sampleRate = GetSampleRate(det, ring, sec, stripBase);
1098 Short_t stripOff = 0;
1099 fAltroMap->Timebin2Strip(sec, timebin, preSamples, sampleRate, stripOff, sam);
1100 str = stripBase + stripOff;
1101 AliFMDDebug(50, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d"
1102 " (pre=%2d, rate=%d)",
1103 ddl, board, chip, chan, timebin,
1104 det, ring, sec, str, sam, preSamples, sampleRate));
1109 //____________________________________________________________________
1111 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
1112 UShort_t sec, UShort_t str,
1114 UShort_t& ddl, UShort_t& board,
1115 UShort_t& altro, UShort_t& channel,
1116 UShort_t& timebin) const
1119 // Map a detector index into a hardware address.
1122 // det The detector #
1126 // sam The sample number
1127 // ddl On return, hardware DDL number
1128 // board On return, the FEC board address (local to DDL)
1129 // altro On return, the ALTRO number (local to FEC)
1130 // channel On return, the channel number (local to ALTRO)
1131 // timebin On return, the timebin number (local to ALTRO)
1134 // @c true on success, false otherwise
1136 if (!fAltroMap) return kFALSE;
1137 UShort_t preSamples = GetPreSamples(det, ring, sec, str);
1138 UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
1139 UShort_t strip = str - GetMinStrip(det,ring,sec,str);
1140 return fAltroMap->Detector2Hardware(det, ring, sec, strip, sam,
1141 preSamples, sampleRate,
1142 ddl, board, altro, channel, timebin);
1147 //____________________________________________________________________
1149 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
1150 UShort_t sec, UShort_t str,
1152 UShort_t& ddl, UShort_t& addr,
1153 UShort_t& timebin) const
1156 // Map a detector index into a hardware address.
1159 // det The detector #
1163 // sam The sample number
1164 // ddl On return, hardware DDL number
1165 // addr On return, hardware address.
1166 // timebin On return, the timebin number (local to ALTRO)
1169 // @c true on success, false otherwise
1171 if (!fAltroMap) return kFALSE;
1172 UShort_t preSamples = GetPreSamples(det, ring, sec, str);
1173 UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
1174 UShort_t strip = str - GetMinStrip(det,ring,sec,str);
1175 return fAltroMap->Detector2Hardware(det, ring, sec, strip, sam,
1176 preSamples, sampleRate,
1177 ddl, addr, timebin);
1181 //__________________________________________________________________
1183 AliFMDParameters::GetEdepMip() const
1187 // The average energy deposited by one MIP
1190 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
1191 fEdepMip = (fkSiDeDxMip
1192 * fmd->GetRing('I')->GetSiThickness()
1193 * fmd->GetSiDensity());
1197 //____________________________________________________________________
1199 AliFMDParameters::GetDACPerMIP() const
1202 // This is the conversion from Digital-to-Analog-Converter setting
1203 // to the number of MIPs. The number was measured in the NBI lab during
1207 // The conversion factor from DAC to ADC
1213 //____________________________________________________________________