Geant4  9.6.p02
 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 69786 2013-05-15 09:38:51Z 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 
64 class G4Field
65 {
66  public: // with description
67 
68  virtual void GetFieldValue( const double Point[4],
69  double *fieldArr ) const = 0;
70  // Given the position time vector 'Point',
71  // return the value of the field in the array fieldArr.
72  // Notes:
73  // 1) The 'Point' vector has the following structure:
74  // Point[0] is x ( position, in Geant4 units )
75  // Point[1] is y
76  // Point[2] is z
77  // Point[3] is t ( time, in Geant4 units )
78  // 2) The convention for the components of the field
79  // array 'fieldArr' are determined by the type of field.
80  // See for example the class G4ElectroMagneticField.
81 
82  G4Field( G4bool gravityOn= false);
83  G4Field( const G4Field & );
84  virtual ~G4Field();
85  inline G4Field& operator = (const G4Field &p);
86 
87  // A field signature function that can be used to insure
88  // that the Equation of motion object and the G4Field object
89  // have the same "field signature"?
90 
91  virtual G4bool DoesFieldChangeEnergy() const= 0 ;
92  // Each type/class of field should respond this accordingly
93  // For example:
94  // - an electric field should return "true"
95  // - a pure magnetic field should return "false"
96 
97  G4bool IsGravityActive() const { return fGravityActive;}
98  // Does this field include gravity?
99  inline void SetGravityActive( G4bool OnOffFlag );
100  private:
101  G4bool fGravityActive;
102 };
103 
104 inline void G4Field::SetGravityActive( G4bool OnOffFlag )
105 {
106  fGravityActive= OnOffFlag;
107 }
108 #endif /* G4FIELD_HH */