ITSV replaced with an assembly. (M. Sitta)
[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),
eefec958 44fIsBad(kFALSE),
028a3709 45fBadChannels(),
c9a38d3d 46fUseACorrMap(0),
47fUseTCorrMap(0),
028a3709 48fMapAW0(0),
49fMapAW1(0),
50fMapTW0(0),
18da6e54 51fMapTW1(0),
52fDrSpeed0(0),
53fDrSpeed1(0)
4bfbde86 54{
fcf95fc7 55 // default constructor
56
57 SetDeadChannels();
f45f6658 58 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
59 fBaseline[ian]=fgkBaselineDefault;
60 fNoise[ian]=fgkNoiseDefault;
eefec958 61 fGain[ian]=1.;
f45f6658 62 SetNoiseAfterElectronics(ian);
63 }
64 for(Int_t iw=0;iw<fgkWings;iw++){
65 for(Int_t icp=0;icp<fgkChips;icp++){
eefec958 66 Int_t chipindex=iw*fgkChips+icp;
67 fIsChipBad[chipindex]=kFALSE;
f45f6658 68 }
69 }
fcf95fc7 70 SetThresholds(fgkMinValDefault,0.);
71 SetTemperature(fgkTemperatureDefault);
c9a38d3d 72 SetUseCorrectionMaps(kTRUE,kTRUE);
fcf95fc7 73 SetDataType();
fcf95fc7 74 }
75//______________________________________________________________________
4bfbde86 76AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType):
77AliITSCalibration(),
78fDeadChips(0),
79fDeadChannels(0),
80fMinVal(fgkMinValDefault),
eefec958 81fIsBad(kFALSE),
028a3709 82fBadChannels(),
c9a38d3d 83fUseACorrMap(0),
84fUseTCorrMap(0),
028a3709 85fMapAW0(0),
86fMapAW1(0),
87fMapTW0(0),
18da6e54 88fMapTW1(0),
89fDrSpeed0(0),
90fDrSpeed1(0)
91{
fcf95fc7 92 // constructor
93
94 SetDeadChannels();
f45f6658 95 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
96 fBaseline[ian]=fgkBaselineDefault;
eefec958 97 fNoise[ian]=fgkNoiseDefault;
98 fGain[ian]=1.;
99 SetNoiseAfterElectronics(ian);
f45f6658 100 }
101 for(Int_t iw=0;iw<fgkWings;iw++){
102 for(Int_t icp=0;icp<fgkChips;icp++){
eefec958 103 Int_t chipindex=iw*fgkChips+icp;
104 fIsChipBad[chipindex]=kFALSE;
f45f6658 105 }
106 }
fcf95fc7 107
c9a38d3d 108
fcf95fc7 109 SetThresholds(fgkMinValDefault,0.);
110 SetTemperature(fgkTemperatureDefault);
c9a38d3d 111 SetUseCorrectionMaps(kTRUE,kTRUE);
fcf95fc7 112 SetDataType(dataType);
fcf95fc7 113 }
028a3709 114//_____________________________________________________________________
115AliITSCalibrationSDD::~AliITSCalibrationSDD(){
fcf95fc7 116
028a3709 117 //destructor
118 if(fMapAW0) delete fMapAW0;
119 if(fMapAW1) delete fMapAW1;
120 if(fMapTW0) delete fMapTW0;
121 if(fMapTW1) delete fMapTW1;
18da6e54 122 if(fDrSpeed0) delete fDrSpeed0;
123 if(fDrSpeed1) delete fDrSpeed1;
028a3709 124}
fcf95fc7 125
126//______________________________________________________________________
f45f6658 127void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
fcf95fc7 128 // give compression param
129
f45f6658 130 cp[0]=(Int_t) fBaseline[ian];
131 cp[1]=(Int_t) fBaseline[ian];
132 cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
133 cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
134 cp[4]=0;
135 cp[5]=0;
136 cp[6]=0;
137 cp[7]=0;
fcf95fc7 138}
f45f6658 139//_____________________________________________________________________
140void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
141 //Set bad anode (set gain=0 for these channels);
fcf95fc7 142
f45f6658 143 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
f45f6658 144 fBadChannels[i]=anode;
eefec958 145 fGain[anode]=0;
4952f440 146}
c9a38d3d 147//______________________________________________________________________
148void AliITSCalibrationSDD::GetCorrections(Float_t z, Float_t x, Float_t &devz, Float_t &devx, AliITSsegmentationSDD* seg){
149 //correction of coordinates using the maps stored in the DB
150 Int_t nSide=seg->GetSideFromLocalX(x);
151 devz=0;
152 if(fUseACorrMap){
153 if(nSide==0) devz=fMapAW0->GetCorrection(z,x,seg);
154 else devz=fMapAW1->GetCorrection(z,x,seg);
155 }
156 devx=0;
157 if(fUseTCorrMap){
158 if(nSide==0) devx=fMapTW0->GetCorrection(z,x,seg);
159 else devx=fMapTW1->GetCorrection(z,x,seg);
160 }
161 return;
162}
fcf95fc7 163//______________________________________________________________________
164void AliITSCalibrationSDD::PrintGains() const{
165 //
166
167 if( GetDeadChips() == 0 &&
168 GetDeadChannels() == 0 )
169 return;
170
171 // Print Electronics Gains
172 cout << "**************************************************" << endl;
173 cout << " Print Electronics Gains " << endl;
174 cout << "**************************************************" << endl;
175
176 // Print SDD electronic gains
eefec958 177 for(Int_t ian=0; ian<fgkWings*fgkChips*fgkChannels;ian++){
178 printf("Gain for channel %d = %f\n",ian,fGain[ian]);
179 }
fcf95fc7 180}
e56160b8 181
fcf95fc7 182//______________________________________________________________________
183void AliITSCalibrationSDD::Print(){
184 // Print SDD response Parameters
185
186 cout << "**************************************************" << endl;
187 cout << " Silicon Drift Detector Response Parameters " << endl;
188 cout << "**************************************************" << endl;
189 cout << "Hardware compression parameters: " << endl;
f45f6658 190 cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
191 cout << "Baseline (ADC units): " << fBaseline[0] << endl;
192 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
fcf95fc7 193 cout << "Temperature: " << Temperature() << " K " << endl;
194 cout << "Min. Value: " << fMinVal << endl;
195 PrintGains();
196
5bfe44ce 197}