BLGlobalField Class Reference

#include <BLGlobalField.hh>

List of all members.


Detailed Description

BLGlobalField - handles the global ElectroMagnetic field.

There is a single BLGlobalField object.

The field from each individual beamline element is given by a BLElementField object. Any number of overlapping BLElementField objects can be added to the global field. Any element command that represents an element with an EM field must add the appropriate BLElementField to the global BLGlobalField object.

Public Member Functions

void GetFieldValue (const G4double *point, G4double *field) const
 GetFieldValue() returns the field value at a given point[]. field is really field[6]: Bx,By,Bz,Ex,Ey,Ez. point[] is in global coordinates: x,y,z,t. Uses the field map for solenoids, when possible.
G4bool DoesFieldChangeEnergy () const
 DoesFieldChangeEnergy() returns true.
void addElementField (const BLElementField *f)
 addElementField() adds the BLElementField object for a single element to the global field.
void clear ()
 clear() removes all BLElementField-s from the global object, and destroys them. Used before the geometry is completely re-created.

Static Public Member Functions

static BLGlobalFieldgetObject ()
 getObject() returns the single BLGlobalField object. It is constructed, if necessary.

Protected Member Functions

 BLGlobalField ()
 ~BLGlobalField ()
 BLGlobalField (const BLGlobalField &)
BLGlobalFieldoperator= (const BLGlobalField &)
void setupArray ()

Protected Attributes

std::vector< const
BLElementField * > 
fields
const BLElementField ** fp
bool first
int nfp

Static Protected Attributes

static BLGlobalFieldobject = 0


Constructor & Destructor Documentation

BLGlobalField::BLGlobalField (  )  [protected]

References clear(), first, fp, BLParam::getDouble(), nfp, and Param.

Referenced by getObject().

00046                              : G4ElectroMagneticField(), fields()
00047 {
00048         first = true;
00049         fp = 0;
00050         nfp = 0;
00051 
00052         clear();
00053 
00054         // Get transportation, field, and propagator  managers
00055         G4TransportationManager  *pTransportMgr= 
00056                G4TransportationManager::GetTransportationManager();
00057         G4FieldManager* fieldMgr = pTransportMgr->GetFieldManager();
00058         G4PropagatorInField *pFieldPropagator =
00059                                         pTransportMgr->GetPropagatorInField(); 
00060 
00061         // Need to SetFieldChangesEnergy to account for a time varying electric
00062         // field (r.f. fields)
00063         fieldMgr->SetFieldChangesEnergy(true);
00064 
00065         // Construct equation of motion of particles through e.m. fields
00066         G4EqMagElectricField *fEquationE = new G4EqMagElectricField(this);
00067 
00068 #ifdef STUB
00069         // Set the field
00070         fieldMgr->SetDetectorField(this);
00071 
00072         // Choose a stepper for integration of the equation of motion
00073         G4MagIntegratorStepper *pStepper = new G4ClassicalRK4(fEquationE,8);
00074         //G4MagIntegratorStepper *pStepper = new G4SimpleRunge(fEquationE,8);
00075      
00076         // Create a cord finder providing the (global field, min step length,
00077         // a pointer to the stepper)
00078 #ifndef GEANT4_NOT4_6
00079         G4double min_step = Param.getDouble("minStep");
00080         G4ChordFinder* pChordFinder = new G4ChordFinder((G4MagneticField *)this,min_step,pStepper);
00081 #else
00082         G4double min_step = Param.getDouble("minStep");
00083         G4ChordFinder* pChordFinder = new G4ChordFinder(this,min_step,pStepper);
00084 #endif
00085 
00086 #else   //STUB
00087         G4double min_step = Param.getDouble("minStep");
00088         G4MagIntegratorStepper *pStepper = new G4ClassicalRK4(fEquationE,8);
00089         fieldMgr->SetDetectorField(this);
00090         G4MagInt_Driver *fIntgrDriver = new G4MagInt_Driver(min_step, 
00091                                 pStepper, pStepper->GetNumberOfVariables() ); 
00092         G4ChordFinder *pChordFinder = new G4ChordFinder(fIntgrDriver); 
00093         fieldMgr->SetChordFinder( pChordFinder ); 
00094 #endif  //STUB
00095 
00096         // Set accuracy parameters
00097         G4double delta_chord = Param.getDouble("deltaChord");
00098         pChordFinder->SetDeltaChord( delta_chord );
00099         G4double delta_onestep = Param.getDouble("deltaOneStep");
00100         fieldMgr->SetAccuraciesWithDeltaOneStep(delta_onestep);
00101         G4double delta_intersection = Param.getDouble("deltaIntersection");
00102         fieldMgr->SetDeltaIntersection(delta_intersection); 
00103         G4double eps_min = Param.getDouble("epsMin");
00104         G4double eps_max = Param.getDouble("epsMax");
00105         pFieldPropagator->SetMinimumEpsilonStep(eps_min);
00106         pFieldPropagator->SetMaximumEpsilonStep(eps_max);
00107 //      G4cout << "Accuracy Parameters:" <<
00108 //              " MinStep=" << min_step <<
00109 //              " DeltaChord=" << delta_chord <<
00110 //              " DeltaOneStep=" << delta_onestep << G4endl;
00111 //      G4cout << "                    " <<
00112 //              " DeltaIntersection=" << delta_intersection <<
00113 //              " EpsMin=" << eps_min <<
00114 //              " EpsMax=" << eps_max <<  G4endl;
00115         fieldMgr->SetChordFinder(pChordFinder);
00116 
00117         // set object
00118         object = this;
00119 }

BLGlobalField::~BLGlobalField (  )  [protected]

References clear().

00122 {
00123         clear();
00124 }

BLGlobalField::BLGlobalField ( const BLGlobalField  )  [protected]


Member Function Documentation

BLGlobalField& BLGlobalField::operator= ( const BLGlobalField  )  [protected]

void BLGlobalField::setupArray (  )  [protected]

References fields, first, fp, and nfp.

00173 {
00174         first = false;
00175         nfp = fields.size();
00176         fp = new const BLElementField *[nfp+1]; // add 1 so it's never 0
00177         for(int i=0; i<nfp; ++i)
00178                 fp[i] = fields[i];
00179 }

BLGlobalField * BLGlobalField::getObject (  )  [static]

void BLGlobalField::GetFieldValue ( const G4double *  point,
G4double *  field 
) const

GetFieldValue() returns the field value at a given point[]. field is really field[6]: Bx,By,Bz,Ex,Ey,Ez. point[] is in global coordinates: x,y,z,t. Uses the field map for solenoids, when possible.

References BLElementField::addFieldValue(), first, fp, BLElementField::isInBoundingBox(), and nfp.

Referenced by TraceNTuple::appendTrace(), BLCMDprobefield::callback(), BLCMDprintfield::do_points(), BLCMDprintfield::do_print(), BLCMDtracker::fitTrack(), Bug1021::PostStepGetPhysicalInteractionLength(), BLEvaluator::setTrackVariables(), BLManager::steppingVerbosePrint(), BLVirtualDetectorNTuple::UserSteppingAction(), BLCMDzntuple::Entry::UserZSteppingAction(), and BLCMDtracker::UserZSteppingAction().

00133 {
00134         // NOTE: this routine dominates the CPU time for tracking.
00135         // The test case is the MICE beamline + detector, which has 38 
00136         // entries in fields[].
00137         // Using bounding boxes sped it up by a factor of 8 (13 ev/sec => 
00138         // 100 ev/sec).
00139         // Using the simple array fp[] instead of fields[] directly sped
00140         // it up by an additional factor of two (200 ev/sec).
00141         // Making this a friend of BLElementField and putting the code for
00142         // isInBoundingBox() inline here didn't help at all.
00143 
00144         field[0] = field[1] = field[2] = field[3] = field[4] = field[5] = 0.0;
00145         // protect against Geant4 bug that calls us with point[] NaN.
00146         if(point[0] != point[0]) return;
00147 
00148         if(first)               // (can't use nfp or fp, as they may change)
00149                 ((BLGlobalField*)this)->setupArray();   // (cast away const)
00150 
00151         for(int i=0; i<nfp; ++i) {
00152                 const BLElementField *p = fp[i];
00153                 if(p->isInBoundingBox(point))
00154                         p->addFieldValue(point,field);
00155         }
00156 }

G4bool BLGlobalField::DoesFieldChangeEnergy (  )  const [inline]

DoesFieldChangeEnergy() returns true.

00061 { return true; }

void BLGlobalField::addElementField ( const BLElementField f  )  [inline]

void BLGlobalField::clear (  ) 

clear() removes all BLElementField-s from the global object, and destroys them. Used before the geometry is completely re-created.

References fields, first, fp, and nfp.

Referenced by BLGlobalField(), and ~BLGlobalField().

00159 {
00160         std::vector<const BLElementField *>::iterator i;
00161         for(i=fields.begin(); i!=fields.end(); ++i) {
00162                 delete *i;
00163         }
00164         fields.clear();
00165 
00166         if(fp) delete fp;
00167         first = true;
00168         fp = 0;
00169         nfp = 0;
00170 }


Member Data Documentation

std::vector<const BLElementField *> BLGlobalField::fields [protected]

Referenced by addElementField(), clear(), and setupArray().

const BLElementField** BLGlobalField::fp [protected]

bool BLGlobalField::first [protected]

int BLGlobalField::nfp [protected]

BLGlobalField * BLGlobalField::object = 0 [static, protected]

Referenced by getObject().


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