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

#include <G4UserTaskThreadInitialization.hh>

+ Inheritance diagram for G4UserTaskThreadInitialization:

Public Member Functions

 G4UserTaskThreadInitialization ()=default
 
 ~G4UserTaskThreadInitialization () override=default
 
G4ThreadCreateAndStartWorker (G4WorkerThread *workerThreadContext) override
 
void SetupRNGEngine (const CLHEP::HepRandomEngine *aRNGEngine) const override
 
void JoinWorker (G4Thread *aThread) override
 
G4WorkerRunManagerCreateWorkerRunManager () const override
 
- Public Member Functions inherited from G4UserWorkerThreadInitialization
 G4UserWorkerThreadInitialization ()=default
 
virtual ~G4UserWorkerThreadInitialization ()=default
 

Detailed Description

Definition at line 50 of file G4UserTaskThreadInitialization.hh.

Constructor & Destructor Documentation

◆ G4UserTaskThreadInitialization()

G4UserTaskThreadInitialization::G4UserTaskThreadInitialization ( )
default

◆ ~G4UserTaskThreadInitialization()

G4UserTaskThreadInitialization::~G4UserTaskThreadInitialization ( )
overridedefault

Member Function Documentation

◆ CreateAndStartWorker()

G4Thread * G4UserTaskThreadInitialization::CreateAndStartWorker ( G4WorkerThread * workerThreadContext)
overridevirtual

Reimplemented from G4UserWorkerThreadInitialization.

Definition at line 50 of file G4UserTaskThreadInitialization.cc.

51{
52 // Note: this method is called by G4MTRunManager, here we are still sequential
53 // Create a new thread/worker structure
54 return nullptr;
55}

◆ CreateWorkerRunManager()

G4WorkerRunManager * G4UserTaskThreadInitialization::CreateWorkerRunManager ( ) const
overridevirtual

◆ JoinWorker()

void G4UserTaskThreadInitialization::JoinWorker ( G4Thread * aThread)
overridevirtual

Reimplemented from G4UserWorkerThreadInitialization.

Definition at line 60 of file G4UserTaskThreadInitialization.cc.

61{
62 if (aThread != nullptr) {
63 G4THREADJOIN(*aThread);
64 }
65}
#define G4THREADJOIN(worker)

◆ SetupRNGEngine()

void G4UserTaskThreadInitialization::SetupRNGEngine ( const CLHEP::HepRandomEngine * aRNGEngine) const
overridevirtual

Reimplemented from G4UserWorkerThreadInitialization.

Definition at line 69 of file G4UserTaskThreadInitialization.cc.

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

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