Import Geant4 10.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 12:08:39 +02:00
parent 286caacf06
commit c9b32a6c0a
5770 changed files with 1050949 additions and 367105 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4EnhancedVecAllocator.hh 66872 2013-01-15 01:25:57Z japost $
// $Id: G4EnhancedVecAllocator.hh 80286 2014-04-10 09:48:48Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -117,24 +117,27 @@ template<typename _Tp>
void G4EnhancedVecAllocator<_Tp>::deallocate(_Tp* _Ptr, size_t _Count)
{
G4int found = -1;
for (register int j = 0 ; j < G4AllocStats::numCat ; j++)
if (G4AllocStats::allocStat != 0)
{
if ( (G4AllocStats::allocStat != 0)
&& (G4AllocStats::allocStat[j].size == (_Count * sizeof(_Tp))))
for (G4int j = 0 ; j < G4AllocStats::numCat ; j++)
{
found = j;
break;
if (G4AllocStats::allocStat[j].size == (_Count * sizeof(_Tp)))
{
found = j;
break;
}
}
}
// assert(found != -1);
for (register int k = 0; k < G4AllocStats::allocStat[found].totalspace; k++)
G4ChunkIndexType& chunk = G4AllocStats::allocStat[found];
for (G4int k = 0; k < chunk.totalspace; k++)
{
if ( ((G4AllocStats::allocStat[found]).preAllocated[k]).address
== ((char *) _Ptr))
if ( (chunk.preAllocated[k]).address == ((char *) _Ptr))
{
// assert(((G4AllocStats::allocStat[found]).preAllocated[k]).isAllocated==1);
((G4AllocStats::allocStat[found]).preAllocated[k]).isAllocated = 0;
// assert((chunk.preAllocated[k]).isAllocated==1);
(chunk.preAllocated[k]).isAllocated = 0;
return;
}
}
@@ -155,14 +158,16 @@ _Tp* G4EnhancedVecAllocator<_Tp>::allocate(size_t _Count)
size_t totalsize = _Count * sizeof(_Tp);
G4int found = -1;
for (register int j = 0 ; j < G4AllocStats::numCat ; j++)
if (G4AllocStats::allocStat != 0)
{
if ( (G4AllocStats::allocStat != 0)
&& (G4AllocStats::allocStat[j].size == totalsize) )
for (G4int j = 0 ; j < G4AllocStats::numCat ; j++)
{
found = j;
break;
}
if (G4AllocStats::allocStat[j].size == totalsize)
{
found = j;
break;
}
}
}
if (found == -1) // Find the new size
@@ -186,74 +191,69 @@ _Tp* G4EnhancedVecAllocator<_Tp>::allocate(size_t _Count)
G4AllocStats::allocStat[G4AllocStats::numCat-1].preAllocated = 0;
found = G4AllocStats::numCat - 1;
G4ChunkIndexType& chunk = G4AllocStats::allocStat[found];
G4AllocStats::allocStat[found].totalspace = 512;
chunk.totalspace = 512;
// heuristic for the number of STL vector instances
G4AllocStats::allocStat[found].preAllocated =
(G4ChunkType *) realloc(G4AllocStats::allocStat[found].preAllocated,
sizeof(G4ChunkType) * G4AllocStats::allocStat[found].totalspace);
chunk.preAllocated = (G4ChunkType *) realloc(chunk.preAllocated,
sizeof(G4ChunkType) * chunk.totalspace);
// This value must be different than zero; otherwise means
// failure in allocating extra space for pointers !
// assert(G4AllocStats::allocStat[found].preAllocated != 0);
// assert(chunk.preAllocated != 0);
char *newSpace1 = (char *) malloc(totalsize * 512);
// This pointer must be different than zero; otherwise means
// failure in allocating extra space for instances !
// assert(newSpace1 != 0);
for (register int k = 0; k < 512 ; k++)
for (G4int k = 0; k < 512 ; k++)
{
((G4AllocStats::allocStat[found]).preAllocated[k]).isAllocated = 0;
((G4AllocStats::allocStat[found]).preAllocated[k]).address =
newSpace1+totalsize*k;
(chunk.preAllocated[k]).isAllocated = 0;
(chunk.preAllocated[k]).address = newSpace1+totalsize*k;
}
((G4AllocStats::allocStat[found]).preAllocated[0]).isAllocated = 1;
return (_Tp*)(((G4AllocStats::allocStat[found]).preAllocated[0]).address);
(chunk.preAllocated[0]).isAllocated = 1;
return (_Tp*)((chunk.preAllocated[0]).address);
}
// assert(G4AllocStats::allocStat[found].size == totalsize);
G4ChunkIndexType& chunk = G4AllocStats::allocStat[found];
for (register int k = 0; k < G4AllocStats::allocStat[found].totalspace; k++)
// assert(chunk.size == totalsize);
for (G4int k = 0; k < chunk.totalspace; k++)
{
if (((G4AllocStats::allocStat[found]).preAllocated[k]).isAllocated == 0)
if ((chunk.preAllocated[k]).isAllocated == 0)
{
((G4AllocStats::allocStat[found]).preAllocated[k]).isAllocated = 1;
return (_Tp*)(((G4AllocStats::allocStat[found]).preAllocated[k]).address);
(chunk.preAllocated[k]).isAllocated = 1;
return (_Tp*)((chunk.preAllocated[k]).address);
}
}
G4int originalchunknumber = G4AllocStats::allocStat[found].totalspace;
G4int originalchunknumber = chunk.totalspace;
G4AllocStats::allocStat[found].totalspace = // heuristic for the number
G4AllocStats::allocStat[found].totalspace+512; // of STL vector instances
chunk.totalspace += 512; // heuristic for the number of STL vector instances
G4AllocStats::allocStat[found].preAllocated =
(G4ChunkType *) realloc(G4AllocStats::allocStat[found].preAllocated,
sizeof(G4ChunkType) * G4AllocStats::allocStat[found].totalspace);
chunk.preAllocated = (G4ChunkType *) realloc(chunk.preAllocated,
sizeof(G4ChunkType) * chunk.totalspace);
// This value must be different than zero; otherwise means
// failure in allocating extra space for pointers !
// assert(G4AllocStats::allocStat[found].preAllocated != 0);
// assert(chunk.preAllocated != 0);
char *newSpace = (char *) malloc(totalsize * 512);
// This pointer must be different than zero; otherwise means
// failure in allocating extra space for instances !
// assert(newSpace != 0);
for (register int k = 0; k < 512 ; k++)
for (G4int k = 0; k < 512 ; k++)
{
((G4AllocStats::allocStat[found]).
preAllocated[originalchunknumber + k]).isAllocated= 0;
((G4AllocStats::allocStat[found]).
preAllocated[originalchunknumber + k]).address= newSpace+totalsize*k;
(chunk.preAllocated[originalchunknumber+k]).isAllocated = 0;
(chunk.preAllocated[originalchunknumber+k]).address = newSpace+totalsize*k;
}
((G4AllocStats::allocStat[found]).preAllocated[originalchunknumber])
.isAllocated = 1;
(chunk.preAllocated[originalchunknumber]).isAllocated = 1;
return (_Tp*)(((G4AllocStats::allocStat[found]).
preAllocated[originalchunknumber]).address);
return (_Tp*)((chunk.preAllocated[originalchunknumber]).address);
}
// ************************************************************
@@ -23,24 +23,29 @@
// * 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
//
// $Id: G4GeometryWorkspace.hh 79096 2014-02-14 16:07:39Z gcosmo $
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// Class Description:
//
// Class managing 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
// - owns classes/objects which are owned by the split classes.
// 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
// classes to work with multi-threading.
// Authors: John Apostolakis (CERN), Andrea Dotti (SLAC), July 2013
// ------------------------------------------------------------
#ifndef G4GEOMETRYWORKSPACE_HH
#define G4GEOMETRYWORKSPACE_HH
@@ -56,41 +61,44 @@
class G4GeometryWorkspace
{
public:
G4GeometryWorkspace();
~G4GeometryWorkspace();
public:
G4GeometryWorkspace();
~G4GeometryWorkspace();
void UseWorkspace(); //Take ownership
void ReleaseWorkspace(); //Release ownership
void DestroyWorkspace(); //Release ownership and destroy
void UseWorkspace(); // Take ownership
void ReleaseWorkspace(); // Release ownership
void DestroyWorkspace(); // Release ownership and destroy
void InitialiseWorkspace();
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; }
inline void SetVerbose(G4bool v) { fVerbose=v; }
inline G4bool GetVerbose() { return fVerbose; }
protected: // Implementation methods
void InitialisePhysicalVolumes();
G4bool CloneParameterisedSolids( G4PVParameterised *paramVol );
G4bool CloneReplicaSolid( G4PVReplica *);
protected: // Implementation methods
void InitialisePhysicalVolumes();
G4bool CloneParameterisedSolids( G4PVParameterised *paramVol );
G4bool CloneReplicaSolid( G4PVReplica *);
private: // Helper pointers - can be per instance or shared
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;
// Per Instance variables
// NOTE: the ownership of the Data Arrays is IN this object
// Store SubInstanceManager object pointers (SIM pointers)
G4bool fVerbose;
G4LVData *fLogicalVolumeOffset; // (G4LVolume::GetSubInstanceManager())
G4PVData *fPhysicalVolumeOffset;
G4ReplicaData *fReplicaOffset;
G4RegionData *fRegionOffset;
G4bool fVerbose;
};
#endif //G4GEOMETRYWORKSPACE_HH
#endif
@@ -23,65 +23,84 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GeometryWorkspacePool.hh 79096 2014-02-14 16:07:39Z gcosmo $
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// Class Description:
//
// Create and recycle Workspaces
// Only one object of this type exists; true Singleton (not per thread).
// Create, recycle and Workspaces
// Only one object of this type exists - it is a true Singleton (not per thread).
// Author: John Apostolakis (CERN), December 2013
// ------------------------------------------------------------
#ifndef G4GEOMETRYWORKSPACEPOOL_HH
#define G4GEOMETRYWORKSPACEPOOL_HH
class G4GeometryWorkspace;
// #include "G4GeometryWorkspace.hh"
#include "G4Types.hh"
//Note: Investigate potential to make it a template - on the workspace type
class G4GeometryWorkspace;
// 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();
static G4GeometryWorkspacePool* GetInstance();
void CreateAndUseWorkspace(); // Create it (as above) and use it
G4GeometryWorkspace* CreateWorkspace();
// For use with simple MT mode
// Each thread gets a workspace and uses it until end
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.
G4GeometryWorkspace* FindOrCreateWorkspace();
// For use with 'dynamic' model of threading. Workspaces can be recycled.
// 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; }
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 Recycle( G4GeometryWorkspace * );
// Keep the unused Workspace for recycling
void CleanUpAndDestroyAllWorkspaces();
// To be called once at the end of the job
void CleanUpAndDestroyAllWorkspaces();
// To be called once at the end of the job
protected:
void ReleaseAndDestroyWorkspace(G4GeometryWorkspace*);
// Destroy workspace - after releasing it
protected:
// void RegisterWarehouse( G4GeometryWarehouse *) ;
void ReleaseAndDestroyWorkspace(G4GeometryWorkspace*);
// Destroy workspace after releasing it
// void RegisterWarehouse( G4GeometryWarehouse *);
// The (optional) warehouse keeps a list of free workspaces
private:
G4GeometryWorkspacePool();
~G4GeometryWorkspacePool();
private:
private:
static G4GeometryWorkspacePool* thePool;
G4GeometryWorkspacePool();
~G4GeometryWorkspacePool();
//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
private:
static G4ThreadLocal G4GeometryWorkspace* fMyWorkspace;
// The thread's workspace - if assigned.
// --> Can we do without this ? It is dirty!!
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
#endif
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4LogicalBorderSurface.hh 73926 2013-09-17 07:59:06Z gcosmo $
// $Id: G4LogicalBorderSurface.hh 80067 2014-03-31 13:48:09Z gcosmo $
//
// class G4LogicalBorderSurface
//
@@ -89,7 +89,7 @@ class G4LogicalBorderSurface : public G4LogicalSurface
private:
G4LogicalBorderSurface(const G4LogicalBorderSurface &right);
const G4LogicalBorderSurface& operator=(const G4LogicalBorderSurface &right);
G4LogicalBorderSurface& operator=(const G4LogicalBorderSurface &right);
private:
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4LogicalSkinSurface.hh 73926 2013-09-17 07:59:06Z gcosmo $
// $Id: G4LogicalSkinSurface.hh 80067 2014-03-31 13:48:09Z gcosmo $
//
// class G4LogicalSkinSurface
//
@@ -80,7 +80,7 @@ class G4LogicalSkinSurface : public G4LogicalSurface
private:
G4LogicalSkinSurface(const G4LogicalSkinSurface &right);
const G4LogicalSkinSurface& operator=(const G4LogicalSkinSurface &right);
G4LogicalSkinSurface& operator=(const G4LogicalSkinSurface &right);
// Assignment and copying must be denied.
private:
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4NavigationHistory.hh 75578 2013-11-04 12:03:33Z gcosmo $
// $Id: G4NavigationHistory.hh 86527 2014-11-13 15:06:24Z gcosmo $
//
// class G4NavigationHistory
//
@@ -47,13 +47,12 @@
#include <iostream>
#include "geomdefs.hh"
#include "geomwdefs.hh"
#include "G4AffineTransform.hh"
#include "G4VPhysicalVolume.hh"
#include "G4NavigationLevel.hh"
#if (defined(G4MULTITHREADED) || !defined(WIN32))
#include "G4EnhancedVecAllocator.hh"
#endif
#include "G4NavigationHistoryPool.hh"
#include "G4Allocator.hh"
class G4NavigationHistory
{
@@ -72,7 +71,7 @@ class G4NavigationHistory
G4NavigationHistory(const G4NavigationHistory &h);
// Copy constructor.
G4NavigationHistory& operator=(const G4NavigationHistory &h);
inline G4NavigationHistory& operator=(const G4NavigationHistory &h);
// Assignment operator.
inline void Reset();
@@ -133,6 +132,11 @@ class G4NavigationHistory
inline void BackLevel(G4int n);
// Back up specified number of levels in history.
inline void *operator new(size_t);
// Override "new" for "G4Allocator".
inline void operator delete(void *aHistory);
// Override "delete" for "G4Allocator".
private:
inline void EnlargeHistory();
@@ -142,18 +146,11 @@ class G4NavigationHistory
private:
#if defined(WIN32)
std::vector<G4NavigationLevel> fNavHistory;
#else
std::vector<G4NavigationLevel,
G4EnhancedVecAllocator<G4NavigationLevel> > fNavHistory;
// The geometrical tree; uses specialized allocator to optimize memory
// handling, reduce possible fragmentation and use of malloc in MT mode
#endif
std::vector<G4NavigationLevel> *fNavHistory;
// Pointer to the vector of navigation levels.
G4int fStackDepth;
// Depth of stack: effectively depth in geometrical tree
// Depth of stack: effectively depth in geometrical tree.
};
#include "G4NavigationHistory.icc"
@@ -24,29 +24,53 @@
// ********************************************************************
//
//
// $Id: G4NavigationHistory.icc 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4NavigationHistory.icc 86527 2014-11-13 15:06:24Z gcosmo $
//
//
// class G4NavigationHistory Inline implementation
//
// ----------------------------------------------------------------------
extern G4GEOM_DLL G4ThreadLocal
G4Allocator<G4NavigationHistory> *aNavigHistoryAllocator;
// There is no provision that this class is subclassed.
// If it is subclassed & new data members are added then the
// following "new" & "delete" will fail and give errors.
//
inline
void* G4NavigationHistory::operator new(size_t)
{
if (!aNavigHistoryAllocator)
{
aNavigHistoryAllocator = new G4Allocator<G4NavigationHistory>;
}
return (void *) aNavigHistoryAllocator->MallocSingle();
}
inline
void G4NavigationHistory::operator delete(void *aHistory)
{
aNavigHistoryAllocator->FreeSingle((G4NavigationHistory *) aHistory);
}
inline
G4NavigationHistory&
G4NavigationHistory::operator=(const G4NavigationHistory &h)
{
if (&h == this) { return *this; }
// fNavHistory=h.fNavHistory; // This works, but is very slow.
// *fNavHistory=*(h.fNavHistory); // This works, but is very slow.
if( this->GetMaxDepth() < h.fStackDepth )
if( GetMaxDepth() != h.GetMaxDepth() )
{
fNavHistory.resize( h.fStackDepth );
fNavHistory->resize( h.GetMaxDepth() );
}
for ( register G4int ilev=h.fStackDepth; ilev>=0; ilev-- )
for ( G4int ilev=h.fStackDepth; ilev>=0; --ilev )
{
fNavHistory[ilev] = h.fNavHistory[ilev];
}
(*fNavHistory)[ilev] = (*h.fNavHistory)[ilev];
}
fStackDepth=h.fStackDepth;
return *this;
@@ -65,9 +89,9 @@ void G4NavigationHistory::Clear()
G4NavigationLevel tmpNavLevel = G4NavigationLevel(0, origin, kNormal, -1) ;
Reset();
for (register G4int ilev=fNavHistory.size()-1; ilev>=0; ilev--)
for (G4int ilev=fNavHistory->size()-1; ilev>=0; ilev--)
{
fNavHistory[ilev] = tmpNavLevel;
(*fNavHistory)[ilev] = tmpNavLevel;
}
}
@@ -85,38 +109,38 @@ void G4NavigationHistory::SetFirstEntry(G4VPhysicalVolume* pVol)
translation = pVol->GetTranslation();
copyNo = pVol->GetCopyNo();
}
fNavHistory[0] =
(*fNavHistory)[0] =
G4NavigationLevel( pVol, G4AffineTransform(translation), kNormal, copyNo );
}
inline
const G4AffineTransform* G4NavigationHistory::GetPtrTopTransform() const
{
return fNavHistory[fStackDepth].GetPtrTransform();
return (*fNavHistory)[fStackDepth].GetPtrTransform();
}
inline
const G4AffineTransform& G4NavigationHistory::GetTopTransform() const
{
return fNavHistory[fStackDepth].GetTransform();
return (*fNavHistory)[fStackDepth].GetTransform();
}
inline
G4int G4NavigationHistory::GetTopReplicaNo() const
{
return fNavHistory[fStackDepth].GetReplicaNo();
return (*fNavHistory)[fStackDepth].GetReplicaNo();
}
inline
EVolume G4NavigationHistory::GetTopVolumeType() const
{
return fNavHistory[fStackDepth].GetVolumeType();
return (*fNavHistory)[fStackDepth].GetVolumeType();
}
inline
G4VPhysicalVolume* G4NavigationHistory::GetTopVolume() const
{
return fNavHistory[fStackDepth].GetPhysicalVolume();
return (*fNavHistory)[fStackDepth].GetPhysicalVolume();
}
inline
@@ -129,31 +153,31 @@ inline
const G4AffineTransform&
G4NavigationHistory::GetTransform(G4int n) const
{
return fNavHistory[n].GetTransform();
return (*fNavHistory)[n].GetTransform();
}
inline
G4int G4NavigationHistory::GetReplicaNo(G4int n) const
{
return fNavHistory[n].GetReplicaNo();
return (*fNavHistory)[n].GetReplicaNo();
}
inline
EVolume G4NavigationHistory::GetVolumeType(G4int n) const
{
return fNavHistory[n].GetVolumeType();
return (*fNavHistory)[n].GetVolumeType();
}
inline
G4VPhysicalVolume* G4NavigationHistory::GetVolume(G4int n) const
{
return fNavHistory[n].GetPhysicalVolume();
return (*fNavHistory)[n].GetPhysicalVolume();
}
inline
G4int G4NavigationHistory::GetMaxDepth() const
{
return fNavHistory.size();
return fNavHistory->size();
}
inline
@@ -162,7 +186,7 @@ void G4NavigationHistory::BackLevel()
assert( fStackDepth>0 );
// Tell the level that I am forgetting it
// delete fNavHistory(fStackDepth);
// delete (*fNavHistory)[fStackDepth];
//
fStackDepth--;
}
@@ -177,13 +201,13 @@ void G4NavigationHistory::BackLevel(G4int n)
inline
void G4NavigationHistory::EnlargeHistory()
{
G4int len = fNavHistory.size();
G4int len = fNavHistory->size();
if ( len==fStackDepth )
{
// Note: Resize operation clears additional entries
//
G4int nlen = len+kHistoryStride;
fNavHistory.resize(nlen);
fNavHistory->resize(nlen);
}
}
@@ -195,9 +219,9 @@ void G4NavigationHistory::NewLevel( G4VPhysicalVolume *pNewMother,
{
fStackDepth++;
EnlargeHistory(); // Enlarge if required
fNavHistory[fStackDepth] =
(*fNavHistory)[fStackDepth] =
G4NavigationLevel( pNewMother,
fNavHistory[fStackDepth-1].GetTransform(),
(*fNavHistory)[fStackDepth-1].GetTransform(),
G4AffineTransform(pNewMother->GetRotation(),
pNewMother->GetTranslation()),
vType,
@@ -0,0 +1,125 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
// class G4NavigationHistoryPool
//
// Class description:
//
// Thread-local pool for navigation history levels collections being
// allocated by G4NavigationHistory. Allows for reuse of the vectors
// allocated according to lifetime of G4NavigationHistory objects.
// History:
// 07.05.14 G.Cosmo Initial version
// --------------------------------------------------------------------
#ifndef G4NAVIGATIONHISTORYPOOL_HH
#define G4NAVIGATIONHISTORYPOOL_HH
#include <vector>
#include "G4NavigationLevel.hh"
class G4NavigationHistoryPool
{
public: // with description
static G4NavigationHistoryPool* GetInstance();
// Return unique instance of G4NavigationHistoryPool.
inline std::vector<G4NavigationLevel> * GetNewLevels();
// Return the pointer to a new collection of levels being allocated.
std::vector<G4NavigationLevel> * GetLevels();
// Return the pointer of the first available collection of levels
// If none are available (i.e. non active) allocate collection.
inline void DeRegister(std::vector<G4NavigationLevel> * pLevels);
// Deactivate levels collection in pool.
void Clean();
// Delete all levels stored in the pool.
~G4NavigationHistoryPool();
// Destructor: takes care to delete allocated levels.
private:
G4NavigationHistoryPool();
// Default constructor.
inline void Register(std::vector<G4NavigationLevel> * pLevels);
// Register levels collection to pool and activate it.
void Reset();
// Set internal vectors content to zero.
private:
static G4ThreadLocal G4NavigationHistoryPool* fgInstance;
std::vector<std::vector<G4NavigationLevel> *> fPool;
std::vector<G4bool> fActive;
};
// ***************************************************************************
// Register levels collection to pool (add and/or activate)
// ***************************************************************************
//
inline void G4NavigationHistoryPool::
Register(std::vector<G4NavigationLevel> * pLevels)
{
fPool.push_back(pLevels);
fActive.push_back(true);
}
// ***************************************************************************
// Deactivate levels collection in pool
// ***************************************************************************
//
inline void G4NavigationHistoryPool::
DeRegister(std::vector<G4NavigationLevel> * pLevels)
{
std::vector<std::vector<G4NavigationLevel> *>::iterator
pos = std::find(fPool.begin(), fPool.end(), pLevels);
fActive[pos-fPool.begin()]=false;
}
// ***************************************************************************
// Return the pointer of a new collection of levels allocated
// ***************************************************************************
//
inline std::vector<G4NavigationLevel> * G4NavigationHistoryPool::GetNewLevels()
{
std::vector<G4NavigationLevel> * aLevelVec =
new std::vector<G4NavigationLevel>(kHistoryMax);
Register(aLevelVec);
return aLevelVec;
}
#endif
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4NavigationLevel.hh 67974 2013-03-13 10:17:37Z gcosmo $
// $Id: G4NavigationLevel.hh 86527 2014-11-13 15:06:24Z gcosmo $
//
// class G4NavigationLevel
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4NavigationLevel.icc 67974 2013-03-13 10:17:37Z gcosmo $
// $Id: G4NavigationLevel.icc 86527 2014-11-13 15:06:24Z gcosmo $
//
// 30.09.97 J.Apostolakis Initial version.
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4NavigationLevelRep.hh 67974 2013-03-13 10:17:37Z gcosmo $
// $Id: G4NavigationLevelRep.hh 85846 2014-11-05 15:45:28Z gcosmo $
//
// class G4NavigationLevelRep
//
@@ -57,26 +57,26 @@ class G4NavigationLevelRep
public: // with description
G4NavigationLevelRep( G4VPhysicalVolume* newPtrPhysVol,
const G4AffineTransform& newT,
EVolume newVolTp,
G4int newRepNo= -1 );
inline G4NavigationLevelRep( G4VPhysicalVolume* newPtrPhysVol,
const G4AffineTransform& newT,
EVolume newVolTp,
G4int newRepNo= -1 );
G4NavigationLevelRep( G4VPhysicalVolume* newPtrPhysVol,
const G4AffineTransform& levelAbove,
const G4AffineTransform& relativeCurrent,
EVolume newVolTp,
G4int newRepNo= -1 );
inline G4NavigationLevelRep( G4VPhysicalVolume* newPtrPhysVol,
const G4AffineTransform& levelAbove,
const G4AffineTransform& relativeCurrent,
EVolume newVolTp,
G4int newRepNo= -1 );
// As the previous constructor, but instead of giving Transform, give
// the AffineTransform to the level above and the current level's
// Transform relative to that.
G4NavigationLevelRep();
G4NavigationLevelRep( G4NavigationLevelRep& );
inline G4NavigationLevelRep();
inline G4NavigationLevelRep( G4NavigationLevelRep& );
~G4NavigationLevelRep();
inline ~G4NavigationLevelRep();
G4NavigationLevelRep& operator=(const G4NavigationLevelRep &right);
inline G4NavigationLevelRep& operator=(const G4NavigationLevelRep &right);
inline G4VPhysicalVolume* GetPhysicalVolume();
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4NavigationLevelRep.icc 67974 2013-03-13 10:17:37Z gcosmo $
// $Id: G4NavigationLevelRep.icc 85846 2014-11-05 15:45:28Z gcosmo $
//
// 1 October 1997 J.Apostolakis Initial version.
//
@@ -33,6 +33,90 @@
extern G4GEOM_DLL G4ThreadLocal
G4Allocator<G4NavigationLevelRep> *aNavigLevelRepAllocator;
// Constructors
//--------------
inline
G4NavigationLevelRep::G4NavigationLevelRep( G4VPhysicalVolume* pPhysVol,
const G4AffineTransform& afTransform,
EVolume volTp,
G4int repNo )
: sTransform(afTransform),
sPhysicalVolumePtr(pPhysVol),
sReplicaNo(repNo),
sVolumeType(volTp),
fCountRef(1)
{
}
inline
G4NavigationLevelRep::G4NavigationLevelRep()
: sTransform(),
sPhysicalVolumePtr(0),
sReplicaNo(-1),
sVolumeType(kReplica),
fCountRef(1)
{
}
inline
G4NavigationLevelRep::G4NavigationLevelRep( G4VPhysicalVolume* pPhysVol,
const G4AffineTransform& levelAbove,
const G4AffineTransform& relativeCurrent,
EVolume volTp,
G4int repNo )
: sPhysicalVolumePtr(pPhysVol),
sReplicaNo(repNo),
sVolumeType(volTp),
fCountRef(1)
{
sTransform.InverseProduct( levelAbove, relativeCurrent );
}
inline
G4NavigationLevelRep::G4NavigationLevelRep( G4NavigationLevelRep& right )
: sTransform(right.sTransform),
sPhysicalVolumePtr(right.sPhysicalVolumePtr),
sReplicaNo(right.sReplicaNo),
sVolumeType(right.sVolumeType),
fCountRef(1)
{
}
// Destructor
//--------------
inline
G4NavigationLevelRep::~G4NavigationLevelRep()
{
#ifdef DEBUG_NAVIG_LEVEL
if(fCountRef>0)
{
G4Exception("G4NavigationLevelRep::~G4NavigationLevelRep()",
"GeomVol0003", FatalException,
"Deletion of data-level object with positive reference count.");
}
#endif
}
// Operators
// --------------
inline
G4NavigationLevelRep&
G4NavigationLevelRep::operator=( const G4NavigationLevelRep &right )
{
if ( &right != this )
{
sTransform = right.sTransform;
sPhysicalVolumePtr = right.sPhysicalVolumePtr;
sVolumeType = right.sVolumeType;
sReplicaNo = right.sReplicaNo;
fCountRef = right.fCountRef;
}
return *this;
}
// Accessors
// --------------
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PVPlacement.hh 73250 2013-08-22 13:22:23Z gcosmo $
// $Id: G4PVPlacement.hh 85846 2014-11-05 15:45:28Z gcosmo $
//
//
// class G4PVPlacement
@@ -122,7 +122,8 @@ class G4PVPlacement : public G4VPhysicalVolume
virtual ~G4PVPlacement();
// Default destructor.
G4int GetCopyNo() const;
inline G4int GetCopyNo() const { return fcopyNo; }
void SetCopyNo(G4int CopyNo);
// Gets and sets the copy number of the volume.
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PVReplica.hh 67974 2013-03-13 10:17:37Z gcosmo $
// $Id: G4PVReplica.hh 85846 2014-11-05 15:45:28Z gcosmo $
//
//
// class G4PVReplica
@@ -187,19 +187,19 @@ class G4PVReplica : public G4VPhysicalVolume
// 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.
private:
void CheckAndSetParameters(const EAxis pAxis, const G4int nReplicas,
const G4double width, const G4double offset);
G4PVReplica(const G4PVReplica&);
G4PVReplica& operator=(const G4PVReplica&);
protected:
EAxis faxis;
G4int fnReplicas;
G4double fwidth,foffset;
private:
void CheckAndSetParameters(const EAxis pAxis, const G4int nReplicas,
const G4double width, const G4double offset);
G4PVReplica(const G4PVReplica&);
const G4PVReplica& operator=(const G4PVReplica&);
private:
G4int fRegularStructureCode;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4TouchableHistory.hh 67974 2013-03-13 10:17:37Z gcosmo $
// $Id: G4TouchableHistory.hh 86527 2014-11-13 15:06:24Z gcosmo $
//
//
// class G4TouchableHistory
@@ -55,13 +55,16 @@ class G4TouchableHistory : public G4VTouchable
public: // with description
G4TouchableHistory( const G4NavigationHistory& history );
G4TouchableHistory();
// The default constructor produces a touchable-history of
// 'zero-depth', ie an "unphysical" and not very unusable one.
// It is for initialisation only.
~G4TouchableHistory();
G4TouchableHistory( const G4NavigationHistory& history );
// Copy constructor
~G4TouchableHistory();
// Destructor
inline G4VPhysicalVolume* GetVolume( G4int depth=0 ) const;
inline G4VSolid* GetSolid( G4int depth=0 ) const;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4TouchableHistory.icc 67974 2013-03-13 10:17:37Z gcosmo $
// $Id: G4TouchableHistory.icc 86527 2014-11-13 15:06:24Z gcosmo $
//
//
// class G4TouchableHistory inline implementation