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