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