ATLAS Offline Software
Loading...
Searching...
No Matches
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 373 of file Sherpa_i.cxx.

373 :
374 External_RNG(), p_engine(engine), m_filename("Config.conf")
375{
376}
CLHEP::HepRandomEngine * p_engine
Definition Sherpa_i.h:78
std::string m_filename
Definition Sherpa_i.h:79

◆ ~Atlas_RNG()

Atlas_RNG::~Atlas_RNG ( )

Definition at line 378 of file Sherpa_i.cxx.

378{ std::ignore = std::remove(m_filename.c_str()); }
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.

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 386 of file Sherpa_i.cxx.

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

◆ Get()

double Atlas_RNG::Get ( )

Definition at line 380 of file Sherpa_i.cxx.

380 {
381
382 return CLHEP::RandFlat::shoot(p_engine);
383
384}

◆ RestoreStatus()

void Atlas_RNG::RestoreStatus ( )

Definition at line 412 of file Sherpa_i.cxx.

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

◆ SaveStatus()

void Atlas_RNG::SaveStatus ( )

Definition at line 399 of file Sherpa_i.cxx.

399 {
400 // We set the file name first time the worker calls SaveStatus
401 std::call_once(m_once_flag_atlas_rng, [&](){
402 struct stat info;
403 if ( !stat("/dev/shm", &info)) {
404 m_filename = "/dev/shm/Config.conf.";
405 }
407 std::cout << "RNG state being saved to: " << m_filename << std::endl;
408 });
409 p_engine->saveStatus(m_filename.c_str());
410}
std::once_flag m_once_flag_atlas_rng
Definition Sherpa_i.h:80
const std::string GenerateUID() const
Definition Sherpa_i.cxx:386

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: