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