Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:46

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 // Created: I.Gavrilenko, 15.05.2009 (as G4AtlasRK4)
0038 // Adaptations: J.Apostolakis, November 2009
0039 // -------------------------------------------------------------------
0040 
0041 #ifndef G4NYSTROMRK4_HH
0042 #define G4NYSTROMRK4_HH
0043 
0044 #include "G4MagIntegratorStepper.hh"
0045 #include "G4Mag_EqRhs.hh"
0046 #include "G4CachedMagneticField.hh"
0047 #include "G4ThreeVector.hh"
0048 
0049 #include <memory>
0050 
0051 class G4NystromRK4 : public G4MagIntegratorStepper
0052 {
0053   public: 
0054 
0055     G4NystromRK4(G4Mag_EqRhs* EquationMotion, 
0056                  G4double distanceConstField = 0.0); 
0057       // Can be used only for Magnetic Fields - and for 6 variables (x,p)
0058    ~G4NystromRK4() override = default;
0059    
0060     void Stepper(const G4double y[],
0061                  const G4double dydx[],
0062                        G4double hstep,
0063                        G4double yOut[],
0064                        G4double yError[]) override;
0065       // Single call for integration result and error
0066       // Provides error via analytical method
0067 
0068     void SetDistanceForConstantField(G4double length); 
0069     G4double GetDistanceForConstantField() const; 
0070    
0071     G4int IntegratorOrder() const override { return 4; }
0072     G4double DistChord() const override; 
0073   
0074   private:
0075 
0076     inline void GetFieldValue(const G4double point[4], G4double field[3]);
0077     inline G4double GetFCof();
0078 
0079     G4CachedMagneticField* GetField();
0080     const G4CachedMagneticField* GetField() const;
0081 
0082     G4double fMomentum = 0.0;
0083     G4double fMomentum2 = 0.0;
0084     G4double fInverseMomentum = 0.0;
0085     G4double fCoefficient = 0.0;
0086     G4ThreeVector fInitialPoint;
0087     G4ThreeVector fMidPoint;
0088     G4ThreeVector fEndPoint;
0089 
0090     std::unique_ptr<G4CachedMagneticField> fCachedField;
0091 };
0092 
0093 #include "G4NystromRK4.icc"
0094 
0095 #endif