]>
Commit | Line | Data |
---|---|---|
4ee23d3d | 1 | /************************************************************************** |
2 | * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | /* $Id$ */ | |
18 | ||
b15de2d2 | 19 | ////////////////////////////////////////////////////////////////////// |
20 | // Author: Henrik Tydesjo // | |
21 | // For easier handling of dead and noisy pixels they are kept in // | |
22 | // container maps (AliITSIntMap). // | |
23 | // The TArrayI objects that are put in the AliITSCalibrationSPD // | |
24 | // objects can be obtained from the methods GetDeadArray and // | |
25 | // GetNoisyArray. // | |
26 | ////////////////////////////////////////////////////////////////////// | |
27 | ||
28 | #include "AliITSOnlineCalibrationSPDhandler.h" | |
29 | #include "AliITSOnlineCalibrationSPD.h" | |
53ae21ce | 30 | #include "AliITSIntMap.h" |
31 | #include <TObjArray.h> | |
b15de2d2 | 32 | #include <TArrayI.h> |
33 | #include <TFile.h> | |
53ae21ce | 34 | #include <TError.h> |
35 | #include <fstream> | |
b15de2d2 | 36 | |
53ae21ce | 37 | #ifndef SPD_DA_OFF // you may want to exclude cdb classes, if using this class outside aliroot |
38 | #include "AliITSCalibrationSPD.h" | |
39 | #include "AliCDBManager.h" | |
40 | #include "AliCDBEntry.h" | |
41 | #endif | |
b15de2d2 | 42 | |
53ae21ce | 43 | AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler(): |
44 | fFileLocation("."), | |
45 | fModuleMapInited(kFALSE) | |
46 | { | |
47 | // constructor | |
48 | for (UInt_t module=0; module<240; module++) { | |
49 | fNrDead[module]=0; | |
50 | fNrNoisy[module]=0; | |
51 | fDeadPixelMap[module] = new AliITSIntMap(); | |
52 | fNoisyPixelMap[module] = new AliITSIntMap(); | |
53 | } | |
54 | } | |
b15de2d2 | 55 | |
56 | AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler(const AliITSOnlineCalibrationSPDhandler& handle): | |
53ae21ce | 57 | fFileLocation("."), |
58 | fModuleMapInited(kFALSE) | |
b15de2d2 | 59 | { |
60 | // copy constructor | |
53ae21ce | 61 | for (UInt_t module=0; module<240; module++) { |
62 | fNrDead[module] = handle.fNrDead[module]; | |
63 | fNrNoisy[module] = handle.fNrNoisy[module]; | |
64 | fDeadPixelMap[module] = handle.fDeadPixelMap[module]->Clone(); | |
65 | fNoisyPixelMap[module] = handle.fNoisyPixelMap[module]->Clone(); | |
b15de2d2 | 66 | } |
53ae21ce | 67 | fFileLocation = handle.fFileLocation; |
b15de2d2 | 68 | } |
69 | ||
70 | AliITSOnlineCalibrationSPDhandler::~AliITSOnlineCalibrationSPDhandler() { | |
71 | ClearMaps(); | |
72 | } | |
73 | ||
74 | AliITSOnlineCalibrationSPDhandler& AliITSOnlineCalibrationSPDhandler::operator=(const AliITSOnlineCalibrationSPDhandler& handle) { | |
75 | // assignment operator | |
76 | if (this!=&handle) { | |
77 | this->ClearMaps(); | |
53ae21ce | 78 | for (UInt_t module=0; module<240; module++) { |
79 | fNrDead[module] = handle.fNrDead[module]; | |
80 | fNrNoisy[module] = handle.fNrNoisy[module]; | |
81 | fDeadPixelMap[module] = handle.fDeadPixelMap[module]->Clone(); | |
82 | fNoisyPixelMap[module] = handle.fNoisyPixelMap[module]->Clone(); | |
b15de2d2 | 83 | } |
53ae21ce | 84 | fFileLocation = handle.fFileLocation; |
b15de2d2 | 85 | } |
86 | return *this; | |
87 | } | |
88 | ||
89 | void AliITSOnlineCalibrationSPDhandler::ClearMaps() { | |
90 | // clear the lists of dead and noisy | |
91 | ResetDead(); | |
92 | ResetNoisy(); | |
93 | } | |
94 | ||
53ae21ce | 95 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadFromFiles() { |
96 | // read dead and noisy files from file location. returns true if at least one file found | |
97 | Bool_t returnval=kFALSE; | |
98 | for (UInt_t module=0; module<240; module++) { | |
99 | if (ReadFromFile(module)) { | |
100 | returnval=kTRUE; | |
101 | } | |
102 | } | |
103 | return returnval; | |
b15de2d2 | 104 | } |
53ae21ce | 105 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadFromFile(UInt_t module) { |
106 | // read dead and noisy files for module from file location. | |
107 | TString fileName = Form("%s/SPD_DeadNoisy_%d.root",fFileLocation.Data(),module); | |
108 | return ReadFromFileName(fileName.Data()); | |
b15de2d2 | 109 | } |
53ae21ce | 110 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadFromFileName(const char *fileName) { |
111 | // read dead and noisy from file fileName | |
b15de2d2 | 112 | AliITSOnlineCalibrationSPD* calib; |
113 | FILE* fp0 = fopen(fileName, "r"); | |
03fc6773 | 114 | if (fp0 == NULL) {return kFALSE;} |
b15de2d2 | 115 | else { |
116 | fclose(fp0); | |
117 | TFile file(fileName, "READ"); | |
118 | if (file.IsOpen()) { | |
119 | file.GetObject("AliITSOnlineCalibrationSPD", calib); | |
120 | file.Close(); | |
121 | if (calib!=NULL) { | |
53ae21ce | 122 | UInt_t module = calib->GetModuleNr(); |
b15de2d2 | 123 | Int_t nrDead=calib->GetNrDead(); |
124 | for (Int_t index=0; index<nrDead; index++) { | |
53ae21ce | 125 | UInt_t colM=calib->GetDeadColAt(index); |
126 | UInt_t row=calib->GetDeadRowAt(index); | |
127 | SetDeadPixelM(module,colM,row); | |
b15de2d2 | 128 | } |
129 | Int_t nrNoisy=calib->GetNrNoisy(); | |
130 | for (Int_t index=0; index<nrNoisy; index++) { | |
53ae21ce | 131 | UInt_t colM=calib->GetNoisyColAt(index); |
132 | UInt_t row=calib->GetNoisyRowAt(index); | |
133 | SetNoisyPixelM(module,colM,row); | |
b15de2d2 | 134 | } |
135 | } | |
136 | } | |
137 | } | |
03fc6773 | 138 | return kTRUE; |
b15de2d2 | 139 | } |
53ae21ce | 140 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromFiles() { |
141 | // read dead files from file location. returns true if at least one file found | |
142 | Bool_t returnval=kFALSE; | |
143 | for (UInt_t module=0; module<240; module++) { | |
144 | if (ReadDeadFromFile(module)) { | |
145 | returnval=kTRUE; | |
146 | } | |
147 | } | |
148 | return returnval; | |
149 | } | |
150 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromFile(UInt_t module) { | |
151 | // read dead for module from file location. | |
152 | TString fileName = Form("%s/SPD_DeadNoisy_%d.root",fFileLocation.Data(),module); | |
153 | return ReadDeadFromFileName(fileName.Data()); | |
154 | } | |
155 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromFileName(const char *fileName) { | |
156 | // read dead from file fileName | |
b15de2d2 | 157 | AliITSOnlineCalibrationSPD* calib; |
158 | FILE* fp0 = fopen(fileName, "r"); | |
03fc6773 | 159 | if (fp0 == NULL) {return kFALSE;} |
b15de2d2 | 160 | else { |
161 | fclose(fp0); | |
162 | TFile file(fileName, "READ"); | |
163 | if (file.IsOpen()) { | |
164 | file.GetObject("AliITSOnlineCalibrationSPD", calib); | |
165 | file.Close(); | |
166 | if (calib!=NULL) { | |
53ae21ce | 167 | UInt_t module = calib->GetModuleNr(); |
b15de2d2 | 168 | Int_t nrDead=calib->GetNrDead(); |
169 | for (Int_t index=0; index<nrDead; index++) { | |
53ae21ce | 170 | UInt_t colM=calib->GetDeadColAt(index); |
171 | UInt_t row=calib->GetDeadRowAt(index); | |
172 | SetDeadPixelM(module,colM,row); | |
b15de2d2 | 173 | } |
174 | } | |
175 | } | |
176 | } | |
03fc6773 | 177 | return kTRUE; |
b15de2d2 | 178 | } |
53ae21ce | 179 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromFiles() { |
180 | // read noisy files from file location. returns true if at least one file found | |
181 | Bool_t returnval=kFALSE; | |
182 | for (UInt_t module=0; module<240; module++) { | |
183 | if (ReadNoisyFromFile(module)) { | |
184 | returnval=kTRUE; | |
185 | } | |
186 | } | |
187 | return returnval; | |
188 | } | |
189 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromFile(UInt_t module) { | |
190 | // read noisy for module from file location. | |
191 | TString fileName = Form("%s/SPD_DeadNoisy_%d.root",fFileLocation.Data(),module); | |
192 | return ReadNoisyFromFileName(fileName.Data()); | |
193 | } | |
194 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromFileName(const char *fileName) { | |
195 | // read noisy from file fileName | |
b15de2d2 | 196 | AliITSOnlineCalibrationSPD* calib; |
197 | FILE* fp0 = fopen(fileName, "r"); | |
03fc6773 | 198 | if (fp0 == NULL) {return kFALSE;} |
b15de2d2 | 199 | else { |
200 | fclose(fp0); | |
201 | TFile file(fileName, "READ"); | |
202 | if (file.IsOpen()) { | |
203 | file.GetObject("AliITSOnlineCalibrationSPD", calib); | |
204 | file.Close(); | |
205 | if (calib!=NULL) { | |
53ae21ce | 206 | UInt_t module = calib->GetModuleNr(); |
b15de2d2 | 207 | Int_t nrNoisy=calib->GetNrNoisy(); |
208 | for (Int_t index=0; index<nrNoisy; index++) { | |
53ae21ce | 209 | UInt_t colM=calib->GetNoisyColAt(index); |
210 | UInt_t row=calib->GetNoisyRowAt(index); | |
211 | SetNoisyPixelM(module,colM,row); | |
b15de2d2 | 212 | } |
213 | } | |
214 | } | |
215 | } | |
03fc6773 | 216 | return kTRUE; |
b15de2d2 | 217 | } |
218 | ||
53ae21ce | 219 | |
220 | UInt_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromText(const char *fileName) { | |
221 | // read dead from a text file (lines with eqId,hs,chip,col,row). returns nr of pixels added (not already there) | |
222 | UInt_t newNrDead=0; | |
223 | ifstream textFile; | |
224 | textFile.open(fileName, ifstream::in); | |
225 | if (textFile.fail()) { | |
226 | Error("AliITSOnlineCalibrationSPDhandler::ReadDeadFromText","No noisy text file (%s) present.",fileName); | |
227 | } | |
228 | else { | |
229 | while(1) { | |
230 | UInt_t eqId,hs,chip,col,row; | |
231 | textFile >> eqId; if (textFile.eof()) break; | |
232 | textFile >> hs; if (textFile.eof()) break; | |
233 | textFile >> chip; if (textFile.eof()) break; | |
234 | textFile >> col; if (textFile.eof()) break; | |
235 | textFile >> row; | |
236 | if (SetDeadPixel(eqId,hs,chip,col,row)) { | |
237 | newNrDead++; | |
238 | } | |
239 | if (textFile.eof()) break; | |
240 | } | |
241 | textFile.close(); | |
242 | } | |
243 | return newNrDead; | |
244 | } | |
245 | ||
246 | UInt_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromText(const char *fileName) { | |
247 | // read noisy from a text file (lines with eqId,hs,chip,col,row). returns nr of pixels added (not already here) | |
248 | UInt_t newNrNoisy=0; | |
249 | ifstream textFile; | |
250 | textFile.open(fileName, ifstream::in); | |
251 | if (textFile.fail()) { | |
252 | Error("AliITSOnlineCalibrationSPDhandler::ReadNoisyFromText","No noisy text file (%s) present.",fileName); | |
253 | } | |
254 | else { | |
255 | while(1) { | |
256 | UInt_t eqId,hs,chip,col,row; | |
257 | textFile >> eqId; if (textFile.eof()) break; | |
258 | textFile >> hs; if (textFile.eof()) break; | |
259 | textFile >> chip; if (textFile.eof()) break; | |
260 | textFile >> col; if (textFile.eof()) break; | |
261 | textFile >> row; | |
262 | if (SetNoisyPixel(eqId,hs,chip,col,row)) { | |
263 | newNrNoisy++; | |
264 | } | |
265 | if (textFile.eof()) break; | |
266 | } | |
267 | textFile.close(); | |
268 | } | |
269 | return newNrNoisy; | |
270 | } | |
271 | ||
272 | ||
273 | #ifndef SPD_DA_OFF | |
274 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadModuleFromDB(UInt_t module, Int_t runNr) { | |
275 | // reads dead and noisy pixels from DB for given module and runNr | |
276 | AliCDBManager* man = AliCDBManager::Instance(); | |
277 | if(!man->IsDefaultStorageSet()) { | |
278 | man->SetDefaultStorage("local://$ALICE_ROOT"); | |
279 | } | |
280 | AliCDBEntry *cdbEntry = man->Get("ITS/Calib/CalibSPD", runNr); | |
281 | TObjArray* spdEntry; | |
282 | if(cdbEntry) { | |
283 | spdEntry = (TObjArray*)cdbEntry->GetObject(); | |
284 | if(!spdEntry) return kFALSE; | |
285 | } | |
286 | else { | |
287 | Warning("AliITSOnlineCalibrationSPDhandler::ReadModuleFromDB","Calibration for run %d not found in database.",runNr); | |
288 | return kFALSE; | |
289 | } | |
290 | AliITSCalibrationSPD* calibSPD; | |
291 | calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module); | |
292 | UInt_t nrDead = calibSPD->GetNrDead(); | |
293 | for (UInt_t index=0; index<nrDead; index++) { | |
294 | UInt_t colM = calibSPD->GetDeadColAt(index); | |
295 | UInt_t row = calibSPD->GetDeadRowAt(index); | |
296 | SetDeadPixelM(module,colM,row); | |
297 | } | |
298 | UInt_t nrNoisy = calibSPD->GetNrNoisy(); | |
299 | for (UInt_t index=0; index<nrNoisy; index++) { | |
300 | UInt_t colM = calibSPD->GetNoisyColAt(index); | |
301 | UInt_t row = calibSPD->GetNoisyRowAt(index); | |
302 | SetNoisyPixelM(module,colM,row); | |
303 | } | |
304 | spdEntry->SetOwner(kTRUE); | |
305 | spdEntry->Clear(); | |
306 | return kTRUE; | |
307 | } | |
308 | ||
309 | Bool_t AliITSOnlineCalibrationSPDhandler::ReadFromDB(Int_t runNr) { | |
310 | // reads dead and noisy pixels from DB for given runNr | |
311 | // note that you may want to clear the lists (if they are not empty) before reading | |
312 | AliCDBManager* man = AliCDBManager::Instance(); | |
313 | if(!man->IsDefaultStorageSet()) { | |
314 | man->SetDefaultStorage("local://$ALICE_ROOT"); | |
315 | } | |
316 | AliCDBEntry *cdbEntry = man->Get("ITS/Calib/CalibSPD", runNr); | |
317 | TObjArray* spdEntry; | |
318 | if(cdbEntry) { | |
319 | spdEntry = (TObjArray*)cdbEntry->GetObject(); | |
320 | if(!spdEntry) return kFALSE; | |
321 | } | |
322 | else { | |
323 | Warning("AliITSOnlineCalibrationSPDhandler::ReadFromDB","Calibration for run %d not found in database.",runNr); | |
324 | return kFALSE; | |
325 | } | |
326 | AliITSCalibrationSPD* calibSPD; | |
327 | for (UInt_t module=0; module<240; module++) { | |
328 | // printf("Reading module %d\n",module); | |
329 | calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module); | |
330 | UInt_t nrDead = calibSPD->GetNrDead(); | |
331 | for (UInt_t index=0; index<nrDead; index++) { | |
332 | UInt_t colM = calibSPD->GetDeadColAt(index); | |
333 | UInt_t row = calibSPD->GetDeadRowAt(index); | |
334 | SetDeadPixelM(module,colM,row); | |
335 | } | |
336 | UInt_t nrNoisy = calibSPD->GetNrNoisy(); | |
337 | for (UInt_t index=0; index<nrNoisy; index++) { | |
338 | UInt_t colM = calibSPD->GetNoisyColAt(index); | |
339 | UInt_t row = calibSPD->GetNoisyRowAt(index); | |
340 | SetNoisyPixelM(module,colM,row); | |
341 | } | |
342 | } | |
343 | spdEntry->SetOwner(kTRUE); | |
344 | spdEntry->Clear(); | |
345 | return kTRUE; | |
346 | } | |
347 | ||
348 | Bool_t AliITSOnlineCalibrationSPDhandler::WriteToDB(Int_t runNrStart, Int_t runNrEnd) { | |
349 | // writes dead and noisy pixels to DB for given runNr | |
350 | // overwrites any previous entries | |
351 | AliCDBManager* man = AliCDBManager::Instance(); | |
352 | if(!man->IsDefaultStorageSet()) { | |
353 | man->SetDefaultStorage("local://$ALICE_ROOT"); | |
354 | } | |
355 | AliCDBMetaData* metaData = new AliCDBMetaData(); | |
356 | metaData->SetResponsible("Henrik Tydesjo"); | |
357 | metaData->SetComment("Created by AliITSOnlineCalibrationSPDhandler."); | |
358 | AliCDBId idCalSPD("ITS/Calib/CalibSPD",runNrStart,runNrEnd); | |
359 | TObjArray* spdEntry = new TObjArray(240); | |
360 | spdEntry->SetOwner(kTRUE); | |
361 | for(UInt_t module=0; module<240; module++){ | |
362 | AliITSCalibrationSPD* calObj = new AliITSCalibrationSPD(); | |
3479cee3 | 363 | |
364 | // *** this is temporarily hard coded here ******************** | |
365 | // (later these parameters will be separated from the cal.obj.) | |
366 | calObj->SetThresholds(3000, 250); | |
367 | calObj->SetBiasVoltage(18.182); | |
368 | calObj->SetNoiseParam(0,0); | |
369 | // CouplingRaw changed to 0.055 (fine tuning), was 0.047 in PDC06 | |
370 | calObj->SetCouplingParam(0.,0.055); | |
371 | // *** remove later... | |
372 | // ************************************************************ | |
373 | ||
53ae21ce | 374 | spdEntry->Add(calObj); |
375 | } | |
376 | for(UInt_t module=0; module<240; module++){ | |
377 | ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrDead( GetNrDead(module) ); | |
378 | ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetDeadList( GetDeadArray(module) ); | |
379 | ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrNoisy( GetNrNoisy(module) ); | |
380 | ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNoisyList( GetNoisyArray(module) ); | |
381 | } | |
382 | AliCDBEntry* cdbEntry = new AliCDBEntry((TObject*)spdEntry,idCalSPD,metaData); | |
383 | man->Put(cdbEntry); | |
384 | delete spdEntry; | |
385 | delete cdbEntry; | |
386 | delete metaData; | |
387 | return kTRUE; | |
388 | } | |
389 | #endif | |
390 | ||
3479cee3 | 391 | void AliITSOnlineCalibrationSPDhandler::WriteToFilesAlways() { |
392 | // write the lists of dead and noisy to files (only if there are >0 dead or noisy pixels) | |
393 | for (UInt_t module=0; module<240; module++) { | |
394 | WriteToFile(module); | |
395 | } | |
396 | } | |
53ae21ce | 397 | void AliITSOnlineCalibrationSPDhandler::WriteToFiles() { |
398 | // write the lists of dead and noisy to files (only if there are >0 dead or noisy pixels) | |
399 | for (UInt_t module=0; module<240; module++) { | |
400 | if (fNrDead[module]+fNrNoisy[module] > 0) { | |
401 | WriteToFile(module); | |
402 | } | |
403 | } | |
404 | } | |
405 | void AliITSOnlineCalibrationSPDhandler::WriteToFile(UInt_t module) { | |
406 | // write the lists of dead and noisy for module to file | |
407 | AliITSOnlineCalibrationSPD* calib = new AliITSOnlineCalibrationSPD(); | |
408 | calib->SetModuleNr(module); | |
409 | calib->SetDeadList(GetDeadArray(module)); | |
410 | calib->SetNoisyList(GetNoisyArray(module)); | |
411 | calib->SetNrDead(GetNrDead(module)); | |
412 | calib->SetNrNoisy(GetNrNoisy(module)); | |
413 | TString fileName = Form("%s/SPD_DeadNoisy_%d.root",fFileLocation.Data(),module); | |
414 | TFile file(fileName.Data(), "RECREATE"); | |
415 | file.WriteTObject(calib, "AliITSOnlineCalibrationSPD"); | |
416 | file.Close(); | |
417 | delete calib; | |
418 | } | |
419 | void AliITSOnlineCalibrationSPDhandler::WriteDeadToFiles() { | |
420 | // write the lists of dead to files (only if there are >0 dead pixels) | |
421 | for (UInt_t module=0; module<240; module++) { | |
422 | if (fNrDead[module] > 0) { | |
423 | WriteDeadToFile(module); | |
424 | } | |
425 | } | |
426 | } | |
427 | void AliITSOnlineCalibrationSPDhandler::WriteDeadToFile(UInt_t module) { | |
428 | // write the lists of dead for module to file | |
429 | AliITSOnlineCalibrationSPD* calib = new AliITSOnlineCalibrationSPD(); | |
430 | calib->SetModuleNr(module); | |
431 | calib->SetDeadList(GetDeadArray(module)); | |
432 | calib->SetNrDead(GetNrDead(module)); | |
433 | TString fileName = Form("%s/SPD_DeadNoisy_%d.root",fFileLocation.Data(),module); | |
434 | TFile file(fileName.Data(), "RECREATE"); | |
435 | file.WriteTObject(calib, "AliITSOnlineCalibrationSPD"); | |
436 | file.Close(); | |
437 | delete calib; | |
438 | } | |
439 | void AliITSOnlineCalibrationSPDhandler::WriteNoisyToFiles() { | |
440 | // write the lists of noisy to files (only if there are >0 dead pixels) | |
441 | for (UInt_t module=0; module<240; module++) { | |
442 | if (fNrNoisy[module] > 0) { | |
443 | printf("writing noisy to file for module %d\n",module); | |
444 | WriteNoisyToFile(module); | |
445 | } | |
446 | } | |
447 | } | |
448 | void AliITSOnlineCalibrationSPDhandler::WriteNoisyToFile(UInt_t module) { | |
449 | // write the lists of noisy for module to file | |
450 | AliITSOnlineCalibrationSPD* calib = new AliITSOnlineCalibrationSPD(); | |
451 | calib->SetModuleNr(module); | |
452 | calib->SetNoisyList(GetNoisyArray(module)); | |
453 | calib->SetNrNoisy(GetNrNoisy(module)); | |
454 | TString fileName = Form("%s/SPD_DeadNoisy_%d.root",fFileLocation.Data(),module); | |
455 | TFile file(fileName.Data(), "RECREATE"); | |
456 | file.WriteTObject(calib, "AliITSOnlineCalibrationSPD"); | |
457 | file.Close(); | |
458 | delete calib; | |
459 | } | |
460 | ||
461 | TArrayI AliITSOnlineCalibrationSPDhandler::GetDeadArray(UInt_t module) { | |
b15de2d2 | 462 | // get a TArrayI of the dead pixels (format for the AliITSCalibrationSPD object) |
463 | TArrayI returnArray; | |
53ae21ce | 464 | returnArray.Set(GetNrDead(module)*2); |
465 | fDeadPixelMap[module]->PrepareSerialize(); // for tree ordered values | |
466 | for (UInt_t index=0; index<GetNrDead(module); index++) { | |
467 | Int_t key = fDeadPixelMap[module]->GetKeyIndex(index); | |
468 | Int_t colM = GetColMFromKey(key); | |
b15de2d2 | 469 | Int_t row = GetRowFromKey(key); |
53ae21ce | 470 | returnArray.AddAt(colM,index*2); |
b15de2d2 | 471 | returnArray.AddAt(row,index*2+1); |
472 | } | |
473 | return returnArray; | |
474 | } | |
53ae21ce | 475 | TArrayI AliITSOnlineCalibrationSPDhandler::GetNoisyArray(UInt_t module) { |
b15de2d2 | 476 | // get a TArrayI of the noisy pixels (format for the AliITSCalibrationSPD object) |
477 | TArrayI returnArray; | |
53ae21ce | 478 | returnArray.Set(GetNrNoisy(module)*2); |
479 | fNoisyPixelMap[module]->PrepareSerialize(); // for tree ordered values | |
480 | for (UInt_t index=0; index<GetNrNoisy(module); index++) { | |
481 | Int_t key = fNoisyPixelMap[module]->GetKeyIndex(index); | |
482 | Int_t colM = GetColMFromKey(key); | |
b15de2d2 | 483 | Int_t row = GetRowFromKey(key); |
53ae21ce | 484 | returnArray.AddAt(colM,index*2); |
b15de2d2 | 485 | returnArray.AddAt(row,index*2+1); |
486 | } | |
487 | return returnArray; | |
488 | } | |
489 | ||
490 | void AliITSOnlineCalibrationSPDhandler::ResetDead() { | |
53ae21ce | 491 | // reset the dead pixel map |
492 | for (UInt_t module=0; module<240; module++) { | |
493 | fNrDead[module]=0; | |
494 | fDeadPixelMap[module]->Clear(); | |
495 | } | |
b15de2d2 | 496 | } |
497 | ||
53ae21ce | 498 | void AliITSOnlineCalibrationSPDhandler::ResetDeadForChip(UInt_t eqId, UInt_t hs, UInt_t chip) { |
499 | // clear the noisy pixels for this chip | |
500 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); | |
501 | for (UInt_t col=0; col<32; col++) { | |
502 | for (UInt_t row=0; row<256; row++) { | |
503 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
504 | if (fDeadPixelMap[module]->Remove(key)) { | |
505 | fNrDead[module]--; | |
506 | } | |
507 | } | |
508 | } | |
b15de2d2 | 509 | } |
510 | ||
53ae21ce | 511 | Bool_t AliITSOnlineCalibrationSPDhandler::SetDeadPixel(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) { |
512 | // set a dead pixel, returns false if pixel is already dead | |
513 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); | |
514 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
515 | //!!! // if noisy we dont want to add it... | |
516 | //!!! if (fNoisyPixelMap[module]->Find(key) != NULL) return kFALSE; | |
517 | if (fDeadPixelMap[module]->Insert(key,module)) { | |
518 | fNrDead[module]++; | |
519 | return kTRUE; | |
b15de2d2 | 520 | } |
53ae21ce | 521 | return kFALSE; |
b15de2d2 | 522 | } |
523 | ||
53ae21ce | 524 | Bool_t AliITSOnlineCalibrationSPDhandler::SetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row) { |
525 | // set a dead pixel, returns false if pixel is already dead | |
526 | UInt_t eqId = GetEqIdFromOffline(module); | |
527 | UInt_t hs = GetHSFromOffline(module); | |
528 | UInt_t chip = GetChipFromOffline(module,colM); | |
529 | UInt_t col = GetColFromOffline(colM); | |
530 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
531 | //!!! // if noisy we dont want to add it... | |
532 | //!!! if (fNoisyPixelMap[module]->Find(key) != NULL) return kFALSE; | |
533 | if (fDeadPixelMap[module]->Insert(key,module)) { | |
534 | fNrDead[module]++; | |
535 | return kTRUE; | |
b15de2d2 | 536 | } |
53ae21ce | 537 | return kFALSE; |
b15de2d2 | 538 | } |
539 | ||
3479cee3 | 540 | Bool_t AliITSOnlineCalibrationSPDhandler::UnSetDeadPixel(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) { |
541 | // unset a dead pixel, returns false if pixel is not dead | |
542 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); | |
543 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
544 | if (fDeadPixelMap[module]->Remove(key)) { | |
545 | fNrDead[module]--; | |
546 | return kTRUE; | |
547 | } | |
548 | return kFALSE; | |
549 | } | |
550 | ||
551 | Bool_t AliITSOnlineCalibrationSPDhandler::UnSetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row) { | |
552 | // unset a dead pixel, returns false if pixel is not dead | |
553 | UInt_t eqId = GetEqIdFromOffline(module); | |
554 | UInt_t hs = GetHSFromOffline(module); | |
555 | UInt_t chip = GetChipFromOffline(module,colM); | |
556 | UInt_t col = GetColFromOffline(colM); | |
557 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
558 | if (fDeadPixelMap[module]->Remove(key)) { | |
559 | fNrDead[module]--; | |
560 | return kTRUE; | |
561 | } | |
562 | return kFALSE; | |
563 | } | |
564 | ||
53ae21ce | 565 | Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelDeadKey(Int_t key) const { |
566 | // is this pixel noisy? | |
567 | UInt_t eqId = GetEqIdFromKey(key); | |
568 | UInt_t hs = GetHSFromKey(key); | |
569 | UInt_t chip = GetChipFromKey(key); | |
570 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); | |
571 | return IsPixelDeadMKey(module,key); | |
572 | } | |
573 | ||
574 | Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelDeadMKey(UInt_t module, Int_t key) const { | |
575 | // is this pixel dead? | |
576 | if ( fDeadPixelMap[module]->Find(key) != NULL ) { | |
b15de2d2 | 577 | return kTRUE; |
578 | } | |
579 | else { | |
580 | return kFALSE; | |
581 | } | |
582 | } | |
583 | ||
53ae21ce | 584 | Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelDead(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const { |
585 | // is the pixel dead? | |
586 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); | |
587 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
588 | return IsPixelDeadMKey(module,key); | |
589 | } | |
590 | ||
591 | Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelDeadM(UInt_t module, UInt_t colM, UInt_t row) { | |
592 | // is the pixel dead? | |
593 | UInt_t eqId = GetEqIdFromOffline(module); | |
594 | UInt_t hs = GetHSFromOffline(module); | |
595 | UInt_t chip = GetChipFromOffline(module,colM); | |
596 | UInt_t col = GetColFromOffline(colM); | |
597 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
598 | return IsPixelDeadMKey(module,key); | |
599 | } | |
600 | ||
601 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDead() const { | |
602 | // returns the total nr of dead pixels | |
603 | UInt_t nrDead = 0; | |
604 | for (UInt_t module=0; module<240; module++) { | |
605 | nrDead+=fNrDead[module]; | |
606 | } | |
607 | return nrDead; | |
608 | } | |
609 | ||
610 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDead(UInt_t module) const { | |
611 | // returns the number of dead pixels for a certain module | |
612 | if (module<240) { | |
613 | return fNrDead[module]; | |
614 | } | |
615 | else { | |
616 | return 0; | |
617 | } | |
618 | } | |
619 | ||
620 | UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAt(UInt_t module, UInt_t index) { | |
621 | // get eqId for the dead pixel at position index in list of dead | |
622 | if (index<GetNrDead(module)) { | |
623 | Int_t key = fDeadPixelMap[module]->GetKeyIndex(index); | |
624 | return GetEqIdFromKey(key); | |
625 | } | |
626 | else { | |
627 | Error("AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAt", "Index %d out of bounds.", index); | |
628 | return 0; | |
629 | } | |
630 | } | |
631 | UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAt(UInt_t module, UInt_t index) { | |
632 | // get hs for the dead pixel at position index in list of dead | |
633 | if (index<GetNrDead(module)) { | |
634 | Int_t key = fDeadPixelMap[module]->GetKeyIndex(index); | |
635 | return GetHSFromKey(key); | |
636 | } | |
637 | else { | |
638 | Error("AliITSOnlineCalibrationSPDhandler::GetDeadHSAt", "Index %d out of bounds.", index); | |
639 | return 0; | |
640 | } | |
641 | } | |
642 | UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAt(UInt_t module, UInt_t index) { | |
643 | // get chip for the dead pixel at position index in list of dead | |
644 | if (index<GetNrDead(module)) { | |
645 | Int_t key = fDeadPixelMap[module]->GetKeyIndex(index); | |
646 | return GetChipFromKey(key); | |
647 | } | |
648 | else { | |
649 | Error("AliITSOnlineCalibrationSPDhandler::GetDeadChipAt", "Index %d out of bounds.", index); | |
650 | return 0; | |
651 | } | |
652 | } | |
653 | UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t module, UInt_t index) { | |
654 | // get column for the dead pixel at position index in list of dead | |
655 | if (index<GetNrDead(module)) { | |
656 | Int_t key = fDeadPixelMap[module]->GetKeyIndex(index); | |
657 | return GetColFromKey(key); | |
658 | } | |
659 | else { | |
660 | Error("AliITSOnlineCalibrationSPDhandler::GetDeadColAt", "Index %d out of bounds.", index); | |
661 | return 0; | |
662 | } | |
663 | } | |
664 | UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t module, UInt_t index) { | |
665 | // get row for the dead pixel at position index in list of dead | |
666 | if (index<GetNrDead(module)) { | |
667 | Int_t key = fDeadPixelMap[module]->GetKeyIndex(index); | |
668 | return GetRowFromKey(key); | |
669 | } | |
670 | else { | |
671 | Error("AliITSOnlineCalibrationSPDhandler::GetDeadRowAt", "Index %d out of bounds.", index); | |
672 | return 0; | |
673 | } | |
674 | } | |
675 | ||
b15de2d2 | 676 | void AliITSOnlineCalibrationSPDhandler::ResetNoisy() { |
677 | // clear the list of noisy pixels | |
53ae21ce | 678 | for (UInt_t module=0; module<240; module++) { |
679 | fNrNoisy[module]=0; | |
680 | fNoisyPixelMap[module]->Clear(); | |
681 | } | |
b15de2d2 | 682 | } |
53ae21ce | 683 | void AliITSOnlineCalibrationSPDhandler::ResetNoisyForChip(UInt_t eqId, UInt_t hs, UInt_t chip) { |
684 | // clear the noisy pixels for this chip | |
685 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); | |
686 | for (UInt_t col=0; col<32; col++) { | |
687 | for (UInt_t row=0; row<256; row++) { | |
688 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
689 | if (fNoisyPixelMap[module]->Remove(key)) { | |
690 | fNrNoisy[module]--; | |
691 | } | |
692 | } | |
693 | } | |
694 | } | |
695 | ||
b15de2d2 | 696 | |
53ae21ce | 697 | Bool_t AliITSOnlineCalibrationSPDhandler::SetNoisyPixel(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) { |
b15de2d2 | 698 | // set a noisy pixel, returns false if already there |
53ae21ce | 699 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); |
700 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
701 | //!!! // if dead before - remove from the dead list | |
702 | //!!! UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); | |
703 | //!!! if (fDeadPixelMap.Remove(key)) { | |
704 | //!!! fNrDead[module]--; | |
705 | //!!! } | |
706 | if (fNoisyPixelMap[module]->Insert(key,col)) { | |
707 | fNrNoisy[module]++; | |
708 | return kTRUE; | |
709 | } | |
710 | return kFALSE; | |
b15de2d2 | 711 | } |
712 | ||
53ae21ce | 713 | Bool_t AliITSOnlineCalibrationSPDhandler::SetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row) { |
714 | // set a noisy pixel, returns false if already there | |
715 | UInt_t eqId = GetEqIdFromOffline(module); | |
716 | UInt_t hs = GetHSFromOffline(module); | |
717 | UInt_t chip = GetChipFromOffline(module,colM); | |
718 | UInt_t col = GetColFromOffline(colM); | |
719 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
720 | //!!! // if dead before - remove from the dead list | |
721 | //!!! if (fDeadPixelMap[module]->Remove(key)) { | |
722 | //!!! fNrDead[module]--; | |
723 | //!!! } | |
724 | if (fNoisyPixelMap[module]->Insert(key,col)) { | |
725 | fNrNoisy[module]++; | |
726 | return kTRUE; | |
b15de2d2 | 727 | } |
53ae21ce | 728 | return kFALSE; |
b15de2d2 | 729 | } |
730 | ||
3479cee3 | 731 | Bool_t AliITSOnlineCalibrationSPDhandler::UnSetNoisyPixel(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) { |
732 | // unset a noisy pixel, returns false if not there | |
733 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); | |
734 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
735 | if (fNoisyPixelMap[module]->Remove(key)) { | |
736 | fNrNoisy[module]--; | |
737 | return kTRUE; | |
738 | } | |
739 | return kFALSE; | |
740 | } | |
741 | ||
742 | Bool_t AliITSOnlineCalibrationSPDhandler::UnSetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row) { | |
743 | // unset a noisy pixel, returns false if not there | |
744 | UInt_t eqId = GetEqIdFromOffline(module); | |
745 | UInt_t hs = GetHSFromOffline(module); | |
746 | UInt_t chip = GetChipFromOffline(module,colM); | |
747 | UInt_t col = GetColFromOffline(colM); | |
748 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
749 | if (fNoisyPixelMap[module]->Remove(key)) { | |
750 | fNrNoisy[module]--; | |
751 | return kTRUE; | |
752 | } | |
753 | return kFALSE; | |
754 | } | |
755 | ||
53ae21ce | 756 | Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisyKey(Int_t key) const { |
757 | // is this pixel noisy? | |
758 | UInt_t eqId = GetEqIdFromKey(key); | |
759 | UInt_t hs = GetHSFromKey(key); | |
760 | UInt_t chip = GetChipFromKey(key); | |
761 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); | |
762 | return IsPixelNoisyMKey(module,key); | |
b15de2d2 | 763 | } |
764 | ||
53ae21ce | 765 | Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisyMKey(UInt_t module, Int_t key) const { |
b15de2d2 | 766 | // is this pixel noisy? |
53ae21ce | 767 | if ( fNoisyPixelMap[module]->Find(key) != NULL ) { |
b15de2d2 | 768 | return kTRUE; |
769 | } | |
770 | else { | |
771 | return kFALSE; | |
772 | } | |
773 | } | |
774 | ||
53ae21ce | 775 | Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisy(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const { |
776 | // is this pixel noisy? | |
777 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,hs,chip); | |
778 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
779 | return IsPixelNoisyMKey(module,key); | |
780 | } | |
781 | ||
782 | Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisyM(UInt_t module, UInt_t colM, UInt_t row) { | |
783 | // is this pixel noisy? | |
784 | UInt_t eqId = GetEqIdFromOffline(module); | |
785 | UInt_t hs = GetHSFromOffline(module); | |
786 | UInt_t chip = GetChipFromOffline(module,colM); | |
787 | UInt_t col = GetColFromOffline(colM); | |
788 | Int_t key = GetKey(eqId,hs,chip,col,row); | |
789 | return IsPixelNoisyMKey(module,key); | |
790 | } | |
791 | ||
792 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisy() const { | |
793 | // returns the total nr of noisy pixels | |
794 | UInt_t nrNoisy = 0; | |
795 | for (UInt_t module=0; module<240; module++) { | |
796 | nrNoisy+=fNrNoisy[module]; | |
797 | } | |
798 | return nrNoisy; | |
799 | } | |
800 | ||
801 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisy(UInt_t module) const { | |
802 | // returns the number of noisy pixels for a certain module | |
803 | if (module<240) { | |
804 | return fNrNoisy[module]; | |
805 | } | |
806 | else { | |
807 | return 0; | |
808 | } | |
809 | } | |
810 | ||
811 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAt(UInt_t module, UInt_t index) { | |
812 | // get chip for the noisy pixel at position index in list of noisy | |
813 | if (index<GetNrNoisy(module)) { | |
814 | Int_t key = fNoisyPixelMap[module]->GetKeyIndex(index); | |
815 | return GetEqIdFromKey(key); | |
816 | } | |
817 | else { | |
818 | Error("AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAt", "Index %d out of bounds.", index); | |
819 | return 0; | |
820 | } | |
821 | } | |
822 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAt(UInt_t module, UInt_t index) { | |
823 | // get chip for the noisy pixel at position index in list of noisy | |
824 | if (index<GetNrNoisy(module)) { | |
825 | Int_t key = fNoisyPixelMap[module]->GetKeyIndex(index); | |
826 | return GetHSFromKey(key); | |
827 | } | |
828 | else { | |
829 | Error("AliITSOnlineCalibrationSPDhandler::GetNoisyHSAt", "Index %d out of bounds.", index); | |
830 | return 0; | |
831 | } | |
832 | } | |
833 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAt(UInt_t module, UInt_t index) { | |
834 | // get chip for the noisy pixel at position index in list of noisy | |
835 | if (index<GetNrNoisy(module)) { | |
836 | Int_t key = fNoisyPixelMap[module]->GetKeyIndex(index); | |
837 | return GetChipFromKey(key); | |
838 | } | |
839 | else { | |
840 | Error("AliITSOnlineCalibrationSPDhandler::GetNoisyChipAt", "Index %d out of bounds.", index); | |
841 | return 0; | |
842 | } | |
843 | } | |
844 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t module, UInt_t index) { | |
845 | // get column for the noisy pixel at position index in list of noisy | |
846 | if (index<GetNrNoisy(module)) { | |
847 | Int_t key = fNoisyPixelMap[module]->GetKeyIndex(index); | |
848 | return GetColFromKey(key); | |
849 | } | |
850 | else { | |
851 | Warning("AliITSOnlineCalibrationSPDhandler::GetNoisyColAt", "Index %d out of bounds.", index); | |
852 | return 0; | |
853 | } | |
854 | } | |
855 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t module, UInt_t index) { | |
856 | // get row for the noisy pixel at position index in list of noisy | |
857 | if (index<GetNrNoisy(module)) { | |
858 | Int_t key = fNoisyPixelMap[module]->GetKeyIndex(index); | |
859 | return GetRowFromKey(key); | |
860 | } | |
861 | else { | |
862 | Error("AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt", "Index %d out of bounds.", index); | |
863 | return 0; | |
864 | } | |
865 | } | |
866 | ||
b15de2d2 | 867 | void AliITSOnlineCalibrationSPDhandler::PrintDead() const { |
868 | // print the dead pixels to screen | |
53ae21ce | 869 | printf("-----------------------------------\n"); |
870 | printf("Dead Pixels: (eqId,hs,chip,col,row)\n"); | |
871 | printf("-----------------------------------\n"); | |
872 | for (UInt_t module=0; module<240; module++) { | |
873 | for (UInt_t index=0; index<GetNrDead(module); index++) { | |
874 | Int_t key = fDeadPixelMap[module]->GetKeyIndex(index); | |
875 | UInt_t eqId = GetEqIdFromKey(key); | |
876 | UInt_t hs = GetHSFromKey(key); | |
877 | UInt_t chip = GetChipFromKey(key); | |
878 | UInt_t col = GetColFromKey(key); | |
879 | UInt_t row = GetRowFromKey(key); | |
880 | printf("%d,%d,%d,%d,%d\n",eqId,hs,chip,col,row); | |
881 | } | |
b15de2d2 | 882 | } |
883 | } | |
884 | ||
885 | void AliITSOnlineCalibrationSPDhandler::PrintNoisy() const { | |
53ae21ce | 886 | // print the dead pixels to screen |
887 | printf("-----------------------------------\n"); | |
888 | printf("Noisy Pixels: (eqId,hs,chip,col,row)\n"); | |
889 | printf("-----------------------------------\n"); | |
890 | for (UInt_t module=0; module<240; module++) { | |
891 | for (UInt_t index=0; index<GetNrNoisy(module); index++) { | |
892 | Int_t key = fNoisyPixelMap[module]->GetKeyIndex(index); | |
893 | UInt_t eqId = GetEqIdFromKey(key); | |
894 | UInt_t hs = GetHSFromKey(key); | |
895 | UInt_t chip = GetChipFromKey(key); | |
896 | UInt_t col = GetColFromKey(key); | |
897 | UInt_t row = GetRowFromKey(key); | |
898 | printf("%d,%d,%d,%d,%d\n",eqId,hs,chip,col,row); | |
899 | } | |
900 | } | |
901 | } | |
902 | ||
903 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const { | |
904 | // returns nr of dead in this' lists and not in other's lists | |
905 | UInt_t returnval=0; | |
906 | for (UInt_t module=0; module<240; module++) { | |
907 | for (UInt_t ind1=0; ind1<fNrDead[module]; ind1++) { | |
908 | Int_t key = fDeadPixelMap[module]->GetKeyIndex(ind1); | |
909 | UInt_t eqId = GetEqIdFromKey(key); | |
910 | UInt_t hs = GetHSFromKey(key); | |
911 | UInt_t chip = GetChipFromKey(key); | |
912 | UInt_t col = GetColFromKey(key); | |
913 | UInt_t row = GetRowFromKey(key); | |
914 | if (!(other->IsPixelDead(eqId,hs,chip,col,row))) { | |
915 | returnval++; | |
916 | } | |
917 | } | |
918 | } | |
919 | return returnval; | |
920 | } | |
921 | ||
922 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const { | |
923 | // returns nr of noisy in this' lists and not in other's lists | |
924 | UInt_t returnval=0; | |
925 | for (UInt_t module=0; module<240; module++) { | |
926 | for (UInt_t ind1=0; ind1<fNrNoisy[module]; ind1++) { | |
927 | Int_t key = fNoisyPixelMap[module]->GetKeyIndex(ind1); | |
928 | UInt_t eqId = GetEqIdFromKey(key); | |
929 | UInt_t hs = GetHSFromKey(key); | |
930 | UInt_t chip = GetChipFromKey(key); | |
931 | UInt_t col = GetColFromKey(key); | |
932 | UInt_t row = GetRowFromKey(key); | |
933 | if (!(other->IsPixelNoisy(eqId,hs,chip,col,row))) { | |
934 | returnval++; | |
935 | } | |
936 | } | |
b15de2d2 | 937 | } |
53ae21ce | 938 | return returnval; |
939 | } | |
940 | ||
941 | UInt_t AliITSOnlineCalibrationSPDhandler::GetNrDiff(AliITSOnlineCalibrationSPDhandler* other) const { | |
942 | // returns nr of dead/noisy in this' lists and not in other's lists | |
943 | return GetNrDeadDiff(other) + GetNrNoisyDiff(other); | |
944 | } | |
945 | ||
946 | AliITSOnlineCalibrationSPDhandler* AliITSOnlineCalibrationSPDhandler::GetDiff(AliITSOnlineCalibrationSPDhandler* other) const { | |
947 | // returns handler with dead/noisy in this' lists, except for those in other's lists | |
948 | AliITSOnlineCalibrationSPDhandler* newHandler = new AliITSOnlineCalibrationSPDhandler(); | |
949 | for (UInt_t module=0; module<240; module++) { | |
950 | for (UInt_t ind1=0; ind1<fNrDead[module]; ind1++) { | |
951 | Int_t key = fDeadPixelMap[module]->GetKeyIndex(ind1); | |
952 | UInt_t eqId = GetEqIdFromKey(key); | |
953 | UInt_t hs = GetHSFromKey(key); | |
954 | UInt_t chip = GetChipFromKey(key); | |
955 | UInt_t col = GetColFromKey(key); | |
956 | UInt_t row = GetRowFromKey(key); | |
957 | if (!(other->IsPixelDead(eqId,hs,chip,col,row))) { | |
958 | newHandler->SetDeadPixel(eqId,hs,chip,col,row); | |
959 | } | |
960 | } | |
961 | for (UInt_t ind2=0; ind2<fNrNoisy[module]; ind2++) { | |
962 | Int_t key = fNoisyPixelMap[module]->GetKeyIndex(ind2); | |
963 | UInt_t eqId = GetEqIdFromKey(key); | |
964 | UInt_t hs = GetHSFromKey(key); | |
965 | UInt_t chip = GetChipFromKey(key); | |
966 | UInt_t col = GetColFromKey(key); | |
967 | UInt_t row = GetRowFromKey(key); | |
968 | if (!(other->IsPixelNoisy(eqId,hs,chip,col,row))) { | |
969 | newHandler->SetNoisyPixel(eqId,hs,chip,col,row); | |
970 | } | |
971 | } | |
972 | } | |
973 | return newHandler; | |
974 | } | |
975 | ||
976 | AliITSOnlineCalibrationSPDhandler* AliITSOnlineCalibrationSPDhandler::GetDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const { | |
977 | // returns handler with dead in this' lists, except for those in other's lists | |
978 | AliITSOnlineCalibrationSPDhandler* newHandler = new AliITSOnlineCalibrationSPDhandler(); | |
979 | for (UInt_t module=0; module<240; module++) { | |
980 | for (UInt_t ind1=0; ind1<fNrDead[module]; ind1++) { | |
981 | Int_t key = fDeadPixelMap[module]->GetKeyIndex(ind1); | |
982 | UInt_t eqId = GetEqIdFromKey(key); | |
983 | UInt_t hs = GetHSFromKey(key); | |
984 | UInt_t chip = GetChipFromKey(key); | |
985 | UInt_t col = GetColFromKey(key); | |
986 | UInt_t row = GetRowFromKey(key); | |
987 | if (!(other->IsPixelDead(eqId,hs,chip,col,row))) { | |
988 | newHandler->SetDeadPixel(eqId,hs,chip,col,row); | |
989 | } | |
990 | } | |
991 | } | |
992 | return newHandler; | |
993 | } | |
994 | ||
995 | AliITSOnlineCalibrationSPDhandler* AliITSOnlineCalibrationSPDhandler::GetNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const { | |
996 | // returns handler with noisy in this' lists, except for those in other's lists | |
997 | AliITSOnlineCalibrationSPDhandler* newHandler = new AliITSOnlineCalibrationSPDhandler(); | |
998 | for (UInt_t module=0; module<240; module++) { | |
999 | for (UInt_t ind2=0; ind2<fNrNoisy[module]; ind2++) { | |
1000 | Int_t key = fNoisyPixelMap[module]->GetKeyIndex(ind2); | |
1001 | UInt_t eqId = GetEqIdFromKey(key); | |
1002 | UInt_t hs = GetHSFromKey(key); | |
1003 | UInt_t chip = GetChipFromKey(key); | |
1004 | UInt_t col = GetColFromKey(key); | |
1005 | UInt_t row = GetRowFromKey(key); | |
1006 | if (!(other->IsPixelNoisy(eqId,hs,chip,col,row))) { | |
1007 | newHandler->SetNoisyPixel(eqId,hs,chip,col,row); | |
1008 | } | |
1009 | } | |
1010 | } | |
1011 | return newHandler; | |
1012 | } | |
1013 | ||
1014 | void AliITSOnlineCalibrationSPDhandler::InitModuleMaps() { | |
1015 | // initializes the module mapping arrays needed for the methods below (GetEqIdFromOffline etc.) | |
1016 | for (UInt_t iDDL=0; iDDL<20; iDDL++) { | |
1017 | for (UInt_t iModule=0; iModule<12; iModule++) { | |
1018 | UInt_t module = AliITSRawStreamSPD::GetModuleNumber(iDDL,iModule); | |
1019 | fiDDL[module] = iDDL; | |
1020 | fiModule[module] = iModule; | |
1021 | } | |
1022 | } | |
1023 | } | |
1024 | ||
1025 | void AliITSOnlineCalibrationSPDhandler::GenerateDCSConfigFile(const Char_t* fileName) { | |
1026 | // generates an ascii file in the format as the one produced by online da (but with dummy runNr=0) | |
1027 | ofstream dcsfile; | |
1028 | dcsfile.open(fileName); | |
1029 | dcsfile << "[SPD SCAN]\n"; | |
1030 | dcsfile << "RunNumber=" << "0" << "\n"; // dummy value | |
1031 | dcsfile << "Type=" << "4" << "\n"; | |
4ee23d3d | 1032 | dcsfile << "Router=" << "0" << "\n"; // dummy value |
53ae21ce | 1033 | dcsfile << "ActualDetCoonfiguration=" << "0,-1,-1\n"; // dummy values |
1034 | dcsfile << "[NOISY]\n"; | |
1035 | for (UInt_t module=0; module<240; module++) { | |
1036 | UInt_t headkey=20*10*6; | |
1037 | for (UInt_t ind=0; ind<fNrNoisy[module]; ind++) { | |
1038 | UInt_t newkey = GetNoisyEqIdAt(module,ind)*10*6 + | |
1039 | GetNoisyHSAt(module,ind)*10 + | |
1040 | GetNoisyChipAt(module,ind); | |
1041 | if (newkey!=headkey) { // print eqId,hs,chip header | |
1042 | headkey = newkey; | |
1043 | dcsfile << "-" << newkey/(6*10) << "," << (newkey%(6*10))/10 << "," << (newkey%(6*10))%10 << "\n"; | |
1044 | } | |
1045 | dcsfile << GetNoisyColAt(module,ind) << "," << GetNoisyRowAt(module,ind) << "\n"; | |
1046 | } | |
1047 | } | |
1048 | dcsfile.close(); | |
1049 | } | |
1050 | ||
1051 | UInt_t AliITSOnlineCalibrationSPDhandler::GetEqIdFromOffline(UInt_t module) { | |
1052 | // module to eqId mapping | |
1053 | if (!fModuleMapInited) InitModuleMaps(); | |
1054 | return fiDDL[module]; | |
1055 | } | |
1056 | UInt_t AliITSOnlineCalibrationSPDhandler::GetHSFromOffline(UInt_t module) { | |
1057 | // module to hs mapping | |
1058 | if (!fModuleMapInited) InitModuleMaps(); | |
1059 | return fiModule[module]/2; | |
1060 | } | |
1061 | UInt_t AliITSOnlineCalibrationSPDhandler::GetChipFromOffline(UInt_t module, UInt_t colM) { | |
1062 | // module,colM to chip mapping | |
1063 | if (!fModuleMapInited) InitModuleMaps(); | |
1064 | return colM/32 + 5*(fiModule[module]%2); | |
1065 | } | |
1066 | UInt_t AliITSOnlineCalibrationSPDhandler::GetColFromOffline(UInt_t colM) const { | |
1067 | // colM to col mapping | |
1068 | return colM%32; | |
b15de2d2 | 1069 | } |