1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONCalibrationData.h"
20 #include "AliCDBEntry.h"
21 #include "AliCDBManager.h"
22 #include "AliCodeTimer.h"
24 #include "AliMUONTriggerEfficiencyCells.h"
25 #include "AliMUONTriggerLut.h"
26 #include "AliMUONVStore.h"
27 #include "AliMUONVStore.h"
28 #include "AliMUONVCalibParam.h"
29 #include "AliMUONGlobalCrateConfig.h"
30 #include "AliMUONRegionalTriggerConfig.h"
32 #include <Riostream.h>
36 //-----------------------------------------------------------------------------
37 /// \class AliMUONCalibrationData
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.
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.
46 /// It acts as a "facade" to a bunch of underlying
47 /// containers/calibration classes.
49 /// \author Laurent Aphecetche
50 //-----------------------------------------------------------------------------
53 ClassImp(AliMUONCalibrationData)
56 //_____________________________________________________________________________
57 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
58 Bool_t deferredInitialization)
61 fRunNumber(runNumber),
66 fLocalTriggerBoardMasks(0x0),
67 fRegionalTriggerConfig(0x0),
68 fGlobalTriggerCrateConfig(0x0),
70 fTriggerEfficiency(0x0),
77 // If deferredInitialization is false, we read *all* calibrations
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.
83 if ( deferredInitialization == kFALSE )
90 LocalTriggerBoardMasks(0);
91 RegionalTriggerConfig();
92 GlobalTriggerCrateConfig();
100 //_____________________________________________________________________________
101 AliMUONCalibrationData::~AliMUONCalibrationData()
103 /// Destructor. Note that we're the owner of our pointers.
104 //PH The owner of the objects is CDB, do not delete them!
108 //_____________________________________________________________________________
110 AliMUONCalibrationData::Capacitances() const
112 /// Create (if needed) and return the internal store for capacitances.
116 fCapacitances = CreateCapacitances(fRunNumber);
118 return fCapacitances;
121 //_____________________________________________________________________________
123 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
125 /// Create capa store from OCDB for a given run
127 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
130 //_____________________________________________________________________________
132 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
134 /// Create a new gain store from the OCDB for a given run
135 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
138 //_____________________________________________________________________________
139 AliMUONGlobalCrateConfig*
140 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
142 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
144 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
149 //_____________________________________________________________________________
151 AliMUONCalibrationData::CreateHV(Int_t runNumber, Int_t* startOfValidity)
153 /// Create a new HV map from the OCDB for a given run
154 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
157 //_____________________________________________________________________________
159 AliMUONCalibrationData::CreateTriggerDCS(Int_t runNumber, Int_t* startOfValidity)
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));
165 //_____________________________________________________________________________
167 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
169 /// Get the internal store for LocalTriggerBoardMasks from OCDB
171 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
174 //_____________________________________________________________________________
176 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
178 /// Create a neighbour store from the OCDB for a given run
179 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
182 //_____________________________________________________________________________
184 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
186 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
187 /// and return the corresponding TObject.
189 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path));
191 AliCDBManager* man = AliCDBManager::Instance();
193 AliCDBEntry* entry = man->Get(path,runNumber);
197 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
199 TObject* object = entry->GetObject();
200 entry->SetOwner(kFALSE);
201 if (!(man->GetCacheFlag())) delete entry;
206 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
212 //_____________________________________________________________________________
214 AliMUONCalibrationData::CreateKillMap(Int_t runNumber, Int_t* startOfValidity)
216 /// Create a new killmap store from the OCDB for a given run
217 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/KillMap",startOfValidity));
220 //_____________________________________________________________________________
222 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
224 /// Create a new pedestal store from the OCDB for a given run
225 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
229 //_____________________________________________________________________________
230 AliMUONRegionalTriggerConfig*
231 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
233 /// Create the internal store for RegionalTriggerConfig from OCDB
235 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
238 //_____________________________________________________________________________
239 AliMUONTriggerEfficiencyCells*
240 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
242 /// Create trigger efficiency object from OCBD
244 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
247 //_____________________________________________________________________________
249 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
251 /// Create trigger LUT from OCDB
253 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
256 //_____________________________________________________________________________
258 AliMUONCalibrationData::Gains() const
260 /// Create (if needed) and return the internal store for gains.
263 fGains = CreateGains(fRunNumber);
268 //_____________________________________________________________________________
270 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
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).
276 AliMUONVStore* gains = Gains();
282 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
285 //_____________________________________________________________________________
286 AliMUONGlobalCrateConfig*
287 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
289 /// Return the config for the global trigger board.
291 if (!fGlobalTriggerCrateConfig)
293 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
295 return fGlobalTriggerCrateConfig;
299 //_____________________________________________________________________________
301 AliMUONCalibrationData::HV() const
303 /// Return the calibration for a given (detElemId, manuId) pair
307 fHV = CreateHV(fRunNumber);
312 //_____________________________________________________________________________
314 AliMUONCalibrationData::TriggerDCS() const
316 /// Return the calibration for a given (detElemId, manuId) pair
320 fTriggerDCS = CreateTriggerDCS(fRunNumber);
325 //_____________________________________________________________________________
327 AliMUONCalibrationData::Neighbours() const
329 /// Create (if needed) and return the internal store for neighbours.
332 fNeighbours = CreateNeighbours(fRunNumber);
337 //_____________________________________________________________________________
339 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
341 /// Return the masks for a given trigger local board.
343 if (!fLocalTriggerBoardMasks)
345 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
348 if ( fLocalTriggerBoardMasks )
350 AliMUONVCalibParam* ltbm =
351 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
354 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
361 //_____________________________________________________________________________
363 AliMUONCalibrationData::KillMap() const
368 fKillMap = CreateKillMap(fRunNumber);
373 //_____________________________________________________________________________
375 AliMUONCalibrationData::KillMap(Int_t detElemId, Int_t manuId) const
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 ;-)
381 AliMUONVStore* killMap = KillMap();
387 return static_cast<AliMUONVCalibParam*>(killMap->FindObject(detElemId,manuId));
391 //_____________________________________________________________________________
393 AliMUONCalibrationData::Pedestals() const
398 fPedestals = CreatePedestals(fRunNumber);
403 //_____________________________________________________________________________
405 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
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.
411 AliMUONVStore* pedestals = Pedestals();
417 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
420 //_____________________________________________________________________________
422 AliMUONCalibrationData::Print(Option_t*) const
424 /// A very basic dump of our guts.
426 cout << "RunNumber " << RunNumber()
427 << " fGains=" << fGains
428 << " fPedestals=" << fPedestals
430 << " fTriggerDCS=" << fTriggerDCS
431 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
432 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
433 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
434 << " fTriggerLut=" << fTriggerLut
439 //_____________________________________________________________________________
440 AliMUONRegionalTriggerConfig*
441 AliMUONCalibrationData::RegionalTriggerConfig() const
443 /// Return the config for the regional trigger board.
445 if (!fRegionalTriggerConfig)
447 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
449 return fRegionalTriggerConfig;
453 //_____________________________________________________________________________
454 AliMUONTriggerEfficiencyCells*
455 AliMUONCalibrationData::TriggerEfficiency() const
457 /// Return the trigger efficiency.
459 if (!fTriggerEfficiency)
461 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
463 return fTriggerEfficiency;
467 //_____________________________________________________________________________
469 AliMUONCalibrationData::TriggerLut() const
471 /// Return the trigger look up table.
475 fTriggerLut = CreateTriggerLut(fRunNumber);
480 //_____________________________________________________________________________
482 AliMUONCalibrationData::Reset()
494 delete fLocalTriggerBoardMasks;
495 fLocalTriggerBoardMasks = 0x0;
496 delete fRegionalTriggerConfig;
497 fRegionalTriggerConfig = 0x0;
498 delete fGlobalTriggerCrateConfig;
499 fGlobalTriggerCrateConfig = 0x0;
503 delete fTriggerEfficiency;
504 fTriggerEfficiency = 0x0;
505 delete fCapacitances;
511 //_____________________________________________________________________________
513 AliMUONCalibrationData::Check(Int_t runNumber)
515 /// Self-check to see if we can read all data for a given run
516 /// from the current OCDB...
518 if ( ! CreateCapacitances(runNumber) )
520 AliErrorClass("Could not read capacitances");
524 AliInfoClass("Capacitances read OK");
527 if ( ! CreateGains(runNumber) )
529 AliErrorClass("Could not read gains");
533 AliInfoClass("Gains read OK");
536 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
538 AliErrorClass("Could not read Trigger Crate Config");
542 AliInfoClass("TriggerBoardMasks read OK");
545 if ( ! CreateHV(runNumber) )
547 AliErrorClass("Could not read HV");
551 AliInfoClass("HV read OK");
554 if ( ! CreateTriggerDCS(runNumber) )
556 AliErrorClass("Could not read Trigger HV and Currents");
560 AliInfoClass("Trigger HV and Currents read OK");
563 if ( ! CreateNeighbours(runNumber) )
565 AliErrorClass("Could not read Neighbours");
569 AliInfoClass("Neighbours read OK");
572 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
574 AliErrorClass("Could not read LocalTriggerBoardMasks");
578 AliInfoClass("LocalTriggerBoardMasks read OK");
581 if ( ! CreatePedestals(runNumber) )
583 AliErrorClass("Could not read pedestals");
587 AliInfoClass("Pedestals read OK");
590 if ( ! CreateRegionalTriggerConfig(runNumber) )
592 AliErrorClass("Could not read RegionalTriggerConfig");
596 AliInfoClass("RegionalTriggerBoardMasks read OK");
599 if ( ! CreateTriggerLut(runNumber) )
601 AliErrorClass("Could not read TriggerLut");
605 AliInfoClass("TriggerLut read OK");
608 if ( ! CreateTriggerEfficiency(runNumber) )
610 AliErrorClass("Could not read TriggerEfficiency");
614 AliInfoClass("TriggerEfficiency read OK");