Commit 77857f91 authored by Lynn Garren's avatar Lynn Garren
Browse files

renaming the class to StdHep::RandomState to avoid confusion with std::random()

parent fd78c1fe
2005-03-07 Lynn Garren <garren@fnal.gov>
2005-03-11 Lynn Garren <garren@fnal.gov>
* add StdRandom class which "saves" the random state as a string
* add RandomState class which "saves" the random state as a string
==============================
29.11.04 Release CLHEP-1.9.1.2
......
......@@ -19,7 +19,7 @@ pkginclude_HEADERS = \
StdHep.hh \
StdHeptoGenEvent.icc \
StdHepVersion.h \
StdRandom.hh \
RandomState.hh \
StdRunInfoConvert.hh \
StdRunInfoConvert.icc \
StdRunInfo.hh \
......
#ifndef STDRANDOM_HH
#define STDRANDOM_HH
#ifndef STDHEP_RANDOMSTATE_HH
#define STDHEP_RANDOMSTATE_HH
// ----------------------------------------------------------------------
// StdRandom.hh
// RandomState.hh
//
// Container for the random state
// ----------------------------------------------------------------------
......@@ -16,16 +16,16 @@ namespace StdHep {
* @author
* @ingroup stdhep
*/
class StdRandom {
class RandomState {
public:
// --- birth/death:
//
StdRandom( );
StdRandom( const StdRandom & orig );
StdRandom& operator=( const StdRandom & );
~StdRandom();
RandomState( );
RandomState( const RandomState & orig );
RandomState& operator=( const RandomState & );
~RandomState();
// --- accessors:
//
......@@ -48,8 +48,8 @@ private:
std::string myRandomState;
}; // StdRandom
}; // RandomState
}
#endif // STDRANDOM_HH
#endif // STDHEP_RANDOMSTATE_HH
......@@ -8,7 +8,7 @@
#include <vector>
#include <string>
#include "CLHEP/StdHep/StdRandom.hh"
#include "CLHEP/StdHep/RandomState.hh"
namespace StdHep {
......@@ -68,7 +68,7 @@ private:
std::string itsRunIdentifier;
std::string itsGeneratorName;
std::string itsPDFName;
StdRandom itsSeedList;
RandomState itsSeedList;
}; // StdRunInfo
......
......@@ -31,7 +31,7 @@ libCLHEP_StdHep_@VERSION@_a_SOURCES = \
StdEventVDescendants.cc \
StdEventVertex.cc \
StdEventVParents.cc \
StdRandom.cc \
RandomState.cc \
StdRunInfo.cc \
tree.cc \
writeEventKey.cc \
......
// ----------------------------------------------------------------------
// StdRandom.cc
// RandomState.cc
// ----------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include "CLHEP/StdHep/StdRandom.hh"
#include "CLHEP/StdHep/RandomState.hh"
#include "CLHEP/HepMC/DoubleConversion.hh"
namespace StdHep {
StdRandom::StdRandom( )
RandomState::RandomState( )
: myRandomState( "" )
{ ; }
StdRandom::StdRandom( const StdRandom & orig )
RandomState::RandomState( const RandomState & orig )
: myRandomState( orig.myRandomState )
{ ; }
StdRandom& StdRandom::operator=( const StdRandom & rhs )
RandomState& RandomState::operator=( const RandomState & rhs )
{ if( this != & rhs )
{
myRandomState = rhs.myRandomState;
......@@ -28,17 +28,17 @@ StdRandom& StdRandom::operator=( const StdRandom & rhs )
return *this;
}
StdRandom:: ~StdRandom()
RandomState:: ~RandomState()
{ ; }
std::ostream& StdRandom::getStateAsStream( std::ostream & os ) const
std::ostream& RandomState::getStateAsStream( std::ostream & os ) const
{
os << myRandomState << std::endl;
return os;
}
std::vector<unsigned long> StdRandom::getStateAsLongs( ) const
std::vector<unsigned long> RandomState::getStateAsLongs( ) const
{
// we assume here that this makes sense
// this method assumes that the state consists solely of a list of longs
......@@ -53,14 +53,14 @@ std::vector<unsigned long> StdRandom::getStateAsLongs( ) const
}
void StdRandom::print( std::ostream & os ) const
void RandomState::print( std::ostream & os ) const
{
os << "begin StdRandom state" << std::endl;
os << "begin RandomState state" << std::endl;
os << myRandomState << std::endl;
os << "end StdRandom state" << std::endl;
os << "end RandomState state" << std::endl;
}
void StdRandom::putState( std::istream& ist )
void RandomState::putState( std::istream& ist )
{
std::ostringstream st;
std::string str;
......@@ -71,12 +71,12 @@ void StdRandom::putState( std::istream& ist )
myRandomState = st.str();
}
void StdRandom::putState( std::string const & st )
void RandomState::putState( std::string const & st )
{
myRandomState = st;
}
void StdRandom::putState( std::vector<unsigned long> const & rs )
void RandomState::putState( std::vector<unsigned long> const & rs )
{
std::ostringstream st;
for( unsigned int i=0; i<rs.size(); ++i ) {
......@@ -85,14 +85,14 @@ void StdRandom::putState( std::vector<unsigned long> const & rs )
myRandomState = st.str();
}
void StdRandom::appendSeed( unsigned long sd )
void RandomState::appendSeed( unsigned long sd )
{
std::ostringstream st(myRandomState);
st << " " << sd;
myRandomState = st.str();
}
void StdRandom::appendSeed( double sd )
void RandomState::appendSeed( double sd )
{
std::ostringstream st(myRandomState);
std::vector<unsigned long> two;
......@@ -103,7 +103,7 @@ void StdRandom::appendSeed( double sd )
myRandomState = st.str();
}
void StdRandom::clear( )
void RandomState::clear( )
{
myRandomState = "";
}
......
......@@ -20,7 +20,7 @@ StdRunInfo::StdRunInfo( int runno, int togen, int ngen, int nwrt,
itsRunIdentifier ( " " ),
itsGeneratorName ( " " ),
itsPDFName ( " " ),
itsSeedList ( StdRandom() )
itsSeedList ( RandomState() )
{ ; }
StdRunInfo::StdRunInfo( const StdRunInfo & orig )
......
......@@ -15,19 +15,19 @@ endif
# Identify executables needed during testing:
check_PROGRAMS = \
testStdRandom
testStdHepRandomState
#check_SCRIPTS =
# Identify test(s) to run when 'make check' is requested:
TESTS = \
testStdRandom
testStdHepRandomState
# Identify the test(s) for which failure is the intended outcome:
XFAIL_TESTS =
# Identify the dependencies on a per-test basis:
testStdRandom_SOURCES = testStdRandom.cc SimpleRand.cc
testStdHepRandomState_SOURCES = testStdHepRandomState.cc SimpleRand.cc
# Identify input data file(s) and prototype output file(s):
#EXTRA_DIST =
......
//////////////////////////////////////////////////////////////////////////
// Lynn Garren
//
// This program tests StdHep::StdRandom
// This program tests StdHep::RandomState
//
//////////////////////////////////////////////////////////////////////////
......@@ -10,7 +10,7 @@
#include <sstream>
#include <string>
#include "CLHEP/StdHep/StdRandom.hh"
#include "CLHEP/StdHep/RandomState.hh"
#include "SimpleRand.hh"
......@@ -18,7 +18,7 @@ int main() {
int status=0;
double d, saved;
StdHep::StdRandom rstate;
StdHep::RandomState rstate;
// fill and save an arbitrary vector just for grins
std::vector<unsigned long> rs;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment