]>
Commit | Line | Data |
---|---|---|
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" | |
22 | #include "AliCDBStorage.h" | |
c5bdf179 | 23 | #include "AliLog.h" |
c3ce65fd | 24 | #include "AliMUONV2DStore.h" |
25 | #include "AliMUONVCalibParam.h" | |
c5bdf179 | 26 | #include "Riostream.h" |
27 | ||
28 | ClassImp(AliMUONCalibrationData) | |
29 | ||
30 | //_____________________________________________________________________________ | |
31 | AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber, | |
32 | Bool_t deferredInitialization) | |
33 | : TObject(), | |
34 | fIsValid(kTRUE), | |
35 | fRunNumber(runNumber), | |
36 | fGains(0x0), | |
c3ce65fd | 37 | fPedestals(0x0), |
38 | fDeadChannels(0x0) | |
c5bdf179 | 39 | { |
c3ce65fd | 40 | // |
41 | // Default ctor. | |
42 | // If deferredInitialization is false, we read *all* calibrations | |
43 | // at once. | |
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. | |
47 | // | |
c5bdf179 | 48 | if ( deferredInitialization == kFALSE ) |
49 | { | |
50 | Gains(); | |
51 | Pedestals(); | |
c3ce65fd | 52 | DeadChannels(); |
c5bdf179 | 53 | } |
54 | } | |
55 | ||
56 | ||
57 | //_____________________________________________________________________________ | |
58 | AliMUONCalibrationData::~AliMUONCalibrationData() | |
59 | { | |
c3ce65fd | 60 | // |
61 | // dtor. Note that we're the owner of our pointers. | |
62 | // | |
c5bdf179 | 63 | delete fPedestals; |
64 | delete fGains; | |
c3ce65fd | 65 | delete fDeadChannels; |
66 | } | |
67 | ||
68 | ||
69 | //_____________________________________________________________________________ | |
70 | AliMUONVCalibParam* | |
71 | AliMUONCalibrationData::DeadChannel(Int_t detElemId, Int_t manuId) const | |
72 | { | |
73 | // | |
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). | |
77 | // | |
78 | return | |
79 | static_cast<AliMUONVCalibParam*>(DeadChannels()->Get(detElemId,manuId)); | |
80 | } | |
81 | ||
82 | //_____________________________________________________________________________ | |
83 | AliMUONV2DStore* | |
84 | AliMUONCalibrationData::DeadChannels() const | |
85 | { | |
86 | // | |
87 | // Create (if needed) and return the internal store for DeadChannels. | |
88 | // | |
89 | if (!fDeadChannels) | |
90 | { | |
91 | AliCDBEntry* entry = GetEntry("MUON/Calib/DeadChannels"); | |
92 | if (entry) | |
93 | { | |
94 | fDeadChannels = dynamic_cast<AliMUONV2DStore*>(entry->GetObject()); | |
95 | if (!fDeadChannels) | |
96 | { | |
97 | AliError("fDeadChannels not of the expected type !!!"); | |
98 | } | |
99 | } | |
100 | else | |
101 | { | |
102 | AliError("Could not get dead channels !"); | |
103 | } | |
104 | } | |
105 | return fDeadChannels; | |
c5bdf179 | 106 | } |
107 | ||
108 | //_____________________________________________________________________________ | |
109 | AliCDBEntry* | |
110 | AliMUONCalibrationData::GetEntry(const char* path) const | |
111 | { | |
c3ce65fd | 112 | // |
113 | // Access the CDB for a given path (e.g. MUON/Calib/Pedestals), | |
114 | // and return the corresponding CDBEntry. | |
115 | // | |
c5bdf179 | 116 | AliInfo(Form("Fetching %s from Condition DataBase for run %d",path,fRunNumber)); |
117 | ||
118 | AliCDBManager* man = AliCDBManager::Instance(); | |
119 | if (!man->IsDefaultStorageSet()) | |
120 | { | |
121 | AliError("No default CDB storage set !"); | |
122 | fIsValid = kFALSE; | |
123 | return 0; | |
124 | } | |
125 | ||
126 | AliCDBStorage* storage = man->GetDefaultStorage(); | |
127 | ||
128 | AliCDBEntry* entry = storage->Get(path,fRunNumber); | |
129 | return entry; | |
130 | } | |
131 | ||
132 | //_____________________________________________________________________________ | |
c3ce65fd | 133 | AliMUONVCalibParam* |
134 | AliMUONCalibrationData::Gain(Int_t detElemId, Int_t manuId) const | |
c5bdf179 | 135 | { |
c3ce65fd | 136 | // |
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). | |
140 | // | |
141 | AliMUONVCalibParam* gain = | |
142 | static_cast<AliMUONVCalibParam*>(Gains()->Get(detElemId,manuId)); | |
c5bdf179 | 143 | if (!gain) |
144 | { | |
c3ce65fd | 145 | AliError(Form("Could not get gain for detElemId=%d manuId=%d ", |
146 | detElemId,manuId)); | |
c5bdf179 | 147 | } |
148 | return gain; | |
149 | } | |
150 | ||
151 | //_____________________________________________________________________________ | |
c3ce65fd | 152 | AliMUONV2DStore* |
c5bdf179 | 153 | AliMUONCalibrationData::Gains() const |
154 | { | |
c3ce65fd | 155 | // |
156 | // Create (if needed) and return the internal store for gains. | |
157 | // | |
c5bdf179 | 158 | if (!fGains) |
159 | { | |
160 | AliCDBEntry* entry = GetEntry("MUON/Calib/Gains"); | |
161 | if (entry) | |
162 | { | |
c3ce65fd | 163 | fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject()); |
c5bdf179 | 164 | if (!fGains) |
165 | { | |
166 | AliError("Gains not of the expected type !!!"); | |
167 | } | |
168 | } | |
169 | else | |
170 | { | |
171 | AliError("Could not get gains !"); | |
172 | } | |
173 | } | |
174 | return fGains; | |
175 | } | |
176 | ||
177 | //_____________________________________________________________________________ | |
c3ce65fd | 178 | AliMUONV2DStore* |
c5bdf179 | 179 | AliMUONCalibrationData::Pedestals() const |
180 | { | |
c3ce65fd | 181 | // |
182 | // Create (if needed) and return the internal storage for pedestals. | |
183 | // | |
c5bdf179 | 184 | if (!fPedestals) |
185 | { | |
186 | AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals"); | |
187 | if (entry) | |
188 | { | |
c3ce65fd | 189 | fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject()); |
c5bdf179 | 190 | if (!fPedestals) |
191 | { | |
192 | AliError("fPedestals not of the expected type !!!"); | |
193 | } | |
194 | } | |
195 | else | |
196 | { | |
197 | AliError("Could not get pedestals !"); | |
198 | } | |
199 | } | |
200 | return fPedestals; | |
201 | } | |
202 | ||
203 | //_____________________________________________________________________________ | |
204 | void | |
205 | AliMUONCalibrationData::Print(Option_t*) const | |
206 | { | |
c3ce65fd | 207 | // |
208 | // A very basic dump of our guts. | |
209 | // | |
c5bdf179 | 210 | cout << "RunNumber " << RunNumber() |
211 | << " fGains=" << fGains | |
c3ce65fd | 212 | << " fPedestals=" << fPedestals |
213 | << " fDeadChannels=" << fDeadChannels | |
c5bdf179 | 214 | << endl; |
215 | } | |
216 | ||
c5bdf179 | 217 | |
218 | //_____________________________________________________________________________ | |
c3ce65fd | 219 | AliMUONVCalibParam* |
220 | AliMUONCalibrationData::Pedestal(Int_t detElemId, Int_t manuId) const | |
c5bdf179 | 221 | { |
c3ce65fd | 222 | // |
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. | |
226 | // | |
227 | AliMUONVCalibParam* ped = | |
228 | static_cast<AliMUONVCalibParam*>(Pedestals()->Get(detElemId,manuId)); | |
c5bdf179 | 229 | if (!ped) |
230 | { | |
c3ce65fd | 231 | AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ", |
232 | detElemId,manuId)); | |
c5bdf179 | 233 | } |
234 | return ped; | |
235 | } | |
236 | ||
237 |