Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
+1 -1
View File
@@ -120,7 +120,7 @@ G4MTRunManager::G4MTRunManager() : G4RunManager(masterRM),
numberOfEventToBeProcessed = 0;
randDbl = new double[nSeedsPerEvent*nSeedsMax];
char* env = getenv("G4FORCENUMBEROFTHREADS");
char* env = std::getenv("G4FORCENUMBEROFTHREADS");
if(env)
{
G4String envS = env;
+30 -28
View File
@@ -45,14 +45,14 @@
#include <fstream>
////////////////////////////////////////////////////////
G4ThreadLocal G4PhysicsListHelper* G4PhysicsListHelper::pPLHelper = 0;
G4ThreadLocal G4PhysicsListHelper* G4PhysicsListHelper::pPLHelper = nullptr;
////////////////////////////////////////////////////////
G4PhysicsListHelper::G4PhysicsListHelper()
: useCoupledTransportation(false),
theTransportationProcess(0),
theTransportationProcess(nullptr),
verboseLevel(1),
theTable(0),
theTable(nullptr),
sizeOfTable(0),
ordParamFileName("")
{
@@ -78,10 +78,12 @@ G4PhysicsListHelper::~G4PhysicsListHelper()
theTable=0;
sizeOfTable=0;
}
/*
if (theTransportationProcess!=0) {
delete theTransportationProcess;
theTransportationProcess=0;
}
*/
}
////////////////////////////////////////////////////////
@@ -89,7 +91,8 @@ G4PhysicsListHelper* G4PhysicsListHelper::GetPhysicsListHelper()
{
if (!pPLHelper)
{
pPLHelper = new G4PhysicsListHelper;
static G4ThreadLocalSingleton<G4PhysicsListHelper> inst;
pPLHelper = inst.Instance();
}
return pPLHelper;
}
@@ -97,14 +100,14 @@ G4PhysicsListHelper* G4PhysicsListHelper::GetPhysicsListHelper()
////////////////////////////////////////////////////////
void G4PhysicsListHelper::CheckParticleList() const
{
bool isElectron = false;
bool isPositron = false;
bool isGamma = false;
bool isProton = false;
bool isGenericIon = false;
bool isAnyIon = false;
bool isAnyChargedBaryon = false;
bool isEmProc = false;
G4bool isElectron = false;
G4bool isPositron = false;
G4bool isGamma = false;
G4bool isProton = false;
G4bool isGenericIon = false;
G4bool isAnyIon = false;
G4bool isAnyChargedBaryon = false;
G4bool isEmProc = false;
// loop over all particles in G4ParticleTable
aParticleIterator->reset();
@@ -114,7 +117,7 @@ void G4PhysicsListHelper::CheckParticleList() const
// check if any EM process exists
if (!isEmProc) {
G4ProcessVector* list = particle->GetProcessManager()->GetProcessList();
for (int idx=0; idx<list->size(); idx++){
for (std::size_t idx=0; idx<list->size(); ++idx){
isEmProc = ((*list)[idx])->GetProcessType() == fElectromagnetic;
if (isEmProc) break;
}
@@ -136,8 +139,8 @@ void G4PhysicsListHelper::CheckParticleList() const
// RULE 1
// e+, e- and gamma should exist
// if one of them exist
bool isEmBasic = isElectron || isPositron || isGamma;
bool isMissingEmBasic = !isElectron || !isPositron || !isGamma;
G4bool isEmBasic = isElectron || isPositron || isGamma;
G4bool isMissingEmBasic = !isElectron || !isPositron || !isGamma;
if (isEmBasic && isMissingEmBasic) {
G4String missingName="";
if (!isElectron) missingName += "e- ";
@@ -273,8 +276,8 @@ void G4PhysicsListHelper::ReadOrdingParameterTable()
G4bool readInFile = false;
std::ifstream fIn;
if( getenv("G4ORDPARAMTABLE") ){
ordParamFileName = getenv("G4ORDPARAMTABLE");
if( std::getenv("G4ORDPARAMTABLE") ){
ordParamFileName = std::getenv("G4ORDPARAMTABLE");
#ifdef G4VERBOSE
if (verboseLevel >1){
G4cout << "G4PhysicsListHelper::ReadOrdingParameterTable :"
@@ -339,7 +342,6 @@ void G4PhysicsListHelper::ReadOrdingParameterTable()
"The ordering parameter table is empty ");
delete theTable;
theTable=0;
sizeOfTable=0;
}
return;
}
@@ -347,7 +349,7 @@ void G4PhysicsListHelper::ReadOrdingParameterTable()
////////////////////////////////////////////////////////
void G4PhysicsListHelper::DumpOrdingParameterTable(G4int subType) const
{
if (theTable==0) {
if (theTable==0) {
#ifdef G4VERBOSE
if (verboseLevel >0) {
G4cout << "G4PhysicsListHelper::DumpOrdingParameterTable "
@@ -363,7 +365,7 @@ void G4PhysicsListHelper::DumpOrdingParameterTable(G4int subType) const
<< " ProcessType" << " SubType"
<< " AtRest" << " AlongStep" << " PostStep"
<< " Duplicable" << G4endl;
for (int i=0; i<sizeOfTable ; i++){
for (G4int i=0; i<sizeOfTable ; ++i){
G4PhysicsListOrderingParameter* tmp=&(theTable->at(i));
if ((subType>=0) && (subType!=tmp->processSubType)) continue;
G4cout << std::setw(18) << tmp->processTypeName
@@ -397,7 +399,7 @@ G4PhysicsListOrderingParameter G4PhysicsListHelper::GetOrdingParameter(G4int sub
return value;
}
for (int i=0; i<sizeOfTable ; i++){
for (G4int i=0; i<sizeOfTable ; ++i){
G4PhysicsListOrderingParameter* tmp=&(theTable->at(i));
if (subType == tmp->processSubType){
value.processTypeName = tmp->processTypeName;
@@ -424,7 +426,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
<< G4endl;
}
#endif
G4Exception("G4PhysicsListHelper::RegisterPorcess",
G4Exception("G4PhysicsListHelper::RegisterProcess",
"Run0107", FatalException,
"No Ordering Parameter Table");
return false;
@@ -454,7 +456,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
<< " SubType = "<< pSubType << G4endl;
}
#endif
G4Exception("G4PhysicsListHelper::RegisterPorcess",
G4Exception("G4PhysicsListHelper::RegisterProcess",
"Run0108", FatalException,
"No Matching process Type/SubType");
return false;
@@ -463,7 +465,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
G4bool isFound = false;
G4int ord[3];
G4bool duplicable = false;
for (int i=0; i<sizeOfTable ; i++){
for (G4int i=0; i<sizeOfTable ; ++i){
G4PhysicsListOrderingParameter* tmp=&(theTable->at(i));
if ((tmp->processType==pType)&&(tmp->processSubType==pSubType)){
ord[0] = tmp->ordering[0];
@@ -485,7 +487,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
<< G4endl;
}
#endif
G4Exception("G4PhysicsListHelper::RegisterPorcess",
G4Exception("G4PhysicsListHelper::RegisterProcess",
"Run0109", FatalException,
"No Matching process Type/SubType");
return false;
@@ -512,7 +514,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
if (!duplicable){
G4bool duplicated = false;
G4ProcessVector* pList = pManager->GetProcessList();
for (G4int idx=0; idx<pList->size(); idx++) {
for (std::size_t idx=0; idx<pList->size(); ++idx) {
const G4VProcess* p = (*pList)[idx];
if ((p->GetProcessType()== pType) &&
(p->GetProcessSubType()== pSubType)){
@@ -530,7 +532,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
G4cout << "It will not be added !!" << G4endl;
}
#endif
G4Exception("G4PhysicsListHelper::RegisterPorcess",
G4Exception("G4PhysicsListHelper::RegisterProcess",
"Run0111", JustWarning,
"Duplication of processes");
}
@@ -543,7 +545,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
if (code <0) return false;
// Set Ordering Parameter
for(G4int idx=0; idx<3; idx++){
for(G4int idx=0; idx<3; ++idx){
G4ProcessVectorDoItIndex idxOrd = static_cast<G4ProcessVectorDoItIndex>(idx);
if (ord[idx]<0) {
// Do Nothing because NO DOIT
+50 -42
View File
@@ -95,7 +95,7 @@ G4RunManager::G4RunManager()
storeRandomNumberStatusToG4Event(0),rngStatusEventsFlag(false),
currentWorld(0),nParallelWorlds(0),msgText(" "),n_select_msg(-1),
numberOfEventProcessed(0),selectMacro(""),fakeRun(false),
isScoreNtupleWriter(false)
isScoreNtupleWriter(false),geometryDirectlyUpdated(false)
{
if(fRunManager)
{
@@ -111,14 +111,13 @@ G4RunManager::G4RunManager()
runMessenger = new G4RunMessenger(this);
previousEvents = new std::list<G4Event*>;
G4ParticleTable::GetParticleTable()->CreateMessenger();
G4ProcessTable::GetProcessTable()->CreateMessenger();
G4ProcessTable::GetProcessTable();
randomNumberStatusDir = "./";
std::ostringstream oss;
G4Random::saveFullState(oss);
randomNumberStatusForThisRun = oss.str();
randomNumberStatusForThisEvent = oss.str();
runManagerType = sequentialRM;
InitializeTiMemory();
}
G4RunManager::G4RunManager( RMType rmType )
@@ -136,7 +135,7 @@ G4RunManager::G4RunManager( RMType rmType )
storeRandomNumberStatusToG4Event(0),rngStatusEventsFlag(false),
currentWorld(0),nParallelWorlds(0),msgText(" "),n_select_msg(-1),
numberOfEventProcessed(0),selectMacro(""),fakeRun(false),
isScoreNtupleWriter(false)
isScoreNtupleWriter(false),geometryDirectlyUpdated(false)
{
//This version of the constructor should never be called in sequential mode!
#ifndef G4MULTITHREADED
@@ -176,13 +175,12 @@ G4RunManager::G4RunManager( RMType rmType )
runMessenger = new G4RunMessenger(this);
previousEvents = new std::list<G4Event*>;
G4ParticleTable::GetParticleTable()->CreateMessenger();
G4ProcessTable::GetProcessTable()->CreateMessenger();
G4ProcessTable::GetProcessTable();
randomNumberStatusDir = "./";
std::ostringstream oss;
G4Random::saveFullState(oss);
randomNumberStatusForThisRun = oss.str();
randomNumberStatusForThisEvent = oss.str();
InitializeTiMemory();
}
G4RunManager::~G4RunManager()
@@ -200,7 +198,6 @@ G4RunManager::~G4RunManager()
delete timer;
delete runMessenger;
G4ParticleTable::GetParticleTable()->DeleteMessenger();
G4ProcessTable::GetProcessTable()->DeleteMessenger();
delete previousEvents;
//The following will work for all RunManager types
@@ -609,11 +606,22 @@ void G4RunManager::InitializeGeometry()
G4ApplicationState currentState = stateManager->GetCurrentState();
if(currentState==G4State_PreInit || currentState==G4State_Idle)
{ stateManager->SetNewState(G4State_Init); }
kernel->DefineWorldVolume(userDetector->Construct(),false);
userDetector->ConstructSDandField();
nParallelWorlds = userDetector->ConstructParallelGeometries();
userDetector->ConstructParallelSD();
kernel->SetNumberOfParallelWorld(nParallelWorlds);
if(!geometryDirectlyUpdated)
{
kernel->DefineWorldVolume(userDetector->Construct(),false);
userDetector->ConstructSDandField();
nParallelWorlds = userDetector->ConstructParallelGeometries();
userDetector->ConstructParallelSD();
kernel->SetNumberOfParallelWorld(nParallelWorlds);
}
// Notify the VisManager as well
if(G4Threading::IsMasterThread())
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager) pVVisManager->GeometryHasChanged();
}
geometryDirectlyUpdated = false;
geometryInitialized = true;
stateManager->SetNewState(currentState);
}
@@ -762,6 +770,8 @@ void G4RunManager::DumpRegion(G4Region* region) const
void G4RunManager::ConstructScoringWorlds()
{
using MeshShape = G4VScoringMesh::MeshShape;
G4ScoringManager* ScM = G4ScoringManager::GetScoringManagerIfExist();
if(!ScM) return;
@@ -774,43 +784,41 @@ void G4RunManager::ConstructScoringWorlds()
for(G4int iw=0;iw<nPar;iw++)
{
G4VScoringMesh* mesh = ScM->GetMesh(iw);
if(fGeometryHasBeenDestroyed) mesh->GeometryHasBeenDestroyed();
G4VPhysicalVolume* pWorld
= G4TransportationManager::GetTransportationManager()
->IsWorldExisting(ScM->GetWorldName(iw));
if(!pWorld)
if(fGeometryHasBeenDestroyed) mesh->GeometryHasBeenDestroyed();
G4VPhysicalVolume* pWorld = nullptr;
if(mesh->GetShape()!=MeshShape::realWorldLogVol)
{
pWorld = G4TransportationManager::GetTransportationManager()
->GetParallelWorld(ScM->GetWorldName(iw));
pWorld->SetName(ScM->GetWorldName(iw));
G4ParallelWorldProcess* theParallelWorldProcess
= mesh->GetParallelWorldProcess();
if(theParallelWorldProcess)
{ theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw)); }
else
pWorld = G4TransportationManager::GetTransportationManager()->IsWorldExisting(ScM->GetWorldName(iw));
if(!pWorld)
{
theParallelWorldProcess = new G4ParallelWorldProcess(ScM->GetWorldName(iw));
mesh->SetParallelWorldProcess(theParallelWorldProcess);
theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
pWorld = G4TransportationManager::GetTransportationManager()->GetParallelWorld(ScM->GetWorldName(iw));
pWorld->SetName(ScM->GetWorldName(iw));
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if(pmanager)
{
pmanager->AddProcess(theParallelWorldProcess);
if(theParallelWorldProcess->IsAtRestRequired(particle))
{ pmanager->SetProcessOrdering(theParallelWorldProcess, idxAtRest, 9900); }
pmanager->SetProcessOrderingToSecond(theParallelWorldProcess, idxAlongStep);
pmanager->SetProcessOrdering(theParallelWorldProcess, idxPostStep, 9900);
G4ParallelWorldProcess* theParallelWorldProcess = mesh->GetParallelWorldProcess();
if(theParallelWorldProcess)
{ theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw)); }
else
{
theParallelWorldProcess = new G4ParallelWorldProcess(ScM->GetWorldName(iw));
mesh->SetParallelWorldProcess(theParallelWorldProcess);
theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if(pmanager)
{
pmanager->AddProcess(theParallelWorldProcess);
if(theParallelWorldProcess->IsAtRestRequired(particle))
{ pmanager->SetProcessOrdering(theParallelWorldProcess, idxAtRest, 9900); }
pmanager->SetProcessOrderingToSecond(theParallelWorldProcess, idxAlongStep);
pmanager->SetProcessOrdering(theParallelWorldProcess, idxPostStep, 9900);
}
}
}
}
}
mesh->Construct(pWorld);
}
+2 -1
View File
@@ -441,6 +441,7 @@ void G4RunManagerKernel::DefineWorldVolume(G4VPhysicalVolume* worldVol,
{
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState currentState = stateManager->GetCurrentState();
if(currentState!=G4State_Init)
{
if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
@@ -1038,7 +1039,7 @@ void G4RunManagerKernel::SetupShadowProcess() const
if(pm)
{
G4ProcessVector& procs = *(pm->GetProcessList());
for ( G4int idx = 0 ; idx<procs.size() ; ++idx)
for ( std::size_t idx = 0 ; idx<procs.size() ; ++idx)
{
const G4VProcess* masterP = procs[idx]->GetMasterProcess();
if ( ! masterP )
+1 -1
View File
@@ -320,7 +320,7 @@ G4RunMessenger::G4RunMessenger(G4RunManager * runMgr)
randEvtCmd->SetGuidance("for the case of simplest geometry and small number of tracks per event.");
randEvtCmd->SetParameterName("flag",true);
randEvtCmd->SetDefaultValue(0);
randEvtCmd->SetRange("flag>=0 && flag<3");
randEvtCmd->SetRange("flag>=0 && flag<=3");
randEvtCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
procUICmds = new G4UIcmdWithoutParameter("/run/workersProcessCmds",this);
@@ -98,7 +98,8 @@ void G4UserWorkerThreadInitialization::SetupRNGEngine(const CLHEP::HepRandomEngi
retRNG= new CLHEP::RanecuEngine;
}
if ( dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG) ) {
retRNG= new CLHEP::Ranlux64Engine;
const CLHEP::Ranlux64Engine* theRNG = dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG);
retRNG= new CLHEP::Ranlux64Engine(123,theRNG->getLuxury());
}
if ( dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG) ) {
retRNG= new CLHEP::MTwistEngine;
@@ -107,7 +108,8 @@ void G4UserWorkerThreadInitialization::SetupRNGEngine(const CLHEP::HepRandomEngi
retRNG= new CLHEP::DualRand;
}
if ( dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG) ) {
retRNG= new CLHEP::RanluxEngine;
const CLHEP::RanluxEngine* theRNG = dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG);
retRNG= new CLHEP::RanluxEngine(123,theRNG->getLuxury());
}
if ( dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG) ) {
retRNG= new CLHEP::RanshiEngine;
@@ -115,11 +117,14 @@ void G4UserWorkerThreadInitialization::SetupRNGEngine(const CLHEP::HepRandomEngi
if( retRNG != 0 ) {
G4Random::setTheEngine( retRNG );
}else{
}
else
{
// Does a new method, such as aNewRng->newEngine() exist to clone it ?
G4ExceptionDescription msg;
msg<< " Unknown type of RNG Engine - " << G4endl
<< " Can cope only with HepJamesRandom, MixMaxRng, Ranecu, Ranlux64, MTwistEngine, DualRand, Ranlux or Ranshi."
<< " Can cope only with HepJamesRandom, MixMaxRng, Ranecu, Ranlux64,"
<< " MTwistEngine, DualRand, Ranlux or Ranshi."
<< G4endl
<< " Cannot clone this type of RNG engine, as required for this thread" << G4endl
<< " Aborting " << G4endl;
+7 -9
View File
@@ -672,16 +672,16 @@ void G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition* particle)
if (verboseLevel>2){
G4cout << "G4VUserPhysicsList::BuildPhysicsTable %%%%%% " << particle->GetParticleName() << G4endl;
G4cout << " ProcessManager : " << pManager << " ProcessManagerShadow : " << pManagerShadow << G4endl;
for(G4int iv1=0;iv1<pVector->size();iv1++)
for(std::size_t iv1=0;iv1<pVector->size();++iv1)
{ G4cout << " " << iv1 << " - " << (*pVector)[iv1]->GetProcessName() << G4endl; }
G4cout << "--------------------------------------------------------------" << G4endl;
G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
for(G4int iv2=0;iv2<pVectorShadow->size();iv2++)
for(std::size_t iv2=0;iv2<pVectorShadow->size();++iv2)
{ G4cout << " " << iv2 << " - " << (*pVectorShadow)[iv2]->GetProcessName() << G4endl; }
}
#endif
for (G4int j=0; j < pVector->size(); ++j) {
for (std::size_t j=0; j < pVector->size(); ++j) {
//Andrea July 16th 2013 : migration to new interface...
//Infer if we are in a worker thread or master thread
//Master thread is the one in which the process manager
@@ -746,7 +746,7 @@ void G4VUserPhysicsList::PreparePhysicsTable(G4ParticleDefinition* particle)
"No process Vector");
return;
}
for (G4int j=0; j < pVector->size(); ++j) {
for (std::size_t j=0; j < pVector->size(); ++j) {
//Andrea July 16th 2013 : migration to new interface...
//Infer if we are in a worker thread or master thread
@@ -857,8 +857,7 @@ G4bool G4VUserPhysicsList::StorePhysicsTable(const G4String& directory)
G4ParticleDefinition* particle = theParticleIterator->value();
// Store physics tables for every process for this particle type
G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
G4int j;
for ( j=0; j < pVector->size(); ++j) {
for (std::size_t j=0; j < pVector->size(); ++j) {
if (!(*pVector)[j]->StorePhysicsTable(particle,dir,ascii)){
G4String comment = "Fail to store physics table for ";
comment += (*pVector)[j]->GetProcessName();
@@ -893,11 +892,10 @@ void G4VUserPhysicsList::RetrievePhysicsTable(G4ParticleDefinition* particle,
const G4String& directory,
G4bool ascii)
{
G4int j;
G4bool success[100];
// Retrieve physics tables for every process for this particle type
G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
for ( j=0; j < pVector->size(); ++j) {
for (std::size_t j=0; j < pVector->size(); ++j) {
success[j] =
(*pVector)[j]->RetrievePhysicsTable(particle,directory,ascii);
@@ -914,7 +912,7 @@ void G4VUserPhysicsList::RetrievePhysicsTable(G4ParticleDefinition* particle,
(*pVector)[j]->BuildPhysicsTable(*particle);
}
}
for ( j=0; j < pVector->size(); ++j) {
for (std::size_t j=0; j < pVector->size(); ++j) {
// temporary addition to make the integral schema
if (!success[j]) BuildIntegralPhysicsTable((*pVector)[j], particle);
}
+58 -32
View File
@@ -57,8 +57,10 @@ G4WorkerRunManager* G4WorkerRunManager::GetWorkerRunManager()
G4WorkerRunManagerKernel* G4WorkerRunManager::GetWorkerRunManagerKernel()
{ return static_cast<G4WorkerRunManagerKernel*>(GetWorkerRunManager()->kernel); }
G4WorkerRunManager::G4WorkerRunManager() : G4RunManager(workerRM) {
//This constructor should never be called in non-multithreaded mode
G4WorkerRunManager::G4WorkerRunManager() : G4RunManager(workerRM)
{
// This constructor should never be called in non-multithreaded mode
#ifndef G4MULTITHREADED
G4ExceptionDescription msg;
msg<<"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
@@ -76,6 +78,23 @@ G4WorkerRunManager::G4WorkerRunManager() : G4RunManager(workerRM) {
workerContext = 0;
readStatusFromFile = false;
// Properly initialise luxury level for Ranlux* engines...
//
if ( dynamic_cast<const CLHEP::Ranlux64Engine*>(G4Random::getTheEngine()) )
{
const CLHEP::Ranlux64Engine* theEngine = dynamic_cast<const CLHEP::Ranlux64Engine*>(G4Random::getTheEngine());
luxury = theEngine->getLuxury();
}
else if ( dynamic_cast<const CLHEP::RanluxEngine*>(G4Random::getTheEngine()) )
{
const CLHEP::RanluxEngine* theEngine = dynamic_cast<const CLHEP::RanluxEngine*>(G4Random::getTheEngine());
luxury = theEngine->getLuxury();
}
else
{
luxury = -1;
}
G4UImanager::GetUIpointer()->SetIgnoreCmdNotFound(true);
#ifdef G4MULTITHREADED
@@ -92,7 +111,8 @@ G4WorkerRunManager::G4WorkerRunManager() : G4RunManager(workerRM) {
#include "G4MTRunManager.hh"
G4WorkerRunManager::~G4WorkerRunManager() {
G4WorkerRunManager::~G4WorkerRunManager()
{
// Delete thread-local data process manager objects
physicsList->TerminateWorker();
// physicsList->RemoveProcessManager();
@@ -338,7 +358,7 @@ G4Event* G4WorkerRunManager::GenerateEvent(G4int i_event)
if(eventHasToBeSeeded)
{
long seeds[3] = { s1, s2, 0 };
G4Random::setTheSeeds(seeds,-1);
G4Random::setTheSeeds(seeds,luxury);
runIsSeeded = true;
////G4cout<<"Event "<<currEvID<<" is seeded with { "<<s1<<", "<<s2<<" }"<<G4endl;
}
@@ -460,6 +480,8 @@ void G4WorkerRunManager::BeamOn(G4int n_event,const char* macroFile,G4int n_sele
namespace { G4Mutex ConstructScoringWorldsMutex = G4MUTEX_INITIALIZER; }
void G4WorkerRunManager::ConstructScoringWorlds()
{
using MeshShape = G4VScoringMesh::MeshShape;
// Return if unnecessary
G4ScoringManager* ScM = G4ScoringManager::GetScoringManagerIfExist();
if(!ScM) return;
@@ -479,15 +501,16 @@ void G4WorkerRunManager::ConstructScoringWorlds()
{
G4VScoringMesh* mesh = ScM->GetMesh(iw);
if(fGeometryHasBeenDestroyed) mesh->GeometryHasBeenDestroyed();
G4VPhysicalVolume* pWorld
= G4TransportationManager::GetTransportationManager()
->IsWorldExisting(ScM->GetWorldName(iw));
if(!pWorld)
G4VPhysicalVolume* pWorld = nullptr;
if(mesh->GetShape()!=MeshShape::realWorldLogVol)
{
G4ExceptionDescription ed;
ed<<"Mesh name <"<<ScM->GetWorldName(iw)<<"> is not found in the master thread.";
G4Exception("G4WorkerRunManager::ConstructScoringWorlds()","RUN79001",
FatalException,ed);
pWorld = G4TransportationManager::GetTransportationManager()->IsWorldExisting(ScM->GetWorldName(iw));
if(!pWorld)
{
G4ExceptionDescription ed;
ed<<"Mesh name <"<<ScM->GetWorldName(iw)<<"> is not found in the master thread.";
G4Exception("G4WorkerRunManager::ConstructScoringWorlds()","RUN79001",FatalException,ed);
}
}
if(!(mesh->GetMeshElementLogical()))
{
@@ -496,28 +519,31 @@ void G4WorkerRunManager::ConstructScoringWorlds()
mesh->SetMeshElementLogical(masterMesh->GetMeshElementLogical());
l.unlock();
G4ParallelWorldProcess* theParallelWorldProcess = mesh->GetParallelWorldProcess();
if(theParallelWorldProcess)
{ theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw)); }
else
if(mesh->GetShape()!=MeshShape::realWorldLogVol)
{
theParallelWorldProcess = new G4ParallelWorldProcess(ScM->GetWorldName(iw));
mesh->SetParallelWorldProcess(theParallelWorldProcess);
theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
G4ParallelWorldProcess* theParallelWorldProcess = mesh->GetParallelWorldProcess();
if(theParallelWorldProcess)
{ theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw)); }
else
{
theParallelWorldProcess = new G4ParallelWorldProcess(ScM->GetWorldName(iw));
mesh->SetParallelWorldProcess(theParallelWorldProcess);
theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
particleIterator->reset();
while( (*particleIterator)() ){
G4ParticleDefinition* particle = particleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if(pmanager)
{
pmanager->AddProcess(theParallelWorldProcess);
if(theParallelWorldProcess->IsAtRestRequired(particle))
{ pmanager->SetProcessOrdering(theParallelWorldProcess, idxAtRest, 9900); }
pmanager->SetProcessOrderingToSecond(theParallelWorldProcess, idxAlongStep);
pmanager->SetProcessOrdering(theParallelWorldProcess, idxPostStep, 9900);
} //if(pmanager)
}//while
particleIterator->reset();
while( (*particleIterator)() ){
G4ParticleDefinition* particle = particleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if(pmanager)
{
pmanager->AddProcess(theParallelWorldProcess);
if(theParallelWorldProcess->IsAtRestRequired(particle))
{ pmanager->SetProcessOrdering(theParallelWorldProcess, idxAtRest, 9900); }
pmanager->SetProcessOrderingToSecond(theParallelWorldProcess, idxAlongStep);
pmanager->SetProcessOrdering(theParallelWorldProcess, idxPostStep, 9900);
} //if(pmanager)
}//while
}
}
}
mesh->WorkerConstruct(pWorld);
+3 -3
View File
@@ -74,10 +74,10 @@ void G4WorkerRunManagerKernel::SetupShadowProcess() const
G4cout << "G4WorkerRunManagerKernel::SetupShadowProcess() for particle <"
<< pd->GetParticleName() << ">" << G4endl;
G4cout << " ProcessManager : " << pm << " ProcessManagerShadow : " << pmM << G4endl;
for(G4int iv1=0;iv1<procs.size();iv1++)
for(std::size_t iv1=0;iv1<procs.size();++iv1)
{ G4cout << " " << iv1 << " - " << procs[iv1]->GetProcessName() << G4endl; }
G4cout << "--------------------------------------------------------------" << G4endl;
for(G4int iv2=0;iv2<procsM.size();iv2++)
for(std::size_t iv2=0;iv2<procsM.size();++iv2)
{ G4cout << " " << iv2 << " - " << procsM[iv2]->GetProcessName() << G4endl; }
G4cout << "--------------------------------------------------------------" << G4endl;
G4ExceptionDescription msg;
@@ -91,7 +91,7 @@ void G4WorkerRunManagerKernel::SetupShadowProcess() const
//process from master. Note that we rely on
//processes being in the correct order!
// We could use some checking using process name or type
for ( G4int idx = 0 ; idx < procs.size() ; ++idx )
for ( std::size_t idx = 0 ; idx < procs.size() ; ++idx )
{
procs[idx]->SetMasterProcess(procsM[idx]);
}