]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSresponseSDD.cxx
Added functions needed for SDD new SDigits/Digits (Add and fSigmaAfterElect).
[u/mrichter/AliRoot.git] / ITS / AliITSresponseSDD.cxx
CommitLineData
b0f5e3fc 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
2aea926d 3 * *
b0f5e3fc 4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
1ca7869b 16#include <TString.h>
2aea926d 17#include <TRandom.h>
1ca7869b 18
b0f5e3fc 19#include "AliITSresponseSDD.h"
b0f5e3fc 20
50d05d7b 21
22//___________________________________________
23ClassImp(AliITSresponseSDD)
24
25AliITSresponseSDD::AliITSresponseSDD()
26{
27 // default constructor
28 fGaus = 0;
29 SetDeadChannels();
30 SetMaxAdc();
31 SetDiffCoeff();
32 SetDriftSpeed();
33 SetNSigmaIntegration();
34 SetNLookUp();
35 // SetClock();
36 SetNoiseParam();
37 SetNoiseAfterElectronics();
38 SetElectronics();
39 SetDynamicRange();
40 SetChargeLoss();
41 SetMinVal();
42 SetParamOptions();
43 SetTemperature();
44 SetZeroSupp();
45 SetDataType();
46 SetFilenames();
47 SetOutputOption();
48 SetDo10to8();
49 // set the default zero suppression parameters
50 fCPar[0]=0;
51 fCPar[1]=0;
52 fCPar[2]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.2);
53 fCPar[3]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.2);
54 fCPar[4]=0;
55 fCPar[5]=0;
56 fCPar[6]=0;
57 fCPar[7]=0;
9de0700b 58}
50d05d7b 59
60AliITSresponseSDD::AliITSresponseSDD(const char *dataType)
61{
b0f5e3fc 62 // constructor
50d05d7b 63 fGaus = 0;
2aea926d 64 SetDeadChannels();
b0f5e3fc 65 SetMaxAdc();
66 SetDiffCoeff();
b0f5e3fc 67 SetDriftSpeed();
e8189707 68 SetNSigmaIntegration();
50d05d7b 69 SetNLookUp();
b0f5e3fc 70 // SetClock();
71 SetNoiseParam();
7551c5b2 72 SetNoiseAfterElectronics();
73 SetElectronics();
74 SetDynamicRange();
75 SetChargeLoss();
b0f5e3fc 76 SetMinVal();
77 SetParamOptions();
50d05d7b 78 SetTemperature();
b0f5e3fc 79 SetZeroSupp();
9de0700b 80 SetDataType(dataType);
b0f5e3fc 81 SetFilenames();
82 SetOutputOption();
fa1750f9 83 SetDo10to8();
f49604ec 84 // set the default zero suppression parameters
85 fCPar[0]=0;
86 fCPar[1]=0;
2aea926d 87 fCPar[2]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.2);
88 fCPar[3]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.2);
f49604ec 89 fCPar[4]=0;
90 fCPar[5]=0;
91 fCPar[6]=0;
92 fCPar[7]=0;
b0f5e3fc 93}
f49604ec 94
03898a57 95AliITSresponseSDD::~AliITSresponseSDD() {
b0f5e3fc 96
03898a57 97 if(fGaus) delete fGaus;
b0f5e3fc 98
b0f5e3fc 99}
100
101void AliITSresponseSDD::SetCompressParam(Int_t cp[8])
102{
103 // set compression param
e8189707 104
b0f5e3fc 105 Int_t i;
e8189707 106 for (i=0; i<8; i++) {
50d05d7b 107 fCPar[i]=cp[i];
108 //printf("\n CompressPar %d %d \n",i,fCPar[i]);
109
b0f5e3fc 110 }
111}
50d05d7b 112
b0f5e3fc 113void AliITSresponseSDD::GiveCompressParam(Int_t cp[8])
114{
115 // give compression param
e8189707 116
b0f5e3fc 117 Int_t i;
e8189707 118 for (i=0; i<8; i++) {
50d05d7b 119 cp[i]=fCPar[i];
b0f5e3fc 120 }
121}
7551c5b2 122
50d05d7b 123void AliITSresponseSDD::SetDeadChannels(Int_t nmod, Int_t nchip, Int_t nchan)
124{
125 // Set fGain to zero to simulate a random distribution of
126 // dead modules, dead chips and single dead channels
2aea926d 127
50d05d7b 128 for( Int_t m=0; m<fModules; m++ )
129 for( Int_t n=0; n<fChips; n++ )
130 for( Int_t p=0; p<fChannels; p++ )
131 fGain[m][n][p] = 1.;
132
133 fDeadModules = nmod;
134 fDeadChips = nchip;
135 fDeadChannels = nchan;
136
137 // nothing to do
138 if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
2aea926d 139
50d05d7b 140 if( nmod < 0 || nmod > fModules )
141 {
142 cout << "Wrong number of dead modules: " << nmod << endl;
143 return;
144 }
145 Int_t nmax = (fModules-nmod)*fChips;
146 if( nchip < 0 || nchip > nmax )
147 {
148 cout << "Wrong number of dead chips: " << nchip << endl;
149 return;
150 }
151 nmax = ((fModules - nmod)*fChips - nchip)*fChannels;
152 if( nchan < 0 || nchan > nmax )
153 {
154 cout << "Wrong number of dead channels: " << nchan << endl;
155 return;
156 }
2aea926d 157
50d05d7b 158 TRandom *gran = new TRandom();
2aea926d 159
50d05d7b 160 // cout << "modules" << endl;
161 Int_t * mod = new Int_t [nmod];
162 Int_t i; //loop variable
163 for( i=0; i<nmod; i++ )
164 {
165 mod[i] = (Int_t) (1.+fModules*gran->Uniform());
166 cout << i+1 << ": Dead module nr: " << mod[i] << endl;
167 for(Int_t n=0; n<fChips; n++)
168 for(Int_t p=0; p<fChannels; p++)
169 fGain[mod[i]-1][n][p] = 0.;
170 }
171
172 // cout << "chips" << endl;
173 Int_t * chip = new Int_t[nchip];
174 Int_t * chip_mod = new Int_t[nchip];
175 i = 0;
176 while( i < nchip )
177 {
178 Int_t module = (Int_t) (fModules*gran->Uniform() + 1.);
179 if( module <=0 || module > fModules )
180 cout << "Wrong module: " << module << endl;
181 Int_t flag_mod = 0;
182 for( Int_t k=0; k<nmod; k++ )
183 if( module == mod[k] ) { flag_mod = 1; break; }
184 if( flag_mod == 1 ) continue;
185
186 Int_t chi = (Int_t) (fChips*gran->Uniform() + 1.);
187 if( chi <=0 || chi > fChips ) cout << "Wrong chip: " << chi << endl;
188 i++;
189 chip[i-1] = chi;
190 chip_mod[i-1] = module;
191 for( Int_t m=0; m<fChannels; m++ )
192 fGain[module-1][chi-1][m] = 0.;
193 cout << i << ": Dead chip nr. " << chip[i-1] << " in module nr: " << chip_mod[i-1] << endl;
194 }
195
196 // cout << "channels" << endl;
197 Int_t * channel = new Int_t[nchan];
198 Int_t * channel_chip = new Int_t[nchan];
199 Int_t * channel_mod = new Int_t[nchan];
200 i = 0;
201 while( i < nchan )
202 {
203 Int_t k; //loop variable
204 Int_t module = (Int_t) (fModules*gran->Uniform() + 1.);
205 if( module <=0 || module > fModules )
206 cout << "Wrong module: " << module << endl;
207 Int_t flag_mod = 0;
208 for( k=0; k<nmod; k++ )
209 if( module == mod[k] ) { flag_mod = 1; break; }
210 if( flag_mod == 1 ) continue;
211 Int_t chipp = (Int_t) (fChips*gran->Uniform() + 1.);
212 if( chipp <=0 || chipp > fChips ) cout << "Wrong chip: " << chipp << endl;
213 Int_t flag_chip = 0;
214 for( k=0; k<nchip; k++)
215 if( chipp == chip[k] && module == chip_mod[k] ) { flag_chip = 1; break; }
216 if( flag_chip == 1 ) continue;
217 i++;
218 channel[i-1] = (Int_t) (fChannels*gran->Uniform() + 1.);
219 if( channel[i-1] <=0 || channel[i-1] > fChannels )
220 cout << "Wrong channel: " << channel[i-1] << endl;
221 channel_chip[i-1] = chipp;
222 channel_mod[i-1] = module;
223 fGain[module-1][chipp-1][channel[i-1]-1] = 0.;
224 cout << i << ": Dead channel nr. " << channel[i-1] << " in chip nr. " << channel_chip[i-1] << " in module nr: " << channel_mod[i-1] << endl;
225 }
226
227 delete [] mod;
228 delete [] chip;
229 delete [] chip_mod;
230 delete [] channel;
231 delete [] channel_mod;
232 delete [] channel_chip;
2aea926d 233}
234
235void AliITSresponseSDD::PrintGains()
236{
50d05d7b 237 // Print Electronics Gains
238 cout << "**************************************************" << endl;
239 cout << " Print Electronics Gains " << endl;
240 cout << "**************************************************" << endl;
241
242// FILE *f = fopen( "gains.txt", "w" );
243// fprintf( f, " Module Chip Channel Gain\n" );
244
2aea926d 245 // Print SDD electronic gains
246 for(Int_t t=0; t<fModules;t++)
247 for(Int_t u=0; u<fChips;u++)
248 for(Int_t v=0; v<fChannels;v++)
50d05d7b 249 {
250 cout << "Gain for Module: " << t+1 << ", Chip " << u+1 << ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
251// if( fGain[t][u][v] != 1.0 )
252// fprintf( f, " %8d %8d %8d %f\n", t+1, u+1, v+1, fGain[t][u][v] );
253 }
254// fclose( f );
2aea926d 255}
256
7551c5b2 257void AliITSresponseSDD::Print()
258{
259 // Print SDD response Parameters
260
261 cout << "**************************************************" << endl;
262 cout << " Silicon Drift Detector Response Parameters " << endl;
263 cout << "**************************************************" << endl;
264 cout << "Diffusion Coefficients: " << fDiffCoeff << ", " << fDiffCoeff1 << endl;
265
266 cout << "Hardware compression parameters: " << endl;
267 for(Int_t i=0; i<8; i++) cout << "fCPar[" << i << "] = " << fCPar[i] << endl;
268 cout << "Noise before electronics (arbitrary units): " << fNoise << endl;
269 cout << "Baseline (ADC units): " << fBaseline << endl;
270 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl << endl;
271
272 cout << "Dynamic Range: " << fDynamicRange << endl;
273 cout << "Charge Loss: " << fChargeLoss << endl;
274 cout << "Temperature: " << fTemperature << endl;
275 cout << "Drift Speed: " << fDriftSpeed << endl;
276 cout << "Electronics (1=PASCAL, 2=OLA): " << fElectronics << endl;
277
278 cout << "N. of Sigma for signal integration: " << fNsigmas << endl;
279 cout << "N. of bins in lookup table: " << fNcomps << endl;
280
281 cout << "Max. ADC Value: " << fMaxAdc << endl;
282 cout << "Min. Value: " << fMinVal << endl;
283
2aea926d 284 PrintGains();
7551c5b2 285
286}
287
288
289