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 //_____________________________________________________________________________
58 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
59 Bool_t deferredInitialization)
62 fRunNumber(runNumber),
67 fLocalTriggerBoardMasks(0x0),
68 fRegionalTriggerConfig(0x0),
69 fGlobalTriggerCrateConfig(0x0),
71 fTriggerEfficiency(0x0),
79 // If deferredInitialization is false, we read *all* calibrations
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.
85 if ( deferredInitialization == kFALSE )
93 LocalTriggerBoardMasks(0);
94 RegionalTriggerConfig();
95 GlobalTriggerCrateConfig();
103 //_____________________________________________________________________________
104 AliMUONCalibrationData::~AliMUONCalibrationData()
106 /// Destructor. Note that we're the owner of our pointers.
107 //PH The owner of the objects is CDB, do not delete them!
111 //_____________________________________________________________________________
113 AliMUONCalibrationData::Capacitances() const
115 /// Create (if needed) and return the internal store for capacitances.
119 fCapacitances = CreateCapacitances(fRunNumber);
121 return fCapacitances;
124 //_____________________________________________________________________________
126 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
128 /// Create capa store from OCDB for a given run
130 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
133 //_____________________________________________________________________________
135 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
137 /// Create a new gain store from the OCDB for a given run
138 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
141 //_____________________________________________________________________________
142 AliMUONGlobalCrateConfig*
143 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
145 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
147 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
152 //_____________________________________________________________________________
154 AliMUONCalibrationData::CreateHV(Int_t runNumber, Int_t* startOfValidity)
156 /// Create a new HV map from the OCDB for a given run
157 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
160 //_____________________________________________________________________________
162 AliMUONCalibrationData::CreateTriggerDCS(Int_t runNumber, Int_t* startOfValidity)
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));
168 //_____________________________________________________________________________
170 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
172 /// Get the internal store for LocalTriggerBoardMasks from OCDB
174 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
177 //_____________________________________________________________________________
179 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
181 /// Create a neighbour store from the OCDB for a given run
182 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
185 //_____________________________________________________________________________
187 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
189 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
190 /// and return the corresponding TObject.
192 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path));
194 AliCDBManager* man = AliCDBManager::Instance();
196 AliCDBEntry* entry = man->Get(path,runNumber);
200 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
202 TObject* object = entry->GetObject();
203 entry->SetOwner(kFALSE);
204 if (!(man->GetCacheFlag())) delete entry;
209 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
214 AliCodeTimerAutoClass(Form("Failed to get %s for run %d",path,runNumber));
221 //_____________________________________________________________________________
223 AliMUONCalibrationData::CreateOccupancyMap(Int_t runNumber, Int_t* startOfValidity)
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));
229 //_____________________________________________________________________________
231 AliMUONCalibrationData::CreateRejectList(Int_t runNumber, Int_t* startOfValidity)
233 /// Create a new rejectlist store from the OCDB for a given run
234 return dynamic_cast<AliMUONRejectList*>(CreateObject(runNumber,"MUON/Calib/RejectList",startOfValidity));
237 //_____________________________________________________________________________
239 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
241 /// Create a new pedestal store from the OCDB for a given run
242 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
246 //_____________________________________________________________________________
247 AliMUONRegionalTriggerConfig*
248 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
250 /// Create the internal store for RegionalTriggerConfig from OCDB
252 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
255 //_____________________________________________________________________________
256 AliMUONTriggerEfficiencyCells*
257 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
259 /// Create trigger efficiency object from OCBD
261 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
264 //_____________________________________________________________________________
266 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
268 /// Create trigger LUT from OCDB
270 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
273 //_____________________________________________________________________________
275 AliMUONCalibrationData::Gains() const
277 /// Create (if needed) and return the internal store for gains.
280 fGains = CreateGains(fRunNumber);
285 //_____________________________________________________________________________
287 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
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).
293 AliMUONVStore* gains = Gains();
299 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
302 //_____________________________________________________________________________
303 AliMUONGlobalCrateConfig*
304 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
306 /// Return the config for the global trigger board.
308 if (!fGlobalTriggerCrateConfig)
310 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
312 return fGlobalTriggerCrateConfig;
316 //_____________________________________________________________________________
318 AliMUONCalibrationData::HV() const
320 /// Return the calibration for a given (detElemId, manuId) pair
324 fHV = CreateHV(fRunNumber);
329 //_____________________________________________________________________________
331 AliMUONCalibrationData::TriggerDCS() const
333 /// Return the calibration for a given (detElemId, manuId) pair
337 fTriggerDCS = CreateTriggerDCS(fRunNumber);
342 //_____________________________________________________________________________
344 AliMUONCalibrationData::Neighbours() const
346 /// Create (if needed) and return the internal store for neighbours.
349 fNeighbours = CreateNeighbours(fRunNumber);
354 //_____________________________________________________________________________
356 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
358 /// Return the masks for a given trigger local board.
360 if (!fLocalTriggerBoardMasks)
362 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
365 if ( fLocalTriggerBoardMasks )
367 AliMUONVCalibParam* ltbm =
368 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
371 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
378 //_____________________________________________________________________________
380 AliMUONCalibrationData::OccupancyMap() const
382 /// Get occupancy map
385 fOccupancyMap = CreateOccupancyMap(fRunNumber);
387 return fOccupancyMap;
390 //_____________________________________________________________________________
392 AliMUONCalibrationData::RejectList() const
397 fRejectList = CreateRejectList(fRunNumber);
402 //_____________________________________________________________________________
404 AliMUONCalibrationData::Pedestals() const
409 fPedestals = CreatePedestals(fRunNumber);
414 //_____________________________________________________________________________
416 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
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.
422 AliMUONVStore* pedestals = Pedestals();
428 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
431 //_____________________________________________________________________________
433 AliMUONCalibrationData::Print(Option_t*) const
435 /// A very basic dump of our guts.
437 cout << "RunNumber " << RunNumber()
438 << " fGains=" << fGains
439 << " fPedestals=" << fPedestals
441 << " fTriggerDCS=" << fTriggerDCS
442 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
443 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
444 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
445 << " fTriggerLut=" << fTriggerLut
450 //_____________________________________________________________________________
451 AliMUONRegionalTriggerConfig*
452 AliMUONCalibrationData::RegionalTriggerConfig() const
454 /// Return the config for the regional trigger board.
456 if (!fRegionalTriggerConfig)
458 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
460 return fRegionalTriggerConfig;
464 //_____________________________________________________________________________
465 AliMUONTriggerEfficiencyCells*
466 AliMUONCalibrationData::TriggerEfficiency() const
468 /// Return the trigger efficiency.
470 if (!fTriggerEfficiency)
472 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
474 return fTriggerEfficiency;
478 //_____________________________________________________________________________
480 AliMUONCalibrationData::TriggerLut() const
482 /// Return the trigger look up table.
486 fTriggerLut = CreateTriggerLut(fRunNumber);
491 //_____________________________________________________________________________
493 AliMUONCalibrationData::Reset()
505 delete fLocalTriggerBoardMasks;
506 fLocalTriggerBoardMasks = 0x0;
507 delete fRegionalTriggerConfig;
508 fRegionalTriggerConfig = 0x0;
509 delete fGlobalTriggerCrateConfig;
510 fGlobalTriggerCrateConfig = 0x0;
514 delete fTriggerEfficiency;
515 fTriggerEfficiency = 0x0;
516 delete fCapacitances;
522 //_____________________________________________________________________________
524 AliMUONCalibrationData::Check(Int_t runNumber)
526 /// Self-check to see if we can read all data for a given run
527 /// from the current OCDB...
529 if ( ! CreateCapacitances(runNumber) )
531 AliErrorClass("Could not read capacitances");
535 AliInfoClass("Capacitances read OK");
538 if ( ! CreateGains(runNumber) )
540 AliErrorClass("Could not read gains");
544 AliInfoClass("Gains read OK");
547 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
549 AliErrorClass("Could not read Trigger Crate Config");
553 AliInfoClass("TriggerBoardMasks read OK");
556 if ( ! CreateHV(runNumber) )
558 AliErrorClass("Could not read HV");
562 AliInfoClass("HV read OK");
565 if ( ! CreateTriggerDCS(runNumber) )
567 AliErrorClass("Could not read Trigger HV and Currents");
571 AliInfoClass("Trigger HV and Currents read OK");
574 if ( ! CreateNeighbours(runNumber) )
576 AliErrorClass("Could not read Neighbours");
580 AliInfoClass("Neighbours read OK");
583 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
585 AliErrorClass("Could not read LocalTriggerBoardMasks");
589 AliInfoClass("LocalTriggerBoardMasks read OK");
592 if ( ! CreatePedestals(runNumber) )
594 AliErrorClass("Could not read pedestals");
598 AliInfoClass("Pedestals read OK");
601 if ( ! CreateRegionalTriggerConfig(runNumber) )
603 AliErrorClass("Could not read RegionalTriggerConfig");
607 AliInfoClass("RegionalTriggerBoardMasks read OK");
610 if ( ! CreateTriggerLut(runNumber) )
612 AliErrorClass("Could not read TriggerLut");
616 AliInfoClass("TriggerLut read OK");
619 if ( ! CreateTriggerEfficiency(runNumber) )
621 AliErrorClass("Could not read TriggerEfficiency");
625 AliInfoClass("TriggerEfficiency read OK");