1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
17 #include <Riostream.h>
19 #include "AliITSCalibrationSDD.h"
22 //////////////////////////////////////////////////////
23 // Calibration class for set:ITS //
24 // Specific subdetector implementation //
25 // for silicon drift detectors //
28 //////////////////////////////////////////////////////
30 const Float_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
31 const Float_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
32 const Float_t AliITSCalibrationSDD::fgkGainDefault = 1.;
33 const Float_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
34 const Float_t AliITSCalibrationSDD::fgkMinValDefault = 4;
35 //______________________________________________________________________
36 ClassImp(AliITSCalibrationSDD)
38 AliITSCalibrationSDD::AliITSCalibrationSDD():
42 fMinVal(fgkMinValDefault),
46 // default constructor
49 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
50 fBaseline[ian]=fgkBaselineDefault;
51 fNoise[ian]=fgkNoiseDefault;
52 SetNoiseAfterElectronics(ian);
54 for(Int_t iw=0;iw<fgkWings;iw++){
55 for(Int_t icp=0;icp<fgkChips;icp++){
56 for(Int_t ich=0;ich<fgkChannels;ich++)
57 fGain[iw][icp][ich]=1.;
60 SetThresholds(fgkMinValDefault,0.);
61 SetTemperature(fgkTemperatureDefault);
63 for(Int_t i=0;i<fgkChips*fgkChannels;i++){
64 for(Int_t j=0;j<fgkMapTimeNBin;j++){
70 //______________________________________________________________________
71 AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType):
75 fMinVal(fgkMinValDefault),
81 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
82 fBaseline[ian]=fgkBaselineDefault;
83 fNoise[ian]=fgkNoiseDefault;
84 SetNoiseAfterElectronics(ian);
86 for(Int_t iw=0;iw<fgkWings;iw++){
87 for(Int_t icp=0;icp<fgkChips;icp++){
88 for(Int_t ich=0;ich<fgkChannels;ich++)
89 fGain[iw][icp][ich]=1.;
93 SetThresholds(fgkMinValDefault,0.);
94 SetTemperature(fgkTemperatureDefault);
95 SetDataType(dataType);
96 for(Int_t i=0;i<fgkChips*fgkChannels;i++){
97 for(Int_t j=0;j<fgkMapTimeNBin;j++){
106 //______________________________________________________________________
107 void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
108 // give compression param
110 cp[0]=(Int_t) fBaseline[ian];
111 cp[1]=(Int_t) fBaseline[ian];
112 cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
113 cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
119 //_____________________________________________________________________
120 void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
121 //Set bad anode (set gain=0 for these channels);
123 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
126 chip=anode/fgkChannels;
127 channel=anode-(chip*fgkChannels);
128 if(anode>=fgkChips*fgkChannels) wing=1;
129 if(wing==1)chip-=fgkChips;
130 fBadChannels[i]=anode;
131 fGain[wing][chip][channel]=0;
133 //_____________________________________________________________________
134 Bool_t AliITSCalibrationSDD::IsBadChannel(Int_t anode){
135 //returns kTRUE if the anode i (0-512) has fGain=0
136 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
139 chip=anode/fgkChannels;
140 channel=anode-(chip*fgkChannels);
141 if(anode>=fgkChips*fgkChannels) wing=1;
142 if(wing==1)chip-=fgkChips;
143 if(fGain[wing][chip][channel]==0) return kTRUE;
147 //______________________________________________________________________
148 void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
149 // Set fGain to zero to simulate a random distribution of
150 // dead modules, dead chips and single dead channels
152 for( Int_t m=0; m<fgkWings; m++ )
153 for( Int_t n=0; n<fgkChips; n++ )
154 for( Int_t p=0; p<fgkChannels; p++ )
157 //fDeadModules = nmod;
159 fDeadChannels = nchan;
160 fBadChannels.Set(fDeadChannels);
162 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
164 if( nchip == 0 && nchan == 0 ) return;
165 // if( nmod < 0 || nmod > fgkModules )
167 // cout << "Wrong number of dead modules: " << nmod << endl;
171 Int_t nmax = fgkWings*fgkChips;
172 if( nchip < 0 || nchip > nmax )
174 cout << "Wrong number of dead chips: " << nchip << endl;
177 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
178 if( nchan < 0 || nchan > nmax )
180 cout << "Wrong number of dead channels: " << nchan << endl;
184 TRandom *gran = new TRandom();
185 // cout << "chips" << endl;
186 Int_t * chip = new Int_t[nchip];
190 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
191 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
193 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
194 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
197 for( Int_t m=0; m<fgkChannels; m++ )
198 fGain[wing-1][chi-1][m] = 0.;
201 Int_t * channel = new Int_t[nchan];
202 Int_t * channelChip = new Int_t[nchan];
206 Int_t k; //loop variable
207 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
208 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
209 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
210 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
212 for( k=0; k<nchip; k++)
213 if( chipp == chip[k] ) {
214 flagChip = 1; break; }
215 if( flagChip == 1 ) continue;
217 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
218 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
219 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
220 channelChip[i-1] = chipp;
221 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
226 delete [] channelChip;
229 //______________________________________________________________________
230 void AliITSCalibrationSDD::PrintGains() const{
233 if( GetDeadChips() == 0 &&
234 GetDeadChannels() == 0 )
237 // Print Electronics Gains
238 cout << "**************************************************" << endl;
239 cout << " Print Electronics Gains " << endl;
240 cout << "**************************************************" << endl;
242 // Print SDD electronic gains
243 for(Int_t t=0; t<fgkWings;t++)
244 for(Int_t u=0; u<fgkChips;u++)
245 for(Int_t v=0; v<fgkChannels;v++)
247 if( fGain[t][u][v] != 1.0 )
248 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
249 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
253 //______________________________________________________________________
254 void AliITSCalibrationSDD::Print(){
255 // Print SDD response Parameters
257 cout << "**************************************************" << endl;
258 cout << " Silicon Drift Detector Response Parameters " << endl;
259 cout << "**************************************************" << endl;
260 cout << "Hardware compression parameters: " << endl;
261 cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
262 cout << "Baseline (ADC units): " << fBaseline[0] << endl;
263 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
264 cout << "Temperature: " << Temperature() << " K " << endl;
265 cout << "Min. Value: " << fMinVal << endl;