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 Double_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
31 const Double_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
32 const Double_t AliITSCalibrationSDD::fgkGainDefault = 1.;
33 const Double_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
34 const Double_t AliITSCalibrationSDD::fgkMinValDefault = 4;
35 //______________________________________________________________________
36 ClassImp(AliITSCalibrationSDD)
38 AliITSCalibrationSDD::AliITSCalibrationSDD(){
39 // default constructor
42 fBadChannels.Set(fDeadChannels);
43 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
44 fBaseline[ian]=fgkBaselineDefault;
45 fNoise[ian]=fgkNoiseDefault;
46 SetNoiseAfterElectronics(ian);
48 for(Int_t iw=0;iw<fgkWings;iw++){
49 for(Int_t icp=0;icp<fgkChips;icp++){
50 for(Int_t ich=0;ich<fgkChannels;ich++)
51 fGain[iw][icp][ich]=1.;
54 SetThresholds(fgkMinValDefault,0.);
55 SetTemperature(fgkTemperatureDefault);
58 //______________________________________________________________________
59 AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType){
63 fBadChannels.Set(fDeadChannels);
64 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
65 fBaseline[ian]=fgkBaselineDefault;
66 fNoise[ian]=fgkNoiseDefault;
67 SetNoiseAfterElectronics(ian);
69 for(Int_t iw=0;iw<fgkWings;iw++){
70 for(Int_t icp=0;icp<fgkChips;icp++){
71 for(Int_t ich=0;ich<fgkChannels;ich++)
72 fGain[iw][icp][ich]=1.;
76 SetThresholds(fgkMinValDefault,0.);
77 SetTemperature(fgkTemperatureDefault);
78 SetDataType(dataType);
80 //______________________________________________________________________
81 AliITSCalibrationSDD::AliITSCalibrationSDD(const AliITSCalibrationSDD &ob) : AliITSCalibration(ob) {
83 // Copies are not allowed. The method is protected to avoid misuse.
84 Error("AliITSCalibrationSDD","Copy constructor not allowed\n");
87 //______________________________________________________________________
88 AliITSCalibrationSDD& AliITSCalibrationSDD::operator=(const AliITSCalibrationSDD& /* ob */){
89 // Assignment operator
90 // Assignment is not allowed. The method is protected to avoid misuse.
91 Error("= operator","Assignment operator not allowed\n");
95 //______________________________________________________________________
96 void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
97 // give compression param
99 cp[0]=(Int_t) fBaseline[ian];
100 cp[1]=(Int_t) fBaseline[ian];
101 cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
102 cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
108 //_____________________________________________________________________
109 void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
110 //Set bad anode (set gain=0 for these channels);
112 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
115 chip=anode/fgkChannels;
116 channel=anode-(chip*fgkChannels);
117 if(anode>=fgkChips*fgkChannels) wing=1;
118 if(wing==1)chip-=fgkChips;
119 fBadChannels[i]=anode;
120 fGain[wing][chip][channel]=0;
122 //_____________________________________________________________________
123 Bool_t AliITSCalibrationSDD::IsBadChannel(Int_t anode){
124 //returns kTRUE if the anode i (0-512) has fGain=0
125 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
128 chip=anode/fgkChannels;
129 channel=anode-(chip*fgkChannels);
130 if(anode>=fgkChips*fgkChannels) wing=1;
131 if(wing==1)chip-=fgkChips;
132 if(fGain[wing][chip][channel]==0) return kTRUE;
136 //______________________________________________________________________
137 void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
138 // Set fGain to zero to simulate a random distribution of
139 // dead modules, dead chips and single dead channels
141 for( Int_t m=0; m<fgkWings; m++ )
142 for( Int_t n=0; n<fgkChips; n++ )
143 for( Int_t p=0; p<fgkChannels; p++ )
146 //fDeadModules = nmod;
148 fDeadChannels = nchan;
149 fBadChannels.Set(fDeadChannels);
151 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
153 if( nchip == 0 && nchan == 0 ) return;
154 // if( nmod < 0 || nmod > fgkModules )
156 // cout << "Wrong number of dead modules: " << nmod << endl;
160 Int_t nmax = fgkWings*fgkChips;
161 if( nchip < 0 || nchip > nmax )
163 cout << "Wrong number of dead chips: " << nchip << endl;
166 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
167 if( nchan < 0 || nchan > nmax )
169 cout << "Wrong number of dead channels: " << nchan << endl;
173 TRandom *gran = new TRandom();
174 // cout << "chips" << endl;
175 Int_t * chip = new Int_t[nchip];
179 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
180 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
182 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
183 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
186 for( Int_t m=0; m<fgkChannels; m++ )
187 fGain[wing-1][chi-1][m] = 0.;
190 Int_t * channel = new Int_t[nchan];
191 Int_t * channelChip = new Int_t[nchan];
195 Int_t k; //loop variable
196 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
197 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
198 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
199 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
201 for( k=0; k<nchip; k++)
202 if( chipp == chip[k] ) {
203 flagChip = 1; break; }
204 if( flagChip == 1 ) continue;
206 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
207 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
208 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
209 channelChip[i-1] = chipp;
210 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
215 delete [] channelChip;
218 //______________________________________________________________________
219 void AliITSCalibrationSDD::PrintGains() const{
222 if( GetDeadChips() == 0 &&
223 GetDeadChannels() == 0 )
226 // Print Electronics Gains
227 cout << "**************************************************" << endl;
228 cout << " Print Electronics Gains " << endl;
229 cout << "**************************************************" << endl;
231 // Print SDD electronic gains
232 for(Int_t t=0; t<fgkWings;t++)
233 for(Int_t u=0; u<fgkChips;u++)
234 for(Int_t v=0; v<fgkChannels;v++)
236 if( fGain[t][u][v] != 1.0 )
237 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
238 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
241 //______________________________________________________________________
242 void AliITSCalibrationSDD::Print(){
243 // Print SDD response Parameters
245 cout << "**************************************************" << endl;
246 cout << " Silicon Drift Detector Response Parameters " << endl;
247 cout << "**************************************************" << endl;
248 cout << "Hardware compression parameters: " << endl;
249 cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
250 cout << "Baseline (ADC units): " << fBaseline[0] << endl;
251 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
252 cout << "Temperature: " << Temperature() << " K " << endl;
253 cout << "Min. Value: " << fMinVal << endl;