Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VIntersectionLocator Class Referenceabstract

#include <G4VIntersectionLocator.hh>

+ Inheritance diagram for G4VIntersectionLocator:

Public Member Functions

 G4VIntersectionLocator (G4Navigator *theNavigator)
 
virtual ~G4VIntersectionLocator ()
 
virtual G4bool EstimateIntersectionPoint (const G4FieldTrack &curveStartPointTangent, const G4FieldTrack &curveEndPointTangent, const G4ThreeVector &trialPoint, G4FieldTrack &intersectPointTangent, G4bool &recalculatedEndPoint, G4double &fPreviousSafety, G4ThreeVector &fPreviousSftOrigin)=0
 
void printStatus (const G4FieldTrack &startFT, const G4FieldTrack &currentFT, G4double requestStep, G4double safety, G4int stepNum)
 
G4bool IntersectChord (const G4ThreeVector &StartPointA, const G4ThreeVector &EndPointB, G4double &NewSafety, G4double &PreviousSafety, G4ThreeVector &PreviousSftOrigin, G4double &LinearStepLength, G4ThreeVector &IntersectionPoint, G4bool *calledNavigator=nullptr)
 
void SetEpsilonStepFor (G4double EpsilonStep)
 
void SetDeltaIntersectionFor (G4double deltaIntersection)
 
void SetNavigatorFor (G4Navigator *fNavigator)
 
void SetChordFinderFor (G4ChordFinder *fCFinder)
 
void SetVerboseFor (G4int fVerbose)
 
G4int GetVerboseFor ()
 
G4double GetDeltaIntersectionFor ()
 
G4double GetEpsilonStepFor ()
 
G4NavigatorGetNavigatorFor ()
 
G4ChordFinderGetChordFinderFor ()
 
void SetSafetyParametersFor (G4bool UseSafety)
 
void AddAdjustementOfFoundIntersection (G4bool UseCorrection)
 
G4bool GetAdjustementOfFoundIntersection ()
 
void AdjustIntersections (G4bool UseCorrection)
 
G4bool AreIntersectionsAdjusted ()
 
void SetCheckMode (G4bool value)
 
G4bool GetCheckMode ()
 

Static Public Member Functions

static void printStatus (const G4FieldTrack &startFT, const G4FieldTrack &currentFT, G4double requestStep, G4double safety, G4int stepNum, std::ostream &oss, G4int verboseLevel)
 

Protected Member Functions

G4FieldTrack ReEstimateEndpoint (const G4FieldTrack &CurrentStateA, const G4FieldTrack &EstimtdEndStateB, G4double linearDistSq, G4double curveDist)
 
G4bool CheckAndReEstimateEndpoint (const G4FieldTrack &CurrentStartA, const G4FieldTrack &EstimatedEndB, G4FieldTrack &RevisedEndPoint, G4int &errorCode)
 
G4ThreeVector GetSurfaceNormal (const G4ThreeVector &CurrentInt_Point, G4bool &validNormal)
 
G4ThreeVector GetGlobalSurfaceNormal (const G4ThreeVector &CurrentE_Point, G4bool &validNormal)
 
G4bool AdjustmentOfFoundIntersection (const G4ThreeVector &A, const G4ThreeVector &CurrentE_Point, const G4ThreeVector &CurrentF_Point, const G4ThreeVector &MomentumDir, const G4bool IntersectAF, G4ThreeVector &IntersectionPoint, G4double &NewSafety, G4double &fPrevSafety, G4ThreeVector &fPrevSftOrigin)
 
void ReportTrialStep (G4int step_no, const G4ThreeVector &ChordAB_v, const G4ThreeVector &ChordEF_v, const G4ThreeVector &NewMomentumDir, const G4ThreeVector &NormalAtEntry, G4bool validNormal)
 
G4bool LocateGlobalPointWithinVolumeAndCheck (const G4ThreeVector &pos)
 
void LocateGlobalPointWithinVolumeCheckAndReport (const G4ThreeVector &pos, const G4String &CodeLocationInfo, G4int CheckMode)
 
void ReportReversedPoints (std::ostringstream &ossMsg, const G4FieldTrack &StartPointVel, const G4FieldTrack &EndPointVel, G4double NewSafety, G4double epsStep, const G4FieldTrack &CurrentA_PointVelocity, const G4FieldTrack &CurrentB_PointVelocity, const G4FieldTrack &SubStart_PointVelocity, const G4ThreeVector &CurrentE_Point, const G4FieldTrack &ApproxIntersecPointV, G4int sbstp_no, G4int sbstp_no_p, G4int depth)
 
void ReportProgress (std::ostream &oss, const G4FieldTrack &StartPointVel, const G4FieldTrack &EndPointVel, G4int substep_no, const G4FieldTrack &A_PtVel, const G4FieldTrack &B_PtVel, G4double safetyLast, G4int depth=-1)
 
void ReportImmediateHit (const char *MethodName, const G4ThreeVector &StartPosition, const G4ThreeVector &TrialPoint, G4double tolerance, unsigned long int numCalls)
 

Protected Attributes

G4double kCarTolerance
 
G4int fVerboseLevel = 0
 
G4bool fUseNormalCorrection = false
 
G4bool fCheckMode = false
 
G4bool fiUseSafety = false
 
G4NavigatorfiNavigator
 
G4ChordFinderfiChordFinder = nullptr
 
G4double fiEpsilonStep = -1.0
 
G4double fiDeltaIntersection = -1.0
 
G4NavigatorfHelpingNavigator
 
G4TouchableHistoryfpTouchable = nullptr
 

Detailed Description

Definition at line 49 of file G4VIntersectionLocator.hh.

Constructor & Destructor Documentation

◆ G4VIntersectionLocator()

G4VIntersectionLocator::G4VIntersectionLocator ( G4Navigator * theNavigator)

Definition at line 46 of file G4VIntersectionLocator.cc.

47 : fiNavigator(theNavigator)
48{
50
51 if( fiNavigator->GetExternalNavigation() == nullptr )
52 {
54 }
55 else // Must clone the navigator, together with External Navigation
56 {
58 }
59}
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4VExternalNavigation * GetExternalNavigation() const
G4Navigator * Clone() const

◆ ~G4VIntersectionLocator()

G4VIntersectionLocator::~G4VIntersectionLocator ( )
virtual

Definition at line 65 of file G4VIntersectionLocator.cc.

66{
67 delete fHelpingNavigator;
68 delete fpTouchable;
69}
G4TouchableHistory * fpTouchable

Member Function Documentation

◆ AddAdjustementOfFoundIntersection()

void G4VIntersectionLocator::AddAdjustementOfFoundIntersection ( G4bool UseCorrection)
inline

◆ AdjustIntersections()

void G4VIntersectionLocator::AdjustIntersections ( G4bool UseCorrection)
inline

◆ AdjustmentOfFoundIntersection()

G4bool G4VIntersectionLocator::AdjustmentOfFoundIntersection ( const G4ThreeVector & A,
const G4ThreeVector & CurrentE_Point,
const G4ThreeVector & CurrentF_Point,
const G4ThreeVector & MomentumDir,
const G4bool IntersectAF,
G4ThreeVector & IntersectionPoint,
G4double & NewSafety,
G4double & fPrevSafety,
G4ThreeVector & fPrevSftOrigin )
protected

Definition at line 440 of file G4VIntersectionLocator.cc.

450{
451 G4double dist,lambda;
452 G4ThreeVector Normal, NewPoint, Point_G;
453 G4bool goodAdjust = false, Intersects_FP = false, validNormal = false;
454
455 // Get SurfaceNormal of Intersecting Solid
456 //
457 Normal = GetGlobalSurfaceNormal(CurrentE_Point,validNormal);
458 if(!validNormal) { return false; }
459
460 // Intersection between Line and Plane
461 //
462 G4double n_d_m = Normal.dot(MomentumDir);
463 if ( std::abs(n_d_m)>kCarTolerance )
464 {
465#ifdef G4VERBOSE
466 if ( fVerboseLevel>1 )
467 {
468 G4Exception("G4VIntersectionLocator::AdjustmentOfFoundIntersection()",
469 "GeomNav0003", JustWarning,
470 "No intersection. Parallels lines!");
471 }
472#endif
473 lambda =- Normal.dot(CurrentF_Point-CurrentE_Point)/n_d_m;
474
475 // New candidate for Intersection
476 //
477 NewPoint = CurrentF_Point+lambda*MomentumDir;
478
479 // Distance from CurrentF to Calculated Intersection
480 //
481 dist = std::abs(lambda);
482
483 if ( dist<kCarTolerance*0.001 ) { return false; }
484
485 // Calculation of new intersection point on the path.
486 //
487 if ( IntersectAF ) // First part intersects
488 {
489 G4double stepLengthFP;
490 G4ThreeVector Point_P = CurrentA_Point;
492 Intersects_FP = IntersectChord( Point_P, NewPoint, NewSafety,
494 stepLengthFP, Point_G );
495
496 }
497 else // Second part intersects
498 {
499 G4double stepLengthFP;
501 Intersects_FP = IntersectChord( CurrentF_Point, NewPoint, NewSafety,
503 stepLengthFP, Point_G );
504 }
505 if ( Intersects_FP )
506 {
507 goodAdjust = true;
508 IntersectionPoint = Point_G;
509 }
510 }
511
512 return goodAdjust;
513}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
#define fPreviousSftOrigin
#define fPreviousSafety
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
double dot(const Hep3Vector &) const
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4ThreeVector GetGlobalSurfaceNormal(const G4ThreeVector &CurrentE_Point, G4bool &validNormal)
G4Navigator * GetNavigatorFor()
G4bool IntersectChord(const G4ThreeVector &StartPointA, const G4ThreeVector &EndPointB, G4double &NewSafety, G4double &PreviousSafety, G4ThreeVector &PreviousSftOrigin, G4double &LinearStepLength, G4ThreeVector &IntersectionPoint, G4bool *calledNavigator=nullptr)

Referenced by G4BrentLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), and G4SimpleLocator::EstimateIntersectionPoint().

◆ AreIntersectionsAdjusted()

G4bool G4VIntersectionLocator::AreIntersectionsAdjusted ( )
inline

Definition at line 118 of file G4VIntersectionLocator.hh.

◆ CheckAndReEstimateEndpoint()

G4bool G4VIntersectionLocator::CheckAndReEstimateEndpoint ( const G4FieldTrack & CurrentStartA,
const G4FieldTrack & EstimatedEndB,
G4FieldTrack & RevisedEndPoint,
G4int & errorCode )
protected

Definition at line 330 of file G4VIntersectionLocator.cc.

335{
336 G4double linDistSq, curveDist;
337
338 G4bool recalculated = false;
339 curveError= 0;
340
341 linDistSq = ( EstimatedEndB.GetPosition()
342 - CurrentStartA.GetPosition() ).mag2();
343 curveDist = EstimatedEndB.GetCurveLength()
344 - CurrentStartA.GetCurveLength();
345 if( (curveDist>=0.0)
346 && (curveDist*curveDist *(1.0+2.0*fiEpsilonStep ) < linDistSq ) )
347 {
348 G4FieldTrack newEndPointFT = EstimatedEndB; // Unused
349
350 if (curveDist>0.0)
351 {
352 // Re-integrate to obtain a new B
353 RevisedEndPoint = ReEstimateEndpoint( CurrentStartA,
354 EstimatedEndB,
355 linDistSq,
356 curveDist );
357 recalculated = true;
358 }
359 else
360 {
361 // Zero length -> no advance!
362 newEndPointFT = CurrentStartA;
363 recalculated = true;
364 curveError = 1; // Unexpected co-incidence - milder mixup
365
366 G4Exception("G4MultiLevelLocator::EstimateIntersectionPoint()",
367 "GeomNav1002", JustWarning,
368 "A & B are at equal distance in 2nd half. A & B will coincide." );
369 }
370 }
371
372 // Sanity check
373 //
374 if( curveDist < 0.0 )
375 {
376 curveError = 2; // Real mixup
377 }
378 return recalculated;
379}
G4double GetCurveLength() const
G4ThreeVector GetPosition() const
G4FieldTrack ReEstimateEndpoint(const G4FieldTrack &CurrentStateA, const G4FieldTrack &EstimtdEndStateB, G4double linearDistSq, G4double curveDist)

Referenced by G4MultiLevelLocator::EstimateIntersectionPoint().

◆ EstimateIntersectionPoint()

virtual G4bool G4VIntersectionLocator::EstimateIntersectionPoint ( const G4FieldTrack & curveStartPointTangent,
const G4FieldTrack & curveEndPointTangent,
const G4ThreeVector & trialPoint,
G4FieldTrack & intersectPointTangent,
G4bool & recalculatedEndPoint,
G4double & fPreviousSafety,
G4ThreeVector & fPreviousSftOrigin )
pure virtual

◆ GetAdjustementOfFoundIntersection()

G4bool G4VIntersectionLocator::GetAdjustementOfFoundIntersection ( )
inline

◆ GetCheckMode()

G4bool G4VIntersectionLocator::GetCheckMode ( )
inline

◆ GetChordFinderFor()

◆ GetDeltaIntersectionFor()

G4double G4VIntersectionLocator::GetDeltaIntersectionFor ( )
inline

◆ GetEpsilonStepFor()

◆ GetGlobalSurfaceNormal()

G4ThreeVector G4VIntersectionLocator::GetGlobalSurfaceNormal ( const G4ThreeVector & CurrentE_Point,
G4bool & validNormal )
protected

Definition at line 564 of file G4VIntersectionLocator.cc.

567{
568 G4ThreeVector localNormal = GetLocalSurfaceNormal(CurrentE_Point,validNormal);
569 G4AffineTransform localToGlobal = // Must use the same Navigator !!
571 G4ThreeVector globalNormal = localToGlobal.TransformAxis( localNormal );
572
573#ifdef G4DEBUG_FIELD
574 if( validNormal && ( std::fabs(globalNormal.mag2() - 1.0) > perThousand ) )
575 {
576 std::ostringstream message;
577 message << "**************************************************************"
578 << G4endl;
579 message << " Bad Normal in G4VIntersectionLocator::GetGlobalSurfaceNormal "
580 << G4endl;
581 message << " * Constituents: " << G4endl;
582 message << " Local Normal= " << localNormal << G4endl;
583 message << " Transform: " << G4endl
584 << " Net Translation= " << localToGlobal.NetTranslation()
585 << G4endl
586 << " Net Rotation = " << localToGlobal.NetRotation()
587 << G4endl;
588 message << " * Result: " << G4endl;
589 message << " Global Normal= " << localNormal << G4endl;
590 message << "**************************************************************";
591 G4Exception("G4VIntersectionLocator::GetGlobalSurfaceNormal()",
592 "GeomNav1002", JustWarning, message);
593 }
594#endif
595
596 return globalNormal;
597}
#define G4endl
Definition G4ios.hh:67
double mag2() const
G4ThreeVector NetTranslation() const
G4RotationMatrix NetRotation() const
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
const G4AffineTransform GetLocalToGlobalTransform() const

Referenced by AdjustmentOfFoundIntersection().

◆ GetNavigatorFor()

◆ GetSurfaceNormal()

G4ThreeVector G4VIntersectionLocator::GetSurfaceNormal ( const G4ThreeVector & CurrentInt_Point,
G4bool & validNormal )
protected

Definition at line 519 of file G4VIntersectionLocator.cc.

522{
523 G4ThreeVector NormalAtEntry; // ( -10. , -10., -10. );
524
525 G4ThreeVector NormalAtEntryLast, NormalAtEntryGlobal, diffNormals;
526 G4bool validNormalLast;
527
528 // Relies on a call to Navigator::ComputeStep in IntersectChord before
529 // this call
530 //
531 NormalAtEntryLast = GetLastSurfaceNormal( CurrentInt_Point, validNormalLast );
532 // May return valid=false in cases, including
533 // - if the candidate volume was not found (eg exiting world), or
534 // - a replica was involved -- determined the step size.
535 // (This list is not complete.)
536
537#ifdef G4DEBUG_FIELD
538 if ( validNormalLast
539 && ( std::fabs(NormalAtEntryLast.mag2() - 1.0) > perThousand ) )
540 {
541 std::ostringstream message;
542 message << "PROBLEM: Normal is not unit - magnitude = "
543 << NormalAtEntryLast.mag() << G4endl;
544 message << " at trial intersection point " << CurrentInt_Point << G4endl;
545 message << " Obtained from Get *Last* Surface Normal.";
546 G4Exception("G4VIntersectionLocator::GetSurfaceNormal()",
547 "GeomNav1002", JustWarning, message);
548 }
549#endif
550
551 if( validNormalLast )
552 {
553 NormalAtEntry = NormalAtEntryLast;
554 }
555 validNormal = validNormalLast;
556
557 return NormalAtEntry;
558}
double mag() const

Referenced by G4BrentLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), and G4SimpleLocator::EstimateIntersectionPoint().

◆ GetVerboseFor()

G4int G4VIntersectionLocator::GetVerboseFor ( )
inline

◆ IntersectChord()

G4bool G4VIntersectionLocator::IntersectChord ( const G4ThreeVector & StartPointA,
const G4ThreeVector & EndPointB,
G4double & NewSafety,
G4double & PreviousSafety,
G4ThreeVector & PreviousSftOrigin,
G4double & LinearStepLength,
G4ThreeVector & IntersectionPoint,
G4bool * calledNavigator = nullptr )
inline

◆ LocateGlobalPointWithinVolumeAndCheck()

G4bool G4VIntersectionLocator::LocateGlobalPointWithinVolumeAndCheck ( const G4ThreeVector & pos)
protected

Definition at line 675 of file G4VIntersectionLocator.cc.

677{
678 G4bool good = true;
680 const G4String
681 MethodName("G4VIntersectionLocator::LocateGlobalPointWithinVolumeAndCheck()");
682
683 if( fCheckMode )
684 {
685 G4bool navCheck= nav->IsCheckModeActive(); // Recover original value
686 nav->CheckMode(true);
687
688 // Identify the current volume
689
691 G4VPhysicalVolume* motherPhys = startTH->GetVolume();
692 G4VSolid* motherSolid = startTH->GetSolid();
694 G4int motherCopyNo = motherPhys->GetCopyNo();
695
696 // Let's check that the point is inside the current solid
697 G4ThreeVector localPosition = transform.TransformPoint(position);
698 EInside inMother = motherSolid->Inside( localPosition );
699 if( inMother != kInside )
700 {
701 std::ostringstream message;
702 message << "Position located "
703 << ( inMother == kSurface ? " on Surface " : " outside " )
704 << "expected volume" << G4endl
705 << " Safety (from Outside) = "
706 << motherSolid->DistanceToIn(localPosition);
707 G4Exception("G4VIntersectionLocator::LocateGlobalPointWithinVolumeAndCheck()",
708 "GeomNav1002", JustWarning, message);
709 }
710
711 // 1. Simple next step - quick relocation and check result.
712 // nav->LocateGlobalPointWithinVolume( position );
713
714 // 2. Full relocation - to cross-check answer !
716 if( (nextPhysical != motherPhys)
717 || (nextPhysical->GetCopyNo() != motherCopyNo )
718 )
719 {
720 G4Exception("G4VIntersectionLocator::LocateGlobalPointWithinVolumeAndCheck()",
721 "GeomNav1002", JustWarning,
722 "Position located outside expected volume.");
723 }
724 nav->CheckMode(navCheck); // Recover original value
725 }
726 else
727 {
729 }
730 return good;
731}
int G4int
Definition G4Types.hh:85
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
void CheckMode(G4bool mode)
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4bool IsCheckModeActive() const
virtual G4TouchableHandle CreateTouchableHistoryHandle() const
const G4AffineTransform & GetGlobalToLocalTransform() const
virtual G4VSolid * GetSolid(G4int depth=0) const
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
virtual G4int GetCopyNo() const =0
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
EInside
Definition geomdefs.hh:67
@ kInside
Definition geomdefs.hh:70
@ kSurface
Definition geomdefs.hh:69

Referenced by LocateGlobalPointWithinVolumeCheckAndReport().

◆ LocateGlobalPointWithinVolumeCheckAndReport()

void G4VIntersectionLocator::LocateGlobalPointWithinVolumeCheckAndReport ( const G4ThreeVector & pos,
const G4String & CodeLocationInfo,
G4int CheckMode )
protected

Definition at line 737 of file G4VIntersectionLocator.cc.

741{
742 // Save value of Check mode first
743 G4bool oldCheck = GetCheckMode();
744
746 if( !ok )
747 {
748 std::ostringstream message;
749 message << "Failed point location." << G4endl
750 << " Code Location info: " << CodeLocationInfo;
751 G4Exception("G4VIntersectionLocator::LocateGlobalPointWithinVolumeCheckAndReport()",
752 "GeomNav1002", JustWarning, message);
753 }
754
755 SetCheckMode( oldCheck );
756}
G4bool LocateGlobalPointWithinVolumeAndCheck(const G4ThreeVector &pos)

◆ printStatus() [1/2]

void G4VIntersectionLocator::printStatus ( const G4FieldTrack & startFT,
const G4FieldTrack & currentFT,
G4double requestStep,
G4double safety,
G4int stepNum )

Definition at line 76 of file G4VIntersectionLocator.cc.

81{
82 std::ostringstream os;
83 printStatus( StartFT,CurrentFT,requestStep,safety,stepNo,os,fVerboseLevel);
84 G4cout << os.str();
85}
G4GLOB_DLL std::ostream G4cout
void printStatus(const G4FieldTrack &startFT, const G4FieldTrack &currentFT, G4double requestStep, G4double safety, G4int stepNum)

Referenced by G4BrentLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), G4SimpleLocator::EstimateIntersectionPoint(), printStatus(), printStatus(), ReportProgress(), and ReportReversedPoints().

◆ printStatus() [2/2]

void G4VIntersectionLocator::printStatus ( const G4FieldTrack & startFT,
const G4FieldTrack & currentFT,
G4double requestStep,
G4double safety,
G4int stepNum,
std::ostream & oss,
G4int verboseLevel )
static

Definition at line 92 of file G4VIntersectionLocator.cc.

99{
100 // const G4int verboseLevel= fVerboseLevel;
101 const G4ThreeVector StartPosition = StartFT.GetPosition();
102 const G4ThreeVector StartUnitVelocity = StartFT.GetMomentumDir();
103 const G4ThreeVector CurrentPosition = CurrentFT.GetPosition();
104 const G4ThreeVector CurrentUnitVelocity = CurrentFT.GetMomentumDir();
105
106 G4double step_len = CurrentFT.GetCurveLength() - StartFT.GetCurveLength();
107 G4long oldprc; // cout/cerr precision settings
108
109 if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
110 {
111 oldprc = os.precision(4);
112 os << std::setw( 6) << " "
113 << std::setw( 25) << " Current Position and Direction" << " "
114 << G4endl;
115 os << std::setw( 5) << "Step#"
116 << std::setw(10) << " s " << " "
117 << std::setw(10) << "X(mm)" << " "
118 << std::setw(10) << "Y(mm)" << " "
119 << std::setw(10) << "Z(mm)" << " "
120 << std::setw( 7) << " N_x " << " "
121 << std::setw( 7) << " N_y " << " "
122 << std::setw( 7) << " N_z " << " " ;
123 os << std::setw( 7) << " Delta|N|" << " "
124 << std::setw( 9) << "StepLen" << " "
125 << std::setw(12) << "StartSafety" << " "
126 << std::setw( 9) << "PhsStep" << " ";
127 os << G4endl;
128 os.precision(oldprc);
129 }
130 if((stepNo == 0) && (verboseLevel <=3))
131 {
132 // Recurse to print the start values
133 //
134 printStatus( StartFT, StartFT, -1.0, safety, -1, os, verboseLevel);
135 }
136 if( verboseLevel <= 3 )
137 {
138 if( stepNo >= 0)
139 {
140 os << std::setw( 4) << stepNo << " ";
141 }
142 else
143 {
144 os << std::setw( 5) << "Start" ;
145 }
146 oldprc = os.precision(8);
147 os << std::setw(10) << CurrentFT.GetCurveLength() << " ";
148 os << std::setw(10) << CurrentPosition.x() << " "
149 << std::setw(10) << CurrentPosition.y() << " "
150 << std::setw(10) << CurrentPosition.z() << " ";
151 os.precision(4);
152 os << std::setw( 7) << CurrentUnitVelocity.x() << " "
153 << std::setw( 7) << CurrentUnitVelocity.y() << " "
154 << std::setw( 7) << CurrentUnitVelocity.z() << " ";
155 os.precision(3);
156 os << std::setw( 7)
157 << CurrentFT.GetMomentum().mag()- StartFT.GetMomentum().mag()
158 << " ";
159 os << std::setw( 9) << step_len << " ";
160 os << std::setw(12) << safety << " ";
161 if( requestStep != -1.0 )
162 {
163 os << std::setw( 9) << requestStep << " ";
164 }
165 else
166 {
167 os << std::setw( 9) << "Init/NotKnown" << " ";
168 }
169 os << G4endl;
170 os.precision(oldprc);
171 }
172 else // if( verboseLevel > 3 )
173 {
174 // Multi-line output
175
176 os << "Step taken was " << step_len
177 << " out of PhysicalStep= " << requestStep << G4endl;
178 os << "Final safety is: " << safety << G4endl;
179 os << "Chord length = " << (CurrentPosition-StartPosition).mag()
180 << G4endl;
181 os << G4endl;
182 }
183}
long G4long
Definition G4Types.hh:87
double z() const
double x() const
double y() const

◆ ReEstimateEndpoint()

G4FieldTrack G4VIntersectionLocator::ReEstimateEndpoint ( const G4FieldTrack & CurrentStateA,
const G4FieldTrack & EstimtdEndStateB,
G4double linearDistSq,
G4double curveDist )
protected

Definition at line 189 of file G4VIntersectionLocator.cc.

198{
199 G4FieldTrack newEndPoint( CurrentStateA );
200 auto integrDriver = GetChordFinderFor()->GetIntegrationDriver();
201
202 G4FieldTrack retEndPoint( CurrentStateA );
203 G4bool goodAdvance;
204 G4int itrial = 0;
205 const G4int no_trials = 20;
206
207
208 G4double endCurveLen= EstimatedEndStateB.GetCurveLength();
209
210 do // Loop checking, 07.10.2016, JA
211 {
212 G4double currentCurveLen = newEndPoint.GetCurveLength();
213 G4double advanceLength = endCurveLen - currentCurveLen ;
214 if (std::abs(advanceLength)<kCarTolerance)
215 {
216 goodAdvance=true;
217 }
218 else
219 {
220 goodAdvance = integrDriver->AccurateAdvance(newEndPoint, advanceLength,
222 }
223 }
224 while( !goodAdvance && (++itrial < no_trials) );
225
226 if( goodAdvance )
227 {
228 retEndPoint = newEndPoint;
229 }
230 else
231 {
232 retEndPoint = EstimatedEndStateB; // Could not improve without major work !!
233 }
234
235 // All the work is done
236 // below are some diagnostics only -- before the return!
237 //
238 const G4String MethodName("G4VIntersectionLocator::ReEstimateEndpoint()");
239
240#ifdef G4VERBOSE
241 G4int latest_good_trials = 0;
242 if( itrial > 1)
243 {
244 if( fVerboseLevel > 0 )
245 {
246 G4cout << MethodName << " called - goodAdv= " << goodAdvance
247 << " trials = " << itrial
248 << " previous good= " << latest_good_trials
249 << G4endl;
250 }
251 latest_good_trials = 0;
252 }
253 else
254 {
255 ++latest_good_trials;
256 }
257#endif
258
259#ifdef G4DEBUG_FIELD
260 G4double lengthDone = newEndPoint.GetCurveLength()
261 - CurrentStateA.GetCurveLength();
262 if( !goodAdvance )
263 {
264 if( fVerboseLevel >= 3 )
265 {
266 G4cout << MethodName << "> AccurateAdvance failed " ;
267 G4cout << " in " << itrial << " integration trials/steps. " << G4endl;
268 G4cout << " It went only " << lengthDone << " instead of " << curveDist
269 << " -- a difference of " << curveDist - lengthDone << G4endl;
270 G4cout << " ReEstimateEndpoint> Reset endPoint to original value!"
271 << G4endl;
272 }
273 }
274 G4double linearDist = ( EstimatedEndStateB.GetPosition()
275 - CurrentStateA.GetPosition() ).mag();
276 static G4int noInaccuracyWarnings = 0;
277 G4int maxNoWarnings = 10;
278 if ( (noInaccuracyWarnings < maxNoWarnings )
279 || (fVerboseLevel > 1) )
280 {
281 G4ThreeVector move = newEndPoint.GetPosition()
282 - EstimatedEndStateB.GetPosition();
283 std::ostringstream message;
284 message.precision(12);
285 message << " Integration inaccuracy requires"
286 << " an adjustment in the step's endpoint." << G4endl
287 << " Two mid-points are further apart than their"
288 << " curve length difference" << G4endl
289 << " Dist = " << linearDist
290 << " curve length = " << curveDist << G4endl;
291 message << " Correction applied is " << move.mag() << G4endl
292 << " Old Estimated B position= "
293 << EstimatedEndStateB.GetPosition() << G4endl
294 << " Recalculated Position= "
295 << newEndPoint.GetPosition() << G4endl
296 << " Change ( new - old ) = " << move;
297 G4Exception("G4VIntersectionLocator::ReEstimateEndpoint()",
298 "GeomNav1002", JustWarning, message);
299 }
300/*
301#else
302 // Statistics on the RMS value of the corrections
303
304 static G4ThreadLocal G4int noCorrections = 0;
305 ++noCorrections;
306 if( goodAdvance )
307 {
308 static G4ThreadLocal G4double sumCorrectionsSq;
309 sumCorrectionsSq += (EstimatedEndStateB.GetPosition() -
310 newEndPoint.GetPosition()).mag2();
311 }
312*/
313#endif
314
315 return retEndPoint;
316}
G4VIntegrationDriver * GetIntegrationDriver()
G4ChordFinder * GetChordFinderFor()
G4double GetEpsilonStepFor()

Referenced by CheckAndReEstimateEndpoint(), G4BrentLocator::EstimateIntersectionPoint(), and G4SimpleLocator::EstimateIntersectionPoint().

◆ ReportImmediateHit()

void G4VIntersectionLocator::ReportImmediateHit ( const char * MethodName,
const G4ThreeVector & StartPosition,
const G4ThreeVector & TrialPoint,
G4double tolerance,
unsigned long int numCalls )
protected

Definition at line 846 of file G4VIntersectionLocator.cc.

851{
852 static G4ThreadLocal unsigned int occurredOnTop= 0;
853 static G4ThreadLocal G4ThreeVector* ptrLast = nullptr;
854 if( ptrLast == nullptr )
855 {
856 ptrLast= new G4ThreeVector( DBL_MAX, DBL_MAX, DBL_MAX );
857 G4AutoDelete::Register(ptrLast);
858 }
859 G4ThreeVector &lastStart= *ptrLast;
860
861 if( (TrialPoint - StartPosition).mag2() < tolerance*tolerance)
862 {
863 static G4ThreadLocal unsigned int numUnmoved = 0;
864 static G4ThreadLocal unsigned int numStill = 0; // Still at same point
865
866 G4cout << "Intersection F == start A in " << MethodName;
867 G4cout << "Start Point: " << StartPosition << G4endl;
868 G4cout << " Start-Trial: " << TrialPoint - StartPosition;
869 G4cout << " Start-last: " << StartPosition - lastStart;
870
871 if( (StartPosition - lastStart).mag() < tolerance )
872 {
873 // We are at position of last 'Start' position - ie unmoved
874 ++numUnmoved;
875 ++numStill;
876 G4cout << " { Unmoved: " << " still#= " << numStill
877 << " total # = " << numUnmoved << " } - ";
878 }
879 else
880 {
881 numStill = 0;
882 }
883 G4cout << " Occurred: " << ++occurredOnTop;
884 G4cout << " out of total calls= " << numCalls;
885 G4cout << G4endl;
886 lastStart = StartPosition;
887 }
888} // End of ReportImmediateHit()
CLHEP::Hep3Vector G4ThreeVector
void Register(T *inst)
#define DBL_MAX
Definition templates.hh:62
#define G4ThreadLocal
Definition tls.hh:77

Referenced by G4MultiLevelLocator::EstimateIntersectionPoint().

◆ ReportProgress()

void G4VIntersectionLocator::ReportProgress ( std::ostream & oss,
const G4FieldTrack & StartPointVel,
const G4FieldTrack & EndPointVel,
G4int substep_no,
const G4FieldTrack & A_PtVel,
const G4FieldTrack & B_PtVel,
G4double safetyLast,
G4int depth = -1 )
protected

Definition at line 814 of file G4VIntersectionLocator.cc.

823{
824 oss << "ReportProgress: Current status of intersection search: " << G4endl;
825 if( depth > 0 ) { oss << " Depth= " << depth; }
826 oss << " Substep no = " << substep_no << G4endl;
827 G4int verboseLevel = 5;
828 G4double safetyPrev = -1.0; // Add as argument ?
829
830 printStatus( StartPointVel, EndPointVel, -1.0, -1.0, -1,
831 oss, verboseLevel);
832 oss << " * Start and end-point of requested Step:" << G4endl;
833 oss << " ** State of point A: ";
834 printStatus( A_PtVel, A_PtVel, -1.0, safetyPrev, substep_no-1,
835 oss, verboseLevel);
836 oss << " ** State of point B: ";
837 printStatus( A_PtVel, B_PtVel, -1.0, safetyLast, substep_no,
838 oss, verboseLevel);
839}

Referenced by G4MultiLevelLocator::EstimateIntersectionPoint().

◆ ReportReversedPoints()

void G4VIntersectionLocator::ReportReversedPoints ( std::ostringstream & ossMsg,
const G4FieldTrack & StartPointVel,
const G4FieldTrack & EndPointVel,
G4double NewSafety,
G4double epsStep,
const G4FieldTrack & CurrentA_PointVelocity,
const G4FieldTrack & CurrentB_PointVelocity,
const G4FieldTrack & SubStart_PointVelocity,
const G4ThreeVector & CurrentE_Point,
const G4FieldTrack & ApproxIntersecPointV,
G4int sbstp_no,
G4int sbstp_no_p,
G4int depth )
protected

Definition at line 762 of file G4VIntersectionLocator.cc.

773{
774 // Expect that 'msg' can hold the name of the calling method
775
776 // FieldTrack 'points' A and B have been tangled
777 // Whereas A should be before B, it is found that curveLen(B) < curveLen(A)
778 G4int verboseLevel= 5;
779 G4double curveDist = B_PtVel.GetCurveLength() - A_PtVel.GetCurveLength();
780 G4VIntersectionLocator::printStatus( A_PtVel, B_PtVel,
781 -1.0, NewSafety, substep_no, msg, verboseLevel );
782 msg << "Error in advancing propagation." << G4endl
783 << " The final curve point is NOT further along"
784 << " than the original!" << G4endl
785 << " Going *backwards* from len(A) = " << A_PtVel.GetCurveLength()
786 << " to len(B) = " << B_PtVel.GetCurveLength() << G4endl
787 << " Curve distance is " << curveDist / CLHEP::millimeter << " mm "
788 << G4endl
789 << " Point A' (start) is " << A_PtVel << G4endl
790 << " Point B' (end) is " << B_PtVel << G4endl;
791 msg << " fEpsStep= " << epsStep << G4endl << G4endl;
792
793 G4long oldprc = msg.precision(20);
794 msg << " In full precision, the position, momentum, E_kin, length, rest mass "
795 << " ... are: " << G4endl;
796 msg << " Point A[0] (Curve start) is " << StartPointVel << G4endl
797 << " Point S (Sub start) is " << SubStart_PtVel
798 << " Point A' (Current start) is " << A_PtVel << G4endl
799 << " Point E (Trial Point) is " << E_Point << G4endl
800 << " Point F (Intersection) is " << ApproxIntersecPointV << G4endl
801 << " Point B' (Current end) is " << B_PtVel << G4endl
802 << " Point B[0] (Curve end) is " << EndPointVel << G4endl
803 << G4endl
804 << " LocateIntersection parameters are : " << G4endl
805 << " Substep no (total) = " << substep_no << G4endl
806 << " Substep no = " << substep_no_p << " at depth= " << depth;
807 msg.precision(oldprc);
808}

Referenced by G4MultiLevelLocator::EstimateIntersectionPoint().

◆ ReportTrialStep()

void G4VIntersectionLocator::ReportTrialStep ( G4int step_no,
const G4ThreeVector & ChordAB_v,
const G4ThreeVector & ChordEF_v,
const G4ThreeVector & NewMomentumDir,
const G4ThreeVector & NormalAtEntry,
G4bool validNormal )
protected

Definition at line 619 of file G4VIntersectionLocator.cc.

625{
626 G4double ABchord_length = ChordAB_v.mag();
627 G4double MomDir_dot_Norm = NewMomentumDir.dot( NormalAtEntry );
628 G4double MomDir_dot_ABchord;
629 MomDir_dot_ABchord = (1.0 / ABchord_length) * NewMomentumDir.dot( ChordAB_v );
630
631 std::ostringstream outStream;
632 outStream << std::setw(6) << " Step# "
633 << std::setw(17) << " |ChordEF|(mag)" << " "
634 << std::setw(18) << " uMomentum.Normal" << " "
635 << std::setw(18) << " uMomentum.ABdir " << " "
636 << std::setw(16) << " AB-dist " << " "
637 << " Chord Vector (EF) "
638 << G4endl;
639 outStream.precision(7);
640 outStream << " " << std::setw(5) << step_no
641 << " " << std::setw(18) << ChordEF_v.mag()
642 << " " << std::setw(18) << MomDir_dot_Norm
643 << " " << std::setw(18) << MomDir_dot_ABchord
644 << " " << std::setw(12) << ABchord_length
645 << " " << ChordEF_v
646 << G4endl;
647 outStream << " MomentumDir= " << " " << NewMomentumDir
648 << " Normal at Entry E= " << NormalAtEntry
649 << " AB chord = " << ChordAB_v
650 << G4endl;
651 G4cout << outStream.str();
652
653 if( ( std::fabs(NormalAtEntry.mag2() - 1.0) > perThousand ) )
654 {
655 std::ostringstream message;
656 message << "Normal is not unit - mag= " << NormalAtEntry.mag() << G4endl
657 << " ValidNormalAtE = " << validNormal;
658 G4Exception("G4VIntersectionLocator::ReportTrialStep()",
659 "GeomNav1002", JustWarning, message);
660 }
661 return;
662}

Referenced by G4BrentLocator::EstimateIntersectionPoint(), G4MultiLevelLocator::EstimateIntersectionPoint(), and G4SimpleLocator::EstimateIntersectionPoint().

◆ SetCheckMode()

void G4VIntersectionLocator::SetCheckMode ( G4bool value)
inline

Definition at line 130 of file G4VIntersectionLocator.hh.

130{ fCheckMode = value; }

Referenced by LocateGlobalPointWithinVolumeCheckAndReport().

◆ SetChordFinderFor()

void G4VIntersectionLocator::SetChordFinderFor ( G4ChordFinder * fCFinder)
inline

◆ SetDeltaIntersectionFor()

void G4VIntersectionLocator::SetDeltaIntersectionFor ( G4double deltaIntersection)
inline

◆ SetEpsilonStepFor()

void G4VIntersectionLocator::SetEpsilonStepFor ( G4double EpsilonStep)
inline

◆ SetNavigatorFor()

void G4VIntersectionLocator::SetNavigatorFor ( G4Navigator * fNavigator)
inline

◆ SetSafetyParametersFor()

void G4VIntersectionLocator::SetSafetyParametersFor ( G4bool UseSafety)
inline

◆ SetVerboseFor()

void G4VIntersectionLocator::SetVerboseFor ( G4int fVerbose)
inline

Member Data Documentation

◆ fCheckMode

◆ fHelpingNavigator

G4Navigator* G4VIntersectionLocator::fHelpingNavigator
protected

◆ fiChordFinder

G4ChordFinder* G4VIntersectionLocator::fiChordFinder = nullptr
protected

Definition at line 261 of file G4VIntersectionLocator.hh.

◆ fiDeltaIntersection

G4double G4VIntersectionLocator::fiDeltaIntersection = -1.0
protected

◆ fiEpsilonStep

G4double G4VIntersectionLocator::fiEpsilonStep = -1.0
protected

◆ fiNavigator

G4Navigator* G4VIntersectionLocator::fiNavigator
protected

Definition at line 259 of file G4VIntersectionLocator.hh.

Referenced by G4VIntersectionLocator().

◆ fiUseSafety

G4bool G4VIntersectionLocator::fiUseSafety = false
protected

Definition at line 257 of file G4VIntersectionLocator.hh.

◆ fpTouchable

G4TouchableHistory* G4VIntersectionLocator::fpTouchable = nullptr
protected

Definition at line 270 of file G4VIntersectionLocator.hh.

Referenced by ~G4VIntersectionLocator().

◆ fUseNormalCorrection

G4bool G4VIntersectionLocator::fUseNormalCorrection = false
protected

Definition at line 255 of file G4VIntersectionLocator.hh.

Referenced by AreIntersectionsAdjusted().

◆ fVerboseLevel

◆ kCarTolerance


The documentation for this class was generated from the following files: