]>
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" | |
a0eca509 | 25 | #include "AliMUONVStore.h" |
26 | #include "AliMUONVStore.h" | |
c3ce65fd | 27 | #include "AliMUONVCalibParam.h" |
c5bdf179 | 28 | #include "Riostream.h" |
48ed403b | 29 | #include "TMap.h" |
c5bdf179 | 30 | |
5398f946 | 31 | /// \class AliMUONCalibrationData |
32 | /// | |
48ed403b | 33 | /// For the moment, this class stores pedestals, gains, hv (for tracker) |
34 | /// and lut, masks and efficiencies (for trigger) that are fetched from the CDB. | |
e7d7fa47 | 35 | /// |
36 | /// This class is to be considered as a convenience class. | |
37 | /// Its aim is to ease retrieval of calibration data from the | |
38 | /// condition database. | |
39 | /// | |
40 | /// It acts as a "facade" to a bunch of underlying | |
41 | /// containers/calibration classes. | |
42 | /// | |
5398f946 | 43 | /// \author Laurent Aphecetche |
e7d7fa47 | 44 | |
5398f946 | 45 | /// \cond CLASSIMP |
c5bdf179 | 46 | ClassImp(AliMUONCalibrationData) |
5398f946 | 47 | /// \endcond |
c5bdf179 | 48 | |
49 | //_____________________________________________________________________________ | |
50 | AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber, | |
51 | Bool_t deferredInitialization) | |
52 | : TObject(), | |
53 | fIsValid(kTRUE), | |
54 | fRunNumber(runNumber), | |
55 | fGains(0x0), | |
c3ce65fd | 56 | fPedestals(0x0), |
48ed403b | 57 | fHV(0x0), |
e7d7fa47 | 58 | fLocalTriggerBoardMasks(0x0), |
59 | fRegionalTriggerBoardMasks(0x0), | |
60 | fGlobalTriggerBoardMasks(0x0), | |
61 | fTriggerLut(0x0), | |
c1bbaf66 | 62 | fTriggerEfficiency(0x0), |
d067ba7c | 63 | fCapacitances(0x0), |
64 | fNeighbours(0x0) | |
c5bdf179 | 65 | { |
5398f946 | 66 | /// Default ctor. |
67 | ||
c3ce65fd | 68 | // If deferredInitialization is false, we read *all* calibrations |
69 | // at once. | |
70 | // So when using this class to access only one kind of calibrations (e.g. | |
71 | // only pedestals), you should put deferredInitialization to kTRUE, which | |
72 | // will instruct this object to fetch the data only when neeeded. | |
5398f946 | 73 | |
c5bdf179 | 74 | if ( deferredInitialization == kFALSE ) |
75 | { | |
e7d7fa47 | 76 | OnDemandGains(); |
77 | OnDemandPedestals(); | |
48ed403b | 78 | OnDemandHV(); |
e7d7fa47 | 79 | OnDemandLocalTriggerBoardMasks(); |
80 | OnDemandRegionalTriggerBoardMasks(); | |
81 | OnDemandGlobalTriggerBoardMasks(); | |
82 | OnDemandTriggerLut(); | |
83 | OnDemandTriggerEfficiency(); | |
c1bbaf66 | 84 | OnDemandCapacitances(); |
d067ba7c | 85 | OnDemandNeighbours(); |
c5bdf179 | 86 | } |
87 | } | |
88 | ||
c5bdf179 | 89 | //_____________________________________________________________________________ |
90 | AliMUONCalibrationData::~AliMUONCalibrationData() | |
91 | { | |
c1bbaf66 | 92 | /// Destructor. Note that we're the owner of our pointers. |
93 | Reset(); | |
c3ce65fd | 94 | } |
c3ce65fd | 95 | //_____________________________________________________________________________ |
48ed403b | 96 | TMap* |
97 | AliMUONCalibrationData::HV() const | |
c3ce65fd | 98 | { |
5398f946 | 99 | /// Return the calibration for a given (detElemId, manuId) pair |
5398f946 | 100 | |
48ed403b | 101 | return OnDemandHV(); |
c3ce65fd | 102 | } |
103 | ||
104 | //_____________________________________________________________________________ | |
48ed403b | 105 | TMap* |
106 | AliMUONCalibrationData::OnDemandHV() const | |
c3ce65fd | 107 | { |
5398f946 | 108 | /// Create (if needed) and return the internal store for DeadChannels. |
109 | ||
48ed403b | 110 | if (!fHV) |
c3ce65fd | 111 | { |
48ed403b | 112 | AliCDBEntry* entry = GetEntry("MUON/Calib/HV"); |
c3ce65fd | 113 | if (entry) |
114 | { | |
48ed403b | 115 | fHV = dynamic_cast<TMap*>(entry->GetObject()); |
116 | if (!fHV) | |
c3ce65fd | 117 | { |
48ed403b | 118 | AliError("fHV not of the expected type !!!"); |
c3ce65fd | 119 | } |
120 | } | |
121 | else | |
122 | { | |
48ed403b | 123 | AliError("Could not get HV values !"); |
c3ce65fd | 124 | } |
125 | } | |
48ed403b | 126 | return fHV; |
c5bdf179 | 127 | } |
128 | ||
129 | //_____________________________________________________________________________ | |
130 | AliCDBEntry* | |
131 | AliMUONCalibrationData::GetEntry(const char* path) const | |
132 | { | |
5398f946 | 133 | /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals), |
134 | /// and return the corresponding CDBEntry. | |
135 | ||
e7d7fa47 | 136 | return AliCDBManager::Instance()->Get(path,fRunNumber); |
c5bdf179 | 137 | } |
138 | ||
139 | //_____________________________________________________________________________ | |
c3ce65fd | 140 | AliMUONVCalibParam* |
e7d7fa47 | 141 | AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const |
c5bdf179 | 142 | { |
5398f946 | 143 | /// Return the gains for a given (detElemId, manuId) pair |
144 | /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an | |
145 | /// error (meaning that we should get gains for all channels). | |
146 | ||
a0eca509 | 147 | AliMUONVStore* gains = Gains(); |
48ed403b | 148 | if (!gains) |
149 | { | |
48ed403b | 150 | return 0x0; |
151 | } | |
152 | ||
a0eca509 | 153 | return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId)); |
48ed403b | 154 | } |
155 | ||
c1bbaf66 | 156 | //_____________________________________________________________________________ |
a0eca509 | 157 | AliMUONVStore* |
c1bbaf66 | 158 | AliMUONCalibrationData::Capacitances() const |
159 | { | |
160 | /// Create (if needed) and return the internal store for capacitances. | |
161 | return OnDemandCapacitances(); | |
162 | } | |
163 | ||
d067ba7c | 164 | //_____________________________________________________________________________ |
a0eca509 | 165 | AliMUONVStore* |
d067ba7c | 166 | AliMUONCalibrationData::Neighbours() const |
167 | { | |
168 | /// Create (if needed) and return the internal store for neighbours. | |
169 | return OnDemandNeighbours(); | |
170 | } | |
171 | ||
48ed403b | 172 | //_____________________________________________________________________________ |
a0eca509 | 173 | AliMUONVStore* |
48ed403b | 174 | AliMUONCalibrationData::Gains() const |
175 | { | |
176 | /// Create (if needed) and return the internal store for gains. | |
177 | return OnDemandGains(); | |
c5bdf179 | 178 | } |
179 | ||
d067ba7c | 180 | //_____________________________________________________________________________ |
a0eca509 | 181 | AliMUONVStore* |
d067ba7c | 182 | AliMUONCalibrationData::OnDemandNeighbours() const |
183 | { | |
184 | /// Create (if needed) and return the internal store for neighbours. | |
185 | ||
186 | if (!fNeighbours) | |
187 | { | |
188 | AliCDBEntry* entry = GetEntry("MUON/Calib/Neighbours"); | |
189 | if (entry) | |
190 | { | |
a0eca509 | 191 | fNeighbours = dynamic_cast<AliMUONVStore*>(entry->GetObject()); |
d067ba7c | 192 | if (!fNeighbours) |
193 | { | |
194 | AliError("Neighbours not of the expected type !!!"); | |
195 | } | |
196 | } | |
197 | else | |
198 | { | |
199 | AliError("Could not get neighbours !"); | |
200 | } | |
201 | } | |
202 | return fNeighbours; | |
203 | } | |
204 | ||
c1bbaf66 | 205 | //_____________________________________________________________________________ |
a0eca509 | 206 | AliMUONVStore* |
c1bbaf66 | 207 | AliMUONCalibrationData::OnDemandCapacitances() const |
208 | { | |
209 | /// Create (if needed) and return the internal store for capacitances. | |
210 | ||
211 | if (!fCapacitances) | |
212 | { | |
213 | AliCDBEntry* entry = GetEntry("MUON/Calib/Capacitances"); | |
214 | if (entry) | |
215 | { | |
a0eca509 | 216 | fCapacitances = dynamic_cast<AliMUONVStore*>(entry->GetObject()); |
c1bbaf66 | 217 | if (!fCapacitances) |
218 | { | |
219 | AliError("Capacitances not of the expected type !!!"); | |
220 | } | |
221 | } | |
222 | else | |
223 | { | |
224 | AliError("Could not get capacitances !"); | |
225 | } | |
226 | } | |
227 | return fCapacitances; | |
228 | } | |
229 | ||
c5bdf179 | 230 | //_____________________________________________________________________________ |
a0eca509 | 231 | AliMUONVStore* |
e7d7fa47 | 232 | AliMUONCalibrationData::OnDemandGains() const |
c5bdf179 | 233 | { |
5398f946 | 234 | /// Create (if needed) and return the internal store for gains. |
235 | ||
c5bdf179 | 236 | if (!fGains) |
237 | { | |
238 | AliCDBEntry* entry = GetEntry("MUON/Calib/Gains"); | |
239 | if (entry) | |
240 | { | |
a0eca509 | 241 | fGains = dynamic_cast<AliMUONVStore*>(entry->GetObject()); |
c5bdf179 | 242 | if (!fGains) |
243 | { | |
244 | AliError("Gains not of the expected type !!!"); | |
245 | } | |
246 | } | |
247 | else | |
248 | { | |
249 | AliError("Could not get gains !"); | |
250 | } | |
251 | } | |
252 | return fGains; | |
253 | } | |
254 | ||
d067ba7c | 255 | |
e7d7fa47 | 256 | //_____________________________________________________________________________ |
257 | AliMUONVCalibParam* | |
258 | AliMUONCalibrationData::GlobalTriggerBoardMasks() const | |
259 | { | |
5398f946 | 260 | /// Return the masks for the global trigger board. |
261 | ||
e7d7fa47 | 262 | return OnDemandGlobalTriggerBoardMasks(); |
263 | } | |
264 | ||
265 | //_____________________________________________________________________________ | |
266 | AliMUONVCalibParam* | |
267 | AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const | |
268 | { | |
5398f946 | 269 | /// Create (if needed) and return the internal store for GlobalTriggerBoardMasks. |
270 | ||
e7d7fa47 | 271 | if (!fGlobalTriggerBoardMasks) |
272 | { | |
273 | AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks"); | |
274 | if (entry) | |
275 | { | |
276 | fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject()); | |
277 | if (!fGlobalTriggerBoardMasks) | |
278 | { | |
279 | AliError("fGlobalTriggerBoardMasks not of the expected type !!!"); | |
280 | } | |
281 | } | |
282 | else | |
283 | { | |
284 | AliError("Could not get global trigger board masks !"); | |
285 | } | |
286 | } | |
287 | return fGlobalTriggerBoardMasks; | |
288 | } | |
289 | ||
290 | //_____________________________________________________________________________ | |
291 | AliMUONVCalibParam* | |
292 | AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const | |
293 | { | |
5398f946 | 294 | /// Return the masks for a given trigger local board. |
295 | ||
a0eca509 | 296 | AliMUONVStore* store = OnDemandLocalTriggerBoardMasks(); |
48ed403b | 297 | if (!store) |
298 | { | |
299 | AliError("Could not get LocalTriggerBoardMasks"); | |
300 | return 0x0; | |
301 | } | |
302 | ||
e7d7fa47 | 303 | AliMUONVCalibParam* ltbm = |
a0eca509 | 304 | static_cast<AliMUONVCalibParam*>(store->FindObject(localBoardNumber)); |
e7d7fa47 | 305 | if (!ltbm) |
306 | { | |
307 | AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber)); | |
308 | } | |
309 | return ltbm; | |
310 | } | |
311 | ||
312 | //_____________________________________________________________________________ | |
a0eca509 | 313 | AliMUONVStore* |
e7d7fa47 | 314 | AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const |
315 | { | |
5398f946 | 316 | /// Create (if needed) and return the internal store for LocalTriggerBoardMasks. |
317 | ||
e7d7fa47 | 318 | if (!fLocalTriggerBoardMasks) |
319 | { | |
320 | AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks"); | |
321 | if (entry) | |
322 | { | |
a0eca509 | 323 | fLocalTriggerBoardMasks = dynamic_cast<AliMUONVStore*>(entry->GetObject()); |
e7d7fa47 | 324 | if (!fLocalTriggerBoardMasks) |
325 | { | |
326 | AliError("fLocalTriggerBoardMasks not of the expected type !!!"); | |
327 | } | |
328 | } | |
329 | else | |
330 | { | |
331 | AliError("Could not get local trigger board masks !"); | |
332 | } | |
333 | } | |
334 | return fLocalTriggerBoardMasks; | |
335 | } | |
336 | ||
c5bdf179 | 337 | //_____________________________________________________________________________ |
a0eca509 | 338 | AliMUONVStore* |
e7d7fa47 | 339 | AliMUONCalibrationData::OnDemandPedestals() const |
c5bdf179 | 340 | { |
5398f946 | 341 | /// Create (if needed) and return the internal storage for pedestals. |
342 | ||
c5bdf179 | 343 | if (!fPedestals) |
344 | { | |
345 | AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals"); | |
346 | if (entry) | |
347 | { | |
a0eca509 | 348 | fPedestals = dynamic_cast<AliMUONVStore*>(entry->GetObject()); |
c5bdf179 | 349 | if (!fPedestals) |
350 | { | |
351 | AliError("fPedestals not of the expected type !!!"); | |
352 | } | |
353 | } | |
354 | else | |
355 | { | |
356 | AliError("Could not get pedestals !"); | |
357 | } | |
358 | } | |
359 | return fPedestals; | |
360 | } | |
361 | ||
362 | //_____________________________________________________________________________ | |
363 | void | |
364 | AliMUONCalibrationData::Print(Option_t*) const | |
365 | { | |
5398f946 | 366 | /// A very basic dump of our guts. |
367 | ||
c5bdf179 | 368 | cout << "RunNumber " << RunNumber() |
e7d7fa47 | 369 | << " fGains=" << fGains |
370 | << " fPedestals=" << fPedestals | |
48ed403b | 371 | << " fHV=" << fHV |
e7d7fa47 | 372 | << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks |
373 | << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks | |
374 | << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks | |
375 | << " fTriggerLut=" << fTriggerLut | |
c5bdf179 | 376 | << endl; |
377 | } | |
378 | ||
48ed403b | 379 | //_____________________________________________________________________________ |
a0eca509 | 380 | AliMUONVStore* |
48ed403b | 381 | AliMUONCalibrationData::Pedestals() const |
382 | { | |
383 | /// Return pedestals | |
384 | return OnDemandPedestals(); | |
385 | } | |
c5bdf179 | 386 | |
387 | //_____________________________________________________________________________ | |
c3ce65fd | 388 | AliMUONVCalibParam* |
e7d7fa47 | 389 | AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const |
c5bdf179 | 390 | { |
5398f946 | 391 | /// Return the pedestals for a given (detElemId, manuId) pair. |
392 | /// A return value of 0x0 is considered an error, meaning we should get | |
393 | /// pedestals for all channels. | |
394 | ||
a0eca509 | 395 | AliMUONVStore* pedestals = OnDemandPedestals(); |
48ed403b | 396 | if (!pedestals) |
397 | { | |
48ed403b | 398 | return 0x0; |
399 | } | |
400 | ||
a0eca509 | 401 | return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId)); |
c5bdf179 | 402 | } |
403 | ||
e7d7fa47 | 404 | //_____________________________________________________________________________ |
405 | AliMUONVCalibParam* | |
406 | AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const | |
407 | { | |
5398f946 | 408 | /// Return the masks for a given trigger regional board. |
409 | ||
a0eca509 | 410 | AliMUONVStore* store = OnDemandRegionalTriggerBoardMasks(); |
48ed403b | 411 | |
412 | if (!store) | |
413 | { | |
414 | AliError("Could not get RegionalTriggerBoardMasks"); | |
415 | return 0x0; | |
416 | } | |
417 | ||
e7d7fa47 | 418 | AliMUONVCalibParam* rtbm = |
a0eca509 | 419 | static_cast<AliMUONVCalibParam*>(store->FindObject(index)); |
e7d7fa47 | 420 | if (!rtbm) |
421 | { | |
422 | AliError(Form("Could not get mask for regionalBoard index=%d",index)); | |
423 | } | |
424 | return rtbm; | |
425 | } | |
426 | ||
427 | //_____________________________________________________________________________ | |
a0eca509 | 428 | AliMUONVStore* |
e7d7fa47 | 429 | AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const |
430 | { | |
5398f946 | 431 | /// Create (if needed) and return the internal store for RegionalTriggerBoardMasks. |
432 | ||
e7d7fa47 | 433 | if (!fRegionalTriggerBoardMasks) |
434 | { | |
435 | AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks"); | |
436 | if (entry) | |
437 | { | |
a0eca509 | 438 | fRegionalTriggerBoardMasks = dynamic_cast<AliMUONVStore*>(entry->GetObject()); |
e7d7fa47 | 439 | if (!fRegionalTriggerBoardMasks) |
440 | { | |
441 | AliError("fRegionalTriggerBoardMasks not of the expected type !!!"); | |
442 | } | |
443 | } | |
444 | else | |
445 | { | |
446 | AliError("Could not get regional trigger board masks !"); | |
447 | } | |
448 | } | |
449 | return fRegionalTriggerBoardMasks; | |
450 | } | |
451 | ||
452 | //_____________________________________________________________________________ | |
453 | AliMUONTriggerEfficiencyCells* | |
454 | AliMUONCalibrationData::TriggerEfficiency() const | |
455 | { | |
5398f946 | 456 | /// Return the trigger efficiency. |
457 | ||
e7d7fa47 | 458 | return OnDemandTriggerEfficiency(); |
459 | } | |
460 | ||
461 | //_____________________________________________________________________________ | |
462 | AliMUONTriggerEfficiencyCells* | |
463 | AliMUONCalibrationData::OnDemandTriggerEfficiency() const | |
464 | { | |
5398f946 | 465 | /// \todo: add comment |
466 | ||
e7d7fa47 | 467 | if (!fTriggerEfficiency) |
468 | { | |
469 | AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency"); | |
470 | if (entry) | |
471 | { | |
472 | fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject()); | |
473 | if (!fTriggerEfficiency) | |
474 | { | |
475 | AliError("fTriggerEfficiency not of the expected type !!!"); | |
476 | } | |
477 | } | |
478 | else | |
479 | { | |
480 | AliError("Could not get trigger efficiency !"); | |
481 | } | |
482 | } | |
483 | return fTriggerEfficiency; | |
484 | } | |
485 | ||
486 | //_____________________________________________________________________________ | |
487 | AliMUONTriggerLut* | |
488 | AliMUONCalibrationData::TriggerLut() const | |
489 | { | |
5398f946 | 490 | /// Return the trigger look up table. |
491 | ||
e7d7fa47 | 492 | return OnDemandTriggerLut(); |
493 | } | |
494 | ||
495 | //_____________________________________________________________________________ | |
496 | AliMUONTriggerLut* | |
497 | AliMUONCalibrationData::OnDemandTriggerLut() const | |
498 | { | |
5398f946 | 499 | /// \todo: add comment |
500 | ||
e7d7fa47 | 501 | if (!fTriggerLut) |
502 | { | |
503 | AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut"); | |
504 | if (entry) | |
505 | { | |
506 | fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject()); | |
507 | if (!fTriggerLut) | |
508 | { | |
509 | AliError("fTriggerLut not of the expected type !!!"); | |
510 | } | |
511 | } | |
512 | else | |
513 | { | |
514 | AliError("Could not get trigger lut !"); | |
515 | } | |
516 | } | |
517 | return fTriggerLut; | |
518 | } | |
519 | ||
c1bbaf66 | 520 | //_____________________________________________________________________________ |
521 | void | |
522 | AliMUONCalibrationData::Reset() | |
523 | { | |
524 | /// Reset all data | |
525 | ||
526 | delete fPedestals; | |
527 | fPedestals = 0x0; | |
528 | delete fGains; | |
529 | fGains = 0x0; | |
530 | delete fHV; | |
531 | fHV = 0x0; | |
532 | delete fLocalTriggerBoardMasks; | |
533 | fLocalTriggerBoardMasks = 0x0; | |
534 | delete fRegionalTriggerBoardMasks; | |
535 | fRegionalTriggerBoardMasks = 0x0; | |
536 | delete fGlobalTriggerBoardMasks; | |
537 | fGlobalTriggerBoardMasks = 0x0; | |
538 | delete fTriggerLut; | |
539 | fTriggerLut = 0x0; | |
540 | delete fTriggerEfficiency; | |
541 | fTriggerEfficiency = 0x0; | |
542 | delete fCapacitances; | |
543 | fCapacitances = 0x0; | |
d067ba7c | 544 | delete fNeighbours; |
545 | fNeighbours = 0x0; | |
c1bbaf66 | 546 | } |
547 | ||
e7d7fa47 | 548 | |
c5bdf179 | 549 |