musrfit 1.10.0
PFourier.h
Go to the documentation of this file.
1/***************************************************************************
2
3 PFourier.h
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8***************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2007-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
30#ifndef _PFOURIER_H_
31#define _PFOURIER_H_
32
33#include <vector>
34
35#include "fftw3.h"
36
37#include <TH1F.h>
38
39#include "Minuit2/FCNBase.h"
40
41#include "PMusr.h"
42
43//-------------------------------------------------------------
53#define F_APODIZATION_NONE 1
55#define F_APODIZATION_WEAK 2
57#define F_APODIZATION_MEDIUM 3
59#define F_APODIZATION_STRONG 4
60
61//-------------------------------------------------------------
84class PFTPhaseCorrection : public ROOT::Minuit2::FCNBase
85{
86 public:
93 PFTPhaseCorrection(const Int_t minBin=-1, const Int_t maxBin=-1);
94
103 PFTPhaseCorrection(std::vector<Double_t> &reFT, std::vector<Double_t> &imFT, const Int_t minBin=-1, const Int_t maxBin=-1);
104
106
109 virtual Bool_t IsValid() { return fValid; }
110
117 virtual void Minimize();
118
121 virtual void SetGamma(const Double_t gamma) { fGamma = gamma; }
122
126 virtual void SetPh(const Double_t c0, const Double_t c1) { fPh_c0 = c0; fPh_c1 = c1; CalcPhasedFT(); CalcRealPhFTDerivative(); }
127
130 virtual Double_t GetGamma() { return fGamma; }
131
138 virtual Double_t GetPhaseCorrectionParam(UInt_t idx);
139
142 virtual Double_t GetMinimum();
143
144 private:
145 Bool_t fValid;
146
147 std::vector<Double_t> fReal;
148 std::vector<Double_t> fImag;
149 mutable std::vector<Double_t> fRealPh;
150 mutable std::vector<Double_t> fImagPh;
151 mutable std::vector<Double_t> fRealPhD;
152
153 Int_t fMinBin;
154 Int_t fMaxBin;
155 mutable Double_t fPh_c0;
156 mutable Double_t fPh_c1;
157 Double_t fGamma;
158 Double_t fMin;
159
160 virtual void Init();
161 virtual void CalcPhasedFT() const;
162 virtual void CalcRealPhFTDerivative() const;
163 virtual Double_t Penalty() const;
164 virtual Double_t Entropy() const;
165
166 virtual Double_t Up() const { return 1.0; }
167 virtual Double_t operator()(const std::vector<Double_t>&) const;
168};
169
170//-------------------------------------------------------------
202{
203 public:
214 PFourier(TH1F *data, Int_t unitTag,
215 Double_t startTime = 0.0, Double_t endTime = 0.0,
216 Bool_t dcCorrected = false, UInt_t zeroPaddingPower = 0);
217
218 virtual ~PFourier();
219
228 virtual void Transform(UInt_t apodizationTag = 0);
229
232 virtual const char* GetDataTitle() { return fData->GetTitle(); }
233
236 virtual const Int_t GetUnitTag() { return fUnitTag; }
237
240 virtual Double_t GetResolution() { return fResolution; }
241
247 virtual Double_t GetMaxFreq();
248
255 virtual TH1F* GetRealFourier(const Double_t scale = 1.0);
256
263 virtual TH1F* GetImaginaryFourier(const Double_t scale = 1.0);
264
274 virtual TH1F* GetPowerFourier(const Double_t scale = 1.0);
275
282 virtual TH1F* GetPhaseFourier(const Double_t scale = 1.0);
283
298 static TH1F* GetPhaseOptRealFourier(const TH1F *re, const TH1F *im, std::vector<Double_t> &phase,
299 const Double_t scale = 1.0, const Double_t min = -1.0, const Double_t max = -1.0);
300
303 virtual Bool_t IsValid() { return fValid; }
304
305 private:
306 TH1F *fData;
307
308 Bool_t fValid;
309 Int_t fUnitTag;
310
312
314 Double_t fStartTime;
315 Double_t fEndTime;
318 Double_t fResolution;
319
320 UInt_t fNoOfData;
321 UInt_t fNoOfBins;
322 fftw_plan fFFTwPlan;
323 fftw_complex *fIn;
324 fftw_complex *fOut;
325
326//as PFTPhaseCorrection *fPhCorrectedReFT;
327
328 virtual void PrepareFFTwInputData(UInt_t apodizationTag);
329 virtual void ApodizeData(Int_t apodizationTag);
330};
331
332#endif // _PFOURIER_H_
virtual void Minimize()
Definition PFourier.cpp:144
PFTPhaseCorrection(const Int_t minBin=-1, const Int_t maxBin=-1)
Definition PFourier.cpp:67
virtual void CalcRealPhFTDerivative() const
Definition PFourier.cpp:307
virtual Double_t Up() const
Definition PFourier.h:166
Int_t fMinBin
1st derivative of fRealPh
Definition PFourier.h:153
std::vector< Double_t > fRealPh
original imag Fourier data set
Definition PFourier.h:149
virtual void Init()
keeps the minimum of the entropy/penalty minimization
Definition PFourier.cpp:248
virtual void SetGamma(const Double_t gamma)
Definition PFourier.h:121
virtual ~PFTPhaseCorrection()
Definition PFourier.h:105
std::vector< Double_t > fRealPhD
phased imag Fourier data set
Definition PFourier.h:151
virtual Bool_t IsValid()
Definition PFourier.h:109
virtual Double_t Entropy() const
Definition PFourier.cpp:376
std::vector< Double_t > fImagPh
phased real Fourier data set
Definition PFourier.h:150
std::vector< Double_t > fReal
Definition PFourier.h:147
virtual void CalcPhasedFT() const
Definition PFourier.cpp:276
virtual Double_t operator()(const std::vector< Double_t > &) const
Definition PFourier.cpp:425
Double_t fPh_c1
constant part of the phase dispersion used for the phase correction
Definition PFourier.h:156
virtual void SetPh(const Double_t c0, const Double_t c1)
Definition PFourier.h:126
Double_t fMin
gamma parameter to balance between entropy and penalty
Definition PFourier.h:158
Double_t fGamma
linear part of the phase dispersion used for the phase correction
Definition PFourier.h:157
Double_t fPh_c0
maximum bin from Fourier range to be used for the phase correction estimate
Definition PFourier.h:155
virtual Double_t Penalty() const
Definition PFourier.cpp:339
virtual Double_t GetMinimum()
Definition PFourier.cpp:223
Int_t fMaxBin
minimum bin from Fourier range to be used for the phase correction estimate
Definition PFourier.h:154
virtual Double_t GetPhaseCorrectionParam(UInt_t idx)
Definition PFourier.cpp:195
virtual Double_t GetGamma()
Definition PFourier.h:130
std::vector< Double_t > fImag
original real Fourier data set
Definition PFourier.h:148
PFourier(TH1F *data, Int_t unitTag, Double_t startTime=0.0, Double_t endTime=0.0, Bool_t dcCorrected=false, UInt_t zeroPaddingPower=0)
Definition PFourier.cpp:482
fftw_plan fFFTwPlan
fftw plan (see FFTW3 User Manual)
Definition PFourier.h:322
virtual void ApodizeData(Int_t apodizationTag)
Int_t fApodization
0=none, 1=weak, 2=medium, 3=strong
Definition PFourier.h:311
Bool_t fValid
true = all boundary conditions fullfilled and hence a Fourier transform can be performed.
Definition PFourier.h:308
UInt_t fZeroPaddingPower
power for zero padding, if set < 0 no zero padding will be done
Definition PFourier.h:317
virtual Double_t GetResolution()
Definition PFourier.h:240
UInt_t fNoOfBins
number of bins to be Fourier transformed. Might be different to fNoOfData due to zero padding
Definition PFourier.h:321
virtual TH1F * GetImaginaryFourier(const Double_t scale=1.0)
Definition PFourier.cpp:931
UInt_t fNoOfData
number of bins in the time interval between fStartTime and fStopTime
Definition PFourier.h:320
Double_t fResolution
Fourier resolution (field, frequency, or angular frequency)
Definition PFourier.h:318
virtual void Transform(UInt_t apodizationTag=0)
Definition PFourier.cpp:632
virtual TH1F * GetRealFourier(const Double_t scale=1.0)
Definition PFourier.cpp:731
virtual Double_t GetMaxFreq()
Definition PFourier.cpp:685
virtual TH1F * GetPowerFourier(const Double_t scale=1.0)
static TH1F * GetPhaseOptRealFourier(const TH1F *re, const TH1F *im, std::vector< Double_t > &phase, const Double_t scale=1.0, const Double_t min=-1.0, const Double_t max=-1.0)
Definition PFourier.cpp:817
virtual const char * GetDataTitle()
Definition PFourier.h:232
virtual Bool_t IsValid()
Definition PFourier.h:303
TH1F * fData
data histogram to be Fourier transformed.
Definition PFourier.h:306
virtual const Int_t GetUnitTag()
Definition PFourier.h:236
virtual void PrepareFFTwInputData(UInt_t apodizationTag)
virtual TH1F * GetPhaseFourier(const Double_t scale=1.0)
Int_t fUnitTag
1=Field Units (G), 2=Field Units (T), 3=Frequency Units (MHz), 4=Angular Frequency Units (Mc/s)
Definition PFourier.h:309
Double_t fStartTime
start time of the data histogram
Definition PFourier.h:314
Double_t fTimeResolution
time resolution of the data histogram in (us)
Definition PFourier.h:313
fftw_complex * fIn
real part of the Fourier transform
Definition PFourier.h:323
fftw_complex * fOut
imaginary part of the Fourier transform
Definition PFourier.h:324
Double_t fEndTime
end time of the data histogram
Definition PFourier.h:315
Bool_t fDCCorrected
if true, removed DC offset from signal before Fourier transformation, otherwise not
Definition PFourier.h:316
virtual ~PFourier()
Definition PFourier.cpp:584