Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UniformMagField Class Reference

#include <G4UniformMagField.hh>

+ Inheritance diagram for G4UniformMagField:

Public Member Functions

 G4UniformMagField (const G4ThreeVector &FieldVector)
 
 G4UniformMagField (G4double vField, G4double vTheta, G4double vPhi)
 
 ~G4UniformMagField () override
 
 G4UniformMagField (const G4UniformMagField &p)
 
G4UniformMagFieldoperator= (const G4UniformMagField &p)
 
void GetFieldValue (const G4double yTrack[4], G4double *MagField) const override
 
void SetFieldValue (const G4ThreeVector &newFieldValue)
 
G4ThreeVector GetConstantFieldValue () const
 
G4FieldClone () const override
 
- Public Member Functions inherited from G4MagneticField
 G4MagneticField ()
 
 ~G4MagneticField () override
 
 G4MagneticField (const G4MagneticField &r)
 
G4MagneticFieldoperator= (const G4MagneticField &p)
 
G4bool DoesFieldChangeEnergy () const override
 
- Public Member Functions inherited from G4Field
 G4Field (G4bool gravityOn=false)
 
 G4Field (const G4Field &)
 
virtual ~G4Field ()
 
G4Fieldoperator= (const G4Field &p)
 
G4bool IsGravityActive () const
 
void SetGravityActive (G4bool OnOffFlag)
 

Additional Inherited Members

- Static Public Attributes inherited from G4Field
static constexpr G4int MAX_NUMBER_OF_COMPONENTS = 24
 

Detailed Description

Definition at line 41 of file G4UniformMagField.hh.

Constructor & Destructor Documentation

◆ G4UniformMagField() [1/3]

G4UniformMagField::G4UniformMagField ( const G4ThreeVector & FieldVector)

Definition at line 34 of file G4UniformMagField.cc.

35{
36 fFieldComponents[0] = FieldVector.x();
37 fFieldComponents[1] = FieldVector.y();
38 fFieldComponents[2] = FieldVector.z();
39}
double z() const
double x() const
double y() const

Referenced by Clone().

◆ G4UniformMagField() [2/3]

G4UniformMagField::G4UniformMagField ( G4double vField,
G4double vTheta,
G4double vPhi )

Definition at line 78 of file G4UniformMagField.cc.

81{
82 if ( (vField<0) || (vTheta<0) || (vTheta>pi) || (vPhi<0) || (vPhi>twopi) )
83 {
84 std::ostringstream msg;
85 msg << "ERROR in G4UniformMagField::G4UniformMagField() : "
86 << "Invalid parameter(s). " << std::endl;
87 msg << " Expected " << std::endl;
88
89 msg << " - Magnitude vField: Value = " << vField
90 << " Expected vField > 0 " ;
91 if ( vField<0) { msg << " <------ Erroneous "; }
92 msg << std::endl;
93
94 msg << " - Theta angle: Value = " << vTheta
95 << " Expected between 0 <= theta <= pi = " << pi << " ";
96 if ( (vTheta<0) || (vTheta>pi) ) { msg << " <------ Erroneous "; }
97
98 msg << std::endl;
99 msg << " - Phi angle: Value = " << vPhi
100 << " Expected between 0 <= phi <= 2*pi = " << twopi << std::endl;
101 if ( (vPhi<0) || (vPhi>twopi) ) { msg << " <------ Erroneous "; }
102
103 G4Exception("G4UniformMagField::G4UniformMagField()",
104 "GeomField0002", FatalException, msg );
105 }
106 fFieldComponents[0] = vField*std::sin(vTheta)*std::cos(vPhi) ;
107 fFieldComponents[1] = vField*std::sin(vTheta)*std::sin(vPhi) ;
108 fFieldComponents[2] = vField*std::cos(vTheta) ;
109}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)

◆ ~G4UniformMagField()

G4UniformMagField::~G4UniformMagField ( )
overridedefault

◆ G4UniformMagField() [3/3]

G4UniformMagField::G4UniformMagField ( const G4UniformMagField & p)

Definition at line 43 of file G4UniformMagField.cc.

45{
46 for (auto i=0; i<3; ++i)
47 {
48 fFieldComponents[i] = p.fFieldComponents[i];
49 }
50}

Member Function Documentation

◆ Clone()

G4Field * G4UniformMagField::Clone ( ) const
overridevirtual

Reimplemented from G4Field.

Definition at line 63 of file G4UniformMagField.cc.

64{
65 return new G4UniformMagField( G4ThreeVector(fFieldComponents[0],
66 fFieldComponents[1],
67 fFieldComponents[2]) );
68}
CLHEP::Hep3Vector G4ThreeVector
G4UniformMagField(const G4ThreeVector &FieldVector)

◆ GetConstantFieldValue()

G4ThreeVector G4UniformMagField::GetConstantFieldValue ( ) const

Definition at line 121 of file G4UniformMagField.cc.

122{
123 G4ThreeVector B(fFieldComponents[0],
124 fFieldComponents[1],
125 fFieldComponents[2]);
126 return B;
127}
G4double B(G4double temperature)

Referenced by G4GlobalMagFieldMessenger::GetFieldValue().

◆ GetFieldValue()

void G4UniformMagField::GetFieldValue ( const G4double yTrack[4],
G4double * MagField ) const
overridevirtual

Implements G4MagneticField.

Definition at line 113 of file G4UniformMagField.cc.

115{
116 B[0]= fFieldComponents[0];
117 B[1]= fFieldComponents[1];
118 B[2]= fFieldComponents[2];
119}

◆ operator=()

G4UniformMagField & G4UniformMagField::operator= ( const G4UniformMagField & p)

Definition at line 52 of file G4UniformMagField.cc.

53{
54 if (&p == this) { return *this;}
56 for (auto i=0; i<3; ++i)
57 {
58 fFieldComponents[i] = p.fFieldComponents[i];
59 }
60 return *this;
61}
G4MagneticField & operator=(const G4MagneticField &p)

◆ SetFieldValue()

void G4UniformMagField::SetFieldValue ( const G4ThreeVector & newFieldValue)

Definition at line 71 of file G4UniformMagField.cc.

72{
73 fFieldComponents[0] = newFieldVector.x();
74 fFieldComponents[1] = newFieldVector.y();
75 fFieldComponents[2] = newFieldVector.z();
76}

The documentation for this class was generated from the following files: