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