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