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 "AliMUONRejectList.h"
25 #include "AliMUONTriggerEfficiencyCells.h"
26 #include "AliMUONTriggerLut.h"
27 #include "AliMUONVStore.h"
28 #include "AliMUONVStore.h"
29 #include "AliMUONVCalibParam.h"
30 #include "AliMUONGlobalCrateConfig.h"
31 #include "AliMUONRegionalTriggerConfig.h"
33 #include <Riostream.h>
37 //-----------------------------------------------------------------------------
38 /// \class AliMUONCalibrationData
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.
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.
47 /// It acts as a "facade" to a bunch of underlying
48 /// containers/calibration classes.
50 /// \author Laurent Aphecetche
51 //-----------------------------------------------------------------------------
54 ClassImp(AliMUONCalibrationData)
57 AliMUONVStore* AliMUONCalibrationData::fgBypassPedestals(0x0);
58 AliMUONVStore* AliMUONCalibrationData::fgBypassGains(0x0);
60 //_____________________________________________________________________________
61 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
62 Bool_t deferredInitialization)
65 fRunNumber(runNumber),
70 fLocalTriggerBoardMasks(0x0),
71 fRegionalTriggerConfig(0x0),
72 fGlobalTriggerCrateConfig(0x0),
74 fTriggerEfficiency(0x0),
83 // If deferredInitialization is false, we read *all* calibrations
85 // So when using this class to access only one kind of calibrations (e.g.
86 // only pedestals), you should put deferredInitialization to kTRUE, which
87 // will instruct this object to fetch the data only when neeeded.
89 if ( deferredInitialization == kFALSE )
97 LocalTriggerBoardMasks(0);
98 RegionalTriggerConfig();
99 GlobalTriggerCrateConfig();
108 //_____________________________________________________________________________
109 AliMUONCalibrationData::~AliMUONCalibrationData()
111 /// Destructor. Note that we're the owner of our pointers if the OCDB cache
112 /// is not set. Otherwise the cache is supposed to take care of them...
113 if (!(AliCDBManager::Instance()->GetCacheFlag())) Reset();
116 //_____________________________________________________________________________
118 AliMUONCalibrationData::Capacitances() const
120 /// Create (if needed) and return the internal store for capacitances.
124 fCapacitances = CreateCapacitances(fRunNumber);
126 return fCapacitances;
129 //_____________________________________________________________________________
131 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
133 /// Create capa store from OCDB for a given run
135 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
138 //_____________________________________________________________________________
140 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
142 /// Create a new gain store from the OCDB for a given run
143 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
146 //_____________________________________________________________________________
147 AliMUONGlobalCrateConfig*
148 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
150 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
152 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
157 //_____________________________________________________________________________
159 AliMUONCalibrationData::CreateHV(Int_t runNumber, Int_t* startOfValidity)
161 /// Create a new HV map from the OCDB for a given run
162 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
165 //_____________________________________________________________________________
167 AliMUONCalibrationData::CreateTriggerDCS(Int_t runNumber, Int_t* startOfValidity)
169 /// Create a new Trigger HV and curent map from the OCDB for a given run
170 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/TriggerDCS",startOfValidity));
173 //_____________________________________________________________________________
175 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
177 /// Get the internal store for LocalTriggerBoardMasks from OCDB
179 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
182 //_____________________________________________________________________________
184 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
186 /// Create a neighbour store from the OCDB for a given run
187 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
190 //_____________________________________________________________________________
192 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
194 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
195 /// and return the corresponding TObject.
197 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path),0);
199 AliCDBManager* man = AliCDBManager::Instance();
201 AliCDBEntry* entry = man->Get(path,runNumber);
205 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
207 TObject* object = entry->GetObject();
208 if (!(man->GetCacheFlag()))
210 entry->SetOwner(kFALSE);
217 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
222 AliCodeTimerAutoClass(Form("Failed to get %s for run %d",path,runNumber),1);
229 //_____________________________________________________________________________
231 AliMUONCalibrationData::CreateOccupancyMap(Int_t runNumber, Int_t* startOfValidity)
233 /// Create a new occupancy map store from the OCDB for a given run
234 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/OccupancyMap",startOfValidity));
237 //_____________________________________________________________________________
239 AliMUONCalibrationData::CreateRejectList(Int_t runNumber, Int_t* startOfValidity)
241 /// Create a new rejectlist store from the OCDB for a given run
242 return dynamic_cast<AliMUONRejectList*>(CreateObject(runNumber,"MUON/Calib/RejectList",startOfValidity));
245 //_____________________________________________________________________________
247 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
249 /// Create a new pedestal store from the OCDB for a given run
250 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
253 //_____________________________________________________________________________
255 AliMUONCalibrationData::CreateConfig(Int_t runNumber, Int_t* startOfValidity)
257 /// Create a new config store from the OCDB for a given run
258 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Config",startOfValidity));
262 //_____________________________________________________________________________
263 AliMUONRegionalTriggerConfig*
264 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
266 /// Create the internal store for RegionalTriggerConfig from OCDB
268 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
271 //_____________________________________________________________________________
272 AliMUONTriggerEfficiencyCells*
273 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
275 /// Create trigger efficiency object from OCBD
277 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
280 //_____________________________________________________________________________
282 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
284 /// Create trigger LUT from OCDB
286 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
289 //_____________________________________________________________________________
291 AliMUONCalibrationData::Gains() const
293 /// Create (if needed) and return the internal store for gains.
294 if (fgBypassGains) return fgBypassGains;
298 fGains = CreateGains(fRunNumber);
303 //_____________________________________________________________________________
305 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
307 /// Return the gains for a given (detElemId, manuId) pair
308 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
309 /// error (meaning that we should get gains for all channels).
311 AliMUONVStore* gains = Gains();
317 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
320 //_____________________________________________________________________________
321 AliMUONGlobalCrateConfig*
322 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
324 /// Return the config for the global trigger board.
326 if (!fGlobalTriggerCrateConfig)
328 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
330 return fGlobalTriggerCrateConfig;
334 //_____________________________________________________________________________
336 AliMUONCalibrationData::HV() const
338 /// Return the calibration for a given (detElemId, manuId) pair
342 fHV = CreateHV(fRunNumber);
347 //_____________________________________________________________________________
349 AliMUONCalibrationData::TriggerDCS() const
351 /// Return the calibration for a given (detElemId, manuId) pair
355 fTriggerDCS = CreateTriggerDCS(fRunNumber);
360 //_____________________________________________________________________________
362 AliMUONCalibrationData::Neighbours() const
364 /// Create (if needed) and return the internal store for neighbours.
367 fNeighbours = CreateNeighbours(fRunNumber);
372 //_____________________________________________________________________________
374 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
376 /// Return the masks for a given trigger local board.
378 if (!fLocalTriggerBoardMasks)
380 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
383 if ( fLocalTriggerBoardMasks )
385 AliMUONVCalibParam* ltbm =
386 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
389 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
396 //_____________________________________________________________________________
398 AliMUONCalibrationData::OccupancyMap() const
400 /// Get occupancy map
403 fOccupancyMap = CreateOccupancyMap(fRunNumber);
405 return fOccupancyMap;
408 //_____________________________________________________________________________
410 AliMUONCalibrationData::RejectList() const
415 fRejectList = CreateRejectList(fRunNumber);
420 //_____________________________________________________________________________
422 AliMUONCalibrationData::BypassStores(AliMUONVStore* ped, AliMUONVStore* gain)
424 /// Force the use of those pedestals and gains
425 fgBypassPedestals = ped;
426 fgBypassGains = gain;
430 //_____________________________________________________________________________
432 AliMUONCalibrationData::Pedestals() const
436 if (fgBypassPedestals) return fgBypassPedestals;
440 fPedestals = CreatePedestals(fRunNumber);
445 //_____________________________________________________________________________
447 AliMUONCalibrationData::Config() const
453 fConfig = CreateConfig(fRunNumber);
458 //_____________________________________________________________________________
460 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
462 /// Return the pedestals for a given (detElemId, manuId) pair.
463 /// A return value of 0x0 is considered an error, meaning we should get
464 /// pedestals for all channels.
466 AliMUONVStore* pedestals = Pedestals();
472 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
475 //_____________________________________________________________________________
477 AliMUONCalibrationData::Print(Option_t*) const
479 /// A very basic dump of our guts.
481 cout << "RunNumber " << RunNumber()
482 << " fGains=" << fGains
483 << " fPedestals=" << fPedestals
484 << " fConfig=" << fConfig
486 << " fTriggerDCS=" << fTriggerDCS
487 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
488 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
489 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
490 << " fTriggerLut=" << fTriggerLut
495 //_____________________________________________________________________________
496 AliMUONRegionalTriggerConfig*
497 AliMUONCalibrationData::RegionalTriggerConfig() const
499 /// Return the config for the regional trigger board.
501 if (!fRegionalTriggerConfig)
503 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
505 return fRegionalTriggerConfig;
509 //_____________________________________________________________________________
510 AliMUONTriggerEfficiencyCells*
511 AliMUONCalibrationData::TriggerEfficiency() const
513 /// Return the trigger efficiency.
515 if (!fTriggerEfficiency)
517 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
519 return fTriggerEfficiency;
523 //_____________________________________________________________________________
525 AliMUONCalibrationData::TriggerLut() const
527 /// Return the trigger look up table.
531 fTriggerLut = CreateTriggerLut(fRunNumber);
536 //_____________________________________________________________________________
538 AliMUONCalibrationData::Reset()
542 AliCodeTimerAuto("",0);
554 delete fLocalTriggerBoardMasks;
555 fLocalTriggerBoardMasks = 0x0;
556 delete fRegionalTriggerConfig;
557 fRegionalTriggerConfig = 0x0;
558 delete fGlobalTriggerCrateConfig;
559 fGlobalTriggerCrateConfig = 0x0;
563 delete fTriggerEfficiency;
564 fTriggerEfficiency = 0x0;
565 delete fCapacitances;
571 //_____________________________________________________________________________
573 AliMUONCalibrationData::Check(Int_t runNumber)
575 /// Self-check to see if we can read all data for a given run
576 /// from the current OCDB...
578 if ( ! CreateCapacitances(runNumber) )
580 AliErrorClass("Could not read capacitances");
584 AliInfoClass("Capacitances read OK");
587 if ( ! CreateGains(runNumber) )
589 AliErrorClass("Could not read gains");
593 AliInfoClass("Gains read OK");
596 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
598 AliErrorClass("Could not read Trigger Crate Config");
602 AliInfoClass("TriggerBoardMasks read OK");
605 if ( ! CreateHV(runNumber) )
607 AliErrorClass("Could not read HV");
611 AliInfoClass("HV read OK");
614 if ( ! CreateTriggerDCS(runNumber) )
616 AliErrorClass("Could not read Trigger HV and Currents");
620 AliInfoClass("Trigger HV and Currents read OK");
623 if ( ! CreateNeighbours(runNumber) )
625 AliErrorClass("Could not read Neighbours");
629 AliInfoClass("Neighbours read OK");
632 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
634 AliErrorClass("Could not read LocalTriggerBoardMasks");
638 AliInfoClass("LocalTriggerBoardMasks read OK");
641 if ( ! CreatePedestals(runNumber) )
643 AliErrorClass("Could not read pedestals");
647 AliInfoClass("Pedestals read OK");
650 if ( ! CreateConfig(runNumber) )
652 AliErrorClass("Could not read config");
656 AliInfoClass("Config read OK");
659 if ( ! CreateRegionalTriggerConfig(runNumber) )
661 AliErrorClass("Could not read RegionalTriggerConfig");
665 AliInfoClass("RegionalTriggerBoardMasks read OK");
668 if ( ! CreateTriggerLut(runNumber) )
670 AliErrorClass("Could not read TriggerLut");
674 AliInfoClass("TriggerLut read OK");
677 if ( ! CreateTriggerEfficiency(runNumber) )
679 AliErrorClass("Could not read TriggerEfficiency");
683 AliInfoClass("TriggerEfficiency read OK");