]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSCalibrationSPD.cxx
Custom streamer in AliITSCalibrationSPD for backward compatibility (H. Tydesjo)
[u/mrichter/AliRoot.git] / ITS / AliITSCalibrationSPD.cxx
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  **************************************************************************/
15
16 #include "AliITSCalibrationSPD.h"
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
24 //  Last mod:  H. Tydesjo  Oct 2007
25 //  September   2007: CouplingRowDefault = 0.055 (was 0.047)
26 //
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;
33
34 ClassImp(AliITSCalibrationSPD)  
35
36 //______________________________________________________________________
37 AliITSCalibrationSPD::AliITSCalibrationSPD():
38 AliITSCalibration(),
39 fBaseline(0.0),
40 fNoise(0.0),
41 fThresh(fgkThreshDefault),
42 fSigma(fgkSigmaDefault),
43 fCouplCol(fgkCouplColDefault),
44 fCouplRow(fgkCouplRowDefault),
45 fBiasVoltage(fgkBiasVoltageDefault),
46 fNrBad(0),
47 fBadChannels(0){
48   // constructor
49
50    SetThresholds(fgkThreshDefault,fgkSigmaDefault);
51    SetCouplingParam(fgkCouplColDefault,fgkCouplRowDefault);
52    SetBiasVoltage(fgkBiasVoltageDefault);
53    SetNoiseParam(0.,0.);
54    SetDataType("simulated");
55 }
56 //____________________________________________________________________________
57 void AliITSCalibrationSPD::AddBad(UInt_t col, UInt_t row) {
58   //
59   // add bad pixel 
60   //
61   fBadChannels.Set(fNrBad*2+2);
62   fBadChannels.AddAt(col,fNrBad*2);
63   fBadChannels.AddAt(row,fNrBad*2+1);
64   fNrBad++;
65 }
66 //____________________________________________________________________________
67 Int_t AliITSCalibrationSPD::GetBadColAt(UInt_t index) {
68   //
69   // Get column of index-th bad pixel
70   //
71   if (index<fNrBad) {
72     return fBadChannels.At(index*2);
73   }
74   return -1;
75 }
76 //____________________________________________________________________________
77 Int_t AliITSCalibrationSPD::GetBadRowAt(UInt_t index) {
78   //
79   // Get row of index-th bad pixel
80   //
81   if (index<fNrBad) {
82     return fBadChannels.At(index*2+1);
83   }
84   return -1;
85 }
86 //____________________________________________________________________________
87 Bool_t AliITSCalibrationSPD::IsPixelBad(Int_t col, Int_t row) const {
88   //
89   // Check if pixel (col,row) is bad
90   //
91   for (UInt_t i=0; i<fNrBad; i++) { 
92     if (fBadChannels.At(i*2)==col && fBadChannels.At(i*2+1)==row) {
93       return true;
94     }
95   }
96   return false;
97 }
98
99 //____________________________________________________________________________
100 void AliITSCalibrationSPD::GetBadPixel(Int_t i, Int_t &row, Int_t &col) const {
101   //
102   // i: is the i-th bad pixel in fBadChannels
103   // row: is the corresponding row (-1 if i is out of range)
104   // col: is the corresponding column (-1 if i is out of range)
105   row = -1;
106   col = -1;
107   if(i<0 || i>=GetNrBad()){
108     AliWarning(Form("Index %d is out of bounds - nothing done",i));
109     return;
110   }
111   col = fBadChannels.At(i*2);
112   row = fBadChannels.At(i*2+1);
113 }
114  
115 //___________________________________________________________________________
116 Int_t  AliITSCalibrationSPD::GetNrBadInColumn(Int_t col) const {
117  //
118  // Count n. of bad in a given column: col. range [0,159]
119  //
120  if(col<0 || col>159) {AliWarning("GetNrBadInColumn: wrong column number"); return -1;}
121  Int_t bad=0;
122  for (UInt_t i=0; i<fNrBad; i++) if (fBadChannels.At(i*2)==col) bad++;
123  return bad;
124 }
125 //___________________________________________________________________________
126 Int_t  AliITSCalibrationSPD::GetNrBadInChip(Int_t chip) const {
127  //
128  // Count n. of bad in a given chip: chip range [0,4]
129  //
130  if(chip<0 || chip>4) {AliWarning("GetNrBadInChip: wrong chip number"); return -1;}
131  Int_t bad=0;
132  for (Int_t col=32*chip; col<32*(chip+1); col++) bad+=GetNrBadInColumn(col);
133  return bad;
134 }
135 //______________________________________________________________________
136 void AliITSCalibrationSPD::Streamer(TBuffer &R__b) {
137   // Stream an object of class AliITSCalibrationSPD.
138   UInt_t R__s, R__c;
139   if (R__b.IsReading()) {
140     Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
141     AliITSCalibration::Streamer(R__b);
142     R__b >> fBaseline;
143     R__b >> fNoise;
144     R__b >> fThresh;
145     R__b >> fSigma;
146     R__b >> fCouplCol;
147     R__b >> fCouplRow;
148     R__b >> fBiasVoltage;
149     R__b >> fNrBad;
150     if (R__v > 5) {
151       fBadChannels.Streamer(R__b);
152     }
153     else {
154       TArrayI fBadChannelsV1;
155       fBadChannelsV1.Streamer(R__b);
156       fBadChannels.Set(fNrBad*2);
157       for (UInt_t i=0; i<fNrBad*2; i++) {
158         fBadChannels[i] = fBadChannelsV1[i];
159       }
160     }
161     R__b.CheckByteCount(R__s, R__c, AliITSCalibrationSPD::IsA());
162   }
163   else {
164     R__c = R__b.WriteVersion(AliITSCalibrationSPD::IsA(), kTRUE);
165     AliITSCalibration::Streamer(R__b);
166     R__b << fBaseline;
167     R__b << fNoise;
168     R__b << fThresh;
169     R__b << fSigma;
170     R__b << fCouplCol;
171     R__b << fCouplRow;
172     R__b << fBiasVoltage;
173     R__b << fNrBad;
174     fBadChannels.Streamer(R__b);
175     R__b.SetByteCount(R__c, kTRUE);
176   }
177 }