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"
23 #include "AliMUONTriggerEfficiencyCells.h"
24 #include "AliMUONTriggerLut.h"
25 #include "AliMUONVStore.h"
26 #include "AliMUONVStore.h"
27 #include "AliMUONVCalibParam.h"
28 #include "Riostream.h"
31 //-----------------------------------------------------------------------------
32 /// \class AliMUONCalibrationData
34 /// For the moment, this class stores pedestals, gains, hv (for tracker)
35 /// and lut, masks and efficiencies (for trigger) that are fetched from the CDB.
37 /// This class is to be considered as a convenience class.
38 /// Its aim is to ease retrieval of calibration data from the
39 /// condition database.
41 /// It acts as a "facade" to a bunch of underlying
42 /// containers/calibration classes.
44 /// \author Laurent Aphecetche
45 //-----------------------------------------------------------------------------
48 ClassImp(AliMUONCalibrationData)
51 //_____________________________________________________________________________
52 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
53 Bool_t deferredInitialization)
56 fRunNumber(runNumber),
60 fLocalTriggerBoardMasks(0x0),
61 fRegionalTriggerBoardMasks(0x0),
62 fGlobalTriggerBoardMasks(0x0),
64 fTriggerEfficiency(0x0),
70 // If deferredInitialization is false, we read *all* calibrations
72 // So when using this class to access only one kind of calibrations (e.g.
73 // only pedestals), you should put deferredInitialization to kTRUE, which
74 // will instruct this object to fetch the data only when neeeded.
76 if ( deferredInitialization == kFALSE )
81 LocalTriggerBoardMasks(0);
82 RegionalTriggerBoardMasks(0);
83 GlobalTriggerBoardMasks();
91 //_____________________________________________________________________________
92 AliMUONCalibrationData::~AliMUONCalibrationData()
94 /// Destructor. Note that we're the owner of our pointers.
98 //_____________________________________________________________________________
100 AliMUONCalibrationData::Capacitances() const
102 /// Create (if needed) and return the internal store for capacitances.
106 fCapacitances = CreateCapacitances(fRunNumber);
108 return fCapacitances;
111 //_____________________________________________________________________________
113 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber)
115 /// Create capa store from OCDB for a given run
117 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances"));
120 //_____________________________________________________________________________
122 AliMUONCalibrationData::CreateGains(Int_t runNumber)
124 /// Create a new gain store from the OCDB for a given run
125 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains"));
128 //_____________________________________________________________________________
130 AliMUONCalibrationData::CreateGlobalTriggerBoardMasks(Int_t runNumber)
132 /// Create the internal store for GlobalTriggerBoardMasks from OCDB
134 return dynamic_cast<AliMUONVCalibParam*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerBoardMasks"));
137 //_____________________________________________________________________________
139 AliMUONCalibrationData::CreateHV(Int_t runNumber)
141 /// Create a new HV map from the OCDB for a given run
142 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV"));
145 //_____________________________________________________________________________
147 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber)
149 /// Get the internal store for LocalTriggerBoardMasks from OCDB
151 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks"));
154 //_____________________________________________________________________________
156 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber)
158 /// Create a neighbour store from the OCDB for a given run
159 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours"));
162 //_____________________________________________________________________________
164 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path)
166 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
167 /// and return the corresponding TObject.
169 AliCDBManager* man = AliCDBManager::Instance();
171 Bool_t cacheStatus = man->GetCacheFlag();
173 man->SetCacheFlag(kFALSE);
175 AliCDBEntry* entry = AliCDBManager::Instance()->Get(path,runNumber);
177 man->SetCacheFlag(cacheStatus);
181 return entry->GetObject();
187 //_____________________________________________________________________________
189 AliMUONCalibrationData::CreatePedestals(Int_t runNumber)
191 /// Create a new pedestal store from the OCDB for a given run
192 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals"));
195 //_____________________________________________________________________________
197 AliMUONCalibrationData::CreateRegionalTriggerBoardMasks(Int_t runNumber)
199 /// Create the internal store for RegionalTriggerBoardMasks from OCDB
201 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerBoardMasks"));
204 //_____________________________________________________________________________
205 AliMUONTriggerEfficiencyCells*
206 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber)
208 /// Create trigger efficiency object from OCBD
210 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency"));
213 //_____________________________________________________________________________
215 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber)
217 /// Create trigger LUT from OCDB
219 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut"));
222 //_____________________________________________________________________________
224 AliMUONCalibrationData::Gains() const
226 /// Create (if needed) and return the internal store for gains.
229 fGains = CreateGains(fRunNumber);
234 //_____________________________________________________________________________
236 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
238 /// Return the gains for a given (detElemId, manuId) pair
239 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
240 /// error (meaning that we should get gains for all channels).
242 AliMUONVStore* gains = Gains();
248 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
251 //_____________________________________________________________________________
253 AliMUONCalibrationData::GlobalTriggerBoardMasks() const
255 /// Return the masks for the global trigger board.
257 if (!fGlobalTriggerBoardMasks)
259 fGlobalTriggerBoardMasks = CreateGlobalTriggerBoardMasks(fRunNumber);
261 return fGlobalTriggerBoardMasks;
264 //_____________________________________________________________________________
266 AliMUONCalibrationData::HV() const
268 /// Return the calibration for a given (detElemId, manuId) pair
272 fHV = CreateHV(fRunNumber);
277 //_____________________________________________________________________________
279 AliMUONCalibrationData::Neighbours() const
281 /// Create (if needed) and return the internal store for neighbours.
284 fNeighbours = CreateNeighbours(fRunNumber);
289 //_____________________________________________________________________________
291 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
293 /// Return the masks for a given trigger local board.
295 if (!fLocalTriggerBoardMasks)
297 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
300 if ( fLocalTriggerBoardMasks )
302 AliMUONVCalibParam* ltbm =
303 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
306 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
313 //_____________________________________________________________________________
315 AliMUONCalibrationData::Pedestals() const
320 fPedestals = CreatePedestals(fRunNumber);
325 //_____________________________________________________________________________
327 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
329 /// Return the pedestals for a given (detElemId, manuId) pair.
330 /// A return value of 0x0 is considered an error, meaning we should get
331 /// pedestals for all channels.
333 AliMUONVStore* pedestals = Pedestals();
339 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
342 //_____________________________________________________________________________
344 AliMUONCalibrationData::Print(Option_t*) const
346 /// A very basic dump of our guts.
348 cout << "RunNumber " << RunNumber()
349 << " fGains=" << fGains
350 << " fPedestals=" << fPedestals
352 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
353 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
354 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
355 << " fTriggerLut=" << fTriggerLut
359 //_____________________________________________________________________________
361 AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t regionalBoardNumber) const
363 /// Return the masks for a given trigger regional board.
365 if ( !fRegionalTriggerBoardMasks )
367 fRegionalTriggerBoardMasks = CreateRegionalTriggerBoardMasks(fRunNumber);
370 if ( fRegionalTriggerBoardMasks )
372 AliMUONVCalibParam* rtbm =
373 static_cast<AliMUONVCalibParam*>(fRegionalTriggerBoardMasks->FindObject(regionalBoardNumber));
377 AliError(Form("Could not get mask for regionalBoard index=%d",index));
384 //_____________________________________________________________________________
385 AliMUONTriggerEfficiencyCells*
386 AliMUONCalibrationData::TriggerEfficiency() const
388 /// Return the trigger efficiency.
390 if (!fTriggerEfficiency)
392 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
394 return fTriggerEfficiency;
398 //_____________________________________________________________________________
400 AliMUONCalibrationData::TriggerLut() const
402 /// Return the trigger look up table.
406 fTriggerLut = CreateTriggerLut(fRunNumber);
411 //_____________________________________________________________________________
413 AliMUONCalibrationData::Reset()
423 delete fLocalTriggerBoardMasks;
424 fLocalTriggerBoardMasks = 0x0;
425 delete fRegionalTriggerBoardMasks;
426 fRegionalTriggerBoardMasks = 0x0;
427 delete fGlobalTriggerBoardMasks;
428 fGlobalTriggerBoardMasks = 0x0;
431 delete fTriggerEfficiency;
432 fTriggerEfficiency = 0x0;
433 delete fCapacitances;