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 **************************************************************************/
18 #include <Riostream.h>
21 #include "AliITSresponseSDD.h"
22 //////////////////////////////////////////////////
23 // Response class for set:ITS //
24 // Specific subdetector implementation //
25 // for silicon drift detectors //
28 //////////////////////////////////////////////////////
30 const Int_t AliITSresponseSDD::fgkWings;
31 const Int_t AliITSresponseSDD::fgkChips;
32 const Int_t AliITSresponseSDD::fgkChannels;
33 const Int_t AliITSresponseSDD::fgkMaxAdcDefault = 1024;
34 const Double_t AliITSresponseSDD::fgkDynamicRangeDefault = 132.;
35 const Double_t AliITSresponseSDD::fgkfChargeLossDefault = 0;
36 const Double_t AliITSresponseSDD::fgkDiffCoeffDefault = 3.23;
37 const Double_t AliITSresponseSDD::fgkDiffCoeff1Default = 30.;
38 const Double_t AliITSresponseSDD::fgkTemperatureDefault = 296.;
39 const TString AliITSresponseSDD::fgkParam1Default = "same";
40 const TString AliITSresponseSDD::fgkParam2Default = "same";
41 const Double_t AliITSresponseSDD::fgkNoiseDefault = 10.;
42 const Double_t AliITSresponseSDD::fgkBaselineDefault = 20.;
43 const TString AliITSresponseSDD::fgkOptionDefault = "1D";
44 const Double_t AliITSresponseSDD::fgkMinValDefault = 4;
45 const Double_t AliITSresponseSDD::fgkDriftSpeedDefault = 7.3;
46 const Double_t AliITSresponseSDD::fgkNsigmasDefault = 3.;
47 const Int_t AliITSresponseSDD::fgkNcompsDefault = 121;
48 //______________________________________________________________________
49 ClassImp(AliITSresponseSDD)
51 AliITSresponseSDD::AliITSresponseSDD(){
52 // default constructor
55 SetMaxAdc(fgkMaxAdcDefault);
56 SetDiffCoeff(fgkDiffCoeffDefault,fgkDiffCoeff1Default);
57 SetDriftSpeed(fgkDriftSpeedDefault);
58 SetNSigmaIntegration(fgkNsigmasDefault);
59 SetNLookUp(fgkNcompsDefault);
61 for(Int_t i=0;i<fgkWings;i++){
62 for(Int_t j=0;j<fgkChips;j++){
67 SetNoiseParam(fgkNoiseDefault,fgkBaselineDefault);
68 SetNoiseAfterElectronics();
71 SetDynamicRange(fgkDynamicRangeDefault);
72 SetChargeLoss(fgkfChargeLossDefault);
73 SetThresholds(fgkMinValDefault,0.);
74 SetParamOptions(fgkParam1Default.Data(),fgkParam2Default.Data());
75 SetTemperature(fgkTemperatureDefault);
76 SetZeroSupp(fgkOptionDefault);
81 // set the default zero suppression parameters
82 fCPar[0]=(Int_t) fBaseline;
83 fCPar[1]=(Int_t) fBaseline;
84 fCPar[2]=(Int_t)(2.*fNoiseAfterEl + 0.5);
85 fCPar[3]=(Int_t)(2.*fNoiseAfterEl + 0.5);
91 //______________________________________________________________________
92 AliITSresponseSDD::AliITSresponseSDD(const char *dataType){
96 SetMaxAdc(fgkMaxAdcDefault);
97 SetDiffCoeff(fgkDiffCoeffDefault,fgkDiffCoeff1Default);
98 SetDriftSpeed(fgkDriftSpeedDefault);
99 SetNSigmaIntegration(fgkNsigmasDefault);
100 SetNLookUp(fgkNcompsDefault);
102 for(Int_t i=0;i<fgkWings;i++){
103 for(Int_t j=0;j<fgkChips*fgkChannels;j++){
108 SetNoiseParam(fgkNoiseDefault,fgkBaselineDefault);
109 SetNoiseAfterElectronics();
112 SetDynamicRange(fgkDynamicRangeDefault);
113 SetChargeLoss(fgkfChargeLossDefault);
114 SetThresholds(fgkMinValDefault,0.);
115 SetParamOptions(fgkParam1Default.Data(),fgkParam2Default.Data());
116 SetTemperature(fgkTemperatureDefault);
117 SetZeroSupp(fgkOptionDefault);
118 SetDataType(dataType);
122 // set the default zero suppression parameters
123 fCPar[0]=(Int_t) fBaseline;
124 fCPar[1]=(Int_t) fBaseline;
125 fCPar[2]=(Int_t)(2.*fNoiseAfterEl + 0.5);
126 fCPar[3]=(Int_t)(2.*fNoiseAfterEl + 0.5);
132 //______________________________________________________________________
133 AliITSresponseSDD::AliITSresponseSDD(const AliITSresponseSDD &ob) : AliITSresponse(ob) {
135 // Copies are not allowed. The method is protected to avoid misuse.
136 Error("AliITSresponseSDD","Copy constructor not allowed\n");
139 //______________________________________________________________________
140 AliITSresponseSDD& AliITSresponseSDD::operator=(const AliITSresponseSDD& /* ob */){
141 // Assignment operator
142 // Assignment is not allowed. The method is protected to avoid misuse.
143 Error("= operator","Assignment operator not allowed\n");
147 //______________________________________________________________________
148 AliITSresponseSDD::~AliITSresponseSDD() {
150 if(fGaus) delete fGaus;
153 //______________________________________________________________________
154 Int_t AliITSresponseSDD::Convert8to10(Int_t signal) const {
155 // Undo the lossive 10 to 8 bit compression.
156 // code from Davide C. and Albert W.
157 if(Do10to8()){ // kTRUE if the compression is active
158 if (signal < 0 || signal > 255) {
159 Warning("Convert8to10","out of range signal=%d",signal);
161 } // end if signal <0 || signal >255
163 if (signal < 128) return signal;
165 if (TMath::Odd(signal)) return (128+((signal-128)<<1));
166 else return (128+((signal-128)<<1)+1);
167 } // end if signal < 192
169 if (TMath::Odd(signal)) return (256+((signal-192)<<3)+3);
170 else return (256+((signal-192)<<3)+4);
171 } // end if signal < 224
172 if (TMath::Odd(signal)) return (512+((signal-224)<<4)+7);
173 return (512+((signal-224)<<4)+8);
180 //______________________________________________________________________
181 void AliITSresponseSDD::SetCompressParam(Int_t cp[8]){
182 // set compression param
185 for (i=0; i<8; i++) {
187 //printf("\n CompressPar %d %d \n",i,fCPar[i]);
190 //______________________________________________________________________
191 void AliITSresponseSDD::GiveCompressParam(Int_t cp[8]) const {
192 // give compression param
195 for (i=0; i<8; i++) {
199 //______________________________________________________________________
200 void AliITSresponseSDD::SetNLookUp(Int_t p1){
201 // Set number of sigmas over which cluster disintegration is performed
203 fGaus = new TArrayF(fNcomps+1);
204 for(Int_t i=0; i<=fNcomps; i++) {
205 Double_t x = -fNsigmas + (2.*i*fNsigmas)/(fNcomps-1);
206 (*fGaus)[i] = exp(-((x*x)/2));
207 // cout << "fGaus[" << i << "]: " << fGaus->At(i) << endl;
210 //______________________________________________________________________
211 void AliITSresponseSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
212 // Set fGain to zero to simulate a random distribution of
213 // dead modules, dead chips and single dead channels
215 for( Int_t m=0; m<fgkWings; m++ )
216 for( Int_t n=0; n<fgkChips; n++ )
217 for( Int_t p=0; p<fgkChannels; p++ )
220 //fDeadModules = nmod;
222 fDeadChannels = nchan;
225 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
227 if( nchip == 0 && nchan == 0 ) return;
228 // if( nmod < 0 || nmod > fgkModules )
230 // cout << "Wrong number of dead modules: " << nmod << endl;
234 Int_t nmax = fgkWings*fgkChips;
235 if( nchip < 0 || nchip > nmax )
237 cout << "Wrong number of dead chips: " << nchip << endl;
240 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
241 if( nchan < 0 || nchan > nmax )
243 cout << "Wrong number of dead channels: " << nchan << endl;
247 TRandom *gran = new TRandom();
249 // cout << "modules" << endl;
250 Int_t * mod = new Int_t [nmod];
251 Int_t i; //loop variable
252 for( i=0; i<nmod; i++ )
254 mod[i] = (Int_t) (1.+fgkModules*gran->Uniform());
255 cout << i+1 << ": Dead module nr: " << mod[i] << endl;
256 for(Int_t n=0; n<fgkChips; n++)
257 for(Int_t p=0; p<fgkChannels; p++)
258 fGain[mod[i]-1][n][p] = 0.;
261 // cout << "chips" << endl;
262 Int_t * chip = new Int_t[nchip];
266 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
267 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
269 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
270 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
273 for( Int_t m=0; m<fgkChannels; m++ )
274 fGain[wing-1][chi-1][m] = 0.;
277 Int_t * channel = new Int_t[nchan];
278 Int_t * channelChip = new Int_t[nchan];
282 Int_t k; //loop variable
283 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
284 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
285 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
286 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
288 for( k=0; k<nchip; k++)
289 if( chipp == chip[k] ) {
290 flagChip = 1; break; }
291 if( flagChip == 1 ) continue;
293 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
294 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
295 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
296 channelChip[i-1] = chipp;
297 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
302 delete [] channelChip;
304 //______________________________________________________________________
305 void AliITSresponseSDD::PrintGains() const{
308 if( GetDeadChips() == 0 &&
309 GetDeadChannels() == 0 )
312 // Print Electronics Gains
313 cout << "**************************************************" << endl;
314 cout << " Print Electronics Gains " << endl;
315 cout << "**************************************************" << endl;
317 // Print SDD electronic gains
318 for(Int_t t=0; t<fgkWings;t++)
319 for(Int_t u=0; u<fgkChips;u++)
320 for(Int_t v=0; v<fgkChannels;v++)
322 if( fGain[t][u][v] != 1.0 )
323 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
324 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
327 //______________________________________________________________________
328 void AliITSresponseSDD::Print(){
329 // Print SDD response Parameters
331 cout << "**************************************************" << endl;
332 cout << " Silicon Drift Detector Response Parameters " << endl;
333 cout << "**************************************************" << endl;
334 cout << "Diffusion Coefficients: "<< fDiffCoeff<< ", "<<fDiffCoeff1 << endl;
336 cout << "Hardware compression parameters: " << endl;
337 for(Int_t i=0; i<8; i++) cout << "fCPar[" << i << "] = " << fCPar[i] <<endl;
338 cout << "Noise before electronics (arbitrary units): " << fNoise << endl;
339 cout << "Baseline (ADC units): " << fBaseline << endl;
340 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl << endl;
342 cout << "Dynamic Range: " << fDynamicRange << endl;
343 cout << "Charge Loss: " << fChargeLoss << endl;
344 cout << "Temperature: " << Temperature() << " K " << endl;
345 cout << "Drift Speed: " << fDriftSpeed << endl;
346 cout << "Electronics (1=PASCAL, 2=OLA): " << fElectronics << endl;
348 cout << "N. of Sigma for signal integration: " << fNsigmas << endl;
349 cout << "N. of bins in lookup table: " << fNcomps << endl;
351 cout << "Max. ADC Value: " << fMaxAdc << endl;
352 cout << "Min. Value: " << fMinVal << endl;