[831] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
[921] | 27 | // $Id: G4ChordFinder.hh,v 1.21 2008/10/29 14:17:42 gcosmo Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-02-cand-01 $ |
---|
[831] | 29 | // |
---|
| 30 | // |
---|
[921] | 31 | // Class G4ChordFinder |
---|
[831] | 32 | // |
---|
[921] | 33 | // class description: |
---|
[831] | 34 | // |
---|
| 35 | // A class that provides RK integration of motion ODE (as does g4magtr) |
---|
| 36 | // and also has a method that returns an Approximate point on the curve |
---|
| 37 | // near to a (chord) point. |
---|
| 38 | |
---|
| 39 | // History: |
---|
[921] | 40 | // - 25.02.97 - John Apostolakis - Design and implementation |
---|
[831] | 41 | // ------------------------------------------------------------------- |
---|
| 42 | |
---|
| 43 | #ifndef G4CHORDFINDER_HH |
---|
| 44 | #define G4CHORDFINDER_HH |
---|
| 45 | |
---|
| 46 | #include "G4MagIntegratorDriver.hh" |
---|
| 47 | #include "G4FieldTrack.hh" |
---|
| 48 | |
---|
| 49 | class G4MagneticField; |
---|
| 50 | |
---|
| 51 | class G4ChordFinder |
---|
| 52 | { |
---|
| 53 | public: // with description |
---|
| 54 | |
---|
| 55 | G4ChordFinder( G4MagInt_Driver* pIntegrationDriver ); |
---|
| 56 | |
---|
| 57 | G4ChordFinder( G4MagneticField* itsMagField, |
---|
| 58 | G4double stepMinimum = 1.0e-2 * mm, |
---|
| 59 | G4MagIntegratorStepper* pItsStepper = 0 ); |
---|
| 60 | // A constructor that creates defaults for all "children" classes. |
---|
| 61 | |
---|
| 62 | virtual ~G4ChordFinder(); |
---|
| 63 | |
---|
| 64 | G4double AdvanceChordLimited( G4FieldTrack& yCurrent, |
---|
| 65 | G4double stepInitial, |
---|
| 66 | G4double epsStep_Relative, |
---|
| 67 | const G4ThreeVector latestSafetyOrigin, |
---|
| 68 | G4double lasestSafetyRadius); |
---|
| 69 | // Uses ODE solver's driver to find the endpoint that satisfies |
---|
| 70 | // the chord criterion: that d_chord < delta_chord |
---|
| 71 | // -> Returns Length of Step taken. |
---|
[850] | 72 | |
---|
[921] | 73 | G4FieldTrack ApproxCurvePointS( const G4FieldTrack& curveAPointVelocity, |
---|
| 74 | const G4FieldTrack& curveBPointVelocity, |
---|
| 75 | const G4FieldTrack& ApproxCurveV, |
---|
| 76 | const G4ThreeVector& currentEPoint, |
---|
| 77 | const G4ThreeVector& currentFPoint, |
---|
| 78 | const G4ThreeVector& PointG, |
---|
| 79 | G4bool first, G4double epsStep); |
---|
[850] | 80 | |
---|
[921] | 81 | G4FieldTrack ApproxCurvePointV( const G4FieldTrack& curveAPointVelocity, |
---|
| 82 | const G4FieldTrack& curveBPointVelocity, |
---|
| 83 | const G4ThreeVector& currentEPoint, |
---|
| 84 | G4double epsStep); |
---|
[831] | 85 | |
---|
[850] | 86 | inline G4double InvParabolic( const G4double xa, const G4double ya, |
---|
[921] | 87 | const G4double xb, const G4double yb, |
---|
| 88 | const G4double xc, const G4double yc ); |
---|
[850] | 89 | |
---|
[831] | 90 | inline G4double GetDeltaChord() const; |
---|
| 91 | inline void SetDeltaChord(G4double newval); |
---|
| 92 | |
---|
| 93 | inline void SetChargeMomentumMass(G4double pCharge, // in e+ units |
---|
| 94 | G4double pMomentum, |
---|
| 95 | G4double pMass ); |
---|
| 96 | // Function to inform integration driver of charge, speed. |
---|
| 97 | |
---|
| 98 | inline void SetIntegrationDriver(G4MagInt_Driver* IntegrationDriver); |
---|
| 99 | inline G4MagInt_Driver* GetIntegrationDriver(); |
---|
| 100 | // Access and set Driver. |
---|
| 101 | |
---|
| 102 | inline void ResetStepEstimate(); |
---|
| 103 | // Clear internal state (last step estimate) |
---|
| 104 | |
---|
| 105 | inline G4int GetNoCalls(); |
---|
| 106 | inline G4int GetNoTrials(); // Total number of trials |
---|
| 107 | inline G4int GetNoMaxTrials(); // Maximum # of trials for one call |
---|
| 108 | // Get statistics about number of calls & trials in FindNextChord |
---|
| 109 | |
---|
| 110 | virtual void PrintStatistics(); |
---|
| 111 | // A report with the above -- and possibly other stats |
---|
| 112 | inline G4int SetVerbose( G4int newvalue=1); |
---|
[921] | 113 | // Set verbosity and return old value |
---|
[831] | 114 | |
---|
[921] | 115 | void SetFractions_Last_Next( G4double fractLast= 0.90, |
---|
| 116 | G4double fractNext= 0.95 ); |
---|
| 117 | // Parameters for performance ... change with great care |
---|
| 118 | |
---|
| 119 | inline void SetFirstFraction(G4double fractFirst); |
---|
| 120 | // Parameter for performance ... change with great care |
---|
| 121 | |
---|
| 122 | public: // without description |
---|
| 123 | |
---|
| 124 | void TestChordPrint( G4int noTrials, |
---|
| 125 | G4int lastStepTrial, |
---|
| 126 | G4double dChordStep, |
---|
| 127 | G4double nextStepTrial ); |
---|
| 128 | |
---|
| 129 | // Printing for monitoring ... |
---|
| 130 | |
---|
| 131 | inline G4double GetFirstFraction(); // Originally 0.999 |
---|
| 132 | inline G4double GetFractionLast(); // Originally 1.000 |
---|
| 133 | inline G4double GetFractionNextEstimate(); // Originally 0.980 |
---|
| 134 | inline G4double GetMultipleRadius(); // No original value |
---|
| 135 | // Parameters for adapting performance ... use with great care |
---|
| 136 | |
---|
[831] | 137 | protected: // ......................................................... |
---|
| 138 | |
---|
| 139 | inline void AccumulateStatistics( G4int noTrials ); |
---|
| 140 | // Accumulate the basic statistics |
---|
| 141 | // - other specialised ones must be kept by derived classes |
---|
| 142 | |
---|
| 143 | inline G4bool AcceptableMissDist(G4double dChordStep) const; |
---|
| 144 | |
---|
| 145 | G4double NewStep( G4double stepTrialOld, |
---|
| 146 | G4double dChordStep, // Current dchord estimate |
---|
| 147 | G4double& stepEstimate_Unconstrained ) ; |
---|
| 148 | |
---|
[850] | 149 | virtual G4double FindNextChord( const G4FieldTrack& yStart, |
---|
[831] | 150 | G4double stepMax, |
---|
| 151 | G4FieldTrack& yEnd, |
---|
| 152 | G4double& dyErr, // Error of endpoint |
---|
| 153 | G4double epsStep, |
---|
| 154 | G4double* pNextStepForAccuracy, // = 0, |
---|
| 155 | const G4ThreeVector latestSafetyOrigin, |
---|
| 156 | G4double latestSafetyRadius |
---|
| 157 | ); |
---|
| 158 | |
---|
| 159 | void PrintDchordTrial(G4int noTrials, |
---|
| 160 | G4double stepTrial, |
---|
| 161 | G4double oldStepTrial, |
---|
| 162 | G4double dChordStep); |
---|
| 163 | |
---|
| 164 | inline G4double GetLastStepEstimateUnc(); |
---|
| 165 | inline void SetLastStepEstimateUnc( G4double stepEst ); |
---|
| 166 | |
---|
| 167 | private: // ............................................................ |
---|
| 168 | |
---|
| 169 | G4ChordFinder(const G4ChordFinder&); |
---|
| 170 | G4ChordFinder& operator=(const G4ChordFinder&); |
---|
| 171 | // Private copy constructor and assignment operator. |
---|
| 172 | |
---|
| 173 | private: // ............................................................ |
---|
[921] | 174 | // G4int nOK, nBAD; |
---|
[831] | 175 | G4MagInt_Driver* fIntgrDriver; |
---|
| 176 | |
---|
| 177 | const G4double fDefaultDeltaChord; // SET in G4ChordFinder.cc = 0.25 mm |
---|
| 178 | |
---|
[921] | 179 | G4double fDeltaChord; // Maximum miss distance |
---|
[831] | 180 | |
---|
[921] | 181 | G4double fLastStepEstimate_Unconstrained; |
---|
| 182 | // State information for efficiency |
---|
| 183 | |
---|
[831] | 184 | // Variables used in construction/destruction |
---|
[921] | 185 | |
---|
[831] | 186 | G4bool fAllocatedStepper; |
---|
| 187 | G4EquationOfMotion* fEquation; |
---|
| 188 | G4MagIntegratorStepper* fDriversStepper; |
---|
| 189 | |
---|
| 190 | // Parameters |
---|
| 191 | G4double fFirstFraction, fFractionLast, fFractionNextEstimate; |
---|
| 192 | G4double fMultipleRadius; |
---|
| 193 | |
---|
| 194 | // For Statistics |
---|
| 195 | // -- G4int fNoTrials, fNoCalls; |
---|
| 196 | G4int fTotalNoTrials_FNC, fNoCalls_FNC, fmaxTrials_FNC; // fnoTimesMaxTrFNC; |
---|
| 197 | G4int fStatsVerbose; // if > 0, print Statistics in destructor |
---|
| 198 | }; |
---|
| 199 | |
---|
| 200 | // Inline function implementation: |
---|
| 201 | |
---|
| 202 | #include "G4ChordFinder.icc" |
---|
| 203 | |
---|
| 204 | #endif // G4CHORDFINDER_HH |
---|