]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSOnlineCalibrationSPDhandler.cxx
Mainly changes related to the added treatment of inactive detector parts in
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineCalibrationSPDhandler.cxx
1 //////////////////////////////////////////////////////////////////////
2 // Author: Henrik Tydesjo                                           //
3 // For easier handling of dead and noisy pixels they are kept in    //
4 // container maps (AliITSIntMap).                                   //
5 // Handling of inactive equipments,HSs,chips have been added.       //
6 // A pixel that is either dead or inactive is called SILENT here.   //
7 // The lists of single dead and noisy pixels are separated from the //
8 // information about which eq/hs/chip are inactive.                 //
9 // The TArrayS objects that are put in the AliITSCalibrationSPD     //
10 // objects can be obtained from the methods GetDeadArray and        //
11 // GetNoisyArray.                                                   //
12 //////////////////////////////////////////////////////////////////////   
13
14 #include "AliITSOnlineCalibrationSPDhandler.h"
15 #include "AliITSOnlineCalibrationSPD.h"
16 #include "AliITSIntMap.h"
17 #include <TObjArray.h>
18 #include <TArrayI.h>
19 #include <TArrayS.h>
20 #include <TFile.h>
21 #include <TError.h>
22 #include <fstream>
23
24 #ifndef SPD_DA_OFF // you may want to exclude cdb classes, if using this class outside aliroot
25 #include "AliITSCalibrationSPD.h"
26 #include "AliCDBManager.h"
27 #include "AliCDBEntry.h"
28 #endif
29
30 /* $Id$ */
31 //____________________________________________________________________________________________
32 AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler():
33   fFileLocation(".")
34 {
35   // constructor
36   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
37     fNrDead[gloChip]=0;
38     fNrNoisy[gloChip]=0;
39     fDeadPixelMap[gloChip] = new AliITSIntMap();
40     fNoisyPixelMap[gloChip] = new AliITSIntMap();    
41   }
42   ActivateALL();
43 }
44 //____________________________________________________________________________________________
45 AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler(const AliITSOnlineCalibrationSPDhandler& handle): 
46   fFileLocation(".")
47 {
48   // copy constructor
49   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
50     fNrDead[gloChip] = handle.fNrDead[gloChip];
51     fNrNoisy[gloChip] = handle.fNrNoisy[gloChip];
52     fDeadPixelMap[gloChip] = handle.fDeadPixelMap[gloChip]->Clone();
53     fNoisyPixelMap[gloChip] = handle.fNoisyPixelMap[gloChip]->Clone();
54   }
55   for (UInt_t eq=0; eq<20; eq++) {
56     fActiveEq[eq] = handle.fActiveEq[eq];
57     for (UInt_t hs=0; hs<6; hs++) {
58       fActiveHS[eq][hs] = handle.fActiveHS[eq][hs];
59       for (UInt_t chip=0; chip<10; chip++) {
60         fActiveChip[eq][hs][chip] = handle.fActiveChip[eq][hs][chip];
61       }
62     }
63   }
64   fFileLocation = handle.fFileLocation;
65 }
66 //____________________________________________________________________________________________
67 AliITSOnlineCalibrationSPDhandler::~AliITSOnlineCalibrationSPDhandler() {
68   //  ClearMaps();
69   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
70     delete fDeadPixelMap[gloChip];
71     delete fNoisyPixelMap[gloChip];
72   }
73 }
74 //____________________________________________________________________________________________
75 AliITSOnlineCalibrationSPDhandler& AliITSOnlineCalibrationSPDhandler::operator=(const AliITSOnlineCalibrationSPDhandler& handle) {
76   // assignment operator
77   if (this!=&handle) {
78     this->ClearMaps();
79     for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
80       fNrDead[gloChip] = handle.fNrDead[gloChip];
81       fNrNoisy[gloChip] = handle.fNrNoisy[gloChip];
82       fDeadPixelMap[gloChip] = handle.fDeadPixelMap[gloChip]->Clone();
83       fNoisyPixelMap[gloChip] = handle.fNoisyPixelMap[gloChip]->Clone();
84     }
85     for (UInt_t eq=0; eq<20; eq++) {
86       fActiveEq[eq] = handle.fActiveEq[eq];
87       for (UInt_t hs=0; hs<6; hs++) {
88         fActiveHS[eq][hs] = handle.fActiveHS[eq][hs];
89         for (UInt_t chip=0; chip<10; chip++) {
90           fActiveChip[eq][hs][chip] = handle.fActiveChip[eq][hs][chip];
91         }
92       }
93     }
94     fFileLocation = handle.fFileLocation;
95   }
96   return *this;
97 }
98 //____________________________________________________________________________________________
99 void AliITSOnlineCalibrationSPDhandler::ClearMaps() {
100   // clear the lists of dead and noisy
101   ResetDead();
102   ResetNoisy();
103   ActivateALL();
104 }
105 //____________________________________________________________________________________________
106 void AliITSOnlineCalibrationSPDhandler::ResetDead() {
107   // reset the dead pixel map and inactive eq,hs,chip
108   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
109     fNrDead[gloChip]=0;
110     fDeadPixelMap[gloChip]->Clear();
111   }
112 }
113 //____________________________________________________________________________________________
114 void AliITSOnlineCalibrationSPDhandler::ResetNoisy() {
115   // clear the list of noisy pixels
116   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
117     fNrNoisy[gloChip]=0;
118     fNoisyPixelMap[gloChip]->Clear();
119   }
120 }
121 //____________________________________________________________________________________________
122 void AliITSOnlineCalibrationSPDhandler::ResetDeadForChip(UInt_t eq, UInt_t hs, UInt_t chip) {
123   // clear the dead pixels for this chip
124   UInt_t gloChip = GetGloChip(eq,hs,chip);
125   for (UInt_t col=0; col<32; col++) {
126     for (UInt_t row=0; row<256; row++) {
127       Int_t key = GetKey(eq,hs,chip,col,row);
128       if (fDeadPixelMap[gloChip]->Remove(key)) {
129         fNrDead[gloChip]--;
130       }
131     }
132   }
133 }
134 //____________________________________________________________________________________________
135 void AliITSOnlineCalibrationSPDhandler::ResetNoisyForChip(UInt_t eq, UInt_t hs, UInt_t chip) {
136   // clear the noisy pixels for this chip
137   UInt_t gloChip = GetGloChip(eq,hs,chip);
138   if (gloChip>=1200) {
139     Error("AliITSOnlineCalibrationSPDhandler::ResetNoisyForChip","global chip nr (%d) out of bounds\n",gloChip);
140     return;
141   }
142   for (UInt_t col=0; col<32; col++) {
143     for (UInt_t row=0; row<256; row++) {
144       Int_t key = GetKey(eq,hs,chip,col,row);
145       if (fNoisyPixelMap[gloChip]->Remove(key)) {
146         fNrNoisy[gloChip]--;
147       }
148     }
149   }
150 }
151 //____________________________________________________________________________________________
152 void AliITSOnlineCalibrationSPDhandler::ResetDeadForEq(UInt_t eq) {
153   // clear the dead pixels for this eq
154   if (eq>=20) {
155     Error("AliITSOnlineCalibrationSPDhandler::ResetDeadForEq", "eq (%d) out of bounds.",eq);
156     return;
157   }
158   for (UInt_t hs=0; hs<6; hs++) {
159     for (UInt_t chip=0; chip<10; chip++) {
160       ResetDeadForChip(eq, hs, chip);
161     }
162   }
163 }
164 //____________________________________________________________________________________________
165 void AliITSOnlineCalibrationSPDhandler::ResetNoisyForEq(UInt_t eq) {
166   // clear the noisy pixels for this eq
167   if (eq>=20) {
168     Error("AliITSOnlineCalibrationSPDhandler::ResetNoisyForEq", "eq (%d) out of bounds.",eq);
169     return;
170   }
171   for (UInt_t hs=0; hs<6; hs++) {
172     for (UInt_t chip=0; chip<10; chip++) {
173       ResetNoisyForChip(eq, hs, chip);
174     }
175   }
176 }
177
178
179 //____________________________________________________________________________________________
180 Bool_t AliITSOnlineCalibrationSPDhandler::ReadFromFiles() {
181   // read files from file location (active,dead,noisy info). returns true if at least one file found
182   Bool_t b1 = ReadNoisyFromFiles();
183   Bool_t b2 = ReadSilentFromFiles();
184   return (b1 || b2);
185 }
186 //____________________________________________________________________________________________
187 Bool_t AliITSOnlineCalibrationSPDhandler::ReadSilentFromFiles() {
188   // read dead,active files from file location. returns true if at least one file found
189   Bool_t returnval=kFALSE;
190   for (UInt_t eq=0; eq<20; eq++) {
191     if (ReadSilentFromFile(eq)) {
192       returnval=kTRUE;
193     }
194   }
195   return returnval;
196 }
197 //____________________________________________________________________________________________
198 Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromFiles() {
199   // read dead,active files from file location. returns true if at least one file found
200   Bool_t returnval=kFALSE;
201   for (UInt_t eq=0; eq<20; eq++) {
202     if (ReadDeadFromFile(eq)) {
203       returnval=kTRUE;
204     }
205   }
206   return returnval;
207 }
208 //____________________________________________________________________________________________
209 Bool_t AliITSOnlineCalibrationSPDhandler::ReadSilentFromFile(UInt_t eq) {
210   // read dead file for eq from file location. 
211   TString fileName = Form("%s/SPD_Dead_%d.root",fFileLocation.Data(),eq);
212   return ReadSilentFromFileName(fileName.Data());
213 }
214 //____________________________________________________________________________________________
215 Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromFile(UInt_t eq) {
216   // read dead file for eq from file location. 
217   TString fileName = Form("%s/SPD_Dead_%d.root",fFileLocation.Data(),eq);
218   return ReadDeadFromFileName(fileName.Data());
219 }
220 //____________________________________________________________________________________________
221 Bool_t AliITSOnlineCalibrationSPDhandler::ReadSilentFromFileName(const char *fileName) {
222   // read dead from file fileName (including inactive)
223   return ReadDeadFromFileName(fileName, kTRUE);
224 }
225 //____________________________________________________________________________________________
226 Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromFileName(const char *fileName, Bool_t inactive) {
227   // read dead from file fileName
228   AliITSOnlineCalibrationSPD* calib;
229   FILE* fp0 = fopen(fileName, "r");
230   if (fp0 == NULL) {return kFALSE;}
231   else {
232     fclose(fp0);
233     TFile file(fileName, "READ");
234     if (file.IsOpen()) {
235       file.GetObject("AliITSOnlineCalibrationSPD", calib);
236       file.Close();
237       if (calib!=NULL) {
238         UInt_t nrDead=calib->GetNrBad();
239         for (UInt_t index=0; index<nrDead; index++) {
240           UInt_t key = calib->GetKeyAt(index);
241           UInt_t eq = GetEqIdFromKey(key);
242           UInt_t hs = GetHSFromKey(key);
243           UInt_t chip = GetChipFromKey(key);
244           UInt_t col = GetColFromKey(key);
245           UInt_t row = GetRowFromKey(key);
246           SetDeadPixel(eq,hs,chip,col,row);
247         }
248         if (inactive) {
249           UInt_t eq = calib->GetEqNr();
250           if (calib->IsActiveEq()) ActivateEq(eq);
251           else                     ActivateEq(eq,kFALSE);
252           for (UInt_t hs=0; hs<6; hs++) {
253             if (calib->IsActiveHS(hs)) ActivateHS(eq,hs);
254             else                       ActivateHS(eq,hs,kFALSE);
255             for (UInt_t chip=0; chip<10; chip++) {
256               if (calib->IsActiveChip(hs,chip)) ActivateChip(eq,hs,chip);
257               else                              ActivateChip(eq,hs,chip,kFALSE);
258             }
259           }
260         }
261       }
262     }
263   }
264   return kTRUE;
265 }
266 //____________________________________________________________________________________________
267 Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromFiles() {
268   // read noisy files from file location. returns true if at least one file found
269   Bool_t returnval=kFALSE;
270   for (UInt_t eq=0; eq<20; eq++) {
271     if (ReadNoisyFromFile(eq)) {
272       returnval=kTRUE;
273     }
274   }
275   return returnval;
276 }
277 //____________________________________________________________________________________________
278 Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromFile(UInt_t eq) {
279   // read noisy file for eq from file location. 
280   TString fileName = Form("%s/SPD_Noisy_%d.root",fFileLocation.Data(),eq);
281   return ReadNoisyFromFileName(fileName.Data());
282 }
283 //____________________________________________________________________________________________
284 Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromFileName(const char *fileName) {
285   // read noisy from file fileName
286   AliITSOnlineCalibrationSPD* calib;
287   FILE* fp0 = fopen(fileName, "r");
288   if (fp0 == NULL) {return kFALSE;}
289   else {
290     fclose(fp0);
291     TFile file(fileName, "READ");
292     if (file.IsOpen()) {
293       file.GetObject("AliITSOnlineCalibrationSPD", calib);
294       file.Close();
295       if (calib!=NULL) {
296         UInt_t nrNoisy=calib->GetNrBad();
297         for (UInt_t index=0; index<nrNoisy; index++) {
298           UInt_t key = calib->GetKeyAt(index);
299           UInt_t eq = GetEqIdFromKey(key);
300           UInt_t hs = GetHSFromKey(key);
301           UInt_t chip = GetChipFromKey(key);
302           UInt_t col = GetColFromKey(key);
303           UInt_t row = GetRowFromKey(key);
304           SetNoisyPixel(eq,hs,chip,col,row);
305         }
306       }
307     }
308   }
309   return kTRUE;
310 }
311 //____________________________________________________________________________________________
312 UInt_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromText(const char *fileName, UInt_t module) {
313   // read dead from a text file (lines with eq,hs,chip,col,row). returns nr of pixels added (not already here)
314   // insert only those pixels that belong to module (or all if module=240). 
315   UInt_t newNrDead=0;
316   ifstream textFile;
317   textFile.open(fileName, ifstream::in);
318   if (textFile.fail()) {
319     Warning("AliITSOnlineCalibrationSPDhandler::ReadDeadFromText","No dead text file (%s) present.",fileName);
320   }
321   else {
322     while(1) {
323       UInt_t eq,hs,chip,col,row;
324       textFile >> eq; if (textFile.eof()) break;
325       textFile >> hs; if (textFile.eof()) break;
326       textFile >> chip; if (textFile.eof()) break;
327       textFile >> col; if (textFile.eof()) break;
328       textFile >> row; 
329       if (module==240 || (Int_t)module==AliITSRawStreamSPD::GetModuleNumber(eq,hs,chip)){
330         if (SetDeadPixel(eq,hs,chip,col,row)) {
331           newNrDead++;
332         }
333       }
334       if (textFile.eof()) break;
335     }
336     textFile.close();
337   }
338   return newNrDead;
339 }
340 //____________________________________________________________________________________________
341 UInt_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromText(const char *fileName, UInt_t module) {
342   // read noisy from a text file (lines with eq,hs,chip,col,row). returns nr of pixels added (not already here)
343   // insert only those pixels that belong to module (or all if module=240). 
344   UInt_t newNrNoisy=0;
345   ifstream textFile;
346   textFile.open(fileName, ifstream::in);
347   if (textFile.fail()) {
348     Warning("AliITSOnlineCalibrationSPDhandler::ReadNoisyFromText","No noisy text file (%s) present.",fileName);
349   }
350   else {
351     while(1) {
352       UInt_t eq,hs,chip,col,row;
353       textFile >> eq; if (textFile.eof()) break;
354       textFile >> hs; if (textFile.eof()) break;
355       textFile >> chip; if (textFile.eof()) break;
356       textFile >> col; if (textFile.eof()) break;
357       textFile >> row; 
358       if (module==240 || (Int_t)module==AliITSRawStreamSPD::GetModuleNumber(eq,hs,chip)){
359         if (SetNoisyPixel(eq,hs,chip,col,row)) {
360           newNrNoisy++;
361         }
362       }
363       if (textFile.eof()) break;
364     }
365     textFile.close();
366   }
367   return newNrNoisy;
368 }
369 //____________________________________________________________________________________________
370 void AliITSOnlineCalibrationSPDhandler::WriteToFilesAlways() {
371   // write the lists of active,dead,noisy to files
372   for (UInt_t eq=0; eq<20; eq++) {
373     WriteSilentToFile(eq);
374     WriteNoisyToFile(eq);
375   }
376 }
377 //____________________________________________________________________________________________
378 UInt_t AliITSOnlineCalibrationSPDhandler::WriteToFiles() {
379   // write the lists of dead and noisy to files (only if there are >0 dead or noisy pixels) , returns nr of files produced
380   return (WriteNoisyToFiles() + WriteSilentToFiles());
381 }
382 //____________________________________________________________________________________________
383 void AliITSOnlineCalibrationSPDhandler::WriteSilentToFilesAlways() {
384   // write the lists of silent to files
385   for (UInt_t eq=0; eq<20; eq++) {
386       WriteSilentToFile(eq);
387   }
388 }
389 //____________________________________________________________________________________________
390 void AliITSOnlineCalibrationSPDhandler::WriteDeadToFilesAlways() {
391   // write the lists of dead to files
392   for (UInt_t eq=0; eq<20; eq++) {
393       WriteDeadToFile(eq);
394   }
395 }
396 //____________________________________________________________________________________________
397 void AliITSOnlineCalibrationSPDhandler::WriteNoisyToFilesAlways() {
398   // write the lists of noisy to files
399   for (UInt_t eq=0; eq<20; eq++) {
400     WriteNoisyToFile(eq);
401   }
402 }
403 //____________________________________________________________________________________________
404 UInt_t AliITSOnlineCalibrationSPDhandler::WriteSilentToFiles() {
405   // write the list of silent to file (only if there are >0 silent pixels) , returns nr of files produced
406   UInt_t nrFiles=0;
407   for (UInt_t eq=0; eq<20; eq++) {
408     if (GetNrSilentEq(eq) > 0) {
409       WriteSilentToFile(eq);
410       nrFiles++;
411     }
412   }
413   return nrFiles;
414 }
415 //____________________________________________________________________________________________
416 UInt_t AliITSOnlineCalibrationSPDhandler::WriteDeadToFiles() {
417   // write the list of dead to file (only if there are >0 dead pixels) , returns nr of files produced
418   UInt_t nrFiles=0;
419   for (UInt_t eq=0; eq<20; eq++) {
420     if (GetNrDeadEq(eq) > 0) {
421       WriteDeadToFile(eq);
422       nrFiles++;
423     }
424   }
425   return nrFiles;
426 }
427 //____________________________________________________________________________________________
428 UInt_t AliITSOnlineCalibrationSPDhandler::WriteNoisyToFiles() {
429   // write the list of noisy to file (only if there are >0 noisy pixels) , returns nr of files produced
430   UInt_t nrFiles=0;
431   for (UInt_t eq=0; eq<20; eq++) {
432     if (GetNrNoisyEq(eq) > 0) {
433       WriteNoisyToFile(eq);
434       nrFiles++;
435     }
436   }
437   return nrFiles;
438 }
439 //____________________________________________________________________________________________
440 void AliITSOnlineCalibrationSPDhandler::WriteSilentToFile(UInt_t eq) {
441   WriteDeadToFile(eq,kTRUE);
442 }
443 //____________________________________________________________________________________________
444 void AliITSOnlineCalibrationSPDhandler::WriteDeadToFile(UInt_t eq, Bool_t inactive) {
445   // write the lists of dead (and inactive if input boolean is true) for eq to file
446   AliITSOnlineCalibrationSPD* calib = new AliITSOnlineCalibrationSPD();
447   calib->SetEqNr(eq);
448   calib->SetBadList(GetDeadArrayOnline(eq));
449   calib->SetNrBad(GetNrDeadEq(eq));
450   if (inactive) {
451     if (IsActiveEq(eq)) calib->ActivateEq();
452     else                calib->ActivateEq(kFALSE);
453     for (UInt_t hs=0; hs<6; hs++) {
454       if (IsActiveHS(eq,hs)) calib->ActivateHS(hs);
455       else                   calib->ActivateHS(hs,kFALSE);
456       for (UInt_t chip=0; chip<10; chip++) {
457         if (IsActiveChip(eq,hs,chip)) calib->ActivateChip(hs,chip);
458         else                          calib->ActivateChip(hs,chip,kFALSE);
459       }
460     }
461   }
462   TString fileName = Form("%s/SPD_Dead_%d.root",fFileLocation.Data(),eq);
463   TFile file(fileName.Data(), "RECREATE");
464   file.WriteTObject(calib, "AliITSOnlineCalibrationSPD");
465   file.Close();
466   delete calib;
467 }
468 //____________________________________________________________________________________________
469 void AliITSOnlineCalibrationSPDhandler::WriteNoisyToFile(UInt_t eq) {
470   // write the lists of noisy for eq to file
471   AliITSOnlineCalibrationSPD* calib = new AliITSOnlineCalibrationSPD();
472   calib->SetEqNr(eq);
473   calib->SetBadList(GetNoisyArrayOnline(eq));
474   calib->SetNrBad(GetNrNoisyEq(eq));
475   TString fileName = Form("%s/SPD_Noisy_%d.root",fFileLocation.Data(),eq);
476   TFile file(fileName.Data(), "RECREATE");
477   file.WriteTObject(calib, "AliITSOnlineCalibrationSPD");
478   file.Close();
479   delete calib;
480 }
481 //____________________________________________________________________________________________
482 #ifndef SPD_DA_OFF
483 Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadModuleFromDB(UInt_t module, Int_t runNr, Bool_t treeSerial) {
484   // reads dead pixels from DB for given module and runNr
485   AliCDBManager* man = AliCDBManager::Instance();
486   if(!man->IsDefaultStorageSet()) {
487     man->SetDefaultStorage("local://$ALICE_ROOT");
488   }
489   AliCDBEntry *cdbEntry = man->Get("ITS/Calib/SPDDead", runNr);
490   TObjArray* spdEntry;
491   if(cdbEntry) {
492     spdEntry = (TObjArray*)cdbEntry->GetObject();
493     if(!spdEntry) return kFALSE;
494   }
495   else {
496     Warning("AliITSOnlineCalibrationSPDhandler::ReadDeadModuleFromDB","Calibration for run %d not found in database.",runNr);
497     return kFALSE;
498   }
499   AliITSCalibrationSPD* calibSPD;
500   calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module);
501   UInt_t nrDead = calibSPD->GetNrBad();
502   if (nrDead>0) {
503     if (!treeSerial) RecursiveInsertDead(calibSPD,module,0,nrDead-1);
504     else {
505       for (UInt_t index=0; index<nrDead; index++) {
506         UInt_t colM = calibSPD->GetBadColAt(index);
507         UInt_t rowM = calibSPD->GetBadRowAt(index);
508         SetDeadPixelM(module,colM,rowM);
509       }
510     }
511   }
512   spdEntry->SetOwner(kTRUE);
513   spdEntry->Clear();
514   return kTRUE;
515 }
516 //____________________________________________________________________________________________
517 Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyModuleFromDB(UInt_t module, Int_t runNr, Bool_t treeSerial) {
518   // reads noisy pixels from DB for given module and runNr
519   AliCDBManager* man = AliCDBManager::Instance();
520   if(!man->IsDefaultStorageSet()) {
521     man->SetDefaultStorage("local://$ALICE_ROOT");
522   }
523   AliCDBEntry *cdbEntry = man->Get("ITS/Calib/SPDNoisy", runNr);
524   TObjArray* spdEntry;
525   if(cdbEntry) {
526     spdEntry = (TObjArray*)cdbEntry->GetObject();
527     if(!spdEntry) return kFALSE;
528   }
529   else {
530     Warning("AliITSOnlineCalibrationSPDhandler::ReadNoisyModuleFromDB","Calibration for run %d not found in database.",runNr);
531     return kFALSE;
532   }
533   AliITSCalibrationSPD* calibSPD;
534   calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module);
535   UInt_t nrNoisy = calibSPD->GetNrBad();
536   if (nrNoisy>0) {
537     if (!treeSerial) RecursiveInsertNoisy(calibSPD,module,0,nrNoisy-1);
538     else {
539       for (UInt_t index=0; index<nrNoisy; index++) {
540         UInt_t colM = calibSPD->GetBadColAt(index);
541         UInt_t rowM = calibSPD->GetBadRowAt(index);
542         SetNoisyPixelM(module,colM,rowM);
543       }
544     }
545   }
546   spdEntry->SetOwner(kTRUE);
547   spdEntry->Clear();
548   return kTRUE;
549 }
550 //____________________________________________________________________________________________
551 Bool_t AliITSOnlineCalibrationSPDhandler::ReadFromDB(Int_t runNr, Bool_t treeSerial) {
552   // reads dead and noisy pixels from DB for given runNr
553   // note that you may want to clear the lists (if they are not empty) before reading
554   return (ReadNoisyFromDB(runNr,treeSerial) && ReadDeadFromDB(runNr,treeSerial));
555 }
556 //____________________________________________________________________________________________
557 Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromDB(Int_t runNr, Bool_t treeSerial) {
558   // reads dead pixels from DB for given runNr
559   // note that you may want to clear the list (if it is not empty) before reading
560   AliCDBManager* man = AliCDBManager::Instance();
561   if(!man->IsDefaultStorageSet()) {
562     man->SetDefaultStorage("local://$ALICE_ROOT");
563   }
564   AliCDBEntry *cdbEntry = man->Get("ITS/Calib/SPDDead", runNr);
565   TObjArray* spdEntry;
566   if(cdbEntry) {
567     spdEntry = (TObjArray*)cdbEntry->GetObject();
568     if(!spdEntry) return kFALSE;
569   }
570   else {
571     Warning("AliITSOnlineCalibrationSPDhandler::ReadDeadFromDB","Calibration for run %d not found in database.",runNr);
572     return kFALSE;
573   }
574   AliITSCalibrationSPD* calibSPD;
575   for (UInt_t module=0; module<240; module++) {
576     //    printf("Reading module %d\n",module);
577     calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module);
578     UInt_t nrDead = calibSPD->GetNrBad();
579     if (nrDead>0) {    
580       if (!treeSerial) RecursiveInsertDead(calibSPD,module,0,nrDead-1);
581       else {
582         for (UInt_t index=0; index<nrDead; index++) {
583           UInt_t colM = calibSPD->GetBadColAt(index);
584           UInt_t rowM = calibSPD->GetBadRowAt(index);
585           SetDeadPixelM(module,colM,rowM);
586         }
587       }
588     }
589   }
590   spdEntry->SetOwner(kTRUE);
591   spdEntry->Clear();
592   return kTRUE;
593 }
594 //____________________________________________________________________________________________
595 Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromDB(Int_t runNr, Bool_t treeSerial) {
596   // reads noisy pixels from DB for given runNr
597   // note that you may want to clear the list (if it is not empty) before reading
598   AliCDBManager* man = AliCDBManager::Instance();
599   if(!man->IsDefaultStorageSet()) {
600     man->SetDefaultStorage("local://$ALICE_ROOT");
601   }
602   AliCDBEntry *cdbEntry = man->Get("ITS/Calib/SPDNoisy", runNr);
603   TObjArray* spdEntry;
604   if(cdbEntry) {
605     spdEntry = (TObjArray*)cdbEntry->GetObject();
606     if(!spdEntry) return kFALSE;
607   }
608   else {
609     Warning("AliITSOnlineCalibrationSPDhandler::ReadNoisyFromDB","Calibration for run %d not found in database.",runNr);
610     return kFALSE;
611   }
612   AliITSCalibrationSPD* calibSPD;
613   for (UInt_t module=0; module<240; module++) {
614     //    printf("Reading module %d\n",module);
615     calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module);
616     UInt_t nrNoisy = calibSPD->GetNrBad();
617     if (nrNoisy>0) {    
618       if (!treeSerial) {
619         printf("*** mod %d nrnoisy=%d\n",module,nrNoisy);
620         RecursiveInsertNoisy(calibSPD,module,0,nrNoisy-1);
621       }
622       else {
623         for (UInt_t index=0; index<nrNoisy; index++) {
624           UInt_t colM = calibSPD->GetBadColAt(index);
625           UInt_t rowM = calibSPD->GetBadRowAt(index);
626           SetNoisyPixelM(module,colM,rowM);
627         }
628       }
629     }
630   }
631   spdEntry->SetOwner(kTRUE);
632   spdEntry->Clear();
633   return kTRUE;
634 }
635 //____________________________________________________________________________________________
636 Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromCalibObj(TObjArray* calObj) {
637   // reads dead pixels from calib object
638   for (UInt_t module=0; module<240; module++) {
639     for (Int_t i=0; i<((AliITSCalibrationSPD*)calObj->At(module))->GetNrBad(); i++) {
640       SetDeadPixelM(module,
641                     ((AliITSCalibrationSPD*)calObj->At(module))->GetBadColAt(i),
642                     ((AliITSCalibrationSPD*)calObj->At(module))->GetBadRowAt(i));
643     }
644   }
645   return kTRUE;
646 }
647 //____________________________________________________________________________________________
648 Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromCalibObj(TObjArray* calObj) {
649   // reads noisy pixels from calib object
650   for (UInt_t module=0; module<240; module++) {
651     for (Int_t i=0; i<((AliITSCalibrationSPD*)calObj->At(module))->GetNrBad(); i++) {
652       SetNoisyPixelM(module,
653                      ((AliITSCalibrationSPD*)calObj->At(module))->GetBadColAt(i),
654                      ((AliITSCalibrationSPD*)calObj->At(module))->GetBadRowAt(i));
655     }
656   }
657   return kTRUE;
658 }
659 //____________________________________________________________________________________________
660 Bool_t AliITSOnlineCalibrationSPDhandler::WriteToDB(Int_t runNrStart, Int_t runNrEnd) {
661   // writes dead and noisy pixels to DB for given runNrs
662   // overwrites any previous entries
663   return (WriteNoisyToDB(runNrStart,runNrEnd) && WriteDeadToDB(runNrStart,runNrEnd));
664 }
665 //____________________________________________________________________________________________
666 Bool_t AliITSOnlineCalibrationSPDhandler::WriteDeadToDB(Int_t runNrStart, Int_t runNrEnd) {
667   // writes dead pixels to DB for given runNrs
668   // overwrites any previous entries
669   AliCDBManager* man = AliCDBManager::Instance();
670   if(!man->IsDefaultStorageSet()) {
671     man->SetDefaultStorage("local://$ALICE_ROOT");
672   }
673   AliCDBMetaData* metaData = new AliCDBMetaData();
674   metaData->SetResponsible("Henrik Tydesjo");
675   metaData->SetComment("Created by AliITSOnlineCalibrationSPDhandler.");
676   AliCDBId idCalSPD("ITS/Calib/SPDDead",runNrStart,runNrEnd);
677   TObjArray* spdEntry = new TObjArray(240);
678   spdEntry->SetOwner(kTRUE);
679   for(UInt_t module=0; module<240; module++){
680     AliITSCalibrationSPD* calObj = new AliITSCalibrationSPD();
681
682     // *** this is temporarily hard coded here ********************
683     // (later these parameters will be separated from the cal.obj.)
684     calObj->SetThresholds(3000, 250);
685     calObj->SetBiasVoltage(18.182);
686     calObj->SetNoiseParam(0,0);
687     calObj->SetCouplingParam(0.,0.055);
688     // *** remove later...
689     // ************************************************************
690
691     spdEntry->Add(calObj);
692   }
693   for(UInt_t module=0; module<240; module++){
694     ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrBad( GetNrSilent(module) );
695     ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetBadList( GetSilentArray(module) );
696   }
697   AliCDBEntry* cdbEntry = new AliCDBEntry((TObject*)spdEntry,idCalSPD,metaData);
698   man->Put(cdbEntry);
699   delete spdEntry;
700   delete cdbEntry;
701   delete metaData;
702   return kTRUE;
703 }
704 //____________________________________________________________________________________________
705 Bool_t AliITSOnlineCalibrationSPDhandler::WriteNoisyToDB(Int_t runNrStart, Int_t runNrEnd) {
706   // writes noisy pixels to DB for given runNrs
707   // overwrites any previous entries
708   AliCDBManager* man = AliCDBManager::Instance();
709   if(!man->IsDefaultStorageSet()) {
710     man->SetDefaultStorage("local://$ALICE_ROOT");
711   }
712   AliCDBMetaData* metaData = new AliCDBMetaData();
713   metaData->SetResponsible("Henrik Tydesjo");
714   metaData->SetComment("Created by AliITSOnlineCalibrationSPDhandler.");
715   AliCDBId idCalSPD("ITS/Calib/SPDNoisy",runNrStart,runNrEnd);
716   TObjArray* spdEntry = new TObjArray(240);
717   spdEntry->SetOwner(kTRUE);
718   for(UInt_t module=0; module<240; module++){
719     AliITSCalibrationSPD* calObj = new AliITSCalibrationSPD();
720
721     // *** this is temporarily hard coded here ********************
722     // (later these parameters will be separated from the cal.obj.)
723     calObj->SetThresholds(3000, 250);
724     calObj->SetBiasVoltage(18.182);
725     calObj->SetNoiseParam(0,0);
726     calObj->SetCouplingParam(0.,0.055);
727     // *** remove later...
728     // ************************************************************
729
730     spdEntry->Add(calObj);
731   }
732   for(UInt_t module=0; module<240; module++){
733     ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrBad( GetNrNoisy(module) );
734     ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetBadList( GetNoisyArray(module) );
735   }
736   AliCDBEntry* cdbEntry = new AliCDBEntry((TObject*)spdEntry,idCalSPD,metaData);
737   man->Put(cdbEntry);
738   delete spdEntry;
739   delete cdbEntry;
740   delete metaData;
741   return kTRUE;
742 }
743 //____________________________________________________________________________________________
744 void AliITSOnlineCalibrationSPDhandler::RecursiveInsertDead(AliITSCalibrationSPD* calibSPD, UInt_t module, Int_t lowInd, Int_t highInd) {
745   // inserts dead pixels recursively, used when reading from db
746   if (lowInd>highInd) return;
747   Int_t thisInd = lowInd+(highInd-lowInd)/2;
748   SetDeadPixelM(module,calibSPD->GetBadColAt(thisInd),calibSPD->GetBadRowAt(thisInd));
749   RecursiveInsertDead(calibSPD,module,lowInd,thisInd-1);
750   RecursiveInsertDead(calibSPD,module,thisInd+1,highInd);
751 }
752 //____________________________________________________________________________________________
753 void AliITSOnlineCalibrationSPDhandler::RecursiveInsertNoisy(AliITSCalibrationSPD* calibSPD, UInt_t module, Int_t lowInd, Int_t highInd) {
754   // inserts noisy pixels recursively, used when reading from db
755   if (lowInd>highInd) return;
756   Int_t thisInd = lowInd+(highInd-lowInd)/2;
757   SetNoisyPixelM(module,calibSPD->GetBadColAt(thisInd),calibSPD->GetBadRowAt(thisInd));
758   RecursiveInsertNoisy(calibSPD,module,lowInd,thisInd-1);
759   RecursiveInsertNoisy(calibSPD,module,thisInd+1,highInd);
760 }
761
762 #endif
763 //____________________________________________________________________________________________
764 void AliITSOnlineCalibrationSPDhandler::GenerateDCSConfigFile(const Char_t* fileName) {
765   // generates an ascii file in the format as the one produced by online da (but with dummy runNr=0)
766   ofstream dcsfile;
767   dcsfile.open(fileName);
768   dcsfile << "[SPD SCAN]\n";
769   dcsfile << "RunNumber=" << "0" << "\n"; // dummy value
770   dcsfile << "Type=" << "4" << "\n";
771   dcsfile << "Router=" << "0" << "\n"; // dummy value
772   dcsfile << "ActualDetConfiguration=" << "0,-1,-1\n"; // dummy values
773   dcsfile << "[NOISY]\n";
774   for (UInt_t module=0; module<240; module++) {
775     UInt_t headkey=20*10*6;
776     for (UInt_t ind=0; ind<GetNrNoisy(module); ind++) {
777       UInt_t newkey = GetNoisyEqIdAt(module,ind)*10*6 +
778         GetNoisyHSAt(module,ind)*10 +
779         GetNoisyChipAt(module,ind);
780       if (newkey!=headkey) { // print eq,hs,chip header
781         headkey = newkey;
782         dcsfile << "-" << newkey/(6*10) << "," << (newkey%(6*10))/10 << "," << (newkey%(6*10))%10 << "\n";
783       }
784       dcsfile << GetNoisyColAt(module,ind) << "," << GetNoisyRowAt(module,ind) << "\n";
785     }
786   }
787   dcsfile.close();
788 }
789 //____________________________________________________________________________________________
790 TArrayS AliITSOnlineCalibrationSPDhandler::GetSilentArray(UInt_t module, Bool_t treeSerial) {
791   // get a TArrayS of the silent=dead+inactive pixels (format for the AliITSCalibrationSPD object)
792   TArrayS returnArray;
793
794   UInt_t eq = GetEqIdFromOffline(module);
795   UInt_t hs = GetHSFromOffline(module);
796   UInt_t size=0;
797   if ( !( IsActiveEq(eq) && IsActiveHS(eq,hs) ) ) {
798     size = 8192*5;
799   }
800   else {
801     for (UInt_t ch=0; ch<5; ch++) {
802       UInt_t chip = GetChipFromOffline(module,ch*32);
803       if (!(IsActiveChip(eq,hs,chip))) {
804         size += 8192;
805       }
806       else {
807         UInt_t gloChip = GetGloChip(eq,hs,chip);
808         size += fNrDead[gloChip];
809       }
810     }
811   }
812   returnArray.Set(size*2);
813
814   UInt_t gloIndex=0;
815   if ( !( IsActiveEq(eq) && IsActiveHS(eq,hs) ) ) {
816     for (UInt_t colM=0; colM<160; colM++) {
817       for (UInt_t rowM=0; rowM<256; rowM++) {
818         returnArray.AddAt(colM,gloIndex*2);
819         returnArray.AddAt(rowM,gloIndex*2+1);
820         gloIndex++;
821       }
822     }
823   }
824   else {
825     for (UInt_t ch=0; ch<5; ch++) {
826       UInt_t chip = GetChipFromOffline(module,ch*32);
827       if (!(IsActiveChip(eq,hs,chip))) {
828         for (UInt_t colM=ch*32; colM<ch*32+32; colM++) {
829           for (UInt_t rowM=0; rowM<256; rowM++) {
830             returnArray.AddAt(colM,gloIndex*2);
831             returnArray.AddAt(rowM,gloIndex*2+1);
832             gloIndex++;
833           }
834         }
835       }
836       else {
837         UInt_t gloChip = GetGloChip(eq,hs,chip);
838         if (treeSerial) fDeadPixelMap[gloChip]->PrepareSerialize(); // for tree ordered values
839         else fDeadPixelMap[gloChip]->PrepareSerializeOrdered(); // for key ordered values
840         for (UInt_t index=0; index<fNrDead[gloChip]; index++) {
841           Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
842           Int_t colM = GetColMFromKey(key);
843           Int_t rowM = GetRowMFromKey(key);
844           returnArray.AddAt(colM,gloIndex*2);
845           returnArray.AddAt(rowM,gloIndex*2+1);
846           gloIndex++;
847         }
848       }
849     }
850   }
851   return returnArray;
852 }
853 //____________________________________________________________________________________________
854 TArrayS AliITSOnlineCalibrationSPDhandler::GetDeadArray(UInt_t module, Bool_t treeSerial) {
855   // get a TArrayS of the dead pixels (format for the AliITSCalibrationSPD object)
856   TArrayS returnArray;
857
858   UInt_t eq = GetEqIdFromOffline(module);
859   UInt_t hs = GetHSFromOffline(module);
860   UInt_t size=0;
861   for (UInt_t ch=0; ch<5; ch++) {
862     UInt_t gloChip = GetGloChip(eq,hs,GetChipFromOffline(module,ch*32));
863     size += fNrDead[gloChip];
864   }
865   returnArray.Set(size*2);
866   UInt_t gloIndex=0;
867   for (UInt_t ch=0; ch<5; ch++) {
868     UInt_t gloChip = GetGloChip(eq,hs,GetChipFromOffline(module,ch*32));
869     if (treeSerial) fDeadPixelMap[gloChip]->PrepareSerialize(); // for tree ordered values
870     else fDeadPixelMap[gloChip]->PrepareSerializeOrdered(); // for key ordered values
871     for (UInt_t index=0; index<fNrDead[gloChip]; index++) {
872       Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
873       Int_t colM = GetColMFromKey(key);
874       Int_t rowM = GetRowMFromKey(key);
875       returnArray.AddAt(colM,gloIndex*2);
876       returnArray.AddAt(rowM,gloIndex*2+1);
877       gloIndex++;
878     }
879   }
880   return returnArray;
881 }
882 //____________________________________________________________________________________________
883 TArrayS AliITSOnlineCalibrationSPDhandler::GetNoisyArray(UInt_t module, Bool_t treeSerial) {
884   // get a TArrayS of the noisy pixels (format for the AliITSCalibrationSPD object)
885   TArrayS returnArray;
886
887   UInt_t eq = GetEqIdFromOffline(module);
888   UInt_t hs = GetHSFromOffline(module);
889   UInt_t size=0;
890   for (UInt_t ch=0; ch<5; ch++) {
891     UInt_t gloChip = GetGloChip(eq,hs,GetChipFromOffline(module,ch*32));
892     size += fNrNoisy[gloChip];
893   }
894   returnArray.Set(size*2);
895   UInt_t gloIndex=0;
896   for (UInt_t ch=0; ch<5; ch++) {
897     UInt_t gloChip = GetGloChip(eq,hs,GetChipFromOffline(module,ch*32));
898     if (treeSerial) fNoisyPixelMap[gloChip]->PrepareSerialize(); // for tree ordered values
899     else fNoisyPixelMap[gloChip]->PrepareSerializeOrdered(); // for key ordered values
900     for (UInt_t index=0; index<fNrNoisy[gloChip]; index++) {
901       Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(index);
902       Int_t colM = GetColMFromKey(key);
903       Int_t rowM = GetRowMFromKey(key);
904       returnArray.AddAt(colM,gloIndex*2);
905       returnArray.AddAt(rowM,gloIndex*2+1);
906       gloIndex++;
907     }
908   }
909   return returnArray;
910 }
911 //____________________________________________________________________________________________
912 TArrayI AliITSOnlineCalibrationSPDhandler::GetDeadArrayOnline(UInt_t eq) {
913   // get a TArrayI of the dead pixels (format for the AliITSOnlineCalibrationSPD object)
914   TArrayI returnArray;
915   // fix size of array
916   UInt_t size=0;
917   for (UInt_t hs=0; hs<6; hs++) {
918     for (UInt_t chip=0; chip<10; chip++) {
919       UInt_t gloChip = GetGloChip(eq,hs,chip);
920       size+=fNrDead[gloChip];
921     }
922   }
923   returnArray.Set(size);
924   // put keys in array
925   UInt_t gloIndex=0;
926   for (UInt_t hs=0; hs<6; hs++) {
927     for (UInt_t chip=0; chip<10; chip++) {
928       UInt_t gloChip = GetGloChip(eq,hs,chip);
929       fDeadPixelMap[gloChip]->PrepareSerialize(); // for tree ordered values
930       for (UInt_t index=0; index<fNrDead[gloChip]; index++) {
931         Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
932         returnArray.AddAt(key,gloIndex);
933         gloIndex++;
934       }
935     }
936   }
937   return returnArray;
938 }
939 //____________________________________________________________________________________________
940 TArrayI AliITSOnlineCalibrationSPDhandler::GetNoisyArrayOnline(UInt_t eq) {
941   // get a TArrayI of the noisy pixels (format for the AliITSOnlineCalibrationSPD object)
942   TArrayI returnArray;
943   // fix size of array
944   UInt_t size=0;
945   for (UInt_t hs=0; hs<6; hs++) {
946     for (UInt_t chip=0; chip<10; chip++) {
947       UInt_t gloChip = GetGloChip(eq,hs,chip);
948       size+=fNrNoisy[gloChip];
949     }
950   }
951   returnArray.Set(size);
952   // put keys in array
953   UInt_t gloIndex=0;
954   for (UInt_t hs=0; hs<6; hs++) {
955     for (UInt_t chip=0; chip<10; chip++) {
956       UInt_t gloChip = GetGloChip(eq,hs,chip);
957       fNoisyPixelMap[gloChip]->PrepareSerialize(); // for tree ordered values
958       for (UInt_t index=0; index<fNrNoisy[gloChip]; index++) {
959         Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(index);
960         returnArray.AddAt(key,gloIndex);
961         gloIndex++;
962       }
963     }
964   }
965   return returnArray;
966 }
967 //____________________________________________________________________________________________
968 void AliITSOnlineCalibrationSPDhandler::PrintEqSummary() {
969 // print summary (nr of dead and noisy) for each equipment
970   printf("-----------\n");
971   printf("Eq summary:\n");
972   printf("-----------\n");
973   for (UInt_t eq=0; eq<20; eq++) {
974     printf("Eq %*d: %*d silent(dead+inactive) , %*d dead , %*d noisy\n",2,eq,5,GetNrSilentEq(eq),5,GetNrDeadEq(eq),5,GetNrNoisyEq(eq));
975   }
976 }
977 //____________________________________________________________________________________________
978 void AliITSOnlineCalibrationSPDhandler::PrintSilent() const {
979   // print the inactive and dead pixels to screen
980   printf("------------------------------------------------------\n");
981   printf("Inactive Equipments: (eq  |  module1 .. module12)\n");
982   printf("------------------------------------------------------\n");
983   for (UInt_t eq=0; eq<20; eq++) {
984     if (!IsActiveEq(eq)) {
985       printf("%*d  |  ",2,eq);
986       for (UInt_t hs=0; hs<6; hs++) {
987         for (UInt_t chip=0; chip<10; chip+=5) {
988           UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
989           if (hs>0 || chip==5) printf(",");
990           printf("%*d",3,module);
991         }
992       }
993       printf("\n");
994     }
995   }
996
997   printf("------------------------------------------------------\n");
998   printf("Inactive Half-staves: (eq,hs  |  module1,module2)\n");
999   printf("------------------------------------------------------\n");
1000   for (UInt_t eq=0; eq<20; eq++) {
1001     if (IsActiveEq(eq)) {
1002       for (UInt_t hs=0; hs<6; hs++) {
1003         if (!IsActiveHS(eq,hs)) {
1004           printf("%*d,%*d  |  ",2,eq,1,hs);
1005           for (UInt_t chip=0; chip<10; chip+=5) {
1006             UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
1007             if (chip==5) printf(",");
1008             printf("%*d",3,module);
1009           }
1010           printf("\n");
1011         }
1012       }
1013     }
1014   }
1015
1016   printf("------------------------------------------------------\n");
1017   printf("Inactive Chips: (eq,hs,chip  |  module,colM1-colM2)\n");
1018   printf("------------------------------------------------------\n");
1019   for (UInt_t eq=0; eq<20; eq++) {
1020     if (IsActiveEq(eq)) {
1021       for (UInt_t hs=0; hs<6; hs++) {
1022         if (IsActiveHS(eq,hs)) {
1023           for (UInt_t chip=0; chip<10; chip++) {
1024             if (!IsActiveChip(eq,hs,chip)) {
1025               printf("%*d,%*d,%*d  |  ",2,eq,1,hs,1,chip);
1026               UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
1027               UInt_t colM1 = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,0);
1028               UInt_t colM2 = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,31);
1029               printf("%*d,%*d-%*d\n",3,module,3,colM1,3,colM2);
1030             }
1031           }
1032         }
1033       }
1034     }
1035   }
1036
1037   PrintDead();
1038
1039 //!!!  printf("------------------------------------------------------\n");
1040 //!!!  printf("Dead Pixels: (eq,hs,chip,col,row  |  module,colM,rowM)\n");
1041 //!!!  printf("------------------------------------------------------\n");
1042 //!!!  for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
1043 //!!!    for (UInt_t index=0; index<fNrDead[gloChip]; index++) {
1044 //!!!      Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
1045 //!!!      UInt_t eq = GetEqIdFromKey(key);
1046 //!!!      UInt_t hs = GetHSFromKey(key);
1047 //!!!      UInt_t chip = GetChipFromKey(key);
1048 //!!!      if (!( IsActiveEq(eq) && IsActiveHS(eq,hs) && IsActiveChip(eq,hs,chip) )) continue;
1049 //!!!      UInt_t col = GetColFromKey(key);
1050 //!!!      UInt_t row = GetRowFromKey(key);
1051 //!!!
1052 //!!!      UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
1053 //!!!      UInt_t colM = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,col);
1054 //!!!      UInt_t rowM = AliITSRawStreamSPD::GetOfflineRowFromOnline(eq,hs,chip,row);
1055 //!!!
1056 //!!!      printf("%*d,%*d,%*d,%*d,%*d  |  %*d,%*d,%*d\n",2,eq,1,hs,1,chip,2,col,3,row,3,module,3,colM,3,rowM);
1057 //!!!    }
1058 //!!!  }
1059
1060 }
1061 //____________________________________________________________________________________________
1062 void AliITSOnlineCalibrationSPDhandler::PrintDead() const {
1063   // print the single dead pixels to screen (disregards inactive eq,hs,chip)
1064   printf("------------------------------------------------------\n");
1065   printf("Dead Pixels: (eq,hs,chip,col,row  |  module,colM,rowM)\n");
1066   printf("------------------------------------------------------\n");
1067   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
1068     for (UInt_t index=0; index<fNrDead[gloChip]; index++) {
1069       Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
1070       UInt_t eq = GetEqIdFromKey(key);
1071       UInt_t hs = GetHSFromKey(key);
1072       UInt_t chip = GetChipFromKey(key);
1073       UInt_t col = GetColFromKey(key);
1074       UInt_t row = GetRowFromKey(key);
1075
1076       UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
1077       UInt_t colM = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,col);
1078       UInt_t rowM = AliITSRawStreamSPD::GetOfflineRowFromOnline(eq,hs,chip,row);
1079
1080       printf("%*d,%*d,%*d,%*d,%*d  |  %*d,%*d,%*d\n",2,eq,1,hs,1,chip,2,col,3,row,3,module,3,colM,3,rowM);
1081     }
1082   }
1083 }
1084 //____________________________________________________________________________________________
1085 void AliITSOnlineCalibrationSPDhandler::PrintNoisy() const {
1086   // print the dead pixels to screen
1087   printf("-------------------------------------------------------\n");
1088   printf("Noisy Pixels: (eq,hs,chip,col,row  |  module,colM,rowM)\n");
1089   printf("-------------------------------------------------------\n");
1090   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
1091     for (UInt_t index=0; index<fNrNoisy[gloChip]; index++) {
1092       Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(index);
1093       UInt_t eq = GetEqIdFromKey(key);
1094       UInt_t hs = GetHSFromKey(key);
1095       UInt_t chip = GetChipFromKey(key);
1096       UInt_t col = GetColFromKey(key);
1097       UInt_t row = GetRowFromKey(key);
1098
1099       UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
1100       UInt_t colM = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,col);
1101       UInt_t rowM = AliITSRawStreamSPD::GetOfflineRowFromOnline(eq,hs,chip,row);
1102
1103       printf("%*d,%*d,%*d,%*d,%*d  |  %*d,%*d,%*d\n",2,eq,1,hs,1,chip,2,col,3,row,3,module,3,colM,3,rowM);
1104     }
1105   }
1106 }
1107 //____________________________________________________________________________________________
1108 Bool_t AliITSOnlineCalibrationSPDhandler::SetDeadPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) {
1109   // set a dead pixel, returns false if pixel is already dead
1110   UInt_t gloChip = GetGloChip(eq,hs,chip);
1111   if (gloChip>=1200) {
1112     Error("AliITSOnlineCalibrationSPDhandler::SetDeadPixel", "eq,hs,chip nrs (%d,%d,%d) out of bounds.",eq,hs,chip);
1113     return kFALSE;
1114   }
1115   if (col>=32 && row>=256) {
1116     Error("AliITSOnlineCalibrationSPDhandler::SetDeadPixel", "col,row nrs (%d,%d) out of bounds.",col,row);
1117     return kFALSE;
1118   }
1119   Int_t key = GetKey(eq,hs,chip,col,row);
1120   // if noisy we dont want to add it...
1121   if (fNoisyPixelMap[gloChip]->Find(key) != NULL) return kFALSE;
1122   if (fDeadPixelMap[gloChip]->Insert(key,gloChip)) {
1123     fNrDead[gloChip]++;
1124     return kTRUE;
1125   }
1126   return kFALSE;
1127 }
1128 //____________________________________________________________________________________________
1129 Bool_t AliITSOnlineCalibrationSPDhandler::SetNoisyPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) {
1130   // set a noisy pixel, returns false if pixel is already noisy
1131   UInt_t gloChip = GetGloChip(eq,hs,chip);
1132   if (gloChip>=1200) {
1133     Error("AliITSOnlineCalibrationSPDhandler::SetNoisyPixel", "eq,hs,chip nrs (%d,%d,%d) out of bounds.",eq,hs,chip);
1134     return kFALSE;
1135   }
1136   if (col>=32 && row>=256) {
1137     Error("AliITSOnlineCalibrationSPDhandler::SetNoisyPixel", "col,row nrs (%d,%d) out of bounds.",col,row);
1138     return kFALSE;
1139   }
1140   Int_t key = GetKey(eq,hs,chip,col,row);
1141   // if dead before - remove from the dead list 
1142   if (fDeadPixelMap[gloChip]->Remove(key)) {
1143     fNrDead[gloChip]--;
1144   }
1145   if (fNoisyPixelMap[gloChip]->Insert(key,gloChip)) {
1146     fNrNoisy[gloChip]++;
1147     return kTRUE;
1148   }
1149   return kFALSE;
1150 }
1151 //____________________________________________________________________________________________
1152 Bool_t AliITSOnlineCalibrationSPDhandler::SetDeadPixelM(UInt_t module, UInt_t colM, UInt_t rowM) {
1153   // set a dead pixel, returns false if pixel is already dead
1154   UInt_t eq = GetEqIdFromOffline(module);
1155   UInt_t hs = GetHSFromOffline(module);
1156   UInt_t chip = GetChipFromOffline(module,colM);
1157   UInt_t col = GetColFromOffline(module,colM);
1158   UInt_t row = GetRowFromOffline(module,rowM);
1159   return SetDeadPixel(eq,hs,chip,col,row);
1160 }
1161 //____________________________________________________________________________________________
1162 Bool_t AliITSOnlineCalibrationSPDhandler::SetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t rowM) {
1163   // set a noisy pixel, returns false if pixel is already noisy
1164   UInt_t eq = GetEqIdFromOffline(module);
1165   UInt_t hs = GetHSFromOffline(module);
1166   UInt_t chip = GetChipFromOffline(module,colM);
1167   UInt_t col = GetColFromOffline(module,colM);
1168   UInt_t row = GetRowFromOffline(module,rowM);
1169   return SetNoisyPixel(eq,hs,chip,col,row);
1170 }
1171 //____________________________________________________________________________________________
1172 Bool_t AliITSOnlineCalibrationSPDhandler::UnSetDeadPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) {
1173   // unset a dead pixel, returns false if pixel is not dead
1174   UInt_t gloChip = GetGloChip(eq,hs,chip);
1175   if (gloChip>=1200) {
1176     Error("AliITSOnlineCalibrationSPDhandler::UnSetDeadPixel", "eq,hs,chip nrs (%d,%d,%d) out of bounds.",eq,hs,chip);
1177     return kFALSE;
1178   }
1179   Int_t key = GetKey(eq,hs,chip,col,row);
1180   if (fDeadPixelMap[gloChip]->Remove(key)) {
1181     fNrDead[gloChip]--;
1182     return kTRUE;
1183   }
1184   return kFALSE;
1185 }
1186 //____________________________________________________________________________________________
1187 Bool_t AliITSOnlineCalibrationSPDhandler::UnSetNoisyPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) {
1188   // unset a noisy pixel, returns false if pixel is not noisy
1189   UInt_t gloChip = GetGloChip(eq,hs,chip);
1190   if (gloChip>=1200) {
1191     Error("AliITSOnlineCalibrationSPDhandler::UnSetNoisyPixel", "eq,hs,chip nrs (%d,%d,%d) out of bounds.",eq,hs,chip);
1192     return kFALSE;
1193   }
1194   Int_t key = GetKey(eq,hs,chip,col,row);
1195   if (fNoisyPixelMap[gloChip]->Remove(key)) {
1196     fNrNoisy[gloChip]--;
1197     return kTRUE;
1198   }
1199   return kFALSE;
1200 }
1201 //____________________________________________________________________________________________
1202 Bool_t AliITSOnlineCalibrationSPDhandler::UnSetDeadPixelM(UInt_t module, UInt_t colM, UInt_t rowM) {
1203   // unset a dead pixel, returns false if pixel is not dead
1204   UInt_t eq = GetEqIdFromOffline(module);
1205   UInt_t hs = GetHSFromOffline(module);
1206   UInt_t chip = GetChipFromOffline(module,colM);
1207   UInt_t col = GetColFromOffline(module,colM);
1208   UInt_t row = GetRowFromOffline(module,rowM);
1209   return UnSetDeadPixel(eq,hs,chip,col,row);
1210 }
1211 //____________________________________________________________________________________________
1212 Bool_t AliITSOnlineCalibrationSPDhandler::UnSetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t rowM) {
1213   // unset a noisy pixel, returns false if pixel is not noisy
1214   UInt_t eq = GetEqIdFromOffline(module);
1215   UInt_t hs = GetHSFromOffline(module);
1216   UInt_t chip = GetChipFromOffline(module,colM);
1217   UInt_t col = GetColFromOffline(module,colM);
1218   UInt_t row = GetRowFromOffline(module,rowM);
1219   return UnSetNoisyPixel(eq,hs,chip,col,row);
1220 }
1221 //____________________________________________________________________________________________
1222 UInt_t AliITSOnlineCalibrationSPDhandler::SetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip) {
1223   // set a full chip dead, returns nr of new dead pixels
1224   UInt_t nrNew = 0;
1225   for (UInt_t col=0; col<32; col++) {
1226     for (UInt_t row=0; row<256; row++) {
1227       if (SetDeadPixel(eq,hs,chip,col,row)) {
1228         nrNew++;
1229       }
1230     }
1231   }
1232   return nrNew;
1233 }
1234 //____________________________________________________________________________________________
1235 UInt_t AliITSOnlineCalibrationSPDhandler::SetNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip) {
1236   // set a full chip noisy, returns nr of new noisy pixels
1237   UInt_t nrNew = 0;
1238   for (UInt_t col=0; col<32; col++) {
1239     for (UInt_t row=0; row<256; row++) {
1240       if (SetNoisyPixel(eq,hs,chip,col,row)) {
1241         nrNew++;
1242       }
1243     }
1244   }
1245   return nrNew;
1246 }
1247 //____________________________________________________________________________________________
1248 Bool_t AliITSOnlineCalibrationSPDhandler::UnSetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip) {
1249   // unset a full dead chip, returns false if it was not all dead before
1250   UInt_t nrUnset = 0;
1251   for (UInt_t col=0; col<32; col++) {
1252     for (UInt_t row=0; row<256; row++) {
1253       if (UnSetDeadPixel(eq,hs,chip,col,row)) {
1254         nrUnset++;
1255       }
1256     }
1257   }
1258   if (nrUnset+GetNrNoisyC(eq,hs,chip)<8192) return kFALSE;
1259   else return kTRUE;
1260 }
1261 //____________________________________________________________________________________________
1262 Bool_t AliITSOnlineCalibrationSPDhandler::UnSetNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip) {
1263   // unset a full noisy chip, returns false if it was not all noisy before
1264   UInt_t nrUnset = 0;
1265   for (UInt_t col=0; col<32; col++) {
1266     for (UInt_t row=0; row<256; row++) {
1267       if (UnSetNoisyPixel(eq,hs,chip,col,row)) {
1268         nrUnset++;
1269       }
1270     }
1271   }
1272   if (nrUnset<8192) return kFALSE;
1273   else return kTRUE;
1274 }
1275 //____________________________________________________________________________________________
1276 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelSilent(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const {
1277   // is the pixel silent (dead or inactive)?
1278   UInt_t gloChip = GetGloChip(eq,hs,chip);
1279   if (gloChip>=1200 || col>=32 || row>=256) {
1280     Error("AliITSOnlineCalibrationSPDhandler::IsPixelSilent", "eq,hs,chip,col,row nrs (%d,%d,%d,%d,%d) out of bounds.",eq,hs,chip,col,row);
1281     return kFALSE;
1282   }
1283   if (!(IsActiveEq(eq) && IsActiveHS(eq,hs) && IsActiveChip(eq,hs,chip))) return kTRUE;
1284   else return IsPixelDead(eq,hs,chip,col,row);
1285 }
1286 //____________________________________________________________________________________________
1287 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelDead(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const {
1288   // is the pixel?
1289   UInt_t gloChip = GetGloChip(eq,hs,chip);
1290   if (gloChip>=1200 || col>=32 || row>=256) {
1291     Error("AliITSOnlineCalibrationSPDhandler::IsPixelDead", "eq,hs,chip,col,row nrs (%d,%d,%d,%d,%d) out of bounds.",eq,hs,chip,col,row);
1292     return kFALSE;
1293   }
1294   UInt_t key = GetKey(eq,hs,chip,col,row);
1295   if ( fDeadPixelMap[gloChip]->Find(key) != NULL ) return kTRUE;
1296   else return kFALSE;
1297 }
1298 //____________________________________________________________________________________________
1299 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisy(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const {
1300   // is the pixel noisy?
1301   UInt_t gloChip = GetGloChip(eq,hs,chip);
1302   if (gloChip>=1200 || col>=32 || row>=256) {
1303     Error("AliITSOnlineCalibrationSPDhandler::IsPixelNoisy", "eq,hs,chip,col,row nrs (%d,%d,%d) out of bounds.",eq,hs,chip,col,row);
1304     return kFALSE;
1305   }
1306   UInt_t key = GetKey(eq,hs,chip,col,row);
1307   if ( fNoisyPixelMap[gloChip]->Find(key) != NULL ) return kTRUE;
1308   else return kFALSE;
1309 }
1310 //____________________________________________________________________________________________
1311 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelSilentM(UInt_t module, UInt_t colM, UInt_t rowM) const {
1312   // is the pixel silent (dead or inactive)?
1313   UInt_t eq = GetEqIdFromOffline(module);
1314   UInt_t hs = GetHSFromOffline(module);
1315   UInt_t chip = GetChipFromOffline(module,colM);
1316   UInt_t col = GetColFromOffline(module,colM);
1317   UInt_t row = GetRowFromOffline(module,rowM);
1318   return IsPixelSilent(eq,hs,chip,col,row);
1319 }
1320 //____________________________________________________________________________________________
1321 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelDeadM(UInt_t module, UInt_t colM, UInt_t rowM) const {
1322   // is the pixel dead?
1323   UInt_t eq = GetEqIdFromOffline(module);
1324   UInt_t hs = GetHSFromOffline(module);
1325   UInt_t chip = GetChipFromOffline(module,colM);
1326   UInt_t col = GetColFromOffline(module,colM);
1327   UInt_t row = GetRowFromOffline(module,rowM);
1328   return IsPixelDead(eq,hs,chip,col,row);
1329 }
1330 //____________________________________________________________________________________________
1331 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisyM(UInt_t module, UInt_t colM, UInt_t rowM) const  {
1332   // is the pixel noisy?
1333   UInt_t eq = GetEqIdFromOffline(module);
1334   UInt_t hs = GetHSFromOffline(module);
1335   UInt_t chip = GetChipFromOffline(module,colM);
1336   UInt_t col = GetColFromOffline(module,colM);
1337   UInt_t row = GetRowFromOffline(module,rowM);
1338   return IsPixelNoisy(eq,hs,chip,col,row);
1339 }
1340 //____________________________________________________________________________________________
1341 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelSilentKey(Int_t key) const {
1342   // is this pixel silent (dead or inactive)?
1343   UInt_t eq = GetEqIdFromKey(key);
1344   UInt_t hs = GetHSFromKey(key);
1345   UInt_t chip = GetChipFromKey(key);
1346   UInt_t col = GetColFromKey(key);
1347   UInt_t row = GetRowFromKey(key);
1348   return IsPixelSilent(eq,hs,chip,col,row);
1349 }
1350 //____________________________________________________________________________________________
1351 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelDeadKey(Int_t key) const {
1352   // is this pixel dead?
1353   UInt_t eq = GetEqIdFromKey(key);
1354   UInt_t hs = GetHSFromKey(key);
1355   UInt_t chip = GetChipFromKey(key);
1356   UInt_t col = GetColFromKey(key);
1357   UInt_t row = GetRowFromKey(key);
1358   return IsPixelDead(eq,hs,chip,col,row);
1359 }
1360 //____________________________________________________________________________________________
1361 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisyKey(Int_t key) const {
1362   // is this pixel noisy?
1363   UInt_t eq = GetEqIdFromKey(key);
1364   UInt_t hs = GetHSFromKey(key);
1365   UInt_t chip = GetChipFromKey(key);
1366   UInt_t col = GetColFromKey(key);
1367   UInt_t row = GetRowFromKey(key);
1368   return IsPixelNoisy(eq,hs,chip,col,row);
1369 }
1370 //____________________________________________________________________________________________
1371 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilent() const {
1372   // returns the total nr of silent pixels (dead or inactive)
1373   UInt_t nrDead = 0;
1374   for (UInt_t eq=0; eq<20; eq++) {
1375     if (!IsActiveEq(eq)) {
1376       nrDead+=81920*6;
1377       continue;
1378     }
1379     for (UInt_t hs=0; hs<6; hs++) {
1380       if (!IsActiveHS(eq,hs)) {
1381         nrDead+=81920;
1382         continue;
1383       }
1384       for (UInt_t chip=0; chip<10; chip++) {
1385         if (!IsActiveChip(eq,hs,chip)) {
1386           nrDead+=8192;
1387           continue;
1388         }
1389         else {
1390           UInt_t gloChip = GetGloChip(eq,hs,chip);
1391           nrDead+=fNrDead[gloChip];
1392         }
1393       }
1394     }
1395   }
1396   return nrDead;
1397 }
1398 //____________________________________________________________________________________________
1399 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDead() const {
1400   // returns the total nr of dead pixels
1401   UInt_t nrDead = 0;
1402   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
1403     nrDead+=fNrDead[gloChip];
1404   }
1405   return nrDead;
1406 }
1407 //____________________________________________________________________________________________
1408 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisy() const {
1409   // returns the total nr of noisy pixels
1410   UInt_t nrNoisy = 0;
1411   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
1412     nrNoisy+=fNrNoisy[gloChip];
1413   }
1414   return nrNoisy;
1415 }
1416 //____________________________________________________________________________________________
1417 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAt(UInt_t index) {
1418   // get eq for the dead pixel at position index in list of dead
1419   UInt_t gloChip;
1420   UInt_t chipIndex;
1421   GetChipAndIndexTotDead(index,gloChip,chipIndex);
1422   return GetDeadEqIdAtC2(gloChip,chipIndex);
1423 }
1424 //____________________________________________________________________________________________
1425 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAt(UInt_t index) {
1426   // get eq for the noisy pixel at position index in list of noisy
1427   UInt_t gloChip;
1428   UInt_t chipIndex;
1429   GetChipAndIndexTotNoisy(index,gloChip,chipIndex);
1430   return GetNoisyEqIdAtC2(gloChip,chipIndex);
1431 }
1432 //____________________________________________________________________________________________
1433 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAt(UInt_t index) {
1434   // get hs for the dead pixel at position index in list of dead
1435   UInt_t gloChip;
1436   UInt_t chipIndex;
1437   GetChipAndIndexTotDead(index,gloChip,chipIndex);
1438   return GetDeadHSAtC2(gloChip,chipIndex);
1439 }
1440 //____________________________________________________________________________________________
1441 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAt(UInt_t index) {
1442   // get hs for the noisy pixel at position index in list of noisy
1443   UInt_t gloChip;
1444   UInt_t chipIndex;
1445   GetChipAndIndexTotNoisy(index,gloChip,chipIndex);
1446   return GetNoisyHSAtC2(gloChip,chipIndex);
1447 }
1448 //____________________________________________________________________________________________
1449 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAt(UInt_t index) {
1450   // get chip for the dead pixel at position index in list of dead
1451   UInt_t gloChip;
1452   UInt_t chipIndex;
1453   GetChipAndIndexTotDead(index,gloChip,chipIndex);
1454   return GetDeadChipAtC2(gloChip,chipIndex);
1455 }
1456 //____________________________________________________________________________________________
1457 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAt(UInt_t index) {
1458   // get chip for the noisy pixel at position index in list of noisy
1459   UInt_t gloChip;
1460   UInt_t chipIndex;
1461   GetChipAndIndexTotNoisy(index,gloChip,chipIndex);
1462   return GetNoisyChipAtC2(gloChip,chipIndex);
1463 }
1464 //____________________________________________________________________________________________
1465 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t index) {
1466   // get hs for the dead pixel at position index in list of dead
1467   UInt_t gloChip;
1468   UInt_t chipIndex;
1469   GetChipAndIndexTotDead(index,gloChip,chipIndex);
1470   return GetDeadColAtC2(gloChip,chipIndex);
1471 }
1472 //____________________________________________________________________________________________
1473 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t index) {
1474   // get hs for the noisy pixel at position index in list of noisy
1475   UInt_t gloChip;
1476   UInt_t chipIndex;
1477   GetChipAndIndexTotNoisy(index,gloChip,chipIndex);
1478   return GetNoisyColAtC2(gloChip,chipIndex);
1479 }
1480 //____________________________________________________________________________________________
1481 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t index) {
1482   // get hs for the dead pixel at position index in list of dead
1483   UInt_t gloChip;
1484   UInt_t chipIndex;
1485   GetChipAndIndexTotDead(index,gloChip,chipIndex);
1486   return GetDeadRowAtC2(gloChip,chipIndex);
1487 }
1488 //____________________________________________________________________________________________
1489 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t index) {
1490   // get hs for the noisy pixel at position index in list of noisy
1491   UInt_t gloChip;
1492   UInt_t chipIndex;
1493   GetChipAndIndexTotNoisy(index,gloChip,chipIndex);
1494   return GetNoisyRowAtC2(gloChip,chipIndex);
1495 }
1496 //____________________________________________________________________________________________
1497 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilent(UInt_t module) const {
1498   // returns the number of silent pixels for a certain module (dead or inactive)
1499   if (module>=240) {
1500     Error("AliITSOnlineCalibrationSPDhandler::GetNrSilent", "module nr (%d) out of bounds.",module);
1501     return 0;
1502   }
1503   UInt_t nrSilent = 0;
1504   UInt_t eq = GetEqIdFromOffline(module);
1505   if (!IsActiveEq(eq)) return 160*256;
1506   UInt_t hs = GetHSFromOffline(module);
1507   if (!IsActiveHS(eq,hs)) return 160*256;
1508   for (UInt_t ch=0; ch<5; ch++) {
1509     UInt_t chip = GetChipFromOffline(module,ch*32);
1510     if (!IsActiveChip(eq,hs,chip)) {
1511       nrSilent+=8192;
1512     }
1513     else {
1514       UInt_t gloChip = GetGloChip(eq,hs,chip);
1515       nrSilent+=fNrDead[gloChip];
1516     }
1517   }
1518   return nrSilent;
1519 }
1520 //____________________________________________________________________________________________
1521 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDead(UInt_t module) const {
1522   // returns the number of dead pixels for a certain module
1523   if (module>=240) {
1524     Error("AliITSOnlineCalibrationSPDhandler::GetNrDead", "module nr (%d) out of bounds.",module);
1525     return 0;
1526   }
1527   UInt_t nrDead = 0;
1528   UInt_t eq = GetEqIdFromOffline(module);
1529   UInt_t hs = GetHSFromOffline(module);
1530   for (UInt_t ch=0; ch<5; ch++) {
1531     UInt_t gloChip = GetGloChip(eq,hs,GetChipFromOffline(module,ch*32));
1532     nrDead+=fNrDead[gloChip];
1533   }
1534   return nrDead;
1535 }
1536 //____________________________________________________________________________________________
1537 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisy(UInt_t module) const {
1538   // returns the number of noisy pixels for a certain module
1539   if (module>=240) {
1540     Error("AliITSOnlineCalibrationSPDhandler::GetNrNoisy", "module nr (%d) out of bounds.",module);
1541     return 0;
1542   }
1543   UInt_t nrNoisy = 0;
1544   UInt_t eq = GetEqIdFromOffline(module);
1545   UInt_t hs = GetHSFromOffline(module);
1546   for (UInt_t ch=0; ch<5; ch++) {
1547     UInt_t gloChip = GetGloChip(eq,hs,GetChipFromOffline(module,ch*32));
1548     nrNoisy+=fNrNoisy[gloChip];
1549   }
1550   return nrNoisy;
1551 }
1552 //____________________________________________________________________________________________
1553 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAt(UInt_t module, UInt_t index) {
1554   // get eq for the dead pixel at position index in list of dead
1555   UInt_t gloChip;
1556   UInt_t chipIndex;
1557   GetChipAndIndexDead(module,index,gloChip,chipIndex);
1558   return GetDeadEqIdAtC2(gloChip,chipIndex);
1559 }
1560 //____________________________________________________________________________________________
1561 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAt(UInt_t module, UInt_t index) {
1562   // get eq for the noisy pixel at position index in list of noisy
1563   UInt_t gloChip;
1564   UInt_t chipIndex;
1565   GetChipAndIndexNoisy(module,index,gloChip,chipIndex);
1566   return GetNoisyEqIdAtC2(gloChip,chipIndex);
1567 }
1568 //____________________________________________________________________________________________
1569 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAt(UInt_t module, UInt_t index) {
1570   // get hs for the dead pixel at position index in list of dead
1571   UInt_t gloChip;
1572   UInt_t chipIndex;
1573   GetChipAndIndexDead(module,index,gloChip,chipIndex);
1574   return GetDeadHSAtC2(gloChip,chipIndex);
1575 }
1576 //____________________________________________________________________________________________
1577 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAt(UInt_t module, UInt_t index) {
1578   // get hs for the noisy pixel at position index in list of noisy
1579   UInt_t gloChip;
1580   UInt_t chipIndex;
1581   GetChipAndIndexNoisy(module,index,gloChip,chipIndex);
1582   return GetNoisyHSAtC2(gloChip,chipIndex);
1583 }
1584 //____________________________________________________________________________________________
1585 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAt(UInt_t module, UInt_t index) {
1586   // get chip for the dead pixel at position index in list of dead
1587   UInt_t gloChip;
1588   UInt_t chipIndex;
1589   GetChipAndIndexDead(module,index,gloChip,chipIndex);
1590   return GetDeadChipAtC2(gloChip,chipIndex);
1591 }
1592 //____________________________________________________________________________________________
1593 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAt(UInt_t module, UInt_t index) {
1594   // get chip for the noisy pixel at position index in list of noisy
1595   UInt_t gloChip;
1596   UInt_t chipIndex;
1597   GetChipAndIndexNoisy(module,index,gloChip,chipIndex);
1598   return GetNoisyChipAtC2(gloChip,chipIndex);
1599 }
1600 //____________________________________________________________________________________________
1601 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t module, UInt_t index) {
1602   // get hs for the dead pixel at position index in list of dead
1603   UInt_t gloChip;
1604   UInt_t chipIndex;
1605   GetChipAndIndexDead(module,index,gloChip,chipIndex);
1606   return GetDeadColAtC2(gloChip,chipIndex);
1607 }
1608 //____________________________________________________________________________________________
1609 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t module, UInt_t index) {
1610   // get hs for the noisy pixel at position index in list of noisy
1611   UInt_t gloChip;
1612   UInt_t chipIndex;
1613   GetChipAndIndexNoisy(module,index,gloChip,chipIndex);
1614   return GetNoisyColAtC2(gloChip,chipIndex);
1615 }
1616 //____________________________________________________________________________________________
1617 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t module, UInt_t index) {
1618   // get hs for the dead pixel at position index in list of dead
1619   UInt_t gloChip;
1620   UInt_t chipIndex;
1621   GetChipAndIndexDead(module,index,gloChip,chipIndex);
1622   return GetDeadRowAtC2(gloChip,chipIndex);
1623 }
1624 //____________________________________________________________________________________________
1625 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t module, UInt_t index) {
1626   // get hs for the noisy pixel at position index in list of noisy
1627   UInt_t gloChip;
1628   UInt_t chipIndex;
1629   GetChipAndIndexNoisy(module,index,gloChip,chipIndex);
1630   return GetNoisyRowAtC2(gloChip,chipIndex);
1631 }
1632 //____________________________________________________________________________________________
1633 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilentEq(UInt_t eq) const {
1634   // returns nr of silent for eq (dead or inactive)
1635   UInt_t returnval=0;
1636   if (!IsActiveEq(eq)) return 81920*6;
1637   for (UInt_t hs=0; hs<6; hs++) {
1638     if (!IsActiveHS(eq,hs)) {
1639       returnval+=81920;
1640       continue;
1641     }
1642     for (UInt_t chip=0; chip<10; chip++) {
1643       if (!IsActiveChip(eq,hs,chip)) {
1644         returnval+=8192;
1645         continue;
1646       }
1647       else { 
1648         returnval+=GetNrDeadC(eq,hs,chip);
1649       }
1650     }
1651   }
1652   return returnval;
1653 }
1654 //____________________________________________________________________________________________
1655 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDeadEq(UInt_t eq) const {
1656   // returns nr of dead for eq
1657   UInt_t returnval=0;
1658   for (UInt_t hs=0; hs<6; hs++) {
1659     for (UInt_t chip=0; chip<10; chip++) {
1660       returnval+=GetNrDeadC(eq,hs,chip);
1661     }
1662   }
1663   return returnval;
1664 }
1665 //____________________________________________________________________________________________
1666 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisyEq(UInt_t eq) const {
1667   // returns nr of noisy for eq
1668   UInt_t returnval=0;
1669   for (UInt_t hs=0; hs<6; hs++) {
1670     for (UInt_t chip=0; chip<10; chip++) {
1671       returnval+=GetNrNoisyC(eq,hs,chip);
1672     }
1673   }
1674   return returnval;
1675 }
1676 //____________________________________________________________________________________________
1677 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAtEq(UInt_t eq, UInt_t index) const {
1678   // get eq for the dead pixel at position index in list of dead
1679   if (eq<20 && index<GetNrDeadEq(eq)) {
1680     return eq;
1681   }
1682   else {
1683     return 20;
1684   }
1685 }
1686 //____________________________________________________________________________________________
1687 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAtEq(UInt_t eq, UInt_t index) const {
1688   // get eq for the noisy pixel at position index in list of noisy
1689   if (eq<20 && index<GetNrNoisyEq(eq)) {
1690     return eq;
1691   }
1692   else {
1693     return 20;
1694   }
1695 }
1696 //____________________________________________________________________________________________
1697 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAtEq(UInt_t eq, UInt_t index) {
1698   // get hs for the dead pixel at position index in list of dead
1699   UInt_t gloChip;
1700   UInt_t chipIndex;
1701   GetChipAndIndexEqDead(eq,index,gloChip,chipIndex);
1702   return GetDeadHSAtC2(gloChip,chipIndex);
1703 }
1704 //____________________________________________________________________________________________
1705 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAtEq(UInt_t eq, UInt_t index) {
1706   // get hs for the noisy pixel at position index in list of noisy
1707   UInt_t gloChip;
1708   UInt_t chipIndex;
1709   GetChipAndIndexEqNoisy(eq,index,gloChip,chipIndex);
1710   return GetNoisyHSAtC2(gloChip,chipIndex);
1711 }
1712 //____________________________________________________________________________________________
1713 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAtEq(UInt_t eq, UInt_t index) {
1714   // get chip for the dead pixel at position index in list of dead
1715   UInt_t gloChip;
1716   UInt_t chipIndex;
1717   GetChipAndIndexEqDead(eq,index,gloChip,chipIndex);
1718   return GetDeadChipAtC2(gloChip,chipIndex);
1719 }
1720 //____________________________________________________________________________________________
1721 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAtEq(UInt_t eq, UInt_t index) {
1722   // get chip for the noisy pixel at position index in list of noisy
1723   UInt_t gloChip;
1724   UInt_t chipIndex;
1725   GetChipAndIndexEqNoisy(eq,index,gloChip,chipIndex);
1726   return GetNoisyChipAtC2(gloChip,chipIndex);
1727 }
1728 //____________________________________________________________________________________________
1729 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAtEq(UInt_t eq, UInt_t index) {
1730   // get hs for the dead pixel at position index in list of dead
1731   UInt_t gloChip;
1732   UInt_t chipIndex;
1733   GetChipAndIndexEqDead(eq,index,gloChip,chipIndex);
1734   return GetDeadColAtC2(gloChip,chipIndex);
1735 }
1736 //____________________________________________________________________________________________
1737 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAtEq(UInt_t eq, UInt_t index) {
1738   // get hs for the noisy pixel at position index in list of noisy
1739   UInt_t gloChip;
1740   UInt_t chipIndex;
1741   GetChipAndIndexEqNoisy(eq,index,gloChip,chipIndex);
1742   return GetNoisyColAtC2(gloChip,chipIndex);
1743 }
1744 //____________________________________________________________________________________________
1745 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAtEq(UInt_t eq, UInt_t index) {
1746   // get hs for the dead pixel at position index in list of dead
1747   UInt_t gloChip;
1748   UInt_t chipIndex;
1749   GetChipAndIndexEqDead(eq,index,gloChip,chipIndex);
1750   return GetDeadRowAtC2(gloChip,chipIndex);
1751 }
1752 //____________________________________________________________________________________________
1753 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAtEq(UInt_t eq, UInt_t index) {
1754   // get hs for the noisy pixel at position index in list of noisy
1755   UInt_t gloChip;
1756   UInt_t chipIndex;
1757   GetChipAndIndexEqNoisy(eq,index,gloChip,chipIndex);
1758   return GetNoisyRowAtC2(gloChip,chipIndex);
1759 }
1760 //____________________________________________________________________________________________
1761 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilentC(UInt_t eq, UInt_t hs, UInt_t chip) const {
1762   // returns nr of silent for chip (dead or inactive)
1763   if (!(IsActiveEq(eq) && IsActiveHS(eq,hs) && IsActiveChip(eq,hs,chip))) return 8192;
1764   else return GetNrDeadC(eq,hs,chip);
1765 }
1766 //____________________________________________________________________________________________
1767 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDeadC(UInt_t eq, UInt_t hs, UInt_t chip) const {
1768   // returns nr of dead for chip
1769   UInt_t gloChip = GetGloChip(eq,hs,chip);
1770   return GetNrDeadC2(gloChip);
1771 }
1772 //____________________________________________________________________________________________
1773 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisyC(UInt_t eq, UInt_t hs, UInt_t chip) const {
1774   // returns nr of noisy for chip
1775   UInt_t gloChip = GetGloChip(eq,hs,chip);
1776   return GetNrNoisyC2(gloChip);
1777 }
1778 //____________________________________________________________________________________________
1779 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1780   UInt_t gloChip = GetGloChip(eq,hs,chip);
1781   return GetDeadEqIdAtC2(gloChip,index);
1782 }
1783 //____________________________________________________________________________________________
1784 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1785   UInt_t gloChip = GetGloChip(eq,hs,chip);
1786   return GetNoisyEqIdAtC2(gloChip,index);
1787 }
1788 //____________________________________________________________________________________________
1789 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1790   UInt_t gloChip = GetGloChip(eq,hs,chip);
1791   return GetDeadHSAtC2(gloChip,index);
1792 }
1793 //____________________________________________________________________________________________
1794 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1795   UInt_t gloChip = GetGloChip(eq,hs,chip);
1796   return GetNoisyHSAtC2(gloChip,index);
1797 }
1798 //____________________________________________________________________________________________
1799 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1800   UInt_t gloChip = GetGloChip(eq,hs,chip);
1801   return GetDeadChipAtC2(gloChip,index);
1802 }
1803 //____________________________________________________________________________________________
1804 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1805   UInt_t gloChip = GetGloChip(eq,hs,chip);
1806   return GetNoisyChipAtC2(gloChip,index);
1807 }
1808 //____________________________________________________________________________________________
1809 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1810   UInt_t gloChip = GetGloChip(eq,hs,chip);
1811   return GetDeadColAtC2(gloChip,index);
1812 }
1813 //____________________________________________________________________________________________
1814 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1815   UInt_t gloChip = GetGloChip(eq,hs,chip);
1816   return GetNoisyColAtC2(gloChip,index);
1817 }
1818 //____________________________________________________________________________________________
1819 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1820   UInt_t gloChip = GetGloChip(eq,hs,chip);
1821   return GetDeadRowAtC2(gloChip,index);
1822 }
1823 //____________________________________________________________________________________________
1824 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1825   UInt_t gloChip = GetGloChip(eq,hs,chip);
1826   return GetNoisyRowAtC2(gloChip,index);
1827 }
1828 //____________________________________________________________________________________________
1829 const Char_t* AliITSOnlineCalibrationSPDhandler::GetDeadPixelAsTextC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1830   // get a string of dead pixel info
1831   TString returnMess = "";
1832   UInt_t gloChip = GetGloChip(eq,hs,chip);
1833   if (gloChip>=1200) {
1834     Error("AliITSOnlineCalibrationSPDhandler::GetDeadPixelAsTextC", "global chip nr (%d) out of bounds.",gloChip);
1835     return returnMess.Data();
1836   }
1837   if (index<fNrDead[gloChip]) {
1838     Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
1839     UInt_t col = GetColFromKey(key);
1840     UInt_t row = GetRowFromKey(key);
1841     UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
1842     UInt_t colM = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,col);
1843     UInt_t rowM = AliITSRawStreamSPD::GetOfflineRowFromOnline(eq,hs,chip,row);
1844     returnMess = Form("%*d,%*d,%*d,%*d,%*d  |  %*d,%*d,%*d\n",2,eq,1,hs,1,chip,2,col,3,row,3,module,3,colM,3,rowM);
1845     return returnMess.Data();
1846   }
1847   else {
1848     Error("AliITSOnlineCalibrationSPDhandler::GetDeadPixelAsTextC", "Index %d out of bounds.", index);
1849     return returnMess.Data();
1850   }
1851 }
1852 //____________________________________________________________________________________________
1853 const Char_t* AliITSOnlineCalibrationSPDhandler::GetNoisyPixelAsTextC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const {
1854   // get a string of noisy pixel info
1855   TString returnMess = "";
1856   UInt_t gloChip = GetGloChip(eq,hs,chip);
1857   if (gloChip>=1200) {
1858     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyPixelAsTextC", "global chip nr (%d) out of bounds.",gloChip);
1859     return returnMess.Data();
1860   }
1861   if (index<fNrNoisy[gloChip]) {
1862     Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(index);
1863     UInt_t col = GetColFromKey(key);
1864     UInt_t row = GetRowFromKey(key);    
1865     UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
1866     UInt_t colM = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,col);
1867     UInt_t rowM = AliITSRawStreamSPD::GetOfflineRowFromOnline(eq,hs,chip,row);
1868     returnMess = Form("%*d,%*d,%*d,%*d,%*d  |  %*d,%*d,%*d\n",2,eq,1,hs,1,chip,2,col,3,row,3,module,3,colM,3,rowM);
1869     return returnMess.Data();
1870   }
1871   else {
1872     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyPixelAsTextC", "Index %d out of bounds.", index);
1873     return returnMess.Data();
1874   }
1875 }
1876 //____________________________________________________________________________________________
1877 UInt_t AliITSOnlineCalibrationSPDhandler::AddSilentFrom(AliITSOnlineCalibrationSPDhandler* other) {
1878   // returns number of new silent pixels in this' list (dead or inactive)
1879   UInt_t tmpdead = GetNrSilent();
1880
1881   for (UInt_t eq=0; eq<20; eq++) {
1882     if (!(other->IsActiveEq(eq))) ActivateEq(eq,kFALSE);
1883     for (UInt_t hs=0; hs<6; hs++) {
1884       if (!(other->IsActiveHS(eq,hs))) ActivateHS(eq,hs,kFALSE);
1885       for (UInt_t chip=0; chip<10; chip++) {
1886         if (!(other->IsActiveChip(eq,hs,chip))) ActivateChip(eq,hs,chip,kFALSE);
1887       }
1888     }
1889   }
1890
1891   AddDeadFrom(other);
1892
1893   return GetNrSilent() - tmpdead;
1894 }
1895 //____________________________________________________________________________________________
1896 UInt_t AliITSOnlineCalibrationSPDhandler::AddDeadFrom(AliITSOnlineCalibrationSPDhandler* other) {
1897   // returns number of new dead pixels in this' list
1898   UInt_t returnval=0;
1899   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
1900     for (UInt_t ind1=0; ind1<other->fNrDead[gloChip]; ind1++) {
1901       UInt_t eq = other->GetDeadEqIdAtC2(gloChip,ind1);
1902       UInt_t hs   = other->GetDeadHSAtC2(gloChip,ind1);
1903       UInt_t chip = other->GetDeadChipAtC2(gloChip,ind1);
1904       UInt_t col  = other->GetDeadColAtC2(gloChip,ind1);
1905       UInt_t row  = other->GetDeadRowAtC2(gloChip,ind1);
1906       if (SetDeadPixel(eq,hs,chip,col,row)) {
1907         returnval++;
1908       }
1909     }
1910   }
1911   return returnval;
1912 }
1913 //____________________________________________________________________________________________
1914 UInt_t AliITSOnlineCalibrationSPDhandler::AddNoisyFrom(AliITSOnlineCalibrationSPDhandler* other) {
1915   // returns number of new noisy pixels in this' list
1916   UInt_t returnval=0;
1917   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
1918     for (UInt_t ind1=0; ind1<other->fNrNoisy[gloChip]; ind1++) {
1919       UInt_t eq = other->GetNoisyEqIdAtC2(gloChip,ind1);
1920       UInt_t hs   = other->GetNoisyHSAtC2(gloChip,ind1);
1921       UInt_t chip = other->GetNoisyChipAtC2(gloChip,ind1);
1922       UInt_t col  = other->GetNoisyColAtC2(gloChip,ind1);
1923       UInt_t row  = other->GetNoisyRowAtC2(gloChip,ind1);
1924       if (SetNoisyPixel(eq,hs,chip,col,row)) {
1925         returnval++;
1926       }
1927     }
1928   }
1929   return returnval;
1930 }
1931 //____________________________________________________________________________________________
1932 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDiff(AliITSOnlineCalibrationSPDhandler* other) const {
1933   // returns nr of dead/noisy in this' lists and not in other's lists (including inactive)
1934   return GetNrSilentDiff(other) + GetNrNoisyDiff(other);
1935 }
1936 //____________________________________________________________________________________________
1937 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilentDiff(AliITSOnlineCalibrationSPDhandler* other) const {
1938   // returns nr of single silent pixels in this' lists and not in other's lists (dead or inactive)
1939   UInt_t returnval=0;
1940   for (UInt_t eq=0; eq<20; eq++) {
1941     for (UInt_t hs=0; hs<6; hs++) {
1942       for (UInt_t chip=0; chip<10; chip++) {
1943         if (!(IsActiveEq(eq) && IsActiveHS(eq,hs) && IsActiveChip(eq,hs,chip))) {
1944           if (other->IsActiveEq(eq) && other->IsActiveHS(eq,hs) && other->IsActiveChip(eq,hs,chip)) {
1945             // if this is inactive and the other is active...
1946             returnval+= 8192 - other->GetNrDeadC(eq,hs,chip);
1947           }
1948         }
1949         else {
1950           UInt_t gloChip = GetGloChip(eq,hs,chip);
1951           for (UInt_t ind1=0; ind1<fNrDead[gloChip]; ind1++) {
1952             Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(ind1);
1953             UInt_t col = GetColFromKey(key);
1954             UInt_t row = GetRowFromKey(key);
1955             if (!(other->IsPixelSilent(eq,hs,chip,col,row))) {
1956               returnval++;
1957             }
1958           }
1959         }
1960       }
1961     }
1962   }
1963   return returnval;
1964 }
1965 //____________________________________________________________________________________________
1966 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const {
1967   // returns nr of dead in this' lists and not in other's lists
1968   UInt_t returnval=0;
1969   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
1970     for (UInt_t ind1=0; ind1<fNrDead[gloChip]; ind1++) {
1971       Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(ind1);
1972       UInt_t eq = GetEqIdFromKey(key);
1973       UInt_t hs = GetHSFromKey(key);
1974       UInt_t chip = GetChipFromKey(key);
1975       UInt_t col = GetColFromKey(key);
1976       UInt_t row = GetRowFromKey(key);
1977       if (!(other->IsPixelDead(eq,hs,chip,col,row))) {
1978         returnval++;
1979       }
1980     }
1981   }
1982   return returnval;
1983 }
1984 //____________________________________________________________________________________________
1985 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const {
1986   // returns nr of noisy in this' lists and not in other's lists
1987   UInt_t returnval=0;
1988   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
1989     for (UInt_t ind1=0; ind1<fNrNoisy[gloChip]; ind1++) {
1990       Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(ind1);
1991       UInt_t eq = GetEqIdFromKey(key);
1992       UInt_t hs = GetHSFromKey(key);
1993       UInt_t chip = GetChipFromKey(key);
1994       UInt_t col = GetColFromKey(key);
1995       UInt_t row = GetRowFromKey(key);
1996       if (!(other->IsPixelNoisy(eq,hs,chip,col,row))) {
1997         returnval++;
1998       }
1999     }
2000   }
2001   return returnval;
2002 }
2003 //____________________________________________________________________________________________
2004 AliITSOnlineCalibrationSPDhandler* AliITSOnlineCalibrationSPDhandler::GetDiff(AliITSOnlineCalibrationSPDhandler* other) const {
2005   // returns handler with active/dead/noisy in this' lists, removing those that are in other's lists
2006   AliITSOnlineCalibrationSPDhandler* newHandler = new AliITSOnlineCalibrationSPDhandler();
2007
2008   for (UInt_t eq=0; eq<20; eq++) {
2009     if (!(IsActiveEq(eq))) {
2010       newHandler->ActivateEq(eq,kFALSE);
2011       if (!other->IsActiveEq(eq)) newHandler->ActivateEq(eq);
2012     }
2013     for (UInt_t hs=0; hs<6; hs++) {
2014       if (!(IsActiveHS(eq,hs))) {
2015         newHandler->ActivateHS(eq,hs,kFALSE);
2016         if (!other->IsActiveHS(eq,hs)) newHandler->ActivateHS(eq,hs);
2017       }
2018       for (UInt_t chip=0; chip<10; chip++) {
2019         if (!(IsActiveChip(eq,hs,chip))) {
2020           newHandler->ActivateChip(eq,hs,chip,kFALSE);
2021           if (!other->IsActiveChip(eq,hs,chip)) newHandler->ActivateHS(eq,hs,chip);
2022         }
2023       }
2024     }
2025   }
2026
2027   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
2028     for (UInt_t ind1=0; ind1<fNrDead[gloChip]; ind1++) {
2029       Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(ind1);
2030       UInt_t eq = GetEqIdFromKey(key);
2031       UInt_t hs = GetHSFromKey(key);
2032       UInt_t chip = GetChipFromKey(key);
2033       UInt_t col = GetColFromKey(key);
2034       UInt_t row = GetRowFromKey(key);
2035       if (!(other->IsPixelDead(eq,hs,chip,col,row))) {
2036         newHandler->SetDeadPixel(eq,hs,chip,col,row);
2037       }
2038     }
2039   }
2040
2041   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
2042     for (UInt_t ind2=0; ind2<fNrNoisy[gloChip]; ind2++) {
2043       Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(ind2);
2044       UInt_t eq = GetEqIdFromKey(key);
2045       UInt_t hs = GetHSFromKey(key);
2046       UInt_t chip = GetChipFromKey(key);
2047       UInt_t col = GetColFromKey(key);
2048       UInt_t row = GetRowFromKey(key);
2049       if (!(other->IsPixelNoisy(eq,hs,chip,col,row))) {
2050         newHandler->SetNoisyPixel(eq,hs,chip,col,row);
2051       }
2052     }
2053   }
2054
2055   return newHandler;
2056 }
2057 //____________________________________________________________________________________________
2058 AliITSOnlineCalibrationSPDhandler* AliITSOnlineCalibrationSPDhandler::GetSilentDiff(AliITSOnlineCalibrationSPDhandler* other) const {
2059   // returns handler with active/dead in this' lists, removing those that are in other's lists
2060   AliITSOnlineCalibrationSPDhandler* newHandler = new AliITSOnlineCalibrationSPDhandler();
2061
2062   for (UInt_t eq=0; eq<20; eq++) {
2063     if (!(IsActiveEq(eq))) {
2064       newHandler->ActivateEq(eq,kFALSE);
2065       if (!other->IsActiveEq(eq)) newHandler->ActivateEq(eq);
2066     }
2067     for (UInt_t hs=0; hs<6; hs++) {
2068       if (!(IsActiveHS(eq,hs))) {
2069         newHandler->ActivateHS(eq,hs,kFALSE);
2070         if (!other->IsActiveHS(eq,hs)) newHandler->ActivateHS(eq,hs);
2071       }
2072       for (UInt_t chip=0; chip<10; chip++) {
2073         if (!(IsActiveChip(eq,hs,chip))) {
2074           newHandler->ActivateChip(eq,hs,chip,kFALSE);
2075           if (!other->IsActiveChip(eq,hs,chip)) newHandler->ActivateHS(eq,hs,chip);
2076         }
2077       }
2078     }
2079   }
2080
2081   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
2082     for (UInt_t ind1=0; ind1<fNrDead[gloChip]; ind1++) {
2083       Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(ind1);
2084       UInt_t eq = GetEqIdFromKey(key);
2085       UInt_t hs = GetHSFromKey(key);
2086       UInt_t chip = GetChipFromKey(key);
2087       UInt_t col = GetColFromKey(key);
2088       UInt_t row = GetRowFromKey(key);
2089       if (!(other->IsPixelDead(eq,hs,chip,col,row))) {
2090         newHandler->SetDeadPixel(eq,hs,chip,col,row);
2091       }
2092     }
2093   }
2094
2095   return newHandler;
2096 }
2097 //____________________________________________________________________________________________
2098 AliITSOnlineCalibrationSPDhandler* AliITSOnlineCalibrationSPDhandler::GetDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const {
2099   // returns handler with dead in this' lists, except for those in other's lists
2100   AliITSOnlineCalibrationSPDhandler* newHandler = new AliITSOnlineCalibrationSPDhandler();
2101   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
2102     for (UInt_t ind1=0; ind1<fNrDead[gloChip]; ind1++) {
2103       Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(ind1);
2104       UInt_t eq = GetEqIdFromKey(key);
2105       UInt_t hs = GetHSFromKey(key);
2106       UInt_t chip = GetChipFromKey(key);
2107       UInt_t col = GetColFromKey(key);
2108       UInt_t row = GetRowFromKey(key);
2109       if (!(other->IsPixelDead(eq,hs,chip,col,row))) {
2110         newHandler->SetDeadPixel(eq,hs,chip,col,row);
2111       }
2112     }
2113   }
2114   return newHandler;
2115 }
2116 //____________________________________________________________________________________________
2117 AliITSOnlineCalibrationSPDhandler* AliITSOnlineCalibrationSPDhandler::GetNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const {
2118   // returns handler with noisy in this' lists, except for those in other's lists
2119   AliITSOnlineCalibrationSPDhandler* newHandler = new AliITSOnlineCalibrationSPDhandler();
2120   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
2121     for (UInt_t ind2=0; ind2<fNrNoisy[gloChip]; ind2++) {
2122       Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(ind2);
2123       UInt_t eq = GetEqIdFromKey(key);
2124       UInt_t hs = GetHSFromKey(key);
2125       UInt_t chip = GetChipFromKey(key);
2126       UInt_t col = GetColFromKey(key);
2127       UInt_t row = GetRowFromKey(key);
2128       if (!(other->IsPixelNoisy(eq,hs,chip,col,row))) {
2129         newHandler->SetNoisyPixel(eq,hs,chip,col,row);
2130       }
2131     }
2132   }
2133   return newHandler;
2134 }
2135 //____________________________________________________________________________________________
2136 void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexDead(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
2137   // find gloChip and chipIndex from module and index
2138   if (index<GetNrDead(module)) {
2139     UInt_t eq = GetEqIdFromOffline(module);
2140     UInt_t hs = GetHSFromOffline(module);
2141     
2142     UInt_t glVal=0;
2143     for (UInt_t ch=0; ch<5; ch++) {
2144       gloChip = GetGloChip(eq,hs,GetChipFromOffline(module,ch*32));
2145       if (glVal+fNrDead[gloChip]>index) {
2146         chipIndex = index-glVal;
2147         break;
2148       }
2149       else {
2150         glVal+=fNrDead[gloChip];
2151       }
2152     }
2153
2154   }
2155   else {
2156     Error("AliITSOnlineCalibrationSPDhandler::GetChipAndIndexDead", "Index %d out of bounds.", index);
2157   }
2158 }
2159 //____________________________________________________________________________________________
2160 void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexNoisy(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
2161   // find gloChip and chipIndex from module and index
2162   if (index<GetNrNoisy(module)) {
2163     UInt_t eq = GetEqIdFromOffline(module);
2164     UInt_t hs = GetHSFromOffline(module);
2165     
2166     UInt_t glVal=0;
2167     for (UInt_t ch=0; ch<5; ch++) {
2168       gloChip = GetGloChip(eq,hs,GetChipFromOffline(module,ch*32));
2169       if (glVal+fNrNoisy[gloChip]>index) {
2170         chipIndex = index-glVal;
2171         break;
2172       }
2173       else {
2174         glVal+=fNrNoisy[gloChip];
2175       }
2176     }
2177
2178   }
2179   else {
2180     Error("AliITSOnlineCalibrationSPDhandler::GetChipAndIndexNoisy", "Index %d out of bounds.", index);
2181   }
2182 }
2183 //____________________________________________________________________________________________
2184 void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexEqDead(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
2185   // find gloChip and chipIndex from module and index
2186   if (index<GetNrDeadEq(eq)) {
2187
2188     UInt_t glVal=0;
2189     for (UInt_t hs=0; hs<6; hs++) {
2190       for (UInt_t chip=0; chip<10; chip++) {
2191         gloChip = GetGloChip(eq,hs,chip);
2192         if (glVal+fNrDead[gloChip]>index) {
2193           chipIndex = index-glVal;
2194           break;
2195         }
2196         else {
2197           glVal+=fNrDead[gloChip];
2198         }
2199       }
2200     }
2201
2202   }
2203   else {
2204     Error("AliITSOnlineCalibrationSPDhandler::GetChipAndIndexEqDead", "Index %d out of bounds.", index);
2205   }
2206 }
2207 //____________________________________________________________________________________________
2208 void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexEqNoisy(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
2209   // find gloChip and chipIndex from module and index
2210   if (index<GetNrNoisyEq(eq)) {
2211
2212     UInt_t glVal=0;
2213     for (UInt_t hs=0; hs<6; hs++) {
2214       for (UInt_t chip=0; chip<10; chip++) {
2215         gloChip = GetGloChip(eq,hs,chip);
2216         if (glVal+fNrNoisy[gloChip]>index) {
2217           chipIndex = index-glVal;
2218           break;
2219         }
2220         else {
2221           glVal+=fNrNoisy[gloChip];
2222         }
2223       }
2224     }
2225
2226   }
2227   else {
2228     Error("AliITSOnlineCalibrationSPDhandler::GetChipAndIndexEqNoisy", "Index %d out of bounds.", index);
2229   }
2230 }
2231 //____________________________________________________________________________________________
2232 void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexTotDead(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
2233   // find gloChip and chipIndex from global index
2234   if (index<GetNrDead()) {
2235     
2236     UInt_t glVal=0;
2237     for (gloChip=0; gloChip<1200; gloChip++) {
2238       if (glVal+fNrDead[gloChip]>index) {
2239         chipIndex = index-glVal;
2240         break;
2241       }
2242       else {
2243         glVal+=fNrDead[gloChip];
2244       }
2245     }
2246
2247   }
2248   else {
2249     Error("AliITSOnlineCalibrationSPDhandler::GetChipAndIndexTotDead", "Index %d out of bounds.", index);
2250   }
2251 }
2252 //____________________________________________________________________________________________
2253 void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexTotNoisy(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
2254   // find gloChip and chipIndex from global index
2255   if (index<GetNrNoisy()) {
2256     
2257     UInt_t glVal=0;
2258     for (gloChip=0; gloChip<1200; gloChip++) {
2259       if (glVal+fNrNoisy[gloChip]>index) {
2260         chipIndex = index-glVal;
2261         break;
2262       }
2263       else {
2264         glVal+=fNrNoisy[gloChip];
2265       }
2266     }
2267
2268   }
2269   else {
2270     Error("AliITSOnlineCalibrationSPDhandler::GetChipAndIndexTotNoisy", "Index %d out of bounds.", index);
2271   }
2272 }
2273 //____________________________________________________________________________________________
2274 UInt_t AliITSOnlineCalibrationSPDhandler::GetEqIdFromOffline(UInt_t module) const {
2275   // module to eq mapping
2276   if (module>=240) {
2277     Error("AliITSOnlineCalibrationSPDhandler::GetEqIdFromOffline", "module nr (%d) out of bounds.",module);
2278     return 20;
2279   }
2280   return AliITSRawStreamSPD::GetOnlineEqIdFromOffline(module);
2281 }
2282 //____________________________________________________________________________________________
2283 UInt_t AliITSOnlineCalibrationSPDhandler::GetHSFromOffline(UInt_t module) const {
2284   // module to hs mapping
2285   if (module>=240) {
2286     Error("AliITSOnlineCalibrationSPDhandler::GetHSFromOffline", "module nr (%d) out of bounds.",module);
2287     return 6;
2288   }
2289   return AliITSRawStreamSPD::GetOnlineHSFromOffline(module);
2290 }
2291 //____________________________________________________________________________________________
2292 UInt_t AliITSOnlineCalibrationSPDhandler::GetChipFromOffline(UInt_t module, UInt_t colM) const {
2293   // module,colM to chip mapping
2294   if (module>=240 || colM>=160) {
2295     Error("AliITSOnlineCalibrationSPDhandler::GetChipFromOffline", "module,colM nrs (%d,%d) out of bounds.",module,colM);
2296     return 10;
2297   }
2298   return AliITSRawStreamSPD::GetOnlineChipFromOffline(module,colM);
2299 }
2300 //____________________________________________________________________________________________
2301 UInt_t AliITSOnlineCalibrationSPDhandler::GetColFromOffline(UInt_t module, UInt_t colM) const {
2302   // colM to col mapping
2303   if (colM>=160) {
2304     Error("AliITSOnlineCalibrationSPDhandler::GetColFromOffline", "colM nr (%d) out of bounds.",colM);
2305     return 160;
2306   }
2307   return AliITSRawStreamSPD::GetOnlineColFromOffline(module,colM);
2308 }
2309 //____________________________________________________________________________________________
2310 UInt_t AliITSOnlineCalibrationSPDhandler::GetRowFromOffline(UInt_t module, UInt_t rowM) const {
2311   // rowM to row mapping
2312   if (rowM>=256) {
2313     Error("AliITSOnlineCalibrationSPDhandler::GetRowFromOffline", "rowM nr (%d) out of bounds.",rowM);
2314     return 256;
2315   }
2316   return AliITSRawStreamSPD::GetOnlineRowFromOffline(module,rowM);
2317 }
2318 //____________________________________________________________________________________________
2319 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDeadC2(UInt_t gloChip) const {
2320   // returns nr of dead pixels on this chip
2321   if (gloChip>=1200) {
2322     Error("AliITSOnlineCalibrationSPDhandler::GetNrDeadC2", "global chip nr (%d) out of bounds.",gloChip);
2323     return 0;
2324   }
2325   return fNrDead[gloChip];
2326 }
2327 //____________________________________________________________________________________________
2328 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisyC2(UInt_t gloChip) const {
2329   // returns nr of noisy pixels on this chip
2330   if (gloChip>=1200) {
2331     Error("AliITSOnlineCalibrationSPDhandler::GetNrNoisyC2", "global chip nr (%d) out of bounds.",gloChip);
2332     return 0;
2333   }
2334   return fNrNoisy[gloChip];
2335 }
2336 //____________________________________________________________________________________________
2337 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAtC2(UInt_t gloChip, UInt_t index) const {
2338   // get eq for the dead pixel at position index in list of dead
2339   if (gloChip>=1200) {
2340     Error("AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAtC", "global chip nr (%d) out of bounds.",gloChip);
2341     return 20;
2342   }
2343   if (index<fNrDead[gloChip]) {
2344     Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
2345     return GetEqIdFromKey(key);
2346   }
2347   else {
2348     Error("AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAtC", "Index %d out of bounds.", index);
2349     return 0;
2350   }
2351 }
2352 //____________________________________________________________________________________________
2353 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAtC2(UInt_t gloChip, UInt_t index) const {
2354   // get eq for the noisy pixel at position index in list of noisy
2355   if (gloChip>=1200) {
2356     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAtC", "global chip nr (%d) out of bounds.",gloChip);
2357     return 20;
2358   }
2359   if (index<fNrNoisy[gloChip]) {
2360     Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(index);
2361     return GetEqIdFromKey(key);
2362   }
2363   else {
2364     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAtC", "Index %d out of bounds.", index);
2365     return 0;
2366   }
2367 }
2368 //____________________________________________________________________________________________
2369 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAtC2(UInt_t gloChip, UInt_t index) const {
2370   // get hs for the dead pixel at position index in list of dead
2371   if (gloChip>=1200) {
2372     Error("AliITSOnlineCalibrationSPDhandler::GetDeadHSAtC", "global chip nr (%d) out of bounds.",gloChip);
2373     return 20;
2374   }
2375   if (index<fNrDead[gloChip]) {
2376     Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
2377     return GetHSFromKey(key);
2378   }
2379   else {
2380     Error("AliITSOnlineCalibrationSPDhandler::GetDeadHSAtC", "Index %d out of bounds.", index);
2381     return 0;
2382   }
2383 }
2384 //____________________________________________________________________________________________
2385 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAtC2(UInt_t gloChip, UInt_t index) const {
2386   // get hs for the noisy pixel at position index in list of noisy
2387   if (gloChip>=1200) {
2388     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyHSAtC", "global chip nr (%d) out of bounds.",gloChip);
2389     return 20;
2390   }
2391   if (index<fNrNoisy[gloChip]) {
2392     Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(index);
2393     return GetHSFromKey(key);
2394   }
2395   else {
2396     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyHSAtC", "Index %d out of bounds.", index);
2397     return 0;
2398   }
2399 }
2400 //____________________________________________________________________________________________
2401 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAtC2(UInt_t gloChip, UInt_t index) const {
2402   // get chip for the dead pixel at position index in list of dead
2403   if (gloChip>=1200) {
2404     Error("AliITSOnlineCalibrationSPDhandler::GetDeadChipAtC", "global chip nr (%d) out of bounds.",gloChip);
2405     return 20;
2406   }
2407   if (index<fNrDead[gloChip]) {
2408     Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
2409     return GetChipFromKey(key);
2410   }
2411   else {
2412     Error("AliITSOnlineCalibrationSPDhandler::GetDeadChipAtC", "Index %d out of bounds.", index);
2413     return 0;
2414   }
2415 }
2416 //____________________________________________________________________________________________
2417 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAtC2(UInt_t gloChip, UInt_t index) const {
2418   // get chip for the noisy pixel at position index in list of noisy
2419   if (gloChip>=1200) {
2420     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyChipAtC", "global chip nr (%d) out of bounds.",gloChip);
2421     return 20;
2422   }
2423   if (index<fNrNoisy[gloChip]) {
2424     Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(index);
2425     return GetChipFromKey(key);
2426   }
2427   else {
2428     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyChipAtC", "Index %d out of bounds.", index);
2429     return 0;
2430   }
2431 }
2432 //____________________________________________________________________________________________
2433 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAtC2(UInt_t gloChip, UInt_t index) const {
2434   // get col for the dead pixel at position index in list of dead
2435   if (gloChip>=1200) {
2436     Error("AliITSOnlineCalibrationSPDhandler::GetDeadColAtC2", "global chip nr (%d) out of bounds.",gloChip);
2437     return 20;
2438   }
2439   if (index<fNrDead[gloChip]) {
2440     Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
2441     return GetColFromKey(key);
2442   }
2443   else {
2444     Error("AliITSOnlineCalibrationSPDhandler::GetDeadColAtC2", "Index %d out of bounds.", index);
2445     return 0;
2446   }
2447 }
2448 //____________________________________________________________________________________________
2449 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAtC2(UInt_t gloChip, UInt_t index) const {
2450   // get col for the noisy pixel at position index in list of noisy
2451   if (gloChip>=1200) {
2452     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyColAtC", "global chip nr (%d) out of bounds.",gloChip);
2453     return 20;
2454   }
2455   if (index<fNrNoisy[gloChip]) {
2456     Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(index);
2457     return GetColFromKey(key);
2458   }
2459   else {
2460     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyColAtC", "Index %d out of bounds.", index);
2461     return 0;
2462   }
2463 }
2464 //____________________________________________________________________________________________
2465 UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAtC2(UInt_t gloChip, UInt_t index) const {
2466   // get row for the dead pixel at position index in list of dead
2467   if (gloChip>=1200) {
2468     Error("AliITSOnlineCalibrationSPDhandler::GetDeadRowAtC", "global chip nr (%d) out of bounds.",gloChip);
2469     return 20;
2470   }
2471   if (index<fNrDead[gloChip]) {
2472     Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
2473     return GetRowFromKey(key);
2474   }
2475   else {
2476     Error("AliITSOnlineCalibrationSPDhandler::GetDeadRowAtC", "Index %d out of bounds.", index);
2477     return 0;
2478   }
2479 }
2480 //____________________________________________________________________________________________
2481 UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAtC2(UInt_t gloChip, UInt_t index) const {
2482   // get row for the noisy pixel at position index in list of noisy
2483   if (gloChip>=1200) {
2484     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyRowAtC", "global chip nr (%d) out of bounds.",gloChip);
2485     return 20;
2486   }
2487   if (index<fNrNoisy[gloChip]) {
2488     Int_t key = fNoisyPixelMap[gloChip]->GetKeyIndex(index);
2489     return GetRowFromKey(key);
2490   }
2491   else {
2492     Error("AliITSOnlineCalibrationSPDhandler::GetNoisyRowAtC", "Index %d out of bounds.", index);
2493     return 0;
2494   }
2495 }
2496 //____________________________________________________________________________________________
2497 void AliITSOnlineCalibrationSPDhandler::ActivateALL() {
2498   for (UInt_t eq=0; eq<20; eq++) {
2499     ActivateEq(eq);
2500     for (UInt_t hs=0; hs<6; hs++) {
2501       ActivateHS(eq,hs);
2502       for (UInt_t chip=0; chip<10; chip++) {
2503         ActivateChip(eq,hs,chip);
2504       }
2505     }
2506   }
2507 }
2508 //____________________________________________________________________________________________
2509 void AliITSOnlineCalibrationSPDhandler::ActivateEq(UInt_t eq, Bool_t setval) {
2510   if (eq>=20) {
2511     Error("AliITSOnlineCalibrationSPDhandler::ActivateEq", "eq (%d) out of bounds.",eq);
2512     return;
2513   }
2514   fActiveEq[eq] = setval;
2515 }
2516 //____________________________________________________________________________________________
2517 void AliITSOnlineCalibrationSPDhandler::ActivateHS(UInt_t eq, UInt_t hs, Bool_t setval) {
2518   if (eq>=20 || hs>=6) {
2519     Error("AliITSOnlineCalibrationSPDhandler::ActivateHS", "eq,hs (%d,%d) out of bounds.",eq,hs);
2520     return;
2521   }
2522   fActiveHS[eq][hs] = setval;
2523 }
2524 //____________________________________________________________________________________________
2525 void AliITSOnlineCalibrationSPDhandler::ActivateChip(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setval) {
2526   if (eq>=20 || hs>=6 || chip>=10) {
2527     Error("AliITSOnlineCalibrationSPDhandler::ActivateChip", "eq,hs,chip (%d,%d,%d) out of bounds.",eq,hs,chip);
2528     return;
2529   }
2530   fActiveChip[eq][hs][chip] = setval;
2531 }
2532 //____________________________________________________________________________________________
2533 Bool_t AliITSOnlineCalibrationSPDhandler::IsActiveEq(UInt_t eq) const {
2534   if (eq>=20) {
2535     Error("AliITSOnlineCalibrationSPDhandler::IsActiveEq", "eq (%d) out of bounds.",eq);
2536     return kFALSE;
2537   }
2538   return fActiveEq[eq];
2539 }
2540 //____________________________________________________________________________________________
2541 Bool_t AliITSOnlineCalibrationSPDhandler::IsActiveHS(UInt_t eq, UInt_t hs) const {
2542   if (eq>=20 || hs>=6) {
2543     Error("AliITSOnlineCalibrationSPDhandler::IsActiveHS", "eq,hs (%d,%d) out of bounds.",eq,hs);
2544     return kFALSE;
2545   }
2546   return fActiveHS[eq][hs];
2547 }
2548 //____________________________________________________________________________________________
2549 Bool_t AliITSOnlineCalibrationSPDhandler::IsActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) const {
2550   if (eq>=20 || hs>=6 || chip>=10) {
2551     Error("AliITSOnlineCalibrationSPDhandler::IsActiveChip", "eq,hs,chip (%d,%d,%d) out of bounds.",eq,hs,chip);
2552     return kFALSE;
2553   }
2554   return fActiveChip[eq][hs][chip];
2555 }
2556