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