10 # include <sys/time.h> 15 #include <CLHEP/Random/RandomEngine.h> 17 #include <HepMC/HerwigWrapper.h> 55 assert(instance !=
nullptr);
63 *exit = FortranInstance::getInstance<Herwig6Instance>()->hwwarn(
function, *code);
73 <<
"Herwig6 stopped run with error code " << *ecode
96 #ifdef _POSIX_C_SOURCE 103 assert(instance !=
nullptr);
112 <<
"Herwig6Instance::timeout() called recursively." 114 struct sigaction saOld;
115 std::memset(&saOld, 0,
sizeof saOld);
117 struct itimerval itv;
118 timerclear(&itv.it_value);
119 timerclear(&itv.it_interval);
120 itv.it_value.tv_sec = 0;
121 itv.it_interval.tv_sec = 0;
122 setitimer(ITIMER_VIRTUAL, &itv,
nullptr);
126 sigaddset(&ss, SIGVTALRM);
128 sigprocmask(SIG_UNBLOCK, &ss,
nullptr);
129 sigprocmask(SIG_BLOCK, &ss,
nullptr);
135 itv.it_value.tv_sec = 0;
136 itv.it_interval.tv_sec = 0;
137 setitimer(ITIMER_VIRTUAL, &itv,
nullptr);
138 sigprocmask(SIG_UNBLOCK, &ss,
nullptr);
142 itv.it_value.tv_sec = secs;
143 itv.it_interval.tv_sec = secs;
144 setitimer(ITIMER_VIRTUAL, &itv,
nullptr);
147 std::memset(&sa, 0,
sizeof sa);
149 sa.sa_flags = SA_ONESHOT;
150 sigemptyset(&sa.sa_mask);
152 sigaction(SIGVTALRM, &sa, &saOld);
153 sigprocmask(SIG_UNBLOCK, &ss,
nullptr);
161 itv.it_value.tv_sec = 0;
162 itv.it_interval.tv_sec = 0;
163 setitimer(ITIMER_VIRTUAL, &itv,
nullptr);
165 sigaction(SIGVTALRM, &saOld,
nullptr);
172 itv.it_value.tv_sec = 0;
173 itv.it_interval.tv_sec = 0;
174 setitimer(ITIMER_VIRTUAL, &itv,
nullptr);
176 sigaction(SIGVTALRM, &saOld,
nullptr);
197 typedef std::istringstream::traits_type traits;
199 const char *
p = line.c_str(), *
q;
200 p += std::strspn(p,
" \t\r\n");
202 for(
q = p; std::isalnum(*
q);
q++);
205 const ConfigParam *param;
206 for(param = configParams; param->name; param++)
207 if (name == param->name)
212 p =
q + std::strspn(
q,
" \t\r\n");
215 std::size_t mult = 1;
216 for(
unsigned int i = 0;
i < 3;
i++) {
217 if (!param->dim[
i].size)
220 if (*p++ != (
i ?
',' :
'('))
223 p += std::strspn(p,
" \t\r\n");
225 for(
q = p; std::isdigit(*
q);
q++);
229 if (ss.bad() || ss.peek() != traits::eof())
232 if (index < param->dim[
i].
offset)
234 index -= param->dim[
i].offset;
235 if (index >= param->dim[
i].size)
238 p =
q + std::strspn(
q,
" \t\r\n");
241 mult *= param->dim[
i].size;
244 if (param->dim[0].size) {
247 p += std::strspn(p,
" \t\r\n");
252 p += std::strspn(p,
" \t\r\n");
254 for(
q = p; *
q && (std::isalnum(*
q) || std::strchr(
".-+", *
q));
q++);
257 p =
q + std::strspn(
q,
" \t\r\n");
261 switch(param->type) {
265 if (ss.bad() || ss.peek() != traits::eof())
268 ((
int*)param->ptr)[pos] =
value;
274 if (ss.bad() || ss.peek() != traits::eof())
277 ((
double*)param->ptr)[pos] =
value;
283 if (ss.bad() || ss.peek() != traits::eof())
286 for(std::string::iterator iter = value_.begin();
287 iter != value_.end(); ++iter)
288 *iter = std::tolower(*iter);
290 if (value_ ==
"yes" || value_ ==
"true" || value_ ==
"1")
292 else if (value_ ==
"no" || value_ ==
"false" || value_ ==
"0")
297 ((
int*)param->ptr)[pos] =
value;
CLHEP::HepRandomEngine * randomEngine
static PFTauRenderPlugin instance
bool timeout(unsigned int secs, void(*fn)())
static void _timeout_sighandler(int signr)
void openParticleSpecFile(const std::string fileName)
__attribute__((visibility("hidden"))) void dummy()
~Herwig6Instance() override
bool give(const std::string &line)
void cms_hwwarn_(char fn[6], int *, int *)
virtual bool hwwarn(const std::string &fn, int code)
CLHEP::HepRandomEngine * randomEngine
void lunread_(const char filename[], const int length)
std::string fullPath() const
std::unique_ptr< TimeoutHolder > timeoutPrivate
void cmsending_(int *ecode)