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