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),
68 // If deferredInitialization is false, we read *all* calibrations
70 // So when using this class to access only one kind of calibrations (e.g.
71 // only pedestals), you should put deferredInitialization to kTRUE, which
72 // will instruct this object to fetch the data only when neeeded.
74 if ( deferredInitialization == kFALSE )
79 OnDemandLocalTriggerBoardMasks();
80 OnDemandRegionalTriggerBoardMasks();
81 OnDemandGlobalTriggerBoardMasks();
83 OnDemandTriggerEfficiency();
84 OnDemandCapacitances();
89 //_____________________________________________________________________________
90 AliMUONCalibrationData::~AliMUONCalibrationData()
92 /// Destructor. Note that we're the owner of our pointers.
95 //_____________________________________________________________________________
97 AliMUONCalibrationData::HV() const
99 /// Return the calibration for a given (detElemId, manuId) pair
104 //_____________________________________________________________________________
106 AliMUONCalibrationData::OnDemandHV() const
108 /// Create (if needed) and return the internal store for DeadChannels.
112 AliCDBEntry* entry = GetEntry("MUON/Calib/HV");
115 fHV = dynamic_cast<TMap*>(entry->GetObject());
118 AliError("fHV not of the expected type !!!");
123 AliError("Could not get HV values !");
129 //_____________________________________________________________________________
131 AliMUONCalibrationData::GetEntry(const char* path) const
133 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
134 /// and return the corresponding CDBEntry.
136 return AliCDBManager::Instance()->Get(path,fRunNumber);
139 //_____________________________________________________________________________
141 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
143 /// Return the gains for a given (detElemId, manuId) pair
144 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
145 /// error (meaning that we should get gains for all channels).
147 AliMUONV2DStore* gains = Gains();
153 return static_cast<AliMUONVCalibParam*>(gains->Get(detElemId,manuId));
156 //_____________________________________________________________________________
158 AliMUONCalibrationData::Capacitances() const
160 /// Create (if needed) and return the internal store for capacitances.
161 return OnDemandCapacitances();
164 //_____________________________________________________________________________
166 AliMUONCalibrationData::Neighbours() const
168 /// Create (if needed) and return the internal store for neighbours.
169 return OnDemandNeighbours();
172 //_____________________________________________________________________________
174 AliMUONCalibrationData::Gains() const
176 /// Create (if needed) and return the internal store for gains.
177 return OnDemandGains();
180 //_____________________________________________________________________________
182 AliMUONCalibrationData::OnDemandNeighbours() const
184 /// Create (if needed) and return the internal store for neighbours.
188 AliCDBEntry* entry = GetEntry("MUON/Calib/Neighbours");
191 fNeighbours = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
194 AliError("Neighbours not of the expected type !!!");
199 AliError("Could not get neighbours !");
205 //_____________________________________________________________________________
207 AliMUONCalibrationData::OnDemandCapacitances() const
209 /// Create (if needed) and return the internal store for capacitances.
213 AliCDBEntry* entry = GetEntry("MUON/Calib/Capacitances");
216 fCapacitances = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
219 AliError("Capacitances not of the expected type !!!");
224 AliError("Could not get capacitances !");
227 return fCapacitances;
230 //_____________________________________________________________________________
232 AliMUONCalibrationData::OnDemandGains() const
234 /// Create (if needed) and return the internal store for gains.
238 AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
241 fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
244 AliError("Gains not of the expected type !!!");
249 AliError("Could not get gains !");
256 //_____________________________________________________________________________
258 AliMUONCalibrationData::GlobalTriggerBoardMasks() const
260 /// Return the masks for the global trigger board.
262 return OnDemandGlobalTriggerBoardMasks();
265 //_____________________________________________________________________________
267 AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const
269 /// Create (if needed) and return the internal store for GlobalTriggerBoardMasks.
271 if (!fGlobalTriggerBoardMasks)
273 AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks");
276 fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject());
277 if (!fGlobalTriggerBoardMasks)
279 AliError("fGlobalTriggerBoardMasks not of the expected type !!!");
284 AliError("Could not get global trigger board masks !");
287 return fGlobalTriggerBoardMasks;
290 //_____________________________________________________________________________
292 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
294 /// Return the masks for a given trigger local board.
296 AliMUONV1DStore* store = OnDemandLocalTriggerBoardMasks();
299 AliError("Could not get LocalTriggerBoardMasks");
303 AliMUONVCalibParam* ltbm =
304 static_cast<AliMUONVCalibParam*>(store->Get(localBoardNumber));
307 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
312 //_____________________________________________________________________________
314 AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const
316 /// Create (if needed) and return the internal store for LocalTriggerBoardMasks.
318 if (!fLocalTriggerBoardMasks)
320 AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks");
323 fLocalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
324 if (!fLocalTriggerBoardMasks)
326 AliError("fLocalTriggerBoardMasks not of the expected type !!!");
331 AliError("Could not get local trigger board masks !");
334 return fLocalTriggerBoardMasks;
337 //_____________________________________________________________________________
339 AliMUONCalibrationData::OnDemandPedestals() const
341 /// Create (if needed) and return the internal storage for pedestals.
345 AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
348 fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
351 AliError("fPedestals not of the expected type !!!");
356 AliError("Could not get pedestals !");
362 //_____________________________________________________________________________
364 AliMUONCalibrationData::Print(Option_t*) const
366 /// A very basic dump of our guts.
368 cout << "RunNumber " << RunNumber()
369 << " fGains=" << fGains
370 << " fPedestals=" << fPedestals
372 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
373 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
374 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
375 << " fTriggerLut=" << fTriggerLut
379 //_____________________________________________________________________________
381 AliMUONCalibrationData::Pedestals() const
384 return OnDemandPedestals();
387 //_____________________________________________________________________________
389 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
391 /// Return the pedestals for a given (detElemId, manuId) pair.
392 /// A return value of 0x0 is considered an error, meaning we should get
393 /// pedestals for all channels.
395 AliMUONV2DStore* pedestals = OnDemandPedestals();
401 return static_cast<AliMUONVCalibParam*>(pedestals->Get(detElemId,manuId));
404 //_____________________________________________________________________________
406 AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const
408 /// Return the masks for a given trigger regional board.
410 AliMUONV1DStore* store = OnDemandRegionalTriggerBoardMasks();
414 AliError("Could not get RegionalTriggerBoardMasks");
418 AliMUONVCalibParam* rtbm =
419 static_cast<AliMUONVCalibParam*>(store->Get(index));
422 AliError(Form("Could not get mask for regionalBoard index=%d",index));
427 //_____________________________________________________________________________
429 AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const
431 /// Create (if needed) and return the internal store for RegionalTriggerBoardMasks.
433 if (!fRegionalTriggerBoardMasks)
435 AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks");
438 fRegionalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
439 if (!fRegionalTriggerBoardMasks)
441 AliError("fRegionalTriggerBoardMasks not of the expected type !!!");
446 AliError("Could not get regional trigger board masks !");
449 return fRegionalTriggerBoardMasks;
452 //_____________________________________________________________________________
453 AliMUONTriggerEfficiencyCells*
454 AliMUONCalibrationData::TriggerEfficiency() const
456 /// Return the trigger efficiency.
458 return OnDemandTriggerEfficiency();
461 //_____________________________________________________________________________
462 AliMUONTriggerEfficiencyCells*
463 AliMUONCalibrationData::OnDemandTriggerEfficiency() const
465 /// \todo: add comment
467 if (!fTriggerEfficiency)
469 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency");
472 fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject());
473 if (!fTriggerEfficiency)
475 AliError("fTriggerEfficiency not of the expected type !!!");
480 AliError("Could not get trigger efficiency !");
483 return fTriggerEfficiency;
486 //_____________________________________________________________________________
488 AliMUONCalibrationData::TriggerLut() const
490 /// Return the trigger look up table.
492 return OnDemandTriggerLut();
495 //_____________________________________________________________________________
497 AliMUONCalibrationData::OnDemandTriggerLut() const
499 /// \todo: add comment
503 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut");
506 fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject());
509 AliError("fTriggerLut not of the expected type !!!");
514 AliError("Could not get trigger lut !");
520 //_____________________________________________________________________________
522 AliMUONCalibrationData::Reset()
532 delete fLocalTriggerBoardMasks;
533 fLocalTriggerBoardMasks = 0x0;
534 delete fRegionalTriggerBoardMasks;
535 fRegionalTriggerBoardMasks = 0x0;
536 delete fGlobalTriggerBoardMasks;
537 fGlobalTriggerBoardMasks = 0x0;
540 delete fTriggerEfficiency;
541 fTriggerEfficiency = 0x0;
542 delete fCapacitances;