14 #include <CLHEP/Random/RandomEngine.h>
16 #include <HepMC/HerwigWrapper.h>
54 {
return FortranInstance::getInstance<Herwig6Instance>()->
randomEngine->flat(); }
58 std::string
function(fn, fn +
sizeof fn);
59 *exit = FortranInstance::getInstance<Herwig6Instance>()->hwwarn(
function, *code);
69 <<
"Herwig6 stopped run with error code " << *ecode
94 #ifdef _POSIX_C_SOURCE
99 { siglongjmp(*(sigjmp_buf*)FortranInstance::getInstance<Herwig6Instance>()->
timeoutPrivate, 1); }
105 <<
"Herwig6Instance::timeout() called recursively."
107 struct sigaction saOld;
108 std::memset(&saOld, 0,
sizeof saOld);
110 struct itimerval itv;
111 timerclear(&itv.it_value);
112 timerclear(&itv.it_interval);
113 itv.it_value.tv_sec = 0;
114 itv.it_interval.tv_sec = 0;
115 setitimer(ITIMER_VIRTUAL, &itv,
NULL);
119 sigaddset(&ss, SIGVTALRM);
121 sigprocmask(SIG_UNBLOCK, &ss,
NULL);
122 sigprocmask(SIG_BLOCK, &ss,
NULL);
129 itv.it_value.tv_sec = 0;
130 itv.it_interval.tv_sec = 0;
131 setitimer(ITIMER_VIRTUAL, &itv,
NULL);
132 sigprocmask(SIG_UNBLOCK, &ss,
NULL);
136 itv.it_value.tv_sec = secs;
137 itv.it_interval.tv_sec = secs;
138 setitimer(ITIMER_VIRTUAL, &itv,
NULL);
141 std::memset(&sa, 0,
sizeof sa);
143 sa.sa_flags = SA_ONESHOT;
144 sigemptyset(&sa.sa_mask);
146 sigaction(SIGVTALRM, &sa, &saOld);
147 sigprocmask(SIG_UNBLOCK, &ss,
NULL);
155 itv.it_value.tv_sec = 0;
156 itv.it_interval.tv_sec = 0;
157 setitimer(ITIMER_VIRTUAL, &itv,
NULL);
159 sigaction(SIGVTALRM, &saOld,
NULL);
167 itv.it_value.tv_sec = 0;
168 itv.it_interval.tv_sec = 0;
169 setitimer(ITIMER_VIRTUAL, &itv,
NULL);
171 sigaction(SIGVTALRM, &saOld,
NULL);
192 typedef std::istringstream::traits_type traits;
194 const char *
p = line.c_str(), *
q;
195 p += std::strspn(p,
" \t\r\n");
197 for(
q = p; std::isalnum(*
q);
q++);
198 std::string
name(p,
q - p);
200 const ConfigParam *param;
201 for(param = configParams; param->name; param++)
202 if (name == param->name)
207 p =
q + std::strspn(
q,
" \t\r\n");
210 std::size_t
mult = 1;
211 for(
unsigned int i = 0;
i < 3;
i++) {
212 if (!param->dim[
i].size)
215 if (*p++ != (
i ?
',' :
'('))
218 p += std::strspn(p,
" \t\r\n");
220 for(
q = p; std::isdigit(*
q);
q++);
221 std::istringstream ss(std::string(p,
q - p));
224 if (ss.bad() || ss.peek() != traits::eof())
227 if (index < param->dim[
i].
offset)
229 index -= param->dim[
i].offset;
230 if (index >= param->dim[
i].size)
233 p =
q + std::strspn(
q,
" \t\r\n");
236 mult *= param->dim[
i].size;
239 if (param->dim[0].size) {
242 p += std::strspn(p,
" \t\r\n");
247 p += std::strspn(p,
" \t\r\n");
249 for(
q = p; *
q && (std::isalnum(*
q) || std::strchr(
".-+", *
q));
q++);
250 std::istringstream ss(std::string(p,
q - p));
252 p =
q + std::strspn(
q,
" \t\r\n");
256 switch(param->type) {
260 if (ss.bad() || ss.peek() != traits::eof())
269 if (ss.bad() || ss.peek() != traits::eof())
278 if (ss.bad() || ss.peek() != traits::eof())
281 for(std::string::iterator iter = value_.begin();
282 iter != value_.end(); ++iter)
283 *iter = std::tolower(*iter);
285 if (value_ ==
"yes" || value_ ==
"true" || value_ ==
"1")
287 else if (value_ ==
"no" || value_ ==
"false" || value_ ==
"0")
Herwig6Instance(CLHEP::HepRandomEngine *randomEngine=0)
CLHEP::HepRandomEngine * randomEngine
bool timeout(unsigned int secs, void(*fn)())
static void _timeout_sighandler(int signr)
void openParticleSpecFile(const std::string fileName)
CLHEP::HepRandomEngine & getEngineReference()
void cmsending_(int *ecode)
unsigned int offset(bool)
bool give(const std::string &line)
void cms_hwwarn_(char fn[6], int *, int *)
virtual bool hwwarn(const std::string &fn, int code)
void lunread_(const char filename[], const int length)
std::string fullPath() const
virtual ~Herwig6Instance()
class Geom::Polar2Cartesian __attribute__