#include <BLGlobalField.hh>
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. | |
void | getFieldValue (G4ThreeVector &pos, G4double t, G4ThreeVector &B, G4ThreeVector &E) |
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. | |
void | zeroEfield (bool v) |
zeroEfield() sets the flag that forces the Efield to be zero everywhere. Used for ICOOL-style reference particle tracking. | |
Static Public Member Functions | |
static BLGlobalField * | getObject () |
getObject() returns the single BLGlobalField object. It is constructed, if necessary. | |
Protected Member Functions | |
BLGlobalField () | |
~BLGlobalField () | |
BLGlobalField (const BLGlobalField &) | |
BLGlobalField & | operator= (const BLGlobalField &) |
void | setupArray () |
Protected Attributes | |
std::vector< const BLElementField * > | fields |
const BLElementField ** | fp |
bool | first |
int | nfp |
bool | forceEfieldZero |
Static Protected Attributes | |
static BLGlobalField * | object = 0 |
BLGlobalField::BLGlobalField | ( | ) | [protected] |
References clear(), first, forceEfieldZero, fp, BLParam::getDouble(), nfp, and Param.
Referenced by getObject().
00046 : G4ElectroMagneticField(), fields() 00047 { 00048 first = true; 00049 fp = 0; 00050 nfp = 0; 00051 forceEfieldZero = false; 00052 00053 clear(); 00054 00055 // Get transportation, field, and propagator managers 00056 G4TransportationManager *pTransportMgr= 00057 G4TransportationManager::GetTransportationManager(); 00058 G4FieldManager* fieldMgr = pTransportMgr->GetFieldManager(); 00059 G4PropagatorInField *pFieldPropagator = 00060 pTransportMgr->GetPropagatorInField(); 00061 00062 // Need to SetFieldChangesEnergy to account for a time varying electric 00063 // field (r.f. fields) 00064 fieldMgr->SetFieldChangesEnergy(true); 00065 00066 // Construct equation of motion of particles through e.m. fields 00067 G4EqMagElectricField *fEquationE = new G4EqMagElectricField(this); 00068 00069 #ifdef STUB 00070 // Set the field 00071 fieldMgr->SetDetectorField(this); 00072 00073 // Choose a stepper for integration of the equation of motion 00074 G4MagIntegratorStepper *pStepper = new G4ClassicalRK4(fEquationE,8); 00075 //G4MagIntegratorStepper *pStepper = new G4SimpleRunge(fEquationE,8); 00076 00077 // Create a cord finder providing the (global field, min step length, 00078 // a pointer to the stepper) 00079 #ifndef GEANT4_NOT4_6 00080 G4double min_step = Param.getDouble("minStep"); 00081 G4ChordFinder* pChordFinder = new G4ChordFinder((G4MagneticField *)this,min_step,pStepper); 00082 #else 00083 G4double min_step = Param.getDouble("minStep"); 00084 G4ChordFinder* pChordFinder = new G4ChordFinder(this,min_step,pStepper); 00085 #endif 00086 00087 #else //STUB 00088 G4double min_step = Param.getDouble("minStep"); 00089 G4MagIntegratorStepper *pStepper = new G4ClassicalRK4(fEquationE,8); 00090 fieldMgr->SetDetectorField(this); 00091 G4MagInt_Driver *fIntgrDriver = new G4MagInt_Driver(min_step, 00092 pStepper, pStepper->GetNumberOfVariables() ); 00093 G4ChordFinder *pChordFinder = new G4ChordFinder(fIntgrDriver); 00094 fieldMgr->SetChordFinder( pChordFinder ); 00095 #endif //STUB 00096 00097 // Set accuracy parameters 00098 G4double delta_chord = Param.getDouble("deltaChord"); 00099 pChordFinder->SetDeltaChord( delta_chord ); 00100 G4double delta_onestep = Param.getDouble("deltaOneStep"); 00101 fieldMgr->SetAccuraciesWithDeltaOneStep(delta_onestep); 00102 G4double delta_intersection = Param.getDouble("deltaIntersection"); 00103 fieldMgr->SetDeltaIntersection(delta_intersection); 00104 G4double eps_min = Param.getDouble("epsMin"); 00105 G4double eps_max = Param.getDouble("epsMax"); 00106 pFieldPropagator->SetMinimumEpsilonStep(eps_min); 00107 pFieldPropagator->SetMaximumEpsilonStep(eps_max); 00108 // G4cout << "Accuracy Parameters:" << 00109 // " MinStep=" << min_step << 00110 // " DeltaChord=" << delta_chord << 00111 // " DeltaOneStep=" << delta_onestep << G4endl; 00112 // G4cout << " " << 00113 // " DeltaIntersection=" << delta_intersection << 00114 // " EpsMin=" << eps_min << 00115 // " EpsMax=" << eps_max << G4endl; 00116 fieldMgr->SetChordFinder(pChordFinder); 00117 00118 // set object 00119 object = this; 00120 }
BLGlobalField::BLGlobalField | ( | const BLGlobalField & | ) | [protected] |
BLGlobalField& BLGlobalField::operator= | ( | const BLGlobalField & | ) | [protected] |
void BLGlobalField::setupArray | ( | ) | [protected] |
BLGlobalField * BLGlobalField::getObject | ( | ) | [static] |
getObject() returns the single BLGlobalField object. It is constructed, if necessary.
References BLGlobalField(), and object.
Referenced by BLTrackNTuple::appendTrack(), BLCMDprobefield::callback(), BLCMDfieldntuple::callback(), BLCMDfieldlines::callback(), BLCMDspacechargelw::command(), BLCMDspacecharge::command(), BLCMDcollective::command(), BLManager::Construct(), BLCMDsolenoid::construct(), BLCMDrfdevice::construct(), BLCMDpillbox::construct(), BLCMDmultipole::construct(), BLCMDidealsectorbend::construct(), BLCMDhelicalharmonic::construct(), BLCMDhelicaldipole::construct(), BLCMDgenericquad::construct(), BLCMDgenericbend::construct(), BLCMDfieldmap::construct(), BLCMDfieldexpr::construct(), BLCMDprintfield::do_cylinder(), BLCMDprintfield::do_grid(), BLCMDprintfield::do_points(), BLCMDprintfield::do_print(), BLCMDtracker::fitTrack(), LiLensField::LiLensField(), Bug1021::PostStepGetPhysicalInteractionLength(), BLCMDreference::PostUserTrackingAction(), BLCMDreference::PreUserTrackingAction(), BLEvaluator::setTrackVariables(), BLManager::steppingVerbosePrint(), RFdeviceField::UserSteppingAction(), and BLCMDtracker::UserZSteppingAction().
00128 { 00129 if(!object) new BLGlobalField(); 00130 return object; 00131 }
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, forceEfieldZero, fp, BLElementField::isInBoundingBox(), and nfp.
Referenced by BLTrackNTuple::appendTrack(), BLCMDprobefield::callback(), BLCMDfieldntuple::callback(), BLCMDcollective::collectiveStep(), BLCMDprintfield::do_points(), BLCMDprintfield::do_print(), BLCMDtracker::fitTrack(), getFieldValue(), Bug1021::PostStepGetPhysicalInteractionLength(), BLEvaluator::setTrackVariables(), BLManager::steppingVerbosePrint(), RFdeviceField::UserSteppingAction(), and BLCMDtracker::UserZSteppingAction().
00134 { 00135 // NOTE: this routine dominates the CPU time for tracking. 00136 // The test case is the MICE beamline + detector, which has 38 00137 // entries in fields[]. 00138 // Using bounding boxes sped it up by a factor of 8 (13 ev/sec => 00139 // 100 ev/sec). 00140 // Using the simple array fp[] instead of fields[] directly sped 00141 // it up by an additional factor of two (200 ev/sec). 00142 // Making this a friend of BLElementField and putting the code for 00143 // isInBoundingBox() inline here didn't help at all. 00144 00145 field[0] = field[1] = field[2] = field[3] = field[4] = field[5] = 0.0; 00146 // protect against Geant4 bug that calls us with point[] NaN. 00147 if(point[0] != point[0]) return; 00148 00149 if(first) // (can't use nfp or fp, as they may change) 00150 ((BLGlobalField*)this)->setupArray(); // (cast away const) 00151 00152 for(int i=0; i<nfp; ++i) { 00153 const BLElementField *p = fp[i]; 00154 if(p->isInBoundingBox(point)) 00155 p->addFieldValue(point,field); 00156 } 00157 00158 if(forceEfieldZero) { 00159 field[3] = field[4] = field[5] = 0.0; 00160 } 00161 }
void BLGlobalField::getFieldValue | ( | G4ThreeVector & | pos, | |
G4double | t, | |||
G4ThreeVector & | B, | |||
G4ThreeVector & | E | |||
) | [inline] |
References GetFieldValue().
Referenced by BLCMDfieldlines::bmag(), BLCMDfieldlines::callback(), and BLCMDfieldlines::generateOneFieldLine().
00062 { 00063 G4double point[4], field[6]; 00064 point[0]=pos[0]; point[1]=pos[1]; point[2]=pos[2],point[3]=t; 00065 GetFieldValue(point,field); 00066 B.setX(field[0]); B.setY(field[1]); B.setZ(field[2]); 00067 E.setX(field[3]); E.setY(field[4]); E.setZ(field[5]); 00068 }
G4bool BLGlobalField::DoesFieldChangeEnergy | ( | ) | const [inline] |
void BLGlobalField::addElementField | ( | const BLElementField * | f | ) | [inline] |
addElementField() adds the BLElementField object for a single element to the global field.
References fields.
Referenced by BLCMDspacechargelw::command(), BLCMDspacecharge::command(), BLCMDsolenoid::construct(), BLCMDrfdevice::construct(), BLCMDpillbox::construct(), BLCMDmultipole::construct(), BLCMDidealsectorbend::construct(), BLCMDhelicalharmonic::construct(), BLCMDhelicaldipole::construct(), BLCMDgenericquad::construct(), BLCMDgenericbend::construct(), BLCMDfieldmap::construct(), BLCMDfieldexpr::construct(), and LiLensField::LiLensField().
00076 { fields.push_back(f); }
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().
00164 { 00165 std::vector<const BLElementField *>::iterator i; 00166 for(i=fields.begin(); i!=fields.end(); ++i) { 00167 delete *i; 00168 } 00169 fields.clear(); 00170 00171 if(fp) delete fp; 00172 first = true; 00173 fp = 0; 00174 nfp = 0; 00175 }
void BLGlobalField::zeroEfield | ( | bool | v | ) | [inline] |
zeroEfield() sets the flag that forces the Efield to be zero everywhere. Used for ICOOL-style reference particle tracking.
References forceEfieldZero.
Referenced by BLCMDreference::PostUserTrackingAction(), and BLCMDreference::PreUserTrackingAction().
00085 { forceEfieldZero = v; }
std::vector<const BLElementField *> BLGlobalField::fields [protected] |
Referenced by addElementField(), clear(), and setupArray().
const BLElementField** BLGlobalField::fp [protected] |
Referenced by BLGlobalField(), clear(), GetFieldValue(), and setupArray().
bool BLGlobalField::first [protected] |
Referenced by BLGlobalField(), clear(), GetFieldValue(), and setupArray().
int BLGlobalField::nfp [protected] |
Referenced by BLGlobalField(), clear(), GetFieldValue(), and setupArray().
bool BLGlobalField::forceEfieldZero [protected] |
Referenced by BLGlobalField(), GetFieldValue(), and zeroEfield().
BLGlobalField * BLGlobalField::object = 0 [static, protected] |
Referenced by getObject().