Diana Software
QGuiHistogram.cc
Go to the documentation of this file.
1 #include "QGuiHistogram.hh"
2 #include <iostream>
3 #include <sstream>
4 
5 using std::endl;
6 using std::string;
7 using std::stringstream;
8 using std::vector;
9 
11 {
12 }
13 
15 {
16 }
17 
18 void QGuiHistogram::SetXMin(double xmin)
19 {
20  stringstream ss;
21  ss.precision(16);
22  ss << xmin;
23  fXMin = ss.str();
24 }
25 
26 void QGuiHistogram::SetXMax(double xmax)
27 {
28  stringstream ss;
29  ss.precision(16);
30  ss << xmax;
31  fXMax = ss.str();
32 }
33 
35 {
36  stringstream ss;
37  ss << nbins;
38  fNumberOfBins = ss.str();
39 }
40 
41 void QGuiHistogram::SetBinWidth(double width)
42 {
43  stringstream ss;
44  ss.precision(16);
45  ss << width;
46  fBinWidth = ss.str();
47 }
48 
49 string QGuiHistogram::Dump() const
50 {
51  stringstream histogramDump;
52  histogramDump << HISTOGRAM_KEY << endl;
53  if (fName != "") histogramDump << NAME_KEY << " " << fName << endl;
54  if (fXVariable != "") histogramDump << X_VARIABLE_KEY << " " << fXVariable << endl;
55  if (fXMin != "") histogramDump << MIN_KEY << " " << fXMin << endl;
56  if (fXMax != "") histogramDump << MAX_KEY << " " << fXMax << endl;
57  if (fBinWidth != "") histogramDump << BIN_WIDTH_KEY << " " << fBinWidth << endl;
58  if (fNumberOfBins != "") histogramDump << NUMBER_OF_BINS_KEY << " " << fNumberOfBins << endl;
59  for (vector<string>::const_iterator iter = fCuts.begin(); iter != fCuts.end(); ++iter) {
60  histogramDump << CUT_KEY << " " << *iter << endl;
61  }
62  return histogramDump.str();
63 }
#define BIN_WIDTH_KEY
#define HISTOGRAM_KEY
#define MAX_KEY
#define NUMBER_OF_BINS_KEY
#define CUT_KEY
#define MIN_KEY
#define NAME_KEY
#define X_VARIABLE_KEY
void SetBinWidth(double width)
Set bin width.
std::string fBinWidth
Bin width.
~QGuiHistogram()
Default destructor.
std::string fXMin
x-min
std::string Dump() const
Dump to string to write to session file.
void SetNumberOfBins(int nbins)
Set number of bins.
std::string fXMax
std::string fNumberOfBins
Number of bins.
QGuiHistogram()
Default constructor.
void SetXMin(double xmin)
Set x-min.
std::vector< std::string > fCuts
Cuts.
void SetXMax(double xmax)
Set x-max.
std::string fXVariable
Variable for histogram.
Base class for GUI session objects like histograms and scatter plots.
std::string fName
Name.