- Adding comment lines to class description needed for Root documentation
[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"
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 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),
c1bbaf66 62fTriggerEfficiency(0x0),
d067ba7c 63fCapacitances(0x0),
64fNeighbours(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 {
5562688f 76 Gains();
77 Pedestals();
78 HV();
79 LocalTriggerBoardMasks(0);
80 RegionalTriggerBoardMasks(0);
81 GlobalTriggerBoardMasks();
82 TriggerLut();
83 TriggerEfficiency();
84 Capacitances();
85 Neighbours();
c5bdf179 86 }
87}
88
e7d7fa47 89//_____________________________________________________________________________
c5bdf179 90AliMUONCalibrationData::~AliMUONCalibrationData()
91{
c1bbaf66 92 /// Destructor. Note that we're the owner of our pointers.
93 Reset();
c3ce65fd 94}
c3ce65fd 95
96//_____________________________________________________________________________
5562688f 97AliMUONVStore*
98AliMUONCalibrationData::Capacitances() const
c3ce65fd 99{
5562688f 100 /// Create (if needed) and return the internal store for capacitances.
101
102 if (!fCapacitances)
c3ce65fd 103 {
5562688f 104 fCapacitances = CreateCapacitances(fRunNumber);
c3ce65fd 105 }
5562688f 106 return fCapacitances;
c5bdf179 107}
108
109//_____________________________________________________________________________
5562688f 110AliMUONVStore*
111AliMUONCalibrationData::CreateCapacitances(Int_t runNumber)
c5bdf179 112{
5562688f 113 /// Create capa store from OCDB for a given run
114
115 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances"));
116}
5398f946 117
5562688f 118//_____________________________________________________________________________
119AliMUONVStore*
120AliMUONCalibrationData::CreateGains(Int_t runNumber)
121{
122 /// Create a new gain store from the OCDB for a given run
123 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains"));
c5bdf179 124}
125
126//_____________________________________________________________________________
c3ce65fd 127AliMUONVCalibParam*
5562688f 128AliMUONCalibrationData::CreateGlobalTriggerBoardMasks(Int_t runNumber)
c5bdf179 129{
5562688f 130 /// Create the internal store for GlobalTriggerBoardMasks from OCDB
48ed403b 131
5562688f 132 return dynamic_cast<AliMUONVCalibParam*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerBoardMasks"));
48ed403b 133}
134
135//_____________________________________________________________________________
5562688f 136TMap*
137AliMUONCalibrationData::CreateHV(Int_t runNumber)
c1bbaf66 138{
5562688f 139 /// Create a new HV map from the OCDB for a given run
140 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV"));
c1bbaf66 141}
142
143//_____________________________________________________________________________
a0eca509 144AliMUONVStore*
5562688f 145AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber)
d067ba7c 146{
5562688f 147 /// Get the internal store for LocalTriggerBoardMasks from OCDB
148
149 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks"));
d067ba7c 150}
151
152//_____________________________________________________________________________
a0eca509 153AliMUONVStore*
5562688f 154AliMUONCalibrationData::CreateNeighbours(Int_t runNumber)
48ed403b 155{
5562688f 156 /// Create a neighbour store from the OCDB for a given run
157 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours"));
c5bdf179 158}
159
160//_____________________________________________________________________________
5562688f 161TObject*
162AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path)
d067ba7c 163{
5562688f 164 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
165 /// and return the corresponding TObject.
d067ba7c 166
5562688f 167 AliCDBManager* man = AliCDBManager::Instance();
168
169 Bool_t cacheStatus = man->GetCacheFlag();
170
171 man->SetCacheFlag(kFALSE);
172
173 AliCDBEntry* entry = AliCDBManager::Instance()->Get(path,runNumber);
174
175 man->SetCacheFlag(cacheStatus);
176
177 if (entry)
d067ba7c 178 {
5562688f 179 return entry->GetObject();
d067ba7c 180 }
5562688f 181
182 return 0x0;
d067ba7c 183}
184
185//_____________________________________________________________________________
a0eca509 186AliMUONVStore*
5562688f 187AliMUONCalibrationData::CreatePedestals(Int_t runNumber)
c1bbaf66 188{
5562688f 189 /// Create a new pedestal store from the OCDB for a given run
190 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals"));
c1bbaf66 191}
192
193//_____________________________________________________________________________
a0eca509 194AliMUONVStore*
5562688f 195AliMUONCalibrationData::CreateRegionalTriggerBoardMasks(Int_t runNumber)
196{
197 /// Create the internal store for RegionalTriggerBoardMasks from OCDB
198
199 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerBoardMasks"));
200}
201
202//_____________________________________________________________________________
203AliMUONTriggerEfficiencyCells*
204AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber)
c5bdf179 205{
5562688f 206 /// Create trigger efficiency object from OCBD
207
208 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency"));
209}
5398f946 210
5562688f 211//_____________________________________________________________________________
212AliMUONTriggerLut*
213AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber)
214{
215 /// Create trigger LUT from OCDB
216
217 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut"));
218}
219
220//_____________________________________________________________________________
221AliMUONVStore*
222AliMUONCalibrationData::Gains() const
223{
224 /// Create (if needed) and return the internal store for gains.
c5bdf179 225 if (!fGains)
226 {
5562688f 227 fGains = CreateGains(fRunNumber);
c5bdf179 228 }
229 return fGains;
230}
231
232//_____________________________________________________________________________
5562688f 233AliMUONVCalibParam*
234AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
e7d7fa47 235{
5562688f 236/// Return the gains for a given (detElemId, manuId) pair
237/// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
238/// error (meaning that we should get gains for all channels).
5398f946 239
5562688f 240 AliMUONVStore* gains = Gains();
241 if (!gains)
242 {
243 return 0x0;
244 }
245
246 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
e7d7fa47 247}
248
249//_____________________________________________________________________________
5562688f 250AliMUONVCalibParam*
251AliMUONCalibrationData::GlobalTriggerBoardMasks() const
e7d7fa47 252{
5562688f 253 /// Return the masks for the global trigger board.
254
e7d7fa47 255 if (!fGlobalTriggerBoardMasks)
256 {
5562688f 257 fGlobalTriggerBoardMasks = CreateGlobalTriggerBoardMasks(fRunNumber);
e7d7fa47 258 }
259 return fGlobalTriggerBoardMasks;
260}
261
262//_____________________________________________________________________________
5562688f 263TMap*
264AliMUONCalibrationData::HV() const
e7d7fa47 265{
5562688f 266 /// Return the calibration for a given (detElemId, manuId) pair
48ed403b 267
5562688f 268 if (!fHV)
e7d7fa47 269 {
5562688f 270 fHV = CreateHV(fRunNumber);
e7d7fa47 271 }
5562688f 272 return fHV;
e7d7fa47 273}
274
275//_____________________________________________________________________________
a0eca509 276AliMUONVStore*
5562688f 277AliMUONCalibrationData::Neighbours() const
e7d7fa47 278{
5562688f 279 /// Create (if needed) and return the internal store for neighbours.
280 if (!fNeighbours)
281 {
282 fNeighbours = CreateNeighbours(fRunNumber);
283 }
284 return fNeighbours;
285}
286
287//_____________________________________________________________________________
288AliMUONVCalibParam*
289AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
290{
291/// Return the masks for a given trigger local board.
5398f946 292
e7d7fa47 293 if (!fLocalTriggerBoardMasks)
294 {
5562688f 295 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
296 }
297
298 if ( fLocalTriggerBoardMasks )
299 {
300 AliMUONVCalibParam* ltbm =
301 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
302 if (!ltbm)
e7d7fa47 303 {
5562688f 304 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
e7d7fa47 305 }
5562688f 306 return ltbm;
e7d7fa47 307 }
5562688f 308 return 0x0;
e7d7fa47 309}
310
311//_____________________________________________________________________________
a0eca509 312AliMUONVStore*
5562688f 313AliMUONCalibrationData::Pedestals() const
c5bdf179 314{
5562688f 315 /// Return pedestals
c5bdf179 316 if (!fPedestals)
317 {
5562688f 318 fPedestals = CreatePedestals(fRunNumber);
c5bdf179 319 }
320 return fPedestals;
321}
322
323//_____________________________________________________________________________
5562688f 324AliMUONVCalibParam*
325AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
326{
327 /// Return the pedestals for a given (detElemId, manuId) pair.
328 /// A return value of 0x0 is considered an error, meaning we should get
329 /// pedestals for all channels.
330
331 AliMUONVStore* pedestals = Pedestals();
332 if (!pedestals)
333 {
334 return 0x0;
335 }
336
337 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
338}
339
340//_____________________________________________________________________________
c5bdf179 341void
342AliMUONCalibrationData::Print(Option_t*) const
343{
5562688f 344 /// A very basic dump of our guts.
5398f946 345
c5bdf179 346 cout << "RunNumber " << RunNumber()
e7d7fa47 347 << " fGains=" << fGains
348 << " fPedestals=" << fPedestals
48ed403b 349 << " fHV=" << fHV
e7d7fa47 350 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
351 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
352 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
353 << " fTriggerLut=" << fTriggerLut
c5bdf179 354 << endl;
355}
356
48ed403b 357//_____________________________________________________________________________
e7d7fa47 358AliMUONVCalibParam*
5562688f 359AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t regionalBoardNumber) const
e7d7fa47 360{
5398f946 361/// Return the masks for a given trigger regional board.
362
5562688f 363 if ( !fRegionalTriggerBoardMasks )
48ed403b 364 {
5562688f 365 fRegionalTriggerBoardMasks = CreateRegionalTriggerBoardMasks(fRunNumber);
48ed403b 366 }
367
5562688f 368 if ( fRegionalTriggerBoardMasks )
e7d7fa47 369 {
5562688f 370 AliMUONVCalibParam* rtbm =
371 static_cast<AliMUONVCalibParam*>(fRegionalTriggerBoardMasks->FindObject(regionalBoardNumber));
372
373 if (!rtbm)
e7d7fa47 374 {
5562688f 375 AliError(Form("Could not get mask for regionalBoard index=%d",index));
e7d7fa47 376 }
5562688f 377 return rtbm;
e7d7fa47 378 }
5562688f 379 return 0x0;
e7d7fa47 380}
381
382//_____________________________________________________________________________
383AliMUONTriggerEfficiencyCells*
384AliMUONCalibrationData::TriggerEfficiency() const
385{
5398f946 386/// Return the trigger efficiency.
387
e7d7fa47 388 if (!fTriggerEfficiency)
389 {
5562688f 390 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
e7d7fa47 391 }
392 return fTriggerEfficiency;
393}
394
5562688f 395
e7d7fa47 396//_____________________________________________________________________________
397AliMUONTriggerLut*
398AliMUONCalibrationData::TriggerLut() const
399{
5398f946 400/// Return the trigger look up table.
401
e7d7fa47 402 if (!fTriggerLut)
403 {
5562688f 404 fTriggerLut = CreateTriggerLut(fRunNumber);
e7d7fa47 405 }
406 return fTriggerLut;
407}
408
c1bbaf66 409//_____________________________________________________________________________
410void
411AliMUONCalibrationData::Reset()
412{
413/// Reset all data
414
415 delete fPedestals;
416 fPedestals = 0x0;
417 delete fGains;
418 fGains = 0x0;
419 delete fHV;
420 fHV = 0x0;
421 delete fLocalTriggerBoardMasks;
422 fLocalTriggerBoardMasks = 0x0;
423 delete fRegionalTriggerBoardMasks;
424 fRegionalTriggerBoardMasks = 0x0;
425 delete fGlobalTriggerBoardMasks;
426 fGlobalTriggerBoardMasks = 0x0;
427 delete fTriggerLut;
428 fTriggerLut = 0x0;
429 delete fTriggerEfficiency;
430 fTriggerEfficiency = 0x0;
431 delete fCapacitances;
432 fCapacitances = 0x0;
d067ba7c 433 delete fNeighbours;
434 fNeighbours = 0x0;
c1bbaf66 435}
436
e7d7fa47 437
c5bdf179 438