|
musrfit 1.10.0
|
#include <PFourier.h>


Public Member Functions | |
| PFTPhaseCorrection (const Int_t minBin=-1, const Int_t maxBin=-1) | |
| PFTPhaseCorrection (std::vector< Double_t > &reFT, std::vector< Double_t > &imFT, const Int_t minBin=-1, const Int_t maxBin=-1) | |
| virtual | ~PFTPhaseCorrection () |
| virtual Bool_t | IsValid () |
| virtual void | Minimize () |
| virtual void | SetGamma (const Double_t gamma) |
| virtual void | SetPh (const Double_t c0, const Double_t c1) |
| virtual Double_t | GetGamma () |
| virtual Double_t | GetPhaseCorrectionParam (UInt_t idx) |
| virtual Double_t | GetMinimum () |
Private Member Functions | |
| virtual void | Init () |
| keeps the minimum of the entropy/penalty minimization | |
| virtual void | CalcPhasedFT () const |
| virtual void | CalcRealPhFTDerivative () const |
| virtual Double_t | Penalty () const |
| virtual Double_t | Entropy () const |
| virtual Double_t | Up () const |
| virtual Double_t | operator() (const std::vector< Double_t > &) const |
Private Attributes | |
| Bool_t | fValid |
| std::vector< Double_t > | fReal |
| std::vector< Double_t > | fImag |
| original real Fourier data set | |
| std::vector< Double_t > | fRealPh |
| original imag Fourier data set | |
| std::vector< Double_t > | fImagPh |
| phased real Fourier data set | |
| std::vector< Double_t > | fRealPhD |
| phased imag Fourier data set | |
| Int_t | fMinBin |
| 1st derivative of fRealPh | |
| Int_t | fMaxBin |
| minimum bin from Fourier range to be used for the phase correction estimate | |
| Double_t | fPh_c0 |
| maximum bin from Fourier range to be used for the phase correction estimate | |
| Double_t | fPh_c1 |
| constant part of the phase dispersion used for the phase correction | |
| Double_t | fGamma |
| linear part of the phase dispersion used for the phase correction | |
| Double_t | fMin |
| gamma parameter to balance between entropy and penalty | |
Phase correction optimizer for Fourier transforms.
This class performs automatic phase correction on complex Fourier spectra to maximize the real component and minimize the imaginary component. Phase errors arise from:
Algorithm: Minimizes a combined entropy-penalty functional using Minuit2, finding optimal phase parameters (constant + linear dispersion): φ(ω) = c₀ + c₁·ω
Applications:
Usage: Specify frequency range for optimization to focus on signal peaks while avoiding noise regions.
Definition at line 84 of file PFourier.h.
| PFTPhaseCorrection::PFTPhaseCorrection | ( | const Int_t | minBin = -1, |
| const Int_t | maxBin = -1 ) |
Constructor for phase correction with default Fourier data.
| minBin | Minimum frequency bin for optimization (-1 = use all) |
| maxBin | Maximum frequency bin for optimization (-1 = use all) |
Default constructor for phase correction optimizer.
Initializes a phase correction object with default Fourier data. The actual Fourier data must be set externally before minimization.
| minBin | Minimum frequency bin index for optimization region. Use -1 to optimize over all bins. Default: -1. |
| maxBin | Maximum frequency bin index for optimization region. Use -1 to optimize over all bins. Default: -1. |
Note: Restricting the optimization range to signal-containing regions improves results by excluding noisy baseline regions.
Definition at line 67 of file PFourier.cpp.
| PFTPhaseCorrection::PFTPhaseCorrection | ( | std::vector< Double_t > & | reFT, |
| std::vector< Double_t > & | imFT, | ||
| const Int_t | minBin = -1, | ||
| const Int_t | maxBin = -1 ) |
Constructor with explicit Fourier data.
| reFT | Real part of Fourier transform |
| imFT | Imaginary part of Fourier transform |
| minBin | Minimum frequency bin for optimization |
| maxBin | Maximum frequency bin for optimization |
Constructor with explicit Fourier transform data.
Creates a phase correction optimizer with pre-computed Fourier data. The optimizer will find phase parameters φ(ω) = c₀ + c₁·ω that maximize the real component while minimizing the imaginary component.
| reFT | Real part of the Fourier transform (vector of amplitudes). |
| imFT | Imaginary part of the Fourier transform (vector of amplitudes). |
| minBin | Minimum frequency bin index for optimization region. Use -1 to optimize over all bins. Default: -1. |
| maxBin | Maximum frequency bin index for optimization region. Use -1 to optimize over all bins. Default: -1. |
Usage example:
Definition at line 100 of file PFourier.cpp.
References fImag, fImagPh, fMaxBin, fMinBin, fReal, fRealPh, and Init().
|
inlinevirtual |
Definition at line 105 of file PFourier.h.
|
privatevirtual |
Calculates phase-corrected Fourier transform.
Applies the phase correction φ(ω) = c₀ + c₁·(i/N) to the complex Fourier spectrum using rotation in the complex plane:
The corrected spectra are stored in fRealPh and fImagPh.
Physics: This rotation compensates for:
Definition at line 276 of file PFourier.cpp.
References fImag, fImagPh, fPh_c0, fPh_c1, fReal, and fRealPh.
Referenced by operator()(), and SetPh().
|
privatevirtual |
Calculates first derivative of phase-corrected real Fourier spectrum.
Computes the finite difference derivative: dF/dω ≈ F(i+1) - F(i) for all interior points. Boundary points are set to 1.0.
The derivative is used in the entropy calculation, where smooth spectra (small derivatives) have lower entropy and are preferred by the optimization algorithm.
Purpose: Entropy minimization favors phase corrections that produce smooth, well-resolved real spectra with minimal oscillations.
Definition at line 307 of file PFourier.cpp.
References fRealPh, and fRealPhD.
Referenced by operator()(), and SetPh().
|
privatevirtual |
Calculates Shannon entropy of the real spectrum derivative.
Computes: S = -Σ[p_i·ln(p_i)] where p_i = |dF/dω|_i / Σ|dF/dω|
This entropy measure quantifies the "smoothness" of the real Fourier spectrum:
Physical interpretation: Correct phase alignment produces sharp, well-defined peaks with smooth baselines, resulting in concentrated derivatives and low entropy.
Note: Small values (< 10⁻¹⁵) are skipped to avoid numerical issues with log(0).
Definition at line 376 of file PFourier.cpp.
References fMaxBin, fMinBin, and fRealPhD.
Referenced by operator()().
|
inlinevirtual |
Returns the gamma parameter
Definition at line 130 of file PFourier.h.
References fGamma.
|
virtual |
Returns the minimum value of the optimization functional
Returns the minimum value of the optimization functional.
This value represents the combined entropy-penalty functional at the optimal phase parameters. Lower values indicate better phase correction. A value of -1.0 indicates failed minimization.
Note: Always check IsValid() before using this value.
Definition at line 223 of file PFourier.cpp.
|
virtual |
Gets phase correction parameter.
| idx | Parameter index (0=c₀, 1=c₁) |
Retrieves optimized phase correction parameter by index.
Returns the phase parameter determined by Minimize(). The phase correction formula is: φ(ω) = c₀ + c₁·(ω/ω_max)
| idx | Parameter index:
|
Example:
Definition at line 195 of file PFourier.cpp.
References fPh_c0, and fPh_c1.
Referenced by PFourier::GetPhaseOptRealFourier().
|
privatevirtual |
keeps the minimum of the entropy/penalty minimization
Initializes phase correction object with default values.
Sets initial state:
Called by constructors to establish consistent initial state.
Definition at line 248 of file PFourier.cpp.
References fGamma, fMin, fPh_c0, fPh_c1, and fValid.
Referenced by PFTPhaseCorrection(), and PFTPhaseCorrection().
|
inlinevirtual |
Returns true if phase correction initialized successfully
Definition at line 109 of file PFourier.h.
References fValid.
Referenced by PFourier::GetPhaseOptRealFourier().
|
virtual |
Performs phase correction minimization.
Uses Minuit2 to find optimal phase parameters that maximize the real spectrum while minimizing imaginary components.
Performs phase correction minimization using Minuit2.
This method finds optimal phase parameters (c₀, c₁) by minimizing a combined entropy-penalty functional:
The phase correction is: φ(ω) = c₀ + c₁·ω where:
Algorithm:
After calling this method, use GetPhaseCorrectionParam() to retrieve the optimal phase parameters and IsValid() to check success.
Definition at line 144 of file PFourier.cpp.
References fMin, fPh_c0, fPh_c1, and fValid.
Referenced by PFourier::GetPhaseOptRealFourier().
|
privatevirtual |
Objective function for Minuit2 minimization (FCNBase interface).
Evaluates the combined entropy-penalty functional: f(c₀, c₁) = S + γ·P where:
| par | Parameter vector: [0]=c₀ (constant phase), [1]=c₁ (linear phase) |
Algorithm flow:
Called repeatedly by Minuit2 during optimization.
Definition at line 425 of file PFourier.cpp.
References CalcPhasedFT(), CalcRealPhFTDerivative(), Entropy(), fPh_c0, fPh_c1, and Penalty().
|
privatevirtual |
Calculates penalty term for negative real spectrum values.
Computes: P = γ·Σ[F_re(ω)² for all F_re(ω) < 0]
The penalty term penalizes negative values in the real Fourier spectrum, since physically meaningful absorption-mode spectra should be predominantly positive. The γ parameter controls the relative importance of this constraint.
Note: Only bins in range [fMinBin, fMaxBin) are considered, allowing focus on signal-containing regions.
Definition at line 339 of file PFourier.cpp.
References fGamma, fMaxBin, fMinBin, and fRealPh.
Referenced by operator()().
|
inlinevirtual |
Sets the gamma balancing parameter between entropy and penalty
| gamma | Balancing factor (typical range: 0.1 to 10) |
Definition at line 121 of file PFourier.h.
References fGamma.
|
inlinevirtual |
Sets phase correction parameters manually
| c0 | Constant phase offset in degrees |
| c1 | Linear phase dispersion coefficient |
Definition at line 126 of file PFourier.h.
References CalcPhasedFT(), CalcRealPhFTDerivative(), fPh_c0, and fPh_c1.
|
inlineprivatevirtual |
Definition at line 166 of file PFourier.h.
|
private |
linear part of the phase dispersion used for the phase correction
Definition at line 157 of file PFourier.h.
Referenced by GetGamma(), Init(), Penalty(), and SetGamma().
|
private |
original real Fourier data set
Definition at line 148 of file PFourier.h.
Referenced by CalcPhasedFT(), and PFTPhaseCorrection().
|
mutableprivate |
phased real Fourier data set
Definition at line 150 of file PFourier.h.
Referenced by CalcPhasedFT(), and PFTPhaseCorrection().
|
private |
minimum bin from Fourier range to be used for the phase correction estimate
Definition at line 154 of file PFourier.h.
Referenced by Entropy(), Penalty(), PFTPhaseCorrection(), and PFTPhaseCorrection().
|
private |
gamma parameter to balance between entropy and penalty
Definition at line 158 of file PFourier.h.
Referenced by GetMinimum(), Init(), and Minimize().
|
private |
1st derivative of fRealPh
Definition at line 153 of file PFourier.h.
Referenced by Entropy(), Penalty(), PFTPhaseCorrection(), and PFTPhaseCorrection().
|
mutableprivate |
maximum bin from Fourier range to be used for the phase correction estimate
Definition at line 155 of file PFourier.h.
Referenced by CalcPhasedFT(), GetPhaseCorrectionParam(), Init(), Minimize(), operator()(), and SetPh().
|
mutableprivate |
constant part of the phase dispersion used for the phase correction
Definition at line 156 of file PFourier.h.
Referenced by CalcPhasedFT(), GetPhaseCorrectionParam(), Init(), Minimize(), operator()(), and SetPh().
|
private |
Definition at line 147 of file PFourier.h.
Referenced by CalcPhasedFT(), and PFTPhaseCorrection().
|
mutableprivate |
original imag Fourier data set
Definition at line 149 of file PFourier.h.
Referenced by CalcPhasedFT(), CalcRealPhFTDerivative(), Penalty(), and PFTPhaseCorrection().
|
mutableprivate |
phased imag Fourier data set
Definition at line 151 of file PFourier.h.
Referenced by CalcRealPhFTDerivative(), and Entropy().
|
private |
Definition at line 145 of file PFourier.h.
Referenced by GetMinimum(), Init(), IsValid(), and Minimize().