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)
66 // If deferredInitialization is false, we read *all* calibrations
68 // So when using this class to access only one kind of calibrations (e.g.
69 // only pedestals), you should put deferredInitialization to kTRUE, which
70 // will instruct this object to fetch the data only when neeeded.
72 if ( deferredInitialization == kFALSE )
77 OnDemandLocalTriggerBoardMasks();
78 OnDemandRegionalTriggerBoardMasks();
79 OnDemandGlobalTriggerBoardMasks();
81 OnDemandTriggerEfficiency();
85 //_____________________________________________________________________________
86 AliMUONCalibrationData::~AliMUONCalibrationData()
88 /// Destructor. Note that we're the owner of our pointers.
93 delete fLocalTriggerBoardMasks;
94 delete fRegionalTriggerBoardMasks;
95 delete fGlobalTriggerBoardMasks;
97 delete fTriggerEfficiency;
100 //_____________________________________________________________________________
102 AliMUONCalibrationData::HV() const
104 /// Return the calibration for a given (detElemId, manuId) pair
109 //_____________________________________________________________________________
111 AliMUONCalibrationData::OnDemandHV() const
113 /// Create (if needed) and return the internal store for DeadChannels.
117 AliCDBEntry* entry = GetEntry("MUON/Calib/HV");
120 fHV = dynamic_cast<TMap*>(entry->GetObject());
123 AliError("fHV not of the expected type !!!");
128 AliError("Could not get HV values !");
134 //_____________________________________________________________________________
136 AliMUONCalibrationData::GetEntry(const char* path) const
138 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
139 /// and return the corresponding CDBEntry.
141 return AliCDBManager::Instance()->Get(path,fRunNumber);
144 //_____________________________________________________________________________
146 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
148 /// Return the gains for a given (detElemId, manuId) pair
149 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
150 /// error (meaning that we should get gains for all channels).
152 AliMUONV2DStore* gains = Gains();
158 return static_cast<AliMUONVCalibParam*>(gains->Get(detElemId,manuId));
161 //_____________________________________________________________________________
163 AliMUONCalibrationData::Gains() const
165 /// Create (if needed) and return the internal store for gains.
166 return OnDemandGains();
169 //_____________________________________________________________________________
171 AliMUONCalibrationData::OnDemandGains() const
173 /// Create (if needed) and return the internal store for gains.
177 AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
180 fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
183 AliError("Gains not of the expected type !!!");
188 AliError("Could not get gains !");
194 //_____________________________________________________________________________
196 AliMUONCalibrationData::GlobalTriggerBoardMasks() const
198 /// Return the masks for the global trigger board.
200 return OnDemandGlobalTriggerBoardMasks();
203 //_____________________________________________________________________________
205 AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const
207 /// Create (if needed) and return the internal store for GlobalTriggerBoardMasks.
209 if (!fGlobalTriggerBoardMasks)
211 AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks");
214 fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject());
215 if (!fGlobalTriggerBoardMasks)
217 AliError("fGlobalTriggerBoardMasks not of the expected type !!!");
222 AliError("Could not get global trigger board masks !");
225 return fGlobalTriggerBoardMasks;
228 //_____________________________________________________________________________
230 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
232 /// Return the masks for a given trigger local board.
234 AliMUONV1DStore* store = OnDemandLocalTriggerBoardMasks();
237 AliError("Could not get LocalTriggerBoardMasks");
241 AliMUONVCalibParam* ltbm =
242 static_cast<AliMUONVCalibParam*>(store->Get(localBoardNumber));
245 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
250 //_____________________________________________________________________________
252 AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const
254 /// Create (if needed) and return the internal store for LocalTriggerBoardMasks.
256 if (!fLocalTriggerBoardMasks)
258 AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks");
261 fLocalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
262 if (!fLocalTriggerBoardMasks)
264 AliError("fLocalTriggerBoardMasks not of the expected type !!!");
269 AliError("Could not get local trigger board masks !");
272 return fLocalTriggerBoardMasks;
275 //_____________________________________________________________________________
277 AliMUONCalibrationData::OnDemandPedestals() const
279 /// Create (if needed) and return the internal storage for pedestals.
283 AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
286 fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
289 AliError("fPedestals not of the expected type !!!");
294 AliError("Could not get pedestals !");
300 //_____________________________________________________________________________
302 AliMUONCalibrationData::Print(Option_t*) const
304 /// A very basic dump of our guts.
306 cout << "RunNumber " << RunNumber()
307 << " fGains=" << fGains
308 << " fPedestals=" << fPedestals
310 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
311 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
312 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
313 << " fTriggerLut=" << fTriggerLut
317 //_____________________________________________________________________________
319 AliMUONCalibrationData::Pedestals() const
322 return OnDemandPedestals();
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 AliMUONV2DStore* pedestals = OnDemandPedestals();
339 return static_cast<AliMUONVCalibParam*>(pedestals->Get(detElemId,manuId));
342 //_____________________________________________________________________________
344 AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const
346 /// Return the masks for a given trigger regional board.
348 AliMUONV1DStore* store = OnDemandRegionalTriggerBoardMasks();
352 AliError("Could not get RegionalTriggerBoardMasks");
356 AliMUONVCalibParam* rtbm =
357 static_cast<AliMUONVCalibParam*>(store->Get(index));
360 AliError(Form("Could not get mask for regionalBoard index=%d",index));
365 //_____________________________________________________________________________
367 AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const
369 /// Create (if needed) and return the internal store for RegionalTriggerBoardMasks.
371 if (!fRegionalTriggerBoardMasks)
373 AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks");
376 fRegionalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
377 if (!fRegionalTriggerBoardMasks)
379 AliError("fRegionalTriggerBoardMasks not of the expected type !!!");
384 AliError("Could not get regional trigger board masks !");
387 return fRegionalTriggerBoardMasks;
390 //_____________________________________________________________________________
391 AliMUONTriggerEfficiencyCells*
392 AliMUONCalibrationData::TriggerEfficiency() const
394 /// Return the trigger efficiency.
396 return OnDemandTriggerEfficiency();
399 //_____________________________________________________________________________
400 AliMUONTriggerEfficiencyCells*
401 AliMUONCalibrationData::OnDemandTriggerEfficiency() const
403 /// \todo: add comment
405 if (!fTriggerEfficiency)
407 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency");
410 fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject());
411 if (!fTriggerEfficiency)
413 AliError("fTriggerEfficiency not of the expected type !!!");
418 AliError("Could not get trigger efficiency !");
421 return fTriggerEfficiency;
424 //_____________________________________________________________________________
426 AliMUONCalibrationData::TriggerLut() const
428 /// Return the trigger look up table.
430 return OnDemandTriggerLut();
433 //_____________________________________________________________________________
435 AliMUONCalibrationData::OnDemandTriggerLut() const
437 /// \todo: add comment
441 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut");
444 fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject());
447 AliError("fTriggerLut not of the expected type !!!");
452 AliError("Could not get trigger lut !");