CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
gen::Herwig6Instance Class Reference

#include <Herwig6Instance.h>

Inheritance diagram for gen::Herwig6Instance:
gen::FortranInstance gen::PomwigHadronizer Herwig6Hadronizer MCatNLOSource

Public Member Functions

bool callWithTimeout (unsigned int secs, void(*fn)())
 
bool give (const std::string &line)
 
 Herwig6Instance ()
 
void openParticleSpecFile (const std::string fileName)
 
void setHerwigRandomEngine (CLHEP::HepRandomEngine *v)
 
 ~Herwig6Instance () override
 
- Public Member Functions inherited from gen::FortranInstance
void call (void(&fn)())
 
template<typename T >
T call (T(&fn)())
 
template<typename A >
void call (void(&fn)(A), A a)
 
template<typename T , typename A >
T call (T(&fn)(A), A a)
 
template<typename A1 , typename A2 >
void call (void(&fn)(A1, A2), A1 a1, A2 a2)
 
template<typename T , typename A1 , typename A2 >
T call (T(&fn)(A1, A2), A1 a1, A2 a2)
 
virtual void enter ()
 
 FortranInstance ()
 
virtual void leave ()
 
virtual void upEvnt ()
 
virtual void upInit ()
 
virtual bool upVeto ()
 
virtual ~FortranInstance () noexcept(false)
 

Protected Member Functions

virtual bool hwwarn (const std::string &fn, int code)
 

Private Member Functions

bool timeout (unsigned int secs, void(*fn)())
 

Static Private Member Functions

static void _timeout_sighandler (int signr)
 

Private Attributes

CLHEP::HepRandomEngine * randomEngine
 
std::unique_ptr< TimeoutHoldertimeoutPrivate
 

Friends

void gen::cms_hwwarn_ (char fn[6], int *, int *)
 
double gen::hwrgen_ (int *)
 

Additional Inherited Members

- Static Public Member Functions inherited from gen::FortranInstance
template<typename T >
static TgetInstance ()
 
- Static Public Attributes inherited from gen::FortranInstance
static const std::string kFortranInstance = "FortranInstance"
 

Detailed Description

Definition at line 22 of file Herwig6Instance.h.

Constructor & Destructor Documentation

Herwig6Instance::Herwig6Instance ( )

Definition at line 77 of file Herwig6Instance.cc.

77 : randomEngine(nullptr), timeoutPrivate() {}
CLHEP::HepRandomEngine * randomEngine
std::unique_ptr< TimeoutHolder > timeoutPrivate
Herwig6Instance::~Herwig6Instance ( )
override

Definition at line 79 of file Herwig6Instance.cc.

79 {}

Member Function Documentation

static void gen::Herwig6Instance::_timeout_sighandler ( int  signr)
staticprivate
bool gen::Herwig6Instance::callWithTimeout ( unsigned int  secs,
void(*)()  fn 
)
inline

Definition at line 30 of file Herwig6Instance.h.

References personalPlayback::fn, timeout(), and wrapper.

Referenced by gen::PomwigHadronizer::generatePartonsAndHadronize(), and Herwig6Hadronizer::hadronize().

30  {
31  InstanceWrapper wrapper(this);
32  return timeout(secs, fn);
33  }
bool timeout(unsigned int secs, void(*fn)())
static HepMC::HEPEVT_Wrapper wrapper
bool Herwig6Instance::give ( const std::string &  line)

Definition at line 173 of file Herwig6Instance.cc.

References mps_fire::i, VarParsing::mult, mergeVDriftHistosByStation::name, hltrates_dqm_sourceclient-live_cfg::offset, gen::p, submitPVResolutionJobs::q, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and relativeConstraints::value.

Referenced by Herwig6Hadronizer::initialize(), gen::PomwigHadronizer::readSettings(), Herwig6Hadronizer::readSettings(), Herwig6Hadronizer::upEvnt(), and Herwig6Hadronizer::upInit().

173  {
174  typedef std::istringstream::traits_type traits;
175 
176  const char *p = line.c_str(), *q;
177  p += std::strspn(p, " \t\r\n");
178 
179  for (q = p; std::isalnum(*q); q++)
180  ;
181  std::string name(p, q - p);
182 
183  const ConfigParam *param;
184  for (param = configParams; param->name; param++)
185  if (name == param->name)
186  break;
187  if (!param->name)
188  return false;
189 
190  p = q + std::strspn(q, " \t\r\n");
191 
192  std::size_t pos = 0;
193  std::size_t mult = 1;
194  for (unsigned int i = 0; i < 3; i++) {
195  if (!param->dim[i].size)
196  break;
197 
198  if (*p++ != (i ? ',' : '('))
199  return false;
200 
201  p += std::strspn(p, " \t\r\n");
202 
203  for (q = p; std::isdigit(*q); q++)
204  ;
205  std::istringstream ss(std::string(p, q - p));
206  std::size_t index;
207  ss >> index;
208  if (ss.bad() || ss.peek() != traits::eof())
209  return false;
210 
211  if (index < param->dim[i].offset)
212  return false;
213  index -= param->dim[i].offset;
214  if (index >= param->dim[i].size)
215  return false;
216 
217  p = q + std::strspn(q, " \t\r\n");
218 
219  pos += mult * index;
220  mult *= param->dim[i].size;
221  }
222 
223  if (param->dim[0].size) {
224  if (*p++ != ')')
225  return false;
226  p += std::strspn(p, " \t\r\n");
227  }
228 
229  if (*p++ != '=')
230  return false;
231  p += std::strspn(p, " \t\r\n");
232 
233  for (q = p; *q && (std::isalnum(*q) || std::strchr(".-+", *q)); q++)
234  ;
235  std::istringstream ss(std::string(p, q - p));
236 
237  p = q + std::strspn(q, " \t\r\n");
238  if (*p && *p != '!')
239  return false;
240 
241  switch (param->type) {
242  case kInt: {
243  int value;
244  ss >> value;
245  if (ss.bad() || ss.peek() != traits::eof())
246  return false;
247 
248  ((int *)param->ptr)[pos] = value;
249  break;
250  }
251  case kDouble: {
252  double value;
253  ss >> value;
254  if (ss.bad() || ss.peek() != traits::eof())
255  return false;
256 
257  ((double *)param->ptr)[pos] = value;
258  break;
259  }
260  case kLogical: {
261  std::string value_;
262  ss >> value_;
263  if (ss.bad() || ss.peek() != traits::eof())
264  return false;
265 
266  for (std::string::iterator iter = value_.begin(); iter != value_.end(); ++iter)
267  *iter = std::tolower(*iter);
268  bool value;
269  if (value_ == "yes" || value_ == "true" || value_ == "1")
270  value = true;
271  else if (value_ == "no" || value_ == "false" || value_ == "0")
272  value = false;
273  else
274  return false;
275 
276  ((int *)param->ptr)[pos] = value;
277  break;
278  }
279  }
280 
281  return true;
282 }
double p[5][pyjets_maxn]
bool Herwig6Instance::hwwarn ( const std::string &  fn,
int  code 
)
protectedvirtual

Reimplemented in MCatNLOSource.

Definition at line 169 of file Herwig6Instance.cc.

169 { return false; }
void Herwig6Instance::openParticleSpecFile ( const std::string  fileName)

Definition at line 284 of file Herwig6Instance.cc.

References edm::FileInPath::fullPath(), and lunread_().

Referenced by Herwig6Hadronizer::initialize(), and Herwig6Hadronizer::readSettings().

284  {
285  edm::FileInPath fileAndPath(fileName);
286  // WARING : This will call HWWARN if file does not exist.
287  lunread_(fileAndPath.fullPath().c_str(), strlen(fileAndPath.fullPath().c_str()));
288 
289  return;
290 }
void lunread_(const char filename[], const int length)
void gen::Herwig6Instance::setHerwigRandomEngine ( CLHEP::HepRandomEngine *  v)
inline

Definition at line 38 of file Herwig6Instance.h.

References randomEngine, and gen::v.

Referenced by gen::PomwigHadronizer::doSetRandomEngine(), and Herwig6Hadronizer::doSetRandomEngine().

38 { randomEngine = v; }
double v[5][pyjets_maxn]
CLHEP::HepRandomEngine * randomEngine
bool Herwig6Instance::timeout ( unsigned int  secs,
void(*)()  fn 
)
private

Definition at line 163 of file Herwig6Instance.cc.

References personalPlayback::fn.

Referenced by callWithTimeout().

163  {
164  fn();
165  return false;
166 }

Friends And Related Function Documentation

void gen::cms_hwwarn_ ( char  fn[6],
int *  ,
int *   
)
friend
double gen::hwrgen_ ( int *  )
friend

Member Data Documentation

CLHEP::HepRandomEngine* gen::Herwig6Instance::randomEngine
private

Definition at line 62 of file Herwig6Instance.h.

Referenced by gen::hwrgen_(), and setHerwigRandomEngine().

std::unique_ptr<TimeoutHolder> gen::Herwig6Instance::timeoutPrivate
private

Definition at line 65 of file Herwig6Instance.h.