00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _OCS_ELEC_FILTER_HH_
00015 #define _OCS_ELEC_FILTER_HH_
00016
00017 #include "ocsOptSignal.hh"
00018 #include "ocsPhotodetector.hh"
00019
00020
00022
00030 enum typeElecFilter { NO_ELEC_FILTER = 0,
00031 GAUSSIAN = 1,
00032 BESSEL = 2,
00033 MEASURED = 3,
00034 INTEGRATE_AND_DUMP = 4,
00035 ANRITSU = 5,
00036 GAUSSIAN_AND_ANRITSU = 6};
00037
00038
00039 struct ElecFilterParam
00040 {
00041 int TypeElecFilter;
00042 int OrderElecFilter;
00043 double FreqFWHM_ElecFilter;
00044 double CenterFreqElecFilter;
00045 };
00046
00047
00048
00049 class ElecFilter
00050 {
00051 public:
00052 ElecFilter();
00053 void InitElecFilter(cfftw *fft2
00054 ,fftPowerMatrices sfftPM2
00055 , ElecFilterParam ElecFilter);
00056
00057 ElecFilter(string InFileName, Photodetector *oPhotodetector2);
00058
00059 ElecFilter(ElecFilter *oElecFilter2, Photodetector *oPhotodetector2);
00060
00063
00064 ElecFilter(string InFileName, Photodetector *oPhotodetector2,
00065 cplx * MeasuredFilterFreq2,bool ReadMeasuredFilterFlag);
00066
00067
00068 ElecFilter(string InFileName, cfftw *fft2,fftPowerMatrices sfftPM2);
00069
00070 void FilterElecSignal(void);
00071
00072 void SetPhotodetector(Photodetector *oPhotodetector2);
00073
00074
00075 string GetAnritsuFilterFileName(void)
00076 {return AnritsuFilterFileName;};
00077
00078 typeElecFilter GetTypeElecFilter(void)
00079 {return TypeElecFilter;};
00080
00081 int GetOrderElecFilter(void)
00082 {return OrderElecFilter;};
00083
00084 double GetCenterFreqElecFilter(void)
00085 {return CenterFreqElecFilter;};
00086
00087 double GetFreqFWHM_ElecFilter(void)
00088 {return FreqFWHM_ElecFilter;};
00089 cplx GetMeasuredFilterFreq(int ii)
00090 {return MeasuredFilterFreq[ii];};
00091 void SetFreqFWHM_ElecFilter(double FreqFWHM_ElecFilter2);
00092
00093 void Set_f_3dB_ElecFilter(double f_3dB_ElecFilter2);
00094
00095 double Get_f_3dB_ElecFilter(void)
00096 {return FreqFWHM_ElecFilter/2.;};
00097
00098 void WriteFreqPowerGaussianFilter(string OutFileName);
00099
00100
00101
00102
00103 void WriteTimePowerFilter(string OutFileName);
00104
00105 void WriteFreqPowerFilter(string OutFileName);
00106
00107 double ComputeMatchAndFilter(void);
00108
00109
00110 void GetClockRecoveryTime(BitString *oBitString);
00111 void WriteFreqCplxFilter(string OutFileName);
00112
00113 double GetCurrentEquivalentSpectralWidth(void);
00114 void WriteFilterImpulseResponse(string FileNameImpulseResponseTime,
00115 string FileNameImpulseResponseFreq);
00116
00117 int GetDebugLevel(void) {return DebugLevel;};
00118
00119
00120
00123
00124 double * AverageCurrentInBit;
00125
00126
00127
00128 private:
00129
00130 void ElectricalFilterB5(cplx *my_power_time,cfftw *fft,
00131 double omega_0, double fwhm_norm);
00132 void ElectricalFilterB4(cplx *my_power_time,cfftw *fft,
00133 double omega_0, double fwhm_norm);
00134 void ElectricalFilterGaussian(cplx *my_power_time,
00135 cfftw *fft, double omega_0,
00136 double fwhm_norm);
00137
00139
00140 void IntegrateAndDumpFilter(cplx *my_power_time,cfftw *fft);
00141
00144
00152 void ElectricalFilterMeasured(void);
00153
00155
00156 void ReadMeasuredFilterData(void);
00157
00158 void ReadMeasuredFilterData(cplx *MeasuredFilterFreq2);
00159
00160
00161 double GetPhase(double Frequency);
00162 void ReadElecPhase(string InFileName);
00163 void ReadElecPhasePaola(string InFileName);
00164
00165 double GetElecGain(double Frequency);
00166 void ReadElecGain(string InFileName);
00167
00168 double * xElecGain;
00169 double * yElecGain;
00170 double * y2ElecGain;
00171 double ElecGainStartFreq;
00172 double ElecGainStepFreq;
00173 int NumElecGainWidth;
00174
00175 string AnritsuFilterFileName;
00176
00177 double * xElecPhase;
00178 double * yElecPhase;
00179 double * y2ElecPhase;
00180 double ElecPhaseStartFreq;
00181 double ElecPhaseStepFreq;
00182 int NumElecPhaseWidth;
00183 int RunAnritsuFilter;
00184 void AnritsuFilter(cplx *my_power_time, cfftw *fft, double omega_0,
00185 double fwhm_norm);
00186 void AnritsuFilterPaola(cplx *my_power_time, cfftw *fft,
00187 double omega_0,
00188 double fwhm_norm);
00189 double GainPeak;
00190 double FreqGain3dB;
00191
00192 double splint( double *xa, double *ya, double *y2a, int n, double x);
00193 void spline(double *x, double *y, int n, double yp1, double ypn, double *y2);
00194 double GaussianSmooth(double *y, int Order, int N );
00195
00196
00197
00198
00200
00226 void IntegrateAndDumpFilter_OLD(void);
00227
00228 void AllocateMemoryForAverageCurrentinBit(void);
00229
00230 double GetAverageCurrentInTimeRange(double LeftTime,
00231 double RightTime);
00232
00233
00234
00235 cplx Bessel5(double omega, double omega_0, double FWHM);
00236 cplx Bessel4(double omega, double omega_0, double FWHM);
00237 double Gaussian(double omega, double omega_0, double FWHM);
00238
00240
00241 cplx IntegrateAndDump(double freq);
00242
00244
00245 void Time2Freq(void);
00246
00248
00249 void Freq2Time(void);
00250
00251
00252
00253 fftPowerMatrices sfftPM;
00254 cfftw *fft;
00255 int ObjectInitialized;
00256 int qtPoints;
00257
00258 double DeltaFreq, DeltaTime,FreqWindow, TimeWindow, BitLength;
00259 double ClockRecoveryTimeForIntegrateAndDump;
00260 int StringLength;
00261
00262
00264
00272 typeElecFilter TypeElecFilter;
00273 int OrderElecFilter;
00274 double FreqFWHM_ElecFilter;
00275
00276
00277
00278
00279 double CenterFreqElecFilter;
00280
00282
00284 string MeasuredElecFilterFileName;
00285
00287
00288 cplx * MeasuredFilterFreq;
00289 Photodetector *oPhotodetector;
00290
00291 int DebugLevel;
00292
00293
00294 };
00295
00296 #endif
00297
00298
00299
00300
00301
00302
00303