Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ChordFinderSaf Class Reference

#include <G4ChordFinderSaf.hh>

+ Inheritance diagram for G4ChordFinderSaf:

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 SetChargeMomentumMass (G4double pCharge, G4double pMomentum, G4double pMass)
 
void SetIntegrationDriver (G4MagInt_Driver *IntegrationDriver)
 
G4MagInt_DriverGetIntegrationDriver ()
 
void ResetStepEstimate ()
 
G4int GetNoCalls ()
 
G4int GetNoTrials ()
 
G4int GetNoMaxTrials ()
 
virtual void PrintStatistics ()
 
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)
 
virtual G4double FindNextChord (const G4FieldTrack &yStart, G4double stepMax, G4FieldTrack &yEnd, G4double &dyErr, G4double epsStep, G4double *pNextStepForAccuracy, const G4ThreeVector latestSafetyOrigin, G4double latestSafetyRadius)
 
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() [1/2]

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}

◆ G4ChordFinderSaf() [2/2]

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}

◆ ~G4ChordFinderSaf()

G4ChordFinderSaf::~G4ChordFinderSaf ( )

Definition at line 57 of file G4ChordFinderSaf.cc.

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

◆ FindNextChord()

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.

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
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 CalculatePointSafety(G4ThreeVector safetyOrigin, G4double safetyRadius, G4ThreeVector point)
G4bool CalculatePointInside(G4ThreeVector safetyOrigin, G4double safetyRadius, G4ThreeVector point)
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void SetLastStepEstimateUnc(G4double stepEst)
G4bool AcceptableMissDist(G4double dChordStep) const
G4double NewStep(G4double stepTrialOld, G4double dChordStep, G4double &stepEstimate_Unconstrained)
G4double GetLastStepEstimateUnc()
void AccumulateStatistics(G4int noTrials)
G4double GetFractionLast()
G4MagInt_Driver * GetIntegrationDriver()
G4double GetFirstFraction()
G4ThreeVector GetPosition() const
G4double ComputeNewStepSize(G4double errMaxNorm, G4double hstepCurrent)
G4bool QuickAdvance(G4FieldTrack &y_val, const G4double dydx[], G4double hstep, G4double &dchord_step, G4double &dyerr)

◆ PrintStatistics()

void G4ChordFinderSaf::PrintStatistics ( )
virtual

Reimplemented from G4ChordFinder.

Definition at line 64 of file G4ChordFinderSaf.cc.

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()

Referenced by ~G4ChordFinderSaf().


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