Geant4-11
Public Member Functions | Static Public Attributes | Protected Attributes | Private Attributes
G4CachedMagneticField Class Reference

#include <G4CachedMagneticField.hh>

Inheritance diagram for G4CachedMagneticField:
G4MagneticField G4Field

Public Member Functions

void ClearCounts ()
 
virtual G4FieldClone () const
 
G4bool DoesFieldChangeEnergy () const
 
 G4CachedMagneticField (const G4CachedMagneticField &r)
 
 G4CachedMagneticField (G4MagneticField *, G4double distanceConst)
 
G4double GetConstDistance () const
 
G4int GetCountCalls () const
 
G4int GetCountEvaluations () const
 
virtual void GetFieldValue (const G4double Point[4], G4double *Bfield) const
 
G4bool IsGravityActive () const
 
G4CachedMagneticFieldoperator= (const G4CachedMagneticField &p)
 
void ReportStatistics ()
 
void SetConstDistance (G4double dist)
 
void SetGravityActive (G4bool OnOffFlag)
 
virtual ~G4CachedMagneticField ()
 

Static Public Attributes

static constexpr G4int MAX_NUMBER_OF_COMPONENTS = 24
 

Protected Attributes

G4int fCountCalls = 0
 
G4int fCountEvaluations = 0
 

Private Attributes

G4double fDistanceConst
 
G4bool fGravityActive = false
 
G4ThreeVector fLastLocation
 
G4ThreeVector fLastValue
 
G4MagneticFieldfpMagneticField = nullptr
 

Detailed Description

Definition at line 41 of file G4CachedMagneticField.hh.

Constructor & Destructor Documentation

◆ G4CachedMagneticField() [1/2]

G4CachedMagneticField::G4CachedMagneticField ( G4MagneticField pMagField,
G4double  distanceConst 
)

Definition at line 33 of file G4CachedMagneticField.cc.

References ClearCounts().

Referenced by Clone().

◆ ~G4CachedMagneticField()

G4CachedMagneticField::~G4CachedMagneticField ( )
virtual

Definition at line 53 of file G4CachedMagneticField.cc.

54{
55}

◆ G4CachedMagneticField() [2/2]

G4CachedMagneticField::G4CachedMagneticField ( const G4CachedMagneticField r)

Definition at line 65 of file G4CachedMagneticField.cc.

67 : G4MagneticField(rightCMF)
68{
69 fpMagneticField= rightCMF.fpMagneticField; // NOTE: sharing pointer here!
70 fDistanceConst = rightCMF.fDistanceConst;
71 fLastLocation = rightCMF.fLastLocation;
72 fLastValue = rightCMF.fLastValue;
73 ClearCounts();
74}

References ClearCounts(), fDistanceConst, fLastLocation, fLastValue, and fpMagneticField.

Member Function Documentation

◆ ClearCounts()

void G4CachedMagneticField::ClearCounts ( )
inline

◆ Clone()

G4Field * G4CachedMagneticField::Clone ( ) const
virtual

Reimplemented from G4Field.

Definition at line 41 of file G4CachedMagneticField.cc.

42{
43 // Cannot use copy constructor: need to clone the associated magnetic field
44
47
49 cloned->fLastValue = fLastValue;
50 return cloned;
51}
G4CachedMagneticField(G4MagneticField *, G4double distanceConst)
virtual G4Field * Clone() const
Definition: G4Field.cc:54

References G4Field::Clone(), fDistanceConst, fLastLocation, fLastValue, fpMagneticField, and G4CachedMagneticField().

◆ DoesFieldChangeEnergy()

G4bool G4MagneticField::DoesFieldChangeEnergy ( ) const
inlinevirtualinherited

Implements G4Field.

Definition at line 52 of file G4MagneticField.hh.

52{ return false; }

Referenced by export_G4MagneticField().

◆ GetConstDistance()

G4double G4CachedMagneticField::GetConstDistance ( ) const
inline

Definition at line 56 of file G4CachedMagneticField.hh.

56{ return fDistanceConst; }

References fDistanceConst.

Referenced by G4NystromRK4::GetDistanceForConstantField().

◆ GetCountCalls()

G4int G4CachedMagneticField::GetCountCalls ( ) const
inline

Definition at line 59 of file G4CachedMagneticField.hh.

59{ return fCountCalls; }

References fCountCalls.

◆ GetCountEvaluations()

G4int G4CachedMagneticField::GetCountEvaluations ( ) const
inline

Definition at line 60 of file G4CachedMagneticField.hh.

60{ return fCountEvaluations; }

References fCountEvaluations.

◆ GetFieldValue()

void G4CachedMagneticField::GetFieldValue ( const G4double  Point[4],
G4double Bfield 
) const
virtual

Implements G4MagneticField.

Definition at line 90 of file G4CachedMagneticField.cc.

92{
93 G4ThreeVector newLocation( Point[0], Point[1], Point[2] );
94
95 G4double distSq= (newLocation-fLastLocation).mag2();
97 if( distSq < fDistanceConst*fDistanceConst )
98 {
99 Bfield[0] = fLastValue.x();
100 Bfield[1] = fLastValue.y();
101 Bfield[2] = fLastValue.z();
102 }
103 else
104 {
105 fpMagneticField->GetFieldValue( Point, Bfield );
107 fLastLocation = G4ThreeVector( Point[0], Point[1], Point[2] );
108 fLastValue = G4ThreeVector( Bfield[0], Bfield[1], Bfield[2] );
109 }
110}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
double z() const
double x() const
double y() const
virtual void GetFieldValue(const G4double Point[4], G4double *Bfield) const =0

References fCountCalls, fCountEvaluations, fDistanceConst, fLastLocation, fLastValue, fpMagneticField, G4MagneticField::GetFieldValue(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ IsGravityActive()

G4bool G4Field::IsGravityActive ( ) const
inlineinherited

Definition at line 101 of file G4Field.hh.

102{
103 return fGravityActive;
104}
G4bool fGravityActive
Definition: G4Field.hh:96

References G4Field::fGravityActive.

Referenced by G4CoupledTransportation::AlongStepGetPhysicalInteractionLength(), and G4RepleteEofM::G4RepleteEofM().

◆ operator=()

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

Definition at line 77 of file G4CachedMagneticField.cc.

78{
79 if (&p == this) { return *this; }
81 fpMagneticField= p.fpMagneticField; // NOTE: sharing pointer here!
85 ClearCounts();
86 return *this;
87}
G4MagneticField & operator=(const G4MagneticField &p)

References ClearCounts(), fDistanceConst, fLastLocation, fLastValue, fpMagneticField, and G4MagneticField::operator=().

◆ ReportStatistics()

void G4CachedMagneticField::ReportStatistics ( )

Definition at line 58 of file G4CachedMagneticField.cc.

59{
60 G4cout << " Cached field: " << G4endl
61 << " Number of calls: " << fCountCalls << G4endl
62 << " Number of evaluations : " << fCountEvaluations << G4endl;
63}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout

References fCountCalls, fCountEvaluations, G4cout, and G4endl.

◆ SetConstDistance()

void G4CachedMagneticField::SetConstDistance ( G4double  dist)
inline

Definition at line 57 of file G4CachedMagneticField.hh.

57{ fDistanceConst= dist;}

References fDistanceConst.

Referenced by G4NystromRK4::SetDistanceForConstantField().

◆ SetGravityActive()

void G4Field::SetGravityActive ( G4bool  OnOffFlag)
inlineinherited

Definition at line 106 of file G4Field.hh.

107{
108 fGravityActive = OnOffFlag;
109}

References G4Field::fGravityActive.

Field Documentation

◆ fCountCalls

G4int G4CachedMagneticField::fCountCalls = 0
mutableprotected

◆ fCountEvaluations

G4int G4CachedMagneticField::fCountEvaluations = 0
protected

◆ fDistanceConst

G4double G4CachedMagneticField::fDistanceConst
private

◆ fGravityActive

G4bool G4Field::fGravityActive = false
privateinherited

◆ fLastLocation

G4ThreeVector G4CachedMagneticField::fLastLocation
mutableprivate

Definition at line 78 of file G4CachedMagneticField.hh.

Referenced by Clone(), G4CachedMagneticField(), GetFieldValue(), and operator=().

◆ fLastValue

G4ThreeVector G4CachedMagneticField::fLastValue
mutableprivate

Definition at line 79 of file G4CachedMagneticField.hh.

Referenced by Clone(), G4CachedMagneticField(), GetFieldValue(), and operator=().

◆ fpMagneticField

G4MagneticField* G4CachedMagneticField::fpMagneticField = nullptr
private

Definition at line 72 of file G4CachedMagneticField.hh.

Referenced by Clone(), G4CachedMagneticField(), GetFieldValue(), and operator=().

◆ MAX_NUMBER_OF_COMPONENTS

constexpr G4int G4Field::MAX_NUMBER_OF_COMPONENTS = 24
staticconstexprinherited

Definition at line 92 of file G4Field.hh.

Referenced by G4BFieldIntegrationDriver::CurvatureRadius().


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