15 #include <CLHEP/Random/RandomEngine.h>
17 #include <HepMC/HerwigWrapper.h>
55 return instance->randomEngine->flat();
60 *
exit = FortranInstance::getInstance<Herwig6Instance>()->hwwarn(
function, *code);
67 throw cms::Exception(
"Herwig6Error") <<
"Herwig6 stopped run with error code " << *ecode <<
"." << std::endl;
83 #ifdef _POSIX_C_SOURCE
91 siglongjmp(
instance->timeoutPrivate->buf, 1);
96 throw cms::Exception(
"ReentrancyProblem") <<
"Herwig6Instance::timeout() called recursively." << std::endl;
97 struct sigaction saOld;
98 std::memset(&saOld, 0,
sizeof saOld);
100 struct itimerval itv;
101 timerclear(&itv.it_value);
102 timerclear(&itv.it_interval);
103 itv.it_value.tv_sec = 0;
104 itv.it_interval.tv_sec = 0;
105 setitimer(ITIMER_VIRTUAL, &itv,
nullptr);
109 sigaddset(&
ss, SIGVTALRM);
111 sigprocmask(SIG_UNBLOCK, &
ss,
nullptr);
112 sigprocmask(SIG_BLOCK, &
ss,
nullptr);
118 itv.it_value.tv_sec = 0;
119 itv.it_interval.tv_sec = 0;
120 setitimer(ITIMER_VIRTUAL, &itv,
nullptr);
121 sigprocmask(SIG_UNBLOCK, &
ss,
nullptr);
125 itv.it_value.tv_sec = secs;
126 itv.it_interval.tv_sec = secs;
127 setitimer(ITIMER_VIRTUAL, &itv,
nullptr);
130 std::memset(&sa, 0,
sizeof sa);
132 sa.sa_flags = SA_ONESHOT;
133 sigemptyset(&sa.sa_mask);
135 sigaction(SIGVTALRM, &sa, &saOld);
136 sigprocmask(SIG_UNBLOCK, &
ss,
nullptr);
143 itv.it_value.tv_sec = 0;
144 itv.it_interval.tv_sec = 0;
145 setitimer(ITIMER_VIRTUAL, &itv,
nullptr);
147 sigaction(SIGVTALRM, &saOld,
nullptr);
154 itv.it_value.tv_sec = 0;
155 itv.it_interval.tv_sec = 0;
156 setitimer(ITIMER_VIRTUAL, &itv,
nullptr);
158 sigaction(SIGVTALRM, &saOld,
nullptr);
174 typedef std::istringstream::traits_type traits;
176 const char *
p =
line.c_str(), *
q;
177 p += std::strspn(
p,
" \t\r\n");
179 for (
q =
p; std::isalnum(*
q);
q++)
183 const ConfigParam *param;
184 for (param = configParams; param->name; param++)
185 if (
name == param->name)
190 p =
q + std::strspn(
q,
" \t\r\n");
193 std::size_t
mult = 1;
194 for (
unsigned int i = 0;
i < 3;
i++) {
195 if (!param->dim[
i].size)
198 if (*
p++ != (
i ?
',' :
'('))
201 p += std::strspn(
p,
" \t\r\n");
203 for (
q =
p; std::isdigit(*
q);
q++)
208 if (
ss.bad() ||
ss.peek() != traits::eof())
211 if (index < param->dim[
i].
offset)
213 index -= param->dim[
i].offset;
214 if (
index >= param->dim[
i].size)
217 p =
q + std::strspn(
q,
" \t\r\n");
220 mult *= param->dim[
i].size;
223 if (param->dim[0].size) {
226 p += std::strspn(
p,
" \t\r\n");
231 p += std::strspn(
p,
" \t\r\n");
233 for (
q =
p; *
q && (std::isalnum(*
q) || std::strchr(
".-+", *
q));
q++)
237 p =
q + std::strspn(
q,
" \t\r\n");
241 switch (param->type) {
245 if (
ss.bad() ||
ss.peek() != traits::eof())
254 if (
ss.bad() ||
ss.peek() != traits::eof())
257 ((
double *)param->ptr)[
pos] =
value;
263 if (
ss.bad() ||
ss.peek() != traits::eof())
266 for (std::string::iterator iter = value_.begin(); iter != value_.end(); ++iter)
267 *iter = std::tolower(*iter);
269 if (value_ ==
"yes" || value_ ==
"true" || value_ ==
"1")
271 else if (value_ ==
"no" || value_ ==
"false" || value_ ==
"0")