]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSresponseSDD.cxx
Created standard constructors and proper default constructors. As recomended
[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 #include <TString.h>
17 #include <TRandom.h>
18
19 #include "AliITSresponseSDD.h"
20
21 ClassImp(AliITSresponseSDD)
22 //______________________________________________________________________
23 AliITSresponseSDD::AliITSresponseSDD(){
24     // Default constructor
25
26     fGaus = 0;
27     SetDeadChannels();
28     SetMaxAdc();
29     SetDiffCoeff();
30     SetDriftSpeed();
31     SetNSigmaIntegration();
32     // SetClock();
33     SetNoiseParam();
34     SetNoiseAfterElectronics();
35     SetElectronics();
36     SetDynamicRange();
37     SetChargeLoss();
38     SetMinVal();
39     SetParamOptions();
40     SetZeroSupp();
41     SetDataType();
42     SetFilenames();
43     SetOutputOption();
44     SetDo10to8();
45     // set the default zero suppression parameters
46     fCPar[0]=0;
47     fCPar[1]=0;
48     fCPar[2]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.2);
49     fCPar[3]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.2);
50     fCPar[4]=0;
51     fCPar[5]=0;
52     fCPar[6]=0;
53     fCPar[7]=0;
54 }
55 //______________________________________________________________________
56 AliITSresponseSDD::AliITSresponseSDD(const char *dataType){    
57   // constructor
58   //   fModules = 520;
59   //   fChips = 4;
60   //   fChannels = 64;
61    SetDeadChannels();
62    SetMaxAdc();
63    SetDiffCoeff();
64    SetDriftSpeed();
65    SetNSigmaIntegration();
66    SetNLookUp();    // Sets fGaus
67    // SetClock();
68    SetNoiseParam();
69    SetNoiseAfterElectronics();
70    SetElectronics();
71    SetDynamicRange();
72    SetChargeLoss();
73    SetMinVal();
74    SetParamOptions();
75    SetZeroSupp();
76    SetDataType(dataType);
77    SetFilenames();
78    SetOutputOption();
79    SetDo10to8();
80    // set the default zero suppression parameters
81    fCPar[0]=0;
82    fCPar[1]=0;
83    fCPar[2]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.2);
84    fCPar[3]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.2);
85    fCPar[4]=0;
86    fCPar[5]=0;
87    fCPar[6]=0;
88    fCPar[7]=0;
89 }
90
91 AliITSresponseSDD::~AliITSresponseSDD() { 
92
93   if(fGaus) delete fGaus;
94
95 }
96
97 void AliITSresponseSDD::SetCompressParam(Int_t  cp[8])
98 {
99   // set compression param
100
101     Int_t i;
102     for (i=0; i<8; i++) {
103         fCPar[i]=cp[i];
104         //printf("\n CompressPar %d %d \n",i,fCPar[i]);
105         
106     }
107 }
108 void AliITSresponseSDD::GiveCompressParam(Int_t  cp[8])
109 {
110   // give compression param
111
112     Int_t i;
113     for (i=0; i<8; i++) {
114         cp[i]=fCPar[i];
115     }
116 }
117
118 void AliITSresponseSDD::SetDeadChannels(Int_t nmod, Int_t nchip, Int_t nchan) {
119
120   for(Int_t m=0; m<fModules; m++) 
121     for(Int_t n=0; n<fChips; n++) 
122       for(Int_t p=0; p<fChannels; p++) 
123         fGain[m][n][p] = 1.;
124
125   if(nmod < 0 || nmod > fModules) { cout << "Wrong number of dead modules: " << nmod << endl; return; }
126   Int_t nmax = (fModules-nmod)*fChips; 
127   if(nchip < 0 || nchip > nmax) { cout << "Wrong number of dead chips: " << nchip << endl; return; }
128   nmax = ((fModules - nmod)*fChips - nchip)*fChannels; 
129   if(nchan < 0 || nchan > nmax) { cout << "Wrong number of dead channels: " << nchan << endl; return; }
130   
131   TRandom *gran = new TRandom();
132   
133 //  cout << "modules" << endl;
134   Int_t * mod = new Int_t [nmod];
135   Int_t i; //loop variable
136   for(i=0;i<nmod;i++) {
137     mod[i] = (Int_t) (1.+fModules*gran->Uniform());
138     cout << i+1 << ": Dead module nr: " << mod[i] << endl;
139     for(Int_t n=0; n<fChips; n++)
140       for(Int_t p=0; p<fChannels; p++)
141         fGain[mod[i]-1][n][p] = 0.;
142   }
143
144 //  cout << "chips" << endl;
145   Int_t * chip = new Int_t[nchip];
146   Int_t * chip_mod = new Int_t[nchip];
147   i=0;
148   while(i<nchip) {
149     Int_t module = (Int_t) (fModules*gran->Uniform() + 1.);
150     if(module <=0 || module > fModules) cout << "Wrong module: " << module << endl;
151     Int_t flag_mod = 0;
152     for(Int_t k=0;k<nmod;k++) if(module == mod[k]) flag_mod = 1;
153     if(flag_mod == 1) continue;
154     Int_t chi = (Int_t) (fChips*gran->Uniform() + 1.);
155     if(chi <=0 || chi > fChips) cout << "Wrong chip: " << chi << endl;
156     i++;
157     chip[i-1] = chi; 
158     chip_mod[i-1] = module;
159     for(Int_t m=0; m<fChannels; m++) fGain[module-1][chi-1][m] = 0.;
160     cout << i << ": Dead chip nr. " << chip[i-1] << " in module nr: " << chip_mod[i-1] << endl;
161   }
162
163 //  cout << "channels" << endl;
164   Int_t * channel = new Int_t[nchan];
165   Int_t * channel_chip = new Int_t[nchan];
166   Int_t * channel_mod = new Int_t[nchan];
167   i=0;
168   while(i<nchan) {
169     Int_t k; //loop variable
170     Int_t module = (Int_t) (fModules*gran->Uniform() + 1.);
171     if(module <=0 || module > fModules) cout << "Wrong module: " << module << endl;
172     Int_t flag_mod = 0;
173     for(k=0;k<nmod;k++) if(module == mod[k]) flag_mod = 1;
174     if(flag_mod == 1) continue;
175     Int_t chipp = (Int_t) (fChips*gran->Uniform() + 1.);
176     if(chipp <=0 || chipp > fChips) cout << "Wrong chip: " << chipp << endl;
177     Int_t flag_chip = 0;
178     for(k=0;k<nchip;k++) if(chipp == chip[k] && module == chip_mod[k]) flag_chip = 1;
179     if(flag_chip == 1) continue;
180     i++;
181     channel[i-1] = (Int_t) (fChannels*gran->Uniform() + 1.); 
182     if(channel[i-1] <=0 || channel[i-1] > fChannels) cout << "Wrong channel: " << channel[i-1] << endl;
183     channel_chip[i-1] = chipp;
184     channel_mod[i-1] = module;
185     fGain[module-1][chipp-1][channel[i-1]-1] = 0.;
186     cout << i << ": Dead channel nr. " << channel[i-1] << " in chip nr. " << channel_chip[i-1] << " in module nr: " << channel_mod[i-1] << endl;
187   }
188
189   delete [] mod;
190   delete [] chip;
191   delete [] chip_mod;
192   delete [] channel;
193   delete [] channel_mod;
194   delete [] channel_chip;
195 }
196
197 void AliITSresponseSDD::PrintGains()
198 {
199   // Print SDD electronic gains
200   for(Int_t t=0; t<fModules;t++)
201     for(Int_t u=0; u<fChips;u++)
202       for(Int_t v=0; v<fChannels;v++)
203         cout << "Gain for Module: " << t+1 << ", Chip " << u+1 << ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
204
205 }
206
207 void AliITSresponseSDD::Print()
208 {
209   // Print SDD response Parameters
210
211    cout << "**************************************************" << endl;
212    cout << "   Silicon Drift Detector Response Parameters    " << endl;
213    cout << "**************************************************" << endl;
214    cout << "Diffusion Coefficients: " << fDiffCoeff << ", " << fDiffCoeff1 << endl;
215
216    cout << "Hardware compression parameters: " << endl; 
217    for(Int_t i=0; i<8; i++) cout << "fCPar[" << i << "] = " << fCPar[i] << endl;
218    cout << "Noise before electronics (arbitrary units): " << fNoise << endl;
219    cout << "Baseline (ADC units): " << fBaseline << endl;
220    cout << "Noise after electronics (ADC units): " << fNoiseAfterEl << endl;
221
222    cout << "Dynamic Range: " << fDynamicRange << endl;
223    cout << "Charge Loss: " << fChargeLoss << endl;
224    cout << "Temperature: " << fTemperature << endl;
225    cout << "Drift Speed: " << fDriftSpeed << endl;
226    cout << "Electronics (1=PASCAL, 2=OLA): " << fElectronics << endl;
227
228    cout << "N. of Sigma for signal integration: " << fNsigmas << endl;
229    cout << "N. of bins in lookup table: " << fNcomps << endl;
230
231    cout << "Max. ADC Value: " << fMaxAdc << endl;
232    cout << "Min. Value: " << fMinVal << endl;
233
234    cout << "**************************************************" << endl; 
235    cout << "             Print Electronics Gains              " << endl;
236    cout << "**************************************************" << endl;
237    PrintGains();
238
239 }
240
241
242