CMS 3D CMS Logo

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 84 of file Herwig6Instance.cc.

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

Definition at line 90 of file Herwig6Instance.cc.

References _timeout_sighandler(), Exception, instance, timeout(), and timeoutPrivate.

91 {
92 }

Member Function Documentation

static void gen::Herwig6Instance::_timeout_sighandler ( int  signr)
staticprivate

Referenced by ~Herwig6Instance().

bool gen::Herwig6Instance::callWithTimeout ( unsigned int  secs,
void(*)()  fn 
)
inline

Definition at line 30 of file Herwig6Instance.h.

References MillePedeFileConverter_cfg::fileName, AlCaHLTBitMon_QueryRunRegistry::string, mps_check::timeout, and wrapper.

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

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

Definition at line 195 of file Herwig6Instance.cc.

References mps_fire::i, dataset::name, PFRecoTauDiscriminationByIsolation_cfi::offset, gen::p, lumiQueryAPI::q, AlCaHLTBitMon_QueryRunRegistry::string, and relativeConstraints::value.

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

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

Reimplemented in MCatNLOSource.

Definition at line 188 of file Herwig6Instance.cc.

189 {
190  return false;
191 }
void Herwig6Instance::openParticleSpecFile ( const std::string  fileName)

Definition at line 305 of file Herwig6Instance.cc.

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

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

305  {
306 
307  edm::FileInPath fileAndPath( fileName );
308  // WARING : This will call HWWARN if file does not exist.
309  lunread_( fileAndPath.fullPath().c_str(),strlen(fileAndPath.fullPath().c_str()) );
310 
311  return;
312 }
void lunread_(const char filename[], const int length)
void gen::Herwig6Instance::setHerwigRandomEngine ( CLHEP::HepRandomEngine *  v)
inline
bool Herwig6Instance::timeout ( unsigned int  secs,
void(*)()  fn 
)
private

Definition at line 181 of file Herwig6Instance.cc.

Referenced by ~Herwig6Instance().

182 {
183  fn();
184  return false;
185 }

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 60 of file Herwig6Instance.h.

Referenced by gen::hwrgen_().

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

Definition at line 63 of file Herwig6Instance.h.

Referenced by ~Herwig6Instance().