Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
Atlas_RNG Class Reference

#include <Sherpa_i.h>

Inheritance diagram for Atlas_RNG:
Collaboration diagram for Atlas_RNG:

Public Member Functions

 Atlas_RNG (CLHEP::HepRandomEngine *)
 
 ~Atlas_RNG ()
 
double Get ()
 
bool CanRestoreStatus () const
 
void SaveStatus ()
 
void RestoreStatus ()
 
const std::string GenerateUID () const
 

Private Attributes

CLHEP::HepRandomEngine * p_engine
 
std::string m_filename
 
std::once_flag m_once_flag_atlas_rng
 

Detailed Description

Definition at line 77 of file Sherpa_i.h.

Constructor & Destructor Documentation

◆ Atlas_RNG()

Atlas_RNG::Atlas_RNG ( CLHEP::HepRandomEngine *  engine)

Definition at line 380 of file Sherpa_i.cxx.

380  :
381  External_RNG(), p_engine(engine), m_filename("Config.conf")
382 {
383 }

◆ ~Atlas_RNG()

Atlas_RNG::~Atlas_RNG ( )

Definition at line 385 of file Sherpa_i.cxx.

385 { std::remove(m_filename.c_str()); }

Member Function Documentation

◆ CanRestoreStatus()

bool Atlas_RNG::CanRestoreStatus ( ) const
inline

Definition at line 86 of file Sherpa_i.h.

86 { return true; }

◆ GenerateUID()

const std::string Atlas_RNG::GenerateUID ( ) const

Definition at line 393 of file Sherpa_i.cxx.

393  {
394  std::string result{""};
395  const int nMax = 26;
396  char alphabet[nMax] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
397  'h', 'i', 'j', 'k', 'l', 'm', 'n',
398  'o', 'p', 'q', 'r', 's', 't', 'u',
399  'v', 'w', 'x', 'y', 'z' };
400  for (size_t i = 0; i < 6; ++i) {
401  result += alphabet[rand() % nMax];
402  }
403  return result;
404 }

◆ Get()

double Atlas_RNG::Get ( )

Definition at line 387 of file Sherpa_i.cxx.

387  {
388 
389  return CLHEP::RandFlat::shoot(p_engine);
390 
391 }

◆ RestoreStatus()

void Atlas_RNG::RestoreStatus ( )

Definition at line 419 of file Sherpa_i.cxx.

419 { p_engine->restoreStatus(m_filename.c_str()); }

◆ SaveStatus()

void Atlas_RNG::SaveStatus ( )

Definition at line 406 of file Sherpa_i.cxx.

406  {
407  // We set the file name first time the worker calls SaveStatus
408  std::call_once(m_once_flag_atlas_rng, [&](){
409  struct stat info;
410  if ( !stat("/dev/shm", &info)) {
411  m_filename = "/dev/shm/Config.conf.";
412  }
413  m_filename += GenerateUID();
414  std::cout << "RNG state being saved to: " << m_filename << std::endl;
415  });
416  p_engine->saveStatus(m_filename.c_str());
417 }

Member Data Documentation

◆ m_filename

std::string Atlas_RNG::m_filename
private

Definition at line 79 of file Sherpa_i.h.

◆ m_once_flag_atlas_rng

std::once_flag Atlas_RNG::m_once_flag_atlas_rng
private

Definition at line 80 of file Sherpa_i.h.

◆ p_engine

CLHEP::HepRandomEngine* Atlas_RNG::p_engine
private

Definition at line 78 of file Sherpa_i.h.


The documentation for this class was generated from the following files:
grepfile.info
info
Definition: grepfile.py:38
get_generator_info.result
result
Definition: get_generator_info.py:21
Atlas_RNG::m_filename
std::string m_filename
Definition: Sherpa_i.h:79
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
Atlas_RNG::GenerateUID
const std::string GenerateUID() const
Definition: Sherpa_i.cxx:393
LArG4FSStartPointFilter.rand
rand
Definition: LArG4FSStartPointFilter.py:80
lumiFormat.i
int i
Definition: lumiFormat.py:85
Atlas_RNG::p_engine
CLHEP::HepRandomEngine * p_engine
Definition: Sherpa_i.h:78
beamspotman.stat
stat
Definition: beamspotman.py:266
Atlas_RNG::m_once_flag_atlas_rng
std::once_flag m_once_flag_atlas_rng
Definition: Sherpa_i.h:80