]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCalibrationData.cxx
Formatting changes.
[u/mrichter/AliRoot.git] / MUON / AliMUONCalibrationData.cxx
CommitLineData
c5bdf179 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16// $Id$
17
18#include "AliMUONCalibrationData.h"
19
20#include "AliCDBEntry.h"
21#include "AliCDBManager.h"
c5bdf179 22#include "AliLog.h"
e7d7fa47 23#include "AliMUONTriggerEfficiencyCells.h"
24#include "AliMUONTriggerLut.h"
25#include "AliMUONV1DStore.h"
c3ce65fd 26#include "AliMUONV2DStore.h"
27#include "AliMUONVCalibParam.h"
c5bdf179 28#include "Riostream.h"
29
5398f946 30/// \class AliMUONCalibrationData
31///
32/// For the moment, this class stores pedestals, gains and deadchannels
33/// that are fetched from the CDB.
e7d7fa47 34///
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.
38///
39/// It acts as a "facade" to a bunch of underlying
40/// containers/calibration classes.
41///
5398f946 42/// \author Laurent Aphecetche
e7d7fa47 43
5398f946 44/// \cond CLASSIMP
c5bdf179 45ClassImp(AliMUONCalibrationData)
5398f946 46/// \endcond
c5bdf179 47
48//_____________________________________________________________________________
49AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
50 Bool_t deferredInitialization)
51: TObject(),
52fIsValid(kTRUE),
53fRunNumber(runNumber),
54fGains(0x0),
c3ce65fd 55fPedestals(0x0),
e7d7fa47 56fDeadChannels(0x0),
57fLocalTriggerBoardMasks(0x0),
58fRegionalTriggerBoardMasks(0x0),
59fGlobalTriggerBoardMasks(0x0),
60fTriggerLut(0x0),
61fTriggerEfficiency(0x0)
c5bdf179 62{
5398f946 63/// Default ctor.
64
c3ce65fd 65 // If deferredInitialization is false, we read *all* calibrations
66 // at once.
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.
5398f946 70
c5bdf179 71 if ( deferredInitialization == kFALSE )
72 {
e7d7fa47 73 OnDemandGains();
74 OnDemandPedestals();
75 OnDemandDeadChannels();
76 OnDemandLocalTriggerBoardMasks();
77 OnDemandRegionalTriggerBoardMasks();
78 OnDemandGlobalTriggerBoardMasks();
79 OnDemandTriggerLut();
80 OnDemandTriggerEfficiency();
c5bdf179 81 }
82}
83
c5bdf179 84//_____________________________________________________________________________
85AliMUONCalibrationData::~AliMUONCalibrationData()
86{
5398f946 87/// Destructor. Note that we're the owner of our pointers.
88
c5bdf179 89 delete fPedestals;
90 delete fGains;
c3ce65fd 91 delete fDeadChannels;
e7d7fa47 92 delete fLocalTriggerBoardMasks;
93 delete fRegionalTriggerBoardMasks;
94 delete fGlobalTriggerBoardMasks;
95 delete fTriggerLut;
96 delete fTriggerEfficiency;
c3ce65fd 97}
98
c3ce65fd 99//_____________________________________________________________________________
100AliMUONVCalibParam*
e7d7fa47 101AliMUONCalibrationData::DeadChannels(Int_t detElemId, Int_t manuId) const
c3ce65fd 102{
5398f946 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).
106
c3ce65fd 107 return
e7d7fa47 108 static_cast<AliMUONVCalibParam*>(OnDemandDeadChannels()->Get(detElemId,manuId));
c3ce65fd 109}
110
111//_____________________________________________________________________________
112AliMUONV2DStore*
e7d7fa47 113AliMUONCalibrationData::OnDemandDeadChannels() const
c3ce65fd 114{
5398f946 115/// Create (if needed) and return the internal store for DeadChannels.
116
c3ce65fd 117 if (!fDeadChannels)
118 {
119 AliCDBEntry* entry = GetEntry("MUON/Calib/DeadChannels");
120 if (entry)
121 {
122 fDeadChannels = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
123 if (!fDeadChannels)
124 {
125 AliError("fDeadChannels not of the expected type !!!");
126 }
127 }
128 else
129 {
130 AliError("Could not get dead channels !");
131 }
132 }
133 return fDeadChannels;
c5bdf179 134}
135
136//_____________________________________________________________________________
137AliCDBEntry*
138AliMUONCalibrationData::GetEntry(const char* path) const
139{
5398f946 140/// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
141/// and return the corresponding CDBEntry.
142
e7d7fa47 143 return AliCDBManager::Instance()->Get(path,fRunNumber);
c5bdf179 144}
145
146//_____________________________________________________________________________
c3ce65fd 147AliMUONVCalibParam*
e7d7fa47 148AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
c5bdf179 149{
5398f946 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).
153
c3ce65fd 154 AliMUONVCalibParam* gain =
e7d7fa47 155 static_cast<AliMUONVCalibParam*>(OnDemandGains()->Get(detElemId,manuId));
c5bdf179 156 if (!gain)
157 {
c3ce65fd 158 AliError(Form("Could not get gain for detElemId=%d manuId=%d ",
159 detElemId,manuId));
c5bdf179 160 }
161 return gain;
162}
163
164//_____________________________________________________________________________
c3ce65fd 165AliMUONV2DStore*
e7d7fa47 166AliMUONCalibrationData::OnDemandGains() const
c5bdf179 167{
5398f946 168/// Create (if needed) and return the internal store for gains.
169
c5bdf179 170 if (!fGains)
171 {
172 AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
173 if (entry)
174 {
c3ce65fd 175 fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
c5bdf179 176 if (!fGains)
177 {
178 AliError("Gains not of the expected type !!!");
179 }
180 }
181 else
182 {
183 AliError("Could not get gains !");
184 }
185 }
186 return fGains;
187}
188
e7d7fa47 189//_____________________________________________________________________________
190AliMUONVCalibParam*
191AliMUONCalibrationData::GlobalTriggerBoardMasks() const
192{
5398f946 193/// Return the masks for the global trigger board.
194
e7d7fa47 195 return OnDemandGlobalTriggerBoardMasks();
196}
197
198//_____________________________________________________________________________
199AliMUONVCalibParam*
200AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const
201{
5398f946 202/// Create (if needed) and return the internal store for GlobalTriggerBoardMasks.
203
e7d7fa47 204 if (!fGlobalTriggerBoardMasks)
205 {
206 AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks");
207 if (entry)
208 {
209 fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject());
210 if (!fGlobalTriggerBoardMasks)
211 {
212 AliError("fGlobalTriggerBoardMasks not of the expected type !!!");
213 }
214 }
215 else
216 {
217 AliError("Could not get global trigger board masks !");
218 }
219 }
220 return fGlobalTriggerBoardMasks;
221}
222
223//_____________________________________________________________________________
224AliMUONVCalibParam*
225AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
226{
5398f946 227/// Return the masks for a given trigger local board.
228
e7d7fa47 229 AliMUONVCalibParam* ltbm =
230 static_cast<AliMUONVCalibParam*>(OnDemandLocalTriggerBoardMasks()->Get(localBoardNumber));
231 if (!ltbm)
232 {
233 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
234 }
235 return ltbm;
236}
237
238//_____________________________________________________________________________
239AliMUONV1DStore*
240AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const
241{
5398f946 242/// Create (if needed) and return the internal store for LocalTriggerBoardMasks.
243
e7d7fa47 244 if (!fLocalTriggerBoardMasks)
245 {
246 AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks");
247 if (entry)
248 {
249 fLocalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
250 if (!fLocalTriggerBoardMasks)
251 {
252 AliError("fLocalTriggerBoardMasks not of the expected type !!!");
253 }
254 }
255 else
256 {
257 AliError("Could not get local trigger board masks !");
258 }
259 }
260 return fLocalTriggerBoardMasks;
261}
262
c5bdf179 263//_____________________________________________________________________________
c3ce65fd 264AliMUONV2DStore*
e7d7fa47 265AliMUONCalibrationData::OnDemandPedestals() const
c5bdf179 266{
5398f946 267/// Create (if needed) and return the internal storage for pedestals.
268
c5bdf179 269 if (!fPedestals)
270 {
271 AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
272 if (entry)
273 {
c3ce65fd 274 fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
c5bdf179 275 if (!fPedestals)
276 {
277 AliError("fPedestals not of the expected type !!!");
278 }
279 }
280 else
281 {
282 AliError("Could not get pedestals !");
283 }
284 }
285 return fPedestals;
286}
287
288//_____________________________________________________________________________
289void
290AliMUONCalibrationData::Print(Option_t*) const
291{
5398f946 292/// A very basic dump of our guts.
293
c5bdf179 294 cout << "RunNumber " << RunNumber()
e7d7fa47 295 << " fGains=" << fGains
296 << " fPedestals=" << fPedestals
297 << " fDeadChannels=" << fDeadChannels
298 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
299 << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
300 << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
301 << " fTriggerLut=" << fTriggerLut
c5bdf179 302 << endl;
303}
304
c5bdf179 305
306//_____________________________________________________________________________
c3ce65fd 307AliMUONVCalibParam*
e7d7fa47 308AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
c5bdf179 309{
5398f946 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.
313
c3ce65fd 314 AliMUONVCalibParam* ped =
e7d7fa47 315 static_cast<AliMUONVCalibParam*>(OnDemandPedestals()->Get(detElemId,manuId));
c5bdf179 316 if (!ped)
317 {
c3ce65fd 318 AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ",
319 detElemId,manuId));
c5bdf179 320 }
321 return ped;
322}
323
e7d7fa47 324//_____________________________________________________________________________
325AliMUONVCalibParam*
326AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const
327{
5398f946 328/// Return the masks for a given trigger regional board.
329
e7d7fa47 330 AliMUONVCalibParam* rtbm =
331 static_cast<AliMUONVCalibParam*>(OnDemandRegionalTriggerBoardMasks()->Get(index));
332 if (!rtbm)
333 {
334 AliError(Form("Could not get mask for regionalBoard index=%d",index));
335 }
336 return rtbm;
337}
338
339//_____________________________________________________________________________
340AliMUONV1DStore*
341AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const
342{
5398f946 343/// Create (if needed) and return the internal store for RegionalTriggerBoardMasks.
344
e7d7fa47 345 if (!fRegionalTriggerBoardMasks)
346 {
347 AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks");
348 if (entry)
349 {
350 fRegionalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
351 if (!fRegionalTriggerBoardMasks)
352 {
353 AliError("fRegionalTriggerBoardMasks not of the expected type !!!");
354 }
355 }
356 else
357 {
358 AliError("Could not get regional trigger board masks !");
359 }
360 }
361 return fRegionalTriggerBoardMasks;
362}
363
364//_____________________________________________________________________________
365AliMUONTriggerEfficiencyCells*
366AliMUONCalibrationData::TriggerEfficiency() const
367{
5398f946 368/// Return the trigger efficiency.
369
e7d7fa47 370 return OnDemandTriggerEfficiency();
371}
372
373//_____________________________________________________________________________
374AliMUONTriggerEfficiencyCells*
375AliMUONCalibrationData::OnDemandTriggerEfficiency() const
376{
5398f946 377/// \todo: add comment
378
e7d7fa47 379 if (!fTriggerEfficiency)
380 {
381 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency");
382 if (entry)
383 {
384 fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject());
385 if (!fTriggerEfficiency)
386 {
387 AliError("fTriggerEfficiency not of the expected type !!!");
388 }
389 }
390 else
391 {
392 AliError("Could not get trigger efficiency !");
393 }
394 }
395 return fTriggerEfficiency;
396}
397
398//_____________________________________________________________________________
399AliMUONTriggerLut*
400AliMUONCalibrationData::TriggerLut() const
401{
5398f946 402/// Return the trigger look up table.
403
e7d7fa47 404 return OnDemandTriggerLut();
405}
406
407//_____________________________________________________________________________
408AliMUONTriggerLut*
409AliMUONCalibrationData::OnDemandTriggerLut() const
410{
5398f946 411/// \todo: add comment
412
e7d7fa47 413 if (!fTriggerLut)
414 {
415 AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut");
416 if (entry)
417 {
418 fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject());
419 if (!fTriggerLut)
420 {
421 AliError("fTriggerLut not of the expected type !!!");
422 }
423 }
424 else
425 {
426 AliError("Could not get trigger lut !");
427 }
428 }
429 return fTriggerLut;
430}
431
432
c5bdf179 433