G4CachedMagneticField Class Reference

#include <G4CachedMagneticField.hh>

Inheritance diagram for G4CachedMagneticField:

G4MagneticField G4ElectroMagneticField G4Field

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 ()

Protected Attributes

G4int fCountCalls
G4int fCountEvaluations

Detailed Description

Definition at line 48 of file G4CachedMagneticField.hh.


Constructor & Destructor Documentation

G4CachedMagneticField::G4CachedMagneticField ( G4MagneticField ,
G4double  distanceConst 
)

Definition at line 33 of file G4CachedMagneticField.cc.

References ClearCounts().

00035   : G4MagneticField(), 
00036     fLastLocation(DBL_MAX,DBL_MAX,DBL_MAX),
00037     fLastValue(DBL_MAX,DBL_MAX,DBL_MAX),
00038     fCountCalls(0),  fCountEvaluations(0)
00039 {
00040   fpMagneticField=     pMagField;
00041   fDistanceConst= distance;
00042 
00043   // G4cout << " Cached-B-Field constructor> Distance = " << distance << G4endl;
00044   this->ClearCounts(); 
00045 }

G4CachedMagneticField::~G4CachedMagneticField (  )  [virtual]

Definition at line 47 of file G4CachedMagneticField.cc.

00048 {
00049 }

G4CachedMagneticField::G4CachedMagneticField ( const G4CachedMagneticField r  ) 

Definition at line 59 of file G4CachedMagneticField.cc.

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

00060   : G4MagneticField()
00061 {
00062   fpMagneticField=      rightCMF.fpMagneticField;
00063   fDistanceConst = rightCMF.fDistanceConst;
00064   fLastLocation  = rightCMF.fLastLocation;
00065   fLastValue     = rightCMF.fLastValue;
00066   this->ClearCounts(); 
00067 }


Member Function Documentation

void G4CachedMagneticField::ClearCounts (  )  [inline]

Definition at line 68 of file G4CachedMagneticField.hh.

References fCountCalls, and fCountEvaluations.

Referenced by G4CachedMagneticField().

00068 { fCountCalls = 0; fCountEvaluations=0; }

G4double G4CachedMagneticField::GetConstDistance (  )  const [inline]

Definition at line 63 of file G4CachedMagneticField.hh.

00063 { return fDistanceConst; } 

G4int G4CachedMagneticField::GetCountCalls (  )  const [inline]

Definition at line 66 of file G4CachedMagneticField.hh.

References fCountCalls.

00066 { return fCountCalls; }

G4int G4CachedMagneticField::GetCountEvaluations (  )  const [inline]

Definition at line 67 of file G4CachedMagneticField.hh.

References fCountEvaluations.

00067 { return fCountEvaluations; } 

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

Implements G4MagneticField.

Definition at line 75 of file G4CachedMagneticField.cc.

References fCountCalls, fCountEvaluations, and G4MagneticField::GetFieldValue().

00077 {
00078   G4ThreeVector newLocation( Point[0], Point[1], Point[2] );
00079 
00080   // G4cout << "Cache-B-field called at " << newLocation << G4endl;
00081 
00082   G4double      distSq= (newLocation-fLastLocation).mag2();
00083   fCountCalls++;
00084   if( distSq < fDistanceConst*fDistanceConst ) { 
00085      Bfield[0] = fLastValue.x();
00086      Bfield[1] = fLastValue.y();
00087      Bfield[2] = fLastValue.z();
00088   }else{
00089      // G4CachedMagneticField* thisNonC= const_cast<G4CachedMagneticField*>(this);
00090      fpMagneticField->GetFieldValue( Point, Bfield );
00091      // G4cout << " Evaluating. " << G4endl;
00092      fCountEvaluations++;
00093      // thisNonC->
00094      fLastLocation= G4ThreeVector( Point[0],  Point[1],  Point[2] );
00095      // thisNonC->
00096      fLastValue=    G4ThreeVector( Bfield[0], Bfield[1], Bfield[2] );
00097   }
00098 }

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

Definition at line 69 of file G4CachedMagneticField.cc.

00070 {
00071   if (&p == this) return *this; *this = p; return *this;
00072 }

void G4CachedMagneticField::ReportStatistics (  ) 

Definition at line 52 of file G4CachedMagneticField.cc.

References fCountCalls, fCountEvaluations, G4cout, and G4endl.

00053 {
00054   G4cout << " Cached field: " << G4endl
00055          << "   Number of calls:        " << fCountCalls << G4endl
00056          << "   Number of evaluations : " << fCountEvaluations << G4endl;                     
00057 }

void G4CachedMagneticField::SetConstDistance ( G4double  dist  )  [inline]

Definition at line 64 of file G4CachedMagneticField.hh.

00064 { fDistanceConst= dist;}


Field Documentation

G4int G4CachedMagneticField::fCountCalls [mutable, protected]

Definition at line 80 of file G4CachedMagneticField.hh.

Referenced by ClearCounts(), GetCountCalls(), GetFieldValue(), and ReportStatistics().

G4int G4CachedMagneticField::fCountEvaluations [mutable, protected]

Definition at line 80 of file G4CachedMagneticField.hh.

Referenced by ClearCounts(), GetCountEvaluations(), GetFieldValue(), and ReportStatistics().


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:51:35 2013 for Geant4 by  doxygen 1.4.7