]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSresponseSDD.cxx
Added new plots
[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
18 #include <TString.h>
19 #include <TRandom.h>
20
21 #include "AliITSresponseSDD.h"
22
23
24 //______________________________________________________________________
25 ClassImp(AliITSresponseSDD)
26
27 AliITSresponseSDD::AliITSresponseSDD(){
28   // default constructor
29    fGaus = 0;
30    SetDeadChannels();
31    SetMaxAdc();
32    SetDiffCoeff();
33    SetDriftSpeed();
34    SetNSigmaIntegration();
35    SetNLookUp();
36    // SetClock();
37    SetNoiseParam();
38    SetNoiseAfterElectronics();
39    SetJitterError();
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;
54    fCPar[2]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.5);
55    fCPar[3]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.5);
56    fCPar[4]=0;
57    fCPar[5]=0;
58    fCPar[6]=0;
59    fCPar[7]=0;
60 }
61 //______________________________________________________________________
62 AliITSresponseSDD::AliITSresponseSDD(const char *dataType){
63   // constructor
64    fGaus = 0;
65    SetDeadChannels();
66    SetMaxAdc();
67    SetDiffCoeff();
68    SetDriftSpeed();
69    SetNSigmaIntegration();
70    SetNLookUp();
71    // SetClock();
72    SetNoiseParam();
73    SetNoiseAfterElectronics();
74    SetJitterError();
75    SetElectronics();
76    SetDynamicRange();
77    SetChargeLoss();
78    SetMinVal();
79    SetParamOptions();
80    SetTemperature();
81    SetZeroSupp();
82    SetDataType(dataType);
83    SetFilenames();
84    SetOutputOption();
85    SetDo10to8();
86    // set the default zero suppression parameters
87    fCPar[0]=0;
88    fCPar[1]=0;
89    fCPar[2]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.5);
90    fCPar[3]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.5);
91    fCPar[4]=0;
92    fCPar[5]=0;
93    fCPar[6]=0;
94    fCPar[7]=0;
95 }
96 //______________________________________________________________________
97 AliITSresponseSDD::~AliITSresponseSDD() { 
98
99   if(fGaus) delete fGaus;
100 }
101 //______________________________________________________________________
102 void AliITSresponseSDD::SetCompressParam(Int_t  cp[8]){
103   // set compression param
104
105     Int_t i;
106     for (i=0; i<8; i++) {
107         fCPar[i]=cp[i];
108         //printf("\n CompressPar %d %d \n",i,fCPar[i]);    
109     } // end for i
110 }
111 //______________________________________________________________________
112 void AliITSresponseSDD::GiveCompressParam(Int_t  cp[8]){
113   // give compression param
114
115     Int_t i;
116     for (i=0; i<8; i++) {
117         cp[i]=fCPar[i];
118     } // end for i
119 }
120 //______________________________________________________________________
121 void AliITSresponseSDD::SetDeadChannels(Int_t nmod, Int_t nchip, Int_t nchan){
122     // Set fGain to zero to simulate a random distribution of 
123     // dead modules, dead chips and single dead channels
124
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;
136
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     }
154   
155     TRandom *gran = new TRandom();
156   
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.;
190         cout << i << ": Dead chip nr. " << chip[i-1] << " in module nr: " 
191              << chip_mod[i-1] << endl;
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.);
210         if( chipp <=0 || chipp > fChips ) cout << "Wrong chip: "<< chipp<<endl;
211         Int_t flag_chip = 0;
212         for( k=0; k<nchip; k++) 
213             if( chipp == chip[k] && module == chip_mod[k] ) { 
214                 flag_chip = 1; break; }
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.;
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;
226     }
227     
228     delete [] mod;
229     delete [] chip;
230     delete [] chip_mod;
231     delete [] channel;
232     delete [] channel_mod;
233     delete [] channel_chip;
234 }
235 //______________________________________________________________________
236 void AliITSresponseSDD::PrintGains(){
237     //
238
239   if( GetDeadModules() == 0 && 
240       GetDeadChips() == 0 && 
241       GetDeadChannels() == 0 )
242       return;  
243
244   // Print Electronics Gains
245   cout << "**************************************************" << endl; 
246   cout << "             Print Electronics Gains              " << endl;
247   cout << "**************************************************" << endl;
248
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++)
253       {
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;
257       }
258 }
259 //______________________________________________________________________
260 void AliITSresponseSDD::Print(){
261   // Print SDD response Parameters
262
263    cout << "**************************************************" << endl;
264    cout << "   Silicon Drift Detector Response Parameters    " << endl;
265    cout << "**************************************************" << endl;
266    cout << "Diffusion Coefficients: "<< fDiffCoeff<< ", "<<fDiffCoeff1 << endl;
267
268    cout << "Hardware compression parameters: " << endl; 
269    for(Int_t i=0; i<8; i++) cout << "fCPar[" << i << "] = " << fCPar[i] <<endl;
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
286    PrintGains();
287
288 }
289
290
291