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 )
56 //______________________________________________________________________________
57 AliMUONCalibrationData::AliMUONCalibrationData(const AliMUONCalibrationData& right)
60 /// Protected copy constructor (not implemented)
62 AliFatal("Copy constructor not provided.");
65 //_____________________________________________________________________________
66 AliMUONCalibrationData::~AliMUONCalibrationData()
69 // dtor. Note that we're the owner of our pointers.
76 //______________________________________________________________________________
77 AliMUONCalibrationData&
78 AliMUONCalibrationData::operator=(const AliMUONCalibrationData& right)
80 /// Protected assignement operator (not implemented)
82 // check assignement to self
83 if (this == &right) return *this;
85 AliFatal("Assignement operator not provided.");
90 //_____________________________________________________________________________
92 AliMUONCalibrationData::DeadChannel(Int_t detElemId, Int_t manuId) const
95 // Return the calibration for a given (detElemId, manuId) pair
96 // Note that for DeadChannel, it's "legal" to return 0x0 (e.g. if a manu
97 // is perfect, we might simply forget it in the store).
100 static_cast<AliMUONVCalibParam*>(DeadChannels()->Get(detElemId,manuId));
103 //_____________________________________________________________________________
105 AliMUONCalibrationData::DeadChannels() const
108 // Create (if needed) and return the internal store for DeadChannels.
112 AliCDBEntry* entry = GetEntry("MUON/Calib/DeadChannels");
115 fDeadChannels = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
118 AliError("fDeadChannels not of the expected type !!!");
123 AliError("Could not get dead channels !");
126 return fDeadChannels;
129 //_____________________________________________________________________________
131 AliMUONCalibrationData::GetEntry(const char* path) const
134 // Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
135 // and return the corresponding CDBEntry.
137 AliInfo(Form("Fetching %s from Condition DataBase for run %d",path,fRunNumber));
139 AliCDBManager* man = AliCDBManager::Instance();
140 if (!man->IsDefaultStorageSet())
142 AliError("No default CDB storage set !");
147 AliCDBStorage* storage = man->GetDefaultStorage();
149 AliCDBEntry* entry = storage->Get(path,fRunNumber);
153 //_____________________________________________________________________________
155 AliMUONCalibrationData::Gain(Int_t detElemId, Int_t manuId) const
158 // Return the gains for a given (detElemId, manuId) pair
159 // Note that, unlike the DeadChannel case, if the result is 0x0, that's an
160 // error (meaning that we should get gains for all channels).
162 AliMUONVCalibParam* gain =
163 static_cast<AliMUONVCalibParam*>(Gains()->Get(detElemId,manuId));
166 AliError(Form("Could not get gain for detElemId=%d manuId=%d ",
172 //_____________________________________________________________________________
174 AliMUONCalibrationData::Gains() const
177 // Create (if needed) and return the internal store for gains.
181 AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
184 fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
187 AliError("Gains not of the expected type !!!");
192 AliError("Could not get gains !");
198 //_____________________________________________________________________________
200 AliMUONCalibrationData::Pedestals() const
203 // Create (if needed) and return the internal storage for pedestals.
207 AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
210 fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
213 AliError("fPedestals not of the expected type !!!");
218 AliError("Could not get pedestals !");
224 //_____________________________________________________________________________
226 AliMUONCalibrationData::Print(Option_t*) const
229 // A very basic dump of our guts.
231 cout << "RunNumber " << RunNumber()
232 << " fGains=" << fGains
233 << " fPedestals=" << fPedestals
234 << " fDeadChannels=" << fDeadChannels
239 //_____________________________________________________________________________
241 AliMUONCalibrationData::Pedestal(Int_t detElemId, Int_t manuId) const
244 // Return the pedestals for a given (detElemId, manuId) pair.
245 // A return value of 0x0 is considered an error, meaning we should get
246 // pedestals for all channels.
248 AliMUONVCalibParam* ped =
249 static_cast<AliMUONVCalibParam*>(Pedestals()->Get(detElemId,manuId));
252 AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ",