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
template<typename T >
T call (T(&fn)())
 
template<typename T , typename A >
T call (T(&fn)(A), A a)
 
template<typename T , typename A1 , typename A2 >
T call (T(&fn)(A1, A2), A1 a1, A2 a2)
 
void call (void(&fn)())
 
template<typename A >
void call (void(&fn)(A), A a)
 
template<typename A1 , typename A2 >
void call (void(&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::Herwig6Instance ( )

Definition at line 77 of file Herwig6Instance.cc.

77 : randomEngine(nullptr), timeoutPrivate() {}

◆ ~Herwig6Instance()

Herwig6Instance::~Herwig6Instance ( )
override

Definition at line 79 of file Herwig6Instance.cc.

79 {}

Member Function Documentation

◆ _timeout_sighandler()

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

◆ callWithTimeout()

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

Definition at line 30 of file Herwig6Instance.h.

30  {
31  InstanceWrapper wrapper(this);
32  return timeout(secs, fn);
33  }

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

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

◆ give()

bool Herwig6Instance::give ( const std::string &  line)

Definition at line 173 of file Herwig6Instance.cc.

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 }

References mps_fire::i, mps_splice::line, VarParsing::mult, Skims_PA_cff::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().

◆ hwwarn()

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

Reimplemented in MCatNLOSource.

Definition at line 169 of file Herwig6Instance.cc.

169 { return false; }

◆ openParticleSpecFile()

void Herwig6Instance::openParticleSpecFile ( const std::string  fileName)

Definition at line 284 of file Herwig6Instance.cc.

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 }

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

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

◆ setHerwigRandomEngine()

void gen::Herwig6Instance::setHerwigRandomEngine ( CLHEP::HepRandomEngine *  v)
inline

◆ timeout()

bool Herwig6Instance::timeout ( unsigned int  secs,
void(*)()  fn 
)
private

Definition at line 163 of file Herwig6Instance.cc.

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

References personalPlayback::fn.

Referenced by callWithTimeout().

Friends And Related Function Documentation

◆ gen::cms_hwwarn_

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

◆ gen::hwrgen_

double gen::hwrgen_ ( int *  )
friend

Member Data Documentation

◆ randomEngine

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

Definition at line 62 of file Herwig6Instance.h.

Referenced by setHerwigRandomEngine().

◆ timeoutPrivate

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

Definition at line 65 of file Herwig6Instance.h.

mps_fire.i
i
Definition: mps_fire.py:428
gen::Herwig6Instance::randomEngine
CLHEP::HepRandomEngine * randomEngine
Definition: Herwig6Instance.h:62
lunread_
void lunread_(const char filename[], const int length)
pos
Definition: PixelAliasList.h:18
wrapper
static HepMC::HEPEVT_Wrapper wrapper
Definition: BeamHaloProducer.cc:47
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::FileInPath
Definition: FileInPath.h:64
gen::p
double p[5][pyjets_maxn]
Definition: Cascade2Hadronizer.cc:76
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
gen::Herwig6Instance::timeout
bool timeout(unsigned int secs, void(*fn)())
Definition: Herwig6Instance.cc:163
gen::v
double v[5][pyjets_maxn]
Definition: Cascade2Hadronizer.cc:76
value
Definition: value.py:1
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
gen::Herwig6Instance::timeoutPrivate
std::unique_ptr< TimeoutHolder > timeoutPrivate
Definition: Herwig6Instance.h:65
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
personalPlayback.fn
fn
Definition: personalPlayback.py:515
VarParsing.mult
mult
Definition: VarParsing.py:659
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
mps_splice.line
line
Definition: mps_splice.py:76