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);
57 for(Int_t i=0;i<fgkChips*fgkChannels;i++){
58 for(Int_t j=0;j<fgkMapTimeNBin;j++){
64 //______________________________________________________________________
65 AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType){
69 fBadChannels.Set(fDeadChannels);
70 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
71 fBaseline[ian]=fgkBaselineDefault;
72 fNoise[ian]=fgkNoiseDefault;
73 SetNoiseAfterElectronics(ian);
75 for(Int_t iw=0;iw<fgkWings;iw++){
76 for(Int_t icp=0;icp<fgkChips;icp++){
77 for(Int_t ich=0;ich<fgkChannels;ich++)
78 fGain[iw][icp][ich]=1.;
82 SetThresholds(fgkMinValDefault,0.);
83 SetTemperature(fgkTemperatureDefault);
84 SetDataType(dataType);
85 for(Int_t i=0;i<fgkChips*fgkChannels;i++){
86 for(Int_t j=0;j<fgkMapTimeNBin;j++){
93 //______________________________________________________________________
94 AliITSCalibrationSDD::AliITSCalibrationSDD(const AliITSCalibrationSDD &ob) : AliITSCalibration(ob) {
96 // Copies are not allowed. The method is protected to avoid misuse.
97 Error("AliITSCalibrationSDD","Copy constructor not allowed\n");
100 //______________________________________________________________________
101 AliITSCalibrationSDD& AliITSCalibrationSDD::operator=(const AliITSCalibrationSDD& /* ob */){
102 // Assignment operator
103 // Assignment is not allowed. The method is protected to avoid misuse.
104 Error("= operator","Assignment operator not allowed\n");
108 //______________________________________________________________________
109 void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
110 // give compression param
112 cp[0]=(Int_t) fBaseline[ian];
113 cp[1]=(Int_t) fBaseline[ian];
114 cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
115 cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
121 //_____________________________________________________________________
122 void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
123 //Set bad anode (set gain=0 for these channels);
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 fBadChannels[i]=anode;
133 fGain[wing][chip][channel]=0;
135 //_____________________________________________________________________
136 Bool_t AliITSCalibrationSDD::IsBadChannel(Int_t anode){
137 //returns kTRUE if the anode i (0-512) has fGain=0
138 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
141 chip=anode/fgkChannels;
142 channel=anode-(chip*fgkChannels);
143 if(anode>=fgkChips*fgkChannels) wing=1;
144 if(wing==1)chip-=fgkChips;
145 if(fGain[wing][chip][channel]==0) return kTRUE;
149 //______________________________________________________________________
150 void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
151 // Set fGain to zero to simulate a random distribution of
152 // dead modules, dead chips and single dead channels
154 for( Int_t m=0; m<fgkWings; m++ )
155 for( Int_t n=0; n<fgkChips; n++ )
156 for( Int_t p=0; p<fgkChannels; p++ )
159 //fDeadModules = nmod;
161 fDeadChannels = nchan;
162 fBadChannels.Set(fDeadChannels);
164 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
166 if( nchip == 0 && nchan == 0 ) return;
167 // if( nmod < 0 || nmod > fgkModules )
169 // cout << "Wrong number of dead modules: " << nmod << endl;
173 Int_t nmax = fgkWings*fgkChips;
174 if( nchip < 0 || nchip > nmax )
176 cout << "Wrong number of dead chips: " << nchip << endl;
179 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
180 if( nchan < 0 || nchan > nmax )
182 cout << "Wrong number of dead channels: " << nchan << endl;
186 TRandom *gran = new TRandom();
187 // cout << "chips" << endl;
188 Int_t * chip = new Int_t[nchip];
192 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
193 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
195 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
196 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
199 for( Int_t m=0; m<fgkChannels; m++ )
200 fGain[wing-1][chi-1][m] = 0.;
203 Int_t * channel = new Int_t[nchan];
204 Int_t * channelChip = new Int_t[nchan];
208 Int_t k; //loop variable
209 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
210 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
211 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
212 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
214 for( k=0; k<nchip; k++)
215 if( chipp == chip[k] ) {
216 flagChip = 1; break; }
217 if( flagChip == 1 ) continue;
219 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
220 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
221 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
222 channelChip[i-1] = chipp;
223 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
228 delete [] channelChip;
231 //______________________________________________________________________
232 void AliITSCalibrationSDD::PrintGains() const{
235 if( GetDeadChips() == 0 &&
236 GetDeadChannels() == 0 )
239 // Print Electronics Gains
240 cout << "**************************************************" << endl;
241 cout << " Print Electronics Gains " << endl;
242 cout << "**************************************************" << endl;
244 // Print SDD electronic gains
245 for(Int_t t=0; t<fgkWings;t++)
246 for(Int_t u=0; u<fgkChips;u++)
247 for(Int_t v=0; v<fgkChannels;v++)
249 if( fGain[t][u][v] != 1.0 )
250 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
251 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
254 //______________________________________________________________________
255 void AliITSCalibrationSDD::Print(){
256 // Print SDD response Parameters
258 cout << "**************************************************" << endl;
259 cout << " Silicon Drift Detector Response Parameters " << endl;
260 cout << "**************************************************" << endl;
261 cout << "Hardware compression parameters: " << endl;
262 cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
263 cout << "Baseline (ADC units): " << fBaseline[0] << endl;
264 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
265 cout << "Temperature: " << Temperature() << " K " << endl;
266 cout << "Min. Value: " << fMinVal << endl;