]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSCalibrationSDD.cxx
SDD maps are now separate objects in OCDB
[u/mrichter/AliRoot.git] / ITS / AliITSCalibrationSDD.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 **************************************************************************/
15
16
17#include <Riostream.h>
18#include <TRandom.h>
19#include "AliITSCalibrationSDD.h"
f45f6658 20#include "AliLog.h"
fcf95fc7 21
22//////////////////////////////////////////////////////
23// Calibration class for set:ITS //
24// Specific subdetector implementation //
25// for silicon drift detectors //
26// //
27// //
28//////////////////////////////////////////////////////
29
4bfbde86 30const Float_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
31const Float_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
32const Float_t AliITSCalibrationSDD::fgkGainDefault = 1.;
33const Float_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
34const Float_t AliITSCalibrationSDD::fgkMinValDefault = 4;
fcf95fc7 35//______________________________________________________________________
36ClassImp(AliITSCalibrationSDD)
37
4bfbde86 38AliITSCalibrationSDD::AliITSCalibrationSDD():
39AliITSCalibration(),
40fDeadChips(0),
41fDeadChannels(0),
42fMinVal(fgkMinValDefault),
43fIsDead(kFALSE),
028a3709 44fBadChannels(),
45fMapAW0(0),
46fMapAW1(0),
47fMapTW0(0),
48fMapTW1(0)
4bfbde86 49{
fcf95fc7 50 // default constructor
51
52 SetDeadChannels();
f45f6658 53 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
54 fBaseline[ian]=fgkBaselineDefault;
55 fNoise[ian]=fgkNoiseDefault;
56 SetNoiseAfterElectronics(ian);
57 }
58 for(Int_t iw=0;iw<fgkWings;iw++){
59 for(Int_t icp=0;icp<fgkChips;icp++){
60 for(Int_t ich=0;ich<fgkChannels;ich++)
61 fGain[iw][icp][ich]=1.;
62 }
63 }
fcf95fc7 64 SetThresholds(fgkMinValDefault,0.);
65 SetTemperature(fgkTemperatureDefault);
66 SetDataType();
028a3709 67 /* for(Int_t i=0;i<fgkChips*fgkChannels;i++){
5bfe44ce 68 for(Int_t j=0;j<fgkMapTimeNBin;j++){
5bfe44ce 69 fMapA[i][j]=0;
5bfe44ce 70 fMapT[i][j]=0;
5bfe44ce 71 }
5bfe44ce 72 }
028a3709 73 */
fcf95fc7 74 }
75//______________________________________________________________________
4bfbde86 76AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType):
77AliITSCalibration(),
78fDeadChips(0),
79fDeadChannels(0),
80fMinVal(fgkMinValDefault),
81fIsDead(kFALSE),
028a3709 82fBadChannels(),
83fMapAW0(0),
84fMapAW1(0),
85fMapTW0(0),
86fMapTW1(0){
fcf95fc7 87 // constructor
88
89 SetDeadChannels();
f45f6658 90 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
91 fBaseline[ian]=fgkBaselineDefault;
92 fNoise[ian]=fgkNoiseDefault;
93 SetNoiseAfterElectronics(ian);
94 }
95 for(Int_t iw=0;iw<fgkWings;iw++){
96 for(Int_t icp=0;icp<fgkChips;icp++){
97 for(Int_t ich=0;ich<fgkChannels;ich++)
98 fGain[iw][icp][ich]=1.;
99 }
100 }
fcf95fc7 101
fcf95fc7 102 SetThresholds(fgkMinValDefault,0.);
103 SetTemperature(fgkTemperatureDefault);
104 SetDataType(dataType);
028a3709 105 /*for(Int_t i=0;i<fgkChips*fgkChannels;i++){
5bfe44ce 106 for(Int_t j=0;j<fgkMapTimeNBin;j++){
5bfe44ce 107 fMapA[i][j]=0;
5bfe44ce 108 fMapT[i][j]=0;
5bfe44ce 109 }
5bfe44ce 110 }
028a3709 111 */
fcf95fc7 112 }
028a3709 113//_____________________________________________________________________
114AliITSCalibrationSDD::~AliITSCalibrationSDD(){
fcf95fc7 115
028a3709 116 //destructor
117 if(fMapAW0) delete fMapAW0;
118 if(fMapAW1) delete fMapAW1;
119 if(fMapTW0) delete fMapTW0;
120 if(fMapTW1) delete fMapTW1;
121
122}
fcf95fc7 123
124//______________________________________________________________________
f45f6658 125void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
fcf95fc7 126 // give compression param
127
f45f6658 128 cp[0]=(Int_t) fBaseline[ian];
129 cp[1]=(Int_t) fBaseline[ian];
130 cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
131 cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
132 cp[4]=0;
133 cp[5]=0;
134 cp[6]=0;
135 cp[7]=0;
fcf95fc7 136}
f45f6658 137//_____________________________________________________________________
138void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
139 //Set bad anode (set gain=0 for these channels);
fcf95fc7 140
f45f6658 141 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
142 Int_t wing=0;
143 Int_t chip,channel;
144 chip=anode/fgkChannels;
145 channel=anode-(chip*fgkChannels);
146 if(anode>=fgkChips*fgkChannels) wing=1;
147 if(wing==1)chip-=fgkChips;
148 fBadChannels[i]=anode;
149 fGain[wing][chip][channel]=0;
150}
151//_____________________________________________________________________
152Bool_t AliITSCalibrationSDD::IsBadChannel(Int_t anode){
153 //returns kTRUE if the anode i (0-512) has fGain=0
154 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
155 Int_t wing=0;
156 Int_t chip,channel;
157 chip=anode/fgkChannels;
158 channel=anode-(chip*fgkChannels);
159 if(anode>=fgkChips*fgkChannels) wing=1;
160 if(wing==1)chip-=fgkChips;
161 if(fGain[wing][chip][channel]==0) return kTRUE;
162 else return kFALSE;
163}
164/*
fcf95fc7 165//______________________________________________________________________
166void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
167 // Set fGain to zero to simulate a random distribution of
168 // dead modules, dead chips and single dead channels
169
170 for( Int_t m=0; m<fgkWings; m++ )
171 for( Int_t n=0; n<fgkChips; n++ )
172 for( Int_t p=0; p<fgkChannels; p++ )
173 fGain[m][n][p] = 1.;
174
175 //fDeadModules = nmod;
176 fDeadChips = nchip;
177 fDeadChannels = nchan;
f45f6658 178 fBadChannels.Set(fDeadChannels);
fcf95fc7 179 // nothing to do
180 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
181
182 if( nchip == 0 && nchan == 0 ) return;
183 // if( nmod < 0 || nmod > fgkModules )
184 // {
185 // cout << "Wrong number of dead modules: " << nmod << endl;
186 // return;
187 // }
188
189 Int_t nmax = fgkWings*fgkChips;
190 if( nchip < 0 || nchip > nmax )
191 {
192 cout << "Wrong number of dead chips: " << nchip << endl;
193 return;
194 }
195 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
196 if( nchan < 0 || nchan > nmax )
197 {
198 cout << "Wrong number of dead channels: " << nchan << endl;
199 return;
200 }
201
202 TRandom *gran = new TRandom();
fcf95fc7 203 // cout << "chips" << endl;
204 Int_t * chip = new Int_t[nchip];
205 Int_t i = 0;
206 while( i < nchip )
207 {
208 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
209 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
210
211 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
212 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
213 i++;
214 chip[i-1] = chi;
215 for( Int_t m=0; m<fgkChannels; m++ )
216 fGain[wing-1][chi-1][m] = 0.;
217 }
218
219 Int_t * channel = new Int_t[nchan];
220 Int_t * channelChip = new Int_t[nchan];
221 i = 0;
222 while( i < nchan )
223 {
224 Int_t k; //loop variable
225 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
226 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
227 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
228 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
229 Int_t flagChip = 0;
230 for( k=0; k<nchip; k++)
231 if( chipp == chip[k] ) {
232 flagChip = 1; break; }
233 if( flagChip == 1 ) continue;
234 i++;
235 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
236 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
237 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
238 channelChip[i-1] = chipp;
239 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
240 }
241
242 delete [] chip;
243 delete [] channel;
244 delete [] channelChip;
245}
f45f6658 246*/
fcf95fc7 247//______________________________________________________________________
248void AliITSCalibrationSDD::PrintGains() const{
249 //
250
251 if( GetDeadChips() == 0 &&
252 GetDeadChannels() == 0 )
253 return;
254
255 // Print Electronics Gains
256 cout << "**************************************************" << endl;
257 cout << " Print Electronics Gains " << endl;
258 cout << "**************************************************" << endl;
259
260 // Print SDD electronic gains
261 for(Int_t t=0; t<fgkWings;t++)
262 for(Int_t u=0; u<fgkChips;u++)
263 for(Int_t v=0; v<fgkChannels;v++)
264 {
265 if( fGain[t][u][v] != 1.0 )
266 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
267 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
268 }
269}
e56160b8 270
fcf95fc7 271//______________________________________________________________________
272void AliITSCalibrationSDD::Print(){
273 // Print SDD response Parameters
274
275 cout << "**************************************************" << endl;
276 cout << " Silicon Drift Detector Response Parameters " << endl;
277 cout << "**************************************************" << endl;
278 cout << "Hardware compression parameters: " << endl;
f45f6658 279 cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
280 cout << "Baseline (ADC units): " << fBaseline[0] << endl;
281 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
fcf95fc7 282 cout << "Temperature: " << Temperature() << " K " << endl;
283 cout << "Min. Value: " << fMinVal << endl;
284 PrintGains();
285
5bfe44ce 286}