Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 09:11:07

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 // G4Field
0027 //
0028 // Class description:
0029 //
0030 // Abstract class for any kind of Field.
0031 // It allows any kind of field (vector, scalar, tensor and any set of them)
0032 // to be defined by implementing the inquiry function interface.
0033 //
0034 // The key method is  GetFieldValue( const G4double Point[4],
0035 //                    *************        G4double* fieldArr ) 
0036 // Given an input position/time vector 'Point', 
0037 // this method must return the value of the field in "fieldArr".
0038 //
0039 // A field must also specify whether it changes a track's energy:
0040 //                    DoesFieldChangeEnergy() 
0041 //                    *********************
0042 // A field must co-work with a corresponding Equation of Motion, to
0043 // enable the integration of a particle's position, momentum and, optionally, 
0044 // spin.  For this a field and its equation of motion must follow the
0045 // same convention for the order of field components in the array "fieldArr"
0046 
0047 // Author: John Apostolakis (CERN), 10.03.1997
0048 // -------------------------------------------------------------------
0049 #ifndef G4FIELD_HH
0050 #define G4FIELD_HH
0051 
0052 #include "G4Types.hh"
0053 #include "G4FieldParameters.hh"
0054 #include "globals.hh"
0055 
0056 /**
0057  * @brief G4Field is the abstract class for any kind of field.
0058  * It allows any kind of field (vector, scalar, tensor and any set of them)
0059  * to be defined by implementing the inquiry function interface.
0060  * A field must co-work with a corresponding Equation of Motion, to
0061  * enable the integration of a particle's position, momentum and, optionally, 
0062  * spin. For this a field and its equation of motion must follow the same
0063  * convention for the order of field components.
0064  */
0065 
0066 class G4Field
0067 {
0068   public:
0069 
0070     /**
0071      * Constructor for G4Field.
0072      *  @param[in] gravityOn Flag to indicate if gravity is enabled or not.
0073      */
0074     G4Field(G4bool gravityOn = false);
0075 
0076     /**
0077      * Default virtual Destructor.
0078      */
0079     virtual ~G4Field() = default;
0080 
0081     /**
0082      * Copy constructor and assignment operator.
0083      */
0084     G4Field( const G4Field& p) = default;
0085     G4Field& operator = (const G4Field& p); 
0086 
0087     /**
0088      * Given the position time vector 'Point', returns the value of the
0089      * field in the array 'fieldArr'. Notes: 
0090      * 1) The 'Point' vector has the following structure:
0091      *      Point[0]  is  x  ( position, in Geant4 units )
0092      *      Point[1]  is  y
0093      *      Point[2]  is  z
0094      *      Point[3]  is  t  ( time, in Geant4 units )
0095      * 2) The convention for the components of the field array 'fieldArr'
0096      *    are determined by the type of field.
0097      *  @param[in] Point The position time vector.
0098      *  @param[out] fieldArr The field array in output.
0099      */
0100     virtual void GetFieldValue( const G4double Point[4],
0101                                       G4double* fieldArr ) const = 0;
0102 
0103     /**
0104      * Each type/class of field should respond the field does change energy.
0105      * For example:
0106      *  - an electric field     should return "true"
0107      *  - a pure magnetic field should return "false"
0108      */
0109     virtual G4bool DoesFieldChangeEnergy() const = 0;
0110 
0111     /**
0112      * Returns the field type-ID, "kUserFieldType".
0113      * This should be overriden in derived classes.
0114      */
0115     virtual G4FieldType GetFieldType() const { return kUserFieldType; }
0116 
0117     /**
0118      * Replies if the field includes gravity.
0119      *  @returns true if the field does include gravity.
0120      */
0121     inline G4bool IsGravityActive() const { return fGravityActive; }
0122         //  Does this field include gravity?
0123 
0124     /**
0125      * Sets the gravity flag.
0126      */
0127     inline void SetGravityActive(G4bool OnOffFlag) { fGravityActive = OnOffFlag; }
0128     
0129     /**
0130      * Interface method to implement cloning, needed by multi-threading.
0131      * Here issuing a fatal exception, as expecting this to be implemented
0132      * concretely in derived classes.
0133      */
0134     virtual G4Field* Clone() const;
0135 
0136   public:
0137 
0138     static constexpr G4int MAX_NUMBER_OF_COMPONENTS = 24;
0139 
0140   private:
0141 
0142     G4bool fGravityActive = false;
0143 };
0144  
0145 #endif