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 /// This class is to be considered as a convenience class.
32 /// Its aim is to ease retrieval of calibration data from the
33 /// condition database.
35 /// It acts as a "facade" to a bunch of underlying
36 /// containers/calibration classes.
39 ClassImp(AliMUONCalibrationData)
41 //_____________________________________________________________________________
42 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
43 Bool_t deferredInitialization)
46 fRunNumber(runNumber),
50 fLocalTriggerBoardMasks(0x0),
51 fRegionalTriggerBoardMasks(0x0),
52 fGlobalTriggerBoardMasks(0x0),
54 fTriggerEfficiency(0x0)
58 // If deferredInitialization is false, we read *all* calibrations
60 // So when using this class to access only one kind of calibrations (e.g.
61 // only pedestals), you should put deferredInitialization to kTRUE, which
62 // will instruct this object to fetch the data only when neeeded.
64 if ( deferredInitialization == kFALSE )
68 OnDemandDeadChannels();
69 OnDemandLocalTriggerBoardMasks();
70 OnDemandRegionalTriggerBoardMasks();
71 OnDemandGlobalTriggerBoardMasks();
73 OnDemandTriggerEfficiency();
77 //_____________________________________________________________________________
78 AliMUONCalibrationData::AliMUONCalibrationData(const AliMUONCalibrationData&)
81 AliFatal("Implement me if needed");
84 //_____________________________________________________________________________
85 AliMUONCalibrationData&
86 AliMUONCalibrationData::operator=(const AliMUONCalibrationData&)
88 AliFatal("Implement me if needed");
92 //_____________________________________________________________________________
93 AliMUONCalibrationData::~AliMUONCalibrationData()
96 // dtor. Note that we're the owner of our pointers.
100 delete fDeadChannels;
101 delete fLocalTriggerBoardMasks;
102 delete fRegionalTriggerBoardMasks;
103 delete fGlobalTriggerBoardMasks;
105 delete fTriggerEfficiency;
108 //_____________________________________________________________________________
110 AliMUONCalibrationData::DeadChannels(Int_t detElemId, Int_t manuId) const
113 // Return the calibration for a given (detElemId, manuId) pair
114 // Note that for DeadChannel, it's "legal" to return 0x0 (e.g. if a manu
115 // is perfect, we might simply forget it in the store).
118 static_cast<AliMUONVCalibParam*>(OnDemandDeadChannels()->Get(detElemId,manuId));
121 //_____________________________________________________________________________
123 AliMUONCalibrationData::OnDemandDeadChannels() const
126 // Create (if needed) and return the internal store for DeadChannels.
130 AliCDBEntry* entry = GetEntry("MUON/Calib/DeadChannels");
133 fDeadChannels = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
136 AliError("fDeadChannels not of the expected type !!!");
141 AliError("Could not get dead channels !");
144 return fDeadChannels;
147 //_____________________________________________________________________________
149 AliMUONCalibrationData::GetEntry(const char* path) const
152 // Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
153 // and return the corresponding CDBEntry.
155 return AliCDBManager::Instance()->Get(path,fRunNumber);
158 //_____________________________________________________________________________
160 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
163 // Return the gains for a given (detElemId, manuId) pair
164 // Note that, unlike the DeadChannel case, if the result is 0x0, that's an
165 // error (meaning that we should get gains for all channels).
167 AliMUONVCalibParam* gain =
168 static_cast<AliMUONVCalibParam*>(OnDemandGains()->Get(detElemId,manuId));
171 AliError(Form("Could not get gain for detElemId=%d manuId=%d ",
177 //_____________________________________________________________________________
179 AliMUONCalibrationData::OnDemandGains() const
182 // Create (if needed) and return the internal store for gains.
186 AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
189 fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
192 AliError("Gains not of the expected type !!!");
197 AliError("Could not get gains !");
203 //_____________________________________________________________________________
205 AliMUONCalibrationData::GlobalTriggerBoardMasks() const
208 // Return the masks for the global trigger board.
210 return OnDemandGlobalTriggerBoardMasks();
213 //_____________________________________________________________________________
215 AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const
218 // Create (if needed) and return the internal store for GlobalTriggerBoardMasks.
220 if (!fGlobalTriggerBoardMasks)
222 AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks");
225 fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject());
226 if (!fGlobalTriggerBoardMasks)
228 AliError("fGlobalTriggerBoardMasks not of the expected type !!!");
233 AliError("Could not get global trigger board masks !");
236 return fGlobalTriggerBoardMasks;
239 //_____________________________________________________________________________
241 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
244 // Return the masks for a given trigger local board.
246 AliMUONVCalibParam* ltbm =
247 static_cast<AliMUONVCalibParam*>(OnDemandLocalTriggerBoardMasks()->Get(localBoardNumber));
250 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
255 //_____________________________________________________________________________
257 AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const
260 // Create (if needed) and return the internal store for LocalTriggerBoardMasks.
262 if (!fLocalTriggerBoardMasks)
264 AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks");
267 fLocalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
268 if (!fLocalTriggerBoardMasks)
270 AliError("fLocalTriggerBoardMasks not of the expected type !!!");
275 AliError("Could not get local trigger board masks !");
278 return fLocalTriggerBoardMasks;
281 //_____________________________________________________________________________
283 AliMUONCalibrationData::OnDemandPedestals() const
286 // Create (if needed) and return the internal storage for pedestals.
290 AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
293 fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
296 AliError("fPedestals not of the expected type !!!");
301 AliError("Could not get pedestals !");
307 //_____________________________________________________________________________
309 AliMUONCalibrationData::Print(Option_t*) const
312 // A very basic dump of our guts.
314 cout << "RunNumber " << RunNumber()
315 << " fGains=" << fGains
316 << " fPedestals=" << fPedestals
317 << " fDeadChannels=" << fDeadChannels
318 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
319 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
320 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
321 << " fTriggerLut=" << fTriggerLut
326 //_____________________________________________________________________________
328 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
331 // Return the pedestals for a given (detElemId, manuId) pair.
332 // A return value of 0x0 is considered an error, meaning we should get
333 // pedestals for all channels.
335 AliMUONVCalibParam* ped =
336 static_cast<AliMUONVCalibParam*>(OnDemandPedestals()->Get(detElemId,manuId));
339 AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ",
345 //_____________________________________________________________________________
347 AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const
350 // Return the masks for a given trigger regional board.
352 AliMUONVCalibParam* rtbm =
353 static_cast<AliMUONVCalibParam*>(OnDemandRegionalTriggerBoardMasks()->Get(index));
356 AliError(Form("Could not get mask for regionalBoard index=%d",index));
361 //_____________________________________________________________________________
363 AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const
366 // Create (if needed) and return the internal store for RegionalTriggerBoardMasks.
368 if (!fRegionalTriggerBoardMasks)
370 AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks");
373 fRegionalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
374 if (!fRegionalTriggerBoardMasks)
376 AliError("fRegionalTriggerBoardMasks not of the expected type !!!");
381 AliError("Could not get regional trigger board masks !");
384 return fRegionalTriggerBoardMasks;
387 //_____________________________________________________________________________
388 AliMUONTriggerEfficiencyCells*
389 AliMUONCalibrationData::TriggerEfficiency() const
392 // Return the trigger efficiency.
394 return OnDemandTriggerEfficiency();
397 //_____________________________________________________________________________
398 AliMUONTriggerEfficiencyCells*
399 AliMUONCalibrationData::OnDemandTriggerEfficiency() const
404 if (!fTriggerEfficiency)
406 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency");
409 fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject());
410 if (!fTriggerEfficiency)
412 AliError("fTriggerEfficiency not of the expected type !!!");
417 AliError("Could not get trigger efficiency !");
420 return fTriggerEfficiency;
423 //_____________________________________________________________________________
425 AliMUONCalibrationData::TriggerLut() const
428 // Return the trigger look up table.
430 return OnDemandTriggerLut();
433 //_____________________________________________________________________________
435 AliMUONCalibrationData::OnDemandTriggerLut() const
442 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut");
445 fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject());
448 AliError("fTriggerLut not of the expected type !!!");
453 AliError("Could not get trigger lut !");