Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 ()
 
G4TemplateRNGHelper< G4long > * GetInstance ()
 
G4TemplateRNGHelper< G4long > * GetInstanceIfExist ()
 
G4TemplateRNGHelper< G4String > * GetInstance ()
 
G4TemplateRNGHelper< G4String > * GetInstanceIfExist ()
 

Static Public Member Functions

static G4TemplateRNGHelper< T > * GetInstance ()
 
static G4TemplateRNGHelper< T > * GetInstanceIfExist ()
 

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 46 of file G4RNGHelper.hh.

Member Typedef Documentation

◆ SeedsQueue

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

Definition at line 52 of file G4RNGHelper.hh.

◆ SeedsQueueSize_type

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

Definition at line 53 of file G4RNGHelper.hh.

Constructor & Destructor Documentation

◆ ~G4TemplateRNGHelper()

template<class T >
G4TemplateRNGHelper< T >::~G4TemplateRNGHelper
virtual

Definition at line 83 of file G4RNGHelper.cc.

84{
85 Clear();
86 instance = 0;
87}
virtual void Clear()
Definition: G4RNGHelper.hh:107

Member Function Documentation

◆ AddOneSeed()

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

Definition at line 74 of file G4RNGHelper.hh.

74{ seeds.push_back(seed); }

◆ Clear()

template<class T >
virtual void G4TemplateRNGHelper< T >::Clear ( )
inlinevirtual

Definition at line 107 of file G4RNGHelper.hh.

107{ seeds.clear(); }

◆ Fill()

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

Definition at line 77 of file G4RNGHelper.hh.

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

Referenced by G4MTRunManager::InitializeEventLoop(), and G4TaskRunManager::InitializeEventLoop().

◆ GetInstance() [1/3]

◆ GetInstance() [2/3]

Definition at line 52 of file G4RNGHelper.cc.

53{
54 if(!instance)
55 {
56 instance = new G4TemplateRNGHelper<G4long>();
57 }
58 return instance;
59}

◆ GetInstance() [3/3]

Definition at line 67 of file G4RNGHelper.cc.

68{
69 if(!instance)
70 {
71 instance = new G4TemplateRNGHelper<G4String>();
72 }
73 return instance;
74}

◆ GetInstanceIfExist() [1/3]

template<class T >
G4TemplateRNGHelper< T > * G4TemplateRNGHelper< T >::GetInstanceIfExist
static

Definition at line 46 of file G4RNGHelper.cc.

47{
48 return instance;
49}

Referenced by G4RunManagerKernel::~G4RunManagerKernel().

◆ GetInstanceIfExist() [2/3]

G4TemplateRNGHelper< G4long > * G4TemplateRNGHelper< G4long >::GetInstanceIfExist ( )

Definition at line 61 of file G4RNGHelper.cc.

62{
63 return instance;
64}

◆ GetInstanceIfExist() [3/3]

G4TemplateRNGHelper< G4String > * G4TemplateRNGHelper< G4String >::GetInstanceIfExist ( )

Definition at line 77 of file G4RNGHelper.cc.

78{
79 return instance;
80}

◆ GetNumberSeeds()

template<class T >
const SeedsQueueSize_type G4TemplateRNGHelper< T >::GetNumberSeeds ( ) const
inline

Definition at line 104 of file G4RNGHelper.hh.

104{ return seeds.size(); }

◆ GetSeed()

template<class T >
virtual const T G4TemplateRNGHelper< T >::GetSeed ( const G4int sdId)
inlinevirtual

Definition at line 58 of file G4RNGHelper.hh.

59 {
60 G4int seedId = sdId - 2 * offset;
61 if(seedId < static_cast<G4int>(seeds.size()))
62 {
63 T& seed = seeds[seedId];
64 return seed;
65 }
67 msg << "No seed number " << seedId << "(" << seeds.size() << " available)\n"
68 << " Original seed number " << sdId << " filled so far " << offset;
69 G4Exception("G4RNGHelper::GetSeed", "Run0115", FatalException, msg);
70 return T();
71 }
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40

Referenced by G4WorkerRunManager::GenerateEvent(), G4WorkerTaskRunManager::GenerateEvent(), G4TaskRunManager::SetUpAnEvent(), G4MTRunManager::SetUpAnEvent(), G4MTRunManager::SetUpNEvents(), and G4TaskRunManager::SetUpNEvents().

◆ Refill()

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

Definition at line 90 of file G4RNGHelper.hh.

91 {
92 if(nev == 0)
93 return;
94 seeds.clear();
95 for(G4int i = 0; i < nRandParEvent * nev; i++)
96 {
97 seeds.push_back((G4long)(100000000L * dbl[i]));
98 }
100 nev_filled = nev;
101 }

Referenced by G4MTRunManager::RefillSeeds(), and G4TaskRunManager::RefillSeeds().

Member Data Documentation

◆ nev_filled

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

◆ nev_total

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

Definition at line 115 of file G4RNGHelper.hh.

Referenced by G4TemplateRNGHelper< T >::Fill().

◆ nRandParEvent

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

◆ offset

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

◆ seeds


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