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