66 G4cout <<
"G4ChordFinderSaf statistics report: " <<
G4endl;
99 if( MagSqShift <
sqr(safetyRadius) ){
100 pointSafety = safetyRadius - std::sqrt(MagSqShift) ;
113 return ( OriginShift.
mag2() < safetyRadius*safetyRadius );
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 );
167 pIntgrDriver->QuickAdvance( yCurrent, dydx, stepTrial,
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 )
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 ) {
233 pIntgrDriver->ComputeNewStepSize( dyErr_relative,
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;
G4VIntegrationDriver * GetIntegrationDriver()
G4bool AcceptableMissDist(G4double dChordStep) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void SetLastStepEstimateUnc(G4double stepEst)
G4double NewStep(G4double stepTrialOld, G4double dChordStep, G4double &stepEstimate_Unconstrained)
void message(RunManager *runmanager)
G4ThreeVector GetPosition() const
G4double GetLastStepEstimateUnc()
virtual void PrintStatistics()
G4ChordFinderSaf(G4VIntegrationDriver *pIntegrationDriver)
G4bool CalculatePointInside(G4ThreeVector safetyOrigin, G4double safetyRadius, G4ThreeVector point)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4int SetVerbose(G4int newvalue=1)
G4double GetFirstFraction()
G4double FindNextChord(const G4FieldTrack &yStart, G4double stepMax, G4FieldTrack &yEnd, G4double &dyErrPos, G4double epsStep, G4double *pStepForAccuracy, const G4ThreeVector latestSafetyOrigin, G4double latestSafetyRadius)
G4GLOB_DLL std::ostream G4cout
G4double CalculatePointSafety(G4ThreeVector safetyOrigin, G4double safetyRadius, G4ThreeVector point)
G4double GetFractionLast()
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
void AccumulateStatistics(G4int noTrials)