Import Geant4 10.5.0 source tree

This commit is contained in:
Gabriele Cosmo
2018-12-07 15:15:39 +01:00
parent 6aa23be517
commit db49709b53
11370 changed files with 187480 additions and 160142 deletions
@@ -0,0 +1,188 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// G4AssemblyStore
//
// Implementation for singleton container
//
// History:
// 9.10.18 G.Cosmo Initial version
// --------------------------------------------------------------------
#include "G4AssemblyVolume.hh"
#include "G4AssemblyStore.hh"
#include "G4GeometryManager.hh"
#include "G4ios.hh"
// ***************************************************************************
// Static class variables
// ***************************************************************************
//
G4AssemblyStore* G4AssemblyStore::fgInstance = 0;
G4ThreadLocal G4VStoreNotifier* G4AssemblyStore::fgNotifier = 0;
G4ThreadLocal G4bool G4AssemblyStore::locked = false;
// ***************************************************************************
// Protected constructor: Construct underlying container with
// initial size of 20 entries
// ***************************************************************************
//
G4AssemblyStore::G4AssemblyStore()
: std::vector<G4AssemblyVolume*>()
{
reserve(20);
}
// ***************************************************************************
// Destructor
// ***************************************************************************
//
G4AssemblyStore::~G4AssemblyStore()
{
Clean(); // Delete all assemblies in the store
}
// ***************************************************************************
// Delete all assemblies from the store
// ***************************************************************************
//
void G4AssemblyStore::Clean()
{
// Do nothing if geometry is closed
//
if (G4GeometryManager::IsGeometryClosed())
{
G4cout << "WARNING - Attempt to delete the assembly store"
<< " while geometry closed !" << G4endl;
return;
}
// Locks store for deletion of assemblies. De-registration will be
// performed at this stage. Assemblies will not de-register themselves.
//
locked = true;
size_t i=0;
G4AssemblyStore* store = GetInstance();
#ifdef G4DEBUG_NAVIGATION
G4cout << "Deleting Assemblies ... ";
#endif
for(iterator pos=store->begin(); pos!=store->end(); pos++)
{
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
if (*pos) { delete *pos; }
i++;
}
#ifdef G4DEBUG_NAVIGATION
if (store->size() < i-1)
{ G4cout << "No assembly deleted. Already deleted by user ?" << G4endl; }
else
{ G4cout << i-1 << " assemblies deleted !" << G4endl; }
#endif
locked = false;
store->clear();
}
// ***************************************************************************
// Associate user notifier to the store
// ***************************************************************************
//
void G4AssemblyStore::SetNotifier(G4VStoreNotifier* pNotifier)
{
GetInstance();
fgNotifier = pNotifier;
}
// ***************************************************************************
// Add Assembly to container
// ***************************************************************************
//
void G4AssemblyStore::Register(G4AssemblyVolume* pAssembly)
{
GetInstance()->push_back(pAssembly);
if (fgNotifier) { fgNotifier->NotifyRegistration(); }
}
// ***************************************************************************
// Remove Assembly from container
// ***************************************************************************
//
void G4AssemblyStore::DeRegister(G4AssemblyVolume* pAssembly)
{
if (!locked) // Do not de-register if locked !
{
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
{
if (*i==pAssembly)
{
GetInstance()->erase(i);
break;
}
}
}
}
// ***************************************************************************
// Return ptr to Store, setting if necessary
// ***************************************************************************
//
G4AssemblyStore* G4AssemblyStore::GetInstance()
{
static G4AssemblyStore assemblyStore;
if (!fgInstance)
{
fgInstance = &assemblyStore;
}
return fgInstance;
}
// ***************************************************************************
// Returns an assembly through its name specification.
// ***************************************************************************
//
G4AssemblyVolume*
G4AssemblyStore::GetAssembly(unsigned int Id, G4bool verbose) const
{
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
{
if ((*i)->GetAssemblyID() == Id) { return *i; }
}
if (verbose)
{
std::ostringstream message;
message << "Assembly NOT found in store !" << G4endl
<< " Assembly " << Id << " NOT found in store !" << G4endl
<< " Returning NULL pointer.";
G4Exception("G4AssemblyStore::GetAssembly()",
"GeomVol1001", JustWarning, message);
}
return 0;
}
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4AssemblyVolume.cc 66872 2013-01-15 01:25:57Z japost $
//
//
// Class G4AssemblyVolume - implementation
@@ -32,6 +31,7 @@
// ----------------------------------------------------------------------
#include "G4AssemblyVolume.hh"
#include "G4AssemblyStore.hh"
#include "G4PVPlacement.hh"
#include "G4RotationMatrix.hh"
#include "G4AffineTransform.hh"
@@ -51,6 +51,20 @@ G4AssemblyVolume::G4AssemblyVolume()
InstanceCountPlus();
SetAssemblyID( GetInstanceCount() );
SetImprintsCount( 0 );
G4AssemblyStore* aStore = G4AssemblyStore::GetInstance();
if (aStore->GetAssembly(fAssemblyID,false))
{
std::ostringstream message;
message << "The assembly has NOT been registered !" << G4endl
<< " Assembly " << fAssemblyID
<< " already existing in store !" << G4endl;
G4Exception("G4AssemblyVolume::G4AssemblyVolume()", "GeomVol1001",
JustWarning, message);
}
else
{
aStore->Register(this);
}
}
// Composing constructor
@@ -64,6 +78,20 @@ G4AssemblyVolume::G4AssemblyVolume( G4LogicalVolume* volume,
SetAssemblyID( GetInstanceCount() );
SetImprintsCount( 0 );
AddPlacedVolume(volume, translation, rotation);
G4AssemblyStore* aStore = G4AssemblyStore::GetInstance();
if (aStore->GetAssembly(fAssemblyID,false))
{
std::ostringstream message;
message << "The assembly has NOT been registered !" << G4endl
<< " Assembly " << fAssemblyID
<< " already existing in store !" << G4endl;
G4Exception("G4Assembly::G4Assembly()", "GeomVol1001",
JustWarning, message);
}
else
{
aStore->Register(this);
}
}
// Destructor
@@ -94,6 +122,7 @@ G4AssemblyVolume::~G4AssemblyVolume()
}
fPVStore.clear();
InstanceCountMinus();
G4AssemblyStore::GetInstance()->DeRegister(this);
}
// Add and place the given volume according to the specified
@@ -353,17 +382,17 @@ unsigned int G4AssemblyVolume::GetInstanceCount() const
return G4AssemblyVolume::fsInstanceCounter;
}
void G4AssemblyVolume::SetInstanceCount( unsigned int value )
void G4AssemblyVolume::SetInstanceCount( unsigned int value )
{
G4AssemblyVolume::fsInstanceCounter = value;
}
void G4AssemblyVolume::InstanceCountPlus()
void G4AssemblyVolume::InstanceCountPlus()
{
G4AssemblyVolume::fsInstanceCounter++;
}
void G4AssemblyVolume::InstanceCountMinus()
void G4AssemblyVolume::InstanceCountMinus()
{
G4AssemblyVolume::fsInstanceCounter--;
}
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4GRSSolid.cc 87615 2014-12-12 15:23:11Z gcosmo $
//
//
// class G4GRSSolid Implementation
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4GRSVolume.cc 87615 2014-12-12 15:23:11Z gcosmo $
//
//
// class G4GRSVolume Implementation
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4GeometryWorkspace.cc 100429 2016-10-21 13:00:52Z gcosmo $
//
//
// Class G4GeometryWorkspace - implementation
@@ -49,8 +48,12 @@
namespace
{
G4Mutex solidclone = G4MUTEX_INITIALIZER;
G4GeometryWorkspace::pool_type thePool;
}
G4GeometryWorkspace::pool_type*
G4GeometryWorkspace::GetPool() { return &thePool; }
// ----------------------------------------------------------------------
//
G4GeometryWorkspace::G4GeometryWorkspace()
@@ -1,150 +0,0 @@
//
// ********************************************************************
// * 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: G4GeometryWorkspacePool.cc 110271 2018-05-17 14:41:15Z gcosmo $
//
//
// Class G4GeometryWorkspacePool - implementation
//
// ----------------------------------------------------------------------
#include "G4GeometryWorkspacePool.hh"
#include "G4GeometryWorkspace.hh"
#include "G4AutoLock.hh"
namespace
{
G4Mutex singletonM = G4MUTEX_INITIALIZER;
}
G4GeometryWorkspace*& G4GeometryWorkspacePool::fMyWorkspace()
{
G4ThreadLocalStatic G4GeometryWorkspace* _instance = nullptr;
return _instance;
}
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", "GeomVol003",
FatalException, "Failed to create workspace.");
}
else
{
fMyWorkspace()= geometryWrk;
}
}
else
{
G4Exception("GeometryWorspacePool::CreateWorkspace", "GeomVol003",
FatalException,
"Cannot create workspace twice for the same thread.");
geometryWrk= fMyWorkspace();
}
return geometryWrk;
}
// ----------------------------------------------------------------------
// Create it (as above) and use it
//
void G4GeometryWorkspacePool::CreateAndUseWorkspace()
{
(this->CreateWorkspace())->UseWorkspace();
}
// ----------------------------------------------------------------------
// Reuse an existing workspace - or create a new one if needed.
//
G4GeometryWorkspace* G4GeometryWorkspacePool::FindOrCreateWorkspace()
{
G4GeometryWorkspace* geometryWrk= fMyWorkspace();
if( !geometryWrk )
{
geometryWrk= this->CreateWorkspace();
}
geometryWrk->UseWorkspace();
fMyWorkspace()= geometryWrk; // assign it for use by this thread.
return geometryWrk;
}
// ----------------------------------------------------------------------
//
void G4GeometryWorkspacePool::Recycle( G4GeometryWorkspace *geometryWrk )
{
geometryWrk->ReleaseWorkspace();
// if( fWarehouse ){
// } else {
delete geometryWrk;
// }
}
// ----------------------------------------------------------------------
//
void G4GeometryWorkspacePool::CleanUpAndDestroyAllWorkspaces()
{
if (fMyWorkspace())
{
fMyWorkspace()->DestroyWorkspace();
delete fMyWorkspace();
fMyWorkspace()=0;
}
}
// ----------------------------------------------------------------------
//
G4GeometryWorkspacePool::G4GeometryWorkspacePool()
{
// fWarehouse=0;
}
// ----------------------------------------------------------------------
//
G4GeometryWorkspacePool::~G4GeometryWorkspacePool()
{
}
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4LogicalBorderSurface.cc 87615 2014-12-12 15:23:11Z gcosmo $
//
// --------------------------------------------------------------------
// G4LogicalBorderSurface Implementation
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4LogicalSkinSurface.cc 87615 2014-12-12 15:23:11Z gcosmo $
//
// --------------------------------------------------------------------
// G4LogicalSkinSurface Implementation
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4NavigationHistory.cc 110271 2018-05-17 14:41:15Z gcosmo $
//
//
// G4NavigationHistory Implementation
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id:$
//
// G4NavigationHistoryPool
//
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4NavigationLevel.cc 110271 2018-05-17 14:41:15Z gcosmo $
//
// 30.09.97 J.Apostolakis Initial version.
//
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4NavigationLevelRep.cc 110271 2018-05-17 14:41:15Z gcosmo $
//
// 1 October 1997 J.Apostolakis Initial version.
//
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4PVParameterised.cc 109823 2018-05-09 10:42:34Z gcosmo $
//
//
// class G4PVParameterised
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4PVPlacement.cc 110402 2018-05-22 11:35:41Z gcosmo $
//
//
// class G4PVPlacement Implementation
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4PVReplica.cc 100429 2016-10-21 13:00:52Z gcosmo $
//
//
// class G4PVReplica Implementation
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4ReflectionFactory.cc 66872 2013-01-15 01:25:57Z japost $
//
//
// Class G4ReflectionFactory Implementation
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4TouchableHistory.cc 110271 2018-05-17 14:41:15Z gcosmo $
//
//
// class G4TouchableHistory Implementation