Geant4 11.2.2
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 ()=default
 
virtual ~G4UserWorkerThreadInitialization ()=default
 
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 ( )
default

◆ ~G4UserWorkerThreadInitialization()

virtual G4UserWorkerThreadInitialization::~G4UserWorkerThreadInitialization ( )
virtualdefault

Member Function Documentation

◆ CreateAndStartWorker()

G4Thread * G4UserWorkerThreadInitialization::CreateAndStartWorker ( G4WorkerThread * workerThreadContext)
virtual

Reimplemented in G4UserTaskThreadInitialization.

Definition at line 55 of file G4UserWorkerThreadInitialization.cc.

56{
57 return new G4Thread;
58}
G4DummyThread G4Thread

Referenced by G4MTRunManager::CreateAndStartWorkers().

◆ CreateWorkerRunManager()

G4WorkerRunManager * G4UserWorkerThreadInitialization::CreateWorkerRunManager ( ) const
virtual

◆ JoinWorker()

void G4UserWorkerThreadInitialization::JoinWorker ( G4Thread * aThread)
virtual

Reimplemented in G4UserTaskThreadInitialization.

Definition at line 68 of file G4UserWorkerThreadInitialization.cc.

68{}

Referenced by G4MTRunManager::TerminateWorkers().

◆ SetupRNGEngine()

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

Reimplemented in G4UserTaskThreadInitialization.

Definition at line 78 of file G4UserWorkerThreadInitialization.cc.

79{
80 G4AutoLock l(&rngCreateMutex);
81 // No default available, let's create the instance of random stuff
82 // A Call to this just forces the creation to defaults
83 G4Random::getTheEngine();
84 // Poor man's solution to check which RNG Engine is used in master thread
85 CLHEP::HepRandomEngine* retRNG = nullptr;
86
87 // Need to make these calls thread safe
88 if (dynamic_cast<const CLHEP::HepJamesRandom*>(aNewRNG) != nullptr) {
89 retRNG = new CLHEP::HepJamesRandom;
90 }
91 if (dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG) != nullptr) {
92 retRNG = new CLHEP::MixMaxRng;
93 }
94 if (dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG) != nullptr) {
95 retRNG = new CLHEP::RanecuEngine;
96 }
97 if (dynamic_cast<const CLHEP::RanluxppEngine*>(aNewRNG) != nullptr) {
98 retRNG = new CLHEP::RanluxppEngine;
99 }
100 if (dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG) != nullptr) {
101 const auto theRNG = dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG);
102 retRNG = new CLHEP::Ranlux64Engine(123, theRNG->getLuxury());
103 }
104 if (dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG) != nullptr) {
105 retRNG = new CLHEP::MTwistEngine;
106 }
107 if (dynamic_cast<const CLHEP::DualRand*>(aNewRNG) != nullptr) {
108 retRNG = new CLHEP::DualRand;
109 }
110 if (dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG) != nullptr) {
111 const auto theRNG = dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG);
112 retRNG = new CLHEP::RanluxEngine(123, theRNG->getLuxury());
113 }
114 if (dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG) != nullptr) {
115 retRNG = new CLHEP::RanshiEngine;
116 }
117
118 if (retRNG != nullptr) {
119 G4Random::setTheEngine(retRNG);
120 }
121 else {
122 // Does a new method, such as aNewRng->newEngine() exist to clone it ?
124 msg << " Unknown type of RNG Engine - " << G4endl
125 << " Can cope only with HepJamesRandom, MixMaxRng, Ranecu, Ranlux64,"
126 << " Ranlux++, MTwistEngine, DualRand, Ranlux or Ranshi." << G4endl
127 << " Cannot clone this type of RNG engine, as required for this thread" << G4endl
128 << " Aborting " << G4endl;
129 G4Exception("G4UserWorkerThreadInitialization::SetupRNGEngine()", "Run0122", FatalException,
130 msg);
131 }
132}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4endl
Definition G4ios.hh:67

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


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