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