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"
22 #include "AliCDBStorage.h"
24 #include "AliMUONV2DStore.h"
25 #include "AliMUONVCalibParam.h"
26 #include "Riostream.h"
28 ClassImp(AliMUONCalibrationData)
30 //_____________________________________________________________________________
31 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
32 Bool_t deferredInitialization)
35 fRunNumber(runNumber),
42 // If deferredInitialization is false, we read *all* calibrations
44 // So when using this class to access only one kind of calibrations (e.g.
45 // only pedestals), you should put deferredInitialization to kTRUE, which
46 // will instruct this object to fetch the data only when neeeded.
48 if ( deferredInitialization == kFALSE )
57 //_____________________________________________________________________________
58 AliMUONCalibrationData::~AliMUONCalibrationData()
61 // dtor. Note that we're the owner of our pointers.
69 //_____________________________________________________________________________
71 AliMUONCalibrationData::DeadChannel(Int_t detElemId, Int_t manuId) const
74 // Return the calibration for a given (detElemId, manuId) pair
75 // Note that for DeadChannel, it's "legal" to return 0x0 (e.g. if a manu
76 // is perfect, we might simply forget it in the store).
79 static_cast<AliMUONVCalibParam*>(DeadChannels()->Get(detElemId,manuId));
82 //_____________________________________________________________________________
84 AliMUONCalibrationData::DeadChannels() const
87 // Create (if needed) and return the internal store for DeadChannels.
91 AliCDBEntry* entry = GetEntry("MUON/Calib/DeadChannels");
94 fDeadChannels = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
97 AliError("fDeadChannels not of the expected type !!!");
102 AliError("Could not get dead channels !");
105 return fDeadChannels;
108 //_____________________________________________________________________________
110 AliMUONCalibrationData::GetEntry(const char* path) const
113 // Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
114 // and return the corresponding CDBEntry.
116 AliInfo(Form("Fetching %s from Condition DataBase for run %d",path,fRunNumber));
118 AliCDBManager* man = AliCDBManager::Instance();
119 if (!man->IsDefaultStorageSet())
121 AliError("No default CDB storage set !");
126 AliCDBStorage* storage = man->GetDefaultStorage();
128 AliCDBEntry* entry = storage->Get(path,fRunNumber);
132 //_____________________________________________________________________________
134 AliMUONCalibrationData::Gain(Int_t detElemId, Int_t manuId) const
137 // Return the gains for a given (detElemId, manuId) pair
138 // Note that, unlike the DeadChannel case, if the result is 0x0, that's an
139 // error (meaning that we should get gains for all channels).
141 AliMUONVCalibParam* gain =
142 static_cast<AliMUONVCalibParam*>(Gains()->Get(detElemId,manuId));
145 AliError(Form("Could not get gain for detElemId=%d manuId=%d ",
151 //_____________________________________________________________________________
153 AliMUONCalibrationData::Gains() const
156 // Create (if needed) and return the internal store for gains.
160 AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
163 fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
166 AliError("Gains not of the expected type !!!");
171 AliError("Could not get gains !");
177 //_____________________________________________________________________________
179 AliMUONCalibrationData::Pedestals() const
182 // Create (if needed) and return the internal storage for pedestals.
186 AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
189 fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
192 AliError("fPedestals not of the expected type !!!");
197 AliError("Could not get pedestals !");
203 //_____________________________________________________________________________
205 AliMUONCalibrationData::Print(Option_t*) const
208 // A very basic dump of our guts.
210 cout << "RunNumber " << RunNumber()
211 << " fGains=" << fGains
212 << " fPedestals=" << fPedestals
213 << " fDeadChannels=" << fDeadChannels
218 //_____________________________________________________________________________
220 AliMUONCalibrationData::Pedestal(Int_t detElemId, Int_t manuId) const
223 // Return the pedestals for a given (detElemId, manuId) pair.
224 // A return value of 0x0 is considered an error, meaning we should get
225 // pedestals for all channels.
227 AliMUONVCalibParam* ped =
228 static_cast<AliMUONVCalibParam*>(Pedestals()->Get(detElemId,manuId));
231 AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ",