Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
F04GlobalField Class Reference

#include <Doxymodules_field.h>

Inheritance diagram for F04GlobalField:
G4ElectroMagneticField G4Field

Public Member Functions

 ~F04GlobalField () override
 
void GetFieldValue (const G4double *point, G4double *field) const override
 GetFieldValue() returns the field value at a given point[].
 
G4bool DoesFieldChangeEnergy () const override
 DoesFieldChangeEnergy() returns true.
 
void AddElementField (F04ElementField *f)
 AddElementField() adds the ElementField object for a single element to the global field.
 
void Clear ()
 Clear() removes all ElementField-s from the global object, and destroys them.
 
void ConstructField ()
 constructs all field tracking objects
 
void SetStepperType (G4int i)
 Set the Stepper types.
 
void SetStepper ()
 Set the Stepper.
 
void SetMinStep (G4double stp)
 Set the minimum step length.
 
void SetDeltaChord (G4double dcr)
 Set the delta chord length.
 
void SetDeltaOneStep (G4double stp)
 Set the delta one step length.
 
void SetDeltaIntersection (G4double its)
 Set the delta intersection length.
 
void SetEpsMin (G4double eps)
 Set the minimum eps length.
 
void SetEpsMax (G4double eps)
 Set the maximum eps length.
 
FieldListGetFields ()
 Return the list of Element Fields.
 

Static Public Member Functions

static F04GlobalFieldGetObject (F04DetectorConstruction *const)
 GetObject() returns the single F04GlobalField object.
 
static F04GlobalFieldGetObject ()
 

Protected Member Functions

G4FieldManagerGetGlobalFieldManager ()
 Get the global field manager.
 

Private Member Functions

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

Private Attributes

G4int fNfp = 0
 
G4bool fFirst = true
 
FieldListfFields = nullptr
 
const F04ElementField ** fFp = nullptr
 
G4int fStepperType = 4
 
G4double fMinStep = 0.01 * CLHEP::mm
 
G4double fDeltaChord = 3.0 * CLHEP::mm
 
G4double fDeltaOneStep = 0.01 * CLHEP::mm
 
G4double fDeltaIntersection = 0.1 * CLHEP::mm
 
G4double fEpsMin = 2.5e-7
 
G4double fEpsMax = 0.001
 
G4EqEMFieldWithSpinfEquation = nullptr
 
G4FieldManagerfFieldManager = nullptr
 
G4PropagatorInFieldfFieldPropagator = nullptr
 
G4MagIntegratorStepperfStepper = nullptr
 
G4ChordFinderfChordFinder = nullptr
 
F04FieldMessengerfFieldMessenger
 
F04DetectorConstructionfDetectorConstruction = nullptr
 

Static Private Attributes

static G4ThreadLocal F04GlobalFieldfObject = nullptr
 

Detailed Description

Definition at line 107 of file Doxymodules_field.h.

Constructor & Destructor Documentation

◆ F04GlobalField() [1/2]

F04GlobalField::F04GlobalField ( F04DetectorConstruction * const  det)
private

Definition at line 54 of file F04GlobalField.cc.

56{
57 fFieldMessenger = new F04FieldMessenger(this,det);
58
59 fFields = new FieldList();
60
61 // set object
62 fObject = this;
63
65}
std::vector< F04ElementField * > FieldList
static G4ThreadLocal F04GlobalField * fObject
void ConstructField()
constructs all field tracking objects
F04DetectorConstruction * fDetectorConstruction
F04FieldMessenger * fFieldMessenger
FieldList * fFields

◆ F04GlobalField() [2/2]

F04GlobalField::F04GlobalField ( const F04GlobalField )
private

◆ ~F04GlobalField()

F04GlobalField::~F04GlobalField ( )
override

Definition at line 69 of file F04GlobalField.cc.

70{
71 Clear();
72
73 delete fFields;
74
75 delete fFieldMessenger;
76
77 delete fEquation;
78 delete fStepper;
79 delete fChordFinder;
80}
G4ChordFinder * fChordFinder
void Clear()
Clear() removes all ElementField-s from the global object, and destroys them.
G4EqEMFieldWithSpin * fEquation
G4MagIntegratorStepper * fStepper

Member Function Documentation

◆ operator=()

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

◆ SetupArray()

void F04GlobalField::SetupArray ( )
private

Definition at line 288 of file F04GlobalField.cc.

289{
290 fFirst = false;
291 fNfp = fFields->size();
292 fFp = new const F04ElementField* [fNfp+1]; // add 1 so it's never 0
293 for (int i=0; i<fNfp; ++i) fFp[i] = (*fFields)[i];
294}
const F04ElementField ** fFp

◆ GetObject() [1/2]

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

GetObject() returns the single F04GlobalField object.

It is constructed, if necessary.

Definition at line 179 of file F04GlobalField.cc.

180{
181 if (!fObject) new F04GlobalField(det);
182 return fObject;
183}

◆ GetObject() [2/2]

F04GlobalField * F04GlobalField::GetObject ( )
static

Definition at line 187 of file F04GlobalField.cc.

188{
189 if (fObject) return fObject;
190 return nullptr;
191}

◆ GetFieldValue()

void F04GlobalField::GetFieldValue ( const G4double *  point,
G4double *  field 
) const
override

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

246{
247 // NOTE: this routine dominates the CPU time for tracking.
248 // Using the simple array fFp[] instead of fields[]
249 // directly sped it up
250
251 field[0] = field[1] = field[2] = field[3] = field[4] = field[5] = 0.0;
252
253 // protect against Geant4 bug that calls us with point[] NaN.
254 if(point[0] != point[0]) return;
255
256 // (can't use fNfp or fFp, as they may change)
257 if (fFirst) ((F04GlobalField*)this)->SetupArray(); // (cast away const)
258
259 for (int i=0; i<fNfp; ++i) {
260 const F04ElementField* p = fFp[i];
261 if (p->IsInBoundingBox(point)) {
262 p->AddFieldValue(point,field);
263 }
264 }
265
266}
bool IsInBoundingBox(const G4double point[4]) const
IsInBoundingBox() returns true if the point is within the global bounding box - global coordinates.
virtual void AddFieldValue(const G4double point[4], G4double field[6]) const =0
AddFieldValue() will add the field value for this element to field[].

◆ DoesFieldChangeEnergy()

G4bool F04GlobalField::DoesFieldChangeEnergy ( ) const
inlineoverride

DoesFieldChangeEnergy() returns true.

Definition at line 94 of file F04GlobalField.hh.

94{ return true; }

◆ AddElementField()

void F04GlobalField::AddElementField ( F04ElementField f)
inline

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

Definition at line 98 of file F04GlobalField.hh.

99 {
100 if (fFields) fFields->push_back(f);
101 }

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

271{
272 if (fFields) {
273 if (fFields->size()>0) {
274 FieldList::iterator i;
275 for (i=fFields->begin(); i!=fFields->end(); ++i) delete *i;
276 fFields->clear();
277 }
278 }
279
280 delete [] fFp;
281 fFirst = true;
282 fNfp = 0;
283 fFp = nullptr;
284}

◆ ConstructField()

void F04GlobalField::ConstructField ( )

constructs all field tracking objects

Definition at line 84 of file F04GlobalField.cc.

85{
86 Clear();
87
88 // Construct equ. of motion of particles through B fields
89// fEquation = new G4Mag_EqRhs(this);
90 // Construct equ. of motion of particles through e.m. fields
91// fEquation = new G4EqMagElectricField(this);
92 // Construct equ. of motion of particles including spin through B fields
93// fEquation = new G4Mag_SpinEqRhs(this);
94 // Construct equ. of motion of particles including spin through e.m. fields
96
97 // Get transportation, field, and propagator managers
98 G4TransportationManager* transportManager =
99 G4TransportationManager::GetTransportationManager();
100
102
103 fFieldPropagator = transportManager->GetPropagatorInField();
104
105 // Need to SetFieldChangesEnergy to account for a time varying electric
106 // field (r.f. fields)
107 fFieldManager->SetFieldChangesEnergy(true);
108
109 // Set the field
110 fFieldManager->SetDetectorField(this);
111
112 // Choose a stepper for integration of the equation of motion
113 SetStepper();
114
115 // Create a cord finder providing the (global field, min step length,
116 // a pointer to the stepper)
118
119 // Set accuracy parameters
120 fChordFinder->SetDeltaChord( fDeltaChord );
121
122 fFieldManager->SetAccuraciesWithDeltaOneStep(fDeltaOneStep);
123
124 fFieldManager->SetDeltaIntersection(fDeltaIntersection);
125
126 fFieldPropagator->SetMinimumEpsilonStep(fEpsMin);
127 fFieldPropagator->SetMaximumEpsilonStep(fEpsMax);
128
129 G4cout << "Accuracy Parameters:" <<
130 " MinStep=" << fMinStep <<
131 " DeltaChord=" << fDeltaChord <<
132 " DeltaOneStep=" << fDeltaOneStep << G4endl;
133 G4cout << " " <<
134 " DeltaIntersection=" << fDeltaIntersection <<
135 " EpsMin=" << fEpsMin <<
136 " EpsMax=" << fEpsMax << G4endl;
137
138 fFieldManager->SetChordFinder(fChordFinder);
139
140 G4double l = 0.0;
143
145 G4ThreeVector captureMgntCenter =
147
148 auto focusSolenoid =
149 new F04FocusSolenoid(B1, B2, l, logicCaptureMgnt,captureMgntCenter);
150 focusSolenoid -> SetHalf(true);
151
153
154 G4LogicalVolume* logicTransferMgnt =
156 G4ThreeVector transferMgntCenter =
158
159 auto simpleSolenoid =
160 new F04SimpleSolenoid(B, l, logicTransferMgnt,transferMgntCenter);
161
162 simpleSolenoid->SetColor("1,0,1");
163 simpleSolenoid->SetColor("0,1,1");
164 simpleSolenoid->SetMaxStep(1.5*mm);
165 simpleSolenoid->SetMaxStep(2.5*mm);
166
167 if (fFields) {
168 if (fFields->size()>0) {
169 FieldList::iterator i;
170 for (i=fFields->begin(); i!=fFields->end(); ++i){
171 (*i)->Construct();
172 }
173 }
174 }
175}
G4FieldManager * fFieldManager
G4PropagatorInField * fFieldPropagator
void SetStepper()
Set the Stepper.
G4double fDeltaIntersection
G4FieldManager * GetGlobalFieldManager()
Get the global field manager.

◆ SetStepperType()

void F04GlobalField::SetStepperType ( G4int  i)
inline

Set the Stepper types.

Definition at line 112 of file F04GlobalField.hh.

112{ fStepperType = i; }

◆ SetStepper()

void F04GlobalField::SetStepper ( )

Set the Stepper.

Definition at line 195 of file F04GlobalField.cc.

196{
197 delete fStepper;
198
199 switch ( fStepperType )
200 {
201 case 0:
202// fStepper = new G4ExplicitEuler( fEquation, 8 ); // no spin tracking
203 fStepper = new G4ExplicitEuler( fEquation, 12 ); // with spin tracking
204 G4cout << "G4ExplicitEuler is called" << G4endl;
205 break;
206 case 1:
207// fStepper = new G4ImplicitEuler( fEquation, 8 ); // no spin tracking
208 fStepper = new G4ImplicitEuler( fEquation, 12 ); // with spin tracking
209 G4cout << "G4ImplicitEuler is called" << G4endl;
210 break;
211 case 2:
212// fStepper = new G4SimpleRunge( fEquation, 8 ); // no spin tracking
213 fStepper = new G4SimpleRunge( fEquation, 12 ); // with spin tracking
214 G4cout << "G4SimpleRunge is called" << G4endl;
215 break;
216 case 3:
217// fStepper = new G4SimpleHeum( fEquation, 8 ); // no spin tracking
218 fStepper = new G4SimpleHeum( fEquation, 12 ); // with spin tracking
219 G4cout << "G4SimpleHeum is called" << G4endl;
220 break;
221 case 4:
222// fStepper = new G4ClassicalRK4( fEquation, 8 ); // no spin tracking
223 fStepper = new G4ClassicalRK4( fEquation, 12 ); // with spin tracking
224 G4cout << "G4ClassicalRK4 (default) is called" << G4endl;
225 break;
226 case 5:
227// fStepper = new G4CashKarpRKF45( fEquation, 8 ); // no spin tracking
228 fStepper = new G4CashKarpRKF45( fEquation, 12 ); // with spin tracking
229 G4cout << "G4CashKarpRKF45 is called" << G4endl;
230 break;
231 default: fStepper = nullptr;
232 }
233}

◆ SetMinStep()

void F04GlobalField::SetMinStep ( G4double  stp)
inline

Set the minimum step length.

Definition at line 118 of file F04GlobalField.hh.

118{ fMinStep = stp; }

◆ SetDeltaChord()

void F04GlobalField::SetDeltaChord ( G4double  dcr)
inline

Set the delta chord length.

Definition at line 121 of file F04GlobalField.hh.

121{ fDeltaChord = dcr; }

◆ SetDeltaOneStep()

void F04GlobalField::SetDeltaOneStep ( G4double  stp)
inline

Set the delta one step length.

Definition at line 124 of file F04GlobalField.hh.

124{ fDeltaOneStep = stp; }

◆ SetDeltaIntersection()

void F04GlobalField::SetDeltaIntersection ( G4double  its)
inline

Set the delta intersection length.

Definition at line 127 of file F04GlobalField.hh.

127{ fDeltaIntersection = its; }

◆ SetEpsMin()

void F04GlobalField::SetEpsMin ( G4double  eps)
inline

Set the minimum eps length.

Definition at line 130 of file F04GlobalField.hh.

130{ fEpsMin = eps; }

◆ SetEpsMax()

void F04GlobalField::SetEpsMax ( G4double  eps)
inline

Set the maximum eps length.

Definition at line 133 of file F04GlobalField.hh.

133{ fEpsMax = eps; }

◆ GetFields()

FieldList * F04GlobalField::GetFields ( )
inline

Return the list of Element Fields.

Definition at line 136 of file F04GlobalField.hh.

136{ return fFields; }

◆ GetGlobalFieldManager()

G4FieldManager * F04GlobalField::GetGlobalFieldManager ( )
protected

Get the global field manager.

Definition at line 237 of file F04GlobalField.cc.

238{
239 return G4TransportationManager::GetTransportationManager()
240 ->GetFieldManager();
241}

Member Data Documentation

◆ fObject

G4ThreadLocal F04GlobalField * F04GlobalField::fObject = nullptr
staticprivate

Definition at line 145 of file F04GlobalField.hh.

◆ fNfp

G4int F04GlobalField::fNfp = 0
private

Definition at line 147 of file F04GlobalField.hh.

◆ fFirst

G4bool F04GlobalField::fFirst = true
private

Definition at line 148 of file F04GlobalField.hh.

◆ fFields

FieldList* F04GlobalField::fFields = nullptr
private

Definition at line 150 of file F04GlobalField.hh.

◆ fFp

const F04ElementField** F04GlobalField::fFp = nullptr
private

Definition at line 152 of file F04GlobalField.hh.

◆ fStepperType

G4int F04GlobalField::fStepperType = 4
private

Definition at line 159 of file F04GlobalField.hh.

◆ fMinStep

G4double F04GlobalField::fMinStep = 0.01 * CLHEP::mm
private

Definition at line 163 of file F04GlobalField.hh.

◆ fDeltaChord

G4double F04GlobalField::fDeltaChord = 3.0 * CLHEP::mm
private

Definition at line 164 of file F04GlobalField.hh.

◆ fDeltaOneStep

G4double F04GlobalField::fDeltaOneStep = 0.01 * CLHEP::mm
private

Definition at line 165 of file F04GlobalField.hh.

◆ fDeltaIntersection

G4double F04GlobalField::fDeltaIntersection = 0.1 * CLHEP::mm
private

Definition at line 166 of file F04GlobalField.hh.

◆ fEpsMin

G4double F04GlobalField::fEpsMin = 2.5e-7
private

Definition at line 168 of file F04GlobalField.hh.

◆ fEpsMax

G4double F04GlobalField::fEpsMax = 0.001
private

Definition at line 169 of file F04GlobalField.hh.

◆ fEquation

G4EqEMFieldWithSpin* F04GlobalField::fEquation = nullptr
private

Definition at line 177 of file F04GlobalField.hh.

◆ fFieldManager

G4FieldManager* F04GlobalField::fFieldManager = nullptr
private

Definition at line 179 of file F04GlobalField.hh.

◆ fFieldPropagator

G4PropagatorInField* F04GlobalField::fFieldPropagator = nullptr
private

Definition at line 180 of file F04GlobalField.hh.

◆ fStepper

G4MagIntegratorStepper* F04GlobalField::fStepper = nullptr
private

Definition at line 181 of file F04GlobalField.hh.

◆ fChordFinder

G4ChordFinder* F04GlobalField::fChordFinder = nullptr
private

Definition at line 182 of file F04GlobalField.hh.

◆ fFieldMessenger

F04FieldMessenger* F04GlobalField::fFieldMessenger
private

Definition at line 185 of file F04GlobalField.hh.

◆ fDetectorConstruction

F04DetectorConstruction* F04GlobalField::fDetectorConstruction = nullptr
private

Definition at line 186 of file F04GlobalField.hh.


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

Applications | User Support | Publications | Collaboration