Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FieldSetup Class Reference

G4FieldSetup is a class for constructing magnetic, electromagnetic and gravity fields which strength is defined via G4Field. The equation of motion of a particle in a field and the integration method are set according to the selection in G4FieldParameters, as well as other accuracy parameters. More...

#include <G4FieldSetup.hh>

Public Member Functions

 G4FieldSetup (const G4FieldParameters &parameters, G4Field *field, G4LogicalVolume *lv=nullptr)
 ~G4FieldSetup ()
 G4FieldSetup ()=delete
 G4FieldSetup (const G4FieldSetup &right)=delete
G4FieldSetupoperator= (const G4FieldSetup &right)=delete
void Clear ()
void Update ()
void PrintInfo (G4int verboseLevel, const G4String &about="created")
void SetG4Field (G4Field *field)
G4FieldGetG4Field () const
G4LogicalVolumeGetLogicalVolume () const
G4EquationOfMotionGetEquation () const
G4MagIntegratorStepperGetStepper () const

Detailed Description

G4FieldSetup is a class for constructing magnetic, electromagnetic and gravity fields which strength is defined via G4Field. The equation of motion of a particle in a field and the integration method are set according to the selection in G4FieldParameters, as well as other accuracy parameters.

Definition at line 66 of file G4FieldSetup.hh.

Constructor & Destructor Documentation

◆ G4FieldSetup() [1/3]

G4FieldSetup::G4FieldSetup ( const G4FieldParameters & parameters,
G4Field * field,
G4LogicalVolume * lv = nullptr )

Standard constructor for G4FieldSetup.

Parameters
[in]parametersThe field parameters.
[in]fieldPointer to the field object.
[in]lvOptional logical volume where field applies; if null, global field applies.

Definition at line 82 of file G4FieldSetup.cc.

84 : fParameters(parameters), fG4Field(field), fLogicalVolume(lv)
85{
86 // Standard constructor
87
88 fMessenger = new G4FieldSetupMessenger(this);
89
90 // Get or create field manager
91 if (fLogicalVolume == nullptr)
92 {
93 // global field
95 }
96 else
97 {
98 // local field
99 fFieldManager = new G4FieldManager();
100 G4bool overwriteDaughtersField = true;
101 // TO DO: this parameter should be made optional for users
102 fLogicalVolume->SetFieldManager(fFieldManager, overwriteDaughtersField);
103 }
104}
bool G4bool
Definition G4Types.hh:86
static G4FieldManager * GetGlobalFieldManager()

Referenced by G4FieldSetup(), and operator=().

◆ ~G4FieldSetup()

G4FieldSetup::~G4FieldSetup ( )

Default Destructor.

Definition at line 107 of file G4FieldSetup.cc.

108{
109 // Destructor
110 delete fG4Field;
111 delete fChordFinder;
112 delete fStepper;
113}

◆ G4FieldSetup() [2/3]

G4FieldSetup::G4FieldSetup ( )
delete

Default constructor, copy constructor and assignment operator not allowed.

◆ G4FieldSetup() [3/3]

G4FieldSetup::G4FieldSetup ( const G4FieldSetup & right)
delete

Member Function Documentation

◆ Clear()

void G4FieldSetup::Clear ( )

Clears previously created setup.

Definition at line 480 of file G4FieldSetup.cc.

481{
482 // First clean up previous state.
483 delete fChordFinder;
484 fChordFinder = nullptr;
485
486 if (fG4Field == nullptr)
487 {
488 delete fEquation;
489 delete fDriver;
490 delete fStepper;
491 delete fChordFinder;
492 fEquation = nullptr;
493 fDriver = nullptr;
494 fStepper = nullptr;
495 fChordFinder = nullptr;
496 fFieldManager->SetChordFinder(fChordFinder);
497 fFieldManager->SetDetectorField(fG4Field);
498 }
499}

Referenced by Update().

◆ GetEquation()

G4EquationOfMotion * G4FieldSetup::GetEquation ( ) const
inline

Definition at line 121 of file G4FieldSetup.hh.

121{ return fEquation; }

◆ GetG4Field()

G4Field * G4FieldSetup::GetG4Field ( ) const
inline

Accessors.

Definition at line 119 of file G4FieldSetup.hh.

119{ return fG4Field; }

◆ GetLogicalVolume()

G4LogicalVolume * G4FieldSetup::GetLogicalVolume ( ) const
inline

Definition at line 120 of file G4FieldSetup.hh.

120{ return fLogicalVolume; }

◆ GetStepper()

G4MagIntegratorStepper * G4FieldSetup::GetStepper ( ) const
inline

Definition at line 122 of file G4FieldSetup.hh.

122{ return fStepper; }

◆ operator=()

G4FieldSetup & G4FieldSetup::operator= ( const G4FieldSetup & right)
delete

◆ PrintInfo()

void G4FieldSetup::PrintInfo ( G4int verboseLevel,
const G4String & about = "created" )

Prints information.

Parameters
[in]verboseLevelVerbosity level; if greater than 1, parameters are also printed out to standard output.
[in]aboutOptional string.

Definition at line 520 of file G4FieldSetup.cc.

521{
522 if (verboseLevel == 0) { return; }
523
524 auto fieldType = G4FieldParameters::FieldTypeName(fParameters.GetFieldType());
525 auto isCachedMagneticField = (fParameters.GetConstDistance() > 0.);
526 if (fLogicalVolume == nullptr)
527 {
528 fieldType = "Global";
529 }
530 else
531 {
532 fieldType = "Local (in ";
533 fieldType.append(fLogicalVolume->GetName());
534 fieldType.append(")");
535 }
536 if (isCachedMagneticField)
537 {
538 fieldType.append(" cached");
539 }
540
541 G4cout << fieldType << " field " << about << " with stepper ";
542 G4cout << G4FieldParameters::StepperTypeName(fParameters.GetStepperType())
543 << G4endl;
544
545 if (verboseLevel > 1)
546 {
547 fParameters.PrintParameters();
548 }
549}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static G4String StepperTypeName(G4StepperType stepper)
static G4String FieldTypeName(G4FieldType field)

◆ SetG4Field()

void G4FieldSetup::SetG4Field ( G4Field * field)
inline

Setter for the field object.

Definition at line 114 of file G4FieldSetup.hh.

114{ fG4Field = field; }

◆ Update()

void G4FieldSetup::Update ( )

Updates the field setup with new field parameters.

Definition at line 502 of file G4FieldSetup.cc.

503{
504 // Update field with new field parameters
505
506 Clear();
507 if (fG4Field == nullptr)
508 {
509 // No further update needed
510 return;
511 }
512
513 CreateCachedField();
514 CreateStepper();
515 CreateChordFinder();
516 UpdateFieldManager();
517}

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