musrfit 1.10.0
PFourierCanvas.h
Go to the documentation of this file.
1/***************************************************************************
2
3 PFourierCanvas.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 _PFOURIERCANVAS_H_
31#define _PFOURIERCANVAS_H_
32
33#include <vector>
34#include <memory>
35
36#include <TObject.h>
37#include <TQObject.h>
38#include <TTimer.h>
39#include <TStyle.h>
40#include <TRootCanvas.h>
41#include <TGMenu.h>
42#include <TCanvas.h>
43#include <TPaveText.h>
44#include <TLegend.h>
45#include <TPad.h>
46#include <TH1F.h>
47#include <TLatex.h>
48
49#include "PMusr.h"
50#include "PFourier.h"
51
52// Canvas menu id's
53#define P_MENU_ID_FOURIER 10001
54#define P_MENU_ID_AVERAGE 10002
55#define P_MENU_ID_AVERAGE_PER_DATA_SET 10003
56#define P_MENU_ID_EXPORT_DATA 10004
57
58#define P_MENU_ID_FOURIER_REAL 100
59#define P_MENU_ID_FOURIER_IMAG 101
60#define P_MENU_ID_FOURIER_REAL_AND_IMAG 102
61#define P_MENU_ID_FOURIER_PWR 103
62#define P_MENU_ID_FOURIER_PHASE 104
63#define P_MENU_ID_FOURIER_PHASE_OPT_REAL 105
64#define P_MENU_ID_FOURIER_PHASE_PLUS 106
65#define P_MENU_ID_FOURIER_PHASE_MINUS 107
66
67//------------------------------------------------------------------------
89
90//------------------------------------------------------------------------
100typedef std::vector<PFourierCanvasDataSet> PFourierCanvasDataList;
101
102//--------------------------------------------------------------------------
137class PFourierCanvas : public TObject, public TQObject
138{
139 public:
147
168 PFourierCanvas(std::vector<PFourier*> &fourier, PIntVector dataSetTag, const Char_t* title,
169 const Bool_t showAverage, const Bool_t showAveragePerDataSet,
170 const Int_t fourierPlotOpt, Double_t fourierXrange[2], Double_t phase,
171 Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh, const Bool_t batch);
172
195 PFourierCanvas(std::vector<PFourier*> &fourier, PIntVector dataSetTag, const Char_t* title,
196 const Bool_t showAverage, const Bool_t showAveragePerDataSet,
197 const Int_t fourierPlotOpt, Double_t fourierXrange[2], Double_t phase,
198 Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
199 const PIntVector markerList, const PIntVector colorList, const Bool_t batch);
200
209 virtual void Done(Int_t status=0); // *SIGNAL*
210
224 virtual void HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected); // SLOT
225
237 virtual void HandleMenuPopup(Int_t id); // SLOT
238
245 virtual void LastCanvasClosed(); // SLOT
246
254 virtual void UpdateFourierPad();
255
262 virtual void UpdateInfoPad();
263
269 virtual Bool_t IsValid() { return fValid; }
270
279 virtual void SetTimeout(Int_t ival);
280
289 virtual void SaveGraphicsAndQuit(const Char_t *fileName);
290
299 virtual void ExportData(const Char_t *pathFileName);
300
301 private:
302 Int_t fTimeout;
303 Bool_t fBatchMode;
304 Bool_t fValid;
309 Double_t fInitialXRange[2];
310 Double_t fInitialYRange[2];
311
312 TString fTitle;
313 TString fXaxisTitle;
314 std::vector<PFourier*> fFourier;
318 std::unique_ptr<TLatex> fCurrentFourierPhaseText;
319
320 std::unique_ptr<TStyle> fStyle;
321
322 std::unique_ptr<TTimer> fTimeoutTimer;
323
326
327 // canvas menu related variables
328 TRootCanvas *fImp;
329 TGMenuBar *fBar;
330 TGPopupMenu *fPopupMain;
331 std::unique_ptr<TGPopupMenu> fPopupFourier;
332
333 // canvas related variables
334 std::unique_ptr<TCanvas> fMainCanvas;
335 std::unique_ptr<TPaveText> fTitlePad;
336 std::unique_ptr<TPad> fFourierPad;
337 std::unique_ptr<TLegend> fInfoPad;
338 std::unique_ptr<TLegend> fLegAvgPerDataSet;
339
341 virtual void CreateXaxisTitle();
342
344 virtual void CreateStyle();
345
347 virtual void InitFourierDataSets();
348
355 virtual void InitFourierCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh);
356
358 virtual void CleanupAverage();
359
361 virtual void HandleAverage();
362
364 virtual void CalcPhaseOptReal();
365
367 virtual void PlotFourier();
368
370 virtual void PlotFourierPhaseValue();
371
373 virtual void PlotAverage();
374
376 virtual void IncrementFourierPhase();
377
379 virtual void DecrementFourierPhase();
380
386 virtual Double_t GetMaximum(TH1F* histo, Double_t xmin=-1.0, Double_t xmax=-1.0);
387
393 virtual Double_t GetMinimum(TH1F* histo, Double_t xmin=-1.0, Double_t xmax=-1.0);
394
399 virtual Double_t GetInterpolatedValue(TH1F* histo, Double_t xVal);
400
404 virtual TString GetDataSetName(TString title);
405
406 ClassDef(PFourierCanvas, 1)
407};
408
409#endif // _PFOURIERCANVAS_H_
std::vector< PFourierCanvasDataSet > PFourierCanvasDataList
std::vector< Int_t > PIntVector
Definition PMusr.h:381
return status
virtual void CalcPhaseOptReal()
Calculates phase-optimized real Fourier for all datasets.
Bool_t fValid
if true, everything looks OK
Double_t fInitialXRange[2]
keeps the initial x-range
virtual void LastCanvasClosed()
virtual void HandleMenuPopup(Int_t id)
TGMenuBar * fBar
menu bar
virtual void HandleAverage()
Computes averaged Fourier spectra across runs or per dataset.
std::unique_ptr< TStyle > fStyle
A collection of all graphics attributes.
virtual void Done(Int_t status=0)
virtual Bool_t IsValid()
virtual void SetTimeout(Int_t ival)
Int_t fCurrentPlotView
tag showing what the current plot view is: real, imag, power, phase, ...
PFourierCanvas(std::vector< PFourier * > &fourier, PIntVector dataSetTag, const Char_t *title, const Bool_t showAverage, const Bool_t showAveragePerDataSet, const Int_t fourierPlotOpt, Double_t fourierXrange[2], Double_t phase, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh, const PIntVector markerList, const PIntVector colorList, const Bool_t batch)
virtual void DecrementFourierPhase()
Decreases phase by 5° and redraws Re/Im spectra.
virtual void PlotFourier()
Draws individual Fourier spectra (non-averaged view)
PIntVector fMarkerList
list of markers
std::unique_ptr< TPaveText > fTitlePad
title pad used to display a title
Bool_t fBatchMode
musrview in ROOT batch mode
virtual void PlotAverage()
Draws averaged Fourier spectra (averaged view modes)
std::unique_ptr< TLatex > fCurrentFourierPhaseText
used in Re/Im Fourier to show the current phase in the pad
PFourierCanvasDataList fFourierAverage
keeps the average of the Fourier histos
Double_t fCurrentFourierPhase
keeps the current Fourier phase (real/imag)
std::vector< PFourier * > fFourier
keeps all the Fourier data, ownership is with the caller
Int_t fTimeout
timeout after which the Done signal should be emited. If timeout <= 0, no timeout is taking place
virtual void PlotFourierPhaseValue()
Displays current phase value as text overlay on canvas.
PFourierCanvas(std::vector< PFourier * > &fourier, PIntVector dataSetTag, const Char_t *title, const Bool_t showAverage, const Bool_t showAveragePerDataSet, const Int_t fourierPlotOpt, Double_t fourierXrange[2], Double_t phase, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh, const Bool_t batch)
virtual void SaveGraphicsAndQuit(const Char_t *fileName)
virtual void HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
PFourierCanvasDataList fFourierHistos
keeps all the Fourier histos
virtual Double_t GetInterpolatedValue(TH1F *histo, Double_t xVal)
std::unique_ptr< TLegend > fLegAvgPerDataSet
legend used for averaged per data set view
TGPopupMenu * fPopupMain
popup menu MusrFT in the main menu bar
PIntVector fDataSetTag
vector holding the data set tags
std::unique_ptr< TCanvas > fMainCanvas
main canvas
std::unique_ptr< TLegend > fInfoPad
info pad used to display a legend of the data plotted
PIntVector fColorList
list of colors
virtual Double_t GetMaximum(TH1F *histo, Double_t xmin=-1.0, Double_t xmax=-1.0)
virtual void UpdateInfoPad()
virtual void UpdateFourierPad()
virtual void CreateStyle()
Initializes ROOT plotting style (colors, fonts, margins, etc.)
virtual Double_t GetMinimum(TH1F *histo, Double_t xmin=-1.0, Double_t xmax=-1.0)
virtual void InitFourierCanvas(const Char_t *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
std::unique_ptr< TGPopupMenu > fPopupFourier
popup menu of the MusrFT/Fourier sub menu
Bool_t fAveragedView
tag showing that the averaged view for ALL data or normal view should be presented.
virtual void CreateXaxisTitle()
Creates X-axis label based on unit type (Gauss/Tesla/MHz/Mc/s)
virtual void IncrementFourierPhase()
Increases phase by 5° and redraws Re/Im spectra.
virtual void InitFourierDataSets()
Generates all Fourier histograms (Re/Im/Pwr/Phase) from PFourier objects.
virtual void CleanupAverage()
Deletes averaged histogram data to free memory.
std::unique_ptr< TPad > fFourierPad
fourier pad used to display the fourier
TRootCanvas * fImp
ROOT native GUI version of main window with menubar and drawing area.
virtual void ExportData(const Char_t *pathFileName)
virtual TString GetDataSetName(TString title)
Double_t fInitialYRange[2]
keeps the initial y-range
std::unique_ptr< TTimer > fTimeoutTimer
timeout timer in order to terminate if no action is taking place for too long
Bool_t fAveragedViewPerDataSet
tag showing that the averaged view for individual data sets or normal view should be presented.
TH1F * dataFourierPhaseOptReal
Phase-optimized real spectrum: maximized absorption mode with minimal imaginary component.
TH1F * dataFourierPhase
Phase spectrum φ = atan2(Im, Re): phase angle in radians.
TH1F * dataFourierPwr
Power spectrum |F| = √(Re² + Im²): phase-independent amplitude.
TH1F * dataFourierIm
Imaginary part Im(F): dispersion-mode spectrum.
std::vector< Double_t > optPhase
Optimal phase parameters [c₀, c₁] for phase correction: φ(ω) = c₀ + c₁·ω
TH1F * dataFourierRe
Real part Re(F): absorption-mode spectrum (mixed phase if uncorrected)