Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4TemplateRNGHelper< T > Class Template Reference

#include <G4RNGHelper.hh>

Public Types

typedef std::vector< T > SeedsQueue
 
typedef SeedsQueue::size_type SeedsQueueSize_type
 

Public Member Functions

virtual ~G4TemplateRNGHelper ()
 
virtual const T GetSeed (const G4int &sdId)
 
void AddOneSeed (const T &seed)
 
void Fill (G4double *dbl, G4int nev, G4int nev_tot, G4int nrpe)
 
void Refill (G4double *dbl, G4int nev)
 
const SeedsQueueSize_type GetNumberSeeds () const
 
virtual void Clear ()
 
template<>
G4TemplateRNGHelper< G4long > * GetInstance ()
 
template<>
G4TemplateRNGHelper< G4String > * GetInstance ()
 

Static Public Member Functions

static G4TemplateRNGHelper< T > * GetInstance ()
 

Protected Attributes

SeedsQueue seeds
 
G4int offset
 
G4int nev_filled
 
G4int nev_total
 
G4int nRandParEvent
 

Detailed Description

template<class T>
class G4TemplateRNGHelper< T >

Definition at line 47 of file G4RNGHelper.hh.

Member Typedef Documentation

template<class T>
typedef std::vector<T> G4TemplateRNGHelper< T >::SeedsQueue

Definition at line 52 of file G4RNGHelper.hh.

template<class T>
typedef SeedsQueue::size_type G4TemplateRNGHelper< T >::SeedsQueueSize_type

Definition at line 53 of file G4RNGHelper.hh.

Constructor & Destructor Documentation

template<class T>
virtual G4TemplateRNGHelper< T >::~G4TemplateRNGHelper ( )
inlinevirtual

Definition at line 55 of file G4RNGHelper.hh.

56  {
57  Clear();
58  instance = 0;
59  }
virtual void Clear()
Definition: G4RNGHelper.hh:106

Here is the call graph for this function:

Member Function Documentation

template<class T>
void G4TemplateRNGHelper< T >::AddOneSeed ( const T &  seed)
inline

Definition at line 78 of file G4RNGHelper.hh.

78 { seeds.push_back(seed); }
template<class T>
virtual void G4TemplateRNGHelper< T >::Clear ( )
inlinevirtual

Definition at line 106 of file G4RNGHelper.hh.

106 { seeds.clear(); }

Here is the caller graph for this function:

template<class T>
void G4TemplateRNGHelper< T >::Fill ( G4double dbl,
G4int  nev,
G4int  nev_tot,
G4int  nrpe 
)
inline

Definition at line 81 of file G4RNGHelper.hh.

82  {
83  seeds.clear();
84  for(G4int i=0;i<nrpe*nev;i++)
85  { seeds.push_back((G4long)(100000000L*dbl[i])); }
86  offset = 0;
87  nev_filled = nev;
88  nev_total = nev_tot;
89  nRandParEvent = nrpe;
90  }
long G4long
Definition: G4Types.hh:80
int G4int
Definition: G4Types.hh:78
static constexpr double L
Definition: G4SIunits.hh:124

Here is the caller graph for this function:

template<>
G4TemplateRNGHelper< G4long > * G4TemplateRNGHelper< G4long >::GetInstance ( )

Definition at line 47 of file G4RNGHelper.cc.

48 {
49  if (!instance)
50  {
51  instance = new G4TemplateRNGHelper<G4long>();
52  }
53  return instance;
54 }
template<class T >
G4TemplateRNGHelper< T > * G4TemplateRNGHelper< T >::GetInstance ( )
static

Definition at line 37 of file G4RNGHelper.cc.

38 {
39  if (!instance)
40  {
41  instance = new G4TemplateRNGHelper<T>();
42  }
43  return instance;
44 }

Here is the caller graph for this function:

template<>
G4TemplateRNGHelper< G4String > * G4TemplateRNGHelper< G4String >::GetInstance ( )

Definition at line 57 of file G4RNGHelper.cc.

58 {
59  if (!instance)
60  {
61  instance = new G4TemplateRNGHelper<G4String>();
62  }
63  return instance;
64 }
template<class T>
const SeedsQueueSize_type G4TemplateRNGHelper< T >::GetNumberSeeds ( ) const
inline

Definition at line 103 of file G4RNGHelper.hh.

103 { return seeds.size(); }
template<class T>
virtual const T G4TemplateRNGHelper< T >::GetSeed ( const G4int sdId)
inlinevirtual

Definition at line 62 of file G4RNGHelper.hh.

63  {
64  G4int seedId = sdId - 2*offset;
65  if ( seedId < static_cast<G4int>(seeds.size()) )
66  {
67  T& seed = seeds[seedId];
68  return seed;
69  }
71  msg << "No seed number "<<seedId<<"("<<seeds.size()<<" available)\n"
72  << " Original seed number "<<sdId<<" filled so far "<<offset;
73  G4Exception("G4RNGHelper::GetSeed","Run0115", FatalException,msg);
74  return T();
75  }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
int G4int
Definition: G4Types.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T>
void G4TemplateRNGHelper< T >::Refill ( G4double dbl,
G4int  nev 
)
inline

Definition at line 92 of file G4RNGHelper.hh.

93  {
94  if(nev==0) return;
95  seeds.clear();
96  for(G4int i=0;i<nRandParEvent*nev;i++)
97  { seeds.push_back((G4long)(100000000L*dbl[i])); }
98  offset += nev_filled;
99  nev_filled = nev;
100  }
long G4long
Definition: G4Types.hh:80
int G4int
Definition: G4Types.hh:78
static constexpr double L
Definition: G4SIunits.hh:124

Here is the caller graph for this function:

Member Data Documentation

template<class T>
G4int G4TemplateRNGHelper< T >::nev_filled
protected

Definition at line 113 of file G4RNGHelper.hh.

template<class T>
G4int G4TemplateRNGHelper< T >::nev_total
protected

Definition at line 114 of file G4RNGHelper.hh.

template<class T>
G4int G4TemplateRNGHelper< T >::nRandParEvent
protected

Definition at line 115 of file G4RNGHelper.hh.

template<class T>
G4int G4TemplateRNGHelper< T >::offset
protected

Definition at line 112 of file G4RNGHelper.hh.

template<class T>
SeedsQueue G4TemplateRNGHelper< T >::seeds
protected

Definition at line 109 of file G4RNGHelper.hh.


The documentation for this class was generated from the following files: