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

#include <G4CachedMagneticField.hh>

+ Inheritance diagram for G4CachedMagneticField:

Public Member Functions

 G4CachedMagneticField (G4MagneticField *, G4double distanceConst)
 
virtual ~G4CachedMagneticField ()
 
 G4CachedMagneticField (const G4CachedMagneticField &r)
 
G4CachedMagneticFieldoperator= (const G4CachedMagneticField &p)
 
virtual void GetFieldValue (const G4double Point[4], G4double *Bfield) const
 
G4double GetConstDistance () const
 
void SetConstDistance (G4double dist)
 
G4int GetCountCalls () const
 
G4int GetCountEvaluations () const
 
void ClearCounts ()
 
void ReportStatistics ()
 
- 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 G4ElectroMagneticField
 G4ElectroMagneticField ()
 
virtual ~G4ElectroMagneticField ()
 
 G4ElectroMagneticField (const G4ElectroMagneticField &r)
 
G4ElectroMagneticFieldoperator= (const G4ElectroMagneticField &p)
 
virtual void GetFieldValue (const G4double Point[4], G4double *Bfield) const =0
 
virtual G4bool DoesFieldChangeEnergy () const =0
 
- Public Member Functions inherited from G4Field
virtual void GetFieldValue (const double Point[4], double *fieldArr) const =0
 
 G4Field (G4bool gravityOn=false)
 
 G4Field (const G4Field &)
 
virtual ~G4Field ()
 
G4Fieldoperator= (const G4Field &p)
 
virtual G4bool DoesFieldChangeEnergy () const =0
 
G4bool IsGravityActive () const
 
void SetGravityActive (G4bool OnOffFlag)
 

Protected Attributes

G4int fCountCalls
 
G4int fCountEvaluations
 

Detailed Description

Definition at line 48 of file G4CachedMagneticField.hh.

Constructor & Destructor Documentation

◆ G4CachedMagneticField() [1/2]

G4CachedMagneticField::G4CachedMagneticField ( G4MagneticField pMagField,
G4double  distanceConst 
)

Definition at line 33 of file G4CachedMagneticField.cc.

35 : G4MagneticField(),
36 fLastLocation(DBL_MAX,DBL_MAX,DBL_MAX),
37 fLastValue(DBL_MAX,DBL_MAX,DBL_MAX),
39{
40 fpMagneticField= pMagField;
41 fDistanceConst= distance;
42
43 // G4cout << " Cached-B-Field constructor> Distance = " << distance << G4endl;
44 this->ClearCounts();
45}
#define DBL_MAX
Definition: templates.hh:83

◆ ~G4CachedMagneticField()

G4CachedMagneticField::~G4CachedMagneticField ( )
virtual

Definition at line 47 of file G4CachedMagneticField.cc.

48{
49}

◆ G4CachedMagneticField() [2/2]

G4CachedMagneticField::G4CachedMagneticField ( const G4CachedMagneticField r)

Definition at line 59 of file G4CachedMagneticField.cc.

61{
62 fpMagneticField= rightCMF.fpMagneticField;
63 fDistanceConst = rightCMF.fDistanceConst;
64 fLastLocation = rightCMF.fLastLocation;
65 fLastValue = rightCMF.fLastValue;
66 this->ClearCounts();
67}

Member Function Documentation

◆ ClearCounts()

void G4CachedMagneticField::ClearCounts ( )
inline

Definition at line 68 of file G4CachedMagneticField.hh.

Referenced by G4CachedMagneticField().

◆ GetConstDistance()

G4double G4CachedMagneticField::GetConstDistance ( ) const
inline

Definition at line 63 of file G4CachedMagneticField.hh.

63{ return fDistanceConst; }

◆ GetCountCalls()

G4int G4CachedMagneticField::GetCountCalls ( ) const
inline

Definition at line 66 of file G4CachedMagneticField.hh.

66{ return fCountCalls; }

◆ GetCountEvaluations()

G4int G4CachedMagneticField::GetCountEvaluations ( ) const
inline

Definition at line 67 of file G4CachedMagneticField.hh.

67{ return fCountEvaluations; }

◆ GetFieldValue()

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

Implements G4MagneticField.

Definition at line 75 of file G4CachedMagneticField.cc.

77{
78 G4ThreeVector newLocation( Point[0], Point[1], Point[2] );
79
80 // G4cout << "Cache-B-field called at " << newLocation << G4endl;
81
82 G4double distSq= (newLocation-fLastLocation).mag2();
84 if( distSq < fDistanceConst*fDistanceConst ) {
85 Bfield[0] = fLastValue.x();
86 Bfield[1] = fLastValue.y();
87 Bfield[2] = fLastValue.z();
88 }else{
89 // G4CachedMagneticField* thisNonC= const_cast<G4CachedMagneticField*>(this);
90 fpMagneticField->GetFieldValue( Point, Bfield );
91 // G4cout << " Evaluating. " << G4endl;
93 // thisNonC->
94 fLastLocation= G4ThreeVector( Point[0], Point[1], Point[2] );
95 // thisNonC->
96 fLastValue= G4ThreeVector( Bfield[0], Bfield[1], Bfield[2] );
97 }
98}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:64
double z() const
double x() const
double y() const
virtual void GetFieldValue(const G4double Point[4], G4double *Bfield) const =0

◆ operator=()

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

Definition at line 69 of file G4CachedMagneticField.cc.

70{
71 if (&p == this) return *this; *this = p; return *this;
72}

◆ ReportStatistics()

void G4CachedMagneticField::ReportStatistics ( )

Definition at line 52 of file G4CachedMagneticField.cc.

53{
54 G4cout << " Cached field: " << G4endl
55 << " Number of calls: " << fCountCalls << G4endl
56 << " Number of evaluations : " << fCountEvaluations << G4endl;
57}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout

◆ SetConstDistance()

void G4CachedMagneticField::SetConstDistance ( G4double  dist)
inline

Definition at line 64 of file G4CachedMagneticField.hh.

64{ fDistanceConst= dist;}

Member Data Documentation

◆ fCountCalls

G4int G4CachedMagneticField::fCountCalls
mutableprotected

◆ fCountEvaluations

G4int G4CachedMagneticField::fCountEvaluations
protected

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