]>
Commit | Line | Data |
---|---|---|
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 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // class for PHOS calibration // | |
21 | // // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "TRandom.h" | |
25 | #include "AliPHOSCalibData.h" | |
26 | #include "AliCDBManager.h" | |
27 | #include "AliCDBStorage.h" | |
28 | #include "AliCDBId.h" | |
29 | #include "AliCDBEntry.h" | |
30 | #include "AliPHOSEmcCalibData.h" | |
31 | #include "AliPHOSCpvCalibData.h" | |
32 | #include "AliCDBMetaData.h" | |
33 | ||
34 | ClassImp(AliPHOSCalibData) | |
35 | ||
36 | //________________________________________________________________ | |
37 | AliPHOSCalibData::AliPHOSCalibData(): | |
38 | TNamed(), | |
39 | fCalibDataEmc(0x0), | |
40 | fCalibDataCpv(0x0), | |
41 | fEmcDataPath("PHOS/Calib/EmcGainPedestals"), | |
42 | fCpvDataPath("PHOS/Calib/CpvGainPedestals") | |
43 | { | |
44 | // Default constructor | |
45 | ||
46 | AliCDBEntry* entryEmc = AliCDBManager::Instance()->Get(fEmcDataPath.Data()); | |
47 | if(entryEmc) | |
48 | fCalibDataEmc = (AliPHOSEmcCalibData*)entryEmc->GetObject(); | |
49 | ||
50 | AliCDBEntry* entryCpv = AliCDBManager::Instance()->Get(fCpvDataPath.Data()); | |
51 | if(entryCpv) | |
52 | fCalibDataCpv = (AliPHOSCpvCalibData*)entryCpv->GetObject(); | |
53 | ||
54 | } | |
55 | ||
56 | //________________________________________________________________ | |
57 | AliPHOSCalibData::AliPHOSCalibData(Int_t runNumber) : | |
58 | TNamed("phosCalib","PHOS Calibration Data Manager"), | |
59 | fCalibDataEmc(0x0), fCalibDataCpv(0x0), | |
60 | fEmcDataPath("PHOS/Calib/EmcGainPedestals"), | |
61 | fCpvDataPath("PHOS/Calib/CpvGainPedestals") | |
62 | { | |
63 | // Constructor | |
64 | AliCDBEntry* entryEmc = AliCDBManager::Instance()->Get(fEmcDataPath.Data(),runNumber); | |
65 | if(entryEmc) | |
66 | fCalibDataEmc = (AliPHOSEmcCalibData*)entryEmc->GetObject(); | |
67 | ||
68 | AliCDBEntry* entryCpv = AliCDBManager::Instance()->Get(fCpvDataPath.Data(),runNumber); | |
69 | if(entryCpv) | |
70 | fCalibDataCpv = (AliPHOSCpvCalibData*)entryCpv->GetObject(); | |
71 | ||
72 | } | |
73 | ||
74 | //________________________________________________________________ | |
75 | AliPHOSCalibData::AliPHOSCalibData(AliPHOSCalibData & phosCDB) : | |
76 | TNamed(phosCDB), | |
77 | fCalibDataEmc(phosCDB.fCalibDataEmc), | |
78 | fCalibDataCpv(phosCDB.fCalibDataCpv), | |
79 | fEmcDataPath(phosCDB.fEmcDataPath), | |
80 | fCpvDataPath(phosCDB.fCpvDataPath) | |
81 | { | |
82 | // Copy constructor | |
83 | } | |
84 | //________________________________________________________________ | |
85 | AliPHOSCalibData::~AliPHOSCalibData() | |
86 | { | |
87 | // Destructor | |
88 | ||
89 | } | |
90 | ||
91 | AliPHOSCalibData & AliPHOSCalibData::operator = (const AliPHOSCalibData & rhs) | |
92 | { | |
93 | //Copy-assignment. Does not delete anything (see destructor) | |
94 | //compiler generated is ok, but ... because -Weffc++ and pointer | |
95 | //members we have to define it explicitly. | |
96 | TNamed::operator=(rhs); | |
97 | fCalibDataEmc = rhs.fCalibDataEmc; | |
98 | fCalibDataCpv = rhs.fCalibDataCpv; | |
99 | fEmcDataPath = rhs.fEmcDataPath; | |
100 | fCpvDataPath = rhs.fCpvDataPath; | |
101 | ||
102 | return *this; | |
103 | } | |
104 | ||
105 | //________________________________________________________________ | |
106 | void AliPHOSCalibData::Reset() | |
107 | { | |
108 | // Set all pedestals to 0 and all ADC channels to 1 | |
109 | ||
110 | fCalibDataEmc->Reset(); | |
111 | fCalibDataCpv->Reset(); | |
112 | } | |
113 | ||
114 | //________________________________________________________________ | |
115 | void AliPHOSCalibData::Print(Option_t *option) const | |
116 | { | |
117 | // Print EMC and CPV calibration containers | |
118 | // Input: option="ped" to print pedestals | |
119 | // option="gain" to print calibration coefficients | |
120 | if (fCalibDataEmc) fCalibDataEmc->Print(option); | |
121 | if (fCalibDataCpv) fCalibDataCpv->Print(option); | |
122 | } | |
123 | ||
124 | //________________________________________________________________ | |
125 | void AliPHOSCalibData::CreateNew() | |
126 | { | |
127 | // Create new EMC and CPV calibration containers with ideal coefficients | |
128 | ||
129 | if(fCalibDataEmc) delete fCalibDataEmc; | |
130 | fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC"); | |
131 | ||
132 | if(fCalibDataCpv) delete fCalibDataCpv; | |
133 | fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV"); | |
134 | ||
135 | } | |
136 | ||
137 | //________________________________________________________________ | |
138 | Bool_t AliPHOSCalibData::WriteEmc(Int_t firstRun, Int_t lastRun, AliCDBMetaData *md) | |
139 | { | |
140 | // Write EMC calibration container to CDB | |
141 | ||
142 | if(!fCalibDataEmc) return kFALSE; | |
143 | ||
144 | AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS/*"); | |
145 | if(!storage) | |
146 | storage = AliCDBManager::Instance()->GetDefaultStorage(); | |
147 | ||
148 | if(storage) { | |
149 | AliCDBId id(fEmcDataPath.Data(),firstRun,lastRun); | |
150 | storage->Put(fCalibDataEmc,id, md); | |
151 | return kTRUE; | |
152 | } | |
153 | else | |
154 | return kFALSE; | |
155 | ||
156 | } | |
157 | ||
158 | //________________________________________________________________ | |
159 | Bool_t AliPHOSCalibData::WriteCpv(Int_t firstRun, Int_t lastRun, AliCDBMetaData *md) | |
160 | { | |
161 | // Write CPV calibration container to CDB | |
162 | ||
163 | if(!fCalibDataCpv) return kFALSE; | |
164 | ||
165 | AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS/*"); | |
166 | if(!storage) | |
167 | storage = AliCDBManager::Instance()->GetDefaultStorage(); | |
168 | ||
169 | if(storage) { | |
170 | AliCDBId id(fCpvDataPath.Data(),firstRun,lastRun); | |
171 | storage->Put(fCalibDataCpv,id, md); | |
172 | return kTRUE; | |
173 | } | |
174 | else | |
175 | return kFALSE; | |
176 | ||
177 | } | |
178 | ||
179 | //________________________________________________________________ | |
180 | Float_t AliPHOSCalibData::GetADCchannelEmc(Int_t module, Int_t column, Int_t row) const | |
181 | { | |
182 | // Return EMC calibration coefficient | |
183 | // for channel defined by (module,column,row) | |
184 | // module, column,raw should follow the internal PHOS convention: | |
185 | // module 1:5, column 1:56, row 1:64 | |
186 | // if CBD instance exists, the value is taken from CDB. | |
187 | // Otherwise it is an ideal one | |
188 | ||
189 | if(fCalibDataEmc) | |
190 | return fCalibDataEmc->GetADCchannelEmc(module,column,row); | |
191 | else | |
192 | return 1.0; // default width of one EMC ADC channel in GeV | |
193 | } | |
194 | ||
195 | //________________________________________________________________ | |
196 | Float_t AliPHOSCalibData::GetADCpedestalEmc(Int_t module, Int_t column, Int_t row) const | |
197 | { | |
198 | // Return EMC pedestal for channel defined by (module,column,row) | |
199 | // module, column,raw should follow the internal PHOS convention: | |
200 | // module 1:5, column 1:56, row 1:64 | |
201 | // if CBD instance exists, the value is taken from CDB. | |
202 | // Otherwise it is an ideal one | |
203 | ||
204 | if(fCalibDataEmc) | |
205 | return fCalibDataEmc->GetADCpedestalEmc(module,column,row); | |
206 | else | |
207 | return 0.0; // default EMC ADC pedestal | |
208 | } | |
209 | ||
210 | //________________________________________________________________ | |
211 | void AliPHOSCalibData::SetADCchannelEmc(Int_t module, Int_t column, Int_t row, Float_t value) | |
212 | { | |
213 | // Set EMC calibration coefficient for (module,column,row) | |
214 | ||
215 | if(!fCalibDataEmc) | |
216 | fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC"); | |
217 | ||
218 | fCalibDataEmc->SetADCchannelEmc(module,column,row,value); | |
219 | } | |
220 | ||
221 | //________________________________________________________________ | |
222 | void AliPHOSCalibData::SetADCpedestalEmc(Int_t module, Int_t column, Int_t row, Float_t value) | |
223 | { | |
224 | // Set EMC pedestal for (module,column,row) | |
225 | ||
226 | if(!fCalibDataEmc) | |
227 | fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC"); | |
228 | ||
229 | fCalibDataEmc->SetADCpedestalEmc(module,column,row,value); | |
230 | } | |
231 | ||
232 | //________________________________________________________________ | |
233 | Float_t AliPHOSCalibData::GetADCchannelCpv(Int_t module, Int_t column, Int_t row) const | |
234 | { | |
235 | // Return CPV calibration coefficient | |
236 | // for channel defined by (module,column,row) | |
237 | // module, column,raw should follow the internal CPV convention: | |
238 | // module 1:5, column 1:56, row 1:128 | |
239 | // if CBD instance exists, the value is taken from CDB. | |
240 | // Otherwise it is an ideal one | |
241 | ||
242 | if(fCalibDataCpv) | |
243 | return fCalibDataCpv->GetADCchannelCpv(module,column,row); | |
244 | else | |
245 | return 0.0012; // default width of one ADC channel in CPV arbitrary units | |
246 | } | |
247 | ||
248 | //________________________________________________________________ | |
249 | Float_t AliPHOSCalibData::GetADCpedestalCpv(Int_t module, Int_t column, Int_t row) const | |
250 | { | |
251 | // Return CPV pedestal | |
252 | // for channel defined by (module,column,row) | |
253 | // module, column,raw should follow the internal CPV convention: | |
254 | // module 1:5, column 1:56, row 1:128 | |
255 | // if CBD instance exists, the value is taken from CDB. | |
256 | // Otherwise it is an ideal one | |
257 | ||
258 | if(fCalibDataCpv) | |
259 | return fCalibDataCpv->GetADCpedestalCpv(module,column,row); | |
260 | else | |
261 | return 0.012; // default CPV ADC pedestal | |
262 | } | |
263 | ||
264 | //________________________________________________________________ | |
265 | void AliPHOSCalibData::SetADCchannelCpv(Int_t module, Int_t column, Int_t row, Float_t value) | |
266 | { | |
267 | // Set CPV calibration coefficient for (module,column,row) | |
268 | ||
269 | if(!fCalibDataCpv) | |
270 | fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV"); | |
271 | ||
272 | fCalibDataCpv->SetADCchannelCpv(module,column,row,value); | |
273 | } | |
274 | ||
275 | //________________________________________________________________ | |
276 | void AliPHOSCalibData::SetADCpedestalCpv(Int_t module, Int_t column, Int_t row, Float_t value) | |
277 | { | |
278 | // Set CPV pedestal for (module,column,row) | |
279 | ||
280 | if(!fCalibDataCpv) | |
281 | fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV"); | |
282 | ||
283 | fCalibDataCpv->SetADCpedestalCpv(module,column,row,value); | |
284 | } | |
285 | ||
286 | //________________________________________________________________ | |
287 | void AliPHOSCalibData::RandomEmc(Float_t ccMin, Float_t ccMax) | |
288 | { | |
289 | // Create decalibrated EMC with calibration coefficients and pedestals | |
290 | // randomly distributed within hard-coded limits | |
291 | // Default spread of calibration parameters is Cmax/Cmin = 4, (Cmax-Cmin)/2 = 1 | |
292 | ||
293 | if(fCalibDataEmc) delete fCalibDataEmc; | |
294 | fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC"); | |
295 | ||
296 | TRandom rn; | |
297 | rn.SetSeed(0); //the seed is set to the current machine clock | |
298 | ||
299 | Float_t adcChannelEmc,adcPedestalEmc; | |
300 | ||
301 | for(Int_t module=1; module<6; module++) { | |
302 | for(Int_t column=1; column<57; column++) { | |
303 | for(Int_t row=1; row<65; row++) { | |
304 | adcChannelEmc =rn.Uniform(ccMin,ccMax); | |
305 | adcPedestalEmc=rn.Uniform(0.0,0.0); // 0 spread of pedestals | |
306 | fCalibDataEmc->SetADCchannelEmc(module,column,row,adcChannelEmc); | |
307 | fCalibDataEmc->SetADCpedestalEmc(module,column,row,adcPedestalEmc); | |
308 | } | |
309 | } | |
310 | } | |
311 | ||
312 | } | |
313 | ||
314 | //________________________________________________________________ | |
315 | void AliPHOSCalibData::RandomCpv(Float_t ccMin, Float_t ccMax) | |
316 | { | |
317 | // Create decalibrated CPV with calibration coefficients and pedestals | |
318 | // randomly distributed within hard-coded limits | |
319 | // Default spread of calibration parameters is 0.0012 +- 25% | |
320 | ||
321 | if(fCalibDataCpv) delete fCalibDataCpv; | |
322 | fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV"); | |
323 | ||
324 | TRandom rn; | |
325 | rn.SetSeed(0); //the seed is set to the current machine clock | |
326 | ||
327 | Float_t adcChannelCpv,adcPedestalCpv; | |
328 | ||
329 | for(Int_t module=1; module<6; module++) { | |
330 | for(Int_t column=1; column<57; column++) { | |
331 | for(Int_t row=1; row<129; row++) { | |
332 | adcChannelCpv =rn.Uniform(ccMin,ccMax); | |
333 | adcPedestalCpv=rn.Uniform(0.0048,0.0192); // Ped[max]/Ped[min] = 4, <Ped> = 0.012 | |
334 | fCalibDataCpv->SetADCchannelCpv(module,column,row,adcChannelCpv); | |
335 | fCalibDataCpv->SetADCpedestalCpv(module,column,row,adcPedestalCpv); | |
336 | } | |
337 | } | |
338 | } | |
339 | } |