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