GEMC  2.3
Geant4 Monte-Carlo Framework
primaryTab.cc
Go to the documentation of this file.
1 // gemc headers
2 #include "primaryTab.h"
3 #include "momControls.h"
4 #include "string_utilities.h"
5 
6 // G4 headers
7 #include "G4ParticleTable.hh"
8 
9 // CLHEP units
10 #include "CLHEP/Units/PhysicalConstants.h"
11 using namespace CLHEP;
12 
13 
14 lumiEvent::lumiEvent(goptions *Opts, QWidget *parent, string type)
15 {
16  // Getting Luminosity Event infos from command line
17  vector<string> values = get_info(Opts->optMap["LUMI_EVENT"].args);
18  int lnevents = (int) get_number(values[0]);
19  double twindow = get_number(values[1]);
20  double tbunch = get_number(values[2]);
21 
22  if(type == "Lumi2")
23  {
24  values = get_info(Opts->optMap["LUMI2_EVENT"].args);
25  lnevents = (int) get_number(values[0]);
26  tbunch = get_number(values[1]);
27  }
28 
29  QLabel *neventLabel = new QLabel(tr("N. Particles/Event"));
30  QLabel *timewindowLabel = NULL;
31  if( type == "Primary") timewindowLabel = new QLabel(tr("Dummy, not displayed\n"));
32  if( type == "Lumi1") timewindowLabel = new QLabel(tr("Time Window"));
33  if( type == "Lumi2") timewindowLabel = new QLabel(tr(""));
34  QLabel *bunchLabel = new QLabel(tr("Bunch Time"));
35  neventLabel->setFixedHeight(10);
36  timewindowLabel->setFixedHeight(10);
37  bunchLabel->setFixedHeight(10);
38  QHBoxLayout *lumiHLayout = new QHBoxLayout;
39  lumiHLayout->addSpacing(45);
40  lumiHLayout->addWidget(neventLabel);
41  lumiHLayout->addSpacing(25);
42  lumiHLayout->addWidget(timewindowLabel);
43  lumiHLayout->addSpacing(20);
44  lumiHLayout->addWidget(bunchLabel);
45 
46  nevents = new QLineEdit();
47  timewindow = new QLineEdit();
48  time_bunch = new QLineEdit();
49  nevents->setMaximumWidth(100);
50  timewindow->setMaximumWidth(100);
51  time_bunch->setMaximumWidth(100);
52  nevents->setMinimumHeight(18);
53  timewindow->setMinimumHeight(18);
54  time_bunch->setMinimumHeight(18);
55  QHBoxLayout *lumiHLayout2 = new QHBoxLayout;
56  lumiHLayout2->addWidget(nevents);
57  if( type == "Lumi1") lumiHLayout2->addWidget(timewindow);
58  if( type == "Lumi2") lumiHLayout2->addSpacing(135);
59  lumiHLayout2->addWidget(time_bunch);
60 
61  QString L_ne = stringify(lnevents).c_str();
62  nevents->setText(L_ne);
63 
64  QString L_tw = stringify(twindow/ns).c_str() + QString("*ns");
65  timewindow->setText(L_tw);
66 
67  QString L_tb = stringify(tbunch/ns).c_str() + QString("*ns");
68  time_bunch->setText(L_tb);
69 
70  connect ( nevents , SIGNAL( textChanged(const QString & ) ), parent, SLOT( changePars() ) );
71  connect ( timewindow , SIGNAL( textChanged(const QString & ) ), parent, SLOT( changePars() ) );
72  connect ( time_bunch , SIGNAL( textChanged(const QString & ) ), parent, SLOT( changePars() ) );
73 
74  LumiGroup = new QGroupBox(tr(""));
75  QVBoxLayout *LLayout = new QVBoxLayout;
76  LLayout->addLayout(lumiHLayout);
77  LLayout->addLayout(lumiHLayout2);
78  LLayout->addStretch(1);
79  LumiGroup->setMaximumHeight(52);
80 
81  LumiGroup->setLayout(LLayout);
82 
83 }
84 
85 
86 
87 particleTab::particleTab(QWidget *parent, goptions *Opts, string t) : QWidget(parent)
88 {
89 
90  type = t;
91  verbosity = (int) Opts->optMap["GEN_VERBOSITY"].arg;
92 
93  // luminosity event
94  lEvent = new lumiEvent(Opts, parent, type);
95 
96  // momentum
97  momControl = new momControls(Opts, type);
98 
99  connect ( momControl->beam_particle, SIGNAL( currentIndexChanged(int) ) , parent, SLOT( changePars() ) );
100  connect ( momControl->momLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
101  connect ( momControl->rmomLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
102  connect ( momControl->momUnits , SIGNAL( currentIndexChanged(int) ) , parent, SLOT( changePars() ) );
103  connect ( momControl->theLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
104  connect ( momControl->rtheLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
105  connect ( momControl->theUnits , SIGNAL( currentIndexChanged(int) ) , parent, SLOT( changePars() ) );
106  connect ( momControl->phiLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
107  connect ( momControl->rphiLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
108  connect ( momControl->theUnits , SIGNAL( currentIndexChanged(int) ) , parent, SLOT( changePars() ) );
109 
110 
111  // vertex
112  vtxControl = new vtxControls(Opts, type);
113 
114  connect ( vtxControl->vxLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
115  connect ( vtxControl->vyLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
116  connect ( vtxControl->vzLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
117  connect ( vtxControl->vtxUnits , SIGNAL( currentIndexChanged(int) ) , parent, SLOT( changePars() ) );
118  connect ( vtxControl->rvrLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
119  connect ( vtxControl->rvzLE , SIGNAL( textEdited(const QString &)), parent, SLOT( changePars() ) );
120 
121 
122 
123  // All together
124  QVBoxLayout *mainLayout = new QVBoxLayout;
125  if(type == "Lumi1" || type == "Lumi2")
126  mainLayout->addWidget(lEvent->LumiGroup);
127 
128  mainLayout->addWidget(momControl->momentumGroup);
129  mainLayout->addWidget(vtxControl->vertexGroup);
130  mainLayout->addStretch(1);
131  setLayout(mainLayout);
132 
133 }
134 
135 
136 
138 {
139  string L_ne = qs_tostring(lEvent->nevents->text());
140  string L_tw = qs_tostring(lEvent->timewindow->text());
141  string L_tb = qs_tostring(lEvent->time_bunch->text());
142 
143  string lumi_event = L_ne + ", " + L_tw + ", " + L_tb;
144  if(t != 0) lumi_event = L_ne + ", " + stringify(t) + "*ns, " + L_tb;
145 
146  if(verbosity)
147  cout << " - GUI Generator Settings: " << type << " lumi event " << lumi_event << endl;
148 
149  return lumi_event;
150 }
151 
153 {
154  return get_number(qs_tostring(lEvent->timewindow->text()));
155 }
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
QComboBox * beam_particle
Definition: momControls.h:27
lumiEvent * lEvent
Definition: primaryTab.h:48
QGroupBox * vertexGroup
Definition: vtxControls.h:42
QLineEdit * rtheLE
Definition: momControls.h:31
QLineEdit * time_bunch
Definition: primaryTab.h:26
QLineEdit * momLE
Definition: momControls.h:30
QGroupBox * LumiGroup
Definition: primaryTab.h:28
string type
Definition: primaryTab.h:43
particleTab(QWidget *, goptions *, string)
Definition: primaryTab.cc:87
double get_time_window()
Definition: primaryTab.cc:152
vector< string > get_info(string input, string chars)
get information from strings such as "5*GeV, 2*deg, 10*deg", parses out strings in second argument ...
QLineEdit * vyLE
Definition: vtxControls.h:31
QLineEdit * nevents
Definition: primaryTab.h:24
QLineEdit * vxLE
Definition: vtxControls.h:30
QLineEdit * rphiLE
Definition: momControls.h:32
QLineEdit * rmomLE
Definition: momControls.h:30
double get_number(string v, int warn_no_unit)
Returns number with dimension from string, i.e. 100*cm.
momControls * momControl
Definition: primaryTab.h:50
string stringify(double x)
QLineEdit * vzLE
Definition: vtxControls.h:32
map< string, aopt > optMap
Options map.
Definition: options.h:75
string get_lumi_event(double)
Definition: primaryTab.cc:137
lumiEvent(goptions *Opts, QWidget *, string)
Definition: primaryTab.cc:14
QLineEdit * timewindow
Definition: primaryTab.h:25
string qs_tostring(QString input)
int verbosity
Definition: primaryTab.h:44
QLineEdit * rvrLE
Definition: vtxControls.h:34
QComboBox * theUnits
Definition: momControls.h:35
vtxControls * vtxControl
Definition: primaryTab.h:51
QLineEdit * theLE
Definition: momControls.h:31
QGroupBox * momentumGroup
Definition: momControls.h:38
QComboBox * vtxUnits
Definition: vtxControls.h:39
QLineEdit * phiLE
Definition: momControls.h:32
QComboBox * momUnits
Definition: momControls.h:35
QLineEdit * rvzLE
Definition: vtxControls.h:35