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),
51 // default constructor
54 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
55 fBaseline[ian]=fgkBaselineDefault;
56 fNoise[ian]=fgkNoiseDefault;
57 SetNoiseAfterElectronics(ian);
59 for(Int_t iw=0;iw<fgkWings;iw++){
60 for(Int_t icp=0;icp<fgkChips;icp++){
61 for(Int_t ich=0;ich<fgkChannels;ich++)
62 fGain[iw][icp][ich]=1.;
65 SetThresholds(fgkMinValDefault,0.);
66 SetTemperature(fgkTemperatureDefault);
68 fDriftVelParW0[0]= AliITSresponseSDD::DefaultDriftSpeed();
69 fDriftVelParW1[0]= AliITSresponseSDD::DefaultDriftSpeed();
70 for(Int_t i=1;i<4;i++){
75 //______________________________________________________________________
76 AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType):
80 fMinVal(fgkMinValDefault),
90 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
91 fBaseline[ian]=fgkBaselineDefault;
92 fNoise[ian]=fgkNoiseDefault;
93 SetNoiseAfterElectronics(ian);
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.;
102 SetThresholds(fgkMinValDefault,0.);
103 SetTemperature(fgkTemperatureDefault);
104 SetDataType(dataType);
105 fDriftVelParW0[0]= AliITSresponseSDD::DefaultDriftSpeed();
106 fDriftVelParW1[0]= AliITSresponseSDD::DefaultDriftSpeed();
107 for(Int_t i=1;i<4;i++){
108 fDriftVelParW0[i]=0.;
109 fDriftVelParW1[i]=0.;
112 //_____________________________________________________________________
113 AliITSCalibrationSDD::~AliITSCalibrationSDD(){
116 if(fMapAW0) delete fMapAW0;
117 if(fMapAW1) delete fMapAW1;
118 if(fMapTW0) delete fMapTW0;
119 if(fMapTW1) delete fMapTW1;
123 //______________________________________________________________________
124 void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
125 // give compression param
127 cp[0]=(Int_t) fBaseline[ian];
128 cp[1]=(Int_t) fBaseline[ian];
129 cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
130 cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
136 //_____________________________________________________________________
137 void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
138 //Set bad anode (set gain=0 for these channels);
140 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
143 chip=anode/fgkChannels;
144 channel=anode-(chip*fgkChannels);
145 if(anode>=fgkChips*fgkChannels) wing=1;
146 if(wing==1)chip-=fgkChips;
147 fBadChannels[i]=anode;
148 fGain[wing][chip][channel]=0;
150 //_____________________________________________________________________
151 void AliITSCalibrationSDD::SetDriftSpeedParam(Int_t iWing, Float_t* p){
152 // Sets coefficients of pol3 fit to drift speed vs. anode
154 for(Int_t i=0;i<4;i++) fDriftVelParW0[i]=p[i];
156 for(Int_t i=0;i<4;i++) fDriftVelParW1[i]=p[i];
162 //_____________________________________________________________________
163 Bool_t AliITSCalibrationSDD::IsBadChannel(Int_t anode){
164 //returns kTRUE if the anode i (0-512) has fGain=0
165 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
168 chip=anode/fgkChannels;
169 channel=anode-(chip*fgkChannels);
170 if(anode>=fgkChips*fgkChannels) wing=1;
171 if(wing==1)chip-=fgkChips;
172 if(fGain[wing][chip][channel]==0) return kTRUE;
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;
258 //______________________________________________________________________
259 void AliITSCalibrationSDD::PrintGains() const{
262 if( GetDeadChips() == 0 &&
263 GetDeadChannels() == 0 )
266 // Print Electronics Gains
267 cout << "**************************************************" << endl;
268 cout << " Print Electronics Gains " << endl;
269 cout << "**************************************************" << endl;
271 // Print SDD electronic gains
272 for(Int_t t=0; t<fgkWings;t++)
273 for(Int_t u=0; u<fgkChips;u++)
274 for(Int_t v=0; v<fgkChannels;v++)
276 if( fGain[t][u][v] != 1.0 )
277 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
278 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
282 //______________________________________________________________________
283 void AliITSCalibrationSDD::Print(){
284 // Print SDD response Parameters
286 cout << "**************************************************" << endl;
287 cout << " Silicon Drift Detector Response Parameters " << endl;
288 cout << "**************************************************" << endl;
289 cout << "Hardware compression parameters: " << endl;
290 cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
291 cout << "Baseline (ADC units): " << fBaseline[0] << endl;
292 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
293 cout << "Temperature: " << Temperature() << " K " << endl;
294 cout << "Min. Value: " << fMinVal << endl;