// $Id$ //----------------------------------------------------------------------- // The GSI Online Offline Object Oriented (Go4) Project // Experiment Data Processing at EE department, GSI //----------------------------------------------------------------------- // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH // Planckstr. 1, 64291 Darmstadt, Germany // Contact: http://go4.gsi.de //----------------------------------------------------------------------- // This software can be used under the license agreements as stated // in Go4License.txt file which is part of the distribution. //----------------------------------------------------------------------- #include "TGo4CreateNewHistogram.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include "TDirectory.h" #include "TROOT.h" #include "TGo4QSettings.h" #include TGo4CreateNewHistogram::TGo4CreateNewHistogram( QWidget *parent) : QDialog( parent) { setObjectName("Go4CreateNewHistogram"); setupUi(this); QObject::connect(CreateHistogram, &QPushButton::clicked, this, &TGo4CreateNewHistogram::CreateLocalHist); QObject::connect(CreateRemote, &QPushButton::clicked, this, &TGo4CreateNewHistogram::CreateRemoteHis); HisName->setText(go4sett->getHistName()); HisTitle->setText(go4sett->getHistTitle()); HisClassGrp = new QButtonGroup(this); HisClassGrp->addButton(TH1_b, 1); HisClassGrp->addButton(TH2_b, 2); HisClassGrp->addButton(TH3_b, 3); HisTypeGrp = new QButtonGroup(this); HisTypeGrp->addButton(S_b, 1); HisTypeGrp->addButton(D_b, 2); HisTypeGrp->addButton(F_b, 3); HisTypeGrp->addButton(I_b, 4); HisTypeGrp->addButton(C_b, 5); int htype = go4sett->getHistType(); HisClassGrp->button(htype / 10)->setChecked(true); HisTypeGrp->button(htype % 10)->setChecked(true); int npoints; double min, max; go4sett->getHistAxisPars(0, npoints, min, max); XNoOfBins->setText(QString::number(npoints)); Xmin->setText(QString::number(min)); Xmax->setText(QString::number(max)); go4sett->getHistAxisPars(1, npoints, min, max); YNoOfBins->setText(QString::number(npoints)); Ymin->setText(QString::number(min)); Ymax->setText(QString::number(max)); go4sett->getHistAxisPars(2, npoints, min, max); ZNoOfBins->setText(QString::number(npoints)); Zmin->setText(QString::number(min)); Zmax->setText(QString::number(max)); fSelectedCmd = 0; } void TGo4CreateNewHistogram::SetAnalysisAvaliable(bool on) { CreateRemote->setEnabled(on); } void TGo4CreateNewHistogram::SetLocalAvaliable(bool on) { CreateHistogram->setEnabled(on); } int TGo4CreateNewHistogram::GetSelectedCmd() { return fSelectedCmd; } TH1 *TGo4CreateNewHistogram::MakeHistogram() { QByteArray bname = HisName->text().toLatin1(); QByteArray btitle = HisTitle->text().toLatin1(); const char *hname = bname.constData(); const char *htitle = btitle.constData(); int htype = HisClassGrp->checkedId()*10 + HisTypeGrp->checkedId(); int nxbins = XNoOfBins->text().toInt(); int nybins = YNoOfBins->text().toInt(); int nzbins = ZNoOfBins->text().toInt(); double xmin = Xmin->text().toDouble(); double xmax = Xmax->text().toDouble(); double ymin = Ymin->text().toDouble(); double ymax = Ymax->text().toDouble(); double zmin = Zmin->text().toDouble(); double zmax = Zmax->text().toDouble(); go4sett->setHistName(hname); go4sett->setHistTitle(htitle); go4sett->setHistType(htype); go4sett->setHistAxisPars(0, nxbins, xmin, xmax); go4sett->setHistAxisPars(1, nybins, ymin, ymax); go4sett->setHistAxisPars(2, nzbins, zmin, zmax); TDirectory *savdir = gDirectory; gROOT->cd(); TH1 *h = nullptr; switch(htype) { case 11: h = new TH1S(hname, htitle, nxbins, xmin, xmax); break; case 12: h = new TH1D(hname, htitle, nxbins, xmin, xmax); break; case 13: h = new TH1F(hname, htitle, nxbins, xmin, xmax); break; case 14: h = new TH1I(hname, htitle, nxbins, xmin, xmax); break; case 15: h = new TH1C(hname, htitle, nxbins, xmin, xmax); break; case 21: h = new TH2S(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break; case 22: h = new TH2D(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break; case 23: h = new TH2F(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break; case 24: h = new TH2I(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break; case 25: h = new TH2C(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break; case 31: h = new TH3S(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break; case 32: h = new TH3D(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break; case 33: h = new TH3F(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break; case 34: h = new TH3I(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break; case 35: h = new TH3C(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break; } if (savdir) savdir->cd(); return h; } void TGo4CreateNewHistogram::CreateLocalHist() { fSelectedCmd = 1; accept(); } void TGo4CreateNewHistogram::CreateRemoteHis() { fSelectedCmd = 2; accept(); }