Geant4  10.02.p03
F04GlobalField Class Reference

#include <F04GlobalField.hh>

Inheritance diagram for F04GlobalField:
Collaboration diagram for F04GlobalField:

Public Member Functions

virtual ~F04GlobalField ()
 
virtual void GetFieldValue (const G4double *point, G4double *field) const
 
virtual G4bool DoesFieldChangeEnergy () const
 DoesFieldChangeEnergy() returns true. More...
 
void AddElementField (F04ElementField *f)
 
void Clear ()
 
void ConstructField ()
 constructs all field tracking objects More...
 
void SetStepperType (G4int i)
 Set the Stepper types. More...
 
void SetStepper ()
 Set the Stepper. More...
 
void SetMinStep (G4double stp)
 Set the minimum step length. More...
 
void SetDeltaChord (G4double dcr)
 Set the delta chord length. More...
 
void SetDeltaOneStep (G4double stp)
 Set the delta one step length. More...
 
void SetDeltaIntersection (G4double its)
 Set the delta intersection length. More...
 
void SetEpsMin (G4double eps)
 Set the minimum eps length. More...
 
void SetEpsMax (G4double eps)
 Set the maximum eps length. More...
 
FieldListGetFields ()
 Return the list of Element Fields. More...
 
- Public Member Functions inherited from G4ElectroMagneticField
 G4ElectroMagneticField ()
 
virtual ~G4ElectroMagneticField ()
 
 G4ElectroMagneticField (const G4ElectroMagneticField &r)
 
G4ElectroMagneticFieldoperator= (const G4ElectroMagneticField &p)
 
virtual void GetFieldValue (const G4double Point[4], G4double *Bfield) const =0
 
- 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)
 
virtual G4FieldClone () const
 

Static Public Member Functions

static F04GlobalFieldGetObject (F04DetectorConstruction *const)
 
static F04GlobalFieldGetObject ()
 

Protected Member Functions

G4FieldManagerGetGlobalFieldManager ()
 Get the global field manager. More...
 

Private Member Functions

 F04GlobalField (F04DetectorConstruction *const)
 
 F04GlobalField (const F04GlobalField &)
 
F04GlobalFieldoperator= (const F04GlobalField &)
 
void SetupArray ()
 

Private Attributes

G4int fNfp
 
G4bool fFirst
 
FieldListfFields
 
const F04ElementField ** fFp
 
G4int fStepperType
 
G4double fMinStep
 
G4double fDeltaChord
 
G4double fDeltaOneStep
 
G4double fDeltaIntersection
 
G4double fEpsMin
 
G4double fEpsMax
 
G4EqEMFieldWithSpinfEquation
 
G4FieldManagerfFieldManager
 
G4PropagatorInFieldfFieldPropagator
 
G4MagIntegratorStepperfStepper
 
G4ChordFinderfChordFinder
 
F04FieldMessengerfFieldMessenger
 
F04DetectorConstructionfDetectorConstruction
 

Static Private Attributes

static G4ThreadLocal F04GlobalFieldfObject = 0
 

Detailed Description

Definition at line 68 of file F04GlobalField.hh.

Constructor & Destructor Documentation

◆ F04GlobalField() [1/2]

F04GlobalField::F04GlobalField ( F04DetectorConstruction * const  det)
private

Definition at line 55 of file F04GlobalField.cc.

57  fMinStep(0.01*mm), fDeltaChord(3.0*mm),
59  fEpsMin(2.5e-7*mm), fEpsMax(0.05*mm),
60  fEquation(0), fFieldManager(0),
63 //F04GlobalField::F04GlobalField(F04DetectorConstruction* det)
64 // : G4MagneticField(),
65 // fMinStep(0.01*mm), fDeltaChord(3.0*mm),
66 // fDeltaOneStep(0.01*mm), fDeltaIntersection(0.1*mm),
67 // fEpsMin(2.5e-7*mm), fEpsMax(0.05*mm),
68 // fEquation(0), fFieldManager(0),
69 // fFieldPropagator(0), fStepper(0), fChordFinder(0),
70 // fDetectorConstruction(det)
71 {
72  fFieldMessenger = new F04FieldMessenger(this,det);
73 
74  fFields = new FieldList();
75 
76  fStepperType = 4 ; // ClassicalRK4 is default stepper
77 
78  // set object
79 
80  fObject = this;
81  fFirst = true;
82 
83  fNfp = 0;
84  fFp = NULL;
85 
87 }
G4PropagatorInField * fFieldPropagator
F04DetectorConstruction * fDetectorConstruction
static G4ThreadLocal F04GlobalField * fObject
G4MagIntegratorStepper * fStepper
std::vector< F04ElementField * > FieldList
G4double fDeltaOneStep
G4ChordFinder * fChordFinder
F04FieldMessenger * fFieldMessenger
G4EqEMFieldWithSpin * fEquation
void ConstructField()
constructs all field tracking objects
const F04ElementField ** fFp
FieldList * fFields
G4double fDeltaChord
static const double mm
Definition: G4SIunits.hh:114
G4double fDeltaIntersection
G4FieldManager * fFieldManager
Here is the call graph for this function:
Here is the caller graph for this function:

◆ F04GlobalField() [2/2]

F04GlobalField::F04GlobalField ( const F04GlobalField )
private

◆ ~F04GlobalField()

F04GlobalField::~F04GlobalField ( )
virtual

Definition at line 91 of file F04GlobalField.cc.

92 {
93  Clear();
94 
95  delete fFields;
96 
97  delete fFieldMessenger;
98 
99  if (fEquation) delete fEquation;
100  if (fStepper) delete fStepper;
101  if (fChordFinder) delete fChordFinder;
102 }
G4MagIntegratorStepper * fStepper
G4ChordFinder * fChordFinder
F04FieldMessenger * fFieldMessenger
G4EqEMFieldWithSpin * fEquation
FieldList * fFields
Here is the call graph for this function:

Member Function Documentation

◆ AddElementField()

void F04GlobalField::AddElementField ( F04ElementField f)
inline

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

Definition at line 99 of file F04GlobalField.hh.

100  {
101  if (fFields) fFields->push_back(f);
102  }
FieldList * fFields
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clear()

void F04GlobalField::Clear ( )

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

Definition at line 292 of file F04GlobalField.cc.

293 {
294  if (fFields) {
295  if (fFields->size()>0) {
296  FieldList::iterator i;
297  for (i=fFields->begin(); i!=fFields->end(); ++i) delete *i;
298  fFields->clear();
299  }
300  }
301 
302  if (fFp) { delete [] fFp; }
303  fFirst = true;
304  fNfp = 0;
305  fFp = NULL;
306 }
const F04ElementField ** fFp
FieldList * fFields
Here is the caller graph for this function:

◆ ConstructField()

void F04GlobalField::ConstructField ( )

constructs all field tracking objects

Definition at line 106 of file F04GlobalField.cc.

107 {
108  Clear();
109 
110  // Construct equ. of motion of particles through B fields
111 // fEquation = new G4Mag_EqRhs(this);
112  // Construct equ. of motion of particles through e.m. fields
113 // fEquation = new G4EqMagElectricField(this);
114  // Construct equ. of motion of particles including spin through B fields
115 // fEquation = new G4Mag_SpinEqRhs(this);
116  // Construct equ. of motion of particles including spin through e.m. fields
117  fEquation = new G4EqEMFieldWithSpin(this);
118 
119  // Get transportation, field, and propagator managers
120  G4TransportationManager* transportManager =
122 
124 
125  fFieldPropagator = transportManager->GetPropagatorInField();
126 
127  // Need to SetFieldChangesEnergy to account for a time varying electric
128  // field (r.f. fields)
130 
131  // Set the field
133 
134  // Choose a stepper for integration of the equation of motion
135  SetStepper();
136 
137  // Create a cord finder providing the (global field, min step length,
138  // a pointer to the stepper)
140 
141  // Set accuracy parameters
143 
145 
147 
150 
151  G4cout << "Accuracy Parameters:" <<
152  " MinStep=" << fMinStep <<
153  " DeltaChord=" << fDeltaChord <<
154  " DeltaOneStep=" << fDeltaOneStep << G4endl;
155  G4cout << " " <<
156  " DeltaIntersection=" << fDeltaIntersection <<
157  " EpsMin=" << fEpsMin <<
158  " EpsMax=" << fEpsMax << G4endl;
159 
161 
162  G4double l = 0.0;
165 
167  G4ThreeVector captureMgntCenter =
169 
170  F04FocusSolenoid* focusSolenoid =
171  new F04FocusSolenoid(B1, B2, l, logicCaptureMgnt,captureMgntCenter);
172  focusSolenoid -> SetHalf(true);
173 
175 
176  G4LogicalVolume* logicTransferMgnt =
178  G4ThreeVector transferMgntCenter =
180 
181  F04SimpleSolenoid* simpleSolenoid =
182  new F04SimpleSolenoid(B, l, logicTransferMgnt,transferMgntCenter);
183 
184  simpleSolenoid->SetColor("1,0,1");
185  simpleSolenoid->SetColor("0,1,1");
186  simpleSolenoid->SetMaxStep(1.5*mm);
187  simpleSolenoid->SetMaxStep(2.5*mm);
188 
189  if (fFields) {
190  if (fFields->size()>0) {
191  FieldList::iterator i;
192  for (i=fFields->begin(); i!=fFields->end(); ++i){
193  (*i)->Construct();
194  }
195  }
196  }
197 }
void SetMaxStep(G4double stp)
SetMaxStep(G4double) sets the max. step size.
G4LogicalVolume * GetTransferMgnt()
G4PropagatorInField * fFieldPropagator
G4bool SetDetectorField(G4Field *detectorField)
F04DetectorConstruction * fDetectorConstruction
void SetChordFinder(G4ChordFinder *aChordFinder)
G4MagIntegratorStepper * fStepper
void SetColor(G4String c)
SetColor(G4String) sets the color.
void SetAccuraciesWithDeltaOneStep(G4double valDeltaOneStep)
G4GLOB_DLL std::ostream G4cout
G4double fDeltaOneStep
G4FieldManager * GetGlobalFieldManager()
Get the global field manager.
G4ChordFinder * fChordFinder
static G4TransportationManager * GetTransportationManager()
G4LogicalVolume * GetCaptureMgnt()
G4EqEMFieldWithSpin * fEquation
void SetDeltaIntersection(G4double valueDintersection)
void SetMinimumEpsilonStep(G4double newEpsMin)
void SetFieldChangesEnergy(G4bool value)
#define G4endl
Definition: G4ios.hh:61
FieldList * fFields
G4double fDeltaChord
G4PropagatorInField * GetPropagatorInField() const
double G4double
Definition: G4Types.hh:76
void SetMaximumEpsilonStep(G4double newEpsMax)
void SetStepper()
Set the Stepper.
static const double mm
Definition: G4SIunits.hh:114
G4double fDeltaIntersection
void SetDeltaChord(G4double newval)
G4FieldManager * fFieldManager
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoesFieldChangeEnergy()

virtual G4bool F04GlobalField::DoesFieldChangeEnergy ( ) const
inlinevirtual

DoesFieldChangeEnergy() returns true.

Implements G4ElectroMagneticField.

Definition at line 95 of file F04GlobalField.hh.

95 { return true; }

◆ GetFields()

FieldList* F04GlobalField::GetFields ( )
inline

Return the list of Element Fields.

Definition at line 137 of file F04GlobalField.hh.

137 { return fFields; }
FieldList * fFields
Here is the call graph for this function:

◆ GetFieldValue()

void F04GlobalField::GetFieldValue ( const G4double point,
G4double field 
) const
virtual

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 267 of file F04GlobalField.cc.

268 {
269  // NOTE: this routine dominates the CPU time for tracking.
270  // Using the simple array fFp[] instead of fields[]
271  // directly sped it up
272 
273  field[0] = field[1] = field[2] = field[3] = field[4] = field[5] = 0.0;
274 
275  // protect against Geant4 bug that calls us with point[] NaN.
276  if(point[0] != point[0]) return;
277 
278  // (can't use fNfp or fFp, as they may change)
279  if (fFirst) ((F04GlobalField*)this)->SetupArray(); // (cast away const)
280 
281  for (int i=0; i<fNfp; ++i) {
282  const F04ElementField* p = fFp[i];
283  if (p->IsInBoundingBox(point)) {
284  p->AddFieldValue(point,field);
285  }
286  }
287 
288 }
virtual void AddFieldValue(const G4double point[4], G4double field[6]) const =0
bool IsInBoundingBox(const G4double point[4]) const
const F04ElementField ** fFp
Here is the call graph for this function:

◆ GetGlobalFieldManager()

G4FieldManager * F04GlobalField::GetGlobalFieldManager ( )
protected

Get the global field manager.

Definition at line 259 of file F04GlobalField.cc.

260 {
262  ->GetFieldManager();
263 }
G4FieldManager * GetFieldManager() const
static G4TransportationManager * GetTransportationManager()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetObject() [1/2]

F04GlobalField * F04GlobalField::GetObject ( F04DetectorConstruction * const  det)
static

GetObject() returns the single F04GlobalField object. It is constructed, if necessary.

Definition at line 201 of file F04GlobalField.cc.

202 {
203  if (!fObject) new F04GlobalField(det);
204  return fObject;
205 }
static G4ThreadLocal F04GlobalField * fObject
F04GlobalField(F04DetectorConstruction *const)
Here is the call graph for this function:

◆ GetObject() [2/2]

F04GlobalField * F04GlobalField::GetObject ( )
static

Definition at line 209 of file F04GlobalField.cc.

210 {
211  if (fObject) return fObject;
212  return NULL;
213 }
static G4ThreadLocal F04GlobalField * fObject
Here is the caller graph for this function:

◆ operator=()

F04GlobalField& F04GlobalField::operator= ( const F04GlobalField )
private

◆ SetDeltaChord()

void F04GlobalField::SetDeltaChord ( G4double  dcr)
inline

Set the delta chord length.

Definition at line 122 of file F04GlobalField.hh.

122 { fDeltaChord = dcr; }
G4double fDeltaChord
Here is the caller graph for this function:

◆ SetDeltaIntersection()

void F04GlobalField::SetDeltaIntersection ( G4double  its)
inline

Set the delta intersection length.

Definition at line 128 of file F04GlobalField.hh.

128 { fDeltaIntersection = its; }
G4double fDeltaIntersection

◆ SetDeltaOneStep()

void F04GlobalField::SetDeltaOneStep ( G4double  stp)
inline

Set the delta one step length.

Definition at line 125 of file F04GlobalField.hh.

125 { fDeltaOneStep = stp; }
G4double fDeltaOneStep

◆ SetEpsMax()

void F04GlobalField::SetEpsMax ( G4double  eps)
inline

Set the maximum eps length.

Definition at line 134 of file F04GlobalField.hh.

134 { fEpsMax = eps; }
static const G4double eps
Here is the caller graph for this function:

◆ SetEpsMin()

void F04GlobalField::SetEpsMin ( G4double  eps)
inline

Set the minimum eps length.

Definition at line 131 of file F04GlobalField.hh.

131 { fEpsMin = eps; }
static const G4double eps
Here is the caller graph for this function:

◆ SetMinStep()

void F04GlobalField::SetMinStep ( G4double  stp)
inline

Set the minimum step length.

Definition at line 119 of file F04GlobalField.hh.

119 { fMinStep = stp; }
Here is the caller graph for this function:

◆ SetStepper()

void F04GlobalField::SetStepper ( )

Set the Stepper.

Definition at line 217 of file F04GlobalField.cc.

218 {
219  if(fStepper) delete fStepper;
220 
221  switch ( fStepperType )
222  {
223  case 0:
224 // fStepper = new G4ExplicitEuler( fEquation, 8 ); // no spin tracking
225  fStepper = new G4ExplicitEuler( fEquation, 12 ); // with spin tracking
226  G4cout << "G4ExplicitEuler is called" << G4endl;
227  break;
228  case 1:
229 // fStepper = new G4ImplicitEuler( fEquation, 8 ); // no spin tracking
230  fStepper = new G4ImplicitEuler( fEquation, 12 ); // with spin tracking
231  G4cout << "G4ImplicitEuler is called" << G4endl;
232  break;
233  case 2:
234 // fStepper = new G4SimpleRunge( fEquation, 8 ); // no spin tracking
235  fStepper = new G4SimpleRunge( fEquation, 12 ); // with spin tracking
236  G4cout << "G4SimpleRunge is called" << G4endl;
237  break;
238  case 3:
239 // fStepper = new G4SimpleHeum( fEquation, 8 ); // no spin tracking
240  fStepper = new G4SimpleHeum( fEquation, 12 ); // with spin tracking
241  G4cout << "G4SimpleHeum is called" << G4endl;
242  break;
243  case 4:
244 // fStepper = new G4ClassicalRK4( fEquation, 8 ); // no spin tracking
245  fStepper = new G4ClassicalRK4( fEquation, 12 ); // with spin tracking
246  G4cout << "G4ClassicalRK4 (default) is called" << G4endl;
247  break;
248  case 5:
249 // fStepper = new G4CashKarpRKF45( fEquation, 8 ); // no spin tracking
250  fStepper = new G4CashKarpRKF45( fEquation, 12 ); // with spin tracking
251  G4cout << "G4CashKarpRKF45 is called" << G4endl;
252  break;
253  default: fStepper = 0;
254  }
255 }
G4MagIntegratorStepper * fStepper
G4GLOB_DLL std::ostream G4cout
G4EqEMFieldWithSpin * fEquation
#define G4endl
Definition: G4ios.hh:61
Here is the caller graph for this function:

◆ SetStepperType()

void F04GlobalField::SetStepperType ( G4int  i)
inline

Set the Stepper types.

Definition at line 113 of file F04GlobalField.hh.

113 { fStepperType = i; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetupArray()

void F04GlobalField::SetupArray ( )
private

Definition at line 310 of file F04GlobalField.cc.

311 {
312  fFirst = false;
313  fNfp = fFields->size();
314  fFp = new const F04ElementField* [fNfp+1]; // add 1 so it's never 0
315  for (int i=0; i<fNfp; ++i) fFp[i] = (*fFields)[i];
316 }
const F04ElementField ** fFp
FieldList * fFields

Member Data Documentation

◆ fChordFinder

G4ChordFinder* F04GlobalField::fChordFinder
private

Definition at line 175 of file F04GlobalField.hh.

◆ fDeltaChord

G4double F04GlobalField::fDeltaChord
private

Definition at line 160 of file F04GlobalField.hh.

◆ fDeltaIntersection

G4double F04GlobalField::fDeltaIntersection
private

Definition at line 162 of file F04GlobalField.hh.

◆ fDeltaOneStep

G4double F04GlobalField::fDeltaOneStep
private

Definition at line 161 of file F04GlobalField.hh.

◆ fDetectorConstruction

F04DetectorConstruction* F04GlobalField::fDetectorConstruction
private

Definition at line 179 of file F04GlobalField.hh.

◆ fEpsMax

G4double F04GlobalField::fEpsMax
private

Definition at line 164 of file F04GlobalField.hh.

◆ fEpsMin

G4double F04GlobalField::fEpsMin
private

Definition at line 163 of file F04GlobalField.hh.

◆ fEquation

G4EqEMFieldWithSpin* F04GlobalField::fEquation
private

Definition at line 170 of file F04GlobalField.hh.

◆ fFieldManager

G4FieldManager* F04GlobalField::fFieldManager
private

Definition at line 172 of file F04GlobalField.hh.

◆ fFieldMessenger

F04FieldMessenger* F04GlobalField::fFieldMessenger
private

Definition at line 177 of file F04GlobalField.hh.

◆ fFieldPropagator

G4PropagatorInField* F04GlobalField::fFieldPropagator
private

Definition at line 173 of file F04GlobalField.hh.

◆ fFields

FieldList* F04GlobalField::fFields
private

Definition at line 151 of file F04GlobalField.hh.

◆ fFirst

G4bool F04GlobalField::fFirst
private

Definition at line 149 of file F04GlobalField.hh.

◆ fFp

const F04ElementField** F04GlobalField::fFp
private

Definition at line 153 of file F04GlobalField.hh.

◆ fMinStep

G4double F04GlobalField::fMinStep
private

Definition at line 159 of file F04GlobalField.hh.

◆ fNfp

G4int F04GlobalField::fNfp
private

Definition at line 148 of file F04GlobalField.hh.

◆ fObject

G4ThreadLocal F04GlobalField * F04GlobalField::fObject = 0
staticprivate

Definition at line 146 of file F04GlobalField.hh.

◆ fStepper

G4MagIntegratorStepper* F04GlobalField::fStepper
private

Definition at line 174 of file F04GlobalField.hh.

◆ fStepperType

G4int F04GlobalField::fStepperType
private

Definition at line 157 of file F04GlobalField.hh.


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