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