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"
30 /// \class AliMUONCalibrationData
32 /// For the moment, this class stores pedestals, gains and deadchannels
33 /// that are fetched from the CDB.
35 /// This class is to be considered as a convenience class.
36 /// Its aim is to ease retrieval of calibration data from the
37 /// condition database.
39 /// It acts as a "facade" to a bunch of underlying
40 /// containers/calibration classes.
42 /// \author Laurent Aphecetche
45 ClassImp(AliMUONCalibrationData)
48 //_____________________________________________________________________________
49 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
50 Bool_t deferredInitialization)
53 fRunNumber(runNumber),
57 fLocalTriggerBoardMasks(0x0),
58 fRegionalTriggerBoardMasks(0x0),
59 fGlobalTriggerBoardMasks(0x0),
61 fTriggerEfficiency(0x0)
65 // If deferredInitialization is false, we read *all* calibrations
67 // So when using this class to access only one kind of calibrations (e.g.
68 // only pedestals), you should put deferredInitialization to kTRUE, which
69 // will instruct this object to fetch the data only when neeeded.
71 if ( deferredInitialization == kFALSE )
75 OnDemandDeadChannels();
76 OnDemandLocalTriggerBoardMasks();
77 OnDemandRegionalTriggerBoardMasks();
78 OnDemandGlobalTriggerBoardMasks();
80 OnDemandTriggerEfficiency();
84 //_____________________________________________________________________________
85 AliMUONCalibrationData::~AliMUONCalibrationData()
87 /// Destructor. Note that we're the owner of our pointers.
92 delete fLocalTriggerBoardMasks;
93 delete fRegionalTriggerBoardMasks;
94 delete fGlobalTriggerBoardMasks;
96 delete fTriggerEfficiency;
99 //_____________________________________________________________________________
101 AliMUONCalibrationData::DeadChannels(Int_t detElemId, Int_t manuId) const
103 /// Return the calibration for a given (detElemId, manuId) pair
104 /// Note that for DeadChannel, it's "legal" to return 0x0 (e.g. if a manu
105 /// is perfect, we might simply forget it in the store).
108 static_cast<AliMUONVCalibParam*>(OnDemandDeadChannels()->Get(detElemId,manuId));
111 //_____________________________________________________________________________
113 AliMUONCalibrationData::OnDemandDeadChannels() const
115 /// Create (if needed) and return the internal store for DeadChannels.
119 AliCDBEntry* entry = GetEntry("MUON/Calib/DeadChannels");
122 fDeadChannels = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
125 AliError("fDeadChannels not of the expected type !!!");
130 AliError("Could not get dead channels !");
133 return fDeadChannels;
136 //_____________________________________________________________________________
138 AliMUONCalibrationData::GetEntry(const char* path) const
140 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
141 /// and return the corresponding CDBEntry.
143 return AliCDBManager::Instance()->Get(path,fRunNumber);
146 //_____________________________________________________________________________
148 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
150 /// Return the gains for a given (detElemId, manuId) pair
151 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
152 /// error (meaning that we should get gains for all channels).
154 AliMUONVCalibParam* gain =
155 static_cast<AliMUONVCalibParam*>(OnDemandGains()->Get(detElemId,manuId));
158 AliError(Form("Could not get gain for detElemId=%d manuId=%d ",
164 //_____________________________________________________________________________
166 AliMUONCalibrationData::OnDemandGains() const
168 /// Create (if needed) and return the internal store for gains.
172 AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
175 fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
178 AliError("Gains not of the expected type !!!");
183 AliError("Could not get gains !");
189 //_____________________________________________________________________________
191 AliMUONCalibrationData::GlobalTriggerBoardMasks() const
193 /// Return the masks for the global trigger board.
195 return OnDemandGlobalTriggerBoardMasks();
198 //_____________________________________________________________________________
200 AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const
202 /// Create (if needed) and return the internal store for GlobalTriggerBoardMasks.
204 if (!fGlobalTriggerBoardMasks)
206 AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks");
209 fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject());
210 if (!fGlobalTriggerBoardMasks)
212 AliError("fGlobalTriggerBoardMasks not of the expected type !!!");
217 AliError("Could not get global trigger board masks !");
220 return fGlobalTriggerBoardMasks;
223 //_____________________________________________________________________________
225 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
227 /// Return the masks for a given trigger local board.
229 AliMUONVCalibParam* ltbm =
230 static_cast<AliMUONVCalibParam*>(OnDemandLocalTriggerBoardMasks()->Get(localBoardNumber));
233 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
238 //_____________________________________________________________________________
240 AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const
242 /// Create (if needed) and return the internal store for LocalTriggerBoardMasks.
244 if (!fLocalTriggerBoardMasks)
246 AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks");
249 fLocalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
250 if (!fLocalTriggerBoardMasks)
252 AliError("fLocalTriggerBoardMasks not of the expected type !!!");
257 AliError("Could not get local trigger board masks !");
260 return fLocalTriggerBoardMasks;
263 //_____________________________________________________________________________
265 AliMUONCalibrationData::OnDemandPedestals() const
267 /// Create (if needed) and return the internal storage for pedestals.
271 AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
274 fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
277 AliError("fPedestals not of the expected type !!!");
282 AliError("Could not get pedestals !");
288 //_____________________________________________________________________________
290 AliMUONCalibrationData::Print(Option_t*) const
292 /// A very basic dump of our guts.
294 cout << "RunNumber " << RunNumber()
295 << " fGains=" << fGains
296 << " fPedestals=" << fPedestals
297 << " fDeadChannels=" << fDeadChannels
298 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
299 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
300 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
301 << " fTriggerLut=" << fTriggerLut
306 //_____________________________________________________________________________
308 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
310 /// Return the pedestals for a given (detElemId, manuId) pair.
311 /// A return value of 0x0 is considered an error, meaning we should get
312 /// pedestals for all channels.
314 AliMUONVCalibParam* ped =
315 static_cast<AliMUONVCalibParam*>(OnDemandPedestals()->Get(detElemId,manuId));
318 AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ",
324 //_____________________________________________________________________________
326 AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const
328 /// Return the masks for a given trigger regional board.
330 AliMUONVCalibParam* rtbm =
331 static_cast<AliMUONVCalibParam*>(OnDemandRegionalTriggerBoardMasks()->Get(index));
334 AliError(Form("Could not get mask for regionalBoard index=%d",index));
339 //_____________________________________________________________________________
341 AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const
343 /// Create (if needed) and return the internal store for RegionalTriggerBoardMasks.
345 if (!fRegionalTriggerBoardMasks)
347 AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks");
350 fRegionalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
351 if (!fRegionalTriggerBoardMasks)
353 AliError("fRegionalTriggerBoardMasks not of the expected type !!!");
358 AliError("Could not get regional trigger board masks !");
361 return fRegionalTriggerBoardMasks;
364 //_____________________________________________________________________________
365 AliMUONTriggerEfficiencyCells*
366 AliMUONCalibrationData::TriggerEfficiency() const
368 /// Return the trigger efficiency.
370 return OnDemandTriggerEfficiency();
373 //_____________________________________________________________________________
374 AliMUONTriggerEfficiencyCells*
375 AliMUONCalibrationData::OnDemandTriggerEfficiency() const
377 /// \todo: add comment
379 if (!fTriggerEfficiency)
381 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency");
384 fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject());
385 if (!fTriggerEfficiency)
387 AliError("fTriggerEfficiency not of the expected type !!!");
392 AliError("Could not get trigger efficiency !");
395 return fTriggerEfficiency;
398 //_____________________________________________________________________________
400 AliMUONCalibrationData::TriggerLut() const
402 /// Return the trigger look up table.
404 return OnDemandTriggerLut();
407 //_____________________________________________________________________________
409 AliMUONCalibrationData::OnDemandTriggerLut() const
411 /// \todo: add comment
415 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut");
418 fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject());
421 AliError("fTriggerLut not of the expected type !!!");
426 AliError("Could not get trigger lut !");