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 "AliMUONV1DStore.h"
26 #include "AliMUONV2DStore.h"
27 #include "AliMUONVCalibParam.h"
28 #include "Riostream.h"
31 /// \class AliMUONCalibrationData
33 /// For the moment, this class stores pedestals, gains, hv (for tracker)
34 /// and lut, masks and efficiencies (for trigger) that are fetched from the CDB.
36 /// This class is to be considered as a convenience class.
37 /// Its aim is to ease retrieval of calibration data from the
38 /// condition database.
40 /// It acts as a "facade" to a bunch of underlying
41 /// containers/calibration classes.
43 /// \author Laurent Aphecetche
46 ClassImp(AliMUONCalibrationData)
49 //_____________________________________________________________________________
50 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
51 Bool_t deferredInitialization)
54 fRunNumber(runNumber),
58 fLocalTriggerBoardMasks(0x0),
59 fRegionalTriggerBoardMasks(0x0),
60 fGlobalTriggerBoardMasks(0x0),
62 fTriggerEfficiency(0x0),
67 // If deferredInitialization is false, we read *all* calibrations
69 // So when using this class to access only one kind of calibrations (e.g.
70 // only pedestals), you should put deferredInitialization to kTRUE, which
71 // will instruct this object to fetch the data only when neeeded.
73 if ( deferredInitialization == kFALSE )
78 OnDemandLocalTriggerBoardMasks();
79 OnDemandRegionalTriggerBoardMasks();
80 OnDemandGlobalTriggerBoardMasks();
82 OnDemandTriggerEfficiency();
83 OnDemandCapacitances();
87 //_____________________________________________________________________________
88 AliMUONCalibrationData::~AliMUONCalibrationData()
90 /// Destructor. Note that we're the owner of our pointers.
93 //_____________________________________________________________________________
95 AliMUONCalibrationData::HV() const
97 /// Return the calibration for a given (detElemId, manuId) pair
102 //_____________________________________________________________________________
104 AliMUONCalibrationData::OnDemandHV() const
106 /// Create (if needed) and return the internal store for DeadChannels.
110 AliCDBEntry* entry = GetEntry("MUON/Calib/HV");
113 fHV = dynamic_cast<TMap*>(entry->GetObject());
116 AliError("fHV not of the expected type !!!");
121 AliError("Could not get HV values !");
127 //_____________________________________________________________________________
129 AliMUONCalibrationData::GetEntry(const char* path) const
131 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
132 /// and return the corresponding CDBEntry.
134 return AliCDBManager::Instance()->Get(path,fRunNumber);
137 //_____________________________________________________________________________
139 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
141 /// Return the gains for a given (detElemId, manuId) pair
142 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
143 /// error (meaning that we should get gains for all channels).
145 AliMUONV2DStore* gains = Gains();
151 return static_cast<AliMUONVCalibParam*>(gains->Get(detElemId,manuId));
154 //_____________________________________________________________________________
156 AliMUONCalibrationData::Capacitances() const
158 /// Create (if needed) and return the internal store for capacitances.
159 return OnDemandCapacitances();
162 //_____________________________________________________________________________
164 AliMUONCalibrationData::Gains() const
166 /// Create (if needed) and return the internal store for gains.
167 return OnDemandGains();
170 //_____________________________________________________________________________
172 AliMUONCalibrationData::OnDemandCapacitances() const
174 /// Create (if needed) and return the internal store for capacitances.
178 AliCDBEntry* entry = GetEntry("MUON/Calib/Capacitances");
181 fCapacitances = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
184 AliError("Capacitances not of the expected type !!!");
189 AliError("Could not get capacitances !");
192 return fCapacitances;
195 //_____________________________________________________________________________
197 AliMUONCalibrationData::OnDemandGains() const
199 /// Create (if needed) and return the internal store for gains.
203 AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
206 fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
209 AliError("Gains not of the expected type !!!");
214 AliError("Could not get gains !");
220 //_____________________________________________________________________________
222 AliMUONCalibrationData::GlobalTriggerBoardMasks() const
224 /// Return the masks for the global trigger board.
226 return OnDemandGlobalTriggerBoardMasks();
229 //_____________________________________________________________________________
231 AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const
233 /// Create (if needed) and return the internal store for GlobalTriggerBoardMasks.
235 if (!fGlobalTriggerBoardMasks)
237 AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks");
240 fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject());
241 if (!fGlobalTriggerBoardMasks)
243 AliError("fGlobalTriggerBoardMasks not of the expected type !!!");
248 AliError("Could not get global trigger board masks !");
251 return fGlobalTriggerBoardMasks;
254 //_____________________________________________________________________________
256 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
258 /// Return the masks for a given trigger local board.
260 AliMUONV1DStore* store = OnDemandLocalTriggerBoardMasks();
263 AliError("Could not get LocalTriggerBoardMasks");
267 AliMUONVCalibParam* ltbm =
268 static_cast<AliMUONVCalibParam*>(store->Get(localBoardNumber));
271 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
276 //_____________________________________________________________________________
278 AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const
280 /// Create (if needed) and return the internal store for LocalTriggerBoardMasks.
282 if (!fLocalTriggerBoardMasks)
284 AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks");
287 fLocalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
288 if (!fLocalTriggerBoardMasks)
290 AliError("fLocalTriggerBoardMasks not of the expected type !!!");
295 AliError("Could not get local trigger board masks !");
298 return fLocalTriggerBoardMasks;
301 //_____________________________________________________________________________
303 AliMUONCalibrationData::OnDemandPedestals() const
305 /// Create (if needed) and return the internal storage for pedestals.
309 AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
312 fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
315 AliError("fPedestals not of the expected type !!!");
320 AliError("Could not get pedestals !");
326 //_____________________________________________________________________________
328 AliMUONCalibrationData::Print(Option_t*) const
330 /// A very basic dump of our guts.
332 cout << "RunNumber " << RunNumber()
333 << " fGains=" << fGains
334 << " fPedestals=" << fPedestals
336 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
337 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
338 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
339 << " fTriggerLut=" << fTriggerLut
343 //_____________________________________________________________________________
345 AliMUONCalibrationData::Pedestals() const
348 return OnDemandPedestals();
351 //_____________________________________________________________________________
353 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
355 /// Return the pedestals for a given (detElemId, manuId) pair.
356 /// A return value of 0x0 is considered an error, meaning we should get
357 /// pedestals for all channels.
359 AliMUONV2DStore* pedestals = OnDemandPedestals();
365 return static_cast<AliMUONVCalibParam*>(pedestals->Get(detElemId,manuId));
368 //_____________________________________________________________________________
370 AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const
372 /// Return the masks for a given trigger regional board.
374 AliMUONV1DStore* store = OnDemandRegionalTriggerBoardMasks();
378 AliError("Could not get RegionalTriggerBoardMasks");
382 AliMUONVCalibParam* rtbm =
383 static_cast<AliMUONVCalibParam*>(store->Get(index));
386 AliError(Form("Could not get mask for regionalBoard index=%d",index));
391 //_____________________________________________________________________________
393 AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const
395 /// Create (if needed) and return the internal store for RegionalTriggerBoardMasks.
397 if (!fRegionalTriggerBoardMasks)
399 AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks");
402 fRegionalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
403 if (!fRegionalTriggerBoardMasks)
405 AliError("fRegionalTriggerBoardMasks not of the expected type !!!");
410 AliError("Could not get regional trigger board masks !");
413 return fRegionalTriggerBoardMasks;
416 //_____________________________________________________________________________
417 AliMUONTriggerEfficiencyCells*
418 AliMUONCalibrationData::TriggerEfficiency() const
420 /// Return the trigger efficiency.
422 return OnDemandTriggerEfficiency();
425 //_____________________________________________________________________________
426 AliMUONTriggerEfficiencyCells*
427 AliMUONCalibrationData::OnDemandTriggerEfficiency() const
429 /// \todo: add comment
431 if (!fTriggerEfficiency)
433 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency");
436 fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject());
437 if (!fTriggerEfficiency)
439 AliError("fTriggerEfficiency not of the expected type !!!");
444 AliError("Could not get trigger efficiency !");
447 return fTriggerEfficiency;
450 //_____________________________________________________________________________
452 AliMUONCalibrationData::TriggerLut() const
454 /// Return the trigger look up table.
456 return OnDemandTriggerLut();
459 //_____________________________________________________________________________
461 AliMUONCalibrationData::OnDemandTriggerLut() const
463 /// \todo: add comment
467 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut");
470 fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject());
473 AliError("fTriggerLut not of the expected type !!!");
478 AliError("Could not get trigger lut !");
484 //_____________________________________________________________________________
486 AliMUONCalibrationData::Reset()
496 delete fLocalTriggerBoardMasks;
497 fLocalTriggerBoardMasks = 0x0;
498 delete fRegionalTriggerBoardMasks;
499 fRegionalTriggerBoardMasks = 0x0;
500 delete fGlobalTriggerBoardMasks;
501 fGlobalTriggerBoardMasks = 0x0;
504 delete fTriggerEfficiency;
505 fTriggerEfficiency = 0x0;
506 delete fCapacitances;