Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

TDSPStatistics.h

Go to the documentation of this file.
00001 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
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() {}; // This function has really to change the Representation
00062 
00063   
00064  public: 
00065   
00066   TDSPStochasticProcess();
00067   virtual ~TDSPStochasticProcess();
00068 
00069   void     SetMode(eStochasticType mode) { fMode = mode;}; // Set the Stochatistic Mode                   
00070   Int_t    GetMode(eStochasticType mode) { return fMode;}; // Get the Stochatistic Mode 
00071     
00072 
00073   Bool_t    SetRepresentation(Double_t rate=1);   
00074 
00075   void     SetMean(Double_t  mean)                    // same as SetMeans(s);
00076     { fMeans[0]  = mean;};
00077   void     SetSigma(Double_t sigma)                   // same as SetSigmas(s);
00078     { fSigmas[0] = TComplex(sigma,sigma);};         
00079   void     SetSigmas(Double_t sigma, Int_t index = 0) // Set equal real/imag Sigmas for Gaussian Process
00080     { fSigmas[index] = TComplex(sigma,sigma); };   
00081   void     SetSigmas(TComplex sigma, Int_t index = 0) // Set diff  real/imag Sigmas for Gaussian Process
00082     { fSigmas[index] = sigma; };  
00083   void     SetMeans(Double_t mean,   Int_t index = 0) // Set real Means for Gaussian Process
00084     { fMeans[index] = mean; };   
00085   void     SetMeans(TComplex mean, Int_t index = 0)  // Set complex Means for Gaussian Process
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];}; // Get Sigmas for Gaussian Process
00092   TComplex GetMeans(  Int_t index = 0) { return fMeans[index];};  // Get Means for Gaussian Process
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;      // The actual Representation of the Scalar 
00106   TDSPFifoFilter* fFifoFilter; // Fifo Filter for correlated output
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,                // the SER
00134                    Double_t dError,             // the Error
00135                    UInt_t Default,              // the Default Value
00136                    eEstimateNumSymbols method,  // the Method
00137                    UInt_t Min=0                 // Minimum Number
00138                    );
00139   static UInt_t   EstimateNumSymbols(Double_t SER,    // the SER
00140                      Double_t dError, // the Error
00141                      UInt_t Default,  // the Default Value (for SER=0)
00142                      char *method,    // the Method
00143                      UInt_t Min=0     // Minimum Number
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     // Syncronize the required rate with the rate of the Filter
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:  // No Phase Change (=Coherent Detection is possible)
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   // Prepare the Rating of the Stochastic Process 
00222   // to use the the given rating "rate" of the input signal
00223   //
00224   PrepareRate(rate);
00225   
00226   // Do we have to change the Representation now ?
00227   //
00228 
00229   if ((RepresentationChanged = IsRate())) ChangeRepresentation();
00230   
00231   // Next Entry
00232   //
00233   
00234   Next();
00235 
00236 
00237   return RepresentationChanged; 
00238 
00239 }
00240 
00241 #endif

Generated on Fri Apr 23 16:23:43 2004 by doxygen 1.3.2