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