Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4AssemblyVolume.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
//
|
||||
// Class G4AssemblyVolume - implementation
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
unsigned int G4AssemblyVolume::fsInstanceCounter = 0;
|
||||
G4ThreadLocal unsigned int G4AssemblyVolume::fsInstanceCounter = 0;
|
||||
|
||||
// Default constructor
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4GRSSolid.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4GRSSolid Implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4GRSVolume.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4GRSVolume Implementation
|
||||
|
||||
@@ -0,0 +1,318 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
#include "G4GeometryWorkspace.hh"
|
||||
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4VSolid.hh"
|
||||
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4Region.hh"
|
||||
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
|
||||
G4GeometryWorkspace::G4GeometryWorkspace()
|
||||
: fVerbose(false)
|
||||
{
|
||||
fpLogicalVolumeSIM=
|
||||
&const_cast<G4LVManager&>(G4LogicalVolume::GetSubInstanceManager());
|
||||
fpPhysicalVolumeSIM=
|
||||
&const_cast<G4PVManager&>( G4VPhysicalVolume::GetSubInstanceManager() );
|
||||
fpReplicaSIM=
|
||||
&const_cast<G4PVRManager&>(G4PVReplica::GetSubInstanceManager());
|
||||
fpRegionSIM=
|
||||
&const_cast<G4RegionManager&>(G4Region::GetSubInstanceManager());
|
||||
|
||||
// Create a work area for Logical Volumes in this thread - then capture its address
|
||||
InitialiseWorkspace();
|
||||
|
||||
fLogicalVolumeOffset= fpLogicalVolumeSIM->GetOffset();
|
||||
|
||||
fPhysicalVolumeOffset= fpPhysicalVolumeSIM->GetOffset();
|
||||
|
||||
fReplicaOffset= fpReplicaSIM->GetOffset();
|
||||
|
||||
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;
|
||||
|
||||
// Implementation copied from G4WorkerThread::BuildGeometryAndPhysicsVector()
|
||||
// and improved for G4PVParamaterised
|
||||
// John Apostolakis, May 30, 2013
|
||||
|
||||
//Geometry related, split classes mechanism: instantiate sub-instance for this thread
|
||||
fpLogicalVolumeSIM->UseWorkArea(fLogicalVolumeOffset);
|
||||
fpPhysicalVolumeSIM->UseWorkArea(fPhysicalVolumeOffset);
|
||||
|
||||
fpReplicaSIM->UseWorkArea(fReplicaOffset);
|
||||
fpRegionSIM->UseWorkArea(fRegionOffset);
|
||||
|
||||
// When recycling a workspace
|
||||
// - it must be a lightweight operation, to reuse a valid work area
|
||||
// - so it must NOT Initialise anything!
|
||||
// Do not call InitialisePhysicalVolumes();
|
||||
|
||||
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);
|
||||
|
||||
fpReplicaSIM->UseWorkArea(0);
|
||||
fpRegionSIM->UseWorkArea(0);
|
||||
}
|
||||
|
||||
namespace {
|
||||
G4Mutex solidclone= G4MUTEX_INITIALIZER;
|
||||
}
|
||||
void G4GeometryWorkspace::InitialisePhysicalVolumes()
|
||||
{
|
||||
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)
|
||||
{
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( fVerbose )
|
||||
G4cout << "G4GeometryWorkspace::InitialisePhysicalVolumes: "
|
||||
<< "Copying geometry - Done!" << G4endl;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
G4LogicalVolume *logicalV= replicaPV ->GetLogicalVolume();
|
||||
G4VSolid *solid= logicalV->GetSolid();
|
||||
|
||||
G4AutoLock aLock(&solidclone);
|
||||
G4VSolid *workerSolid = solid->Clone();
|
||||
aLock.unlock();
|
||||
|
||||
if( workerSolid )
|
||||
{
|
||||
logicalV->InitialiseWorker(logicalV,workerSolid,0);
|
||||
}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);
|
||||
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.
|
||||
|
||||
// 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++)
|
||||
{
|
||||
G4VSolid *solidChk= param->ComputeSolid(i, paramVol);
|
||||
if( solidChk != solid)
|
||||
{
|
||||
numDifferent++;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
// 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{
|
||||
// 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);
|
||||
}
|
||||
return true; // It Worked
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
G4GeometryWorkspace::InitialiseWorkspace()
|
||||
{
|
||||
if( fVerbose )
|
||||
G4cout << "G4GeometryWorkspace::InitialiseWorkspace: Copying geometry - Start " << G4endl;
|
||||
|
||||
// Implementation copied from G4WorkerThread::BuildGeometryAndPhysicsVector()
|
||||
// and improved for G4PVParamaterised
|
||||
// John Apostolakis, May 30, 2013
|
||||
|
||||
//Geometry related, split classes mechanism:
|
||||
// Do *NOT* instantiate sub-instance for this thread,
|
||||
// just copy the contents !!
|
||||
fpLogicalVolumeSIM->SlaveCopySubInstanceArray();
|
||||
fpPhysicalVolumeSIM->SlaveCopySubInstanceArray();
|
||||
fpReplicaSIM->SlaveCopySubInstanceArray();
|
||||
fpRegionSIM->SlaveInitializeSubInstance();
|
||||
|
||||
InitialisePhysicalVolumes();
|
||||
|
||||
if( fVerbose )
|
||||
G4cout << "G4GeometryWorkspace::InitialiseWorkspace: "
|
||||
<< "Copying geometry - Done!" << G4endl;
|
||||
}
|
||||
|
||||
void G4GeometryWorkspace::DestroyWorkspace()
|
||||
{
|
||||
G4PhysicalVolumeStore* physVolStore = G4PhysicalVolumeStore::GetInstance();
|
||||
for (size_t ip=0; ip<physVolStore->size(); ip++)
|
||||
{
|
||||
G4VPhysicalVolume* physVol = (*physVolStore)[ip];
|
||||
G4LogicalVolume *logicalVol = physVol->GetLogicalVolume();
|
||||
G4PVReplica *g4PVReplica = 0;
|
||||
g4PVReplica = dynamic_cast<G4PVReplica*>(physVol);
|
||||
if (g4PVReplica)
|
||||
{
|
||||
g4PVReplica->TerminateWorker(g4PVReplica);
|
||||
G4PVParameterised *paramVol = 0;
|
||||
paramVol = dynamic_cast<G4PVParameterised*>(physVol);
|
||||
if (paramVol)
|
||||
{
|
||||
// G4VSolid *solid = logicalVol->fSolid;
|
||||
logicalVol->TerminateWorker(logicalVol);
|
||||
// if( solid->IsClone() ) delete solid;
|
||||
}
|
||||
else
|
||||
{
|
||||
logicalVol->TerminateWorker(logicalVol);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logicalVol->TerminateWorker(logicalVol);
|
||||
}
|
||||
}
|
||||
|
||||
fpLogicalVolumeSIM->FreeSlave();
|
||||
fpPhysicalVolumeSIM->FreeSlave();
|
||||
fpReplicaSIM->FreeSlave();
|
||||
fpRegionSIM->FreeSlave();
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
#include "G4Types.hh"
|
||||
|
||||
#include "G4GeometryWorkspacePool.hh"
|
||||
#include "G4GeometryWorkspace.hh"
|
||||
|
||||
#include "G4AutoLock.hh"
|
||||
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;
|
||||
}
|
||||
|
||||
// For use with MT and current G4WorkerThread -- which uses static methods
|
||||
G4GeometryWorkspace* G4GeometryWorkspacePool::CreateWorkspace()
|
||||
{
|
||||
G4GeometryWorkspace* geometryWrk=0;
|
||||
if( !fMyWorkspace ){
|
||||
geometryWrk= new G4GeometryWorkspace();
|
||||
|
||||
if( !geometryWrk ) {
|
||||
G4Exception("GeometryWorspacePool::CreateWorkspace", "Geom-003",
|
||||
FatalException, "Failed to create workspace.");
|
||||
}else{
|
||||
fMyWorkspace= geometryWrk;
|
||||
}
|
||||
}else{
|
||||
G4Exception("GeometryWorspacePool::CreateWorkspace", "Geom-003",
|
||||
FatalException,
|
||||
"Cannot create workspace twice for the same thread.");
|
||||
geometryWrk= fMyWorkspace;
|
||||
}
|
||||
|
||||
return geometryWrk;
|
||||
}
|
||||
|
||||
|
||||
void G4GeometryWorkspacePool::CreateAndUseWorkspace() // Create it (as above) and use it
|
||||
{
|
||||
(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();
|
||||
|
||||
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;
|
||||
//}
|
||||
}
|
||||
|
||||
void G4GeometryWorkspacePool::CleanUpAndDestroyAllWorkspaces()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
G4GeometryWorkspacePool::G4GeometryWorkspacePool()
|
||||
{
|
||||
// fWarehouse=0;
|
||||
}
|
||||
|
||||
G4GeometryWorkspacePool::~G4GeometryWorkspacePool()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4LogicalBorderSurface.cc 73926 2013-09-17 07:59:06Z gcosmo $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// G4LogicalBorderSurface Implementation
|
||||
@@ -41,36 +41,47 @@
|
||||
#include "G4LogicalBorderSurface.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
G4LogicalBorderSurfaceTable G4LogicalBorderSurface::theBorderSurfaceTable;
|
||||
G4LogicalBorderSurfaceTable *G4LogicalBorderSurface::theBorderSurfaceTable = 0;
|
||||
|
||||
//
|
||||
// Constructor & destructor
|
||||
//
|
||||
|
||||
G4LogicalBorderSurface::G4LogicalBorderSurface(const G4String& name,
|
||||
G4VPhysicalVolume* vol1,
|
||||
G4VPhysicalVolume* vol2,
|
||||
G4SurfaceProperty* surfaceProperty)
|
||||
G4LogicalBorderSurface::
|
||||
G4LogicalBorderSurface(const G4String& name,
|
||||
G4VPhysicalVolume* vol1,
|
||||
G4VPhysicalVolume* vol2,
|
||||
G4SurfaceProperty* surfaceProperty)
|
||||
: G4LogicalSurface(name, surfaceProperty),
|
||||
Volume1(vol1), Volume2(vol2)
|
||||
{
|
||||
if (!theBorderSurfaceTable)
|
||||
{
|
||||
theBorderSurfaceTable = new G4LogicalBorderSurfaceTable;
|
||||
}
|
||||
|
||||
// Store in the table of Surfaces
|
||||
//
|
||||
theBorderSurfaceTable.push_back(this);
|
||||
theBorderSurfaceTable->push_back(this);
|
||||
}
|
||||
|
||||
G4LogicalBorderSurface::
|
||||
G4LogicalBorderSurface(const G4LogicalBorderSurface& right)
|
||||
: G4LogicalSurface(right.GetName(), right.GetSurfaceProperty())
|
||||
{
|
||||
if (!theBorderSurfaceTable)
|
||||
{
|
||||
theBorderSurfaceTable = new G4LogicalBorderSurfaceTable;
|
||||
}
|
||||
SetTransitionRadiationSurface(right.GetTransitionRadiationSurface());
|
||||
Volume1 = right.Volume1;
|
||||
Volume2 = right.Volume2;
|
||||
theBorderSurfaceTable = right.theBorderSurfaceTable;
|
||||
(*theBorderSurfaceTable) = (*right.theBorderSurfaceTable);
|
||||
}
|
||||
|
||||
G4LogicalBorderSurface::~G4LogicalBorderSurface()
|
||||
{
|
||||
// delete theBorderSurfaceTable; theBorderSurfaceTable=0;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -88,7 +99,7 @@ G4LogicalBorderSurface::operator=(const G4LogicalBorderSurface &right)
|
||||
SetTransitionRadiationSurface(right.GetTransitionRadiationSurface());
|
||||
Volume1 = right.Volume1;
|
||||
Volume2 = right.Volume2;
|
||||
theBorderSurfaceTable = right.theBorderSurfaceTable;
|
||||
(*theBorderSurfaceTable) = (*right.theBorderSurfaceTable);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -111,25 +122,36 @@ G4LogicalBorderSurface::operator!=(const G4LogicalBorderSurface &right) const
|
||||
|
||||
const G4LogicalBorderSurfaceTable* G4LogicalBorderSurface::GetSurfaceTable()
|
||||
{
|
||||
return &theBorderSurfaceTable;
|
||||
if (!theBorderSurfaceTable)
|
||||
{
|
||||
theBorderSurfaceTable = new G4LogicalBorderSurfaceTable;
|
||||
}
|
||||
return theBorderSurfaceTable;
|
||||
}
|
||||
|
||||
size_t G4LogicalBorderSurface::GetNumberOfBorderSurfaces()
|
||||
{
|
||||
return theBorderSurfaceTable.size();
|
||||
if (theBorderSurfaceTable)
|
||||
{
|
||||
return theBorderSurfaceTable->size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4LogicalBorderSurface*
|
||||
G4LogicalBorderSurface::GetSurface(const G4VPhysicalVolume* vol1,
|
||||
const G4VPhysicalVolume* vol2)
|
||||
{
|
||||
for (size_t i=0; i<theBorderSurfaceTable.size(); i++)
|
||||
if (theBorderSurfaceTable)
|
||||
{
|
||||
if( (theBorderSurfaceTable[i]->GetVolume1() == vol1) &&
|
||||
(theBorderSurfaceTable[i]->GetVolume2() == vol2) )
|
||||
return theBorderSurfaceTable[i];
|
||||
for (size_t i=0; i<theBorderSurfaceTable->size(); i++)
|
||||
{
|
||||
if( ((*theBorderSurfaceTable)[i]->GetVolume1() == vol1) &&
|
||||
((*theBorderSurfaceTable)[i]->GetVolume2() == vol2) )
|
||||
return (*theBorderSurfaceTable)[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Dump info for known surfaces
|
||||
@@ -139,25 +161,32 @@ void G4LogicalBorderSurface::DumpInfo()
|
||||
G4cout << "***** Surface Table : Nb of Surfaces = "
|
||||
<< GetNumberOfBorderSurfaces() << " *****" << G4endl;
|
||||
|
||||
for (size_t i=0; i<theBorderSurfaceTable.size(); i++)
|
||||
if (theBorderSurfaceTable)
|
||||
{
|
||||
G4LogicalBorderSurface* pBorderSurface = theBorderSurfaceTable[i];
|
||||
G4cout << pBorderSurface->GetName() << " : " << G4endl
|
||||
<< " Border of volumes "
|
||||
<< pBorderSurface->GetVolume1()->GetName() << " and "
|
||||
<< pBorderSurface->GetVolume2()->GetName()
|
||||
<< G4endl;
|
||||
for (size_t i=0; i<theBorderSurfaceTable->size(); i++)
|
||||
{
|
||||
G4LogicalBorderSurface* pBorderSurface = (*theBorderSurfaceTable)[i];
|
||||
G4cout << pBorderSurface->GetName() << " : " << G4endl
|
||||
<< " Border of volumes "
|
||||
<< pBorderSurface->GetVolume1()->GetName() << " and "
|
||||
<< pBorderSurface->GetVolume2()->GetName()
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
void G4LogicalBorderSurface::CleanSurfaceTable()
|
||||
{
|
||||
G4LogicalBorderSurfaceTable::iterator pos;
|
||||
for(pos=theBorderSurfaceTable.begin();
|
||||
pos!=theBorderSurfaceTable.end(); pos++)
|
||||
if (theBorderSurfaceTable)
|
||||
{
|
||||
if (*pos) delete *pos;
|
||||
G4LogicalBorderSurfaceTable::iterator pos;
|
||||
for(pos=theBorderSurfaceTable->begin();
|
||||
pos!=theBorderSurfaceTable->end(); pos++)
|
||||
{
|
||||
if (*pos) { delete *pos; }
|
||||
}
|
||||
theBorderSurfaceTable->clear();
|
||||
}
|
||||
theBorderSurfaceTable.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4LogicalSkinSurface.cc 73926 2013-09-17 07:59:06Z gcosmo $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// G4LogicalSkinSurface Implementation
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "G4LogicalSkinSurface.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
|
||||
G4LogicalSkinSurfaceTable G4LogicalSkinSurface::theSkinSurfaceTable;
|
||||
G4LogicalSkinSurfaceTable *G4LogicalSkinSurface::theSkinSurfaceTable = 0;
|
||||
|
||||
//
|
||||
// Constructors & destructor
|
||||
@@ -53,21 +53,30 @@ G4LogicalSkinSurface::G4LogicalSkinSurface(const G4String& name,
|
||||
: G4LogicalSurface(name, surfaceProperty),
|
||||
LogVolume(logicalVolume)
|
||||
{
|
||||
if (!theSkinSurfaceTable)
|
||||
{
|
||||
theSkinSurfaceTable = new G4LogicalSkinSurfaceTable;
|
||||
}
|
||||
// Store in the table of Surfaces
|
||||
//
|
||||
theSkinSurfaceTable.push_back(this);
|
||||
theSkinSurfaceTable->push_back(this);
|
||||
}
|
||||
|
||||
G4LogicalSkinSurface::G4LogicalSkinSurface(const G4LogicalSkinSurface& right)
|
||||
: G4LogicalSurface(right.GetName(), right.GetSurfaceProperty())
|
||||
{
|
||||
if (!theSkinSurfaceTable)
|
||||
{
|
||||
theSkinSurfaceTable = new G4LogicalSkinSurfaceTable;
|
||||
}
|
||||
SetTransitionRadiationSurface(right.GetTransitionRadiationSurface());
|
||||
LogVolume = right.LogVolume;
|
||||
theSkinSurfaceTable = right.theSkinSurfaceTable;
|
||||
(*theSkinSurfaceTable) = (*right.theSkinSurfaceTable);
|
||||
}
|
||||
|
||||
G4LogicalSkinSurface::~G4LogicalSkinSurface()
|
||||
{
|
||||
// delete theSkinSurfaceTable; theSkinSurfaceTable = 0;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -84,7 +93,7 @@ G4LogicalSkinSurface::operator=(const G4LogicalSkinSurface& right)
|
||||
SetName(right.GetName());
|
||||
SetTransitionRadiationSurface(right.GetTransitionRadiationSurface());
|
||||
LogVolume = right.LogVolume;
|
||||
theSkinSurfaceTable = right.theSkinSurfaceTable;
|
||||
(*theSkinSurfaceTable) = (*right.theSkinSurfaceTable);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -107,49 +116,68 @@ G4LogicalSkinSurface::operator!=(const G4LogicalSkinSurface& right) const
|
||||
|
||||
const G4LogicalSkinSurfaceTable* G4LogicalSkinSurface::GetSurfaceTable()
|
||||
{
|
||||
return &theSkinSurfaceTable;
|
||||
if (!theSkinSurfaceTable)
|
||||
{
|
||||
theSkinSurfaceTable = new G4LogicalSkinSurfaceTable;
|
||||
}
|
||||
return theSkinSurfaceTable;
|
||||
}
|
||||
|
||||
size_t G4LogicalSkinSurface::GetNumberOfSkinSurfaces()
|
||||
{
|
||||
return theSkinSurfaceTable.size();
|
||||
if (theSkinSurfaceTable)
|
||||
{
|
||||
return theSkinSurfaceTable->size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4LogicalSkinSurface*
|
||||
G4LogicalSkinSurface::GetSurface(const G4LogicalVolume* vol)
|
||||
{
|
||||
for (size_t i=0; i<theSkinSurfaceTable.size(); i++)
|
||||
if (theSkinSurfaceTable)
|
||||
{
|
||||
if(theSkinSurfaceTable[i]->GetLogicalVolume() == vol)
|
||||
return theSkinSurfaceTable[i];
|
||||
for (size_t i=0; i<theSkinSurfaceTable->size(); i++)
|
||||
{
|
||||
if((*theSkinSurfaceTable)[i]->GetLogicalVolume() == vol)
|
||||
return (*theSkinSurfaceTable)[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Dump info for known surfaces
|
||||
//
|
||||
void G4LogicalSkinSurface::DumpInfo()
|
||||
{
|
||||
G4cout << "***** Skin Surface Table : Nb of Surfaces = "
|
||||
<< GetNumberOfSkinSurfaces() << " *****" << G4endl;
|
||||
G4cout << "***** Skin Surface Table : Nb of Surfaces = "
|
||||
<< GetNumberOfSkinSurfaces() << " *****" << G4endl;
|
||||
|
||||
for (size_t i=0; i<theSkinSurfaceTable.size(); i++)
|
||||
if (theSkinSurfaceTable)
|
||||
{
|
||||
for (size_t i=0; i<theSkinSurfaceTable->size(); i++)
|
||||
{
|
||||
G4LogicalSkinSurface* pSkinSurface = theSkinSurfaceTable[i];
|
||||
G4LogicalSkinSurface* pSkinSurface = (*theSkinSurfaceTable)[i];
|
||||
G4cout << pSkinSurface->GetName() << " : " << G4endl
|
||||
<< " Skin of logical volume "
|
||||
<< pSkinSurface->GetLogicalVolume()->GetName()
|
||||
<< G4endl;
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
void G4LogicalSkinSurface::CleanSurfaceTable()
|
||||
{
|
||||
G4LogicalSkinSurfaceTable::iterator pos;
|
||||
for(pos=theSkinSurfaceTable.begin(); pos!=theSkinSurfaceTable.end(); pos++)
|
||||
{
|
||||
if (theSkinSurfaceTable)
|
||||
{
|
||||
if (*pos) delete *pos;
|
||||
G4LogicalSkinSurfaceTable::iterator pos;
|
||||
for(pos=theSkinSurfaceTable->begin();
|
||||
pos!=theSkinSurfaceTable->end(); pos++)
|
||||
{
|
||||
if (*pos) { delete *pos; }
|
||||
}
|
||||
theSkinSurfaceTable->clear();
|
||||
}
|
||||
theSkinSurfaceTable.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NavigationHistory.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
//
|
||||
// G4NavigationHistory Implementation
|
||||
@@ -40,9 +40,9 @@
|
||||
// Initialise static data for the specialized memory pool
|
||||
// for the internal STL vector of histories ...
|
||||
//
|
||||
G4ChunkIndexType* G4AllocStats::allocStat = 0;
|
||||
G4int G4AllocStats::totSpace = 0;
|
||||
G4int G4AllocStats::numCat = 0;
|
||||
G4ThreadLocal G4ChunkIndexType* G4AllocStats::allocStat = 0;
|
||||
G4ThreadLocal G4int G4AllocStats::totSpace = 0;
|
||||
G4ThreadLocal G4int G4AllocStats::numCat = 0;
|
||||
#endif
|
||||
|
||||
G4NavigationHistory::G4NavigationHistory()
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NavigationLevel.cc 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
//
|
||||
// 30.09.97 J.Apostolakis Initial version.
|
||||
//
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "G4NavigationLevel.hh"
|
||||
|
||||
G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
|
||||
G4ThreadLocal G4Allocator<G4NavigationLevel> *aNavigationLevelAllocator = 0;
|
||||
|
||||
G4NavigationLevel::G4NavigationLevel( G4VPhysicalVolume* pPhysVol,
|
||||
const G4AffineTransform& afTransform,
|
||||
@@ -72,7 +72,7 @@ G4NavigationLevel::~G4NavigationLevel()
|
||||
}
|
||||
|
||||
G4NavigationLevel& G4NavigationLevel::operator=(const G4NavigationLevel &right)
|
||||
{
|
||||
{
|
||||
if ( &right != this )
|
||||
{
|
||||
right.fLevelRep->AddAReference();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NavigationLevelRep.cc 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
//
|
||||
// 1 October 1997 J.Apostolakis Initial version.
|
||||
//
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "G4NavigationLevelRep.hh"
|
||||
|
||||
G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
|
||||
G4ThreadLocal G4Allocator<G4NavigationLevelRep> *aNavigLevelRepAllocator = 0;
|
||||
|
||||
// Constructors
|
||||
//--------------
|
||||
@@ -100,7 +100,7 @@ G4NavigationLevelRep::~G4NavigationLevelRep()
|
||||
|
||||
G4NavigationLevelRep&
|
||||
G4NavigationLevelRep::operator=( const G4NavigationLevelRep &right )
|
||||
{
|
||||
{
|
||||
if ( &right != this )
|
||||
{
|
||||
sTransform = right.sTransform;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4PVParameterised.cc 73250 2013-08-22 13:22:23Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4PVParameterised
|
||||
@@ -151,10 +151,13 @@ void G4PVParameterised::SetRegularStructureId( G4int Code )
|
||||
// CheckOverlaps
|
||||
//
|
||||
G4bool
|
||||
G4PVParameterised::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
G4PVParameterised::CheckOverlaps(G4int res, G4double tol,
|
||||
G4bool verbose, G4int maxErr)
|
||||
{
|
||||
if (res<=0) { return false; }
|
||||
|
||||
G4int trials = 0;
|
||||
G4bool retval = false;
|
||||
G4VSolid *solidA = 0, *solidB = 0;
|
||||
G4LogicalVolume *motherLog = GetMotherLogical();
|
||||
G4VSolid *motherSolid = motherLog->GetSolid();
|
||||
@@ -192,6 +195,7 @@ G4PVParameterised::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
G4double distin = motherSolid->DistanceToIn(mp);
|
||||
if (distin > tol)
|
||||
{
|
||||
trials++; retval = true;
|
||||
std::ostringstream message;
|
||||
message << "Overlap with mother volume !" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
@@ -201,9 +205,15 @@ G4PVParameterised::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
<< " at mother local point " << mp << ", "
|
||||
<< "overlapping by at least: "
|
||||
<< G4BestUnit(distin, "Length");
|
||||
if (trials>=maxErr)
|
||||
{
|
||||
message << G4endl
|
||||
<< "NOTE: Reached maximum fixed number -" << maxErr
|
||||
<< "- of overlaps reports for this volume !";
|
||||
}
|
||||
G4Exception("G4PVParameterised::CheckOverlaps()",
|
||||
"GeomVol1002", JustWarning, message);
|
||||
return true;
|
||||
if (trials>=maxErr) { return true; }
|
||||
}
|
||||
}
|
||||
points.push_back(mp);
|
||||
@@ -233,6 +243,7 @@ G4PVParameterised::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
G4double distout = solidB->DistanceToOut(md);
|
||||
if (distout > tol)
|
||||
{
|
||||
trials++; retval = true;
|
||||
std::ostringstream message;
|
||||
message << "Overlap within parameterised volumes !" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
@@ -243,9 +254,15 @@ G4PVParameterised::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
<< "overlapping by at least: "
|
||||
<< G4BestUnit(distout, "Length")
|
||||
<< ", related to volume instance: " << j << ".";
|
||||
if (trials>=maxErr)
|
||||
{
|
||||
message << G4endl
|
||||
<< "NOTE: Reached maximum fixed number -" << maxErr
|
||||
<< "- of overlaps reports for this volume !";
|
||||
}
|
||||
G4Exception("G4PVParameterised::CheckOverlaps()",
|
||||
"GeomVol1002", JustWarning, message);
|
||||
return true;
|
||||
if (trials>=maxErr) { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,5 +273,5 @@ G4PVParameterised::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
G4cout << "OK! " << G4endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4PVPlacement.cc 74459 2013-10-07 15:24:43Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4PVPlacement Implementation
|
||||
@@ -158,7 +158,7 @@ G4PVPlacement::G4PVPlacement( __void__& a )
|
||||
//
|
||||
G4PVPlacement::~G4PVPlacement()
|
||||
{
|
||||
if( fallocatedRotM ){ delete frot; }
|
||||
if( fallocatedRotM ){ delete this->GetRotation() ; }
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -241,7 +241,8 @@ G4int G4PVPlacement::GetRegularStructureId() const
|
||||
// ----------------------------------------------------------------------
|
||||
// CheckOverlaps
|
||||
//
|
||||
G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol,
|
||||
G4bool verbose, G4int maxErr)
|
||||
{
|
||||
if (res<=0) { return false; }
|
||||
|
||||
@@ -249,6 +250,9 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
G4LogicalVolume* motherLog = GetMotherLogical();
|
||||
if (!motherLog) { return false; }
|
||||
|
||||
G4int trials = 0;
|
||||
G4bool retval = false;
|
||||
|
||||
G4VSolid* motherSolid = motherLog->GetSolid();
|
||||
|
||||
if (verbose)
|
||||
@@ -277,6 +281,7 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
G4double distin = motherSolid->DistanceToIn(mp);
|
||||
if (distin > tol)
|
||||
{
|
||||
trials++; retval = true;
|
||||
std::ostringstream message;
|
||||
message << "Overlap with mother volume !" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
@@ -286,9 +291,15 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
<< " at mother local point " << mp << ", "
|
||||
<< "overlapping by at least: "
|
||||
<< G4BestUnit(distin, "Length");
|
||||
if (trials>=maxErr)
|
||||
{
|
||||
message << G4endl
|
||||
<< "NOTE: Reached maximum fixed number -" << maxErr
|
||||
<< "- of overlaps reports for this volume !";
|
||||
}
|
||||
G4Exception("G4PVPlacement::CheckOverlaps()",
|
||||
"GeomVol1002", JustWarning, message);
|
||||
return true;
|
||||
if (trials>=maxErr) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,6 +323,7 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
G4double distout = daughterSolid->DistanceToOut(md);
|
||||
if (distout > tol)
|
||||
{
|
||||
trials++; retval = true;
|
||||
std::ostringstream message;
|
||||
message << "Overlap with volume already placed !" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
@@ -321,9 +333,15 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
<< " local point " << md << ", "
|
||||
<< "overlapping by at least: "
|
||||
<< G4BestUnit(distout,"Length");
|
||||
if (trials>=maxErr)
|
||||
{
|
||||
message << G4endl
|
||||
<< "NOTE: Reached maximum fixed number -" << maxErr
|
||||
<< "- of overlaps reports for this volume !";
|
||||
}
|
||||
G4Exception("G4PVPlacement::CheckOverlaps()",
|
||||
"GeomVol1002", JustWarning, message);
|
||||
return true;
|
||||
if (trials>=maxErr) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,6 +363,7 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
|
||||
if (solid->Inside(msi)==kInside)
|
||||
{
|
||||
trials++; retval = true;
|
||||
std::ostringstream message;
|
||||
message << "Overlap with volume already placed !" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
@@ -354,7 +373,7 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
<< " at the same level !";
|
||||
G4Exception("G4PVPlacement::CheckOverlaps()",
|
||||
"GeomVol1002", JustWarning, message);
|
||||
return true;
|
||||
if (trials>=maxErr) { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,7 +384,7 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
G4cout << "OK! " << G4endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
return retval;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4PVReplica.cc 73250 2013-08-22 13:22:23Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4PVReplica Implementation
|
||||
@@ -34,6 +34,14 @@
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
|
||||
// This static member is thread local. For each thread, it points to the
|
||||
// array of G4ReplicaData instances.
|
||||
//
|
||||
template <class G4ReplicaData> G4ThreadLocal
|
||||
G4ReplicaData* G4GeomSplitter<G4ReplicaData>::offset = 0;
|
||||
G4PVRManager G4PVReplica::subInstanceManager;
|
||||
// This new field helps to use the class G4PVRManager.
|
||||
|
||||
G4PVReplica::G4PVReplica( const G4String& pName,
|
||||
G4LogicalVolume* pLogical,
|
||||
G4VPhysicalVolume* pMother,
|
||||
@@ -41,9 +49,13 @@ G4PVReplica::G4PVReplica( const G4String& pName,
|
||||
const G4int nReplicas,
|
||||
const G4double width,
|
||||
const G4double offset )
|
||||
: G4VPhysicalVolume(0, G4ThreeVector(), pName, pLogical, pMother),
|
||||
fcopyNo(-1), fRegularVolsId(0)
|
||||
: G4VPhysicalVolume(0, G4ThreeVector(), pName, pLogical, pMother), fRegularVolsId(0)
|
||||
{
|
||||
|
||||
instanceID = subInstanceManager.CreateSubInstance();
|
||||
|
||||
G4MT_copyNo = -1;
|
||||
|
||||
if ((!pMother) || (!pMother->GetLogicalVolume()))
|
||||
{
|
||||
std::ostringstream message;
|
||||
@@ -83,9 +95,12 @@ G4PVReplica::G4PVReplica( const G4String& pName,
|
||||
const G4int nReplicas,
|
||||
const G4double width,
|
||||
const G4double offset )
|
||||
: G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0),
|
||||
fcopyNo(-1), fRegularVolsId(0)
|
||||
: G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0), fRegularVolsId(0)
|
||||
{
|
||||
|
||||
instanceID = subInstanceManager.CreateSubInstance();
|
||||
G4MT_copyNo = -1;
|
||||
|
||||
if (!pMotherLogical)
|
||||
{
|
||||
std::ostringstream message;
|
||||
@@ -167,8 +182,10 @@ void G4PVReplica::CheckAndSetParameters( const EAxis pAxis,
|
||||
|
||||
G4PVReplica::G4PVReplica( __void__& a )
|
||||
: G4VPhysicalVolume(a), faxis(kZAxis), fnReplicas(0), fwidth(0.),
|
||||
foffset(0.), fcopyNo(-1), fRegularStructureCode(0), fRegularVolsId(0)
|
||||
foffset(0.), fRegularStructureCode(0), fRegularVolsId(0)
|
||||
{
|
||||
instanceID = subInstanceManager.CreateSubInstance();
|
||||
G4MT_copyNo = -1;
|
||||
}
|
||||
|
||||
G4PVReplica::~G4PVReplica()
|
||||
@@ -186,12 +203,12 @@ G4bool G4PVReplica::IsMany() const
|
||||
|
||||
G4int G4PVReplica::GetCopyNo() const
|
||||
{
|
||||
return fcopyNo;
|
||||
return G4MT_copyNo;
|
||||
}
|
||||
|
||||
void G4PVReplica::SetCopyNo(G4int newCopyNo)
|
||||
{
|
||||
fcopyNo = newCopyNo;
|
||||
G4MT_copyNo = newCopyNo;
|
||||
}
|
||||
|
||||
G4bool G4PVReplica::IsReplicated() const
|
||||
@@ -243,3 +260,50 @@ 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.
|
||||
// It does not create a new G4PVReplica instance. It only assigns the value
|
||||
// for the fields encapsulated by the class G4ReplicaData.
|
||||
//
|
||||
void G4PVReplica::InitialiseWorker(G4PVReplica *pMasterObject)
|
||||
{
|
||||
|
||||
G4VPhysicalVolume::InitialiseWorker( pMasterObject, 0, G4ThreeVector());
|
||||
subInstanceManager.SlaveCopySubInstanceArray();
|
||||
G4MT_copyNo = -1;
|
||||
CheckAndSetParameters (faxis, fnReplicas, fwidth, foffset);
|
||||
}
|
||||
|
||||
// This method is similar to the destructor. It is used by each worker
|
||||
// thread to achieve the partial effect as that of the master thread.
|
||||
// For G4PVReplica instances, it destories the rotation matrix.
|
||||
//
|
||||
void G4PVReplica::TerminateWorker(G4PVReplica* /*pMasterObject*/)
|
||||
{
|
||||
if ( faxis==kPhi )
|
||||
{
|
||||
delete GetRotation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4ReflectionFactory.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
//
|
||||
// Class G4ReflectionFactory Implementation
|
||||
@@ -62,7 +62,7 @@
|
||||
#include "G4VPVDivisionFactory.hh"
|
||||
#include "G4GeometryTolerance.hh"
|
||||
|
||||
G4ReflectionFactory* G4ReflectionFactory::fInstance = 0;
|
||||
G4ThreadLocal G4ReflectionFactory* G4ReflectionFactory::fInstance = 0;
|
||||
const G4String G4ReflectionFactory::fDefaultNameExtension = "_refl";
|
||||
const G4Scale3D G4ReflectionFactory::fScale = G4ScaleZ3D(-1.0);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4TouchableHistory.cc 68773 2013-04-05 12:47:53Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4TouchableHistory Implementation
|
||||
@@ -33,63 +33,65 @@
|
||||
|
||||
#include "G4TouchableHistory.hh"
|
||||
|
||||
G4Allocator<G4TouchableHistory> aTouchableHistoryAllocator;
|
||||
G4ThreadLocal G4Allocator<G4TouchableHistory> *aTouchableHistoryAllocator = 0;
|
||||
|
||||
G4TouchableHistory::G4TouchableHistory()
|
||||
: frot(G4RotationMatrix()),
|
||||
ftlate(G4ThreeVector(0.,0.,0.)),
|
||||
fhistory()
|
||||
{
|
||||
{
|
||||
G4VPhysicalVolume* pPhysVol=0;
|
||||
fhistory.SetFirstEntry(pPhysVol);
|
||||
}
|
||||
|
||||
G4TouchableHistory::G4TouchableHistory( const G4NavigationHistory &history )
|
||||
: fhistory(history)
|
||||
{
|
||||
{
|
||||
G4AffineTransform tf(fhistory.GetTopTransform().Inverse());
|
||||
ftlate = tf.NetTranslation();
|
||||
frot = tf.NetRotation();
|
||||
}
|
||||
|
||||
G4TouchableHistory::~G4TouchableHistory()
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
const G4ThreeVector&
|
||||
G4TouchableHistory::GetTranslation(G4int depth) const
|
||||
{
|
||||
{
|
||||
// The value returned will change at the next call
|
||||
// Copy it if you want to use it!
|
||||
//
|
||||
static G4ThreeVector currTranslation;
|
||||
static G4ThreadLocal G4ThreeVector* ctrans = 0;
|
||||
if ( !ctrans ) { ctrans = new G4ThreeVector; }
|
||||
if(depth==0.0)
|
||||
{
|
||||
return ftlate;
|
||||
}
|
||||
else
|
||||
{
|
||||
currTranslation =
|
||||
*ctrans =
|
||||
fhistory.GetTransform(CalculateHistoryIndex(depth)).NetTranslation();
|
||||
return currTranslation;
|
||||
return *ctrans;
|
||||
}
|
||||
}
|
||||
|
||||
const G4RotationMatrix*
|
||||
G4TouchableHistory::GetRotation(G4int depth) const
|
||||
{
|
||||
{
|
||||
// The value returned will change at the next call
|
||||
// Copy it if you want to use it!
|
||||
//
|
||||
static G4RotationMatrix rotM;
|
||||
static G4ThreadLocal G4RotationMatrix* rotM = 0;
|
||||
if (!rotM ) { rotM = new G4RotationMatrix(); }
|
||||
|
||||
if(depth==0.0)
|
||||
if(depth==0)
|
||||
{
|
||||
return &frot;
|
||||
}
|
||||
else
|
||||
{
|
||||
rotM = fhistory.GetTransform(CalculateHistoryIndex(depth)).NetRotation();
|
||||
return &rotM;
|
||||
*rotM = fhistory.GetTransform(CalculateHistoryIndex(depth)).NetRotation();
|
||||
return rotM;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user