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