Diana Software
QGCalibrationPeakFrame.cc
Go to the documentation of this file.
2 #include <algorithm>
3 #include <sstream>
4 #include "QGCalibrationWindow.hh"
5 #include "QGCanvasWindow.hh"
6 #include "QGPlot.hh"
7 #include "QGPlotFrame.hh"
8 #include "TCanvas.h"
9 #include "TFrame.h"
10 #include "TGButton.h"
11 #include "TGTextEntry.h"
12 #include "TRootEmbeddedCanvas.h"
13 #include "TString.h"
14 
16 
17 using std::flush;
18 using std::stringstream;
19 
20 QGCalibrationPeakFrame::QGCalibrationPeakFrame(TGWindow *p, UInt_t w, UInt_t h) :
21 TGHorizontalFrame(p, w, h)
22 {
23  SetCleanup(kDeepCleanup);
24 
25  fPeakEnergyBox = new TGTextEntry(this);
26  fPeakEnergyBox->Resize(fPeakEnergyBox->GetDefaultWidth(), 25);
27  fPeakEnergyBox->SetAlignment(kTextCenterX);
28  fPeakEnergyBox->SetEnabled(kFALSE);
29  AddFrame(fPeakEnergyBox, new TGLayoutHints(kLHintsCenterY, 5, 0, 0, 0));
30 
31  fMinAmplitudeBox = new TGTextEntry(this);
32  fMinAmplitudeBox->Resize(fMinAmplitudeBox->GetDefaultWidth(), 25);
33  AddFrame(fMinAmplitudeBox, new TGLayoutHints(kLHintsCenterY, 5, 0, 0, 0));
34 
35  fMaxAmplitudeBox = new TGTextEntry(this);
36  fMaxAmplitudeBox->Resize(fMaxAmplitudeBox->GetDefaultWidth(), 25);
37  AddFrame(fMaxAmplitudeBox, new TGLayoutHints(kLHintsCenterY, 5, 0, 0, 0));
38 
39  fSetButton = new TGTextButton(this, "Set");
40  AddFrame(fSetButton, new TGLayoutHints(kLHintsCenterY, 5, 0, 0, 0));
41  fSetButton->Connect("Clicked()", "QGCalibrationPeakFrame", this, "HandleSetButton()");
42 }
43 
45 {
46  Cleanup();
47 }
48 
49 void QGCalibrationPeakFrame::Clear(Option_t* opt)
50 {
51  fMinAmplitudeBox->Clear(opt);
52  fMaxAmplitudeBox->Clear(opt);
53 }
54 
56 {
57  TString text(fMaxAmplitudeBox->GetText());
58  return text.Atof();
59 }
60 
62 {
63  TString text(fMinAmplitudeBox->GetText());
64  return text.Atof();
65 }
66 
68 {
69  if (const QGCalibrationWindow *calibrationWindow = dynamic_cast<const QGCalibrationWindow*>(GetParent())) {
70  QGPlot *plot = calibrationWindow->GetCurrentPlot();
71  if (plot) {
72  QGCanvasWindow *canvasWindow = plot->GetCanvasWindow();
73  if (canvasWindow) {
74  const std::list<QGPlot*>& drawnPlots = canvasWindow->GetDrawnPlots();
75  if (find(drawnPlots.begin(), drawnPlots.end(), plot) != drawnPlots.end()) {
76  Double_t min = canvasWindow->GetPlotFrame()->GetEmbeddedCanvas()->GetCanvas()->GetFrame()->GetX1();
77  Double_t max = canvasWindow->GetPlotFrame()->GetEmbeddedCanvas()->GetCanvas()->GetFrame()->GetX2();
80  }
81  }
82  }
83  }
84 }
85 
87 {
88  TString text(fMaxAmplitudeBox->GetText());
89  return text.IsFloat();
90 }
91 
93 {
94  TString text(fMinAmplitudeBox->GetText());
95  return text.IsFloat();
96 }
97 
98 void QGCalibrationPeakFrame::SetEnergy(Double_t energy)
99 {
100  stringstream energyStream;
101  energyStream << energy << " keV" << flush;
102  fPeakEnergyBox->SetText(energyStream.str().c_str());
103  fEnergy = energy;
104 }
105 
107 {
108  stringstream maxStream;
109  maxStream.precision(16);
110  maxStream << max << flush;
111  fMaxAmplitudeBox->SetText(maxStream.str().c_str());
112 }
113 
115 {
116  stringstream minStream;
117  minStream.precision(16);
118  minStream << min << flush;
119  fMinAmplitudeBox->SetText(minStream.str().c_str());
120 }
double max
Definition: CheckOF.C:53
ClassImp(QObject)
double min(const Diana::QVector &v)
Definition: QVector.cc:878
Part of a QGCalibrationWindow for a specific peak.
void HandleSetButton()
Handle set button.
void SetMaxAmplitude(Double_t max)
Set max amplitude.
Double_t GetMinAmplitude() const
Get min amplitude.
TGTextEntry * fMinAmplitudeBox
Min amplitude box.
Bool_t IsMinAmplitudeSet() const
Return true if min amplitude is set.
void SetEnergy(Double_t energy)
Set energy.
virtual ~QGCalibrationPeakFrame()
Destructor.
void SetMinAmplitude(Double_t min)
Set min amplitude.
TGTextEntry * fMaxAmplitudeBox
Max amplitude box.
Double_t GetMaxAmplitude() const
Get max amplitude.
QGCalibrationPeakFrame(TGWindow *p=0, UInt_t w=10, UInt_t h=10)
Constructor.
Double_t fEnergy
Energy of the peak.
TGTextEntry * fPeakEnergyBox
Box for peak energy.
Bool_t IsMaxAmplitudeSet() const
Return true if max amplitude is set.
void Clear(Option_t *opt="")
Clear data.
TGTextButton * fSetButton
Set button.
Used to select amplitude windows for calibration peaks.
Window containing a ROOT canvas.
QGPlotFrame * GetPlotFrame()
Get pointer to the plot frame.
std::list< QGPlot * > & GetDrawnPlots()
Get collection of drawn plots.
TRootEmbeddedCanvas * GetEmbeddedCanvas()
Get pointer to canvas.
Definition: QGPlotFrame.hh:26
Base class for GUI plots including histograms, scatter plots, pulses, and graphical cuts.
Definition: QGPlot.hh:21
virtual QGCanvasWindow * GetCanvasWindow() const
Get pointer to the canvas window to which the plot is associated.
Definition: QGPlot.hh:60