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)
120 /// Create capa store from OCDB for a given run
122 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances"));
125 //_____________________________________________________________________________
127 AliMUONCalibrationData::CreateGains(Int_t runNumber)
129 /// Create a new gain store from the OCDB for a given run
130 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains"));
133 //_____________________________________________________________________________
134 AliMUONGlobalCrateConfig*
135 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber)
137 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
139 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig"));
144 //_____________________________________________________________________________
146 AliMUONCalibrationData::CreateHV(Int_t runNumber)
148 /// Create a new HV map from the OCDB for a given run
149 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV"));
152 //_____________________________________________________________________________
154 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber)
156 /// Get the internal store for LocalTriggerBoardMasks from OCDB
158 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks"));
161 //_____________________________________________________________________________
163 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber)
165 /// Create a neighbour store from the OCDB for a given run
166 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours"));
169 //_____________________________________________________________________________
171 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path)
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);
196 TObject* object = entry->GetObject();
197 entry->SetOwner(kFALSE);
205 //_____________________________________________________________________________
207 AliMUONCalibrationData::CreatePedestals(Int_t runNumber)
209 /// Create a new pedestal store from the OCDB for a given run
210 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals"));
214 //_____________________________________________________________________________
215 AliMUONRegionalTriggerConfig*
216 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber)
218 /// Create the internal store for RegionalTriggerConfig from OCDB
220 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig"));
223 //_____________________________________________________________________________
224 AliMUONTriggerEfficiencyCells*
225 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber)
227 /// Create trigger efficiency object from OCBD
229 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency"));
232 //_____________________________________________________________________________
234 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber)
236 /// Create trigger LUT from OCDB
238 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut"));
241 //_____________________________________________________________________________
243 AliMUONCalibrationData::Gains() const
245 /// Create (if needed) and return the internal store for gains.
248 fGains = CreateGains(fRunNumber);
253 //_____________________________________________________________________________
255 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
257 /// Return the gains for a given (detElemId, manuId) pair
258 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
259 /// error (meaning that we should get gains for all channels).
261 AliMUONVStore* gains = Gains();
267 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
270 //_____________________________________________________________________________
271 AliMUONGlobalCrateConfig*
272 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
274 /// Return the config for the global trigger board.
276 if (!fGlobalTriggerCrateConfig)
278 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
280 return fGlobalTriggerCrateConfig;
284 //_____________________________________________________________________________
286 AliMUONCalibrationData::HV() const
288 /// Return the calibration for a given (detElemId, manuId) pair
292 fHV = CreateHV(fRunNumber);
297 //_____________________________________________________________________________
299 AliMUONCalibrationData::Neighbours() const
301 /// Create (if needed) and return the internal store for neighbours.
304 fNeighbours = CreateNeighbours(fRunNumber);
309 //_____________________________________________________________________________
311 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
313 /// Return the masks for a given trigger local board.
315 if (!fLocalTriggerBoardMasks)
317 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
320 if ( fLocalTriggerBoardMasks )
322 AliMUONVCalibParam* ltbm =
323 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
326 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
333 //_____________________________________________________________________________
335 AliMUONCalibrationData::Pedestals() const
340 fPedestals = CreatePedestals(fRunNumber);
345 //_____________________________________________________________________________
347 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
349 /// Return the pedestals for a given (detElemId, manuId) pair.
350 /// A return value of 0x0 is considered an error, meaning we should get
351 /// pedestals for all channels.
353 AliMUONVStore* pedestals = Pedestals();
359 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
362 //_____________________________________________________________________________
364 AliMUONCalibrationData::Print(Option_t*) const
366 /// A very basic dump of our guts.
368 cout << "RunNumber " << RunNumber()
369 << " fGains=" << fGains
370 << " fPedestals=" << fPedestals
372 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
373 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
374 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
375 << " fTriggerLut=" << fTriggerLut
380 //_____________________________________________________________________________
381 AliMUONRegionalTriggerConfig*
382 AliMUONCalibrationData::RegionalTriggerConfig() const
384 /// Return the config for the regional trigger board.
386 if (!fRegionalTriggerConfig)
388 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
390 return fRegionalTriggerConfig;
394 //_____________________________________________________________________________
395 AliMUONTriggerEfficiencyCells*
396 AliMUONCalibrationData::TriggerEfficiency() const
398 /// Return the trigger efficiency.
400 if (!fTriggerEfficiency)
402 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
404 return fTriggerEfficiency;
408 //_____________________________________________________________________________
410 AliMUONCalibrationData::TriggerLut() const
412 /// Return the trigger look up table.
416 fTriggerLut = CreateTriggerLut(fRunNumber);
421 //_____________________________________________________________________________
423 AliMUONCalibrationData::Reset()
433 delete fLocalTriggerBoardMasks;
434 fLocalTriggerBoardMasks = 0x0;
435 delete fRegionalTriggerConfig;
436 fRegionalTriggerConfig = 0x0;
437 delete fGlobalTriggerCrateConfig;
438 fGlobalTriggerCrateConfig = 0x0;
442 delete fTriggerEfficiency;
443 fTriggerEfficiency = 0x0;
444 delete fCapacitances;