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