49    fUseNormalCorrection(false),
 
   51    fiNavigator(theNavigator),
 
   54    fiDeltaIntersection(-1.0),     
 
   83   std::ostringstream os; 
 
  110   if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
 
  112     oldprc = os.precision(4);
 
  113     os << std::setw( 6)  << 
" "  
  114            << std::setw( 25) << 
" Current Position  and  Direction" << 
" " 
  116     os << std::setw( 5) << 
"Step#"  
  117            << std::setw(10) << 
"  s  " << 
" " 
  118            << std::setw(10) << 
"X(mm)" << 
" " 
  119            << std::setw(10) << 
"Y(mm)" << 
" "   
  120            << std::setw(10) << 
"Z(mm)" << 
" " 
  121            << std::setw( 7) << 
" N_x " << 
" " 
  122            << std::setw( 7) << 
" N_y " << 
" " 
  123            << std::setw( 7) << 
" N_z " << 
" " ;
 
  124     os << std::setw( 7) << 
" Delta|N|" << 
" " 
  125            << std::setw( 9) << 
"StepLen" << 
" "   
  126            << std::setw(12) << 
"StartSafety" << 
" "   
  127            << std::setw( 9) << 
"PhsStep" << 
" ";  
 
  129     os.precision(oldprc);
 
  131   if((stepNo == 0) && (verboseLevel <=3))
 
  135     printStatus( StartFT, StartFT, -1.0, safety, -1, os, verboseLevel);
 
  137   if( verboseLevel <= 3 )
 
  141        os << std::setw( 4) << stepNo << 
" ";
 
  145        os << std::setw( 5) << 
"Start" ;
 
  147     oldprc = os.precision(8);
 
  149     os << std::setw(10) << CurrentPosition.x() << 
" " 
  150            << std::setw(10) << CurrentPosition.y() << 
" " 
  151            << std::setw(10) << CurrentPosition.z() << 
" ";
 
  153     os << std::setw( 7) << CurrentUnitVelocity.x() << 
" " 
  154            << std::setw( 7) << CurrentUnitVelocity.y() << 
" " 
  155            << std::setw( 7) << CurrentUnitVelocity.z() << 
" ";
 
  160     os << std::setw( 9) << step_len << 
" "; 
 
  161     os << std::setw(12) << safety << 
" ";
 
  162     if( requestStep != -1.0 )
 
  164       os << std::setw( 9) << requestStep << 
" ";
 
  168       os << std::setw( 9) << 
"Init/NotKnown" << 
" "; 
 
  171     os.precision(oldprc);
 
  177     os << 
"Step taken was " << step_len  
 
  178            << 
" out of PhysicalStep= " <<  requestStep << 
G4endl;
 
  179     os << 
"Final safety is: " << safety << 
G4endl;
 
  180     os << 
"Chord length = " << (CurrentPosition-StartPosition).mag()
 
  203   const G4int no_trials=20;
 
  210     G4double advanceLength= endCurveLen - currentCurveLen ; 
 
  221   while( !goodAdvance && (++itrial < no_trials) );
 
  225     retEndPoint = newEndPoint; 
 
  229     retEndPoint = EstimatedEndStateB; 
 
  235   const G4String MethodName(
"G4VIntersectionLocator::ReEstimateEndpoint()");
 
  238   G4int  latest_good_trials = 0;
 
  243       G4cout << MethodName << 
" called - goodAdv= " << goodAdvance
 
  244              << 
" trials = " << itrial
 
  245              << 
" previous good= " << latest_good_trials
 
  248     latest_good_trials = 0; 
 
  252     latest_good_trials++; 
 
  263       G4cout << MethodName << 
"> AccurateAdvance failed " ;
 
  264       G4cout << 
" in " << itrial << 
" integration trials/steps. " << 
G4endl;
 
  265       G4cout << 
" It went only " << lengthDone << 
" instead of " << curveDist
 
  266              << 
" -- a difference of " << curveDist - lengthDone  << 
G4endl;
 
  267       G4cout << 
" ReEstimateEndpoint> Reset endPoint to original value!" 
  273   static G4int noInaccuracyWarnings = 0; 
 
  274   G4int maxNoWarnings = 10;
 
  275   if (  (noInaccuracyWarnings < maxNoWarnings ) 
 
  280       std::ostringstream message;
 
  281       message.precision(12);
 
  282       message << 
" Integration inaccuracy requires"  
  283               << 
" an adjustment in the step's endpoint."  << 
G4endl 
  284               << 
"   Two mid-points are further apart than their" 
  285               << 
" curve length difference"                << 
G4endl  
  286               << 
"   Dist = "       << linearDist
 
  287               << 
" curve length = " << curveDist             << 
G4endl; 
 
  288       message << 
" Correction applied is " << move.mag() << G4endl
 
  289               << 
"  Old Estimated B position= " 
  291               << 
"  Recalculated    Position= " 
  293               << 
"   Change ( new - old )   = " << move;
 
  294       G4Exception(
"G4VIntersectionLocator::ReEstimateEndpoint()",
 
  305     sumCorrectionsSq += (EstimatedEndStateB.
GetPosition() - 
 
  333   G4bool recalculated= 
false;
 
  341      && (curveDist*curveDist *(1.0+2.0*
fiEpsilonStep ) < linDistSq ) )
 
  358        newEndPointFT= CurrentStartA;
 
  362        G4Exception(
"G4MultiLevelLocator::EstimateIntersectionPoint()",
 
  364            "A & B are at equal distance in 2nd half. A & B will coincide." );
 
  370   if( curveDist < 0.0 )
 
  409     if( (pLogical != 0) && ( (pSolid=pLogical->
GetSolid()) !=0 )  )
 
  423           G4cerr << 
"PROBLEM in G4VIntersectionLocator::GetLocalSurfaceNormal." 
  425           G4cerr << 
"  Normal is not unit - mag=" << Normal.mag() << 
G4endl; 
 
  426           G4cerr << 
"  at trial local point " << CurrentE_Point << 
G4endl;
 
  453   G4bool goodAdjust=
false, Intersects_FP=
false, validNormal=
false;
 
  458   if(!validNormal) { 
return false; }
 
  462   G4double n_d_m = Normal.dot(MomentumDir);
 
  469              << 
"G4VIntersectionLocator::AdjustementOfFoundIntersection()" 
  471              << 
"        No intersection. Parallels lines!" << 
G4endl;
 
  474     lambda =- Normal.dot(CurrentF_Point-CurrentE_Point)/n_d_m;
 
  478     NewPoint = CurrentF_Point+lambda*MomentumDir;
 
  482     dist = std::abs(lambda);
 
  494                                       fPreviousSafety, fPreviousSftOrigin,
 
  495                                       stepLengthFP, Point_G );
 
  502       Intersects_FP = 
IntersectChord( CurrentF_Point, NewPoint, NewSafety,
 
  503                                       fPreviousSafety, fPreviousSftOrigin,
 
  504                                       stepLengthFP, Point_G );
 
  509       IntersectionPoint = Point_G;              
 
  526   G4ThreeVector NormalAtEntryLast, NormalAtEntryGlobal, diffNormals;
 
  540    && ( std::fabs(NormalAtEntryLast.mag2() - 1.0) > 
perThousand ) )
 
  542     std::ostringstream message; 
 
  543     message << 
"PROBLEM: Normal is not unit - magnitude = " 
  544             << NormalAtEntryLast.mag() << 
G4endl; 
 
  545     message << 
"   at trial intersection point " << CurrentInt_Point << 
G4endl;
 
  546     message << 
"   Obtained from Get *Last* Surface Normal."; 
 
  547     G4Exception(
"G4VIntersectionLocator::GetSurfaceNormal()",
 
  552   if( validNormalLast ) 
 
  554     NormalAtEntry=NormalAtEntryLast;  
 
  556   validNormal  = validNormalLast;
 
  558   return NormalAtEntry;
 
  577   if( validNormal && ( std::fabs(globalNormal.mag2() - 1.0) > 
perThousand ) ) 
 
  579     std::ostringstream message; 
 
  580     message << 
"**************************************************************" 
  582     message << 
" Bad Normal in G4VIntersectionLocator::GetGlobalSurfaceNormal " 
  584     message << 
"  * Constituents: " << 
G4endl;
 
  585     message << 
"    Local  Normal= " << localNormal << 
G4endl;
 
  586     message << 
"    Transform: " << G4endl
 
  589             << 
"      Net Rotation   = " << localToGlobal.
NetRotation()
 
  591     message << 
"  * Result: " << 
G4endl;
 
  592     message << 
"     Global Normal= " << localNormal << 
G4endl;
 
  593     message << 
"**************************************************************" 
  595     G4Exception(
"G4VIntersectionLocator::GetGlobalSurfaceNormal()",
 
  609                             G4bool& normalIsValid)
 const 
  614   normalIsValid= validNorm;
 
  630   G4double       ABchord_length  = ChordAB_v.mag(); 
 
  631   G4double       MomDir_dot_Norm = NewMomentumDir.dot( NormalAtEntry ) ;
 
  633   MomDir_dot_ABchord= (1.0 / ABchord_length) * NewMomentumDir.dot( ChordAB_v );
 
  635   std::ostringstream  outStream; 
 
  637     << std::setw(6)  << 
" Step# " 
  638     << std::setw(17) << 
" |ChordEF|(mag)" << 
"  " 
  639     << std::setw(18) << 
" uMomentum.Normal" << 
"  " 
  640     << std::setw(18) << 
" uMomentum.ABdir " << 
"  "  
  641     << std::setw(16) << 
" AB-dist         " << 
" "  
  642     << 
" Chord Vector (EF) "  
  644   outStream.precision(7); 
 
  646     << 
" " << std::setw(5)  << step_no           
 
  647     << 
" " << std::setw(18) << ChordEF_v.mag() 
 
  648     << 
" " << std::setw(18) << MomDir_dot_Norm    
 
  649     << 
" " << std::setw(18) << MomDir_dot_ABchord 
 
  650     << 
" " << std::setw(12) << ABchord_length     
 
  654     << 
" MomentumDir= " << 
" " << NewMomentumDir 
 
  655     << 
" Normal at Entry E= " << NormalAtEntry
 
  656     << 
" AB chord =   " << ChordAB_v
 
  658   G4cout << outStream.str();  
 
  660   if( ( std::fabs(NormalAtEntry.mag2() - 1.0) > 
perThousand ) ) 
 
  662     G4cerr << 
" PROBLEM in G4VIntersectionLocator::ReportTrialStep " << G4endl
 
  663            << 
"         Normal is not unit - mag=" <<  NormalAtEntry.mag() 
 
  664            << 
"         ValidNormalAtE = " << validNormal
 
  687   MethodName(
"G4VIntersectionLocator::LocateGlobalPointWithinVolumeAndCheck()");
 
  698     G4VSolid*          motherSolid= startTH->GetSolid();
 
  708       G4cerr << 
" ERROR in " << MethodName << 
" Position located " 
  709              << ( inMother == 
kSurface ? 
" on Surface " : 
" outside " )
 
  710              << 
"expected volume" << 
G4endl;
 
  712       G4cerr << 
"   Safety (from Outside) = " << safetyFromOut  << 
G4endl;
 
  720     if(    (nextPhysical != motherPhys)
 
  721         || (nextPhysical->
GetCopyNo() != motherCopyNo )
 
  724       G4cerr << 
" ERROR in " << MethodName
 
  725              << 
" Position located outside expected volume" << 
G4endl;
 
  751     G4cerr << 
" ERROR occured in Intersection Locator" << 
G4endl;
 
  752     G4cerr << 
"       Code Location info: " << CodeLocationInfo << 
G4endl;
 
  753     if( CheckMode > 1 ) {
 
  782    G4int verboseLevel= 5; 
 
  785                            -1.0, NewSafety,  substep_no, msg, verboseLevel );
 
  786    msg << 
"Error in advancing propagation." << 
G4endl 
  787        << 
"        Point A (start) is " << A_PtVel  << 
G4endl 
  788        << 
"        Point B (end)   is " << B_PtVel << 
G4endl 
  789        << 
"        Curve distance is " << curveDist << 
G4endl 
  791        << 
"The final curve point is not further along" 
  792        << 
" than the original!" << 
G4endl;
 
  793    msg << 
" Value of fEpsStep= " << epsStep << 
G4endl;
 
  795    G4int oldprc = msg.precision(20);
 
  796    msg << 
" Point A (Curve start) is " << StartPointVel << G4endl
 
  797        << 
" Point B (Curve   end)   is " << EndPointVel << G4endl
 
  798        << 
" Point A (Current start) is " << A_PtVel << G4endl
 
  799        << 
" Point B (Current end)   is " << B_PtVel << G4endl
 
  800        << 
" Point S (Sub start)     is " << SubStart_PtVel
 
  801        << 
" Point E (Trial Point)   is " << E_Point << G4endl
 
  802        << 
" Point F (Intersection)  is " << ApproxIntersecPointV 
 
  804        << 
" LocateIntersection parameters are : " << G4endl
 
  805        << 
"      Substep no (total) = "  << substep_no << G4endl
 
  806        << 
"      Substep (depth= " << depth << substep_no_p;
 
  807    msg.precision(oldprc);
 
  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; 
 
  832   printStatus( StartPointVel, EndPointVel, -1.0, -1.0, -1, 
 
  834   oss << 
" * Start and end-point of requested Step:" << 
G4endl;
 
  835   oss << 
" ** State of point A: "; 
 
  836   printStatus( A_PtVel, A_PtVel, -1.0, safetyPrev, substep_no-1,
 
  838   oss << 
" ** State of point B: "; 
 
  839   printStatus( A_PtVel, B_PtVel, -1.0, safetyLast, substep_no, 
 
  852                                             unsigned long int    numCalls )
 
  863   if( (TrialPoint - StartPosition).mag2() < tolerance*tolerance) 
 
  868      G4cout << 
"Intersection F == start A in " << MethodName;
 
  871      G4cout << 
" Start-Trial: " << TrialPoint - StartPosition; 
 
  872      G4cout << 
" Start-last: " << StartPosition - lastStart;
 
  874      if( (StartPosition - lastStart).mag() < tolerance )
 
  879         G4cout << 
" { Unmoved: "  << 
" still#= " << numStill
 
  880                << 
" total # = " << numUnmoved << 
" } - ";
 
  886      G4cout << 
" Occured: " << ++occurredOnTop;  
 
  887      G4cout <<  
" out of total calls= " << numCalls;
 
  889      lastStart = StartPosition;
 
G4FieldTrack ReEstimateEndpoint(const G4FieldTrack &CurrentStateA, const G4FieldTrack &EstimtdEndStateB, G4double linearDistSq, G4double curveDist)
 
G4double GetCurveLength() const 
 
CLHEP::Hep3Vector G4ThreeVector
 
G4ThreeVector GetGlobalSurfaceNormal(const G4ThreeVector &CurrentE_Point, G4bool &validNormal)
 
G4bool IsCheckModeActive() const 
 
static const G4float tolerance
 
G4ThreeVector GetSurfaceNormal(const G4ThreeVector &CurrentInt_Point, G4bool &validNormal)
 
virtual G4TouchableHistoryHandle CreateTouchableHistoryHandle() const 
 
G4bool IntersectChord(const G4ThreeVector &StartPointA, const G4ThreeVector &EndPointB, G4double &NewSafety, G4double &PreviousSafety, G4ThreeVector &PreviousSftOrigin, G4double &LinearStepLength, G4ThreeVector &IntersectionPoint, G4bool *calledNavigator=0)
 
G4double GetSurfaceTolerance() const 
 
const G4ThreeVector & GetMomentumDir() const 
 
G4ThreeVector GetLastSurfaceNormal(const G4ThreeVector &intersectPoint, G4bool &validNormal) const 
 
G4Navigator * fiNavigator
 
static const double perThousand
 
const G4AffineTransform GetLocalToGlobalTransform() const 
 
void printStatus(const G4FieldTrack &startFT, const G4FieldTrack ¤tFT, G4double requestStep, G4double safety, G4int stepNum)
 
void SetCheckMode(G4bool value)
 
G4double GetEpsilonStepFor()
 
void ReportImmediateHit(const char *MethodName, const G4ThreeVector &StartPosition, const G4ThreeVector &TrialPoint, double tolerance, unsigned long int numCalls)
 
G4ThreeVector GetPosition() const 
 
G4GLOB_DLL std::ostream G4cout
 
virtual EInside Inside(const G4ThreeVector &p) const =0
 
virtual ~G4VIntersectionLocator()
 
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
 
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 ReportTrialStep(G4int step_no, const G4ThreeVector &ChordAB_v, const G4ThreeVector &ChordEF_v, const G4ThreeVector &NewMomentumDir, const G4ThreeVector &NormalAtEntry, G4bool validNormal)
 
void LocateGlobalPointWithinVolumeCheckAndReport(const G4ThreeVector &pos, const G4String &CodeLocationInfo, G4int CheckMode)
 
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
 
G4Navigator * GetNavigatorFor()
 
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
G4bool LocateGlobalPointWithinVolumeAndCheck(const G4ThreeVector &pos)
 
G4TouchableHistory * CreateTouchableHistory() const 
 
G4LogicalVolume * GetLogicalVolume() const 
 
#define fPreviousSftOrigin
 
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
 
G4Navigator * fHelpingNavigator
 
G4VIntersectionLocator(G4Navigator *theNavigator)
 
virtual G4int GetCopyNo() const =0
 
void SetWorldVolume(G4VPhysicalVolume *pWorld)
 
const G4AffineTransform & GetGlobalToLocalTransform() const 
 
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
 
G4bool CheckAndReEstimateEndpoint(const G4FieldTrack &CurrentStartA, const G4FieldTrack &EstimatedEndB, G4FieldTrack &RevisedEndPoint, G4int &errorCode)
 
G4ThreeVector GetLocalSurfaceNormal(const G4ThreeVector &CurrentE_Point, G4bool &validNormal)
 
const G4AffineTransform & GetTopTransform() const 
 
void CheckMode(G4bool mode)
 
const G4NavigationHistory * GetHistory() const 
 
G4ThreeVector GetMomentum() const 
 
G4TouchableHistory * fpTouchable
 
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
 
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)
 
G4MagInt_Driver * GetIntegrationDriver()
 
G4ChordFinder * GetChordFinderFor()
 
G4bool AccurateAdvance(G4FieldTrack &y_current, G4double hstep, G4double eps, G4double hinitial=0.0)
 
static G4GeometryTolerance * GetInstance()
 
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
 
G4VSolid * GetSolid() const 
 
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)
 
G4GLOB_DLL std::ostream G4cerr