]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSCalibrationSDD.cxx
HLT build system fix
[u/mrichter/AliRoot.git] / ITS / AliITSCalibrationSDD.cxx
CommitLineData
fcf95fc7 1/**************************************************************************
c2bd28b6 2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
fcf95fc7 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
c2bd28b6 16/* $Id$ */
fcf95fc7 17
18#include <Riostream.h>
19#include <TRandom.h>
20#include "AliITSCalibrationSDD.h"
f45f6658 21#include "AliLog.h"
fcf95fc7 22
23//////////////////////////////////////////////////////
24// Calibration class for set:ITS //
25// Specific subdetector implementation //
26// for silicon drift detectors //
27// //
28// //
29//////////////////////////////////////////////////////
30
4bfbde86 31const Float_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
32const Float_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
33const Float_t AliITSCalibrationSDD::fgkGainDefault = 1.;
34const Float_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
35const Float_t AliITSCalibrationSDD::fgkMinValDefault = 4;
fcf95fc7 36//______________________________________________________________________
37ClassImp(AliITSCalibrationSDD)
38
4bfbde86 39AliITSCalibrationSDD::AliITSCalibrationSDD():
40AliITSCalibration(),
41fDeadChips(0),
42fDeadChannels(0),
43fMinVal(fgkMinValDefault),
44fIsDead(kFALSE),
028a3709 45fBadChannels(),
46fMapAW0(0),
47fMapAW1(0),
48fMapTW0(0),
49fMapTW1(0)
4bfbde86 50{
fcf95fc7 51 // default constructor
52
53 SetDeadChannels();
f45f6658 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 }
fcf95fc7 65 SetThresholds(fgkMinValDefault,0.);
66 SetTemperature(fgkTemperatureDefault);
67 SetDataType();
c2bd28b6 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.;
5bfe44ce 73 }
fcf95fc7 74 }
75//______________________________________________________________________
4bfbde86 76AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType):
77AliITSCalibration(),
78fDeadChips(0),
79fDeadChannels(0),
80fMinVal(fgkMinValDefault),
81fIsDead(kFALSE),
028a3709 82fBadChannels(),
83fMapAW0(0),
84fMapAW1(0),
85fMapTW0(0),
86fMapTW1(0){
fcf95fc7 87 // constructor
88
89 SetDeadChannels();
f45f6658 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 }
fcf95fc7 101
fcf95fc7 102 SetThresholds(fgkMinValDefault,0.);
103 SetTemperature(fgkTemperatureDefault);
104 SetDataType(dataType);
c2bd28b6 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.;
5bfe44ce 110 }
fcf95fc7 111 }
028a3709 112//_____________________________________________________________________
113AliITSCalibrationSDD::~AliITSCalibrationSDD(){
fcf95fc7 114
028a3709 115 //destructor
116 if(fMapAW0) delete fMapAW0;
117 if(fMapAW1) delete fMapAW1;
118 if(fMapTW0) delete fMapTW0;
119 if(fMapTW1) delete fMapTW1;
120
121}
fcf95fc7 122
123//______________________________________________________________________
f45f6658 124void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
fcf95fc7 125 // give compression param
126
f45f6658 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;
fcf95fc7 135}
f45f6658 136//_____________________________________________________________________
137void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
138 //Set bad anode (set gain=0 for these channels);
fcf95fc7 139
f45f6658 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}
c2bd28b6 150//_____________________________________________________________________
151void 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
f45f6658 162//_____________________________________________________________________
163Bool_t AliITSCalibrationSDD::IsBadChannel(Int_t anode){
164 //returns kTRUE if the anode i (0-512) has fGain=0
165 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
166 Int_t wing=0;
167 Int_t chip,channel;
168 chip=anode/fgkChannels;
169 channel=anode-(chip*fgkChannels);
170 if(anode>=fgkChips*fgkChannels) wing=1;
171 if(wing==1)chip-=fgkChips;
172 if(fGain[wing][chip][channel]==0) return kTRUE;
173 else return kFALSE;
174}
175/*
fcf95fc7 176//______________________________________________________________________
177void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
178 // Set fGain to zero to simulate a random distribution of
179 // dead modules, dead chips and single dead channels
180
181 for( Int_t m=0; m<fgkWings; m++ )
182 for( Int_t n=0; n<fgkChips; n++ )
183 for( Int_t p=0; p<fgkChannels; p++ )
184 fGain[m][n][p] = 1.;
185
186 //fDeadModules = nmod;
187 fDeadChips = nchip;
188 fDeadChannels = nchan;
f45f6658 189 fBadChannels.Set(fDeadChannels);
fcf95fc7 190 // nothing to do
191 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
192
193 if( nchip == 0 && nchan == 0 ) return;
194 // if( nmod < 0 || nmod > fgkModules )
195 // {
196 // cout << "Wrong number of dead modules: " << nmod << endl;
197 // return;
198 // }
199
200 Int_t nmax = fgkWings*fgkChips;
201 if( nchip < 0 || nchip > nmax )
202 {
203 cout << "Wrong number of dead chips: " << nchip << endl;
204 return;
205 }
206 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
207 if( nchan < 0 || nchan > nmax )
208 {
209 cout << "Wrong number of dead channels: " << nchan << endl;
210 return;
211 }
212
213 TRandom *gran = new TRandom();
fcf95fc7 214 // cout << "chips" << endl;
215 Int_t * chip = new Int_t[nchip];
216 Int_t i = 0;
217 while( i < nchip )
218 {
219 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
220 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
221
222 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
223 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
224 i++;
225 chip[i-1] = chi;
226 for( Int_t m=0; m<fgkChannels; m++ )
227 fGain[wing-1][chi-1][m] = 0.;
228 }
229
230 Int_t * channel = new Int_t[nchan];
231 Int_t * channelChip = new Int_t[nchan];
232 i = 0;
233 while( i < nchan )
234 {
235 Int_t k; //loop variable
236 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
237 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
238 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
239 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
240 Int_t flagChip = 0;
241 for( k=0; k<nchip; k++)
242 if( chipp == chip[k] ) {
243 flagChip = 1; break; }
244 if( flagChip == 1 ) continue;
245 i++;
246 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
247 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
248 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
249 channelChip[i-1] = chipp;
250 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
251 }
252
253 delete [] chip;
254 delete [] channel;
255 delete [] channelChip;
256}
f45f6658 257*/
fcf95fc7 258//______________________________________________________________________
259void AliITSCalibrationSDD::PrintGains() const{
260 //
261
262 if( GetDeadChips() == 0 &&
263 GetDeadChannels() == 0 )
264 return;
265
266 // Print Electronics Gains
267 cout << "**************************************************" << endl;
268 cout << " Print Electronics Gains " << endl;
269 cout << "**************************************************" << endl;
270
271 // Print SDD electronic gains
272 for(Int_t t=0; t<fgkWings;t++)
273 for(Int_t u=0; u<fgkChips;u++)
274 for(Int_t v=0; v<fgkChannels;v++)
275 {
276 if( fGain[t][u][v] != 1.0 )
277 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
278 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
279 }
280}
e56160b8 281
fcf95fc7 282//______________________________________________________________________
283void AliITSCalibrationSDD::Print(){
284 // Print SDD response Parameters
285
286 cout << "**************************************************" << endl;
287 cout << " Silicon Drift Detector Response Parameters " << endl;
288 cout << "**************************************************" << endl;
289 cout << "Hardware compression parameters: " << endl;
f45f6658 290 cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
291 cout << "Baseline (ADC units): " << fBaseline[0] << endl;
292 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
fcf95fc7 293 cout << "Temperature: " << Temperature() << " K " << endl;
294 cout << "Min. Value: " << fMinVal << endl;
295 PrintGains();
296
5bfe44ce 297}