]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSresponseSDD.cxx
Correct the number of buspatches for station 1 & 2 and for R2 & R3 type slat (Christian)
[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
703a4e51 18#include <Riostream.h>
2aea926d 19#include <TRandom.h>
1ca7869b 20
b0f5e3fc 21#include "AliITSresponseSDD.h"
703a4e51 22//////////////////////////////////////////////////
23// Response class for set:ITS //
24// Specific subdetector implementation //
25// for silicon drift detectors //
26// //
27// //
28//////////////////////////////////////////////////////
50d05d7b 29
8ba39da9 30const Int_t AliITSresponseSDD::fgkWings;
703a4e51 31const Int_t AliITSresponseSDD::fgkChips;
32const Int_t AliITSresponseSDD::fgkChannels;
33const Int_t AliITSresponseSDD::fgkMaxAdcDefault = 1024;
aacedc3e 34const Double_t AliITSresponseSDD::fgkDynamicRangeDefault = 132.;
35const Double_t AliITSresponseSDD::fgkfChargeLossDefault = 0;
36const Double_t AliITSresponseSDD::fgkDiffCoeffDefault = 3.23;
37const Double_t AliITSresponseSDD::fgkDiffCoeff1Default = 30.;
38const Double_t AliITSresponseSDD::fgkTemperatureDefault = 296.;
703a4e51 39const TString AliITSresponseSDD::fgkParam1Default = "same";
40const TString AliITSresponseSDD::fgkParam2Default = "same";
aacedc3e 41const Double_t AliITSresponseSDD::fgkNoiseDefault = 10.;
42const Double_t AliITSresponseSDD::fgkBaselineDefault = 20.;
703a4e51 43const TString AliITSresponseSDD::fgkOptionDefault = "1D";
aacedc3e 44const Double_t AliITSresponseSDD::fgkMinValDefault = 4;
45const Double_t AliITSresponseSDD::fgkDriftSpeedDefault = 7.3;
46const Double_t AliITSresponseSDD::fgkNsigmasDefault = 3.;
703a4e51 47const Int_t AliITSresponseSDD::fgkNcompsDefault = 121;
48058160 48//______________________________________________________________________
49ClassImp(AliITSresponseSDD)
50d05d7b 50
3d2c9d72 51 AliITSresponseSDD::AliITSresponseSDD(){
50d05d7b 52 // default constructor
3d2c9d72 53 fGaus = 0;
54 SetDeadChannels();
55 SetMaxAdc(fgkMaxAdcDefault);
56 SetDiffCoeff(fgkDiffCoeffDefault,fgkDiffCoeff1Default);
57 SetDriftSpeed(fgkDriftSpeedDefault);
58 SetNSigmaIntegration(fgkNsigmasDefault);
59 SetNLookUp(fgkNcompsDefault);
60 // SetClock();
8ba39da9 61 for(Int_t i=0;i<fgkWings;i++){
62 for(Int_t j=0;j<fgkChips;j++){
63 fBaseline=0;
64 fNoise=0;
65 }
66 }
3d2c9d72 67 SetNoiseParam(fgkNoiseDefault,fgkBaselineDefault);
68 SetNoiseAfterElectronics();
69 SetJitterError();
70 SetElectronics();
71 SetDynamicRange(fgkDynamicRangeDefault);
72 SetChargeLoss(fgkfChargeLossDefault);
73 SetThresholds(fgkMinValDefault,0.);
74 SetParamOptions(fgkParam1Default.Data(),fgkParam2Default.Data());
75 SetTemperature(fgkTemperatureDefault);
76 SetZeroSupp(fgkOptionDefault);
77 SetDataType();
78 SetFilenames();
79 SetOutputOption();
80 SetDo10to8();
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);
86 fCPar[4]=0;
87 fCPar[5]=0;
88 fCPar[6]=0;
89 fCPar[7]=0;
9de0700b 90}
48058160 91//______________________________________________________________________
92AliITSresponseSDD::AliITSresponseSDD(const char *dataType){
b0f5e3fc 93 // constructor
3d2c9d72 94 fGaus = 0;
95 SetDeadChannels();
96 SetMaxAdc(fgkMaxAdcDefault);
97 SetDiffCoeff(fgkDiffCoeffDefault,fgkDiffCoeff1Default);
98 SetDriftSpeed(fgkDriftSpeedDefault);
99 SetNSigmaIntegration(fgkNsigmasDefault);
100 SetNLookUp(fgkNcompsDefault);
101 // SetClock();
8ba39da9 102 for(Int_t i=0;i<fgkWings;i++){
103 for(Int_t j=0;j<fgkChips*fgkChannels;j++){
104 fBaseline=0;
105 fNoise=0;
106 }
107 }
3d2c9d72 108 SetNoiseParam(fgkNoiseDefault,fgkBaselineDefault);
109 SetNoiseAfterElectronics();
110 SetJitterError();
111 SetElectronics();
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);
119 SetFilenames();
120 SetOutputOption();
121 SetDo10to8();
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);
127 fCPar[4]=0;
128 fCPar[5]=0;
129 fCPar[6]=0;
130 fCPar[7]=0;
b0f5e3fc 131}
703a4e51 132//______________________________________________________________________
133AliITSresponseSDD::AliITSresponseSDD(const AliITSresponseSDD &ob) : AliITSresponse(ob) {
134 // Copy constructor
135 // Copies are not allowed. The method is protected to avoid misuse.
136 Error("AliITSresponseSDD","Copy constructor not allowed\n");
137}
138
139//______________________________________________________________________
140AliITSresponseSDD& 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");
144 return *this;
145}
146
48058160 147//______________________________________________________________________
03898a57 148AliITSresponseSDD::~AliITSresponseSDD() {
b0f5e3fc 149
03898a57 150 if(fGaus) delete fGaus;
b0f5e3fc 151}
7f1a504b 152
153//______________________________________________________________________
154Int_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);
160 return 0;
161 } // end if signal <0 || signal >255
162
163 if (signal < 128) return signal;
164 if (signal < 192) {
165 if (TMath::Odd(signal)) return (128+((signal-128)<<1));
166 else return (128+((signal-128)<<1)+1);
167 } // end if signal < 192
168 if (signal < 224) {
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);
174 }
175 else {
176 return signal;
177 }
178}
179
48058160 180//______________________________________________________________________
181void AliITSresponseSDD::SetCompressParam(Int_t cp[8]){
b0f5e3fc 182 // set compression param
e8189707 183
3d2c9d72 184 Int_t i;
185 for (i=0; i<8; i++) {
186 fCPar[i]=cp[i];
187 //printf("\n CompressPar %d %d \n",i,fCPar[i]);
188 } // end for i
b0f5e3fc 189}
48058160 190//______________________________________________________________________
703a4e51 191void AliITSresponseSDD::GiveCompressParam(Int_t cp[8]) const {
b0f5e3fc 192 // give compression param
e8189707 193
3d2c9d72 194 Int_t i;
195 for (i=0; i<8; i++) {
196 cp[i]=fCPar[i];
197 } // end for i
b0f5e3fc 198}
48058160 199//______________________________________________________________________
703a4e51 200void AliITSresponseSDD::SetNLookUp(Int_t p1){
201 // Set number of sigmas over which cluster disintegration is performed
202 fNcomps=p1;
203 fGaus = new TArrayF(fNcomps+1);
204 for(Int_t i=0; i<=fNcomps; i++) {
aacedc3e 205 Double_t x = -fNsigmas + (2.*i*fNsigmas)/(fNcomps-1);
703a4e51 206 (*fGaus)[i] = exp(-((x*x)/2));
207 // cout << "fGaus[" << i << "]: " << fGaus->At(i) << endl;
208 }
209}
210//______________________________________________________________________
8ba39da9 211void AliITSresponseSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
3d2c9d72 212 // Set fGain to zero to simulate a random distribution of
213 // dead modules, dead chips and single dead channels
2aea926d 214
8ba39da9 215 for( Int_t m=0; m<fgkWings; m++ )
3d2c9d72 216 for( Int_t n=0; n<fgkChips; n++ )
217 for( Int_t p=0; p<fgkChannels; p++ )
218 fGain[m][n][p] = 1.;
50d05d7b 219
8ba39da9 220 //fDeadModules = nmod;
3d2c9d72 221 fDeadChips = nchip;
222 fDeadChannels = nchan;
50d05d7b 223
3d2c9d72 224 // nothing to do
8ba39da9 225 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
2aea926d 226
8ba39da9 227 if( nchip == 0 && nchan == 0 ) return;
228 // if( nmod < 0 || nmod > fgkModules )
229 // {
230 // cout << "Wrong number of dead modules: " << nmod << endl;
231 // return;
232 // }
233
234 Int_t nmax = fgkWings*fgkChips;
3d2c9d72 235 if( nchip < 0 || nchip > nmax )
50d05d7b 236 {
3d2c9d72 237 cout << "Wrong number of dead chips: " << nchip << endl;
238 return;
50d05d7b 239 }
8ba39da9 240 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
3d2c9d72 241 if( nchan < 0 || nchan > nmax )
50d05d7b 242 {
3d2c9d72 243 cout << "Wrong number of dead channels: " << nchan << endl;
244 return;
50d05d7b 245 }
2aea926d 246
3d2c9d72 247 TRandom *gran = new TRandom();
8ba39da9 248 /*
3d2c9d72 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++ )
50d05d7b 253 {
3d2c9d72 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.;
50d05d7b 259 }
8ba39da9 260 */
3d2c9d72 261 // cout << "chips" << endl;
262 Int_t * chip = new Int_t[nchip];
8ba39da9 263 Int_t i = 0;
3d2c9d72 264 while( i < nchip )
50d05d7b 265 {
8ba39da9 266 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
267 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
50d05d7b 268
3d2c9d72 269 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
8ba39da9 270 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
3d2c9d72 271 i++;
272 chip[i-1] = chi;
3d2c9d72 273 for( Int_t m=0; m<fgkChannels; m++ )
8ba39da9 274 fGain[wing-1][chi-1][m] = 0.;
50d05d7b 275 }
276
3d2c9d72 277 Int_t * channel = new Int_t[nchan];
278 Int_t * channelChip = new Int_t[nchan];
3d2c9d72 279 i = 0;
280 while( i < nchan )
50d05d7b 281 {
3d2c9d72 282 Int_t k; //loop variable
8ba39da9 283 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
284 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
3d2c9d72 285 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
8ba39da9 286 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
3d2c9d72 287 Int_t flagChip = 0;
288 for( k=0; k<nchip; k++)
8ba39da9 289 if( chipp == chip[k] ) {
3d2c9d72 290 flagChip = 1; break; }
291 if( flagChip == 1 ) continue;
292 i++;
293 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
294 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
8ba39da9 295 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
3d2c9d72 296 channelChip[i-1] = chipp;
8ba39da9 297 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
50d05d7b 298 }
299
3d2c9d72 300 delete [] chip;
3d2c9d72 301 delete [] channel;
3d2c9d72 302 delete [] channelChip;
2aea926d 303}
48058160 304//______________________________________________________________________
8ba39da9 305void AliITSresponseSDD::PrintGains() const{
3d2c9d72 306 //
2aea926d 307
8ba39da9 308 if( GetDeadChips() == 0 &&
48058160 309 GetDeadChannels() == 0 )
3d2c9d72 310 return;
48058160 311
312 // Print Electronics Gains
50d05d7b 313 cout << "**************************************************" << endl;
314 cout << " Print Electronics Gains " << endl;
315 cout << "**************************************************" << endl;
316
2aea926d 317 // Print SDD electronic gains
8ba39da9 318 for(Int_t t=0; t<fgkWings;t++)
703a4e51 319 for(Int_t u=0; u<fgkChips;u++)
320 for(Int_t v=0; v<fgkChannels;v++)
3d2c9d72 321 {
322 if( fGain[t][u][v] != 1.0 )
8ba39da9 323 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
3d2c9d72 324 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
325 }
2aea926d 326}
48058160 327//______________________________________________________________________
328void AliITSresponseSDD::Print(){
7551c5b2 329 // Print SDD response Parameters
330
3d2c9d72 331 cout << "**************************************************" << endl;
332 cout << " Silicon Drift Detector Response Parameters " << endl;
333 cout << "**************************************************" << endl;
334 cout << "Diffusion Coefficients: "<< fDiffCoeff<< ", "<<fDiffCoeff1 << endl;
7551c5b2 335
3d2c9d72 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;
7551c5b2 341
3d2c9d72 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;
7551c5b2 347
3d2c9d72 348 cout << "N. of Sigma for signal integration: " << fNsigmas << endl;
349 cout << "N. of bins in lookup table: " << fNcomps << endl;
7551c5b2 350
3d2c9d72 351 cout << "Max. ADC Value: " << fMaxAdc << endl;
352 cout << "Min. Value: " << fMinVal << endl;
7551c5b2 353
3d2c9d72 354 PrintGains();
7551c5b2 355
356}
357
358
359