Geant4 10.7.0
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 ()
 
virtual ~G4UserTaskThreadInitialization ()
 
virtual G4ThreadCreateAndStartWorker (G4WorkerThread *workerThreadContext)
 
virtual void SetupRNGEngine (const CLHEP::HepRandomEngine *aRNGEngine) const
 
virtual void JoinWorker (G4Thread *aThread)
 
virtual G4WorkerRunManagerCreateWorkerRunManager () const
 
- Public Member Functions inherited from G4UserWorkerThreadInitialization
 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 G4UserTaskThreadInitialization.hh.

Constructor & Destructor Documentation

◆ G4UserTaskThreadInitialization()

G4UserTaskThreadInitialization::G4UserTaskThreadInitialization ( )

Definition at line 68 of file G4UserTaskThreadInitialization.cc.

68{}

◆ ~G4UserTaskThreadInitialization()

G4UserTaskThreadInitialization::~G4UserTaskThreadInitialization ( )
virtual

Definition at line 72 of file G4UserTaskThreadInitialization.cc.

72{}

Member Function Documentation

◆ CreateAndStartWorker()

G4Thread * G4UserTaskThreadInitialization::CreateAndStartWorker ( G4WorkerThread workerThreadContext)
virtual

Reimplemented from G4UserWorkerThreadInitialization.

Definition at line 48 of file G4UserTaskThreadInitialization.cc.

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

◆ CreateWorkerRunManager()

G4WorkerRunManager * G4UserTaskThreadInitialization::CreateWorkerRunManager ( ) const
virtual

Reimplemented from G4UserWorkerThreadInitialization.

Definition at line 122 of file G4UserTaskThreadInitialization.cc.

◆ JoinWorker()

void G4UserTaskThreadInitialization::JoinWorker ( G4Thread aThread)
virtual

Reimplemented from G4UserWorkerThreadInitialization.

Definition at line 58 of file G4UserTaskThreadInitialization.cc.

59{
60 if(aThread)
61 {
62 G4THREADJOIN(*aThread);
63 }
64}
#define G4THREADJOIN(worker)
Definition: G4Threading.hh:259

◆ SetupRNGEngine()

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

Reimplemented from G4UserWorkerThreadInitialization.

Definition at line 76 of file G4UserTaskThreadInitialization.cc.

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

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