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