70{
72
73
74 G4Random::getTheEngine();
75
76 CLHEP::HepRandomEngine* retRNG = nullptr;
77
78
79 if (dynamic_cast<const CLHEP::HepJamesRandom*>(aNewRNG) != nullptr)
80 retRNG = new CLHEP::HepJamesRandom;
81 else if (dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG) != nullptr)
82 retRNG = new CLHEP::MixMaxRng;
83 else if (dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG) != nullptr)
84 retRNG = new CLHEP::RanecuEngine;
85 else if (dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG) != nullptr)
86 retRNG = new CLHEP::Ranlux64Engine;
87 else if (dynamic_cast<const CLHEP::RanluxppEngine*>(aNewRNG) != nullptr)
88 retRNG = new CLHEP::RanluxppEngine;
89 else if (dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG) != nullptr)
90 retRNG = new CLHEP::MTwistEngine;
91 else if (dynamic_cast<const CLHEP::DualRand*>(aNewRNG) != nullptr)
92 retRNG = new CLHEP::DualRand;
93 else if (dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG) != nullptr)
94 retRNG = new CLHEP::RanluxEngine;
95 else if (dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG) != nullptr)
96 retRNG = new CLHEP::RanshiEngine;
97
98 if (retRNG != nullptr)
99 G4Random::setTheEngine(retRNG);
100 else {
101
103 msg <<
" Unknown type of RNG Engine - " <<
G4endl
104 << " Can cope only with HepJamesRandom, MixMaxRng, Ranecu, Ranlux64,"
105 <<
" Ranlux++, MTwistEngine, DualRand, Ranlux or Ranshi." <<
G4endl
106 <<
" Cannot clone this type of RNG engine, as required for this thread" <<
G4endl
107 <<
" Aborting... " <<
G4endl;
109 }
110}
G4TemplateAutoLock< G4Mutex > G4AutoLock
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription