Import Geant4 11.0.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2021-06-25 16:12:29 +02:00
parent c968e26a39
commit 6399a014b6
4200 changed files with 207479 additions and 237366 deletions
@@ -141,6 +141,16 @@ G4LogicalVolume::~G4LogicalVolume()
G4LogicalVolumeStore::DeRegister(this);
}
// ********************************************************************
// SetName - Set volume name and notify store of the change
// ********************************************************************
//
void G4LogicalVolume::SetName(const G4String& pName)
{
fName = pName;
G4LogicalVolumeStore::GetInstance()->SetMapValid(false);
}
// ********************************************************************
// InitialiseWorker
//
@@ -23,15 +23,22 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4LogicalVolumeStore implementation for singleton container
// G4LogicalVolumeStore implementation
//
// 10.07.95 - P.Kent, Initial version
// 10.07.95, P.Kent, G.Cosmo
// --------------------------------------------------------------------
#include "G4Types.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4GeometryManager.hh"
#include "G4AutoLock.hh"
namespace
{
G4Mutex mapMutex = G4MUTEX_INITIALIZER;
}
// ***************************************************************************
// Static class variables
// ***************************************************************************
@@ -81,7 +88,7 @@ void G4LogicalVolumeStore::Clean()
//
locked = true;
size_t i = 0;
std::size_t i = 0;
G4LogicalVolumeStore* store = GetInstance();
#ifdef G4GEOMETRY_VOXELDEBUG
@@ -102,6 +109,7 @@ void G4LogicalVolumeStore::Clean()
{ G4cout << i-1 << " volumes deleted !" << G4endl; }
#endif
store->bmap.clear(); store->mvalid = false;
locked = false;
store->clear();
}
@@ -116,14 +124,54 @@ void G4LogicalVolumeStore::SetNotifier(G4VStoreNotifier* pNotifier)
fgNotifier = pNotifier;
}
// ***************************************************************************
// Bring contents of internal map up to date and reset validity flag
// ***************************************************************************
//
void G4LogicalVolumeStore::UpdateMap()
{
G4AutoLock l(&mapMutex); // to avoid thread contention at initialisation
if (mvalid) return;
bmap.clear();
for(auto pos=GetInstance()->cbegin(); pos!=GetInstance()->cend(); ++pos)
{
const G4String& vol_name = (*pos)->GetName();
auto it = bmap.find(vol_name);
if (it != bmap.cend())
{
it->second.push_back(*pos);
}
else
{
std::vector<G4LogicalVolume*> vol_vec { *pos };
bmap.insert(std::make_pair(vol_name, vol_vec));
}
}
mvalid = true;
l.unlock();
}
// ***************************************************************************
// Add volume to container
// ***************************************************************************
//
void G4LogicalVolumeStore::Register(G4LogicalVolume* pVolume)
{
GetInstance()->push_back(pVolume);
G4LogicalVolumeStore* store = GetInstance();
store->push_back(pVolume);
const G4String& vol_name = pVolume->GetName();
auto it = store->bmap.find(vol_name);
if (it != store->bmap.cend())
{
it->second.push_back(pVolume);
}
else
{
std::vector<G4LogicalVolume*> vol_vec { pVolume };
store->bmap.insert(std::make_pair(vol_name, vol_vec));
}
if (fgNotifier) { fgNotifier->NotifyRegistration(); }
store->mvalid = true;
}
// ***************************************************************************
@@ -132,17 +180,38 @@ void G4LogicalVolumeStore::Register(G4LogicalVolume* pVolume)
//
void G4LogicalVolumeStore::DeRegister(G4LogicalVolume* pVolume)
{
G4LogicalVolumeStore* store = GetInstance();
if (!locked) // Do not de-register if locked !
{
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
for (auto i=store->cbegin(); i!=store->cend(); ++i)
{
if (**i==*pVolume)
{
GetInstance()->erase(i);
store->erase(i);
break;
}
}
const G4String& vol_name = pVolume->GetName();
auto it = store->bmap.find(vol_name);
if (it != store->bmap.cend())
{
if (it->second.size() > 1)
{
for (auto i=it->second.cbegin(); i!=it->second.cend(); ++i)
{
if (**i==*pVolume)
{
it->second.erase(i);
break;
}
}
}
else
{
store->bmap.erase(it);
}
}
}
}
@@ -153,9 +222,21 @@ void G4LogicalVolumeStore::DeRegister(G4LogicalVolume* pVolume)
G4LogicalVolume*
G4LogicalVolumeStore::GetVolume(const G4String& name, G4bool verbose) const
{
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
G4LogicalVolumeStore* store = GetInstance();
if (!store->mvalid) { store->UpdateMap(); }
auto pos = store->bmap.find(name);
if(pos != store->bmap.cend())
{
if ((*i)->GetName() == name) { return *i; }
if ((verbose) && (pos->second.size()>1))
{
std::ostringstream message;
message << "There exists more than ONE logical volume in store named: "
<< name << "!" << G4endl
<< "Returning the first found.";
G4Exception("G4LogicalVolumeStore::GetVolume()",
"GeomMgt1001", JustWarning, message);
}
return pos->second[0];
}
if (verbose)
{
@@ -166,7 +247,7 @@ G4LogicalVolumeStore::GetVolume(const G4String& name, G4bool verbose) const
G4Exception("G4LogicalVolumeStore::GetVolume()",
"GeomMgt1001", JustWarning, message);
}
return 0;
return nullptr;
}
// ***************************************************************************
@@ -23,9 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4PhysicalVolumeStore implementation for singleton container
// G4PhysicalVolumeStore implementation
//
// 25.07.95, P.Kent - Initial version
// 25.07.95, P.Kent, G.Cosmo
// --------------------------------------------------------------------
#include "G4Types.hh"
@@ -33,6 +33,13 @@
#include "G4GeometryManager.hh"
#include "G4LogicalVolume.hh"
#include "G4AutoLock.hh"
namespace
{
G4Mutex mapMutex = G4MUTEX_INITIALIZER;
}
// ***************************************************************************
// Static class variables
// ***************************************************************************
@@ -83,7 +90,7 @@ void G4PhysicalVolumeStore::Clean()
//
locked = true;
size_t i=0;
std::size_t i=0;
G4PhysicalVolumeStore* store = GetInstance();
#ifdef G4GEOMETRY_VOXELDEBUG
@@ -103,6 +110,7 @@ void G4PhysicalVolumeStore::Clean()
{ G4cout << i-1 << " volumes deleted !" << G4endl; }
#endif
store->bmap.clear(); store->mvalid = false;
locked = false;
store->clear();
}
@@ -117,14 +125,54 @@ void G4PhysicalVolumeStore::SetNotifier(G4VStoreNotifier* pNotifier)
fgNotifier = pNotifier;
}
// ***************************************************************************
// Bring contents of internal map up to date and reset validity flag
// ***************************************************************************
//
void G4PhysicalVolumeStore::UpdateMap()
{
G4AutoLock l(&mapMutex); // to avoid thread contention at initialisation
if (mvalid) return;
bmap.clear();
for(auto pos=GetInstance()->cbegin(); pos!=GetInstance()->cend(); ++pos)
{
const G4String& vol_name = (*pos)->GetName();
auto it = bmap.find(vol_name);
if (it != bmap.cend())
{
it->second.push_back(*pos);
}
else
{
std::vector<G4VPhysicalVolume*> vol_vec { *pos };
bmap.insert(std::make_pair(vol_name, vol_vec));
}
}
mvalid = true;
l.unlock();
}
// ***************************************************************************
// Add Volume to container
// ***************************************************************************
//
void G4PhysicalVolumeStore::Register(G4VPhysicalVolume* pVolume)
{
GetInstance()->push_back(pVolume);
G4PhysicalVolumeStore* store = GetInstance();
store->push_back(pVolume);
const G4String& vol_name = pVolume->GetName();
auto it = store->bmap.find(vol_name);
if (it != store->bmap.cend())
{
it->second.push_back(pVolume);
}
else
{
std::vector<G4VPhysicalVolume*> vol_vec { pVolume };
store->bmap.insert(std::make_pair(vol_name, vol_vec));
}
if (fgNotifier) { fgNotifier->NotifyRegistration(); }
store->mvalid = true;
}
// ***************************************************************************
@@ -134,19 +182,40 @@ void G4PhysicalVolumeStore::Register(G4VPhysicalVolume* pVolume)
//
void G4PhysicalVolumeStore::DeRegister(G4VPhysicalVolume* pVolume)
{
G4PhysicalVolumeStore* store = GetInstance();
if (!locked) // Do not de-register if locked !
{
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
G4LogicalVolume* motherLogical = pVolume->GetMotherLogical();
if (motherLogical != nullptr) { motherLogical->RemoveDaughter(pVolume); }
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
for (auto i=store->cbegin(); i!=store->cend(); ++i)
{
if (**i==*pVolume)
{
GetInstance()->erase(i);
store->erase(i);
break;
}
}
const G4String& vol_name = pVolume->GetName();
auto it = store->bmap.find(vol_name);
if (it != store->bmap.cend())
{
if (it->second.size() > 1)
{
for (auto i=it->second.cbegin(); i!=it->second.cend(); ++i)
{
if (**i==*pVolume)
{
it->second.erase(i);
break;
}
}
}
else
{
store->bmap.erase(it);
}
}
}
}
@@ -157,9 +226,21 @@ void G4PhysicalVolumeStore::DeRegister(G4VPhysicalVolume* pVolume)
G4VPhysicalVolume*
G4PhysicalVolumeStore::GetVolume(const G4String& name, G4bool verbose) const
{
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
G4PhysicalVolumeStore* store = GetInstance();
if (!store->mvalid) { store->UpdateMap(); }
auto pos = store->bmap.find(name);
if(pos != store->bmap.cend())
{
if ((*i)->GetName() == name) { return *i; }
if ((verbose) && (pos->second.size()>1))
{
std::ostringstream message;
message << "There exists more than ONE physical volume in store named: "
<< name << "!" << G4endl
<< "Returning the first found.";
G4Exception("G4PhysicalVolumeStore::GetVolume()",
"GeomMgt1001", JustWarning, message);
}
return pos->second[0];
}
if (verbose)
{
@@ -114,6 +114,16 @@ G4Region::~G4Region()
if(fUserInfo != nullptr) { delete fUserInfo; }
}
// ********************************************************************
// SetName - Set region name and notify store of the change
// ********************************************************************
//
void G4Region::SetName(const G4String& pName)
{
fName = pName;
G4RegionStore::GetInstance()->SetMapValid(false);
}
// ********************************************************************
// SetFastSimulationManager
// ********************************************************************
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4RegionStore implementation for singleton container
// G4RegionStore implementation
//
// 18.09.02, G.Cosmo - Initial version
// --------------------------------------------------------------------
@@ -35,6 +35,12 @@
#include "G4PhysicalVolumeStore.hh"
#include "G4ios.hh"
#include "G4AutoLock.hh"
namespace
{
G4Mutex mapMutex = G4MUTEX_INITIALIZER;
}
// ***************************************************************************
// Static class variables
@@ -85,7 +91,7 @@ void G4RegionStore::Clean()
//
locked = true;
size_t i=0;
std::size_t i=0;
G4RegionStore* store = GetInstance();
#ifdef G4GEOMETRY_VOXELDEBUG
@@ -105,6 +111,7 @@ void G4RegionStore::Clean()
{ G4cout << i-1 << " regions deleted !" << G4endl; }
#endif
store->bmap.clear(); store->mvalid = false;
locked = false;
store->clear();
}
@@ -119,14 +126,54 @@ void G4RegionStore::SetNotifier(G4VStoreNotifier* pNotifier)
fgNotifier = pNotifier;
}
// ***************************************************************************
// Bring contents of internal map up to date and reset validity flag
// ***************************************************************************
//
void G4RegionStore::UpdateMap()
{
G4AutoLock l(&mapMutex); // to avoid thread contention at initialisation
if (mvalid) return;
bmap.clear();
for(auto pos=GetInstance()->cbegin(); pos!=GetInstance()->cend(); ++pos)
{
const G4String& reg_name = (*pos)->GetName();
auto it = bmap.find(reg_name);
if (it != bmap.cend())
{
it->second.push_back(*pos);
}
else
{
std::vector<G4Region*> reg_vec { *pos };
bmap.insert(std::make_pair(reg_name, reg_vec));
}
}
mvalid = true;
l.unlock();
}
// ***************************************************************************
// Add Region to container
// ***************************************************************************
//
void G4RegionStore::Register(G4Region* pRegion)
{
GetInstance()->push_back(pRegion);
if (fgNotifier) { fgNotifier->NotifyRegistration(); }
G4RegionStore* store = GetInstance();
store->push_back(pRegion);
const G4String& reg_name = pRegion->GetName();
auto it = store->bmap.find(reg_name);
if (it != store->bmap.cend())
{
it->second.push_back(pRegion);
}
else
{
std::vector<G4Region*> reg_vec { pRegion };
store->bmap.insert(std::make_pair(reg_name, reg_vec));
}
if (fgNotifier) { fgNotifier->NotifyRegistration(); }
store->mvalid = true;
}
// ***************************************************************************
@@ -135,17 +182,38 @@ void G4RegionStore::Register(G4Region* pRegion)
//
void G4RegionStore::DeRegister(G4Region* pRegion)
{
G4RegionStore* store = GetInstance();
if (!locked) // Do not de-register if locked !
{
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
for (auto i=store->cbegin(); i!=store->cend(); ++i)
{
if (**i==*pRegion)
{
GetInstance()->erase(i);
store->erase(i);
break;
}
}
const G4String& reg_name = pRegion->GetName();
auto it = store->bmap.find(reg_name);
if (it != store->bmap.cend())
{
if (it->second.size() > 1)
{
for (auto i=it->second.cbegin(); i!=it->second.cend(); ++i)
{
if (**i==*pRegion)
{
it->second.erase(i);
break;
}
}
}
else
{
store->bmap.erase(it);
}
}
}
}
@@ -210,9 +278,21 @@ void G4RegionStore::UpdateMaterialList(G4VPhysicalVolume* currentWorld)
//
G4Region* G4RegionStore::GetRegion(const G4String& name, G4bool verbose) const
{
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
G4RegionStore* store = GetInstance();
if (!store->mvalid) { store->UpdateMap(); }
auto pos = store->bmap.find(name);
if(pos != store->bmap.cend())
{
if ((*i)->GetName() == name) { return *i; }
if ((verbose) && (pos->second.size()>1))
{
std::ostringstream message;
message << "There exists more than ONE region in store named: "
<< name << "!" << G4endl
<< "Returning the first found.";
G4Exception("G4RegionStore::GetSolid()",
"GeomMgt1001", JustWarning, message);
}
return pos->second[0];
}
if (verbose)
{
@@ -223,7 +303,7 @@ G4Region* G4RegionStore::GetRegion(const G4String& name, G4bool verbose) const
G4Exception("G4RegionStore::GetRegion()",
"GeomMgt1001", JustWarning, message);
}
return 0;
return nullptr;
}
// ***************************************************************************
+96 -15
View File
@@ -23,16 +23,22 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4SolidStore implementation for singleton container
// G4SolidStore implementation
//
// 18.04.01, G.Cosmo - Migrated to STL vector
// 10.07.95, P.Kent - Initial version
// 10.07.95, P.Kent, G.Cosmo
// --------------------------------------------------------------------
#include "globals.hh"
#include "G4SolidStore.hh"
#include "G4GeometryManager.hh"
#include "G4AutoLock.hh"
namespace
{
G4Mutex mapMutex = G4MUTEX_INITIALIZER;
}
// ***************************************************************************
// Static class variables
// ***************************************************************************
@@ -81,7 +87,7 @@ void G4SolidStore::Clean()
//
locked = true;
size_t i = 0;
std::size_t i = 0;
G4SolidStore* store = GetInstance();
#ifdef G4GEOMETRY_VOXELDEBUG
@@ -101,6 +107,7 @@ void G4SolidStore::Clean()
{ G4cout << i-1 << " solids deleted !" << G4endl; }
#endif
store->bmap.clear(); store->mvalid = false;
locked = false;
store->clear();
}
@@ -115,14 +122,54 @@ void G4SolidStore::SetNotifier(G4VStoreNotifier* pNotifier)
fgNotifier = pNotifier;
}
// ***************************************************************************
// Bring contents of internal map up to date and reset validity flag
// ***************************************************************************
//
void G4SolidStore::UpdateMap()
{
G4AutoLock l(&mapMutex); // to avoid thread contention at initialisation
if (mvalid) return;
bmap.clear();
for(auto pos=GetInstance()->cbegin(); pos!=GetInstance()->cend(); ++pos)
{
const G4String& sol_name = (*pos)->GetName();
auto it = bmap.find(sol_name);
if (it != bmap.cend())
{
it->second.push_back(*pos);
}
else
{
std::vector<G4VSolid*> sol_vec { *pos };
bmap.insert(std::make_pair(sol_name, sol_vec));
}
}
mvalid = true;
l.unlock();
}
// ***************************************************************************
// Add Solid to container
// ***************************************************************************
//
void G4SolidStore::Register(G4VSolid* pSolid)
{
GetInstance()->push_back(pSolid);
if (fgNotifier != nullptr) { fgNotifier->NotifyRegistration(); }
G4SolidStore* store = GetInstance();
store->push_back(pSolid);
const G4String& sol_name = pSolid->GetName();
auto it = store->bmap.find(sol_name);
if (it != store->bmap.cend())
{
it->second.push_back(pSolid);
}
else
{
std::vector<G4VSolid*> sol_vec { pSolid };
store->bmap.insert(std::make_pair(sol_name, sol_vec));
}
if (fgNotifier) { fgNotifier->NotifyRegistration(); }
store->mvalid = true;
}
// ***************************************************************************
@@ -131,17 +178,39 @@ void G4SolidStore::Register(G4VSolid* pSolid)
//
void G4SolidStore::DeRegister(G4VSolid* pSolid)
{
G4SolidStore* store = GetInstance();
if (!locked) // Do not de-register if locked !
{
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
for (auto i=GetInstance()->crbegin(); i!=GetInstance()->crend(); ++i)
for (auto i=store->crbegin(); i!=store->crend(); ++i)
{
if (**i==*pSolid)
{
GetInstance()->erase(std::next(i).base());
store->erase(std::next(i).base());
store->mvalid = false;
break;
}
}
const G4String& sol_name = pSolid->GetName();
auto it = store->bmap.find(sol_name);
if (it != store->bmap.cend())
{
if (it->second.size() > 1)
{
for (auto i=it->second.cbegin(); i!=it->second.cend(); ++i)
{
if (**i==*pSolid)
{
it->second.erase(i);
break;
}
}
}
else
{
store->bmap.erase(it);
}
}
}
}
@@ -151,17 +220,29 @@ void G4SolidStore::DeRegister(G4VSolid* pSolid)
//
G4VSolid* G4SolidStore::GetSolid(const G4String& name, G4bool verbose) const
{
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
G4SolidStore* store = GetInstance();
if (!store->mvalid) { store->UpdateMap(); }
auto pos = store->bmap.find(name);
if(pos != store->bmap.cend())
{
if ((*i)->GetName() == name) { return *i; }
if ((verbose) && (pos->second.size()>1))
{
std::ostringstream message;
message << "There exists more than ONE solid in store named: "
<< name << "!" << G4endl
<< "Returning the first found.";
G4Exception("G4SolidStore::GetSolid()",
"GeomMgt1001", JustWarning, message);
}
return pos->second[0];
}
if (verbose)
{
std::ostringstream message;
message << "Solid " << name << " not found in store !" << G4endl
<< "Returning NULL pointer.";
G4Exception("G4SolidStore::GetSolid()",
"GeomMgt1001", JustWarning, message);
std::ostringstream message;
message << "Solid " << name << " not found in store !" << G4endl
<< "Returning NULL pointer.";
G4Exception("G4SolidStore::GetSolid()",
"GeomMgt1001", JustWarning, message);
}
return nullptr;
}
@@ -94,6 +94,14 @@ G4VPhysicalVolume::~G4VPhysicalVolume()
G4PhysicalVolumeStore::DeRegister(this);
}
// Set volume name and notify store of the change
//
void G4VPhysicalVolume::SetName(const G4String& pName)
{
fname = pName;
G4PhysicalVolumeStore::GetInstance()->SetMapValid(false);
}
// 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.
@@ -118,6 +118,16 @@ std::ostream& operator<< ( std::ostream& os, const G4VSolid& e )
return e.StreamInfo(os);
}
//////////////////////////////////////////////////////////////////////////
//
// Set solid name and notify store of the change
void G4VSolid::SetName(const G4String& name)
{
fshapeName = name;
G4SolidStore::GetInstance()->SetMapValid(false);
}
//////////////////////////////////////////////////////////////////////////
//
// Throw exception if ComputeDimensions called for illegal derived class