15 #include <CLHEP/Random/RandomEngine.h>
17 #include <HepMC/HerwigWrapper.h>
53 assert(instance !=
nullptr);
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
89 assert(instance !=
nullptr);
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())
248 ((
int *)param->ptr)[pos] =
value;
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")
276 ((
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)
float __attribute__((vector_size(8))) cms_float32x2_t
~Herwig6Instance() override
void cmsending_(int *ecode)
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