Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4ChordFinderSaf Class Reference

#include <G4ChordFinderSaf.hh>

Inheritance diagram for G4ChordFinderSaf:
G4ChordFinder

Public Member Functions

 G4ChordFinderSaf (G4MagInt_Driver *pIntegrationDriver)
 
 G4ChordFinderSaf (G4MagneticField *theMagField, G4double stepMinimum, G4MagIntegratorStepper *pItsStepper)
 
 ~G4ChordFinderSaf ()
 
G4double FindNextChord (const G4FieldTrack &yStart, G4double stepMax, G4FieldTrack &yEnd, G4double &dyErrPos, G4double epsStep, G4double *pStepForAccuracy, const G4ThreeVector latestSafetyOrigin, G4double latestSafetyRadius)
 
void PrintStatistics ()
 
- Public Member Functions inherited from G4ChordFinder
 G4ChordFinder (G4MagInt_Driver *pIntegrationDriver)
 
 G4ChordFinder (G4MagneticField *itsMagField, G4double stepMinimum=1.0e-2, G4MagIntegratorStepper *pItsStepper=0)
 
virtual ~G4ChordFinder ()
 
G4double AdvanceChordLimited (G4FieldTrack &yCurrent, G4double stepInitial, G4double epsStep_Relative, const G4ThreeVector latestSafetyOrigin, G4double lasestSafetyRadius)
 
G4FieldTrack ApproxCurvePointS (const G4FieldTrack &curveAPointVelocity, const G4FieldTrack &curveBPointVelocity, const G4FieldTrack &ApproxCurveV, const G4ThreeVector &currentEPoint, const G4ThreeVector &currentFPoint, const G4ThreeVector &PointG, G4bool first, G4double epsStep)
 
G4FieldTrack ApproxCurvePointV (const G4FieldTrack &curveAPointVelocity, const G4FieldTrack &curveBPointVelocity, const G4ThreeVector &currentEPoint, G4double epsStep)
 
G4double InvParabolic (const G4double xa, const G4double ya, const G4double xb, const G4double yb, const G4double xc, const G4double yc)
 
G4double GetDeltaChord () const
 
void SetDeltaChord (G4double newval)
 
void SetIntegrationDriver (G4MagInt_Driver *IntegrationDriver)
 
G4MagInt_DriverGetIntegrationDriver ()
 
void ResetStepEstimate ()
 
G4int GetNoCalls ()
 
G4int GetNoTrials ()
 
G4int GetNoMaxTrials ()
 
G4int SetVerbose (G4int newvalue=1)
 
void SetFractions_Last_Next (G4double fractLast=0.90, G4double fractNext=0.95)
 
void SetFirstFraction (G4double fractFirst)
 
void TestChordPrint (G4int noTrials, G4int lastStepTrial, G4double dChordStep, G4double nextStepTrial)
 
G4double GetFirstFraction ()
 
G4double GetFractionLast ()
 
G4double GetFractionNextEstimate ()
 
G4double GetMultipleRadius ()
 

Additional Inherited Members

- Protected Member Functions inherited from G4ChordFinder
void AccumulateStatistics (G4int noTrials)
 
G4bool AcceptableMissDist (G4double dChordStep) const
 
G4double NewStep (G4double stepTrialOld, G4double dChordStep, G4double &stepEstimate_Unconstrained)
 
void PrintDchordTrial (G4int noTrials, G4double stepTrial, G4double oldStepTrial, G4double dChordStep)
 
G4double GetLastStepEstimateUnc ()
 
void SetLastStepEstimateUnc (G4double stepEst)
 

Detailed Description

Definition at line 42 of file G4ChordFinderSaf.hh.

Constructor & Destructor Documentation

G4ChordFinderSaf::G4ChordFinderSaf ( G4MagInt_Driver pIntegrationDriver)

Definition at line 33 of file G4ChordFinderSaf.cc.

34  : G4ChordFinder(pIntegrationDriver)
35 {
36  // check the values and set the other parameters
37  // fNoInitialRadBig=0; fNoInitialRadSmall=0;
38  // fNoTrialsRadBig=0; fNoTrialsRadSmall=0;
39 
40 }
G4ChordFinder(G4MagInt_Driver *pIntegrationDriver)
G4ChordFinderSaf::G4ChordFinderSaf ( G4MagneticField theMagField,
G4double  stepMinimum,
G4MagIntegratorStepper pItsStepper 
)

Definition at line 44 of file G4ChordFinderSaf.cc.

47  : G4ChordFinder( theMagField, stepMinimum, pItsStepper )
48 {
49  // Let G4ChordFinder create the Driver, the Stepper and EqRhs ...
50  // ...
51 }
G4ChordFinder(G4MagInt_Driver *pIntegrationDriver)
G4ChordFinderSaf::~G4ChordFinderSaf ( )

Definition at line 57 of file G4ChordFinderSaf.cc.

References PrintStatistics(), and G4ChordFinder::SetVerbose().

58 {
59  if( SetVerbose(0) ) { PrintStatistics(); }
60  // Set verbosity 0, so that will be called in base class again
61 }
G4int SetVerbose(G4int newvalue=1)

Member Function Documentation

G4double G4ChordFinderSaf::FindNextChord ( const G4FieldTrack yStart,
G4double  stepMax,
G4FieldTrack yEnd,
G4double dyErrPos,
G4double  epsStep,
G4double pStepForAccuracy,
const G4ThreeVector  latestSafetyOrigin,
G4double  latestSafetyRadius 
)
virtual

Reimplemented from G4ChordFinder.

Definition at line 118 of file G4ChordFinderSaf.cc.

References G4ChordFinder::AcceptableMissDist(), G4ChordFinder::AccumulateStatistics(), CalculatePointInside(), CalculatePointSafety(), G4MagInt_Driver::ComputeNewStepSize(), G4cout, G4endl, G4ChordFinder::GetFirstFraction(), G4ChordFinder::GetFractionLast(), G4ChordFinder::GetIntegrationDriver(), G4ChordFinder::GetLastStepEstimateUnc(), G4FieldTrack::GetPosition(), G4INCL::Math::max(), G4INCL::Math::min(), G4FieldTrack::ncompSVEC, G4ChordFinder::NewStep(), G4MagInt_Driver::QuickAdvance(), and G4ChordFinder::SetLastStepEstimateUnc().

128 {
129  // G4int stepRKnumber=0;
130  G4FieldTrack yCurrent= yStart;
131  G4double stepTrial, stepForAccuracy;
133 
134  // 1.) Try to "leap" to end of interval
135  // 2.) Evaluate if resulting chord gives d_chord that is good enough.
136  // 2a.) If d_chord is not good enough, find one that is.
137 
138  G4bool validEndPoint= false;
139  G4double dChordStep, lastStepLength; // stepOfLastGoodChord;
140 
141  GetIntegrationDriver()-> GetDerivatives( yCurrent, dydx ) ;
142 
143  G4int noTrials=0;
144  const G4double safetyFactor= GetFirstFraction(); // was 0.999
145 
146  // Figure out the starting safety
147  G4double startSafety=
148  CalculatePointSafety( latestSafetyOrigin,
149  latestSafetyRadius,
150  yCurrent.GetPosition() );
151 
152  G4double
153  likelyGood = std::max( startSafety ,
154  safetyFactor * GetLastStepEstimateUnc() );
155 
156  stepTrial = std::min( stepMax, likelyGood );
157 
159  G4double newStepEst_Uncons= 0.0;
160  do
161  {
162  G4double stepForChord;
163  yCurrent = yStart; // Always start from initial point
164 
165  // ************
166  pIntgrDriver->QuickAdvance( yCurrent, dydx, stepTrial,
167  dChordStep, dyErrPos);
168  // ************
169 
170  G4ThreeVector EndPointCand= yCurrent.GetPosition();
171  G4bool endPointInSafetySphere=
172  CalculatePointInside(latestSafetyOrigin, latestSafetyRadius, EndPointCand);
173 
174  // We check whether the criterion is met here.
175  validEndPoint = AcceptableMissDist(dChordStep)
176  || endPointInSafetySphere;
177  // && (dyErrPos < eps) ;
178 
179  lastStepLength = stepTrial;
180 
181  // This method estimates to step size for a good chord.
182  stepForChord = NewStep(stepTrial, dChordStep, newStepEst_Uncons );
183 
184  if( ! validEndPoint ) {
185  if( stepTrial<=0.0 )
186  stepTrial = stepForChord;
187  else if (stepForChord <= stepTrial)
188  // Reduce by a fraction, possibly up to 20%
189  stepTrial = std::min( stepForChord,
190  GetFractionLast() * stepTrial);
191  else
192  stepTrial *= 0.1;
193 
194  // if(dbg) G4cerr<<"Dchord too big. Try new hstep="<<stepTrial<<G4endl;
195  }
196  // #ifdef TEST_CHORD_PRINT
197  // TestChordPrint( noTrials, lastStepLength, dChordStep, stepTrial );
198  // #endif
199 
200  noTrials++;
201  }
202  while( ! validEndPoint ); // End of do-while RKD
203 
204  AccumulateStatistics( noTrials );
205 
206  // Should we update newStepEst_Uncons for a 'long step' via safety ??
207  if( newStepEst_Uncons > 0.0 ){
208  SetLastStepEstimateUnc( newStepEst_Uncons );
209  }
210 
211  // stepOfLastGoodChord = stepTrial;
212 
213  if( pStepForAccuracy ){
214  // Calculate the step size required for accuracy, if it is needed
215  G4double dyErr_relative = dyErrPos/(epsStep*lastStepLength);
216  if( dyErr_relative > 1.0 ) {
217  stepForAccuracy =
218  pIntgrDriver->ComputeNewStepSize( dyErr_relative,
219  lastStepLength );
220  }else{
221  stepForAccuracy = 0.0; // Convention to show step was ok
222  }
223  *pStepForAccuracy = stepForAccuracy;
224  }
225 
226 #ifdef TEST_CHORD_PRINT
227  static int dbg=0;
228  if( dbg )
229  G4cout << "ChordF/FindNextChord: NoTrials= " << noTrials
230  << " StepForGoodChord=" << std::setw(10) << stepTrial << G4endl;
231 #endif
232 
233  yEnd= yCurrent;
234  return stepTrial;
235 }
G4double GetFirstFraction()
void SetLastStepEstimateUnc(G4double stepEst)
int G4int
Definition: G4Types.hh:78
G4bool CalculatePointInside(G4ThreeVector safetyOrigin, G4double safetyRadius, G4ThreeVector point)
G4ThreeVector GetPosition() const
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
G4bool AcceptableMissDist(G4double dChordStep) const
void AccumulateStatistics(G4int noTrials)
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()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4MagInt_Driver * GetIntegrationDriver()
G4double GetFractionLast()
G4double CalculatePointSafety(G4ThreeVector safetyOrigin, G4double safetyRadius, G4ThreeVector point)
void G4ChordFinderSaf::PrintStatistics ( )
virtual

Reimplemented from G4ChordFinder.

Definition at line 64 of file G4ChordFinderSaf.cc.

References G4cout, G4endl, and G4ChordFinder::PrintStatistics().

Referenced by ~G4ChordFinderSaf().

65 {
66  // Print Statistics
67  G4cout << "G4ChordFinderSaf statistics report: " << G4endl;
69 
70 /*******************
71  G4cout
72  << " No radbig calls " << std::setw(10) << fNoInitialRadBig
73  << " trials " << std::setw(10) << fNoTrialsRadBig
74  << " - over " << std::setw(10) << fNoTrialsRadBig - fNoInitialRadBig
75  << G4endl
76  << " No radsm calls " << std::setw(10) << fNoInitialRadSmall
77  << " trials " << std::setw(10) << fNoTrialsRadSmall
78  << " - over " << std::setw(10) << fNoTrialsRadSmall - fNoInitialRadSmall
79  << G4endl;
80  G4cout
81  << " *** Limiting stepTrial via if Delta_chord < R_curvature "
82  << " for large to angle from Delta_chord / R_curv "
83  << " and for small with multiple " << GetMultipleRadius()
84  << G4endl;
85 ********************/
86 }
virtual void PrintStatistics()
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

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