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