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 Bool_t AliITSOnlineCalibrationSPDhandler::ReadFromFile() {
96 // read dead and noisy from default file
98 sprintf(fileName,"%s/SPD_DeadNoisy_%d.root",fFileLocation,fModuleNr);
99 return ReadFromFile(fileName);
101 Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromFile() {
102 // read dead from default file
103 Char_t fileName[200];
104 sprintf(fileName,"%s/SPD_DeadNoisy_%d.root",fFileLocation,fModuleNr);
105 return ReadDeadFromFile(fileName);
107 Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromFile() {
108 // read noisy from default file
109 Char_t fileName[200];
110 sprintf(fileName,"%s/SPD_DeadNoisy_%d.root",fFileLocation,fModuleNr);
111 return ReadNoisyFromFile(fileName);
114 Bool_t 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");
119 if (fp0 == NULL) {return kFALSE;}
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);
145 Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromFile(Char_t* fileName) {
146 // read dead from file fileName (clear the previous list of dead pixels)
148 AliITSOnlineCalibrationSPD* calib;
149 FILE* fp0 = fopen(fileName, "r");
150 if (fp0 == NULL) {return kFALSE;}
153 TFile file(fileName, "READ");
155 file.GetObject("AliITSOnlineCalibrationSPD", calib);
158 SetModuleNr(calib->GetModuleNr());
159 Int_t nrDead=calib->GetNrDead();
160 for (Int_t index=0; index<nrDead; index++) {
161 Int_t col=calib->GetDeadColAt(index);
162 Int_t row=calib->GetDeadRowAt(index);
163 SetDeadPixel(col,row);
170 Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromFile(Char_t* fileName) {
171 // read noisy from file fileName (clear the previous list of noisy pixels)
173 AliITSOnlineCalibrationSPD* calib;
174 FILE* fp0 = fopen(fileName, "r");
175 if (fp0 == NULL) {return kFALSE;}
178 TFile file(fileName, "READ");
180 file.GetObject("AliITSOnlineCalibrationSPD", calib);
183 SetModuleNr(calib->GetModuleNr());
184 Int_t nrNoisy=calib->GetNrNoisy();
185 for (Int_t index=0; index<nrNoisy; index++) {
186 Int_t col=calib->GetNoisyColAt(index);
187 Int_t row=calib->GetNoisyRowAt(index);
188 SetNoisyPixel(col,row);
196 TArrayI AliITSOnlineCalibrationSPDhandler::GetDeadArray() {
197 // get a TArrayI of the dead pixels (format for the AliITSCalibrationSPD object)
199 returnArray.Set(GetNrDead()*2);
200 for (UInt_t index=0; index<fDeadPixelMap.GetNrEntries(); index++) {
201 Int_t key = fDeadPixelMap.GetKey(index);
202 Int_t col = GetColFromKey(key);
203 Int_t row = GetRowFromKey(key);
204 returnArray.AddAt(col,index*2);
205 returnArray.AddAt(row,index*2+1);
210 TArrayI AliITSOnlineCalibrationSPDhandler::GetNoisyArray() {
211 // get a TArrayI of the noisy pixels (format for the AliITSCalibrationSPD object)
213 returnArray.Set(GetNrNoisy()*2);
214 for (UInt_t index=0; index<fNoisyPixelMap.GetNrEntries(); index++) {
215 Int_t key = fNoisyPixelMap.GetKey(index);
216 Int_t col = GetColFromKey(key);
217 Int_t row = GetRowFromKey(key);
218 returnArray.AddAt(col,index*2);
219 returnArray.AddAt(row,index*2+1);
224 void AliITSOnlineCalibrationSPDhandler::ResetDead() {
225 fDeadPixelMap.Clear();
229 Bool_t AliITSOnlineCalibrationSPDhandler::SetDeadPixel(Int_t col, Int_t row) {
230 // set a dead pixel, returns false if pixel is already dead or noisy
231 Int_t key = GetKey(col,row);
232 // if noisy we dont want to add it...
233 if (fNoisyPixelMap.Find(key) != NULL) return kFALSE;
234 return fDeadPixelMap.Insert(key,col);
237 Int_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t index) const {
238 // get column for the dead pixel at position index in list of dead
239 if (index<fDeadPixelMap.GetNrEntries()) {
240 Int_t key = fDeadPixelMap.GetKey(index);
241 return GetColFromKey(key);
246 Int_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t index) const {
247 // get row for the dead pixel at position index in list of dead
248 if (index<fDeadPixelMap.GetNrEntries()) {
249 Int_t key = fDeadPixelMap.GetKey(index);
250 return GetRowFromKey(key);
255 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelDead(Int_t col, Int_t row) const {
256 // is the pixel dead?
257 Int_t key = GetKey(col,row);
258 if ( fDeadPixelMap.Find(key) != NULL) {
266 void AliITSOnlineCalibrationSPDhandler::ResetNoisy() {
267 // clear the list of noisy pixels
268 fNoisyPixelMap.Clear();
271 Bool_t AliITSOnlineCalibrationSPDhandler::SetNoisyPixel(Int_t col, Int_t row) {
272 // set a noisy pixel, returns false if already there
273 Int_t key = GetKey(col,row);
274 // if dead before - remove from the dead list
275 fDeadPixelMap.Remove(key);
276 return fNoisyPixelMap.Insert(key,col);
279 Int_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t index) const {
280 // get column for the noisy pixel at position index in list of noisy
281 if (index<fNoisyPixelMap.GetNrEntries()) {
282 Int_t key = fNoisyPixelMap.GetKey(index);
283 return GetColFromKey(key);
288 Int_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t index) const {
289 // get row for the noisy pixel at position index in list of noisy
290 if (index<fNoisyPixelMap.GetNrEntries()) {
291 Int_t key = fNoisyPixelMap.GetKey(index);
292 return GetRowFromKey(key);
297 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisy(Int_t col, Int_t row) const {
298 // is this pixel noisy?
299 Int_t key = GetKey(col,row);
300 if ( fNoisyPixelMap.Find(key) != NULL ) {
308 void AliITSOnlineCalibrationSPDhandler::PrintDead() const {
309 // print the dead pixels to screen
310 printf("-----------------------\n");
311 printf("Dead Pixels Module %d:\n",fModuleNr);
312 printf("-----------------------\n");
313 for (UInt_t index=0; index<fDeadPixelMap.GetNrEntries(); index++) {
314 Int_t key = fDeadPixelMap.GetKey(index);
315 Int_t col = GetColFromKey(key);
316 Int_t row = GetRowFromKey(key);
317 printf("%d,%d\n",col,row);
321 void AliITSOnlineCalibrationSPDhandler::PrintNoisy() const {
322 // print the noisy pixels to screen
323 printf("-----------------------\n");
324 printf("Noisy Pixels Module %d:\n",fModuleNr);
325 printf("-----------------------\n");
326 for (UInt_t index=0; index<fNoisyPixelMap.GetNrEntries(); index++) {
327 Int_t key = fNoisyPixelMap.GetKey(index);
328 Int_t col = GetColFromKey(key);
329 Int_t row = GetRowFromKey(key);
330 printf("%d,%d\n",col,row);