]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCalibrationData.cxx
Adding classes forgotten in previous commit
[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"
92c23b09 29#include "AliMUONGlobalCrateConfig.h"
30#include "AliMUONRegionalTriggerConfig.h"
31
4bec0403 32#include <Riostream.h>
33#include <TClass.h>
34#include <TMap.h>
c5bdf179 35
3d1463c8 36//-----------------------------------------------------------------------------
5398f946 37/// \class AliMUONCalibrationData
38///
48ed403b 39/// For the moment, this class stores pedestals, gains, hv (for tracker)
40/// and lut, masks and efficiencies (for trigger) that are fetched from the CDB.
e7d7fa47 41///
42/// This class is to be considered as a convenience class.
43/// Its aim is to ease retrieval of calibration data from the
44/// condition database.
45///
46/// It acts as a "facade" to a bunch of underlying
47/// containers/calibration classes.
48///
5398f946 49/// \author Laurent Aphecetche
3d1463c8 50//-----------------------------------------------------------------------------
e7d7fa47 51
5398f946 52/// \cond CLASSIMP
c5bdf179 53ClassImp(AliMUONCalibrationData)
5398f946 54/// \endcond
c5bdf179 55
56//_____________________________________________________________________________
57AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
58 Bool_t deferredInitialization)
59: TObject(),
60fIsValid(kTRUE),
61fRunNumber(runNumber),
62fGains(0x0),
c3ce65fd 63fPedestals(0x0),
48ed403b 64fHV(0x0),
49e110ec 65fTriggerDCS(0x0),
e7d7fa47 66fLocalTriggerBoardMasks(0x0),
92c23b09 67fRegionalTriggerConfig(0x0),
68fGlobalTriggerCrateConfig(0x0),
e7d7fa47 69fTriggerLut(0x0),
c1bbaf66 70fTriggerEfficiency(0x0),
d067ba7c 71fCapacitances(0x0),
72fNeighbours(0x0)
c5bdf179 73{
5398f946 74/// Default ctor.
75
c3ce65fd 76 // If deferredInitialization is false, we read *all* calibrations
77 // at once.
78 // So when using this class to access only one kind of calibrations (e.g.
79 // only pedestals), you should put deferredInitialization to kTRUE, which
80 // will instruct this object to fetch the data only when neeeded.
5398f946 81
c5bdf179 82 if ( deferredInitialization == kFALSE )
83 {
5562688f 84 Gains();
85 Pedestals();
86 HV();
49e110ec 87 TriggerDCS();
5562688f 88 LocalTriggerBoardMasks(0);
92c23b09 89 RegionalTriggerConfig();
90 GlobalTriggerCrateConfig();
5562688f 91 TriggerLut();
92 TriggerEfficiency();
93 Capacitances();
94 Neighbours();
c5bdf179 95 }
96}
97
c5bdf179 98//_____________________________________________________________________________
99AliMUONCalibrationData::~AliMUONCalibrationData()
100{
c1bbaf66 101 /// Destructor. Note that we're the owner of our pointers.
23b1bc04 102 //PH The owner of the objects is CDB, do not delete them!
103 // Reset();
c3ce65fd 104}
c3ce65fd 105
106//_____________________________________________________________________________
5562688f 107AliMUONVStore*
108AliMUONCalibrationData::Capacitances() const
c3ce65fd 109{
5562688f 110 /// Create (if needed) and return the internal store for capacitances.
111
112 if (!fCapacitances)
c3ce65fd 113 {
5562688f 114 fCapacitances = CreateCapacitances(fRunNumber);
c3ce65fd 115 }
5562688f 116 return fCapacitances;
c5bdf179 117}
118
119//_____________________________________________________________________________
5562688f 120AliMUONVStore*
143cd71a 121AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
c5bdf179 122{
5562688f 123 /// Create capa store from OCDB for a given run
124
143cd71a 125 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
5562688f 126}
5398f946 127
5562688f 128//_____________________________________________________________________________
129AliMUONVStore*
143cd71a 130AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
5562688f 131{
132 /// Create a new gain store from the OCDB for a given run
143cd71a 133 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
c5bdf179 134}
135
136//_____________________________________________________________________________
92c23b09 137AliMUONGlobalCrateConfig*
143cd71a 138AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
c5bdf179 139{
92c23b09 140 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
48ed403b 141
143cd71a 142 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
48ed403b 143}
144
92c23b09 145
146
c1bbaf66 147//_____________________________________________________________________________
5562688f 148TMap*
143cd71a 149AliMUONCalibrationData::CreateHV(Int_t runNumber, Int_t* startOfValidity)
c1bbaf66 150{
5562688f 151 /// Create a new HV map from the OCDB for a given run
143cd71a 152 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
c1bbaf66 153}
154
49e110ec 155//_____________________________________________________________________________
156TMap*
157AliMUONCalibrationData::CreateTriggerDCS(Int_t runNumber, Int_t* startOfValidity)
158{
159 /// Create a new Trigger HV and curent map from the OCDB for a given run
160 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/TriggerDCS",startOfValidity));
161}
162
d067ba7c 163//_____________________________________________________________________________
a0eca509 164AliMUONVStore*
143cd71a 165AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
d067ba7c 166{
5562688f 167 /// Get the internal store for LocalTriggerBoardMasks from OCDB
168
143cd71a 169 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
d067ba7c 170}
171
48ed403b 172//_____________________________________________________________________________
a0eca509 173AliMUONVStore*
143cd71a 174AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
48ed403b 175{
5562688f 176 /// Create a neighbour store from the OCDB for a given run
143cd71a 177 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
c5bdf179 178}
179
d067ba7c 180//_____________________________________________________________________________
5562688f 181TObject*
143cd71a 182AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
d067ba7c 183{
5562688f 184 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
185 /// and return the corresponding TObject.
d067ba7c 186
4bec0403 187 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path));
188
5562688f 189 AliCDBManager* man = AliCDBManager::Instance();
190
465302eb 191 AliCDBEntry* entry = man->Get(path,runNumber);
5562688f 192
5562688f 193 if (entry)
d067ba7c 194 {
143cd71a 195 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
196
4bec0403 197 TObject* object = entry->GetObject();
198 entry->SetOwner(kFALSE);
465302eb 199 if (!(man->GetCacheFlag())) delete entry;
4bec0403 200 return object;
201 }
143cd71a 202 else
203 {
204 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
205 }
206
5562688f 207 return 0x0;
d067ba7c 208}
209
c1bbaf66 210//_____________________________________________________________________________
a0eca509 211AliMUONVStore*
143cd71a 212AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
c1bbaf66 213{
5562688f 214 /// Create a new pedestal store from the OCDB for a given run
143cd71a 215 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
c1bbaf66 216}
217
92c23b09 218
c5bdf179 219//_____________________________________________________________________________
92c23b09 220AliMUONRegionalTriggerConfig*
143cd71a 221AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
5562688f 222{
92c23b09 223 /// Create the internal store for RegionalTriggerConfig from OCDB
5562688f 224
143cd71a 225 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
5562688f 226}
227
228//_____________________________________________________________________________
229AliMUONTriggerEfficiencyCells*
143cd71a 230AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
c5bdf179 231{
5562688f 232 /// Create trigger efficiency object from OCBD
233
143cd71a 234 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
5562688f 235}
5398f946 236
5562688f 237//_____________________________________________________________________________
238AliMUONTriggerLut*
143cd71a 239AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
5562688f 240{
241 /// Create trigger LUT from OCDB
242
143cd71a 243 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
5562688f 244}
245
246//_____________________________________________________________________________
247AliMUONVStore*
248AliMUONCalibrationData::Gains() const
249{
250 /// Create (if needed) and return the internal store for gains.
c5bdf179 251 if (!fGains)
252 {
5562688f 253 fGains = CreateGains(fRunNumber);
c5bdf179 254 }
255 return fGains;
256}
257
e7d7fa47 258//_____________________________________________________________________________
5562688f 259AliMUONVCalibParam*
260AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
e7d7fa47 261{
5562688f 262/// Return the gains for a given (detElemId, manuId) pair
263/// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
264/// error (meaning that we should get gains for all channels).
5398f946 265
5562688f 266 AliMUONVStore* gains = Gains();
267 if (!gains)
268 {
269 return 0x0;
270 }
271
272 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
e7d7fa47 273}
274
275//_____________________________________________________________________________
92c23b09 276AliMUONGlobalCrateConfig*
277AliMUONCalibrationData::GlobalTriggerCrateConfig() const
e7d7fa47 278{
92c23b09 279 /// Return the config for the global trigger board.
5562688f 280
92c23b09 281 if (!fGlobalTriggerCrateConfig)
e7d7fa47 282 {
92c23b09 283 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
e7d7fa47 284 }
92c23b09 285 return fGlobalTriggerCrateConfig;
e7d7fa47 286}
287
92c23b09 288
e7d7fa47 289//_____________________________________________________________________________
5562688f 290TMap*
291AliMUONCalibrationData::HV() const
e7d7fa47 292{
5562688f 293 /// Return the calibration for a given (detElemId, manuId) pair
48ed403b 294
5562688f 295 if (!fHV)
e7d7fa47 296 {
5562688f 297 fHV = CreateHV(fRunNumber);
e7d7fa47 298 }
5562688f 299 return fHV;
e7d7fa47 300}
301
49e110ec 302//_____________________________________________________________________________
303TMap*
304AliMUONCalibrationData::TriggerDCS() const
305{
306 /// Return the calibration for a given (detElemId, manuId) pair
307
308 if (!fTriggerDCS)
309 {
310 fTriggerDCS = CreateTriggerDCS(fRunNumber);
311 }
312 return fTriggerDCS;
313}
314
e7d7fa47 315//_____________________________________________________________________________
a0eca509 316AliMUONVStore*
5562688f 317AliMUONCalibrationData::Neighbours() const
e7d7fa47 318{
5562688f 319 /// Create (if needed) and return the internal store for neighbours.
320 if (!fNeighbours)
321 {
322 fNeighbours = CreateNeighbours(fRunNumber);
323 }
324 return fNeighbours;
325}
326
327//_____________________________________________________________________________
328AliMUONVCalibParam*
329AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
330{
331/// Return the masks for a given trigger local board.
5398f946 332
e7d7fa47 333 if (!fLocalTriggerBoardMasks)
334 {
5562688f 335 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
336 }
337
338 if ( fLocalTriggerBoardMasks )
339 {
340 AliMUONVCalibParam* ltbm =
341 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
342 if (!ltbm)
e7d7fa47 343 {
5562688f 344 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
e7d7fa47 345 }
5562688f 346 return ltbm;
e7d7fa47 347 }
5562688f 348 return 0x0;
e7d7fa47 349}
350
c5bdf179 351//_____________________________________________________________________________
a0eca509 352AliMUONVStore*
5562688f 353AliMUONCalibrationData::Pedestals() const
c5bdf179 354{
5562688f 355 /// Return pedestals
c5bdf179 356 if (!fPedestals)
357 {
5562688f 358 fPedestals = CreatePedestals(fRunNumber);
c5bdf179 359 }
360 return fPedestals;
361}
362
5562688f 363//_____________________________________________________________________________
364AliMUONVCalibParam*
365AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
366{
367 /// Return the pedestals for a given (detElemId, manuId) pair.
368 /// A return value of 0x0 is considered an error, meaning we should get
369 /// pedestals for all channels.
370
371 AliMUONVStore* pedestals = Pedestals();
372 if (!pedestals)
373 {
374 return 0x0;
375 }
376
377 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
378}
379
c5bdf179 380//_____________________________________________________________________________
381void
382AliMUONCalibrationData::Print(Option_t*) const
383{
5562688f 384 /// A very basic dump of our guts.
5398f946 385
c5bdf179 386 cout << "RunNumber " << RunNumber()
e7d7fa47 387 << " fGains=" << fGains
388 << " fPedestals=" << fPedestals
48ed403b 389 << " fHV=" << fHV
49e110ec 390 << " fTriggerDCS=" << fTriggerDCS
e7d7fa47 391 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
92c23b09 392 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
393 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
e7d7fa47 394 << " fTriggerLut=" << fTriggerLut
c5bdf179 395 << endl;
396}
397
92c23b09 398
e7d7fa47 399//_____________________________________________________________________________
92c23b09 400AliMUONRegionalTriggerConfig*
401AliMUONCalibrationData::RegionalTriggerConfig() const
e7d7fa47 402{
92c23b09 403 /// Return the config for the regional trigger board.
48ed403b 404
92c23b09 405 if (!fRegionalTriggerConfig)
e7d7fa47 406 {
92c23b09 407 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
e7d7fa47 408 }
92c23b09 409 return fRegionalTriggerConfig;
e7d7fa47 410}
411
92c23b09 412
e7d7fa47 413//_____________________________________________________________________________
414AliMUONTriggerEfficiencyCells*
415AliMUONCalibrationData::TriggerEfficiency() const
416{
5398f946 417/// Return the trigger efficiency.
418
e7d7fa47 419 if (!fTriggerEfficiency)
420 {
5562688f 421 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
e7d7fa47 422 }
423 return fTriggerEfficiency;
424}
425
5562688f 426
e7d7fa47 427//_____________________________________________________________________________
428AliMUONTriggerLut*
429AliMUONCalibrationData::TriggerLut() const
430{
5398f946 431/// Return the trigger look up table.
432
e7d7fa47 433 if (!fTriggerLut)
434 {
5562688f 435 fTriggerLut = CreateTriggerLut(fRunNumber);
e7d7fa47 436 }
437 return fTriggerLut;
438}
439
c1bbaf66 440//_____________________________________________________________________________
441void
442AliMUONCalibrationData::Reset()
443{
444/// Reset all data
445
446 delete fPedestals;
447 fPedestals = 0x0;
448 delete fGains;
449 fGains = 0x0;
450 delete fHV;
451 fHV = 0x0;
49e110ec 452 delete fTriggerDCS;
453 fTriggerDCS = 0x0;
c1bbaf66 454 delete fLocalTriggerBoardMasks;
455 fLocalTriggerBoardMasks = 0x0;
92c23b09 456 delete fRegionalTriggerConfig;
457 fRegionalTriggerConfig = 0x0;
458 delete fGlobalTriggerCrateConfig;
459 fGlobalTriggerCrateConfig = 0x0;
460
c1bbaf66 461 delete fTriggerLut;
462 fTriggerLut = 0x0;
463 delete fTriggerEfficiency;
464 fTriggerEfficiency = 0x0;
465 delete fCapacitances;
466 fCapacitances = 0x0;
d067ba7c 467 delete fNeighbours;
468 fNeighbours = 0x0;
c1bbaf66 469}
470
630711ed 471//_____________________________________________________________________________
472void
473AliMUONCalibrationData::Check(Int_t runNumber)
474{
475 /// Self-check to see if we can read all data for a given run
476 /// from the current OCDB...
477
478 if ( ! CreateCapacitances(runNumber) )
479 {
480 AliErrorClass("Could not read capacitances");
481 }
482 else
483 {
484 AliInfoClass("Capacitances read OK");
485 }
486
487 if ( ! CreateGains(runNumber) )
488 {
489 AliErrorClass("Could not read gains");
490 }
491 else
492 {
493 AliInfoClass("Gains read OK");
494 }
495
496 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
497 {
498 AliErrorClass("Could not read Trigger Crate Config");
499 }
500 else
501 {
502 AliInfoClass("TriggerBoardMasks read OK");
503 }
504
505 if ( ! CreateHV(runNumber) )
506 {
507 AliErrorClass("Could not read HV");
508 }
509 else
510 {
511 AliInfoClass("HV read OK");
49e110ec 512 }
513
514 if ( ! CreateTriggerDCS(runNumber) )
515 {
516 AliErrorClass("Could not read Trigger HV and Currents");
517 }
518 else
519 {
520 AliInfoClass("Trigger HV and Currents read OK");
630711ed 521 }
522
523 if ( ! CreateNeighbours(runNumber) )
524 {
525 AliErrorClass("Could not read Neighbours");
526 }
527 else
528 {
529 AliInfoClass("Neighbours read OK");
530 }
531
532 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
533 {
534 AliErrorClass("Could not read LocalTriggerBoardMasks");
535 }
536 else
537 {
538 AliInfoClass("LocalTriggerBoardMasks read OK");
539 }
540
541 if ( ! CreatePedestals(runNumber) )
542 {
543 AliErrorClass("Could not read pedestals");
544 }
545 else
546 {
547 AliInfoClass("Pedestals read OK");
548 }
549
550 if ( ! CreateRegionalTriggerConfig(runNumber) )
551 {
552 AliErrorClass("Could not read RegionalTriggerConfig");
553 }
554 else
555 {
556 AliInfoClass("RegionalTriggerBoardMasks read OK");
557 }
558
559 if ( ! CreateTriggerLut(runNumber) )
560 {
561 AliErrorClass("Could not read TriggerLut");
562 }
563 else
564 {
565 AliInfoClass("TriggerLut read OK");
566 }
567
568 if ( ! CreateTriggerEfficiency(runNumber) )
569 {
570 AliErrorClass("Could not read TriggerEfficiency");
571 }
572 else
573 {
574 AliInfoClass("TriggerEfficiency read OK");
575 }
576}
e7d7fa47 577
c5bdf179 578