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 //
8 //////////////////////////////////////////////////////////////////////
10 #include "AliITSOnlineCalibrationSPDhandler.h"
11 #include "AliITSOnlineCalibrationSPD.h"
15 AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler():
17 fDeadPixelMap(AliITSIntMap()),
18 fNoisyPixelMap(AliITSIntMap())
21 AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler(UInt_t module):
23 fDeadPixelMap(AliITSIntMap()),
24 fNoisyPixelMap(AliITSIntMap())
27 AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler(const AliITSOnlineCalibrationSPDhandler& handle):
28 fModuleNr(handle.fModuleNr),
29 fDeadPixelMap(AliITSIntMap()),
30 fNoisyPixelMap(AliITSIntMap())
33 UInt_t nrDead = handle.GetNrDead();
34 for (UInt_t index=0; index<nrDead; index++) {
35 this->SetDeadPixel(handle.GetDeadColAt(index),handle.GetDeadRowAt(index));
37 UInt_t nrNoisy = handle.GetNrNoisy();
38 for (UInt_t index=0; index<nrNoisy; index++) {
39 this->SetNoisyPixel(handle.GetNoisyColAt(index),handle.GetNoisyRowAt(index));
41 sprintf(fFileLocation,"%s",handle.fFileLocation);
44 AliITSOnlineCalibrationSPDhandler::~AliITSOnlineCalibrationSPDhandler() {
48 AliITSOnlineCalibrationSPDhandler& AliITSOnlineCalibrationSPDhandler::operator=(const AliITSOnlineCalibrationSPDhandler& handle) {
49 // assignment operator
52 fModuleNr = handle.fModuleNr;
53 UInt_t nrDead = handle.GetNrDead();
54 for (UInt_t index=0; index<nrDead; index++) {
55 this->SetDeadPixel(handle.GetDeadColAt(index),handle.GetDeadRowAt(index));
57 UInt_t nrNoisy = handle.GetNrNoisy();
58 for (UInt_t index=0; index<nrNoisy; index++) {
59 this->SetNoisyPixel(handle.GetNoisyColAt(index),handle.GetNoisyRowAt(index));
61 sprintf(fFileLocation,"%s",handle.fFileLocation);
66 void AliITSOnlineCalibrationSPDhandler::ClearMaps() {
67 // clear the lists of dead and noisy
72 void AliITSOnlineCalibrationSPDhandler::WriteToFile() {
73 // write the lists of dead and noisy to default file
75 sprintf(fileName,"%s/SPD_DeadNoisy_%d.root",fFileLocation,fModuleNr);
76 WriteToFile(fileName);
79 void AliITSOnlineCalibrationSPDhandler::WriteToFile(Char_t* fileName) {
80 // write the lists of dead and noisy to file fileName
81 AliITSOnlineCalibrationSPD* calib = new AliITSOnlineCalibrationSPD();
82 calib->SetModuleNr(GetModuleNr());
83 calib->SetDeadList(GetDeadArray());
84 calib->SetNoisyList(GetNoisyArray());
85 calib->SetNrDead(GetNrDead());
86 calib->SetNrNoisy(GetNrNoisy());
88 TFile file(fileName, "RECREATE");
89 file.WriteTObject(calib, "AliITSOnlineCalibrationSPD");
95 void AliITSOnlineCalibrationSPDhandler::ReadFromFile() {
96 // read dead and noisy from default file
98 sprintf(fileName,"%s/SPD_DeadNoisy_%d.root",fFileLocation,fModuleNr);
99 ReadFromFile(fileName);
101 void AliITSOnlineCalibrationSPDhandler::ReadDeadFromFile() {
102 // read dead from default file
103 Char_t fileName[200];
104 sprintf(fileName,"%s/SPD_DeadNoisy_%d.root",fFileLocation,fModuleNr);
105 ReadDeadFromFile(fileName);
107 void AliITSOnlineCalibrationSPDhandler::ReadNoisyFromFile() {
108 // read noisy from default file
109 Char_t fileName[200];
110 sprintf(fileName,"%s/SPD_DeadNoisy_%d.root",fFileLocation,fModuleNr);
111 ReadNoisyFromFile(fileName);
114 void AliITSOnlineCalibrationSPDhandler::ReadFromFile(Char_t* fileName) {
115 // read dead and noisy from file fileName (clear the previous list of dead and noisy pixels)
117 AliITSOnlineCalibrationSPD* calib;
118 FILE* fp0 = fopen(fileName, "r");
122 TFile file(fileName, "READ");
124 file.GetObject("AliITSOnlineCalibrationSPD", calib);
127 SetModuleNr(calib->GetModuleNr());
128 Int_t nrDead=calib->GetNrDead();
129 for (Int_t index=0; index<nrDead; index++) {
130 Int_t col=calib->GetDeadColAt(index);
131 Int_t row=calib->GetDeadRowAt(index);
132 SetDeadPixel(col,row);
134 Int_t nrNoisy=calib->GetNrNoisy();
135 for (Int_t index=0; index<nrNoisy; index++) {
136 Int_t col=calib->GetNoisyColAt(index);
137 Int_t row=calib->GetNoisyRowAt(index);
138 SetNoisyPixel(col,row);
144 void AliITSOnlineCalibrationSPDhandler::ReadDeadFromFile(Char_t* fileName) {
145 // read dead from file fileName (clear the previous list of dead pixels)
147 AliITSOnlineCalibrationSPD* calib;
148 FILE* fp0 = fopen(fileName, "r");
152 TFile file(fileName, "READ");
154 file.GetObject("AliITSOnlineCalibrationSPD", calib);
157 SetModuleNr(calib->GetModuleNr());
158 Int_t nrDead=calib->GetNrDead();
159 for (Int_t index=0; index<nrDead; index++) {
160 Int_t col=calib->GetDeadColAt(index);
161 Int_t row=calib->GetDeadRowAt(index);
162 SetDeadPixel(col,row);
168 void AliITSOnlineCalibrationSPDhandler::ReadNoisyFromFile(Char_t* fileName) {
169 // read noisy from file fileName (clear the previous list of noisy pixels)
171 AliITSOnlineCalibrationSPD* calib;
172 FILE* fp0 = fopen(fileName, "r");
176 TFile file(fileName, "READ");
178 file.GetObject("AliITSOnlineCalibrationSPD", calib);
181 SetModuleNr(calib->GetModuleNr());
182 Int_t nrNoisy=calib->GetNrNoisy();
183 for (Int_t index=0; index<nrNoisy; index++) {
184 Int_t col=calib->GetNoisyColAt(index);
185 Int_t row=calib->GetNoisyRowAt(index);
186 SetNoisyPixel(col,row);
193 TArrayI AliITSOnlineCalibrationSPDhandler::GetDeadArray() {
194 // get a TArrayI of the dead pixels (format for the AliITSCalibrationSPD object)
196 returnArray.Set(GetNrDead()*2);
197 for (UInt_t index=0; index<fDeadPixelMap.GetNrEntries(); index++) {
198 Int_t key = fDeadPixelMap.GetKey(index);
199 Int_t col = GetColFromKey(key);
200 Int_t row = GetRowFromKey(key);
201 returnArray.AddAt(col,index*2);
202 returnArray.AddAt(row,index*2+1);
207 TArrayI AliITSOnlineCalibrationSPDhandler::GetNoisyArray() {
208 // get a TArrayI of the noisy pixels (format for the AliITSCalibrationSPD object)
210 returnArray.Set(GetNrNoisy()*2);
211 for (UInt_t index=0; index<fNoisyPixelMap.GetNrEntries(); index++) {
212 Int_t key = fNoisyPixelMap.GetKey(index);
213 Int_t col = GetColFromKey(key);
214 Int_t row = GetRowFromKey(key);
215 returnArray.AddAt(col,index*2);
216 returnArray.AddAt(row,index*2+1);
221 void AliITSOnlineCalibrationSPDhandler::ResetDead() {
222 fDeadPixelMap.Clear();
226 Bool_t AliITSOnlineCalibrationSPDhandler::SetDeadPixel(Int_t col, Int_t row) {
227 // set a dead pixel, returns false if pixel is already dead or noisy
228 Int_t key = GetKey(col,row);
229 // if noisy we dont want to add it...
230 if (fNoisyPixelMap.Find(key) != NULL) return kFALSE;
231 return fDeadPixelMap.Insert(key,col);
234 Int_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t index) const {
235 // get column for the dead pixel at position index in list of dead
236 if (index<fDeadPixelMap.GetNrEntries()) {
237 Int_t key = fDeadPixelMap.GetKey(index);
238 return GetColFromKey(key);
243 Int_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t index) const {
244 // get row for the dead pixel at position index in list of dead
245 if (index<fDeadPixelMap.GetNrEntries()) {
246 Int_t key = fDeadPixelMap.GetKey(index);
247 return GetRowFromKey(key);
252 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelDead(Int_t col, Int_t row) const {
253 // is the pixel dead?
254 Int_t key = GetKey(col,row);
255 if ( fDeadPixelMap.Find(key) != NULL) {
263 void AliITSOnlineCalibrationSPDhandler::ResetNoisy() {
264 // clear the list of noisy pixels
265 fNoisyPixelMap.Clear();
268 Bool_t AliITSOnlineCalibrationSPDhandler::SetNoisyPixel(Int_t col, Int_t row) {
269 // set a noisy pixel, returns false if already there
270 Int_t key = GetKey(col,row);
271 // if dead before - remove from the dead list
272 fDeadPixelMap.Remove(key);
273 return fNoisyPixelMap.Insert(key,col);
276 Int_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t index) const {
277 // get column for the noisy pixel at position index in list of noisy
278 if (index<fNoisyPixelMap.GetNrEntries()) {
279 Int_t key = fNoisyPixelMap.GetKey(index);
280 return GetColFromKey(key);
285 Int_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t index) const {
286 // get row for the noisy pixel at position index in list of noisy
287 if (index<fNoisyPixelMap.GetNrEntries()) {
288 Int_t key = fNoisyPixelMap.GetKey(index);
289 return GetRowFromKey(key);
294 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisy(Int_t col, Int_t row) const {
295 // is this pixel noisy?
296 Int_t key = GetKey(col,row);
297 if ( fNoisyPixelMap.Find(key) != NULL ) {
305 void AliITSOnlineCalibrationSPDhandler::PrintDead() const {
306 // print the dead pixels to screen
307 printf("-----------------------\n");
308 printf("Dead Pixels Module %d:\n",fModuleNr);
309 printf("-----------------------\n");
310 for (UInt_t index=0; index<fDeadPixelMap.GetNrEntries(); index++) {
311 Int_t key = fDeadPixelMap.GetKey(index);
312 Int_t col = GetColFromKey(key);
313 Int_t row = GetRowFromKey(key);
314 printf("%d,%d\n",col,row);
318 void AliITSOnlineCalibrationSPDhandler::PrintNoisy() const {
319 // print the noisy pixels to screen
320 printf("-----------------------\n");
321 printf("Noisy Pixels Module %d:\n",fModuleNr);
322 printf("-----------------------\n");
323 for (UInt_t index=0; index<fNoisyPixelMap.GetNrEntries(); index++) {
324 Int_t key = fNoisyPixelMap.GetKey(index);
325 Int_t col = GetColFromKey(key);
326 Int_t row = GetRowFromKey(key);
327 printf("%d,%d\n",col,row);