Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:13:13

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4HelixMixedStepper
0027 //
0028 // Class description:
0029 //
0030 // G4HelixMixedStepper split the Method used for Integration in two:
0031 //
0032 // If Stepping Angle ( h / R_curve) < pi/3 : use Stepper for small step
0033 // 
0034 // Else use  HelixExplicitEuler Stepper
0035 //
0036 // Stepper for the small step is G4ClassicalRK4 by default, but
0037 // it possible to choose other stepper,like G4CashKarpRK45 or G4RKG3_Stepper,
0038 // by setting StepperNumber : new HelixMixedStepper(EqRhs,N)
0039 //
0040 //  N=2  G4SimpleRunge;            N=3  G4SimpleHeum;
0041 //  N=4  G4ClassicalRK4;      
0042 //  N=6  G4HelixImplicitEuler;     N=7  G4HelixSimpleRunge;
0043 //  N=8  G4CashKarpRK45;           N=9  G4ExactHelixStepper;
0044 //  N=10 G4RKG3_Stepper;           N=13 G4NystromRK4
0045 //  N=23 BogackiShampine23         N=145 TsitourasRK45 
0046 //  N=45 BogackiShampine45         N=745 DormandPrince745 (ie DoPri5)
0047 //
0048 // For completeness also available are:
0049 //  N=11 G4ExplicitEuler           N=12 G4ImplicitEuler;   -- Likely poor
0050 //  N=5  G4HelixExplicitEuler (testing only)
0051 //  For recommendations see comments in 'SetupStepper' method.
0052 //
0053 // Note: Like other helix steppers, only applicable in pure magnetic field.
0054 
0055 // Author: Tatiana Nikitina (CERN), 18.05.2007
0056 // -------------------------------------------------------------------
0057 #ifndef G4HELIXMIXEDSTEPPER_HH
0058 #define G4HELIXMIXEDSTEPPER_HH
0059 
0060 #include "G4MagHelicalStepper.hh"
0061 
0062 /**
0063  * @brief G4HelixMixedStepper is a concrete class for particle motion in
0064  * magnetic field which splits the method used for Integration in two:
0065  * if the stepping angle ( h / R_curve) is less than pi/3, use a RK stepper
0066  * for small step, else use G4HelixExplicitEuler stepper.
0067  * Like other helix steppers, it is only applicable in pure magnetic field.
0068  */
0069 
0070 class G4HelixMixedStepper : public G4MagHelicalStepper
0071 {
0072   public:  
0073 
0074     /**
0075      * Constructor for G4ExactHelixStepper.
0076      *  @param[in] EqRhs Pointer to the standard equation of motion.
0077      *  @param[in] StepperNumber Identified for selecting the stepper type;
0078      *             default (-1) is DormandPrince745.
0079      *  @param[in] Angle_threshold The stepping angle threshold; default (-1)
0080      *             is (1/3)*pi.
0081      */
0082     G4HelixMixedStepper(G4Mag_EqRhs* EqRhs,
0083                         G4int StepperNumber = -1,
0084                         G4double Angle_threshold = -1.0);
0085 
0086     /**
0087      * Default Destructor.
0088      */
0089     ~G4HelixMixedStepper() override;
0090 
0091     /**
0092      * The integration stepper. The stepsize is fixed, with the step size
0093      * given by 'hstep'. Integrates ODE starting values yInput[0 to 6].
0094      * Outputs yout[] and its estimated error yerr[].
0095      * If SteppingAngle = h/R_curve < pi/3, uses default RK stepper else
0096      * use Helix fast method.
0097      *  @param[in] y Starting values array of integration variables.
0098      *  @param[in] dydx Derivatives array.
0099      *  @param[in] h The given step size.
0100      *  @param[out] yout Integration output.
0101      *  @param[out] yerr The estimated error.
0102      */
0103     void Stepper( const G4double y[],
0104                   const G4double dydx[],
0105                         G4double h,
0106                         G4double yout[],
0107                         G4double yerr[] ) override;
0108 
0109     /**
0110      * Same as Stepper() function above, but should perform a 'dump' step
0111      * without error calculation. Assuming a constant field, the solution is
0112      * a helix.
0113      *  @param[in] y Starting values array of integration variables.
0114      *  @param[in] Bfld The field vector.
0115      *  @param[in] h The given step size.
0116      *  @param[out] yout Integration output.
0117      */
0118     void DumbStepper( const G4double y[],
0119                             G4ThreeVector Bfld,
0120                             G4double h,
0121                             G4double yout[] ) override;
0122 
0123     /**
0124      * Estimates the maximum distance of curved solution and chord.
0125      */
0126     G4double DistChord() const override;
0127     
0128     /**
0129      * Sets the verbosity level.
0130      */
0131     inline void SetVerbose (G4int newvalue) { fVerbose = newvalue; }
0132   
0133     /**
0134      * Setter and getter for the stepping angle threshold.
0135      */
0136     inline void SetAngleThreshold( G4double val ) { fAngle_threshold = val; }
0137     inline G4double GetAngleThreshold() { return fAngle_threshold; }
0138 
0139     /**
0140      * Returns the order, 4, of integration.
0141      */
0142     inline G4int IntegratorOrder() const override { return 4; }
0143 
0144     /**
0145      * Returns the stepper type-ID, "kHelixMixedStepper".
0146      */
0147     inline G4StepperType StepperType() const override { return kHelixMixedStepper; }
0148 
0149     /**
0150      * Logger function for the number of calls.
0151      */
0152     void PrintCalls();
0153 
0154     /**
0155      * Sets the chosen stepper and equation of motion.
0156      */
0157     G4MagIntegratorStepper* SetupStepper(G4Mag_EqRhs* EqRhs, G4int StepperName);
0158 
0159   private:
0160 
0161     /** Mixed Integration RK4 for 'small' steps. */
0162     G4MagIntegratorStepper* fRK4Stepper = nullptr;
0163 
0164     /** Int ID of Runge-Kutta stepper. */ 
0165     G4int fStepperNumber = -1;
0166 
0167     /** Threshold angle (in radians ); above it, the Helical stepper is used. */
0168     G4double fAngle_threshold = -1.0;
0169 
0170     /** Verbosity level. */ 
0171     G4int fVerbose = 0;
0172 
0173     /** Used for statistic, i.e. how many calls to different steppers. */
0174     G4int fNumCallsRK4 = 0;
0175     G4int fNumCallsHelix = 0;
0176 };
0177 
0178 #endif