]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSCalibrationSDD.cxx
Getting rid of trivial warnings.
[u/mrichter/AliRoot.git] / ITS / AliITSCalibrationSDD.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2009, 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 /* $Id$ */
17
18 #include <Riostream.h>
19 #include <TRandom.h>
20 #include "AliITSCalibrationSDD.h"
21 #include "AliLog.h"
22
23 //////////////////////////////////////////////////////
24 //  Calibration class for set:ITS                   //
25 //  Specific subdetector implementation             //
26 //  for silicon drift detectors                     //
27 //                                                  //
28 //                                                  //
29 //////////////////////////////////////////////////////
30
31 const Float_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
32 const Float_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
33 const Float_t AliITSCalibrationSDD::fgkGainDefault = 1.;
34 const Float_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
35 const Float_t AliITSCalibrationSDD::fgkMinValDefault  = 4;
36 //______________________________________________________________________
37 ClassImp(AliITSCalibrationSDD)
38
39 AliITSCalibrationSDD::AliITSCalibrationSDD():
40 AliITSCalibration(),
41 fDeadChips(0),
42 fDeadChannels(0),
43 fMinVal(fgkMinValDefault),
44 fIsDead(kFALSE),
45 fBadChannels(),
46 fMapAW0(0),
47 fMapAW1(0),
48 fMapTW0(0),
49 fMapTW1(0)
50 {
51   // default constructor
52
53   SetDeadChannels();
54   for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
55     fBaseline[ian]=fgkBaselineDefault;
56     fNoise[ian]=fgkNoiseDefault;
57     SetNoiseAfterElectronics(ian);
58   }
59   for(Int_t iw=0;iw<fgkWings;iw++){
60     for(Int_t icp=0;icp<fgkChips;icp++){
61       for(Int_t ich=0;ich<fgkChannels;ich++)
62         fGain[iw][icp][ich]=1.;
63     }
64   }
65   SetThresholds(fgkMinValDefault,0.);
66   SetTemperature(fgkTemperatureDefault);
67   SetDataType();
68   fDriftVelParW0[0]= AliITSresponseSDD::DefaultDriftSpeed();
69   fDriftVelParW1[0]= AliITSresponseSDD::DefaultDriftSpeed();
70   for(Int_t i=1;i<4;i++){
71     fDriftVelParW0[i]=0.;
72     fDriftVelParW1[i]=0.;
73   }
74  }
75 //______________________________________________________________________
76 AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType):
77 AliITSCalibration(),
78 fDeadChips(0),
79 fDeadChannels(0),
80 fMinVal(fgkMinValDefault),
81 fIsDead(kFALSE),
82 fBadChannels(),
83 fMapAW0(0),
84 fMapAW1(0),
85 fMapTW0(0),
86 fMapTW1(0){
87   // constructor
88
89   SetDeadChannels();
90   for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
91     fBaseline[ian]=fgkBaselineDefault;
92       fNoise[ian]=fgkNoiseDefault;
93       SetNoiseAfterElectronics(ian);
94   }  
95   for(Int_t iw=0;iw<fgkWings;iw++){
96     for(Int_t icp=0;icp<fgkChips;icp++){
97       for(Int_t ich=0;ich<fgkChannels;ich++)
98         fGain[iw][icp][ich]=1.;
99     }
100   }
101
102   SetThresholds(fgkMinValDefault,0.);
103   SetTemperature(fgkTemperatureDefault);
104   SetDataType(dataType);
105   fDriftVelParW0[0]= AliITSresponseSDD::DefaultDriftSpeed();
106   fDriftVelParW1[0]= AliITSresponseSDD::DefaultDriftSpeed();
107   for(Int_t i=1;i<4;i++){
108     fDriftVelParW0[i]=0.;
109     fDriftVelParW1[i]=0.;
110   }
111  }
112 //_____________________________________________________________________
113 AliITSCalibrationSDD::~AliITSCalibrationSDD(){
114
115   //destructor
116   if(fMapAW0) delete fMapAW0;
117   if(fMapAW1) delete fMapAW1;
118   if(fMapTW0) delete fMapTW0;
119   if(fMapTW1) delete fMapTW1;
120
121 }
122
123 //______________________________________________________________________
124 void AliITSCalibrationSDD::GiveCompressParam(Int_t  cp[8],Int_t ian) const {
125   // give compression param
126
127   cp[0]=(Int_t) fBaseline[ian];
128   cp[1]=(Int_t) fBaseline[ian];
129   cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
130   cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
131   cp[4]=0;
132   cp[5]=0;
133   cp[6]=0;
134   cp[7]=0;
135 }
136 //_____________________________________________________________________
137 void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
138   //Set bad anode (set gain=0 for these channels);
139
140   if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
141   Int_t wing=0;
142   Int_t chip,channel;
143   chip=anode/fgkChannels;
144   channel=anode-(chip*fgkChannels);
145   if(anode>=fgkChips*fgkChannels) wing=1;
146   if(wing==1)chip-=fgkChips;
147   fBadChannels[i]=anode;
148   fGain[wing][chip][channel]=0;
149 }
150 //_____________________________________________________________________
151 void AliITSCalibrationSDD::SetDriftSpeedParam(Int_t iWing, Float_t* p){
152   // Sets coefficients of pol3 fit to drift speed vs. anode
153   if(iWing==0){
154     for(Int_t i=0;i<4;i++) fDriftVelParW0[i]=p[i];
155   }else{
156     for(Int_t i=0;i<4;i++) fDriftVelParW1[i]=p[i];
157   }
158 }
159
160 //_____________________________________________________________________
161 Float_t AliITSCalibrationSDD::GetDriftSpeedAtAnode(Float_t nAnode) const {
162   // Calculates drift speed for given position along anodes
163   if(nAnode<256){
164     return fDriftVelParW0[0]+fDriftVelParW0[1]*nAnode+fDriftVelParW0[2]*nAnode*nAnode+fDriftVelParW0[3]*nAnode*nAnode*nAnode;
165   }else{
166     nAnode-=256;
167     return fDriftVelParW1[0]+fDriftVelParW1[1]*nAnode+fDriftVelParW1[2]*nAnode*nAnode+fDriftVelParW1[3]*nAnode*nAnode*nAnode;
168   }
169 }
170
171 //______________________________________________________________________
172 Float_t AliITSCalibrationSDD::GetChannelGain(Int_t anode) const{
173   // returns gain for givenanode
174   Int_t iWing=GetWing(anode);
175   Int_t iChip=GetChip(anode);
176   Int_t iChan=GetChipChannel(anode);
177   return fGain[iWing][iChip][iChan];
178 }
179 /*
180 //______________________________________________________________________
181 void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
182   // Set fGain to zero to simulate a random distribution of 
183   // dead modules, dead chips and single dead channels
184
185   for( Int_t m=0; m<fgkWings; m++ ) 
186     for( Int_t n=0; n<fgkChips; n++ ) 
187       for( Int_t p=0; p<fgkChannels; p++ ) 
188         fGain[m][n][p] = 1.;
189                  
190   //fDeadModules  = nmod;  
191   fDeadChips    = nchip;  
192   fDeadChannels = nchan; 
193   fBadChannels.Set(fDeadChannels);  
194   // nothing to do
195   //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
196
197   if( nchip == 0 && nchan == 0 ) return;
198   // if( nmod < 0 || nmod > fgkModules ) 
199   //  { 
200   //    cout << "Wrong number of dead modules: " << nmod << endl; 
201   //    return; 
202   //  }
203   
204   Int_t nmax = fgkWings*fgkChips; 
205   if( nchip < 0 || nchip > nmax ) 
206     { 
207       cout << "Wrong number of dead chips: " << nchip << endl; 
208       return; 
209     }
210   nmax = (fgkWings*fgkChips - nchip)*fgkChannels; 
211   if( nchan < 0 || nchan > nmax ) 
212     { 
213       cout << "Wrong number of dead channels: " << nchan << endl; 
214       return; 
215     }
216   
217   TRandom *gran = new TRandom();
218   //  cout << "chips" << endl;
219   Int_t * chip     = new Int_t[nchip];
220   Int_t i = 0;
221   while( i < nchip ) 
222     {
223       Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
224       if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
225         
226       Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
227       if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
228       i++;
229       chip[i-1] = chi; 
230       for( Int_t m=0; m<fgkChannels; m++ ) 
231         fGain[wing-1][chi-1][m] = 0.;
232     }
233
234   Int_t * channel      = new Int_t[nchan];
235   Int_t * channelChip = new Int_t[nchan];
236   i = 0;
237   while( i < nchan ) 
238     {
239       Int_t k; //loop variable
240       Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
241       if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
242       Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
243       if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
244       Int_t flagChip = 0;
245       for( k=0; k<nchip; k++) 
246         if( chipp == chip[k] ) { 
247           flagChip = 1; break; }
248       if( flagChip == 1 ) continue;
249       i++;
250       channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.); 
251       if( channel[i-1] <=0 || channel[i-1] > fgkChannels ) 
252         Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
253       channelChip[i-1] = chipp;
254       fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
255     }
256     
257   delete [] chip;
258   delete [] channel;
259   delete [] channelChip;
260 }
261 */
262
263
264 //______________________________________________________________________
265 void AliITSCalibrationSDD::PrintGains() const{
266   //
267
268   if( GetDeadChips() == 0 && 
269       GetDeadChannels() == 0 )
270     return;  
271
272   // Print Electronics Gains
273   cout << "**************************************************" << endl; 
274   cout << "             Print Electronics Gains              " << endl;
275   cout << "**************************************************" << endl;
276
277   // Print SDD electronic gains
278   for(Int_t t=0; t<fgkWings;t++)
279     for(Int_t u=0; u<fgkChips;u++)
280       for(Int_t v=0; v<fgkChannels;v++)
281         {
282           if( fGain[t][u][v] != 1.0 )
283             cout << "Gain for wing: " << t+1 << ", Chip " << u+1 << 
284               ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
285         }
286 }
287
288 //______________________________________________________________________
289 void AliITSCalibrationSDD::Print(){
290   // Print SDD response Parameters
291
292   cout << "**************************************************" << endl;
293   cout << "   Silicon Drift Detector Response Parameters    " << endl;
294   cout << "**************************************************" << endl;
295   cout << "Hardware compression parameters: " << endl; 
296   cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
297   cout << "Baseline (ADC units): " << fBaseline[0] << endl;
298   cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
299   cout << "Temperature: " << Temperature() << " K " << endl;
300   cout << "Min. Value: " << fMinVal << endl;
301   PrintGains();
302
303 }