]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCalibrationData.cxx
Version number incremented
[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"
4bec0403 22#include "AliCodeTimer.h"
c5bdf179 23#include "AliLog.h"
e7d7fa47 24#include "AliMUONTriggerEfficiencyCells.h"
25#include "AliMUONTriggerLut.h"
a0eca509 26#include "AliMUONVStore.h"
27#include "AliMUONVStore.h"
c3ce65fd 28#include "AliMUONVCalibParam.h"
4bec0403 29#include <Riostream.h>
30#include <TClass.h>
31#include <TMap.h>
c5bdf179 32
3d1463c8 33//-----------------------------------------------------------------------------
5398f946 34/// \class AliMUONCalibrationData
35///
48ed403b 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.
e7d7fa47 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///
5398f946 46/// \author Laurent Aphecetche
3d1463c8 47//-----------------------------------------------------------------------------
e7d7fa47 48
5398f946 49/// \cond CLASSIMP
c5bdf179 50ClassImp(AliMUONCalibrationData)
5398f946 51/// \endcond
c5bdf179 52
53//_____________________________________________________________________________
54AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
55 Bool_t deferredInitialization)
56: TObject(),
57fIsValid(kTRUE),
58fRunNumber(runNumber),
59fGains(0x0),
c3ce65fd 60fPedestals(0x0),
48ed403b 61fHV(0x0),
e7d7fa47 62fLocalTriggerBoardMasks(0x0),
63fRegionalTriggerBoardMasks(0x0),
64fGlobalTriggerBoardMasks(0x0),
65fTriggerLut(0x0),
c1bbaf66 66fTriggerEfficiency(0x0),
d067ba7c 67fCapacitances(0x0),
68fNeighbours(0x0)
c5bdf179 69{
5398f946 70/// Default ctor.
71
c3ce65fd 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.
5398f946 77
c5bdf179 78 if ( deferredInitialization == kFALSE )
79 {
5562688f 80 Gains();
81 Pedestals();
82 HV();
83 LocalTriggerBoardMasks(0);
84 RegionalTriggerBoardMasks(0);
85 GlobalTriggerBoardMasks();
86 TriggerLut();
87 TriggerEfficiency();
88 Capacitances();
89 Neighbours();
c5bdf179 90 }
91}
92
c5bdf179 93//_____________________________________________________________________________
94AliMUONCalibrationData::~AliMUONCalibrationData()
95{
c1bbaf66 96 /// Destructor. Note that we're the owner of our pointers.
97 Reset();
c3ce65fd 98}
c3ce65fd 99
100//_____________________________________________________________________________
5562688f 101AliMUONVStore*
102AliMUONCalibrationData::Capacitances() const
c3ce65fd 103{
5562688f 104 /// Create (if needed) and return the internal store for capacitances.
105
106 if (!fCapacitances)
c3ce65fd 107 {
5562688f 108 fCapacitances = CreateCapacitances(fRunNumber);
c3ce65fd 109 }
5562688f 110 return fCapacitances;
c5bdf179 111}
112
113//_____________________________________________________________________________
5562688f 114AliMUONVStore*
115AliMUONCalibrationData::CreateCapacitances(Int_t runNumber)
c5bdf179 116{
5562688f 117 /// Create capa store from OCDB for a given run
118
119 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances"));
120}
5398f946 121
5562688f 122//_____________________________________________________________________________
123AliMUONVStore*
124AliMUONCalibrationData::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"));
c5bdf179 128}
129
130//_____________________________________________________________________________
c3ce65fd 131AliMUONVCalibParam*
5562688f 132AliMUONCalibrationData::CreateGlobalTriggerBoardMasks(Int_t runNumber)
c5bdf179 133{
5562688f 134 /// Create the internal store for GlobalTriggerBoardMasks from OCDB
48ed403b 135
5562688f 136 return dynamic_cast<AliMUONVCalibParam*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerBoardMasks"));
48ed403b 137}
138
c1bbaf66 139//_____________________________________________________________________________
5562688f 140TMap*
141AliMUONCalibrationData::CreateHV(Int_t runNumber)
c1bbaf66 142{
5562688f 143 /// Create a new HV map from the OCDB for a given run
144 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV"));
c1bbaf66 145}
146
d067ba7c 147//_____________________________________________________________________________
a0eca509 148AliMUONVStore*
5562688f 149AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber)
d067ba7c 150{
5562688f 151 /// Get the internal store for LocalTriggerBoardMasks from OCDB
152
153 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks"));
d067ba7c 154}
155
48ed403b 156//_____________________________________________________________________________
a0eca509 157AliMUONVStore*
5562688f 158AliMUONCalibrationData::CreateNeighbours(Int_t runNumber)
48ed403b 159{
5562688f 160 /// Create a neighbour store from the OCDB for a given run
161 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours"));
c5bdf179 162}
163
d067ba7c 164//_____________________________________________________________________________
5562688f 165TObject*
166AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path)
d067ba7c 167{
5562688f 168 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
169 /// and return the corresponding TObject.
d067ba7c 170
4bec0403 171 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path));
172
5562688f 173 AliCDBManager* man = AliCDBManager::Instance();
174
4bec0403 175 if ( !man->IsDefaultStorageSet() )
176 {
7f432a7e 177 AliErrorClass("CDB Storage not set. Must use AliCDBManager::Instance()->SetDefaultStorage() first.");
178 return 0x0;
4bec0403 179 }
180
5562688f 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)
d067ba7c 190 {
4bec0403 191 TObject* object = entry->GetObject();
192 entry->SetOwner(kFALSE);
193 delete entry;
194 return object;
195 }
196
5562688f 197 return 0x0;
d067ba7c 198}
199
c1bbaf66 200//_____________________________________________________________________________
a0eca509 201AliMUONVStore*
5562688f 202AliMUONCalibrationData::CreatePedestals(Int_t runNumber)
c1bbaf66 203{
5562688f 204 /// Create a new pedestal store from the OCDB for a given run
205 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals"));
c1bbaf66 206}
207
c5bdf179 208//_____________________________________________________________________________
a0eca509 209AliMUONVStore*
5562688f 210AliMUONCalibrationData::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//_____________________________________________________________________________
218AliMUONTriggerEfficiencyCells*
219AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber)
c5bdf179 220{
5562688f 221 /// Create trigger efficiency object from OCBD
222
223 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency"));
224}
5398f946 225
5562688f 226//_____________________________________________________________________________
227AliMUONTriggerLut*
228AliMUONCalibrationData::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//_____________________________________________________________________________
236AliMUONVStore*
237AliMUONCalibrationData::Gains() const
238{
239 /// Create (if needed) and return the internal store for gains.
c5bdf179 240 if (!fGains)
241 {
5562688f 242 fGains = CreateGains(fRunNumber);
c5bdf179 243 }
244 return fGains;
245}
246
e7d7fa47 247//_____________________________________________________________________________
5562688f 248AliMUONVCalibParam*
249AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
e7d7fa47 250{
5562688f 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).
5398f946 254
5562688f 255 AliMUONVStore* gains = Gains();
256 if (!gains)
257 {
258 return 0x0;
259 }
260
261 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
e7d7fa47 262}
263
264//_____________________________________________________________________________
5562688f 265AliMUONVCalibParam*
266AliMUONCalibrationData::GlobalTriggerBoardMasks() const
e7d7fa47 267{
5562688f 268 /// Return the masks for the global trigger board.
269
e7d7fa47 270 if (!fGlobalTriggerBoardMasks)
271 {
5562688f 272 fGlobalTriggerBoardMasks = CreateGlobalTriggerBoardMasks(fRunNumber);
e7d7fa47 273 }
274 return fGlobalTriggerBoardMasks;
275}
276
277//_____________________________________________________________________________
5562688f 278TMap*
279AliMUONCalibrationData::HV() const
e7d7fa47 280{
5562688f 281 /// Return the calibration for a given (detElemId, manuId) pair
48ed403b 282
5562688f 283 if (!fHV)
e7d7fa47 284 {
5562688f 285 fHV = CreateHV(fRunNumber);
e7d7fa47 286 }
5562688f 287 return fHV;
e7d7fa47 288}
289
290//_____________________________________________________________________________
a0eca509 291AliMUONVStore*
5562688f 292AliMUONCalibrationData::Neighbours() const
e7d7fa47 293{
5562688f 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//_____________________________________________________________________________
303AliMUONVCalibParam*
304AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
305{
306/// Return the masks for a given trigger local board.
5398f946 307
e7d7fa47 308 if (!fLocalTriggerBoardMasks)
309 {
5562688f 310 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
311 }
312
313 if ( fLocalTriggerBoardMasks )
314 {
315 AliMUONVCalibParam* ltbm =
316 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
317 if (!ltbm)
e7d7fa47 318 {
5562688f 319 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
e7d7fa47 320 }
5562688f 321 return ltbm;
e7d7fa47 322 }
5562688f 323 return 0x0;
e7d7fa47 324}
325
c5bdf179 326//_____________________________________________________________________________
a0eca509 327AliMUONVStore*
5562688f 328AliMUONCalibrationData::Pedestals() const
c5bdf179 329{
5562688f 330 /// Return pedestals
c5bdf179 331 if (!fPedestals)
332 {
5562688f 333 fPedestals = CreatePedestals(fRunNumber);
c5bdf179 334 }
335 return fPedestals;
336}
337
5562688f 338//_____________________________________________________________________________
339AliMUONVCalibParam*
340AliMUONCalibrationData::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
c5bdf179 355//_____________________________________________________________________________
356void
357AliMUONCalibrationData::Print(Option_t*) const
358{
5562688f 359 /// A very basic dump of our guts.
5398f946 360
c5bdf179 361 cout << "RunNumber " << RunNumber()
e7d7fa47 362 << " fGains=" << fGains
363 << " fPedestals=" << fPedestals
48ed403b 364 << " fHV=" << fHV
e7d7fa47 365 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
366 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
367 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
368 << " fTriggerLut=" << fTriggerLut
c5bdf179 369 << endl;
370}
371
e7d7fa47 372//_____________________________________________________________________________
373AliMUONVCalibParam*
5562688f 374AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t regionalBoardNumber) const
e7d7fa47 375{
5398f946 376/// Return the masks for a given trigger regional board.
377
5562688f 378 if ( !fRegionalTriggerBoardMasks )
48ed403b 379 {
5562688f 380 fRegionalTriggerBoardMasks = CreateRegionalTriggerBoardMasks(fRunNumber);
48ed403b 381 }
382
5562688f 383 if ( fRegionalTriggerBoardMasks )
e7d7fa47 384 {
5562688f 385 AliMUONVCalibParam* rtbm =
386 static_cast<AliMUONVCalibParam*>(fRegionalTriggerBoardMasks->FindObject(regionalBoardNumber));
387
388 if (!rtbm)
e7d7fa47 389 {
bafc927b 390 AliError(Form("Could not get mask for regionalBoard index=%d",regionalBoardNumber));
e7d7fa47 391 }
5562688f 392 return rtbm;
e7d7fa47 393 }
5562688f 394 return 0x0;
e7d7fa47 395}
396
397//_____________________________________________________________________________
398AliMUONTriggerEfficiencyCells*
399AliMUONCalibrationData::TriggerEfficiency() const
400{
5398f946 401/// Return the trigger efficiency.
402
e7d7fa47 403 if (!fTriggerEfficiency)
404 {
5562688f 405 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
e7d7fa47 406 }
407 return fTriggerEfficiency;
408}
409
5562688f 410
e7d7fa47 411//_____________________________________________________________________________
412AliMUONTriggerLut*
413AliMUONCalibrationData::TriggerLut() const
414{
5398f946 415/// Return the trigger look up table.
416
e7d7fa47 417 if (!fTriggerLut)
418 {
5562688f 419 fTriggerLut = CreateTriggerLut(fRunNumber);
e7d7fa47 420 }
421 return fTriggerLut;
422}
423
c1bbaf66 424//_____________________________________________________________________________
425void
426AliMUONCalibrationData::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;
d067ba7c 448 delete fNeighbours;
449 fNeighbours = 0x0;
c1bbaf66 450}
451
e7d7fa47 452
c5bdf179 453