]>
Commit | Line | Data |
---|---|---|
c5bdf179 | 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 | ||
16 | // $Id$ | |
17 | ||
18 | #include "AliMUONCalibrationData.h" | |
19 | ||
20 | #include "AliCDBEntry.h" | |
21 | #include "AliCDBManager.h" | |
c5bdf179 | 22 | #include "AliLog.h" |
e7d7fa47 | 23 | #include "AliMUONTriggerEfficiencyCells.h" |
24 | #include "AliMUONTriggerLut.h" | |
25 | #include "AliMUONV1DStore.h" | |
c3ce65fd | 26 | #include "AliMUONV2DStore.h" |
27 | #include "AliMUONVCalibParam.h" | |
c5bdf179 | 28 | #include "Riostream.h" |
29 | ||
e7d7fa47 | 30 | /// |
31 | /// This class is to be considered as a convenience class. | |
32 | /// Its aim is to ease retrieval of calibration data from the | |
33 | /// condition database. | |
34 | /// | |
35 | /// It acts as a "facade" to a bunch of underlying | |
36 | /// containers/calibration classes. | |
37 | /// | |
38 | ||
c5bdf179 | 39 | ClassImp(AliMUONCalibrationData) |
40 | ||
41 | //_____________________________________________________________________________ | |
42 | AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber, | |
43 | Bool_t deferredInitialization) | |
44 | : TObject(), | |
45 | fIsValid(kTRUE), | |
46 | fRunNumber(runNumber), | |
47 | fGains(0x0), | |
c3ce65fd | 48 | fPedestals(0x0), |
e7d7fa47 | 49 | fDeadChannels(0x0), |
50 | fLocalTriggerBoardMasks(0x0), | |
51 | fRegionalTriggerBoardMasks(0x0), | |
52 | fGlobalTriggerBoardMasks(0x0), | |
53 | fTriggerLut(0x0), | |
54 | fTriggerEfficiency(0x0) | |
c5bdf179 | 55 | { |
c3ce65fd | 56 | // |
57 | // Default ctor. | |
58 | // If deferredInitialization is false, we read *all* calibrations | |
59 | // at once. | |
60 | // So when using this class to access only one kind of calibrations (e.g. | |
61 | // only pedestals), you should put deferredInitialization to kTRUE, which | |
62 | // will instruct this object to fetch the data only when neeeded. | |
63 | // | |
c5bdf179 | 64 | if ( deferredInitialization == kFALSE ) |
65 | { | |
e7d7fa47 | 66 | OnDemandGains(); |
67 | OnDemandPedestals(); | |
68 | OnDemandDeadChannels(); | |
69 | OnDemandLocalTriggerBoardMasks(); | |
70 | OnDemandRegionalTriggerBoardMasks(); | |
71 | OnDemandGlobalTriggerBoardMasks(); | |
72 | OnDemandTriggerLut(); | |
73 | OnDemandTriggerEfficiency(); | |
c5bdf179 | 74 | } |
75 | } | |
76 | ||
e7d7fa47 | 77 | //_____________________________________________________________________________ |
78 | AliMUONCalibrationData::AliMUONCalibrationData(const AliMUONCalibrationData&) | |
79 | : TObject() | |
80 | { | |
81 | AliFatal("Implement me if needed"); | |
82 | } | |
884a73f1 | 83 | |
e7d7fa47 | 84 | //_____________________________________________________________________________ |
85 | AliMUONCalibrationData& | |
86 | AliMUONCalibrationData::operator=(const AliMUONCalibrationData&) | |
87 | { | |
88 | AliFatal("Implement me if needed"); | |
89 | return *this; | |
884a73f1 | 90 | } |
c5bdf179 | 91 | |
92 | //_____________________________________________________________________________ | |
93 | AliMUONCalibrationData::~AliMUONCalibrationData() | |
94 | { | |
c3ce65fd | 95 | // |
96 | // dtor. Note that we're the owner of our pointers. | |
97 | // | |
c5bdf179 | 98 | delete fPedestals; |
99 | delete fGains; | |
c3ce65fd | 100 | delete fDeadChannels; |
e7d7fa47 | 101 | delete fLocalTriggerBoardMasks; |
102 | delete fRegionalTriggerBoardMasks; | |
103 | delete fGlobalTriggerBoardMasks; | |
104 | delete fTriggerLut; | |
105 | delete fTriggerEfficiency; | |
c3ce65fd | 106 | } |
107 | ||
c3ce65fd | 108 | //_____________________________________________________________________________ |
109 | AliMUONVCalibParam* | |
e7d7fa47 | 110 | AliMUONCalibrationData::DeadChannels(Int_t detElemId, Int_t manuId) const |
c3ce65fd | 111 | { |
112 | // | |
113 | // Return the calibration for a given (detElemId, manuId) pair | |
114 | // Note that for DeadChannel, it's "legal" to return 0x0 (e.g. if a manu | |
115 | // is perfect, we might simply forget it in the store). | |
116 | // | |
117 | return | |
e7d7fa47 | 118 | static_cast<AliMUONVCalibParam*>(OnDemandDeadChannels()->Get(detElemId,manuId)); |
c3ce65fd | 119 | } |
120 | ||
121 | //_____________________________________________________________________________ | |
122 | AliMUONV2DStore* | |
e7d7fa47 | 123 | AliMUONCalibrationData::OnDemandDeadChannels() const |
c3ce65fd | 124 | { |
125 | // | |
126 | // Create (if needed) and return the internal store for DeadChannels. | |
127 | // | |
128 | if (!fDeadChannels) | |
129 | { | |
130 | AliCDBEntry* entry = GetEntry("MUON/Calib/DeadChannels"); | |
131 | if (entry) | |
132 | { | |
133 | fDeadChannels = dynamic_cast<AliMUONV2DStore*>(entry->GetObject()); | |
134 | if (!fDeadChannels) | |
135 | { | |
136 | AliError("fDeadChannels not of the expected type !!!"); | |
137 | } | |
138 | } | |
139 | else | |
140 | { | |
141 | AliError("Could not get dead channels !"); | |
142 | } | |
143 | } | |
144 | return fDeadChannels; | |
c5bdf179 | 145 | } |
146 | ||
147 | //_____________________________________________________________________________ | |
148 | AliCDBEntry* | |
149 | AliMUONCalibrationData::GetEntry(const char* path) const | |
150 | { | |
c3ce65fd | 151 | // |
152 | // Access the CDB for a given path (e.g. MUON/Calib/Pedestals), | |
153 | // and return the corresponding CDBEntry. | |
154 | // | |
e7d7fa47 | 155 | return AliCDBManager::Instance()->Get(path,fRunNumber); |
c5bdf179 | 156 | } |
157 | ||
158 | //_____________________________________________________________________________ | |
c3ce65fd | 159 | AliMUONVCalibParam* |
e7d7fa47 | 160 | AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const |
c5bdf179 | 161 | { |
c3ce65fd | 162 | // |
163 | // Return the gains for a given (detElemId, manuId) pair | |
164 | // Note that, unlike the DeadChannel case, if the result is 0x0, that's an | |
165 | // error (meaning that we should get gains for all channels). | |
166 | // | |
167 | AliMUONVCalibParam* gain = | |
e7d7fa47 | 168 | static_cast<AliMUONVCalibParam*>(OnDemandGains()->Get(detElemId,manuId)); |
c5bdf179 | 169 | if (!gain) |
170 | { | |
c3ce65fd | 171 | AliError(Form("Could not get gain for detElemId=%d manuId=%d ", |
172 | detElemId,manuId)); | |
c5bdf179 | 173 | } |
174 | return gain; | |
175 | } | |
176 | ||
177 | //_____________________________________________________________________________ | |
c3ce65fd | 178 | AliMUONV2DStore* |
e7d7fa47 | 179 | AliMUONCalibrationData::OnDemandGains() const |
c5bdf179 | 180 | { |
c3ce65fd | 181 | // |
182 | // Create (if needed) and return the internal store for gains. | |
183 | // | |
c5bdf179 | 184 | if (!fGains) |
185 | { | |
186 | AliCDBEntry* entry = GetEntry("MUON/Calib/Gains"); | |
187 | if (entry) | |
188 | { | |
c3ce65fd | 189 | fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject()); |
c5bdf179 | 190 | if (!fGains) |
191 | { | |
192 | AliError("Gains not of the expected type !!!"); | |
193 | } | |
194 | } | |
195 | else | |
196 | { | |
197 | AliError("Could not get gains !"); | |
198 | } | |
199 | } | |
200 | return fGains; | |
201 | } | |
202 | ||
e7d7fa47 | 203 | //_____________________________________________________________________________ |
204 | AliMUONVCalibParam* | |
205 | AliMUONCalibrationData::GlobalTriggerBoardMasks() const | |
206 | { | |
207 | // | |
208 | // Return the masks for the global trigger board. | |
209 | // | |
210 | return OnDemandGlobalTriggerBoardMasks(); | |
211 | } | |
212 | ||
213 | //_____________________________________________________________________________ | |
214 | AliMUONVCalibParam* | |
215 | AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const | |
216 | { | |
217 | // | |
218 | // Create (if needed) and return the internal store for GlobalTriggerBoardMasks. | |
219 | // | |
220 | if (!fGlobalTriggerBoardMasks) | |
221 | { | |
222 | AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks"); | |
223 | if (entry) | |
224 | { | |
225 | fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject()); | |
226 | if (!fGlobalTriggerBoardMasks) | |
227 | { | |
228 | AliError("fGlobalTriggerBoardMasks not of the expected type !!!"); | |
229 | } | |
230 | } | |
231 | else | |
232 | { | |
233 | AliError("Could not get global trigger board masks !"); | |
234 | } | |
235 | } | |
236 | return fGlobalTriggerBoardMasks; | |
237 | } | |
238 | ||
239 | //_____________________________________________________________________________ | |
240 | AliMUONVCalibParam* | |
241 | AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const | |
242 | { | |
243 | // | |
244 | // Return the masks for a given trigger local board. | |
245 | // | |
246 | AliMUONVCalibParam* ltbm = | |
247 | static_cast<AliMUONVCalibParam*>(OnDemandLocalTriggerBoardMasks()->Get(localBoardNumber)); | |
248 | if (!ltbm) | |
249 | { | |
250 | AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber)); | |
251 | } | |
252 | return ltbm; | |
253 | } | |
254 | ||
255 | //_____________________________________________________________________________ | |
256 | AliMUONV1DStore* | |
257 | AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const | |
258 | { | |
259 | // | |
260 | // Create (if needed) and return the internal store for LocalTriggerBoardMasks. | |
261 | // | |
262 | if (!fLocalTriggerBoardMasks) | |
263 | { | |
264 | AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks"); | |
265 | if (entry) | |
266 | { | |
267 | fLocalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject()); | |
268 | if (!fLocalTriggerBoardMasks) | |
269 | { | |
270 | AliError("fLocalTriggerBoardMasks not of the expected type !!!"); | |
271 | } | |
272 | } | |
273 | else | |
274 | { | |
275 | AliError("Could not get local trigger board masks !"); | |
276 | } | |
277 | } | |
278 | return fLocalTriggerBoardMasks; | |
279 | } | |
280 | ||
c5bdf179 | 281 | //_____________________________________________________________________________ |
c3ce65fd | 282 | AliMUONV2DStore* |
e7d7fa47 | 283 | AliMUONCalibrationData::OnDemandPedestals() const |
c5bdf179 | 284 | { |
c3ce65fd | 285 | // |
286 | // Create (if needed) and return the internal storage for pedestals. | |
287 | // | |
c5bdf179 | 288 | if (!fPedestals) |
289 | { | |
290 | AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals"); | |
291 | if (entry) | |
292 | { | |
c3ce65fd | 293 | fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject()); |
c5bdf179 | 294 | if (!fPedestals) |
295 | { | |
296 | AliError("fPedestals not of the expected type !!!"); | |
297 | } | |
298 | } | |
299 | else | |
300 | { | |
301 | AliError("Could not get pedestals !"); | |
302 | } | |
303 | } | |
304 | return fPedestals; | |
305 | } | |
306 | ||
307 | //_____________________________________________________________________________ | |
308 | void | |
309 | AliMUONCalibrationData::Print(Option_t*) const | |
310 | { | |
c3ce65fd | 311 | // |
312 | // A very basic dump of our guts. | |
313 | // | |
c5bdf179 | 314 | cout << "RunNumber " << RunNumber() |
e7d7fa47 | 315 | << " fGains=" << fGains |
316 | << " fPedestals=" << fPedestals | |
317 | << " fDeadChannels=" << fDeadChannels | |
318 | << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks | |
319 | << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks | |
320 | << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks | |
321 | << " fTriggerLut=" << fTriggerLut | |
c5bdf179 | 322 | << endl; |
323 | } | |
324 | ||
c5bdf179 | 325 | |
326 | //_____________________________________________________________________________ | |
c3ce65fd | 327 | AliMUONVCalibParam* |
e7d7fa47 | 328 | AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const |
c5bdf179 | 329 | { |
c3ce65fd | 330 | // |
331 | // Return the pedestals for a given (detElemId, manuId) pair. | |
332 | // A return value of 0x0 is considered an error, meaning we should get | |
333 | // pedestals for all channels. | |
334 | // | |
335 | AliMUONVCalibParam* ped = | |
e7d7fa47 | 336 | static_cast<AliMUONVCalibParam*>(OnDemandPedestals()->Get(detElemId,manuId)); |
c5bdf179 | 337 | if (!ped) |
338 | { | |
c3ce65fd | 339 | AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ", |
340 | detElemId,manuId)); | |
c5bdf179 | 341 | } |
342 | return ped; | |
343 | } | |
344 | ||
e7d7fa47 | 345 | //_____________________________________________________________________________ |
346 | AliMUONVCalibParam* | |
347 | AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const | |
348 | { | |
349 | // | |
350 | // Return the masks for a given trigger regional board. | |
351 | // | |
352 | AliMUONVCalibParam* rtbm = | |
353 | static_cast<AliMUONVCalibParam*>(OnDemandRegionalTriggerBoardMasks()->Get(index)); | |
354 | if (!rtbm) | |
355 | { | |
356 | AliError(Form("Could not get mask for regionalBoard index=%d",index)); | |
357 | } | |
358 | return rtbm; | |
359 | } | |
360 | ||
361 | //_____________________________________________________________________________ | |
362 | AliMUONV1DStore* | |
363 | AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const | |
364 | { | |
365 | // | |
366 | // Create (if needed) and return the internal store for RegionalTriggerBoardMasks. | |
367 | // | |
368 | if (!fRegionalTriggerBoardMasks) | |
369 | { | |
370 | AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks"); | |
371 | if (entry) | |
372 | { | |
373 | fRegionalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject()); | |
374 | if (!fRegionalTriggerBoardMasks) | |
375 | { | |
376 | AliError("fRegionalTriggerBoardMasks not of the expected type !!!"); | |
377 | } | |
378 | } | |
379 | else | |
380 | { | |
381 | AliError("Could not get regional trigger board masks !"); | |
382 | } | |
383 | } | |
384 | return fRegionalTriggerBoardMasks; | |
385 | } | |
386 | ||
387 | //_____________________________________________________________________________ | |
388 | AliMUONTriggerEfficiencyCells* | |
389 | AliMUONCalibrationData::TriggerEfficiency() const | |
390 | { | |
391 | // | |
392 | // Return the trigger efficiency. | |
393 | // | |
394 | return OnDemandTriggerEfficiency(); | |
395 | } | |
396 | ||
397 | //_____________________________________________________________________________ | |
398 | AliMUONTriggerEfficiencyCells* | |
399 | AliMUONCalibrationData::OnDemandTriggerEfficiency() const | |
400 | { | |
401 | // | |
402 | // | |
403 | // | |
404 | if (!fTriggerEfficiency) | |
405 | { | |
406 | AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency"); | |
407 | if (entry) | |
408 | { | |
409 | fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject()); | |
410 | if (!fTriggerEfficiency) | |
411 | { | |
412 | AliError("fTriggerEfficiency not of the expected type !!!"); | |
413 | } | |
414 | } | |
415 | else | |
416 | { | |
417 | AliError("Could not get trigger efficiency !"); | |
418 | } | |
419 | } | |
420 | return fTriggerEfficiency; | |
421 | } | |
422 | ||
423 | //_____________________________________________________________________________ | |
424 | AliMUONTriggerLut* | |
425 | AliMUONCalibrationData::TriggerLut() const | |
426 | { | |
427 | // | |
428 | // Return the trigger look up table. | |
429 | // | |
430 | return OnDemandTriggerLut(); | |
431 | } | |
432 | ||
433 | //_____________________________________________________________________________ | |
434 | AliMUONTriggerLut* | |
435 | AliMUONCalibrationData::OnDemandTriggerLut() const | |
436 | { | |
437 | // | |
438 | // | |
439 | // | |
440 | if (!fTriggerLut) | |
441 | { | |
442 | AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut"); | |
443 | if (entry) | |
444 | { | |
445 | fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject()); | |
446 | if (!fTriggerLut) | |
447 | { | |
448 | AliError("fTriggerLut not of the expected type !!!"); | |
449 | } | |
450 | } | |
451 | else | |
452 | { | |
453 | AliError("Could not get trigger lut !"); | |
454 | } | |
455 | } | |
456 | return fTriggerLut; | |
457 | } | |
458 | ||
459 | ||
c5bdf179 | 460 |