]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSCalibrationSPD.cxx
Added in ITS upgrade -
[u/mrichter/AliRoot.git] / ITS / AliITSCalibrationSPD.cxx
CommitLineData
fcf95fc7 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
5bfe44ce 15
fcf95fc7 16#include "AliITSCalibrationSPD.h"
590d15ee 17///////////////////////////////////////////////////////////////////////////
18// Calibration class for set:ITS
19// Specific subdetector implementation for
20// Silicon pixels
21//
22// Modified by D. Elia, G.E. Bruno, H. Tydesjo
590d15ee 23///////////////////////////////////////////////////////////////////////////
b15de2d2 24
478d804c 25ClassImp(AliITSCalibrationSPD)
590d15ee 26
fcf95fc7 27//______________________________________________________________________
28AliITSCalibrationSPD::AliITSCalibrationSPD():
29AliITSCalibration(),
6727e2db 30fNrBad(0),
31fBadChannels(0){
fcf95fc7 32 // constructor
33
fcf95fc7 34 SetDataType("simulated");
478d804c 35 ClearBad();
36}
37//____________________________________________________________________________
38void AliITSCalibrationSPD::ClearBad() {
39 // clear all bad pixels (single+chips)
40 fBadChannels.Reset();
41 fNrBad=0;
42 for (UInt_t chip=0; chip<5; chip++) {
43 fBadChip[chip]=kFALSE;
44 }
fcf95fc7 45}
5bfe44ce 46//____________________________________________________________________________
6727e2db 47void AliITSCalibrationSPD::AddBad(UInt_t col, UInt_t row) {
478d804c 48 // add single bad pixel
6727e2db 49 fBadChannels.Set(fNrBad*2+2);
50 fBadChannels.AddAt(col,fNrBad*2);
51 fBadChannels.AddAt(row,fNrBad*2+1);
52 fNrBad++;
5bfe44ce 53}
590d15ee 54//____________________________________________________________________________
478d804c 55void AliITSCalibrationSPD::SetChipBad(UInt_t chip) {
56 // set full chip bad
57 if (chip>=5) {AliError("Wrong chip number");}
58 fBadChip[chip]=kTRUE;
59}
60//____________________________________________________________________________
61void AliITSCalibrationSPD::UnSetChipBad(UInt_t chip) {
62 // unset full chip bad
63 if (chip>=5) {AliError("Wrong chip number");}
64 fBadChip[chip]=kFALSE;
65}
66//____________________________________________________________________________
67Int_t AliITSCalibrationSPD::GetBadColAt(UInt_t index) const {
6727e2db 68 // Get column of index-th bad pixel
478d804c 69 if ((Int_t)index<GetNrBadSingle()) {
6727e2db 70 return fBadChannels.At(index*2);
5bfe44ce 71 }
478d804c 72 else {
73 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
74 Int_t badChipsFound =0;
75 for (UInt_t chip=0; chip<5; chip++) {
76 if (fBadChip[chip]) badChipsFound++;
77 if (badChipIndex==badChipsFound-1) {
78 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
79 return chip*32 + badPixelIndex/256;
80 }
81 }
82 }
83 AliError(Form("Index %d is out of bounds - returning -1",index));
5bfe44ce 84 return -1;
85}
590d15ee 86//____________________________________________________________________________
478d804c 87Int_t AliITSCalibrationSPD::GetBadRowAt(UInt_t index) const {
6727e2db 88 // Get row of index-th bad pixel
478d804c 89 if ((Int_t)index<GetNrBadSingle()) {
6727e2db 90 return fBadChannels.At(index*2+1);
5bfe44ce 91 }
478d804c 92 else {
93 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
94 Int_t badChipsFound =0;
95 for (UInt_t chip=0; chip<5; chip++) {
96 if (fBadChip[chip]) badChipsFound++;
97 if (badChipIndex==badChipsFound-1) {
98 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
99 return badPixelIndex%256;
100 }
5bfe44ce 101 }
102 }
478d804c 103 AliError(Form("Index %d is out of bounds - returning -1",index));
104 return -1;
5bfe44ce 105}
8d37cc87 106//____________________________________________________________________________
478d804c 107void AliITSCalibrationSPD::GetBadPixel(Int_t index, Int_t &row, Int_t &col) const {
108 // i: is the i-th bad pixel in single bad pixel list
8d37cc87 109 // row: is the corresponding row (-1 if i is out of range)
110 // col: is the corresponding column (-1 if i is out of range)
111 row = -1;
112 col = -1;
478d804c 113 if(index>=0 && index<GetNrBadSingle()){
114 col = GetBadColAt(index);
115 row = GetBadRowAt(index);
8d37cc87 116 return;
117 }
478d804c 118 else {
119 if (index>=0) {
120 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
121 Int_t badChipsFound =0;
122 for (UInt_t chip=0; chip<5; chip++) {
123 if (fBadChip[chip]) badChipsFound++;
124 if (badChipIndex==badChipsFound-1) {
125 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
126 col = chip*32 + badPixelIndex/256;
127 row = badPixelIndex%256;
128 return;
129 }
130 }
131 }
132 }
133 AliError(Form("Index %d is out of bounds - nothing done",index));
8d37cc87 134}
1bdd39a1 135//___________________________________________________________________________
478d804c 136Int_t AliITSCalibrationSPD::GetNrBad() const {
137 // Total number of bad pixels (including bad chips) in a given module
138 Int_t bad=0;
139 // single pixels:
140 bad+=fNrBad;
141 // whole chips:
142 for (UInt_t chip=0; chip<5; chip++) {
143 bad+=fBadChip[chip]*32*256;
144 }
145 return bad;
1bdd39a1 146}
147//___________________________________________________________________________
148Int_t AliITSCalibrationSPD::GetNrBadInChip(Int_t chip) const {
478d804c 149 // Total number of bad pixels (including bad chips) in a given chip: chip range [0,4]
150 if(chip<0 || chip>4) {AliError("Wrong chip number"); return -1;}
151 if (fBadChip[chip]) return 32*256;
152 else {
153 Int_t bad=0;
154 for (UInt_t i=0; i<fNrBad; i++) {
155 Int_t col = GetBadColAt(i);
156 if (col!=-1) {
157 if (GetChipIndexFromCol(col)==chip) bad++;
158 }
159 }
160 return bad;
161 }
162}
163//___________________________________________________________________________
164Int_t AliITSCalibrationSPD::GetNrBadInColumn(Int_t col) const {
165 // Total number of bad pixels (including bad chips) in a given column: col. range [0,159]
166 if(col<0 || col>159) {AliError("Wrong column number"); return -1;}
167 if (fBadChip[GetChipIndexFromCol(col)]) return 256;
168 else {
169 Int_t bad=0;
170 for (UInt_t i=0; i<fNrBad; i++) {
171 if (GetBadColAt(i)==col) bad++;
172 }
173 return bad;
174 }
175}
176//______________________________________________________________________
177Bool_t AliITSCalibrationSPD::IsBad() const {
178 // Are all chips of this module bad?
179 for (UInt_t chip=0; chip<5; chip++) {
180 if (!fBadChip[chip]) return kFALSE;
181 }
182 return kTRUE;
183}
184//______________________________________________________________________
185Bool_t AliITSCalibrationSPD::IsChipBad(Int_t chip) const {
186 // Is the full chip bad?
187 return (GetNrBadInChip(chip)==32*256);
188}
189//______________________________________________________________________
190Bool_t AliITSCalibrationSPD::IsColumnBad(Int_t col) const {
191 // Is the full column bad?
192 return (GetNrBadInColumn(col)==256);
193}
194//____________________________________________________________________________
195Bool_t AliITSCalibrationSPD::IsPixelBad(Int_t col, Int_t row) const {
196 // Is this pixel bad?
197 if(col<0 || col>159) {AliError("Wrong column number"); return kFALSE;}
198 Int_t chip = GetChipIndexFromCol(col);
199 if (fBadChip[chip]) return kTRUE;
200 for (UInt_t i=0; i<fNrBad; i++) {
201 if (GetBadColAt(i)==col && GetBadRowAt(i)==row) {
202 return kTRUE;
203 }
204 }
205 return kFALSE;
206}
207//______________________________________________________________________
208Int_t AliITSCalibrationSPD::GetChipIndexFromCol(UInt_t col) const {
209 // returns chip index for specific column
210 if(col>=160) {AliWarning("Wrong column number"); return -1;}
211 return col/32;
212}
213//______________________________________________________________________
214void AliITSCalibrationSPD::SetNrBad(UInt_t /*nr*/) {
215 // should not be used anymore !!!
216 AliError("This method should not be used anymore. Use SetNrBadSingle instead!!!");
1bdd39a1 217}
14089bc5 218//______________________________________________________________________
219void AliITSCalibrationSPD::Streamer(TBuffer &R__b) {
220 // Stream an object of class AliITSCalibrationSPD.
221 UInt_t R__s, R__c;
222 if (R__b.IsReading()) {
223 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
224 AliITSCalibration::Streamer(R__b);
bb292d31 225 if (R__v >= 8) {
226 R__b >> fNrBad;
14089bc5 227 fBadChannels.Streamer(R__b);
478d804c 228 R__b.ReadStaticArray((bool*)fBadChip);
14089bc5 229 }
230 else {
bb292d31 231 Double_t dummy;
232 R__b >> dummy;
233 R__b >> dummy;
234 R__b >> dummy;
235 R__b >> dummy;
236 R__b >> dummy;
237 R__b >> dummy;
238 R__b >> dummy;
239 R__b >> fNrBad;
240 if (R__v == 7) {
478d804c 241 fBadChannels.Streamer(R__b);
bb292d31 242 R__b.ReadStaticArray((bool*)fBadChip);
478d804c 243 }
244 else {
bb292d31 245 if (R__v == 6) {
246 fBadChannels.Streamer(R__b);
247 }
248 else {
249 TArrayI fBadChannelsV1;
250 fBadChannelsV1.Streamer(R__b);
251 fBadChannels.Set(fNrBad*2);
252 for (UInt_t i=0; i<fNrBad*2; i++) {
253 fBadChannels[i] = fBadChannelsV1[i];
254 }
255 }
256 for (UInt_t i=0; i<5; i++) {
257 fBadChip[i]=kFALSE;
478d804c 258 }
14089bc5 259 }
260 }
261 R__b.CheckByteCount(R__s, R__c, AliITSCalibrationSPD::IsA());
262 }
263 else {
264 R__c = R__b.WriteVersion(AliITSCalibrationSPD::IsA(), kTRUE);
265 AliITSCalibration::Streamer(R__b);
14089bc5 266 R__b << fNrBad;
267 fBadChannels.Streamer(R__b);
478d804c 268 R__b.WriteArray(fBadChip, 5);
14089bc5 269 R__b.SetByteCount(R__c, kTRUE);
270 }
271}