]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSCalibrationSDD.cxx
New SPD simulation (Massimo):
[u/mrichter/AliRoot.git] / ITS / AliITSCalibrationSDD.cxx
1 /**************************************************************************
2
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4
5  *                                                                        *
6
7  * Author: The ALICE Off-line Project.                                    *
8
9  * Contributors are mentioned in the code where appropriate.              *
10
11  *                                                                        *
12
13  * Permission to use, copy, modify and distribute this software and its   *
14
15  * documentation strictly for non-commercial purposes is hereby granted   *
16
17  * without fee, provided that the above copyright notice appears in all   *
18
19  * copies and that both the copyright notice and this permission notice   *
20
21  * appear in the supporting documentation. The authors make no claims     *
22
23  * about the suitability of this software for any purpose. It is          *
24
25  * provided "as is" without express or implied warranty.                  *
26
27  **************************************************************************/
28
29
30
31
32
33 #include <Riostream.h>
34
35 #include <TRandom.h>
36
37 #include "AliITSCalibrationSDD.h"
38
39 #include "AliLog.h"
40
41
42
43 //////////////////////////////////////////////////////
44
45 //  Calibration class for set:ITS                   //
46
47 //  Specific subdetector implementation             //
48
49 //  for silicon drift detectors                     //
50
51 //                                                  //
52
53 //                                                  //
54
55 //////////////////////////////////////////////////////
56
57
58
59 const Double_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
60
61 const Double_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
62
63 const Double_t AliITSCalibrationSDD::fgkGainDefault = 1.;
64
65 const Double_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
66
67 const Double_t AliITSCalibrationSDD::fgkMinValDefault  = 4;
68
69 //______________________________________________________________________
70
71 ClassImp(AliITSCalibrationSDD)
72
73
74
75 AliITSCalibrationSDD::AliITSCalibrationSDD(){
76
77   // default constructor
78
79
80
81   SetDeadChannels();
82
83   fBadChannels.Set(fDeadChannels);
84
85   for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
86
87     fBaseline[ian]=fgkBaselineDefault;
88
89     fNoise[ian]=fgkNoiseDefault;
90
91     SetNoiseAfterElectronics(ian);
92
93   }
94
95   for(Int_t iw=0;iw<fgkWings;iw++){
96
97     for(Int_t icp=0;icp<fgkChips;icp++){
98
99       for(Int_t ich=0;ich<fgkChannels;ich++)
100
101         fGain[iw][icp][ich]=1.;
102
103     }
104
105   }
106
107   SetThresholds(fgkMinValDefault,0.);
108
109   SetTemperature(fgkTemperatureDefault);
110
111   SetDataType();
112
113   for(Int_t i=0;i<fgkChips*fgkChannels;i++){
114
115     for(Int_t j=0;j<fgkMapTimeNBin;j++){
116
117       fMapA[i][j]=0;
118
119       fMapT[i][j]=0;
120
121     }
122
123   }
124
125  }
126
127 //______________________________________________________________________
128
129 AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType){
130
131   // constructor
132
133
134
135   SetDeadChannels();
136
137   fBadChannels.Set(fDeadChannels);
138
139   for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
140
141     fBaseline[ian]=fgkBaselineDefault;
142
143       fNoise[ian]=fgkNoiseDefault;
144
145       SetNoiseAfterElectronics(ian);
146
147   }  
148
149   for(Int_t iw=0;iw<fgkWings;iw++){
150
151     for(Int_t icp=0;icp<fgkChips;icp++){
152
153       for(Int_t ich=0;ich<fgkChannels;ich++)
154
155         fGain[iw][icp][ich]=1.;
156
157     }
158
159   }
160
161
162
163   SetThresholds(fgkMinValDefault,0.);
164
165   SetTemperature(fgkTemperatureDefault);
166
167   SetDataType(dataType);
168
169   for(Int_t i=0;i<fgkChips*fgkChannels;i++){
170
171     for(Int_t j=0;j<fgkMapTimeNBin;j++){
172
173       fMapA[i][j]=0;
174
175       fMapT[i][j]=0;
176
177     }
178
179   }
180
181
182
183  }
184
185 //______________________________________________________________________
186
187 AliITSCalibrationSDD::AliITSCalibrationSDD(const AliITSCalibrationSDD &ob) : AliITSCalibration(ob) {
188
189   // Copy constructor
190
191   // Copies are not allowed. The method is protected to avoid misuse.
192
193   Error("AliITSCalibrationSDD","Copy constructor not allowed\n");
194
195 }
196
197
198
199 //______________________________________________________________________
200
201 AliITSCalibrationSDD& AliITSCalibrationSDD::operator=(const AliITSCalibrationSDD& /* ob */){
202
203   // Assignment operator
204
205   // Assignment is not allowed. The method is protected to avoid misuse.
206
207   Error("= operator","Assignment operator not allowed\n");
208
209   return *this;
210
211 }
212
213
214
215 //______________________________________________________________________
216
217 void AliITSCalibrationSDD::GiveCompressParam(Int_t  cp[8],Int_t ian) const {
218
219   // give compression param
220
221
222
223   cp[0]=(Int_t) fBaseline[ian];
224
225   cp[1]=(Int_t) fBaseline[ian];
226
227   cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
228
229   cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
230
231   cp[4]=0;
232
233   cp[5]=0;
234
235   cp[6]=0;
236
237   cp[7]=0;
238
239 }
240
241 //_____________________________________________________________________
242
243 void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
244
245   //Set bad anode (set gain=0 for these channels);
246
247
248
249   if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
250
251   Int_t wing=0;
252
253   Int_t chip,channel;
254
255   chip=anode/fgkChannels;
256
257   channel=anode-(chip*fgkChannels);
258
259   if(anode>=fgkChips*fgkChannels) wing=1;
260
261   if(wing==1)chip-=fgkChips;
262
263   fBadChannels[i]=anode;
264
265   fGain[wing][chip][channel]=0;
266
267 }
268
269 //_____________________________________________________________________
270
271 Bool_t AliITSCalibrationSDD::IsBadChannel(Int_t anode){
272
273   //returns kTRUE if the anode i (0-512) has fGain=0
274
275   if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
276
277   Int_t wing=0;
278
279   Int_t chip,channel;
280
281   chip=anode/fgkChannels;
282
283   channel=anode-(chip*fgkChannels);
284
285   if(anode>=fgkChips*fgkChannels) wing=1;
286
287   if(wing==1)chip-=fgkChips;
288
289   if(fGain[wing][chip][channel]==0) return kTRUE;
290
291   else return kFALSE;
292
293
294
295 /*
296
297 //______________________________________________________________________
298
299 void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
300
301   // Set fGain to zero to simulate a random distribution of 
302
303   // dead modules, dead chips and single dead channels
304
305
306
307   for( Int_t m=0; m<fgkWings; m++ ) 
308
309     for( Int_t n=0; n<fgkChips; n++ ) 
310
311       for( Int_t p=0; p<fgkChannels; p++ ) 
312
313         fGain[m][n][p] = 1.;
314
315                  
316
317   //fDeadModules  = nmod;  
318
319   fDeadChips    = nchip;  
320
321   fDeadChannels = nchan; 
322
323   fBadChannels.Set(fDeadChannels);  
324
325   // nothing to do
326
327   //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
328
329
330
331   if( nchip == 0 && nchan == 0 ) return;
332
333   // if( nmod < 0 || nmod > fgkModules ) 
334
335   //  { 
336
337   //    cout << "Wrong number of dead modules: " << nmod << endl; 
338
339   //    return; 
340
341   //  }
342
343   
344
345   Int_t nmax = fgkWings*fgkChips; 
346
347   if( nchip < 0 || nchip > nmax ) 
348
349     { 
350
351       cout << "Wrong number of dead chips: " << nchip << endl; 
352
353       return; 
354
355     }
356
357   nmax = (fgkWings*fgkChips - nchip)*fgkChannels; 
358
359   if( nchan < 0 || nchan > nmax ) 
360
361     { 
362
363       cout << "Wrong number of dead channels: " << nchan << endl; 
364
365       return; 
366
367     }
368
369   
370
371   TRandom *gran = new TRandom();
372
373   //  cout << "chips" << endl;
374
375   Int_t * chip     = new Int_t[nchip];
376
377   Int_t i = 0;
378
379   while( i < nchip ) 
380
381     {
382
383       Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
384
385       if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
386
387         
388
389       Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
390
391       if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
392
393       i++;
394
395       chip[i-1] = chi; 
396
397       for( Int_t m=0; m<fgkChannels; m++ ) 
398
399         fGain[wing-1][chi-1][m] = 0.;
400
401     }
402
403
404
405   Int_t * channel      = new Int_t[nchan];
406
407   Int_t * channelChip = new Int_t[nchan];
408
409   i = 0;
410
411   while( i < nchan ) 
412
413     {
414
415       Int_t k; //loop variable
416
417       Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
418
419       if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
420
421       Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
422
423       if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
424
425       Int_t flagChip = 0;
426
427       for( k=0; k<nchip; k++) 
428
429         if( chipp == chip[k] ) { 
430
431           flagChip = 1; break; }
432
433       if( flagChip == 1 ) continue;
434
435       i++;
436
437       channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.); 
438
439       if( channel[i-1] <=0 || channel[i-1] > fgkChannels ) 
440
441         Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
442
443       channelChip[i-1] = chipp;
444
445       fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
446
447     }
448
449     
450
451   delete [] chip;
452
453   delete [] channel;
454
455   delete [] channelChip;
456
457 }
458
459 */
460
461 //______________________________________________________________________
462
463 void AliITSCalibrationSDD::PrintGains() const{
464
465   //
466
467
468
469   if( GetDeadChips() == 0 && 
470
471       GetDeadChannels() == 0 )
472
473     return;  
474
475
476
477   // Print Electronics Gains
478
479   cout << "**************************************************" << endl; 
480
481   cout << "             Print Electronics Gains              " << endl;
482
483   cout << "**************************************************" << endl;
484
485
486
487   // Print SDD electronic gains
488
489   for(Int_t t=0; t<fgkWings;t++)
490
491     for(Int_t u=0; u<fgkChips;u++)
492
493       for(Int_t v=0; v<fgkChannels;v++)
494
495         {
496
497           if( fGain[t][u][v] != 1.0 )
498
499             cout << "Gain for wing: " << t+1 << ", Chip " << u+1 << 
500
501               ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
502
503         }
504
505 }
506
507 //______________________________________________________________________
508
509 void AliITSCalibrationSDD::Print(){
510
511   // Print SDD response Parameters
512
513
514
515   cout << "**************************************************" << endl;
516
517   cout << "   Silicon Drift Detector Response Parameters    " << endl;
518
519   cout << "**************************************************" << endl;
520
521   cout << "Hardware compression parameters: " << endl; 
522
523   cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
524
525   cout << "Baseline (ADC units): " << fBaseline[0] << endl;
526
527   cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
528
529   cout << "Temperature: " << Temperature() << " K " << endl;
530
531   cout << "Min. Value: " << fMinVal << endl;
532
533   PrintGains();
534
535
536
537 }
538