Geant4 11.2.2
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 54 of file G4RNGHelper.hh.

◆ SeedsQueueSize_type

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

Definition at line 55 of file G4RNGHelper.hh.

Constructor & Destructor Documentation

◆ ~G4TemplateRNGHelper()

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

Definition at line 94 of file G4RNGHelper.cc.

95{
96 Clear();
97 instance = nullptr;
98}
virtual void Clear()

Member Function Documentation

◆ AddOneSeed()

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

Definition at line 79 of file G4RNGHelper.hh.

79{ seeds.push_back(seed); }

◆ Clear()

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

Definition at line 109 of file G4RNGHelper.hh.

109{ seeds.clear(); }

◆ Fill()

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

Definition at line 82 of file G4RNGHelper.hh.

83 {
84 seeds.clear();
85 for (G4int i = 0; i < nrpe * nev; ++i) {
86 seeds.push_back((G4long)(100000000L * dbl[i]));
87 }
88 offset = 0;
89 nev_filled = nev;
90 nev_total = nev_tot;
91 nRandParEvent = nrpe;
92 }
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 instance = new G4TemplateRNGHelper<G4long>();
64 }
65 return instance;
66}

◆ GetInstance() [3/3]

Definition at line 77 of file G4RNGHelper.cc.

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

◆ 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 70 of file G4RNGHelper.cc.

71{
72 return instance;
73}

◆ GetInstanceIfExist() [3/3]

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

Definition at line 87 of file G4RNGHelper.cc.

88{
89 return instance;
90}

◆ GetNumberSeeds()

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

Definition at line 106 of file G4RNGHelper.hh.

106{ 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 T& seed = seeds[seedId];
69 return seed;
70 }
72 msg << "No seed number " << seedId << "(" << seeds.size() << " available)\n"
73 << " Original seed number " << sdId << " filled so far " << offset;
74 G4Exception("G4RNGHelper::GetSeed", "Run0115", FatalException, msg);
75 return T();
76 }
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription

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

◆ Refill()

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

Definition at line 94 of file G4RNGHelper.hh.

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

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 117 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: