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