1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 #include "AliITSCalibrationSPD.h"
17 ///////////////////////////////////////////////////////////////////////////
18 // Calibration class for set:ITS
19 // Specific subdetector implementation for
22 // Modified by D. Elia, G.E. Bruno, H. Tydesjo
23 ///////////////////////////////////////////////////////////////////////////
25 ClassImp(AliITSCalibrationSPD)
27 //______________________________________________________________________
28 AliITSCalibrationSPD::AliITSCalibrationSPD():
34 SetDataType("simulated");
37 //____________________________________________________________________________
38 void AliITSCalibrationSPD::ClearBad() {
39 // clear all bad pixels (single+chips)
42 for (UInt_t chip=0; chip<5; chip++) {
43 fBadChip[chip]=kFALSE;
46 //____________________________________________________________________________
47 void AliITSCalibrationSPD::AddBad(UInt_t col, UInt_t row) {
48 // add single bad pixel
49 fBadChannels.Set(fNrBad*2+2);
50 fBadChannels.AddAt(col,fNrBad*2);
51 fBadChannels.AddAt(row,fNrBad*2+1);
54 //____________________________________________________________________________
55 void AliITSCalibrationSPD::SetChipBad(UInt_t chip) {
57 if (chip>=5) {AliError("Wrong chip number");
63 //____________________________________________________________________________
64 void AliITSCalibrationSPD::UnSetChipBad(UInt_t chip) {
65 // unset full chip bad
66 if (chip>=5 ) {AliError("Wrong chip number");
69 fBadChip[chip]=kFALSE;
72 //____________________________________________________________________________
73 Int_t AliITSCalibrationSPD::GetBadColAt(UInt_t index) const {
74 // Get column of index-th bad pixel
75 if ((Int_t)index<GetNrBadSingle()) {
76 return fBadChannels.At(index*2);
79 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
80 Int_t badChipsFound =0;
81 for (UInt_t chip=0; chip<5; chip++) {
82 if (fBadChip[chip]) badChipsFound++;
83 if (badChipIndex==badChipsFound-1) {
84 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
85 return chip*32 + badPixelIndex/256;
89 AliError(Form("Index %d is out of bounds - returning -1",index));
92 //____________________________________________________________________________
93 Int_t AliITSCalibrationSPD::GetBadRowAt(UInt_t index) const {
94 // Get row of index-th bad pixel
95 if ((Int_t)index<GetNrBadSingle()) {
96 return fBadChannels.At(index*2+1);
99 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
100 Int_t badChipsFound =0;
101 for (UInt_t chip=0; chip<5; chip++) {
102 if (fBadChip[chip]) badChipsFound++;
103 if (badChipIndex==badChipsFound-1) {
104 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
105 return badPixelIndex%256;
109 AliError(Form("Index %d is out of bounds - returning -1",index));
112 //____________________________________________________________________________
113 void AliITSCalibrationSPD::GetBadPixel(Int_t index, Int_t &row, Int_t &col) const {
114 // i: is the i-th bad pixel in single bad pixel list
115 // row: is the corresponding row (-1 if i is out of range)
116 // col: is the corresponding column (-1 if i is out of range)
119 if(index>=0 && index<GetNrBadSingle()){
120 col = GetBadColAt(index);
121 row = GetBadRowAt(index);
126 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
127 Int_t badChipsFound =0;
128 for (UInt_t chip=0; chip<5; chip++) {
129 if (fBadChip[chip]) badChipsFound++;
130 if (badChipIndex==badChipsFound-1) {
131 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
132 col = chip*32 + badPixelIndex/256;
133 row = badPixelIndex%256;
139 AliError(Form("Index %d is out of bounds - nothing done",index));
141 //___________________________________________________________________________
142 Int_t AliITSCalibrationSPD::GetNrBad() const {
143 // Total number of bad pixels (including bad chips) in a given module
148 for (UInt_t chip=0; chip<5; chip++) {
149 bad+=fBadChip[chip]*32*256;
153 //___________________________________________________________________________
154 Int_t AliITSCalibrationSPD::GetNrBadInChip(Int_t chip) const {
155 // Total number of bad pixels (including bad chips) in a given chip: chip range [0,4]
156 if(chip<0 || chip>4) {AliError("Wrong chip number"); return -1;}
157 if (fBadChip[chip]) return 32*256;
160 for (UInt_t i=0; i<fNrBad; i++) {
161 Int_t col = GetBadColAt(i);
163 if (GetChipIndexFromCol(col)==chip) bad++;
169 //___________________________________________________________________________
170 Int_t AliITSCalibrationSPD::GetNrBadInColumn(Int_t col) const {
171 // Total number of bad pixels (including bad chips) in a given column: col. range [0,159]
172 if(col<0 || col>159) {AliError("Wrong column number"); return -1;}
173 if (fBadChip[GetChipIndexFromCol(col)]) return 256;
176 for (UInt_t i=0; i<fNrBad; i++) {
177 if (GetBadColAt(i)==col) bad++;
182 //______________________________________________________________________
183 Bool_t AliITSCalibrationSPD::IsBad() const {
184 // Are all chips of this module bad?
185 for (UInt_t chip=0; chip<5; chip++) {
186 if (!fBadChip[chip]) return kFALSE;
190 //______________________________________________________________________
191 Bool_t AliITSCalibrationSPD::IsChipBad(Int_t chip) const {
192 // Is the full chip bad?
193 return (GetNrBadInChip(chip)==32*256);
195 //______________________________________________________________________
196 Bool_t AliITSCalibrationSPD::IsColumnBad(Int_t col) const {
197 // Is the full column bad?
198 return (GetNrBadInColumn(col)==256);
200 //____________________________________________________________________________
201 Bool_t AliITSCalibrationSPD::IsPixelBad(Int_t col, Int_t row) const {
202 // Is this pixel bad?
203 if(col<0 || col>159) {AliError("Wrong column number"); return kFALSE;}
204 Int_t chip = GetChipIndexFromCol(col);
205 if (fBadChip[chip]) return kTRUE;
206 for (UInt_t i=0; i<fNrBad; i++) {
207 if (GetBadColAt(i)==col && GetBadRowAt(i)==row) {
213 //______________________________________________________________________
214 Int_t AliITSCalibrationSPD::GetChipIndexFromCol(UInt_t col) const {
215 // returns chip index for specific column
216 if(col>=160) {AliWarning("Wrong column number"); return -1;}
219 //______________________________________________________________________
220 void AliITSCalibrationSPD::SetNrBad(UInt_t /*nr*/) {
221 // should not be used anymore !!!
222 AliError("This method should not be used anymore. Use SetNrBadSingle instead!!!");
224 //______________________________________________________________________
225 void AliITSCalibrationSPD::Streamer(TBuffer &R__b) {
226 // Stream an object of class AliITSCalibrationSPD.
228 if (R__b.IsReading()) {
229 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
230 AliITSCalibration::Streamer(R__b);
233 fBadChannels.Streamer(R__b);
234 R__b.ReadStaticArray((bool*)fBadChip);
247 fBadChannels.Streamer(R__b);
248 R__b.ReadStaticArray((bool*)fBadChip);
252 fBadChannels.Streamer(R__b);
255 TArrayI fBadChannelsV1;
256 fBadChannelsV1.Streamer(R__b);
257 fBadChannels.Set(fNrBad*2);
258 for (UInt_t i=0; i<fNrBad*2; i++) {
259 fBadChannels[i] = fBadChannelsV1[i];
262 for (UInt_t i=0; i<5; i++) {
267 R__b.CheckByteCount(R__s, R__c, AliITSCalibrationSPD::IsA());
270 R__c = R__b.WriteVersion(AliITSCalibrationSPD::IsA(), kTRUE);
271 AliITSCalibration::Streamer(R__b);
273 fBadChannels.Streamer(R__b);
274 R__b.WriteArray(fBadChip, 5);
275 R__b.SetByteCount(R__c, kTRUE);