Geant4 11.1.1
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

using SeedsQueue = std::vector< T >
 
using SeedsQueueSize_type = typename SeedsQueue::size_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 = 0
 
G4int nev_filled = 0
 
G4int nev_total = 0
 
G4int nRandParEvent = 0
 

Detailed Description

template<class T>
class G4TemplateRNGHelper< T >

Definition at line 51 of file G4RNGHelper.hh.

Member Typedef Documentation

◆ SeedsQueue

template<class T >
using G4TemplateRNGHelper< T >::SeedsQueue = std::vector<T>

Definition at line 58 of file G4RNGHelper.hh.

◆ SeedsQueueSize_type

template<class T >
using G4TemplateRNGHelper< T >::SeedsQueueSize_type = typename SeedsQueue::size_type

Definition at line 59 of file G4RNGHelper.hh.

Constructor & Destructor Documentation

◆ ~G4TemplateRNGHelper()

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

Definition at line 97 of file G4RNGHelper.cc.

98{
99 Clear();
100 instance = nullptr;
101}
virtual void Clear()
Definition: G4RNGHelper.hh:113

Member Function Documentation

◆ AddOneSeed()

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

Definition at line 80 of file G4RNGHelper.hh.

80{ seeds.push_back(seed); }

◆ Clear()

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

Definition at line 113 of file G4RNGHelper.hh.

113{ seeds.clear(); }

◆ Fill()

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

Definition at line 83 of file G4RNGHelper.hh.

84 {
85 seeds.clear();
86 for(G4int i = 0; i < nrpe * nev; ++i)
87 {
88 seeds.push_back((G4long)(100000000L * dbl[i]));
89 }
90 offset = 0;
91 nev_filled = nev;
92 nev_total = nev_tot;
93 nRandParEvent = nrpe;
94 }
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 60 of file G4RNGHelper.cc.

61{
62 if(instance == nullptr)
63 {
64 instance = new G4TemplateRNGHelper<G4long>();
65 }
66 return instance;
67}

◆ GetInstance() [3/3]

Definition at line 78 of file G4RNGHelper.cc.

79{
80 if(instance == nullptr)
81 {
82 instance = new G4TemplateRNGHelper<G4String>();
83 }
84 return instance;
85}

◆ GetInstanceIfExist() [1/3]

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

Definition at line 53 of file G4RNGHelper.cc.

54{
55 return instance;
56}

Referenced by G4RunManagerKernel::~G4RunManagerKernel().

◆ GetInstanceIfExist() [2/3]

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

Definition at line 71 of file G4RNGHelper.cc.

72{
73 return instance;
74}

◆ GetInstanceIfExist() [3/3]

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

Definition at line 90 of file G4RNGHelper.cc.

91{
92 return instance;
93}

◆ GetNumberSeeds()

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

Definition at line 110 of file G4RNGHelper.hh.

110{ return seeds.size(); }

◆ GetSeed()

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

Definition at line 64 of file G4RNGHelper.hh.

65 {
66 G4int seedId = sdId - 2 * offset;
67 if(seedId < static_cast<G4int>(seeds.size()))
68 {
69 T& seed = seeds[seedId];
70 return seed;
71 }
73 msg << "No seed number " << seedId << "(" << seeds.size() << " available)\n"
74 << " Original seed number " << sdId << " filled so far " << offset;
75 G4Exception("G4RNGHelper::GetSeed", "Run0115", FatalException, msg);
76 return T();
77 }
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
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 96 of file G4RNGHelper.hh.

97 {
98 if(nev == 0)
99 return;
100 seeds.clear();
101 for(G4int i = 0; i < nRandParEvent * nev; ++i)
102 {
103 seeds.push_back((G4long)(100000000L * dbl[i]));
104 }
106 nev_filled = nev;
107 }

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

Member Data Documentation

◆ nev_filled

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

◆ nev_total

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

Definition at line 122 of file G4RNGHelper.hh.

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

◆ nRandParEvent

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

◆ offset

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

◆ seeds


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