musrfit  1.9.2
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-2023 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 //------------------------------------------------------------------------
72  TH1F *dataFourierRe;
73  TH1F *dataFourierIm;
77  std::vector<Double_t> optPhase;
78 };
79 
80 //------------------------------------------------------------------------
84 typedef std::vector<PFourierCanvasDataSet> PFourierCanvasDataList;
85 
86 //--------------------------------------------------------------------------
90 class PFourierCanvas : public TObject, public TQObject
91 {
92  public:
94  PFourierCanvas(std::vector<PFourier*> &fourier, PIntVector dataSetTag, const Char_t* title,
95  const Bool_t showAverage, const Bool_t showAveragePerDataSet,
96  const Int_t fourierPlotOpt, Double_t fourierXrange[2], Double_t phase,
97  Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh, const Bool_t batch);
98  PFourierCanvas(std::vector<PFourier*> &fourier, PIntVector dataSetTag, const Char_t* title,
99  const Bool_t showAverage, const Bool_t showAveragePerDataSet,
100  const Int_t fourierPlotOpt, Double_t fourierXrange[2], Double_t phase,
101  Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
102  const PIntVector markerList, const PIntVector colorList, const Bool_t batch);
103 
104  virtual void Done(Int_t status=0); // *SIGNAL*
105  virtual void HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected); // SLOT
106  virtual void HandleMenuPopup(Int_t id); // SLOT
107  virtual void LastCanvasClosed(); // SLOT
108 
109  virtual void UpdateFourierPad();
110  virtual void UpdateInfoPad();
111 
112  virtual Bool_t IsValid() { return fValid; }
113 
114  virtual void SetTimeout(Int_t ival);
115 
116  virtual void SaveGraphicsAndQuit(const Char_t *fileName);
117  virtual void ExportData(const Char_t *pathFileName);
118 
119  private:
120  Int_t fTimeout;
121  Bool_t fBatchMode;
122  Bool_t fValid;
123  Bool_t fAveragedView;
127  Double_t fInitialXRange[2];
128  Double_t fInitialYRange[2];
129 
130  TString fTitle;
131  TString fXaxisTitle;
132  std::vector<PFourier*> fFourier;
136  std::unique_ptr<TLatex> fCurrentFourierPhaseText;
137 
138  std::unique_ptr<TStyle> fStyle;
139 
140  std::unique_ptr<TTimer> fTimeoutTimer;
141 
144 
145  // canvas menu related variables
146  TRootCanvas *fImp;
147  TGMenuBar *fBar;
148  TGPopupMenu *fPopupMain;
149  std::unique_ptr<TGPopupMenu> fPopupFourier;
150 
151  // canvas related variables
152  std::unique_ptr<TCanvas> fMainCanvas;
153  std::unique_ptr<TPaveText> fTitlePad;
154  std::unique_ptr<TPad> fFourierPad;
155  std::unique_ptr<TLegend> fInfoPad;
156  std::unique_ptr<TLegend> fLegAvgPerDataSet;
157 
158  virtual void CreateXaxisTitle();
159  virtual void CreateStyle();
160  virtual void InitFourierDataSets();
161  virtual void InitFourierCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh);
162  virtual void CleanupAverage();
163  virtual void HandleAverage();
164  virtual void CalcPhaseOptReal();
165 
166  virtual void PlotFourier();
167  virtual void PlotFourierPhaseValue();
168  virtual void PlotAverage();
169  virtual void IncrementFourierPhase();
170  virtual void DecrementFourierPhase();
171 
172  virtual Double_t GetMaximum(TH1F* histo, Double_t xmin=-1.0, Double_t xmax=-1.0);
173  virtual Double_t GetMinimum(TH1F* histo, Double_t xmin=-1.0, Double_t xmax=-1.0);
174  virtual Double_t GetInterpolatedValue(TH1F* histo, Double_t xVal);
175  virtual TString GetDataSetName(TString title);
176 
177  ClassDef(PFourierCanvas, 1)
178 };
179 
180 #endif // _PFOURIERCANVAS_H_
std::unique_ptr< TLatex > fCurrentFourierPhaseText
used in Re/Im Fourier to show the current phase in the pad
Int_t fTimeout
timeout after which the Done signal should be emited. If timeout <= 0, no timeout is taking place ...
virtual void DecrementFourierPhase()
PIntVector fColorList
list of colors
std::vector< Double_t > optPhase
optimal phase which maximizes the real Fourier
std::unique_ptr< TTimer > fTimeoutTimer
timeout timer in order to terminate if no action is taking place for too long
virtual void SaveGraphicsAndQuit(const Char_t *fileName)
virtual void PlotAverage()
PFourierCanvasDataList fFourierHistos
keeps all the Fourier histos
PIntVector fDataSetTag
vector holding the data set tags
std::unique_ptr< TPaveText > fTitlePad
title pad used to display a title
Int_t fCurrentPlotView
tag showing what the current plot view is: real, imag, power, phase, ...
virtual void LastCanvasClosed()
virtual void Done(Int_t status=0)
virtual void PlotFourierPhaseValue()
virtual void PlotFourier()
Bool_t fAveragedViewPerDataSet
tag showing that the averaged view for individual data sets or normal view should be presented...
Bool_t fValid
if true, everything looks OK
virtual void CleanupAverage()
TRootCanvas * fImp
ROOT native GUI version of main window with menubar and drawing area.
std::vector< Int_t > PIntVector
Definition: PMusr.h:178
virtual void SetTimeout(Int_t ival)
std::unique_ptr< TPad > fFourierPad
fourier pad used to display the fourier
virtual Bool_t IsValid()
virtual void UpdateInfoPad()
std::unique_ptr< TLegend > fInfoPad
info pad used to display a legend of the data plotted
virtual void CalcPhaseOptReal()
virtual void CreateXaxisTitle()
TH1F * dataFourierPhaseOptReal
phase otpimized real Fourier transform of the data histogram
TH1F * dataFourierPwr
power spectrum of the Fourier transform of the data histogram
virtual void InitFourierDataSets()
std::unique_ptr< TLegend > fLegAvgPerDataSet
legend used for averaged per data set view
TH1F * dataFourierPhase
phase spectrum of the Fourier transform of the data histogram
Double_t fInitialXRange[2]
keeps the initial x-range
Bool_t fAveragedView
tag showing that the averaged view for ALL data or normal view should be presented.
Double_t fInitialYRange[2]
keeps the initial y-range
TH1F * dataFourierIm
imaginary part of the Fourier transform of the data histogram
std::unique_ptr< TGPopupMenu > fPopupFourier
popup menu of the MusrFT/Fourier sub menu
Bool_t fBatchMode
musrview in ROOT batch mode
PFourierCanvasDataList fFourierAverage
keeps the average of the Fourier histos
virtual void HandleMenuPopup(Int_t id)
TGMenuBar * fBar
menu bar
virtual TString GetDataSetName(TString title)
std::vector< PFourierCanvasDataSet > PFourierCanvasDataList
virtual void IncrementFourierPhase()
virtual void HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
virtual Double_t GetInterpolatedValue(TH1F *histo, Double_t xVal)
std::vector< PFourier * > fFourier
keeps all the Fourier data, ownership is with the caller
virtual Double_t GetMinimum(TH1F *histo, Double_t xmin=-1.0, Double_t xmax=-1.0)
TH1F * dataFourierRe
real part of the Fourier transform of the data histogram
TGPopupMenu * fPopupMain
popup menu MusrFT in the main menu bar
std::unique_ptr< TStyle > fStyle
A collection of all graphics attributes.
virtual void HandleAverage()
return status
virtual void UpdateFourierPad()
PIntVector fMarkerList
list of markers
virtual void ExportData(const Char_t *pathFileName)
virtual void InitFourierCanvas(const Char_t *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
std::unique_ptr< TCanvas > fMainCanvas
main canvas
virtual Double_t GetMaximum(TH1F *histo, Double_t xmin=-1.0, Double_t xmax=-1.0)
virtual void CreateStyle()
Double_t fCurrentFourierPhase
keeps the current Fourier phase (real/imag)