MyGlobalField Class Reference

#include <MyGlobalField.hh>

List of all members.

Public Member Functions

void GetFieldValue (const G4double *point, G4double *field) const
G4bool DoesFieldChangeEnergy () const
 DoesFieldChangeEnergy() returns true.
void addElementField (MyElementField *f)
void clear ()
void updateField ()
 updates all field tracking objects and clear()
void SetStepperType (G4int i)
 Set the Stepper types.
void SetStepper ()
 Set the Stepper.
void SetMinStep (G4double s)
 Set the minimum step length.
void SetDeltaChord (G4double s)
 Set the delta chord length.
void SetDeltaOneStep (G4double s)
 Set the delta one step length.
void SetDeltaIntersection (G4double s)
 Set the delta intersection length.
void SetEpsMin (G4double s)
 Set the minimum eps length.
void SetEpsMax (G4double s)
 Set the maximum eps length.
FieldListgetFields ()
 Return the list of Element Fields.

Static Public Member Functions

static MyGlobalFieldgetObject ()

Protected Member Functions

G4FieldManager * GetGlobalFieldManager ()
 Get the global field manager.

Private Member Functions

 MyGlobalField ()
 MyGlobalField (const MyGlobalField &)
 ~MyGlobalField ()
MyGlobalFieldoperator= (const MyGlobalField &)
void setupArray ()

Private Attributes

G4int nfp
G4bool first
FieldListfields
const MyElementField ** fp
G4int fStepperType
G4double minStep
G4double deltaChord
G4double deltaOneStep
G4double deltaIntersection
G4double epsMin
G4double epsMax
G4EqEMFieldWithSpin * fEquation
G4FieldManager * fFieldManager
G4PropagatorInField * fFieldPropagator
G4MagIntegratorStepper * fStepper
G4ChordFinder * fChordFinder
MyGlobalFieldMessengerfGlobalFieldMessenger

Static Private Attributes

static MyGlobalFieldobject = 0

Detailed Description

Definition at line 67 of file MyGlobalField.hh.


Constructor & Destructor Documentation

MyGlobalField::MyGlobalField (  )  [private]

Definition at line 45 of file MyGlobalField.cc.

References fGlobalFieldMessenger, fields, fStepperType, and updateField().

Referenced by getObject().

00045                              : G4ElectroMagneticField(),
00046 minStep(0.01*mm), deltaChord(3.0*mm),
00047 deltaOneStep(0.01*mm), deltaIntersection(0.1*mm),
00048 epsMin(2.5e-7*mm), epsMax(0.05*mm),
00049 fEquation(0), fFieldManager(0),
00050 fFieldPropagator(0), fStepper(0), fChordFinder(0) {
00051     //MyGlobalField::MyGlobalField() : G4MagneticField(),
00052     //                             minStep(0.01*mm), deltaChord(3.0*mm),
00053     //                             deltaOneStep(0.01*mm), deltaIntersection(0.1*mm),
00054     //                             epsMin(2.5e-7*mm), epsMax(0.05*mm),
00055     //                             fEquation(0), fFieldManager(0),
00056     //                             fFieldPropagator(0), fStepper(0), fChordFinder(0)
00057     fGlobalFieldMessenger = new MyGlobalFieldMessenger(this);
00058 
00059     fields = new FieldList();
00060 
00061     fStepperType = 4 ;                                // ClassicalRK4 is default stepper
00062 
00063     //  set object
00064 
00065     object = this;
00066 
00067     updateField();
00068 }

MyGlobalField::MyGlobalField ( const MyGlobalField  )  [private]
MyGlobalField::~MyGlobalField (  )  [private]

Definition at line 71 of file MyGlobalField.cc.

References clear(), fChordFinder, fEquation, fFieldManager, fFieldPropagator, fGlobalFieldMessenger, and fStepper.

00071                               {
00072     clear();
00073 
00074     delete fGlobalFieldMessenger;
00075 
00076     if (fEquation)        delete fEquation;
00077     if (fFieldManager)    delete fFieldManager;
00078     if (fFieldPropagator) delete fFieldPropagator;
00079     if (fStepper)         delete fStepper;
00080     if (fChordFinder)     delete fChordFinder;
00081 }


Member Function Documentation

void MyGlobalField::addElementField ( MyElementField f  )  [inline]

addElementField() adds the ElementField object for a single element to the global field.

Definition at line 97 of file MyGlobalField.hh.

References fields.

Referenced by MyElementField::MyElementField().

00097 { if (fields) fields->push_back(f); }

void MyGlobalField::clear (  ) 

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

Definition at line 235 of file MyGlobalField.cc.

References fields, first, fp, and nfp.

Referenced by updateField(), and ~MyGlobalField().

00235                           {
00236     if (fields) {
00237         if (fields->size()>0) {
00238             FieldList::iterator i;
00239             for (i=fields->begin(); i!=fields->end(); ++i) delete *i;
00240             fields->clear();
00241         }
00242     }
00243 
00244     if (fp) delete[] fp;
00245 
00246     first = true;
00247 
00248     nfp = 0;
00249     fp = NULL;
00250 }

G4bool MyGlobalField::DoesFieldChangeEnergy (  )  const [inline]

DoesFieldChangeEnergy() returns true.

Definition at line 93 of file MyGlobalField.hh.

00093 { return true; }

FieldList* MyGlobalField::getFields (  )  [inline]

Return the list of Element Fields.

Definition at line 132 of file MyGlobalField.hh.

References fields.

Referenced by RunAction::BeginOfRunAction().

00132 { return fields; }

void MyGlobalField::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.

Definition at line 204 of file MyGlobalField.cc.

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

Referenced by MyGlobalFieldMessenger::SetNewValue().

00204                                                                               {
00205     // NOTE: this routine dominates the CPU time for tracking.
00206     // Using the simple array fp[] instead of fields[]
00207     // directly sped it up
00208 
00209     field[0] = field[1] = field[2] = field[3] = field[4] = field[5] = 0.0;
00210 
00211     // protect against Geant4 bug that calls us with point[] NaN.
00212     if(point[0] != point[0]) return;
00213 
00214     // (can't use nfp or fp, as they may change)
00215     if (first) ((MyGlobalField*)this)->setupArray();  // (cast away const)
00216 
00217     for (int i=0; i<nfp; ++i) {
00218         const MyElementField* p = fp[i];
00219         if (p->isInBoundingBox(point)) {
00220             p->addFieldValue(point,field);
00221         }
00222     }
00223 
00224     if(0) {
00225         G4cout << "Point = [" << point[0]/cm << ", "
00226             << point[1]/cm << ", " << point[2]/cm << "] cm" << G4endl;
00227         G4cout << " Field = [" << field[0]/tesla << ", " << field[1]/tesla << ", "
00228             << field[2]/tesla << "]" << G4endl
00229             << "         [" << field[3] << ", " << field[4]
00230             << ", " << field[5]<< "] " << G4endl;
00231     }
00232 }

G4FieldManager * MyGlobalField::GetGlobalFieldManager (  )  [protected]

Get the global field manager.

Definition at line 198 of file MyGlobalField.cc.

Referenced by updateField().

00198                                                      {
00199     return G4TransportationManager::GetTransportationManager()
00200         ->GetFieldManager();
00201 }

MyGlobalField * MyGlobalField::getObject (  )  [static]

getObject() returns the single MyGlobalField object. It is constructed, if necessary.

Definition at line 147 of file MyGlobalField.cc.

References MyGlobalField(), and object.

Referenced by RunAction::BeginOfRunAction(), MyElementField::MyElementField(), and MyFieldSvc::MyFieldSvc().

00147                                         {
00148     if (!object) new MyGlobalField();
00149     return object;
00150 }

MyGlobalField& MyGlobalField::operator= ( const MyGlobalField  )  [private]
void MyGlobalField::SetDeltaChord ( G4double  s  )  [inline]

Set the delta chord length.

Definition at line 117 of file MyGlobalField.hh.

References deltaChord.

Referenced by MyGlobalFieldMessenger::SetNewValue().

00117 { deltaChord = s; }

void MyGlobalField::SetDeltaIntersection ( G4double  s  )  [inline]

Set the delta intersection length.

Definition at line 123 of file MyGlobalField.hh.

References deltaIntersection.

00123 { deltaIntersection = s; }

void MyGlobalField::SetDeltaOneStep ( G4double  s  )  [inline]

Set the delta one step length.

Definition at line 120 of file MyGlobalField.hh.

References deltaOneStep.

00120 { deltaOneStep = s; }

void MyGlobalField::SetEpsMax ( G4double  s  )  [inline]

Set the maximum eps length.

Definition at line 129 of file MyGlobalField.hh.

References epsMax.

Referenced by MyGlobalFieldMessenger::SetNewValue().

00129 { epsMax = s; }

void MyGlobalField::SetEpsMin ( G4double  s  )  [inline]

Set the minimum eps length.

Definition at line 126 of file MyGlobalField.hh.

References epsMin.

Referenced by MyGlobalFieldMessenger::SetNewValue().

00126 { epsMin = s; }

void MyGlobalField::SetMinStep ( G4double  s  )  [inline]

Set the minimum step length.

Definition at line 114 of file MyGlobalField.hh.

References minStep.

Referenced by MyGlobalFieldMessenger::SetNewValue().

00114 { minStep = s; }

void MyGlobalField::SetStepper (  ) 

Set the Stepper.

Definition at line 153 of file MyGlobalField.cc.

References fEquation, fStepper, and fStepperType.

Referenced by updateField().

00153                                {
00154     if(fStepper) delete fStepper;
00155 
00156     switch ( fStepperType ) {
00157         case 0:
00158             //      fStepper = new G4ExplicitEuler( fEquation, 8 ); // no spin tracking
00159                                                       // with spin tracking
00160             fStepper = new G4ExplicitEuler( fEquation, 12 );
00161             G4cout << "G4ExplicitEuler is called" << G4endl;
00162             break;
00163         case 1:
00164             //      fStepper = new G4ImplicitEuler( fEquation, 8 ); // no spin tracking
00165                                                       // with spin tracking
00166             fStepper = new G4ImplicitEuler( fEquation, 12 );
00167             G4cout << "G4ImplicitEuler is called" << G4endl;
00168             break;
00169         case 2:
00170             //      fStepper = new G4SimpleRunge( fEquation, 8 ); // no spin tracking
00171                                                       // with spin tracking
00172             fStepper = new G4SimpleRunge( fEquation, 12 );
00173             G4cout << "G4SimpleRunge is called" << G4endl;
00174             break;
00175         case 3:
00176             //      fStepper = new G4SimpleHeum( fEquation, 8 ); // no spin tracking
00177                                                       // with spin tracking
00178             fStepper = new G4SimpleHeum( fEquation, 12 );
00179             G4cout << "G4SimpleHeum is called" << G4endl;
00180             break;
00181         case 4:
00182             //      fStepper = new G4ClassicalRK4( fEquation, 8 ); // no spin tracking
00183                                                       // with spin tracking
00184             fStepper = new G4ClassicalRK4( fEquation, 12 );
00185             G4cout << "G4ClassicalRK4 (default) is called" << G4endl;
00186             break;
00187         case 5:
00188             //      fStepper = new G4CashKarpRKF45( fEquation, 8 ); // no spin tracking
00189                                                       // with spin tracking
00190             fStepper = new G4CashKarpRKF45( fEquation, 12 );
00191             G4cout << "G4CashKarpRKF45 is called" << G4endl;
00192             break;
00193         default: fStepper = 0;
00194     }
00195 }

void MyGlobalField::SetStepperType ( G4int  i  )  [inline]

Set the Stepper types.

Definition at line 108 of file MyGlobalField.hh.

References fStepperType.

Referenced by MyGlobalFieldMessenger::SetNewValue().

00108 { fStepperType = i; }

void MyGlobalField::setupArray (  )  [private]

Definition at line 253 of file MyGlobalField.cc.

References fields, first, fp, and nfp.

00253                                {
00254     first = false;
00255     nfp = fields->size();
00256     fp = new const MyElementField* [nfp+1];           // add 1 so it's never 0
00257     for (int i=0; i<nfp; ++i) fp[i] = (*fields)[i];
00258 
00259     //G4cout << " In MyGlobalField::setupArray nfp is " << nfp << G4endl;
00260 }

void MyGlobalField::updateField (  ) 

updates all field tracking objects and clear()

Definition at line 84 of file MyGlobalField.cc.

References clear(), deltaChord, deltaIntersection, deltaOneStep, epsMax, epsMin, fChordFinder, fEquation, fFieldManager, fFieldPropagator, first, fp, fStepper, GetGlobalFieldManager(), minStep, nfp, and SetStepper().

Referenced by MyGlobalField(), and MyGlobalFieldMessenger::SetNewValue().

00084                                 {
00085     first = true;
00086 
00087     nfp = 0;
00088     fp = 0;
00089 
00090     clear();
00091 
00092     //  Construct equ. of motion of particles through B fields
00093     //  fEquation = new G4Mag_EqRhs(this);
00094     //  Construct equ. of motion of particles through e.m. fields
00095     //  fEquation = new G4EqMagElectricField(this);
00096     //  Construct equ. of motion of particles including spin through B fields
00097     //  fEquation = new G4Mag_SpinEqRhs(this);
00098     //  Construct equ. of motion of particles including spin through e.m. fields
00099     fEquation = new G4EqEMFieldWithSpin(this);
00100 
00101     //  Get transportation, field, and propagator managers
00102     G4TransportationManager* fTransportManager =
00103         G4TransportationManager::GetTransportationManager();
00104 
00105     fFieldManager = GetGlobalFieldManager();
00106 
00107     fFieldPropagator = fTransportManager->GetPropagatorInField();
00108 
00109     //  Need to SetFieldChangesEnergy to account for a time varying electric
00110     //  field (r.f. fields)
00111     fFieldManager->SetFieldChangesEnergy(true);
00112 
00113     //  Set the field
00114     fFieldManager->SetDetectorField(this);
00115 
00116     //  Choose a stepper for integration of the equation of motion
00117     SetStepper();
00118 
00119     //  Create a cord finder providing the (global field, min step length,
00120     //  a pointer to the stepper)
00121     fChordFinder = new G4ChordFinder((G4MagneticField*)this,minStep,fStepper);
00122 
00123     // Set accuracy parameters
00124     fChordFinder->SetDeltaChord( deltaChord );
00125 
00126     fFieldManager->SetAccuraciesWithDeltaOneStep(deltaOneStep);
00127 
00128     fFieldManager->SetDeltaIntersection(deltaIntersection);
00129 
00130     fFieldPropagator->SetMinimumEpsilonStep(epsMin);
00131     fFieldPropagator->SetMaximumEpsilonStep(epsMax);
00132 
00133     G4cout << "Accuracy Parameters:" <<
00134         " MinStep=" << minStep <<
00135         " DeltaChord=" << deltaChord <<
00136         " DeltaOneStep=" << deltaOneStep << G4endl;
00137     G4cout << "                    " <<
00138         " DeltaIntersection=" << deltaIntersection <<
00139         " EpsMin=" << epsMin <<
00140         " EpsMax=" << epsMax <<  G4endl;
00141 
00142     fFieldManager->SetChordFinder(fChordFinder);
00143 
00144 }


Member Data Documentation

G4double MyGlobalField::deltaChord [private]

Definition at line 155 of file MyGlobalField.hh.

Referenced by SetDeltaChord(), and updateField().

Definition at line 157 of file MyGlobalField.hh.

Referenced by SetDeltaIntersection(), and updateField().

G4double MyGlobalField::deltaOneStep [private]

Definition at line 156 of file MyGlobalField.hh.

Referenced by SetDeltaOneStep(), and updateField().

G4double MyGlobalField::epsMax [private]

Definition at line 159 of file MyGlobalField.hh.

Referenced by SetEpsMax(), and updateField().

G4double MyGlobalField::epsMin [private]

Definition at line 158 of file MyGlobalField.hh.

Referenced by SetEpsMin(), and updateField().

G4ChordFinder* MyGlobalField::fChordFinder [private]

Definition at line 170 of file MyGlobalField.hh.

Referenced by updateField(), and ~MyGlobalField().

G4EqEMFieldWithSpin* MyGlobalField::fEquation [private]

Definition at line 165 of file MyGlobalField.hh.

Referenced by SetStepper(), updateField(), and ~MyGlobalField().

G4FieldManager* MyGlobalField::fFieldManager [private]

Definition at line 167 of file MyGlobalField.hh.

Referenced by updateField(), and ~MyGlobalField().

G4PropagatorInField* MyGlobalField::fFieldPropagator [private]

Definition at line 168 of file MyGlobalField.hh.

Referenced by updateField(), and ~MyGlobalField().

Definition at line 172 of file MyGlobalField.hh.

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

Definition at line 146 of file MyGlobalField.hh.

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

G4bool MyGlobalField::first [private]

Definition at line 144 of file MyGlobalField.hh.

Referenced by clear(), GetFieldValue(), setupArray(), and updateField().

const MyElementField** MyGlobalField::fp [private]

Definition at line 148 of file MyGlobalField.hh.

Referenced by clear(), GetFieldValue(), setupArray(), and updateField().

G4MagIntegratorStepper* MyGlobalField::fStepper [private]

Definition at line 169 of file MyGlobalField.hh.

Referenced by SetStepper(), updateField(), and ~MyGlobalField().

G4int MyGlobalField::fStepperType [private]

Definition at line 152 of file MyGlobalField.hh.

Referenced by MyGlobalField(), SetStepper(), and SetStepperType().

G4double MyGlobalField::minStep [private]

Definition at line 154 of file MyGlobalField.hh.

Referenced by SetMinStep(), and updateField().

G4int MyGlobalField::nfp [private]

Definition at line 143 of file MyGlobalField.hh.

Referenced by clear(), GetFieldValue(), setupArray(), and updateField().

MyGlobalField * MyGlobalField::object = 0 [static, private]

Definition at line 141 of file MyGlobalField.hh.

Referenced by getObject().


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

Generated on 15 Jun 2016 for g4sim by  doxygen 1.6.1