11 #include "TGComboBox.h"
26 QGWindow(p, w, h), fCurrentHistogramName(
"")
30 vector<string> instructions_above_histograms;
31 instructions_above_histograms.push_back(
"Select a channel from the list to calibrate and click \"Draw\"");
33 for ( vector<string>::const_iterator iter = instructions_above_histograms.begin();
34 iter != instructions_above_histograms.end();
36 TGLabel *instruction =
new TGLabel(
this, iter->c_str());
37 AddFrame(instruction,
new TGLayoutHints(kLHintsCenterX, 5, 5, 1, 0));
46 fHistogramDropDownBox->Connect(
"Selected(const char*)",
"QGCalibrationWindow",
this,
"HandleHistogramDropDownBox(const char*)");
49 fDrawButton->Connect(
"Clicked()",
"QGCalibrationWindow",
this,
"HandleDrawButton()");
52 AddFrame(
fHistogramFrame,
new TGLayoutHints(kLHintsCenterX, 0, 0, 5, 4));
54 vector<string> instructions_above_peaks;
55 instructions_above_peaks.push_back(
"Zoom in to a window containing each peak and click\"Set\" to record the");
56 instructions_above_peaks.push_back(
"max and min of the window. When you are finished with");
57 instructions_above_peaks.push_back(
" all the peaks and channels, click \"Save\" to produce the output file.");
59 for ( vector<string>::const_iterator iter = instructions_above_peaks.begin();
60 iter != instructions_above_peaks.end();
62 TGLabel *instruction =
new TGLabel(
this, iter->c_str());
63 AddFrame(instruction,
new TGLayoutHints(kLHintsCenterX, 5, 5, 1, 0));
67 AddFrame(
fSaveButton,
new TGLayoutHints(kLHintsCenterX, 0, 0, 5, 5));
68 fSaveButton->Connect(
"Clicked()",
"QGCalibrationWindow",
this,
"HandleSaveButton()");
87 AddFrame(calibrationPeakFrame,
new TGLayoutHints(kLHintsLeft, 0, 5, 5, 0));
89 AddFrame(
fSaveButton,
new TGLayoutHints(kLHintsCenterX, 0, 0, 5, 5));
97 vector<QGCalibrationPeakFrame*>::const_iterator peakIter;
99 (*peakIter)->Clear(opt);
133 std::ofstream filestream;
136 if(!filestream.good())
142 std::vector<int> channels;
143 std::vector<double> energies;
144 std::vector<double> mins;
145 std::vector<double> maxs;
149 cout <<
"Number of max values set must equal number of min values!" << endl;
154 map<string, map<QGCalibrationPeakFrame*, Double_t> >::iterator iter;
157 string histname = iter->first;
159 sscanf(histname.c_str(),
"Channel_%d", &
channel);
163 cout <<
"Number of max values set must equal number of min values!" << endl;
168 map<QGCalibrationPeakFrame*, Double_t>::iterator peakIter;
169 for(peakIter=
fMaxData[histname].begin(); peakIter !=
fMaxData[histname].end(); peakIter++)
172 energies.push_back((peakIter->first)->GetEnergy());
173 maxs.push_back(
fMaxData[histname][peakIter->first]);
174 if(
fMinData[histname].count(peakIter->first))
176 mins.push_back(
fMinData[histname][peakIter->first]);
180 cout <<
"Min value missing for channel " <<
channel;
181 cout <<
", energy " << energies.back() << endl;
188 int nRows = channels.size();
191 filestream <<
"# begin GUI@peaks" << endl;
192 filestream <<
"# QMatrix" << endl;
193 filestream <<
"# " << nRows <<
' ' << nCols << endl;
195 for(
int i=0; i<nRows; i++)
197 filestream << channels[i] <<
'\t';
198 filestream << energies[i] <<
'\t';
199 filestream << mins[i] <<
'\t';
200 filestream << maxs[i] << endl;
202 filestream <<
"# end peaks" << endl;
209 if (
fMinData.count(histogramName) != 0) {
210 map<QGCalibrationPeakFrame*, Double_t>::const_iterator peakIter;
211 for (peakIter =
fMinData[histogramName].begin(); peakIter !=
fMinData[histogramName].end(); ++peakIter) {
212 (peakIter->first)->SetMinAmplitude(peakIter->second);
215 if (
fMaxData.count(histogramName) != 0) {
216 map<QGCalibrationPeakFrame*, Double_t>::const_iterator peakIter;
217 for (peakIter =
fMaxData[histogramName].begin(); peakIter !=
fMaxData[histogramName].end(); ++peakIter) {
218 (peakIter->first)->SetMaxAmplitude(peakIter->second);
226 vector<QGCalibrationPeakFrame*>::const_iterator peakIter;
228 if ((*peakIter)->IsMinAmplitudeSet()) {
233 if ((*peakIter)->IsMaxAmplitudeSet()) {
245 TString valueTString(value);
246 if (valueTString.IsFloat()) {
261 list<QGHistogram*>::const_iterator histogramIter;
262 for (histogramIter = histograms.begin(); histogramIter != histograms.end(); ++histogramIter) {
#define CALIBRATION_OUTPUT_FILENAME_KEY
Part of a QGCalibrationWindow for a specific peak.
void SetEnergy(Double_t energy)
Set energy.
Used to select amplitude windows for calibration peaks.
std::map< std::string, std::map< QGCalibrationPeakFrame *, Double_t > > fMaxData
Max amplitude data for each histogram and peak.
TGTextButton * fSaveButton
Save button.
QGPlot * GetCurrentPlot() const
Get current plot.
void LoadData(const std::string &histogramName)
Load data for histogram.
void HandleSaveButton()
Handle save button.
void AddPeak(Double_t energy)
Add peak.
void SetUpHistograms()
Set up histogram drop down box.
void Clear(Option_t *opt="")
Clear data.
void HandleHistogramDropDownBox(const char *text)
Handle histogram drop down box.
TGHorizontalFrame * fHistogramFrame
Histogram frame.
std::string fCurrentHistogramName
Current histogram name.
TGTextButton * fDrawButton
Draw button.
TGComboBox * fHistogramDropDownBox
Histogram drop down box.
std::string fOutputFilename
Output filename.
void HandleDrawButton()
Handle draw button.
void SaveData()
Save data for current histogram.
std::map< std::string, std::map< QGCalibrationPeakFrame *, Double_t > > fMinData
Min amplitude data for each histogram and peak.
void SetProperty(const std::string &key, const std::string &value)
Set property (used for opening a session)
QGCalibrationWindow(const TGWindow *p=0, UInt_t w=350, UInt_t h=300)
Constructor.
virtual ~QGCalibrationWindow()
Destructor.
std::vector< QGCalibrationPeakFrame * > fCalibrationPeakFrames
Collection of calibration peak frames.
static const std::list< QGHistogram * > & GetHistograms()
Get collection of histograms.
Base class for GUI plots including histograms, scatter plots, pulses, and graphical cuts.
virtual void Plot()
Plot this in the associated canvas window, generating it if necessary.
static QGPlot * GetPlotByName(const std::string &name)
Get plot by name.
Base class for GUI windows.
virtual void SetWindowName(const char *name=0)
Set name of window.
std::string Resize(const std::string &s, size_t len)
resize a string to len, adding spaces if necessary