6 #include "G4ParticleTable.hh" 10 #include "CLHEP/Units/PhysicalConstants.h" 11 using namespace CLHEP;
15 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
18 vector<string> values;
21 if(type ==
"Primary") values =
get_info(Opts->
optMap[
"BEAM_P"].args);
22 if(type ==
"Lumi1") values =
get_info(Opts->
optMap[
"LUMI_P"].args);
23 if(type ==
"Lumi2") values =
get_info(Opts->
optMap[
"LUMI2_P"].args);
27 if(!particleTable->FindParticle(pname))
28 cout <<
" !! GUI Control: Particle " << pname <<
" not found in G4 table." << endl << endl;
31 beam_particle =
new QComboBox;
33 beam_particle->addItem(pname.c_str());
34 beam_particle->addItem(
"e-");
35 beam_particle->addItem(
"proton");
36 beam_particle->addItem(
"pi+");
37 beam_particle->addItem(
"pi-");
38 beam_particle->addItem(
"kaon+");
39 beam_particle->addItem(
"kaon-");
40 for(
int i=0; i<particleTable->entries(); i++)
41 beam_particle->addItem(particleTable->GetParticleName(i).c_str());
44 QHBoxLayout *beam_particleLayout =
new QHBoxLayout;
45 beam_particleLayout->addSpacing(40);
46 beam_particleLayout->addWidget(
new QLabel(tr(
"Particle Type:")));
47 beam_particleLayout->addWidget(beam_particle);
48 beam_particleLayout->addStretch(1);
53 momLE =
new QLineEdit(tr(
"10"));
54 momLE->setMaximumWidth(100);
56 rmomLE =
new QLineEdit(tr(
"0"));
57 rmomLE->setMaximumWidth(100);
60 momUnits =
new QComboBox;
61 momUnits->addItem(tr(
"GeV"));
62 momUnits->addItem(tr(
"MeV"));
63 momUnits->addItem(tr(
"eV"));
64 momUnits->addItem(tr(
"KeV"));
65 momUnits->addItem(tr(
"TeV"));
67 QHBoxLayout *momLayout =
new QHBoxLayout;
68 momLayout->addWidget(
new QLabel(tr(
"p: ")));
69 momLayout->addWidget(momLE);
70 momLayout->addWidget(
new QLabel(tr(
" ± ")));
71 momLayout->addWidget(rmomLE);
72 momLayout->addWidget(momUnits);
73 momLayout->addStretch(1);
77 theLE =
new QLineEdit(tr(
"0"));
78 theLE->setMaximumWidth(100);
80 rtheLE =
new QLineEdit(tr(
"0"));
81 rtheLE->setMaximumWidth(100);
84 theUnits =
new QComboBox;
85 theUnits->addItem(tr(
"deg"));
86 theUnits->addItem(tr(
"rad"));
88 QHBoxLayout *theLayout =
new QHBoxLayout;
89 theLayout->addWidget(
new QLabel(tr(
"θ: ")));
90 theLayout->addWidget(theLE);
91 theLayout->addWidget(
new QLabel(tr(
" ± ")));
92 theLayout->addWidget(rtheLE);
93 theLayout->addWidget(theUnits);
94 theLayout->addStretch(1);
99 phiLE =
new QLineEdit(tr(
"0"));
100 phiLE->setMaximumWidth(100);
102 rphiLE =
new QLineEdit(tr(
"0"));
103 rphiLE->setMaximumWidth(100);
106 phiUnits =
new QComboBox;
107 phiUnits->addItem(tr(
"deg"));
108 phiUnits->addItem(tr(
"rad"));
110 QHBoxLayout *phiLayout =
new QHBoxLayout;
111 phiLayout->addWidget(
new QLabel(tr(
"φ: ")));
112 phiLayout->addWidget(phiLE);
113 phiLayout->addWidget(
new QLabel(tr(
" ± ")));
114 phiLayout->addWidget(rphiLE);
115 phiLayout->addWidget(phiUnits);
116 phiLayout->addStretch(1);
120 QVBoxLayout *mLayout =
new QVBoxLayout;
121 mLayout->addLayout(beam_particleLayout);
122 mLayout->addSpacing(10);
123 mLayout->addLayout(momLayout);
124 mLayout->addLayout(theLayout);
125 mLayout->addLayout(phiLayout);
127 momentumGroup =
new QGroupBox(tr(
"Momentum:"));
128 momentumGroup->setLayout(mLayout);
148 string particle =
qs_tostring(beam_particle->currentText());
150 string momU =
qs_tostring(momUnits->currentText());
152 string theU =
qs_tostring(theUnits->currentText());
154 string phiU =
qs_tostring(phiUnits->currentText());
156 string beam_p = particle +
", " +
157 mom +
"*" + momU +
", " +
158 the +
"*" + theU +
", " +
162 cout <<
" - GUI BEAM_P: " << beam_p << endl;
170 vector<string> values =
get_info(momOption);
172 if(values.size() == 4)
181 beam_particle->setCurrentIndex(beam_particle->findText(QString(pname.c_str())));
182 momLE->setText(QString(
stringify(mom).c_str()));
183 theLE->setText(QString(
stringify(theta).c_str()));
184 phiLE->setText(QString(
stringify(phi).c_str()));
195 string momU =
qs_tostring(momUnits->currentText());
197 string theU =
qs_tostring(theUnits->currentText());
199 string phiU =
qs_tostring(phiUnits->currentText());
201 string spread_p = rmom +
"*" + momU +
", " +
202 rthe +
"*" + theU +
", " +
206 cout <<
" - GUI SPREAD_P: " << spread_p << endl;
212 vector<string> values =
get_info(momOption);
214 if(values.size() == 3)
221 rmomLE->setText(QString(
stringify(dmom).c_str()));
222 rtheLE->setText(QString(
stringify(dtheta).c_str()));
223 rphiLE->setText(QString(
stringify(dphi).c_str()));
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 ...
string get_momentum(double verbosity)
double get_number(string v, int warn_no_unit)
Returns number with dimension from string, i.e. 100*cm.
string stringify(double x)
map< string, aopt > optMap
Options map.
string qs_tostring(QString input)
string get_rmomentum(double verbosity)
string TrimSpaces(string in)
Removes leading and trailing spaces.
void set_rmomentum(string momOption)
void set_momentum(string momOption)
momControls(goptions *Opts, string type)