10 # include <sys/time.h>
15 #include <CLHEP/Random/RandomEngine.h>
17 #include <HepMC/HerwigWrapper.h>
57 assert(instance != 0);
65 *exit = FortranInstance::getInstance<Herwig6Instance>()->hwwarn(
function, *code);
75 <<
"Herwig6 stopped run with error code " << *ecode
100 #ifdef _POSIX_C_SOURCE
107 assert(instance != 0);
116 <<
"Herwig6Instance::timeout() called recursively."
118 struct sigaction saOld;
119 std::memset(&saOld, 0,
sizeof saOld);
121 struct itimerval itv;
122 timerclear(&itv.it_value);
123 timerclear(&itv.it_interval);
124 itv.it_value.tv_sec = 0;
125 itv.it_interval.tv_sec = 0;
126 setitimer(ITIMER_VIRTUAL, &itv,
NULL);
130 sigaddset(&ss, SIGVTALRM);
132 sigprocmask(SIG_UNBLOCK, &ss,
NULL);
133 sigprocmask(SIG_BLOCK, &ss,
NULL);
140 itv.it_value.tv_sec = 0;
141 itv.it_interval.tv_sec = 0;
142 setitimer(ITIMER_VIRTUAL, &itv,
NULL);
143 sigprocmask(SIG_UNBLOCK, &ss,
NULL);
147 itv.it_value.tv_sec = secs;
148 itv.it_interval.tv_sec = secs;
149 setitimer(ITIMER_VIRTUAL, &itv,
NULL);
152 std::memset(&sa, 0,
sizeof sa);
154 sa.sa_flags = SA_ONESHOT;
155 sigemptyset(&sa.sa_mask);
157 sigaction(SIGVTALRM, &sa, &saOld);
158 sigprocmask(SIG_UNBLOCK, &ss,
NULL);
166 itv.it_value.tv_sec = 0;
167 itv.it_interval.tv_sec = 0;
168 setitimer(ITIMER_VIRTUAL, &itv,
NULL);
170 sigaction(SIGVTALRM, &saOld,
NULL);
178 itv.it_value.tv_sec = 0;
179 itv.it_interval.tv_sec = 0;
180 setitimer(ITIMER_VIRTUAL, &itv,
NULL);
182 sigaction(SIGVTALRM, &saOld,
NULL);
203 typedef std::istringstream::traits_type traits;
205 const char *
p = line.c_str(), *
q;
206 p += std::strspn(p,
" \t\r\n");
208 for(
q = p; std::isalnum(*
q);
q++);
211 const ConfigParam *param;
212 for(param = configParams; param->name; param++)
213 if (name == param->name)
218 p =
q + std::strspn(
q,
" \t\r\n");
221 std::size_t
mult = 1;
222 for(
unsigned int i = 0;
i < 3;
i++) {
223 if (!param->dim[
i].size)
226 if (*p++ != (
i ?
',' :
'('))
229 p += std::strspn(p,
" \t\r\n");
231 for(
q = p; std::isdigit(*
q);
q++);
235 if (ss.bad() || ss.peek() != traits::eof())
238 if (index < param->dim[
i].
offset)
240 index -= param->dim[
i].offset;
241 if (index >= param->dim[
i].size)
244 p =
q + std::strspn(
q,
" \t\r\n");
247 mult *= param->dim[
i].size;
250 if (param->dim[0].size) {
253 p += std::strspn(p,
" \t\r\n");
258 p += std::strspn(p,
" \t\r\n");
260 for(
q = p; *
q && (std::isalnum(*
q) || std::strchr(
".-+", *
q));
q++);
263 p =
q + std::strspn(
q,
" \t\r\n");
267 switch(param->type) {
271 if (ss.bad() || ss.peek() != traits::eof())
274 ((
int*)param->ptr)[pos] =
value;
280 if (ss.bad() || ss.peek() != traits::eof())
283 ((
double*)param->ptr)[pos] =
value;
289 if (ss.bad() || ss.peek() != traits::eof())
292 for(std::string::iterator iter = value_.begin();
293 iter != value_.end(); ++iter)
294 *iter = std::tolower(*iter);
296 if (value_ ==
"yes" || value_ ==
"true" || value_ ==
"1")
298 else if (value_ ==
"no" || value_ ==
"false" || value_ ==
"0")
303 ((
int*)param->ptr)[pos] =
value;
CLHEP::HepRandomEngine * randomEngine
Herwig6Instance(CLHEP::HepRandomEngine *randomEngine=0)
static PFTauRenderPlugin instance
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 *)
float __attribute__((vector_size(8))) float32x2_t
virtual bool hwwarn(const std::string &fn, int code)
CLHEP::HepRandomEngine * randomEngine
void lunread_(const char filename[], const int length)
std::string fullPath() const
virtual ~Herwig6Instance()