1 //////////////////////////////////////////////////////////////////////////
3 // Example of usage: //
5 // 2. Randomly store 1% dead pixels all over the SPD //
6 // 3. Print the number of dead pixels temporarily generated //
7 // 4. Store the dead pixels in calibration objects for runNrs 1 to 10 //
9 // root [0] .L AliITSStoreDeadSPD.C //
10 // root [1] SetSeed(11) //
11 // root [2] RandomizeDeadPixelsFrac(0.01) //
12 // root [3] PrintNrDead() //
13 // root [4] StoreCalib(1,10) //
15 //////////////////////////////////////////////////////////////////////////
17 AliITSOnlineCalibrationSPDhandler* handler = NULL;
18 TRandom* rnd = new TRandom();
20 void StoreCalib(Int_t RunNrStart=0, Int_t RunNrEnd=9999999) {
22 handler->WriteToDB(RunNrStart,RunNrEnd);
26 void ReadCalib(UInt_t runNr) {
27 if (handler==NULL) handler = new AliITSOnlineCalibrationSPDhandler();
29 handler->ReadFromDB(runNr);
32 void SetSeed(UInt_t seed) {
38 printf("Nr of dead pixels: %d\n",handler->GetNrDead());
54 void RandomizeDeadPixelsFrac(Double_t fraction) {
55 if (fraction>0 && fraction<=1) {
56 UInt_t nrdeadpixels = static_cast<UInt_t>(fraction*256*160*240 + 0.5);
57 RandomizeDeadPixels(nrdeadpixels);
60 void RandomizeDeadPixels(UInt_t nrDead) {
61 if (handler==NULL) handler = new AliITSOnlineCalibrationSPDhandler();
62 UInt_t nrDeadInserted = 0;
63 while (nrDeadInserted<nrDead) {
64 UInt_t mod = (UInt_t)(rnd->Rndm()*240);
65 UInt_t col = (UInt_t)(rnd->Rndm()*160);
66 UInt_t row = (UInt_t)(rnd->Rndm()*256);
67 if (handler->SetDeadPixelM(mod,col,row)) nrDeadInserted++;
71 void RandomizeDeadPixelsFrac(Double_t fraction, UInt_t layer) {
72 if (fraction>0 && fraction<=1) {
77 nr_pixels = 256*160*80;
78 nrdeadpixels = static_cast<UInt_t>(fraction*nr_pixels + 0.5);
79 RandomizeDeadPixels(nrdeadpixels,layer);
82 nr_pixels = 256*160*160;
83 nrdeadpixels = static_cast<Int_t>(fraction*nr_pixels + 0.5);
84 RandomizeDeadPixels(nrdeadpixels,layer);
91 void RandomizeDeadPixels(UInt_t nrDead, UInt_t layer) {
92 if (handler==NULL) handler = new AliITSOnlineCalibrationSPDhandler();
107 UInt_t nrDeadInserted = 0;
108 while (nrDeadInserted<nrDead) {
109 UInt_t mod = (UInt_t)(rnd->Rndm()*nr_modules) + mod_offset;
110 UInt_t col = (UInt_t)(rnd->Rndm()*160);
111 UInt_t row = (UInt_t)(rnd->Rndm()*256);
112 if (handler->SetDeadPixelM(mod,col,row)) nrDeadInserted++;
116 void RandomizeDeadChipsFrac(Double_t fraction) {
117 if (fraction>0 && fraction<=1) {
118 UInt_t nrdeadchips = static_cast<UInt_t>(fraction*240*5 + 0.5);
119 RandomizeDeadChips(nrdeadchips);
122 void RandomizeDeadChips(UInt_t nrDeadChips) {
123 if (handler==NULL) handler = new AliITSOnlineCalibrationSPDhandler();
124 UInt_t nrDeadChipsInserted = 0;
125 AliITSIntMap* chipMap = new AliITSIntMap();
126 while (nrDeadChipsInserted<nrDeadChips) {
127 UInt_t eq = (UInt_t)(rnd->Rndm()*20);
128 UInt_t hs = (UInt_t)(rnd->Rndm()*6);
129 UInt_t chip = (UInt_t)(rnd->Rndm()*10);
130 if (!chipMap->Find(20*6*chip + 20*hs + eq)) {
131 for (UInt_t col=0; col<32; col++) {
132 for (UInt_t row=0; row<256; row++) {
133 handler->SetDeadPixel(eq,hs,chip,col,row);
136 chipMap->Insert(20*6*chip + 20*hs + eq, chip);
137 nrDeadChipsInserted++;
143 void RandomizeDeadChipsFrac(Double_t fraction, UInt_t layer) {
144 if (fraction>0 && fraction<=1) {
150 nrdeadchips = static_cast<UInt_t>(fraction*nr_chips + 0.5);
151 RandomizeDeadChips(nrdeadchips,layer);
155 nrdeadchips = static_cast<UInt_t>(fraction*nr_chips + 0.5);
156 RandomizeDeadChips(nrdeadchips,layer);
163 void RandomizeDeadChips(UInt_t nrDeadChips, UInt_t layer) {
164 if (handler==NULL) handler = new AliITSOnlineCalibrationSPDhandler();
179 UInt_t nrDeadChipsInserted = 0;
180 AliITSIntMap* chipMap = new AliITSIntMap();
181 while (nrDeadChipsInserted<nrDeadChips) {
182 UInt_t eq = (UInt_t)(rnd->Rndm()*20);
183 UInt_t hs = (UInt_t)(rnd->Rndm()*hs_nr+hs_offset);
184 UInt_t chip = (UInt_t)(rnd->Rndm()*10);
185 if (!chipMap->Find(20*6*chip + 20*hs + eq)) {
186 for (UInt_t col=0; col<32; col++) {
187 for (UInt_t row=0; row<256; row++) {
188 handler->SetDeadPixel(eq,hs,chip,col,row);
191 chipMap->Insert(20*6*chip + 20*hs + eq, chip);
192 nrDeadChipsInserted++;
198 void RandomizeDeadHalfStavesFrac(Double_t fraction) {
199 if (fraction>0 && fraction<=1) {
200 UInt_t nrdeadhstaves = static_cast<UInt_t>(fraction*120 + 0.5);
201 RandomizeDeadHalfStaves(nrdeadhstaves);
204 void RandomizeDeadHalfStaves(UInt_t nrDeadHS) {
205 if (handler==NULL) handler = new AliITSOnlineCalibrationSPDhandler();
206 UInt_t nrDeadHSInserted = 0;
207 AliITSIntMap* hsMap = new AliITSIntMap();
208 while (nrDeadHSInserted<nrDeadHS) {
209 UInt_t eq = (UInt_t)(rnd->Rndm()*20);
210 UInt_t hs = (UInt_t)(rnd->Rndm()*6);
211 if (!hsMap->Find(20*hs + eq)) {
212 for (UInt_t chip=0; chip<10; chip++) {
213 for (UInt_t col=0; col<32; col++) {
214 for (UInt_t row=0; row<256; row++) {
215 handler->SetDeadPixel(eq,hs,chip,col,row);
219 hsMap->Insert(20*hs + eq, hs);
226 void RandomizeDeadHalfStavesFrac(Double_t fraction, UInt_t layer) {
227 if (fraction>0 && fraction<=1) {
231 nr_hstaves=static_cast<UInt_t>(fraction*40 + 0.5);
232 RandomizeDeadHalfStaves(nr_hstaves,layer);
235 nr_hstaves=static_cast<UInt_t>(fraction*80 + 0.5);
236 RandomizeDeadHalfStaves(nr_hstaves,layer);
243 void RandomizeDeadHalfStaves(UInt_t nrDeadHS, UInt_t layer) {
244 if (handler==NULL) handler = new AliITSOnlineCalibrationSPDhandler();
259 UInt_t nrDeadHSInserted = 0;
260 AliITSIntMap* hsMap = new AliITSIntMap();
261 while (nrDeadHSInserted<nrDeadHS) {
262 UInt_t eq = (UInt_t)(rnd->Rndm()*20);
263 UInt_t hs = (UInt_t)(rnd->Rndm()*hs_nr+hs_offset);
264 if (!hsMap->Find(20*hs + eq)) {
265 for (UInt_t chip=0; chip<10; chip++) {
266 for (UInt_t col=0; col<32; col++) {
267 for (UInt_t row=0; row<256; row++) {
268 handler->SetDeadPixel(eq,hs,chip,col,row);
272 hsMap->Insert(20*hs + eq, hs);
279 void RandomizeDeadColumnChipsFrac(Double_t chipfraction, Double_t columnfraction) {
280 if (chipfraction>0 && chipfraction<=1 && columnfraction>0 && columnfraction<=1) {
281 if (handler==NULL) handler = new AliITSOnlineCalibrationSPDhandler();
282 UInt_t nrColChips = static_cast<UInt_t>(chipfraction*240*5 + 0.5);
283 UInt_t nrColChipsUsed = 0;
284 AliITSIntMap* colChipMap = new AliITSIntMap();
285 while (nrColChipsUsed<nrColChips) {
286 UInt_t eq = (UInt_t)(rnd->Rndm()*20);
287 UInt_t hs = (UInt_t)(rnd->Rndm()*6);
288 UInt_t chip = (UInt_t)(rnd->Rndm()*10);
289 if (!colChipMap->Find(20*6*chip + 20*hs + eq)) {
290 UInt_t nrCols = static_cast<UInt_t>(columnfraction*32 + 0.5);
291 UInt_t nrColsInserted = 0;
292 AliITSIntMap* colMap = new AliITSIntMap();
293 while (nrColsInserted<nrCols) {
294 UInt_t col = (UInt_t)(rnd->Rndm()*32);
295 if (!colMap->Find(col)) {
296 for (UInt_t row=0; row<256; row++) {
297 handler->SetDeadPixel(eq,hs,chip,col,row);
299 colMap->Insert(col,col);
304 colChipMap->Insert(20*6*chip + 20*hs + eq, chip);
311 void RandomizeDeadColumnChipsFrac(Double_t chipfraction, Double_t columnfraction, Int_t layer) {
312 if (chipfraction>0 && chipfraction<=1 && columnfraction>0 && columnfraction<=1) {
313 if (handler==NULL) handler = new AliITSOnlineCalibrationSPDhandler();
328 UInt_t nrColChips = static_cast<UInt_t>(chipfraction*240*5 + 0.5);
329 UInt_t nrColChipsUsed = 0;
330 AliITSIntMap* colChipMap = new AliITSIntMap();
331 while (nrColChipsUsed<nrColChips) {
332 UInt_t eq = (UInt_t)(rnd->Rndm()*20);
333 UInt_t hs = (UInt_t)(rnd->Rndm()*hs_nr+hs_offset);
334 UInt_t chip = (UInt_t)(rnd->Rndm()*10);
335 if (!colChipMap->Find(20*6*chip + 20*hs + eq)) {
336 UInt_t nrCols = static_cast<UInt_t>(columnfraction*32 + 0.5);
337 UInt_t nrColsInserted = 0;
338 AliITSIntMap* colMap = new AliITSIntMap();
339 while (nrColsInserted<nrCols) {
340 UInt_t col = (UInt_t)(rnd->Rndm()*32);
341 if (!colMap->Find(col)) {
342 for (UInt_t row=0; row<256; row++) {
343 handler->SetDeadPixel(eq,hs,chip,col,row);
345 colMap->Insert(col,col);
350 colChipMap->Insert(20*6*chip + 20*hs + eq, chip);