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();
155 AliError("Could not get gains");
159 AliMUONVCalibParam* g =
160 static_cast<AliMUONVCalibParam*>(gains->Get(detElemId,manuId));
163 AliError(Form("Could not get gain for detElemId=%d manuId=%d ",
169 //_____________________________________________________________________________
171 AliMUONCalibrationData::Gains() const
173 /// Create (if needed) and return the internal store for gains.
174 return OnDemandGains();
177 //_____________________________________________________________________________
179 AliMUONCalibrationData::OnDemandGains() const
181 /// Create (if needed) and return the internal store for gains.
185 AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
188 fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
191 AliError("Gains not of the expected type !!!");
196 AliError("Could not get gains !");
202 //_____________________________________________________________________________
204 AliMUONCalibrationData::GlobalTriggerBoardMasks() const
206 /// Return the masks for the global trigger board.
208 return OnDemandGlobalTriggerBoardMasks();
211 //_____________________________________________________________________________
213 AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const
215 /// Create (if needed) and return the internal store for GlobalTriggerBoardMasks.
217 if (!fGlobalTriggerBoardMasks)
219 AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks");
222 fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject());
223 if (!fGlobalTriggerBoardMasks)
225 AliError("fGlobalTriggerBoardMasks not of the expected type !!!");
230 AliError("Could not get global trigger board masks !");
233 return fGlobalTriggerBoardMasks;
236 //_____________________________________________________________________________
238 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
240 /// Return the masks for a given trigger local board.
242 AliMUONV1DStore* store = OnDemandLocalTriggerBoardMasks();
245 AliError("Could not get LocalTriggerBoardMasks");
249 AliMUONVCalibParam* ltbm =
250 static_cast<AliMUONVCalibParam*>(store->Get(localBoardNumber));
253 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
258 //_____________________________________________________________________________
260 AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const
262 /// Create (if needed) and return the internal store for LocalTriggerBoardMasks.
264 if (!fLocalTriggerBoardMasks)
266 AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks");
269 fLocalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
270 if (!fLocalTriggerBoardMasks)
272 AliError("fLocalTriggerBoardMasks not of the expected type !!!");
277 AliError("Could not get local trigger board masks !");
280 return fLocalTriggerBoardMasks;
283 //_____________________________________________________________________________
285 AliMUONCalibrationData::OnDemandPedestals() const
287 /// Create (if needed) and return the internal storage for pedestals.
291 AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
294 fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
297 AliError("fPedestals not of the expected type !!!");
302 AliError("Could not get pedestals !");
308 //_____________________________________________________________________________
310 AliMUONCalibrationData::Print(Option_t*) const
312 /// A very basic dump of our guts.
314 cout << "RunNumber " << RunNumber()
315 << " fGains=" << fGains
316 << " fPedestals=" << fPedestals
318 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
319 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
320 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
321 << " fTriggerLut=" << fTriggerLut
325 //_____________________________________________________________________________
327 AliMUONCalibrationData::Pedestals() const
330 return OnDemandPedestals();
333 //_____________________________________________________________________________
335 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
337 /// Return the pedestals for a given (detElemId, manuId) pair.
338 /// A return value of 0x0 is considered an error, meaning we should get
339 /// pedestals for all channels.
341 AliMUONV2DStore* pedestals = OnDemandPedestals();
344 AliError(Form("Did not find pedestals for DE %d manuId %d",
349 AliMUONVCalibParam* ped =
350 static_cast<AliMUONVCalibParam*>(pedestals->Get(detElemId,manuId));
353 AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ",
359 //_____________________________________________________________________________
361 AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const
363 /// Return the masks for a given trigger regional board.
365 AliMUONV1DStore* store = OnDemandRegionalTriggerBoardMasks();
369 AliError("Could not get RegionalTriggerBoardMasks");
373 AliMUONVCalibParam* rtbm =
374 static_cast<AliMUONVCalibParam*>(store->Get(index));
377 AliError(Form("Could not get mask for regionalBoard index=%d",index));
382 //_____________________________________________________________________________
384 AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const
386 /// Create (if needed) and return the internal store for RegionalTriggerBoardMasks.
388 if (!fRegionalTriggerBoardMasks)
390 AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks");
393 fRegionalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
394 if (!fRegionalTriggerBoardMasks)
396 AliError("fRegionalTriggerBoardMasks not of the expected type !!!");
401 AliError("Could not get regional trigger board masks !");
404 return fRegionalTriggerBoardMasks;
407 //_____________________________________________________________________________
408 AliMUONTriggerEfficiencyCells*
409 AliMUONCalibrationData::TriggerEfficiency() const
411 /// Return the trigger efficiency.
413 return OnDemandTriggerEfficiency();
416 //_____________________________________________________________________________
417 AliMUONTriggerEfficiencyCells*
418 AliMUONCalibrationData::OnDemandTriggerEfficiency() const
420 /// \todo: add comment
422 if (!fTriggerEfficiency)
424 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency");
427 fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject());
428 if (!fTriggerEfficiency)
430 AliError("fTriggerEfficiency not of the expected type !!!");
435 AliError("Could not get trigger efficiency !");
438 return fTriggerEfficiency;
441 //_____________________________________________________________________________
443 AliMUONCalibrationData::TriggerLut() const
445 /// Return the trigger look up table.
447 return OnDemandTriggerLut();
450 //_____________________________________________________________________________
452 AliMUONCalibrationData::OnDemandTriggerLut() const
454 /// \todo: add comment
458 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut");
461 fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject());
464 AliError("fTriggerLut not of the expected type !!!");
469 AliError("Could not get trigger lut !");