Import Geant4 10.7.0.beta source tree
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# CMakeLists.txt
|
||||
# Module : G4navigation
|
||||
# Package: Geant4.src.G4geometry.G4navigation
|
||||
#
|
||||
# CMakeLists.txt for building a single granular library.
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
if(GEANT4_BUILD_GRANULAR_LIBS)
|
||||
include(Geant4MacroLibraryTargets)
|
||||
GEANT4_GRANULAR_LIBRARY_TARGET(COMPONENT sources.cmake)
|
||||
endif()
|
||||
|
||||
@@ -16,11 +16,51 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
February 5, 2020 - P.Arce (geomnav-V10-05-20)
|
||||
June 15, 2020 - G.Cosmo (geomnav-V10-06-05)
|
||||
-----------------------
|
||||
- Fixed Coverity defects in G4LocatorChangeRecord and some code cleanup.
|
||||
|
||||
June 8, 2020 - G.Cosmo (geomnav-V10-06-04)
|
||||
----------------------
|
||||
- Enabled "check-mode" for G4PropagatorInField and G4VIntersectionLocator.
|
||||
Enable use of whiteboard for logging/debugging in G4MultiLevelLocator, if
|
||||
"check-mode" in navigation is being activated through UI command.
|
||||
|
||||
May 28, 2020 - J.Apostolakis (geomnav-V10-06-03)
|
||||
----------------------------
|
||||
- G4MultiLevelLocator: introduced whiteboard for logging/debugging in
|
||||
G4MultiLevelLocator, to help identify source(s) of recent issues seen
|
||||
in CMS and Belle2.
|
||||
Activating the following:
|
||||
* Record points ( e.g. A, B, H ) changes using G4LocatorChangeRecord
|
||||
* Report when a problem is encountered.
|
||||
* Improved reports of check of distance of endpoints <= the curve length.
|
||||
and of exception of interval start A being past end B during integration.
|
||||
* New separate name for return of intersection 'PointGi'.
|
||||
Improved PiF ClearPropagatorState.
|
||||
- New classes G4LocatorChangeLogger and G4LocatorChangeRecord, implementing
|
||||
simple 'whiteboard' to store successive curve-point values (e.g. start(A)
|
||||
or end(B) ).
|
||||
- G4PropagationInField: improved ClearPropagatorState() method.
|
||||
Clears values of additional data members.
|
||||
|
||||
March 24, 2020 - J.Apostolakis (geomnav-V10-06-02)
|
||||
------------------------------
|
||||
- Reordered the data members of G4Navigator, to reduce size
|
||||
of G4Navigator object(s), as compromise between full compactification and
|
||||
keeping some related data members declarations close.
|
||||
Inspired by the effort of G.Amadio in this direction.
|
||||
|
||||
February 5, 2020 - P.Arce (geomnav-V10-06-01)
|
||||
-------------------------
|
||||
- Fixed problem report #2196.
|
||||
- Addressing problem report #2196.
|
||||
Avoid looping infinitely by pushing N times with increasing step size.
|
||||
|
||||
December 10, 2019 - B.Morgan (geomnav-V10-06-0)
|
||||
----------------------------
|
||||
- Cleanup CMake build, removing obsolete granular library options and
|
||||
explicit include_directories.
|
||||
|
||||
November 29, 2019 - J.Apostolakis (geomnav-V10-05-19)
|
||||
---------------------------------
|
||||
- Added method to PropagatorInField to Get/Set new parameter that
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4LocatorChangeLogger
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Aggregate the records of changes in an endpoint of a locator.
|
||||
// Its key use is in playing these back in case of a problem.
|
||||
|
||||
// Author: John Apostolakis, 04.09.19 - First version
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4LOCATOR_CHANGE_LOGGER_HH
|
||||
#define G4LOCATOR_CHANGE_LOGGER_HH
|
||||
|
||||
#include <vector>
|
||||
#include "G4LocatorChangeRecord.hh"
|
||||
#include "G4FieldTrack.hh"
|
||||
|
||||
class G4LocatorChangeLogger : public std::vector<G4LocatorChangeRecord>
|
||||
{
|
||||
public:
|
||||
|
||||
G4LocatorChangeLogger( const std::string name ) : fName(name) {}
|
||||
|
||||
void AddRecord( G4LocatorChangeRecord && chngRecord );
|
||||
void AddRecord( const G4LocatorChangeRecord & chngRecord );
|
||||
|
||||
// Create a new record with full information
|
||||
inline
|
||||
void AddRecord( G4LocatorChangeRecord::EChangeLocation codeLocation,
|
||||
G4int iter,
|
||||
unsigned int count,
|
||||
const G4FieldTrack & fieldTrack );
|
||||
|
||||
friend std::ostream& operator << ( std::ostream& os,
|
||||
const G4LocatorChangeLogger& logR );
|
||||
std::ostream& StreamInfo(std::ostream& os) const;
|
||||
|
||||
static std::ostream& ReportEndChanges ( std::ostream& os,
|
||||
const G4LocatorChangeLogger& startA,
|
||||
const G4LocatorChangeLogger& endB );
|
||||
// Print the changes in start, end points in columns
|
||||
// One event per row
|
||||
|
||||
private:
|
||||
|
||||
const std::string fName;
|
||||
};
|
||||
|
||||
// --------------
|
||||
// Inline methods
|
||||
// --------------
|
||||
|
||||
void G4LocatorChangeLogger::
|
||||
AddRecord( G4LocatorChangeRecord::EChangeLocation codeLocation,
|
||||
G4int iter, unsigned int count,
|
||||
const G4FieldTrack & fieldTrack )
|
||||
{
|
||||
this->push_back(G4LocatorChangeRecord(codeLocation, iter, count, fieldTrack));
|
||||
}
|
||||
|
||||
inline
|
||||
void G4LocatorChangeLogger::
|
||||
AddRecord( const G4LocatorChangeRecord& chngRecord )
|
||||
{
|
||||
this->push_back( chngRecord );
|
||||
}
|
||||
|
||||
inline
|
||||
void G4LocatorChangeLogger::
|
||||
AddRecord( G4LocatorChangeRecord && chngRecord )
|
||||
{
|
||||
this->push_back( chngRecord );
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4LocatorChangeRecord
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Record the changes in an endpoint of a locator.
|
||||
// Its key use is in playing these back in case of a problem.
|
||||
|
||||
// Author: John Apostolakis, 27.08.19 - First version
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4LOCATOR_CHANGE_RECORD_HH
|
||||
#define G4LOCATOR_CHANGE_RECORD_HH
|
||||
|
||||
#include <vector>
|
||||
#include "G4FieldTrack.hh"
|
||||
|
||||
class G4LocatorChangeRecord
|
||||
{
|
||||
public:
|
||||
|
||||
enum EChangeLocation { kInvalidCL = 0, kUnknownCL = 1, // 2
|
||||
kInitialisingCL, kIntersectsAF, kIntersectsFB, // 3
|
||||
kNoIntersectAForFB, kRecalculatedB, // 2
|
||||
kInsertingMidPoint, kRecalculatedBagn, // 2
|
||||
kLevelPop };
|
||||
|
||||
static const char* fNameChangeLocation[];
|
||||
static const char* GetNameChangeLocation( EChangeLocation );
|
||||
|
||||
G4LocatorChangeRecord( EChangeLocation codeLocation,
|
||||
G4int iter,
|
||||
unsigned int count,
|
||||
const G4FieldTrack& fieldTrack )
|
||||
: fCodeLocation( codeLocation), fIteration(iter), fEventCount(count),
|
||||
fFieldTrack( fieldTrack ) {}
|
||||
G4LocatorChangeRecord( const G4LocatorChangeRecord & ) = default;
|
||||
G4LocatorChangeRecord( G4LocatorChangeRecord && ) = default;
|
||||
|
||||
// No set methods -> create a new record for each entry (more reliable)
|
||||
// void SetLocation( EChangeLocation loc ) { fCodeLocation= loc; }
|
||||
// void SetLength( double len ) { fLength= len; }
|
||||
// void SetCount( int cnt ) { fEventCount= cnt; }
|
||||
// void SetIteration( int iter ) { fIteration= iter; }
|
||||
|
||||
inline EChangeLocation GetLocation() const { return fCodeLocation; }
|
||||
inline unsigned int GetCount() const { return fEventCount; }
|
||||
inline G4int GetIteration() const { return fIteration; }
|
||||
inline G4double GetLength() const { return fFieldTrack.GetCurveLength(); }
|
||||
|
||||
friend std::ostream& operator<< ( std::ostream& os,
|
||||
const G4LocatorChangeRecord& r );
|
||||
// Streaming operator, using StreamInfo().
|
||||
|
||||
friend std::ostream& operator<< ( std::ostream& os,
|
||||
const std::vector<G4LocatorChangeRecord> & vecR );
|
||||
|
||||
std::ostream& StreamInfo(std::ostream& os) const;
|
||||
|
||||
static std::ostream& ReportVector ( std::ostream& os,
|
||||
const std::string & nameOfRecord,
|
||||
const std::vector<G4LocatorChangeRecord> & lcr );
|
||||
|
||||
static std::ostream& ReportEndChanges ( std::ostream& os,
|
||||
const std::vector<G4LocatorChangeRecord> & startA,
|
||||
const std::vector<G4LocatorChangeRecord> & endB );
|
||||
|
||||
private:
|
||||
|
||||
EChangeLocation fCodeLocation = kInvalidCL;
|
||||
G4int fIteration = -1;
|
||||
unsigned int fEventCount = 0;
|
||||
G4FieldTrack fFieldTrack;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -379,6 +379,16 @@ class G4Navigator
|
||||
// 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.
|
||||
|
||||
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).
|
||||
@@ -391,19 +401,52 @@ class G4Navigator
|
||||
|
||||
G4bool fWasLimitedByGeometry = false;
|
||||
// Set true if last Step was limited by geometry.
|
||||
|
||||
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].
|
||||
|
||||
|
||||
private:
|
||||
|
||||
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 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
|
||||
|
||||
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.)
|
||||
|
||||
// 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
|
||||
|
||||
G4bool fActive = false;
|
||||
// States if the navigator is activated or not.
|
||||
|
||||
@@ -421,60 +464,26 @@ class G4Navigator
|
||||
// o If entering
|
||||
// volume ptr & replica number (set by ComputeStep(),used by
|
||||
// Locate..()) of volume for `automatic' entry
|
||||
|
||||
G4VPhysicalVolume* fBlockedPhysicalVolume;
|
||||
G4int fBlockedReplicaNo;
|
||||
|
||||
G4ThreeVector fLastLocatedPointLocal;
|
||||
// Position of the last located point relative to its containing volume.
|
||||
G4bool fLocatedOutsideWorld;
|
||||
// Whether the last call to Locate methods left the world
|
||||
|
||||
|
||||
G4bool fValidExitNormal; // Set true if have leaving volume normal
|
||||
G4ThreeVector fExitNormal; // Leaving volume normal, in the
|
||||
// volume containing the exited
|
||||
// volume's coordinate system
|
||||
G4ThreeVector fGrandMotherExitNormal; // Leaving volume normal, in its
|
||||
// own coordinate system
|
||||
G4bool fChangedGrandMotherRefFrame; // Whether frame is changed
|
||||
|
||||
G4ThreeVector fExitNormalGlobalFrame; // Leaving volume normal, in the
|
||||
// global coordinate system
|
||||
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
|
||||
|
||||
// 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
|
||||
//
|
||||
G4bool fLastStepWasZero;
|
||||
// Whether the last ComputeStep moved Zero. Used to check for edges.
|
||||
|
||||
G4bool fLocatedOnEdge;
|
||||
// Whether the Navigator has detected an edge
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
//
|
||||
// END State information
|
||||
//
|
||||
|
||||
// Optional State information (created/used as needed)
|
||||
//
|
||||
|
||||
// Save key state information (NOT the navigation history stack)
|
||||
//
|
||||
struct G4SaveNavigatorState
|
||||
@@ -496,19 +505,13 @@ class G4Navigator
|
||||
G4double sPreviousSafety;
|
||||
} fSaveState;
|
||||
|
||||
// Tracking Invariants
|
||||
//
|
||||
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.
|
||||
|
||||
// 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;
|
||||
@@ -517,7 +520,16 @@ class G4Navigator
|
||||
G4ReplicaNavigation freplicaNav;
|
||||
G4RegularNavigation fregularNav;
|
||||
G4VExternalNavigation* fpExternalNav = nullptr;
|
||||
G4VoxelSafety* fpVoxelSafety;
|
||||
G4VoxelSafety* fpVoxelSafety;
|
||||
|
||||
// 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"
|
||||
|
||||
@@ -92,6 +92,7 @@ class G4PropagatorInField
|
||||
G4int SetVerboseLevel( G4int verbose );
|
||||
inline G4int GetVerboseLevel() const;
|
||||
inline G4int Verbose() const;
|
||||
inline void CheckMode(G4bool mode);
|
||||
|
||||
inline void SetVerboseTrace( G4bool enable );
|
||||
inline G4bool GetVerboseTrace();
|
||||
@@ -293,6 +294,7 @@ class G4PropagatorInField
|
||||
|
||||
G4int fVerboseLevel = 0;
|
||||
G4bool fVerbTracePiF = false;
|
||||
G4bool fCheck = false;
|
||||
// For debugging purposes
|
||||
|
||||
G4bool fFirstStepInVolume = true;
|
||||
|
||||
@@ -150,6 +150,18 @@ G4bool G4PropagatorInField::GetVerboseTrace()
|
||||
return fVerbTracePiF;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
inline
|
||||
void G4PropagatorInField::CheckMode(G4bool mode)
|
||||
{
|
||||
fCheck = mode;
|
||||
if (fIntersectionLocator != nullptr)
|
||||
{
|
||||
fIntersectionLocator->SetCheckMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
inline
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
// navigation does not stop at the surface
|
||||
|
||||
// History:
|
||||
// - Created. P.Arce, May 2007
|
||||
// - Created. P. Arce, May 2007
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4RegularNavigation_HH
|
||||
#define G4RegularNavigation_HH
|
||||
@@ -119,22 +119,21 @@ class G4RegularNavigation
|
||||
|
||||
G4int fverbose = false;
|
||||
G4bool fcheck = false;
|
||||
|
||||
|
||||
G4NormalNavigation* fnormalNav = nullptr;
|
||||
G4double kCarTolerance;
|
||||
G4double fMinStep;
|
||||
|
||||
|
||||
G4bool fLastStepWasZero;
|
||||
// Whether the last ComputeStep moved Zero. Used to check for edges.
|
||||
G4int fNumberZeroSteps;
|
||||
// Number of preceding moves that were Zero. Reset to 0 after finite step
|
||||
G4int fActionThreshold_NoZeroSteps;
|
||||
// After this many failed/zero steps, act (push etc)
|
||||
G4int fAbandonThreshold_NoZeroSteps;
|
||||
G4int fActionThreshold_NoZeroSteps;
|
||||
// After this many failed/zero steps, act (push etc)
|
||||
G4int fAbandonThreshold_NoZeroSteps;
|
||||
// After this many failed/zero steps, abandon track
|
||||
G4int fNoStepsAllowed;
|
||||
// Maximum number of steps a track can travel skipping voxels
|
||||
// (if there are more, track is assumed to be stuck and it is killed)
|
||||
// Maximum number of steps a track can travel skipping voxels (if there are more, track is assumed to be stuck and it is killed)
|
||||
G4bool fWarnPush;
|
||||
// Send warning message that a stuck particle has been pushed
|
||||
};
|
||||
|
||||
@@ -126,7 +126,10 @@ class G4VIntersectionLocator
|
||||
std::ostream& oss,
|
||||
G4int verboseLevel );
|
||||
// Print Method for any ostream - e.g. cerr -- and for G4Exception
|
||||
|
||||
|
||||
inline void SetCheckMode( G4bool value ) { fCheckMode = value; }
|
||||
inline G4bool GetCheckMode() { return fCheckMode; }
|
||||
|
||||
protected: // with description
|
||||
|
||||
G4FieldTrack ReEstimateEndpoint( const G4FieldTrack& CurrentStateA,
|
||||
@@ -197,9 +200,6 @@ class G4VIntersectionLocator
|
||||
G4int CheckMode );
|
||||
// As above, but report information about code location.
|
||||
// If CheckMode > 1, report extra information.
|
||||
|
||||
inline void SetCheckMode( G4bool value ) { fCheckMode = value; }
|
||||
inline G4bool GetCheckMode() { return fCheckMode; }
|
||||
|
||||
protected: // without description
|
||||
|
||||
@@ -254,13 +254,13 @@ class G4VIntersectionLocator
|
||||
G4int fVerboseLevel = 0; // For debugging
|
||||
G4bool fUseNormalCorrection = false; // Configuration parameter
|
||||
G4bool fCheckMode = false;
|
||||
G4bool fiUseSafety = false; // Whether to use safety for 'fast steps'
|
||||
|
||||
G4Navigator* fiNavigator;
|
||||
|
||||
G4ChordFinder* fiChordFinder = nullptr; // Overridden at each step
|
||||
G4double fiEpsilonStep = -1.0; // Overridden at each step
|
||||
G4double fiDeltaIntersection = -1.0; // Overridden at each step
|
||||
G4bool fiUseSafety = false; // Overridden at each step
|
||||
// Parameters set at each physical step by calling method
|
||||
// by G4PropagatorInField
|
||||
|
||||
|
||||
@@ -1,119 +1,95 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# sources.cmake
|
||||
# Module : G4navigation
|
||||
# Package: Geant4.src.G4geometry.G4navigation
|
||||
#
|
||||
# Sources description for a library.
|
||||
# Lists the sources and headers of the code explicitely.
|
||||
# Lists include paths needed.
|
||||
# Lists the internal granular and global dependencies of the library.
|
||||
# Source specific properties should be added at the end.
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# List external includes needed.
|
||||
include_directories(${CLHEP_INCLUDE_DIRS})
|
||||
|
||||
# List internal includes needed.
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/magneticfield/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/management/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/volumes/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/graphics_reps/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/intercoms/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/materials/include)
|
||||
|
||||
#
|
||||
# Define the Geant4 Module.
|
||||
#
|
||||
include(Geant4MacroDefineModule)
|
||||
GEANT4_DEFINE_MODULE(NAME G4navigation
|
||||
HEADERS
|
||||
G4AuxiliaryNavServices.hh
|
||||
G4AuxiliaryNavServices.icc
|
||||
G4BrentLocator.hh
|
||||
G4DrawVoxels.hh
|
||||
G4ErrorPropagationNavigator.hh
|
||||
G4GeomTestVolume.hh
|
||||
G4GeometryMessenger.hh
|
||||
G4GlobalMagFieldMessenger.hh
|
||||
G4MultiLevelLocator.hh
|
||||
G4MultiNavigator.hh
|
||||
G4NavigationLogger.hh
|
||||
G4Navigator.hh
|
||||
G4Navigator.icc
|
||||
G4NormalNavigation.hh
|
||||
G4NormalNavigation.icc
|
||||
G4ParameterisedNavigation.hh
|
||||
G4ParameterisedNavigation.icc
|
||||
G4PartialPhantomParameterisation.hh
|
||||
G4PathFinder.hh
|
||||
G4PhantomParameterisation.hh
|
||||
G4PhantomParameterisation.icc
|
||||
G4PropagatorInField.hh
|
||||
G4PropagatorInField.icc
|
||||
G4RegularNavigation.hh
|
||||
G4RegularNavigationHelper.hh
|
||||
G4ReplicaNavigation.hh
|
||||
G4ReplicaNavigation.icc
|
||||
G4SafetyHelper.hh
|
||||
G4SimpleLocator.hh
|
||||
G4TransportationManager.hh
|
||||
G4TransportationManager.icc
|
||||
G4VExternalNavigation.hh
|
||||
G4VIntersectionLocator.hh
|
||||
G4VIntersectionLocator.icc
|
||||
G4VoxelNavigation.hh
|
||||
G4VoxelNavigation.icc
|
||||
G4VoxelSafety.hh
|
||||
SOURCES
|
||||
G4AuxiliaryNavServices.cc
|
||||
G4BrentLocator.cc
|
||||
G4DrawVoxels.cc
|
||||
G4ErrorPropagationNavigator.cc
|
||||
G4GeomTestVolume.cc
|
||||
G4GeometryMessenger.cc
|
||||
G4GlobalMagFieldMessenger.cc
|
||||
G4MultiLevelLocator.cc
|
||||
G4MultiNavigator.cc
|
||||
G4NavigationLogger.cc
|
||||
G4Navigator.cc
|
||||
G4NormalNavigation.cc
|
||||
G4ParameterisedNavigation.cc
|
||||
G4PartialPhantomParameterisation.cc
|
||||
G4PathFinder.cc
|
||||
G4PhantomParameterisation.cc
|
||||
G4PropagatorInField.cc
|
||||
G4RegularNavigation.cc
|
||||
G4RegularNavigationHelper.cc
|
||||
G4ReplicaNavigation.cc
|
||||
G4SafetyHelper.cc
|
||||
G4SimpleLocator.cc
|
||||
G4TransportationManager.cc
|
||||
G4VExternalNavigation.cc
|
||||
G4VIntersectionLocator.cc
|
||||
G4VoxelNavigation.cc
|
||||
G4VoxelSafety.cc
|
||||
GRANULAR_DEPENDENCIES
|
||||
G4geometrymng
|
||||
G4globman
|
||||
G4graphics_reps
|
||||
G4intercoms
|
||||
G4magneticfield
|
||||
G4materials
|
||||
G4volumes
|
||||
GLOBAL_DEPENDENCIES
|
||||
G4global
|
||||
G4graphics_reps
|
||||
G4intercoms
|
||||
G4materials
|
||||
LINK_LIBRARIES
|
||||
geant4_define_module(NAME G4navigation
|
||||
HEADERS
|
||||
G4AuxiliaryNavServices.hh
|
||||
G4AuxiliaryNavServices.icc
|
||||
G4BrentLocator.hh
|
||||
G4DrawVoxels.hh
|
||||
G4ErrorPropagationNavigator.hh
|
||||
G4GeomTestVolume.hh
|
||||
G4GeometryMessenger.hh
|
||||
G4GlobalMagFieldMessenger.hh
|
||||
G4LocatorChangeRecord.hh
|
||||
G4LocatorChangeLogger.hh
|
||||
G4MultiLevelLocator.hh
|
||||
G4MultiNavigator.hh
|
||||
G4NavigationLogger.hh
|
||||
G4Navigator.hh
|
||||
G4Navigator.icc
|
||||
G4NormalNavigation.hh
|
||||
G4NormalNavigation.icc
|
||||
G4ParameterisedNavigation.hh
|
||||
G4ParameterisedNavigation.icc
|
||||
G4PartialPhantomParameterisation.hh
|
||||
G4PathFinder.hh
|
||||
G4PhantomParameterisation.hh
|
||||
G4PhantomParameterisation.icc
|
||||
G4PropagatorInField.hh
|
||||
G4PropagatorInField.icc
|
||||
G4RegularNavigation.hh
|
||||
G4RegularNavigationHelper.hh
|
||||
G4ReplicaNavigation.hh
|
||||
G4ReplicaNavigation.icc
|
||||
G4SafetyHelper.hh
|
||||
G4SimpleLocator.hh
|
||||
G4TransportationManager.hh
|
||||
G4TransportationManager.icc
|
||||
G4VExternalNavigation.hh
|
||||
G4VIntersectionLocator.hh
|
||||
G4VIntersectionLocator.icc
|
||||
G4VoxelNavigation.hh
|
||||
G4VoxelNavigation.icc
|
||||
G4VoxelSafety.hh
|
||||
SOURCES
|
||||
G4AuxiliaryNavServices.cc
|
||||
G4BrentLocator.cc
|
||||
G4DrawVoxels.cc
|
||||
G4ErrorPropagationNavigator.cc
|
||||
G4GeomTestVolume.cc
|
||||
G4GeometryMessenger.cc
|
||||
G4GlobalMagFieldMessenger.cc
|
||||
G4LocatorChangeRecord.cc
|
||||
G4LocatorChangeLogger.cc
|
||||
G4MultiLevelLocator.cc
|
||||
G4MultiNavigator.cc
|
||||
G4NavigationLogger.cc
|
||||
G4Navigator.cc
|
||||
G4NormalNavigation.cc
|
||||
G4ParameterisedNavigation.cc
|
||||
G4PartialPhantomParameterisation.cc
|
||||
G4PathFinder.cc
|
||||
G4PhantomParameterisation.cc
|
||||
G4PropagatorInField.cc
|
||||
G4RegularNavigation.cc
|
||||
G4RegularNavigationHelper.cc
|
||||
G4ReplicaNavigation.cc
|
||||
G4SafetyHelper.cc
|
||||
G4SimpleLocator.cc
|
||||
G4TransportationManager.cc
|
||||
G4VExternalNavigation.cc
|
||||
G4VIntersectionLocator.cc
|
||||
G4VoxelNavigation.cc
|
||||
G4VoxelSafety.cc
|
||||
GRANULAR_DEPENDENCIES
|
||||
G4geometrymng
|
||||
G4globman
|
||||
G4graphics_reps
|
||||
G4intercoms
|
||||
G4magneticfield
|
||||
G4materials
|
||||
G4volumes
|
||||
GLOBAL_DEPENDENCIES
|
||||
G4global
|
||||
G4graphics_reps
|
||||
G4intercoms
|
||||
G4materials
|
||||
)
|
||||
|
||||
# List any source specific properties here
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Navigator.hh"
|
||||
#include "G4PropagatorInField.hh"
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
@@ -317,6 +318,8 @@ G4GeometryMessenger::SetCheckMode(G4String input)
|
||||
G4bool mode = chkCmd->GetNewBoolValue(input);
|
||||
G4Navigator* navigator = tmanager->GetNavigatorForTracking();
|
||||
navigator->CheckMode(mode);
|
||||
G4PropagatorInField* pField = tmanager->GetPropagatorInField();
|
||||
if (pField != nullptr) { pField->CheckMode(mode); }
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4LocatorChangeLogger class implementation
|
||||
//
|
||||
// Author: John Apostolakis, 04.09.19 - First version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
// #include <cassert>
|
||||
|
||||
#include "G4LocatorChangeLogger.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Streaming operator dumping record
|
||||
//
|
||||
std::ostream& operator<< ( std::ostream& os,
|
||||
const G4LocatorChangeLogger& logger )
|
||||
{
|
||||
return logger.StreamInfo(os);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Stream object contents to an output stream
|
||||
//
|
||||
std::ostream& G4LocatorChangeLogger::StreamInfo(std::ostream& os) const
|
||||
{
|
||||
G4int oldprc = os.precision(16);
|
||||
G4LocatorChangeRecord::ReportVector( os, this->fName, *this );
|
||||
os.precision(oldprc);
|
||||
return os;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Print the changes in start, end points in columns -- one event per row
|
||||
//
|
||||
std::ostream& G4LocatorChangeLogger::ReportEndChanges( std::ostream& os,
|
||||
const G4LocatorChangeLogger & startA,
|
||||
const G4LocatorChangeLogger & endB )
|
||||
{
|
||||
using std::setw;
|
||||
G4int prec= 16;
|
||||
const G4bool confirm = true;
|
||||
G4int oldprc = os.precision(prec);
|
||||
|
||||
auto itrecA= startA.cbegin();
|
||||
auto itrecB= endB.cbegin();
|
||||
|
||||
os << "====================================================================="
|
||||
<< G4endl;
|
||||
os << " Size of individual change record: startA : " << startA.size()
|
||||
<< " endB : " << endB.size() << G4endl;
|
||||
os << "====================================================================="
|
||||
<< G4endl;
|
||||
|
||||
os << setw( 7 ) << "Change#" << " "
|
||||
<< setw( 4 ) << "Iter" << " "
|
||||
<< setw( 20 ) << "CodeLocation" << " "
|
||||
<< setw( prec+9 ) << "Length-A (start)" << " "
|
||||
<< setw( prec+9 ) << "Length-B (end)" << " "
|
||||
<< G4endl;
|
||||
os << "=====================================================================";
|
||||
|
||||
auto eventA = (*itrecA).GetCount();
|
||||
auto eventB = (*itrecB).GetCount();
|
||||
|
||||
G4bool isLastA= false;
|
||||
G4bool isLastB= false;
|
||||
|
||||
G4int jA=0, jB=0;
|
||||
|
||||
G4int maxEvent = std::max( startA[ startA.size() - 1 ].GetCount() ,
|
||||
endB[ endB.size() - 1 ].GetCount() );
|
||||
G4int prevA = -1;
|
||||
G4int prevB = -1;
|
||||
|
||||
G4bool advanceA= false, advanceB= false;
|
||||
do
|
||||
{
|
||||
advanceA= false;
|
||||
advanceB= false;
|
||||
|
||||
if( ((G4int)eventA>prevA) && ((G4int)eventB>prevB) )
|
||||
{
|
||||
auto codeLocA= (*itrecA).GetLocation();
|
||||
|
||||
os << G4endl;
|
||||
os << setw( 7 ) << eventA << " "
|
||||
<< setw( 4 ) << (*itrecA).GetIteration() << " "
|
||||
<< setw( 3 ) << codeLocA << " "
|
||||
<< setw( 15 )
|
||||
<< G4LocatorChangeRecord::GetNameChangeLocation( codeLocA ) << " "
|
||||
<< setw( prec+9 ) << (*itrecA).GetLength() << " "
|
||||
<< setw( prec+9 ) << (*itrecB).GetLength() << " ";
|
||||
if( confirm )
|
||||
{
|
||||
os << setw( 4 ) << (*itrecB).GetIteration() << " "
|
||||
<< setw( 15 ) << (*itrecB).GetLocation();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (G4int)eventA > prevA )
|
||||
{
|
||||
auto codeLocA= (*itrecA).GetLocation();
|
||||
os << G4endl;
|
||||
os << setw( 7 ) << (*itrecA).GetCount() << " "
|
||||
<< setw( 4 ) << (*itrecA).GetIteration() << " "
|
||||
<< setw( 3 ) << codeLocA << " "
|
||||
<< setw( 15 )
|
||||
<< G4LocatorChangeRecord::GetNameChangeLocation( codeLocA ) << " "
|
||||
<< setw( prec+9 ) << (*itrecA).GetLength() << " "
|
||||
<< setw( prec+9 ) << " " << " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
// assert( (G4int)eventB > prevB );
|
||||
auto codeLocB= (*itrecB).GetLocation();
|
||||
|
||||
os << G4endl;
|
||||
os << setw( 7 ) << eventB << " "
|
||||
<< setw( 4 ) << (*itrecB).GetIteration() << " "
|
||||
<< setw( 3 ) << codeLocB << " "
|
||||
<< setw( 15 )
|
||||
<< G4LocatorChangeRecord::GetNameChangeLocation( codeLocB ) << " "
|
||||
<< setw( prec+9 ) << " " << " "
|
||||
<< setw( prec+9 ) << (*itrecB).GetLength() << " " ;
|
||||
}
|
||||
}
|
||||
|
||||
prevA= eventA;
|
||||
prevB= eventB;
|
||||
|
||||
auto nextA= itrecA;
|
||||
auto nextB= itrecB;
|
||||
|
||||
G4int nextAct = maxEvent, nextBct = maxEvent;
|
||||
++nextA;
|
||||
++nextB;
|
||||
if ( nextA != startA.end() ) { nextAct = (*nextA).GetCount(); }
|
||||
if ( nextB != endB.end() ) { nextBct = (*nextB).GetCount(); }
|
||||
|
||||
isLastA= ( nextA >= startA.end() );
|
||||
isLastB= ( nextB >= endB.end() );
|
||||
|
||||
advanceA= ( nextAct <= nextBct ) && !isLastA;
|
||||
advanceB= ( nextBct <= nextAct ) && !isLastB;
|
||||
|
||||
if( advanceA )
|
||||
{
|
||||
++itrecA;
|
||||
if( !isLastA ) { ++jA; }
|
||||
eventA = isLastA ? maxEvent : (*itrecA).GetCount();
|
||||
}
|
||||
|
||||
if( advanceB )
|
||||
{
|
||||
++itrecB;
|
||||
if( !isLastB ) { ++jB; }
|
||||
eventB = isLastB ? maxEvent : (*itrecB).GetCount();
|
||||
}
|
||||
|
||||
// Checks
|
||||
if( isLastA != ( nextA == startA.end() ) )
|
||||
{
|
||||
os << G4endl;
|
||||
os << " Checking isLastA= " << isLastA
|
||||
<< " vs expected : " << ( itrecA == startA.end() );
|
||||
os << " BAD --- ERROR " << G4endl;
|
||||
}
|
||||
if( isLastB != ( nextB == endB.end() ) )
|
||||
{
|
||||
os << G4endl;
|
||||
os << " Checking isLastB= " << isLastB
|
||||
<< " vs expected : " << ( itrecB == endB.end() );
|
||||
os << " BAD --- ERROR " << G4endl;
|
||||
}
|
||||
} while ( ! ( isLastA && isLastB ) );
|
||||
|
||||
os << G4endl;
|
||||
os.precision(oldprc);
|
||||
return os;
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4LocatorChangeRecord class implementation
|
||||
//
|
||||
// Author: John Apostolakis, 28.08.19 - First version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
// #include <cassert>
|
||||
|
||||
#include "G4LocatorChangeRecord.hh"
|
||||
|
||||
// Must correspond exactly with the count of the enum EChangeLocation
|
||||
//
|
||||
const char * G4LocatorChangeRecord::fNameChangeLocation[] =
|
||||
{ "Invalid", "Unknown", "Initialising", "IntersectsAF", "IntersectsFB", // 5
|
||||
"NoIntersections-AForFB", "RecalculatedB", // 2
|
||||
"InsertingMidPoint", "RecalculatedB-2ndHalf", // 2
|
||||
"Level Pop" };
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
std::ostream& G4LocatorChangeRecord::ReportVector ( std::ostream& os,
|
||||
const std::string & name,
|
||||
const std::vector<G4LocatorChangeRecord> & vecRec )
|
||||
{
|
||||
using std::setw;
|
||||
G4int prec= 16;
|
||||
if( vecRec.size() == 0 )
|
||||
{
|
||||
os << "Locator Change Record for " << name << " is empty" << G4endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
G4int oldprc = os.precision(prec);
|
||||
|
||||
// std::vector<G4LocatorChangeRecord>::const_iterator
|
||||
auto itRec
|
||||
= std::vector<G4LocatorChangeRecord>::const_iterator(vecRec.cbegin());
|
||||
|
||||
os << setw( 7 ) << "Change#" << " "
|
||||
<< setw( 4 ) << "Iter" << " "
|
||||
<< std::left
|
||||
<< setw( prec+9 ) << "Length" << " "
|
||||
<< setw( 15 ) << "Code-Location" << " "
|
||||
<< G4endl;
|
||||
os << "====================================================================="
|
||||
<< G4endl;
|
||||
|
||||
do
|
||||
{
|
||||
auto locationCode= (*itRec).GetLocation();
|
||||
os << std::internal
|
||||
<< setw( 7 ) << (*itRec).GetCount() << " " // Event Count
|
||||
<< setw( 4 ) << (*itRec).GetIteration() << " "
|
||||
<< std::left
|
||||
<< setw( prec+9 ) << (*itRec).GetLength() << " "
|
||||
<< setw( 2 ) << locationCode << " " // location enum
|
||||
<< setw( 15 ) << fNameChangeLocation[ locationCode ]
|
||||
<< std::internal
|
||||
;
|
||||
os << G4endl;
|
||||
++itRec;
|
||||
|
||||
} while ( itRec != vecRec.cend() );
|
||||
|
||||
os.precision(oldprc);
|
||||
return os;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
std::ostream&
|
||||
G4LocatorChangeRecord::ReportEndChanges (
|
||||
std::ostream& os,
|
||||
const std::vector<G4LocatorChangeRecord> & startA,
|
||||
const std::vector<G4LocatorChangeRecord> & endB )
|
||||
{
|
||||
using std::setw;
|
||||
G4int prec= 16;
|
||||
const G4bool confirm = true;
|
||||
G4int oldprc = os.precision(prec);
|
||||
|
||||
std::vector<G4LocatorChangeRecord>::const_iterator itrecA, itrecB;
|
||||
itrecA= startA.begin();
|
||||
itrecB= endB.begin();
|
||||
|
||||
os << "====================================================================="
|
||||
<< G4endl;
|
||||
os << " Size of individual change record: startA : " << startA.size()
|
||||
<< " endB : " << endB.size() << G4endl;
|
||||
os << "====================================================================="
|
||||
<< G4endl;
|
||||
|
||||
os << setw( 7 ) << "Change#" << " "
|
||||
<< setw( 4 ) << "Iter" << " "
|
||||
<< setw( 20 ) << "CodeLocation" << " "
|
||||
<< setw( prec+9 ) << "Length-A (start)" << " "
|
||||
<< setw( prec+9 ) << "Length-B (end)" << " "
|
||||
<< G4endl;
|
||||
os << "=====================================================================";
|
||||
|
||||
|
||||
auto eventA = (*itrecA).GetCount();
|
||||
auto eventB = (*itrecB).GetCount();
|
||||
|
||||
G4bool isLastA= false;
|
||||
G4bool isLastB= false;
|
||||
|
||||
G4int jA=0, jB=0;
|
||||
|
||||
G4int maxEvent = std::max( startA[ startA.size() - 1 ].GetCount() ,
|
||||
endB[ endB.size() - 1 ].GetCount() );
|
||||
G4int prevA = -1;
|
||||
G4int prevB = -1;
|
||||
|
||||
G4bool advanceA= false, advanceB= false;
|
||||
do
|
||||
{
|
||||
advanceA= false;
|
||||
advanceB= false;
|
||||
|
||||
if( ((G4int)eventA>prevA) && ((G4int)eventB>prevB) )
|
||||
{
|
||||
auto codeLocA= (*itrecA).GetLocation();
|
||||
|
||||
os << G4endl;
|
||||
os << setw( 7 ) << eventA << " "
|
||||
<< setw( 4 ) << (*itrecA).GetIteration() << " "
|
||||
<< setw( 3 ) << codeLocA << " "
|
||||
<< setw( 15 ) << fNameChangeLocation[ codeLocA ] << " "
|
||||
<< setw( prec+9 ) << (*itrecA).GetLength() << " "
|
||||
<< setw( prec+9 ) << (*itrecB).GetLength() << " ";
|
||||
if( confirm )
|
||||
{
|
||||
os << setw( 4 ) << (*itrecB).GetIteration() << " "
|
||||
<< setw( 15 ) << (*itrecB).GetLocation();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (G4int)eventA > prevA )
|
||||
{
|
||||
auto codeLocA = (*itrecA).GetLocation();
|
||||
os << G4endl;
|
||||
os << setw( 7 ) << (*itrecA).GetCount() << " "
|
||||
<< setw( 4 ) << (*itrecA).GetIteration() << " "
|
||||
<< setw( 3 ) << codeLocA << " "
|
||||
<< setw( 15 ) << fNameChangeLocation[ codeLocA ] << " "
|
||||
<< setw( prec+9 ) << (*itrecA).GetLength() << " "
|
||||
<< setw( prec+9 ) << " " << " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
// assert( (G4int)eventB > prevB );
|
||||
auto codeLocB = (*itrecB).GetLocation();
|
||||
|
||||
os << G4endl;
|
||||
os << setw( 7 ) << eventB << " "
|
||||
<< setw( 4 ) << (*itrecB).GetIteration() << " "
|
||||
<< setw( 3 ) << codeLocB << " "
|
||||
<< setw( 15 ) << fNameChangeLocation[ codeLocB ] << " "
|
||||
<< setw( prec+9 ) << " " << " "
|
||||
<< setw( prec+9 ) << (*itrecB).GetLength() << " " ;
|
||||
}
|
||||
}
|
||||
|
||||
prevA= eventA;
|
||||
prevB= eventB;
|
||||
|
||||
auto nextA= itrecA;
|
||||
auto nextB= itrecB;
|
||||
|
||||
G4int nextAct = maxEvent, nextBct = maxEvent;
|
||||
++nextA;
|
||||
++nextB;
|
||||
if ( nextA != startA.end() ) { nextAct = (*nextA).GetCount(); }
|
||||
if ( nextB != endB.end() ) { nextBct = (*nextB).GetCount(); }
|
||||
|
||||
isLastA= ( nextA >= startA.end() );
|
||||
isLastB= ( nextB >= endB.end() );
|
||||
|
||||
advanceA= ( nextAct <= nextBct ) && !isLastA;
|
||||
advanceB= ( nextBct <= nextAct ) && !isLastB;
|
||||
|
||||
if( advanceA )
|
||||
{
|
||||
++itrecA;
|
||||
if( !isLastA ) { ++jA; eventA = (*itrecA).GetCount(); }
|
||||
else { eventA = maxEvent; }
|
||||
}
|
||||
|
||||
if( advanceB )
|
||||
{
|
||||
++itrecB;
|
||||
if( !isLastB ) { ++jB; eventB = (*itrecB).GetCount(); }
|
||||
else { eventB = maxEvent; }
|
||||
}
|
||||
|
||||
// Checks
|
||||
if( isLastA != ( nextA == startA.end() ) )
|
||||
{
|
||||
os << G4endl;
|
||||
os << " Checking isLastA= " << isLastA << " vs expected : "
|
||||
<< ( itrecA == startA.end() );
|
||||
os << " BAD --- ERROR " << G4endl;
|
||||
}
|
||||
if( isLastB != ( nextB == endB.end() ) )
|
||||
{
|
||||
os << G4endl;
|
||||
os << " Checking isLastB= " << isLastB << " vs expected : "
|
||||
<< ( itrecB == endB.end() );
|
||||
os << " BAD --- ERROR " << G4endl;
|
||||
}
|
||||
|
||||
} while ( ! ( isLastA && isLastB ) );
|
||||
|
||||
os << G4endl;
|
||||
os.precision(oldprc);
|
||||
return os;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Streaming operator dumping record
|
||||
//
|
||||
std::ostream& operator<< ( std::ostream& os, const G4LocatorChangeRecord& e )
|
||||
{
|
||||
return e.StreamInfo(os);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Stream object contents to an output stream
|
||||
//
|
||||
std::ostream& G4LocatorChangeRecord::StreamInfo(std::ostream& os) const
|
||||
{
|
||||
G4int oldprc = os.precision(16);
|
||||
os << " count = " << fEventCount
|
||||
<< " iter= " << fIteration
|
||||
<< " Location code = " << fCodeLocation
|
||||
<< " Length = " << GetLength() << G4endl;
|
||||
os.precision(oldprc);
|
||||
return os;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Streaming operator
|
||||
//
|
||||
std::ostream& operator << ( std::ostream& os,
|
||||
const std::vector<G4LocatorChangeRecord> & vecR )
|
||||
{
|
||||
G4LocatorChangeRecord::ReportVector( os, "", vecR );
|
||||
return os;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
const char *G4LocatorChangeRecord::GetNameChangeLocation( EChangeLocation loc )
|
||||
{
|
||||
return fNameChangeLocation[loc];
|
||||
}
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "G4MultiLevelLocator.hh"
|
||||
#include "G4LocatorChangeRecord.hh"
|
||||
#include "G4LocatorChangeLogger.hh"
|
||||
|
||||
G4MultiLevelLocator::G4MultiLevelLocator(G4Navigator *theNavigator)
|
||||
: G4VIntersectionLocator(theNavigator)
|
||||
@@ -47,12 +49,13 @@ G4MultiLevelLocator::G4MultiLevelLocator(G4Navigator *theNavigator)
|
||||
ptrInterMedFT[ idepth ] = new G4FieldTrack( zeroV, zeroV, 0., 0., 0., 0.);
|
||||
}
|
||||
|
||||
#ifdef G4DEBUG_FIELD
|
||||
// Trial values Loose Tight
|
||||
// To happen: Infrequent Often
|
||||
SetMaxSteps(50); // 300 25
|
||||
SetWarnSteps(40); // 250 15
|
||||
#endif
|
||||
if (fCheckMode)
|
||||
{
|
||||
// Trial values Loose Medium Tight
|
||||
// To happen: Infrequent Occasional Often
|
||||
SetMaxSteps(150); // 300 85 25
|
||||
SetWarnSteps(80); // 250 60 15
|
||||
}
|
||||
}
|
||||
|
||||
G4MultiLevelLocator::~G4MultiLevelLocator()
|
||||
@@ -123,7 +126,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
|
||||
G4bool found_approximate_intersection = false;
|
||||
G4bool there_is_no_intersection = false;
|
||||
|
||||
|
||||
G4FieldTrack CurrentA_PointVelocity = CurveStartPointVelocity;
|
||||
G4FieldTrack CurrentB_PointVelocity = CurveEndPointVelocity;
|
||||
G4ThreeVector CurrentE_Point = TrialPoint;
|
||||
@@ -138,8 +141,6 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
auto integrDriver = GetChordFinderFor()->GetIntegrationDriver();
|
||||
G4bool driverReIntegrates = integrDriver->DoesReIntegrate();
|
||||
|
||||
// G4bool final_section= true; // Shows whether current section is last
|
||||
// (i.e. B=full end)
|
||||
G4bool first_section = true;
|
||||
recalculatedEndPoint = false;
|
||||
G4bool restoredFullEndpoint = false;
|
||||
@@ -147,8 +148,37 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
unsigned int substep_no = 0;
|
||||
|
||||
// Statistics for substeps
|
||||
//
|
||||
static G4ThreadLocal unsigned int max_no_seen= 0;
|
||||
static G4ThreadLocal unsigned int max_no_seen= 0;
|
||||
|
||||
#ifdef G4DEBUG_FIELD
|
||||
unsigned int trigger_substepno_print = 0;
|
||||
const G4double tolerance = 1.0e-8 * CLHEP::mm;
|
||||
unsigned int biggest_depth = 0;
|
||||
// using kInitialisingCL = G4LocatorChangeRecord::kInitialisingCL;
|
||||
#endif
|
||||
|
||||
// Log the location, iteration of changes in A,B
|
||||
//----------------------------------------------
|
||||
static G4ThreadLocal G4LocatorChangeLogger endChangeA("StartPointA"),
|
||||
endChangeB("EndPointB"), recApproxPoint("ApproxPoint"),
|
||||
pointH_logger("Trial points 'E': position, normal");
|
||||
unsigned int eventCount = 0;
|
||||
|
||||
if (fCheckMode)
|
||||
{
|
||||
// Clear previous call's data
|
||||
endChangeA.clear();
|
||||
endChangeB.clear();
|
||||
recApproxPoint.clear();
|
||||
pointH_logger.clear();
|
||||
|
||||
// Record the initialisation
|
||||
++eventCount;
|
||||
endChangeA.AddRecord( G4LocatorChangeRecord::kInitialisingCL, substep_no,
|
||||
eventCount, CurrentA_PointVelocity );
|
||||
endChangeB.AddRecord( G4LocatorChangeRecord::kInitialisingCL, substep_no,
|
||||
eventCount, CurrentB_PointVelocity );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Algorithm for the case if progress in founding intersection is too slow.
|
||||
@@ -175,22 +205,23 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
unsigned int depth = 0; // Depth counts subdivisions of initial step made
|
||||
++fNumCalls;
|
||||
|
||||
#ifdef G4DEBUG_FIELD
|
||||
unsigned int trigger_substepno_print = 0;
|
||||
const G4double tolerance = 1.0e-8 * CLHEP::mm;
|
||||
unsigned int biggest_depth = 0;
|
||||
NormalAtEntry = GetSurfaceNormal(CurrentE_Point, validNormalAtE);
|
||||
|
||||
#if (G4DEBUG_FIELD>1)
|
||||
G4ThreeVector StartPosition = CurveStartPointVelocity.GetPosition();
|
||||
if( (TrialPoint - StartPosition).mag2() < sqr(tolerance))
|
||||
if (fCheckMode)
|
||||
{
|
||||
ReportImmediateHit( MethodName, StartPosition, TrialPoint,
|
||||
tolerance, fNumCalls);
|
||||
pointH_logger.AddRecord( G4LocatorChangeRecord::kInitialisingCL,
|
||||
substep_no, eventCount,
|
||||
G4FieldTrack( CurrentE_Point,0.,NormalAtEntry,0.,
|
||||
0., 1.,G4ThreeVector(0.),0.,0.) );
|
||||
#if (G4DEBUG_FIELD>1)
|
||||
G4ThreeVector StartPosition = CurveStartPointVelocity.GetPosition();
|
||||
if( (TrialPoint - StartPosition).mag2() < sqr(tolerance))
|
||||
{
|
||||
ReportImmediateHit( MethodName, StartPosition, TrialPoint,
|
||||
tolerance, fNumCalls);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
NormalAtEntry = GetSurfaceNormal(CurrentE_Point, validNormalAtE);
|
||||
|
||||
// Intermediates Points on the Track = Subdivided Points must be stored.
|
||||
// Give the initial values to 'InterMedFt'
|
||||
@@ -222,9 +253,21 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
|
||||
do // Loop checking, 07.10.2016, J.Apostolakis
|
||||
{ // REPEAT param
|
||||
|
||||
#ifdef G4DEBUG_FIELD
|
||||
if( CurrentA_PointVelocity.GetCurveLength() >=
|
||||
CurrentB_PointVelocity.GetCurveLength() )
|
||||
{
|
||||
G4cerr << "ERROR> (Start) Point A coincides with or has gone past (end) point B"
|
||||
<< "MLL: iters = " << substep_no << G4endl;
|
||||
// G4LocatorChangeRecord::ReportVector(G4cerr, "endPointB", endChangeB );
|
||||
// G4cerr<<"EndPoints A(start) and B(end): combined changes " << G4endl;
|
||||
G4LocatorChangeLogger::ReportEndChanges(G4cerr, endChangeA, endChangeB);
|
||||
}
|
||||
#endif
|
||||
G4ThreeVector Point_A = CurrentA_PointVelocity.GetPosition();
|
||||
G4ThreeVector Point_B = CurrentB_PointVelocity.GetPosition();
|
||||
|
||||
|
||||
// F = a point on true AB path close to point E
|
||||
// (the closest if possible)
|
||||
//
|
||||
@@ -232,15 +275,33 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
->ApproxCurvePointV( CurrentA_PointVelocity,
|
||||
CurrentB_PointVelocity,
|
||||
CurrentE_Point,
|
||||
GetEpsilonStepFor());
|
||||
GetEpsilonStepFor() );
|
||||
// The above method is the key & most intuitive part ...
|
||||
|
||||
#ifdef G4DEBUG_FIELD
|
||||
if( ApproxIntersecPointV.GetCurveLength() >
|
||||
CurrentB_PointVelocity.GetCurveLength() * (1.0 + tolerance) )
|
||||
#ifdef G4DEBUG_FIELD
|
||||
recApproxPoint.push_back(G4LocatorChangeRecord(G4LocatorChangeRecord::kInvalidCL,
|
||||
substep_no, eventCount, ApproxIntersecPointV ) );
|
||||
G4double lenIntsc= ApproxIntersecPointV.GetCurveLength();
|
||||
G4double lenB = CurrentB_PointVelocity.GetCurveLength();
|
||||
G4double checkVsEnd= lenB - lenIntsc;
|
||||
|
||||
if( lenIntsc > lenB )
|
||||
{
|
||||
G4Exception(MethodName, "GeomNav0003", FatalException,
|
||||
"Intermediate F point is past end B point" );
|
||||
std::ostringstream errmsg;
|
||||
errmsg.precision(17);
|
||||
G4double ratio = checkVsEnd / lenB;
|
||||
G4double ratioTol = std::fabs(ratio) / tolerance;
|
||||
errmsg << "Intermediate F point is past end B point" << G4endl
|
||||
<< " l( intersection ) = " << lenIntsc << G4endl
|
||||
<< " l( endpoint ) = " << lenB << G4endl;
|
||||
errmsg.precision(8);
|
||||
errmsg << " l_end - l_inters = " << checkVsEnd << G4endl
|
||||
<< " / l_end = " << ratio << G4endl
|
||||
<< " ratio / tolerance = " << ratioTol << G4endl;
|
||||
if( ratioTol < 1.0 )
|
||||
G4Exception(MethodName, "GeomNav0003", JustWarning, errmsg );
|
||||
else
|
||||
G4Exception(MethodName, "GeomNav0003", FatalException, errmsg );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -253,7 +314,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
|
||||
G4ThreeVector NewMomentumDir = ApproxIntersecPointV.GetMomentumDir();
|
||||
G4double MomDir_dot_Norm = NewMomentumDir.dot( NormalAtEntry );
|
||||
|
||||
|
||||
#ifdef G4DEBUG_FIELD
|
||||
if( fVerboseLevel > 3 )
|
||||
{
|
||||
@@ -316,6 +377,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
|
||||
G4ThreeVector PointG; // Candidate intersection point
|
||||
G4double stepLengthAF;
|
||||
G4bool Intersects_FB = false;
|
||||
G4bool Intersects_AF = IntersectChord( Point_A, CurrentF_Point,
|
||||
NewSafety, previousSafety,
|
||||
previousSftOrigin,
|
||||
@@ -325,13 +387,9 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
if( Intersects_AF )
|
||||
{
|
||||
// G is our new Candidate for the intersection point.
|
||||
// It replaces "E" and we will repeat the test to see if
|
||||
// it is a good enough approximate point for us.
|
||||
// B <- F
|
||||
// E <- G
|
||||
//
|
||||
CurrentB_PointVelocity = ApproxIntersecPointV;
|
||||
CurrentE_Point = PointG;
|
||||
// It replaces "E" and we will see if it's good enough.
|
||||
CurrentB_PointVelocity = ApproxIntersecPointV; // B <- F
|
||||
CurrentE_Point = PointG; // E <- G
|
||||
|
||||
validIntersectP = true; // 'E' has been updated.
|
||||
|
||||
@@ -339,11 +397,17 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
NormalAtEntry = GetSurfaceNormal( PointG, validNormalLast );
|
||||
validNormalAtE = validNormalLast;
|
||||
|
||||
// By moving point B, must take care if current
|
||||
// As we move point B, must take care in case the current
|
||||
// AF has no intersection to try current FB!!
|
||||
//
|
||||
fin_section_depth[depth] = false;
|
||||
|
||||
if (fCheckMode)
|
||||
{
|
||||
++eventCount;
|
||||
endChangeB.push_back(
|
||||
G4LocatorChangeRecord(G4LocatorChangeRecord::kIntersectsAF,
|
||||
substep_no, eventCount, CurrentB_PointVelocity) );
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
if( fVerboseLevel > 3 )
|
||||
{
|
||||
@@ -368,11 +432,11 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
// Check whether any volumes are encountered by the chord FB
|
||||
// ---------------------------------------------------------
|
||||
|
||||
G4bool Intersects_FB = IntersectChord( CurrentF_Point, Point_B,
|
||||
NewSafety, previousSafety,
|
||||
previousSftOrigin,
|
||||
stepLengthFB,
|
||||
PointH );
|
||||
Intersects_FB = IntersectChord( CurrentF_Point, Point_B,
|
||||
NewSafety, previousSafety,
|
||||
previousSftOrigin,
|
||||
stepLengthFB,
|
||||
PointH );
|
||||
if( Intersects_FB )
|
||||
{
|
||||
// There is an intersection of FB with a volume boundary
|
||||
@@ -394,7 +458,21 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
|
||||
G4bool validNormalH;
|
||||
NormalAtEntry = GetSurfaceNormal( PointH, validNormalH );
|
||||
validNormalAtE = validNormalH;
|
||||
validNormalAtE = validNormalH;
|
||||
|
||||
if (fCheckMode)
|
||||
{
|
||||
++eventCount;
|
||||
endChangeA.push_back(
|
||||
G4LocatorChangeRecord(G4LocatorChangeRecord::kIntersectsFB,
|
||||
substep_no, eventCount, CurrentA_PointVelocity) );
|
||||
G4FieldTrack intersectH_pn('0'); // Point and normal
|
||||
// nothing else will be valid
|
||||
intersectH_pn.SetPosition( PointH );
|
||||
intersectH_pn.SetMomentum( NormalAtEntry );
|
||||
pointH_logger.AddRecord(G4LocatorChangeRecord::kIntersectsFB,
|
||||
substep_no, eventCount, intersectH_pn );
|
||||
}
|
||||
}
|
||||
else // not Intersects_FB
|
||||
{
|
||||
@@ -433,6 +511,19 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
restoredFullEndpoint = true;
|
||||
|
||||
validIntersectP = false; // 'E' has NOT been updated.
|
||||
|
||||
if (fCheckMode)
|
||||
{
|
||||
++eventCount;
|
||||
endChangeA.push_back(
|
||||
G4LocatorChangeRecord(
|
||||
G4LocatorChangeRecord::kNoIntersectAForFB,
|
||||
substep_no, eventCount, CurrentA_PointVelocity) );
|
||||
endChangeB.push_back(
|
||||
G4LocatorChangeRecord (
|
||||
G4LocatorChangeRecord::kNoIntersectAForFB,
|
||||
substep_no, eventCount, CurrentB_PointVelocity) );
|
||||
}
|
||||
}
|
||||
} // Endif (Intersects_FB)
|
||||
} // Endif (Intersects_AF)
|
||||
@@ -469,6 +560,18 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
// [ Implementation: a counter for # of recomputations
|
||||
// => avoids extra work]
|
||||
}
|
||||
// else
|
||||
// Move forward the other points
|
||||
// - or better flag it, so that they are re-computed when next used
|
||||
// [ Implementation: a counter for # of recomputations
|
||||
// => avoids extra work]
|
||||
if (fCheckMode)
|
||||
{
|
||||
++eventCount;
|
||||
endChangeB.push_back(
|
||||
G4LocatorChangeRecord( G4LocatorChangeRecord::kRecalculatedB,
|
||||
substep_no, eventCount, RevisedB_FT ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -479,15 +582,19 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
if( errorEndPt > 1 ) // errorEndPt = 1 is milder, just: len(B)=len(A)
|
||||
{
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "Location: " << MethodName
|
||||
<< "- After EndIf(Intersects_AF)" << G4endl;
|
||||
ReportReversedPoints(errmsg,
|
||||
CurveStartPointVelocity, CurveEndPointVelocity,
|
||||
NewSafety, fiEpsilonStep,
|
||||
CurrentA_PointVelocity, CurrentB_PointVelocity,
|
||||
SubStart_PointVelocity, CurrentE_Point,
|
||||
ApproxIntersecPointV, substep_no, substep_no_p, depth);
|
||||
G4Exception(MethodName, "GeomNav0003", FatalException, errmsg);
|
||||
errmsg << G4endl << " * Location: " << MethodName
|
||||
<< "- After EndIf(Intersects_AF)" << G4endl;
|
||||
errmsg << " * Bool flags: Recalculated = " << recalculatedB
|
||||
<< " Intersects_AF = " << Intersects_AF
|
||||
<< " Intersects_FB = " << Intersects_FB << G4endl;
|
||||
errmsg << " * Number of calls to MLL:EIP= " << fNumCalls << G4endl;
|
||||
G4Exception(MethodName, "GeomNav0003", FatalException, errmsg);
|
||||
}
|
||||
if( restoredFullEndpoint )
|
||||
{
|
||||
@@ -506,17 +613,21 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
if( substep_no >= trigger_substepno_print )
|
||||
{
|
||||
G4cout << "Difficulty in converging in " << MethodName
|
||||
<< G4endl
|
||||
<< " Substep no = " << substep_no << G4endl;
|
||||
if( substep_no == trigger_substepno_print )
|
||||
{
|
||||
G4cout << " Start: ";
|
||||
printStatus( CurveStartPointVelocity, CurveEndPointVelocity,
|
||||
-1.0, NewSafety, 0 );
|
||||
|
||||
G4cout << " ** Change records: " << G4endl;
|
||||
G4cout << "endPoints A (start) and B (end): combined changes of AB intervals" << G4endl;
|
||||
G4LocatorChangeRecord::ReportEndChanges(G4cout, endChangeA, endChangeB );
|
||||
}
|
||||
G4cout << " State of point A: ";
|
||||
G4cout << " Point A: ";
|
||||
printStatus( CurrentA_PointVelocity, CurrentA_PointVelocity,
|
||||
-1.0, NewSafety, substep_no-1 );
|
||||
G4cout << " State of point B: ";
|
||||
G4cout << " Point B: ";
|
||||
printStatus( CurrentA_PointVelocity, CurrentB_PointVelocity,
|
||||
-1.0, NewSafety, substep_no );
|
||||
}
|
||||
@@ -537,7 +648,6 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
- SubStart_PointVelocity.GetCurveLength());
|
||||
|
||||
G4double distAB = -1;
|
||||
G4ThreeVector PointGe;
|
||||
//
|
||||
// Is progress is too slow, and is it possible to go deeper?
|
||||
// If so, then *halve the step*
|
||||
@@ -605,6 +715,14 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
*ptrInterMedFT[depth] = midPoint;
|
||||
CurrentB_PointVelocity = midPoint;
|
||||
|
||||
if (fCheckMode)
|
||||
{
|
||||
++eventCount;
|
||||
endChangeB.push_back(
|
||||
G4LocatorChangeRecord( G4LocatorChangeRecord::kInsertingMidPoint,
|
||||
substep_no, eventCount, midPoint) );
|
||||
}
|
||||
|
||||
// Adjust 'SubStartPoint' to calculate the 'did_length' in next loop
|
||||
//
|
||||
SubStart_PointVelocity = CurrentA_PointVelocity;
|
||||
@@ -613,7 +731,8 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
//
|
||||
G4ThreeVector Point_A = CurrentA_PointVelocity.GetPosition();
|
||||
G4ThreeVector Point_B = CurrentB_PointVelocity.GetPosition();
|
||||
|
||||
|
||||
G4ThreeVector PointGe;
|
||||
GetNavigatorFor()->LocateGlobalPointWithinVolume(Point_A);
|
||||
G4bool Intersects_AB = IntersectChord(Point_A, Point_B,
|
||||
NewSafety, previousSafety,
|
||||
@@ -658,8 +777,21 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
CurrentA_PointVelocity = *ptrInterMedFT[depth];
|
||||
CurrentB_PointVelocity = *ptrInterMedFT[depth-1];
|
||||
|
||||
G4int errorEndPt = 0; // Default: no error (if not calling CheckAnd...
|
||||
|
||||
if (fCheckMode)
|
||||
{
|
||||
++eventCount;
|
||||
G4LocatorChangeRecord chngPop_a( G4LocatorChangeRecord::kLevelPop,
|
||||
substep_no, eventCount, CurrentA_PointVelocity);
|
||||
endChangeA.push_back( chngPop_a );
|
||||
G4LocatorChangeRecord chngPop_b( G4LocatorChangeRecord::kLevelPop,
|
||||
substep_no, eventCount, CurrentB_PointVelocity);
|
||||
endChangeB.push_back( chngPop_b );
|
||||
}
|
||||
|
||||
// Ensure that the new endpoints are not further apart in space
|
||||
// than on the curve due to different errors in the integration
|
||||
//
|
||||
G4int errorEndPt = -1;
|
||||
G4bool recalculatedB= false;
|
||||
if( driverReIntegrates )
|
||||
{
|
||||
@@ -688,45 +820,53 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
|
||||
if( CurrentB_PointVelocity.GetCurveLength() < CurrentA_PointVelocity.GetCurveLength() )
|
||||
errorEndPt = 2;
|
||||
}
|
||||
|
||||
if (fCheckMode)
|
||||
{
|
||||
++eventCount;
|
||||
endChangeB.push_back(
|
||||
G4LocatorChangeRecord(G4LocatorChangeRecord::kRecalculatedBagn,
|
||||
substep_no, eventCount, RevisedEndPointFT));
|
||||
}
|
||||
}
|
||||
if( errorEndPt > 1 ) // errorEndPt = 1 is milder, just: len(B)=len(A)
|
||||
{
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "Location: " << MethodName << "- Second-Half" << G4endl;
|
||||
ReportReversedPoints(errmsg,
|
||||
CurveStartPointVelocity, CurveEndPointVelocity,
|
||||
NewSafety, fiEpsilonStep,
|
||||
CurrentA_PointVelocity, CurrentB_PointVelocity,
|
||||
SubStart_PointVelocity, CurrentE_Point,
|
||||
ApproxIntersecPointV, substep_no, substep_no_p, depth);
|
||||
errmsg << " * Location: " << MethodName << "- Second-Half" << G4endl;
|
||||
errmsg << " * Recalculated = " << recalculatedB << G4endl; // false
|
||||
G4Exception(MethodName, "GeomNav0003", FatalException, errmsg);
|
||||
}
|
||||
|
||||
G4ThreeVector Point_A = CurrentA_PointVelocity.GetPosition();
|
||||
G4ThreeVector Point_B = CurrentB_PointVelocity.GetPosition();
|
||||
G4ThreeVector Point_B = CurrentB_PointVelocity.GetPosition();
|
||||
G4ThreeVector PointGi;
|
||||
GetNavigatorFor()->LocateGlobalPointWithinVolume(Point_A);
|
||||
G4bool Intersects_AB = IntersectChord(Point_A, Point_B, NewSafety,
|
||||
previousSafety,
|
||||
previousSftOrigin, distAB,
|
||||
PointGe);
|
||||
PointGi);
|
||||
if( Intersects_AB )
|
||||
{
|
||||
last_AF_intersection = Intersects_AB;
|
||||
CurrentE_Point = PointGe;
|
||||
CurrentE_Point = PointGi;
|
||||
|
||||
validIntersectP = true; // 'E' has been updated.
|
||||
|
||||
G4bool validNormalAB;
|
||||
NormalAtEntry = GetSurfaceNormal( PointGe, validNormalAB );
|
||||
validNormalAtE = validNormalAB;
|
||||
NormalAtEntry = GetSurfaceNormal( PointGi, validNormalAtE );
|
||||
}
|
||||
else
|
||||
{
|
||||
validIntersectP = false; // No new 'E' chord intersection found
|
||||
if( depth == 1)
|
||||
{
|
||||
{
|
||||
there_is_no_intersection = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
depth--;
|
||||
fin_section_depth[depth] = true;
|
||||
unfinished = !validIntersectP;
|
||||
|
||||
@@ -678,6 +678,9 @@ void G4PropagatorInField::ClearPropagatorState()
|
||||
fParticleIsLooping = false;
|
||||
fNoZeroStep = 0;
|
||||
|
||||
fSetFieldMgr = false; // Has field-manager been set for the current step?
|
||||
fEpsilonStep= 1.0e-5; // Relative accuracy of current Step
|
||||
|
||||
End_PointAndTangent= G4FieldTrack( G4ThreeVector(0.,0.,0.),
|
||||
G4ThreeVector(0.,0.,0.),
|
||||
0.0,0.0,0.0,0.0,0.0);
|
||||
@@ -686,6 +689,8 @@ void G4PropagatorInField::ClearPropagatorState()
|
||||
|
||||
fPreviousSftOrigin= G4ThreeVector(0.,0.,0.);
|
||||
fPreviousSafety= 0.0;
|
||||
|
||||
fNewTrack = true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -210,16 +210,16 @@ G4double G4RegularNavigation::ComputeStepSkippingEqualMaterials(
|
||||
.InverseTransformPoint(localPoint);
|
||||
std::ostringstream message;
|
||||
message << "G4RegularNavigation::ComputeStepSkippingEqualMaterials()"
|
||||
<< "Stuck Track: potential geometry or navigation problem."
|
||||
<< G4endl
|
||||
<< " Track stuck, moving for more than "
|
||||
<< ii << " steps" << G4endl
|
||||
<< "- at point " << pGlobalpoint << G4endl
|
||||
<< " local direction: " << localDirection << G4endl;
|
||||
<< "Stuck Track: potential geometry or navigation problem."
|
||||
<< G4endl
|
||||
<< " Track stuck, moving for more than "
|
||||
<< ii << " steps" << G4endl
|
||||
<< "- at point " << pGlobalpoint << G4endl
|
||||
<< " local direction: " << localDirection << G4endl;
|
||||
G4Exception("G4RegularNavigation::ComputeStepSkippingEqualMaterials()",
|
||||
"GeomRegNav1001",
|
||||
EventMustBeAborted,
|
||||
message);
|
||||
"GeomRegNav1001",
|
||||
EventMustBeAborted,
|
||||
message);
|
||||
}
|
||||
newStep = voxelBox->DistanceToOut( localPoint, localDirection );
|
||||
fLastStepWasZero = (newStep<fMinStep);
|
||||
@@ -231,65 +231,64 @@ G4double G4RegularNavigation::ComputeStepSkippingEqualMaterials(
|
||||
{
|
||||
G4ThreeVector pGlobalpoint = history.GetTransform(ide)
|
||||
.InverseTransformPoint(localPoint);
|
||||
G4cout << "G4RegularNavigation::ComputeStepSkippingEqualMaterials():"
|
||||
<< " another 'zero' step, # "
|
||||
<< fNumberZeroSteps
|
||||
<< ", at " << pGlobalpoint
|
||||
<< ", nav-comp-step calls # " << ii
|
||||
<< ", Step= " << newStep
|
||||
<< G4endl;
|
||||
G4cout << "G4RegularNavigation::ComputeStepSkippingEqualMaterials(): another 'zero' step, # "
|
||||
<< fNumberZeroSteps
|
||||
<< ", at " << pGlobalpoint
|
||||
<< ", nav-comp-step calls # " << ii
|
||||
<< ", Step= " << newStep
|
||||
<< G4endl;
|
||||
}
|
||||
//#endif
|
||||
if( fNumberZeroSteps > fActionThreshold_NoZeroSteps-1 )
|
||||
{
|
||||
// Act to recover this stuck track. Pushing it along direction
|
||||
//
|
||||
newStep = std::min(101*kCarTolerance*pow(10,fNumberZeroSteps-2),0.1);
|
||||
// Act to recover this stuck track. Pushing it along direction
|
||||
//
|
||||
newStep = std::min(101*kCarTolerance*std::pow(10,fNumberZeroSteps-2),0.1);
|
||||
#ifdef G4VERBOSE
|
||||
if (fWarnPush)
|
||||
{
|
||||
if (fWarnPush)
|
||||
{
|
||||
G4ThreeVector pGlobalpoint = history.GetTransform(ide)
|
||||
.InverseTransformPoint(localPoint);
|
||||
std::ostringstream message;
|
||||
message.precision(16);
|
||||
message << "Track stuck or not moving." << G4endl
|
||||
<< " Track stuck, not moving for "
|
||||
<< fNumberZeroSteps << " steps" << G4endl
|
||||
<< "- at point " << pGlobalpoint
|
||||
<< " (local point " << localPoint << ")" << G4endl
|
||||
<< " local direction: " << localDirection
|
||||
<< " Potential geometry or navigation problem !"
|
||||
<< G4endl
|
||||
<< " Trying pushing it of " << newStep << " mm ...";
|
||||
G4Exception("G4RegularNavigation::ComputeStepSkippingEqualMaterials()",
|
||||
"GeomRegNav1002",
|
||||
JustWarning,
|
||||
message,
|
||||
"Potential overlap in geometry!");
|
||||
}
|
||||
std::ostringstream message;
|
||||
message.precision(16);
|
||||
message << "Track stuck or not moving." << G4endl
|
||||
<< " Track stuck, not moving for "
|
||||
<< fNumberZeroSteps << " steps" << G4endl
|
||||
<< "- at point " << pGlobalpoint
|
||||
<< " (local point " << localPoint << ")" << G4endl
|
||||
<< " local direction: " << localDirection
|
||||
<< " Potential geometry or navigation problem !"
|
||||
<< G4endl
|
||||
<< " Trying pushing it of " << newStep << " mm ...";
|
||||
G4Exception("G4RegularNavigation::ComputeStepSkippingEqualMaterials()",
|
||||
"GeomRegNav1002",
|
||||
JustWarning,
|
||||
message,
|
||||
"Potential overlap in geometry!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if( fNumberZeroSteps > fAbandonThreshold_NoZeroSteps-1 )
|
||||
{
|
||||
// Must kill this stuck track
|
||||
//
|
||||
G4ThreeVector pGlobalpoint = history.GetTransform(ide)
|
||||
// Must kill this stuck track
|
||||
//
|
||||
G4ThreeVector pGlobalpoint = history.GetTransform(ide)
|
||||
.InverseTransformPoint(localPoint);
|
||||
std::ostringstream message;
|
||||
message << "G4RegularNavigation::ComputeStepSkippingEqualMaterials()"
|
||||
<< "Stuck Track: potential geometry or navigation problem."
|
||||
<< G4endl
|
||||
<< " Track stuck, not moving for "
|
||||
<< fNumberZeroSteps << " steps" << G4endl
|
||||
<< "- at point " << pGlobalpoint << G4endl
|
||||
<< " local direction: " << localDirection << G4endl;
|
||||
G4Exception("G4RegularNavigation::ComputeStepSkippingEqualMaterials()",
|
||||
"GeomRegNav1003",
|
||||
EventMustBeAborted,
|
||||
message);
|
||||
std::ostringstream message;
|
||||
message << "G4RegularNavigation::ComputeStepSkippingEqualMaterials()"
|
||||
<< "Stuck Track: potential geometry or navigation problem."
|
||||
<< G4endl
|
||||
<< " Track stuck, not moving for "
|
||||
<< fNumberZeroSteps << " steps" << G4endl
|
||||
<< "- at point " << pGlobalpoint << G4endl
|
||||
<< " local direction: " << localDirection << G4endl;
|
||||
G4Exception("G4RegularNavigation::ComputeStepSkippingEqualMaterials()",
|
||||
"GeomRegNav1003",
|
||||
EventMustBeAborted,
|
||||
message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( (bFirstStep) && (newStep < currentProposedStepLength) )
|
||||
{
|
||||
exiting = true;
|
||||
|
||||
@@ -777,26 +777,30 @@ ReportReversedPoints( std::ostringstream& msg,
|
||||
G4VIntersectionLocator::printStatus( A_PtVel, B_PtVel,
|
||||
-1.0, NewSafety, substep_no, msg, verboseLevel );
|
||||
msg << "Error in advancing propagation." << G4endl
|
||||
<< " Point A (start) is " << A_PtVel << G4endl
|
||||
<< " Point B (end) is " << B_PtVel << G4endl
|
||||
<< " Curve distance is " << curveDist << G4endl
|
||||
<< " The final curve point is NOT further along"
|
||||
<< " than the original!" << G4endl
|
||||
<< " Going *backwards* from len(A) = " << A_PtVel.GetCurveLength()
|
||||
<< " to len(B) = " << B_PtVel.GetCurveLength() << G4endl
|
||||
<< " Curve distance is " << curveDist / CLHEP::millimeter << " mm "
|
||||
<< G4endl
|
||||
<< "The final curve point is not further along"
|
||||
<< " than the original!" << G4endl;
|
||||
msg << " Value of fEpsStep= " << epsStep << G4endl;
|
||||
<< " Point A' (start) is " << A_PtVel << G4endl
|
||||
<< " Point B' (end) is " << B_PtVel << G4endl;
|
||||
msg << " fEpsStep= " << epsStep << G4endl << G4endl;
|
||||
|
||||
G4int oldprc = msg.precision(20);
|
||||
msg << " Point A (Curve start) is " << StartPointVel << G4endl
|
||||
<< " Point B (Curve end) is " << EndPointVel << G4endl
|
||||
<< " Point A (Current start) is " << A_PtVel << G4endl
|
||||
<< " Point B (Current end) is " << B_PtVel << G4endl
|
||||
<< " Point S (Sub start) is " << SubStart_PtVel
|
||||
<< " Point E (Trial Point) is " << E_Point << G4endl
|
||||
<< " Point F (Intersection) is " << ApproxIntersecPointV
|
||||
msg << " In full precision, the position, momentum, E_kin, length, rest mass "
|
||||
<< " ... are: " << G4endl;
|
||||
msg << " Point A[0] (Curve start) is " << StartPointVel << G4endl
|
||||
<< " Point S (Sub start) is " << SubStart_PtVel
|
||||
<< " Point A' (Current start) is " << A_PtVel << G4endl
|
||||
<< " Point E (Trial Point) is " << E_Point << G4endl
|
||||
<< " Point F (Intersection) is " << ApproxIntersecPointV << G4endl
|
||||
<< " Point B' (Current end) is " << B_PtVel << G4endl
|
||||
<< " Point B[0] (Curve end) is " << EndPointVel << G4endl
|
||||
<< G4endl
|
||||
<< " LocateIntersection parameters are : " << G4endl
|
||||
<< " Substep no (total) = " << substep_no << G4endl
|
||||
<< " Substep (depth= " << depth << substep_no_p;
|
||||
<< " Substep no = " << substep_no_p << " at depth= " << depth;
|
||||
msg.precision(oldprc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user