1 /**************************************************************************
2 * Copyright(c) 2007-2009, 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 **************************************************************************/
18 #include <Riostream.h>
20 #include "AliITSCalibrationSDD.h"
23 //////////////////////////////////////////////////////
24 // Calibration class for set:ITS //
25 // Specific subdetector implementation //
26 // for silicon drift detectors //
29 //////////////////////////////////////////////////////
31 const Float_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
32 const Float_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
33 const Float_t AliITSCalibrationSDD::fgkGainDefault = 1.;
34 const Float_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
35 const Float_t AliITSCalibrationSDD::fgkMinValDefault = 4;
36 //______________________________________________________________________
37 ClassImp(AliITSCalibrationSDD)
39 AliITSCalibrationSDD::AliITSCalibrationSDD():
43 fMinVal(fgkMinValDefault),
55 // default constructor
58 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
59 fBaseline[ian]=fgkBaselineDefault;
60 fNoise[ian]=fgkNoiseDefault;
61 SetNoiseAfterElectronics(ian);
63 for(Int_t iw=0;iw<fgkWings;iw++){
64 for(Int_t icp=0;icp<fgkChips;icp++){
65 for(Int_t ich=0;ich<fgkChannels;ich++)
66 fGain[iw][icp][ich]=1.;
69 SetThresholds(fgkMinValDefault,0.);
70 SetTemperature(fgkTemperatureDefault);
71 SetUseCorrectionMaps(kTRUE,kTRUE);
74 //______________________________________________________________________
75 AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType):
79 fMinVal(fgkMinValDefault),
94 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
95 fBaseline[ian]=fgkBaselineDefault;
96 fNoise[ian]=fgkNoiseDefault;
97 SetNoiseAfterElectronics(ian);
99 for(Int_t iw=0;iw<fgkWings;iw++){
100 for(Int_t icp=0;icp<fgkChips;icp++){
101 for(Int_t ich=0;ich<fgkChannels;ich++)
102 fGain[iw][icp][ich]=1.;
107 SetThresholds(fgkMinValDefault,0.);
108 SetTemperature(fgkTemperatureDefault);
109 SetUseCorrectionMaps(kTRUE,kTRUE);
110 SetDataType(dataType);
112 //_____________________________________________________________________
113 AliITSCalibrationSDD::~AliITSCalibrationSDD(){
116 if(fMapAW0) delete fMapAW0;
117 if(fMapAW1) delete fMapAW1;
118 if(fMapTW0) delete fMapTW0;
119 if(fMapTW1) delete fMapTW1;
120 if(fDrSpeed0) delete fDrSpeed0;
121 if(fDrSpeed1) delete fDrSpeed1;
124 //______________________________________________________________________
125 void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
126 // give compression param
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);
137 //_____________________________________________________________________
138 void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
139 //Set bad anode (set gain=0 for these channels);
141 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
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;
151 //______________________________________________________________________
152 Float_t AliITSCalibrationSDD::GetChannelGain(Int_t anode) const{
153 // returns gain for givenanode
154 Int_t iWing=GetWing(anode);
155 Int_t iChip=GetChip(anode);
156 Int_t iChan=GetChipChannel(anode);
157 return fGain[iWing][iChip][iChan];
159 //______________________________________________________________________
160 void AliITSCalibrationSDD::GetCorrections(Float_t z, Float_t x, Float_t &devz, Float_t &devx, AliITSsegmentationSDD* seg){
161 //correction of coordinates using the maps stored in the DB
162 Int_t nSide=seg->GetSideFromLocalX(x);
165 if(nSide==0) devz=fMapAW0->GetCorrection(z,x,seg);
166 else devz=fMapAW1->GetCorrection(z,x,seg);
170 if(nSide==0) devx=fMapTW0->GetCorrection(z,x,seg);
171 else devx=fMapTW1->GetCorrection(z,x,seg);
176 //______________________________________________________________________
177 void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
178 // Set fGain to zero to simulate a random distribution of
179 // dead modules, dead chips and single dead channels
181 for( Int_t m=0; m<fgkWings; m++ )
182 for( Int_t n=0; n<fgkChips; n++ )
183 for( Int_t p=0; p<fgkChannels; p++ )
186 //fDeadModules = nmod;
188 fDeadChannels = nchan;
189 fBadChannels.Set(fDeadChannels);
191 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
193 if( nchip == 0 && nchan == 0 ) return;
194 // if( nmod < 0 || nmod > fgkModules )
196 // cout << "Wrong number of dead modules: " << nmod << endl;
200 Int_t nmax = fgkWings*fgkChips;
201 if( nchip < 0 || nchip > nmax )
203 cout << "Wrong number of dead chips: " << nchip << endl;
206 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
207 if( nchan < 0 || nchan > nmax )
209 cout << "Wrong number of dead channels: " << nchan << endl;
213 TRandom *gran = new TRandom();
214 // cout << "chips" << endl;
215 Int_t * chip = new Int_t[nchip];
219 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
220 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
222 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
223 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
226 for( Int_t m=0; m<fgkChannels; m++ )
227 fGain[wing-1][chi-1][m] = 0.;
230 Int_t * channel = new Int_t[nchan];
231 Int_t * channelChip = new Int_t[nchan];
235 Int_t k; //loop variable
236 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
237 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
238 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
239 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
241 for( k=0; k<nchip; k++)
242 if( chipp == chip[k] ) {
243 flagChip = 1; break; }
244 if( flagChip == 1 ) continue;
246 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
247 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
248 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
249 channelChip[i-1] = chipp;
250 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
255 delete [] channelChip;
260 //______________________________________________________________________
261 void AliITSCalibrationSDD::PrintGains() const{
264 if( GetDeadChips() == 0 &&
265 GetDeadChannels() == 0 )
268 // Print Electronics Gains
269 cout << "**************************************************" << endl;
270 cout << " Print Electronics Gains " << endl;
271 cout << "**************************************************" << endl;
273 // Print SDD electronic gains
274 for(Int_t t=0; t<fgkWings;t++)
275 for(Int_t u=0; u<fgkChips;u++)
276 for(Int_t v=0; v<fgkChannels;v++)
278 if( fGain[t][u][v] != 1.0 )
279 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
280 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
284 //______________________________________________________________________
285 void AliITSCalibrationSDD::Print(){
286 // Print SDD response Parameters
288 cout << "**************************************************" << endl;
289 cout << " Silicon Drift Detector Response Parameters " << endl;
290 cout << "**************************************************" << endl;
291 cout << "Hardware compression parameters: " << endl;
292 cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
293 cout << "Baseline (ADC units): " << fBaseline[0] << endl;
294 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
295 cout << "Temperature: " << Temperature() << " K " << endl;
296 cout << "Min. Value: " << fMinVal << endl;