]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSetfSDD.cxx
addressing coverity warnings: now checking return value of fscanf
[u/mrichter/AliRoot.git] / ITS / AliITSetfSDD.cxx
CommitLineData
b0f5e3fc 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 **************************************************************************/
4ae5bbc4 15
88cb7938 16/* $Id$ */
b9d0a01d 17
ee523d3a 18
4ae5bbc4 19#include <Riostream.h>
b0f5e3fc 20#include <TMath.h>
21#include "AliITSetfSDD.h"
22
23////////////////////////////////////////////////////////////////////////
24// Version: 0
25// Written by Piergiorgio Cerello
26// November 23 1999
ee523d3a 27// Revised to comply with coding conventions: Nov, 21 2003 m.m.
b0f5e3fc 28//_____________________________________________________________________________
b669392e 29
30
b0f5e3fc 31ClassImp(AliITSetfSDD)
32
ee523d3a 33const Int_t AliITSetfSDD::AliITSetfSDDparam::fgkMaxNofPoles = 5;
34const Int_t AliITSetfSDD::AliITSetfSDDparam::fgkMaxNofSamples = 1024;
35
7537d03c 36AliITSetfSDD::AliITSetfSDD():
37fTimeDelay(0),
38fSamplingTime(0),
39fT0(0),
40fDf(0.),
41fA0(0.) ,
42fZeroM(0),
43fZeroR(0),
44fZeroI(0),
45fPoleM(0),
46fPoleR(0),
47fPoleI(0),
48fTfR(0),
49fTfI(0),
50fWR(0),
51fWI(0){
ee523d3a 52 // Default constructor
ee523d3a 53}
54
7537d03c 55AliITSetfSDD::AliITSetfSDD(Double_t timestep, Int_t amplif):
56fTimeDelay(0),
57fSamplingTime(0),
58fT0(0),
59fDf(0.),
60fA0(0.) ,
61fZeroM(0),
62fZeroR(0),
63fZeroI(0),
64fPoleM(0),
65fPoleR(0),
66fPoleI(0),
67fTfR(0),
68fTfI(0),
69fWR(0),
70fWI(0)
b0f5e3fc 71{
ee523d3a 72 // Standard constructor. sampling time in ns
e8189707 73
ee523d3a 74 /*
75 cout<<"Number of poles: "<<AliITSetfSDDparam::NumberOfPoles()<<endl;
76 cout<<"Number of samples: "<<AliITSetfSDDparam::NumberOfSamples()<<endl;
77 */
11ad066f 78 fTimeDelay = 53.5;
79 if(amplif == 2) fTimeDelay = 35.5;
e8189707 80 fSamplingTime = timestep;
8343dab6 81 Double_t xGiga=1.0E+9;
b0f5e3fc 82 fT0 = 0.;
8343dab6 83 fDf = xGiga/(AliITSetfSDDparam::NumberOfSamples()*fSamplingTime);
e8189707 84 Int_t i,j;
ee523d3a 85 fZeroM = new Double_t[AliITSetfSDDparam::NumberOfPoles()];
86 fZeroR = new Double_t [AliITSetfSDDparam::NumberOfPoles()];
87 fZeroI = new Double_t [AliITSetfSDDparam::NumberOfPoles()];
88 fPoleM = new Double_t [AliITSetfSDDparam::NumberOfPoles()];
89 fPoleR = new Double_t [AliITSetfSDDparam::NumberOfPoles()];
90 fPoleI = new Double_t [AliITSetfSDDparam::NumberOfPoles()];
91 fTfR = new Double_t [AliITSetfSDDparam::NumberOfSamples()];
92 fTfI = new Double_t [AliITSetfSDDparam::NumberOfSamples()];
93 fWR = new Double_t [AliITSetfSDDparam::NumberOfSamples()];
94 fWI = new Double_t [AliITSetfSDDparam::NumberOfSamples()];
95
96 for(i=0; i<AliITSetfSDDparam::NumberOfPoles(); i++) {
e8189707 97 fZeroM[i] = 0.;
98 fZeroR[i] = 0.;
99 fZeroI[i] = 0.;
100 fPoleM[i] = 0.;
101 fPoleR[i] = 0.;
102 fPoleI[i] = 0.;
b0f5e3fc 103 }
11ad066f 104 // Alice
105
48058160 106 // PASCAL amplif
107 fA0 = 5.53269815e+11;
108 fPoleM[0] = 3.;
109 fPoleR[0] = -8280000.;
110 fPoleI[0] = 0.;
111
112 if(amplif == 2) { // OLA amplif.
113 fA0 = 24000.;
114 fPoleM[0] = 1.;
11ad066f 115 fPoleR[0] = -3000000.;
116 fPoleI[0] = 4000000.;
48058160 117 fPoleM[1] = 1.;
118 fPoleR[1] = fPoleR[0];
119 fPoleI[1] = -fPoleI[0];
120 }
121
122 if( amplif == 3 ) { // old PASCAL
123 fA0 = 16500.; // AL: 16500.; // TB: 24000.; // 26000.; // 24000.; // 18000.;
124 fPoleM[0] = 1.;
125 fPoleR[0] = -4140000.; // AL: -4140000.; // TB: -3000000.; // -3750000.; // -3500000; // -3000000.;
126 fPoleI[0] = 0.; // AL: 0.; // TB: 4000000.; // 3750000.; // 3500000.; // 3000000.;
127 fPoleM[1] = 1.;
128 fPoleR[1] = fPoleR[0];
129 fPoleI[1] = -fPoleI[0];
11ad066f 130 }
b0f5e3fc 131
48058160 132 //cout << "fA0: " << fA0 << endl;
133 //cout << "fTimeDelay: " << fTimeDelay << endl;
134
11ad066f 135 // Compute Transfer Function
b0f5e3fc 136
ee523d3a 137 Double_t pigr = acos(-1.);
138 for(i=0; i<=AliITSetfSDDparam::NumberOfSamples()/2; i++) {
b0f5e3fc 139 Double_t frequency = fDf*i;
ee523d3a 140 Double_t vVM = fA0;
141 Double_t vVA = 0.;
142 for(Int_t k=0; k<AliITSetfSDDparam::NumberOfPoles(); k++) {
e8189707 143 if(fZeroM[k]) {
ee523d3a 144 Double_t vVZR = -fZeroR[k];
145 Double_t vVZI = frequency - fZeroI[k];
146 Double_t vVZM = TMath::Sqrt(vVZR*vVZR+vVZI*vVZI);
147 Double_t vVZA = TMath::ATan2(vVZI,vVZR);
148 // cout << "VZM: " << vVZM << ", VZA: " << vVZA << endl;
149 // cout << "VZR: " << vVZR << ", VZI: " << vVZI << endl;
e8189707 150 for(j=1; j<= (Int_t) fZeroM[k]; j++) {
ee523d3a 151 vVM *= vVZM;
152 vVA += vVZA;
153 if(vVA >= pigr) vVA -= (2.*pigr);
154 if(vVA <= -pigr) vVA += (2.*pigr);
155 //cout << "vVM: " << vVM << ", VA: " << vVA << endl;
b0f5e3fc 156 }
157 }
158
e8189707 159 if(fPoleM[k]) {
ee523d3a 160 Double_t vVPR = -fPoleR[k];
161 Double_t vVPI = frequency - fPoleI[k];
162 Double_t vVPM = TMath::Sqrt(vVPR*vVPR+vVPI*vVPI);
163 Double_t vVPA = TMath::ATan2(vVPI,vVPR);
164 //cout << "VPM: " << vVPM << ", VPA: " << vVPA << endl;
165 //cout << "VPR: " << vVPR << ", VPI: " << vVPI << endl;
e8189707 166 for(j=1; j<= (Int_t) fPoleM[k]; j++) {
ee523d3a 167 vVM /= vVPM;
168 vVA -= vVPA;
169 if(vVA >= pigr) vVA -= (2.*pigr);
170 if(vVA <= -pigr) vVA += (2.*pigr);
171 //cout << "VM: " << vVM << ", vVA: " << vVA << endl;
b0f5e3fc 172 }
173 }
ee523d3a 174 Double_t vVR = vVM*cos(vVA);
175 Double_t vVI = vVM*sin(vVA);
176 //cout << "VM: " << vVM << ", VA: " << vVA << endl;
177 //cout << "VR: " << vVR << ", VI: " << vVI << endl;
8343dab6 178 fTfR[i] = vVR*xGiga;
179 fTfI[i] = vVI*xGiga;
e8189707 180 //cout << "fTfR[" << i << "] = " << fTfR[i] << endl;
181 //cout << "fTfI[" << i << "] = " << fTfI[i] << endl;
b0f5e3fc 182 if(i) {
ee523d3a 183 fTfR[AliITSetfSDDparam::NumberOfSamples()-i] = fTfR[i];
184 fTfI[AliITSetfSDDparam::NumberOfSamples()-i] = -fTfI[i];
b0f5e3fc 185 }
186 }
187 }
188
189 // Compute Fourier Weights
190
ee523d3a 191 for(i=0; i<=AliITSetfSDDparam::NumberOfSamples()/2; i++) {
192 fWR[i] = cos(-2.*pigr*i/AliITSetfSDDparam::NumberOfSamples());
193 fWI[i] = sin(-2.*pigr*i/AliITSetfSDDparam::NumberOfSamples());
b0f5e3fc 194 if(i) {
ee523d3a 195 fWR[AliITSetfSDDparam::NumberOfSamples()-i] = fWR[i];
196 fWI[AliITSetfSDDparam::NumberOfSamples()-i] = -fWI[i];
b0f5e3fc 197 }
198 }
199
200}
201
ee523d3a 202
203AliITSetfSDD::~AliITSetfSDD(){
204 // Destructor
205 if(fZeroM) delete []fZeroM;
206 if(fZeroR) delete []fZeroR;
207 if(fZeroI) delete []fZeroI;
208 if(fPoleM) delete []fPoleM;
209 if(fPoleR) delete []fPoleR;
210 if(fPoleI) delete []fPoleI;
211 if(fTfR) delete []fTfR;
212 if(fTfI) delete []fTfI;
213 if(fWR) delete []fWR;
214 if(fWI) delete []fWI;
215}
216
217void AliITSetfSDD::PrintElectronics() const {
218 // Printout of the parameters defining the f.e. electronics
219
11ad066f 220 cout << "Time Delay " << fTimeDelay << endl;
b0f5e3fc 221 cout << "Sampling Time " << fSamplingTime << endl;
ee523d3a 222 cout << "Number of Time Samples " << AliITSetfSDDparam::NumberOfSamples() << endl;
b0f5e3fc 223 cout << "fT0 " << fT0 << endl;
224 cout << "fDf " << fDf << endl;
225 cout << "fA0 " << fA0 << endl;
226
227 cout << "Zero's and Pole's" << endl;
e8189707 228 cout << "fZeroM " << endl;
229 Int_t i;
ee523d3a 230 for(i=0; i<AliITSetfSDDparam::NumberOfPoles(); i++) cout << fZeroM[i] << endl;
b0f5e3fc 231 cout << "fZero_R " << endl;
ee523d3a 232 for(i=0; i<AliITSetfSDDparam::NumberOfPoles(); i++) cout << fZeroR[i] << endl;
e8189707 233 cout << "fZeroI " << endl;
ee523d3a 234 for(i=0; i<AliITSetfSDDparam::NumberOfPoles(); i++) cout << fZeroI[i] << endl;
e8189707 235 cout << "fPoleM " << endl;
ee523d3a 236 for(i=0; i<AliITSetfSDDparam::NumberOfPoles(); i++) cout << fPoleM[i] << endl;
e8189707 237 cout << "fPoleR " << endl;
ee523d3a 238 for(i=0; i<AliITSetfSDDparam::NumberOfPoles(); i++) cout << fPoleR[i] << endl;
e8189707 239 cout << "fPoleI " << endl;
ee523d3a 240 for(i=0; i<AliITSetfSDDparam::NumberOfPoles(); i++) cout << fPoleI[i] << endl;
b0f5e3fc 241
242 cout << "Transfer function" << endl;
243 cout << "Real Part" << endl;
ee523d3a 244 for(i=0; i<AliITSetfSDDparam::NumberOfSamples(); i++) cout << fTfR[i] << endl;
b0f5e3fc 245 cout << "Imaginary Part " << endl;
ee523d3a 246 for(i=0; i<AliITSetfSDDparam::NumberOfSamples(); i++) cout << fTfI[i] << endl;
b0f5e3fc 247
248 cout << "Fourier Weights" << endl;
249 cout << "Real Part" << endl;
ee523d3a 250 for(i=0; i<AliITSetfSDDparam::NumberOfSamples(); i++) cout << fWR[i] << endl;
b0f5e3fc 251 cout << "Imaginary Part " << endl;
ee523d3a 252 for(i=0; i<AliITSetfSDDparam::NumberOfSamples(); i++) cout << fWI[i] << endl;
b0f5e3fc 253}
254
255
256
257
258
259
260
261