Line data Source code
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 "AliLog.h"
26 : #include "AliPHOSCalibData.h"
27 : #include "AliCDBManager.h"
28 : #include "AliCDBStorage.h"
29 : #include "AliCDBId.h"
30 : #include "AliCDBEntry.h"
31 : #include "AliPHOSEmcCalibData.h"
32 : #include "AliPHOSCpvCalibData.h"
33 : #include "AliPHOSEmcBadChannelsMap.h"
34 : #include "AliPHOSCpvBadChannelsMap.h"
35 : #include "AliCDBMetaData.h"
36 :
37 22 : ClassImp(AliPHOSCalibData)
38 :
39 : //________________________________________________________________
40 : AliPHOSCalibData::AliPHOSCalibData():
41 0 : TNamed(),
42 0 : fCalibDataEmc(0x0),
43 0 : fCalibDataCpv(0x0),
44 0 : fEmcBadChannelsMap(0x0),
45 0 : fCpvBadChannelsMap(0x0),
46 0 : fEmcDataPath("PHOS/Calib/EmcGainPedestals"),
47 0 : fCpvDataPath("PHOS/Calib/CpvGainPedestals"),
48 0 : fEmcBadChannelsMapPath("PHOS/Calib/EmcBadChannels"),
49 0 : fCpvBadChannelsMapPath("PHOS/Calib/CpvBadChannels")
50 0 : {
51 : // Default constructor.
52 : // Open CDB entry, get EMC and CPV calibration data and bad channel map.
53 : // If EMC or CPV calibration data does not exist, stop the run
54 :
55 0 : }
56 :
57 : //________________________________________________________________
58 : AliPHOSCalibData::AliPHOSCalibData(Int_t runNumber) :
59 7 : TNamed("phosCalib","PHOS Calibration Data Manager"),
60 7 : fCalibDataEmc(0x0),
61 7 : fCalibDataCpv(0x0),
62 7 : fEmcBadChannelsMap(0x0),
63 7 : fCpvBadChannelsMap(0x0),
64 7 : fEmcDataPath("PHOS/Calib/EmcGainPedestals"),
65 7 : fCpvDataPath("PHOS/Calib/CpvGainPedestals"),
66 7 : fEmcBadChannelsMapPath("PHOS/Calib/EmcBadChannels"),
67 7 : fCpvBadChannelsMapPath("PHOS/Calib/CpvBadChannels")
68 35 : {
69 : // Constructor
70 : // Open CDB entry, get EMC and CPV calibration data and bad channel map.
71 : // If EMC or CPV calibration data does not exist, stop the run
72 :
73 35 : AliCDBEntry* entryEmc = AliCDBManager::Instance()->Get(fEmcDataPath.Data(),runNumber);
74 7 : if(entryEmc)
75 7 : fCalibDataEmc = (AliPHOSEmcCalibData*)entryEmc->GetObject();
76 :
77 7 : if(!fCalibDataEmc)
78 0 : AliFatal("Calibration parameters for PHOS EMC not found. Stop reconstruction!\n");
79 :
80 35 : AliCDBEntry* entryCpv = AliCDBManager::Instance()->Get(fCpvDataPath.Data(),runNumber);
81 7 : if(entryCpv)
82 7 : fCalibDataCpv = (AliPHOSCpvCalibData*)entryCpv->GetObject();
83 :
84 7 : if(!fCalibDataCpv)
85 0 : AliFatal("Calibration parameters for PHOS CPV not found. Stop reconstruction!\n");
86 :
87 21 : AliCDBEntry* entryEmcBadMap = AliCDBManager::Instance()->
88 14 : Get(fEmcBadChannelsMapPath.Data(),runNumber);
89 7 : if(entryEmcBadMap)
90 7 : fEmcBadChannelsMap = (AliPHOSEmcBadChannelsMap*)entryEmcBadMap->GetObject();
91 :
92 21 : AliCDBEntry* entryCpvBadMap = AliCDBManager::Instance()->
93 14 : Get(fCpvBadChannelsMapPath.Data(),runNumber);
94 7 : if(entryCpvBadMap)
95 7 : fCpvBadChannelsMap = (AliPHOSCpvBadChannelsMap*)entryCpvBadMap->GetObject();
96 :
97 14 : }
98 :
99 : //________________________________________________________________
100 : AliPHOSCalibData::AliPHOSCalibData(AliPHOSCalibData & phosCDB) :
101 0 : TNamed(phosCDB),
102 0 : fCalibDataEmc(phosCDB.fCalibDataEmc),
103 0 : fCalibDataCpv(phosCDB.fCalibDataCpv),
104 0 : fEmcBadChannelsMap(phosCDB.fEmcBadChannelsMap),
105 0 : fCpvBadChannelsMap(phosCDB.fCpvBadChannelsMap),
106 0 : fEmcDataPath(phosCDB.fEmcDataPath),
107 0 : fCpvDataPath(phosCDB.fCpvDataPath),
108 0 : fEmcBadChannelsMapPath(phosCDB.fEmcBadChannelsMapPath),
109 0 : fCpvBadChannelsMapPath(phosCDB.fCpvBadChannelsMapPath)
110 0 : {
111 : // Copy constructor
112 0 : }
113 : //________________________________________________________________
114 : AliPHOSCalibData::~AliPHOSCalibData()
115 12 : {
116 : // Destructor
117 :
118 6 : }
119 :
120 : //________________________________________________________________
121 : AliPHOSCalibData & AliPHOSCalibData::operator = (const AliPHOSCalibData & rhs)
122 : {
123 : //Copy-assignment. Does not delete anything (see destructor)
124 : //compiler generated is ok, but ... because -Weffc++ and pointer
125 : //members we have to define it explicitly.
126 0 : TNamed::operator=(rhs);
127 0 : if (this != &rhs) {
128 0 : fCalibDataEmc = rhs.fCalibDataEmc;
129 0 : fCalibDataCpv = rhs.fCalibDataCpv;
130 0 : fEmcBadChannelsMap = rhs.fEmcBadChannelsMap;
131 0 : fCpvBadChannelsMap = rhs.fCpvBadChannelsMap;
132 0 : fEmcDataPath = rhs.fEmcDataPath;
133 0 : fCpvDataPath = rhs.fCpvDataPath;
134 0 : fEmcBadChannelsMapPath = rhs.fEmcBadChannelsMapPath;
135 0 : fCpvBadChannelsMapPath = rhs.fCpvBadChannelsMapPath;
136 0 : }
137 : else {
138 0 : AliFatal("Self assignment!");
139 : }
140 0 : return *this;
141 : }
142 :
143 : //________________________________________________________________
144 : void AliPHOSCalibData::Reset()
145 : {
146 : // Set all pedestals to 0 and all ADC channels to 1,
147 : // and all channels are good (alive)
148 :
149 0 : fCalibDataEmc ->Reset();
150 0 : fCalibDataCpv ->Reset();
151 0 : fEmcBadChannelsMap->Reset();
152 0 : fCpvBadChannelsMap->Reset();
153 0 : }
154 :
155 : //________________________________________________________________
156 : void AliPHOSCalibData::Print(Option_t *option) const
157 : {
158 : // Print EMC and CPV calibration containers
159 : // Input: option="ped" to print pedestals
160 : // option="gain" to print calibration coefficients
161 0 : if (fCalibDataEmc) fCalibDataEmc->Print(option);
162 0 : if (fCalibDataCpv) fCalibDataCpv->Print(option);
163 0 : }
164 :
165 : //________________________________________________________________
166 : void AliPHOSCalibData::CreateNew()
167 : {
168 : // Create new EMC and CPV calibration containers with ideal coefficients
169 :
170 0 : if(fCalibDataEmc) delete fCalibDataEmc;
171 0 : fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
172 :
173 0 : if(fCalibDataCpv) delete fCalibDataCpv;
174 0 : fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV");
175 :
176 0 : if(fEmcBadChannelsMap) delete fEmcBadChannelsMap;
177 0 : fEmcBadChannelsMap = new AliPHOSEmcBadChannelsMap();
178 :
179 0 : if(fCpvBadChannelsMap) delete fCpvBadChannelsMap;
180 0 : fCpvBadChannelsMap = new AliPHOSCpvBadChannelsMap();
181 :
182 :
183 0 : }
184 :
185 : //________________________________________________________________
186 : Bool_t AliPHOSCalibData::WriteEmc(Int_t firstRun, Int_t lastRun, AliCDBMetaData *md)
187 : {
188 : // Write EMC calibration container to CDB
189 :
190 0 : if(!fCalibDataEmc) return kFALSE;
191 :
192 0 : AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS/*");
193 0 : if(!storage)
194 0 : storage = AliCDBManager::Instance()->GetDefaultStorage();
195 :
196 0 : if(storage) {
197 0 : AliCDBId id(fEmcDataPath.Data(),firstRun,lastRun);
198 0 : storage->Put(fCalibDataEmc,id, md);
199 : return kTRUE;
200 0 : }
201 : else
202 0 : return kFALSE;
203 :
204 0 : }
205 :
206 : //________________________________________________________________
207 : Bool_t AliPHOSCalibData::WriteCpv(Int_t firstRun, Int_t lastRun, AliCDBMetaData *md)
208 : {
209 : // Write CPV calibration container to CDB
210 :
211 0 : if(!fCalibDataCpv) return kFALSE;
212 :
213 0 : AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS/*");
214 0 : if(!storage)
215 0 : storage = AliCDBManager::Instance()->GetDefaultStorage();
216 :
217 0 : if(storage) {
218 0 : AliCDBId id(fCpvDataPath.Data(),firstRun,lastRun);
219 0 : storage->Put(fCalibDataCpv,id, md);
220 : return kTRUE;
221 0 : }
222 : else
223 0 : return kFALSE;
224 :
225 0 : }
226 :
227 :
228 : //________________________________________________________________
229 : Bool_t AliPHOSCalibData::WriteEmcBadChannelsMap(Int_t firstRun,Int_t lastRun,AliCDBMetaData *md)
230 : {
231 : //Write EMC bad channels map into CDB.
232 :
233 0 : if(!fEmcBadChannelsMap) return kFALSE;
234 :
235 0 : AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS/*");
236 0 : if(!storage)
237 0 : storage = AliCDBManager::Instance()->GetDefaultStorage();
238 :
239 0 : if(storage) {
240 0 : AliCDBId id(fEmcBadChannelsMapPath.Data(),firstRun,lastRun);
241 0 : storage->Put(fEmcBadChannelsMap,id, md);
242 : return kTRUE;
243 0 : }
244 : else
245 0 : return kFALSE;
246 0 : }
247 :
248 : //________________________________________________________________
249 : Bool_t AliPHOSCalibData::WriteCpvBadChannelsMap(Int_t firstRun,Int_t lastRun,AliCDBMetaData *md)
250 : {
251 : //Write CPV bad channels map into CDB.
252 :
253 0 : if(!fCpvBadChannelsMap) return kFALSE;
254 :
255 0 : AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS/*");
256 0 : if(!storage)
257 0 : storage = AliCDBManager::Instance()->GetDefaultStorage();
258 :
259 0 : if(storage) {
260 0 : AliCDBId id(fCpvBadChannelsMapPath.Data(),firstRun,lastRun);
261 0 : storage->Put(fCpvBadChannelsMap,id, md);
262 : return kTRUE;
263 0 : }
264 : else
265 0 : return kFALSE;
266 0 : }
267 :
268 : //________________________________________________________________
269 : Float_t AliPHOSCalibData::GetADCchannelEmc(Int_t module, Int_t column, Int_t row) const
270 : {
271 : // Return EMC calibration coefficient
272 : // for channel defined by (module,column,row)
273 : // module, column,raw should follow the internal PHOS convention:
274 : // module 1:5, column 1:56, row 1:64
275 : // if CBD instance exists, the value is taken from CDB.
276 : // Otherwise it is an ideal one
277 :
278 88080 : if(fCalibDataEmc)
279 44040 : return fCalibDataEmc->GetADCchannelEmc(module,column,row);
280 : else
281 0 : return 1.0; // default width of one EMC ADC channel in GeV
282 44040 : }
283 :
284 : //________________________________________________________________
285 : void AliPHOSCalibData::SetADCchannelEmc(Int_t module, Int_t column, Int_t row, Float_t value)
286 : {
287 : // Set EMC calibration coefficient for (module,column,row)
288 :
289 0 : if(!fCalibDataEmc)
290 0 : fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
291 :
292 0 : fCalibDataEmc->SetADCchannelEmc(module,column,row,value);
293 0 : }
294 :
295 : //________________________________________________________________
296 : Float_t AliPHOSCalibData::GetADCpedestalEmc(Int_t module, Int_t column, Int_t row) const
297 : {
298 : // Return EMC pedestal for channel defined by (module,column,row)
299 : // module, column,raw should follow the internal PHOS convention:
300 : // module 1:5, column 1:56, row 1:64
301 : // if CBD instance exists, the value is taken from CDB.
302 : // Otherwise it is an ideal one
303 :
304 308 : if(fCalibDataEmc)
305 154 : return fCalibDataEmc->GetADCpedestalEmc(module,column,row);
306 : else
307 0 : return 0.0; // default EMC ADC pedestal
308 154 : }
309 :
310 : //________________________________________________________________
311 : void AliPHOSCalibData::SetADCpedestalEmc(Int_t module, Int_t column, Int_t row, Float_t value)
312 : {
313 : // Set EMC pedestal for (module,column,row)
314 :
315 0 : if(!fCalibDataEmc)
316 0 : fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
317 :
318 0 : fCalibDataEmc->SetADCpedestalEmc(module,column,row,value);
319 0 : }
320 :
321 : //________________________________________________________________
322 : Float_t AliPHOSCalibData::GetHighLowRatioEmc(Int_t module, Int_t column, Int_t row) const
323 : {
324 : // Return EMC calibration coefficient
325 : // for channel defined by (module,column,row)
326 : // module, column,raw should follow the internal PHOS convention:
327 : // module 1:5, column 1:56, row 1:64
328 : // if CBD instance exists, the value is taken from CDB.
329 : // Otherwise it is an ideal one
330 :
331 254 : if(fCalibDataEmc)
332 127 : return fCalibDataEmc->GetHighLowRatioEmc(module,column,row);
333 : else
334 0 : return 1.0; // default width of one EMC ADC channel in GeV
335 127 : }
336 :
337 : //________________________________________________________________
338 : void AliPHOSCalibData::SetHighLowRatioEmc(Int_t module, Int_t column, Int_t row, Float_t value)
339 : {
340 : // Set EMC calibration coefficient for (module,column,row)
341 :
342 0 : if(!fCalibDataEmc)
343 0 : fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
344 :
345 0 : fCalibDataEmc->SetHighLowRatioEmc(module,column,row,value);
346 0 : }
347 :
348 : //________________________________________________________________
349 : Float_t AliPHOSCalibData::GetTimeShiftEmc(Int_t module, Int_t column, Int_t row) const
350 : {
351 : // Return EMC calibration coefficient
352 : // for channel defined by (module,column,row)
353 : // module, column,raw should follow the internal PHOS convention:
354 : // module 1:5, column 1:56, row 1:64
355 : // if CBD instance exists, the value is taken from CDB.
356 : // Otherwise it is an ideal one
357 :
358 86740 : if(fCalibDataEmc)
359 43370 : return fCalibDataEmc->GetTimeShiftEmc(module,column,row);
360 : else
361 0 : return 0.0; // by default no offset
362 43370 : }
363 : //________________________________________________________________
364 : Float_t AliPHOSCalibData::GetLGTimeShiftEmc(Int_t module, Int_t column, Int_t row) const
365 : {
366 : // Return EMC calibration coefficient
367 : // for channel defined by (module,column,row)
368 : // module, column,raw should follow the internal PHOS convention:
369 : // module 1:5, column 1:56, row 1:64
370 : // if CBD instance exists, the value is taken from CDB.
371 : // Otherwise it is an ideal one
372 :
373 40 : if(fCalibDataEmc)
374 20 : return fCalibDataEmc->GetLGTimeShiftEmc(module,column,row);
375 : else
376 0 : return 0.0; // no offset by default
377 20 : }
378 :
379 : //________________________________________________________________
380 : void AliPHOSCalibData::SetLGTimeShiftEmc(Int_t module, Int_t column, Int_t row, Float_t value)
381 : {
382 : // Set EMC calibration coefficient for (module,column,row)
383 :
384 0 : if(!fCalibDataEmc)
385 0 : fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
386 :
387 0 : fCalibDataEmc->SetLGTimeShiftEmc(module,column,row,value);
388 0 : }
389 : //________________________________________________________________
390 : void AliPHOSCalibData::SetTimeShiftEmc(Int_t module, Int_t column, Int_t row, Float_t value)
391 : {
392 : // Set EMC calibration coefficient for (module,column,row)
393 :
394 0 : if(!fCalibDataEmc)
395 0 : fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
396 :
397 0 : fCalibDataEmc->SetTimeShiftEmc(module,column,row,value);
398 0 : }
399 : //________________________________________________________________
400 : Float_t AliPHOSCalibData::GetSampleTimeStep() const
401 : {
402 : //Get conversion coeff. from sample time step to seconds.
403 : //Negative value means that it is not used in reconstruction
404 : //but only in simulation of raw.
405 24 : if(fCalibDataEmc)
406 12 : return fCalibDataEmc->GetSampleTimeStep();
407 : else
408 0 : return 0.0; // default width of one EMC ADC channel in GeV
409 12 : }
410 : //________________________________________________________________
411 : void AliPHOSCalibData::SetSampleTimeStep(Float_t step)
412 : {
413 : //Set conversion coeff. from sample time step to seconds.
414 : //Negative value means that it is not used in reconstruction
415 : //but only in simulation of raw.
416 0 : if(!fCalibDataEmc)
417 0 : fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
418 :
419 0 : fCalibDataEmc->SetSampleTimeStep(step) ;
420 0 : }
421 : //________________________________________________________________
422 : Int_t AliPHOSCalibData::GetAltroOffsetEmc(Int_t module, Int_t column, Int_t row) const
423 : {
424 : // Return ALTRO pedestal coefficient
425 : // for channel defined by (module,column,row)
426 : // module, column,raw should follow the internal PHOS convention:
427 : // module 1:5, column 1:56, row 1:64
428 : // if CBD instance exists, the value is taken from CDB.
429 : // Otherwise it is an ideal one
430 :
431 308 : if(fCalibDataEmc)
432 154 : return fCalibDataEmc->GetAltroOffsetEmc(module,column,row);
433 : else
434 0 : return 0; // default width of one EMC ADC channel in GeV
435 154 : }
436 :
437 : //________________________________________________________________
438 : void AliPHOSCalibData::SetAltroOffsetEmc(Int_t module, Int_t column, Int_t row, Int_t value)
439 : {
440 : // Set altro offset for (module,column,row)
441 :
442 0 : if(!fCalibDataEmc)
443 0 : fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
444 :
445 0 : fCalibDataEmc->SetAltroOffsetEmc(module,column,row,value);
446 0 : }
447 :
448 :
449 : //________________________________________________________________
450 : Float_t AliPHOSCalibData::GetADCchannelCpv(Int_t module, Int_t column, Int_t row) const
451 : {
452 : // Return CPV calibration coefficient
453 : // for channel defined by (module,column,row)
454 : // module, column,raw should follow the internal CPV convention:
455 : // module 1:5, column 1:128, row 1:60
456 : // if CBD instance exists, the value is taken from CDB.
457 : // Otherwise it is an ideal one
458 :
459 0 : if(fCalibDataCpv)
460 0 : return fCalibDataCpv->GetADCchannelCpv(module,column,row);
461 : else
462 0 : return 1.; // default width of one ADC channel in CPV arbitrary units
463 0 : }
464 :
465 : //________________________________________________________________
466 : Float_t AliPHOSCalibData::GetADCpedestalCpv(Int_t module, Int_t column, Int_t row) const
467 : {
468 : // Return CPV pedestal
469 : // for channel defined by (module,column,row)
470 : // module, column,raw should follow the internal CPV convention:
471 : // module 1:5, column 1:128, row 1:60
472 : // if CBD instance exists, the value is taken from CDB.
473 : // Otherwise it is an ideal one
474 :
475 0 : if(fCalibDataCpv)
476 0 : return fCalibDataCpv->GetADCpedestalCpv(module,column,row);
477 : else
478 0 : return 0.; // default CPV ADC pedestal
479 0 : }
480 :
481 : //________________________________________________________________
482 : void AliPHOSCalibData::SetADCchannelCpv(Int_t module, Int_t column, Int_t row, Float_t value)
483 : {
484 : // Set CPV calibration coefficient for (module,column,row)
485 :
486 0 : if(!fCalibDataCpv)
487 0 : fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV");
488 :
489 0 : fCalibDataCpv->SetADCchannelCpv(module,column,row,value);
490 0 : }
491 :
492 : //________________________________________________________________
493 : void AliPHOSCalibData::SetADCpedestalCpv(Int_t module, Int_t column, Int_t row, Float_t value)
494 : {
495 : // Set CPV pedestal for (module,column,row)
496 :
497 0 : if(!fCalibDataCpv)
498 0 : fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV");
499 :
500 0 : fCalibDataCpv->SetADCpedestalCpv(module,column,row,value);
501 0 : }
502 :
503 : //________________________________________________________________
504 : void AliPHOSCalibData::RandomEmc(Float_t ccMin, Float_t ccMax)
505 : {
506 : // Create decalibrated EMC with calibration coefficients and pedestals
507 : // randomly distributed within hard-coded limits
508 : // Default spread of calibration parameters is Cmax/Cmin = 4, (Cmax-Cmin)/2 = 1
509 :
510 0 : if(fCalibDataEmc) delete fCalibDataEmc;
511 0 : fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
512 :
513 0 : TRandom rn;
514 0 : rn.SetSeed(0); //the seed is set to the current machine clock
515 :
516 : Float_t adcChannelEmc,adcPedestalEmc;
517 :
518 0 : for(Int_t module=1; module<6; module++) {
519 0 : for(Int_t column=1; column<57; column++) {
520 0 : for(Int_t row=1; row<65; row++) {
521 0 : adcChannelEmc =rn.Uniform(ccMin,ccMax);
522 0 : adcPedestalEmc=rn.Uniform(0.0,0.0); // 0 spread of pedestals
523 0 : fCalibDataEmc->SetADCchannelEmc(module,column,row,adcChannelEmc);
524 0 : fCalibDataEmc->SetADCpedestalEmc(module,column,row,adcPedestalEmc);
525 : }
526 : }
527 : }
528 :
529 0 : }
530 :
531 : //________________________________________________________________
532 : void AliPHOSCalibData::RandomCpv(Float_t ccMin, Float_t ccMax)
533 : {
534 : // Create decalibrated CPV with calibration coefficients and pedestals
535 : // randomly distributed within hard-coded limits
536 : // Default spread of calibration parameters is 1. +- 50%
537 :
538 0 : if(fCalibDataCpv) delete fCalibDataCpv;
539 0 : fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV");
540 :
541 0 : TRandom rn;
542 0 : rn.SetSeed(0); //the seed is set to the current machine clock
543 :
544 : Float_t adcChannelCpv,adcPedestalCpv;
545 :
546 0 : for(Int_t module=1; module<=AliPHOSCpvParam::kNModules; module++) {
547 0 : for(Int_t column=1; column<=AliPHOSCpvParam::kPadPcX; column++) {
548 0 : for(Int_t row=1; row<=AliPHOSCpvParam::kPadPcY; row++) {
549 0 : adcChannelCpv =rn.Uniform(ccMin,ccMax);
550 0 : adcPedestalCpv=rn.Uniform(25.,400.); // Ped[max]/Ped[min] = 4, <Ped> = 100
551 0 : fCalibDataCpv->SetADCchannelCpv(module,column,row,adcChannelCpv);
552 0 : fCalibDataCpv->SetADCpedestalCpv(module,column,row,adcPedestalCpv);
553 : }
554 : }
555 : }
556 0 : }
557 : //________________________________________________________________
558 : Bool_t AliPHOSCalibData::IsBadChannelEmc(Int_t module, Int_t col, Int_t row) const
559 : {
560 : //If no bad channels map found, channel considered good
561 :
562 86016 : if(fEmcBadChannelsMap)
563 43008 : return fEmcBadChannelsMap->IsBadChannel(module,col,row);
564 : else
565 0 : return kFALSE;
566 43008 : }
567 : //________________________________________________________________
568 : Bool_t AliPHOSCalibData::IsBadChannelCpv(Int_t module, Int_t col, Int_t row) const
569 : {
570 : //If no bad channels map found, channel considered good
571 :
572 0 : if(fCpvBadChannelsMap)
573 0 : return fCpvBadChannelsMap->IsBadChannel(module,col,row);
574 : else
575 0 : return kFALSE;
576 0 : }
577 :
578 : //________________________________________________________________
579 : Int_t AliPHOSCalibData::GetNumOfEmcBadChannels() const
580 : {
581 28 : if(fEmcBadChannelsMap)
582 14 : return fEmcBadChannelsMap->GetNumOfBadChannels();
583 : else
584 0 : return 0;
585 14 : }
586 : //________________________________________________________________
587 : Int_t AliPHOSCalibData::GetNumOfCpvBadChannels() const
588 : {
589 0 : if(fCpvBadChannelsMap)
590 0 : return fCpvBadChannelsMap->GetNumOfBadChannels();
591 : else
592 0 : return 0;
593 0 : }
594 :
595 : //________________________________________________________________
596 : void AliPHOSCalibData::EmcBadChannelIds(Int_t *badIds)
597 : {
598 : //Fill array badIds by the Ids of EMC bad channels.
599 : //Array badIds of length GetNumOfBadChannels() should be prepared in advance.
600 :
601 0 : if(fEmcBadChannelsMap)
602 0 : fEmcBadChannelsMap->BadChannelIds(badIds);
603 0 : }
604 : //________________________________________________________________
605 : void AliPHOSCalibData::CpvBadChannelIds(Int_t *badIds)
606 : {
607 : //Fill array badIds by the Ids of EMC bad channels.
608 : //Array badIds of length GetNumOfBadChannels() should be prepared in advance.
609 :
610 0 : if(fCpvBadChannelsMap)
611 0 : fCpvBadChannelsMap->BadChannelIds(badIds);
612 0 : }
613 :
614 : //________________________________________________________________
615 : Float_t AliPHOSCalibData::GetADCchannelEmcDecalib(Int_t module, Int_t column, Int_t row) const
616 : {
617 : // Return random EMC (de)calibration factor O(1) for channel defined by (module,column,row).
618 : // Used in simulation.
619 :
620 : // module, column,raw should follow the internal PHOS convention:
621 : // module 1:5, column 1:56, row 1:64
622 : // if CBD instance exists, the value is taken from CDB.
623 : // Otherwise it is an ideal one (no decalibration).
624 :
625 86016 : if(fCalibDataEmc)
626 43008 : return fCalibDataEmc->GetADCchannelEmcDecalib(module,column,row);
627 : else
628 0 : return 1.0; // no decalibration by default
629 43008 : }
630 :
631 : //________________________________________________________________
632 : void AliPHOSCalibData::SetADCchannelEmcDecalib(Int_t module, Int_t column, Int_t row, Float_t value)
633 : {
634 : // Set EMC (de)calibration factor for (module,column,row).
635 : // Used in simulation.
636 :
637 0 : if(!fCalibDataEmc)
638 0 : fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
639 :
640 0 : fCalibDataEmc->SetADCchannelEmcDecalib(module,column,row,value);
641 0 : }
|