Import Geant4 10.5.1 source tree

This commit is contained in:
Gabriele Cosmo
2019-04-17 10:39:02 +02:00
parent a7fdc52004
commit 28a70706e0
661 changed files with 55791 additions and 106984 deletions
+4
View File
@@ -16,6 +16,10 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
Jan 31, 2019 Ivana Hrivnacova geometry-V10-04-00
----------------------------
- Merged GitHub PR #4: all Boolean operators now return G4bool.
Oct 31, 2014 Gabriele Cosmo geometry-V10-00-02
----------------------------
- Fixed internal link dependency on USolids module in CMake scripts.
+10 -1
View File
@@ -16,6 +16,16 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
April 8, 2019 H.Burkhardt - field-V10-04-18
-------------------------
- Correcting transformation to local system in G4QuadrupoleMagField.cc
March 20, 2019 G.Cosmo
----------------------
- Corrected 'RegularStepperName' in G4ChordFinder to refer to the actual
default stepper G4DormandPrince745 rather than G4NystromRK4...
November 9, 2018 J.Apostolakis - field-V10-04-17
------------------------------
- Small fixes for warnings in compilation.
@@ -2035,4 +2045,3 @@ May 7th, 1998 J. Apostolakis - magfield-06-01
* G4ChordFinder: methods to get/set IntegratorDriver
* G4MagIntegratorDriver: made OneGoodStep method public
- created the file.
@@ -52,7 +52,7 @@
// New FSAL type driver / steppers -----
#include "G4IntegrationDriver.hh"
#include "G4FSALBogackiShampine45.hh"
// #include "G4FSALBogackiShampine45.hh"
// #include "G4FSALDormandPrince745.hh"
#include <cassert>
@@ -88,17 +88,19 @@ G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
// by creating in inverse order the Driver, the Stepper and EqRhs ...
using NewFsalStepperType = G4RK547FEq1; // or 2 or 3
const char* NewFSALStepperName = "G4RK574FEq1> FSAL 4th/5th order 7-stage 'Equilibrium-type' #1.";
const char* NewFSALStepperName =
"G4RK574FEq1> FSAL 4th/5th order 7-stage 'Equilibrium-type' #1.";
using RegularStepperType =
G4DormandPrince745; //
G4DormandPrince745; // DOPRI5 (MatLab) 5th order embedded method. High efficiency.
// G4ClassicalRK4; // The old default
// G4CashKarpRKF45; // First embedded method in G4
// G4BogackiShampine45; // High efficiency 5th order embedded method
// G4DormandPrince745 // Famous DOPRI5 (MatLab) 5th order embedded method. High efficiency.
// G4NystromRK4; // Nystrom stepper 4th order
// G4RK547FEq1; // or 2 or 3
const char* RegularStepperName = "Nystrom stepper 4th order";
//"G4DormandPrince745 (aka DOPRI5): 5th/4th Order 7-stage embedded stepper";
const char* RegularStepperName =
"G4DormandPrince745 (aka DOPRI5): 5th/4th Order 7-stage embedded stepper";
// "BogackiShampine 45 (Embedded 5th/4th Order, 7-stage)";
// "Nystrom stepper 4th order";
// Configurable
G4bool forceFSALstepper= false; // Choice - true to enable !!
@@ -118,10 +120,10 @@ G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
G4Mag_EqRhs *pEquation = new G4Mag_UsualEqRhs(theMagField);
fEquation = pEquation;
// G4MagIntegratorStepper* regularStepper = nullptr;
// G4VFSALIntegrationStepper* fsalSepper = nullptr; // for new-type FSAL steppers only
// NewFsalStepperType* fsalStepper =nullptr;
// G4MagIntegratorStepper* oldFSALStepper =nullptr;
// G4MagIntegratorStepper* regularStepper = nullptr;
// G4VFSALIntegrationStepper* fsalSepper = nullptr; // for new-type FSAL steppers only
// NewFsalStepperType* fsalStepper = nullptr;
// G4MagIntegratorStepper* oldFSALStepper = nullptr;
G4bool errorInStepperCreation = false;
@@ -62,32 +62,18 @@ G4QuadrupoleMagField::~G4QuadrupoleMagField()
{
}
////////////////////////////////////////////////////////////////////////
// Allow displaced origin and rotation
// Extensions by Björn Riese (GSI)
void G4QuadrupoleMagField::GetFieldValue( const G4double y[7],
G4double B[3] ) const
G4double B[3] ) const
// with displaced origin and rotation
{
G4ThreeVector r_global = G4ThreeVector(
y[0] - fOrigin.x(),
y[1] - fOrigin.y(),
y[2] - fOrigin.z());
G4ThreeVector r_local = G4ThreeVector(
fpMatrix->colX() * r_global,
fpMatrix->colY() * r_global,
fpMatrix->colZ() * r_global);
G4ThreeVector B_local = G4ThreeVector(
fGradient * r_local.y(),
fGradient * r_local.x(),
0);
G4ThreeVector B_global = G4ThreeVector(
fpMatrix->inverse().rowX() * B_local,
fpMatrix->inverse().rowY() * B_local,
fpMatrix->inverse().rowZ() * B_local);
G4ThreeVector r_global = G4ThreeVector(
y[0] - fOrigin.x(),
y[1] - fOrigin.y(),
y[2] - fOrigin.z());
const G4ThreeVector r_local = (*fpMatrix) * r_global;
const G4ThreeVector B_local( fGradient * r_local.y(),fGradient * r_local.x(),0);
const G4ThreeVector B_global = fpMatrix->inverse() * B_local;
B[0] = B_global.x() ;
B[1] = B_global.y() ;
+10
View File
@@ -16,6 +16,16 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
March 8, 2019 G.Cosmo (geommng-V10-04-09)
- G4LogicalVolume: in AddDaughter() avoid propagating pointer to field-manager
if this is null. Addressing problem report #2145.
January 30, 2019 A.Dotti, G.Cosmo
- Use reverse_iterator in G4SolidStore::DeRegister() in order to speedup
partial deregistration on setups with many solids instances.
- G4Region: added possibility to disable search in the tree in
AddRootLogicalVolume() for speeding up process in complex flat geometries.
October 18, 2018 E.Tcherniaev (geommng-V10-04-08)
- G4VSolid: improved setting of surface thickness in EstimateSurfaceArea().
@@ -93,8 +93,8 @@ class G4LogicalSurface
virtual ~G4LogicalSurface();
inline G4int operator==(const G4LogicalSurface &right) const;
inline G4int operator!=(const G4LogicalSurface &right) const;
inline G4bool operator==(const G4LogicalSurface &right) const;
inline G4bool operator!=(const G4LogicalSurface &right) const;
protected:
@@ -88,13 +88,13 @@ G4LogicalSurface::operator=(const G4LogicalSurface &right)
return *this;
}
inline G4int
inline G4bool
G4LogicalSurface::operator==(const G4LogicalSurface &right) const
{
return (this == (G4LogicalSurface *) &right);
}
inline G4int
inline G4bool
G4LogicalSurface::operator!=(const G4LogicalSurface &right) const
{
return (this != (G4LogicalSurface *) &right);
@@ -110,11 +110,15 @@ class G4Region
inline G4bool operator==(const G4Region& rg) const;
// Equality defined by address only.
void AddRootLogicalVolume(G4LogicalVolume* lv);
void AddRootLogicalVolume(G4LogicalVolume* lv, G4bool search=true);
void RemoveRootLogicalVolume(G4LogicalVolume* lv, G4bool scan=true);
// Add/remove root logical volumes and set/reset their
// daughters flags as regions. They also recompute the
// materials list for the region.
// materials list for the region. Flag for scanning the subtree
// always enabled by default. Search in the tree can be turned off
// when adding, assuming the user guarantees the logical volume is
// NOT already inserted, in which case significant speedup can be
// achieved in very complex flat geometry setups.
inline void SetName(const G4String& name);
inline const G4String& GetName() const;
@@ -85,14 +85,14 @@ G4LogicalVolume::G4LogicalVolume( G4VSolid* pSolid,
fSmartless(2.), fVisAttributes(0), fRegion(0), fBiasWeight(1.)
{
// Initialize 'Shadow'/master pointers - for use in copying to workers
//
fSolid = pSolid;
fSensitiveDetector = pSDetector;
fFieldManager = pFieldMgr;
instanceID = subInstanceManager.CreateSubInstance();
AssignFieldManager(pFieldMgr); // G4MT_fmanager = pFieldMgr;
AssignFieldManager(pFieldMgr);
// fMasterFieldMgr= pFieldMgr;
G4MT_mass = 0.;
G4MT_ccouple = 0;
@@ -103,6 +103,7 @@ G4LogicalVolume::G4LogicalVolume( G4VSolid* pSolid,
SetUserLimits(pULimits);
// Initialize 'Shadow' data structure - for use by object persistency
//
lvdata = new G4LVData();
lvdata->fSolid = pSolid;
lvdata->fMaterial = pMaterial;
@@ -172,18 +173,22 @@ InitialiseWorker( G4LogicalVolume* /*pMasterObject*/,
SetSolid(pSolid);
SetSensitiveDetector(pSDetector); // How this object is available now ?
AssignFieldManager(fFieldManager); // Should be set - but a per-thread copy is not available yet
// G4MT_fmanager= fFieldManager;
// Must not call SetFieldManager(fFieldManager, false); which propagates FieldMgr
AssignFieldManager(fFieldManager);
// Should be set - but a per-thread copy is not available yet
// Must not call SetFieldManager(), which propagates FieldMgr
#ifdef CLONE_FIELD_MGR
// Create a field FieldManager by cloning
//
G4FieldManager workerFldMgr= fFieldManager->GetWorkerClone(G4bool* created);
if( created || (GetFieldManager()!=workerFldMgr) )
if( created || (GetFieldManager() != workerFldMgr) )
{
SetFieldManager(fFieldManager, false); // which propagates FieldMgr
}else{
}
else
{
// Field manager existed and is equal to current one
//
AssignFieldManager(workerFldMgr);
}
#endif
@@ -238,7 +243,7 @@ G4FieldManager* G4LogicalVolume::GetFieldManager() const
void G4LogicalVolume::AssignFieldManager( G4FieldManager *fldMgr)
{
G4MT_fmanager= fldMgr;
if(G4Threading::IsMasterThread()) fFieldManager = fldMgr;
if(G4Threading::IsMasterThread()) { fFieldManager = fldMgr; }
}
// ********************************************************************
@@ -258,7 +263,6 @@ void
G4LogicalVolume::SetFieldManager(G4FieldManager* pNewFieldMgr,
G4bool forceAllDaughters)
{
// G4MT_fmanager = pNewFieldMgr;
AssignFieldManager(pNewFieldMgr);
G4int NoDaughters = GetNoDaughters();
@@ -294,17 +298,20 @@ void G4LogicalVolume::AddDaughter(G4VPhysicalVolume* pNewDaughter)
}
// Invalidate previous calculation of mass - if any - for all threads
//
G4MT_mass = 0.;
// SignalVolumeChange(); // fVolumeChanged= true;
fDaughters.push_back(pNewDaughter);
G4LogicalVolume* pDaughterLogical = pNewDaughter->GetLogicalVolume();
// Propagate the Field Manager, if the daughter has no field Manager.
// Propagate the Field Manager, if the daughter has no field Manager
//
G4FieldManager* pDaughterFieldManager = pDaughterLogical->GetFieldManager();
if( pDaughterFieldManager == 0 )
// Avoid propagating the fieldManager pointer if null
// and daughter's one is null as well...
//
if( (G4MT_fmanager !=0 ) && (pDaughterFieldManager == 0) )
{
pDaughterLogical->SetFieldManager(G4MT_fmanager, false);
}
@@ -371,8 +378,6 @@ G4VSolid* G4LogicalVolume::GetSolid(G4LVData &instLVdata) // const
G4VSolid* G4LogicalVolume::GetSolid() const
{
// return G4MT_solid;
// return ((subInstanceManager.offset[instanceID]).fSolid);
return this->GetSolid( subInstanceManager.offset[instanceID] );
}
@@ -383,18 +388,15 @@ G4VSolid* G4LogicalVolume::GetSolid() const
void G4LogicalVolume::SetSolid(G4VSolid *pSolid)
{
// ((subInstanceManager.offset[instanceID]).fSolid) = pSolid;
G4MT_solid=pSolid;
// G4MT_mass = 0.;
G4MT_solid = pSolid;
this->ResetMass();
}
void G4LogicalVolume::SetSolid(G4LVData &instLVdata, G4VSolid *pSolid)
{
instLVdata.fSolid = pSolid;
// G4MT_solid=pSolid;
instLVdata.fMass= 0;
// A fast way to reset the mass ... ie G4MT_mass = 0.;
// A fast way to reset the mass... i.e. G4MT_mass = 0.;
}
// ********************************************************************
@@ -412,7 +414,7 @@ G4Material* G4LogicalVolume::GetMaterial() const
//
void G4LogicalVolume::SetMaterial(G4Material *pMaterial)
{
G4MT_material=pMaterial;
G4MT_material = pMaterial;
G4MT_mass = 0.;
}
@@ -423,7 +425,7 @@ void G4LogicalVolume::SetMaterial(G4Material *pMaterial)
void G4LogicalVolume::UpdateMaterial(G4Material *pMaterial)
{
G4MT_material=pMaterial;
if(fRegion) { G4MT_ccouple = fRegion->FindCouple(pMaterial); }
if (fRegion) { G4MT_ccouple = fRegion->FindCouple(pMaterial); }
G4MT_mass = 0.;
}
@@ -443,7 +445,7 @@ G4VSensitiveDetector* G4LogicalVolume::GetSensitiveDetector() const
void G4LogicalVolume::SetSensitiveDetector(G4VSensitiveDetector* pSDetector)
{
G4MT_sdetector = pSDetector;
if(G4Threading::IsMasterThread()) fSensitiveDetector = pSDetector;
if (G4Threading::IsMasterThread()) { fSensitiveDetector = pSDetector; }
}
// ********************************************************************
@@ -532,27 +534,27 @@ G4double G4LogicalVolume::GetMass(G4bool forced,
{
// Return the cached non-zero value, if not forced
//
if ( (G4MT_mass) && (!forced) ) return G4MT_mass;
if ( (G4MT_mass) && (!forced) ) { return G4MT_mass; }
// Global density and computed mass associated to the logical
// volume without considering its daughters
//
G4Material* logMaterial = parMaterial ? parMaterial : GetMaterial(); // G4MT_material;
G4Material* logMaterial = parMaterial ? parMaterial : GetMaterial();
if (!logMaterial)
{
std::ostringstream message;
message << "No material associated to the logical volume: " << fName << " !"
<< G4endl
message << "No material associated to the logical volume: "
<< fName << " !" << G4endl
<< "Sorry, cannot compute the mass ...";
G4Exception("G4LogicalVolume::GetMass()", "GeomMgt0002",
FatalException, message);
return 0;
}
if (! GetSolid() ) // !G4MT_solid)
if ( !GetSolid() )
{
std::ostringstream message;
message << "No solid is associated to the logical volume: " << fName << " !"
<< G4endl
message << "No solid is associated to the logical volume: "
<< fName << " !" << G4endl
<< "Sorry, cannot compute the mass ...";
G4Exception("G4LogicalVolume::GetMass()", "GeomMgt0002",
FatalException, message);
@@ -560,10 +562,7 @@ G4double G4LogicalVolume::GetMass(G4bool forced,
}
G4double globalDensity = logMaterial->GetDensity();
G4double motherMass= GetSolid()->GetCubicVolume() * globalDensity;
// G4MT_mass =
// SetMass( motherMmass );
G4double massSum= motherMass;
G4double massSum = motherMass;
// For each daughter in the tree, subtract the mass occupied
// and if required by the propagate flag, add the real daughter's
@@ -584,8 +583,7 @@ G4double G4LogicalVolume::GetMass(G4bool forced,
//
for (G4int i=0; i<physDaughter->GetMultiplicity(); i++)
{
G4VPVParameterisation*
physParam = physDaughter->GetParameterisation();
G4VPVParameterisation* physParam = physDaughter->GetParameterisation();
if (physParam)
{
daughterSolid = physParam->ComputeSolid(i, physDaughter);
@@ -617,4 +615,3 @@ void G4LogicalVolume::SetVisAttributes (const G4VisAttributes& VA)
{
fVisAttributes = new G4VisAttributes(VA);
}
+14 -7
View File
@@ -286,20 +286,27 @@ void G4Region::ScanVolumeTree(G4LogicalVolume* lv, G4bool region)
// regions. It also recomputes the materials list for the region.
// *******************************************************************
//
void G4Region::AddRootLogicalVolume(G4LogicalVolume* lv)
void G4Region::AddRootLogicalVolume(G4LogicalVolume* lv, G4bool search)
{
// Check the logical volume is not already in the list
//
G4RootLVList::iterator pos;
pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
if (pos == fRootVolumes.end())
if (search)
{
// Insert the root volume in the list and set it as root region
//
G4RootLVList::iterator pos;
pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
if (pos == fRootVolumes.end())
{
// Insert the root volume in the list and set it as root region
//
fRootVolumes.push_back(lv);
lv->SetRegionRootFlag(true);
}
}
else // WARNING: user *MUST* guarantee lv is not already inserted.
{ // Providing speedup for very complex flat geometries
fRootVolumes.push_back(lv);
lv->SetRegionRootFlag(true);
}
// Scan recursively the tree of daugther volumes and set regions
//
ScanVolumeTree(lv, true);
@@ -139,11 +139,12 @@ void G4SolidStore::DeRegister(G4VSolid* pSolid)
if (!locked) // Do not de-register if locked !
{
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
for (reverse_iterator i=GetInstance()->rbegin();
i!=GetInstance()->rend(); i++)
{
if (**i==*pSolid)
{
GetInstance()->erase(i);
GetInstance()->erase(std::next(i).base());
break;
}
}
+10 -2
View File
@@ -16,9 +16,17 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
April 1, 2019 - G.Cosmo (geomnav-V10-04-13)
------------------------
- Protected report for looping particles under verbosity flag.
March 11, 2019 - G.Cosmo
------------------------
- Fixed typos in printouts in G4NavigationLogger.
September 26, 2018 - D.Sorokin (geomnav-V10-04-12)
-----------------------
- Notify G4ChordFinder at the beginning of each ComputeStep call.
------------------------------
- Notify G4ChordFinder at the beginning of each ComputeStep() call.
June 15, 2018 - G.Cosmo (geomnav-V10-04-11)
-----------------------
@@ -381,7 +381,7 @@ G4NavigationLogger::CheckDaughterEntryPoint(const G4VSolid* sampleSolid,
{
msg << "NearMiss> Intersection to Daughter volume is in extension past the"
<< " current exit point of the mother volume." << G4endl;
msg << " This is not an error - just an unusual occurence,"
msg << " This is not an error - just an unusual occurrence,"
<< " possible in the case of concave volume. " << G4endl;
}
msg << "---- Information about intersection with daughter, mother: "
@@ -243,8 +243,10 @@ G4PropagatorInField::ComputeStep(
G4double stepTrial;
stepTrial= fFull_CurveLen_of_LastAttempt;
if( (stepTrial <= 0.0) && (fLast_ProposedStepLength > 0.0) )
if( (stepTrial <= 0.0) && (fLast_ProposedStepLength > 0.0) )
{
stepTrial= fLast_ProposedStepLength;
}
G4double decreaseFactor = 0.9; // Unused default
if( (fNoZeroStep < fSevereActionThreshold_NoZeroSteps)
@@ -302,7 +304,9 @@ G4PropagatorInField::ComputeStep(
return 0; // = stepTrial;
}
if( stepTrial < CurrentProposedStepLength )
{
CurrentProposedStepLength = stepTrial;
}
}
fLast_ProposedStepLength = CurrentProposedStepLength;
@@ -406,9 +410,10 @@ G4PropagatorInField::ComputeStep(
}
if( !intersects )
{
StepTaken += s_length_taken;
// For smooth trajectory display (jacek 01/11/2002)
if (fpTrajectoryFilter) {
StepTaken += s_length_taken;
if (fpTrajectoryFilter) // For smooth trajectory display (jacek 1/11/2002)
{
fpTrajectoryFilter->TakeIntermediatePoint(CurrentState.GetPosition());
}
}
@@ -453,7 +458,7 @@ G4PropagatorInField::ComputeStep(
{
fParticleIsLooping = true;
}
if ( fParticleIsLooping ) // && (fVerboseLevel > 0) )
if ( ( fParticleIsLooping ) && (fVerboseLevel > 0) )
{
ReportLoopingParticle( do_loop_count, StepTaken,
CurrentProposedStepLength, methodName,
@@ -512,7 +517,8 @@ G4PropagatorInField::ComputeStep(
{
fNoZeroStep++;
}
else{
else
{
fNoZeroStep = 0;
}
}
+1 -1
View File
@@ -461,7 +461,7 @@ committal in the CVS repository !
Aug 13 2001 Vladimir Grichine geom-solid-bool-V03-02-00
- Introduced G4BOOLDEBUG flag and replaced G4Exception statements with
simple warnings to G4cerr for rare occurences of anomalous conditions.
simple warnings to G4cerr for rare occurrences of anomalous conditions.
May 30 2001 Vladimir Grichine geom-solid-bool-V03-01-00
- G4IntersectionSolid: fix in DistanceToIn(p,v) resolving bug observed
+18
View File
@@ -16,6 +16,24 @@ committal in the source repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
15-February-2019 E.Tcherniaev (geom-specific-V10-04-16)
- Accurate calculation of radical in G4IntersectingCone.
It addresses the problem report #2111.
4-February-2019 G.Cosmo
- Fix in G4EllipticalTube::CheckParameters() for typo in condition.
30-January-2019 G.Cosmo
- Disabled precise computation of extent and use simple bounding-box
in CalculateExtent() for G4Tet and G4TessellatedSolid, to speed up
intialisation in setups with relatively complex meshes.
- Apply bounding-box calculation for extent also for corresponding
VecGeom wrappers.
24-January-2019 E.Tcherniaev
- Completely revised, more robust and performant G4EllipticalTube;
new exhaustive test/testEllipticalTube.cc based on Shape Conventions.
20-September-2018 G.Cosmo (geom-specific-V10-04-15)
- Make G4UPolycone wrapper inheriting from vecgeom::GenericUnplacedPolycone,
following the latest changes in VecGeom.
@@ -34,16 +34,20 @@
//
// Declaration of a CSG volume representing a tube with elliptical
// cross section (geant3 solid 'ELTU'):
//
// G4EllipticalTube( const G4String& name,
//
// G4EllipticalTube( const G4String& name,
// G4double Dx,
// G4double Dy,
// G4double Dz )
//
// The equation of the surface in x/y is 1.0 = (x/dx)**2 + (y/dy)**2
// The equation of the lateral surface : (x/dx)^2 + (y/dy)^2 = 1
// Author:
// First implementation:
// David C. Williams (davidw@scipp.ucsc.edu)
//
// Revision:
// Evgueni Tcherniaev (evgueni.tcherniaev@cern.ch), 23.12.2019
//
// --------------------------------------------------------------------
#ifndef G4EllipticalTube_hh
@@ -56,34 +60,37 @@ class G4EllipticalTube : public G4VSolid
{
public: // with description
G4EllipticalTube( const G4String &name,
G4double theDx,
G4double theDy,
G4double theDz );
G4EllipticalTube( const G4String &name,
G4double Dx,
G4double Dy,
G4double Dz );
virtual ~G4EllipticalTube();
// Standard solid methods
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
// Standard methods
//
void BoundingLimits( G4ThreeVector& pMin, G4ThreeVector& pMax ) const;
G4bool CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax ) const;
EInside Inside( const G4ThreeVector& p ) const;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const;
G4double DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const;
G4double DistanceToIn( const G4ThreeVector& p ) const;
G4double DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,
G4ThreeVector *n=0 ) const;
G4double DistanceToOut( const G4ThreeVector& p ) const;
G4GeometryType GetEntityType() const;
@@ -98,57 +105,67 @@ class G4EllipticalTube : public G4VSolid
G4ThreeVector GetPointOnSurface() const;
// Visualisation methods
//
G4Polyhedron* CreatePolyhedron() const;
G4Polyhedron* GetPolyhedron () const;
void DescribeYourselfTo( G4VGraphicsScene& scene ) const;
G4VisExtent GetExtent() const;
// Accessors
//
inline G4double GetDx() const;
inline G4double GetDy() const;
inline G4double GetDz() const;
inline void SetDx( const G4double newDx );
inline void SetDy( const G4double newDy );
inline void SetDz( const G4double newDz );
inline void SetDx( G4double Dx );
inline void SetDy( G4double Dy );
inline void SetDz( G4double Dz );
public: // without description
G4EllipticalTube(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
// persistifiable objects
G4EllipticalTube(const G4EllipticalTube& rhs);
G4EllipticalTube& operator=(const G4EllipticalTube& rhs);
// Copy constructor and assignment operator.
protected: // without description
G4double dx, dy, dz;
// Utility
inline G4double CheckXY( const G4double x,
const G4double y,
const G4double toler ) const;
inline G4double CheckXY( const G4double x, const G4double y ) const;
G4int IntersectXY( const G4ThreeVector &p,
const G4ThreeVector &v, G4double s[2] ) const;
G4EllipticalTube& operator=(const G4EllipticalTube& rhs);
// Copy constructor and assignment operator
private:
void CheckParameters();
// Check parameters and set pre-calculated values
G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
// Algorithm for SurfaceNormal() following the original
// specification for points not on the surface.
// specification for points not on the surface
G4double halfTol;
G4double GetCachedSurfaceArea() const;
// Calculate surface area and cache it
private:
G4double halfTolerance;
G4double fDx; // semi-axis in X
G4double fDy; // semi-axis in Y
G4double fDz; // half length in Z
G4double fCubicVolume; // volume
G4double fSurfaceArea; // surface area
// Cached pre-calculated values
G4double fRsph; // R of bounding sphere
G4double fDDx; // Dx squared
G4double fDDy; // Dy squared
G4double fSx; // X scale factor
G4double fSy; // Y scale factor
G4double fR; // resulting Radius, after scaling elipse to circle
G4double fQ1; // distance approximation : dist = Q1*(x^2 + y^2) - Q2
G4double fQ2; // distance approximation : dist = Q1*(x^2 + y^2) - Q2
G4double fScratch; // half length of scratching segment squared
G4double fCubicVolume;
G4double fSurfaceArea;
mutable G4bool fRebuildPolyhedron;
mutable G4Polyhedron* fpPolyhedron;
};
@@ -36,57 +36,47 @@
inline
G4double G4EllipticalTube::GetDx() const
{
return dx;
return fDx;
}
inline
G4double G4EllipticalTube::GetDy() const
{
return dy;
return fDy;
}
inline
G4double G4EllipticalTube::GetDz() const
{
return dz;
return fDz;
}
inline
void G4EllipticalTube::SetDx( const G4double newDx )
inline
void G4EllipticalTube::SetDx(G4double Dx)
{
dx = newDx;
fDx = Dx;
CheckParameters();
fCubicVolume = 0.;
fSurfaceArea = 0.;
fRebuildPolyhedron = true;
}
inline
void G4EllipticalTube::SetDy( const G4double newDy )
void G4EllipticalTube::SetDy( G4double Dy )
{
dy = newDy;
fDy = Dy;
CheckParameters();
fCubicVolume = 0.;
fSurfaceArea = 0.;
fRebuildPolyhedron = true;
}
inline
void G4EllipticalTube::SetDz( const G4double newDz )
void G4EllipticalTube::SetDz( G4double Dz )
{
dz = newDz;
fDz = Dz;
CheckParameters();
fCubicVolume = 0.;
fSurfaceArea = 0.;
fRebuildPolyhedron = true;
}
inline
G4double G4EllipticalTube::CheckXY( const G4double x,
const G4double y,
const G4double toler ) const
{
G4double rx = x/(dx+toler), ry = y/(dy+toler);
return rx*rx + ry*ry;
}
inline
G4double G4EllipticalTube::CheckXY( const G4double x, const G4double y ) const
{
G4double rx = x/dx, ry = y/dy;
return rx*rx + ry*ry;
}
@@ -132,7 +132,7 @@ class G4Tet : public G4VSolid
// Copy constructor and assignment operator.
const char* CVSHeaderVers()
{ return "$Id: G4Tet.hh 113723 2018-12-06 14:12:07Z gunter $"; }
{ return "$Id$"; }
const char* CVSFileVers()
{ return CVSVers; }
void PrintWarnings(G4bool flag)
File diff suppressed because it is too large Load Diff
@@ -25,7 +25,7 @@
//
//
//
//
//
// --------------------------------------------------------------------
// GEANT 4 class source file
//
@@ -44,45 +44,31 @@
//
G4IntersectingCone::G4IntersectingCone( const G4double r[2],
const G4double z[2] )
{
{
const G4double halfCarTolerance
= 0.5 * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
//
// What type of cone are we?
//
type1 = (std::fabs(z[1]-z[0]) > std::fabs(r[1]-r[0]));
if (type1)
type1 = (std::abs(z[1]-z[0]) > std::abs(r[1]-r[0]));
if (type1) // tube like
{
B = (r[1]-r[0])/(z[1]-z[0]); // tube like
A = 0.5*( r[1]+r[0] - B*(z[1]+z[0]) );
B = (r[1] - r[0]) / (z[1] - z[0]);
A = (r[0]*z[1] - r[1]*z[0]) / (z[1] -z[0]);
}
else
else // disk like
{
B = (z[1]-z[0])/(r[1]-r[0]); // disk like
A = 0.5*( z[1]+z[0] - B*(r[1]+r[0]) );
B = (z[1] - z[0]) / (r[1] - r[0]);
A = (z[0]*r[1] - z[1]*r[0]) / (r[1] - r[0]);
}
//
// Calculate extent
//
if (r[0] < r[1])
{
rLo = r[0]-halfCarTolerance; rHi = r[1]+halfCarTolerance;
}
else
{
rLo = r[1]-halfCarTolerance; rHi = r[0]+halfCarTolerance;
}
if (z[0] < z[1])
{
zLo = z[0]-halfCarTolerance; zHi = z[1]+halfCarTolerance;
}
else
{
zLo = z[1]-halfCarTolerance; zHi = z[0]+halfCarTolerance;
}
rLo = std::min(r[0], r[1]) - halfCarTolerance;
rHi = std::max(r[0], r[1]) + halfCarTolerance;
zLo = std::min(z[0], z[1]) - halfCarTolerance;
zHi = std::max(z[0], z[1]) + halfCarTolerance;
}
@@ -171,11 +157,11 @@ G4int G4IntersectingCone::LineHitsCone( const G4ThreeVector &p,
//
// where:
//
// a = x0**2 + y0**2 - (A + B*z0)**2
// a = tx**2 + ty**2 - (B*tz)**2
//
// b = 2*( x0*tx + y0*ty - (A*B - B*B*z0)*tz)
// b = 2*( px*vx + py*vy - B*(A + B*pz)*vz )
//
// c = tx**2 + ty**2 - (B*tz)**2
// c = x0**2 + y0**2 - (A + B*z0)**2
//
// Notice, that if a < 0, this indicates that the two solutions (assuming
// they exist) are in opposite cones (that is, given z0 = -A/B, one z < z0
@@ -191,7 +177,7 @@ G4int G4IntersectingCone::LineHitsCone( const G4ThreeVector &p,
// This should be rare.
//
// For b*b - 4*a*c = 0, we also have one solution, which is almost always
// a line just grazing the surface of a the cone, which we want to ignore.
// a line just grazing the surface of a the cone, which we want to ignore.
// However, there are two other, very rare, possibilities:
// a line intersecting the z axis and either:
// 1. At the same angle std::atan(B) to just miss one side of the cone, or
@@ -204,12 +190,12 @@ G4int G4IntersectingCone::LineHitsCone( const G4ThreeVector &p,
//
// Now: x0*tx + y0*ty = 0 in terms of roundoff error. We can write:
// Delta = x0*tx + y0*ty
// b = 2*( Delta - (A*B + B*B*z0)*tz )
// b = 2*( Delta - B*(A + B*z0)*tz )
// For:
// b*b - 4*a*c = epsilon
// where epsilon is small, then:
// Delta = epsilon/2/B
//
//
G4int G4IntersectingCone::LineHitsCone1( const G4ThreeVector &p,
const G4ThreeVector &v,
G4double *s1, G4double *s2 )
@@ -219,14 +205,34 @@ G4int G4IntersectingCone::LineHitsCone1( const G4ThreeVector &p,
G4double x0 = p.x(), y0 = p.y(), z0 = p.z();
G4double tx = v.x(), ty = v.y(), tz = v.z();
G4double a = tx*tx + ty*ty - sqr(B*tz);
G4double b = 2*( x0*tx + y0*ty - (A*B + B*B*z0)*tz);
G4double c = x0*x0 + y0*y0 - sqr(A + B*z0);
G4double radical = b*b - 4*a*c;
if (radical < -EPS*std::fabs(b)) { return 0; } // No solution
// Value of radical can be inaccurate due to loss of precision
// if to calculate the coefficiets a,b,c like the following:
// G4double a = tx*tx + ty*ty - sqr(B*tz);
// G4double b = 2*( x0*tx + y0*ty - B*(A + B*z0)*tz);
// G4double c = x0*x0 + y0*y0 - sqr(A + B*z0);
//
// For more accurate calculation of radical the coefficients
// are splitted in two components, radial and along z-axis
//
G4double ar = tx*tx + ty*ty;
G4double az = sqr(B*tz);
G4double br = 2*(x0*tx + y0*ty);
G4double bz = 2*B*(A + B*z0)*tz;
G4double cr = x0*x0 + y0*y0;
G4double cz = sqr(A + B*z0);
// Instead radical = b*b - 4*a*c
G4double arcz = 4*ar*cz;
G4double azcr = 4*az*cr;
G4double radical = (br*br - 4*ar*cr) + ((std::max(arcz,azcr) - 2*bz*br) + std::min(arcz,azcr));
// Find the coefficients
G4double a = ar - az;
G4double b = br - bz;
G4double c = cr - cz;
if (radical < -EPS*std::fabs(b)) { return 0; } // No solution
if (radical < EPS*std::fabs(b))
{
//
@@ -247,7 +253,7 @@ G4int G4IntersectingCone::LineHitsCone1( const G4ThreeVector &p,
{
radical = std::sqrt(radical);
}
if (a > 1/kInfinity)
{
G4double sa, sb, q = -0.5*( b + (b < 0 ? -radical : +radical) );
@@ -277,7 +283,7 @@ G4int G4IntersectingCone::LineHitsCone1( const G4ThreeVector &p,
}
}
//
// LineHitsCone2
//
@@ -297,7 +303,7 @@ G4int G4IntersectingCone::LineHitsCone1( const G4ThreeVector &p,
//
// a > 0 now means we intersect only once in the correct hemisphere.
//
// a > 0 ? We only want solution which produces R > 0.
// a > 0 ? We only want solution which produces R > 0.
// since R = (z0+s*tz-A)/B, for tz/B > 0, this is the largest s
// for tz/B < 0, this is the smallest s
// thus, same as in case 1 ( since sign(tz/B) = sign(tz*B) )
@@ -310,27 +316,47 @@ G4int G4IntersectingCone::LineHitsCone2( const G4ThreeVector &p,
// originally it was 1E-6
G4double x0 = p.x(), y0 = p.y(), z0 = p.z();
G4double tx = v.x(), ty = v.y(), tz = v.z();
// Special case which might not be so rare: B = 0 (precisely)
//
if (B==0)
{
if (std::fabs(tz) < 1/kInfinity) { return 0; }
*s1 = (A-z0)/tz;
return 1;
}
// Value of radical can be inaccurate due to loss of precision
// if to calculate the coefficiets a,b,c like the following:
// G4double a = tz*tz - B2*(tx*tx + ty*ty);
// G4double b = 2*( (z0-A)*tz - B2*(x0*tx + y0*ty) );
// G4double c = sqr(z0-A) - B2*( x0*x0 + y0*y0 );
//
// For more accurate calculation of radical the coefficients
// are splitted in two components, radial and along z-axis
//
G4double B2 = B*B;
G4double a = tz*tz - B2*(tx*tx + ty*ty);
G4double b = 2*( (z0-A)*tz - B2*(x0*tx + y0*ty) );
G4double c = sqr(z0-A) - B2*( x0*x0 + y0*y0 );
G4double radical = b*b - 4*a*c;
if (radical < -EPS*std::fabs(b)) { return 0; } // No solution
G4double az = tz*tz;
G4double ar = B2*(tx*tx + ty*ty);
G4double bz = 2*(z0-A)*tz;
G4double br = 2*B2*(x0*tx + y0*ty);
G4double cz = sqr(z0-A);
G4double cr = B2*(x0*x0 + y0*y0);
// Instead radical = b*b - 4*a*c
G4double arcz = 4*ar*cz;
G4double azcr = 4*az*cr;
G4double radical = (br*br - 4*ar*cr) + ((std::max(arcz,azcr) - 2*bz*br) + std::min(arcz,azcr));
// Find the coefficients
G4double a = az - ar;
G4double b = bz - br;
G4double c = cz - cr;
if (radical < -EPS*std::fabs(b)) { return 0; } // No solution
if (radical < EPS*std::fabs(b))
{
//
@@ -350,7 +376,7 @@ G4int G4IntersectingCone::LineHitsCone2( const G4ThreeVector &p,
{
radical = std::sqrt(radical);
}
if (a < -1/kInfinity)
{
G4double sa, sb, q = -0.5*( b + (b < 0 ? -radical : +radical) );
@@ -1859,18 +1859,22 @@ G4TessellatedSolid::CalculateExtent(const EAxis pAxis,
G4double& pMin, G4double& pMax) const
{
G4ThreeVector bmin, bmax;
G4bool exist;
// Check bounding box (bbox)
//
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#endif
// Use simple bounding-box to help in the case of complex meshes
//
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#if 0
// Precise extent computation (disabled by default for this shape)
//
if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
{
return exist = (pMin < pMax) ? true : false;
return (pMin < pMax) ? true : false;
}
// The extent is calculated as cumulative extent of the pyramids
@@ -1907,6 +1911,7 @@ G4TessellatedSolid::CalculateExtent(const EAxis pAxis,
if (eminlim > pMin && emaxlim < pMax) break; // max possible extent
}
return (pMin < pMax);
#endif
}
///////////////////////////////////////////////////////////////////////////////
+12 -7
View File
@@ -58,7 +58,7 @@
//#if !defined(G4GEOM_USE_UTET)
const char G4Tet::CVSVers[]="$Id: G4Tet.cc 113723 2018-12-06 14:12:07Z gunter $";
const char G4Tet::CVSVers[]="$Id$";
#include "G4VoxelLimits.hh"
#include "G4AffineTransform.hh"
@@ -328,15 +328,20 @@ G4bool G4Tet::CalculateExtent(const EAxis pAxis,
G4double& pMin, G4double& pMax) const
{
G4ThreeVector bmin, bmax;
G4bool exist;
// Check bounding box (bbox)
//
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#endif
// Use simple bounding-box to help in the case of complex 3D meshes
//
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#if 0
// Precise extent computation (disabled by default for this shape)
//
G4bool exist;
if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
{
return exist = (pMin < pMax) ? true : false;
@@ -359,8 +364,8 @@ G4bool G4Tet::CalculateExtent(const EAxis pAxis,
polygons[1] = &base;
G4BoundingEnvelope benv(bmin,bmax,polygons);
exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
return exist;
return exists = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#endif
}
/////////////////////////////////////////////////////////////////////////
@@ -326,19 +326,23 @@ G4UTessellatedSolid::CalculateExtent(const EAxis pAxis,
G4double& pMin, G4double& pMax) const
{
G4ThreeVector bmin, bmax;
G4bool exist;
G4double kCarToleranceHalf = 0.5*kCarTolerance;
// Check bounding box (bbox)
//
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#endif
// Use simple bounding-box to help in the case of complex meshes
//
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#if 0
// Precise extent computation (disabled by default for this shape)
//
G4double kCarToleranceHalf = 0.5*kCarTolerance;
if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
{
return exist = (pMin < pMax) ? true : false;
return (pMin < pMax) ? true : false;
}
// The extent is calculated as cumulative extent of the pyramids
@@ -373,6 +377,7 @@ G4UTessellatedSolid::CalculateExtent(const EAxis pAxis,
if (eminlim > pMin && emaxlim < pMax) break; // max possible extent
}
return (pMin < pMax);
#endif
}
+11 -6
View File
@@ -188,15 +188,20 @@ G4UTet::CalculateExtent(const EAxis pAxis,
G4double& pMin, G4double& pMax) const
{
G4ThreeVector bmin, bmax;
G4bool exist;
// Check bounding box (bbox)
//
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#endif
// Use simple bounding-box to help in the case of complex 3D meshes
//
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#if 0
// Precise extent computation (disabled by default for this shape)
//
G4bool exist;
if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
{
return exist = (pMin < pMax) ? true : false;
@@ -219,8 +224,8 @@ G4UTet::CalculateExtent(const EAxis pAxis,
polygons[1] = &base;
G4BoundingEnvelope benv(bmin,bmax,polygons);
exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
return exist;
return exists = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#endif
}
////////////////////////////////////////////////////////////////////////
+5
View File
@@ -16,6 +16,11 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
March 1st, 2019 G.Cosmo - geomvol-V10-04-06
- Correction in G4AssemblyVolume destructor to avoid deletion of internal
physical volumes, as cleanup is taken care by G4PhysicalVolumeStore.
Addressing problem report #2140.
October 9th, 2018 G.Cosmo - geomvol-V10-04-05, 04
- Added G4AssemblyStore singleton class for assembly structures bookeeping,
to address the specific use-case of allowing identification of assembly
@@ -260,7 +260,7 @@ _Tp* G4EnhancedVecAllocator<_Tp>::allocate(size_t _Count)
// ************************************************************
//
template<typename _T1, typename _T2>
inline bool operator==(const G4EnhancedVecAllocator<_T1>&,
inline G4bool operator==(const G4EnhancedVecAllocator<_T1>&,
const G4EnhancedVecAllocator<_T2>&)
{ return true; }
@@ -269,7 +269,7 @@ inline bool operator==(const G4EnhancedVecAllocator<_T1>&,
// ************************************************************
//
template<typename _T1, typename _T2>
inline bool operator!=(const G4EnhancedVecAllocator<_T1>&,
inline G4bool operator!=(const G4EnhancedVecAllocator<_T1>&,
const G4EnhancedVecAllocator<_T2>&)
{ return false; }
@@ -81,8 +81,8 @@ class G4LogicalBorderSurface : public G4LogicalSurface
static void DumpInfo();
// To handle the table of surfaces.
G4int operator==( const G4LogicalBorderSurface &right ) const;
G4int operator!=( const G4LogicalBorderSurface &right ) const;
G4bool operator==( const G4LogicalBorderSurface &right ) const;
G4bool operator!=( const G4LogicalBorderSurface &right ) const;
// Operators.
private:
@@ -72,8 +72,8 @@ class G4LogicalSkinSurface : public G4LogicalSurface
static void DumpInfo(); // const
// To handle with the table of surfaces.
G4int operator==(const G4LogicalSkinSurface &right) const;
G4int operator!=(const G4LogicalSkinSurface &right) const;
G4bool operator==(const G4LogicalSkinSurface &right) const;
G4bool operator!=(const G4LogicalSkinSurface &right) const;
// Operators.
private:
@@ -101,7 +101,7 @@ G4AssemblyVolume::~G4AssemblyVolume()
unsigned int howmany = fTriplets.size();
if( howmany != 0 )
{
for( unsigned int i = 0; i < howmany; i++ )
for( unsigned int i = 0; i < howmany; ++i )
{
G4RotationMatrix* pRotToClean = fTriplets[i].GetRotation();
if( pRotToClean != 0 )
@@ -112,14 +112,9 @@ G4AssemblyVolume::~G4AssemblyVolume()
}
fTriplets.clear();
howmany = fPVStore.size();
if( howmany != 0 )
{
for( unsigned int j = 0; j < howmany; j++ )
{
delete fPVStore[j];
}
}
// No need to delete physical volumes, as these are deleted
// by physical-volumes store.
//
fPVStore.clear();
InstanceCountMinus();
G4AssemblyStore::GetInstance()->DeRegister(this);
@@ -102,13 +102,13 @@ G4LogicalBorderSurface::operator=(const G4LogicalBorderSurface &right)
return *this;
}
G4int
G4bool
G4LogicalBorderSurface::operator==(const G4LogicalBorderSurface &right) const
{
return (this == (G4LogicalBorderSurface *) &right);
}
G4int
G4bool
G4LogicalBorderSurface::operator!=(const G4LogicalBorderSurface &right) const
{
return (this != (G4LogicalBorderSurface *) &right);
@@ -96,13 +96,13 @@ G4LogicalSkinSurface::operator=(const G4LogicalSkinSurface& right)
return *this;
}
G4int
G4bool
G4LogicalSkinSurface::operator==(const G4LogicalSkinSurface& right) const
{
return (this == (G4LogicalSkinSurface *) &right);
}
G4int
G4bool
G4LogicalSkinSurface::operator!=(const G4LogicalSkinSurface& right) const
{
return (this != (G4LogicalSkinSurface *) &right);