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
24 // Last mod: H. Tydesjo Aug 2008
25 // September 2007: CouplingRowDefault = 0.055 (was 0.047)
27 ///////////////////////////////////////////////////////////////////////////
28 const Double_t AliITSCalibrationSPD::fgkThreshDefault = 3000.;
29 const Double_t AliITSCalibrationSPD::fgkSigmaDefault = 250.;
30 const Double_t AliITSCalibrationSPD::fgkCouplColDefault = 0.;
31 const Double_t AliITSCalibrationSPD::fgkCouplRowDefault = 0.055;
32 const Double_t AliITSCalibrationSPD::fgkBiasVoltageDefault = 18.182;
34 ClassImp(AliITSCalibrationSPD)
36 //______________________________________________________________________
37 AliITSCalibrationSPD::AliITSCalibrationSPD():
41 fThresh(fgkThreshDefault),
42 fSigma(fgkSigmaDefault),
43 fCouplCol(fgkCouplColDefault),
44 fCouplRow(fgkCouplRowDefault),
45 fBiasVoltage(fgkBiasVoltageDefault),
50 SetThresholds(fgkThreshDefault,fgkSigmaDefault);
51 SetCouplingParam(fgkCouplColDefault,fgkCouplRowDefault);
52 SetBiasVoltage(fgkBiasVoltageDefault);
54 SetDataType("simulated");
57 //____________________________________________________________________________
58 void AliITSCalibrationSPD::ClearBad() {
59 // clear all bad pixels (single+chips)
62 for (UInt_t chip=0; chip<5; chip++) {
63 fBadChip[chip]=kFALSE;
66 //____________________________________________________________________________
67 void AliITSCalibrationSPD::AddBad(UInt_t col, UInt_t row) {
68 // add single bad pixel
69 fBadChannels.Set(fNrBad*2+2);
70 fBadChannels.AddAt(col,fNrBad*2);
71 fBadChannels.AddAt(row,fNrBad*2+1);
74 //____________________________________________________________________________
75 void AliITSCalibrationSPD::SetChipBad(UInt_t chip) {
77 if (chip>=5) {AliError("Wrong chip number");}
80 //____________________________________________________________________________
81 void AliITSCalibrationSPD::UnSetChipBad(UInt_t chip) {
82 // unset full chip bad
83 if (chip>=5) {AliError("Wrong chip number");}
84 fBadChip[chip]=kFALSE;
86 //____________________________________________________________________________
87 Int_t AliITSCalibrationSPD::GetBadColAt(UInt_t index) const {
88 // Get column of index-th bad pixel
89 if ((Int_t)index<GetNrBadSingle()) {
90 return fBadChannels.At(index*2);
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 chip*32 + badPixelIndex/256;
103 AliError(Form("Index %d is out of bounds - returning -1",index));
106 //____________________________________________________________________________
107 Int_t AliITSCalibrationSPD::GetBadRowAt(UInt_t index) const {
108 // Get row of index-th bad pixel
109 if ((Int_t)index<GetNrBadSingle()) {
110 return fBadChannels.At(index*2+1);
113 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
114 Int_t badChipsFound =0;
115 for (UInt_t chip=0; chip<5; chip++) {
116 if (fBadChip[chip]) badChipsFound++;
117 if (badChipIndex==badChipsFound-1) {
118 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
119 return badPixelIndex%256;
123 AliError(Form("Index %d is out of bounds - returning -1",index));
126 //____________________________________________________________________________
127 void AliITSCalibrationSPD::GetBadPixel(Int_t index, Int_t &row, Int_t &col) const {
128 // i: is the i-th bad pixel in single bad pixel list
129 // row: is the corresponding row (-1 if i is out of range)
130 // col: is the corresponding column (-1 if i is out of range)
133 if(index>=0 && index<GetNrBadSingle()){
134 col = GetBadColAt(index);
135 row = GetBadRowAt(index);
140 Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
141 Int_t badChipsFound =0;
142 for (UInt_t chip=0; chip<5; chip++) {
143 if (fBadChip[chip]) badChipsFound++;
144 if (badChipIndex==badChipsFound-1) {
145 Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
146 col = chip*32 + badPixelIndex/256;
147 row = badPixelIndex%256;
153 AliError(Form("Index %d is out of bounds - nothing done",index));
155 //___________________________________________________________________________
156 Int_t AliITSCalibrationSPD::GetNrBad() const {
157 // Total number of bad pixels (including bad chips) in a given module
162 for (UInt_t chip=0; chip<5; chip++) {
163 bad+=fBadChip[chip]*32*256;
167 //___________________________________________________________________________
168 Int_t AliITSCalibrationSPD::GetNrBadInChip(Int_t chip) const {
169 // Total number of bad pixels (including bad chips) in a given chip: chip range [0,4]
170 if(chip<0 || chip>4) {AliError("Wrong chip number"); return -1;}
171 if (fBadChip[chip]) return 32*256;
174 for (UInt_t i=0; i<fNrBad; i++) {
175 Int_t col = GetBadColAt(i);
177 if (GetChipIndexFromCol(col)==chip) bad++;
183 //___________________________________________________________________________
184 Int_t AliITSCalibrationSPD::GetNrBadInColumn(Int_t col) const {
185 // Total number of bad pixels (including bad chips) in a given column: col. range [0,159]
186 if(col<0 || col>159) {AliError("Wrong column number"); return -1;}
187 if (fBadChip[GetChipIndexFromCol(col)]) return 256;
190 for (UInt_t i=0; i<fNrBad; i++) {
191 if (GetBadColAt(i)==col) bad++;
196 //______________________________________________________________________
197 Bool_t AliITSCalibrationSPD::IsBad() const {
198 // Are all chips of this module bad?
199 for (UInt_t chip=0; chip<5; chip++) {
200 if (!fBadChip[chip]) return kFALSE;
204 //______________________________________________________________________
205 Bool_t AliITSCalibrationSPD::IsChipBad(Int_t chip) const {
206 // Is the full chip bad?
207 return (GetNrBadInChip(chip)==32*256);
209 //______________________________________________________________________
210 Bool_t AliITSCalibrationSPD::IsColumnBad(Int_t col) const {
211 // Is the full column bad?
212 return (GetNrBadInColumn(col)==256);
214 //____________________________________________________________________________
215 Bool_t AliITSCalibrationSPD::IsPixelBad(Int_t col, Int_t row) const {
216 // Is this pixel bad?
217 if(col<0 || col>159) {AliError("Wrong column number"); return kFALSE;}
218 Int_t chip = GetChipIndexFromCol(col);
219 if (fBadChip[chip]) return kTRUE;
220 for (UInt_t i=0; i<fNrBad; i++) {
221 if (GetBadColAt(i)==col && GetBadRowAt(i)==row) {
227 //______________________________________________________________________
228 Int_t AliITSCalibrationSPD::GetChipIndexFromCol(UInt_t col) const {
229 // returns chip index for specific column
230 if(col>=160) {AliWarning("Wrong column number"); return -1;}
233 //______________________________________________________________________
234 void AliITSCalibrationSPD::SetNrBad(UInt_t /*nr*/) {
235 // should not be used anymore !!!
236 AliError("This method should not be used anymore. Use SetNrBadSingle instead!!!");
238 //______________________________________________________________________
239 void AliITSCalibrationSPD::Streamer(TBuffer &R__b) {
240 // Stream an object of class AliITSCalibrationSPD.
242 if (R__b.IsReading()) {
243 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
244 AliITSCalibration::Streamer(R__b);
251 R__b >> fBiasVoltage;
254 fBadChannels.Streamer(R__b);
255 R__b.ReadStaticArray((bool*)fBadChip);
259 fBadChannels.Streamer(R__b);
262 TArrayI fBadChannelsV1;
263 fBadChannelsV1.Streamer(R__b);
264 fBadChannels.Set(fNrBad*2);
265 for (UInt_t i=0; i<fNrBad*2; i++) {
266 fBadChannels[i] = fBadChannelsV1[i];
269 for (UInt_t i=0; i<5; i++) {
273 R__b.CheckByteCount(R__s, R__c, AliITSCalibrationSPD::IsA());
276 R__c = R__b.WriteVersion(AliITSCalibrationSPD::IsA(), kTRUE);
277 AliITSCalibration::Streamer(R__b);
284 R__b << fBiasVoltage;
286 fBadChannels.Streamer(R__b);
287 R__b.WriteArray(fBadChip, 5);
288 R__b.SetByteCount(R__c, kTRUE);