Import Geant4 10.1.0 source tree
This commit is contained in:
@@ -23,6 +23,13 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GeometryWorkspace.cc 79096 2014-02-14 16:07:39Z gcosmo $
|
||||
//
|
||||
//
|
||||
// Class G4GeometryWorkspace - implementation
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#include "G4GeometryWorkspace.hh"
|
||||
|
||||
@@ -39,7 +46,13 @@
|
||||
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
namespace
|
||||
{
|
||||
G4Mutex solidclone = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
G4GeometryWorkspace::G4GeometryWorkspace()
|
||||
: fVerbose(false)
|
||||
{
|
||||
@@ -52,7 +65,8 @@ G4GeometryWorkspace::G4GeometryWorkspace()
|
||||
fpRegionSIM=
|
||||
&const_cast<G4RegionManager&>(G4Region::GetSubInstanceManager());
|
||||
|
||||
// Create a work area for Logical Volumes in this thread - then capture its address
|
||||
// Create a work area for Logical Volumes in this thread
|
||||
// then capture its address
|
||||
InitialiseWorkspace();
|
||||
|
||||
fLogicalVolumeOffset= fpLogicalVolumeSIM->GetOffset();
|
||||
@@ -64,25 +78,28 @@ G4GeometryWorkspace::G4GeometryWorkspace()
|
||||
fRegionOffset= fpRegionSIM->GetOffset();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
G4GeometryWorkspace::~G4GeometryWorkspace()
|
||||
{
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
// Static methods
|
||||
// For with current (original) G4WorkerThread -- which uses static methods
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
void
|
||||
G4GeometryWorkspace::UseWorkspace()
|
||||
{
|
||||
if( fVerbose )
|
||||
G4cout << "G4GeometryWorkspace::UseWorkspace: Start " << G4endl;
|
||||
{
|
||||
G4cout << "G4GeometryWorkspace::UseWorkspace: Start " << G4endl;
|
||||
}
|
||||
|
||||
// Implementation copied from G4WorkerThread::BuildGeometryAndPhysicsVector()
|
||||
// and improved for G4PVParamaterised
|
||||
// John Apostolakis, May 30, 2013
|
||||
// Implementation originally in:
|
||||
// G4WorkerThread::BuildGeometryAndPhysicsVector()
|
||||
// and improved for G4PVParamaterised
|
||||
|
||||
//Geometry related, split classes mechanism: instantiate sub-instance for this thread
|
||||
// Geometry related, split classes mechanism: instantiate sub-instance
|
||||
// for this thread
|
||||
fpLogicalVolumeSIM->UseWorkArea(fLogicalVolumeOffset);
|
||||
fpPhysicalVolumeSIM->UseWorkArea(fPhysicalVolumeOffset);
|
||||
|
||||
@@ -94,13 +111,15 @@ G4GeometryWorkspace::UseWorkspace()
|
||||
// - so it must NOT Initialise anything!
|
||||
// Do not call InitialisePhysicalVolumes();
|
||||
|
||||
if( fVerbose )
|
||||
if( fVerbose )
|
||||
{
|
||||
G4cout << "G4GeometryWorkspace::UseWorkspace: End " << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
void G4GeometryWorkspace::ReleaseWorkspace()
|
||||
// The opposite of Use Workspace - let go of it.
|
||||
{
|
||||
fpLogicalVolumeSIM->UseWorkArea(0);
|
||||
fpPhysicalVolumeSIM->UseWorkArea(0);
|
||||
@@ -109,62 +128,65 @@ void G4GeometryWorkspace::ReleaseWorkspace()
|
||||
fpRegionSIM->UseWorkArea(0);
|
||||
}
|
||||
|
||||
namespace {
|
||||
G4Mutex solidclone= G4MUTEX_INITIALIZER;
|
||||
}
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
void G4GeometryWorkspace::InitialisePhysicalVolumes()
|
||||
{
|
||||
G4PhysicalVolumeStore* physVolStore = G4PhysicalVolumeStore::GetInstance();
|
||||
for (size_t ip=0; ip<physVolStore->size(); ip++)
|
||||
{
|
||||
G4PhysicalVolumeStore* physVolStore = G4PhysicalVolumeStore::GetInstance();
|
||||
for (size_t ip=0; ip<physVolStore->size(); ip++)
|
||||
G4VPhysicalVolume* physVol = (*physVolStore)[ip];
|
||||
G4LogicalVolume *logicalVol = physVol->GetLogicalVolume();
|
||||
|
||||
// Use shadow pointer
|
||||
//
|
||||
G4VSolid *solid = logicalVol->GetMasterSolid();
|
||||
G4PVReplica *g4PVReplica = 0;
|
||||
g4PVReplica = dynamic_cast<G4PVReplica*>(physVol);
|
||||
if (!g4PVReplica)
|
||||
{
|
||||
G4VPhysicalVolume* physVol = (*physVolStore)[ip];
|
||||
G4LogicalVolume *logicalVol = physVol->GetLogicalVolume();
|
||||
//use shadow pointer
|
||||
G4VSolid *solid = logicalVol->GetMasterSolid();
|
||||
G4PVReplica *g4PVReplica = 0;
|
||||
g4PVReplica = dynamic_cast<G4PVReplica*>(physVol);
|
||||
if (!g4PVReplica)
|
||||
{
|
||||
// Placement volume
|
||||
logicalVol->InitialiseWorker(logicalVol,solid,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//g4PVReplica->SlaveG4PVReplica(g4PVReplica);
|
||||
g4PVReplica->InitialiseWorker(g4PVReplica);
|
||||
if( ! g4PVReplica->IsParameterised() )
|
||||
{
|
||||
logicalVol->InitialiseWorker(logicalVol,solid,0);
|
||||
// If the replica's solid (in LV) is changed during navigation, it must be thread-private
|
||||
CloneReplicaSolid( g4PVReplica );
|
||||
}
|
||||
else
|
||||
{
|
||||
G4PVParameterised *paramVol
|
||||
= dynamic_cast<G4PVParameterised*>(physVol);
|
||||
if (!paramVol)
|
||||
{
|
||||
G4Exception("G4GeometryWorkspace::CreateAndUseWorkspace", "Runtime Error PV01",
|
||||
FatalException,
|
||||
"Cannot find Parameterisation for G4PVParameterised object.");
|
||||
}
|
||||
CloneParameterisedSolids( paramVol );
|
||||
}
|
||||
}
|
||||
// Placement volume
|
||||
logicalVol->InitialiseWorker(logicalVol,solid,0);
|
||||
}
|
||||
if( fVerbose )
|
||||
G4cout << "G4GeometryWorkspace::InitialisePhysicalVolumes: "
|
||||
<< "Copying geometry - Done!" << G4endl;
|
||||
else
|
||||
{
|
||||
g4PVReplica->InitialiseWorker(g4PVReplica);
|
||||
if( ! g4PVReplica->IsParameterised() )
|
||||
{
|
||||
logicalVol->InitialiseWorker(logicalVol,solid,0);
|
||||
|
||||
// If the replica's solid (in LV) is changed during navigation,
|
||||
// it must be thread-private
|
||||
//
|
||||
CloneReplicaSolid( g4PVReplica );
|
||||
}
|
||||
else
|
||||
{
|
||||
G4PVParameterised *paramVol = dynamic_cast<G4PVParameterised*>(physVol);
|
||||
if (!paramVol)
|
||||
{
|
||||
G4Exception("G4GeometryWorkspace::CreateAndUseWorkspace()",
|
||||
"GeomVol0003", FatalException,
|
||||
"Cannot find Parameterisation for parameterised volume.");
|
||||
}
|
||||
CloneParameterisedSolids( paramVol );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( fVerbose )
|
||||
{
|
||||
G4cout << "G4GeometryWorkspace::InitialisePhysicalVolumes: "
|
||||
<< "Copying geometry - Done!" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Create a clone of the solid for this replica in this thread
|
||||
//
|
||||
G4bool G4GeometryWorkspace::CloneReplicaSolid( G4PVReplica *replicaPV )
|
||||
{
|
||||
// Create a clone of the solid for this replica in this thread
|
||||
|
||||
// Check that it is not a parameterisation ?
|
||||
|
||||
// The solid Ptr is in the Logical Volume
|
||||
// The solid Ptr is in the Logical Volume
|
||||
//
|
||||
G4LogicalVolume *logicalV= replicaPV ->GetLogicalVolume();
|
||||
G4VSolid *solid= logicalV->GetSolid();
|
||||
|
||||
@@ -175,39 +197,44 @@ G4bool G4GeometryWorkspace::CloneReplicaSolid( G4PVReplica *replicaPV )
|
||||
if( workerSolid )
|
||||
{
|
||||
logicalV->InitialiseWorker(logicalV,workerSolid,0);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
// In the case that not all solids support(ed) the Clone()
|
||||
// method, we do similar thing here to dynamically cast
|
||||
// and then get the clone method.
|
||||
//
|
||||
G4ExceptionDescription ed;
|
||||
ed << " ERROR: Unable to initialise geometry for worker node." << G4endl;
|
||||
ed << " A solid lacks the Clone() method - or Clone() failed." << G4endl;
|
||||
ed << " Type of solid: " << solid->GetEntityType() << G4endl;
|
||||
ed << " Parameters: " << *solid << G4endl;
|
||||
G4Exception(" G4GeometryWorkspace::CloneParameterisedVolume", "MT-BuildGeometry001",
|
||||
FatalException, ed);
|
||||
ed << "ERROR - Unable to initialise geometry for worker node." << "\n"
|
||||
<< "A solid lacks the Clone() method - or Clone() failed." << "\n"
|
||||
<< " Type of solid: " << solid->GetEntityType() << "\n"
|
||||
<< " Parameters: " << *solid;
|
||||
G4Exception("G4GeometryWorkspace::CloneParameterisedVolume()",
|
||||
"GeomVol0003", FatalException, ed);
|
||||
return false;
|
||||
}
|
||||
return true; // It Worked
|
||||
}
|
||||
|
||||
G4bool G4GeometryWorkspace::CloneParameterisedSolids( G4PVParameterised *paramVol )
|
||||
// ----------------------------------------------------------------------
|
||||
// Each G4PVParameterised instance, has associated with it at least one
|
||||
// solid for each worker thread.
|
||||
// *Simple* Parameterisations have a single type of solid, and the
|
||||
// pointer points to the same instance of a solid during the simulation.
|
||||
// For this case, it is possible to adapt automatically to
|
||||
// multi-threading, simply by cloning the solid - so long
|
||||
// as all solids support the Clone() method.
|
||||
//
|
||||
G4bool G4GeometryWorkspace::
|
||||
CloneParameterisedSolids( G4PVParameterised *paramVol )
|
||||
{
|
||||
// Each G4PVParameterised instance, has associated with it at least one
|
||||
// solid for each worker thread.
|
||||
// *Simple* Parameterisations have a single type of solid, and the
|
||||
// pointer points to the same instance of a solid during the simulation.
|
||||
// For this case, it is possible to adapt automatically to
|
||||
// multi-threading, simply by cloning the solid - so long
|
||||
// as all solids support the Clone() method.
|
||||
|
||||
// Check whether it is a simple parameterisation or not
|
||||
//
|
||||
G4VPVParameterisation *param= paramVol->GetParameterisation();
|
||||
unsigned int numCopies= paramVol->GetMultiplicity();
|
||||
unsigned int numDifferent= 0;
|
||||
|
||||
G4LogicalVolume *logicalV= paramVol->GetLogicalVolume();
|
||||
// assert( logicalV != 0);
|
||||
G4VSolid *solid= logicalV->GetSolid();
|
||||
|
||||
for( unsigned int i=0; i< numCopies; i++)
|
||||
@@ -221,53 +248,59 @@ G4bool G4GeometryWorkspace::CloneParameterisedSolids( G4PVParameterised *paramVo
|
||||
if( numDifferent>0 )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
|
||||
ed << " Parameterisation is implemented using several instances of Solids "
|
||||
<< " - potentially to support different types of solids. " << G4endl;
|
||||
ed << " The current implementation of Geant4-MT does not support "
|
||||
<< " this type of Parameterisation" << G4endl;
|
||||
G4Exception("G4GeometryWorkspace::CloneParameterisedVolume", "GeometryNotSupportedInMT-01",
|
||||
FatalException, ed);
|
||||
ed << "ERROR - Parameterisation using several instances of Solids \n"
|
||||
<< "potentially to support different types of solids. \n"
|
||||
<< "Geant4-MT currently does not support this type of \n"
|
||||
<< "parameterisation, sorry !";
|
||||
G4Exception("G4GeometryWorkspace::CloneParameterisedVolume()",
|
||||
"GeomVol0001", FatalException, ed);
|
||||
}
|
||||
|
||||
// Threads may attempt to clone a solids simultaneously. Those cloned solids will be
|
||||
// registered into a shared solid store (C++ container). Need a lock to
|
||||
// guarantee thread safety
|
||||
// Threads may attempt to clone a solids simultaneously.
|
||||
// Those cloned solids will be registered into a shared solid
|
||||
// store (C++ container). Need a lock to guarantee thread safety
|
||||
//
|
||||
G4AutoLock aLock(&solidclone);
|
||||
G4VSolid *workerSolid = solid->Clone();
|
||||
aLock.unlock();
|
||||
if( workerSolid )
|
||||
{
|
||||
logicalV->InitialiseWorker(logicalV,workerSolid,0);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
// In the case that not all solids support(ed) the Clone()
|
||||
// method, we do similar thing here to dynamically cast
|
||||
// and then get the clone method.
|
||||
// and then get the clone method
|
||||
//
|
||||
G4ExceptionDescription ed;
|
||||
ed << " ERROR: Unable to initialise geometry for worker node." << G4endl;
|
||||
ed << " A solid lacks the Clone() method - or Clone() failed." << G4endl;
|
||||
ed << " Type of solid: " << solid->GetEntityType() << G4endl;
|
||||
ed << " Parameters: " << *solid << G4endl;
|
||||
G4Exception(" G4GeometryWorkspace::CloneParameterisedVolume", "MT-BuildGeometry001",
|
||||
FatalException, ed);
|
||||
ed << "ERROR - Unable to initialise geometry for worker node. \n"
|
||||
<< "A solid lacks the Clone() method - or Clone() failed. \n"
|
||||
<< " Type of solid: " << solid->GetEntityType() << "\n"
|
||||
<< " Parameters: " << *solid;
|
||||
G4Exception("G4GeometryWorkspace::CloneParameterisedVolume()",
|
||||
"GeomVol0003", FatalException, ed);
|
||||
}
|
||||
return true; // It Worked
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
G4GeometryWorkspace::InitialiseWorkspace()
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
void G4GeometryWorkspace::InitialiseWorkspace()
|
||||
{
|
||||
if( fVerbose )
|
||||
G4cout << "G4GeometryWorkspace::InitialiseWorkspace: Copying geometry - Start " << G4endl;
|
||||
if( fVerbose )
|
||||
{
|
||||
G4cout << "G4GeometryWorkspace::InitialiseWorkspace():"
|
||||
<< " Copying geometry - Start " << G4endl;
|
||||
}
|
||||
|
||||
// Implementation copied from G4WorkerThread::BuildGeometryAndPhysicsVector()
|
||||
// and improved for G4PVParamaterised
|
||||
// John Apostolakis, May 30, 2013
|
||||
// Implementation originally in:
|
||||
// G4WorkerThread::BuildGeometryAndPhysicsVector()
|
||||
// and improved for G4PVParamaterised
|
||||
|
||||
//Geometry related, split classes mechanism:
|
||||
// Do *NOT* instantiate sub-instance for this thread,
|
||||
// just copy the contents !!
|
||||
// Geometry related, split classes mechanism:
|
||||
// Do *NOT* instantiate sub-instance for this thread, just copy the contents!
|
||||
//
|
||||
fpLogicalVolumeSIM->SlaveCopySubInstanceArray();
|
||||
fpPhysicalVolumeSIM->SlaveCopySubInstanceArray();
|
||||
fpReplicaSIM->SlaveCopySubInstanceArray();
|
||||
@@ -275,11 +308,15 @@ G4GeometryWorkspace::InitialiseWorkspace()
|
||||
|
||||
InitialisePhysicalVolumes();
|
||||
|
||||
if( fVerbose )
|
||||
G4cout << "G4GeometryWorkspace::InitialiseWorkspace: "
|
||||
<< "Copying geometry - Done!" << G4endl;
|
||||
if( fVerbose )
|
||||
{
|
||||
G4cout << "G4GeometryWorkspace::InitialiseWorkspace: "
|
||||
<< "Copying geometry - Done!" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
void G4GeometryWorkspace::DestroyWorkspace()
|
||||
{
|
||||
G4PhysicalVolumeStore* physVolStore = G4PhysicalVolumeStore::GetInstance();
|
||||
@@ -310,7 +347,6 @@ void G4GeometryWorkspace::DestroyWorkspace()
|
||||
logicalVol->TerminateWorker(logicalVol);
|
||||
}
|
||||
}
|
||||
|
||||
fpLogicalVolumeSIM->FreeSlave();
|
||||
fpPhysicalVolumeSIM->FreeSlave();
|
||||
fpReplicaSIM->FreeSlave();
|
||||
|
||||
@@ -23,42 +23,60 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
#include "G4Types.hh"
|
||||
//
|
||||
// $Id: G4GeometryWorkspacePool.cc 79096 2014-02-14 16:07:39Z gcosmo $
|
||||
//
|
||||
//
|
||||
// Class G4GeometryWorkspacePool - implementation
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#include "G4GeometryWorkspacePool.hh"
|
||||
#include "G4GeometryWorkspace.hh"
|
||||
|
||||
#include "G4AutoLock.hh"
|
||||
namespace {
|
||||
G4Mutex singletonM = G4MUTEX_INITIALIZER;
|
||||
|
||||
namespace
|
||||
{
|
||||
G4Mutex singletonM = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
G4ThreadLocal G4GeometryWorkspace* G4GeometryWorkspacePool::fMyWorkspace=0;
|
||||
|
||||
G4GeometryWorkspacePool* G4GeometryWorkspacePool::thePool=0;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
G4GeometryWorkspacePool* G4GeometryWorkspacePool::GetInstance()
|
||||
{
|
||||
G4AutoLock l(&singletonM);
|
||||
if( !thePool ) thePool= new G4GeometryWorkspacePool();
|
||||
return thePool;
|
||||
G4AutoLock l(&singletonM);
|
||||
if ( !thePool ) { thePool= new G4GeometryWorkspacePool(); }
|
||||
return thePool;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// For use with MT and current G4WorkerThread -- which uses static methods
|
||||
//
|
||||
G4GeometryWorkspace* G4GeometryWorkspacePool::CreateWorkspace()
|
||||
{
|
||||
G4GeometryWorkspace* geometryWrk=0;
|
||||
if( !fMyWorkspace ){
|
||||
if( !fMyWorkspace )
|
||||
{
|
||||
geometryWrk= new G4GeometryWorkspace();
|
||||
|
||||
if( !geometryWrk ) {
|
||||
G4Exception("GeometryWorspacePool::CreateWorkspace", "Geom-003",
|
||||
if( !geometryWrk )
|
||||
{
|
||||
G4Exception("GeometryWorspacePool::CreateWorkspace", "GeomVol003",
|
||||
FatalException, "Failed to create workspace.");
|
||||
}else{
|
||||
fMyWorkspace= geometryWrk;
|
||||
}
|
||||
}else{
|
||||
G4Exception("GeometryWorspacePool::CreateWorkspace", "Geom-003",
|
||||
else
|
||||
{
|
||||
fMyWorkspace= geometryWrk;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Exception("GeometryWorspacePool::CreateWorkspace", "GeomVol003",
|
||||
FatalException,
|
||||
"Cannot create workspace twice for the same thread.");
|
||||
geometryWrk= fMyWorkspace;
|
||||
@@ -67,62 +85,56 @@ G4GeometryWorkspace* G4GeometryWorkspacePool::CreateWorkspace()
|
||||
return geometryWrk;
|
||||
}
|
||||
|
||||
|
||||
void G4GeometryWorkspacePool::CreateAndUseWorkspace() // Create it (as above) and use it
|
||||
// ----------------------------------------------------------------------
|
||||
// Create it (as above) and use it
|
||||
//
|
||||
void G4GeometryWorkspacePool::CreateAndUseWorkspace()
|
||||
{
|
||||
(this->CreateWorkspace())->UseWorkspace();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Reuse an existing workspace - or create a new one if needed.
|
||||
//
|
||||
G4GeometryWorkspace* G4GeometryWorkspacePool::FindOrCreateWorkspace()
|
||||
{
|
||||
G4GeometryWorkspace* geometryWrk= fMyWorkspace;
|
||||
if( !geometryWrk ){
|
||||
geometryWrk= this->CreateWorkspace();
|
||||
}
|
||||
geometryWrk->UseWorkspace();
|
||||
G4GeometryWorkspace* geometryWrk= fMyWorkspace;
|
||||
if( !geometryWrk )
|
||||
{
|
||||
geometryWrk= this->CreateWorkspace();
|
||||
}
|
||||
geometryWrk->UseWorkspace();
|
||||
|
||||
fMyWorkspace= geometryWrk; // assign it for use by this thread.
|
||||
return geometryWrk;
|
||||
fMyWorkspace= geometryWrk; // assign it for use by this thread.
|
||||
return geometryWrk;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void G4GeometryWorkspacePool::ReleaseAndDestroyMyWorkspace()
|
||||
{
|
||||
ReleaseAndDestroyWorkspace(fMyWorkspace);
|
||||
fMyWorkspace=0;
|
||||
}
|
||||
|
||||
void G4GeometryWorkspacePool::ReleaseAndDestroyWorkspace(G4GeometryWorkspace *geometryWrk)
|
||||
{
|
||||
geometryWrk->ReleaseWorkspace();
|
||||
delete geometryWrk;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
void G4GeometryWorkspacePool::Recycle( G4GeometryWorkspace *geometryWrk )
|
||||
{
|
||||
geometryWrk->ReleaseWorkspace();
|
||||
//if( fWarehouse ){
|
||||
//} else {
|
||||
delete geometryWrk;
|
||||
//}
|
||||
geometryWrk->ReleaseWorkspace();
|
||||
// if( fWarehouse ){
|
||||
// } else {
|
||||
delete geometryWrk;
|
||||
// }
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
void G4GeometryWorkspacePool::CleanUpAndDestroyAllWorkspaces()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
G4GeometryWorkspacePool::G4GeometryWorkspacePool()
|
||||
{
|
||||
// fWarehouse=0;
|
||||
// fWarehouse=0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
G4GeometryWorkspacePool::~G4GeometryWorkspacePool()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4LogicalBorderSurface.cc 73926 2013-09-17 07:59:06Z gcosmo $
|
||||
// $Id: G4LogicalBorderSurface.cc 80067 2014-03-31 13:48:09Z gcosmo $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// G4LogicalBorderSurface Implementation
|
||||
@@ -88,7 +88,7 @@ G4LogicalBorderSurface::~G4LogicalBorderSurface()
|
||||
// Operators
|
||||
//
|
||||
|
||||
const G4LogicalBorderSurface&
|
||||
G4LogicalBorderSurface&
|
||||
G4LogicalBorderSurface::operator=(const G4LogicalBorderSurface &right)
|
||||
{
|
||||
if (&right == this) return *this;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4LogicalSkinSurface.cc 73926 2013-09-17 07:59:06Z gcosmo $
|
||||
// $Id: G4LogicalSkinSurface.cc 80067 2014-03-31 13:48:09Z gcosmo $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// G4LogicalSkinSurface Implementation
|
||||
@@ -83,7 +83,7 @@ G4LogicalSkinSurface::~G4LogicalSkinSurface()
|
||||
// Operators
|
||||
//
|
||||
|
||||
const G4LogicalSkinSurface&
|
||||
G4LogicalSkinSurface&
|
||||
G4LogicalSkinSurface::operator=(const G4LogicalSkinSurface& right)
|
||||
{
|
||||
if (&right == this) return *this;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4NavigationHistory.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
// $Id: G4NavigationHistory.cc 86527 2014-11-13 15:06:24Z gcosmo $
|
||||
//
|
||||
//
|
||||
// G4NavigationHistory Implementation
|
||||
@@ -33,31 +33,36 @@
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#include "G4NavigationHistory.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4NavigationHistory.hh"
|
||||
|
||||
#ifndef WIN32
|
||||
// Initialise static data for the specialized memory pool
|
||||
// for the internal STL vector of histories ...
|
||||
//
|
||||
G4ThreadLocal G4ChunkIndexType* G4AllocStats::allocStat = 0;
|
||||
G4ThreadLocal G4int G4AllocStats::totSpace = 0;
|
||||
G4ThreadLocal G4int G4AllocStats::numCat = 0;
|
||||
#endif
|
||||
G4ThreadLocal G4Allocator<G4NavigationHistory> *aNavigHistoryAllocator = 0;
|
||||
|
||||
G4NavigationHistory::G4NavigationHistory()
|
||||
: fNavHistory(kHistoryMax), fStackDepth(0)
|
||||
: fStackDepth(0)
|
||||
{
|
||||
fNavHistory = G4NavigationHistoryPool::GetInstance()->GetNewLevels();
|
||||
Clear();
|
||||
}
|
||||
|
||||
G4NavigationHistory::G4NavigationHistory(const G4NavigationHistory &h)
|
||||
: fNavHistory(h.fNavHistory), fStackDepth(h.fStackDepth)
|
||||
{
|
||||
fNavHistory = G4NavigationHistoryPool::GetInstance()->GetLevels();
|
||||
if( GetMaxDepth() != h.GetMaxDepth() )
|
||||
{
|
||||
fNavHistory->resize( h.GetMaxDepth() );
|
||||
}
|
||||
|
||||
for ( G4int ilev=h.fStackDepth; ilev>=0; --ilev )
|
||||
{
|
||||
(*fNavHistory)[ilev] = (*h.fNavHistory)[ilev];
|
||||
}
|
||||
fStackDepth=h.fStackDepth;
|
||||
}
|
||||
|
||||
G4NavigationHistory::~G4NavigationHistory()
|
||||
{
|
||||
G4NavigationHistoryPool::GetInstance()->DeRegister(fNavHistory);
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id:$
|
||||
//
|
||||
// G4NavigationHistoryPool
|
||||
//
|
||||
// Implementation for singleton container
|
||||
//
|
||||
// History:
|
||||
// 07.05.14 G.Cosmo Initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4NavigationHistoryPool.hh"
|
||||
|
||||
// ***************************************************************************
|
||||
// Static class variables
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4ThreadLocal G4NavigationHistoryPool* G4NavigationHistoryPool::fgInstance = 0;
|
||||
|
||||
// ***************************************************************************
|
||||
// Private constructor: Construct underlying containers
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4NavigationHistoryPool::G4NavigationHistoryPool()
|
||||
{
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Destructor
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4NavigationHistoryPool::~G4NavigationHistoryPool()
|
||||
{
|
||||
Clean(); fgInstance = 0;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Delete all elements from the pool
|
||||
// ***************************************************************************
|
||||
//
|
||||
void G4NavigationHistoryPool::Clean()
|
||||
{
|
||||
for(size_t i=0; i<fPool.size(); ++i)
|
||||
{
|
||||
delete fPool[i];
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << "Total navigation history collections cleaned: "
|
||||
<< fPool.size() << G4endl;
|
||||
#endif
|
||||
fPool.clear();
|
||||
fActive.clear();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Delete all elements from the pool
|
||||
// ***************************************************************************
|
||||
//
|
||||
void G4NavigationHistoryPool::Reset()
|
||||
{
|
||||
for(size_t i=0; i<fPool.size(); ++i)
|
||||
{
|
||||
fPool[i] = 0; fActive[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Return the pointer of the first available collection of levels
|
||||
// If none are available (i.e. non active) allocate collection
|
||||
// ***************************************************************************
|
||||
//
|
||||
std::vector<G4NavigationLevel> * G4NavigationHistoryPool::GetLevels()
|
||||
{
|
||||
std::vector<G4bool>::iterator
|
||||
pos = std::find(fActive.begin(), fActive.end(), false);
|
||||
if (pos != fActive.end())
|
||||
{
|
||||
*pos = true;
|
||||
return fPool[pos-fActive.begin()];
|
||||
}
|
||||
return GetNewLevels();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Return ptr to Store, setting if necessary
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4NavigationHistoryPool* G4NavigationHistoryPool::GetInstance()
|
||||
{
|
||||
if (!fgInstance)
|
||||
{
|
||||
fgInstance = new G4NavigationHistoryPool;
|
||||
}
|
||||
return fgInstance;
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4NavigationLevel.cc 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
// $Id: G4NavigationLevel.cc 86527 2014-11-13 15:06:24Z gcosmo $
|
||||
//
|
||||
// 30.09.97 J.Apostolakis Initial version.
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4NavigationLevelRep.cc 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
// $Id: G4NavigationLevelRep.cc 85846 2014-11-05 15:45:28Z gcosmo $
|
||||
//
|
||||
// 1 October 1997 J.Apostolakis Initial version.
|
||||
//
|
||||
@@ -33,81 +33,3 @@
|
||||
#include "G4NavigationLevelRep.hh"
|
||||
|
||||
G4ThreadLocal G4Allocator<G4NavigationLevelRep> *aNavigLevelRepAllocator = 0;
|
||||
|
||||
// Constructors
|
||||
//--------------
|
||||
|
||||
G4NavigationLevelRep::G4NavigationLevelRep( G4VPhysicalVolume* pPhysVol,
|
||||
const G4AffineTransform& afTransform,
|
||||
EVolume volTp,
|
||||
G4int repNo )
|
||||
: sTransform(afTransform),
|
||||
sPhysicalVolumePtr(pPhysVol),
|
||||
sReplicaNo(repNo),
|
||||
sVolumeType(volTp),
|
||||
fCountRef(1)
|
||||
{
|
||||
}
|
||||
|
||||
G4NavigationLevelRep::G4NavigationLevelRep()
|
||||
: sTransform(),
|
||||
sPhysicalVolumePtr(0),
|
||||
sReplicaNo(-1),
|
||||
sVolumeType(kReplica),
|
||||
fCountRef(1)
|
||||
{
|
||||
}
|
||||
|
||||
G4NavigationLevelRep::G4NavigationLevelRep( G4VPhysicalVolume* pPhysVol,
|
||||
const G4AffineTransform& levelAbove,
|
||||
const G4AffineTransform& relativeCurrent,
|
||||
EVolume volTp,
|
||||
G4int repNo )
|
||||
: sPhysicalVolumePtr(pPhysVol),
|
||||
sReplicaNo(repNo),
|
||||
sVolumeType(volTp),
|
||||
fCountRef(1)
|
||||
{
|
||||
sTransform.InverseProduct( levelAbove, relativeCurrent );
|
||||
}
|
||||
|
||||
G4NavigationLevelRep::G4NavigationLevelRep( G4NavigationLevelRep& right )
|
||||
: sTransform(right.sTransform),
|
||||
sPhysicalVolumePtr(right.sPhysicalVolumePtr),
|
||||
sReplicaNo(right.sReplicaNo),
|
||||
sVolumeType(right.sVolumeType),
|
||||
fCountRef(1)
|
||||
{
|
||||
}
|
||||
|
||||
// Destructor
|
||||
//--------------
|
||||
|
||||
G4NavigationLevelRep::~G4NavigationLevelRep()
|
||||
{
|
||||
#ifdef DEBUG_NAVIG_LEVEL
|
||||
if(fCountRef>0)
|
||||
{
|
||||
G4Exception("G4NavigationLevelRep::~G4NavigationLevelRep()",
|
||||
"GeomVol0003", FatalException,
|
||||
"Deletion of data-level object with positive reference count.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Operators
|
||||
// --------------
|
||||
|
||||
G4NavigationLevelRep&
|
||||
G4NavigationLevelRep::operator=( const G4NavigationLevelRep &right )
|
||||
{
|
||||
if ( &right != this )
|
||||
{
|
||||
sTransform = right.sTransform;
|
||||
sPhysicalVolumePtr = right.sPhysicalVolumePtr;
|
||||
sVolumeType = right.sVolumeType;
|
||||
sReplicaNo = right.sReplicaNo;
|
||||
fCountRef = right.fCountRef;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PVPlacement.cc 74459 2013-10-07 15:24:43Z gcosmo $
|
||||
// $Id: G4PVPlacement.cc 85846 2014-11-05 15:45:28Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4PVPlacement Implementation
|
||||
@@ -169,14 +169,6 @@ G4bool G4PVPlacement::IsMany() const
|
||||
return fmany;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// GetCopyNo
|
||||
//
|
||||
G4int G4PVPlacement::GetCopyNo() const
|
||||
{
|
||||
return fcopyNo;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// SetCopyNo
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PVReplica.cc 73250 2013-08-22 13:22:23Z gcosmo $
|
||||
// $Id: G4PVReplica.cc 85846 2014-11-05 15:45:28Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4PVReplica Implementation
|
||||
@@ -40,7 +40,7 @@
|
||||
template <class G4ReplicaData> G4ThreadLocal
|
||||
G4ReplicaData* G4GeomSplitter<G4ReplicaData>::offset = 0;
|
||||
G4PVRManager G4PVReplica::subInstanceManager;
|
||||
// This new field helps to use the class G4PVRManager.
|
||||
// Helping in the use of the class G4PVRManager.
|
||||
|
||||
G4PVReplica::G4PVReplica( const G4String& pName,
|
||||
G4LogicalVolume* pLogical,
|
||||
@@ -49,7 +49,8 @@ G4PVReplica::G4PVReplica( const G4String& pName,
|
||||
const G4int nReplicas,
|
||||
const G4double width,
|
||||
const G4double offset )
|
||||
: G4VPhysicalVolume(0, G4ThreeVector(), pName, pLogical, pMother), fRegularVolsId(0)
|
||||
: G4VPhysicalVolume(0, G4ThreeVector(), pName, pLogical, pMother),
|
||||
fRegularVolsId(0)
|
||||
{
|
||||
|
||||
instanceID = subInstanceManager.CreateSubInstance();
|
||||
@@ -231,8 +232,6 @@ G4int G4PVReplica::GetMultiplicity() const
|
||||
return fnReplicas;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void G4PVReplica::GetReplicationData( EAxis& axis,
|
||||
G4int& nReplicas,
|
||||
G4double& width,
|
||||
@@ -261,23 +260,13 @@ void G4PVReplica::SetRegularStructureId( G4int Code )
|
||||
fRegularVolsId= Code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
// ********************************************************************
|
||||
// GetSubInstanceManager
|
||||
//
|
||||
// Returns the private data instance manager.
|
||||
// *******************************************************************
|
||||
//
|
||||
const G4PVRManager& G4PVReplica::GetSubInstanceManager()
|
||||
{
|
||||
return subInstanceManager;
|
||||
}
|
||||
|
||||
|
||||
// This method is similar to the constructor. It is used by each worker
|
||||
// thread to achieve the same effect as that of the master thread exept
|
||||
// to register the new created instance. This method is invoked explicitly.
|
||||
@@ -290,7 +279,39 @@ void G4PVReplica::InitialiseWorker(G4PVReplica *pMasterObject)
|
||||
G4VPhysicalVolume::InitialiseWorker( pMasterObject, 0, G4ThreeVector());
|
||||
subInstanceManager.SlaveCopySubInstanceArray();
|
||||
G4MT_copyNo = -1;
|
||||
CheckAndSetParameters (faxis, fnReplicas, fwidth, foffset);
|
||||
|
||||
// This call causes "self-assignment" of the input paramters
|
||||
// Issue reported by DRD since TerminateWorker below can be called
|
||||
// at the same time by another thread
|
||||
// What we need here is the splic-class component of this funciton
|
||||
// that is copied here
|
||||
// CheckAndSetParameters (faxis, fnReplicas, fwidth, foffset);
|
||||
|
||||
// Create rotation matrix for phi axis case & check axis is valid
|
||||
//
|
||||
G4RotationMatrix* pRMat=0;
|
||||
switch (faxis)
|
||||
{
|
||||
case kPhi:
|
||||
pRMat=new G4RotationMatrix();
|
||||
if (!pRMat)
|
||||
{
|
||||
G4Exception("G4PVReplica::InitialiseWorker(...)", "GeomVol0003",
|
||||
FatalException, "Rotation matrix allocation failed.");
|
||||
}
|
||||
SetRotation(pRMat);
|
||||
break;
|
||||
case kRho:
|
||||
case kXAxis:
|
||||
case kYAxis:
|
||||
case kZAxis:
|
||||
case kUndefined:
|
||||
break;
|
||||
default:
|
||||
G4Exception("G4PVReplica::InitialiseWorker(...)", "GeomVol0002",
|
||||
FatalException, "Unknown axis of replication.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// This method is similar to the destructor. It is used by each worker
|
||||
@@ -304,6 +325,3 @@ void G4PVReplica::TerminateWorker(G4PVReplica* /*pMasterObject*/)
|
||||
delete GetRotation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4TouchableHistory.cc 68773 2013-04-05 12:47:53Z gcosmo $
|
||||
// $Id: G4TouchableHistory.cc 86527 2014-11-13 15:06:24Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4TouchableHistory Implementation
|
||||
|
||||
Reference in New Issue
Block a user