00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4CreateNewHistogram.h"
00015
00016 #include "TH1.h"
00017 #include "TH2.h"
00018 #include "TH3.h"
00019 #include "TDirectory.h"
00020 #include "TROOT.h"
00021 #include "TGo4QSettings.h"
00022 #include <QButtonGroup>
00023
00024 TGo4CreateNewHistogram::TGo4CreateNewHistogram( QWidget* parent)
00025 : QDialog( parent)
00026 {
00027 setObjectName("Go4CreateNewHistogram");
00028 setupUi(this);
00029 HisName->setText(go4sett->getHistName());
00030 HisTitle->setText(go4sett->getHistTitle());
00031
00032 HisClassGrp = new QButtonGroup(this);
00033 HisClassGrp->addButton(TH1_b, 1);
00034 HisClassGrp->addButton(TH2_b, 2);
00035 HisClassGrp->addButton(TH3_b, 3);
00036
00037 HisTypeGrp = new QButtonGroup(this);
00038 HisTypeGrp->addButton(S_b, 1);
00039 HisTypeGrp->addButton(D_b, 2);
00040 HisTypeGrp->addButton(F_b, 3);
00041 HisTypeGrp->addButton(I_b, 4);
00042 HisTypeGrp->addButton(C_b, 5);
00043
00044 int htype = go4sett->getHistType();
00045 HisClassGrp->button(htype / 10)->setChecked(true);
00046 HisTypeGrp->button(htype % 10)->setChecked(true);
00047
00048 int npoints;
00049 double min, max;
00050
00051 go4sett->getHistAxisPars(0, npoints, min, max);
00052 XNoOfBins->setText(QString::number(npoints));
00053 Xmin->setText(QString::number(min));
00054 Xmax->setText(QString::number(max));
00055
00056 go4sett->getHistAxisPars(1, npoints, min, max);
00057 YNoOfBins->setText(QString::number(npoints));
00058 Ymin->setText(QString::number(min));
00059 Ymax->setText(QString::number(max));
00060
00061 go4sett->getHistAxisPars(2, npoints, min, max);
00062 ZNoOfBins->setText(QString::number(npoints));
00063 Zmin->setText(QString::number(min));
00064 Zmax->setText(QString::number(max));
00065
00066 fSelectedCmd = 0;
00067 }
00068
00069 void TGo4CreateNewHistogram::SetAnalysisAvaliable(bool on)
00070 {
00071 CreateRemote->setEnabled(on);
00072 }
00073
00074 void TGo4CreateNewHistogram::SetLocalAvaliable(bool on)
00075 {
00076 CreateHistogram->setEnabled(on);
00077 }
00078
00079 int TGo4CreateNewHistogram::GetSelectedCmd()
00080 {
00081 return fSelectedCmd;
00082 }
00083
00084 TH1* TGo4CreateNewHistogram::MakeHistogram()
00085 {
00086 QByteArray bname = HisName->text().toLatin1();
00087 QByteArray btitle = HisTitle->text().toLatin1();
00088
00089 const char* hname = bname.constData();
00090 const char* htitle = btitle.constData();
00091
00092 int htype = HisClassGrp->checkedId()*10 + HisTypeGrp->checkedId();
00093
00094 int nxbins = XNoOfBins->text().toInt();
00095 int nybins = YNoOfBins->text().toInt();
00096 int nzbins = ZNoOfBins->text().toInt();
00097
00098 double xmin = Xmin->text().toDouble();
00099 double xmax = Xmax->text().toDouble();
00100 double ymin = Ymin->text().toDouble();
00101 double ymax = Ymax->text().toDouble();
00102 double zmin = Zmin->text().toDouble();
00103 double zmax = Zmax->text().toDouble();
00104
00105 go4sett->setHistName(hname);
00106 go4sett->setHistTitle(htitle);
00107 go4sett->setHistType(htype);
00108 go4sett->setHistAxisPars(0, nxbins, xmin, xmax);
00109 go4sett->setHistAxisPars(1, nybins, ymin, ymax);
00110 go4sett->setHistAxisPars(2, nzbins, zmin, zmax);
00111
00112 TDirectory* savdir = gDirectory;
00113 gROOT->cd();
00114 TH1* h = 0;
00115 switch(htype) {
00116 case 11: h = new TH1S(hname, htitle, nxbins, xmin, xmax); break;
00117 case 12: h = new TH1D(hname, htitle, nxbins, xmin, xmax); break;
00118 case 13: h = new TH1F(hname, htitle, nxbins, xmin, xmax); break;
00119 case 14: h = new TH1I(hname, htitle, nxbins, xmin, xmax); break;
00120 case 15: h = new TH1C(hname, htitle, nxbins, xmin, xmax); break;
00121 case 21: h = new TH2S(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
00122 case 22: h = new TH2D(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
00123 case 23: h = new TH2F(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
00124 case 24: h = new TH2I(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
00125 case 25: h = new TH2C(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
00126 case 31: h = new TH3S(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
00127 case 32: h = new TH3D(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
00128 case 33: h = new TH3F(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
00129 case 34: h = new TH3I(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
00130 case 35: h = new TH3C(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
00131 }
00132
00133 if (savdir!=0) savdir->cd();
00134
00135 return h;
00136 }
00137
00138 void TGo4CreateNewHistogram::CreateLocalHist()
00139 {
00140 fSelectedCmd = 1;
00141 accept();
00142 }
00143
00144 void TGo4CreateNewHistogram::CreateRemoteHis()
00145 {
00146 fSelectedCmd = 2;
00147 accept();
00148 }
00149
00150