added class PFTPhaseCorrection which allows to calculate the phase optimzied real part of the Fourier transform. musrFT is already using it, for musrview it is still missing.

This commit is contained in:
2016-11-29 11:16:45 +01:00
parent 1e5bfb8216
commit f7834aaead
4 changed files with 339 additions and 60 deletions

View File

@ -30,8 +30,13 @@
#ifndef _PFOURIER_H_
#define _PFOURIER_H_
#include <vector>
using namespace std;
#include "fftw3.h"
#include "Minuit2/FCNBase.h"
#include "PMusr.h"
#define F_APODIZATION_NONE 1
@ -39,6 +44,52 @@
#define F_APODIZATION_MEDIUM 3
#define F_APODIZATION_STRONG 4
/**
* Re Fourier phase correction
*/
class PFTPhaseCorrection : public ROOT::Minuit2::FCNBase
{
public:
PFTPhaseCorrection(const Int_t minBin=-1, const Int_t maxBin=-1);
PFTPhaseCorrection(vector<Double_t> &reFT, vector<Double_t> &imFT, const Int_t minBin=-1, const Int_t maxBin=-1);
virtual ~PFTPhaseCorrection() {}
virtual Bool_t IsValid() { return fValid; }
virtual void Minimize();
virtual void SetGamma(const Double_t gamma) { fGamma = gamma; }
virtual void SetPh(const Double_t c0, const Double_t c1) { fPh_c0 = c0; fPh_c1 = c1; CalcPhasedFT(); CalcRealPhFTDerivative(); }
virtual Double_t GetGamma() { return fGamma; }
virtual Double_t GetPhaseCorrectionParam(UInt_t idx);
virtual Double_t GetMinimum();
private:
Bool_t fValid;
vector<Double_t> fReal; /// original real Fourier data set
vector<Double_t> fImag; /// original imag Fourier data set
mutable vector<Double_t> fRealPh; /// phased real Fourier data set
mutable vector<Double_t> fImagPh; /// phased imag Fourier data set
mutable vector<Double_t> fRealPhD; /// 1st derivative of fRealPh
Double_t fMinBin; /// minimum bin from Fourier range to be used for the phase correction estimate
Double_t fMaxBin; /// maximum bin from Fourier range to be used for the phase correction estimate
mutable Double_t fPh_c0; /// constant part of the phase dispersion used for the phase correction
mutable Double_t fPh_c1; /// linear part of the phase dispersion used for the phase correction
Double_t fGamma; /// gamma parameter to balance between entropy and penalty
Double_t fMin; /// keeps the minimum of the entropy/penalty minimization
virtual void Init();
virtual void CalcPhasedFT() const;
virtual void CalcRealPhFTDerivative() const;
virtual Double_t Penalty() const;
virtual Double_t Entropy() const;
virtual Double_t Up() const { return 1.0; }
virtual Double_t operator()(const vector<Double_t>&) const;
};
/**
* muSR Fourier class.
*/
@ -57,7 +108,7 @@ class PFourier
virtual Double_t GetResolution() { return fResolution; }
virtual Double_t GetMaxFreq();
virtual TH1F* GetRealFourier(const Double_t scale = 1.0);
virtual TH1F* GetPhaseOptRealFourier(Double_t &phase, const Double_t scale = 1.0, const Double_t min = -1.0, const Double_t max = -1.0);
virtual TH1F* GetPhaseOptRealFourier(vector<Double_t> &phase, const Double_t scale = 1.0, const Double_t min = -1.0, const Double_t max = -1.0);
virtual TH1F* GetImaginaryFourier(const Double_t scale = 1.0);
virtual TH1F* GetPowerFourier(const Double_t scale = 1.0);
virtual TH1F* GetPhaseFourier(const Double_t scale = 1.0);
@ -85,6 +136,8 @@ class PFourier
fftw_complex *fIn; ///< real part of the Fourier transform
fftw_complex *fOut; ///< imaginary part of the Fourier transform
PFTPhaseCorrection *fPhCorrectedReFT;
virtual void PrepareFFTwInputData(UInt_t apodizationTag);
virtual void ApodizeData(Int_t apodizationTag);
};