Geant4 10.7.0
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)
 
virtual ~G4UniformMagField () override
 
 G4UniformMagField (const G4UniformMagField &p)
 
G4UniformMagFieldoperator= (const G4UniformMagField &p)
 
virtual void GetFieldValue (const G4double yTrack[4], G4double *MagField) const override final
 
void SetFieldValue (const G4ThreeVector &newFieldValue)
 
G4ThreeVector GetConstantFieldValue () const
 
virtual G4FieldClone () const override
 
- Public Member Functions inherited from G4MagneticField
 G4MagneticField ()
 
virtual ~G4MagneticField ()
 
 G4MagneticField (const G4MagneticField &r)
 
G4MagneticFieldoperator= (const G4MagneticField &p)
 
G4bool DoesFieldChangeEnergy () const
 
virtual void GetFieldValue (const G4double Point[4], G4double *Bfield) const =0
 
- Public Member Functions inherited from G4Field
 G4Field (G4bool gravityOn=false)
 
 G4Field (const G4Field &)
 
virtual ~G4Field ()
 
G4Fieldoperator= (const G4Field &p)
 
virtual void GetFieldValue (const G4double Point[4], G4double *fieldArr) const =0
 
virtual G4bool DoesFieldChangeEnergy () const =0
 
G4bool IsGravityActive () const
 
void SetGravityActive (G4bool OnOffFlag)
 
virtual G4FieldClone () const
 

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

◆ G4UniformMagField() [2/3]

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

Definition at line 80 of file G4UniformMagField.cc.

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

◆ ~G4UniformMagField()

G4UniformMagField::~G4UniformMagField ( )
overridevirtual

Definition at line 41 of file G4UniformMagField.cc.

42{
43}

◆ G4UniformMagField() [3/3]

G4UniformMagField::G4UniformMagField ( const G4UniformMagField p)

Definition at line 45 of file G4UniformMagField.cc.

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

Member Function Documentation

◆ Clone()

G4Field * G4UniformMagField::Clone ( ) const
overridevirtual

Reimplemented from G4Field.

Definition at line 65 of file G4UniformMagField.cc.

66{
67 return new G4UniformMagField( G4ThreeVector(fFieldComponents[0],
68 fFieldComponents[1],
69 fFieldComponents[2]) );
70}
CLHEP::Hep3Vector G4ThreeVector

◆ GetConstantFieldValue()

G4ThreeVector G4UniformMagField::GetConstantFieldValue ( ) const

Definition at line 123 of file G4UniformMagField.cc.

124{
125 G4ThreeVector B(fFieldComponents[0],
126 fFieldComponents[1],
127 fFieldComponents[2]);
128 return B;
129}
double B(double temperature)

Referenced by G4GlobalMagFieldMessenger::GetFieldValue().

◆ GetFieldValue()

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

Implements G4MagneticField.

Definition at line 115 of file G4UniformMagField.cc.

117{
118 B[0]= fFieldComponents[0];
119 B[1]= fFieldComponents[1];
120 B[2]= fFieldComponents[2];
121}

◆ operator=()

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

Definition at line 54 of file G4UniformMagField.cc.

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

◆ SetFieldValue()

void G4UniformMagField::SetFieldValue ( const G4ThreeVector newFieldValue)

Definition at line 73 of file G4UniformMagField.cc.

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

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