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 "AliITSUCalibrationPix.h"
18 ///////////////////////////////////////////////////////////////////////////
20 // Calibration class for set:ITS
21 // Specific subdetector implementation for
24 // Modified by D. Elia, G.E. Bruno, H. Tydesjo
25 // Adapted for upgrade ruben.shahoyan@cern.ch
27 ///////////////////////////////////////////////////////////////////////////
29 ClassImp(AliITSUCalibrationPix)
31 //______________________________________________________________________
32 AliITSUCalibrationPix::AliITSUCalibrationPix()
42 SetDataType("simulated");
46 //______________________________________________________________________
47 AliITSUCalibrationPix::AliITSUCalibrationPix(Short_t nChips,Short_t nColPerChip,Short_t nRow)
57 SetDataType("simulated");
58 SetColRowData(nChips,nColPerChip,nRow);
62 //______________________________________________________________________
63 AliITSUCalibrationPix::AliITSUCalibrationPix(const AliITSUCalibrationPix &src) :
64 AliITSCalibration(src)
66 ,fNColPerChip(src.fNColPerChip)
69 ,fNrBadSingle(src.fNrBadSingle)
70 ,fBadChips(src.fBadChips)
71 ,fBadChannels(src.fBadChannels)
75 //____________________________________________________________________________
76 void AliITSUCalibrationPix::ClearBad()
78 // clear all bad pixels (single+chips)
85 //____________________________________________________________________________
86 void AliITSUCalibrationPix::AddBad(Int_t col, Int_t row)
88 // add single bad pixel
89 fBadChannels.Set(fNrBadSingle*2+2);
90 fBadChannels.AddAt(col,fNrBadSingle*2);
91 fBadChannels.AddAt(row,fNrBadSingle*2+1);
95 //____________________________________________________________________________
96 void AliITSUCalibrationPix::SetChipBad(Int_t chip)
99 if ((int)chip>=fNChips) {AliError(Form("chip number %d exceeds allowed limit %d",chip,fNChips)); return;}
100 fBadChips |= 0x1<<chip;
104 //____________________________________________________________________________
105 void AliITSUCalibrationPix::UnSetChipBad(Int_t chip)
107 // unset full chip bad
108 if (chip>=fNChips) {AliError(Form("chip number %d exceeds allowed limit %d",chip,fNChips)); return;}
109 fBadChips &= ~(0x1<<chip);
113 //____________________________________________________________________________
114 Int_t AliITSUCalibrationPix::GetBadColAt(Int_t index) const
116 // Get column of index-th bad pixel
117 int nrc = fNColPerChip*fNRow;
118 if (nrc<1) AliFatal("Number of colums and rows is not set");
120 if ((Int_t)index<GetNrBadSingle()) return fBadChannels.At(index*2);
122 Int_t badChipIndex=(index-GetNrBadSingle())/nrc;
123 Int_t badChipsFound =0;
124 for (int chip=fNChips; chip--;) {
125 if (IsChipMarkedBad(chip)) badChipsFound++;
126 if (badChipIndex==badChipsFound-1) {
127 Int_t badPixelIndex=(index-GetNrBadSingle())%(nrc);
128 return chip*fNColPerChip + badPixelIndex/fNRow;
132 AliError(Form("Index %d is out of bounds - returning -1",index));
136 //____________________________________________________________________________
137 Int_t AliITSUCalibrationPix::GetBadRowAt(Int_t index) const
139 // Get row of index-th bad pixel
140 int nrc = fNColPerChip*fNRow;
141 if (nrc<1) AliFatal("Number of colums and rows is not set");
143 if ((Int_t)index<GetNrBadSingle()) return fBadChannels.At(index*2+1);
145 Int_t badChipIndex=(index-GetNrBadSingle())/nrc;
146 Int_t badChipsFound =0;
147 for (int chip=fNChips; chip--;) {
148 if (IsChipMarkedBad(chip)) badChipsFound++;
149 if (badChipIndex==badChipsFound-1) {
150 Int_t badPixelIndex=(index-GetNrBadSingle())%nrc;
151 return badPixelIndex%fNRow;
155 AliError(Form("Index %d is out of bounds - returning -1",index));
159 //____________________________________________________________________________
160 void AliITSUCalibrationPix::GetBadPixel(Int_t index, Int_t &row, Int_t &col) const
162 // i: is the i-th bad pixel in single bad pixel list
163 // row: is the corresponding row (-1 if i is out of range)
164 // col: is the corresponding column (-1 if i is out of range)
167 if(index>=0 && index<GetNrBadSingle()){
168 col = GetBadColAt(index);
169 row = GetBadRowAt(index);
174 int nrc = fNColPerChip*fNRow;
175 if (nrc<1) AliFatal("Number of colums and rows is not set");
176 Int_t badChipIndex=(index-GetNrBadSingle())/nrc;
177 Int_t badChipsFound =0;
178 for (int chip=fNChips; chip--;) {
179 if (IsChipMarkedBad(chip)) badChipsFound++;
180 if (badChipIndex==badChipsFound-1) {
181 Int_t badPixelIndex=(index-GetNrBadSingle())%nrc;
182 col = chip*fNColPerChip + badPixelIndex/fNRow;
183 row = badPixelIndex%fNRow;
189 AliError(Form("Index %d is out of bounds - nothing done",index));
192 //____________________________________________________________________________
193 void AliITSUCalibrationPix::GetBadPixelSingle(Int_t index, UInt_t &row, UInt_t &col) const
195 // i: is the i-th bad pixel in single bad pixel list
196 // row: is the corresponding row (-1 if i is out of range)
197 // col: is the corresponding column (-1 if i is out of range)
198 if(index<0 && index>=GetNrBadSingle()) AliFatal(Form("Index %d >= NrBadSingle=%d",index,fNrBadSingle));
199 col = fBadChannels.At(index*2);
200 row = fBadChannels.At(index*2+1);
203 //___________________________________________________________________________
204 Int_t AliITSUCalibrationPix::GetNrBad() const
206 // Total number of bad pixels (including bad chips) in a given chip
211 for (int chip=fNChips; chip--;) if (IsChipMarkedBad(chip)) bad += fNColPerChip*fNRow;
215 //___________________________________________________________________________
216 Int_t AliITSUCalibrationPix::GetNrBadInChip(Int_t chip) const
218 // Total number of bad pixels (including bad chips) in a given chip
219 if(chip<0 || chip>=fNChips) {AliError("Wrong chip number"); return -1;}
220 if (IsChipMarkedBad(chip)) return fNColPerChip*fNRow;
223 for (int i=fNrBadSingle; i--;) {
224 Int_t col = GetBadColAt(i);
225 if (col!=-1) if (GetChipIndexFromCol(col)==chip) bad++;
231 //___________________________________________________________________________
232 Int_t AliITSUCalibrationPix::GetNrBadInColumn(Int_t col) const
234 // Total number of bad pixels (including bad chips) in a given column: col. range
235 if(col<0 || col>=fNCol) {AliError("Wrong column number"); return -1;}
236 if (IsChipMarkedBad(GetChipIndexFromCol(col))) return fNRow;
239 for (int i=fNrBadSingle; i--;) if (GetBadColAt(i)==col) bad++;
244 //______________________________________________________________________
245 Bool_t AliITSUCalibrationPix::IsBad() const
247 // Are all chips of this chip bad?
248 for (Int_t chip=fNChips; chip--;) if (!IsChipMarkedBad(chip)) return kFALSE;
252 //______________________________________________________________________
253 Bool_t AliITSUCalibrationPix::IsChipBad(Int_t chip) const
255 // Is the full chip bad?
256 return (GetNrBadInChip(chip)==fNColPerChip*fNRow);
259 //______________________________________________________________________
260 Bool_t AliITSUCalibrationPix::IsColumnBad(Int_t col) const
262 // Is the full column bad?
263 return (GetNrBadInColumn(col)==fNRow);
266 //____________________________________________________________________________
267 Bool_t AliITSUCalibrationPix::IsPixelBad(Int_t col, Int_t row) const
269 // Is this pixel bad?
270 if(col<0 || col>=fNCol) {AliError("Wrong column number"); return kFALSE;}
271 Int_t chip = GetChipIndexFromCol(col);
272 if (IsChipMarkedBad(chip)) return kTRUE;
273 for (Int_t i=fNrBadSingle; i--;) if (GetBadColAt(i)==col && GetBadRowAt(i)==row) return kTRUE;
277 //______________________________________________________________________
278 Int_t AliITSUCalibrationPix::GetChipIndexFromCol(Int_t col) const
280 // returns chip index for specific column
281 if(col>=fNCol) {AliWarning("Wrong column number"); return -1;}
282 return col/fNColPerChip;
285 //______________________________________________________________________
286 void AliITSUCalibrationPix::SetNrBad(Int_t /*nr*/)
288 // should not be used anymore !!!
289 AliError("This method should not be used anymore. Use SetNrBadSingle instead!!!");
292 //____________________________________________________________________________
293 void AliITSUCalibrationPix::SetColRowData(Short_t nchip, Short_t ncolperchip, Short_t nrow)
295 // set segmentation data
297 fNCol = nchip*ncolperchip;
299 fNColPerChip = ncolperchip;