GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4CreateNewHistogram.cpp
Go to the documentation of this file.
1 // $Id: TGo4CreateNewHistogram.cpp 3122 2021-03-30 08:16:50Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4CreateNewHistogram.h"
15 
16 #include "TH1.h"
17 #include "TH2.h"
18 #include "TH3.h"
19 #include "TDirectory.h"
20 #include "TROOT.h"
21 
22 #include "TGo4QSettings.h"
23 
24 #include <QButtonGroup>
25 
27  : QDialog( parent)
28 {
29  setObjectName("Go4CreateNewHistogram");
30  setupUi(this);
31  QObject::connect(CreateHistogram, SIGNAL(clicked()), this, SLOT(CreateLocalHist()));
32  QObject::connect(CreateRemote, SIGNAL(clicked()), this, SLOT(CreateRemoteHis()));
33  HisName->setText(go4sett->getHistName());
34  HisTitle->setText(go4sett->getHistTitle());
35 
36  HisClassGrp = new QButtonGroup(this);
37  HisClassGrp->addButton(TH1_b, 1);
38  HisClassGrp->addButton(TH2_b, 2);
39  HisClassGrp->addButton(TH3_b, 3);
40 
41  HisTypeGrp = new QButtonGroup(this);
42  HisTypeGrp->addButton(S_b, 1);
43  HisTypeGrp->addButton(D_b, 2);
44  HisTypeGrp->addButton(F_b, 3);
45  HisTypeGrp->addButton(I_b, 4);
46  HisTypeGrp->addButton(C_b, 5);
47 
48  int htype = go4sett->getHistType();
49  HisClassGrp->button(htype / 10)->setChecked(true);
50  HisTypeGrp->button(htype % 10)->setChecked(true);
51 
52  int npoints;
53  double min, max;
54 
55  go4sett->getHistAxisPars(0, npoints, min, max);
56  XNoOfBins->setText(QString::number(npoints));
57  Xmin->setText(QString::number(min));
58  Xmax->setText(QString::number(max));
59 
60  go4sett->getHistAxisPars(1, npoints, min, max);
61  YNoOfBins->setText(QString::number(npoints));
62  Ymin->setText(QString::number(min));
63  Ymax->setText(QString::number(max));
64 
65  go4sett->getHistAxisPars(2, npoints, min, max);
66  ZNoOfBins->setText(QString::number(npoints));
67  Zmin->setText(QString::number(min));
68  Zmax->setText(QString::number(max));
69 
70  fSelectedCmd = 0;
71 }
72 
74 {
75  CreateRemote->setEnabled(on);
76 }
77 
79 {
80  CreateHistogram->setEnabled(on);
81 }
82 
84 {
85  return fSelectedCmd;
86 }
87 
89 {
90  QByteArray bname = HisName->text().toLatin1();
91  QByteArray btitle = HisTitle->text().toLatin1();
92 
93  const char* hname = bname.constData();
94  const char* htitle = btitle.constData();
95 
96  int htype = HisClassGrp->checkedId()*10 + HisTypeGrp->checkedId();
97 
98  int nxbins = XNoOfBins->text().toInt();
99  int nybins = YNoOfBins->text().toInt();
100  int nzbins = ZNoOfBins->text().toInt();
101 
102  double xmin = Xmin->text().toDouble();
103  double xmax = Xmax->text().toDouble();
104  double ymin = Ymin->text().toDouble();
105  double ymax = Ymax->text().toDouble();
106  double zmin = Zmin->text().toDouble();
107  double zmax = Zmax->text().toDouble();
108 
109  go4sett->setHistName(hname);
110  go4sett->setHistTitle(htitle);
111  go4sett->setHistType(htype);
112  go4sett->setHistAxisPars(0, nxbins, xmin, xmax);
113  go4sett->setHistAxisPars(1, nybins, ymin, ymax);
114  go4sett->setHistAxisPars(2, nzbins, zmin, zmax);
115 
116  TDirectory* savdir = gDirectory;
117  gROOT->cd();
118  TH1* h = 0;
119  switch(htype) {
120  case 11: h = new TH1S(hname, htitle, nxbins, xmin, xmax); break;
121  case 12: h = new TH1D(hname, htitle, nxbins, xmin, xmax); break;
122  case 13: h = new TH1F(hname, htitle, nxbins, xmin, xmax); break;
123  case 14: h = new TH1I(hname, htitle, nxbins, xmin, xmax); break;
124  case 15: h = new TH1C(hname, htitle, nxbins, xmin, xmax); break;
125  case 21: h = new TH2S(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
126  case 22: h = new TH2D(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
127  case 23: h = new TH2F(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
128  case 24: h = new TH2I(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
129  case 25: h = new TH2C(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
130  case 31: h = new TH3S(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
131  case 32: h = new TH3D(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
132  case 33: h = new TH3F(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
133  case 34: h = new TH3I(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
134  case 35: h = new TH3C(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
135  }
136 
137  if (savdir!=0) savdir->cd();
138 
139  return h;
140 }
141 
143 {
144  fSelectedCmd = 1;
145  accept();
146 }
147 
149 {
150  fSelectedCmd = 2;
151  accept();
152 }
153 
154 
void setHistType(int value)
QString getHistName()
void getHistAxisPars(int naxis, int &npoints, double &min, double &max)
void setHistAxisPars(int naxis, int npoints, double min, double max)
void setHistName(const QString &value)
TGo4QSettings * go4sett
void setHistTitle(const QString &value)
TGo4CreateNewHistogram(QWidget *parent=0)
QString getHistTitle()