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),
53 // default constructor
56 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
57 fBaseline[ian]=fgkBaselineDefault;
58 fNoise[ian]=fgkNoiseDefault;
59 SetNoiseAfterElectronics(ian);
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.;
67 SetThresholds(fgkMinValDefault,0.);
68 SetTemperature(fgkTemperatureDefault);
71 //______________________________________________________________________
72 AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType):
76 fMinVal(fgkMinValDefault),
89 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
90 fBaseline[ian]=fgkBaselineDefault;
91 fNoise[ian]=fgkNoiseDefault;
92 SetNoiseAfterElectronics(ian);
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.;
101 SetThresholds(fgkMinValDefault,0.);
102 SetTemperature(fgkTemperatureDefault);
103 SetDataType(dataType);
105 //_____________________________________________________________________
106 AliITSCalibrationSDD::~AliITSCalibrationSDD(){
109 if(fMapAW0) delete fMapAW0;
110 if(fMapAW1) delete fMapAW1;
111 if(fMapTW0) delete fMapTW0;
112 if(fMapTW1) delete fMapTW1;
113 if(fDrSpeed0) delete fDrSpeed0;
114 if(fDrSpeed1) delete fDrSpeed1;
117 //______________________________________________________________________
118 void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
119 // give compression param
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);
130 //_____________________________________________________________________
131 void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
132 //Set bad anode (set gain=0 for these channels);
134 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
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;
144 //______________________________________________________________________
145 Float_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];
153 //______________________________________________________________________
154 void 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
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++ )
163 //fDeadModules = nmod;
165 fDeadChannels = nchan;
166 fBadChannels.Set(fDeadChannels);
168 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
170 if( nchip == 0 && nchan == 0 ) return;
171 // if( nmod < 0 || nmod > fgkModules )
173 // cout << "Wrong number of dead modules: " << nmod << endl;
177 Int_t nmax = fgkWings*fgkChips;
178 if( nchip < 0 || nchip > nmax )
180 cout << "Wrong number of dead chips: " << nchip << endl;
183 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
184 if( nchan < 0 || nchan > nmax )
186 cout << "Wrong number of dead channels: " << nchan << endl;
190 TRandom *gran = new TRandom();
191 // cout << "chips" << endl;
192 Int_t * chip = new Int_t[nchip];
196 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
197 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
199 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
200 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
203 for( Int_t m=0; m<fgkChannels; m++ )
204 fGain[wing-1][chi-1][m] = 0.;
207 Int_t * channel = new Int_t[nchan];
208 Int_t * channelChip = new Int_t[nchan];
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);
218 for( k=0; k<nchip; k++)
219 if( chipp == chip[k] ) {
220 flagChip = 1; break; }
221 if( flagChip == 1 ) continue;
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.;
232 delete [] channelChip;
237 //______________________________________________________________________
238 void AliITSCalibrationSDD::PrintGains() const{
241 if( GetDeadChips() == 0 &&
242 GetDeadChannels() == 0 )
245 // Print Electronics Gains
246 cout << "**************************************************" << endl;
247 cout << " Print Electronics Gains " << endl;
248 cout << "**************************************************" << endl;
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++)
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;
261 //______________________________________________________________________
262 void AliITSCalibrationSDD::Print(){
263 // Print SDD response Parameters
265 cout << "**************************************************" << endl;
266 cout << " Silicon Drift Detector Response Parameters " << endl;
267 cout << "**************************************************" << endl;
268 cout << "Hardware compression parameters: " << endl;
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;
272 cout << "Temperature: " << Temperature() << " K " << endl;
273 cout << "Min. Value: " << fMinVal << endl;