]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSCalibrationSDD.cxx
Coding conventions
[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   for(Int_t i=0;i<fgkChips*fgkChannels;i++){
58     for(Int_t j=0;j<fgkMapTimeNBin;j++){
59       fMapA[i][j]=0;
60       fMapT[i][j]=0;
61     }
62   }
63  }
64 //______________________________________________________________________
65 AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType){
66   // constructor
67
68   SetDeadChannels();
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   }
81
82   SetThresholds(fgkMinValDefault,0.);
83   SetTemperature(fgkTemperatureDefault);
84   SetDataType(dataType);
85   for(Int_t i=0;i<fgkChips*fgkChannels;i++){
86     for(Int_t j=0;j<fgkMapTimeNBin;j++){
87       fMapA[i][j]=0;
88       fMapT[i][j]=0;
89     }
90   }
91
92  }
93 //______________________________________________________________________
94 AliITSCalibrationSDD::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 //______________________________________________________________________
101 AliITSCalibrationSDD& 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 //______________________________________________________________________
109 void AliITSCalibrationSDD::GiveCompressParam(Int_t  cp[8],Int_t ian) const {
110   // give compression param
111
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;
120 }
121 //_____________________________________________________________________
122 void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
123   //Set bad anode (set gain=0 for these channels);
124
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 //_____________________________________________________________________
136 Bool_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 /*
149 //______________________________________________________________________
150 void 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; 
162   fBadChannels.Set(fDeadChannels);  
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();
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 }
230 */
231 //______________________________________________________________________
232 void 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 //______________________________________________________________________
255 void 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; 
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;
265   cout << "Temperature: " << Temperature() << " K " << endl;
266   cout << "Min. Value: " << fMinVal << endl;
267   PrintGains();
268
269 }