]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCalibrationData.cxx
Exec changed to UserExec.
[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
4bec0403 180 if ( !man->IsDefaultStorageSet() )
181 {
7f432a7e 182 AliErrorClass("CDB Storage not set. Must use AliCDBManager::Instance()->SetDefaultStorage() first.");
183 return 0x0;
4bec0403 184 }
185
5562688f 186 Bool_t cacheStatus = man->GetCacheFlag();
187
188 man->SetCacheFlag(kFALSE);
189
190 AliCDBEntry* entry = AliCDBManager::Instance()->Get(path,runNumber);
191
192 man->SetCacheFlag(cacheStatus);
143cd71a 193
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);
201 delete entry;
202 return object;
203 }
143cd71a 204 else
205 {
206 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
207 }
208
5562688f 209 return 0x0;
d067ba7c 210}
211
c1bbaf66 212//_____________________________________________________________________________
a0eca509 213AliMUONVStore*
143cd71a 214AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
c1bbaf66 215{
5562688f 216 /// Create a new pedestal store from the OCDB for a given run
143cd71a 217 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
c1bbaf66 218}
219
92c23b09 220
c5bdf179 221//_____________________________________________________________________________
92c23b09 222AliMUONRegionalTriggerConfig*
143cd71a 223AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
5562688f 224{
92c23b09 225 /// Create the internal store for RegionalTriggerConfig from OCDB
5562688f 226
143cd71a 227 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
5562688f 228}
229
230//_____________________________________________________________________________
231AliMUONTriggerEfficiencyCells*
143cd71a 232AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
c5bdf179 233{
5562688f 234 /// Create trigger efficiency object from OCBD
235
143cd71a 236 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
5562688f 237}
5398f946 238
5562688f 239//_____________________________________________________________________________
240AliMUONTriggerLut*
143cd71a 241AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
5562688f 242{
243 /// Create trigger LUT from OCDB
244
143cd71a 245 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
5562688f 246}
247
248//_____________________________________________________________________________
249AliMUONVStore*
250AliMUONCalibrationData::Gains() const
251{
252 /// Create (if needed) and return the internal store for gains.
c5bdf179 253 if (!fGains)
254 {
5562688f 255 fGains = CreateGains(fRunNumber);
c5bdf179 256 }
257 return fGains;
258}
259
e7d7fa47 260//_____________________________________________________________________________
5562688f 261AliMUONVCalibParam*
262AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
e7d7fa47 263{
5562688f 264/// Return the gains for a given (detElemId, manuId) pair
265/// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
266/// error (meaning that we should get gains for all channels).
5398f946 267
5562688f 268 AliMUONVStore* gains = Gains();
269 if (!gains)
270 {
271 return 0x0;
272 }
273
274 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
e7d7fa47 275}
276
277//_____________________________________________________________________________
92c23b09 278AliMUONGlobalCrateConfig*
279AliMUONCalibrationData::GlobalTriggerCrateConfig() const
e7d7fa47 280{
92c23b09 281 /// Return the config for the global trigger board.
5562688f 282
92c23b09 283 if (!fGlobalTriggerCrateConfig)
e7d7fa47 284 {
92c23b09 285 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
e7d7fa47 286 }
92c23b09 287 return fGlobalTriggerCrateConfig;
e7d7fa47 288}
289
92c23b09 290
e7d7fa47 291//_____________________________________________________________________________
5562688f 292TMap*
293AliMUONCalibrationData::HV() const
e7d7fa47 294{
5562688f 295 /// Return the calibration for a given (detElemId, manuId) pair
48ed403b 296
5562688f 297 if (!fHV)
e7d7fa47 298 {
5562688f 299 fHV = CreateHV(fRunNumber);
e7d7fa47 300 }
5562688f 301 return fHV;
e7d7fa47 302}
303
304//_____________________________________________________________________________
a0eca509 305AliMUONVStore*
5562688f 306AliMUONCalibrationData::Neighbours() const
e7d7fa47 307{
5562688f 308 /// Create (if needed) and return the internal store for neighbours.
309 if (!fNeighbours)
310 {
311 fNeighbours = CreateNeighbours(fRunNumber);
312 }
313 return fNeighbours;
314}
315
316//_____________________________________________________________________________
317AliMUONVCalibParam*
318AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
319{
320/// Return the masks for a given trigger local board.
5398f946 321
e7d7fa47 322 if (!fLocalTriggerBoardMasks)
323 {
5562688f 324 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
325 }
326
327 if ( fLocalTriggerBoardMasks )
328 {
329 AliMUONVCalibParam* ltbm =
330 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
331 if (!ltbm)
e7d7fa47 332 {
5562688f 333 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
e7d7fa47 334 }
5562688f 335 return ltbm;
e7d7fa47 336 }
5562688f 337 return 0x0;
e7d7fa47 338}
339
c5bdf179 340//_____________________________________________________________________________
a0eca509 341AliMUONVStore*
5562688f 342AliMUONCalibrationData::Pedestals() const
c5bdf179 343{
5562688f 344 /// Return pedestals
c5bdf179 345 if (!fPedestals)
346 {
5562688f 347 fPedestals = CreatePedestals(fRunNumber);
c5bdf179 348 }
349 return fPedestals;
350}
351
5562688f 352//_____________________________________________________________________________
353AliMUONVCalibParam*
354AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
355{
356 /// Return the pedestals for a given (detElemId, manuId) pair.
357 /// A return value of 0x0 is considered an error, meaning we should get
358 /// pedestals for all channels.
359
360 AliMUONVStore* pedestals = Pedestals();
361 if (!pedestals)
362 {
363 return 0x0;
364 }
365
366 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
367}
368
c5bdf179 369//_____________________________________________________________________________
370void
371AliMUONCalibrationData::Print(Option_t*) const
372{
5562688f 373 /// A very basic dump of our guts.
5398f946 374
c5bdf179 375 cout << "RunNumber " << RunNumber()
e7d7fa47 376 << " fGains=" << fGains
377 << " fPedestals=" << fPedestals
48ed403b 378 << " fHV=" << fHV
e7d7fa47 379 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
92c23b09 380 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
381 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
e7d7fa47 382 << " fTriggerLut=" << fTriggerLut
c5bdf179 383 << endl;
384}
385
92c23b09 386
e7d7fa47 387//_____________________________________________________________________________
92c23b09 388AliMUONRegionalTriggerConfig*
389AliMUONCalibrationData::RegionalTriggerConfig() const
e7d7fa47 390{
92c23b09 391 /// Return the config for the regional trigger board.
48ed403b 392
92c23b09 393 if (!fRegionalTriggerConfig)
e7d7fa47 394 {
92c23b09 395 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
e7d7fa47 396 }
92c23b09 397 return fRegionalTriggerConfig;
e7d7fa47 398}
399
92c23b09 400
e7d7fa47 401//_____________________________________________________________________________
402AliMUONTriggerEfficiencyCells*
403AliMUONCalibrationData::TriggerEfficiency() const
404{
5398f946 405/// Return the trigger efficiency.
406
e7d7fa47 407 if (!fTriggerEfficiency)
408 {
5562688f 409 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
e7d7fa47 410 }
411 return fTriggerEfficiency;
412}
413
5562688f 414
e7d7fa47 415//_____________________________________________________________________________
416AliMUONTriggerLut*
417AliMUONCalibrationData::TriggerLut() const
418{
5398f946 419/// Return the trigger look up table.
420
e7d7fa47 421 if (!fTriggerLut)
422 {
5562688f 423 fTriggerLut = CreateTriggerLut(fRunNumber);
e7d7fa47 424 }
425 return fTriggerLut;
426}
427
c1bbaf66 428//_____________________________________________________________________________
429void
430AliMUONCalibrationData::Reset()
431{
432/// Reset all data
433
434 delete fPedestals;
435 fPedestals = 0x0;
436 delete fGains;
437 fGains = 0x0;
438 delete fHV;
439 fHV = 0x0;
440 delete fLocalTriggerBoardMasks;
441 fLocalTriggerBoardMasks = 0x0;
92c23b09 442 delete fRegionalTriggerConfig;
443 fRegionalTriggerConfig = 0x0;
444 delete fGlobalTriggerCrateConfig;
445 fGlobalTriggerCrateConfig = 0x0;
446
c1bbaf66 447 delete fTriggerLut;
448 fTriggerLut = 0x0;
449 delete fTriggerEfficiency;
450 fTriggerEfficiency = 0x0;
451 delete fCapacitances;
452 fCapacitances = 0x0;
d067ba7c 453 delete fNeighbours;
454 fNeighbours = 0x0;
c1bbaf66 455}
456
630711ed 457//_____________________________________________________________________________
458void
459AliMUONCalibrationData::Check(Int_t runNumber)
460{
461 /// Self-check to see if we can read all data for a given run
462 /// from the current OCDB...
463
464 if ( ! CreateCapacitances(runNumber) )
465 {
466 AliErrorClass("Could not read capacitances");
467 }
468 else
469 {
470 AliInfoClass("Capacitances read OK");
471 }
472
473 if ( ! CreateGains(runNumber) )
474 {
475 AliErrorClass("Could not read gains");
476 }
477 else
478 {
479 AliInfoClass("Gains read OK");
480 }
481
482 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
483 {
484 AliErrorClass("Could not read Trigger Crate Config");
485 }
486 else
487 {
488 AliInfoClass("TriggerBoardMasks read OK");
489 }
490
491 if ( ! CreateHV(runNumber) )
492 {
493 AliErrorClass("Could not read HV");
494 }
495 else
496 {
497 AliInfoClass("HV read OK");
498 }
499
500 if ( ! CreateNeighbours(runNumber) )
501 {
502 AliErrorClass("Could not read Neighbours");
503 }
504 else
505 {
506 AliInfoClass("Neighbours read OK");
507 }
508
509 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
510 {
511 AliErrorClass("Could not read LocalTriggerBoardMasks");
512 }
513 else
514 {
515 AliInfoClass("LocalTriggerBoardMasks read OK");
516 }
517
518 if ( ! CreatePedestals(runNumber) )
519 {
520 AliErrorClass("Could not read pedestals");
521 }
522 else
523 {
524 AliInfoClass("Pedestals read OK");
525 }
526
527 if ( ! CreateRegionalTriggerConfig(runNumber) )
528 {
529 AliErrorClass("Could not read RegionalTriggerConfig");
530 }
531 else
532 {
533 AliInfoClass("RegionalTriggerBoardMasks read OK");
534 }
535
536 if ( ! CreateTriggerLut(runNumber) )
537 {
538 AliErrorClass("Could not read TriggerLut");
539 }
540 else
541 {
542 AliInfoClass("TriggerLut read OK");
543 }
544
545 if ( ! CreateTriggerEfficiency(runNumber) )
546 {
547 AliErrorClass("Could not read TriggerEfficiency");
548 }
549 else
550 {
551 AliInfoClass("TriggerEfficiency read OK");
552 }
553}
e7d7fa47 554
c5bdf179 555