]>
Commit | Line | Data |
---|---|---|
09b6c804 | 1 | /************************************************************************* |
1a1fdef7 | 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. * | |
09b6c804 | 14 | ************************************************************************* |
15 | * $Id$ */ | |
16 | /** | |
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 | |
21 | */ | |
1a1fdef7 | 22 | //____________________________________________________________________ |
23 | // | |
24 | // Forward Multiplicity Detector based on Silicon wafers. | |
25 | // | |
26 | // This class is a singleton that handles various parameters of | |
27 | // the FMD detectors. | |
6169f936 | 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. | |
1a1fdef7 | 32 | // |
f95a63c4 | 33 | #include "AliFMDDebug.h" // ALILOG_H |
8f6ee336 | 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 | |
c2fc1258 | 39 | #include "AliFMDCalibSampleRate.h" // ALIFMDCALIBSAMPLERATE_H |
40 | #include "AliFMDCalibStripRange.h" // ALIFMDCALIBSTRIPRANGE_H | |
57c3c593 | 41 | #include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H |
42 | #include <AliCDBManager.h> // ALICDBMANAGER_H | |
43 | #include <AliCDBEntry.h> // ALICDBMANAGER_H | |
dc02d468 | 44 | #include <AliFMDPreprocessor.h> |
45 | #include <AliLog.h> | |
1a1fdef7 | 46 | #include <Riostream.h> |
8ec606c2 | 47 | #include <sstream> |
dc02d468 | 48 | #include <TSystem.h> |
6169f936 | 49 | #include <TArrayF.h> |
50 | #include <TH2D.h> | |
1a1fdef7 | 51 | |
52 | //==================================================================== | |
53 | ClassImp(AliFMDParameters) | |
54 | #if 0 | |
55 | ; // This is here to keep Emacs for indenting the next line | |
56 | #endif | |
57 | ||
58 | //____________________________________________________________________ | |
59 | AliFMDParameters* AliFMDParameters::fgInstance = 0; | |
60 | ||
57c3c593 | 61 | //____________________________________________________________________ |
77186f44 | 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"; | |
57c3c593 | 72 | |
1a1fdef7 | 73 | //____________________________________________________________________ |
74 | AliFMDParameters* | |
75 | AliFMDParameters::Instance() | |
76 | { | |
09b6c804 | 77 | // |
1a1fdef7 | 78 | // Get static instance |
09b6c804 | 79 | // |
1a1fdef7 | 80 | if (!fgInstance) fgInstance = new AliFMDParameters; |
81 | return fgInstance; | |
82 | } | |
83 | ||
84 | //____________________________________________________________________ | |
85 | AliFMDParameters::AliFMDParameters() | |
57c3c593 | 86 | : fIsInit(kFALSE), |
02a27b50 | 87 | fkSiDeDxMip(1.664), |
b5ee4425 | 88 | fVA1MipRange(0), |
89 | fAltroChannelSize(0), | |
90 | fChannelsPerAltro(0), | |
91 | fPedestalFactor(0), | |
cce354f6 | 92 | fZSPre(0), |
93 | fZSPost(0), | |
94 | fZSPedSubtract(kFALSE), | |
b5ee4425 | 95 | fFixedPedestal(0), |
96 | fFixedPedestalWidth(0), | |
97 | fFixedZeroSuppression(0), | |
98 | fFixedSampleRate(0), | |
99 | fFixedThreshold(0), | |
100 | fFixedMinStrip(0), | |
101 | fFixedMaxStrip(0), | |
8f6ee336 | 102 | fFixedPulseGain(0), |
103 | fEdepMip(0), | |
625d7886 | 104 | fHasCompleteHeader(kTRUE), |
8f6ee336 | 105 | fZeroSuppression(0), |
106 | fSampleRate(0), | |
107 | fPedestal(0), | |
108 | fPulseGain(0), | |
57c3c593 | 109 | fDeadMap(0), |
c2fc1258 | 110 | fAltroMap(0), |
3d7ed4ed | 111 | fStripRange(0) |
1a1fdef7 | 112 | { |
09b6c804 | 113 | // |
1a1fdef7 | 114 | // Default constructor |
09b6c804 | 115 | // |
1a1fdef7 | 116 | SetVA1MipRange(); |
117 | SetAltroChannelSize(); | |
118 | SetChannelsPerAltro(); | |
119 | SetZeroSuppression(); | |
120 | SetSampleRate(); | |
121 | SetPedestal(); | |
122 | SetPedestalWidth(); | |
123 | SetPedestalFactor(); | |
8f6ee336 | 124 | SetThreshold(); |
c2fc1258 | 125 | SetStripRange(); |
06ca6759 | 126 | fAltroMap = new AliFMDAltroMapping; |
1a1fdef7 | 127 | } |
128 | ||
57c3c593 | 129 | //__________________________________________________________________ |
130 | void | |
f6449cc0 | 131 | AliFMDParameters::Init(Bool_t forceReInit, UInt_t what) |
57c3c593 | 132 | { |
09b6c804 | 133 | // |
134 | // Initialize the manager. This tries to read the parameters from | |
135 | // CDB. If that fails, the class uses the hard-coded parameters. | |
136 | // | |
137 | // Parameters: | |
138 | // forceReInit Force (re-)initalize flag | |
139 | // what What to initialize | |
140 | // | |
a9579262 | 141 | if (forceReInit) fIsInit = kFALSE; |
57c3c593 | 142 | if (fIsInit) return; |
f6449cc0 | 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(); | |
6bf06d81 | 149 | if (what & kStripRange) InitStripRange(); |
1e8f773e | 150 | fIsInit = kTRUE; |
dc02d468 | 151 | } |
152 | //__________________________________________________________________ | |
153 | void | |
154 | AliFMDParameters::Init(AliFMDPreprocessor* pp, Bool_t forceReInit, UInt_t what) | |
155 | { | |
09b6c804 | 156 | // |
157 | // Initialize the manager. This tries to read the parameters from | |
158 | // CDB. If that fails, the class uses the hard-coded parameters. | |
159 | // | |
160 | // Parameters: | |
161 | // pp Preprocessor | |
162 | // forceReInit Force (re-)initalize flag | |
163 | // what What to initialize | |
164 | // | |
dc02d468 | 165 | if (forceReInit) fIsInit = kFALSE; |
166 | if (fIsInit) return; | |
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); | |
6bf06d81 | 173 | if (what & kStripRange) InitStripRange(pp); |
dc02d468 | 174 | fIsInit = kTRUE; |
1e8f773e | 175 | } |
c2fc1258 | 176 | |
f560b28c | 177 | //__________________________________________________________________ |
178 | Bool_t | |
179 | AliFMDParameters::CheckFile(const char* prefix, | |
180 | const char* path, | |
181 | int number, | |
182 | TString& f) const | |
183 | { | |
09b6c804 | 184 | // |
185 | // Check if the file <i>prefix</i><i>number</i> exists in @a path, | |
186 | // and write the full path to @a f. | |
187 | // | |
188 | // Parameters: | |
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) | |
193 | // | |
194 | // Return: | |
195 | // @c true if file exists and is readable, @c false otherwise | |
196 | // | |
f560b28c | 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())); | |
201 | return !f.IsNull(); | |
202 | } | |
203 | ||
204 | //__________________________________________________________________ | |
205 | void | |
206 | AliFMDParameters::Init(const char* path, Bool_t forceReInit, UInt_t what) | |
207 | { | |
09b6c804 | 208 | // |
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 | |
214 | // OCDB. | |
215 | // | |
216 | // The CSV files should be named as | |
217 | // | |
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> | |
222 | // | |
223 | // where <i>det_number</i> is the detector number (1, 2, or 3). | |
224 | // | |
225 | // Parameters: | |
226 | // path Where to look for the CSV files | |
227 | // forceReInit Always reinitialise | |
228 | // what What calibrations to load. | |
229 | // | |
f560b28c | 230 | if (forceReInit) fIsInit = kFALSE; |
231 | if (fIsInit) return; | |
232 | ||
233 | AliFMDCalibStripRange* range = 0; | |
234 | AliFMDCalibSampleRate* rate = 0; | |
235 | AliFMDCalibPedestal* peds = 0; | |
236 | AliFMDCalibGain* gains = 0; | |
237 | ||
238 | for (Int_t i = 1; i <= 3; i++) { | |
239 | TString f; | |
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); | |
247 | in.close(); | |
248 | } | |
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); | |
253 | in.close(); | |
254 | } | |
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); | |
259 | in.close(); | |
260 | } | |
261 | } | |
262 | ||
263 | if (range) what &= ~kStripRange; | |
264 | if (rate) what &= ~kSampleRate; | |
265 | if (peds) what &= ~kPedestal; | |
266 | if (gains) what &= ~kPulseGain; | |
267 | ||
268 | Init(kFALSE, what); | |
269 | ||
270 | if (range) SetStripRange(range); | |
271 | if (rate) SetSampleRate(rate); | |
272 | if (peds) SetPedestal(peds); | |
273 | if (gains) SetGain(gains); | |
274 | ||
275 | fIsInit = kTRUE; | |
276 | } | |
277 | ||
278 | //__________________________________________________________________ | |
279 | void | |
280 | AliFMDParameters::MakeDeadMap(Float_t maxNoise, | |
281 | Float_t minGain, | |
282 | Float_t maxGain) | |
283 | { | |
09b6c804 | 284 | // |
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). | |
289 | // | |
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. | |
294 | // | |
295 | // Parameters: | |
296 | // maxNoise Maximum noise value before a channel is marked | |
297 | // as dead. | |
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. | |
302 | // | |
f560b28c | 303 | if (fPedestal) |
304 | fDeadMap = fPedestal->MakeDeadMap(maxNoise, fDeadMap); | |
305 | if (fPulseGain) | |
306 | fDeadMap = fPulseGain->MakeDeadMap(minGain, maxGain, fDeadMap); | |
307 | } | |
6169f936 | 308 | //__________________________________________________________________ |
309 | #define DET2IDX(det,ring,sec,str) \ | |
a9579262 | 310 | (det * 1000 + (ring == 'I' ? 0 : 512) + str) |
6169f936 | 311 | |
312 | //__________________________________________________________________ | |
313 | void | |
314 | AliFMDParameters::Draw(Option_t* option) | |
315 | { | |
09b6c804 | 316 | // |
317 | // Draw parameters. | |
318 | // | |
319 | // Parameters: | |
320 | // option What to draw. Should be one of | |
321 | // - dead Dead channels | |
322 | // - threshold Threshold | |
323 | // - gain Gain | |
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 | |
331 | // | |
6169f936 | 332 | TString opt(option); |
333 | enum { | |
458e52e8 | 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 | |
6169f936 | 344 | } what; |
6169f936 | 345 | |
346 | if (opt.Contains("dead", TString::kIgnoreCase)) | |
458e52e8 | 347 | what = kLocalDead; |
6169f936 | 348 | else if (opt.Contains("threshold",TString::kIgnoreCase)) |
458e52e8 | 349 | what = kLocalThreshold; |
6169f936 | 350 | else if (opt.Contains("gain",TString::kIgnoreCase)) |
458e52e8 | 351 | what = kLocalPulseGain; |
6169f936 | 352 | else if (opt.Contains("pedestal",TString::kIgnoreCase)) |
458e52e8 | 353 | what = kLocalPedestal; |
6169f936 | 354 | else if (opt.Contains("noise",TString::kIgnoreCase)) |
458e52e8 | 355 | what = kLocalPedestalWidth; |
6169f936 | 356 | else if (opt.Contains("zero",TString::kIgnoreCase)) |
458e52e8 | 357 | what = kLocalZeroSuppression; |
6169f936 | 358 | else if (opt.Contains("rate",TString::kIgnoreCase)) |
458e52e8 | 359 | what = kLocalSampleRate; |
6169f936 | 360 | else if (opt.Contains("min",TString::kIgnoreCase)) |
458e52e8 | 361 | what = kLocalMinStripRange; |
6169f936 | 362 | else if (opt.Contains("max",TString::kIgnoreCase)) |
458e52e8 | 363 | what = kLocalMaxStripRange; |
6169f936 | 364 | else if (opt.Contains("map",TString::kIgnoreCase)) |
458e52e8 | 365 | what = kLocalAltroMap; |
6169f936 | 366 | else { |
367 | Warning("Draw", "unknown parameter: %s\n\tShould be one of\n\t" | |
368 | "dead, threshold, gain, pedestal, noise, zero, rate, " | |
369 | "min, max, map", | |
370 | option); | |
371 | return; | |
372 | } | |
373 | ||
374 | TArrayD xbins(3 * 512 + 2 * 256 + 5); | |
375 | Int_t i = 1; | |
376 | Bool_t skip = kTRUE; | |
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++) { | |
a9579262 | 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++) { | |
6169f936 | 386 | Int_t idx = DET2IDX(det, ring, 0, str); |
a9579262 | 387 | // Int_t idx = DET2IDX(det, ring, sec, 0); |
6169f936 | 388 | if (skip) { |
389 | xbins[i-1] = idx - .5; | |
390 | skip = kFALSE; | |
391 | } | |
392 | xbins[i] = idx + .5; | |
393 | i++; | |
394 | } | |
395 | skip = kTRUE; | |
396 | i++; | |
397 | } | |
398 | } | |
399 | TArrayD ybins(41); | |
458e52e8 | 400 | for (/*Int_t*/ i = 0; i < ybins.fN; i++) ybins[i] = Float_t(i - .5); |
6169f936 | 401 | TH2D* hist = new TH2D("calib", Form("Calibration %s", option), |
402 | xbins.fN-1, xbins.fArray, | |
403 | ybins.fN-1, ybins.fArray); | |
a9579262 | 404 | hist->GetXaxis()->SetTitle("1000 #times detector + 512 #times ring + strip"); |
405 | hist->GetYaxis()->SetTitle("sector"); | |
406 | ||
6169f936 | 407 | // hist->Draw("Lego"); |
408 | // return; | |
409 | ||
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); | |
b995fc28 | 419 | UShort_t ddl, addr, time, sam=0; |
6169f936 | 420 | Double_t val = 0; |
421 | switch (what) { | |
458e52e8 | 422 | case kLocalPulseGain: // Path to PulseGain calib object |
6169f936 | 423 | val = GetPulseGain(det,ring,sec,str); break; |
458e52e8 | 424 | case kLocalThreshold: // Path to PulseGain calib object |
6169f936 | 425 | val = GetThreshold(); break; |
458e52e8 | 426 | case kLocalPedestal: // Path to Pedestal calib object |
6169f936 | 427 | val = GetPedestal(det,ring,sec,str); break; |
458e52e8 | 428 | case kLocalPedestalWidth: // Path to Pedestal calib object |
6169f936 | 429 | val = GetPedestalWidth(det,ring,sec,str); break; |
458e52e8 | 430 | case kLocalDead: // Path to Dead calib object |
6169f936 | 431 | val = IsDead(det,ring,sec,str); break; |
458e52e8 | 432 | case kLocalSampleRate: // Path to SampleRate calib object |
6169f936 | 433 | val = GetSampleRate(det,ring,sec,str); break; |
458e52e8 | 434 | case kLocalAltroMap: // Path to AltroMap calib object |
b995fc28 | 435 | Detector2Hardware(det,ring,sec,str,sam,ddl,addr,time); |
6169f936 | 436 | val = addr; break; |
458e52e8 | 437 | case kLocalZeroSuppression: // Path to ZeroSuppression cal object |
6169f936 | 438 | val = GetZeroSuppression(det,ring,sec,str); break; |
458e52e8 | 439 | case kLocalMinStripRange: // Path to strip range cal object |
6169f936 | 440 | val = GetMinStrip(det,ring,sec,str); break; |
458e52e8 | 441 | case kLocalMaxStripRange: // Path to strip range cal object |
6169f936 | 442 | val = GetMaxStrip(det,ring,sec,str); break; |
443 | } | |
444 | hist->Fill(idx,sec,val); | |
a9579262 | 445 | // hist->Fill(idx,str,val); |
6169f936 | 446 | } |
447 | } | |
448 | } | |
449 | } | |
450 | hist->Draw("lego"); | |
451 | } | |
452 | ||
c2fc1258 | 453 | //__________________________________________________________________ |
454 | void | |
455 | AliFMDParameters::Print(Option_t* option) const | |
456 | { | |
02a27b50 | 457 | // Print information. |
458 | // If option contains an 'A' then everything is printed. | |
a9579262 | 459 | // If the option contains the string "FMD" the function will search |
460 | // for detector, ring, sector, and strip numbers to print, in the | |
461 | // format | |
462 | // | |
463 | // FMD<detector><ring>[<sector>,<string>] | |
464 | // | |
465 | // The wild card '*' means all of <detector>, <ring>, <sector>, or | |
466 | // <strip>. | |
c2fc1258 | 467 | TString opt(option); |
a9579262 | 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; | |
475 | ||
476 | ||
8ec606c2 | 477 | if (opt.Contains("fmd",TString::kIgnoreCase)) { |
7868d9e2 | 478 | Int_t i = opt.Index("fmd",TString::kIgnoreCase); |
479 | Int_t j = opt.Index("]",TString::kIgnoreCase); | |
480 | if (j != kNPOS) | |
481 | showStrips = kTRUE; | |
482 | else | |
483 | j = opt.Length(); | |
a9579262 | 484 | enum { |
97e94238 | 485 | kReadDet, |
486 | kReadRing, | |
487 | kReadLbrack, | |
488 | kReadSector, | |
489 | kReadComma, | |
490 | kReadStrip, | |
491 | kReadRbrack, | |
492 | kEnd | |
493 | } state = kReadDet; | |
8ec606c2 | 494 | std::stringstream s(opt(i+4, j-i-3).Data()); |
97e94238 | 495 | while (state != kEnd) { |
a9579262 | 496 | Char_t tmp = s.peek(); |
497 | if (tmp == ' ' || tmp == '\t') { | |
498 | s.get(); | |
499 | continue; | |
500 | } | |
501 | switch (state) { | |
97e94238 | 502 | case kReadDet: { // First, try to kRead the detector |
a9579262 | 503 | if (tmp == '*') s.get(); |
504 | else { | |
505 | UShort_t det; | |
506 | s >> det; | |
507 | if (!s.bad()) { | |
508 | ds[0] = det; | |
509 | ds[1] = 0; | |
510 | } | |
511 | } | |
97e94238 | 512 | state = (s.bad() ? kEnd : kReadRing); |
a9579262 | 513 | } break; |
97e94238 | 514 | case kReadRing: { // Then try to read the ring; |
a9579262 | 515 | Char_t ring; |
516 | s >> ring; | |
517 | if (ring != '*' && !s.bad()) { | |
518 | rs[0] = ring; | |
519 | rs[1] = '\0'; | |
520 | } | |
97e94238 | 521 | state = (s.bad() ? kEnd : kReadLbrack); |
a9579262 | 522 | } break; |
97e94238 | 523 | case kReadLbrack: { // Try to read a left bracket |
a9579262 | 524 | Char_t lbrack; |
525 | s >> lbrack; | |
97e94238 | 526 | state = (s.bad() ? kEnd : kReadSector); |
a9579262 | 527 | } break; |
97e94238 | 528 | case kReadSector: { // Try to read a sector |
a9579262 | 529 | if (tmp == '*') s.get(); |
530 | else { | |
531 | UShort_t sec; | |
532 | s >> sec; | |
533 | if (!s.bad()) { | |
534 | minSector = sec; | |
535 | maxSector = sec + 1; | |
536 | } | |
537 | } | |
97e94238 | 538 | state = (s.bad() ? kEnd : kReadComma); |
a9579262 | 539 | } break; |
97e94238 | 540 | case kReadComma: { // Try to read a left bracket |
a9579262 | 541 | Char_t comma; |
542 | s >> comma; | |
97e94238 | 543 | state = (s.bad() ? kEnd : kReadStrip); |
a9579262 | 544 | } break; |
97e94238 | 545 | case kReadStrip: { // Try to read a strip |
a9579262 | 546 | if (tmp == '*') s.get(); |
547 | else { | |
548 | UShort_t str; | |
549 | s >> str; | |
550 | if (!s.bad()) { | |
551 | minStrip = str; | |
552 | maxStrip = str + 1; | |
553 | } | |
554 | } | |
97e94238 | 555 | state = (s.bad() ? kEnd : kReadRbrack); |
a9579262 | 556 | } break; |
97e94238 | 557 | case kReadRbrack: { // Try to read a left bracket |
a9579262 | 558 | Char_t rbrack; |
559 | s >> rbrack; | |
97e94238 | 560 | state = kEnd; |
a9579262 | 561 | } break; |
97e94238 | 562 | case kEnd: |
a9579262 | 563 | break; |
564 | } | |
565 | } | |
8ec606c2 | 566 | } |
a9579262 | 567 | UShort_t* dp = ds; |
568 | UShort_t det; | |
569 | while ((det = *(dp++))) { | |
570 | ||
571 | Char_t* rp = rs; | |
572 | Char_t ring; | |
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); | |
a9579262 | 577 | std::cout << "FMD" << det << ring |
578 | << " Strip range: " | |
579 | << std::setw(3) << min << "," | |
ef8e8623 | 580 | << std::setw(3) << max << std::endl; |
a9579262 | 581 | |
a9579262 | 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++) { | |
ef8e8623 | 585 | |
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; | |
589 | ||
590 | if (!showStrips) continue; | |
c2fc1258 | 591 | std::cout |
8ec606c2 | 592 | << " Strip | Pedestal | Gain | ZS thr. | Address\n" |
593 | << "--------+-------------------+------------+---------+---------" | |
c2fc1258 | 594 | << std::endl; |
a9579262 | 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)) { | |
c2fc1258 | 600 | std::cout << "dead" << std::endl; |
601 | continue; | |
602 | } | |
b995fc28 | 603 | UShort_t ddl, addr, time, sam=0; |
604 | Detector2Hardware(det, ring, sec, str, sam, ddl, addr, time); | |
a9579262 | 605 | std::cout << std::setw(7) << GetPedestal(det, ring, sec, str) |
c2fc1258 | 606 | << "+/-" << std::setw(7) |
a9579262 | 607 | << GetPedestalWidth(det, ring, sec, str) |
8ec606c2 | 608 | << " | " << std::setw(10) |
a9579262 | 609 | << GetPulseGain(det, ring, sec, str) |
610 | << " | " << std::setw(7) | |
611 | << GetZeroSuppression(det, ring, sec, str) | |
c2fc1258 | 612 | << " | 0x" << std::hex << std::setw(4) |
613 | << std::setfill('0') << ddl << ",0x" << std::setw(3) | |
614 | << addr << std::dec << std::setfill(' ') << std::endl; | |
a9579262 | 615 | } // for (strip) |
616 | } // for (sector) | |
617 | std::cout | |
618 | << "=============================================================" | |
619 | << std::endl; | |
620 | } // while (ring) | |
621 | } // while (det) | |
622 | ||
c2fc1258 | 623 | } |
624 | ||
dc02d468 | 625 | //__________________________________________________________________ |
626 | AliCDBEntry* | |
627 | AliFMDParameters::GetEntry(const char* path, AliFMDPreprocessor* pp, | |
628 | Bool_t fatal) const | |
629 | { | |
09b6c804 | 630 | // |
631 | // Get an entry from either global AliCDBManager or passed | |
632 | // AliFMDPreprocessor. | |
633 | // | |
634 | // Parameters: | |
635 | // path Path to CDB object. | |
636 | // pp AliFMDPreprocessor | |
637 | // fatal If true, raise a fatal flag if we didn't get the entry. | |
638 | // Return: | |
639 | // AliCDBEntry if found | |
640 | // | |
dc02d468 | 641 | AliCDBEntry* entry = 0; |
642 | if (!pp) { | |
643 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
644 | entry = cdb->Get(path); | |
645 | } | |
646 | else { | |
647 | const char* third = gSystem->BaseName(path); | |
648 | const char* second = gSystem->BaseName(gSystem->DirName(path)); | |
649 | entry = pp->GetFromCDB(second, third); | |
650 | } | |
651 | if (!entry) { | |
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__, | |
657 | __LINE__); | |
658 | return 0; | |
659 | } | |
660 | return entry; | |
661 | } | |
662 | ||
663 | ||
1e8f773e | 664 | //__________________________________________________________________ |
665 | void | |
dc02d468 | 666 | AliFMDParameters::InitPulseGain(AliFMDPreprocessor* pp) |
1e8f773e | 667 | { |
09b6c804 | 668 | // |
669 | // Initialize gains. Try to get them from CDB | |
670 | // | |
671 | // Parameters: | |
672 | // pp Pre-processor if called from shuttle | |
673 | // | |
dc02d468 | 674 | AliCDBEntry* gain = GetEntry(fgkPulseGain, pp); |
675 | if (!gain) return; | |
57c3c593 | 676 | |
42f1b2f5 | 677 | AliFMDDebug(5, ("Got gain from CDB")); |
1e8f773e | 678 | fPulseGain = dynamic_cast<AliFMDCalibGain*>(gain->GetObject()); |
f95a63c4 | 679 | if (!fPulseGain) AliFatal("Invalid pulser gain object from CDB"); |
1e8f773e | 680 | } |
681 | //__________________________________________________________________ | |
682 | void | |
dc02d468 | 683 | AliFMDParameters::InitPedestal(AliFMDPreprocessor* pp) |
1e8f773e | 684 | { |
09b6c804 | 685 | // |
686 | // Initialize pedestals. Try to get them from CDB | |
687 | // | |
688 | // Parameters: | |
689 | // pp Pre-processor if called from shuttle | |
690 | // | |
dc02d468 | 691 | AliCDBEntry* pedestal = GetEntry(fgkPedestal, pp); |
692 | if (!pedestal) return; | |
693 | ||
42f1b2f5 | 694 | AliFMDDebug(5, ("Got pedestal from CDB")); |
1e8f773e | 695 | fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject()); |
f95a63c4 | 696 | if (!fPedestal) AliFatal("Invalid pedestal object from CDB"); |
1e8f773e | 697 | } |
698 | ||
699 | //__________________________________________________________________ | |
700 | void | |
dc02d468 | 701 | AliFMDParameters::InitDeadMap(AliFMDPreprocessor* pp) |
1e8f773e | 702 | { |
09b6c804 | 703 | // |
704 | // Initialize dead map. Try to get it from CDB | |
705 | // | |
706 | // Parameters: | |
707 | // pp Pre-processor if called from shuttle | |
708 | // | |
dc02d468 | 709 | AliCDBEntry* deadMap = GetEntry(fgkDead, pp); |
710 | if (!deadMap) return; | |
711 | ||
42f1b2f5 | 712 | AliFMDDebug(5, ("Got dead map from CDB")); |
1e8f773e | 713 | fDeadMap = dynamic_cast<AliFMDCalibDeadMap*>(deadMap->GetObject()); |
f95a63c4 | 714 | if (!fDeadMap) AliFatal("Invalid dead map object from CDB"); |
1e8f773e | 715 | } |
716 | ||
717 | //__________________________________________________________________ | |
718 | void | |
dc02d468 | 719 | AliFMDParameters::InitZeroSuppression(AliFMDPreprocessor* pp) |
1e8f773e | 720 | { |
09b6c804 | 721 | // |
722 | // Initialize zero suppression thresholds. Try to get them from CDB | |
723 | // | |
724 | // Parameters: | |
725 | // pp Pre-processor if called from shuttle | |
726 | // | |
dc02d468 | 727 | AliCDBEntry* zeroSup = GetEntry(fgkZeroSuppression, pp); |
728 | if (!zeroSup) return; | |
42f1b2f5 | 729 | AliFMDDebug(5, ("Got zero suppression from CDB")); |
1e8f773e | 730 | fZeroSuppression = |
731 | dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject()); | |
f95a63c4 | 732 | if (!fZeroSuppression)AliFatal("Invalid zero suppression object from CDB"); |
1e8f773e | 733 | } |
734 | ||
735 | //__________________________________________________________________ | |
736 | void | |
dc02d468 | 737 | AliFMDParameters::InitSampleRate(AliFMDPreprocessor* pp) |
1e8f773e | 738 | { |
09b6c804 | 739 | // |
740 | // Initialize sample rates. Try to get them from CDB | |
741 | // | |
742 | // Parameters: | |
743 | // pp Pre-processor if called from shuttle | |
744 | // | |
dc02d468 | 745 | AliCDBEntry* sampRat = GetEntry(fgkSampleRate, pp); |
746 | if (!sampRat) return; | |
42f1b2f5 | 747 | AliFMDDebug(5, ("Got zero suppression from CDB")); |
1e8f773e | 748 | fSampleRate = dynamic_cast<AliFMDCalibSampleRate*>(sampRat->GetObject()); |
f95a63c4 | 749 | if (!fSampleRate) AliFatal("Invalid zero suppression object from CDB"); |
1e8f773e | 750 | } |
751 | ||
752 | //__________________________________________________________________ | |
753 | void | |
dc02d468 | 754 | AliFMDParameters::InitAltroMap(AliFMDPreprocessor* pp) |
1e8f773e | 755 | { |
09b6c804 | 756 | // |
757 | // Initialize hardware map. Try to get it from CDB | |
758 | // | |
759 | // Parameters: | |
760 | // pp Pre-processor if called from shuttle | |
761 | // | |
06ca6759 | 762 | if (fAltroMap) { |
763 | delete fAltroMap; | |
764 | fAltroMap = 0; | |
765 | } | |
458e52e8 | 766 | AliCDBEntry* hwMap = GetEntry(fgkAltroMap, pp, kFALSE); |
dc02d468 | 767 | if (!hwMap) return; |
768 | ||
42f1b2f5 | 769 | AliFMDDebug(5, ("Got ALTRO map from CDB")); |
1e8f773e | 770 | fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject()); |
771 | if (!fAltroMap) { | |
f95a63c4 | 772 | AliFatal("Invalid ALTRO map object from CDB"); |
1e8f773e | 773 | fAltroMap = new AliFMDAltroMapping; |
57c3c593 | 774 | } |
57c3c593 | 775 | } |
776 | ||
c2fc1258 | 777 | //__________________________________________________________________ |
778 | void | |
dc02d468 | 779 | AliFMDParameters::InitStripRange(AliFMDPreprocessor* pp) |
c2fc1258 | 780 | { |
09b6c804 | 781 | // |
782 | // Initialize strip range. Try to get it from CDB | |
783 | // | |
784 | // Parameters: | |
785 | // pp Pre-processor if called from shuttle | |
786 | // | |
dc02d468 | 787 | AliCDBEntry* range = GetEntry(fgkStripRange, pp); |
788 | if (!range) return; | |
42f1b2f5 | 789 | AliFMDDebug(5, ("Got strip range from CDB")); |
c2fc1258 | 790 | fStripRange = dynamic_cast<AliFMDCalibStripRange*>(range->GetObject()); |
f95a63c4 | 791 | if (!fStripRange) AliFatal("Invalid strip range object from CDB"); |
c2fc1258 | 792 | } |
793 | ||
1e8f773e | 794 | |
8f6ee336 | 795 | //__________________________________________________________________ |
796 | Float_t | |
797 | AliFMDParameters::GetThreshold() const | |
798 | { | |
09b6c804 | 799 | // |
800 | // Get the threshold in the pulser gain | |
801 | // | |
802 | // | |
803 | // Return: | |
804 | // Threshold from pulser | |
805 | // | |
8f6ee336 | 806 | if (!fPulseGain) return fFixedThreshold; |
807 | return fPulseGain->Threshold(); | |
808 | } | |
809 | ||
810 | //__________________________________________________________________ | |
811 | Float_t | |
812 | AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring, | |
813 | UShort_t sector, UShort_t strip) const | |
814 | { | |
8f6ee336 | 815 | // |
09b6c804 | 816 | // Gain of pre-amp. for strip, sector, ring, detector |
817 | // | |
818 | // For simulations this is normally set to | |
819 | // | |
820 | // @f[ | |
821 | // \frac{\mbox{VA1_MIP_Range}{\mbox{ALTRO_channel_size}}\mbox{MIP_Energy_Loss} | |
822 | // @f] | |
8f6ee336 | 823 | // |
8f6ee336 | 824 | // |
09b6c804 | 825 | // Parameters: |
826 | // detector Detector # (1-3) | |
827 | // ring Ring ID ('I' or 'O') | |
828 | // sector Sector number (0-39) | |
829 | // strip Strip number (0-511) | |
830 | // | |
831 | // Return: | |
832 | // Gain of pre-amp. | |
833 | // | |
8f6ee336 | 834 | if (!fPulseGain) { |
835 | if (fFixedPulseGain <= 0) | |
836 | fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize; | |
837 | return fFixedPulseGain; | |
838 | } | |
f95a63c4 | 839 | AliFMDDebug(50, ("pulse gain for FMD%d%c[%2d,%3d]=%f", |
1e8f773e | 840 | detector, ring, sector, strip, |
841 | fPulseGain->Value(detector, ring, sector, strip))); | |
8f6ee336 | 842 | return fPulseGain->Value(detector, ring, sector, strip); |
843 | } | |
844 | ||
845 | //__________________________________________________________________ | |
846 | Bool_t | |
847 | AliFMDParameters::IsDead(UShort_t detector, Char_t ring, | |
848 | UShort_t sector, UShort_t strip) const | |
849 | { | |
09b6c804 | 850 | // |
851 | // Whether the strip is considered dead | |
852 | // | |
853 | // Parameters: | |
854 | // detector Detector # (1-3) | |
855 | // ring Ring ID ('I' or 'O') | |
856 | // sector Sector number (0-39) | |
857 | // strip Strip number (0-511) | |
858 | // | |
859 | // Return: | |
860 | // @c true if the strip is considered dead, @c false if it's | |
861 | // OK. | |
862 | // | |
8f6ee336 | 863 | if (!fDeadMap) return kFALSE; |
f95a63c4 | 864 | AliFMDDebug(50, ("Dead for FMD%d%c[%2d,%3d]=%s", |
1e8f773e | 865 | detector, ring, sector, strip, |
866 | fDeadMap->operator()(detector, ring, sector, strip) ? | |
867 | "no" : "yes")); | |
8f6ee336 | 868 | return fDeadMap->operator()(detector, ring, sector, strip); |
869 | } | |
870 | ||
871 | //__________________________________________________________________ | |
872 | UShort_t | |
873 | AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring, | |
874 | UShort_t sector, UShort_t strip) const | |
875 | { | |
09b6c804 | 876 | // |
877 | // zero suppression threshold (in ADC counts) | |
878 | // | |
879 | // Parameters: | |
880 | // detector Detector # (1-3) | |
881 | // ring Ring ID ('I' or 'O') | |
882 | // sector Sector number (0-39) | |
883 | // strip Strip number (0-511) | |
884 | // | |
885 | // Return: | |
886 | // zero suppression threshold (in ADC counts) | |
887 | // | |
8f6ee336 | 888 | if (!fZeroSuppression) return fFixedZeroSuppression; |
889 | // Need to map strip to ALTRO chip. | |
4f8dd8ab | 890 | AliFMDDebug(50, ("zero sup. for FMD%d%c[%2d,%3d]=%d", |
1e8f773e | 891 | detector, ring, sector, strip, |
892 | fZeroSuppression->operator()(detector, ring, | |
893 | sector, strip))); | |
8f6ee336 | 894 | return fZeroSuppression->operator()(detector, ring, sector, strip/128); |
895 | } | |
896 | ||
897 | //__________________________________________________________________ | |
898 | UShort_t | |
c2fc1258 | 899 | AliFMDParameters::GetSampleRate(UShort_t det, Char_t ring, UShort_t sector, |
900 | UShort_t str) const | |
8f6ee336 | 901 | { |
09b6c804 | 902 | // |
903 | // Get the sampling rate | |
904 | // | |
905 | // Parameters: | |
906 | // detector Detector # (1-3) | |
907 | // ring Ring ID ('I' or 'O') | |
908 | // sector Sector number (0-39) | |
909 | // strip Strip number (0-511) | |
910 | // | |
911 | // Return: | |
912 | // The sampling rate | |
913 | // | |
8f6ee336 | 914 | if (!fSampleRate) return fFixedSampleRate; |
915 | // Need to map sector to digitizier card. | |
c2fc1258 | 916 | UInt_t ret = fSampleRate->Rate(det, ring, sector, str); |
f95a63c4 | 917 | AliFMDDebug(50, ("Sample rate for FMD%d%c[%2d,%3d]=%d", |
c2fc1258 | 918 | det, ring, sector, str, ret)); |
919 | return ret; | |
920 | } | |
921 | ||
922 | //__________________________________________________________________ | |
923 | UShort_t | |
924 | AliFMDParameters::GetMinStrip(UShort_t det, Char_t ring, UShort_t sector, | |
925 | UShort_t str) const | |
926 | { | |
09b6c804 | 927 | // |
928 | // Get the minimum strip in the read-out range | |
929 | // | |
930 | // Parameters: | |
931 | // detector Detector # (1-3) | |
932 | // ring Ring ID ('I' or 'O') | |
933 | // sector Sector number (0-39) | |
934 | // strip Strip number (0-511) | |
935 | // | |
936 | // Return: | |
937 | // Minimum strip | |
938 | // | |
c2fc1258 | 939 | if (!fStripRange) return fFixedMinStrip; |
940 | // Need to map sector to digitizier card. | |
941 | UInt_t ret = fStripRange->Min(det, ring, sector, str); | |
f95a63c4 | 942 | AliFMDDebug(50, ("Min strip # for FMD%d%c[%2d,%3d]=%d", |
c2fc1258 | 943 | det, ring, sector, str, ret)); |
944 | return ret; | |
945 | } | |
946 | ||
947 | //__________________________________________________________________ | |
948 | UShort_t | |
949 | AliFMDParameters::GetMaxStrip(UShort_t det, Char_t ring, UShort_t sector, | |
950 | UShort_t str) const | |
951 | { | |
09b6c804 | 952 | // |
953 | // Get the maximum strip in the read-out range | |
954 | // | |
955 | // Parameters: | |
956 | // detector Detector # (1-3) | |
957 | // ring Ring ID ('I' or 'O') | |
958 | // sector Sector number (0-39) | |
959 | // strip Strip number (0-511) | |
960 | // | |
961 | // Return: | |
962 | // Maximum strip | |
963 | // | |
c2fc1258 | 964 | if (!fStripRange) return fFixedMaxStrip; |
965 | // Need to map sector to digitizier card. | |
966 | UInt_t ret = fStripRange->Max(det, ring, sector, str); | |
f95a63c4 | 967 | AliFMDDebug(50, ("Max strip # for FMD%d%c[%2d,%3d]=%d", |
c2fc1258 | 968 | det, ring, sector, str, ret)); |
969 | return ret; | |
8f6ee336 | 970 | } |
1a1fdef7 | 971 | |
8f6ee336 | 972 | //__________________________________________________________________ |
973 | Float_t | |
974 | AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring, | |
975 | UShort_t sector, UShort_t strip) const | |
976 | { | |
09b6c804 | 977 | // |
978 | // Get mean of pedestal | |
979 | // | |
980 | // Parameters: | |
981 | // detector Detector # (1-3) | |
982 | // ring Ring ID ('I' or 'O') | |
983 | // sector Sector number (0-39) | |
984 | // strip Strip number (0-511) | |
985 | // | |
986 | // Return: | |
987 | // Mean of pedestal | |
988 | // | |
8f6ee336 | 989 | if (!fPedestal) return fFixedPedestal; |
f95a63c4 | 990 | AliFMDDebug(50, ("pedestal for FMD%d%c[%2d,%3d]=%f", |
1e8f773e | 991 | detector, ring, sector, strip, |
992 | fPedestal->Value(detector, ring, sector, strip))); | |
8f6ee336 | 993 | return fPedestal->Value(detector, ring, sector, strip); |
994 | } | |
995 | ||
996 | //__________________________________________________________________ | |
997 | Float_t | |
998 | AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring, | |
999 | UShort_t sector, UShort_t strip) const | |
1000 | { | |
09b6c804 | 1001 | // |
1002 | // Width of pedestal | |
1003 | // | |
1004 | // Parameters: | |
1005 | // detector Detector # (1-3) | |
1006 | // ring Ring ID ('I' or 'O') | |
1007 | // sector Sector number (0-39) | |
1008 | // strip Strip number (0-511) | |
1009 | // | |
1010 | // Return: | |
1011 | // Width of pedestal | |
1012 | // | |
8f6ee336 | 1013 | if (!fPedestal) return fFixedPedestalWidth; |
f95a63c4 | 1014 | AliFMDDebug(50, ("pedetal width for FMD%d%c[%2d,%3d]=%f", |
1e8f773e | 1015 | detector, ring, sector, strip, |
1016 | fPedestal->Width(detector, ring, sector, strip))); | |
8f6ee336 | 1017 | return fPedestal->Width(detector, ring, sector, strip); |
1018 | } | |
1019 | ||
1a1fdef7 | 1020 | //__________________________________________________________________ |
57c3c593 | 1021 | AliFMDAltroMapping* |
1022 | AliFMDParameters::GetAltroMap() const | |
1023 | { | |
09b6c804 | 1024 | // |
1025 | // Get the map that translates hardware to detector coordinates | |
1026 | // | |
1027 | // Return: | |
1028 | // Get the map that translates hardware to detector | |
1029 | // coordinates | |
1030 | // | |
57c3c593 | 1031 | return fAltroMap; |
1a1fdef7 | 1032 | } |
1033 | ||
57c3c593 | 1034 | |
f38b1653 | 1035 | //____________________________________________________________________ |
1036 | Bool_t | |
b995fc28 | 1037 | AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t addr, |
f38b1653 | 1038 | UShort_t timebin, |
b995fc28 | 1039 | UShort_t& det, Char_t& ring, |
f38b1653 | 1040 | UShort_t& sec, Short_t& str, |
1041 | UShort_t& sam) const | |
1042 | { | |
f38b1653 | 1043 | // |
09b6c804 | 1044 | // Map a hardware address into a detector index. |
1045 | // | |
1046 | // Parameters: | |
1047 | // ddl Hardware DDL number | |
1048 | // addr Hardware address. | |
1049 | // timebin Timebin | |
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 | |
1055 | // | |
1056 | // Return: | |
1057 | // @c true on success, false otherwise | |
1058 | // | |
b995fc28 | 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); | |
f38b1653 | 1063 | } |
1064 | //____________________________________________________________________ | |
1065 | Bool_t | |
83dbc5b8 | 1066 | AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t board, |
1067 | UShort_t chip, UShort_t chan, | |
f38b1653 | 1068 | UShort_t timebin, |
1069 | UShort_t& det, Char_t& ring, | |
1070 | UShort_t& sec, Short_t& str, | |
1071 | UShort_t& sam) const | |
1072 | { | |
f38b1653 | 1073 | // |
09b6c804 | 1074 | // Map a hardware address into a detector index. |
1075 | // | |
1076 | // Parameters: | |
1077 | // ddl Hardware DDL number | |
1078 | // board FEC number | |
1079 | // altro ALTRO number | |
1080 | // channel Channel number | |
1081 | // timebin Timebin | |
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 | |
1087 | // | |
1088 | // Return: | |
1089 | // @c true on success, false otherwise | |
1090 | // | |
83dbc5b8 | 1091 | if (!fAltroMap) { |
1092 | AliFMDDebug(1, ("No ALTRO map available")); | |
1093 | return kFALSE; | |
1094 | } | |
1095 | if (fAltroMap->DDL2Detector(ddl) < 0) { | |
1096 | AliFMDDebug(1, ("Invalid DDL number %d", ddl)); | |
1097 | return kFALSE; | |
1098 | } | |
1099 | det = fAltroMap->DDL2Detector(ddl); | |
b995fc28 | 1100 | Short_t stripBase = 0; |
83dbc5b8 | 1101 | if (!fAltroMap->Channel2StripBase(board,chip,chan, ring, sec, stripBase)) { |
1102 | AliFMDDebug(1, ("Failed to translate " | |
1103 | "%d/0x%02x/0x%x/0x%x/%04d -> " | |
1104 | "FMD%d%c[%2d,%3d] to detector", | |
1105 | ddl, board, chip, chan, timebin, | |
1106 | det, ring, sec, stripBase)); | |
b995fc28 | 1107 | return kFALSE; |
83dbc5b8 | 1108 | } |
b995fc28 | 1109 | UShort_t preSamples = GetPreSamples(det, ring, sec, stripBase); |
1110 | UShort_t sampleRate = GetSampleRate(det, ring, sec, stripBase); | |
1111 | Short_t stripOff = 0; | |
1112 | fAltroMap->Timebin2Strip(sec, timebin, preSamples, sampleRate, stripOff, sam); | |
1113 | str = stripBase + stripOff; | |
1114 | AliFMDDebug(50, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d" | |
1115 | " (pre=%2d, rate=%d)", | |
1116 | ddl, board, chip, chan, timebin, | |
1117 | det, ring, sec, str, sam, preSamples, sampleRate)); | |
f38b1653 | 1118 | return kTRUE; |
1119 | } | |
1120 | ||
bf000c32 | 1121 | |
f38b1653 | 1122 | //____________________________________________________________________ |
1123 | Bool_t | |
1124 | AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring, | |
1125 | UShort_t sec, UShort_t str, | |
1126 | UShort_t sam, | |
b995fc28 | 1127 | UShort_t& ddl, UShort_t& board, |
1128 | UShort_t& altro, UShort_t& channel, | |
f38b1653 | 1129 | UShort_t& timebin) const |
1130 | { | |
09b6c804 | 1131 | // |
1132 | // Map a detector index into a hardware address. | |
1133 | // | |
1134 | // Parameters: | |
1135 | // det The detector # | |
1136 | // ring The ring ID | |
1137 | // sec The sector # | |
1138 | // str The strip # | |
1139 | // sam The sample number | |
1140 | // ddl On return, hardware DDL number | |
1141 | // board On return, the FEC board address (local to DDL) | |
1142 | // altro On return, the ALTRO number (local to FEC) | |
1143 | // channel On return, the channel number (local to ALTRO) | |
1144 | // timebin On return, the timebin number (local to ALTRO) | |
1145 | // | |
1146 | // Return: | |
1147 | // @c true on success, false otherwise | |
1148 | // | |
83dbc5b8 | 1149 | if (!fAltroMap) { |
1150 | AliFMDDebug(1, ("No ALTRO map available")); | |
1151 | return kFALSE; | |
1152 | } | |
f38b1653 | 1153 | UShort_t preSamples = GetPreSamples(det, ring, sec, str); |
1154 | UShort_t sampleRate = GetSampleRate(det, ring, sec, str); | |
1155 | UShort_t strip = str - GetMinStrip(det,ring,sec,str); | |
1156 | return fAltroMap->Detector2Hardware(det, ring, sec, strip, sam, | |
1157 | preSamples, sampleRate, | |
1158 | ddl, board, altro, channel, timebin); | |
1159 | } | |
1160 | ||
1161 | ||
1162 | ||
f38b1653 | 1163 | //____________________________________________________________________ |
1164 | Bool_t | |
1165 | AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring, | |
1166 | UShort_t sec, UShort_t str, | |
1167 | UShort_t sam, | |
b995fc28 | 1168 | UShort_t& ddl, UShort_t& addr, |
f38b1653 | 1169 | UShort_t& timebin) const |
1170 | { | |
09b6c804 | 1171 | // |
1172 | // Map a detector index into a hardware address. | |
1173 | // | |
1174 | // Parameters: | |
1175 | // det The detector # | |
1176 | // ring The ring ID | |
1177 | // sec The sector # | |
1178 | // str The strip # | |
1179 | // sam The sample number | |
1180 | // ddl On return, hardware DDL number | |
1181 | // addr On return, hardware address. | |
1182 | // timebin On return, the timebin number (local to ALTRO) | |
1183 | // | |
1184 | // Return: | |
1185 | // @c true on success, false otherwise | |
1186 | // | |
f38b1653 | 1187 | if (!fAltroMap) return kFALSE; |
1188 | UShort_t preSamples = GetPreSamples(det, ring, sec, str); | |
1189 | UShort_t sampleRate = GetSampleRate(det, ring, sec, str); | |
1190 | UShort_t strip = str - GetMinStrip(det,ring,sec,str); | |
1191 | return fAltroMap->Detector2Hardware(det, ring, sec, strip, sam, | |
1192 | preSamples, sampleRate, | |
1193 | ddl, addr, timebin); | |
1194 | } | |
1195 | ||
57c3c593 | 1196 | |
1197 | //__________________________________________________________________ | |
1198 | Float_t | |
1199 | AliFMDParameters::GetEdepMip() const | |
1200 | { | |
09b6c804 | 1201 | // |
1202 | // Return: | |
1203 | // The average energy deposited by one MIP | |
1204 | // | |
57c3c593 | 1205 | if (fEdepMip <= 0){ |
1206 | AliFMDGeometry* fmd = AliFMDGeometry::Instance(); | |
02a27b50 | 1207 | fEdepMip = (fkSiDeDxMip |
57c3c593 | 1208 | * fmd->GetRing('I')->GetSiThickness() |
1209 | * fmd->GetSiDensity()); | |
1210 | } | |
1211 | return fEdepMip; | |
1212 | } | |
68aba90a | 1213 | //____________________________________________________________________ |
1214 | Float_t | |
1215 | AliFMDParameters::GetDACPerMIP() const | |
1216 | { | |
09b6c804 | 1217 | // |
1218 | // This is the conversion from Digital-to-Analog-Converter setting | |
68aba90a | 1219 | // to the number of MIPs. The number was measured in the NBI lab during |
1220 | // August 2008. | |
09b6c804 | 1221 | // |
1222 | // Return: | |
1223 | // The conversion factor from DAC to ADC | |
1224 | // | |
68aba90a | 1225 | return 29.67; |
bf000c32 | 1226 | |
68aba90a | 1227 | } |
1228 | ||
1a1fdef7 | 1229 | //____________________________________________________________________ |
1230 | // | |
1231 | // EOF | |
1232 | // |