G4ChordFinder.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4ChordFinder.hh 69786 2013-05-15 09:38:51Z gcosmo $
00028 //
00029 // 
00030 // Class G4ChordFinder
00031 //
00032 // class description:
00033 //
00034 // A class that provides RK integration of motion ODE  (as does g4magtr)
00035 // and also has a method that returns an Approximate point on the curve 
00036 // near to a (chord) point.
00037 
00038 // History:
00039 // - 25.02.97 - John Apostolakis - Design and implementation 
00040 // -------------------------------------------------------------------
00041 
00042 #ifndef G4CHORDFINDER_HH
00043 #define G4CHORDFINDER_HH
00044 
00045 #include "G4MagIntegratorDriver.hh"
00046 #include "G4FieldTrack.hh"
00047 
00048 class G4MagneticField;  
00049 
00050 class G4ChordFinder
00051 { 
00052    public:  // with description
00053 
00054       G4ChordFinder( G4MagInt_Driver* pIntegrationDriver );
00055 
00056       G4ChordFinder( G4MagneticField* itsMagField,
00057                      G4double         stepMinimum = 1.0e-2, // * mm 
00058                      G4MagIntegratorStepper* pItsStepper = 0 );  
00059         // A constructor that creates defaults for all "children" classes.
00060       
00061       virtual ~G4ChordFinder();
00062 
00063       G4double    AdvanceChordLimited( G4FieldTrack& yCurrent,
00064                                        G4double stepInitial,
00065                                        G4double epsStep_Relative,
00066                                        const G4ThreeVector latestSafetyOrigin,
00067                                        G4double lasestSafetyRadius);
00068         // Uses ODE solver's driver to find the endpoint that satisfies 
00069         // the chord criterion: that d_chord < delta_chord
00070         // -> Returns Length of Step taken.
00071      
00072       G4FieldTrack ApproxCurvePointS( const G4FieldTrack&  curveAPointVelocity,
00073                                       const G4FieldTrack&  curveBPointVelocity,
00074                                       const G4FieldTrack&  ApproxCurveV,
00075                                       const G4ThreeVector& currentEPoint,
00076                                       const G4ThreeVector& currentFPoint,
00077                                       const G4ThreeVector& PointG,
00078                                             G4bool first,  G4double epsStep);
00079  
00080       G4FieldTrack ApproxCurvePointV( const G4FieldTrack&  curveAPointVelocity,
00081                                       const G4FieldTrack&  curveBPointVelocity,
00082                                       const G4ThreeVector& currentEPoint,
00083                                             G4double       epsStep);
00084 
00085       inline G4double InvParabolic( const G4double xa, const G4double ya,
00086                                     const G4double xb, const G4double yb,
00087                                     const G4double xc, const G4double yc );
00088 
00089       inline G4double  GetDeltaChord() const;
00090       inline void      SetDeltaChord(G4double newval);
00091 
00092       inline void SetChargeMomentumMass(G4double pCharge,  // in e+ units
00093                                         G4double pMomentum,
00094                                         G4double pMass );
00095         // Function to inform integration driver of charge, speed.
00096 
00097       inline void SetIntegrationDriver(G4MagInt_Driver* IntegrationDriver);
00098       inline G4MagInt_Driver* GetIntegrationDriver();
00099         // Access and set Driver.
00100 
00101       inline void ResetStepEstimate();
00102         // Clear internal state (last step estimate)
00103 
00104       inline G4int GetNoCalls(); 
00105       inline G4int GetNoTrials();        // Total number of trials
00106       inline G4int GetNoMaxTrials();     // Maximum # of trials for one call
00107         // Get statistics about number of calls & trials in FindNextChord
00108 
00109       virtual void   PrintStatistics(); 
00110         // A report with the above -- and possibly other stats
00111       inline G4int SetVerbose( G4int newvalue=1); 
00112         // Set verbosity and return old value
00113 
00114       void SetFractions_Last_Next( G4double fractLast= 0.90, 
00115                                    G4double fractNext= 0.95 ); 
00116         // Parameters for  performance ... change with great care
00117 
00118       inline void SetFirstFraction(G4double fractFirst);
00119         // Parameter for  performance ... change with great care
00120 
00121    public:  // without description
00122 
00123       void     TestChordPrint( G4int    noTrials, 
00124                                G4int    lastStepTrial, 
00125                                G4double dChordStep, 
00126                                G4double nextStepTrial );
00127 
00128         //   Printing for monitoring ...
00129  
00130       inline   G4double GetFirstFraction();         // Originally 0.999
00131       inline   G4double GetFractionLast();          // Originally 1.000
00132       inline   G4double GetFractionNextEstimate();  // Originally 0.980
00133       inline   G4double GetMultipleRadius();        // No original value
00134         //  Parameters for adapting performance ... use with great care
00135 
00136    protected:   // .........................................................
00137 
00138       inline  void    AccumulateStatistics( G4int noTrials ); 
00139         // Accumulate the basic statistics 
00140         //   - other specialised ones must be kept by derived classes
00141  
00142       inline G4bool AcceptableMissDist(G4double dChordStep) const;
00143 
00144       G4double NewStep( G4double stepTrialOld, 
00145                         G4double dChordStep,     // Current dchord estimate
00146                         G4double& stepEstimate_Unconstrained ) ;  
00147       
00148       virtual G4double FindNextChord( const  G4FieldTrack& yStart,
00149                               G4double     stepMax,
00150                               G4FieldTrack& yEnd,
00151                               G4double&    dyErr,      //  Error of endpoint 
00152                               G4double     epsStep,
00153                               G4double*  pNextStepForAccuracy,  // = 0,
00154                               const G4ThreeVector latestSafetyOrigin,
00155                               G4double       latestSafetyRadius 
00156                                       );  
00157 
00158       void     PrintDchordTrial(G4int     noTrials, 
00159                                 G4double  stepTrial, 
00160                                 G4double  oldStepTrial, 
00161                                 G4double  dChordStep);
00162 
00163       inline G4double GetLastStepEstimateUnc(); 
00164       inline void     SetLastStepEstimateUnc( G4double stepEst ); 
00165 
00166    private:  // ............................................................
00167 
00168       G4ChordFinder(const G4ChordFinder&);
00169       G4ChordFinder& operator=(const G4ChordFinder&);
00170         // Private copy constructor and assignment operator.
00171 
00172    private:  // ............................................................
00173                                           // G4int    nOK, nBAD;
00174 
00175       // Constants
00176       const G4double fDefaultDeltaChord;  // SET in G4ChordFinder.cc = 0.25 mm
00177 
00178       //  PARAMETERS 
00179       //  ---------------------
00180       G4double  fDeltaChord;               //  Maximum miss distance 
00181       //    Internal parameters
00182       G4double  fFirstFraction, fFractionLast, fFractionNextEstimate;
00183       G4double  fMultipleRadius; 
00184       G4int     fStatsVerbose;  // if > 0, print Statistics in destructor
00185 
00186       //  DEPENDENT Objects
00187       //  ---------------------
00188       G4MagInt_Driver*        fIntgrDriver;
00189       G4MagIntegratorStepper* fDriversStepper; 
00190       G4bool                  fAllocatedStepper;  // Bookkeeping of dependent object
00191       G4EquationOfMotion*     fEquation; 
00192 
00193       //  STATE information
00194       //  --------------------
00195       G4double    fLastStepEstimate_Unconstrained;
00196         //  State information for efficiency
00197 
00198       // For Statistics
00199       // -- G4int   fNoTrials, fNoCalls;
00200       G4int   fTotalNoTrials_FNC,  fNoCalls_FNC, fmaxTrials_FNC; // fnoTimesMaxTrFNC; 
00201 };
00202 
00203 // Inline function implementation:
00204 
00205 #include "G4ChordFinder.icc"
00206 
00207 #endif  // G4CHORDFINDER_HH

Generated on Mon May 27 17:47:53 2013 for Geant4 by  doxygen 1.4.7