]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSCalibrationSDD.cxx
Crrected versions of AliAltroBuffer, AliAltroMapping and AliTPCRawStream
[u/mrichter/AliRoot.git] / ITS / AliITSCalibrationSDD.cxx
CommitLineData
fcf95fc7 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
17#include <Riostream.h>
18#include <TRandom.h>
19#include "AliITSCalibrationSDD.h"
20
21//////////////////////////////////////////////////////
22// Calibration class for set:ITS //
23// Specific subdetector implementation //
24// for silicon drift detectors //
25// //
26// //
27//////////////////////////////////////////////////////
28
29const Double_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
30const Double_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
31const Double_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
32const Double_t AliITSCalibrationSDD::fgkMinValDefault = 4;
33//______________________________________________________________________
34ClassImp(AliITSCalibrationSDD)
35
36 AliITSCalibrationSDD::AliITSCalibrationSDD(){
37 // default constructor
38
39 SetDeadChannels();
40 fBaseline=0;
41 fNoise=0;
42
43 SetNoiseParam(fgkNoiseDefault,fgkBaselineDefault);
44 SetNoiseAfterElectronics();
45 SetThresholds(fgkMinValDefault,0.);
46 SetTemperature(fgkTemperatureDefault);
47 SetDataType();
48 fCPar[1]=(Int_t) fBaseline;
49 fCPar[2]=(Int_t)(2.*fNoiseAfterEl + 0.5);
50 fCPar[3]=(Int_t)(2.*fNoiseAfterEl + 0.5);
51 fCPar[4]=0;
52 fCPar[5]=0;
53 fCPar[6]=0;
54 fCPar[7]=0;
55 }
56//______________________________________________________________________
57AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType){
58 // constructor
59
60 SetDeadChannels();
61 fBaseline=0;
62 fNoise=0;
63
64 SetNoiseParam(fgkNoiseDefault,fgkBaselineDefault);
65 SetNoiseAfterElectronics();
66 SetThresholds(fgkMinValDefault,0.);
67 SetTemperature(fgkTemperatureDefault);
68 SetDataType(dataType);
69 fCPar[0]=(Int_t) fBaseline;
70 fCPar[1]=(Int_t) fBaseline;
71 fCPar[2]=(Int_t)(2.*fNoiseAfterEl + 0.5);
72 fCPar[3]=(Int_t)(2.*fNoiseAfterEl + 0.5);
73 fCPar[4]=0;
74 fCPar[5]=0;
75 fCPar[6]=0;
76 fCPar[7]=0;
77 }
78//______________________________________________________________________
79AliITSCalibrationSDD::AliITSCalibrationSDD(const AliITSCalibrationSDD &ob) : AliITSCalibration(ob) {
80 // Copy constructor
81 // Copies are not allowed. The method is protected to avoid misuse.
82 Error("AliITSCalibrationSDD","Copy constructor not allowed\n");
83}
84
85//______________________________________________________________________
86AliITSCalibrationSDD& AliITSCalibrationSDD::operator=(const AliITSCalibrationSDD& /* ob */){
87 // Assignment operator
88 // Assignment is not allowed. The method is protected to avoid misuse.
89 Error("= operator","Assignment operator not allowed\n");
90 return *this;
91}
92
93//______________________________________________________________________
94void AliITSCalibrationSDD::SetCompressParam(Int_t cp[8]){
95 // set compression param
96
97 Int_t i;
98 for (i=0; i<8; i++) {
99 fCPar[i]=cp[i];
100 //printf("\n CompressPar %d %d \n",i,fCPar[i]);
101 } // end for i
102}
103//______________________________________________________________________
104void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8]) const {
105 // give compression param
106
107 Int_t i;
108 for (i=0; i<8; i++) {
109 cp[i]=fCPar[i];
110 } // end for i
111}
112
113//______________________________________________________________________
114void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
115 // Set fGain to zero to simulate a random distribution of
116 // dead modules, dead chips and single dead channels
117
118 for( Int_t m=0; m<fgkWings; m++ )
119 for( Int_t n=0; n<fgkChips; n++ )
120 for( Int_t p=0; p<fgkChannels; p++ )
121 fGain[m][n][p] = 1.;
122
123 //fDeadModules = nmod;
124 fDeadChips = nchip;
125 fDeadChannels = nchan;
126
127 // nothing to do
128 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
129
130 if( nchip == 0 && nchan == 0 ) return;
131 // if( nmod < 0 || nmod > fgkModules )
132 // {
133 // cout << "Wrong number of dead modules: " << nmod << endl;
134 // return;
135 // }
136
137 Int_t nmax = fgkWings*fgkChips;
138 if( nchip < 0 || nchip > nmax )
139 {
140 cout << "Wrong number of dead chips: " << nchip << endl;
141 return;
142 }
143 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
144 if( nchan < 0 || nchan > nmax )
145 {
146 cout << "Wrong number of dead channels: " << nchan << endl;
147 return;
148 }
149
150 TRandom *gran = new TRandom();
151 /*
152 // cout << "modules" << endl;
153 Int_t * mod = new Int_t [nmod];
154 Int_t i; //loop variable
155 for( i=0; i<nmod; i++ )
156 {
157 mod[i] = (Int_t) (1.+fgkModules*gran->Uniform());
158 cout << i+1 << ": Dead module nr: " << mod[i] << endl;
159 for(Int_t n=0; n<fResponseSDD->Chips(); n++)
160 for(Int_t p=0; p<fResponseSDD->Channels(); p++)
161 fGain[mod[i]-1][n][p] = 0.;
162 }
163 */
164 // cout << "chips" << endl;
165 Int_t * chip = new Int_t[nchip];
166 Int_t i = 0;
167 while( i < nchip )
168 {
169 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
170 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
171
172 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
173 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
174 i++;
175 chip[i-1] = chi;
176 for( Int_t m=0; m<fgkChannels; m++ )
177 fGain[wing-1][chi-1][m] = 0.;
178 }
179
180 Int_t * channel = new Int_t[nchan];
181 Int_t * channelChip = new Int_t[nchan];
182 i = 0;
183 while( i < nchan )
184 {
185 Int_t k; //loop variable
186 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
187 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
188 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
189 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
190 Int_t flagChip = 0;
191 for( k=0; k<nchip; k++)
192 if( chipp == chip[k] ) {
193 flagChip = 1; break; }
194 if( flagChip == 1 ) continue;
195 i++;
196 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
197 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
198 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
199 channelChip[i-1] = chipp;
200 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
201 }
202
203 delete [] chip;
204 delete [] channel;
205 delete [] channelChip;
206}
207//______________________________________________________________________
208void AliITSCalibrationSDD::PrintGains() const{
209 //
210
211 if( GetDeadChips() == 0 &&
212 GetDeadChannels() == 0 )
213 return;
214
215 // Print Electronics Gains
216 cout << "**************************************************" << endl;
217 cout << " Print Electronics Gains " << endl;
218 cout << "**************************************************" << endl;
219
220 // Print SDD electronic gains
221 for(Int_t t=0; t<fgkWings;t++)
222 for(Int_t u=0; u<fgkChips;u++)
223 for(Int_t v=0; v<fgkChannels;v++)
224 {
225 if( fGain[t][u][v] != 1.0 )
226 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
227 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
228 }
229}
230//______________________________________________________________________
231void AliITSCalibrationSDD::Print(){
232 // Print SDD response Parameters
233
234 cout << "**************************************************" << endl;
235 cout << " Silicon Drift Detector Response Parameters " << endl;
236 cout << "**************************************************" << endl;
237 cout << "Hardware compression parameters: " << endl;
238 for(Int_t i=0; i<8; i++) cout << "fCPar[" << i << "] = " << fCPar[i] <<endl;
239 cout << "Noise before electronics (arbitrary units): " << fNoise << endl;
240 cout << "Baseline (ADC units): " << fBaseline << endl;
241 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl << endl;
242 cout << "Temperature: " << Temperature() << " K " << endl;
243 cout << "Min. Value: " << fMinVal << endl;
244 PrintGains();
245
246}
247
248
249