Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
+1
View File
@@ -6,6 +6,7 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2022-12-12 Ben Morgan (geometry-V11-01-00)
- Remove obsolete GNUmakefile scripts
+8
View File
@@ -6,6 +6,14 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2023-11-03 Gabriele Cosmo (field-V11-01-06)
- Reinstated default DormandPrince745 stepper.
## 2023-10-27 Lucio Santi (field-V11-01-05)
- Improvements on the QSS Stepper
The main QSS integration loop is interrupted when the number of substeps
exceeds a predefined threshold (set to 1000 by default).
## 2023-06-14 Gabriele Cosmo (field-V11-01-04)
- Applied clang-tidy fixes (readability, modernization, performance, ...).
@@ -57,7 +57,6 @@ class G4QSSDriver : public G4InterpolationDriver<T, true>
void OnComputeStep(const G4FieldTrack* track) override
{
Base::OnComputeStep(track);
for (const auto& item : this->fSteppers) { item.stepper->reset(track); }
#ifdef GEANT4_DUMP_STEPPER_STATS
this->GetStepper()->stats.steps++;
#endif
@@ -72,83 +72,29 @@ G4double G4QSSDriver<T>::AdvanceChordLimited(
// For now, just extract functionality that we don't use from G4InterpolationDriver
// We should probably end up making a custom G4QSSDriver separated from it
++this->fTotalStepsForTrack;
this->fLastStepper = this->fSteppers.begin();
// SetPrecision(10*epsStep, epsStep); // Propagate the required accuracy to QSS
const G4double curveLengthBegin = track.GetCurveLength();
const G4double hend = std::min(hstep, this->fChordStepEstimate);
G4double hdid = 0.0;
const G4double preCurveLength = track.GetCurveLength();
G4double postCurveLength = preCurveLength;
auto it = this->fSteppers.begin();
G4double dChordStep = 0.0;
it->stepper->reset(const_cast<const G4FieldTrack*>(&track));
field_utils::State yBegin, y;
track.DumpToArray(yBegin);
track.DumpToArray(y);
if (this->fFirstStep) {
Base::GetEquationOfMotion()->RightHandSide(y, this->fdydx);
this->fFirstStep = false;
}
G4double hdid = OneGoodStep(it, y, this->fdydx, hstep, epsStep, preCurveLength, &track);
postCurveLength += hdid;
if (this->fKeepLastStepper) {
std::swap(*this->fSteppers.begin(), *this->fLastStepper);
it = this->fSteppers.begin(); // new begin, update iterator
this->fLastStepper = it;
hdid = it->end - curveLengthBegin;
if (hdid > hend) {
hdid = hend;
this->InterpolateImpl(curveLengthBegin + hdid, it, y);
}
else {
field_utils::copy(y, it->stepper->GetYOut());
}
dChordStep = this->DistChord(yBegin, curveLengthBegin, y, curveLengthBegin + hdid);
++it;
}
// accurate advance & check chord distance
G4double h = this->fhnext;
for (; hdid < hend && dChordStep < chordDistance && it != this->fSteppers.end(); ++it) {
h = hstep; // h = std::min(h, hstep - hdid); <--- Omit
// make one step
hdid += OneGoodStep(it, y, this->fdydx, h, epsStep, curveLengthBegin + hdid, &track);
// update last stepper
this->fLastStepper = it;
G4double dcTmp = this->DistChord(yBegin, curveLengthBegin, y, curveLengthBegin + hdid);
// estimate chord distance
dChordStep = std::max(dChordStep, dcTmp);
// this->DistChord(yBegin, curveLengthBegin, y, curveLengthBegin + hdid) );
// std::cout << "QSSdrv: h= " << h << " hdid= " << hdid << " dcTmp= " << dcTmp << " dChord= "
// << dChordStep << std::endl;
}
// Now, either
// - full integration ( hdid >= hend )
// - estimated chord has exceeded limit 'chordDistance'
// - reached maximum number of steps (from number of steppers.)
// update step estimation
if (h > this->fMinimumStep) {
this->fhnext = h;
}
// CheckState();
G4double dChordStep = this->DistChord(yBegin, preCurveLength, y, postCurveLength);
// update chord step estimate
//
hdid = this->FindNextChord(
yBegin, curveLengthBegin, y, curveLengthBegin + hdid, dChordStep, chordDistance);
yBegin, preCurveLength, y, postCurveLength, dChordStep, chordDistance);
const G4double curveLengthEnd = curveLengthBegin + hdid;
this->fKeepLastStepper = this->fLastStepper->end - curveLengthEnd > CLHEP::perMillion;
track.LoadFromArray(y, this->fLastStepper->stepper->GetNumberOfVariables());
track.SetCurveLength(curveLengthBegin + hdid);
track.LoadFromArray(y, this->fSteppers[0].stepper->GetNumberOfVariables());
track.SetCurveLength(preCurveLength + hdid);
return hdid;
}
@@ -159,10 +105,10 @@ G4double G4QSSDriver<T>::OneGoodStep(typename G4InterpolationDriver<T, true>::St
G4double curveLength, G4FieldTrack* /*track*/)
{
G4double yerr[G4FieldTrack::ncompSVEC], ytemp[G4FieldTrack::ncompSVEC];
G4double h = hstep;
it->stepper->Stepper(y, dydx, h, ytemp, yerr);
it->stepper->Stepper(y, dydx, hstep, ytemp, yerr);
G4double h = it->stepper->GetLastStepLength();
// set interpolation inverval
// set interpolation interval
it->begin = curveLength;
it->end = curveLength + h;
it->inverseLength = 1. / h;
@@ -46,6 +46,9 @@
#include <cmath>
#include <cassert>
// Maximum allowed number of QSS substeps per integration step
#define QSS_MAX_SUBSTEPS 1000
template <class QSS>
class G4QSStepper : public G4MagIntegratorStepper
{
@@ -95,6 +98,8 @@ class G4QSStepper : public G4MagIntegratorStepper
inline const field_utils::State& GetYOut() const { return fyOut; }
inline G4double GetLastStepLength() { return fLastStepLength; }
private:
G4QSStepper(QSS* method,
@@ -263,7 +268,7 @@ inline void G4QSStepper<QSS>::Stepper(const G4double yInput[],
t = simulator->time;
index = simulator->minIndex;
while (length < max_length && t < Qss_misc::INF) {
while (length < max_length && t < Qss_misc::INF && CUR_SUBSTEP(simulator) < QSS_MAX_SUBSTEPS) {
cf0 = index * coeffs;
elapsed = t - tx[index];
method->advance_time_x(cf0, elapsed);
@@ -301,6 +306,10 @@ inline void G4QSStepper<QSS>::Stepper(const G4double yInput[],
index = simulator->minIndex;
}
if(CUR_SUBSTEP(simulator) >= QSS_MAX_SUBSTEPS) {
max_length = length;
}
auto* const substep = &LAST_SUBSTEP_STRUCT(simulator);
t = substep->start_time + (max_length - substep->len) / fVelocity;
@@ -395,7 +404,6 @@ inline void G4QSStepper<QSS>::reset(const G4FieldTrack* track)
this->update_field();
method->full_definition(get_coeff());
// TODO
method->recompute_all_state_times(0);
simulator->time = 0;
@@ -406,22 +414,13 @@ inline void G4QSStepper<QSS>::SetPrecision(G4double dq_rel, G4double dq_min)
{
G4double* dQMin = simulator->dQMin;
G4double* dQRel = simulator->dQRel;
// G4double* x = simulator->x;
G4double* lqu = simulator->lqu;
G4int n_vars = simulator->states;
// G4int coeffs = method->order() + 1;
G4int i;
if (dq_min <= 0) { dq_min = dq_rel * 1e-3;
}
if (dq_min <= 0) { dq_min = dq_rel * 1e-3; }
for (i = 0; i < n_vars; ++i) {
for (G4int i = 0; i < n_vars; ++i) {
dQRel[i] = dq_rel;
dQMin[i] = dq_min;
// lqu[i] = dQRel[i] * fabs(x[i * coeffs]); // x[i*coeffs] not always initialised!!
// if (lqu[i] < dq_min ) lqu[i] = dq_min;
lqu[i]= dq_min;
}
}
@@ -100,21 +100,18 @@ G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
G4cout << " G4ChordFinder: stepperDriverId: " << stepperDriverId << G4endl;
G4bool useFSALstepper= (stepperDriverId == kFSALStepperType); // Was 1
G4bool useFSALstepper = (stepperDriverId == kFSALStepperType); // Was 1
G4bool useTemplatedStepper= (stepperDriverId == kTemplatedStepperType); // Was 2
G4bool useRegularStepper = (stepperDriverId == kRegularStepperType); // Was 3
G4bool useBfieldDriver = (stepperDriverId == kBfieldDriverType); // Was 4
G4bool useG4QSSDriver = (stepperDriverId == kQss2DriverType) || (stepperDriverId == kQss3DriverType);
G4bool useG4QSSDriver = (stepperDriverId == kQss2DriverType) || (stepperDriverId == kQss3DriverType);
if( stepperDriverId == kQss3DriverType)
{
stepperDriverId = kQss2DriverType;
G4cout << " G4ChordFinder: QSS 3 is currently replaced by QSS 2 driver." << G4endl;
}
// --- REINSTATE after QSS testing -- to impose DEFAULT
// G4bool useDefault= (stepperDriverId == kDefaultDriverType )
// || ( !useRegularStepper && !useFSALstepper && !useTemplatedStepper && !useG4QSSDriver );
//
// useBfieldDriver |= useDefault; // Was default in release 10.6, used for 'unknown' since 10.7
// G4bool useRegularStepper = !stepperDriverId != 3) && !useFSALStepper && !useTemplatedStepper;
// If it's not 0, 1 or 2 then 'BFieldDriver' which combines DoPri5 (short) and helix is used.
using EquationType = G4Mag_UsualEqRhs;
using TemplatedStepperType =
+13
View File
@@ -6,6 +6,19 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2023-10-06 Gabriele Cosmo (geommng-V11-01-05)
- Restore virtual methods in G4TouchableHistory to allow for backwards
compatibility with visualization modeling code.
## 2023-09-04 Gabriele Cosmo (geommng-V11-01-04)
- Made G4TouchableHistoryHandle a typedef of G4TouchableHandle.
## 2023-08-31 Gabriele Cosmo (geommng-V11-01-03)
- Removed inheritance level for G4TouchableHistory and making G4VTouchable a
simple typdef of G4TouchableHistory, therefore no longer acting as base class.
- Imported G4NavigationHistory, G4NavigationHistoryPool, G4NavigationLevel and
G4NavigationLevelRep classes and translation units from "volumes" module.
## 2023-05-08 Gabriele Cosmo (geommng-V11-01-02)
- Applied clang-tidy fixes (readability, modernization, performance, ...).
@@ -42,7 +42,7 @@
class G4NavigationHistoryPool
{
public: // with description
public:
static G4NavigationHistoryPool* GetInstance();
// Return unique instance of G4NavigationHistoryPool.
@@ -49,7 +49,7 @@
class G4NavigationLevel
{
public: // with description
public:
G4NavigationLevel(G4VPhysicalVolume* newPtrPhysVol,
const G4AffineTransform& newT,
@@ -79,8 +79,6 @@ class G4NavigationLevel
inline EVolume GetVolumeType() const ;
inline G4int GetReplicaNo() const ;
public: // without description
inline const G4AffineTransform* GetPtrTransform() const;
// To try to resolve the possible problem with returning a reference.
@@ -50,7 +50,7 @@
class G4NavigationLevelRep
{
public: // with description
public:
inline G4NavigationLevelRep( G4VPhysicalVolume* newPtrPhysVol,
const G4AffineTransform& newT,
@@ -0,0 +1,151 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4TouchableHistory
//
// Class description:
//
// Object representing a touchable detector element, and its history in the
// geometrical hierarchy, including its net resultant local->global transform.
//
// Touchables are objects capable of maintaining an
// association between parts of the geometrical hierarchy (volumes
// &/or solids) and their resultant transformation.
//
// Utilisation:
// -----------
// A touchable is a geometrical volume (solid) which has a unique
// placement in a detector description. It is an abstract base class which
// can be implemented in a variety of ways. Each way must provide the
// capabilities of obtaining the transformation and solid that is described
// by the touchable.
//
// All touchable implementations must respond to the two following "requests":
//
// 1) GetTranslation and GetRotation that return the components of the
// volume's transformation.
//
// 2) GetSolid that gives the solid of this touchable.
//
//
// Additional capabilities are available from implementations with more
// information. These have a default implementation that causes an exception.
//
// Several capabilities are available from touchables with physical volumes:
//
// 3) GetVolume gives the physical volume.
//
// 4) GetReplicaNumber or GetCopyNumber gives the copy number of the
// physical volume, either if it is replicated or not.
//
// Touchables that store volume hierarchy (history) have the whole stack of
// parent volumes available. Thus it is possible to add a little more state
// in order to extend its functionality. We add a "pointer" to a level and a
// member function to move the level in this stack. Then calling the above
// member functions for another level, the information for that level can be
// retrieved.
//
// The top of the history tree is, by convention, the world volume.
//
// 5) GetHistoryDepth gives the depth of the history tree.
//
// 6) GetReplicaNumber/GetCopyNumber, GetVolume, GetTranslation and
// GetRotation each can be called with a depth argument.
// They return the value of the respective level of the touchable.
//
// 7) MoveUpHistory(num) moves the current pointer inside the touchable
// to point "num" levels up the history tree. Thus, eg, calling
// it with num=1 will cause the internal pointer to move to the mother
// of the current volume.
// NOTE: this method MODIFIES the touchable.
//
// An update method, with different arguments is available, so that the
// information in a touchable can be updated:
//
// 8) UpdateYourself takes a physical volume pointer and can additionally
// take a NavigationHistory.
// Created: Paul Kent, August 1996
// ----------------------------------------------------------------------
#ifndef G4TOUCHABLEHISTORY_HH
#define G4TOUCHABLEHISTORY_HH
#include "G4NavigationHistory.hh"
#include "G4Allocator.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
#include "geomwdefs.hh"
class G4TouchableHistory
{
public:
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( const G4NavigationHistory& history );
// Copy constructor
virtual ~G4TouchableHistory();
// Destructor
inline virtual G4VPhysicalVolume* GetVolume( G4int depth = 0 ) const;
inline virtual G4VSolid* GetSolid( G4int depth = 0 ) const;
virtual const G4ThreeVector& GetTranslation( G4int depth = 0 ) const;
virtual const G4RotationMatrix* GetRotation( G4int depth = 0 ) const;
inline virtual G4int GetReplicaNumber( G4int depth = 0 ) const;
inline G4int GetCopyNumber( G4int depth = 0 ) const;
inline virtual G4int GetHistoryDepth() const;
virtual G4int MoveUpHistory( G4int num_levels = 1 );
// Access methods for touchables with history
virtual void UpdateYourself( G4VPhysicalVolume* pPhysVol,
const G4NavigationHistory* history = nullptr );
// Update methods for touchables with history
inline virtual const G4NavigationHistory* GetHistory() const;
// Internal: used in G4Navigator::LocateGlobalPointAndSetup().
inline void* operator new(std::size_t);
inline void operator delete(void* aTH);
// Override "new" and "delete" to use "G4Allocator".
private:
inline G4int CalculateHistoryIndex( G4int stackDepth ) const;
G4RotationMatrix frot;
G4ThreeVector ftlate;
G4NavigationHistory fhistory;
};
#include "G4TouchableHistory.icc"
#endif
@@ -73,6 +73,12 @@ G4int G4TouchableHistory::GetReplicaNumber( G4int depth ) const
return fhistory.GetReplicaNo(CalculateHistoryIndex(depth));
}
inline
G4int G4TouchableHistory::GetCopyNumber(G4int depth) const
{
return GetReplicaNumber(depth);
}
inline
G4int G4TouchableHistory::GetHistoryDepth() const
{
@@ -110,7 +116,7 @@ const G4NavigationHistory* G4TouchableHistory::GetHistory() const
// If it is subclassed, this will fail and may not give errors!
//
inline
void* G4TouchableHistory::operator new(size_t)
void* G4TouchableHistory::operator new(std::size_t)
{
// Once the Navigator calls InitializeAllocator,
// the if block below can be removed.
@@ -40,9 +40,8 @@
#ifndef G4TOUCHABLEHISTORYHANDLE_HH
#define G4TOUCHABLEHISTORYHANDLE_HH 1
#include "G4TouchableHistory.hh"
#include "G4ReferenceCountedHandle.hh"
#include "G4TouchableHandle.hh"
using G4TouchableHistoryHandle = G4ReferenceCountedHandle<G4TouchableHistory>;
using G4TouchableHistoryHandle = G4TouchableHandle;
#endif // G4TOUCHABLEHISTORYHANDLE_HH
@@ -50,9 +50,9 @@
#include "G4Types.hh"
#include "G4VPVParameterisation.hh"
#include "G4VVolumeMaterialScanner.hh"
#include "G4VTouchable.hh"
class G4VPhysicalVolume;
class G4VTouchable;
class G4VSolid;
class G4Material;
@@ -41,9 +41,9 @@
#include "G4Types.hh"
#include "G4VVolumeMaterialScanner.hh"
#include "G4VTouchable.hh"
class G4VPhysicalVolume;
class G4VTouchable;
class G4VSolid;
class G4Material;
@@ -27,108 +27,15 @@
//
// Class description:
//
// Base class for `touchable' objects capable of maintaining an
// association between parts of the geometrical hierarchy (volumes
// &/or solids) and their resultant transformation.
//
// Utilisation:
// -----------
// A touchable is a geometrical volume (solid) which has a unique
// placement in a detector description. It is an abstract base class which
// can be implemented in a variety of ways. Each way must provide the
// capabilities of obtaining the transformation and solid that is described
// by the touchable.
//
// All G4VTouchable implementations must respond to the two following
// "requests":
//
// 1) GetTranslation and GetRotation that return the components of the
// volume's transformation.
//
// 2) GetSolid that gives the solid of this touchable.
//
//
// Additional capabilities are available from implementations with more
// information. These have a default implementation that causes an exception.
//
// Several capabilities are available from touchables with physical volumes:
//
// 3) GetVolume gives the physical volume.
//
// 4) GetReplicaNumber or GetCopyNumber gives the copy number of the
// physical volume, either if it is replicated or not.
//
// Touchables that store volume hierarchy (history) have the whole stack of
// parent volumes available. Thus it is possible to add a little more state
// in order to extend its functionality. We add a "pointer" to a level and a
// member function to move the level in this stack. Then calling the above
// member functions for another level, the information for that level can be
// retrieved.
//
// The top of the history tree is, by convention, the world volume.
//
// 5) GetHistoryDepth gives the depth of the history tree.
//
// 6) GetReplicaNumber/GetCopyNumber, GetVolume, GetTranslation and
// GetRotation each can be called with a depth argument.
// They return the value of the respective level of the touchable.
//
// 7) MoveUpHistory(num) moves the current pointer inside the touchable
// to point "num" levels up the history tree. Thus, eg, calling
// it with num=1 will cause the internal pointer to move to the mother
// of the current volume.
// NOTE: this method MODIFIES the touchable.
//
// An update method, with different arguments is available, so that the
// information in a touchable can be updated:
//
// 8) UpdateYourself takes a physical volume pointer and can additionally
// take a NavigationHistory.
// A G4TouchableHistory object.
// Created: Paul Kent, August 1996
// --------------------------------------------------------------------
#ifndef G4VTOUCHABLE_HH
#define G4VTOUCHABLE_HH 1
#include "G4Types.hh"
#include "G4TouchableHistory.hh"
class G4VPhysicalVolume;
class G4VSolid;
class G4NavigationHistory;
#include "G4RotationMatrix.hh"
#include "G4ThreeVector.hh"
class G4VTouchable
{
public:
G4VTouchable() = default;
virtual ~G4VTouchable() = default;
// Constructor and destructor.
virtual const G4ThreeVector& GetTranslation(G4int depth=0) const = 0;
virtual const G4RotationMatrix* GetRotation(G4int depth=0) const = 0;
// Accessors for translation and rotation.
virtual G4VPhysicalVolume* GetVolume(G4int depth=0) const;
virtual G4VSolid* GetSolid(G4int depth=0) const;
// Accessors for physical volumes and solid.
virtual G4int GetReplicaNumber(G4int depth=0) const;
inline G4int GetCopyNumber(G4int depth=0) const;
virtual G4int GetHistoryDepth() const;
virtual G4int MoveUpHistory(G4int num_levels=1);
// Methods for touchables with history.
virtual void UpdateYourself(G4VPhysicalVolume* pPhysVol,
const G4NavigationHistory* history = nullptr);
// Update method.
virtual const G4NavigationHistory* GetHistory() const;
// Method used in G4Navigator.
};
#include "G4VTouchable.icc"
using G4VTouchable = G4TouchableHistory;
#endif
@@ -1,34 +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. *
// ********************************************************************
//
// class G4VTouchable inline implementation
//
// --------------------------------------------------------------------
inline
G4int G4VTouchable::GetCopyNumber(G4int depth) const
{
return GetReplicaNumber(depth);
}
+16 -3
View File
@@ -29,6 +29,13 @@ geant4_add_module(G4geometrymng
G4LogicalVolume.hh
G4LogicalVolume.icc
G4LogicalVolumeStore.hh
G4NavigationHistory.hh
G4NavigationHistory.icc
G4NavigationHistoryPool.hh
G4NavigationLevel.hh
G4NavigationLevel.icc
G4NavigationLevelRep.hh
G4NavigationLevelRep.icc
G4PhysicalVolumeStore.hh
G4ReflectedSolid.hh
G4Region.hh
@@ -45,18 +52,20 @@ geant4_add_module(G4geometrymng
G4SmartVoxelStat.hh
G4SolidStore.hh
G4TouchableHandle.hh
G4TouchableHistory.hh
G4TouchableHistory.icc
G4TouchableHistoryHandle.hh
G4UAdapter.hh
G4VCurvedTrajectoryFilter.hh
G4VNestedParameterisation.hh
G4VPVDivisionFactory.hh
G4VPVParameterisation.hh
G4VPhysicalVolume.hh
G4VPhysicalVolume.icc
G4VPVParameterisation.hh
G4VSolid.hh
G4VSolid.icc
G4VStoreNotifier.hh
G4VTouchable.hh
G4VTouchable.icc
G4VUserRegionInformation.hh
G4VVolumeMaterialScanner.hh
G4VoxelLimits.hh
@@ -79,6 +88,10 @@ geant4_add_module(G4geometrymng
G4LogicalSurface.cc
G4LogicalVolume.cc
G4LogicalVolumeStore.cc
G4NavigationHistory.cc
G4NavigationHistoryPool.cc
G4NavigationLevel.cc
G4NavigationLevelRep.cc
G4PhysicalVolumeStore.cc
G4ReflectedSolid.cc
G4Region.cc
@@ -88,13 +101,13 @@ geant4_add_module(G4geometrymng
G4SmartVoxelProxy.cc
G4SmartVoxelStat.cc
G4SolidStore.cc
G4TouchableHistory.cc
G4VCurvedTrajectoryFilter.cc
G4VNestedParameterisation.cc
G4VPVDivisionFactory.cc
G4VPVParameterisation.cc
G4VPhysicalVolume.cc
G4VSolid.cc
G4VTouchable.cc
G4VoxelLimits.cc)
# - Add path to generated header
@@ -32,7 +32,6 @@
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VTouchable.hh"
// --------------------------------------------------------------------
G4VSolid* G4VNestedParameterisation::ComputeSolid(const G4int,
@@ -1,87 +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. *
// ********************************************************************
//
// class G4VTouchable implementation
//
// Created: Paul Kent, August 1996
// --------------------------------------------------------------------
#include "G4VTouchable.hh"
// --------------------------------------------------------------------
G4VPhysicalVolume* G4VTouchable::GetVolume(G4int) const
{
G4Exception("G4VTouchable::GetVolume()", "GeomMgt0001",
FatalException, "Undefined call to base class.");
return nullptr;
}
// --------------------------------------------------------------------
G4VSolid* G4VTouchable::GetSolid(G4int) const
{
G4Exception("G4VTouchable::GetSolid()", "GeomMgt0001",
FatalException, "Undefined call to base class.");
return nullptr;
}
// --------------------------------------------------------------------
G4int G4VTouchable::GetReplicaNumber(G4int) const
{
G4Exception("G4VTouchable::GetReplicaNumber()", "GeomMgt0001",
FatalException, "Undefined call to base class.");
return 0;
}
// --------------------------------------------------------------------
G4int G4VTouchable::MoveUpHistory(G4int)
{
G4Exception("G4VTouchable::MoveUpHistory()", "GeomMgt0001",
FatalException, "Undefined call to base class.");
return 0;
}
// --------------------------------------------------------------------
void G4VTouchable::UpdateYourself(G4VPhysicalVolume*,
const G4NavigationHistory* )
{
G4Exception("G4VTouchable::UpdateYourself()", "GeomMgt0001",
FatalException, "Undefined call to base class.");
}
// --------------------------------------------------------------------
G4int G4VTouchable::GetHistoryDepth() const
{
G4Exception("G4VTouchable::GetHistoryDepth()", "GeomMgt0001",
FatalException, "Undefined call to base class.");
return 0;
}
// --------------------------------------------------------------------
const G4NavigationHistory* G4VTouchable::GetHistory() const
{
G4Exception("G4VTouchable::GetHistory()", "GeomMgt0001",
FatalException, "Undefined call to base class.");
return nullptr;
}
+31
View File
@@ -6,6 +6,37 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2023-11-17 Gabriele Cosmo (geomnav-V11-01-08)
- Fixed "/geometry/test/check_parallel" UI command in G4GeometryMessenger.
## 2023-11-06 Gabriele Cosmo (geomnav-V11-01-07)
- Fixed uninitialised data in G4SafetyCalculator.
Addressing a reported Coverity defect.
## 2023-11-04 Gabriele Cosmo (geomnav-V11-01-06)
- Some code cleanup in G4Navigator and code formatting.
## 2023-10-30 John Apostolakis (geomnav-V11-01-05)
- Add new G4SafetyCalculator class, auxiliary to G4Navigator.
Use this in G4Navigator in ComputeSafety() to avoid saving/restoring state.
## 2023-10-12 Guilherme Amadio (geomnav-V11-01-04)
- Add new G4VNavigation common navigation interface.
- Add RelocateWithinVolume method to G4VoxelNavigation
and G4ParameterisedNavigation.
- Update existing navigators to make use of new common interface.
## 2023-09-04 Gabriele Cosmo (geomnav-V11-01-03)
- In G4Navigator, use G4TouchableHandle in place of G4TouchableHistoryHandle
which is now deprecated. Same in G4MultiNavigator, G4DrawVoxels and
G4VIntersectionLocator.
## 2023-08-31 Gabriele Cosmo (geomnav-V11-01-02)
- Removed references to unused classes G4GRSSolid and G4GRSVolume
in G4Navigator.
- Removed use of forward declarations to G4VTouchable in phantom
parameterisation classes.
## 2023-06-13 Gabriele Cosmo (geomnav-V11-01-01)
- Applied clang-tidy fixes (readability, modernization, performance, ...).
@@ -42,7 +42,7 @@
#include "G4ThreeVector.hh"
#include "G4Navigator.hh"
#include "G4TouchableHistoryHandle.hh"
#include "G4TouchableHandle.hh"
#include "G4NavigationHistory.hh"
@@ -112,7 +112,7 @@ class G4MultiNavigator : public G4Navigator
// in any geometry from the specified point in the global coordinate
// system. The geometry must be closed.
G4TouchableHistoryHandle CreateTouchableHistoryHandle() const override;
G4TouchableHandle CreateTouchableHistoryHandle() const override;
// Returns a reference counted handle to a touchable history.
G4ThreeVector GetLocalExitNormal( G4bool* obtained ) override; // const
+385 -401
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// class G4Navigator
// G4Navigator
//
// Class description:
//
@@ -37,10 +37,9 @@
// - Made Navigator Abstract G. Cosmo, Nov 2003
// - Added check mode G. Cosmo, Mar 2004
// - Zero step protections J.A. / G.C., Nov 2004
// *********************************************************************
// --------------------------------------------------------------------
#ifndef G4NAVIGATOR_HH
#define G4NAVIGATOR_HH
#define G4NAVIGATOR_HH 1
#include "geomdefs.hh"
@@ -49,10 +48,7 @@
#include "G4RotationMatrix.hh"
#include "G4LogicalVolume.hh" // Used in inline methods
#include "G4GRSVolume.hh" // " "
#include "G4GRSSolid.hh" // " "
#include "G4TouchableHandle.hh" // " "
#include "G4TouchableHistoryHandle.hh"
#include "G4NavigationHistory.hh"
#include "G4NormalNavigation.hh"
@@ -65,481 +61,469 @@
#include <iostream>
class G4VPhysicalVolume;
#define ALTERNATIVE_VOXEL_NAV 1
class G4SafetyCalculator;
class G4Navigator
{
public: // with description
public:
friend std::ostream& operator << (std::ostream &os, const G4Navigator &n);
friend std::ostream& operator << (std::ostream &os, const G4Navigator &n);
G4Navigator();
// Constructor - initialisers and setup.
G4Navigator();
// Constructor - initialisers and setup.
G4Navigator(const G4Navigator&) = delete;
G4Navigator& operator=(const G4Navigator&) = delete;
// Copy constructor & assignment operator not allowed.
G4Navigator(const G4Navigator&) = delete;
G4Navigator& operator=(const G4Navigator&) = delete;
// Copy constructor & assignment operator not allowed.
virtual ~G4Navigator();
// Destructor. No actions.
virtual ~G4Navigator();
// Destructor. No actions.
virtual G4double ComputeStep(const G4ThreeVector& pGlobalPoint,
const G4ThreeVector& pDirection,
const G4double pCurrentProposedStepLength,
G4double& pNewSafety);
// Calculate the distance to the next boundary intersected
// along the specified NORMALISED vector direction and
// from the specified point in the global coordinate
// system. LocateGlobalPointAndSetup or LocateGlobalPointWithinVolume
// must have been called with the same global point prior to this call.
// The isotropic distance to the nearest boundary is also
// calculated (usually an underestimate). The current
// proposed Step length is used to avoid intersection
// calculations: if it can be determined that the nearest
// boundary is >pCurrentProposedStepLength away, kInfinity
// is returned together with the computed isotropic safety
// distance. Geometry must be closed.
virtual G4double ComputeStep(const G4ThreeVector& pGlobalPoint,
const G4ThreeVector& pDirection,
const G4double pCurrentProposedStepLength,
G4double& pNewSafety);
// Calculate the distance to the next boundary intersected
// along the specified NORMALISED vector direction and
// from the specified point in the global coordinate
// system. LocateGlobalPointAndSetup or LocateGlobalPointWithinVolume
// must have been called with the same global point prior to this call.
// The isotropic distance to the nearest boundary is also
// calculated (usually an underestimate). The current
// proposed Step length is used to avoid intersection
// calculations: if it can be determined that the nearest
// boundary is >pCurrentProposedStepLength away, kInfinity
// is returned together with the computed isotropic safety
// distance. Geometry must be closed.
G4double CheckNextStep(const G4ThreeVector& pGlobalPoint,
const G4ThreeVector& pDirection,
const G4double pCurrentProposedStepLength,
G4double& pNewSafety);
// Same as above, but do not disturb the state of the Navigator.
G4double CheckNextStep(const G4ThreeVector& pGlobalPoint,
const G4ThreeVector& pDirection,
const G4double pCurrentProposedStepLength,
G4double& pNewSafety);
// Same as above, but do not disturb the state of the Navigator.
virtual
G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector& point,
const G4ThreeVector& direction,
const G4TouchableHistory& h);
virtual
G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector& point,
const G4ThreeVector& direction,
const G4TouchableHistory& h);
// Resets the geometrical hierarchy and search for the volumes deepest
// in the hierarchy containing the point in the global coordinate space.
// The direction is used to check if a volume is entered.
// The search begin is the geometrical hierarchy at the location of the
// last located point, or the endpoint of the previous Step if
// SetGeometricallyLimitedStep() has been called immediately before.
//
// Important Note: In order to call this the geometry MUST be closed.
// Resets the geometrical hierarchy and search for the volumes deepest
// in the hierarchy containing the point in the global coordinate space.
// The direction is used to check if a volume is entered.
// The search begin is the geometrical hierarchy at the location of the
// last located point, or the endpoint of the previous Step if
// SetGeometricallyLimitedStep() has been called immediately before.
//
// Important Note: In order to call this the geometry MUST be closed.
virtual
G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point,
const G4ThreeVector* direction = nullptr,
const G4bool pRelativeSearch = true,
const G4bool ignoreDirection = true);
// Search the geometrical hierarchy for the volumes deepest in the hierarchy
// containing the point in the global coordinate space. Two main cases are:
// i) If pRelativeSearch=false it makes use of no previous/state
// information. Returns the physical volume containing the point,
// with all previous mothers correctly set up.
// ii) If pRelativeSearch is set to true, the search begin is the
// geometrical hierarchy at the location of the last located point,
// or the endpoint of the previous Step if SetGeometricallyLimitedStep()
// has been called immediately before.
// The direction is used (to check if a volume is entered) if either
// - the argument ignoreDirection is false, or
// - the Navigator has determined that it is on an edge shared by two or
// more volumes. (This is state information.)
//
// Important Note: In order to call this the geometry MUST be closed.
virtual
G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point,
const G4ThreeVector* direction = nullptr,
const G4bool pRelativeSearch = true,
const G4bool ignoreDirection = true);
// Search the geometrical hierarchy for the volumes deepest in hierarchy
// containing the point in the global coordinate space. Two main cases
// are:
// i) If pRelativeSearch=false it makes use of no previous/state
// information. Returns the physical volume containing the point,
// with all previous mothers correctly set up.
// ii) If pRelativeSearch is set to true, the search begin is the
// geometrical hierarchy at the location of the last located point,
// or the endpoint of previous Step if SetGeometricallyLimitedStep()
// has been called immediately before.
// The direction is used (to check if a volume is entered) if either
// - the argument ignoreDirection is false, or
// - the Navigator has determined that it is on an edge shared by two
// or more volumes. (This is state information.)
//
// Important Note: In order to call this the geometry MUST be closed.
virtual
void LocateGlobalPointWithinVolume(const G4ThreeVector& position);
// Notify the Navigator that a track has moved to the new Global point
// 'position', that is known to be within the current safety.
// No check is performed to ensure that it is within the volume.
// This method can be called instead of LocateGlobalPointAndSetup ONLY if
// the caller is certain that the new global point (position) is inside the
// same volume as the previous position. Usually this can be guaranteed
// only if the point is within safety.
virtual
void LocateGlobalPointWithinVolume(const G4ThreeVector& position);
// Notify the Navigator that a track has moved to the new Global point
// 'position', that is known to be within the current safety.
// No check is performed to ensure that it is within the volume.
// This method can be called instead of LocateGlobalPointAndSetup ONLY if
// the caller is certain that the new global point (position) is inside
// the same volume as the previous position.
// Usually this can be guaranteed only if the point is within safety.
inline void LocateGlobalPointAndUpdateTouchableHandle(
const G4ThreeVector& position,
const G4ThreeVector& direction,
G4TouchableHandle& oldTouchableToUpdate,
const G4bool RelativeSearch = true);
// First, search the geometrical hierarchy like the above method
// LocateGlobalPointAndSetup(). Then use the volume found and its
// navigation history to update the touchable.
inline void LocateGlobalPointAndUpdateTouchableHandle(
const G4ThreeVector& position,
const G4ThreeVector& direction,
G4TouchableHandle& oldTouchableToUpdate,
const G4bool RelativeSearch = true);
// First, search the geometrical hierarchy like the above method
// LocateGlobalPointAndSetup(). Then use the volume found and its
// navigation history to update the touchable.
inline void LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
const G4ThreeVector& direction,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch = true);
// First, search the geometrical hierarchy like the above method
// LocateGlobalPointAndSetup(). Then use the volume found and its
// navigation history to update the touchable.
inline void LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
const G4ThreeVector& direction,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch = true);
// First, search the geometrical hierarchy like the above method
// LocateGlobalPointAndSetup(). Then use the volume found and its
// navigation history to update the touchable.
inline void LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch = true);
// Same as the method above but missing direction.
inline void LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch = true);
// Same as the method above but missing direction.
inline void SetGeometricallyLimitedStep();
// Inform the navigator that the previous Step calculated
// by the geometry was taken in its entirety.
inline void SetGeometricallyLimitedStep();
// Inform the navigator that the previous Step calculated
// by the geometry was taken in its entirety.
virtual G4double ComputeSafety(const G4ThreeVector& globalpoint,
const G4double pProposedMaxLength = DBL_MAX,
const G4bool keepState = true);
// Calculate the isotropic distance to the nearest boundary from the
// specified point in the global coordinate system.
// The globalpoint utilised must be within the current volume.
// The value returned is usually an underestimate.
// The proposed maximum length is used to avoid volume safety
// calculations. The geometry must be closed.
// To ensure minimum side effects from the call, keepState
// must be true.
virtual G4double ComputeSafety(const G4ThreeVector& globalpoint,
const G4double pProposedMaxLength = DBL_MAX,
const G4bool keepState = true);
// Calculate the isotropic distance to the nearest boundary from the
// specified point in the global coordinate system.
// The globalpoint utilised must be within the current volume.
// The value returned is usually an underestimate.
// The proposed maximum length is used to avoid volume safety
// calculations. The geometry must be closed.
// To ensure minimum side effects from the call, keepState must be true.
inline G4VPhysicalVolume* GetWorldVolume() const;
// Return the current world (`topmost') volume.
inline G4VPhysicalVolume* GetWorldVolume() const;
// Return the current world (`topmost') volume.
inline void SetWorldVolume(G4VPhysicalVolume* pWorld);
// Set the world (`topmost') volume. This must be positioned at
// origin (0,0,0) and unrotated.
inline void SetWorldVolume(G4VPhysicalVolume* pWorld);
// Set the world (`topmost') volume. This must be positioned at
// origin (0,0,0) and unrotated.
inline G4GRSVolume* CreateGRSVolume() const;
inline G4GRSSolid* CreateGRSSolid() const;
inline G4TouchableHistory* CreateTouchableHistory() const;
inline G4TouchableHistory* CreateTouchableHistory(const G4NavigationHistory*) const;
// `Touchable' creation methods: caller has deletion responsibility.
inline G4TouchableHistory* CreateTouchableHistory() const;
inline G4TouchableHistory* CreateTouchableHistory(const G4NavigationHistory*) const;
// `Touchable' creation methods: caller has deletion responsibility.
virtual G4TouchableHistoryHandle CreateTouchableHistoryHandle() const;
// Returns a reference counted handle to a touchable history.
virtual G4TouchableHandle CreateTouchableHistoryHandle() const;
// Returns a reference counted handle to a touchable history.
virtual G4ThreeVector GetLocalExitNormal(G4bool* valid);
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector& point,
G4bool* valid);
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector& point,
G4bool* valid);
// Return Exit Surface Normal and validity too.
// Can only be called if the Navigator's last Step has crossed a
// volume geometrical boundary.
// It returns the Normal to the surface pointing out of the volume that
// was left behind and/or into the volume that was entered.
// Convention:
// The *local* normal is in the coordinate system of the *final* volume.
// Restriction:
// Normals are not available for replica volumes (returns valid= false)
// These methods takes full care about how to calculate this normal,
// but if the surfaces are not convex it will return valid=false.
virtual G4ThreeVector GetLocalExitNormal(G4bool* valid);
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector& point,
G4bool* valid);
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector& point,
G4bool* valid);
// Return Exit Surface Normal and validity too.
// Can only be called if the Navigator's last Step has crossed a
// volume geometrical boundary.
// It returns the Normal to the surface pointing out of the volume that
// was left behind and/or into the volume that was entered.
// Convention:
// The *local* normal is in the coordinate system of the *final* volume.
// Restriction:
// Normals are not available for replica volumes (returns valid= false)
// These methods takes full care about how to calculate this normal,
// but if the surfaces are not convex it will return valid=false.
inline G4int GetVerboseLevel() const;
inline void SetVerboseLevel(G4int level);
// Get/Set Verbose(ness) level.
// [if level>0 && G4VERBOSE, printout can occur]
inline G4int GetVerboseLevel() const;
inline void SetVerboseLevel(G4int level);
// Get/Set Verbose(ness) level.
// [if level>0 && G4VERBOSE, printout can occur]
inline G4bool IsActive() const;
// Verify if the navigator is active.
inline void Activate(G4bool flag);
// Activate/inactivate the navigator.
inline G4bool IsActive() const;
// Verify if the navigator is active.
inline void Activate(G4bool flag);
// Activate/inactivate the navigator.
inline G4bool EnteredDaughterVolume() const;
// The purpose of this function is to inform the caller if the track is
// entering a daughter volume while exiting from the current volume.
// This method returns
// - True only in case 1) above, that is when the Step has caused
// the track to arrive at a boundary of a daughter.
// - False in cases 2), 3) and 4), i.e. in all other cases.
// This function is not guaranteed to work if SetGeometricallyLimitedStep()
// was not called when it should have been called.
inline G4bool ExitedMotherVolume() const;
// Verify if the step has exited the mother volume.
inline G4bool EnteredDaughterVolume() const;
// The purpose of this function is to inform the caller if the track is
// entering a daughter volume while exiting from the current volume.
// This method returns
// - True only in case 1) above, that is when the Step has caused
// the track to arrive at a boundary of a daughter.
// - False in cases 2), 3) and 4), i.e. in all other cases.
// This function is not guaranteed to work if SetGeometricallyLimitedStep()
// was not called when it should have been called.
inline G4bool ExitedMotherVolume() const;
// Verify if the step has exited the mother volume.
inline void CheckMode(G4bool mode);
// Run navigation in "check-mode", therefore using additional
// verifications and more strict correctness conditions.
// Is effective only with G4VERBOSE set.
inline G4bool IsCheckModeActive() const;
inline void SetPushVerbosity(G4bool mode);
// Set/unset verbosity for pushed tracks (default is true).
inline void CheckMode(G4bool mode);
// Run navigation in "check-mode", therefore using additional
// verifications and more strict correctness conditions.
// Is effective only with G4VERBOSE set.
inline G4bool IsCheckModeActive() const;
inline void SetPushVerbosity(G4bool mode);
// Set/unset verbosity for pushed tracks (default is true).
void PrintState() const;
// Print the internal state of the Navigator (for debugging).
// The level of detail is according to the verbosity.
void PrintState() const;
// Print the internal state of the Navigator (for debugging).
// The level of detail is according to the verbosity.
inline const G4AffineTransform& GetGlobalToLocalTransform() const;
inline const G4AffineTransform GetLocalToGlobalTransform() const;
// Obtain the transformations Global/Local (and inverse).
// Clients of these methods must copy the data if they need to keep it.
inline const G4AffineTransform& GetGlobalToLocalTransform() const;
inline const G4AffineTransform GetLocalToGlobalTransform() const;
// Obtain the transformations Global/Local (and inverse).
// Clients of these methods must copy the data if they need to keep it.
G4AffineTransform GetMotherToDaughterTransform(G4VPhysicalVolume* dVolume,
G4int dReplicaNo,
EVolume dVolumeType );
// Obtain mother to daughter transformation
G4AffineTransform GetMotherToDaughterTransform(G4VPhysicalVolume* dVolume,
G4int dReplicaNo,
EVolume dVolumeType );
// Obtain mother to daughter transformation.
inline void ResetStackAndState();
// Reset stack and minimum or navigator state machine necessary for reset
// as needed by LocalGlobalPointAndSetup.
// [Does not perform clears, resizes, or reset fLastLocatedPointLocal]
inline void ResetStackAndState();
// Reset stack and minimum or navigator state machine necessary for reset
// as needed by LocalGlobalPointAndSetup.
// Does not perform clears, resizes, or reset fLastLocatedPointLocal.
inline G4int SeverityOfZeroStepping( G4int* noZeroSteps ) const;
// Report on severity of error and number of zero steps,
// in case Navigator is stuck and is returning zero steps.
// Values: 1 (small problem), 5 (correcting),
// 9 (ready to abandon), 10 (abandoned)
inline G4int SeverityOfZeroStepping( G4int* noZeroSteps ) const;
// Report on severity of error and number of zero steps,
// in case Navigator is stuck and is returning zero steps.
// Values: 1 (small problem), 5 (correcting),
// 9 (ready to abandon), 10 (abandoned)
inline G4ThreeVector GetCurrentLocalCoordinate() const;
// Return the local coordinate of the point in the reference system
// of its containing volume that was found by LocalGlobalPointAndSetup.
// The local coordinate of the last located track.
inline G4ThreeVector GetCurrentLocalCoordinate() const;
// Return the local coordinate of the point in the reference system
// of its containing volume that was found by LocalGlobalPointAndSetup.
// The local coordinate of the last located track.
inline G4ThreeVector NetTranslation() const;
inline G4RotationMatrix NetRotation() const;
// Compute+return the local->global translation/rotation of current volume.
inline G4ThreeVector NetTranslation() const;
inline G4RotationMatrix NetRotation() const;
// Compute+return the local->global translation/rotation of current volume.
inline void EnableBestSafety( G4bool value = false );
// Enable best-possible evaluation of isotropic safety.
inline void EnableBestSafety( G4bool value = false );
// Enable best-possible evaluation of isotropic safety.
inline G4VExternalNavigation* GetExternalNavigation() const;
inline void SetExternalNavigation(G4VExternalNavigation* externalNav);
// Accessor & modifier for custom external navigation.
inline G4VExternalNavigation* GetExternalNavigation() const;
void SetExternalNavigation(G4VExternalNavigation* externalNav);
// Accessor & modifier for custom external navigation.
inline G4Navigator* Clone() const;
// Cloning feature for use in MT applications to clone
// navigator, including external sub-navigator.
// Client has responsibility for ownership of returned allocated pointer.
inline G4VoxelNavigation& GetVoxelNavigator();
void SetVoxelNavigation(G4VoxelNavigation* voxelNav);
// Alternative navigator for voxel volumes.
inline G4ThreeVector GetLastStepEndPoint() const { return fStepEndPoint;}
// Get endpoint of last step
inline G4Navigator* Clone() const;
// Cloning feature for use in MT applications to clone
// navigator, including external sub-navigator.
// Client has responsibility for ownership of returned allocated pointer.
void InformLastStep(G4double lastStep, G4bool entersDaughtVol, G4bool exitsMotherVol );
// Derived navigators which rely on LocateGlobalPointAndSetup
// need to inform size of step -- to maintain logic about
// arriving on boundary for challenging cases.
// Required in order to cope with multile trials at boundaries
// => Locate with use direction rather than simple, fast logic
inline G4ThreeVector GetLastStepEndPoint() const { return fStepEndPoint;}
// Get endpoint of last step.
protected: // with description
void InformLastStep(G4double lastStep,
G4bool entersDaughtVol,
G4bool exitsMotherVol );
// Derived navigators which rely on LocateGlobalPointAndSetup() need to
// inform size of step, to maintain logic about arriving on boundary
// for challenging cases.
// Required in order to cope with multiple trials at boundaries
// => Locate with use direction rather than simple, fast logic.
void SetSavedState();
// ( fValidExitNormal, fExitNormal, fExiting, fEntering,
// fBlockedPhysicalVolume, fBlockedReplicaNo, fLastStepWasZero);
// Extended to include:
// ( fLastLocatedPointLocal, fLocatedOutsideWorld;
// fEnteredDaughter, fExitedMother
// fPreviousSftOrigin, sPreviousSafety) Safety Sphere.
protected:
void RestoreSavedState();
// Copy aspects of the state, to enable a non-state changing
// call to ComputeStep().
void SetSavedState();
// ( fValidExitNormal, fExitNormal, fExiting, fEntering,
// fBlockedPhysicalVolume, fBlockedReplicaNo, fLastStepWasZero);
// Extended to include:
// ( fLastLocatedPointLocal, fLocatedOutsideWorld;
// fEnteredDaughter, fExitedMother
// fPreviousSftOrigin, sPreviousSafety) Safety Sphere.
void RestoreSavedState();
// Copy aspects of the state, to enable a non-state changing
// call to ComputeStep().
virtual void ResetState();
// Utility method to reset the navigator state machine.
virtual void ResetState();
// Utility method to reset the navigator state machine.
inline G4ThreeVector ComputeLocalPoint(const G4ThreeVector& rGlobPoint) const;
// Return position vector in local coordinate system, given a position
// vector in world coordinate system.
inline G4ThreeVector ComputeLocalPoint(const G4ThreeVector& rGlobPoint) const;
// Return position vector in local coordinate system, given a position
// vector in world coordinate system.
inline G4ThreeVector ComputeLocalAxis(const G4ThreeVector& pVec) const;
// Return the local direction of the specified vector in the reference
// system of the volume that was found by LocalGlobalPointAndSetup.
// The Local Coordinates of point in world coordinate system.
inline G4ThreeVector ComputeLocalAxis(const G4ThreeVector& pVec) const;
// Return the local direction of the specified vector in the reference
// system of the volume that was found by LocalGlobalPointAndSetup.
// The Local Coordinates of point in world coordinate system.
inline EVolume VolumeType(const G4VPhysicalVolume *pVol) const;
// Characterise `type' of volume - normal/replicated/parameterised.
inline EVolume VolumeType(const G4VPhysicalVolume *pVol) const;
// Characterise `type' of volume - normal/replicated/parameterised.
inline EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const;
// Characterise daughter of logical volume.
inline EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const;
// Characterise daughter of logical volume.
inline G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLv) const;
// Get regular structure ID of first daughter
inline G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLv) const;
// Get regular structure ID of first daughter.
virtual void SetupHierarchy();
// Renavigate & reset hierarchy described by current history
// o Reset volumes
// o Recompute transforms and/or solids of replicated/parameterised
// volumes.
virtual void SetupHierarchy();
// Renavigate & reset hierarchy described by current history:
// o Reset volumes and recompute transforms and/or solids of
// replicated/parameterised volumes.
G4bool CheckOverlapsIterative(G4VPhysicalVolume* vol);
// Utility method to trigger overlaps check on a volume with reported
// overlaps ordered by relevance. Used in ComputeStep() when loopings
// with zero step are detected.
G4bool CheckOverlapsIterative(G4VPhysicalVolume* vol);
// Utility method to trigger overlaps check on a volume with reported
// overlaps ordered by relevance. Used in ComputeStep() when loopings
// with zero step are detected.
#ifdef ALTERNATIVE_VOXEL_NAV
public:
void SetVoxelNavigation(G4VoxelNavigation *voxelNav);
// Alternative navigator for voxel volumes -- for use in integrating
// VecGeom Navigation
#endif
private:
inline G4VoxelNavigation& GetVoxelNavigator();
private:
private:
void ComputeStepLog(const G4ThreeVector& pGlobalpoint,
G4double moveLenSq) const;
// Log and checks for steps larger than the tolerance.
void ComputeStepLog(const G4ThreeVector& pGlobalpoint,
G4double moveLenSq) const;
// Log and checks for steps larger than the tolerance
protected:
protected: // without description
G4double kCarTolerance, fMinStep, fSqTol;
// Cached tolerances.
G4double kCarTolerance, fMinStep, fSqTol;
// Cached tolerances.
//
// BEGIN State information
//
//
// BEGIN State information
//
G4NavigationHistory fHistory;
// Transformation and history of the current path
// through the geometrical hierarchy.
G4NavigationHistory fHistory;
// Transformation and history of the current path
// through the geometrical hierarchy.
G4ThreeVector fStepEndPoint;
// Endpoint of last ComputeStep
// can be used for optimisation (e.g. when computing safety).
G4ThreeVector fLastStepEndPointLocal;
// Position of the end-point of the last call to ComputeStep
// in last Local coordinates.
G4ThreeVector fStepEndPoint;
// Endpoint of last ComputeStep
// can be used for optimisation (e.g. when computing safety).
G4ThreeVector fLastStepEndPointLocal;
// Position of the end-point of the last call to ComputeStep
// in last Local coordinates.
G4int fVerbose = 0;
// Verbose(ness) level [if > 0, printout can occur].
G4int fVerbose = 0;
// Verbose(ness) level [if > 0, printout can occur].
G4bool fEnteredDaughter;
// A memory of whether in this Step a daughter volume is entered
// (set in Compute & Locate).
// After Compute: it expects to enter a daughter
// After Locate: it has entered a daughter
G4bool fEnteredDaughter;
// A memory of whether in this Step a daughter volume is entered
// (set in Compute & Locate).
// After Compute: it expects to enter a daughter
// After Locate: it has entered a daughter.
G4bool fExitedMother;
// A similar memory whether the Step exited current "mother" volume
// completely, not entering daughter.
G4bool fExitedMother;
// A similar memory whether the Step exited current "mother" volume
// completely, not entering daughter.
G4bool fWasLimitedByGeometry = false;
// Set true if last Step was limited by geometry.
G4bool fWasLimitedByGeometry = false;
// Set true if last Step was limited by geometry.
private:
private:
G4ThreeVector fLastLocatedPointLocal;
// Position of the last located point relative to its containing volume.
// This is coupled with the bool member fLocatedOutsideWorld;
G4ThreeVector fLastLocatedPointLocal;
// Position of the last located point relative to its containing volume.
// This is coupled with the bool member fLocatedOutsideWorld;
G4ThreeVector fExitNormal; // Leaving volume normal, in the
// volume containing the exited
// volume's coordinate system
// This is closely coupled with G4bool fValidExitNormal - which
// signals whether we have a (valid) normal for volume we're leaving
G4ThreeVector fExitNormal;
// Leaving volume normal, in the volume containing the exited
// volume's coordinate system.
// This is closely coupled with fValidExitNormal, which signals whether
// we have a (valid) normal for volume we're leaving.
G4ThreeVector fGrandMotherExitNormal; // Leaving volume normal, in its
// own coordinate system
G4ThreeVector fExitNormalGlobalFrame; // Leaving volume normal, in the
// global coordinate system
G4ThreeVector fGrandMotherExitNormal;
// Leaving volume normal, in its own coordinate system.
G4ThreeVector fExitNormalGlobalFrame;
// Leaving volume normal, in the global coordinate system.
G4ThreeVector fPreviousSftOrigin;
G4double fPreviousSafety;
// Memory of last safety origin & value. Used in ComputeStep to ensure
// that origin of current Step is in the same volume as the point of the
// last relocation
G4ThreeVector fPreviousSftOrigin;
G4double fPreviousSafety;
// Memory of last safety origin & value. Used in ComputeStep() to ensure
// that origin of current Step is in the same volume as the point of the
// last relocation.
G4VPhysicalVolume* fLastMotherPhys = nullptr;
// Memory of the mother volume during previous step.
// Intended use: inform user in case of stuck track.
G4VPhysicalVolume* fLastMotherPhys = nullptr;
// Memory of the mother volume during previous step.
// Intended use: inform user in case of stuck track.
G4VPhysicalVolume* fBlockedPhysicalVolume;
G4int fBlockedReplicaNo;
// Identifies the volume and copy / replica number that is
// blocked (after exiting -- because the exit direction is along the exit normal)
// or a candidate for entry (after compute step.)
G4VPhysicalVolume* fBlockedPhysicalVolume;
G4int fBlockedReplicaNo;
// Identifies the volume and copy / replica number that is blocked
// (after exiting -- because the exit direction is along the exit normal)
// or a candidate for entry (after compute step).
// Count zero steps - as one or two can occur due to changing momentum at
// a boundary or at an edge common between volumes
// - several are likely a problem in the geometry
// description or in the navigation
//
G4int fNumberZeroSteps;
// Number of preceding moves that were Zero. Reset to 0 after finite step
G4int fActionThreshold_NoZeroSteps = 10;
// After this many failed/zero steps, act (push etc)
G4int fAbandonThreshold_NoZeroSteps = 25;
// After this many failed/zero steps, abandon track
G4int fNumberZeroSteps;
// Count zero steps, as one or two can occur due to changing momentum at
// a boundary or at an edge common between volumes; several zero steps
// are likely a problem in the geometry description or in the navigation.
// Number of preceding moves that were Zero. Reset to 0 after finite step.
G4int fActionThreshold_NoZeroSteps = 10;
// After this many failed/zero steps, act (push etc).
G4int fAbandonThreshold_NoZeroSteps = 25;
// After this many failed/zero steps, abandon track.
G4bool fActive = false;
// States if the navigator is activated or not.
G4bool fActive = false;
// States if the navigator is activated or not.
G4bool fLastTriedStepComputation = false;
// Whether ComputeStep was called since the last call to a Locate method
// Uses: - distinguish parts of state which differ before/after calls
// to ComputeStep or one of the Locate methods;
// - avoid two consecutive calls to compute-step (illegal).
G4bool fLastTriedStepComputation = false;
// Whether ComputeStep() was called since the last call to a Locate().
// Uses: distinguish parts of state which differ before/after calls
// to ComputeStep() or one of the Locate() methods; avoid two consecutive
// calls to compute-step (illegal).
G4bool fEntering,fExiting;
// Entering/Exiting volumes blocking/setup
// o If exiting
// volume ptr & replica number (set & used by Locate..())
// used for blocking on redescent of geometry
// o If entering
// volume ptr & replica number (set by ComputeStep(),used by
// Locate..()) of volume for `automatic' entry
G4bool fEntering, fExiting;
// Entering/Exiting volumes blocking/setup.
// o If exiting, volume ptr & replica number (set & used by Locate..())
// used for blocking on redescent of geometry;
// o If entering, volume ptr & replica number (set by ComputeStep(),
// used by Locate..()) of volume for 'automatic' entry.
G4bool fValidExitNormal; // Set true if have leaving volume normal
G4bool fLastStepWasZero;
// Whether the last ComputeStep moved Zero. Used to check for edges.
G4bool fLocatedOnEdge;
// Whether the Navigator has detected an edge
G4bool fLocatedOutsideWorld;
// Whether the last call to Locate methods left the world
G4bool fValidExitNormal;
// Set true if have leaving volume normal.
G4bool fLastStepWasZero;
// Whether the last ComputeStep moved Zero. Used to check for edges.
G4bool fLocatedOnEdge;
// Whether the Navigator has detected an edge.
G4bool fLocatedOutsideWorld;
// Whether the last call to Locate methods left the world.
G4bool fChangedGrandMotherRefFrame; // Whether frame is changed
G4bool fCalculatedExitNormal; // Has it been computed since
// the last call to ComputeStep
// Covers both Global and GrandMother
//
// END State information
//
G4bool fChangedGrandMotherRefFrame;
// Whether frame is changed.
G4bool fCalculatedExitNormal;
// Has it been computed since the last call to ComputeStep().
// Covers both Global and GrandMother.
// Optional State information (created/used as needed)
//
// END State information
//
// Optional State information (created/used as needed)
//
// Save key state information (NOT the navigation history stack)
//
struct G4SaveNavigatorState
{
G4ThreeVector sExitNormal;
G4bool sValidExitNormal;
G4bool sEntering, sExiting;
G4VPhysicalVolume* spBlockedPhysicalVolume;
G4int sBlockedReplicaNo;
G4int sLastStepWasZero;
G4bool sWasLimitedByGeometry;
// Save key state information (NOT the navigation history stack)
//
struct G4SaveNavigatorState
{
G4ThreeVector sExitNormal;
G4bool sValidExitNormal;
G4bool sEntering, sExiting;
G4VPhysicalVolume* spBlockedPhysicalVolume;
G4int sBlockedReplicaNo;
G4int sLastStepWasZero;
G4bool sWasLimitedByGeometry;
// Potentially relevant
//
G4bool sLocatedOutsideWorld;
G4ThreeVector sLastLocatedPointLocal;
G4bool sEnteredDaughter, sExitedMother;
G4ThreeVector sPreviousSftOrigin;
G4double sPreviousSafety;
} fSaveState;
// Potentially relevant
//
G4bool sLocatedOutsideWorld;
G4ThreeVector sLastLocatedPointLocal;
G4bool sEnteredDaughter, sExitedMother;
G4ThreeVector sPreviousSftOrigin;
G4double sPreviousSafety;
} fSaveState;
private:
// BEGIN -- Tracking Invariants
// ===========================================
G4VPhysicalVolume* fTopPhysical = nullptr;
// A link to the topmost physical volume in the detector.
// Must be positioned at the origin and unrotated.
// BEGIN -- Tracking Invariants
// ===========================================
// Helpers/Utility classes
//
G4NormalNavigation fnormalNav;
#ifdef ALTERNATIVE_VOXEL_NAV
G4VoxelNavigation* fpvoxelNav;
#else
G4VoxelNavigation fvoxelNav;
#endif
G4ParameterisedNavigation fparamNav;
G4ReplicaNavigation freplicaNav;
G4RegularNavigation fregularNav;
G4VExternalNavigation* fpExternalNav = nullptr;
G4VoxelSafety* fpVoxelSafety;
G4VPhysicalVolume* fTopPhysical = nullptr;
// A link to the topmost physical volume in the detector.
// Must be positioned at the origin and unrotated.
// Utility information
//
G4bool fCheck = false;
// Check-mode flag [if true, more strict checks are performed].
G4bool fPushed = false, fWarnPush = true;
// Push flags [if true, means a stuck particle has been pushed].
// Helpers/Utility classes
//
G4NormalNavigation fnormalNav;
G4VoxelNavigation* fpvoxelNav;
G4ParameterisedNavigation fparamNav;
G4ReplicaNavigation freplicaNav;
G4RegularNavigation fregularNav;
G4VExternalNavigation* fpExternalNav = nullptr;
G4VoxelSafety* fpVoxelSafety;
G4SafetyCalculator* fpSafetyCalculator = nullptr;
// End -- Tracking Invariants
// Utility information
//
G4bool fCheck = false;
// Check-mode flag [if true, more strict checks are performed].
G4bool fPushed = false, fWarnPush = true;
// Push flags [if true, means a stuck particle has been pushed].
// End -- Tracking Invariants
};
#include "G4Navigator.icc"
@@ -23,9 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// class G4Navigator Inline implementation
// G4Navigator class Inline implementation
//
// ********************************************************************
// --------------------------------------------------------------------
// ********************************************************************
// GetCurrentLocalCoordinate
@@ -215,36 +215,6 @@ G4RotationMatrix G4Navigator::NetRotation() const
return fHistory.GetTopTransform().InverseNetRotation();
}
// ********************************************************************
// CreateGRSVolume
//
// `Touchable' creation method: caller has deletion responsibility
// ********************************************************************
//
inline
G4GRSVolume* G4Navigator::CreateGRSVolume() const
{
const G4AffineTransform& tf = fHistory.GetTopTransform();
return new G4GRSVolume(fHistory.GetTopVolume(),
tf.InverseNetRotation(),
tf.InverseNetTranslation());
}
// ********************************************************************
// CreateGRSSolid
//
// `Touchable' creation method: caller has deletion responsibility
// ********************************************************************
//
inline
G4GRSSolid* G4Navigator::CreateGRSSolid() const
{
const G4AffineTransform& tf = fHistory.GetTopTransform();
return new G4GRSSolid(fHistory.GetTopVolume()->GetLogicalVolume()->GetSolid(),
tf.InverseNetRotation(),
tf.InverseNetTranslation());
}
// ********************************************************************
// CreateTouchableHistory
//
@@ -478,12 +448,9 @@ G4int G4Navigator::SeverityOfZeroStepping( G4int* noZeroSteps ) const
// ********************************************************************
//
inline
G4VoxelNavigation& G4Navigator::GetVoxelNavigator() {
#ifdef ALTERNATIVE_VOXEL_NAV
return *fpvoxelNav;
#else
return fvoxelNav;
#endif
G4VoxelNavigation& G4Navigator::GetVoxelNavigator()
{
return *fpvoxelNav;
}
// ********************************************************************
@@ -505,16 +472,6 @@ G4VExternalNavigation* G4Navigator::GetExternalNavigation() const
return fpExternalNav;
}
// ********************************************************************
// SetExternalNavigation
// ********************************************************************
//
inline
void G4Navigator::SetExternalNavigation(G4VExternalNavigation* externalNav)
{
fpExternalNav = externalNav;
}
// ********************************************************************
// Clone
// ********************************************************************
@@ -38,6 +38,7 @@
#include <iomanip>
#include "G4VNavigation.hh"
#include "G4NavigationHistory.hh"
#include "G4VPhysicalVolume.hh"
@@ -48,7 +49,7 @@
class G4NavigationLogger;
class G4NormalNavigation
class G4NormalNavigation : public G4VNavigation
{
public: // with description
@@ -64,7 +65,7 @@ class G4NormalNavigation
const G4ThreeVector &globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector &localPoint);
G4ThreeVector &localPoint) final;
// Search positioned volumes in mother at current top level of history
// for volume containing globalPoint. Do not test the blocked volume.
// If a containing volume is found, `stack' the new volume and return
@@ -82,25 +83,18 @@ class G4NormalNavigation
G4bool &exiting,
G4bool &entering,
G4VPhysicalVolume *(*pBlockedPhysical),
G4int &blockedReplicaNo );
G4int &blockedReplicaNo ) final;
G4double ComputeSafety( const G4ThreeVector &globalpoint,
const G4NavigationHistory &history,
const G4double pMaxLength=DBL_MAX );
const G4double pMaxLength=DBL_MAX ) final;
G4int GetVerboseLevel() const;
void SetVerboseLevel(G4int level);
virtual G4int GetVerboseLevel() const final;
virtual void SetVerboseLevel(G4int level) final;
// Get/Set Verbose(ness) level.
// [if level>0 && G4VERBOSE, printout can occur]
inline void CheckMode(G4bool mode);
// Run navigation in "check-mode", therefore using additional
// verifications and more strict correctness conditions.
// Is effective only with G4VERBOSE set.
private:
G4bool fCheck = false;
G4NavigationLogger* fLogger;
};
@@ -27,16 +27,6 @@
//
// --------------------------------------------------------------------
// ********************************************************************
// CheckMode
// ********************************************************************
//
inline
void G4NormalNavigation::CheckMode(G4bool mode)
{
fCheck = mode;
}
// ********************************************************************
// LevelLocate
// ********************************************************************
@@ -85,6 +85,9 @@ class G4ParameterisedNavigation : public G4VoxelNavigation
const G4NavigationHistory& history,
const G4double pProposedMaxLength=DBL_MAX ) override;
void RelocateWithinVolume( G4VPhysicalVolume* motherPhysical,
const G4ThreeVector& localPoint ) override;
private:
G4double ComputeVoxelSafety( const G4ThreeVector& localPoint,
@@ -44,9 +44,9 @@
#include "G4Types.hh"
#include "G4PhantomParameterisation.hh"
#include "G4AffineTransform.hh"
#include "G4VTouchable.hh"
class G4VPhysicalVolume;
class G4VTouchable;
class G4VSolid;
class G4Material;
@@ -43,9 +43,9 @@
#include "G4Types.hh"
#include "G4VPVParameterisation.hh"
#include "G4AffineTransform.hh"
#include "G4VTouchable.hh"
class G4VPhysicalVolume;
class G4VTouchable;
class G4VSolid;
class G4Material;
@@ -41,13 +41,14 @@
#include "G4Types.hh"
#include "G4ThreeVector.hh"
#include "G4VNavigation.hh"
class G4NormalNavigation;
class G4VPhysicalVolume;
class G4Navigator;
class G4NavigationHistory;
class G4RegularNavigation
class G4RegularNavigation : public G4VNavigation
{
public: // with description
@@ -60,7 +61,7 @@ class G4RegularNavigation
const G4ThreeVector& globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector& localPoint );
G4ThreeVector& localPoint ) final;
// Locate point using its position with respect to regular
// parameterisation container volume.
@@ -74,7 +75,7 @@ class G4RegularNavigation
G4bool& exiting,
G4bool& entering,
G4VPhysicalVolume *(*pBlockedPhysical),
G4int& blockedReplicaNo );
G4int& blockedReplicaNo ) final;
// Method never called because to be called the daughter has to be a
// 'regular' volume. This would only happen if the track is in the
// mother of voxels volume. But the voxels fill completely their mother,
@@ -100,7 +101,7 @@ class G4RegularNavigation
G4double ComputeSafety( const G4ThreeVector& localPoint,
const G4NavigationHistory& history,
const G4double pProposedMaxLength = DBL_MAX );
const G4double pProposedMaxLength = DBL_MAX ) final;
// Method never called because to be called the daughter has to be a
// 'regular' volume. This would only happen if the track is in the
// mother of voxels volume. But the voxels fill completely their mother,
@@ -108,18 +109,11 @@ class G4RegularNavigation
public: // without description
// Set and Get methods
void SetVerboseLevel(G4int level) { fverbose = level; }
void CheckMode(G4bool mode) { fcheck = mode; }
void SetNormalNavigation( G4NormalNavigation* fnormnav )
{ fnormalNav = fnormnav; }
private:
G4int fverbose = 0;
G4bool fcheck = false;
G4NormalNavigation* fnormalNav = nullptr;
G4double kCarTolerance;
G4double fMinStep;
@@ -107,8 +107,8 @@ class G4ReplicaNavigation
G4double ComputeSafety( const G4ThreeVector& globalPoint,
const G4ThreeVector& localPoint,
G4NavigationHistory& history,
const G4double pProposedMaxLength = DBL_MAX );
const G4NavigationHistory& history,
const G4double pProposedMaxLength = DBL_MAX ) const;
EInside BackLocate( G4NavigationHistory &history,
const G4ThreeVector& globalPoint,
@@ -0,0 +1,204 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4SafetyCalculator
//
// Class description:
//
// A class that provides an estimate of the isotropic safety - the
// minimum distance from a global point to the nearest boundary
// of the current volume or the nearest daughter volumes.
// This estimate can be an underestimate, either because a solid
// provides an underestimate (for speed) or in order to avoid
// substantial additional computations.
//
// Obtains from the navigator the current transformation history.
// Author: John Apostolakis, CERN - February 2023
// --------------------------------------------------------------------
#ifndef G4SafetyCalculator_HH
#define G4SafetyCalculator_HH 1
#include "geomdefs.hh"
#include "G4ThreeVector.hh"
#include "G4AffineTransform.hh"
#include "G4RotationMatrix.hh"
#include "G4LogicalVolume.hh" // Used in inline methods
#include "G4TouchableHistoryHandle.hh"
#include "G4NavigationHistory.hh"
#include "G4NormalNavigation.hh"
#include "G4VoxelNavigation.hh"
#include "G4ParameterisedNavigation.hh"
#include "G4ReplicaNavigation.hh"
#include "G4RegularNavigation.hh"
#include "G4VExternalNavigation.hh"
#include "G4VoxelSafety.hh"
#include <iostream>
class G4VPhysicalVolume;
class G4SafetyCalculator
{
public:
G4SafetyCalculator( const G4Navigator& navigator,
const G4NavigationHistory& navHistory );
// Constructor - initialisers and setup.
G4SafetyCalculator(const G4SafetyCalculator&) = delete;
G4SafetyCalculator& operator=(const G4SafetyCalculator&) = delete;
// Copy constructor & assignment operator not allowed.
~G4SafetyCalculator() = default;
// Destructor. No actions.
G4double SafetyInCurrentVolume(const G4ThreeVector& globalpoint,
G4VPhysicalVolume* physicalVolume,
const G4double pProposedMaxLength = DBL_MAX,
G4bool verbose = false );
// Calculate the isotropic distance to the nearest boundary from the
// specified point in the global coordinate system.
// The globalpoint utilised *must* be located exactly within the
// current volume (it also must *not* be in a daughter volume).
// The value returned can be an underestimate (and typically will be
// if complex volumes are involved).
// The calculation will not look beyond the proposed maximum length
// to avoid extra volume safety calculations. The geometry must be closed.
G4VExternalNavigation* GetExternalNavigation() const;
void SetExternalNavigation(G4VExternalNavigation* externalNav);
// Accessor & modifier for custom external navigation.
void CompareSafetyValues( G4double oldSafety,
G4double newValue,
G4VPhysicalVolume* motherPhysical,
const G4ThreeVector &globalPoint,
G4bool keepState,
G4double maxLength,
G4bool enteredVolume,
G4bool exitedVolume );
// Compare estimates of the safety, and report if difference(s) found.
protected:
void QuickLocateWithinVolume(const G4ThreeVector& pointLocal,
G4VPhysicalVolume* motherPhysical);
// Prepare state of sub-navigators by informing them of current point.
inline G4ThreeVector ComputeLocalPoint(const G4ThreeVector& rGlobPoint) const;
// Return position vector in local coordinate system, given a position
// vector in world coordinate system.
inline G4ThreeVector ComputeLocalAxis(const G4ThreeVector& pVec) const;
// Return the local direction of the specified vector in the reference
// system of the volume that was found by LocalGlobalPointAndSetup().
// The Local Coordinates of point in world coordinate system.
inline EVolume CharacteriseDaughters(const G4LogicalVolume* pLog) const;
// Characterise daughter of logical volume.
inline G4int GetDaughtersRegularStructureId(const G4LogicalVolume* pLv) const;
// Get regular structure ID of first daughter.
private:
// BEGIN -- Tracking Invariants part 1
//
const G4Navigator& fNavigator;
// Associated navigator. Needed for details of current state,
// for optimisation
const G4NavigationHistory& fNavHistory;
// Associated navigator's navigation history. Transformation and history
// of the current path through the geometrical hierarchy.
//
// END -- Tracking Invariants part 1
G4double fkCarTolerance;
// Cached tolerance.
// BEGIN State information
//
G4ThreeVector fPreviousSftOrigin;
G4double fPreviousSafety = 0.0;
// Memory of last safety origin & value. Used in ComputeStep to ensure
// that origin of current Step is in the same volume as the point of the
// last relocation.
// Helpers/Utility classes - their state can change
//
G4NormalNavigation fnormalNav;
G4VoxelNavigation fvoxelNav;
G4ParameterisedNavigation fparamNav;
G4ReplicaNavigation freplicaNav;
G4RegularNavigation fregularNav;
G4VExternalNavigation* fpExternalNav = nullptr;
G4VoxelSafety fVoxelSafety;
};
// Auxiliary inline methods -- copied from G4Navigator
// Return local coordinates given point in the world coord system.
//
inline G4ThreeVector
G4SafetyCalculator::ComputeLocalPoint(const G4ThreeVector& pGlobalPoint) const
{
return fNavHistory.GetTopTransform().TransformPoint(pGlobalPoint);
}
// Returns local direction given vector direction in world coord system.
//
inline G4ThreeVector
G4SafetyCalculator::ComputeLocalAxis(const G4ThreeVector& pVec) const
{
return fNavHistory.GetTopTransform().TransformAxis(pVec);
}
inline EVolume
G4SafetyCalculator::CharacteriseDaughters(const G4LogicalVolume* pLog) const
{
return pLog->CharacteriseDaughters();
}
inline G4int
G4SafetyCalculator::GetDaughtersRegularStructureId(const G4LogicalVolume* pLog) const
{
G4int regId = 0;
G4VPhysicalVolume *pVol;
if ( pLog->GetNoDaughters() == 1 )
{
pVol = pLog->GetDaughter(0);
regId = pVol->GetRegularStructureId();
}
return regId;
}
#endif
@@ -35,13 +35,14 @@
#ifndef G4VEXTERNALNAVIGATION_HH
#define G4VEXTERNALNAVIGATION_HH
#include "G4NavigationHistory.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4NavigationHistory.hh"
#include "G4ThreeVector.hh"
#include "G4VNavigation.hh"
#include "G4VPhysicalVolume.hh"
#include "G4VSolid.hh"
class G4VExternalNavigation
class G4VExternalNavigation : public G4VNavigation
{
public: // with description
@@ -50,45 +51,6 @@ class G4VExternalNavigation
virtual ~G4VExternalNavigation();
// Destructor
virtual G4bool LevelLocate( G4NavigationHistory& history,
const G4VPhysicalVolume* blockedVol,
const G4int blockedNum,
const G4ThreeVector& globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector& localPoint) = 0;
// Search positioned volumes in mother at current top level of history
// for volume containing globalPoint. Do not test the blocked volume.
// If a containing volume is found, `stack' the new volume and return
// true, else return false (the point lying in the mother but not any
// of the daughters). localPoint = global point in local system on entry,
// point in new system on exit.
virtual G4double ComputeStep( const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double currentProposedStepLength,
G4double& newSafety,
G4NavigationHistory& history,
G4bool& validExitNormal,
G4ThreeVector& exitNormal,
G4bool& exiting,
G4bool& entering,
G4VPhysicalVolume** pBlockedPhysical,
G4int& blockedReplicaNo ) = 0;
// Compute the length of a step to the next boundary.
// Ignore the (input) pBlockedPhysical volume (with replica/parameterisation
// number 'blockedReplica')
// Identify the next candidate volume (if a daughter of current volume),
// and return it in pBlockedPhysical, blockedReplicaNo
// In/Out Navigation history: to be update for volume of next intersection.
// In/out 'newsafety' is the known isotropic safety of the initial point:
// an earlier (likely crude) estimate on input,
// to be updated with new estimate for the same (start) point.
virtual G4double ComputeSafety( const G4ThreeVector& globalpoint,
const G4NavigationHistory& history,
const G4double pMaxLength = DBL_MAX ) = 0;
virtual G4VExternalNavigation* Clone() = 0;
@@ -105,20 +67,6 @@ class G4VExternalNavigation
// Update any relevant internal state to take account that
// - the location has been moved to 'localPoint'
// - it remains in the current (mother) physical volume 'motherPhysical'
inline G4int GetVerboseLevel() const { return fVerbose; }
inline void SetVerboseLevel(G4int level) { fVerbose = level; }
// Get/Set verbosity level.
inline void CheckMode(G4bool mode) { fCheck = mode; }
// Run navigation in "check-mode", therefore using additional
// verifications and more strict correctness conditions.
// Should be effective only with G4VERBOSE set.
protected:
G4bool fCheck = false;
G4int fVerbose = 0;
};
#endif
@@ -0,0 +1,151 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// class G4VNavigation
//
// Class description:
//
// Navigation interface common between all navigator types.
// Author: G. Amadio - CERN, March 2022
// --------------------------------------------------------------------
#ifndef G4VNAVIGATION_HH
#define G4VNAVIGATION_HH
#include "G4ThreeVector.hh"
class G4LogicalVolume;
class G4VPhysicalVolume;
class G4NavigationHistory;
/**
* @brief G4VNavigation class holds the common navigation interface
* for all geometry navigator types.
*/
class G4VNavigation
{
public:
/** Virtual Destructor. */
virtual ~G4VNavigation() {}
/**
* Search positioned volumes in mother at current top level of @p history
* for volume containing @p globalPoint. Do not test against @p blockedVol.
* If a containing volume is found, push it onto navigation history state.
* @param[in,out] history Navigation history.
* @param[in,out] blockedVol Blocked volume that should be ignored in queries.
* @param[in,out] blockedNum Copy number for blocked replica volumes.
* @param[in,out] globalPoint Global point
* @param[in,out] globalDirection Pointer to global direction or null pointer.
* @param[in,out] localPoint = global point in local system on entry, point
* in new system on exit.
* @returns Whether a containing volume has been found.
*/
virtual G4bool LevelLocate(G4NavigationHistory& history,
const G4VPhysicalVolume* blockedVol,
const G4int blockedNum,
const G4ThreeVector& globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector& localPoint) = 0;
/**
* Compute the length of a step to the next boundary.
* Do not test against @p pBlockedPhysical. Identify the next candidate volume
* (if a daughter of current volume), and return it in pBlockedPhysical,
* blockedReplicaNo.
* @param[in] localPoint Local point
* @param[in] localDirection Pointer to local direction or null pointer.
* @param[in] currentProposedStepLength Current proposed step length.
* @param[in,out] newSafety New safety.
* @param[in,out] history Navigation history.
* @param[in,out] validExitNormal Flag to indicate whether exit normal is
* valid or not.
* @param[in,out] exitNormal Exit normal.
* @param[in,out] entering Flag to indicate whether we are entering a volume.
* @param[in,out] exiting Flag to indicate whether we are exiting a volume.
* @param[in,out] pBlockedPhysical Blocked physical volume that should be
* ignored in queries.
* @param[in,out] blockedReplicaNo Copy number for blocked replica volumes.
* @returns Length from current point to next boundary surface along @p
* localDirection.
*/
virtual G4double ComputeStep(const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double currentProposedStepLength,
G4double& newSafety,
G4NavigationHistory& history,
G4bool& validExitNormal,
G4ThreeVector& exitNormal,
G4bool& exiting,
G4bool& entering,
G4VPhysicalVolume*(*pBlockedPhysical),
G4int& blockedReplicaNo) = 0;
/**
* Compute the distance to the closest surface.
* @param[in] globalPoint Global point.
* @param[in] history Navigation history.
* @param[in] pMaxLength Maximum step length beyond which volumes need not be
* checked.
* @returns Length from current point to closest surface.
*/
virtual G4double ComputeSafety(const G4ThreeVector& globalpoint,
const G4NavigationHistory& history,
const G4double pMaxLength = DBL_MAX) = 0;
/**
* Update internal navigation state to take into account that location
* has been moved, but remains within the @p motherPhysical volume.
* @param[in] motherPhysical Current physical volume.
* @param[in] localPoint Local point.
*/
virtual void RelocateWithinVolume(G4VPhysicalVolume* /* motherPhysical */,
const G4ThreeVector& /* localPoint */)
{
/* do nothing by default */
}
/** Get current verbosity level */
virtual G4int GetVerboseLevel() const { return fVerbose; }
/** Set current verbosity level */
virtual void SetVerboseLevel(G4int level) { fVerbose = level; }
/**
* Set check mode.
* When enabled, forces navigator to run in "check mode", hence using
* additional verifications and stricter condictions for ensuring correctness.
* Effective only when G4VERBOSE is enabled.
*/
void CheckMode(G4bool mode) { fCheck = mode; }
protected:
G4int fVerbose = 0;
G4bool fCheck = false;
};
#endif
@@ -37,6 +37,7 @@
#define G4VOXELNAVIGATION_HH
#include "geomdefs.hh"
#include "G4VNavigation.hh"
#include "G4NavigationHistory.hh"
#include "G4NavigationLogger.hh"
#include "G4AffineTransform.hh"
@@ -60,7 +61,7 @@ class G4VoxelSafety;
#include "G4SmartVoxelNode.hh"
#include "G4SmartVoxelHeader.hh"
class G4VoxelNavigation
class G4VoxelNavigation : public G4VNavigation
{
public: // with description
@@ -76,7 +77,7 @@ class G4VoxelNavigation
const G4ThreeVector& globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector& localPoint );
G4ThreeVector& localPoint ) override;
virtual G4double ComputeStep( const G4ThreeVector& globalPoint,
const G4ThreeVector& globalDirection,
@@ -88,22 +89,20 @@ class G4VoxelNavigation
G4bool& exiting,
G4bool& entering,
G4VPhysicalVolume* (*pBlockedPhysical),
G4int& blockedReplicaNo );
G4int& blockedReplicaNo ) override;
virtual G4double ComputeSafety( const G4ThreeVector& globalpoint,
const G4NavigationHistory& history,
const G4double pMaxLength = DBL_MAX );
const G4double pMaxLength = DBL_MAX ) override;
inline G4int GetVerboseLevel() const;
void SetVerboseLevel(G4int level);
virtual void RelocateWithinVolume( G4VPhysicalVolume* motherPhysical,
const G4ThreeVector& localPoint ) override;
virtual G4int GetVerboseLevel() const override;
virtual void SetVerboseLevel(G4int level) override;
// Get/Set Verbose(ness) level.
// [if level>0 && G4VERBOSE, printout can occur]
inline void CheckMode(G4bool mode);
// Run navigation in "check-mode", therefore using additional
// verifications and more strict correctness conditions.
// Is effective only with G4VERBOSE set.
inline void EnableBestSafety( G4bool flag = false );
// Enable best-possible evaluation of isotropic safety
@@ -182,7 +181,6 @@ class G4VoxelNavigation
G4double fHalfTolerance;
// Surface tolerance
G4bool fCheck = false;
G4bool fBestSafety = false;
G4NavigationLogger* fLogger;
@@ -163,16 +163,6 @@ G4int G4VoxelNavigation::GetVerboseLevel() const
return fLogger->GetVerboseLevel();
}
// ********************************************************************
// CheckMode
// ********************************************************************
//
inline
void G4VoxelNavigation::CheckMode(G4bool mode)
{
fCheck = mode;
}
// ********************************************************************
// EnableBestSafety
// ********************************************************************
+5 -2
View File
@@ -32,6 +32,7 @@ geant4_add_module(G4navigation
G4RegularNavigationHelper.hh
G4ReplicaNavigation.hh
G4ReplicaNavigation.icc
G4SafetyCalculator.hh
G4SafetyHelper.hh
G4SimpleLocator.hh
G4TransportationManager.hh
@@ -39,6 +40,7 @@ geant4_add_module(G4navigation
G4VExternalNavigation.hh
G4VIntersectionLocator.hh
G4VIntersectionLocator.icc
G4VNavigation.hh
G4VoxelNavigation.hh
G4VoxelNavigation.icc
G4VoxelSafety.hh
@@ -65,6 +67,7 @@ geant4_add_module(G4navigation
G4RegularNavigation.cc
G4RegularNavigationHelper.cc
G4ReplicaNavigation.cc
G4SafetyCalculator.cc
G4SafetyHelper.cc
G4SimpleLocator.cc
G4TransportationManager.cc
@@ -74,5 +77,5 @@ geant4_add_module(G4navigation
G4VoxelSafety.cc)
geant4_module_link_libraries(G4navigation
PUBLIC G4geometrymng G4magneticfield G4volumes G4graphics_reps G4globman G4intercoms G4hepgeometry
PRIVATE G4materials)
PUBLIC G4geometrymng G4magneticfield G4graphics_reps G4globman G4intercoms G4hepgeometry
PRIVATE G4volumes G4materials)
@@ -38,7 +38,7 @@
#include "G4VVisManager.hh"
#include "G4Colour.hh"
#include "G4TransportationManager.hh"
#include "G4TouchableHistoryHandle.hh"
#include "G4TouchableHandle.hh"
#define voxel_width 0
@@ -203,7 +203,7 @@ void G4DrawVoxels::DrawVoxels(const G4LogicalVolume* lv) const
// (the drawing is directly in the world volume while the axis
// are relative to the mother volume of lv's daughter.)
G4TouchableHistoryHandle aTouchable =
G4TouchableHandle aTouchable =
G4TransportationManager::GetTransportationManager()->
GetNavigatorForTracking()->CreateTouchableHistoryHandle();
G4AffineTransform globTransform =
@@ -179,8 +179,8 @@ G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
G4GeometryMessenger::~G4GeometryMessenger()
{
delete verCmd; delete recCmd; delete rslCmd;
delete resCmd; delete rcsCmd; delete rcdCmd; delete errCmd;
delete tolCmd;
delete resCmd; delete rcsCmd; delete rcdCmd;
delete errCmd; delete parCmd; delete tolCmd;
delete verbCmd; delete pchkCmd; delete chkCmd;
delete geodir; delete navdir; delete testdir;
for(auto* tvolume: tvolumes) {
@@ -258,6 +258,9 @@ G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
else if (command == rcdCmd) {
recDepth = rcdCmd->GetNewIntValue( newValues );
}
else if (command == parCmd) {
checkParallelWorlds = parCmd->GetNewBoolValue( newValues );
}
else if (command == errCmd) {
Init();
for(auto* tvolume: tvolumes)
@@ -442,8 +442,7 @@ G4double G4MultiNavigator::ComputeSafety( const G4ThreeVector& position,
// -----------------------------------------------------------------------
G4TouchableHistoryHandle
G4MultiNavigator::CreateTouchableHistoryHandle() const
G4TouchableHandle G4MultiNavigator::CreateTouchableHistoryHandle() const
{
G4Exception( "G4MultiNavigator::CreateTouchableHistoryHandle()",
"GeomNav0001", FatalException,
+34 -148
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// class G4Navigator Implementation
// G4Navigator class Implementation
//
// Original author: Paul Kent, July 95/96
// Responsible 1996-present: John Apostolakis, Gabriele Cosmo
@@ -39,6 +39,7 @@
#include "G4VPhysicalVolume.hh"
#include "G4VoxelSafety.hh"
#include "G4SafetyCalculator.hh"
// Constant determining how precise normals should be (how close to unit
// vectors). If exceeded, warnings will be issued.
@@ -76,9 +77,9 @@ G4Navigator::G4Navigator()
fLastStepEndPointLocal = G4ThreeVector( kInfinity, kInfinity, kInfinity );
fpVoxelSafety = new G4VoxelSafety();
#ifdef ALTERNATIVE_VOXEL_NAV
fpvoxelNav = new G4VoxelNavigation();
#endif
fpSafetyCalculator = new G4SafetyCalculator( *this, fHistory );
fpSafetyCalculator->SetExternalNavigation(fpExternalNav);
}
// ********************************************************************
@@ -89,9 +90,8 @@ G4Navigator::~G4Navigator()
{
delete fpVoxelSafety;
delete fpExternalNav;
#ifdef ALTERNATIVE_VOXEL_NAV
delete fpvoxelNav;
#endif
delete fpSafetyCalculator;
}
// ********************************************************************
@@ -619,23 +619,14 @@ G4Navigator::LocateGlobalPointWithinVolume(const G4ThreeVector& pGlobalpoint)
//
G4VPhysicalVolume* motherPhysical = fHistory.GetTopVolume();
G4LogicalVolume* motherLogical = motherPhysical->GetLogicalVolume();
G4SmartVoxelHeader* pVoxelHeader = motherLogical->GetVoxelHeader();
switch( CharacteriseDaughters(motherLogical) )
{
case kNormal:
if ( pVoxelHeader != nullptr )
{
GetVoxelNavigator().VoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
}
GetVoxelNavigator().RelocateWithinVolume( motherPhysical, fLastLocatedPointLocal );
break;
case kParameterised:
if( GetDaughtersRegularStructureId(motherLogical) != 1 )
{
// Resets state & returns voxel node
//
fparamNav.ParamVoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
}
fparamNav.RelocateWithinVolume( motherPhysical, fLastLocatedPointLocal );
break;
case kReplica:
// Nothing to do
@@ -1605,7 +1596,6 @@ G4Navigator::GetLocalExitNormalAndCheck(
return GetLocalExitNormal( pValid );
}
// ********************************************************************
// GetGlobalExitNormal
//
@@ -1787,151 +1777,38 @@ G4Navigator::GetGlobalExitNormal(const G4ThreeVector& IntersectPointGlobal,
//
G4double G4Navigator::ComputeSafety( const G4ThreeVector& pGlobalpoint,
const G4double pMaxLength,
const G4bool keepState)
const G4bool )
{
#ifdef G4DEBUG_NAVIGATION
G4int oldcoutPrec = G4cout.precision(8);
if( fVerbose > 0 )
{
G4cout << "*** G4Navigator::ComputeSafety: ***" << G4endl
<< " Called at point: " << pGlobalpoint << G4endl;
G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
G4cout << " Volume = " << motherPhysical->GetName()
<< " - Maximum length = " << pMaxLength << G4endl;
if( fVerbose >= 4 )
{
G4cout << " ----- Upon entering Compute Safety:" << G4endl;
PrintState();
}
}
#endif
G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
G4double safety = 0.0;
G4double distEndpointSq = (pGlobalpoint-fStepEndPoint).mag2();
G4bool stayedOnEndpoint = distEndpointSq < sqr(kCarTolerance);
G4bool endpointOnSurface = fEnteredDaughter || fExitedMother;
if( endpointOnSurface && stayedOnEndpoint )
G4bool onSurface = endpointOnSurface && stayedOnEndpoint;
if( ! onSurface )
{
#ifdef G4DEBUG_NAVIGATION
if( fVerbose >= 2 )
{
G4cout << " G4Navigator::ComputeSafety() finds that point - "
<< pGlobalpoint << " - is on surface " << G4endl;
if( fEnteredDaughter ) { G4cout << " entered new daughter volume"; }
if( fExitedMother ) { G4cout << " and exited previous volume."; }
G4cout << G4endl;
G4cout << " EndPoint was = " << fStepEndPoint << G4endl;
G4cout << " ---- Exiting ComputeSafety " << G4endl;
PrintState();
G4cout << " Returned value of Safety is zero " << G4endl;
G4cout.precision(oldcoutPrec);
}
#endif
return 0.0;
}
safety= fpSafetyCalculator->SafetyInCurrentVolume(pGlobalpoint, motherPhysical, pMaxLength);
// offload to G4SafetyCalculator - avoids need to save / reload state
G4double newSafety = 0.0;
if (keepState) { SetSavedState(); }
// Pseudo-relocate to this point (updates voxel information only)
//
LocateGlobalPointWithinVolume( pGlobalpoint );
// --->> DANGER: Side effects on sub-navigator voxel information <<---
// Could be replaced again by 'granular' calls to sub-navigator
// locates (similar side-effects, but faster.
// Solutions:
// 1) Re-locate (to where?)
// 2) Insure that the methods using (G4ComputeStep?)
// does a relocation (if information is disturbed only ?)
#ifdef G4DEBUG_NAVIGATION
if( fVerbose >= 2 )
{
G4cout << " G4Navigator::ComputeSafety() relocates-in-volume to point: "
<< pGlobalpoint << G4endl;
}
#endif
G4VPhysicalVolume* motherPhysical = fHistory.GetTopVolume();
G4LogicalVolume* motherLogical = motherPhysical->GetLogicalVolume();
G4SmartVoxelHeader* pVoxelHeader = motherLogical->GetVoxelHeader();
G4ThreeVector localPoint = ComputeLocalPoint(pGlobalpoint);
if ( fHistory.GetTopVolumeType() != kReplica )
{
switch(CharacteriseDaughters(motherLogical))
{
case kNormal:
if ( pVoxelHeader != nullptr )
{
newSafety = fpVoxelSafety->ComputeSafety(localPoint,
*motherPhysical, pMaxLength);
// = VoxelNav().ComputeSafety(localPoint,fHistory,pMaxLength); // - Old method
}
else
{
newSafety=fnormalNav.ComputeSafety(localPoint,fHistory,pMaxLength);
}
break;
case kParameterised:
if( GetDaughtersRegularStructureId(motherLogical) != 1 )
{
newSafety=fparamNav.ComputeSafety(localPoint,fHistory,pMaxLength);
}
else // Regular structure
{
newSafety=fregularNav.ComputeSafety(localPoint,fHistory,pMaxLength);
}
break;
case kReplica:
G4Exception("G4Navigator::ComputeSafety()", "GeomNav0001",
FatalException, "Not applicable for replicated volumes.");
break;
case kExternal:
newSafety = fpExternalNav->ComputeSafety(localPoint, fHistory,
pMaxLength);
break;
}
}
else
{
newSafety = freplicaNav.ComputeSafety(pGlobalpoint, localPoint,
fHistory, pMaxLength);
}
if (keepState)
{
RestoreSavedState();
// This now overwrites the values of the Safety 'sphere' (correction)
}
// Remember last safety origin & value
//
// We overwrite the Safety 'sphere' - keeping old behaviour
fPreviousSftOrigin = pGlobalpoint;
fPreviousSafety = newSafety;
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 1 )
{
G4cout << " ---- Exiting ComputeSafety " << G4endl;
if( fVerbose > 2 ) { PrintState(); }
G4cout << " Returned value of Safety = " << newSafety << G4endl;
fPreviousSafety = safety;
// We overwrite the Safety 'sphere' - keeping old behaviour
}
G4cout.precision(oldcoutPrec);
#endif
return newSafety;
return safety;
}
// ********************************************************************
// CreateTouchableHistoryHandle
// ********************************************************************
//
G4TouchableHistoryHandle G4Navigator::CreateTouchableHistoryHandle() const
G4TouchableHandle G4Navigator::CreateTouchableHistoryHandle() const
{
return { CreateTouchableHistory() };
return G4TouchableHandle( CreateTouchableHistory() );
}
// ********************************************************************
@@ -2202,9 +2079,8 @@ std::ostream& operator << (std::ostream &os,const G4Navigator &n)
return os;
}
#ifdef ALTERNATIVE_VOXEL_NAV
// ********************************************************************
// SetVoxelNavigation -- alternative navigator for Voxel geom
// SetVoxelNavigation: alternative navigator for voxelised geometry
// ********************************************************************
//
void G4Navigator::SetVoxelNavigation(G4VoxelNavigation* voxelNav)
@@ -2212,13 +2088,13 @@ void G4Navigator::SetVoxelNavigation(G4VoxelNavigation* voxelNav)
delete fpvoxelNav;
fpvoxelNav = voxelNav;
}
#endif
// ********************************************************************
// InformLastStep: Derived navigators can inform of its step
// - used to update fLastStepWasZero
// InformLastStep: derived navigators can inform of its step
// used to update fLastStepWasZero
// ********************************************************************
void G4Navigator::InformLastStep(G4double lastStep, G4bool entersDaughtVol, G4bool exitsMotherVol )
void G4Navigator::InformLastStep(G4double lastStep, G4bool entersDaughtVol,
G4bool exitsMotherVol)
{
G4bool zeroStep = ( lastStep == 0.0 );
fLocatedOnEdge = fLastStepWasZero && zeroStep;
@@ -2227,3 +2103,13 @@ void G4Navigator::InformLastStep(G4double lastStep, G4bool entersDaughtVol, G4b
fExiting = exitsMotherVol;
fEntering = entersDaughtVol;
}
// ********************************************************************
// SetExternalNavigation
// ********************************************************************
//
void G4Navigator::SetExternalNavigation(G4VExternalNavigation* externalNav)
{
fpExternalNav = externalNav;
fpSafetyCalculator->SetExternalNavigation(externalNav);
}
@@ -49,6 +49,8 @@
#include "G4AuxiliaryNavServices.hh"
#include <cassert>
// ********************************************************************
// Constructor
// ********************************************************************
@@ -683,3 +685,16 @@ G4ParameterisedNavigation::LevelLocate( G4NavigationHistory& history,
}
return false;
}
void G4ParameterisedNavigation::RelocateWithinVolume( G4VPhysicalVolume* motherPhysical,
const G4ThreeVector& localPoint )
{
auto motherLogical = motherPhysical->GetLogicalVolume();
/* this should only be called on parameterized volumes, which always satisfy the conditions below */
assert(motherPhysical->GetRegularStructureId() != 1);
assert(motherLogical->GetNoDaughters() == 1);
if ( auto pVoxelHeader = motherLogical->GetVoxelHeader() )
ParamVoxelLocate( pVoxelHeader, localPoint );
}
@@ -1154,8 +1154,8 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector& globalPoint,
G4double
G4ReplicaNavigation::ComputeSafety(const G4ThreeVector& globalPoint,
const G4ThreeVector& localPoint,
G4NavigationHistory& history,
const G4double )
const G4NavigationHistory& history,
const G4double ) const
{
G4VPhysicalVolume *repPhysical, *motherPhysical;
G4VPhysicalVolume *samplePhysical, *blockedExitedVol = nullptr;
@@ -0,0 +1,284 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4SafetyCalculator class Implementation
//
// Author: John Apostolakis, CERN - February 2023
// --------------------------------------------------------------------
#include "G4SafetyCalculator.hh"
#include "G4Navigator.hh"
#include "G4GeometryTolerance.hh"
G4SafetyCalculator::
G4SafetyCalculator( const G4Navigator& navigator,
const G4NavigationHistory& navHistory )
: fNavigator(navigator), fNavHistory(navHistory)
{
fkCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
}
// ********************************************************************
// ComputeSafety
//
// It assumes that it will be
// i) called at the Point in the same volume as the EndPoint of the
// ComputeStep.
// ii) after (or at the end of) ComputeStep OR after the relocation.
// ********************************************************************
//
G4double G4SafetyCalculator::
SafetyInCurrentVolume( const G4ThreeVector& pGlobalpoint,
G4VPhysicalVolume* physicalVolume,
const G4double pMaxLength,
G4bool /* verbose */ )
{
G4double safety = 0.0;
G4ThreeVector stepEndPoint = fNavigator.GetLastStepEndPoint();
G4ThreeVector localPoint = ComputeLocalPoint(pGlobalpoint);
G4double distEndpointSq = (pGlobalpoint-stepEndPoint).mag2();
G4bool stayedOnEndpoint = distEndpointSq < sqr(fkCarTolerance);
G4bool endpointOnSurface = fNavigator.EnteredDaughterVolume()
|| fNavigator.ExitedMotherVolume();
G4VPhysicalVolume* motherPhysical = fNavHistory.GetTopVolume();
if( motherPhysical != physicalVolume )
{
std::ostringstream msg;
msg << " Current (navigation) phys-volume: " << motherPhysical
<< " name= " << motherPhysical->GetName() << G4endl
<< " Request made for phys-volume: " << physicalVolume
<< " name= " << physicalVolume->GetName() << G4endl;
G4Exception("G4SafetyCalculator::SafetyInCurrentVolume", "GeomNav0001",
FatalException, msg,
"This method must be called only in the Current volume.");
}
if( !(endpointOnSurface && stayedOnEndpoint) )
{
G4LogicalVolume* motherLogical = motherPhysical->GetLogicalVolume();
G4SmartVoxelHeader* pVoxelHeader = motherLogical->GetVoxelHeader();
// Pseudo-relocate to this point (updates voxel information only)
//
QuickLocateWithinVolume( localPoint, motherPhysical );
//*********************
// switch(CharacteriseDaughters(motherLogical))
auto dtype= CharacteriseDaughters(motherLogical);
switch(dtype)
{
case kNormal:
if ( pVoxelHeader )
{
// New way: best safety
safety = fVoxelSafety.ComputeSafety(localPoint,
*motherPhysical, pMaxLength);
}
else
{
safety=fnormalNav.ComputeSafety(localPoint,fNavHistory,pMaxLength);
}
break;
case kParameterised:
if( GetDaughtersRegularStructureId(motherLogical) != 1 )
{
safety=fparamNav.ComputeSafety(localPoint,fNavHistory,pMaxLength);
}
else // Regular structure
{
safety=fregularNav.ComputeSafety(localPoint,fNavHistory,pMaxLength);
}
break;
case kReplica:
safety = freplicaNav.ComputeSafety(pGlobalpoint, localPoint,
fNavHistory, pMaxLength);
break;
case kExternal:
safety = fpExternalNav->ComputeSafety(localPoint, fNavHistory,
pMaxLength);
break;
}
// Remember last safety origin & value
//
fPreviousSftOrigin = pGlobalpoint;
fPreviousSafety = safety;
}
return safety;
}
// ********************************************************************
// QuickLocateWithinVolume
//
// -> the state information of this Navigator and its subNavigators
// is updated in order to start the next step at pGlobalpoint
// -> no check is performed whether pGlobalpoint is inside the
// original volume (this must be the case).
//
// Note: a direction could be added to the arguments, to aid in future
// optional checking (via the old code below, flagged by OLD_LOCATE).
// [ This would be done only in verbose mode ]
//
// Adapted simplied from G4Navigator::LocateGlobalPointWithinVolume()
// ********************************************************************
//
void G4SafetyCalculator::
QuickLocateWithinVolume( const G4ThreeVector& pointLocal,
G4VPhysicalVolume* motherPhysical )
{
// For the case of Voxel (or Parameterised) volume the respective
// sub-navigator must be messaged to update its voxel information etc
// Update the state of the Sub Navigators
// - in particular any voxel information they store/cache
//
G4LogicalVolume* motherLogical = motherPhysical->GetLogicalVolume();
G4SmartVoxelHeader* pVoxelHeader = motherLogical->GetVoxelHeader();
switch( CharacteriseDaughters(motherLogical) )
{
case kNormal:
if ( pVoxelHeader )
{
fvoxelNav.VoxelLocate( pVoxelHeader, pointLocal );
}
break;
case kParameterised:
if( GetDaughtersRegularStructureId(motherLogical) != 1 )
{
// Resets state & returns voxel node
//
fparamNav.ParamVoxelLocate( pVoxelHeader, pointLocal );
}
break;
case kReplica:
// Nothing to do
break;
case kExternal:
fpExternalNav->RelocateWithinVolume( motherPhysical,
pointLocal );
break;
}
}
// ********************************************************************
// Accessor for custom external navigation.
// ********************************************************************
G4VExternalNavigation* G4SafetyCalculator::GetExternalNavigation() const
{
return fpExternalNav;
}
// ********************************************************************
// Modifier for custom external navigation.
// ********************************************************************
void G4SafetyCalculator::SetExternalNavigation(G4VExternalNavigation* eNav)
{
fpExternalNav = eNav;
}
// ********************************************************************
// CompareSafetyValues
// ********************************************************************
void G4SafetyCalculator::
CompareSafetyValues( G4double oldSafety,
G4double newValue,
G4VPhysicalVolume* motherPhysical,
const G4ThreeVector& globalPoint,
G4bool keepState,
G4double maxLength,
G4bool enteredDaughterVol,
G4bool exitedMotherVol )
{
constexpr G4double reportThreshold= 3.0e-14;
// At least warn if rel-error exceeds it
constexpr G4double errorThreshold= 1.0e-08;
// Fatal if relative error is larger
constexpr G4double epsilonLen= 1.0e-20;
// Baseline minimal value for divisor
const G4double oldSafetyPlus = std::fabs(oldSafety)+epsilonLen;
if( std::fabs( newValue - oldSafety) > reportThreshold * oldSafetyPlus )
{
G4ExceptionSeverity severity= FatalException;
std::ostringstream msg;
G4double diff= (newValue-oldSafety);
G4double relativeDiff= diff / oldSafetyPlus;
msg << " New (G4SafetyCalculator) value *disagrees* by relative diff " << relativeDiff
<< " in physical volume '" << motherPhysical->GetName() << "' "
<< "copy-no = " << motherPhysical->GetCopyNo();
if( enteredDaughterVol ) { msg << " ( Just Entered new daughter volume. ) "; }
if( exitedMotherVol ) { msg << " ( Just Exited previous volume. ) "; }
msg << G4endl;
msg << " Safeties: old= " << std::setprecision(12) << oldSafety
<< " trial " << newValue
<< " new-old= " << std::setprecision(7) << diff << G4endl;
if( std::fabs(diff) < errorThreshold * ( std::fabs(oldSafety)+1.0e-20 ) )
{
msg << " (tiny difference) ";
severity= JustWarning;
}
else
{
msg << " (real difference) ";
severity= FatalException;
// Extra information -- for big errors
msg << " NOTE: keepState = " << keepState << G4endl;
msg << " Location - Global coordinates: " << globalPoint
<< " volume= '" << motherPhysical->GetName() << "'"
<< " copy-no= " << motherPhysical->GetCopyNo() << G4endl;
msg << " Argument maxLength= " << maxLength << G4endl;
std::size_t depth= fNavHistory.GetDepth();
msg << " Navigation History: depth = " << depth << G4endl;
for( G4int i=1; i<(G4int)depth; ++i )
{
msg << " d= " << i << " " << std::setw(32)
<< fNavHistory.GetVolume(i)->GetName()
<< " copyNo= " << fNavHistory.GetReplicaNo(i);
msg << G4endl;
}
}
#ifdef G4DEBUG_NAVIGATION
G4double redo= SafetyInCurrentVolume(globalPoint, motherPhysical,
maxLength, true);
msg << " Redoing estimator: value = " << std::setprecision(16) << redo
<< " diff/last= " << std::setprecision(7) << redo - newValue
<< " diff/old= " << redo - oldSafety << G4endl;
#endif
G4Exception("G4SafetyCalculator::CompareSafetyValues()", "GeomNav1007",
severity, msg);
}
}
@@ -36,6 +36,7 @@
#include "G4AutoDelete.hh"
#include "G4SystemOfUnits.hh"
#include "G4VIntersectionLocator.hh"
#include "G4TouchableHandle.hh"
#include "G4GeometryTolerance.hh"
///////////////////////////////////////////////////////////////////////////
@@ -686,7 +687,7 @@ LocateGlobalPointWithinVolumeAndCheck( const G4ThreeVector& position )
// Identify the current volume
G4TouchableHistoryHandle startTH= nav->CreateTouchableHistoryHandle();
G4TouchableHandle startTH= nav->CreateTouchableHistoryHandle();
G4VPhysicalVolume* motherPhys = startTH->GetVolume();
G4VSolid* motherSolid = startTH->GetSolid();
G4AffineTransform transform = nav->GetGlobalToLocalTransform();
@@ -28,14 +28,15 @@
// Author: P.Kent, 1996
//
// --------------------------------------------------------------------
#include <ostream>
#include "G4VoxelNavigation.hh"
#include "G4GeometryTolerance.hh"
#include "G4VoxelSafety.hh"
#include "G4AuxiliaryNavServices.hh"
#include <cassert>
#include <ostream>
// ********************************************************************
// Constructor
// ********************************************************************
@@ -761,6 +762,17 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
return ourSafety;
}
void G4VoxelNavigation::RelocateWithinVolume( G4VPhysicalVolume* motherPhysical,
const G4ThreeVector& localPoint )
{
auto motherLogical = motherPhysical->GetLogicalVolume();
assert(motherLogical != nullptr);
if ( auto pVoxelHeader = motherLogical->GetVoxelHeader() )
VoxelLocate( pVoxelHeader, localPoint );
}
// ********************************************************************
// SetVerboseLevel
// ********************************************************************
+8
View File
@@ -6,6 +6,14 @@ It must **not** be used as a substitute for writing good git commit messages!
------------------------------------------------------------------------------
## 2023-10-28 Stewart Boogert (geom-bool-V11-01-05)
- Fix problem with downcast in external boolean processor, could result incorrect nullptr
## 2023-09-14 Gabriele Cosmo, Evgueni Tcherniaev (geom-bool-V11-01-04)
- Define distinct statistics value in G4BooleanSolid for area and cubic volume.
- Reduce internal statistics for calculation of cubic volume in G4UnionSolid
and G4SubtractionSolid.
## 2023-05-10 Gabriele Cosmo (geom-bool-V11-01-03)
- Applied clang-tidy fixes (readability, modernization, performance, ...).
@@ -123,17 +123,19 @@ class G4BooleanSolid : public G4VSolid
G4VSolid* fPtrSolidB = nullptr;
G4double fCubicVolume = -1.0;
// Stored value of fCubicVolume
// Cached value of fCubicVolume
G4double fSurfaceArea = -1.0;
// Cached value of Surface Area
static G4VBooleanProcessor* fExternalBoolProcessor;
// External Boolean processor
private:
G4int fStatistics = 1000000;
G4int fCubVolStatistics = 1000000;
G4int fAreaStatistics = 1000000;
G4double fCubVolEpsilon = 0.001;
G4double fAreaAccuracy = -1;
G4double fSurfaceArea = -1.0;
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fpPolyhedron = nullptr;
@@ -30,7 +30,7 @@
inline
G4int G4BooleanSolid::GetCubVolStatistics() const
{
return fStatistics;
return fCubVolStatistics;
}
inline
@@ -42,21 +42,21 @@ G4double G4BooleanSolid::GetCubVolEpsilon() const
inline
void G4BooleanSolid::SetCubVolStatistics(G4int st)
{
fCubicVolume = -1.;
fStatistics = st;
if (st != fCubVolStatistics) { fCubicVolume = -1.; }
fCubVolStatistics = st;
}
inline
void G4BooleanSolid::SetCubVolEpsilon(G4double ep)
{
fCubicVolume = -1.;
if (ep != fCubVolEpsilon) { fCubicVolume = -1.; }
fCubVolEpsilon = ep;
}
inline
G4int G4BooleanSolid::GetAreaStatistics() const
{
return fStatistics;
return fAreaStatistics;
}
inline
@@ -68,14 +68,14 @@ G4double G4BooleanSolid::GetAreaAccuracy() const
inline
void G4BooleanSolid::SetAreaStatistics(G4int st)
{
fSurfaceArea = -1.;
fStatistics = st;
if (st != fAreaStatistics) { fSurfaceArea = -1.; }
fAreaStatistics = st;
}
inline
void G4BooleanSolid::SetAreaAccuracy(G4double ep)
{
fSurfaceArea = -1.;
if (ep != fAreaAccuracy) { fSurfaceArea = -1.; }
fAreaAccuracy = ep;
}
@@ -84,7 +84,7 @@ G4double G4BooleanSolid::GetSurfaceArea()
{
if(fSurfaceArea < 0.)
{
fSurfaceArea = EstimateSurfaceArea(fStatistics,fAreaAccuracy);
fSurfaceArea = EstimateSurfaceArea(fAreaStatistics, fAreaAccuracy);
}
return fSurfaceArea;
}
@@ -116,9 +116,12 @@ G4BooleanSolid::~G4BooleanSolid()
G4BooleanSolid::G4BooleanSolid(const G4BooleanSolid& rhs)
: G4VSolid (rhs), fPtrSolidA(rhs.fPtrSolidA), fPtrSolidB(rhs.fPtrSolidB),
fCubicVolume(rhs.fCubicVolume), fStatistics(rhs.fStatistics),
fCubVolEpsilon(rhs.fCubVolEpsilon), fAreaAccuracy(rhs.fAreaAccuracy),
fSurfaceArea(rhs.fSurfaceArea), createdDisplacedSolid(rhs.createdDisplacedSolid)
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
fCubVolStatistics(rhs.fCubVolStatistics),
fAreaStatistics(rhs.fAreaStatistics),
fCubVolEpsilon(rhs.fCubVolEpsilon),
fAreaAccuracy(rhs.fAreaAccuracy),
createdDisplacedSolid(rhs.createdDisplacedSolid)
{
fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
}
@@ -140,10 +143,11 @@ G4BooleanSolid& G4BooleanSolid::operator = (const G4BooleanSolid& rhs)
// Copy data
//
fPtrSolidA= rhs.fPtrSolidA; fPtrSolidB= rhs.fPtrSolidB;
fStatistics= rhs.fStatistics; fCubVolEpsilon= rhs.fCubVolEpsilon;
fAreaAccuracy= rhs.fAreaAccuracy; fCubicVolume= rhs.fCubicVolume;
fSurfaceArea= rhs.fSurfaceArea;
fCubicVolume= rhs.fCubicVolume; fSurfaceArea= rhs.fSurfaceArea;
fCubVolStatistics = rhs.fCubVolStatistics; fCubVolEpsilon = rhs.fCubVolEpsilon;
fAreaStatistics = rhs.fAreaStatistics; fAreaAccuracy = rhs.fAreaAccuracy;
createdDisplacedSolid= rhs.createdDisplacedSolid;
fRebuildPolyhedron = false;
delete fpPolyhedron; fpPolyhedron = nullptr;
fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
@@ -414,13 +418,13 @@ G4BooleanSolid::StackPolyhedron(HepPolyhedronProcessor& processor,
//////////////////////////////////////////////////////////////////////////
//
// Estimate Cubic Volume (capacity) and store it for reuse.
// Estimate Cubic Volume (capacity) and cache it for reuse.
G4double G4BooleanSolid::GetCubicVolume()
{
if(fCubicVolume < 0.)
{
fCubicVolume = EstimateCubicVolume(fStatistics,fCubVolEpsilon);
fCubicVolume = EstimateCubicVolume(fCubVolStatistics, fCubVolEpsilon);
}
return fCubicVolume;
}
@@ -1005,8 +1005,7 @@ G4Polyhedron* G4MultiUnion::CreatePolyhedron() const
else
{
G4VSolid* solidA = GetSolid(0);
auto solidAPolyhedron =
dynamic_cast<G4PolyhedronArbitrary*>(solidA->GetPolyhedron());
auto solidAPolyhedron =solidA->GetPolyhedron();
const G4Transform3D transform0 = GetTransformation(0);
G4DisplacedSolid dispSolidA("placedA", solidA, transform0);
@@ -607,8 +607,9 @@ G4double G4SubtractionSolid::GetCubicVolume()
bminB.x() < bmaxA.x() && bminB.y() < bmaxA.y() && bminB.z() < bmaxA.z();
if ( canIntersect )
{
G4IntersectionSolid intersectVol( "Temporary-Intersection-for-Union",
G4IntersectionSolid intersectVol( "Temporary-Intersection-for-Subtraction",
fPtrSolidA, fPtrSolidB );
intersectVol.SetCubVolStatistics(100000);
intersection = intersectVol.GetCubicVolume();
}
@@ -574,6 +574,7 @@ G4double G4UnionSolid::GetCubicVolume()
{
G4IntersectionSolid intersectVol( "Temporary-Intersection-for-Union",
fPtrSolidA, fPtrSolidB );
intersectVol.SetCubVolStatistics(100000);
intersection = intersectVol.GetCubicVolume();
}
+3
View File
@@ -6,6 +6,9 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2023-07-10 Evgueni Tcherniaev (geom-specific-V11-01-06)
- Fixed bounding box calculation in G4VTwistedFaceted::BoundingLimits().
## 2023-06-16 Stephan Hageboeck (geom-specific-V11-01-05)
- Fix an uninitialised value in G4VCSGfaceted::SurfaceNormal().
@@ -288,9 +288,35 @@ void G4VTwistedFaceted::ComputeDimensions(G4VPVParameterisation* ,
void G4VTwistedFaceted::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
G4double maxRad = std::sqrt(fDx*fDx + fDy*fDy);
pMin.set(-maxRad,-maxRad,-fDz);
pMax.set( maxRad, maxRad, fDz);
G4double cosPhi = std::cos(fPhi);
G4double sinPhi = std::sin(fPhi);
G4double tanTheta = std::tan(fTheta);
G4double tanAlpha = fTAlph;
G4double xmid1 = fDy1*tanAlpha;
G4double x1 = std::abs(xmid1 + fDx1);
G4double x2 = std::abs(xmid1 - fDx1);
G4double x3 = std::abs(xmid1 + fDx2);
G4double x4 = std::abs(xmid1 - fDx2);
G4double xmax1 = std::max(std::max(std::max(x1, x2), x3), x4);
G4double rmax1 = std::sqrt(xmax1*xmax1 + fDy1*fDy1);
G4double xmid2 = fDy2*tanAlpha;
G4double x5 = std::abs(xmid2 + fDx3);
G4double x6 = std::abs(xmid2 - fDx3);
G4double x7 = std::abs(xmid2 + fDx4);
G4double x8 = std::abs(xmid2 - fDx4);
G4double xmax2 = std::max(std::max(std::max(x5, x6), x7), x8);
G4double rmax2 = std::sqrt(xmax2*xmax2 + fDy2*fDy2);
G4double x0 = fDz*tanTheta*cosPhi;
G4double y0 = fDz*tanTheta*sinPhi;
G4double xmin = std::min(-x0 - rmax1, x0 - rmax2);
G4double ymin = std::min(-y0 - rmax1, y0 - rmax2);
G4double xmax = std::max(-x0 + rmax1, x0 + rmax2);
G4double ymax = std::max(-y0 + rmax1, y0 + rmax2);
pMin.set(xmin, ymin,-fDz);
pMax.set(xmax, ymax, fDz);
}
+9
View File
@@ -6,6 +6,15 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2023-10-24 Gabriele Cosmo (geomvol-V11-01-02)
- Minor cleanup and code indentation. No functional changes.
## 2023-08-31 Gabriele Cosmo (geomvol-V11-01-01)
- Moved to "management" the following classes and translation units:
G4NavigationHistory, G4NavigationHistoryPool, G4NavigationLevel and
G4NavigationLevelRep.
- Removed unused classes G4GRSSolid and G4GRSVolume.
## 2023-05-09 Gabriele Cosmo (geomvol-V11-01-00)
- Applied clang-tidy fixes (readability, modernization, performance, ...).
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// class G4AssemblyStore
// G4AssemblyStore
//
// Class description:
//
@@ -36,15 +36,9 @@
// their destruction. The underlying container initially has a capacity of 20.
//
// If much additional functionality is added, should consider containment
// instead of inheritance for std::vector<T>
//
// Member data:
//
// static G4AssemblyStore*
// - Pointer to the single G4AssemblyStore
// instead of inheritance for std::vector<T>.
// History:
// 9.10.18 G.Cosmo Initial version
// 9.10.2018 G.Cosmo - Initial version
// --------------------------------------------------------------------
#ifndef G4ASSEMBLYSTORE_HH
#define G4ASSEMBLYSTORE_HH
@@ -58,7 +52,7 @@ class G4AssemblyVolume;
class G4AssemblyStore : public std::vector<G4AssemblyVolume*>
{
public: // with description
public:
static void Register(G4AssemblyVolume* pAssembly);
// Add the assembly to the collection.
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Class G4AssemblyTriplet
// G4AssemblyTriplet
//
// Class description:
//
@@ -40,8 +40,8 @@
// Ivana Hrivnacova: extended to support assembly of assemblies
// of volumes and reflections, March 2006
// ----------------------------------------------------------------------
#ifndef G4_ASSEMBLYTRIPLET_H
#define G4_ASSEMBLYTRIPLET_H
#ifndef G4_ASSEMBLYTRIPLET_HH
#define G4_ASSEMBLYTRIPLET_HH
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
@@ -51,7 +51,7 @@ class G4AssemblyVolume;
class G4AssemblyTriplet
{
public: // with description
public:
G4AssemblyTriplet();
// Default constructor
@@ -104,28 +104,26 @@ class G4AssemblyTriplet
inline G4bool IsReflection() const;
// Return true if the logical or assembly volume has reflection
private:
private:
G4LogicalVolume* fVolume = nullptr;
G4LogicalVolume* fVolume = nullptr;
// A logical volume
G4ThreeVector fTranslation;
G4ThreeVector fTranslation;
// A logical volume translation
G4RotationMatrix* fRotation = nullptr;
// A logical volume rotation
private:
// Member data for handling assemblies of assemblies and reflections
G4AssemblyVolume* fAssembly = nullptr;
// An assembly volume
G4bool fIsReflection = false;
G4bool fIsReflection = false;
// True if the logical or assembly volume has reflection
};
#include "G4AssemblyTriplet.icc"
#endif // G4_ASSEMBLYTRIPLET_H
#endif // G4_ASSEMBLYTRIPLET_HH
@@ -65,8 +65,7 @@ G4AssemblyTriplet::G4AssemblyTriplet( const G4AssemblyTriplet& scopy )
}
inline
G4AssemblyTriplet::~G4AssemblyTriplet()
= default;
G4AssemblyTriplet::~G4AssemblyTriplet() = default;
inline
G4LogicalVolume* G4AssemblyTriplet::GetVolume() const
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Class G4AssemblyVolume
// G4AssemblyVolume
//
// Class description:
//
@@ -40,8 +40,8 @@
// Ivana Hrivnacova: extended to support assembly of assemblies
// of volumes and reflections - March 2006
// ----------------------------------------------------------------------
#ifndef G4_ASSEMBLYVOLUME_H
#define G4_ASSEMBLYVOLUME_H
#ifndef G4_ASSEMBLYVOLUME_HH
#define G4_ASSEMBLYVOLUME_HH
#include <vector>
@@ -52,177 +52,177 @@ class G4VPhysicalVolume;
class G4AssemblyVolume
{
public: // with description
public:
G4AssemblyVolume();
G4AssemblyVolume( G4LogicalVolume* volume,
G4ThreeVector& translation,
G4RotationMatrix* rotation);
~G4AssemblyVolume();
//
// Constructors & destructor.
// At destruction all the generated physical volumes and associated
// rotation matrices of the imprints will be destroyed.
//
// The rotation matrix passed as argument can be nullptr (identity) or an
// address even of an object on the upper stack frame. During assembly
// imprint, a new matrix is created anyway and it is kept track of it so
// it can be automatically deleted later at the end of the application.
// This policy is adopted since user has no control on the way the
// rotations are combined.
G4AssemblyVolume();
G4AssemblyVolume( G4LogicalVolume* volume,
G4ThreeVector& translation,
G4RotationMatrix* rotation);
~G4AssemblyVolume();
//
// Constructors & destructor.
// At destruction all the generated physical volumes and associated
// rotation matrices of the imprints will be destroyed.
//
// The rotation matrix passed as argument can be nullptr (identity) or an
// address even of an object on the upper stack frame. During assembly
// imprint, a new matrix is created anyway and it is kept track of it so
// it can be automatically deleted later at the end of the application.
// This policy is adopted since user has no control on the way the
// rotations are combined.
void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
G4ThreeVector& translation,
G4RotationMatrix* rotation);
//
// Place the given volume 'pPlacedVolume' inside the assembly.
//
// The adopted approach:
//
// - Place it w.r.t. the assembly coordinate system.
// This step is applied to each of the participating volumes.
//
// The other possible approaches:
//
// - Place w.r.t. the firstly added volume.
// When placed the first, the virtual coordinate system becomes
// the coordinate system of the first one.
// Every next volume being added into the assembly will be placed
// w.r.t to the first one.
//
// - Place w.r.t the last placed volume.
// When placed the first, the virtual coordinate system becomes
// the coordinate system of the first one.
// Every next volume being added into the assembly will be placed
// w.r.t to the previous one.
//
// The rotation matrix passed as argument can be nullptr (identity) or an
// address even of an object on the upper stack frame. During assembly
// imprint, a new matrix is created anyway and it is kept track of it so
// it can be automatically deleted later at the end of the application.
// This policy is adopted since user has no control on the way the
// rotations are combined.
void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
G4Transform3D& transformation);
//
// The same as previous, but takes complete 3D transformation in space
// as its argument.
void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
G4Transform3D& transformation);
//
// The same as previous AddPlacedVolume(), but takes an assembly volume
// as its argument.
void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
G4ThreeVector& translation,
G4RotationMatrix* rotation);
//
// The same as above AddPlacedVolume(), but takes an assembly volume
// as its argument with translation and rotation.
//
// Place the given volume 'pPlacedVolume' inside the assembly.
//
// The adopted approach:
//
// - Place it w.r.t. the assembly coordinate system.
// This step is applied to each of the participating volumes.
//
// The other possible approaches:
//
// - Place w.r.t. the firstly added volume.
// When placed the first, the virtual coordinate system becomes
// the coordinate system of the first one.
// Every next volume being added into the assembly will be placed
// w.r.t to the first one.
//
// - Place w.r.t the last placed volume.
// When placed the first, the virtual coordinate system becomes
// the coordinate system of the first one.
// Every next volume being added into the assembly will be placed
// w.r.t to the previous one.
//
// The rotation matrix passed as argument can be nullptr (identity) or an
// address even of an object on the upper stack frame. During assembly
// imprint, a new matrix is created anyway and it is kept track of it so
// it can be automatically deleted later at the end of the application.
// This policy is adopted since user has no control on the way the
// rotations are combined.
void MakeImprint( G4LogicalVolume* pMotherLV,
G4ThreeVector& translationInMother,
G4RotationMatrix* pRotationInMother,
G4int copyNumBase = 0,
G4bool surfCheck = false );
//
// Creates instance of an assembly volume inside the given mother volume.
void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
G4Transform3D& transformation);
//
// The same as previous, but takes complete 3D transformation in space
// as its argument.
void MakeImprint( G4LogicalVolume* pMotherLV,
G4Transform3D& transformation,
G4int copyNumBase = 0,
G4bool surfCheck = false );
//
// The same as previous Imprint() method, but takes complete 3D
// transformation in space as its argument.
void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
G4Transform3D& transformation);
//
// The same as previous AddPlacedVolume(), but takes an assembly volume
// as its argument.
inline std::vector<G4VPhysicalVolume*>::iterator GetVolumesIterator();
inline std::size_t TotalImprintedVolumes() const;
//
// Methods to access the physical volumes imprinted with the assembly.
inline G4Transform3D& GetImprintTransformation(unsigned int imprintID);
// Method to access transformation for each imprint
void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
G4ThreeVector& translation,
G4RotationMatrix* rotation);
//
// The same as above AddPlacedVolume(), but takes an assembly volume
// as its argument with translation and rotation.
inline std::vector<G4AssemblyTriplet>::iterator GetTripletsIterator();
inline std::size_t TotalTriplets() const;
//
// Methods to access the triplets which are part of the assembly
void MakeImprint( G4LogicalVolume* pMotherLV,
G4ThreeVector& translationInMother,
G4RotationMatrix* pRotationInMother,
G4int copyNumBase = 0,
G4bool surfCheck = false );
//
// Creates instance of an assembly volume inside the given mother volume.
void MakeImprint( G4LogicalVolume* pMotherLV,
G4Transform3D& transformation,
G4int copyNumBase = 0,
G4bool surfCheck = false );
//
// The same as previous Imprint() method, but takes complete 3D
// transformation in space as its argument.
inline std::vector<G4VPhysicalVolume*>::iterator GetVolumesIterator();
inline std::size_t TotalImprintedVolumes() const;
//
// Methods to access the physical volumes imprinted with the assembly.
inline G4Transform3D& GetImprintTransformation(unsigned int imprintID);
// Method to access transformation for each imprint
inline std::vector<G4AssemblyTriplet>::iterator GetTripletsIterator();
inline std::size_t TotalTriplets() const;
//
// Methods to access the triplets which are part of the assembly
inline unsigned int GetImprintsCount() const;
//
// Return the number of made imprints.
inline unsigned int GetImprintsCount() const;
//
// Return the number of made imprints.
unsigned int GetInstanceCount() const;
//
// Return the number of existing instance of G4AssemblyVolume class.
unsigned int GetInstanceCount() const;
//
// Return the number of existing instance of G4AssemblyVolume class.
inline unsigned int GetAssemblyID() const;
//
// Return instance number of this concrete object.
inline unsigned int GetAssemblyID() const;
//
// Return instance number of this concrete object.
protected:
inline void SetInstanceCount( unsigned int value );
inline void SetAssemblyID( unsigned int value );
protected:
inline void SetInstanceCount( unsigned int value );
inline void SetAssemblyID( unsigned int value );
void InstanceCountPlus();
void InstanceCountMinus();
void InstanceCountPlus();
void InstanceCountMinus();
inline void SetImprintsCount( unsigned int value );
inline void ImprintsCountPlus();
inline void ImprintsCountMinus();
//
// Internal counting mechanism, used to compute unique the names of
// physical volumes created by MakeImprint() methods.
inline void SetImprintsCount( unsigned int value );
inline void ImprintsCountPlus();
inline void ImprintsCountMinus();
//
// Internal counting mechanism, used to compute unique the names of
// physical volumes created by MakeImprint() methods.
private:
private:
void MakeImprint( G4AssemblyVolume* pAssembly,
G4LogicalVolume* pMotherLV,
G4Transform3D& transformation,
G4int copyNumBase = 0,
G4bool surfCheck = false );
//
// Function for placement of the given assembly in the given mother
// (called recursively if the assembly contains an assembly).
void MakeImprint( G4AssemblyVolume* pAssembly,
G4LogicalVolume* pMotherLV,
G4Transform3D& transformation,
G4int copyNumBase = 0,
G4bool surfCheck = false );
//
// Function for placement of the given assembly in the given mother
// (called recursively if the assembly contains an assembly).
private:
private:
std::vector<G4AssemblyTriplet> fTriplets;
//
// Participating volumes represented as a vector of
// <logical volume, translation, rotation>.
std::vector<G4AssemblyTriplet> fTriplets;
//
// Participating volumes represented as a vector of
// <logical volume, translation, rotation>.
std::vector<G4VPhysicalVolume*> fPVStore;
//
// We need to keep list of physical volumes created by MakeImprint() method
// in order to be able to cleanup the objects when not needed anymore.
// This requires the user to keep assembly objects in memory during the
// whole job or during the life-time of G4Navigator, logical volume store
// and physical volume store keep pointers to physical volumes generated by
// the assembly volume.
// When an assembly object is about to die it will destroy all its
// generated physical volumes and rotation matrices as well !
std::vector<G4VPhysicalVolume*> fPVStore;
//
// We need to keep list of physical volumes created by MakeImprint()
// in order to be able to cleanup the objects when not needed anymore.
// This requires the user to keep assembly objects in memory during the
// whole job or during the life-time of G4Navigator, logical volume store
// and physical volume store keep pointers to physical volumes generated
// by the assembly volume.
// When an assembly object is about to die it will destroy all its
// generated physical volumes and rotation matrices as well !
unsigned int fImprintsCounter;
//
// Number of imprints of the given assembly volume.
unsigned int fImprintsCounter;
//
// Number of imprints of the given assembly volume.
static G4ThreadLocal unsigned int fsInstanceCounter;
//
// Class instance counter.
static G4ThreadLocal unsigned int fsInstanceCounter;
//
// Class instance counter.
unsigned int fAssemblyID = 0;
//
// Assembly object ID derived from instance counter at construction time.
unsigned int fAssemblyID = 0;
//
// Assembly object ID derived from instance counter at construction time.
std::map<unsigned int, G4Transform3D> fImprintsTransf;
//
// Container of transformations for each imprint (used by GDML persistency)
std::map<unsigned int, G4Transform3D> fImprintsTransf;
//
// Container of transformations for each imprint (used in GDML)
};
#include "G4AssemblyVolume.icc"
#endif // G4_ASSEMBLYVOLUME_H
#endif // G4_ASSEMBLYVOLUME_HH
@@ -34,19 +34,19 @@ unsigned int G4AssemblyVolume::GetImprintsCount() const
}
inline
void G4AssemblyVolume::SetImprintsCount( unsigned int value )
void G4AssemblyVolume::SetImprintsCount( unsigned int value )
{
fImprintsCounter = value;
}
inline
void G4AssemblyVolume::ImprintsCountPlus()
void G4AssemblyVolume::ImprintsCountPlus()
{
++fImprintsCounter;
}
inline
void G4AssemblyVolume::ImprintsCountMinus()
void G4AssemblyVolume::ImprintsCountMinus()
{
--fImprintsCounter;
}
@@ -58,7 +58,7 @@ unsigned int G4AssemblyVolume::GetAssemblyID() const
}
inline
void G4AssemblyVolume::SetAssemblyID( unsigned int value )
void G4AssemblyVolume::SetAssemblyID( unsigned int value )
{
fAssemblyID = value;
}
@@ -33,9 +33,8 @@
// Original author: X.Dong (NorthEastern Univ.), November 2009
// Reviewed implementation: G.Cosmo (CERN), December 2009
// ------------------------------------------------------------
#ifndef G4EnhancedVecAllocator_h
#define G4EnhancedVecAllocator_h 1
#ifndef G4EnhancedVecAllocator_hh
#define G4EnhancedVecAllocator_hh 1
#include "G4Types.hh"
@@ -1,75 +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. *
// ********************************************************************
//
// class G4GRSSolid
//
// Class description:
//
// Object representing a touchable solid - maintains the association
// between a solid and its net resultant local->global transform.
//
// NOTE: The (optional) rotation matrix is copied
// Created: Paul Kent - August 1996
// ----------------------------------------------------------------------
#ifndef G4GRSSOLID_HH
#define G4GRSSOLID_HH
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
#include "G4VTouchable.hh"
class G4VSolid;
class G4GRSSolid : public G4VTouchable
{
public: // with description
G4GRSSolid(G4VSolid *pSolid,
const G4RotationMatrix *pRot,
const G4ThreeVector &tlate);
G4GRSSolid(G4VSolid *pSolid,
const G4RotationMatrix &rot,
const G4ThreeVector &tlate);
~G4GRSSolid() override;
G4GRSSolid(const G4GRSSolid&) = delete;
G4GRSSolid& operator=(const G4GRSSolid&) = delete;
// Copy constructor and assignment operator not allowed
inline G4VSolid* GetSolid(G4int depth=0) const override;
inline const G4ThreeVector& GetTranslation(G4int depth=0) const override;
inline const G4RotationMatrix* GetRotation(G4int depth=0) const override;
private:
G4VSolid* fsolid = nullptr;
G4RotationMatrix* frot = nullptr;
G4ThreeVector ftlate;
};
#include "G4GRSSolid.icc"
#endif
@@ -1,98 +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. *
// ********************************************************************
//
//
//
//
// class G4GRSSolid inline implementation
// ----------------------------------------------------------------------
inline
G4GRSSolid::G4GRSSolid( G4VSolid *pSolid,
const G4RotationMatrix *pRot,
const G4ThreeVector &tlate )
: fsolid(pSolid), ftlate(tlate)
{
if (pRot != nullptr)
{
frot = new G4RotationMatrix(*pRot);
if ( frot == nullptr )
{
G4Exception("G4GRSSolid::G4GRSSolid()","GeomVol0002",FatalException,
"Cannot allocate G4RotationMatrix, NULL pointer.");
}
}
else
{
frot = nullptr;
}
}
inline
G4GRSSolid::G4GRSSolid( G4VSolid *pSolid,
const G4RotationMatrix &rot,
const G4ThreeVector &tlate )
: fsolid(pSolid), ftlate(tlate)
{
frot = new G4RotationMatrix(rot);
if ( frot == nullptr )
{
G4Exception("G4GRSSolid::G4GRSSolid()","GeomVol0002",FatalException,
"Cannot allocate G4RotationMatrix, NULL pointer.");
}
}
inline
G4VSolid* G4GRSSolid::GetSolid( G4int depth ) const
{
if( depth != 0 )
{
G4Exception("G4GRSSolid::GetSolid()", "GeomVol0003",
FatalException, "History depth in input must be 0 !");
}
return fsolid;
}
inline
const G4ThreeVector& G4GRSSolid::GetTranslation( G4int depth ) const
{
if( depth != 0 )
{
G4Exception("G4GRSSolid::GetTranslation()", "GeomVol0003",
FatalException, "History depth in input must be 0 !");
}
return ftlate;
}
inline
const G4RotationMatrix* G4GRSSolid::GetRotation( G4int depth ) const
{
if( depth != 0 )
{
G4Exception("G4GRSSolid::GetRotation()", "GeomVol0003",
FatalException, "History depth in input must be 0 !");
}
return frot;
}
@@ -1,48 +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. *
// ********************************************************************
//
// Class G4GRSSolidHandle
//
// Class description:
//
// Type providing reference counting mechanism solid touchables.
// The basic rule for the use of this type is that this handle must always
// be exchanged by reference never dinamically allocated (i.e. never
// instantiated using 'new').
//
// For more details see G4ReferenceCountedHandle.
// Author: Radovan Chytracek (Radovan.Chytracek@cern.ch), March 2001
//
// ----------------------------------------------------------------------
#ifndef G4GRSSOLIDHANDLE_HH
#define G4GRSSOLIDHANDLE_HH 1
#include "G4GRSSolid.hh"
#include "G4ReferenceCountedHandle.hh"
using G4GRSSolidHandle = G4ReferenceCountedHandle<G4GRSSolid>;
#endif // G4GRSSOLIDHANDLE_HH
@@ -1,77 +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. *
// ********************************************************************
//
// class G4GRSVolume
//
// Class description:
//
// Object representing a touchable detector element - maintains
// associations between a physical volume and its net resultant
// local->global transform.
//
// NOTE: The (optional) rotation matrix is copied
// Created: Paul Kent - August 1996
// ----------------------------------------------------------------------
#ifndef G4GRSVOLUME_HH
#define G4GRSVOLUME_HH
#include "G4VTouchable.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
class G4GRSVolume : public G4VTouchable
{
public: // with description
G4GRSVolume(G4VPhysicalVolume* pVol,
const G4RotationMatrix* pRot,
const G4ThreeVector& tlate);
G4GRSVolume(G4VPhysicalVolume* pVol,
const G4RotationMatrix& rot,
const G4ThreeVector& tlate);
~G4GRSVolume() override;
G4GRSVolume(const G4GRSVolume&) = delete;
G4GRSVolume& operator=(const G4GRSVolume&) = delete;
// Copy constructor and assignment operator not allowed
inline G4VPhysicalVolume* GetVolume(G4int depth=0) const override;
inline G4VSolid* GetSolid(G4int depth=0) const override;
inline const G4ThreeVector& GetTranslation(G4int depth=0) const override;
inline const G4RotationMatrix* GetRotation(G4int depth=0) const override;
private:
G4VPhysicalVolume* fvol = nullptr;
G4RotationMatrix* frot = nullptr;
G4ThreeVector ftlate;
};
#include "G4GRSVolume.icc"
#endif
@@ -1,109 +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. *
// ********************************************************************
//
//
//
//
// class G4GRSVolume inline implementation
// ----------------------------------------------------------------------
inline
G4GRSVolume::G4GRSVolume( G4VPhysicalVolume* pVol,
const G4RotationMatrix* pRot,
const G4ThreeVector& tlate )
: fvol(pVol), ftlate(tlate)
{
if ( pRot != nullptr )
{
frot = new G4RotationMatrix(*pRot);
if ( frot == nullptr )
{
G4Exception("G4GRSVolume::G4GRSVolume()", "GeomVol0002", FatalException,
"Cannot allocate G4RotationMatrix, NULL pointer.");
}
}
else
{
frot = nullptr;
}
}
inline
G4GRSVolume::G4GRSVolume( G4VPhysicalVolume* pVol,
const G4RotationMatrix& rot,
const G4ThreeVector& tlate )
: fvol(pVol), ftlate(tlate)
{
frot = new G4RotationMatrix(rot);
if ( frot == nullptr )
{
G4Exception("G4GRSVolume::G4GRSVolume()", "GeomVol0002", FatalException,
"Cannot allocate G4RotationMatrix, NULL pointer.");
}
}
inline
G4VPhysicalVolume* G4GRSVolume::GetVolume( G4int depth ) const
{
if( depth != 0 )
{
G4Exception("G4GRSVolume::GetVolume()", "GeomVol0003",
FatalException, "History depth in input must be 0 !");
}
return fvol;
}
inline
G4VSolid* G4GRSVolume::GetSolid( G4int depth ) const
{
if( depth != 0 )
{
G4Exception("G4GRSVolume::GetSolid()", "GeomVol0003",
FatalException, "History depth in input must be 0 !");
}
return fvol->GetLogicalVolume()->GetSolid();
}
inline
const G4ThreeVector& G4GRSVolume::GetTranslation( G4int depth ) const
{
if( depth != 0 )
{
G4Exception("G4GRSVolume::GetTranslation()", "GeomVol0003",
FatalException, "History depth in input must be 0 !");
}
return ftlate;
}
inline
const G4RotationMatrix* G4GRSVolume::GetRotation( G4int depth ) const
{
if( depth != 0 )
{
G4Exception("G4GRSVolume::GetRotation()", "GeomVol0003",
FatalException, "History depth in input must be 0 !");
}
return frot;
}
@@ -1,48 +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. *
// ********************************************************************
//
// Class G4GRSVolumeHandle
//
// Class description:
//
// Type providing reference counting mechanism for volume touchables.
// The basic rule for the use of this type is that this handle must always
// be exchanged by reference never dinamically allocated (i.e. never
// instantiated using 'new').
//
// For more details see G4ReferenceCountedHandle.
// Author: Radovan Chytracek (Radovan.Chytracek@cern.ch), March 2001
//
// ----------------------------------------------------------------------
#ifndef G4GRSVOLUMEHANDLE_HH
#define G4GRSVOLUMEHANDLE_HH 1
#include "G4GRSVolume.hh"
#include "G4ReferenceCountedHandle.hh"
using G4GRSVolumeHandle = G4ReferenceCountedHandle<G4GRSVolume>;
#endif // G4GRSVOLUMEHANDLE_HH
@@ -30,7 +30,7 @@
// A Logical Surface class for surfaces defined by the boundary
// of two physical volumes.
// Author: John Apostolakis (John.Apostolakis@cern.ch), 17-06-1997
// Author: John Apostolakis, CERN - 17-06-1997
// --------------------------------------------------------------------
#ifndef G4LogicalBorderSurface_hh
#define G4LogicalBorderSurface_hh 1
@@ -49,7 +49,6 @@ using G4LogicalBorderSurfaceTable
class G4LogicalBorderSurface : public G4LogicalSurface
{
public:
G4LogicalBorderSurface( const G4String& name,
@@ -30,7 +30,7 @@
// A Logical Surface class for the surface surrounding a single logical
// volume.
// Author: John Apostolakis (John.Apostolakis@cern.ch), 16-06-1997
// Author: John Apostolakis, CERN - 16-06-1997
// --------------------------------------------------------------------
#ifndef G4LogicalSkinSurface_hh
#define G4LogicalSkinSurface_hh 1
@@ -46,7 +46,6 @@ using G4LogicalSkinSurfaceTable = std::vector<G4LogicalSkinSurface*>;
class G4LogicalSkinSurface : public G4LogicalSurface
{
public:
G4LogicalSkinSurface( const G4String& name,
@@ -81,7 +80,6 @@ class G4LogicalSkinSurface : public G4LogicalSurface
static G4LogicalSkinSurfaceTable *theSkinSurfaceTable;
// The static Table of SkinSurfaces.
};
// ********************************************************************
@@ -35,13 +35,13 @@
// 29.07.95, P.Kent - first non-stub version
// ----------------------------------------------------------------------
#ifndef G4PVPARAMETERISED_HH
#define G4PVPARAMETERISED_HH
#define G4PVPARAMETERISED_HH 1
#include "G4PVReplica.hh"
class G4PVParameterised : public G4PVReplica
{
public: // with description
public:
G4PVParameterised(const G4String& pName,
G4LogicalVolume* pLogical,
@@ -55,8 +55,6 @@ class G4PVParameterised : public G4PVReplica
// The positioning of the replicas is dominant along the specified axis.
// pSurfChk if true activates check for overlaps with existing volumes.
public: // without description
G4PVParameterised(const G4String& pName,
G4LogicalVolume* pLogical,
G4VPhysicalVolume* pMother,
@@ -72,8 +70,6 @@ class G4PVParameterised : public G4PVReplica
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
public: // with description
~G4PVParameterised() override;
// Virtual empty destructor.
@@ -30,19 +30,17 @@
// Class representing a single volume positioned within and relative
// to a mother volume.
// 24.07.95 P.Kent, First non-stub version
// 25.07.96 P.Kent, Modified interface for new `Replica' capable geometry
// 28.08.96 P.Kent. Tidied + transform replaced by rotmat+vector
// 24.07.95 P.Kent, First non-stub version.
// ----------------------------------------------------------------------
#ifndef G4PVPLACEMENT_HH
#define G4PVPLACEMENT_HH
#define G4PVPLACEMENT_HH 1
#include "G4VPhysicalVolume.hh"
#include "G4Transform3D.hh"
class G4PVPlacement : public G4VPhysicalVolume
{
public: // with description
public:
G4PVPlacement(G4RotationMatrix* pRot,
const G4ThreeVector& tlate,
@@ -85,8 +83,6 @@ class G4PVPlacement : public G4VPhysicalVolume
// of moving objects in a given reference frame. ]
// All other arguments are the same as for the previous constructor.
public: // without description
G4PVPlacement(G4RotationMatrix* pRot,
const G4ThreeVector& tlate,
const G4String& pName,
@@ -109,8 +105,6 @@ class G4PVPlacement : public G4VPhysicalVolume
// Utilises both variations above (from 2nd and 3rd constructor).
// The effect is the same as for the 2nd constructor.
public: // with description
~G4PVPlacement() override;
// Default destructor.
@@ -129,8 +123,6 @@ class G4PVPlacement : public G4VPhysicalVolume
// Reports a maximum of overlaps errors according to parameter in input.
// Returns true if the volume is overlapping.
public: // without description
G4PVPlacement(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
@@ -166,8 +158,6 @@ class G4PVPlacement : public G4VPhysicalVolume
G4bool fmany = false; // flag for overlapping structure - not used
G4bool fallocatedRotM = false; // flag for allocation of Rotation Matrix
G4int fcopyNo = 0; // for identification
};
#endif
@@ -61,7 +61,6 @@
// n=0..nReplicas-1
// 29.07.95 P.Kent - First non-stub version
// 26.10.97 J.Apostolakis - Added constructor that takes mother LV
// 13.01.13 G.Cosmo, A.Dotti - Modified for thread-safety for MT
// ----------------------------------------------------------------------
#ifndef G4PVREPLICA_HH
@@ -77,9 +77,9 @@ using G4ReflectedVolumesMap = std::map<G4LogicalVolume*, G4LogicalVolume*,
std::less<G4LogicalVolume*> >;
class G4ReflectionFactory
{
using LogicalVolumesMapIterator = G4ReflectedVolumesMap::const_iterator;
using LogicalVolumesMapIterator = G4ReflectedVolumesMap::const_iterator;
public: // with description
public:
virtual ~G4ReflectionFactory();
// Virtual destructor.
@@ -188,11 +188,11 @@ class G4ReflectionFactory
private:
G4LogicalVolume* ReflectLV(G4LogicalVolume* LV, G4bool surfCheck = false);
G4LogicalVolume* ReflectLV(G4LogicalVolume* LV, G4bool surfCheck = false);
// Gets/creates the reflected solid and logical volume
// and copies + transforms LV daughters.
G4LogicalVolume* CreateReflectedLV(G4LogicalVolume* LV);
G4LogicalVolume* CreateReflectedLV(G4LogicalVolume* LV);
// Creates the reflected solid and logical volume
// and add the logical volumes pair in the maps.
@@ -1,98 +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. *
// ********************************************************************
//
// class G4TouchableHistory
//
// Class description:
//
// Object representing a touchable detector element, and its history in the
// geometrical hierarchy, including its net resultant local->global transform.
// Created: Paul Kent, August 1996
// ----------------------------------------------------------------------
#ifndef G4TOUCHABLEHISTORY_HH
#define G4TOUCHABLEHISTORY_HH
#include "G4VTouchable.hh"
#include "G4NavigationHistory.hh"
#include "G4Allocator.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
#include "geomwdefs.hh"
class G4TouchableHistory : public G4VTouchable
{
public: // with description
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( const G4NavigationHistory& history );
// Copy constructor
~G4TouchableHistory() override;
// Destructor
inline G4VPhysicalVolume* GetVolume( G4int depth = 0 ) const override;
inline G4VSolid* GetSolid( G4int depth = 0 ) const override;
const G4ThreeVector& GetTranslation( G4int depth = 0 ) const override;
const G4RotationMatrix* GetRotation( G4int depth = 0 ) const override;
inline G4int GetReplicaNumber( G4int depth = 0 ) const override;
inline G4int GetHistoryDepth() const override;
G4int MoveUpHistory( G4int num_levels = 1 ) override;
// Access methods for touchables with history
void UpdateYourself( G4VPhysicalVolume* pPhysVol,
const G4NavigationHistory* history = nullptr ) override;
// Update methods for touchables with history
public: // without description
inline const G4NavigationHistory* GetHistory() const override;
// Should this method be "deprecated" ?
// it is used now in G4Navigator::LocateGlobalPointAndSetup
inline void* operator new(size_t);
inline void operator delete(void* aTH);
// Override "new" and "delete" to use "G4Allocator".
private:
inline G4int CalculateHistoryIndex( G4int stackDepth ) const;
G4RotationMatrix frot;
G4ThreeVector ftlate;
G4NavigationHistory fhistory;
};
#include "G4TouchableHistory.icc"
#endif
@@ -34,17 +34,17 @@
// * volume type is similar to G4PVPlacement -- not replicated
// * external navigator may provide 'many'/Boolean operation
// Author: J.Apostolakis, October 2019
// Author: J.Apostolakis, CERN - October 2019
// ----------------------------------------------------------------------
#ifndef G4VEXTERNALPHYSICSVOLUME_HH
#define G4VEXTERNALPHYSICSVOLUME_HH
#define G4VEXTERNALPHYSICSVOLUME_HH 1
#include "G4VPhysicalVolume.hh"
#include "G4Transform3D.hh"
class G4VExternalPhysicalVolume : public G4VPhysicalVolume
{
public: // with description
public:
G4VExternalPhysicalVolume( G4RotationMatrix* pRot,
const G4ThreeVector& tlate,
@@ -69,8 +69,6 @@ class G4VExternalPhysicalVolume : public G4VPhysicalVolume
// Reports a maximum of overlaps errors according to parameter in input.
// Returns true if the volume is overlapping.
public: // without description
G4VExternalPhysicalVolume(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
@@ -102,4 +100,3 @@ class G4VExternalPhysicalVolume : public G4VPhysicalVolume
};
#endif
+4 -26
View File
@@ -12,48 +12,26 @@ geant4_add_module(G4volumes
G4AssemblyVolume.icc
G4EnhancedVecAllocator.hh
G4GeometryWorkspace.hh
G4GRSSolid.hh
G4GRSSolid.icc
G4GRSSolidHandle.hh
G4GRSVolume.hh
G4GRSVolume.icc
G4GRSVolumeHandle.hh
G4LogicalBorderSurface.hh
G4LogicalBorderSurface.icc
G4LogicalSkinSurface.hh
G4LogicalSkinSurface.icc
G4NavigationHistory.hh
G4NavigationHistory.icc
G4NavigationHistoryPool.hh
G4NavigationLevel.hh
G4NavigationLevel.icc
G4NavigationLevelRep.hh
G4NavigationLevelRep.icc
G4PVParameterised.hh
G4PVPlacement.hh
G4PVReplica.hh
G4ReflectionFactory.hh
G4TouchableHistory.hh
G4TouchableHistory.icc
G4TouchableHistoryHandle.hh
G4VExternalPhysicalVolume.hh
G4VExternalPhysicalVolume.hh
SOURCES
G4AssemblyStore.cc
G4AssemblyVolume.cc
G4GeometryWorkspace.cc
G4GRSSolid.cc
G4GRSVolume.cc
G4LogicalBorderSurface.cc
G4LogicalSkinSurface.cc
G4NavigationHistory.cc
G4NavigationHistoryPool.cc
G4NavigationLevel.cc
G4NavigationLevelRep.cc
G4PVParameterised.cc
G4PVPlacement.cc
G4PVReplica.cc
G4ReflectionFactory.cc
G4TouchableHistory.cc
G4VExternalPhysicalVolume.cc)
G4VExternalPhysicalVolume.cc)
geant4_module_link_libraries(G4volumes PUBLIC G4globman G4hepgeometry G4geometrymng)
geant4_module_link_libraries(G4volumes
PUBLIC G4globman G4hepgeometry G4geometrymng)
@@ -23,13 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// G4AssemblyStore
//
// Implementation for singleton container
//
// History:
// 9.10.18 G.Cosmo Initial version
// 9.10.2018 G.Cosmo, CERN - Initial version
// --------------------------------------------------------------------
#include "G4AssemblyVolume.hh"
@@ -25,7 +25,8 @@
//
// Class G4AssemblyVolume - implementation
//
// ----------------------------------------------------------------------
// Author: Radovan Chytracek, CERN - November 2000
// --------------------------------------------------------------------
#include "G4AssemblyVolume.hh"
#include "G4AssemblyStore.hh"
@@ -40,6 +41,7 @@
G4ThreadLocal unsigned int G4AssemblyVolume::fsInstanceCounter = 0;
// --------------------------------------------------------------------
// Default constructor
//
G4AssemblyVolume::G4AssemblyVolume()
@@ -63,6 +65,7 @@ G4AssemblyVolume::G4AssemblyVolume()
}
}
// --------------------------------------------------------------------
// Composing constructor
//
G4AssemblyVolume::G4AssemblyVolume( G4LogicalVolume* volume,
@@ -89,6 +92,7 @@ G4AssemblyVolume::G4AssemblyVolume( G4LogicalVolume* volume,
}
}
// --------------------------------------------------------------------
// Destructor
//
G4AssemblyVolume::~G4AssemblyVolume()
@@ -112,6 +116,7 @@ G4AssemblyVolume::~G4AssemblyVolume()
G4AssemblyStore::GetInstance()->DeRegister(this);
}
// --------------------------------------------------------------------
// Add and place the given volume according to the specified
// translation and rotation.
//
@@ -134,6 +139,7 @@ void G4AssemblyVolume::AddPlacedVolume( G4LogicalVolume* pVolume,
fTriplets.push_back( toAdd );
}
// --------------------------------------------------------------------
// Add and place the given volume according to the specified transformation
//
void G4AssemblyVolume::AddPlacedVolume( G4LogicalVolume* pVolume,
@@ -156,6 +162,7 @@ void G4AssemblyVolume::AddPlacedVolume( G4LogicalVolume* pVolume,
fTriplets.push_back( toAdd );
}
// --------------------------------------------------------------------
// Add and place the given assembly volume according to the specified
// translation and rotation.
//
@@ -171,6 +178,7 @@ void G4AssemblyVolume::AddPlacedAssembly( G4AssemblyVolume* pAssembly,
fTriplets.push_back( toAdd );
}
// --------------------------------------------------------------------
// Add and place the given assembly volume according to the specified
// transformation
//
@@ -195,6 +203,7 @@ void G4AssemblyVolume::AddPlacedAssembly( G4AssemblyVolume* pAssembly,
fTriplets.push_back( toAdd );
}
// --------------------------------------------------------------------
// Create an instance of an assembly volume inside of the specified
// mother volume. This works analogically to making stamp imprints.
// This method makes use of the Geant4 affine transformation class.
@@ -330,6 +339,7 @@ void G4AssemblyVolume::MakeImprint( G4AssemblyVolume* pAssembly,
}
}
// --------------------------------------------------------------------
void G4AssemblyVolume::MakeImprint( G4LogicalVolume* pMotherLV,
G4ThreeVector& translationInMother,
G4RotationMatrix* pRotationInMother,
@@ -357,6 +367,7 @@ void G4AssemblyVolume::MakeImprint( G4LogicalVolume* pMotherLV,
MakeImprint(this, pMotherLV, transform, copyNumBase, surfCheck);
}
// --------------------------------------------------------------------
void G4AssemblyVolume::MakeImprint( G4LogicalVolume* pMotherLV,
G4Transform3D& transformation,
G4int copyNumBase,
@@ -371,21 +382,25 @@ void G4AssemblyVolume::MakeImprint( G4LogicalVolume* pMotherLV,
MakeImprint(this, pMotherLV, transformation, copyNumBase, surfCheck);
}
// --------------------------------------------------------------------
unsigned int G4AssemblyVolume::GetInstanceCount() const
{
return G4AssemblyVolume::fsInstanceCounter;
}
// --------------------------------------------------------------------
void G4AssemblyVolume::SetInstanceCount( unsigned int value )
{
G4AssemblyVolume::fsInstanceCounter = value;
}
// --------------------------------------------------------------------
void G4AssemblyVolume::InstanceCountPlus()
{
G4AssemblyVolume::fsInstanceCounter++;
}
// --------------------------------------------------------------------
void G4AssemblyVolume::InstanceCountMinus()
{
G4AssemblyVolume::fsInstanceCounter--;
-35
View File
@@ -1,35 +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. *
// ********************************************************************
//
// class G4GRSSolid Implementation
//
// ----------------------------------------------------------------------
#include "G4GRSSolid.hh"
G4GRSSolid::~G4GRSSolid()
{
delete frot; // safe if null
}
@@ -1,35 +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. *
// ********************************************************************
//
// class G4GRSVolume Implementation
//
// ----------------------------------------------------------------------
#include "G4GRSVolume.hh"
G4GRSVolume::~G4GRSVolume()
{
delete frot; // safe if null
}
@@ -28,7 +28,7 @@
// A Logical Surface class for surfaces defined by the boundary
// of two physical volumes.
//
// Author: John Apostolakis (John.Apostolakis@cern.ch), 26-06-1997
// Author: John Apostolakis, CERN - 26-06-1997
// --------------------------------------------------------------------
#include "G4LogicalBorderSurface.hh"
@@ -37,10 +37,9 @@
G4LogicalBorderSurfaceTable*
G4LogicalBorderSurface::theBorderSurfaceTable = nullptr;
//
// --------------------------------------------------------------------
// Constructor
//
G4LogicalBorderSurface::
G4LogicalBorderSurface(const G4String& name,
G4VPhysicalVolume* vol1,
@@ -60,32 +59,26 @@ G4LogicalBorderSurface(const G4String& name,
theBorderSurfaceTable->insert(std::make_pair(std::make_pair(vol1,vol2),this));
}
//
// --------------------------------------------------------------------
// Default destructor
//
G4LogicalBorderSurface::~G4LogicalBorderSurface() = default;
//
// Operators
//
// --------------------------------------------------------------------
G4bool
G4LogicalBorderSurface::operator==(const G4LogicalBorderSurface &right) const
{
return (this == (G4LogicalBorderSurface *) &right);
}
// --------------------------------------------------------------------
G4bool
G4LogicalBorderSurface::operator!=(const G4LogicalBorderSurface &right) const
{
return (this != (G4LogicalBorderSurface *) &right);
}
//
// Methods
//
// --------------------------------------------------------------------
const G4LogicalBorderSurfaceTable* G4LogicalBorderSurface::GetSurfaceTable()
{
if (theBorderSurfaceTable == nullptr)
@@ -95,6 +88,7 @@ const G4LogicalBorderSurfaceTable* G4LogicalBorderSurface::GetSurfaceTable()
return theBorderSurfaceTable;
}
// --------------------------------------------------------------------
std::size_t G4LogicalBorderSurface::GetNumberOfBorderSurfaces()
{
if (theBorderSurfaceTable != nullptr)
@@ -104,6 +98,7 @@ std::size_t G4LogicalBorderSurface::GetNumberOfBorderSurfaces()
return 0;
}
// --------------------------------------------------------------------
G4LogicalBorderSurface*
G4LogicalBorderSurface::GetSurface(const G4VPhysicalVolume* vol1,
const G4VPhysicalVolume* vol2)
@@ -116,6 +111,7 @@ G4LogicalBorderSurface::GetSurface(const G4VPhysicalVolume* vol1,
return nullptr;
}
// --------------------------------------------------------------------
// Dump info for known surfaces
//
void G4LogicalBorderSurface::DumpInfo()
@@ -137,6 +133,7 @@ void G4LogicalBorderSurface::DumpInfo()
G4cout << G4endl;
}
// --------------------------------------------------------------------
void G4LogicalBorderSurface::CleanSurfaceTable()
{
if (theBorderSurfaceTable != nullptr)
@@ -28,7 +28,7 @@
// A Logical Surface class for the surface surrounding a single
// logical volume.
//
// Author: John Apostolakis (John.Apostolakis@cern.ch), 26-06-1997
// Author: John Apostolakis, CERN - 26-06-1997
// --------------------------------------------------------------------
#include "G4LogicalSkinSurface.hh"
@@ -36,10 +36,9 @@
G4LogicalSkinSurfaceTable *G4LogicalSkinSurface::theSkinSurfaceTable = nullptr;
//
// --------------------------------------------------------------------
// Constructor
//
G4LogicalSkinSurface::G4LogicalSkinSurface(const G4String& name,
G4LogicalVolume* logicalVolume,
G4SurfaceProperty* surfaceProperty)
@@ -55,32 +54,26 @@ G4LogicalSkinSurface::G4LogicalSkinSurface(const G4String& name,
theSkinSurfaceTable->push_back(this);
}
//
// --------------------------------------------------------------------
// Default destructor
//
G4LogicalSkinSurface::~G4LogicalSkinSurface() = default;
//
// Operators
//
// --------------------------------------------------------------------
G4bool
G4LogicalSkinSurface::operator==(const G4LogicalSkinSurface& right) const
{
return (this == (G4LogicalSkinSurface *) &right);
}
// --------------------------------------------------------------------
G4bool
G4LogicalSkinSurface::operator!=(const G4LogicalSkinSurface& right) const
{
return (this != (G4LogicalSkinSurface *) &right);
}
//
// Methods
//
// --------------------------------------------------------------------
const G4LogicalSkinSurfaceTable* G4LogicalSkinSurface::GetSurfaceTable()
{
if (theSkinSurfaceTable == nullptr)
@@ -90,6 +83,7 @@ const G4LogicalSkinSurfaceTable* G4LogicalSkinSurface::GetSurfaceTable()
return theSkinSurfaceTable;
}
// --------------------------------------------------------------------
size_t G4LogicalSkinSurface::GetNumberOfSkinSurfaces()
{
if (theSkinSurfaceTable != nullptr)
@@ -99,6 +93,7 @@ size_t G4LogicalSkinSurface::GetNumberOfSkinSurfaces()
return 0;
}
// --------------------------------------------------------------------
G4LogicalSkinSurface*
G4LogicalSkinSurface::GetSurface(const G4LogicalVolume* vol)
{
@@ -112,6 +107,7 @@ G4LogicalSkinSurface::GetSurface(const G4LogicalVolume* vol)
return nullptr;
}
// --------------------------------------------------------------------
// Dump info for known surfaces
//
void G4LogicalSkinSurface::DumpInfo()
@@ -132,6 +128,7 @@ void G4LogicalSkinSurface::DumpInfo()
G4cout << G4endl;
}
// --------------------------------------------------------------------
void G4LogicalSkinSurface::CleanSurfaceTable()
{
if (theSkinSurfaceTable != nullptr)
+1 -1
View File
@@ -25,6 +25,7 @@
//
// class G4PVPlacement Implementation
//
// 24.07.95 P.Kent, First non-stub version.
// ----------------------------------------------------------------------
#include "G4PVPlacement.hh"
@@ -114,7 +115,6 @@ G4PVPlacement::G4PVPlacement( G4RotationMatrix* pRot,
if ((pSurfChk) && ((pMotherLogical) != nullptr)) { CheckOverlaps(); }
}
// ----------------------------------------------------------------------
// Constructor
//
+1 -2
View File
@@ -135,8 +135,7 @@ G4PVReplica::G4PVReplica( const G4String& pName,
G4int nReplicas,
EAxis pAxis,
G4LogicalVolume* pLogical,
G4LogicalVolume* pMotherLogical
)
G4LogicalVolume* pMotherLogical )
: G4VPhysicalVolume(nullptr, G4ThreeVector(), pName, pLogical, nullptr)
{
// Constructor for derived type(s)
@@ -45,7 +45,7 @@
// = TV * R * TD * x(inD)
// = TV * R*TD*R-1 * R*x(inD)
// = TV * ReflTD * x(inReflD)
//
// Author: Ivana Hrivnacova (Ivana.Hrivnacova@cern.ch), 16.10.2001
// --------------------------------------------------------------------
@@ -25,7 +25,7 @@
//
// G4VExternalPhysicalVolume Implementation
//
// Author: J.Apostolakis, October 2019
// Author: J.Apostolakis, CERN - October 2019
// ----------------------------------------------------------------------
#include "G4VExternalPhysicalVolume.hh"