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

374 :
375 External_RNG(), p_engine(engine), m_filename("Config.conf")
376{
377}
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 379 of file Sherpa_i.cxx.

379{ 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 387 of file Sherpa_i.cxx.

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

◆ Get()

double Atlas_RNG::Get ( )

Definition at line 381 of file Sherpa_i.cxx.

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

◆ RestoreStatus()

void Atlas_RNG::RestoreStatus ( )

Definition at line 413 of file Sherpa_i.cxx.

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

◆ SaveStatus()

void Atlas_RNG::SaveStatus ( )

Definition at line 400 of file Sherpa_i.cxx.

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

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: