00001
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef TDSPSTATISTICS_H
00019 #define TDSPSTATISTICS_H
00020 #include <Rtypes.h>
00021 #include <TError.h>
00022 #include <TRandom.h>
00023 #include <TComplex.h>
00024 #include <TDSPRating.h>
00025 #include <TDSPFifoFilter.h>
00026
00027
00032 enum eStochasticType {
00033 kNoChange,
00034 kGauss,
00035 kRayleigh,
00036 kFilterGauss,
00037 kFilterRayleigh
00038 };
00039
00040 enum eEstimateNumSymbols {
00041 kEstimateSER,
00042 kEstimateSERlog,
00043 kEstimatedSERlog
00044 };
00045
00046 #include "TDSPSymbolGenerator.h"
00047
00048 class TDSPSymbolGenerator;
00049
00050
00051 class TDSPStochasticProcess : public TDSPRating {
00052
00053 protected:
00054
00055 eStochasticType fMode;
00056
00057 TComplex *fSigmas;
00058 TComplex *fMeans;
00059
00060
00061 virtual void ChangeRepresentation() {};
00062
00063
00064 public:
00065
00066 TDSPStochasticProcess();
00067 virtual ~TDSPStochasticProcess();
00068
00069 void SetMode(eStochasticType mode) { fMode = mode;};
00070 Int_t GetMode(eStochasticType mode) { return fMode;};
00071
00072
00073 Bool_t SetRepresentation(Double_t rate=1);
00074
00075 void SetMean(Double_t mean)
00076 { fMeans[0] = mean;};
00077 void SetSigma(Double_t sigma)
00078 { fSigmas[0] = TComplex(sigma,sigma);};
00079 void SetSigmas(Double_t sigma, Int_t index = 0)
00080 { fSigmas[index] = TComplex(sigma,sigma); };
00081 void SetSigmas(TComplex sigma, Int_t index = 0)
00082 { fSigmas[index] = sigma; };
00083 void SetMeans(Double_t mean, Int_t index = 0)
00084 { fMeans[index] = mean; };
00085 void SetMeans(TComplex mean, Int_t index = 0)
00086 { fMeans[index] = mean; };
00087
00088 virtual Double_t SER(Double_t SNR, TDSPSymbolGenerator*);
00089
00090
00091 TComplex GetSigmas( Int_t index = 0) { return fSigmas[index];};
00092 TComplex GetMeans( Int_t index = 0) { return fMeans[index];};
00093
00094 virtual void Reset() = 0;
00095
00096 ClassDef(TDSPStochasticProcess,0)
00097 };
00098
00099
00100 class TDSPStochasticScalar : public TDSPStochasticProcess {
00101
00102
00103 protected:
00104
00105 TComplex fValue;
00106 TDSPFifoFilter* fFifoFilter;
00107
00108 public:
00109
00110
00111 TDSPStochasticScalar();
00112 virtual ~TDSPStochasticScalar();
00113
00114 void SetMode(eStochasticType mode);
00115 TComplex& Value() { return fValue; };
00116 virtual void ChangeRepresentation();
00117
00118 void SetFifoFilter(TDSPFifoFilter* f) { fFifoFilter = f;};
00119 TDSPFifoFilter* GetFifoFilter() const { return fFifoFilter; };
00120
00121 virtual void PrepareRate(Double_t rate);
00122
00123 virtual void Reset();
00124
00125 ClassDef(TDSPStochasticScalar,1)
00126 };
00127
00128
00129 class TDSPStatistics {
00130
00131 public:
00132
00133 static UInt_t EstimateNumSymbols(Double_t SER,
00134 Double_t dError,
00135 UInt_t Default,
00136 eEstimateNumSymbols method,
00137 UInt_t Min=0
00138 );
00139 static UInt_t EstimateNumSymbols(Double_t SER,
00140 Double_t dError,
00141 UInt_t Default,
00142 char *method,
00143 UInt_t Min=0
00144 );
00145
00146
00147 ClassDef(TDSPStatistics,0)
00148 };
00149
00150
00151
00152 inline void TDSPStochasticScalar::PrepareRate(Double_t rate) {
00153
00154 switch(fMode) {
00155 case kFilterGauss:
00156 case kFilterRayleigh:
00157
00158
00159 TDSPStochasticProcess::PrepareRate(rate*fFifoFilter->GetRate());
00160
00161 break;
00162 default:
00163 TDSPStochasticProcess::PrepareRate(rate);
00164 break;
00165 }
00166 }
00167
00168
00169
00170 inline void TDSPStochasticScalar::ChangeRepresentation() {
00171
00172 switch(fMode) {
00173
00174 case kNoChange:
00175 fValue = 1;
00176 break;
00177
00178 case kGauss:
00179 fValue = TComplex(gRandom->Gaus(fMeans->fRe,fSigmas->fRe), gRandom->Gaus(fMeans->fIm,fSigmas->fIm));
00180 break;
00181
00182 case kRayleigh:
00183 fValue = Abs(TComplex(gRandom->Gaus(fMeans->fRe,fSigmas->fRe), gRandom->Gaus(fMeans->fIm,fSigmas->fIm)));
00184 break;
00185
00186 case kFilterGauss:
00187 if (fFifoFilter) {
00188 fValue = TComplex(gRandom->Gaus(fMeans->fRe,fSigmas->fRe),
00189 gRandom->Gaus(fMeans->fIm,fSigmas->fIm));
00190 fValue = fFifoFilter->filter(fValue);
00191 } else {
00192 Error("ChangeRepresentation","No FifoFilter set !!");
00193 fValue=0;
00194 }
00195 break;
00196
00197 case kFilterRayleigh:
00198 if (fFifoFilter) {
00199 fValue = TComplex(gRandom->Gaus(fMeans->fRe,fSigmas->fRe),
00200 gRandom->Gaus(fMeans->fIm,fSigmas->fIm));
00201 fValue = Abs(fFifoFilter->filter(fValue));
00202 } else {
00203 Error("ChangeRepresentation","No FifoFilter set !!");
00204 fValue=0;
00205 }
00206 break;
00207
00208 default:
00209 Error("ChangeRepresentation","Unknown Stochastic Model!");
00210 fValue = TComplex(0,0);
00211 break;
00212
00213 }
00214
00215 }
00216
00217
00218 inline Bool_t TDSPStochasticProcess::SetRepresentation(Double_t rate) {
00219
00220 Bool_t RepresentationChanged = kFALSE;
00221
00222
00223
00224 PrepareRate(rate);
00225
00226
00227
00228
00229 if ((RepresentationChanged = IsRate())) ChangeRepresentation();
00230
00231
00232
00233
00234 Next();
00235
00236
00237 return RepresentationChanged;
00238
00239 }
00240
00241 #endif