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

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

377{ 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 385 of file Sherpa_i.cxx.

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

◆ Get()

double Atlas_RNG::Get ( )

Definition at line 379 of file Sherpa_i.cxx.

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

◆ RestoreStatus()

void Atlas_RNG::RestoreStatus ( )

Definition at line 411 of file Sherpa_i.cxx.

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

◆ SaveStatus()

void Atlas_RNG::SaveStatus ( )

Definition at line 398 of file Sherpa_i.cxx.

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

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: