Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
# $Id: CMakeLists.txt,v 1.1 2010-09-29 18:43:25 bmorgan Exp $
|
||||
# $Id: CMakeLists.txt 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# $Id: GNUmakefile,v 1.10 2010-12-15 17:05:05 gcosmo Exp $
|
||||
# $Id: GNUmakefile 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
# --------------------------------------------------------------------
|
||||
# GNUmakefile for geometry/volumes library. Gabriele Cosmo, 16/11/96.
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.173 2010-12-15 17:05:06 gcosmo Exp $
|
||||
$Id: History 77024 2013-11-20 16:08:38Z gcosmo $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -16,6 +16,113 @@ committal in the CVS repository !
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
November 19th, 2013 J.Apostolakis - geomvol-V09-06-20
|
||||
- Fix(es) for issues identified by Coverity:
|
||||
G4GeometryWorkspace: initialisation of data member.
|
||||
G4GeometryWorkspacePool: fixed implementation of singleton.
|
||||
|
||||
November 8th, 2013 J.Apostolakis - geomvol-V09-06-19
|
||||
- Cleanup: reduced verbosity of G4GeometryWorkspace by making
|
||||
it optional.
|
||||
Added Set/Get Verbose methods to toggle and view it.
|
||||
|
||||
November 7th, 2013 J.Apostolakis - geomvol-V09-06-18
|
||||
- Restored the ability to 'clone' Nested Parameterisations.
|
||||
This allows the use of Nested Parameterizations with MT.
|
||||
This precaution is not needed - 'good' user code will cope with
|
||||
the changing of target solid in each thread.
|
||||
Note: The restriction on parameterizations which use multiple types
|
||||
of solids remains.
|
||||
|
||||
November 1st, 2013 G.Cosmo - geomvol-V09-06-17
|
||||
- Restored use of G4EnhancedVecAllocator in G4NavigationHistory for
|
||||
sequential mode.
|
||||
|
||||
October 18th, 2013 J.Apostolakis - geomvol-V09-06-16
|
||||
- G4GeometryWorkspace: Add new method CloneReplicaSolid, to
|
||||
ensure that the solid for each Replica is separate object.
|
||||
|
||||
October 17th, 2013 J.Apostolakis, A.Dotti - geomvol-V09-06-15
|
||||
- Cleanup of the code removing unnecessary lines of codes and comments
|
||||
- G4GeometryWorkspacePool::CreateWorkspace
|
||||
Do not create a second object G4GeometryWorkspace'.
|
||||
- Fixed Singleton G4GeometryWorkspacePool - for thread safe creation
|
||||
of object.
|
||||
|
||||
G4GeometryWorkspacePool: CreateWorkspace will not create a second
|
||||
object G4GeometryWorkspace (in the same thread)
|
||||
Fixed Singleton G4GeometryWorkspacePool - for thread safe creation
|
||||
of object.
|
||||
|
||||
October 4th, 2013 J.Apostolakis - geomvol-V09-06-14
|
||||
- Retag due to issue with testing (needed to ensure use of geommng-V09-06-12)
|
||||
Co-works with geommng-V09-06-12 and geom-specific-V09-06-19.
|
||||
|
||||
October 4th, 2013 J.Apostolakis - geomvol-V09-06-13
|
||||
- Separated functionality for Solids (PCone/PHedra Sides) from
|
||||
G4GeometryWorkspace into separate class G4SolidsWorkspace in
|
||||
solids/specific. Needed to satisfy dependence issue.
|
||||
Co-works with geommng-V09-06-12 and geom-specific-V09-06-18.
|
||||
|
||||
October 3rd, 2013 J.Apostolakis - geomvol-V09-06-12
|
||||
- Added new classes G4GeometryWorkspace - to create and manage MT objects.
|
||||
and G4GeometryWorkspacePool which keeps Workspace objects.
|
||||
- Small improvements and description in G4GeometryWorkspace.
|
||||
|
||||
September 17th, 2013 G.Cosmo - geomvol-V09-06-10
|
||||
- Test: use G4EnhancedVecAllocator in G4NavigationHistory only in MT mode.
|
||||
|
||||
September 16th, 2013 I.Hrivnacova - geomvol-V09-06-09
|
||||
- Removed thread-local specification for G4LogicalBorderSurfaceTable and
|
||||
G4LogicalSkinSurfaceTable, as now supposed to be shared.
|
||||
|
||||
August 22nd, 2013 G.Cosmo - geomvol-V09-06-08
|
||||
- Added parameter to specify maximum number of overlap errors to report.
|
||||
Adapted code in CheckOverlaps() in G4PVPlacement and G4PVParameterised
|
||||
to take into account the threshold.
|
||||
|
||||
April 2nd, 2013 G.Cosmo - geomvol-V09-06-07
|
||||
- More optimisation to G4LogicalBorderSurface and G4LogicalSkinSurface
|
||||
in the use of static tables.
|
||||
|
||||
March 18th, 2013 G.Cosmo - geomvol-V09-06-06
|
||||
- More cleanup from MT changes in G4TouchableHistory.
|
||||
|
||||
March 12th, 2013 A.Dotti - geomvol-V09-06-05
|
||||
- Added missing implementation of member function GetSubInstanceManager()
|
||||
in G4PVReplica.
|
||||
|
||||
March 12th, 2013 G.Cosmo - geomvol-V09-06-04
|
||||
- Added public accessors for MT data to G4PVReplica.
|
||||
|
||||
March 11th, 2013 G.Cosmo - geomvol-V09-06-03
|
||||
- Fixed accessors adding check for existance of static surface table.
|
||||
|
||||
March 10th, 2013 G.Cosmo - geomvol-V09-06-02
|
||||
- Redefined G4DLL_API to G4GEOM_DLL to avoid cases of macro redefinition.
|
||||
|
||||
March 8th, 2013 G.Cosmo - geomvol-V09-06-01
|
||||
- Renamed G4MTTransitory to G4GeomSplitter. Adapted G4PVReplica.
|
||||
- More cleanup of MT changes in G4PVReplica split class and other classes:
|
||||
G4NavigationLevel, G4NavigationLevelRep, G4TouchableHistory,
|
||||
G4LogicalBorderSurface and G4LogicalSkinSurface.
|
||||
|
||||
February 12th, 2013 J.Apostolakis - geomvol-V09-06-00
|
||||
- G4TouchableHistory: inspected changes for Geant4-MT.
|
||||
Took out unneeded calls that initialised allocator in many methods.
|
||||
Only the call in new() is needed, and is kept.
|
||||
Cleared extra code introducing a performance penalty and also complicating
|
||||
the code without reason.
|
||||
Note: constructors cannot check that the Allocator is initialised.
|
||||
They could be called first to create an object which was created
|
||||
in a different way (e.g. on the stack, via new(prealloc) or new[ ] ).
|
||||
|
||||
January 13th, 2013 A.Dotti
|
||||
- Introduced changes for thread-safety from G4MT prototype.
|
||||
Classes with Allocator: all methods now initialising allocator pointer.
|
||||
Revised key classes, to separate the part of the state which is
|
||||
thread-dependent (changed in event loop), including:
|
||||
G4LogicalVolume, G4PhysicalVolume, G4PVReplica, G4PVPlacement.
|
||||
|
||||
November 6th, 2012 G.Cosmo - geomvol-V09-05-02
|
||||
- Fix in G4EnhancedVecAllocator for porting on AIX.
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4AssemblyTriplet.hh 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// Class G4AssemblyTriplet
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4AssemblyTriplet.icc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// Class G4AssemblyTriplet - inline implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4AssemblyVolume.hh 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
//
|
||||
// Class G4AssemblyVolume
|
||||
@@ -210,7 +210,7 @@ class G4AssemblyVolume
|
||||
//
|
||||
// Number of imprints of the given assembly volume.
|
||||
|
||||
static unsigned int fsInstanceCounter;
|
||||
static G4ThreadLocal unsigned int fsInstanceCounter;
|
||||
//
|
||||
// Class instance counter.
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4AssemblyVolume.icc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// Class G4AssemblyVolume - inline implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4EnhancedVecAllocator.hh 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
@@ -71,9 +71,9 @@ class G4AllocStats
|
||||
|
||||
public:
|
||||
|
||||
static G4ChunkIndexType * allocStat;
|
||||
static G4int totSpace;
|
||||
static G4int numCat;
|
||||
static G4ThreadLocal G4ChunkIndexType * allocStat;
|
||||
static G4ThreadLocal G4int totSpace;
|
||||
static G4ThreadLocal G4int numCat;
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4GRSSolid.hh 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4GRSSolid
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4GRSSolid.icc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4GRSSolid inline implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4GRSSolidHandle.hh 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
// Class G4GRSSolidHandle
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4GRSVolume.hh 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4GRSVolume
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4GRSVolume.icc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4GRSVolume inline implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4GRSVolumeHandle.hh 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
// Class G4GRSVolumeHandle
|
||||
//
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Description:
|
||||
// Manage the per-thread state of the geometry, spanning those
|
||||
// which have a per-thread state and their dependents.
|
||||
// In particular it
|
||||
// - owns the arrays that implement 'split' classes
|
||||
// - classes/objects which are owned by the split classes.
|
||||
// Background: the classes/objects affected are
|
||||
// - 'split' classes part of its state is per-thread,
|
||||
// - per-thread objects, in particular those which are owned
|
||||
// by the split classes.
|
||||
// Goal: Take ownership and control of per-thread state of
|
||||
// classes to work with multi-threading.
|
||||
//
|
||||
// Designed / created by John Apostolakis
|
||||
// Interface design - review with Andrea Dotti (July 2013)
|
||||
//
|
||||
// First version: 7th July 2013
|
||||
// Working version: 4th October 2013
|
||||
|
||||
#ifndef G4GEOMETRYWORKSPACE_HH
|
||||
#define G4GEOMETRYWORKSPACE_HH
|
||||
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4VSolid.hh"
|
||||
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4Region.hh"
|
||||
|
||||
class G4GeometryWorkspace
|
||||
{
|
||||
public:
|
||||
G4GeometryWorkspace();
|
||||
~G4GeometryWorkspace();
|
||||
|
||||
void UseWorkspace(); //Take ownership
|
||||
void ReleaseWorkspace(); //Release ownership
|
||||
void DestroyWorkspace(); //Release ownership and destroy
|
||||
|
||||
void InitialiseWorkspace();
|
||||
// To be called at start of each run (especially 2nd and further runs)
|
||||
|
||||
void SetVerbose(G4bool v) { fVerbose=v; }
|
||||
G4bool GetVerbose() { return fVerbose; }
|
||||
|
||||
protected: // Implementation methods
|
||||
void InitialisePhysicalVolumes();
|
||||
G4bool CloneParameterisedSolids( G4PVParameterised *paramVol );
|
||||
G4bool CloneReplicaSolid( G4PVReplica *);
|
||||
|
||||
private: // Helper pointers - can be per instance or shared
|
||||
G4LVManager *fpLogicalVolumeSIM;
|
||||
G4PVManager *fpPhysicalVolumeSIM;
|
||||
G4PVRManager *fpReplicaSIM;
|
||||
G4RegionManager *fpRegionSIM;
|
||||
|
||||
// Per Instance variables
|
||||
// NOTE: the ownership of the Data Arrays is IN this object
|
||||
private:
|
||||
// Store SubInstanceManager object pointers (SIM pointers)
|
||||
G4LVData *fLogicalVolumeOffset; // (G4LogicalVolume::GetSubInstanceManager())
|
||||
G4PVData *fPhysicalVolumeOffset;
|
||||
G4ReplicaData *fReplicaOffset;
|
||||
G4RegionData *fRegionOffset;
|
||||
|
||||
G4bool fVerbose;
|
||||
};
|
||||
|
||||
#endif //G4GEOMETRYWORKSPACE_HH
|
||||
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Create, recycle and Workspaces
|
||||
// Only one object of this type exists - it is a true Singleton (not per thread).
|
||||
|
||||
#ifndef G4GEOMETRYWORKSPACEPOOL_HH
|
||||
#define G4GEOMETRYWORKSPACEPOOL_HH
|
||||
|
||||
class G4GeometryWorkspace;
|
||||
// #include "G4GeometryWorkspace.hh"
|
||||
|
||||
//Note: Investigate potential to make it a template - on the workspace type
|
||||
|
||||
class G4GeometryWorkspacePool
|
||||
{
|
||||
public:
|
||||
static G4GeometryWorkspacePool* GetInstance();
|
||||
|
||||
// For use with simple MT mode - each thread gets a workspace and uses it until end
|
||||
G4GeometryWorkspace* CreateWorkspace();
|
||||
|
||||
void CreateAndUseWorkspace(); // Create it (as above) and use it
|
||||
|
||||
// For use with 'dynamic' model of threading - workspaces can be recycled
|
||||
G4GeometryWorkspace* FindOrCreateWorkspace();
|
||||
// Reuse an existing workspace - or create a new one if needed.
|
||||
// This will never fail, except if system is out of resources
|
||||
|
||||
inline G4GeometryWorkspace* GetWorkspace() { return fMyWorkspace; }
|
||||
// Give back the existing, active workspace for my thread / task
|
||||
|
||||
void Recycle( G4GeometryWorkspace * );
|
||||
// Keep the unused Workspace - for recycling
|
||||
|
||||
void CleanUpAndDestroyAllWorkspaces();
|
||||
// To be called once at the end of the job
|
||||
|
||||
protected:
|
||||
void ReleaseAndDestroyWorkspace(G4GeometryWorkspace*);
|
||||
// Destroy workspace - after releasing it
|
||||
|
||||
// void RegisterWarehouse( G4GeometryWarehouse *) ;
|
||||
// The (optional) warehouse keeps a list of free workspaces
|
||||
|
||||
private:
|
||||
G4GeometryWorkspacePool();
|
||||
~G4GeometryWorkspacePool();
|
||||
|
||||
private:
|
||||
static G4GeometryWorkspacePool* thePool;
|
||||
|
||||
//void* fWarehouse;
|
||||
// G4GeometryWarehouse* fWarehouse;
|
||||
// This is "void" to hide the actual container type for workspaces
|
||||
// Implementations: a simple STL contaier for MT or something better for tbb
|
||||
// Further development: template parameter with portable default
|
||||
|
||||
static G4ThreadLocal G4GeometryWorkspace* fMyWorkspace;
|
||||
// The thread's workspace - if assigned.
|
||||
// --> Can we do without this ? It is dirty!!
|
||||
};
|
||||
|
||||
#endif //G4GEOMETRYWORKSPACEPOOL_HH
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4LogicalBorderSurface.hh 73926 2013-09-17 07:59:06Z gcosmo $
|
||||
//
|
||||
// class G4LogicalBorderSurface
|
||||
//
|
||||
@@ -96,7 +96,7 @@ class G4LogicalBorderSurface : public G4LogicalSurface
|
||||
G4VPhysicalVolume* Volume1; // Physical Volume pointer on side 1
|
||||
G4VPhysicalVolume* Volume2; // Physical Volume pointer on side 2
|
||||
|
||||
static G4LogicalBorderSurfaceTable theBorderSurfaceTable;
|
||||
static G4LogicalBorderSurfaceTable *theBorderSurfaceTable;
|
||||
// The static Table of BorderSurfaces.
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4LogicalBorderSurface.icc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4LogicalBorderSurface inline implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4LogicalSkinSurface.hh 73926 2013-09-17 07:59:06Z gcosmo $
|
||||
//
|
||||
// class G4LogicalSkinSurface
|
||||
//
|
||||
@@ -88,7 +88,7 @@ class G4LogicalSkinSurface : public G4LogicalSurface
|
||||
G4LogicalVolume* LogVolume;
|
||||
// Logical Volume pointer on side 1.
|
||||
|
||||
static G4LogicalSkinSurfaceTable theSkinSurfaceTable;
|
||||
static G4LogicalSkinSurfaceTable *theSkinSurfaceTable;
|
||||
// The static Table of SkinSurfaces.
|
||||
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4LogicalSkinSurface.icc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4LogicalSkinSurface inline implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NavigationHistory.hh 75578 2013-11-04 12:03:33Z gcosmo $
|
||||
//
|
||||
// class G4NavigationHistory
|
||||
//
|
||||
@@ -43,15 +43,17 @@
|
||||
#define G4NAVIGATIONHISTORY_HH
|
||||
|
||||
#include <assert.h>
|
||||
#include "geomdefs.hh"
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include "geomdefs.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4NavigationLevel.hh"
|
||||
#include "G4EnhancedVecAllocator.hh"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#if (defined(G4MULTITHREADED) || !defined(WIN32))
|
||||
#include "G4EnhancedVecAllocator.hh"
|
||||
#endif
|
||||
|
||||
class G4NavigationHistory
|
||||
{
|
||||
@@ -140,13 +142,13 @@ class G4NavigationHistory
|
||||
|
||||
private:
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32)
|
||||
std::vector<G4NavigationLevel> fNavHistory;
|
||||
#else
|
||||
std::vector<G4NavigationLevel,
|
||||
G4EnhancedVecAllocator<G4NavigationLevel> > fNavHistory;
|
||||
// The geometrical tree; uses specialized allocator to optimize
|
||||
// memory handling and reduce possible fragmentation
|
||||
// The geometrical tree; uses specialized allocator to optimize memory
|
||||
// handling, reduce possible fragmentation and use of malloc in MT mode
|
||||
#endif
|
||||
|
||||
G4int fStackDepth;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NavigationHistory.icc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4NavigationHistory Inline implementation
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NavigationLevel.hh 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
//
|
||||
// class G4NavigationLevel
|
||||
//
|
||||
@@ -49,6 +49,8 @@
|
||||
#include "G4NavigationLevelRep.hh"
|
||||
#include "G4Allocator.hh"
|
||||
|
||||
#include "geomwdefs.hh"
|
||||
|
||||
class G4NavigationLevel
|
||||
{
|
||||
|
||||
|
||||
@@ -24,45 +24,42 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NavigationLevel.icc 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
//
|
||||
// 30.09.97 J.Apostolakis Initial version.
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if defined G4GEOM_ALLOC_EXPORT
|
||||
extern G4DLLEXPORT G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
|
||||
#else
|
||||
extern G4DLLIMPORT G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
|
||||
#endif
|
||||
extern G4GEOM_DLL G4ThreadLocal
|
||||
G4Allocator<G4NavigationLevel> *aNavigationLevelAllocator;
|
||||
|
||||
inline
|
||||
G4VPhysicalVolume* G4NavigationLevel::GetPhysicalVolume() const
|
||||
{
|
||||
{
|
||||
return fLevelRep->GetPhysicalVolume();
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform& G4NavigationLevel::GetTransform() const
|
||||
{
|
||||
{
|
||||
return fLevelRep->GetTransform() ;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform* G4NavigationLevel::GetPtrTransform() const
|
||||
{
|
||||
{
|
||||
return fLevelRep->GetTransformPtr() ;
|
||||
}
|
||||
|
||||
inline
|
||||
EVolume G4NavigationLevel::GetVolumeType() const
|
||||
{
|
||||
{
|
||||
return fLevelRep->GetVolumeType() ;
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4NavigationLevel::GetReplicaNo() const
|
||||
{
|
||||
{
|
||||
return fLevelRep->GetReplicaNo() ;
|
||||
}
|
||||
|
||||
@@ -72,7 +69,11 @@ G4int G4NavigationLevel::GetReplicaNo() const
|
||||
inline
|
||||
void* G4NavigationLevel::operator new(size_t)
|
||||
{
|
||||
return (void *) aNavigationLevelAllocator.MallocSingle();
|
||||
if (!aNavigationLevelAllocator)
|
||||
{
|
||||
aNavigationLevelAllocator = new G4Allocator<G4NavigationLevel>;
|
||||
}
|
||||
return (void *) aNavigationLevelAllocator->MallocSingle();
|
||||
}
|
||||
|
||||
// Added for use by STL (used for pre-allocation).
|
||||
@@ -86,7 +87,7 @@ void* G4NavigationLevel::operator new(size_t,void *a)
|
||||
inline
|
||||
void G4NavigationLevel::operator delete(void *aLevel)
|
||||
{
|
||||
aNavigationLevelAllocator.FreeSingle((G4NavigationLevel *) aLevel);
|
||||
aNavigationLevelAllocator->FreeSingle((G4NavigationLevel *) aLevel);
|
||||
}
|
||||
|
||||
// Added for use by STL (used for free-ing pre-allocated?).
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NavigationLevelRep.hh 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
//
|
||||
// class G4NavigationLevelRep
|
||||
//
|
||||
@@ -50,6 +50,8 @@
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Allocator.hh"
|
||||
|
||||
#include "geomwdefs.hh"
|
||||
|
||||
class G4NavigationLevelRep
|
||||
{
|
||||
|
||||
|
||||
@@ -24,17 +24,14 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4NavigationLevelRep.icc 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
//
|
||||
// 1 October 1997 J.Apostolakis Initial version.
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if defined G4GEOM_ALLOC_EXPORT
|
||||
extern G4DLLEXPORT G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
|
||||
#else
|
||||
extern G4DLLIMPORT G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
|
||||
#endif
|
||||
extern G4GEOM_DLL G4ThreadLocal
|
||||
G4Allocator<G4NavigationLevelRep> *aNavigLevelRepAllocator;
|
||||
|
||||
// Accessors
|
||||
// --------------
|
||||
@@ -42,33 +39,33 @@
|
||||
inline
|
||||
G4VPhysicalVolume*
|
||||
G4NavigationLevelRep::GetPhysicalVolume()
|
||||
{
|
||||
{
|
||||
return sPhysicalVolumePtr;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform&
|
||||
G4NavigationLevelRep::GetTransform() const
|
||||
{
|
||||
{
|
||||
return sTransform;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4AffineTransform*
|
||||
G4NavigationLevelRep::GetTransformPtr() const
|
||||
{
|
||||
{
|
||||
return &sTransform;
|
||||
}
|
||||
|
||||
inline
|
||||
EVolume G4NavigationLevelRep::GetVolumeType() const
|
||||
{
|
||||
{
|
||||
return sVolumeType;
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4NavigationLevelRep::GetReplicaNo() const
|
||||
{
|
||||
{
|
||||
return sReplicaNo;
|
||||
}
|
||||
|
||||
@@ -91,11 +88,15 @@ G4bool G4NavigationLevelRep::RemoveAReference()
|
||||
inline
|
||||
void* G4NavigationLevelRep::operator new(size_t)
|
||||
{
|
||||
return (void *) aNavigLevelRepAllocator.MallocSingle();
|
||||
if (!aNavigLevelRepAllocator)
|
||||
{
|
||||
aNavigLevelRepAllocator = new G4Allocator<G4NavigationLevelRep>;
|
||||
}
|
||||
return (void *) aNavigLevelRepAllocator->MallocSingle();
|
||||
}
|
||||
|
||||
inline
|
||||
void G4NavigationLevelRep::operator delete(void *aLevelRep)
|
||||
{
|
||||
aNavigLevelRepAllocator.FreeSingle((G4NavigationLevelRep *) aLevelRep);
|
||||
aNavigLevelRepAllocator->FreeSingle((G4NavigationLevelRep *) aLevelRep);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4PVParameterised.hh 73250 2013-08-22 13:22:23Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4PVParameterised
|
||||
@@ -97,12 +97,14 @@ class G4PVParameterised : public G4PVReplica
|
||||
virtual void SetRegularStructureId( G4int Code );
|
||||
// Method sets code and can prepare for special type of regular volumes.
|
||||
|
||||
G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true);
|
||||
G4bool CheckOverlaps(G4int res=1000, G4double tol=0.,
|
||||
G4bool verbose=true, G4int maxErr=1);
|
||||
// Verifies if each instance of the parameterised volume is overlapping
|
||||
// with other instances or with the mother volume. Provides default
|
||||
// resolution for the number of points to be generated and verified.
|
||||
// A tolerance for the precision of the overlap check can be specified,
|
||||
// by default it is set to maximum precision.
|
||||
// Reports a maximum of overlaps errors according to parameter in input.
|
||||
// Returns true if an overlap occurs.
|
||||
|
||||
private:
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4PVPlacement.hh 73250 2013-08-22 13:22:23Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4PVPlacement
|
||||
@@ -126,12 +126,14 @@ class G4PVPlacement : public G4VPhysicalVolume
|
||||
void SetCopyNo(G4int CopyNo);
|
||||
// Gets and sets the copy number of the volume.
|
||||
|
||||
G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true);
|
||||
G4bool CheckOverlaps(G4int res=1000, G4double tol=0.,
|
||||
G4bool verbose=true, G4int maxErr=1);
|
||||
// Verifies if the placed volume is overlapping with existing
|
||||
// daughters or with the mother volume. Provides default resolution
|
||||
// for the number of points to be generated and verified.
|
||||
// A tolerance for the precision of the overlap check can be specified,
|
||||
// by default it is set to maximum precision.
|
||||
// Reports a maximum of overlaps errors according to parameter in input.
|
||||
// Returns true if the volume is overlapping.
|
||||
|
||||
public: // without description
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4PVReplica.hh 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4PVReplica
|
||||
@@ -65,14 +65,56 @@
|
||||
// n=0..nReplicas-1
|
||||
|
||||
// History:
|
||||
// 29.07.95 P.Kent First non-stub version
|
||||
// 26.10.97 J.Apostolakis Added constructor that takes mother logical volume
|
||||
// 16.02.98 J.Apostolakis Added copy number
|
||||
// 29.07.95 P.Kent - First non-stub version
|
||||
// 26.10.97 J.Apostolakis - Added constructor that takes mother LV
|
||||
// 16.02.98 J.Apostolakis - Added copy number
|
||||
// 13.01.13 G.Cosmo, A.Dotti - Modified for thread-safety for MT
|
||||
// ----------------------------------------------------------------------
|
||||
#ifndef G4PVREPLICA_HH
|
||||
#define G4PVREPLICA_HH
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4GeomSplitter.hh"
|
||||
|
||||
class G4ReplicaData
|
||||
{
|
||||
// Encapsulates the fields of the class G4PVReplica that may not be
|
||||
// read-only. G4PVReplica inherits from the class G4VPhysicalVolume.
|
||||
// The fields from the ancestor that may not be read-only are handled
|
||||
// by the ancestor class.
|
||||
|
||||
public:
|
||||
|
||||
void initialize() {}
|
||||
|
||||
G4int fcopyNo;
|
||||
};
|
||||
|
||||
// The type G4PVRManager is introduced to encapsulate the methods used by
|
||||
// both the master thread and worker threads to allocate memory space for
|
||||
// the fields encapsulated by the class G4ReplicaData. When each thread
|
||||
// initializes the value for these fields, it refers to them using a macro
|
||||
// definition defined below. For every G4PVReplica instance, there is
|
||||
// a corresponding G4ReplicaData instance. All G4ReplicaData instances are
|
||||
// organized by the class G4PVRManager as an array.
|
||||
// The field "int instanceID" is added to the class G4PVReplica.
|
||||
// The value of this field in each G4LogicalVolume instance is the subscript
|
||||
// of the corresponding G4ReplicaData instance.
|
||||
// In order to use the class G4PVRManager, we add a static member in the
|
||||
// class G4LogicalVolume as follows: "static G4PVRManager subInstanceManager".
|
||||
// For the master thread, the array for G4ReplicaData instances grows
|
||||
// dynamically along with G4PVReplica instances arecreated.
|
||||
// For each worker thread, it copies the array of G4ReplicaData instances
|
||||
// from the master thread.
|
||||
// In addition, it invokes a method similiar to the constructor explicitly
|
||||
// to achieve the partial effect for each instance in the array.
|
||||
//
|
||||
typedef G4GeomSplitter<G4ReplicaData> G4PVRManager;
|
||||
|
||||
// This macro changes the references to fields that are now encapsulated
|
||||
// in the class G4ReplicaData.
|
||||
//
|
||||
#define G4MT_copyNo ((subInstanceManager.offset[instanceID]).fcopyNo)
|
||||
|
||||
class G4PVReplica : public G4VPhysicalVolume
|
||||
{
|
||||
@@ -129,13 +171,28 @@ class G4PVReplica : public G4VPhysicalVolume
|
||||
G4int GetRegularStructureId() const;
|
||||
// Accessors for specialised geometries
|
||||
|
||||
public: // without description
|
||||
|
||||
inline G4int GetInstanceID() const { return instanceID; }
|
||||
// Returns the instance ID.
|
||||
|
||||
static const G4PVRManager& GetSubInstanceManager();
|
||||
// Returns the private data instance manager.
|
||||
|
||||
void InitialiseWorker(G4PVReplica *pMasterObject);
|
||||
// This method is similar to the constructor. It is used by each worker
|
||||
// thread to achieve the partial effect as that of the master thread.
|
||||
|
||||
void TerminateWorker(G4PVReplica *pMasterObject);
|
||||
// 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.
|
||||
|
||||
protected:
|
||||
|
||||
EAxis faxis;
|
||||
G4int fnReplicas;
|
||||
G4double fwidth,foffset;
|
||||
G4int fcopyNo;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void CheckAndSetParameters(const EAxis pAxis, const G4int nReplicas,
|
||||
@@ -147,6 +204,11 @@ class G4PVReplica : public G4VPhysicalVolume
|
||||
|
||||
G4int fRegularStructureCode;
|
||||
G4int fRegularVolsId;
|
||||
|
||||
G4int instanceID;
|
||||
// This new field is used as instance ID.
|
||||
G4GEOM_DLL static G4PVRManager subInstanceManager;
|
||||
// This new field helps to use the class G4PVRManager introduced above.
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4ReflectionFactory.hh 66872 2013-01-15 01:25:57Z japost $
|
||||
//
|
||||
//
|
||||
// class G4ReflectionFactory
|
||||
@@ -240,7 +240,7 @@ class G4ReflectionFactory
|
||||
|
||||
private:
|
||||
|
||||
static G4ReflectionFactory* fInstance;
|
||||
static G4ThreadLocal G4ReflectionFactory* fInstance;
|
||||
static const G4String fDefaultNameExtension;
|
||||
static const G4Scale3D fScale;
|
||||
G4double fScalePrecision;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4TouchableHistory.hh 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4TouchableHistory
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4RotationMatrix.hh"
|
||||
|
||||
#include "geomwdefs.hh"
|
||||
|
||||
class G4TouchableHistory : public G4VTouchable
|
||||
{
|
||||
|
||||
|
||||
@@ -24,22 +24,18 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4TouchableHistory.icc 67974 2013-03-13 10:17:37Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4TouchableHistory inline implementation
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if defined G4GEOM_ALLOC_EXPORT
|
||||
extern G4DLLEXPORT G4Allocator<G4TouchableHistory> aTouchableHistoryAllocator;
|
||||
#else
|
||||
extern G4DLLIMPORT G4Allocator<G4TouchableHistory> aTouchableHistoryAllocator;
|
||||
#endif
|
||||
extern G4GEOM_DLL G4ThreadLocal G4Allocator<G4TouchableHistory> *aTouchableHistoryAllocator;
|
||||
|
||||
inline
|
||||
void G4TouchableHistory::UpdateYourself( G4VPhysicalVolume* pPhysVol,
|
||||
const G4NavigationHistory* pHistory )
|
||||
{
|
||||
{
|
||||
fhistory = *pHistory;
|
||||
G4AffineTransform tf(fhistory.GetTopTransform().Inverse());
|
||||
if( pPhysVol == 0 )
|
||||
@@ -56,38 +52,38 @@ void G4TouchableHistory::UpdateYourself( G4VPhysicalVolume* pPhysVol,
|
||||
|
||||
inline
|
||||
G4int G4TouchableHistory::CalculateHistoryIndex( G4int stackDepth ) const
|
||||
{
|
||||
{
|
||||
return (fhistory.GetDepth()-stackDepth); // was -1
|
||||
}
|
||||
|
||||
inline
|
||||
G4VPhysicalVolume* G4TouchableHistory::GetVolume( G4int depth ) const
|
||||
{
|
||||
{
|
||||
return fhistory.GetVolume(CalculateHistoryIndex(depth));
|
||||
}
|
||||
|
||||
inline
|
||||
G4VSolid* G4TouchableHistory::GetSolid( G4int depth ) const
|
||||
{
|
||||
{
|
||||
return fhistory.GetVolume(CalculateHistoryIndex(depth))
|
||||
->GetLogicalVolume()->GetSolid();
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4TouchableHistory::GetReplicaNumber( G4int depth ) const
|
||||
{
|
||||
{
|
||||
return fhistory.GetReplicaNo(CalculateHistoryIndex(depth));
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4TouchableHistory::GetHistoryDepth() const
|
||||
{
|
||||
{
|
||||
return fhistory.GetDepth();
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4TouchableHistory::MoveUpHistory( G4int num_levels )
|
||||
{
|
||||
{
|
||||
G4int maxLevelsMove = fhistory.GetDepth();
|
||||
G4int minLevelsMove = 0; // Cannot redescend today!
|
||||
// Soon it will be possible
|
||||
@@ -108,7 +104,7 @@ G4int G4TouchableHistory::MoveUpHistory( G4int num_levels )
|
||||
|
||||
inline
|
||||
const G4NavigationHistory* G4TouchableHistory::GetHistory() const
|
||||
{
|
||||
{
|
||||
return &fhistory;
|
||||
}
|
||||
|
||||
@@ -117,13 +113,20 @@ const G4NavigationHistory* G4TouchableHistory::GetHistory() const
|
||||
//
|
||||
inline
|
||||
void* G4TouchableHistory::operator new(size_t)
|
||||
{
|
||||
return (void *) aTouchableHistoryAllocator.MallocSingle();
|
||||
{
|
||||
// Once the Navigator calls InitializeAllocator,
|
||||
// the if block below can be removed.
|
||||
//
|
||||
if (!aTouchableHistoryAllocator)
|
||||
{
|
||||
aTouchableHistoryAllocator = new G4Allocator<G4TouchableHistory>;
|
||||
}
|
||||
return (void *) aTouchableHistoryAllocator->MallocSingle();
|
||||
}
|
||||
|
||||
inline
|
||||
void G4TouchableHistory::operator delete(void *aTH)
|
||||
{
|
||||
aTouchableHistoryAllocator.FreeSingle((G4TouchableHistory *) aTH);
|
||||
{
|
||||
aTouchableHistoryAllocator->FreeSingle((G4TouchableHistory *) aTH);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4TouchableHistoryHandle.hh 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
//
|
||||
// Class G4TouchableHistoryHandle
|
||||
//
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
# $Id: sources.cmake,v 1.1 2010-09-29 18:43:33 bmorgan Exp $
|
||||
# $Id: sources.cmake 74459 2013-10-07 15:24:43Z gcosmo $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@@ -38,6 +38,8 @@ GEANT4_DEFINE_MODULE(NAME G4volumes
|
||||
G4AssemblyVolume.hh
|
||||
G4AssemblyVolume.icc
|
||||
G4EnhancedVecAllocator.hh
|
||||
G4GeometryWorkspace.hh
|
||||
G4GeometryWorkspacePool.hh
|
||||
G4GRSSolid.hh
|
||||
G4GRSSolid.icc
|
||||
G4GRSSolidHandle.hh
|
||||
@@ -63,6 +65,8 @@ GEANT4_DEFINE_MODULE(NAME G4volumes
|
||||
G4TouchableHistoryHandle.hh
|
||||
SOURCES
|
||||
G4AssemblyVolume.cc
|
||||
G4GeometryWorkspace.cc
|
||||
G4GeometryWorkspacePool.cc
|
||||
G4GRSSolid.cc
|
||||
G4GRSVolume.cc
|
||||
G4LogicalBorderSurface.cc
|
||||
|
||||
@@ -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