00001
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef TDSPSYMBOLGENERATOR_H
00019 #define TDSPSYMBOLGENERATOR_H
00020
00021 #include <TRandom.h>
00022 #include <TH1.h>
00023 #include <TH2.h>
00024 #include <Rtypes.h>
00025 #include <TDSPOutput1.h>
00026 #include <TDSPStatistics.h>
00027
00032
00033
00034 #define kDEFAULT_OPTIONS 0
00035
00036 #define NOT_DETECTED -1
00037
00038 #define NUMSYMBOLS64
00039
00040 class TDSPSymbolGenerator : public TDSPOutput1 {
00041
00042 private:
00043 Bool_t fAnalysed;
00044
00045 protected:
00046 UInt_t fDumpOptions;
00047 UInt_t fOptions;
00048 #ifdef NUMSYMBOLS64
00049 Long64_t fAnalyseGrid;
00050 Long64_t fNumAnalysed;
00051 #else
00052 UInt_t fAnalyseGrid;
00053 UInt_t fNumAnalysed;
00054 #endif
00055 Int_t fNumSymbols;
00056 Double_t *fProbs;
00057
00058 Double_t *fDetectSigmas;
00059
00060 TDSPSignal *fDecisionSignal;
00061
00062 Int_t fNumISymbols;
00063 Int_t fNumISymbolsAlloc;
00064 Int_t *fISymbols;
00065 Double_t *fDetectProbs;
00066
00067
00068 TComplex fGlobalCorrection;
00069 TComplex fCorrection;
00070 UInt_t fCorrectionTrackingInterval;
00071 UInt_t fCorrectionTrackingIndex;
00072 TDSPSignal* fReferenceSignal;
00073
00074 TString Slot_Generate;
00075 TString Slot_Update;
00076 TString Slot_ReferenceUpdate;
00077
00078 void NormalizeProbs();
00079
00080
00081 virtual void BookSymbols(Int_t num);
00082 virtual void InitSymbols() = 0;
00083
00084
00085
00086
00087 virtual void GenerateSymbols(Int_t, TComplex*);
00088 virtual Int_t GenerateSymbol(TComplex*);
00089
00090 virtual Int_t DetectSymbol(TComplex&);
00091
00092 void Analyse_Reset();
00093 void Analyse_Finish();
00094 void Analyse_Symbol(Int_t,TComplex*,
00095 Int_t,TComplex*);
00096
00097
00098
00099
00100 Double_t fMinDistance;
00101 Double_t fMeanDistance;
00102 Double_t fVarianceDistance;
00103 Double_t fQWeightedDistance;
00104 Double_t fQWeightedVarianceDistance;
00105
00106 void _calc_distances();
00107 void _check_distances();
00108 Bool_t _recalc_distances;
00109
00110 void DumpStep();
00111
00112 public:
00113
00114 TComplex *fSymbols;
00115
00116 Int_t *fYields;
00117 Int_t fMisIdentified;
00118 Double_t fInEfficiency;
00119 Double_t fdInEfficiency;
00120
00121 Double_t fNoisePower;
00122 Double_t fSignalPower;
00123 Double_t fReceivedPower;
00124 TComplex fAttentuation;
00125 Double_t fSINR;
00126 Double_t fLogSER;
00127 Double_t fdLogSER;
00128
00129
00130
00131
00132 TDSPSymbolGenerator(char *name,
00133 Int_t,
00134 UInt_t = kDEFAULT_OPTIONS);
00135
00136 ~TDSPSymbolGenerator();
00137
00138
00139
00140
00141 virtual Double_t SER(Double_t SNR);
00142 Double_t LogSER_dB(Double_t SNRdB);
00143 TComplex* GetSymbols() const { return fSymbols;};
00144
00145
00146 UInt_t GetNumSymbols() { return fNumSymbols;};
00147 void SetAnalyseGrid(UInt_t a);
00148 void SetSignalLength(Int_t num);
00149 void ReduceSignalLength(Int_t num);
00150 Int_t GetSignalLength() { return fNumISymbols;};
00151 Bool_t IsAnalysed() { return fAnalysed; };
00152 void SetOption(Option_t*);
00153
00154 Double_t GetSignalPower() { return fSignalPower/fNumAnalysed;};
00155 Double_t GetReceivedPower() { return fReceivedPower/fNumAnalysed;};
00156 Double_t GetIntNoisePower() { return fNoisePower/fNumAnalysed;};
00157 Double_t GetSINR() { return fSignalPower/fNoisePower;};
00158 TComplex GetAttentuation() { return fAttentuation/Double_t(fNumAnalysed);};
00159
00160 Double_t GetDistance(Option_t *opt);
00161
00162 TDSPSignal* GetDecisionSignal();
00163
00164
00165
00166 TComplex& GetGlobalCorrection() { return fGlobalCorrection;};
00167 void SetGlobalCorrection(TComplex c) { fGlobalCorrection=c;};
00168
00169
00170
00171
00172 TComplex& GetCorrection() { return fCorrection;};
00173 void SetCorrection(TComplex c) { fCorrection=c;};
00174
00175 UInt_t GetCorrectionTrackingInterval() const { return fCorrectionTrackingInterval;};
00176 void SetCorrectionTrackingInterval(UInt_t i) { fCorrectionTrackingInterval=i;};
00177
00178 UInt_t EstimateNumSymbols(Double_t dError,
00179 UInt_t d,
00180 eEstimateNumSymbols method,
00181 UInt_t min=0);
00182
00183 UInt_t EstimateNumSymbols(Double_t dError,
00184 UInt_t d = 10000,
00185 char *method = "",
00186 UInt_t min=0);
00187
00188
00189
00190 void Generate();
00191 TDSPSignal *Update(TDSPSignal*);
00192 void ReferenceUpdate(TDSPSignal*s) { fReferenceSignal=s;};
00193
00194 ClassDef(TDSPSymbolGenerator,1)
00195
00196 };
00197
00198
00199
00200 inline Int_t TDSPSymbolGenerator::GenerateSymbol(TComplex *c) {
00201 Double_t fR = gRandom->Rndm();
00202 Double_t prob = 0;
00203
00204 for(Int_t i=0;i<fNumSymbols;i++) {
00205 prob += fProbs[i];
00206 if (fR < prob) {*c = fSymbols[i];return i;};
00207 }
00208
00209
00210
00211
00212
00213 Error("GenerateSymbol","(..) - Unnormal case fR = %f, prob = %f\n",
00214 fR,prob);
00215
00216 *c = fSymbols[fNumSymbols-1];
00217
00218 return fNumSymbols-1;
00219 }
00220
00221 inline Int_t TDSPSymbolGenerator::DetectSymbol(TComplex& s) {
00222
00223 Double_t len,s1;
00224 Double_t max_lik = 0;
00225
00226 Int_t detected = NOT_DETECTED;
00227
00228
00229
00230 for(register Int_t i=0;i<fNumSymbols;i++) {
00231
00232 len=Abs(s-fSymbols[i]);
00233 len*=-len;
00234
00235 s1=2*fDetectSigmas[i];
00236 s1*=s1;
00237
00238 fDetectProbs[i] = TMath::Exp(len/s1);
00239
00240 if (fDetectProbs[i]>max_lik) {
00241 detected = i;
00242 max_lik = fDetectProbs[i];
00243 } else
00244 if (fDetectProbs[i] == max_lik) {
00245 detected = NOT_DETECTED;
00246 }
00247 }
00248
00249
00250 return detected;
00251
00252 }
00253
00254
00255
00256 inline void TDSPSymbolGenerator::GenerateSymbols(Int_t num,
00257 TComplex *c) {
00258 Int_t *sym = fISymbols;
00259 for(register Int_t i=num;i;--i)
00260 *(sym++) = GenerateSymbol(c++);
00261 }
00262
00263
00264
00265 inline Double_t TDSPSymbolGenerator::LogSER_dB(Double_t SNRdB) {
00266 Double_t s=TMath::Power(10,SNRdB/10);
00267 return TMath::Log10(SER(s));
00268 }
00269
00270
00271 TDSPSymbolGenerator* Modulator(Option_t *name, Int_t param = 0);
00272
00273 #endif