Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Field.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4Field.hh 96751 2016-05-04 09:39:38Z gcosmo $
28 //
29 //
30 // class G4Field
31 //
32 // Class description:
33 //
34 // Abstract class for any kind of Field.
35 // It allows any kind of field (vector, scalar, tensor and any set of them)
36 // to be defined by implementing the inquiry function interface.
37 //
38 // The key method is GetFieldValue( const double Point[4],
39 // ************* double *fieldArr )
40 // Given an input position/time vector 'Point',
41 // this method must return the value of the field in "fieldArr".
42 //
43 // A field must also specify whether it changes a track's energy:
44 // DoesFieldChangeEnergy()
45 // *********************
46 // A field must co-work with a corresponding Equation of Motion, to
47 // enable the integration of a particle's position, momentum and, optionally,
48 // spin. For this a field and its equation of motion must follow the
49 // same convention for the order of field components in the array "fieldArr"
50 // -------------------------------------------------------------------
51 // History:
52 // - Created: John Apostolakis, 10.03.1997
53 // - Modified:
54 // V. Grichine 8 Nov 2001: Extended "Point" arg to [4] array to add time
55 // J. Apostolakis 5 Nov 2003: Added virtual method DoesFieldChangeEnergy()
56 // J. Apostolakis 31 Aug 2004: Information on convention for components
57 // -------------------------------------------------------------------
58 
59 #ifndef G4FIELD_HH
60 #define G4FIELD_HH
61 
62 #include "G4Types.hh"
63 #include "globals.hh"
64 
65 class G4Field
66 {
67  public: // with description
68 
69  virtual void GetFieldValue( const double Point[4],
70  double *fieldArr ) const = 0;
71  // Given the position time vector 'Point',
72  // return the value of the field in the array fieldArr.
73  // Notes:
74  // 1) The 'Point' vector has the following structure:
75  // Point[0] is x ( position, in Geant4 units )
76  // Point[1] is y
77  // Point[2] is z
78  // Point[3] is t ( time, in Geant4 units )
79  // 2) The convention for the components of the field
80  // array 'fieldArr' are determined by the type of field.
81  // See for example the class G4ElectroMagneticField.
82 
83  G4Field( G4bool gravityOn= false);
84  G4Field( const G4Field & );
85  virtual ~G4Field();
86  G4Field& operator = (const G4Field &p);
87 
88  // A field signature function that can be used to insure
89  // that the Equation of motion object and the G4Field object
90  // have the same "field signature"?
91 
92  virtual G4bool DoesFieldChangeEnergy() const= 0 ;
93  // Each type/class of field should respond this accordingly
94  // For example:
95  // - an electric field should return "true"
96  // - a pure magnetic field should return "false"
97 
98  G4bool IsGravityActive() const { return fGravityActive;}
99  // Does this field include gravity?
100  inline void SetGravityActive( G4bool OnOffFlag );
101 
102  virtual G4Field* Clone() const;
103  // Implements cloning, needed by G4 MT
104 
105  private:
106 
107  G4bool fGravityActive;
108 };
109 
110 inline void G4Field::SetGravityActive( G4bool OnOffFlag )
111 {
112  fGravityActive= OnOffFlag;
113 }
114 #endif /* G4FIELD_HH */
virtual void GetFieldValue(const double Point[4], double *fieldArr) const =0
const char * p
Definition: xmltok.h:285
virtual G4Field * Clone() const
Definition: G4Field.cc:54
void SetGravityActive(G4bool OnOffFlag)
Definition: G4Field.hh:110
virtual G4bool DoesFieldChangeEnergy() const =0
bool G4bool
Definition: G4Types.hh:79
virtual ~G4Field()
Definition: G4Field.cc:38
G4bool IsGravityActive() const
Definition: G4Field.hh:98
G4Field & operator=(const G4Field &p)
Definition: G4Field.cc:42
G4Field(G4bool gravityOn=false)
Definition: G4Field.cc:33