]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSCalibrationSPD.cxx
In Open() and GotoEvent() try the ESD operations first, fallback to run-loader.
[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
23// March-April 2006
478d804c 24// Last mod: H. Tydesjo Aug 2008
06017659 25// September 2007: CouplingRowDefault = 0.055 (was 0.047)
590d15ee 26//
27///////////////////////////////////////////////////////////////////////////
b15de2d2 28const Double_t AliITSCalibrationSPD::fgkThreshDefault = 3000.;
29const Double_t AliITSCalibrationSPD::fgkSigmaDefault = 250.;
30const Double_t AliITSCalibrationSPD::fgkCouplColDefault = 0.;
06017659 31const Double_t AliITSCalibrationSPD::fgkCouplRowDefault = 0.055;
b15de2d2 32const Double_t AliITSCalibrationSPD::fgkBiasVoltageDefault = 18.182;
33
478d804c 34ClassImp(AliITSCalibrationSPD)
590d15ee 35
fcf95fc7 36//______________________________________________________________________
37AliITSCalibrationSPD::AliITSCalibrationSPD():
38AliITSCalibration(),
39fBaseline(0.0),
40fNoise(0.0),
41fThresh(fgkThreshDefault),
42fSigma(fgkSigmaDefault),
5bfe44ce 43fCouplCol(fgkCouplColDefault),
44fCouplRow(fgkCouplRowDefault),
45fBiasVoltage(fgkBiasVoltageDefault),
6727e2db 46fNrBad(0),
47fBadChannels(0){
fcf95fc7 48 // constructor
49
50 SetThresholds(fgkThreshDefault,fgkSigmaDefault);
5bfe44ce 51 SetCouplingParam(fgkCouplColDefault,fgkCouplRowDefault);
52 SetBiasVoltage(fgkBiasVoltageDefault);
fcf95fc7 53 SetNoiseParam(0.,0.);
54 SetDataType("simulated");
478d804c 55 ClearBad();
56}
57//____________________________________________________________________________
58void AliITSCalibrationSPD::ClearBad() {
59 // clear all bad pixels (single+chips)
60 fBadChannels.Reset();
61 fNrBad=0;
62 for (UInt_t chip=0; chip<5; chip++) {
63 fBadChip[chip]=kFALSE;
64 }
fcf95fc7 65}
5bfe44ce 66//____________________________________________________________________________
6727e2db 67void AliITSCalibrationSPD::AddBad(UInt_t col, UInt_t row) {
478d804c 68 // add single bad pixel
6727e2db 69 fBadChannels.Set(fNrBad*2+2);
70 fBadChannels.AddAt(col,fNrBad*2);
71 fBadChannels.AddAt(row,fNrBad*2+1);
72 fNrBad++;
5bfe44ce 73}
590d15ee 74//____________________________________________________________________________
478d804c 75void AliITSCalibrationSPD::SetChipBad(UInt_t chip) {
76 // set full chip bad
77 if (chip>=5) {AliError("Wrong chip number");}
78 fBadChip[chip]=kTRUE;
79}
80//____________________________________________________________________________
81void AliITSCalibrationSPD::UnSetChipBad(UInt_t chip) {
82 // unset full chip bad
83 if (chip>=5) {AliError("Wrong chip number");}
84 fBadChip[chip]=kFALSE;
85}
86//____________________________________________________________________________
87Int_t AliITSCalibrationSPD::GetBadColAt(UInt_t index) const {
6727e2db 88 // Get column of index-th bad pixel
478d804c 89 if ((Int_t)index<GetNrBadSingle()) {
6727e2db 90 return fBadChannels.At(index*2);
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 chip*32 + badPixelIndex/256;
100 }
101 }
102 }
103 AliError(Form("Index %d is out of bounds - returning -1",index));
5bfe44ce 104 return -1;
105}
590d15ee 106//____________________________________________________________________________
478d804c 107Int_t AliITSCalibrationSPD::GetBadRowAt(UInt_t index) const {
6727e2db 108 // Get row of index-th bad pixel
478d804c 109 if ((Int_t)index<GetNrBadSingle()) {
6727e2db 110 return fBadChannels.At(index*2+1);
5bfe44ce 111 }
478d804c 112 else {
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;
120 }
5bfe44ce 121 }
122 }
478d804c 123 AliError(Form("Index %d is out of bounds - returning -1",index));
124 return -1;
5bfe44ce 125}
8d37cc87 126//____________________________________________________________________________
478d804c 127void 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
8d37cc87 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)
131 row = -1;
132 col = -1;
478d804c 133 if(index>=0 && index<GetNrBadSingle()){
134 col = GetBadColAt(index);
135 row = GetBadRowAt(index);
8d37cc87 136 return;
137 }
478d804c 138 else {
139 if (index>=0) {
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;
148 return;
149 }
150 }
151 }
152 }
153 AliError(Form("Index %d is out of bounds - nothing done",index));
8d37cc87 154}
1bdd39a1 155//___________________________________________________________________________
478d804c 156Int_t AliITSCalibrationSPD::GetNrBad() const {
157 // Total number of bad pixels (including bad chips) in a given module
158 Int_t bad=0;
159 // single pixels:
160 bad+=fNrBad;
161 // whole chips:
162 for (UInt_t chip=0; chip<5; chip++) {
163 bad+=fBadChip[chip]*32*256;
164 }
165 return bad;
1bdd39a1 166}
167//___________________________________________________________________________
168Int_t AliITSCalibrationSPD::GetNrBadInChip(Int_t chip) const {
478d804c 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;
172 else {
173 Int_t bad=0;
174 for (UInt_t i=0; i<fNrBad; i++) {
175 Int_t col = GetBadColAt(i);
176 if (col!=-1) {
177 if (GetChipIndexFromCol(col)==chip) bad++;
178 }
179 }
180 return bad;
181 }
182}
183//___________________________________________________________________________
184Int_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;
188 else {
189 Int_t bad=0;
190 for (UInt_t i=0; i<fNrBad; i++) {
191 if (GetBadColAt(i)==col) bad++;
192 }
193 return bad;
194 }
195}
196//______________________________________________________________________
197Bool_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;
201 }
202 return kTRUE;
203}
204//______________________________________________________________________
205Bool_t AliITSCalibrationSPD::IsChipBad(Int_t chip) const {
206 // Is the full chip bad?
207 return (GetNrBadInChip(chip)==32*256);
208}
209//______________________________________________________________________
210Bool_t AliITSCalibrationSPD::IsColumnBad(Int_t col) const {
211 // Is the full column bad?
212 return (GetNrBadInColumn(col)==256);
213}
214//____________________________________________________________________________
215Bool_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) {
222 return kTRUE;
223 }
224 }
225 return kFALSE;
226}
227//______________________________________________________________________
228Int_t AliITSCalibrationSPD::GetChipIndexFromCol(UInt_t col) const {
229 // returns chip index for specific column
230 if(col>=160) {AliWarning("Wrong column number"); return -1;}
231 return col/32;
232}
233//______________________________________________________________________
234void AliITSCalibrationSPD::SetNrBad(UInt_t /*nr*/) {
235 // should not be used anymore !!!
236 AliError("This method should not be used anymore. Use SetNrBadSingle instead!!!");
1bdd39a1 237}
14089bc5 238//______________________________________________________________________
239void AliITSCalibrationSPD::Streamer(TBuffer &R__b) {
240 // Stream an object of class AliITSCalibrationSPD.
241 UInt_t R__s, R__c;
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);
245 R__b >> fBaseline;
246 R__b >> fNoise;
247 R__b >> fThresh;
248 R__b >> fSigma;
249 R__b >> fCouplCol;
250 R__b >> fCouplRow;
251 R__b >> fBiasVoltage;
252 R__b >> fNrBad;
478d804c 253 if (R__v >= 7) {
14089bc5 254 fBadChannels.Streamer(R__b);
478d804c 255 R__b.ReadStaticArray((bool*)fBadChip);
14089bc5 256 }
257 else {
478d804c 258 if (R__v == 6) {
259 fBadChannels.Streamer(R__b);
260 }
261 else {
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];
267 }
268 }
269 for (UInt_t i=0; i<5; i++) {
270 fBadChip[i]=kFALSE;
14089bc5 271 }
272 }
273 R__b.CheckByteCount(R__s, R__c, AliITSCalibrationSPD::IsA());
274 }
275 else {
276 R__c = R__b.WriteVersion(AliITSCalibrationSPD::IsA(), kTRUE);
277 AliITSCalibration::Streamer(R__b);
278 R__b << fBaseline;
279 R__b << fNoise;
280 R__b << fThresh;
281 R__b << fSigma;
282 R__b << fCouplCol;
283 R__b << fCouplRow;
284 R__b << fBiasVoltage;
285 R__b << fNrBad;
286 fBadChannels.Streamer(R__b);
478d804c 287 R__b.WriteArray(fBadChip, 5);
14089bc5 288 R__b.SetByteCount(R__c, kTRUE);
289 }
290}