Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-31 09:11:49

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 // G4NystromRK4
0027 //
0028 // Class description:
0029 //
0030 // Integrates the equations of the motion of a particle in a magnetic field
0031 // using 4th Runge-Kutta-Nystrom method with errors estimation 
0032 // (ATL-SOFT-PUB-2009-01)
0033 // Current form can be used only for 'pure' magnetic field.
0034 // Notes: 1) field must be time-independent.
0035 //        2) time is not integrated
0036 
0037 // Author: Igor Gavrilenko (CERN), 15.05.2009 (as G4AtlasRK4)
0038 // Adaptations: John Apostolakis (CERN), 05.11.2009
0039 // -------------------------------------------------------------------
0040 #ifndef G4NYSTROMRK4_HH
0041 #define G4NYSTROMRK4_HH
0042 
0043 #include "G4MagIntegratorStepper.hh"
0044 #include "G4Mag_EqRhs.hh"
0045 #include "G4CachedMagneticField.hh"
0046 #include "G4ThreeVector.hh"
0047 
0048 #include <memory>
0049 
0050 /**
0051  * @brief G4NystromRK4 integrates the equations of the motion of a particle
0052  * in a magnetic field using 4th Runge-Kutta-Nystrom method with errors
0053  * estimation. The current form can be used only for 'pure' magnetic field.
0054  */
0055 
0056 class G4NystromRK4 : public G4MagIntegratorStepper
0057 {
0058   public: 
0059 
0060     /**
0061      * Constructor for G4NystromRK4. Can be used only for Magnetic Fields
0062      * and for 6 variables (x,p).
0063      *  @param[in] EquationMotion Pointer to the provided equation of motion.
0064      *  @param[in] distanceConstField Distance value for constant field.
0065      */
0066     G4NystromRK4(G4Mag_EqRhs* EquationMotion, 
0067                  G4double distanceConstField = 0.0); 
0068 
0069     /**
0070      * Default Destructor.
0071      */
0072    ~G4NystromRK4() override = default;
0073    
0074     /**
0075      * The stepper for the Runge Kutta integration.
0076      * The stepsize is fixed, with the step size given by 'hstep'.
0077      * Integrates ODE starting values y[0 to 6].
0078      * Outputs yOut[] and its estimated error yError[].
0079      * Provides error via analytical method.
0080      *  @param[in] y Starting values array of integration variables.
0081      *  @param[in] dydx Derivatives array.
0082      *  @param[in] hstep The given step size.
0083      *  @param[out] yOut Integration output.
0084      *  @param[out] yError The estimated error.
0085      */
0086     void Stepper(const G4double y[],
0087                  const G4double dydx[],
0088                        G4double hstep,
0089                        G4double yOut[],
0090                        G4double yError[]) override;
0091 
0092     /**
0093      * Setter and getter for the distance value for constant field.
0094      */
0095     void SetDistanceForConstantField(G4double length); 
0096     G4double GetDistanceForConstantField() const; 
0097    
0098     /**
0099      * Returns the order, 4, of integration.
0100      */
0101     inline G4int IntegratorOrder() const override;
0102 
0103     /**
0104      * Returns the distance from chord line.
0105      */
0106     G4double DistChord() const override; 
0107 
0108     /**
0109      * Returns the stepper type-ID, "kNystromRK4".
0110      */
0111     inline G4StepperType StepperType() const override;
0112   
0113   private:
0114 
0115     /**
0116      * Private accessors for field data.
0117      */
0118     inline void GetFieldValue(const G4double point[4], G4double field[3]);
0119     inline G4double GetFCof();
0120     G4CachedMagneticField* GetField();
0121     const G4CachedMagneticField* GetField() const;
0122 
0123   private:
0124 
0125     G4double fMomentum = 0.0;
0126     G4double fMomentum2 = 0.0;
0127     G4double fInverseMomentum = 0.0;
0128     G4double fCoefficient = 0.0;
0129     G4ThreeVector fInitialPoint;
0130     G4ThreeVector fMidPoint;
0131     G4ThreeVector fEndPoint;
0132 
0133     std::unique_ptr<G4CachedMagneticField> fCachedField;
0134 };
0135 
0136 #include "G4NystromRK4.icc"
0137 
0138 #endif