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"
18 ///////////////////////////////////////////////////////////////////////////
19 // Calibration class for set:ITS
20 // Specific subdetector implementation for
23 // Modified by D. Elia, G.E. Bruno, H. Tydesjo
24 ///////////////////////////////////////////////////////////////////////////
26 ClassImp(AliITSCalibrationSPD)
28 //______________________________________________________________________
29 AliITSCalibrationSPD::AliITSCalibrationSPD():
35 SetDataType("simulated");
38 //____________________________________________________________________________
39 void AliITSCalibrationSPD::ClearBad() {
40 // clear all bad pixels (single+chips)
43 for (UInt_t chip=0; chip<5; chip++) {
44 fBadChip[chip]=kFALSE;
47 //____________________________________________________________________________
48 void AliITSCalibrationSPD::AddBad(UInt_t col, UInt_t row) {
49 // add single bad pixel
50 fBadChannels.Set(fNrBad*2+2);
51 fBadChannels.AddAt(col,fNrBad*2);
52 fBadChannels.AddAt(row,fNrBad*2+1);
55 //____________________________________________________________________________
56 void AliITSCalibrationSPD::SetChipBad(UInt_t chip) {
58 if (chip>=5) {AliError("Wrong chip number");
64 //____________________________________________________________________________
65 void AliITSCalibrationSPD::UnSetChipBad(UInt_t chip) {
66 // unset full chip bad
67 if (chip>=5 ) {AliError("Wrong chip number");
70 fBadChip[chip]=kFALSE;
73 //____________________________________________________________________________
74 Int_t AliITSCalibrationSPD::GetBadColAt(UInt_t index) const {
75 // Get column of index-th bad pixel
76 if ((Int_t)index<GetNrBadSingle()) {
77 return fBadChannels.At(index*2);
80 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
81 Int_t badChipsFound =0;
82 for (UInt_t chip=0; chip<5; chip++) {
83 if (fBadChip[chip]) badChipsFound++;
84 if (badChipIndex==badChipsFound-1) {
85 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
86 return chip*32 + badPixelIndex/256;
90 AliError(Form("Index %d is out of bounds - returning -1",index));
93 //____________________________________________________________________________
94 Int_t AliITSCalibrationSPD::GetBadRowAt(UInt_t index) const {
95 // Get row of index-th bad pixel
96 if ((Int_t)index<GetNrBadSingle()) {
97 return fBadChannels.At(index*2+1);
100 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
101 Int_t badChipsFound =0;
102 for (UInt_t chip=0; chip<5; chip++) {
103 if (fBadChip[chip]) badChipsFound++;
104 if (badChipIndex==badChipsFound-1) {
105 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
106 return badPixelIndex%256;
110 AliError(Form("Index %d is out of bounds - returning -1",index));
113 //____________________________________________________________________________
114 void AliITSCalibrationSPD::GetBadPixel(Int_t index, Int_t &row, Int_t &col) const {
115 // i: is the i-th bad pixel in single bad pixel list
116 // row: is the corresponding row (-1 if i is out of range)
117 // col: is the corresponding column (-1 if i is out of range)
120 if(index>=0 && index<GetNrBadSingle()){
121 col = GetBadColAt(index);
122 row = GetBadRowAt(index);
127 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
128 Int_t badChipsFound =0;
129 for (UInt_t chip=0; chip<5; chip++) {
130 if (fBadChip[chip]) badChipsFound++;
131 if (badChipIndex==badChipsFound-1) {
132 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
133 col = chip*32 + badPixelIndex/256;
134 row = badPixelIndex%256;
140 AliError(Form("Index %d is out of bounds - nothing done",index));
142 //___________________________________________________________________________
143 Int_t AliITSCalibrationSPD::GetNrBad() const {
144 // Total number of bad pixels (including bad chips) in a given module
149 for (UInt_t chip=0; chip<5; chip++) {
150 bad+=fBadChip[chip]*32*256;
154 //___________________________________________________________________________
155 Int_t AliITSCalibrationSPD::GetNrBadInChip(Int_t chip) const {
156 // Total number of bad pixels (including bad chips) in a given chip: chip range [0,4]
157 if(chip<0 || chip>4) {AliError("Wrong chip number"); return -1;}
158 if (fBadChip[chip]) return 32*256;
161 for (UInt_t i=0; i<fNrBad; i++) {
162 Int_t col = GetBadColAt(i);
164 if (GetChipIndexFromCol(col)==chip) bad++;
170 //___________________________________________________________________________
171 Int_t AliITSCalibrationSPD::GetNrBadInColumn(Int_t col) const {
172 // Total number of bad pixels (including bad chips) in a given column: col. range [0,159]
173 if(col<0 || col>159) {AliError("Wrong column number"); return -1;}
174 if (fBadChip[GetChipIndexFromCol(col)]) return 256;
177 for (UInt_t i=0; i<fNrBad; i++) {
178 if (GetBadColAt(i)==col) bad++;
183 //______________________________________________________________________
184 Bool_t AliITSCalibrationSPD::IsBad() const {
185 // Are all chips of this module bad?
186 for (UInt_t chip=0; chip<5; chip++) {
187 if (!fBadChip[chip]) return kFALSE;
191 //______________________________________________________________________
192 Bool_t AliITSCalibrationSPD::IsChipBad(Int_t chip) const {
193 // Is the full chip bad?
194 return (GetNrBadInChip(chip)==32*256);
196 //______________________________________________________________________
197 Bool_t AliITSCalibrationSPD::IsColumnBad(Int_t col) const {
198 // Is the full column bad?
199 return (GetNrBadInColumn(col)==256);
201 //____________________________________________________________________________
202 Bool_t AliITSCalibrationSPD::IsPixelBad(Int_t col, Int_t row) const {
203 // Is this pixel bad?
204 if(col<0 || col>159) {AliError("Wrong column number"); return kFALSE;}
205 Int_t chip = GetChipIndexFromCol(col);
206 if (fBadChip[chip]) return kTRUE;
207 for (UInt_t i=0; i<fNrBad; i++) {
208 if (GetBadColAt(i)==col && GetBadRowAt(i)==row) {
214 //______________________________________________________________________
215 Int_t AliITSCalibrationSPD::GetChipIndexFromCol(UInt_t col) const {
216 // returns chip index for specific column
217 if(col>=160) {AliWarning("Wrong column number"); return -1;}
220 //______________________________________________________________________
221 void AliITSCalibrationSPD::SetNrBad(UInt_t /*nr*/) {
222 // should not be used anymore !!!
223 AliError("This method should not be used anymore. Use SetNrBadSingle instead!!!");
225 //______________________________________________________________________
226 void AliITSCalibrationSPD::Streamer(TBuffer &ruub) {
227 // Stream an object of class AliITSCalibrationSPD.
229 if (ruub.IsReading()) {
230 Version_t ruuv = ruub.ReadVersion(&ruus, &ruuc); if (ruuv) { }
231 AliITSCalibration::Streamer(ruub);
234 fBadChannels.Streamer(ruub);
235 ruub.ReadStaticArray((bool*)fBadChip);
248 fBadChannels.Streamer(ruub);
249 ruub.ReadStaticArray((bool*)fBadChip);
253 fBadChannels.Streamer(ruub);
256 TArrayI fBadChannelsV1;
257 fBadChannelsV1.Streamer(ruub);
258 fBadChannels.Set(fNrBad*2);
259 for (UInt_t i=0; i<fNrBad*2; i++) {
260 fBadChannels[i] = fBadChannelsV1[i];
263 for (UInt_t i=0; i<5; i++) {
268 ruub.CheckByteCount(ruus, ruuc, AliITSCalibrationSPD::IsA());
271 ruuc = ruub.WriteVersion(AliITSCalibrationSPD::IsA(), kTRUE);
272 AliITSCalibration::Streamer(ruub);
274 fBadChannels.Streamer(ruub);
275 ruub.WriteArray(fBadChip, 5);
276 ruub.SetByteCount(ruuc, kTRUE);