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