Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4CachedMagneticField Class Reference

#include <G4CachedMagneticField.hh>

Inheritance diagram for G4CachedMagneticField:
Collaboration 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 ()
 
virtual G4FieldClone () const
 
- Public Member Functions inherited from G4MagneticField
 G4MagneticField ()
 
virtual ~G4MagneticField ()
 
 G4MagneticField (const G4MagneticField &r)
 
G4MagneticFieldoperator= (const G4MagneticField &p)
 
G4bool DoesFieldChangeEnergy () const
 
- Public Member Functions inherited from G4ElectroMagneticField
 G4ElectroMagneticField ()
 
virtual ~G4ElectroMagneticField ()
 
 G4ElectroMagneticField (const G4ElectroMagneticField &r)
 
G4ElectroMagneticFieldoperator= (const G4ElectroMagneticField &p)
 
- 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)
 

Protected Attributes

G4int fCountCalls
 
G4int fCountEvaluations
 

Detailed Description

Definition at line 47 of file G4CachedMagneticField.hh.

Constructor & Destructor Documentation

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

Here is the call graph for this function:

Here is the caller graph for this function:

G4CachedMagneticField::~G4CachedMagneticField ( )
virtual

Definition at line 58 of file G4CachedMagneticField.cc.

59 {
60 }
G4CachedMagneticField::G4CachedMagneticField ( const G4CachedMagneticField r)

Definition at line 70 of file G4CachedMagneticField.cc.

71  : G4MagneticField(rightCMF)
72 {
73  fpMagneticField= rightCMF.fpMagneticField; // NOTE: sharing pointer here!
74  fDistanceConst = rightCMF.fDistanceConst;
75  fLastLocation = rightCMF.fLastLocation;
76  fLastValue = rightCMF.fLastValue;
77  this->ClearCounts();
78 }

Here is the call graph for this function:

Member Function Documentation

void G4CachedMagneticField::ClearCounts ( )
inline

Definition at line 67 of file G4CachedMagneticField.hh.

Here is the caller graph for this function:

G4Field * G4CachedMagneticField::Clone ( ) const
virtual

Reimplemented from G4Field.

Definition at line 47 of file G4CachedMagneticField.cc.

48 {
49  // Cannot use copy constructor: I need to clone the associated magnetic field
50  G4MagneticField* aF = static_cast<G4MagneticField*>(fpMagneticField->Clone());
51  G4CachedMagneticField* cloned = new G4CachedMagneticField(aF, fDistanceConst);
52 
53  cloned->fLastLocation = fLastLocation;
54  cloned->fLastValue = fLastValue;
55  return cloned;
56 }
virtual G4Field * Clone() const
Definition: G4Field.cc:54
G4CachedMagneticField(G4MagneticField *, G4double distanceConst)

Here is the call graph for this function:

G4double G4CachedMagneticField::GetConstDistance ( ) const
inline

Definition at line 62 of file G4CachedMagneticField.hh.

62 { return fDistanceConst; }
G4int G4CachedMagneticField::GetCountCalls ( ) const
inline

Definition at line 65 of file G4CachedMagneticField.hh.

65 { return fCountCalls; }
G4int G4CachedMagneticField::GetCountEvaluations ( ) const
inline

Definition at line 66 of file G4CachedMagneticField.hh.

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

Implements G4MagneticField.

Definition at line 93 of file G4CachedMagneticField.cc.

95 {
96  G4ThreeVector newLocation( Point[0], Point[1], Point[2] );
97 
98  // G4cout << "Cache-B-field called at " << newLocation << G4endl;
99 
100  G4double distSq= (newLocation-fLastLocation).mag2();
101  fCountCalls++;
102  if( distSq < fDistanceConst*fDistanceConst ) {
103  Bfield[0] = fLastValue.x();
104  Bfield[1] = fLastValue.y();
105  Bfield[2] = fLastValue.z();
106  }else{
107  // G4CachedMagneticField* thisNonC= const_cast<G4CachedMagneticField*>(this);
108  fpMagneticField->GetFieldValue( Point, Bfield );
109  // G4cout << " Evaluating. " << G4endl;
111  // thisNonC->
112  fLastLocation= G4ThreeVector( Point[0], Point[1], Point[2] );
113  // thisNonC->
114  fLastValue= G4ThreeVector( Bfield[0], Bfield[1], Bfield[2] );
115  }
116 }
CLHEP::Hep3Vector G4ThreeVector
double x() const
virtual void GetFieldValue(const G4double Point[4], G4double *Bfield) const =0
double z() const
double y() const
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

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

Definition at line 80 of file G4CachedMagneticField.cc.

81 {
82  if (&p == this) return *this;
84  fpMagneticField= p.fpMagneticField; // NOTE: sharing pointer here!
85  fDistanceConst = p.fDistanceConst;
86  fLastLocation = p.fLastLocation;
87  fLastValue = p.fLastValue;
88  this->ClearCounts();
89  return *this;
90 }
G4MagneticField & operator=(const G4MagneticField &p)

Here is the call graph for this function:

void G4CachedMagneticField::ReportStatistics ( )

Definition at line 63 of file G4CachedMagneticField.cc.

64 {
65  G4cout << " Cached field: " << G4endl
66  << " Number of calls: " << fCountCalls << G4endl
67  << " Number of evaluations : " << fCountEvaluations << G4endl;
68 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void G4CachedMagneticField::SetConstDistance ( G4double  dist)
inline

Definition at line 63 of file G4CachedMagneticField.hh.

63 { fDistanceConst= dist;}

Member Data Documentation

G4int G4CachedMagneticField::fCountCalls
mutableprotected

Definition at line 81 of file G4CachedMagneticField.hh.

G4int G4CachedMagneticField::fCountEvaluations
mutableprotected

Definition at line 81 of file G4CachedMagneticField.hh.


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