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