130 G4double stepTrial, stepForAccuracy;
137 G4bool validEndPoint=
false;
138 G4double dChordStep, lastStepLength;
142 unsigned int noTrials=0;
143 const unsigned int maxTrials= 75;
154 likelyGood =
std::max( startSafety ,
157 stepTrial =
std::min( stepMax, likelyGood );
168 dChordStep, dyErrPos);
172 G4bool endPointInSafetySphere=
177 || endPointInSafetySphere;
180 lastStepLength = stepTrial;
183 stepForChord =
NewStep(stepTrial, dChordStep, newStepEst_Uncons );
185 if( ! validEndPoint ) {
187 stepTrial = stepForChord;
188 else if (stepForChord <= stepTrial)
203 while( (! validEndPoint) && (noTrials < maxTrials) );
206 if( noTrials >= maxTrials )
208 std::ostringstream message;
209 message <<
"Exceeded maximum number of trials= " << maxTrials <<
G4endl
210 <<
"Current sagita dist= " << dChordStep <<
G4endl
211 <<
"Step sizes (actual and proposed): " <<
G4endl
212 <<
"Last trial = " << lastStepLength <<
G4endl
213 <<
"Next trial = " << stepTrial <<
G4endl
214 <<
"Proposed for chord = " << stepForChord <<
G4endl
216 G4Exception(
"G4ChordFinderSaf::FindNextChord()",
"GeomField0003",
222 if( newStepEst_Uncons > 0.0 ){
228 if( pStepForAccuracy ){
230 G4double dyErr_relative = dyErrPos/(epsStep*lastStepLength);
231 if( dyErr_relative > 1.0 ) {
236 stepForAccuracy = 0.0;
238 *pStepForAccuracy = stepForAccuracy;
241 #ifdef TEST_CHORD_PRINT
244 G4cout <<
"ChordF/FindNextChord: NoTrials= " << noTrials
245 <<
" StepForGoodChord=" << std::setw(10) << stepTrial <<
G4endl;
G4double GetFirstFraction()
void SetLastStepEstimateUnc(G4double stepEst)
G4bool CalculatePointInside(G4ThreeVector safetyOrigin, G4double safetyRadius, G4ThreeVector point)
G4ThreeVector GetPosition() const
G4GLOB_DLL std::ostream G4cout
G4bool AcceptableMissDist(G4double dChordStep) const
void AccumulateStatistics(G4int noTrials)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4bool QuickAdvance(G4FieldTrack &y_val, const G4double dydx[], G4double hstep, G4double &dchord_step, G4double &dyerr)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4double NewStep(G4double stepTrialOld, G4double dChordStep, G4double &stepEstimate_Unconstrained)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4double ComputeNewStepSize(G4double errMaxNorm, G4double hstepCurrent)
G4double GetLastStepEstimateUnc()
G4MagInt_Driver * GetIntegrationDriver()
G4double GetFractionLast()
G4double CalculatePointSafety(G4ThreeVector safetyOrigin, G4double safetyRadius, G4ThreeVector point)