Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UserWorkerThreadInitialization Class Reference

#include <G4UserWorkerThreadInitialization.hh>

+ Inheritance diagram for G4UserWorkerThreadInitialization:

Public Member Functions

 G4UserWorkerThreadInitialization ()
 
virtual ~G4UserWorkerThreadInitialization ()
 
virtual G4ThreadCreateAndStartWorker (G4WorkerThread *workerThreadContext)
 
virtual void SetupRNGEngine (const CLHEP::HepRandomEngine *aRNGEngine) const
 
virtual void JoinWorker (G4Thread *aThread)
 
virtual G4WorkerRunManagerCreateWorkerRunManager () const
 

Detailed Description

Definition at line 50 of file G4UserWorkerThreadInitialization.hh.

Constructor & Destructor Documentation

◆ G4UserWorkerThreadInitialization()

G4UserWorkerThreadInitialization::G4UserWorkerThreadInitialization ( )

Definition at line 81 of file G4UserWorkerThreadInitialization.cc.

82{
83}

◆ ~G4UserWorkerThreadInitialization()

G4UserWorkerThreadInitialization::~G4UserWorkerThreadInitialization ( )
virtual

Definition at line 86 of file G4UserWorkerThreadInitialization.cc.

87{
88}

Member Function Documentation

◆ CreateAndStartWorker()

G4Thread * G4UserWorkerThreadInitialization::CreateAndStartWorker ( G4WorkerThread workerThreadContext)
virtual

Reimplemented in G4UserTaskThreadInitialization.

Definition at line 61 of file G4UserWorkerThreadInitialization.cc.

63{
64 return new G4Thread;
65}
G4DummyThread G4Thread
Definition: G4Threading.hh:247

Referenced by G4MTRunManager::CreateAndStartWorkers().

◆ CreateWorkerRunManager()

G4WorkerRunManager * G4UserWorkerThreadInitialization::CreateWorkerRunManager ( ) const
virtual

◆ JoinWorker()

void G4UserWorkerThreadInitialization::JoinWorker ( G4Thread aThread)
virtual

Reimplemented in G4UserTaskThreadInitialization.

Definition at line 75 of file G4UserWorkerThreadInitialization.cc.

76{
77}

Referenced by G4MTRunManager::TerminateWorkers().

◆ SetupRNGEngine()

void G4UserWorkerThreadInitialization::SetupRNGEngine ( const CLHEP::HepRandomEngine aRNGEngine) const
virtual

Reimplemented in G4UserTaskThreadInitialization.

Definition at line 97 of file G4UserWorkerThreadInitialization.cc.

99{
100 G4AutoLock l(&rngCreateMutex);
101 // No default available, let's create the instance of random stuff
102 // A Call to this just forces the creation to defaults
103 G4Random::getTheEngine();
104 // Poor man's solution to check which RNG Engine is used in master thread
105 CLHEP::HepRandomEngine* retRNG = nullptr;
106
107 // Need to make these calls thread safe
108 if(dynamic_cast<const CLHEP::HepJamesRandom*>(aNewRNG))
109 {
110 retRNG = new CLHEP::HepJamesRandom;
111 }
112 if(dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG))
113 {
114 retRNG = new CLHEP::MixMaxRng;
115 }
116 if(dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG))
117 {
118 retRNG = new CLHEP::RanecuEngine;
119 }
120 if(dynamic_cast<const CLHEP::RanluxppEngine*>(aNewRNG))
121 {
122 retRNG = new CLHEP::RanluxppEngine;
123 }
124 if(dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG))
125 {
126 const CLHEP::Ranlux64Engine* theRNG =
127 dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG);
128 retRNG = new CLHEP::Ranlux64Engine(123, theRNG->getLuxury());
129 }
130 if(dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG))
131 {
132 retRNG = new CLHEP::MTwistEngine;
133 }
134 if(dynamic_cast<const CLHEP::DualRand*>(aNewRNG))
135 {
136 retRNG = new CLHEP::DualRand;
137 }
138 if(dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG))
139 {
140 const CLHEP::RanluxEngine* theRNG =
141 dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG);
142 retRNG = new CLHEP::RanluxEngine(123, theRNG->getLuxury());
143 }
144 if(dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG))
145 {
146 retRNG = new CLHEP::RanshiEngine;
147 }
148
149 if(retRNG != nullptr)
150 {
151 G4Random::setTheEngine(retRNG);
152 }
153 else
154 {
155 // Does a new method, such as aNewRng->newEngine() exist to clone it ?
157 msg << " Unknown type of RNG Engine - " << G4endl
158 << " Can cope only with HepJamesRandom, MixMaxRng, Ranecu, Ranlux64,"
159 << " Ranlux++, MTwistEngine, DualRand, Ranlux or Ranshi." << G4endl
160 << " Cannot clone this type of RNG engine, as required for this thread"
161 << G4endl << " Aborting " << G4endl;
162 G4Exception("G4UserWorkerThreadInitialization::SetupRNGEngine()",
163 "Run0122", FatalException, msg);
164 }
165}
@ 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
#define G4endl
Definition: G4ios.hh:57
int getLuxury() const
Definition: RanluxEngine.h:90

Referenced by G4TaskRunManagerKernel::InitializeWorker(), and G4MTRunManagerKernel::StartThread().


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