]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCalibrationData.cxx
Adding CVS Id
[u/mrichter/AliRoot.git] / MUON / AliMUONCalibrationData.cxx
CommitLineData
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 46ClassImp(AliMUONCalibrationData)
5398f946 47/// \endcond
c5bdf179 48
49//_____________________________________________________________________________
50AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
51 Bool_t deferredInitialization)
52: TObject(),
53fIsValid(kTRUE),
54fRunNumber(runNumber),
55fGains(0x0),
c3ce65fd 56fPedestals(0x0),
48ed403b 57fHV(0x0),
e7d7fa47 58fLocalTriggerBoardMasks(0x0),
59fRegionalTriggerBoardMasks(0x0),
60fGlobalTriggerBoardMasks(0x0),
61fTriggerLut(0x0),
62fTriggerEfficiency(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//_____________________________________________________________________________
86AliMUONCalibrationData::~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 101TMap*
102AliMUONCalibrationData::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 110TMap*
111AliMUONCalibrationData::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//_____________________________________________________________________________
135AliCDBEntry*
136AliMUONCalibrationData::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 145AliMUONVCalibParam*
e7d7fa47 146AliMUONCalibrationData::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 {
48ed403b 155 return 0x0;
156 }
157
56df3e46 158 return static_cast<AliMUONVCalibParam*>(gains->Get(detElemId,manuId));
48ed403b 159}
160
161//_____________________________________________________________________________
162AliMUONV2DStore*
163AliMUONCalibrationData::Gains() const
164{
165 /// Create (if needed) and return the internal store for gains.
166 return OnDemandGains();
c5bdf179 167}
168
169//_____________________________________________________________________________
c3ce65fd 170AliMUONV2DStore*
e7d7fa47 171AliMUONCalibrationData::OnDemandGains() const
c5bdf179 172{
5398f946 173/// Create (if needed) and return the internal store for gains.
174
c5bdf179 175 if (!fGains)
176 {
177 AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
178 if (entry)
179 {
c3ce65fd 180 fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
c5bdf179 181 if (!fGains)
182 {
183 AliError("Gains not of the expected type !!!");
184 }
185 }
186 else
187 {
188 AliError("Could not get gains !");
189 }
190 }
191 return fGains;
192}
193
e7d7fa47 194//_____________________________________________________________________________
195AliMUONVCalibParam*
196AliMUONCalibrationData::GlobalTriggerBoardMasks() const
197{
5398f946 198/// Return the masks for the global trigger board.
199
e7d7fa47 200 return OnDemandGlobalTriggerBoardMasks();
201}
202
203//_____________________________________________________________________________
204AliMUONVCalibParam*
205AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const
206{
5398f946 207/// Create (if needed) and return the internal store for GlobalTriggerBoardMasks.
208
e7d7fa47 209 if (!fGlobalTriggerBoardMasks)
210 {
211 AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks");
212 if (entry)
213 {
214 fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject());
215 if (!fGlobalTriggerBoardMasks)
216 {
217 AliError("fGlobalTriggerBoardMasks not of the expected type !!!");
218 }
219 }
220 else
221 {
222 AliError("Could not get global trigger board masks !");
223 }
224 }
225 return fGlobalTriggerBoardMasks;
226}
227
228//_____________________________________________________________________________
229AliMUONVCalibParam*
230AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
231{
5398f946 232/// Return the masks for a given trigger local board.
233
48ed403b 234 AliMUONV1DStore* store = OnDemandLocalTriggerBoardMasks();
235 if (!store)
236 {
237 AliError("Could not get LocalTriggerBoardMasks");
238 return 0x0;
239 }
240
e7d7fa47 241 AliMUONVCalibParam* ltbm =
48ed403b 242 static_cast<AliMUONVCalibParam*>(store->Get(localBoardNumber));
e7d7fa47 243 if (!ltbm)
244 {
245 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
246 }
247 return ltbm;
248}
249
250//_____________________________________________________________________________
251AliMUONV1DStore*
252AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const
253{
5398f946 254/// Create (if needed) and return the internal store for LocalTriggerBoardMasks.
255
e7d7fa47 256 if (!fLocalTriggerBoardMasks)
257 {
258 AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks");
259 if (entry)
260 {
261 fLocalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
262 if (!fLocalTriggerBoardMasks)
263 {
264 AliError("fLocalTriggerBoardMasks not of the expected type !!!");
265 }
266 }
267 else
268 {
269 AliError("Could not get local trigger board masks !");
270 }
271 }
272 return fLocalTriggerBoardMasks;
273}
274
c5bdf179 275//_____________________________________________________________________________
c3ce65fd 276AliMUONV2DStore*
e7d7fa47 277AliMUONCalibrationData::OnDemandPedestals() const
c5bdf179 278{
5398f946 279/// Create (if needed) and return the internal storage for pedestals.
280
c5bdf179 281 if (!fPedestals)
282 {
283 AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
284 if (entry)
285 {
c3ce65fd 286 fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
c5bdf179 287 if (!fPedestals)
288 {
289 AliError("fPedestals not of the expected type !!!");
290 }
291 }
292 else
293 {
294 AliError("Could not get pedestals !");
295 }
296 }
297 return fPedestals;
298}
299
300//_____________________________________________________________________________
301void
302AliMUONCalibrationData::Print(Option_t*) const
303{
5398f946 304/// A very basic dump of our guts.
305
c5bdf179 306 cout << "RunNumber " << RunNumber()
e7d7fa47 307 << " fGains=" << fGains
308 << " fPedestals=" << fPedestals
48ed403b 309 << " fHV=" << fHV
e7d7fa47 310 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
311 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
312 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
313 << " fTriggerLut=" << fTriggerLut
c5bdf179 314 << endl;
315}
316
48ed403b 317//_____________________________________________________________________________
318AliMUONV2DStore*
319AliMUONCalibrationData::Pedestals() const
320{
321 /// Return pedestals
322 return OnDemandPedestals();
323}
c5bdf179 324
325//_____________________________________________________________________________
c3ce65fd 326AliMUONVCalibParam*
e7d7fa47 327AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
c5bdf179 328{
5398f946 329/// Return the pedestals for a given (detElemId, manuId) pair.
330/// A return value of 0x0 is considered an error, meaning we should get
331/// pedestals for all channels.
332
48ed403b 333 AliMUONV2DStore* pedestals = OnDemandPedestals();
334 if (!pedestals)
335 {
48ed403b 336 return 0x0;
337 }
338
56df3e46 339 return static_cast<AliMUONVCalibParam*>(pedestals->Get(detElemId,manuId));
c5bdf179 340}
341
e7d7fa47 342//_____________________________________________________________________________
343AliMUONVCalibParam*
344AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const
345{
5398f946 346/// Return the masks for a given trigger regional board.
347
48ed403b 348 AliMUONV1DStore* store = OnDemandRegionalTriggerBoardMasks();
349
350 if (!store)
351 {
352 AliError("Could not get RegionalTriggerBoardMasks");
353 return 0x0;
354 }
355
e7d7fa47 356 AliMUONVCalibParam* rtbm =
48ed403b 357 static_cast<AliMUONVCalibParam*>(store->Get(index));
e7d7fa47 358 if (!rtbm)
359 {
360 AliError(Form("Could not get mask for regionalBoard index=%d",index));
361 }
362 return rtbm;
363}
364
365//_____________________________________________________________________________
366AliMUONV1DStore*
367AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const
368{
5398f946 369/// Create (if needed) and return the internal store for RegionalTriggerBoardMasks.
370
e7d7fa47 371 if (!fRegionalTriggerBoardMasks)
372 {
373 AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks");
374 if (entry)
375 {
376 fRegionalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
377 if (!fRegionalTriggerBoardMasks)
378 {
379 AliError("fRegionalTriggerBoardMasks not of the expected type !!!");
380 }
381 }
382 else
383 {
384 AliError("Could not get regional trigger board masks !");
385 }
386 }
387 return fRegionalTriggerBoardMasks;
388}
389
390//_____________________________________________________________________________
391AliMUONTriggerEfficiencyCells*
392AliMUONCalibrationData::TriggerEfficiency() const
393{
5398f946 394/// Return the trigger efficiency.
395
e7d7fa47 396 return OnDemandTriggerEfficiency();
397}
398
399//_____________________________________________________________________________
400AliMUONTriggerEfficiencyCells*
401AliMUONCalibrationData::OnDemandTriggerEfficiency() const
402{
5398f946 403/// \todo: add comment
404
e7d7fa47 405 if (!fTriggerEfficiency)
406 {
407 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency");
408 if (entry)
409 {
410 fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject());
411 if (!fTriggerEfficiency)
412 {
413 AliError("fTriggerEfficiency not of the expected type !!!");
414 }
415 }
416 else
417 {
418 AliError("Could not get trigger efficiency !");
419 }
420 }
421 return fTriggerEfficiency;
422}
423
424//_____________________________________________________________________________
425AliMUONTriggerLut*
426AliMUONCalibrationData::TriggerLut() const
427{
5398f946 428/// Return the trigger look up table.
429
e7d7fa47 430 return OnDemandTriggerLut();
431}
432
433//_____________________________________________________________________________
434AliMUONTriggerLut*
435AliMUONCalibrationData::OnDemandTriggerLut() const
436{
5398f946 437/// \todo: add comment
438
e7d7fa47 439 if (!fTriggerLut)
440 {
441 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut");
442 if (entry)
443 {
444 fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject());
445 if (!fTriggerLut)
446 {
447 AliError("fTriggerLut not of the expected type !!!");
448 }
449 }
450 else
451 {
452 AliError("Could not get trigger lut !");
453 }
454 }
455 return fTriggerLut;
456}
457
458
c5bdf179 459