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),
65 fLocalTriggerBoardMasks(0x0),
66 fRegionalTriggerConfig(0x0),
67 fGlobalTriggerCrateConfig(0x0),
69 fTriggerEfficiency(0x0),
75 // If deferredInitialization is false, we read *all* calibrations
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.
81 if ( deferredInitialization == kFALSE )
86 LocalTriggerBoardMasks(0);
87 RegionalTriggerConfig();
88 GlobalTriggerCrateConfig();
96 //_____________________________________________________________________________
97 AliMUONCalibrationData::~AliMUONCalibrationData()
99 /// Destructor. Note that we're the owner of our pointers.
103 //_____________________________________________________________________________
105 AliMUONCalibrationData::Capacitances() const
107 /// Create (if needed) and return the internal store for capacitances.
111 fCapacitances = CreateCapacitances(fRunNumber);
113 return fCapacitances;
116 //_____________________________________________________________________________
118 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
120 /// Create capa store from OCDB for a given run
122 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
125 //_____________________________________________________________________________
127 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
129 /// Create a new gain store from the OCDB for a given run
130 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
133 //_____________________________________________________________________________
134 AliMUONGlobalCrateConfig*
135 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
137 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
139 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
144 //_____________________________________________________________________________
146 AliMUONCalibrationData::CreateHV(Int_t runNumber, Int_t* startOfValidity)
148 /// Create a new HV map from the OCDB for a given run
149 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
152 //_____________________________________________________________________________
154 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
156 /// Get the internal store for LocalTriggerBoardMasks from OCDB
158 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
161 //_____________________________________________________________________________
163 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
165 /// Create a neighbour store from the OCDB for a given run
166 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
169 //_____________________________________________________________________________
171 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
173 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
174 /// and return the corresponding TObject.
176 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path));
178 AliCDBManager* man = AliCDBManager::Instance();
180 if ( !man->IsDefaultStorageSet() )
182 AliErrorClass("CDB Storage not set. Must use AliCDBManager::Instance()->SetDefaultStorage() first.");
186 Bool_t cacheStatus = man->GetCacheFlag();
188 man->SetCacheFlag(kFALSE);
190 AliCDBEntry* entry = AliCDBManager::Instance()->Get(path,runNumber);
192 man->SetCacheFlag(cacheStatus);
197 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
199 TObject* object = entry->GetObject();
200 entry->SetOwner(kFALSE);
206 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
212 //_____________________________________________________________________________
214 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
216 /// Create a new pedestal store from the OCDB for a given run
217 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
221 //_____________________________________________________________________________
222 AliMUONRegionalTriggerConfig*
223 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
225 /// Create the internal store for RegionalTriggerConfig from OCDB
227 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
230 //_____________________________________________________________________________
231 AliMUONTriggerEfficiencyCells*
232 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
234 /// Create trigger efficiency object from OCBD
236 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
239 //_____________________________________________________________________________
241 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
243 /// Create trigger LUT from OCDB
245 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
248 //_____________________________________________________________________________
250 AliMUONCalibrationData::Gains() const
252 /// Create (if needed) and return the internal store for gains.
255 fGains = CreateGains(fRunNumber);
260 //_____________________________________________________________________________
262 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
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).
268 AliMUONVStore* gains = Gains();
274 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
277 //_____________________________________________________________________________
278 AliMUONGlobalCrateConfig*
279 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
281 /// Return the config for the global trigger board.
283 if (!fGlobalTriggerCrateConfig)
285 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
287 return fGlobalTriggerCrateConfig;
291 //_____________________________________________________________________________
293 AliMUONCalibrationData::HV() const
295 /// Return the calibration for a given (detElemId, manuId) pair
299 fHV = CreateHV(fRunNumber);
304 //_____________________________________________________________________________
306 AliMUONCalibrationData::Neighbours() const
308 /// Create (if needed) and return the internal store for neighbours.
311 fNeighbours = CreateNeighbours(fRunNumber);
316 //_____________________________________________________________________________
318 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
320 /// Return the masks for a given trigger local board.
322 if (!fLocalTriggerBoardMasks)
324 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
327 if ( fLocalTriggerBoardMasks )
329 AliMUONVCalibParam* ltbm =
330 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
333 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
340 //_____________________________________________________________________________
342 AliMUONCalibrationData::Pedestals() const
347 fPedestals = CreatePedestals(fRunNumber);
352 //_____________________________________________________________________________
354 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
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.
360 AliMUONVStore* pedestals = Pedestals();
366 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
369 //_____________________________________________________________________________
371 AliMUONCalibrationData::Print(Option_t*) const
373 /// A very basic dump of our guts.
375 cout << "RunNumber " << RunNumber()
376 << " fGains=" << fGains
377 << " fPedestals=" << fPedestals
379 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
380 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
381 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
382 << " fTriggerLut=" << fTriggerLut
387 //_____________________________________________________________________________
388 AliMUONRegionalTriggerConfig*
389 AliMUONCalibrationData::RegionalTriggerConfig() const
391 /// Return the config for the regional trigger board.
393 if (!fRegionalTriggerConfig)
395 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
397 return fRegionalTriggerConfig;
401 //_____________________________________________________________________________
402 AliMUONTriggerEfficiencyCells*
403 AliMUONCalibrationData::TriggerEfficiency() const
405 /// Return the trigger efficiency.
407 if (!fTriggerEfficiency)
409 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
411 return fTriggerEfficiency;
415 //_____________________________________________________________________________
417 AliMUONCalibrationData::TriggerLut() const
419 /// Return the trigger look up table.
423 fTriggerLut = CreateTriggerLut(fRunNumber);
428 //_____________________________________________________________________________
430 AliMUONCalibrationData::Reset()
440 delete fLocalTriggerBoardMasks;
441 fLocalTriggerBoardMasks = 0x0;
442 delete fRegionalTriggerConfig;
443 fRegionalTriggerConfig = 0x0;
444 delete fGlobalTriggerCrateConfig;
445 fGlobalTriggerCrateConfig = 0x0;
449 delete fTriggerEfficiency;
450 fTriggerEfficiency = 0x0;
451 delete fCapacitances;
457 //_____________________________________________________________________________
459 AliMUONCalibrationData::Check(Int_t runNumber)
461 /// Self-check to see if we can read all data for a given run
462 /// from the current OCDB...
464 if ( ! CreateCapacitances(runNumber) )
466 AliErrorClass("Could not read capacitances");
470 AliInfoClass("Capacitances read OK");
473 if ( ! CreateGains(runNumber) )
475 AliErrorClass("Could not read gains");
479 AliInfoClass("Gains read OK");
482 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
484 AliErrorClass("Could not read Trigger Crate Config");
488 AliInfoClass("TriggerBoardMasks read OK");
491 if ( ! CreateHV(runNumber) )
493 AliErrorClass("Could not read HV");
497 AliInfoClass("HV read OK");
500 if ( ! CreateNeighbours(runNumber) )
502 AliErrorClass("Could not read Neighbours");
506 AliInfoClass("Neighbours read OK");
509 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
511 AliErrorClass("Could not read LocalTriggerBoardMasks");
515 AliInfoClass("LocalTriggerBoardMasks read OK");
518 if ( ! CreatePedestals(runNumber) )
520 AliErrorClass("Could not read pedestals");
524 AliInfoClass("Pedestals read OK");
527 if ( ! CreateRegionalTriggerConfig(runNumber) )
529 AliErrorClass("Could not read RegionalTriggerConfig");
533 AliInfoClass("RegionalTriggerBoardMasks read OK");
536 if ( ! CreateTriggerLut(runNumber) )
538 AliErrorClass("Could not read TriggerLut");
542 AliInfoClass("TriggerLut read OK");
545 if ( ! CreateTriggerEfficiency(runNumber) )
547 AliErrorClass("Could not read TriggerEfficiency");
551 AliInfoClass("TriggerEfficiency read OK");